bootargs

Linux/Linux Kernel : 2017. 7. 19. 15:36
반응형


**********************************************************************

arch/arm/kernel/setup.c


void __init setup_arch(char **cmdline_p)

{

strlcpy(cmd_line, boot_command_line, COMMAND_LINE_SIZE);

*cmdline_p = cmd_line;


**********************************************************************


init/main.c


asmlinkage void __init start_kernel(void)

{

setup_arch(&command_line);

mm_init_owner(&init_mm, &init_task);

mm_init_cpumask(&init_mm);

setup_command_line(command_line);

setup_nr_cpu_ids();

setup_per_cpu_areas();

smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */


build_all_zonelists(NULL);

page_alloc_init();


printk(KERN_NOTICE "Kernel command line: %s\n", boot_command_line);

parse_early_param();

parse_args("Booting kernel", static_command_line, __start___param,

  __stop___param - __start___param,

  -1, -1, &unknown_bootoption);


**********************************************************************


/*

 * We need to store the untouched command line for future reference.

 * We also need to store the touched command line since the parameter

 * parsing is performed in place, and we should allow a component to

 * store reference of name/value for future reference.

 */

static void __init setup_command_line(char *command_line)

{

saved_command_line = alloc_bootmem(strlen (boot_command_line)+1);

static_command_line = alloc_bootmem(strlen (command_line)+1);

strcpy (saved_command_line, boot_command_line);

strcpy (static_command_line, command_line);

}


**********************************************************************


/*

 * Unknown boot options get handed to init, unless they look like

 * unused parameters (modprobe will find them in /proc/cmdline).

 */

static int __init unknown_bootoption(char *param, char *val)

{

repair_env_string(param, val);


        printk("HHHHHHHO :%s:%s\n",param,val);

/* Handle obsolete-style parameters */

if (obsolete_checksetup(param))

return 0;


/* Unused module parameter. */

if (strchr(param, '.') && (!val || strchr(param, '.') < val))

return 0;


if (panic_later)

return 0;


if (val) {

/* Environment option */

unsigned int i;

for (i = 0; envp_init[i]; i++) {

if (i == MAX_INIT_ENVS) {

panic_later = "Too many boot env vars at `%s'";

panic_param = param;

}

if (!strncmp(param, envp_init[i], val - param))

break;

}

envp_init[i] = param;

} else {

/* Command line option */

unsigned int i;

for (i = 0; argv_init[i]; i++) {

if (i == MAX_INIT_ARGS) {

panic_later = "Too many boot init vars at `%s'";

panic_param = param;

}

}

argv_init[i] = param;

}

return 0;

}


**********************************************************************


static void run_init_process(const char *init_filename)

{

argv_init[0] = init_filename;

kernel_execve(init_filename, argv_init, envp_init);

}


**********************************************************************


arch/arm/kernel/sys_arm.c


int kernel_execve(const char *filename,
 const char *const argv[],
 const char *const envp[])
{
struct pt_regs regs;
int ret;

memset(&regs, 0, sizeof(struct pt_regs));
ret = do_execve(filename,
(const char __user *const __user *)argv,
(const char __user *const __user *)envp, &regs);
if (ret < 0)
goto out;

/*
* Save argc to the register structure for userspace.
*/
regs.ARM_r0 = ret;

/*
* We were successful.  We won't be returning to our caller, but
* instead to user space by manipulating the kernel stack.
*/
asm( "add r0, %0, %1\n\t"
"mov r1, %2\n\t"
"mov r2, %3\n\t"
"bl memmove\n\t" /* copy regs to top of stack */
"mov r8, #0\n\t" /* not a syscall */
"mov r9, %0\n\t" /* thread structure */
"mov sp, r0\n\t" /* reposition stack pointer */
"b ret_to_user"
:
: "r" (current_thread_info()),
 "Ir" (THREAD_START_SP - sizeof(regs)),
 "r" (&regs),
 "Ir" (sizeof(regs))
: "r0", "r1", "r2", "r3", "r8", "r9", "ip", "lr", "memory");

 out:
return ret;
}
EXPORT_SYMBOL(kernel_execve);

**********************************************************************

**********************************************************************

**********************************************************************

**********************************************************************

**********************************************************************

**********************************************************************

**********************************************************************

**********************************************************************

**********************************************************************

**********************************************************************

반응형

'Linux > Linux Kernel' 카테고리의 다른 글

linux kernel 에서 random 값 얻기  (0) 2017.07.20
i2c instantiating <Documentation/i2c/instantiating-devices>  (0) 2016.10.18
Linux USB SoundCard  (0) 2016.10.11
Posted by Real_G