Ensure that a serial port is set up before used.

This commit is contained in:
okuji committed 2001-10-13 12:02:30 +00:00
1 parent a8ac7eb3f9
commit 61928d1323
11 files changed
+58 -11

No files matched your search

+12 -3
View File
@@ -3914,9 +3914,18 @@ terminal_func (char *arg, int flags)
#ifdef SUPPORT_SERIAL
else if (grub_memcmp (arg, "serial", sizeof ("serial") - 1) == 0)
{
terminal |= TERMINAL_SERIAL;
if (! default_terminal)
default_terminal = TERMINAL_SERIAL;
if (serial_exists ())
{
terminal |= TERMINAL_SERIAL;
if (! default_terminal)
default_terminal = TERMINAL_SERIAL;
}
else
{
terminal = saved_terminal;
errnum = ERR_NEED_SERIAL;
return 1;
}
}
#endif /* SUPPORT_SERIAL */
else
+2 -1
View File
@@ -2,7 +2,7 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1996 Erich Boleyn <erich@uruk.org>
* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
* Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -73,6 +73,7 @@ char *err_list[] =
[ERR_GEOM] = "Selected cylinder exceeds maximum supported by BIOS",
[ERR_NEED_LX_KERNEL] = "Linux kernel must be loaded before initrd",
[ERR_NEED_MB_KERNEL] = "Multiboot kernel must be loaded before modules",
[ERR_NEED_SERIAL] = "Serial device not configured",
[ERR_NO_DISK] = "Selected disk does not exist",
[ERR_NO_PART] = "No such partition",
[ERR_NUMBER_PARSING] = "Error while parsing number",
+9 -2
View File
@@ -1,7 +1,7 @@
/* serial.c - serial device interface */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2000 Free Software Foundation, Inc.
* Copyright (C) 2000, 2001 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -31,7 +31,7 @@ struct divisor
};
/* Store the port number of a serial unit. */
static unsigned short serial_port;
static unsigned short serial_port = -1;
/* The table which lists common configurations. */
static struct divisor divisor_tab[] =
@@ -102,6 +102,13 @@ serial_putchar (int c)
outb (serial_port + UART_TX, c);
}
/* Check if a serial port is set up. */
int
serial_exists (void)
{
return serial_port != -1;
}
/* Return the port number for the UNITth serial device. */
unsigned short
serial_get_port (int unit)
+4 -1
View File
@@ -1,7 +1,7 @@
/* serial.h - serial device interface */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2000 Free Software Foundation, Inc.
* Copyright (C) 2000, 2001 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -93,6 +93,9 @@ unsigned short serial_get_port (int unit);
int serial_init (unsigned short port, unsigned int speed,
int word_len, int parity, int stop_bit_len);
/* Check if a serial port is set up. */
int serial_exists (void);
#ifdef GRUB_UTIL
/* Set the file name of a serial device (or a pty device). This is a
function specific to the grub shell. */
+1
View File
@@ -541,6 +541,7 @@ typedef enum
ERR_BAD_ARGUMENT,
ERR_UNALIGNED,
ERR_PRIVILEGED,
ERR_NEED_SERIAL,
MAX_ERR_NUM
} grub_error_t;