firmware: Add .get_serial_console_info
authorMatt Fleming <matt.fleming@intel.com>
Fri, 20 Jan 2012 15:35:49 +0000 (15:35 +0000)
committerMatt Fleming <matt.fleming@intel.com>
Thu, 2 Feb 2012 16:11:31 +0000 (16:11 +0000)
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
com32/include/syslinux/firmware.h
com32/lib/syslinux/firmware.c
com32/lib/syslinux/serial.c
core/conio.c
efi/main.c

index 355cf04..5938a65 100644 (file)
@@ -28,6 +28,7 @@ struct firmware {
        struct output_ops *o_ops;
        struct input_ops *i_ops;
        char *(*get_config_file_name)(void);
+       void (*get_serial_console_info)(uint16_t *, uint16_t *, uint16_t *);
 };
 
 extern struct firmware *firmware;
index af57a05..f5765b6 100644 (file)
@@ -36,6 +36,7 @@ struct input_ops bios_input_ops = {
 };
 
 extern char *bios_get_config_file_name(void);
+extern void bios_get_serial_console_info(uint16_t *, uint16_t *, uint16_t *);
 
 struct firmware bios_fw = {
        .init = bios_init,
@@ -46,6 +47,7 @@ struct firmware bios_fw = {
        .o_ops = &bios_output_ops,
        .i_ops = &bios_input_ops,
        .get_config_file_name = bios_get_config_file_name,
+       .get_serial_console_info = bios_get_serial_console_info,
 };
 
 void syslinux_register_bios(void)
index f06e8c8..4c6c199 100644 (file)
  */
 
 #include <klibc/compiler.h>
+#include <syslinux/firmware.h>
 #include <syslinux/config.h>
 #include <string.h>
 #include <com32.h>
 
 struct syslinux_serial_console_info __syslinux_serial_console_info;
 
-void __constructor __syslinux_get_serial_console_info(void)
+void bios_get_serial_console_info(uint16_t *iobase, uint16_t *divisor,
+                                 uint16_t *flowctl)
 {
     static com32sys_t reg;
 
@@ -46,7 +48,18 @@ void __constructor __syslinux_get_serial_console_info(void)
     reg.eax.w[0] = 0x000b;
     __intcall(0x22, &reg, &reg);
 
-    __syslinux_serial_console_info.iobase = reg.edx.w[0];
-    __syslinux_serial_console_info.divisor = reg.ecx.w[0];
-    __syslinux_serial_console_info.flowctl = reg.ebx.w[0];
+    *iobase = reg.edx.w[0];
+    *divisor = reg.ecx.w[0];
+    *flowctl = reg.ebx.w[0];
+}
+
+void __constructor __syslinux_get_serial_console_info(void)
+{
+       uint16_t iobase, divisor, flowctl;
+
+       firmware->get_serial_console_info(&iobase, &divisor, &flowctl);
+
+       __syslinux_serial_console_info.iobase = iobase;
+       __syslinux_serial_console_info.divisor = divisor;
+       __syslinux_serial_console_info.flowctl = flowctl;
 }
index 860aabc..e18f0c7 100644 (file)
@@ -153,12 +153,12 @@ void pm_write_serial(com32sys_t *regs)
        write_serial(regs->eax.b[0]);
 }
 
-void pm_serialcfg(com32sys_t *regs)
+void serialcfg(uint16_t *iobase, uint16_t *divisor, uint16_t *flowctl)
 {
        uint8_t al, ah;
 
-       regs->eax.w[0] = SerialPort;
-       regs->ecx.w[0] = BaudDivisor;
+       *iobase = SerialPort;
+       *divisor = BaudDivisor;
 
        al = FlowOutput;
        ah = FlowInput;
@@ -170,7 +170,12 @@ void pm_serialcfg(com32sys_t *regs)
        if (!DisplayCon)
                ah |= 0x80;
 
-       regs->ebx.w[0] = al | (ah << 8);
+       *flowctl = al | (ah << 8);
+}
+
+void pm_serialcfg(com32sys_t *regs)
+{
+       serialcfg(&regs->eax.w[0], &regs->ecx.w[0], &regs->ebx.w[0]);
 }
 
 static void write_serial_displaymask(char data)
index 5b42258..c7354e1 100644 (file)
@@ -254,6 +254,8 @@ char *efi_get_config_file_name(void)
 }
 
 extern struct disk *efi_disk_init(com32sys_t *);
+extern void serialcfg(uint16_t *, uint16_t *, uint16_t *);
+
 struct firmware efi_fw = {
        .init = efi_init,
        .scan_memory = efi_scan_memory,
@@ -261,6 +263,7 @@ struct firmware efi_fw = {
        .o_ops = &efi_ops,
        .i_ops = &efi_iops,
        .get_config_file_name = efi_get_config_file_name,
+       .get_serial_console_info = serialcfg,
 };
 
 static inline void syslinux_register_efi(void)