1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <acpi/acpigen.h>
11 #include <console/console.h>
12 #include <ec/google/chromeec/ec.h>
14 #include <security/vboot/vbnv.h>
15 #include <security/vboot/vboot_common.h>
21 static struct chromeos_acpi
*chromeos_acpi
;
23 static size_t chromeos_vpd_region(const char *region
, uintptr_t *base
)
25 struct region_device vpd
;
27 if (fmap_locate_area_as_rdev(region
, &vpd
))
30 *base
= (uintptr_t)rdev_mmap_full(&vpd
);
32 return region_device_sz(&vpd
);
35 static void chromeos_init_chromeos_acpi(void *unused
)
38 uintptr_t vpd_base
= 0;
40 chromeos_acpi
= cbmem_add(CBMEM_ID_ACPI_CNVS
, sizeof(struct chromeos_acpi
));
44 /* Retain CNVS contents on S3 resume path. */
45 if (acpi_is_wakeup_s3())
48 vpd_size
= chromeos_vpd_region("RO_VPD", &vpd_base
);
49 if (vpd_size
&& vpd_base
) {
50 chromeos_acpi
->vpd_ro_base
= vpd_base
;
51 chromeos_acpi
->vpd_ro_size
= vpd_size
;
54 vpd_size
= chromeos_vpd_region("RW_VPD", &vpd_base
);
55 if (vpd_size
&& vpd_base
) {
56 chromeos_acpi
->vpd_rw_base
= vpd_base
;
57 chromeos_acpi
->vpd_rw_size
= vpd_size
;
61 BOOT_STATE_INIT_ENTRY(BS_PRE_DEVICE
, BS_ON_EXIT
, chromeos_init_chromeos_acpi
, NULL
);
63 void chromeos_set_me_hash(u32
*hash
, int len
)
65 if ((len
*sizeof(u32
)) > sizeof(chromeos_acpi
->mehh
))
70 memcpy(chromeos_acpi
->mehh
, hash
, len
*sizeof(u32
));
73 void chromeos_set_ramoops(void *ram_oops
, size_t size
)
78 printk(BIOS_DEBUG
, "Ramoops buffer: 0x%zx@%p.\n", size
, ram_oops
);
79 chromeos_acpi
->ramoops_base
= (uintptr_t)ram_oops
;
80 chromeos_acpi
->ramoops_len
= size
;
83 void smbios_type0_bios_version(uintptr_t address
)
87 /* Location of smbios_type0.bios_version() string filled with spaces. */
88 chromeos_acpi
->vbt10
= address
;
91 void acpi_fill_cnvs(void)
93 const struct opregion cnvs_op
= OPREGION("CNVS", SYSTEMMEMORY
, (uintptr_t)chromeos_acpi
,
94 sizeof(*chromeos_acpi
));
99 acpigen_write_scope("\\");
100 acpigen_write_opregion(&cnvs_op
);
103 chromeos_acpi_gpio_generate();