tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
bootloaders handling of unknown console device
Hello
I just tried to use the nullcons console device, and I discovered that
x86 bootloaders needed a patch for that: in current sources, they will
refuse to pass the kernel a console device they do not know about.
What about this patch? Instead of refusing "consdev nullcons", it just
warns it is unknown and still pass it to the kernel.
Index: boot/boot2.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/stand/boot/boot2.c,v
retrieving revision 1.70
diff -U4 -r1.70 boot2.c
--- boot/boot2.c 14 Nov 2017 09:55:41 -0000 1.70
+++ boot/boot2.c 31 Jul 2019 01:58:16 -0000
@@ -298,9 +298,9 @@
char c;
twiddle_toggle = 1; /* no twiddling until we're ready */
- initio(boot_params.bp_consdev);
+ initio(boot_params.bp_consdev, NULL);
#ifdef SUPPORT_PS2
biosmca();
#endif
@@ -530,14 +530,16 @@
const struct cons_devs *cdp;
for (cdp = cons_devs; cdp->name; cdp++) {
if (strcmp(arg, cdp->name) == 0) {
- initio(cdp->tag);
+ initio(cdp->tag, NULL);
print_banner();
return;
}
}
- printf("invalid console device.\n");
+ printf("unknown console device %s.\n", arg);
+ initio(CONSDEV_PC, arg);
+ return;
}
#ifndef SMALL
/* ARGSUSED */
Index: dosboot/main.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/stand/dosboot/main.c,v
retrieving revision 1.33
diff -U4 -r1.33 main.c
--- dosboot/main.c 13 May 2019 17:50:30 -0000 1.33
+++ dosboot/main.c 31 Jul 2019 01:58:16 -0000
@@ -233,11 +233,11 @@
extern char *optarg;
extern int optind;
#ifdef SUPPORT_SERIAL
- initio(SUPPORT_SERIAL);
+ initio(SUPPORT_SERIAL, NULL);
#else
- initio(CONSDEV_PC);
+ initio(CONSDEV_PC, NULL);
#endif
gateA20();
print_banner();
Index: efiboot/boot.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/stand/efiboot/boot.c,v
retrieving revision 1.11
diff -U4 -r1.11 boot.c
--- efiboot/boot.c 20 Jun 2019 17:33:31 -0000 1.11
+++ efiboot/boot.c 31 Jul 2019 01:58:16 -0000
@@ -542,15 +542,17 @@
if (sep2 != NULL)
goto error;
}
}
- consinit(cdp->tag, ioport, speed);
+ consinit(cdp->tag, NULL, ioport, speed);
print_banner();
return;
}
}
error:
- printf("invalid console device.\n");
+ printf("unknown console device %s.\n", arg);
+ consinit(CONSDEV_PC, arg, 0, 0);
+ return;
}
#ifndef SMALL
/* ARGSUSED */
Index: efiboot/efiboot.h
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/stand/efiboot/efiboot.h,v
retrieving revision 1.8
diff -U4 -r1.8 efiboot.h
--- efiboot/efiboot.h 11 Apr 2018 10:32:09 -0000 1.8
+++ efiboot/efiboot.h 31 Jul 2019 01:58:16 -0000
@@ -64,9 +64,9 @@
int utf8_to_ucs2(const char *, CHAR16 **, size_t *);
/* eficons.c */
int cninit(void);
-void consinit(int, int, int);
+void consinit(int, char *, int, int);
void efi_cons_show(void);
void command_text(char *);
void command_gop(char *);
Index: efiboot/eficons.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/stand/efiboot/eficons.c,v
retrieving revision 1.6
diff -U4 -r1.6 eficons.c
--- efiboot/eficons.c 16 May 2018 19:53:54 -0000 1.6
+++ efiboot/eficons.c 31 Jul 2019 01:58:16 -0000
@@ -90,9 +90,9 @@
/*
* XXX only pass console parameters to kernel.
*/
void
-consinit(int dev, int ioport, int speed)
+consinit(int dev, char *devname, int ioport, int speed)
{
int i;
btinfo_console.speed = default_comspeed;
@@ -171,9 +171,12 @@
keybuf_read = keybuf_write = 0;
break;
}
- strlcpy(btinfo_console.devname, iodev == CONSDEV_PC ? "pc" :
"com", 16);
+ if (devname == NULL)
+ devname = (iodev == CONSDEV_PC) ? "pc" : "com";
+
+ strlcpy(btinfo_console.devname, devname, 16);
}
int
cninit(void)
@@ -182,9 +185,9 @@
efi_switch_video_to_text_mode();
eficons_init_video();
efi_com_probe();
- consinit(boot_params.bp_consdev, boot_params.bp_consaddr,
+ consinit(boot_params.bp_consdev, NULL, boot_params.bp_consaddr,
boot_params.bp_conspeed);
return 0;
}
Index: lib/libi386.h
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/stand/lib/libi386.h,v
retrieving revision 1.43
diff -U4 -r1.43 libi386.h
--- lib/libi386.h 24 Jun 2019 13:58:24 -0000 1.43
+++ lib/libi386.h 31 Jul 2019 01:58:16 -0000
@@ -59,9 +59,9 @@
void reboot(void);
void gateA20(void);
void clear_pc_screen(void);
-void initio(int);
+void initio(int, char *);
#define CONSDEV_PC 0
#define CONSDEV_COM0 1
#define CONSDEV_COM1 2
#define CONSDEV_COM2 3
Index: lib/pcio.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/stand/lib/pcio.c,v
retrieving revision 1.30
diff -U4 -r1.30 pcio.c
--- lib/pcio.c 8 Jun 2011 16:04:40 -0000 1.30
+++ lib/pcio.c 31 Jul 2019 01:58:16 -0000
@@ -106,9 +106,9 @@
#endif
}
void
-initio(int dev)
+initio(int dev, char *devname)
{
#ifdef SUPPORT_SERIAL
int i;
@@ -218,14 +218,17 @@
break;
}
conputc('\015');
conputc('\n');
- strncpy(btinfo_console.devname, iodev == CONSDEV_PC ? "pc" :
"com", 16);
+
+ if (devname == NULL)
+ devname = (iodev == CONSDEV_PC) ? "pc" : "com";
+ strncpy(btinfo_console.devname, devname, 16);
#else /* !SUPPORT_SERIAL */
- btinfo_console.devname[0] = 'p';
- btinfo_console.devname[1] = 'c';
- btinfo_console.devname[2] = 0;
+ if (devname == NULL)
+ devname = "pc";
+ strncpy(btinfo_console.devname, devname, 16);
#endif /* SUPPORT_SERIAL */
}
static inline void internal_putchar(int);
Index: netboot/main.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/stand/netboot/main.c,v
retrieving revision 1.18
diff -U4 -r1.18 main.c
--- netboot/main.c 20 Dec 2010 01:12:44 -0000 1.18
+++ netboot/main.c 31 Jul 2019 01:58:16 -0000
@@ -89,9 +89,9 @@
main(void)
{
char c;
- initio(CONSDEV_AUTO);
+ initio(CONSDEV_AUTO, NULL);
gateA20();
print_banner();
Index: pxeboot/main.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/stand/pxeboot/main.c,v
retrieving revision 1.31
diff -U4 -r1.31 main.c
--- pxeboot/main.c 28 Jun 2014 09:16:18 -0000 1.31
+++ pxeboot/main.c 31 Jul 2019 01:58:16 -0000
@@ -128,11 +128,11 @@
twiddle_toggle = 1; /* no twiddling until we're ready */
#ifdef SUPPORT_SERIAL
- initio(SUPPORT_SERIAL);
+ initio(SUPPORT_SERIAL, NULL);
#else
- initio(CONSDEV_PC);
+ initio(CONSDEV_PC, NULL);
#endif
gateA20();
boot_modules_enabled = !(boot_params.bp_flags
& X86_BP_FLAGS_NOMODULES);
@@ -252,14 +252,16 @@
const struct cons_devs *cdp;
for (cdp = cons_devs; cdp->name; cdp++) {
if (!strcmp(arg, cdp->name)) {
- initio(cdp->tag);
+ initio(cdp->tag, NULL);
print_banner();
return;
}
}
- printf("invalid console device.\n");
+ printf("unkown console device.\n");
+ initio(CONSDEV_PC, arg);
+ return;
}
void
command_modules(char *arg)
{
--
Emmanuel Dreyfus
http://hcpnet.free.fr/pubz
manu%netbsd.org@localhost
Home |
Main Index |
Thread Index |
Old Index