SMEM :shared memory,是高通平台各子系统共享信息的一种机制,通过SMEM机制,PBL可以将信息传递给SBL1,SBL1可以将信息传递给RPM、LK。下面分析一个SMEM信息传递的具体实现过程。
1 Platform id信息
SBL1会将board level platform id信息通过SMEM机制保存,LK在启动过程中会自动platform detect,检测当前平台board infor信息,根据检测到的board infor加载相应的device tree
SBL1:从emmc中读取platform id等CDT信息,并保存到约定的smem中
voidboot_config_data_table_init(bl_shared_data_type* bl_shared_data)
{
/*populate configuration data table's info*/
config_data_table_info.size =config_data_table_size;
config_data_table_info.cdt_ptr =config_data_table; //platform id & ddr default parameter
boot_update_config_data_table(&config_data_table_info);
/*put a pointer to the table info into sblshared data so next sbl can access it*/
bl_shared_data->sbl_shared_data->config_data_table_info =&config_data_table_info;
}
LK通过读取smem获取platform infor信息
static void platform_detect()
{
ret= smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
&board_info_v8,
board_info_len);
board.platform= board_info_v8.board_info_v3.msm_id;
board.platform_version= board_info_v8.board_info_v3.msm_version;
board.platform_hw= board_info_v8.board_info_v3.hw_platform;
board.platform_subtype= board_info_v8.platform_subtype;
}
同理,SBL1可通过SMEM将DDR default parameter传递给RPM,当然也可以将OEM定制信息通过SMEM保存,在启动阶段根据不同OEM信息进行相应的特制化。
2 如何在SBL1和LK间通过SMEM传递客制化信息
step1. Add a new enum (i.e SMEM_OEM_MAGIC_INFO = XXX)in smem_mem_type
step 2. After the boot_smem_init() is called, you use smem_alloc() to allocate the SMEM space for your data,i.e:
- smem_oem_magic_ptr = (uint32 *) smem_alloc( SMEM_OEM_MAGIC_INFO, sizeof(uint32));
step3. On lk side add a new enum (i.e SMEM_OEM_MAGIC_INFO =XXX) in smem_mem_type_t
step4. In lk code, you can usethe smem_read_alloc_entry() to read data which is passed from SBL1,i.e:
- smem_read_alloc_entry( SMEM_OEM_MAGIC_INFO,&apps_oem_magic_info, sizeof( uint32));