mirror of
https://github.com/vivier/EMILE.git
synced 2025-04-30 07:37:09 +00:00
store read_config() result in a structure
This commit is contained in:
parent
a844b4c51a
commit
ac524c2a45
@ -138,9 +138,7 @@ static char *decode_serial(char* s, int *baudrate, int *parity, int *datasize, i
|
||||
return s;
|
||||
}
|
||||
|
||||
int read_config(emile_l2_header_t* info,
|
||||
char **kernel_path, char **command_line, char **ramdisk_path,
|
||||
char **chainloader)
|
||||
int read_config(emile_l2_header_t* info, emile_config_t *econfig)
|
||||
{
|
||||
char property[COMMAND_LINE_LENGTH];
|
||||
int8_t *configuration;
|
||||
@ -373,9 +371,7 @@ int read_config(emile_l2_header_t* info,
|
||||
}
|
||||
#endif
|
||||
|
||||
*kernel_path = NULL;
|
||||
*command_line = NULL;
|
||||
*ramdisk_path = NULL;
|
||||
memset(econfig, 0, sizeof(*econfig));
|
||||
for (i = 0; i < prop_nb[choice]; i++)
|
||||
{
|
||||
char *id, *next;
|
||||
@ -385,13 +381,13 @@ int read_config(emile_l2_header_t* info,
|
||||
next++;
|
||||
|
||||
if (strcmp("kernel", id) == 0)
|
||||
*kernel_path = strdup(next);
|
||||
econfig->kernel = strdup(next);
|
||||
else if (strcmp("parameters", id) == 0)
|
||||
*command_line = strdup(next);
|
||||
econfig->command_line = strdup(next);
|
||||
else if (strcmp("initrd", id) == 0)
|
||||
*ramdisk_path = strdup(next);
|
||||
econfig->initrd = strdup(next);
|
||||
else if (strcmp("chainloader", id) == 0)
|
||||
*chainloader = strdup(next);
|
||||
econfig->chainloader = strdup(next);
|
||||
}
|
||||
|
||||
for (index--; index >= 0; index--)
|
||||
|
@ -6,4 +6,11 @@
|
||||
|
||||
#include "head.h"
|
||||
|
||||
extern int read_config(emile_l2_header_t* info, char **kernel_path, char **command_line, char **ramdisk_path, char **chainloader);
|
||||
typedef struct emile_config {
|
||||
char *kernel;
|
||||
char *command_line;
|
||||
char *initrd;
|
||||
char *chainloader;
|
||||
} emile_config_t;
|
||||
|
||||
extern int read_config(emile_l2_header_t* info, emile_config_t *config);
|
||||
|
@ -53,7 +53,8 @@ extern u_int32_t _bootstrap_end;
|
||||
|
||||
int start(emile_l2_header_t* info)
|
||||
{
|
||||
char * kernel;
|
||||
char *kernel;
|
||||
char *loader;
|
||||
#ifdef ARCH_M68K
|
||||
entry_t entry;
|
||||
unsigned long physImage;
|
||||
@ -72,9 +73,7 @@ int start(emile_l2_header_t* info)
|
||||
char *ramdisk_start;
|
||||
unsigned long kernel_size;
|
||||
unsigned long ramdisk_size;
|
||||
char *kernel_path = NULL;
|
||||
char *ramdisk_path = NULL;
|
||||
char *command_line = NULL;
|
||||
emile_config_t econfig;
|
||||
|
||||
serial_init();
|
||||
console_init();
|
||||
@ -85,16 +84,24 @@ int start(emile_l2_header_t* info)
|
||||
#endif
|
||||
enter_kernel_init();
|
||||
|
||||
retry:
|
||||
if (kernel_path != NULL)
|
||||
free(kernel_path);
|
||||
if (command_line != NULL)
|
||||
free(command_line);
|
||||
if (ramdisk_path != NULL)
|
||||
free(command_line);
|
||||
memset(&econfig, 0, sizeof(econfig));
|
||||
|
||||
if (read_config(info, &kernel_path, &command_line, &ramdisk_path) != 0)
|
||||
retry:
|
||||
if (econfig.kernel != NULL)
|
||||
free(econfig.kernel);
|
||||
if (econfig.command_line != NULL)
|
||||
free(econfig.command_line);
|
||||
if (econfig.initrd != NULL)
|
||||
free(econfig.initrd);
|
||||
if (econfig.chainloader != NULL)
|
||||
free(econfig.chainloader);
|
||||
|
||||
if (read_config(info, &econfig) != 0)
|
||||
error("cannot read configuration\n");
|
||||
if (econfig.chainloader)
|
||||
{
|
||||
loader = load_chainloader(econfig.chainloader);
|
||||
}
|
||||
|
||||
#ifdef ARCH_M68K
|
||||
if (arch_type == gestalt68k)
|
||||
@ -123,7 +130,7 @@ retry:
|
||||
|
||||
/* load kernel */
|
||||
|
||||
kernel = load_kernel(kernel_path,
|
||||
kernel = load_kernel(econfig.kernel,
|
||||
bootstrap_size,
|
||||
&start_mem, &entry_point, &kernel_size);
|
||||
if (kernel == NULL)
|
||||
@ -136,9 +143,9 @@ retry:
|
||||
|
||||
/* load ramdisk if needed */
|
||||
|
||||
if (ramdisk_path)
|
||||
if (econfig.initrd)
|
||||
{
|
||||
ramdisk_start = load_ramdisk(ramdisk_path, &ramdisk_size);
|
||||
ramdisk_start = load_ramdisk(econfig.initrd, &ramdisk_size);
|
||||
if (ramdisk_start == NULL)
|
||||
{
|
||||
if (kernel != NULL)
|
||||
@ -177,7 +184,7 @@ retry:
|
||||
#if defined(__LINUX__)
|
||||
/* initialize bootinfo structure */
|
||||
|
||||
bootinfo_init(command_line,
|
||||
bootinfo_init(econfig.command_line,
|
||||
ramdisk_start, ramdisk_size);
|
||||
|
||||
/* set bootinfo at end of kernel image */
|
||||
@ -203,7 +210,7 @@ retry:
|
||||
#if defined(__LINUX__)
|
||||
/* initialize bootinfo structure */
|
||||
|
||||
bootinfo_init(command_line,
|
||||
bootinfo_init(econfig.command_line,
|
||||
ramdisk_start, ramdisk_size);
|
||||
|
||||
/* add KERNEL_ALIGN if we have to align */
|
||||
@ -254,7 +261,7 @@ retry:
|
||||
{
|
||||
PPCRegisterList regs;
|
||||
|
||||
bootx_init(command_line, ramdisk_start, ramdisk_size);
|
||||
bootx_init(econfig.command_line, ramdisk_start, ramdisk_size);
|
||||
|
||||
regs.PC = (u_int32_t)&_bootstrap_start;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user