Implement memcpy_far and checksum_far, and replace _fl variants.
[seabios.git] / src / system.c
index 6615b31c4eb05ff3080110e5cb36a69dda6f2e3c..798dc25cb3fac9e4fa2fd5f8135c1781ccef9c01 100644 (file)
@@ -1,9 +1,9 @@
-// 16bit system callbacks
+// Handler for int 0x15 "system" calls
 //
 // Copyright (C) 2008  Kevin O'Connor <kevin@koconnor.net>
 // Copyright (C) 2002  MandrakeSoft S.A.
 //
-// This file may be distributed under the terms of the GNU GPLv3 license.
+// This file may be distributed under the terms of the GNU LGPLv3 license.
 
 #include "util.h" // irq_restore
 #include "biosvar.h" // BIOS_CONFIG_TABLE
@@ -191,7 +191,7 @@ handle_1587(struct bregs *regs)
 static void
 handle_1588(struct bregs *regs)
 {
-    u32 rs = GET_EBDA(ram_size);
+    u32 rs = GET_GLOBAL(RamSize);
 
     // According to Ralf Brown's interrupt the limit should be 15M,
     // but real machines mostly return max. 63M.
@@ -232,7 +232,7 @@ handle_15c0(struct bregs *regs)
 static void
 handle_15c1(struct bregs *regs)
 {
-    regs->es = GET_BDA(ebda_seg);
+    regs->es = get_ebda_seg();
     set_success(regs);
 }
 
@@ -246,7 +246,7 @@ handle_15e801(struct bregs *regs)
     // regs.u.r16.ax = 0;
     // regs.u.r16.bx = 0;
 
-    u32 rs = GET_EBDA(ram_size);
+    u32 rs = GET_GLOBAL(RamSize);
 
     // Get the amount of extended memory (above 1M)
     if (rs > 16*1024*1024) {
@@ -266,11 +266,9 @@ handle_15e801(struct bregs *regs)
     set_success(regs);
 }
 
-#if MODE16
 // Info on e820 map location and size.
-struct e820entry *e820_list VISIBLE16;
-int e820_count VISIBLE16;
-#endif
+struct e820entry e820_list[CONFIG_MAX_E820] VAR16_32;
+int e820_count VAR16_32;
 
 static void
 handle_15e820(struct bregs *regs)
@@ -281,14 +279,15 @@ handle_15e820(struct bregs *regs)
         return;
     }
 
-    struct e820entry *l = GET_GLOBAL(e820_list);
-    memcpy_far(MAKE_FARPTR(regs->es, regs->di), &l[regs->bx], sizeof(l[0]));
+    memcpy_far(regs->es, (void*)(regs->di+0)
+               , get_global_seg(), &e820_list[regs->bx]
+               , sizeof(e820_list[0]));
     if (regs->bx == count-1)
         regs->ebx = 0;
     else
         regs->ebx++;
     regs->eax = 0x534D4150;
-    regs->ecx = sizeof(l[0]);
+    regs->ecx = sizeof(e820_list[0]);
     set_success(regs);
 }
 
@@ -338,66 +337,3 @@ handle_15(struct bregs *regs)
     default:   handle_15XX(regs); break;
     }
 }
-
-// INT 12h Memory Size Service Entry Point
-void VISIBLE16
-handle_12(struct bregs *regs)
-{
-    debug_enter(regs, DEBUG_HDL_12);
-    regs->ax = GET_BDA(mem_size_kb);
-}
-
-// INT 11h Equipment List Service Entry Point
-void VISIBLE16
-handle_11(struct bregs *regs)
-{
-    debug_enter(regs, DEBUG_HDL_11);
-    regs->ax = GET_BDA(equipment_list_flags);
-}
-
-// INT 05h Print Screen Service Entry Point
-void VISIBLE16
-handle_05(struct bregs *regs)
-{
-    debug_enter(regs, DEBUG_HDL_05);
-}
-
-// INT 10h Video Support Service Entry Point
-void VISIBLE16
-handle_10(struct bregs *regs)
-{
-    debug_enter(regs, DEBUG_HDL_10);
-    // dont do anything, since the VGA BIOS handles int10h requests
-}
-
-void VISIBLE16
-handle_nmi()
-{
-    debug_isr(DEBUG_ISR_nmi);
-    BX_PANIC("NMI Handler called\n");
-}
-
-void
-mathcp_setup()
-{
-    dprintf(3, "math cp init\n");
-    // 80x87 coprocessor installed
-    SETBITS_BDA(equipment_list_flags, 0x02);
-    enable_hwirq(13, entry_75);
-}
-
-// INT 75 - IRQ13 - MATH COPROCESSOR EXCEPTION
-void VISIBLE16
-handle_75()
-{
-    debug_isr(DEBUG_ISR_75);
-
-    // clear irq13
-    outb(0, PORT_MATH_CLEAR);
-    // clear interrupt
-    eoi_pic2();
-    // legacy nmi call
-    struct bregs br;
-    memset(&br, 0, sizeof(br));
-    call16_int(0x02, &br);
-}