Ensure that a serial port is set up before used.

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

View file

@ -1,3 +1,17 @@
2001-10-13 Yoshinori K. Okuji <okuji@gnu.org>
Based on a patch from Jeremy Katz <katzj@redhat.com>:
* docs/grub.texi (Stage2 errors): Added documentation on the
error number 33 (Serial device not configured).
* grub/asmstub.c (serial_exists): New function.
* stage2/serial.c (serial_exists): Likewise.
* stage2/serial.h (serial_exists): New prototype.
* stage2/shared.h (grub_error_t): ERR_NEED_SERIAL is added.
* stage2/builtins.c (terminal_func) [SUPPORT_SERIAL]: If a
serial device is not configured yet, restore the terminal and
set ERRNUM to ERR_NEED_SERIAL.
* stage2/common.c (err_list): Added an item for ERR_NEED_SERIAL.
2001-10-13 Yoshinori K. Okuji <okuji@gnu.org>
From Jason Thomas <jason@topic.com.au>:

1
THANKS
View file

@ -40,6 +40,7 @@ Hisazumi Kenji <nel@soraneko.com>
HORIKAWA Kazunori <kaz-hori@tkd.att.ne.jp>
Jan Fricke <fricke@uni-greifswald.de>
Jan Zerebecki <jan.list@elite-pferde.de>
Jeremy Katz <katzj@redhat.com>
Jochen Hoenicke <jochen@gnu.org>
Johannes Kroeger <hanne@squirrel.owl.de>
John Tobey <spam@john-edwin-tobey.org>

View file

@ -3054,6 +3054,10 @@ should mount the partition with the @samp{-o notail} option.
@item 32 : Must be authenticated
This error is returned if you try to run a locked entry. You should
enter a correct password before running such an entry.
@item 33 : Serial device not configured
This error is returned if you try to change your terminal to a serial
one before initializing any serial device.
@end table

View file

@ -1,4 +1,4 @@
@set UPDATED 5 July 2001
@set UPDATED-MONTH July 2001
@set UPDATED 13 October 2001
@set UPDATED-MONTH October 2001
@set EDITION 0.90
@set VERSION 0.90

View file

@ -1,4 +1,4 @@
@set UPDATED 5 July 2001
@set UPDATED-MONTH July 2001
@set UPDATED 13 October 2001
@set UPDATED-MONTH October 2001
@set EDITION 0.90
@set VERSION 0.90

View file

@ -1026,6 +1026,13 @@ serial_get_port (int unit)
return 0;
}
/* Check if a serial port is set up. */
int
serial_exists (void)
{
return serial_fd >= 0;
}
/* Initialize a serial device. In the grub shell, PORT is unused. */
int
serial_init (unsigned short port, unsigned int speed,

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

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",

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)

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. */

View file

@ -541,6 +541,7 @@ typedef enum
ERR_BAD_ARGUMENT,
ERR_UNALIGNED,
ERR_PRIVILEGED,
ERR_NEED_SERIAL,
MAX_ERR_NUM
} grub_error_t;