bootargs : read oem unlock status

Read oem unlock status from optee_client api
and attach it to bootargs

Change-Id: Ib8b1a9bc115ec9cb7e5ce09dc50845cfd7c1c81b
Signed-off-by: Qiu Jian <qiujian@rock-chips.com>
This commit is contained in:
qiujian 2018-03-28 18:03:45 +08:00 committed by Kever Yang
parent f61a997e29
commit 9e68721b27
2 changed files with 33 additions and 0 deletions

View File

@ -8,6 +8,9 @@
#include <android_bootloader.h>
#include <attestation_key.h>
#include <boot_rkimg.h>
#include <optee_include/OpteeClientInterface.h>
#define OEM_UNLOCK_ARG_SIZE 30
static int do_boot_rockchip(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[])
@ -33,6 +36,20 @@ static int do_boot_rockchip(cmd_tbl_t *cmdtp, int flag, int argc,
load_attestation_key(dev_desc, &misc_part_info);
#endif
#ifdef CONFIG_OPTEE_CLIENT
/* read oem unlock status and attach to bootargs */
uint8_t unlock = 0;
TEEC_Result result;
char oem_unlock[OEM_UNLOCK_ARG_SIZE] = {0};
result = trusty_read_oem_unlock(&unlock);
if (result) {
printf("read oem unlock status with error : 0x%x\n", result);
} else {
snprintf(oem_unlock, OEM_UNLOCK_ARG_SIZE, "androidboot.oem_unlocked=%d", unlock);
env_update("bootargs", oem_unlock);
}
#endif
mode = rockchip_get_boot_mode();
if (mode == BOOT_MODE_RECOVERY) {
boot_partname = PART_RECOVERY;

View File

@ -16,6 +16,7 @@
#include <fs.h>
#include <boot_rkimg.h>
#include <attestation_key.h>
#include <optee_include/OpteeClientInterface.h>
#define ANDROID_PARTITION_BOOT "boot"
#define ANDROID_PARTITION_MISC "misc"
@ -33,6 +34,7 @@
#else
#define ANDROID_ARG_FDT_FILENAME "kernel.dtb"
#endif
#define OEM_UNLOCK_ARG_SIZE 30
char *android_str_append(char *base_name, char *slot_suffix)
{
@ -562,6 +564,20 @@ int android_bootloader_boot_flow(struct blk_desc *dev_desc,
env_set_ulong("android_root_devnum", dev_desc->devnum);
env_set("android_slotsufix", slot_suffix);
#ifdef CONFIG_OPTEE_CLIENT
/* read oem unlock status and attach to bootargs */
uint8_t unlock = 0;
TEEC_Result result;
char oem_unlock[OEM_UNLOCK_ARG_SIZE] = {0};
result = trusty_read_oem_unlock(&unlock);
if (result) {
printf("read oem unlock status with error : 0x%x\n", result);
} else {
snprintf(oem_unlock, OEM_UNLOCK_ARG_SIZE, "androidboot.oem_unlocked=%d", unlock);
env_update("bootargs", oem_unlock);
}
#endif
/* Assemble the command line */
command_line = android_assemble_cmdline(slot_suffix, mode_cmdline);
env_update("bootargs", command_line);