| 1 |
|
| 2 |
|
| 3 |
#include <assert.h> |
| 4 |
#include <console/console.h> |
| 5 |
#include <drivers/vpd/vpd.h> |
| 6 |
#include <security/tpm/tss.h> |
| 7 |
#include <types.h> |
| 8 |
#include <vendorcode/google/chromeos/chromeos.h> |
| 9 |
|
| 10 |
#define CHROMEBOOK_PLUS_HARD_BRANDED BIT(4) |
| 11 |
|
| 12 |
uint64_t chromeos_get_factory_config(void) |
| 13 |
{ |
| 14 |
static uint64_t factory_config = UNDEFINED_FACTORY_CONFIG; |
| 15 |
|
| 16 |
if (factory_config != UNDEFINED_FACTORY_CONFIG) |
| 17 |
return factory_config; |
| 18 |
|
| 19 |
|
| 20 |
tpm_result_t rc = tlcl_lib_init(); |
| 21 |
if (rc != TPM_SUCCESS) { |
| 22 |
printk(BIOS_ERR, "%s:%d - tlcl_lib_init() failed: %#x\n", |
| 23 |
__func__, __LINE__, rc); |
| 24 |
return UNDEFINED_FACTORY_CONFIG; |
| 25 |
} |
| 26 |
|
| 27 |
rc = tlcl_cr50_get_factory_config(&factory_config); |
| 28 |
|
| 29 |
if (rc != TPM_SUCCESS) { |
| 30 |
printk(BIOS_ERR, "%s:%d - tlcl_cr50_get_factory_config() failed: %#x\n", |
| 31 |
__func__, __LINE__, rc); |
| 32 |
return UNDEFINED_FACTORY_CONFIG; |
| 33 |
} |
| 34 |
|
| 35 |
assert(factory_config != UNDEFINED_FACTORY_CONFIG); |
| 36 |
|
| 37 |
return factory_config; |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
bool chromeos_device_branded_plus_hard(void) |
| 48 |
{ |
| 49 |
uint64_t factory_config = chromeos_get_factory_config(); |
| 50 |
|
| 51 |
if (factory_config == UNDEFINED_FACTORY_CONFIG) |
| 52 |
return false; |
| 53 |
|
| 54 |
return (factory_config & CHROMEBOOK_PLUS_HARD_BRANDED) == CHROMEBOOK_PLUS_HARD_BRANDED; |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
bool chromeos_device_branded_plus_soft(void) |
| 65 |
{ |
| 66 |
if (vpd_get_feature_level() > 1) |
| 67 |
return true; |
| 68 |
|
| 69 |
return false; |
| 70 |
} |