summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSubrata Banik <subratabanik@google.com>2023-12-28 23:37:27 +0530
committerSubrata Banik <subratabanik@google.com>2023-12-31 03:19:54 +0000
commitd968b8515c584896543e6c74c173e342369a89b9 (patch)
tree8baf77f732baaae52cf634502ff1c9e5c38550ef
parent73505f1f9efff6e1622be8190dcd310fb723aa03 (diff)
downloadcoreboot-d968b8515c584896543e6c74c173e342369a89b9.tar.gz
coreboot-d968b8515c584896543e6c74c173e342369a89b9.tar.bz2
coreboot-d968b8515c584896543e6c74c173e342369a89b9.zip
vendorcode/google/chromeos: Add API for Chromebook Plus check
This patch implements an API which relies on the chromeos_get_factory_config() function to retrieve the factory config value. This information is useful to determine whether a ChromeOS device is branded as a Chromebook Plus based on specific bit flags: - Bit 4 (0x10): Indicates whether the device chassis has the "chromebook-plus" branding. - Bits 3-0 (0x1): Must be 0x1 to signify compliance with Chromebook Plus hardware specifications. BUG=b:317880956 TEST=Able to verify that google/screebo is branded as Chromebook Plus. Change-Id: Iebaed1c60e34af4cc36316f1f87a89df778b0857 Signed-off-by: Subrata Banik <subratabanik@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/79763 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Kapil Porwal <kapilporwal@google.com>
-rw-r--r--src/vendorcode/google/chromeos/chromeos.h12
-rw-r--r--src/vendorcode/google/chromeos/tpm_factory_config.c26
2 files changed, 38 insertions, 0 deletions
diff --git a/src/vendorcode/google/chromeos/chromeos.h b/src/vendorcode/google/chromeos/chromeos.h
index c14af319f5a6..0c5e4f7daf89 100644
--- a/src/vendorcode/google/chromeos/chromeos.h
+++ b/src/vendorcode/google/chromeos/chromeos.h
@@ -32,6 +32,18 @@ void chromeos_set_ramoops(void *ram_oops, size_t size);
* Return `-1` in case of error.
*/
int64_t chromeos_get_factory_config(void);
+/*
+ * Determines whether a ChromeOS device is branded as a Chromebook Plus
+ * based on specific bit flags:
+ *
+ * - Bit 4 (0x10): Indicates whether the device chassis has the
+ * "chromebook-plus" branding.
+ * - Bits 3-0 (0x1): Must be 0x1 to signify compliance with Chromebook Plus
+ * hardware specifications.
+ *
+ * To be considered a Chromebook Plus, either of these conditions needs to be met.
+ */
+bool chromeos_device_branded_plus(void);
/*
* Declaration for mainboards to use to generate ACPI-specific ChromeOS needs.
diff --git a/src/vendorcode/google/chromeos/tpm_factory_config.c b/src/vendorcode/google/chromeos/tpm_factory_config.c
index 3b68020bd1b7..4f8801ab0dde 100644
--- a/src/vendorcode/google/chromeos/tpm_factory_config.c
+++ b/src/vendorcode/google/chromeos/tpm_factory_config.c
@@ -2,8 +2,13 @@
#include <console/console.h>
#include <security/tpm/tss.h>
+#include <types.h>
#include <vendorcode/google/chromeos/chromeos.h>
+#define CHROMEBOOK_PLUS_HARD_BRANDED BIT(4)
+#define CHROMEBOOK_PLUS_SOFT_BRANDED BIT(0)
+#define CHROMEBOOK_PLUS_DEVICE (CHROMEBOOK_PLUS_HARD_BRANDED | CHROMEBOOK_PLUS_SOFT_BRANDED)
+
int64_t chromeos_get_factory_config(void)
{
static int64_t factory_config = -1;
@@ -29,3 +34,24 @@ int64_t chromeos_get_factory_config(void)
return factory_config;
}
+
+/*
+ * Determines whether a ChromeOS device is branded as a Chromebook Plus
+ * based on specific bit flags:
+ *
+ * - Bit 4 (0x10): Indicates whether the device chassis has the
+ * "chromebook-plus" branding.
+ * - Bits 3-0 (0x1): Must be 0x1 to signify compliance with Chromebook Plus
+ * hardware specifications.
+ *
+ * To be considered a Chromebook Plus, either of these conditions needs to be met.
+ */
+bool chromeos_device_branded_plus(void)
+{
+ int64_t factory_config = chromeos_get_factory_config();
+
+ if (factory_config < 0)
+ return false;
+
+ return factory_config & CHROMEBOOK_PLUS_DEVICE;
+}