Skip to content

Commit d19c87e

Browse files
committed
Add board id to cmdline
ufdt is bad at overlaying it, or mb kernel breakes it somehow? Anyway put it to cmdline for app to figure out stuff
1 parent dcc9a8f commit d19c87e

1 file changed

Lines changed: 39 additions & 1 deletion

File tree

uefi/common_linuxloader/common_linuxloader.c

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,42 @@
3333
#define MAGIC_QCOM_DTBO_IMG 0x1EABB7D7
3434
#define MAGIC_DTBO 0xEDFE0DD0
3535

36+
typedef struct qcom_msm_id{
37+
uint32_t platform_id;
38+
uint32_t soc_rev;
39+
}qcom_msm_id;
40+
41+
typedef struct qcom_board_id{
42+
uint32_t variant_id;
43+
uint32_t platform_subtype;
44+
}qcom_board_id;
45+
46+
typedef struct qcom_pmic_id{
47+
uint32_t pmic_version[4];
48+
}qcom_pmic_id;
49+
50+
static int get_board_varient_id(){
51+
int node=0,r=-1;
52+
EFI_STATUS st;
53+
uint64_t base=0,size=0;
54+
KERNEL_FDT_PROTOCOL*fdt;
55+
st=gBS->LocateProtocol(
56+
&gKernelFdtProtocolGuid,
57+
NULL,
58+
(VOID**)&fdt
59+
);
60+
if(EFI_ERROR(st)||!fdt||!fdt->Fdt)return r;
61+
droidboot_log(DROIDBOOT_LOG_INFO,"update board-id from kernel fdt");
62+
63+
int off,msm_len=0,board_len=0;
64+
if(!fdt->Fdt||fdt_check_header(fdt->Fdt)!=0)return -1;
65+
if((off=fdt_path_offset(fdt->Fdt,"/"))<0)return -1;
66+
qcom_msm_id*msm_id=(qcom_msm_id*)fdt_getprop(fdt->Fdt,off,"qcom,msm-id",&msm_len);
67+
qcom_board_id*board_id=(qcom_board_id*)fdt_getprop(fdt->Fdt,off,"qcom,board-id",&board_len);
68+
droidboot_log(DROIDBOOT_LOG_INFO,"Update ids, board-id varient_id: %lx, platform_subtypr: %lx\n", board_id->variant_id, board_id->platform_subtype);
69+
70+
return board_id->variant_id;
71+
}
3672
// Function to update memory node in target dtb from dtb provided by 1st stage bootloader
3773
static int update_from_kernel_fdt(void *dtb_raw){
3874
int node=0,r=-1;
@@ -164,10 +200,12 @@ void droidboot_internal_boot_linux_from_ram(void *kernel_raw, off_t kernel_raw_s
164200
}
165201

166202
// Update fdt
203+
char abm_board_id[31];
204+
sprintf(abm_board_id, " abm-board-id=%lx ", get_board_varient_id());
167205
fdt_add_ramdisk_addr(ramdisk_reallocated, ramdisk_size, dtb_address);
168206
update_from_kernel_fdt(dtb_address);
169207
strcpy(cmdline, options);
170-
strcat(cmdline, " ");
208+
strcat(cmdline, abm_board_id);
171209
const char *kfdt_cmdline=droidboot_uefi_get_cmdline_from_kfdt();
172210
if(kfdt_cmdline>=0){
173211
strcat(cmdline, kfdt_cmdline);

0 commit comments

Comments
 (0)