35#if defined(LOSCFG_STORAGE_SPINOR) || defined(LOSCFG_STORAGE_SPINAND) || defined(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7)
39#ifdef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7
43#ifdef LOSCFG_STORAGE_EMMC
57 PRINT_ERR(
"Malloc g_cmdLine space error!\n");
61#ifdef LOSCFG_STORAGE_EMMC
63 if (emmcDisk == NULL) {
64 PRINT_ERR(
"Get EMMC disk failed!\n");
69 COMMAND_LINE_SIZE / EMMC_SEC_SIZE, TRUE);
75#ifdef LOSCFG_STORAGE_SPINOR
78 PRINT_ERR(
"Get spinor mtd failed!\n");
82 ret = mtd->
read(mtd, COMMAND_LINE_ADDR, COMMAND_LINE_SIZE,
g_cmdLine);
83 if (ret == COMMAND_LINE_SIZE) {
88#ifdef LOSCFG_STORAGE_SPINAND
91 PRINT_ERR(
"Get nand mtd failed!\n");
95 ret = mtd->
read(mtd, COMMAND_LINE_ADDR, COMMAND_LINE_SIZE,
g_cmdLine);
96 if (ret == COMMAND_LINE_SIZE) {
101#ifdef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7
102 struct MtdDev *mtd = GetCfiMtdDev();
104 PRINT_ERR(
"Get CFI mtd failed!\n");
108 ret = mtd->
read(mtd, CFIFLASH_BOOTARGS_ADDR, COMMAND_LINE_SIZE,
g_cmdLine);
109 if (ret == COMMAND_LINE_SIZE) {
114 PRINT_ERR(
"Read cmdline error!\n");
131#ifdef LOSCFG_BOOTENV_RAM
138 const CHAR *bootargsName =
"bootargs=";
141 PRINT_ERR(
"Should call LOS_GetCmdLine() first!\n");
145 for (i = 0; i < COMMAND_LINE_SIZE; i += len + 1) {
147 tmp = strstr(
g_cmdLine + i, bootargsName);
149 *args = tmp + strlen(bootargsName);
153 PRINT_ERR(
"Cannot find bootargs!\n");
163 CHAR *argName = NULL;
164 CHAR *argValue = NULL;
171 while ((argValue = strsep(&args,
" ")) != NULL) {
172 argName = strsep(&argValue,
"=");
173 if (argValue == NULL) {
181 if (++idx >= MAX_ARGS_NUM) {
193 while (idx < MAX_ARGS_NUM) {
197 if (strcmp(argName,
g_bootArgs[idx].argName) == 0) {
217 if (sscanf_s(value,
"0x%llx", &num) > 0) {
218 value += strlen(
"0x");
219 if (strspn(value,
"0123456789abcdefABCDEF") < strlen(value)) {
226 INT32 ret = sscanf_s(value,
"%d", &num);
227 INT32 decOffset = strspn(value,
"0123456789");
228 CHAR *endPos = value + decOffset;
229 if ((ret <= 0) || (decOffset < (strlen(value) - 1))) {
233 if (strlen(endPos) == 0) {
235 }
else if (strcasecmp(endPos,
"k") == 0) {
236 num = num * BYTES_PER_KBYTE;
237 }
else if (strcasecmp(endPos,
"m") == 0) {
238 num = num * BYTES_PER_MBYTE;
239 }
else if (strcasecmp(endPos,
"g") == 0) {
240 num = num * BYTES_PER_GBYTE;
248 PRINT_ERR(
"Invalid value string \"%s\"!\n", value);
los_disk * los_get_mmcdisk_bytype(UINT8 type)
INT32 los_disk_read(INT32 drvID, VOID *buf, UINT64 sector, UINT32 count, BOOL useRead)
Read data from disk driver.
STATIC INT32 GetBootargs(CHAR **args)
获取boot参数
STATIC struct BootArgs g_bootArgs[MAX_ARGS_NUM]
STATIC UINT64 g_alignSize
VOID LOS_FreeCmdLine(VOID)
UINT64 LOS_GetAlignsize(VOID)
INT32 LOS_GetCmdLine(VOID)
读取环境变量bootcmd 来启动内核
INT32 LOS_GetArgValue(CHAR *argName, CHAR **argValue)
INT32 LOS_ParseBootargs(VOID)
解析boot参数
UINT64 LOS_SizeStrToNum(CHAR *value)
CHAR * OsGetArgsAddr(VOID)
void * malloc(size_t size)
动态分配内存块大小
void free(void *ptr)
释放ptr所指向的内存空间
void * GetMtd(const char *type)
UINT32 eraseSize
4K, 跟PAGE_CACHE_SIZE对应
int(* read)(struct MtdDev *mtd, UINT64 start, UINT64 len, const char *buf)
读操作