65 for (i = 0; i < entries_num; i++) {
66 if (rsdt->
entry[i] == 0)
70 if (i >= entries_num) {
72 "too many tables.\n");
96 (
sizeof(
u64) * (i + 1));
111 memset(mmconfig, 0,
sizeof(*mmconfig));
125 lapic->
flags = (1 << 0);
137 lapic->
flags = (1 << 0);
147 int index, apic_ids[CONFIG_MAX_CPUS] = {0}, num_cpus = 0;
162 for (index = 0; index < num_cpus; index++) {
163 if (apic_ids[index] < 0xff)
165 index, apic_ids[index]);
168 index, apic_ids[index]);
193 irqoverride->
source = source;
194 irqoverride->
gsirq = gsirq;
195 irqoverride->
flags = flags;
197 return irqoverride->
length;
205 lapic_nmi->
flags = flags;
207 lapic_nmi->
lint = lint;
217 lapic_nmi->
flags = flags;
219 lapic_nmi->
lint = lint;
230 unsigned long current = (
unsigned long)madt +
sizeof(
acpi_madt_t);
248 if (
CONFIG(ACPI_HAVE_PCAT_8259))
254 header->length = current - (
unsigned long)madt;
262 CONFIG_ECAM_MMCONF_BASE_ADDRESS, 0, 0,
263 CONFIG_ECAM_MMCONF_BUS_NUMBER - 1);
271 unsigned long current = (
unsigned long)mcfg +
sizeof(
acpi_mcfg_t);
288 if (
CONFIG(ECAM_MMCONF_SUPPORT))
292 header->length = current - (
unsigned long)mcfg;
298 const struct cbmem_entry *ce;
299 const u32 tcpa_default_log_len = 0x10000;
315 memset(lasa, 0, tcpa_default_log_len);
317 *size = tcpa_default_log_len;
347 tcpa->
laml = tcpa_log_len;
356 const struct cbmem_entry *ce;
357 const u32 tpm2_default_log_len = 0x10000;
373 memset(lasa, 0, tpm2_default_log_len);
375 *size = tpm2_default_log_len;
412 tpm2->
control_area = CONFIG_CRB_TPM_BASE_ADDRESS + 0x40;
422 tpm2->
laml = tpm2_log_len;
431 const struct cbmem_entry *cbtable;
454 unsigned long current = (
unsigned long)ssdt +
sizeof(
acpi_header_t);
476 dev->
ops->acpi_fill_ssdt(dev);
481 ssdt->
length = current - (
unsigned long)ssdt;
491 lapic->
flags = (1 << 0);
536 unsigned long current = (
unsigned long)srat +
sizeof(
acpi_srat_t);
558 header->length = current - (
unsigned long)srat;
572 mpda->
flags = (1 << 0);
580 unsigned long (*acpi_fill_hmat)(
unsigned long current))
583 unsigned long current = (
unsigned long)hmat +
sizeof(
acpi_hmat_t);
600 current = acpi_fill_hmat(current);
603 header->length = current - (
unsigned long)hmat;
611 unsigned long current = (
unsigned long)dmar +
sizeof(
acpi_dmar_t);
634 header->length = current - (
unsigned long)dmar;
642 memset(drhd, 0,
sizeof(*drhd));
644 drhd->
length =
sizeof(*drhd);
656 memset(rmrr, 0,
sizeof(*rmrr));
658 rmrr->
length =
sizeof(*rmrr);
670 memset(atsr, 0,
sizeof(*atsr));
672 atsr->
length =
sizeof(*atsr);
680 u32 proximity_domain)
683 memset(rhsa, 0,
sizeof(*rhsa));
685 rhsa->
length =
sizeof(*rhsa);
697 memset(andd, 0, andd_len);
710 memset(satc, 0, satc_len);
747 const size_t dev_scope_length =
sizeof(
dev_scope_t) + 2;
750 memset(ds, 0, dev_scope_length);
752 ds->
length = dev_scope_length;
794 unsigned long current = (
unsigned long)slit +
sizeof(
acpi_slit_t);
814 header->length = current - (
unsigned long)slit;
841 addr->bit_width = 64;
842 addr->bit_offset = 0;
848 hpet->
min_tick = CONFIG_HPET_MIN_TICKS;
883 for (i = 0; i < actions; i++) {
911 .mask = 0xFFFFFFFFFFFFFFFF
977 default_actions[i].reg.addr);
979 memset((
void *)einj, 0,
sizeof(*einj));
1001 unsigned long (*acpi_fill_vfct)(
const struct device *
device,
1005 unsigned long current = (
unsigned long)vfct +
sizeof(
acpi_vfct_t);
1021 current = acpi_fill_vfct(
device, vfct, current);
1024 if (!vfct->VBIOSImageOffset)
1028 header->length = current - (
unsigned long)vfct;
1034 const u16 ipmi_revision,
1037 const s8 gpe_interrupt,
1038 const u32 apic_interrupt,
1070 if (gpe_interrupt >= 0 && gpe_interrupt < 32) {
1071 spmi->
gpe = gpe_interrupt;
1074 if (apic_interrupt > 0) {
1085 unsigned long current))
1088 unsigned long current = (
unsigned long)ivrs +
sizeof(
acpi_ivrs_t);
1108 header->length = current - (
unsigned long)ivrs;
1114 unsigned long current))
1117 unsigned long current = (
unsigned long)crat +
sizeof(
struct acpi_crat_header);
1137 header->length = current - (
unsigned long)crat;
1161 int port_type,
int port_subtype,
1199 device->address_count = 1;
1200 device->port_type = port_type;
1201 device->port_subtype = port_subtype;
1209 dbg2_addr_size = (
uint32_t *)current;
1211 *dbg2_addr_size = address_size;
1217 path_len =
strlen(path) + 1;
1218 namespace = (char *)current;
1219 device->namespace_string_length = path_len;
1221 strncpy(
namespace, path, path_len);
1222 current += path_len;
1264 address.access_size = access_size;
1424 memcpy(pos, data, data_len);
1508 fadt->
dsdt = (
unsigned long) dsdt;
1509 fadt->
x_dsdt_l = (
unsigned long)dsdt;
1517 if (
CONFIG(USE_PC_CMOS_ALTCENTURY))
1534 unsigned long current = (
unsigned long)lpit +
sizeof(
acpi_lpit_t);
1549 header->oem_revision = 42;
1555 header->length = current - (
unsigned long)lpit;
1576 const char *
file = CONFIG_CBFS_PREFIX
"/dsdt.aml";
1578 if (!
CONFIG(CBFS_PRELOAD))
1594 unsigned long current;
1611 size_t slic_size, dsdt_size;
1612 char oem_id[6], oem_table_id[8];
1624 for (
void *p = (
void *)current; p < (
void *)fw; p += 16) {
1640 memcpy(&ssdt->signature,
"SSDT", 4);
1643 memcpy(&ssdt->oem_table_id, oem_table_id, 8);
1644 ssdt->oem_revision = 42;
1655 ssdt->length = current - (
unsigned long)ssdt;
1665 dsdt_file =
cbfs_map(CONFIG_CBFS_PREFIX
"/dsdt.aml", &dsdt_size);
1671 if (dsdt_file->
length > dsdt_size
1678 slic_file =
cbfs_map(CONFIG_CBFS_PREFIX
"/slic", &slic_size);
1680 && (slic_file->
length > slic_size
1710 memset((
void *) start, 0, current - start);
1731 if (
CONFIG(ACPI_SOC_NVS))
1733 if (
CONFIG(CHROMEOS_NVS))
1737 if (dev->
ops && dev->
ops->acpi_inject_dsdt)
1738 dev->
ops->acpi_inject_dsdt(dev);
1746 dsdt->
length = current - (
unsigned long)dsdt;
1765 current += slic_file->
length;
1851 if (dev->
ops && dev->
ops->write_acpi_tables) {
1852 current = dev->
ops->write_acpi_tables(dev, current,
1897 for (p = (
char *)0xe0000; p < (
char *)0xfffff; p += 16) {
1905 "No RSDP found, wake up from S3 not possible.\n");
1915 for (i = 0; ((
char *)&rsdt->
entry[i]) < end; i++) {
1917 if (
strncmp((
char *)fadt,
"FACP", 4) == 0)
1924 "No FADT found, wake up from S3 not possible.\n");
1933 "No FACS found, wake up from S3 not possible.\n");
unsigned long acpi_create_lpi_desc_ncst(acpi_lpi_desc_ncst_t *lpi_desc, uint16_t uid)
void acpi_create_madt(acpi_madt_t *madt)
void acpi_create_srat(acpi_srat_t *srat, unsigned long(*acpi_fill_srat)(unsigned long current))
unsigned long write_acpi_tables(unsigned long start)
static void * get_tcpa_log(u32 *size)
unsigned long acpi_create_dmar_ds_ioapic(unsigned long current, u8 enumeration_id, u8 bus, u8 dev, u8 fn)
__weak void mainboard_fill_fadt(acpi_fadt_t *fadt)
unsigned long acpi_create_madt_lapics(unsigned long current)
int acpi_create_madt_lx2apic_nmi(acpi_madt_lx2apic_nmi_t *lapic_nmi, u32 cpu, u16 flags, u8 lint)
void acpi_create_lpit(acpi_lpit_t *lpit)
void acpi_dmar_satc_fixup(unsigned long base, unsigned long current)
unsigned long acpi_create_dmar_rmrr(unsigned long current, u16 segment, u64 bar, u64 limit)
void acpi_create_ivrs(acpi_ivrs_t *ivrs, unsigned long(*acpi_fill_ivrs)(acpi_ivrs_t *ivrs_struct, unsigned long current))
static void acpi_write_rsdt(acpi_rsdt_t *rsdt, char *oem_id, char *oem_table_id)
void acpi_create_mcfg(acpi_mcfg_t *mcfg)
unsigned long acpi_write_hpet(const struct device *device, unsigned long current, acpi_rsdp_t *rsdp)
uintptr_t get_coreboot_rsdp(void)
void acpi_create_fadt(acpi_fadt_t *fadt, acpi_facs_t *facs, void *dsdt)
void acpi_create_facs(acpi_facs_t *facs)
unsigned long acpi_write_dbg2_pci_uart(acpi_rsdp_t *rsdp, unsigned long current, const struct device *dev, uint8_t access_size)
__weak void soc_fill_fadt(acpi_fadt_t *fadt)
void preload_acpi_dsdt(void)
void acpi_dmar_drhd_fixup(unsigned long base, unsigned long current)
void acpi_create_ipmi(const struct device *device, struct acpi_spmi *spmi, const u16 ipmi_revision, const acpi_addr_t *addr, const enum acpi_ipmi_interface_type type, const s8 gpe_interrupt, const u32 apic_interrupt, const u32 uid)
void acpi_add_table(acpi_rsdp_t *rsdp, void *table)
Add an ACPI table to the RSDT (and XSDT) structure, recalculate length and checksum.
static void acpi_ssdt_write_cbtable(void)
void acpi_create_vfct(const struct device *device, acpi_vfct_t *vfct, unsigned long(*acpi_fill_vfct)(const struct device *device, acpi_vfct_t *vfct_struct, unsigned long current))
void acpi_create_slit(acpi_slit_t *slit, unsigned long(*acpi_fill_slit)(unsigned long current))
unsigned long acpi_create_dmar_ds_msi_hpet(unsigned long current, u8 enumeration_id, u8 bus, u8 dev, u8 fn)
unsigned long acpi_create_dmar_ds_pci(unsigned long current, u8 bus, u8 dev, u8 fn)
unsigned long acpi_create_dmar_ds_pci_br(unsigned long current, u8 bus, u8 dev, u8 fn)
u8 acpi_checksum(u8 *table, u32 length)
void acpi_create_dmar(acpi_dmar_t *dmar, enum dmar_flags flags, unsigned long(*acpi_fill_dmar)(unsigned long))
static unsigned long acpi_create_dmar_ds(unsigned long current, enum dev_scope_type type, u8 enumeration_id, u8 bus, u8 dev, u8 fn)
unsigned long __weak fw_cfg_acpi_tables(unsigned long start)
int acpi_create_madt_lx2apic(acpi_madt_lx2apic_t *lapic, u32 cpu, u32 apic)
void acpi_create_crat(struct acpi_crat_header *crat, unsigned long(*acpi_fill_crat)(struct acpi_crat_header *crat_struct, unsigned long current))
static unsigned long acpi_fill_mcfg(unsigned long current)
void acpi_write_bert(acpi_bert_t *bert, uintptr_t region, size_t length)
void * acpi_find_wakeup_vector(void)
void acpi_create_dbg2(acpi_dbg2_header_t *dbg2, int port_type, int port_subtype, acpi_addr_t *address, uint32_t address_size, const char *device_path)
int acpi_create_srat_mem(acpi_srat_mem_t *mem, u8 node, u32 basek, u32 sizek, u32 flags)
static void acpi_write_rsdp(acpi_rsdp_t *rsdp, acpi_rsdt_t *rsdt, acpi_xsdt_t *xsdt, char *oem_id)
int acpi_create_madt_lapic(acpi_madt_lapic_t *lapic, u8 cpu, u8 apic)
void acpi_create_einj(acpi_einj_t *einj, uintptr_t addr, u8 actions)
int acpi_create_srat_lapic(acpi_srat_lapic_t *lapic, u8 node, u8 apic)
unsigned long acpi_create_dmar_atsr(unsigned long current, u8 flags, u16 segment)
static void acpi_create_tcpa(acpi_tcpa_t *tcpa)
void acpi_create_ssdt_generator(acpi_header_t *ssdt, const char *oem_table_id)
unsigned long acpi_create_hest_error_source(acpi_hest_t *hest, acpi_hest_esd_t *esd, u16 type, void *data, u16 data_len)
void acpi_create_hpet(acpi_hpet_t *hpet)
int get_acpi_table_revision(enum acpi_tables table)
static acpi_rsdp_t * valid_rsdp(acpi_rsdp_t *rsdp)
int acpi_create_madt_irqoverride(acpi_madt_irqoverride_t *irqoverride, u8 bus, u8 source, u32 gsirq, u16 flags)
int acpi_create_srat_gia_pci(acpi_srat_gia_t *gia, u32 proximity_domain, u16 seg, u8 bus, u8 dev, u8 func, u32 flags)
int acpi_create_madt_ioapic(acpi_madt_ioapic_t *ioapic, u8 id, u32 addr, u32 gsi_base)
u8 get_acpi_fadt_minor_version(void)
void acpi_create_hmat(acpi_hmat_t *hmat, unsigned long(*acpi_fill_hmat)(unsigned long current))
__weak void arch_fill_fadt(acpi_fadt_t *fadt)
void acpi_dmar_rmrr_fixup(unsigned long base, unsigned long current)
void acpi_dmar_atsr_fixup(unsigned long base, unsigned long current)
__weak int acpi_get_gpe(int gpe)
unsigned long acpi_create_dmar_rhsa(unsigned long current, u64 base_addr, u32 proximity_domain)
static uintptr_t coreboot_rsdp
int acpi_create_madt_lapic_nmi(acpi_madt_lapic_nmi_t *lapic_nmi, u8 cpu, u16 flags, u8 lint)
unsigned long acpi_create_dmar_drhd(unsigned long current, u8 flags, u16 segment, u64 bar)
int acpi_create_hmat_mpda(acpi_hmat_mpda_t *mpda, u32 initiator, u32 memory)
static void acpi_create_tpm2(acpi_tpm2_t *tpm2)
void acpi_write_hest(acpi_hest_t *hest, unsigned long(*acpi_fill_hest)(acpi_hest_t *hest))
static void acpi_write_xsdt(acpi_xsdt_t *xsdt, char *oem_id, char *oem_table_id)
int acpi_create_mcfg_mmconfig(acpi_mcfg_mmconfig_t *mmconfig, u32 base, u16 seg_nr, u8 start, u8 end)
static void * get_tpm2_log(u32 *size)
unsigned long acpi_create_dmar_satc(unsigned long current, u8 flags, u16 segment)
unsigned long acpi_create_dmar_andd(unsigned long current, u8 device_number, const char *device_name)
const char * acpi_device_path(const struct device *dev)
void acpi_fill_gnvs(void)
#define IVRS_FORMAT_MIXED
uint8_t acpi_get_preferred_pm_profile(void)
void acpigen_pop_len(void)
void acpigen_write_coreboot_hid(enum coreboot_acpi_ids id)
void acpigen_write_resourcetemplate_footer(void)
void acpigen_write_name_integer(const char *name, uint64_t val)
void acpigen_write_STA(uint8_t status)
void acpigen_write_resourcetemplate_header(void)
void acpigen_set_current(char *curr)
void acpigen_write_mem32fixed(int readwrite, u32 base, u32 size)
char * acpigen_get_current(void)
void acpigen_write_device(const char *name)
void acpigen_write_name(const char *name)
struct arm64_kernel_header header
static int acpi_is_wakeup_s3(void)
#define HPET_BASE_ADDRESS
void * memcpy(void *dest, const void *src, size_t n)
void * memset(void *dstpp, int c, size_t len)
@ CB_SUCCESS
Call completed successfully.
static void * cbfs_map(const char *name, size_t *size_out)
void cbfs_preload(const char *name)
void * cbmem_entry_start(const struct cbmem_entry *entry)
const struct cbmem_entry * cbmem_entry_find(u32 id)
void * cbmem_add(u32 id, u64 size)
u64 cbmem_entry_size(const struct cbmem_entry *entry)
#define CBMEM_ID_TPM2_TCG_LOG
#define CBMEM_ID_TCPA_TCG_LOG
enum fch_io_device device
#define printk(level,...)
int cpu_phys_address_size(void)
DEVTREE_CONST struct device *DEVTREE_CONST all_devices
Linked list of ALL devices.
struct resource * probe_resource(const struct device *dev, unsigned int index)
See if a resource structure already exists for a given index.
const char * dev_path(const struct device *dev)
struct acpi_madt_lx2apic acpi_madt_lx2apic_t
struct acpi_injection_header acpi_injection_header_t
struct acpi_einj acpi_einj_t
struct acpi_mcfg acpi_mcfg_t
struct acpi_madt_lx2apic_nmi acpi_madt_lx2apic_nmi_t
static uintptr_t acpi_align_current(uintptr_t current)
struct acpi_xsdt acpi_xsdt_t
@ ACPI_LPI_DESC_TYPE_NATIVE_CSTATE
struct acpi_dmar acpi_dmar_t
struct acpi_madt_lapic_nmi acpi_madt_lapic_nmi_t
#define ACPI_FADT_MINOR_VERSION_0
struct acpi_dbg2_device acpi_dbg2_device_t
struct acpi_hest_hen acpi_hest_hen_t
#define READ_REGISTER_VALUE
struct acpi_hmat acpi_hmat_t
#define ACPI_IPMI_INT_TYPE_SCI
struct acpi_lpi_desc_ncst acpi_lpi_desc_ncst_t
#define ACPI_EINJ_DEFAULT_CAP
struct acpi_gen_regaddr acpi_addr_t
#define WRITE_REGISTER_VALUE
struct acpi_hest_esd acpi_hest_esd_t
struct acpi_mcfg_mmconfig acpi_mcfg_mmconfig_t
#define ACPI_ADDRESS_SPACE_MEMORY
struct dmar_satc_entry dmar_satc_entry_t
#define ACPI_TABLE_CREATOR
#define EINJ_REG_MEMORY(address)
#define ACPI_ACCESS_SIZE_QWORD_ACCESS
struct acpi_facs acpi_facs_t
struct acpi_srat_gia acpi_srat_gia_t
struct acpi_hest acpi_hest_t
#define ACPI_DBG2_PORT_SERIAL_16550
#define EXECUTE_INJECT_OP
struct acpi_srat_mem acpi_srat_mem_t
#define ACPI_IPMI_PCI_DEVICE_FLAG
#define ACPI_DBG2_PORT_SERIAL
struct acpi_srat_lapic acpi_srat_lapic_t
struct acpi_madt_irqoverride acpi_madt_irqoverride_t
struct acpi_madt_lapic acpi_madt_lapic_t
#define ACPI_SRAT_GIA_DEV_HANDLE_PCI
struct acpi_tpm2 acpi_tpm2_t
struct acpi_table_header acpi_header_t
void acpi_fill_cnvs(void)
struct acpi_rsdt acpi_rsdt_t
struct acpi_madt_ioapic acpi_madt_ioapic_t
struct acpi_tcpa acpi_tcpa_t
struct acpi_srat acpi_srat_t
struct acpi_einj_trigger_table acpi_einj_trigger_table_t
struct acpi_hmat_mpda acpi_hmat_mpda_t
#define CHECK_BUSY_STATUS
struct acpi_fadt acpi_fadt_t
struct acpi_bert acpi_bert_t
@ COREBOOT_ACPI_ID_CBTABLE
#define SET_ERROR_TYPE_WITH_ADDRESS
struct acpi_rsdp acpi_rsdp_t
#define GET_TRIGGER_ACTION_TABLE
struct dmar_andd_entry dmar_andd_entry_t
enum cb_err acpi_soc_get_bert_region(void **region, size_t *length)
struct acpi_dbg2_header acpi_dbg2_header_t
#define ACPI_IPMI_INT_TYPE_APIC
unsigned long acpi_fill_lpit(unsigned long current)
#define ACPI_SRAT_STRUCTURE_GIA
struct acpi_slit acpi_slit_t
struct acpi_madt acpi_madt_t
#define ACPI_FADT_REV_ACPI_6
#define ACPI_ADDRESS_SPACE_IO
struct dev_scope dev_scope_t
struct acpi_ivrs acpi_ivrs_t
struct acpi_hpet acpi_hpet_t
struct acpi_lpit acpi_lpit_t
#define ACPI_STATUS_DEVICE_HIDDEN_ON
static __always_inline uint32_t read32p(const uintptr_t addr)
uintptr_t cpu_get_lapic_addr(void)
#define BIOS_INFO
BIOS_INFO - Expected events.
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
#define BIOS_ALERT
BIOS_ALERT - Dying / Unrecoverable.
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
#define RTC_CLK_ALTCENTURY
static unsigned long acpi_fill_srat(unsigned long current)
static unsigned long acpi_fill_slit(unsigned long current)
static unsigned long acpi_fill_hest(acpi_hest_t *hest)
static unsigned long acpi_fill_ivrs(acpi_ivrs_t *ivrs, unsigned long current)
static unsigned long acpi_fill_dmar(unsigned long current)
@ DEVICE_PATH_CPU_CLUSTER
static const PCI_SUBCLASS memory[]
#define PCI_BASE_ADDRESS_0
static unsigned long acpi_fill_crat(struct acpi_crat_header *crat, unsigned long current)
const struct smm_save_state_ops *legacy_ops __weak
void acpi_fill_fadt(acpi_fadt_t *fadt)
unsigned long acpi_fill_madt(unsigned long current)
void bubblesort(int *v, size_t num_entries, sort_order_t order)
char * strncpy(char *to, const char *from, int count)
int strncmp(const char *s1, const char *s2, int maxlen)
int memcmp(const void *s1, const void *s2, size_t n)
size_t strlen(const char *src)
set_error_type_t setaddrtable
u64 err_inject[EINJ_PARAM_NUM]
acpi_einj_action_table_t trigger_action[1]
acpi_einj_action_table_t action_table[ACTION_COUNT]
acpi_injection_header_t inj_header
u32 x_firmware_waking_vector_l
u32 x_firmware_waking_vector_h
u32 firmware_waking_vector
u32 max_section_per_record
u32 sw2poll_threshold_win
u32 sw2poll_threshold_val
u32 proximity_domain_initiator
u32 proximity_domain_memory
acpi_lpi_desc_hdr_t header
u16 pci_segment_group_number
u32 entry[MAX_ACPI_TABLES]
u16 specification_revision
u32 global_system_interrupt
u64 entry[MAX_ACPI_TABLES]
DEVTREE_CONST struct device * dev
struct dev_scope::@187 path[0]
enum device_path_type type
struct device_operations * ops
DEVTREE_CONST struct bus * bus
DEVTREE_CONST struct device * next
const unsigned int asl_revision