comX notation support
This commit is contained in:
parent
2386d586b9
commit
5fb5182f8a
3 changed files with 25 additions and 12 deletions
|
@ -64,4 +64,7 @@
|
|||
/* Turn on DTR, RTS, and OUT2. */
|
||||
#define UART_ENABLE_MODEM 0x0B
|
||||
|
||||
unsigned short
|
||||
grub_serial_hw_get_port (const unsigned int unit);
|
||||
|
||||
#endif /* ! GRUB_SERIAL_MACHINE_HEADER */
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <grub/command.h>
|
||||
#include <grub/extcmd.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/i386/pc/serial.h>
|
||||
|
||||
#ifdef GRUB_MACHINE_PCBIOS
|
||||
#include <grub/machine/biosnum.h>
|
||||
|
@ -137,7 +138,7 @@ static const struct grub_arg_option netbsd_opts[] =
|
|||
{"silent", 'z', 0, N_("Supress normal output (warnings remain)."), 0, 0},
|
||||
{"root", 'r', 0, N_("Set root device."), N_("DEVICE"), ARG_TYPE_STRING},
|
||||
{"serial", 'h', GRUB_ARG_OPTION_OPTIONAL,
|
||||
N_("Use serial console."), N_("ADDR,SPEED"), ARG_TYPE_STRING},
|
||||
N_("Use serial console."), N_("[ADDR|comUNIT][,SPEED]"), ARG_TYPE_STRING},
|
||||
{0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
|
@ -1275,15 +1276,24 @@ grub_cmd_netbsd (grub_extcmd_t cmd, int argc, char *argv[])
|
|||
if (cmd->state[NETBSD_SERIAL_ARG].arg)
|
||||
{
|
||||
ptr = cmd->state[NETBSD_SERIAL_ARG].arg;
|
||||
serial.addr = grub_strtoul (ptr, &ptr, 0);
|
||||
if (grub_errno)
|
||||
return grub_errno;
|
||||
if (*ptr != ',')
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid format");
|
||||
ptr++;
|
||||
serial.speed = grub_strtoul (ptr, &ptr, 0);
|
||||
if (grub_memcmp (ptr, "com", sizeof ("com") - 1) == 0)
|
||||
{
|
||||
ptr += sizeof ("com") - 1;
|
||||
serial.addr
|
||||
= grub_serial_hw_get_port (grub_strtoul (ptr, &ptr, 0));
|
||||
}
|
||||
else
|
||||
serial.addr = grub_strtoul (ptr, &ptr, 0);
|
||||
if (grub_errno)
|
||||
return grub_errno;
|
||||
|
||||
if (*ptr == ',')
|
||||
{
|
||||
ptr++;
|
||||
serial.speed = grub_strtoul (ptr, &ptr, 0);
|
||||
if (grub_errno)
|
||||
return grub_errno;
|
||||
}
|
||||
}
|
||||
|
||||
grub_bsd_add_meta (NETBSD_BTINFO_CONSOLE, &serial, sizeof (serial));
|
||||
|
|
|
@ -74,8 +74,8 @@ static const unsigned short serial_hw_io_addr[] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 }
|
|||
#endif
|
||||
|
||||
/* Return the port number for the UNITth serial device. */
|
||||
static inline unsigned short
|
||||
serial_hw_get_port (const unsigned int unit)
|
||||
unsigned short
|
||||
grub_serial_hw_get_port (const unsigned int unit)
|
||||
{
|
||||
if (unit < GRUB_SERIAL_PORT_NUM)
|
||||
return serial_hw_io_addr[unit];
|
||||
|
@ -498,7 +498,7 @@ grub_cmd_serial (grub_extcmd_t cmd,
|
|||
unsigned int unit;
|
||||
|
||||
unit = grub_strtoul (state[0].arg, 0, 0);
|
||||
serial_settings.port = serial_hw_get_port (unit);
|
||||
serial_settings.port = grub_serial_hw_get_port (unit);
|
||||
if (!serial_settings.port)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "bad unit number");
|
||||
}
|
||||
|
@ -608,7 +608,7 @@ GRUB_MOD_INIT(serial)
|
|||
N_("Configure serial port."), options);
|
||||
|
||||
/* Set default settings. */
|
||||
serial_settings.port = serial_hw_get_port (0);
|
||||
serial_settings.port = grub_serial_hw_get_port (0);
|
||||
serial_settings.divisor = serial_get_divisor (9600);
|
||||
serial_settings.word_len = UART_8BITS_WORD;
|
||||
serial_settings.parity = UART_NO_PARITY;
|
||||
|
|
Loading…
Reference in a new issue