--- rombios.c.orig	2003-04-20 00:18:00.000000000 +0900
+++ rombios.c	2003-05-12 16:49:06.000000000 +0900
@@ -59,6 +59,12 @@
 // $fff5 ; ASCII Date ROM was built - 8 characters in MM/DD/YY
 // $fffe ; System Model ID
 
+// NOTES for ADLO & serial debug (hcyun@etri.re.kr)
+//   - Messages can be seen in the serial console (SERIAL_DEBUG)
+//   - Can boot with/without VGABIOS. (SKIP_VGABIOS).
+//     int10 handler direct output to serial terminal. Therefore
+//     you will see LILO message from serial termial. 
+
 // NOTES for ATA/ATAPI driver (cbbochs@free.fr)
 //   Features
 //     - supports up to 4 ATA interfaces
@@ -129,9 +135,13 @@
 //
 //   BCC Bug: find a generic way to handle the bug of #asm after an "if"  (fixed in 0.16.7)
 
+#define SKIP_VGABIOS       1
+#define SERIAL_DEBUG       1
+
 #define DEBUG_ROMBIOS      1
 
 #define DEBUG_ATA          1
+#define DEBUG_INT10        0 
 #define DEBUG_INT13_HD     0
 #define DEBUG_INT13_CD     0
 #define DEBUG_INT13_ET     0
@@ -968,6 +978,11 @@
 #else
 #  define BX_DEBUG_ATA(a...)
 #endif
+#if DEBUG_INT10 // hcyun 
+#  define BX_DEBUG_INT10(a...) BX_DEBUG(##a)
+#else
+#  define BX_DEBUG_INT10(a...)
+#endif 
 #if DEBUG_INT13_HD
 #  define BX_DEBUG_INT13_HD(a...) BX_DEBUG(##a)
 #else
@@ -1424,18 +1439,77 @@
   pop  bp
   ASM_END
 }
- 
-  void
+
+
+#if SERIAL_DEBUG
+
+/* Data */
+#define UART_RBR 0x00
+#define UART_TBR 0x00
+
+/* Control */
+#define UART_IER 0x01
+#define UART_IIR 0x02
+#define UART_FCR 0x02
+#define UART_LCR 0x03
+#define UART_MCR 0x04
+#define UART_DLL 0x00
+#define UART_DLM 0x01
+
+/* Status */
+#define UART_LSR 0x05
+#define UART_MSR 0x06
+#define UART_SCR 0x07
+
+int uart_can_tx_byte(base_port)
+     Bit16u base_port; 
+{
+	return inb(base_port + UART_LSR) & 0x20;
+}
+
+void uart_wait_to_tx_byte(base_port)
+     Bit16u base_port;      
+{
+	while(!uart_can_tx_byte(base_port))
+		;
+}
+
+void uart_wait_until_sent(base_port)
+     Bit16u base_port;      
+{
+	while(!(inb(base_port + UART_LSR) & 0x40)) 
+		;
+}
+
+void uart_tx_byte(base_port, data)
+     Bit16u base_port; 
+     Bit8u  data;      
+{
+  uart_wait_to_tx_byte(base_port);
+  outb(base_port + UART_TBR, data);
+  /* Make certain the data clears the fifos */
+  uart_wait_until_sent(base_port);
+}
+
+#endif // SERIAL_DEBUG 
+
+void
 send(action, c)
   Bit16u action;
   Bit8u  c;
 {
+
+#if SERIAL_DEBUG // hcyun
+  if ( c == '\n') uart_tx_byte(0x3f8, '\r'); 
+  uart_tx_byte(0x3f8, c);
+#else
   if (action & BIOS_PRINTF_DEBUG) outb(DEBUG_PORT, c);
   if (action & BIOS_PRINTF_INFO) outb(INFO_PORT, c);
   if (action & BIOS_PRINTF_SCREEN) {
     if (c == '\n') wrch('\r');
     wrch(c);
-    }
+  }
+#endif 
 }
 
   void
@@ -7160,6 +7234,33 @@
 #endif
 }
 
+#if SKIP_VGABIOS 
+void
+int10_function(regs, ds, iret_addr)
+     pusha_regs_t regs;
+     Bit16u ds;
+     iret_addr_t iret_addr;
+{
+  switch ( regs.u.r8.ah ) {
+  case 0x0e: // put char 
+    printf("%c", regs.u.r8.al ); 
+    break;
+  case 0x0f: // get video mode
+    BX_DEBUG_INT10("int10 AX=%04x: get video mode \n", regs.u.r16.ax);
+    break;
+  case 0x03: // get cursor & video size 
+    BX_DEBUG_INT10("int10 AX=%04x: get cursor & video size \n", regs.u.r16.ax);
+    break;
+  case 0x02: // set cursor position 
+    BX_DEBUG_INT10("int10 AX=%04x: set cursor position \n", regs.u.r16.ax);
+    break;
+  default:
+    BX_DEBUG_INT10("int10 AX=%04x\n",regs.u.r16.ax);
+    break;
+  } 
+}
+#endif // SKIP_VGABIOS 
+
   void
 int17_function(regs, ds, iret_addr)
   pusha_regs_t regs; // regs pushed from PUSHA instruction
@@ -9026,7 +9127,10 @@
 #endif
   out  0xa1, AL ;slave  pic: unmask IRQ 12, 13, 14
 
-
+#if SKIP_VGABIOS 
+  jmp skip_video 
+#endif
+		 
   ;; Scan for existence of valid expansion ROMS.
   ;;   Video ROM:   from 0xC0000..0xC7FFF in 2k increments
   ;;   General ROM: from 0xC8000..0xDFFFF in 2k increments
@@ -9079,6 +9183,10 @@
   xor  ax, ax   ;; Restore DS back to 0000:
   mov  ds, ax
 
+#if SKIP_VGABIOS 
+skip_video:
+#endif
+
   call _print_bios_banner 
 
   ;;
@@ -9490,9 +9598,19 @@
 ;----------
 .org 0xf065 ; INT 10h Video Support Service Entry Point
 int10_handler:
+#if SKIP_VGABIOS
+  push ds
+  pusha
+  mov  ax, #0x0000
+  mov  ds, ax
+  call _int10_function
+  popa
+  pop  ds
+  iret
+#else 
   ;; dont do anything, since the VGA BIOS handles int10h requests
   iret
-
+#endif
 .org 0xf0a4 ; MDA/CGA Video Parameter Table (INT 1Dh)
 
 ;----------
