serial console support
cover serial console support
Hi,
After a looong break finally the next round
of the seabios serial console patches.
cheers,
Gerd
Gerd Hoffmann (7):
std: add cp437 to unicode map
kbd: make enqueue_key public, add ascii_to_keycode
paravirt: read QEMU_CFG_NOGRAPHIC, store in etc/sercon-enable romfile add serial console support
sercon: split-output implementation
sercon: add compile time option
[hack] ignore sgabios, enable sercon instead
Makefile | 3 +- src/Kconfig | 5 + src/clock.c | 1 + src/cp437.c | 275 +++++++++++++++++++++++ src/cp437.h | 1 + src/fw/paravirt.c | 2 + src/kbd.c | 18 +- src/misc.c | 2 + src/optionroms.c | 17 +- src/romlayout.S | 14 ++ src/sercon.c | 660 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/util.h | 5 + 12 files changed, 999 insertions(+), 4 deletions(-) create mode 100644 src/cp437.c create mode 100644 src/cp437.h create mode 100644 src/sercon.c
Signature · 1 line
1.8.3.1
PATCH 1/7 std: add cp437 to unicode map
--- Makefile | 1 + src/cp437.c | 275 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/cp437.h | 1 + 3 files changed, 277 insertions(+) create mode 100644 src/cp437.c create mode 100644 src/cp437.h
Makefile +1 -0
@@ -30,6 +30,7 @@ LD32BIT_FLAG:=-melf_i386 # Source files SRCBOTH=misc.c stacks.c output.c string.c block.c cdrom.c disk.c mouse.c kbd.c \ system.c serial.c clock.c resume.c pnpbios.c vgahooks.c pcibios.c apm.c \ + cp437.c \ hw/pci.c hw/timer.c hw/rtc.c hw/dma.c hw/pic.c hw/ps2port.c hw/serialio.c \ hw/usb.c hw/usb-uhci.c hw/usb-ohci.c hw/usb-ehci.c \ hw/usb-hid.c hw/usb-msc.c hw/usb-uas.c \
src/cp437.c new file +275 -0
275 lines not on this page · raw message
src/cp437.h new file +1 -0
@@ -0,0 +1 @@ +u16 cp437_to_unicode (u8 cp437);
Signature · 1 line
1.8.3.1
PATCH 2/7 kbd: make enqueue_key public, add ascii_to_keycode
In reply to Gerd Hoffmannserial console wants queue key events and needs to map ascii chars to the keycode, so make enqueue_key public and also exports a helper function so sercon can use the scan_to_keycode mapping table.
--- src/kbd.c | 18 +++++++++++++++++- src/util.h | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-)
src/kbd.c +17 -1
@@ -29,7 +29,7 @@ kbd_init(void) , x + FIELD_SIZEOF(struct bios_data_area_s, kbd_buf)); } -static u8 +u8 enqueue_key (u16 keycode) {u16 buffer_start =GET_BDA (kbd_buf_start_offset);
@@ -375,6 +375,22 @@ struct scaninfo key_ext_slash VAR16 = {0xe02f ,0xe02f ,0x9500 ,0xa400 }; +u16 ascii_to_keycode (u8 ascii) +{ +int i; + +for (i =0 ; i <ARRAY_SIZE (scan_to_keycode); i++) { +if ((GET_GLOBAL (scan_to_keycode[i].normal) &0xff ) == ascii) +return GET_GLOBAL (scan_to_keycode[i].normal); +if ((GET_GLOBAL (scan_to_keycode[i].shift) &0xff ) == ascii) +return GET_GLOBAL (scan_to_keycode[i].shift); +if ((GET_GLOBAL (scan_to_keycode[i].control) &0xff ) == ascii) +return GET_GLOBAL (scan_to_keycode[i].control); + } +return 0 ; +} + +// Handle a ps2 style scancode read from the keyboard. static void kbd_set_flag (int key_release,u16 set_bit0,u8 set_bit1,u16 toggle_bit) {
src/util.h +2 -0
@@ -185,6 +185,8 @@ int jpeg_show(struct jpeg_decdata *jpeg, unsigned char *pic, int widthvoid kbd_init (void );void handle_15c2 (struct bregs *regs);void process_key (u8 key); +u8 enqueue_key (u16 keycode); +u16 ascii_to_keycode (u8 ascii);// misc.c extern int HaveRunPost;
Signature · 1 line
1.8.3.1
PATCH 3/7 paravirt: read QEMU_CFG_NOGRAPHIC, store in etc/sercon-enable romfile
In reply to Gerd HoffmannWill be used as runtime switch to enable serial console support.
--- src/fw/paravirt.c | 2 ++ 1 file changed, 2 insertions(+)
src/fw/paravirt.c +2 -0
@@ -201,6 +201,7 @@ qemu_platform_setup(void)#define QEMU_CFG_SIGNATURE 0x00#define QEMU_CFG_ID 0x01#define QEMU_CFG_UUID 0x02 +#define QEMU_CFG_NOGRAPHIC 0x04#define QEMU_CFG_NUMA 0x0d#define QEMU_CFG_BOOT_MENU 0x0e#define QEMU_CFG_MAX_CPUS 0x0f
@@ -418,6 +419,7 @@ qemu_cfg_legacy(void)qemu_romfile_add ("etc/show-boot-menu" ,QEMU_CFG_BOOT_MENU ,0 ,2 );qemu_romfile_add ("etc/irq0-override" ,QEMU_CFG_IRQ0_OVERRIDE ,0 ,1 );qemu_romfile_add ("etc/max-cpus" ,QEMU_CFG_MAX_CPUS ,0 ,2 ); +qemu_romfile_add ("etc/sercon-enable" ,QEMU_CFG_NOGRAPHIC ,0 ,2 );// NUMA data u64 numacount;
Signature · 1 line
1.8.3.1
PATCH 4/7 add serial console support
In reply to Gerd HoffmannRedirect int10 calls to serial console output.
Parse serial input and queue key events.
--- Makefile | 2 +- src/clock.c | 1 + src/misc.c | 2 + src/optionroms.c | 7 +- src/sercon.c | 595 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/util.h | 3 + 6 files changed, 608 insertions(+), 2 deletions(-) create mode 100644 src/sercon.c
Makefile +1 -1
@@ -29,7 +29,7 @@ LD32BIT_FLAG:=-melf_i386 # Source files SRCBOTH=misc.c stacks.c output.c string.c block.c cdrom.c disk.c mouse.c kbd.c \ - system.c serial.c clock.c resume.c pnpbios.c vgahooks.c pcibios.c apm.c \ + system.c serial.c sercon.c clock.c resume.c pnpbios.c vgahooks.c pcibios.c apm.c \ cp437.c \ hw/pci.c hw/timer.c hw/rtc.c hw/dma.c hw/pic.c hw/ps2port.c hw/serialio.c \ hw/usb.c hw/usb-uhci.c hw/usb-ohci.c hw/usb-ehci.c \
src/clock.c +1 -0
@@ -295,6 +295,7 @@ clock_update(void)floppy_tick ();usb_check_event ();ps2_check_event (); +sercon_check_event (); }// INT 08h System Timer ISR Entry Point
src/misc.c +2 -0
@@ -11,6 +11,7 @@#include "output.h" // debug_enter #include "stacks.h" // call16_int #include "string.h" // memset +#include "util.h" // serial_10 #define PORT_MATH_CLEAR 0x00f0
@@ -57,6 +58,7 @@ handle_10(struct bregs *regs) {debug_enter (regs,DEBUG_HDL_10 );// don't do anything, since the VGA BIOS handles int10h requests +sercon_10 (regs); }// NMI handler
src/optionroms.c +6 -1
@@ -432,9 +432,14 @@ vgarom_setup(void)run_file_roms ("vgaroms/" ,1 ,NULL );rom_reserve (0 ); -if (rom_get_last () ==BUILD_ROM_START ) +if (rom_get_last () ==BUILD_ROM_START ) {// No VGA rom found +if (romfile_loadint ("etc/sercon-enable" ,0 )) { +sercon_enable (); +enable_vga_console (); + }return ; + } VgaROM = (void *)BUILD_ROM_START ;enable_vga_console ();
src/sercon.c new file +595 -0
595 lines not on this page · raw message
src/util.h +3 -0
@@ -233,6 +233,9 @@ void code_mutable_preinit(void);// serial.c void serial_setup (void );void lpt_setup (void ); +void sercon_10 (struct bregs *regs); +void sercon_enable (void ); +void sercon_check_event (void );// version.c extern const char VERSION [],BUILDINFO [];
Signature · 1 line
1.8.3.1
PATCH 5/7 sercon: split-output implementation
In reply to Gerd HoffmannAllows to run the serial console in parallel with a vga display. Output will show up on both vga and serial line.
Input will be accepted from both keyboard and serial line.
--- src/optionroms.c | 2 ++ src/romlayout.S | 14 +++++++++ src/sercon.c | 95 ++++++++++++++++++++++++++++++++++++++++++++------------ 3 files changed, 91 insertions(+), 20 deletions(-)
src/optionroms.c +2 -0
@@ -442,6 +442,8 @@ vgarom_setup(void) } VgaROM = (void *)BUILD_ROM_START ; +if (romfile_loadint ("etc/sercon-enable" ,0 )) +sercon_enable ();enable_vga_console (); }
src/romlayout.S +14 -0
@@ -524,6 +524,20 @@ irqentry_arg: DECL_IRQ_ENTRY hwpic1 DECL_IRQ_ENTRY hwpic2 + // hooked int10, for sercon + DECLFUNC entry_10_hooked +entry_10_hooked: + // Setup for iretw in irqentry_arg + pushfw + pushl %cs:sercon_int10_hook_resume + + pushl $sercon_10_splitmode +#if CONFIG_ENTRY_EXTRASTACK + jmp irqentry_arg_extrastack +#else + jmp irqentry_arg +#endif + // int 18/19 are special - they reset stack and call into 32bit mode. DECLFUNC entry_19 entry_19:
src/sercon.c +75 -20
170 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 6/7 sercon: add compile time option
In reply to Gerd Hoffmann--- src/Kconfig | 5 +++++ src/sercon.c | 10 ++++++++++ 2 files changed, 15 insertions(+)
src/Kconfig +5 -0
@@ -300,6 +300,11 @@ menu "Hardware support" default y help Support serial ports. This also enables int 14 serial port calls. + config SERCON + bool "Serial console" + default y + help + Support redirecting vga output to the serial console. config LPT bool "Parallel port" default y
src/sercon.c +10 -0
@@ -456,6 +456,8 @@ static void sercon_10XX(struct bregs *regs) void VISIBLE16sercon_10 (struct bregs *regs) { +if (!CONFIG_SERCON ) +return ;if (!GET_LOW (sercon_port))return ;
@@ -477,6 +479,8 @@ sercon_10(struct bregs *regs) void VISIBLE16sercon_10_splitmode (struct bregs *regs) { +if (!CONFIG_SERCON ) +return ;if (!GET_LOW (sercon_port))return ;
@@ -499,6 +503,9 @@ sercon_10_splitmode(struct bregs *regs)void sercon_enable (void ) { +if (!CONFIG_SERCON ) +return ; +struct segoff_s seabios, vgabios;u16 addr =PORT_SERIAL1 ;
@@ -596,6 +603,9 @@ static int findseq(void)void sercon_check_event (void ) { +if (!CONFIG_SERCON ) +return ; +u16 addr =GET_LOW (sercon_port);u16 keycode;u8 byte, count =0 ;
Signature · 1 line
1.8.3.1
PATCH 7/7 ignore sgabios, enable sercon instead
In reply to Gerd HoffmannTemporary, for testing convinience.
--- src/optionroms.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
src/optionroms.c +9 -3
@@ -23,7 +23,7 @@#include "tcgbios.h" // tpm_* static int EnforceChecksum, S3ResumeVga, RunPCIroms; - +static int sgabios;/**************************************************************** * Helper functions
@@ -193,6 +193,12 @@ run_file_roms(const char *prefix, int isvga, u64 *sources) file =romfile_findprefix (prefix, file);if (!file)break ; +if (strcmp (file->name,"vgaroms/sgabios.bin" ) ==0 ) { +dprintf (1 ,"sgabios.bin found -> ignoring, enabling sercon instead.\n" ); +dprintf (1 ,"hint: use '-machine graphics=no' instead of '-device sga'.\n" ); + sgabios++; +continue ; + }struct rom_header *rom =deploy_romfile (file);if (rom) {setRomSource (sources, rom, (u32 )file);
@@ -434,7 +440,7 @@ vgarom_setup(void)if (rom_get_last () ==BUILD_ROM_START ) {// No VGA rom found -if (romfile_loadint ("etc/sercon-enable" ,0 )) { +if (romfile_loadint ("etc/sercon-enable" ,0 ) || sgabios) {sercon_enable ();enable_vga_console (); }
@@ -442,7 +448,7 @@ vgarom_setup(void) } VgaROM = (void *)BUILD_ROM_START ; -if (romfile_loadint ("etc/sercon-enable" ,0 )) +if (romfile_loadint ("etc/sercon-enable" ,0 ) || sgabios)sercon_enable ();enable_vga_console (); }
Signature · 1 line
1.8.3.1
Quoted 4 lines · Gerd Hoffmann
Hi,
After a looong break finally the next round
of the seabios serial console patches.
Hi Gerd,
Sorry for the delay in responding.
I ran some tests on your series and it looks like it causes issues with some systems that are picky about the vgabios.
It looks like it tickles the skifree bug. Test case is windows vista running the ancient dos program skifree. When we last investigated this, it looked like anything in the vgabios path that tries to write to memory above 0xc0000 causes problems. The SeaBIOS extra stack is in that range by default.
It originally looked like old versions of x86emu were working. But when I apply a trivial debugging patch (see below) I then find I can't start X. Test case is an old fedora13 image. I suspect that random code movement could cause x86emu to sometimes hit a problematic instruction and sometimes not.
I don't see these issues with sgabios.
-Kevin
src/sercon.c +1 -0
@@ -483,6 +483,7 @@ sercon_10_splitmode(struct bregs *regs)return ;if (!GET_LOW (sercon_port))return ; +dprintf (1 ,"here\n" );switch (regs->ah) {case 0x01 :