From: Ben Gras Date: Fri, 19 Dec 2008 13:21:42 +0000 (+0000) Subject: if serial output is enabled in the boot monitor, on the first serial line, X-Git-Tag: v3.1.4~162 X-Git-Url: http://zhaoyanbai.com/repos/?a=commitdiff_plain;h=b740ff055f7fca6d675f0533f38d7c4f8b423f3f;p=minix.git if serial output is enabled in the boot monitor, on the first serial line, enable serial debug output in the kernel too. --- diff --git a/boot/boot.c b/boot/boot.c index bd0b7754e..70fe45254 100755 --- a/boot/boot.c +++ b/boot/boot.c @@ -48,6 +48,8 @@ char version[]= "2.20"; #define arraylimit(a) ((a) + arraysize(a)) #define between(a, c, z) ((unsigned) ((c) - (a)) <= ((z) - (a))) +int serial_line = -1; + u16_t vid_port; /* Video i/o port. */ u32_t vid_mem_base; /* Video memory base address. */ u32_t vid_mem_size; /* Video memory size. */ @@ -1389,13 +1391,14 @@ void boot_device(char *devname) void ctty(char *line) { if (line == nil) { - serial_init(-1); - } else - if (between('0', line[0], '3') && line[1] == 0) { - serial_init(line[0] - '0'); + serial_line = -1; + } else if (between('0', line[0], '3') && line[1] == 0) { + serial_line = line[0] - '0'; } else { printf("Bad serial line number: %s\n", line); + return; } + serial_init(serial_line); } #else /* DOS */ diff --git a/boot/bootimage.c b/boot/bootimage.c index 66354c173..dcec1200d 100755 --- a/boot/bootimage.c +++ b/boot/bootimage.c @@ -29,6 +29,7 @@ static int block_size = 0; +extern int serial_line; extern u16_t vid_port; /* Video i/o port. */ extern u32_t vid_mem_base; /* Video memory base address. */ extern u32_t vid_mem_size; /* Video memory size. */ @@ -748,6 +749,14 @@ void bootminix(void) if ((image= select_image(b_value("image"))) == nil) return; + if(serial_line >= 0) { + char linename[2]; + linename[0] = serial_line + '0'; + linename[1] = '\0'; + b_setvar(E_VAR, SERVARNAME, linename); + printf("set %s to %s\n", SERVARNAME, linename); + } + exec_image(image); switch (errno) { @@ -763,6 +772,9 @@ void bootminix(void) /* No error or error already reported. */; } free(image); + + if(serial_line >= 0) + b_unset(SERVARNAME); } /* diff --git a/include/minix/const.h b/include/minix/const.h index 93d499958..153a40ca0 100755 --- a/include/minix/const.h +++ b/include/minix/const.h @@ -131,6 +131,8 @@ #define NO_ZONE ((zone_t) 0) /* absence of a zone number */ #define NO_DEV ((dev_t) 0) /* absence of a device numb */ +#define SERVARNAME "cttyline" + /* Bits for the system property flags in boot image processes. */ #define PREEMPTIBLE 0x02 /* kernel tasks are not preemptible */ #define BILLABLE 0x04 /* some processes are not billable */ diff --git a/kernel/start.c b/kernel/start.c index b2cb09a43..6af02814f 100755 --- a/kernel/start.c +++ b/kernel/start.c @@ -71,6 +71,9 @@ U16_t parmoff, parmsize; /* boot parameters offset and length */ system_hz = atoi(value); if(!value || system_hz < 2 || system_hz > 50000) /* sanity check */ system_hz = DEFAULT_HZ; + value = get_value(params_buffer, "cttyline"); + if(value && atoi(value) == 0) + do_serial_debug=1; /* Return to assembler code to switch to protected mode (if 286), * reload selectors and call main().