remove read_config_vga(), read_config_modem() and read_config_printer() and initialize vga and modem from read_config(), select one console when several available

This commit is contained in:
Laurent Vivier 2007-09-16 15:27:53 +00:00
parent abb1e988bf
commit b82dc3e69f
2 changed files with 34 additions and 71 deletions

View File

@ -21,6 +21,8 @@
#include "arch.h" #include "arch.h"
#include "misc.h" #include "misc.h"
#include "bank.h" #include "bank.h"
#include "vga.h"
#include "serial.h"
#define MSG_STATE_0 console_set_cursor_position(5, 1); \ #define MSG_STATE_0 console_set_cursor_position(5, 1); \
printf(" Press 'b' or [RETURN] to boot or 'e' to edit\n"); printf(" Press 'b' or [RETURN] to boot or 'e' to edit\n");
@ -49,7 +51,17 @@ static int8_t *open_config(emile_l2_header_t *info)
char property[COMMAND_LINE_LENGTH]; char property[COMMAND_LINE_LENGTH];
int ret; int ret;
if (config_get_property(info->configuration, configuration = (int8_t*)malloc(info->conf_size);
if (configuration == NULL)
{
printf("ERROR: cannot allocate %d bytes for "
"configuration file %s\n",
(int)stat.st_size, property);
return NULL;
}
memcpy(configuration, info->configuration, info->conf_size);
if (config_get_property(configuration,
"configuration", property) != -1) "configuration", property) != -1)
{ {
stream = stream_open(property); stream = stream_open(property);
@ -62,6 +74,8 @@ static int8_t *open_config(emile_l2_header_t *info)
stream_fstat(stream, &stat); stream_fstat(stream, &stat);
free(configuration);
configuration = (int8_t*)malloc(stat.st_size); configuration = (int8_t*)malloc(stat.st_size);
if (configuration == NULL) if (configuration == NULL)
{ {
@ -82,18 +96,6 @@ static int8_t *open_config(emile_l2_header_t *info)
stream_close(stream); stream_close(stream);
} }
else
{
configuration = (int8_t*)malloc(info->conf_size);
if (configuration == NULL)
{
printf("ERROR: cannot allocate %d bytes for "
"configuration file %s\n",
(int)stat.st_size, property);
return NULL;
}
memcpy(configuration, info->configuration, info->conf_size);
}
return configuration; return configuration;
} }
@ -134,59 +136,6 @@ static char *decode_serial(char* s, int *baudrate, int *parity, int *datasize, i
return s; return s;
} }
char* read_config_vga(emile_l2_header_t* info)
{
int8_t *configuration;
char property[64];
int ret;
configuration = open_config(info);
ret = config_get_property(configuration, "vga", property);
close_config(configuration);
if (ret == -1)
return NULL;
return strdup(property);
}
int read_config_modem(emile_l2_header_t* info, int *bitrate, int *parity, int *datasize, int *stopbits)
{
int8_t *configuration;
char property[64];
int ret;
configuration = open_config(info);
ret = config_get_property(configuration, "modem", property);
if (ret == -1)
{
close_config(configuration);
return -1;
}
decode_serial(property, bitrate, parity, datasize, stopbits);
close_config(configuration);
return 0;
}
int read_config_printer(emile_l2_header_t* info, int *bitrate, int *parity, int *datasize, int *stopbits)
{
int8_t *configuration;
char property[64];
int ret;
configuration = open_config(info);
ret = config_get_property(configuration, "printer", property);
if (ret == -1)
{
close_config(configuration);
return -1;
}
decode_serial(property, bitrate, parity, datasize, stopbits);
close_config(configuration);
return 0;
}
int read_config(emile_l2_header_t* info, int read_config(emile_l2_header_t* info,
char **kernel_path, char **command_line, char **ramdisk_path) char **kernel_path, char **command_line, char **ramdisk_path)
{ {
@ -207,6 +156,7 @@ int read_config(emile_l2_header_t* info,
int timeout; int timeout;
int current; int current;
int res; int res;
int bitrate, parity, datasize, stopbits;
#if defined(USE_CLI) && defined(__LINUX__) #if defined(USE_CLI) && defined(__LINUX__)
int l, c; int l, c;
emile_window_t win; emile_window_t win;
@ -216,12 +166,28 @@ int read_config(emile_l2_header_t* info,
if (!EMILE_COMPAT(EMILE_07_SIGNATURE, info->signature)) if (!EMILE_COMPAT(EMILE_07_SIGNATURE, info->signature))
{ {
vga_init("default");
printf("Bad header signature !\n"); printf("Bad header signature !\n");
return -1; return -1;
} }
configuration = open_config(info); configuration = open_config(info);
if (config_get_property(configuration, "vga", property) != -1)
vga_init(property);
if (config_get_property(configuration, "modem", property) != -1)
{
decode_serial(property, &bitrate, &parity, &datasize, &stopbits);
serial_enable(SERIAL_MODEM_PORT, bitrate, parity, datasize, stopbits);
}
if (config_get_property(configuration, "printer", property) != -1)
{
decode_serial(property, &bitrate, &parity, &datasize, &stopbits);
serial_enable(SERIAL_PRINTER_PORT, bitrate, parity, datasize, stopbits);
}
if (config_get_property(configuration, "gestaltID", property) != -1) if (config_get_property(configuration, "gestaltID", property) != -1)
{ {
machine_id = strtol(property, NULL, 0); machine_id = strtol(property, NULL, 0);
@ -293,11 +259,11 @@ int read_config(emile_l2_header_t* info,
choice = index - 1; choice = index - 1;
#if defined(USE_CLI) && defined(__LINUX__) #if defined(USE_CLI) && defined(__LINUX__)
if (console_select(timeout)) timeout = console_select(timeout);
timeout = 0;
console_get_size(&l, &c); console_get_size(&l, &c);
console_clear(); console_clear();
console_set_position(1,1);
#endif #endif
printf( " EMILE v"VERSION printf( " EMILE v"VERSION
" (c) 2004-2007 Laurent Vivier (%ld kB)\n", " (c) 2004-2007 Laurent Vivier (%ld kB)\n",

View File

@ -7,6 +7,3 @@
#include "head.h" #include "head.h"
extern int read_config(emile_l2_header_t* info, char **kernel_path, char **command_line, char **ramdisk_path); extern int read_config(emile_l2_header_t* info, char **kernel_path, char **command_line, char **ramdisk_path);
extern char *read_config_vga(emile_l2_header_t* info);
extern int read_config_modem(emile_l2_header_t* info, int *bitrate, int *parity, int *datasize, int *stopbits);
extern int read_config_printer(emile_l2_header_t* info, int *bitrate, int *parity, int *datasize, int *stopbits);