static void __init parse_vhpt_size(char *s) { int sz = parse_size_and_unit(s, NULL); if (sz > 0) { default_vhpt_sz = fls(sz - 1); default_vhpt_sz = canonicalize_vhpt_size(default_vhpt_sz); } }
static void __init parse_vtlb_size(char *s) { int sz = parse_size_and_unit(s, NULL); if (sz > 0) { default_vtlb_sz = fls(sz - 1); /* minimum 16KB (for tag uniqueness) */ if (default_vtlb_sz < 14) default_vtlb_sz = 14; } }
void __init cmdline_parse(const char *cmdline) { char opt[100], *optval, *optkey, *q; const char *p = cmdline; struct kernel_param *param; int bool_assert; if ( cmdline == NULL ) return; safe_strcpy(saved_cmdline, cmdline); for ( ; ; ) { /* Skip whitespace. */ while ( *p == ' ' ) p++; if ( *p == '\0' ) break; /* Grab the next whitespace-delimited option. */ q = optkey = opt; while ( (*p != ' ') && (*p != '\0') ) { if ( (q-opt) < (sizeof(opt)-1) ) /* avoid overflow */ *q++ = *p; p++; } *q = '\0'; /* Search for value part of a key=value option. */ optval = strchr(opt, '='); if ( optval != NULL ) { *optval++ = '\0'; /* nul-terminate the option value */ q = strpbrk(opt, "([{<"); } else { optval = q; /* default option value is empty string */ q = NULL; } /* Boolean parameters can be inverted with 'no-' prefix. */ bool_assert = !!strncmp("no-", optkey, 3); if ( !bool_assert ) optkey += 3; for ( param = &__setup_start; param < &__setup_end; param++ ) { if ( strcmp(param->name, optkey) ) { if ( param->type == OPT_CUSTOM && q && strlen(param->name) == q + 1 - opt && !strncmp(param->name, opt, q + 1 - opt) ) { optval[-1] = '='; ((void (*)(const char *))param->var)(q); optval[-1] = '\0'; } continue; } switch ( param->type ) { case OPT_STR: strlcpy(param->var, optval, param->len); break; case OPT_UINT: assign_integer_param( param, simple_strtoll(optval, NULL, 0)); break; case OPT_BOOL: case OPT_INVBOOL: if ( !parse_bool(optval) ) bool_assert = !bool_assert; assign_integer_param( param, (param->type == OPT_BOOL) == bool_assert); break; case OPT_SIZE: assign_integer_param( param, parse_size_and_unit(optval, NULL)); break; case OPT_CUSTOM: if ( !bool_assert ) { if ( *optval ) break; safe_strcpy(opt, "no"); optval = opt; } ((void (*)(const char *))param->var)(optval); break; default: BUG(); break; } } } }
static void __init parse_crashkernel(const char *str) { kexec_crash_area.size = parse_size_and_unit(str, &str); if ( *str == '@' ) kexec_crash_area.start = parse_size_and_unit(str+1, NULL); }
static void __init parse_serial_tx_buffer(const char *s) { serial_txbufsz = max((unsigned int)parse_size_and_unit(s, NULL), 512u); }
static void parse_mem(char *s) { opt_mem = parse_size_and_unit(s, NULL); }
void cmdline_parse(char *cmdline) { char opt[100], *optval, *optkey, *q; const char *p = cmdline; struct kernel_param *param; int bool_assert; safe_strcpy(saved_cmdline, cmdline); if ( p == NULL ) return; for ( ; ; ) { /* Skip whitespace. */ while ( *p == ' ' ) p++; if ( *p == '\0' ) break; /* Grab the next whitespace-delimited option. */ q = optkey = opt; while ( (*p != ' ') && (*p != '\0') ) { if ( (q-opt) < (sizeof(opt)-1) ) /* avoid overflow */ *q++ = *p; p++; } *q = '\0'; /* Search for value part of a key=value option. */ optval = strchr(opt, '='); if ( optval != NULL ) *optval++ = '\0'; /* nul-terminate the option value */ else optval = q; /* default option value is empty string */ /* Boolean parameters can be inverted with 'no-' prefix. */ bool_assert = !!strncmp("no-", optkey, 3); if ( !bool_assert ) optkey += 3; for ( param = &__setup_start; param <= &__setup_end; param++ ) { if ( strcmp(param->name, optkey) ) continue; switch ( param->type ) { case OPT_STR: strlcpy(param->var, optval, param->len); break; case OPT_UINT: *(unsigned int *)param->var = simple_strtol(optval, NULL, 0); break; case OPT_BOOL: case OPT_INVBOOL: if ( !strcmp("no", optval) || !strcmp("off", optval) || !strcmp("false", optval) || !strcmp("0", optval) ) bool_assert = !bool_assert; if ( param->type == OPT_INVBOOL ) bool_assert = !bool_assert; *(int *)param->var = bool_assert; break; case OPT_SIZE: { uint64_t sz = parse_size_and_unit(optval, NULL); switch ( param->len ) { case sizeof(uint32_t): *(uint32_t *)param->var = sz; break; case sizeof(uint64_t): *(uint64_t *)param->var = sz; break; default: BUG(); } break; } case OPT_CUSTOM: ((void (*)(const char *))param->var)(optval); break; } } } }
static void parse_conring_size(char *s) { opt_conring_size = parse_size_and_unit(s, NULL); }