Minor cleanups.
authorKevin O'Connor <kevin@koconnor.net>
Mon, 31 Mar 2008 01:46:53 +0000 (21:46 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Mon, 31 Mar 2008 01:46:53 +0000 (21:46 -0400)
Rename EBDA_SEG to SEG_EBDA - it is more consistent with other defs.
Introduce SEG_BDA definition and use it instead of 0x0000 wherea appropriate.
Move ACPI_DATA_SIZE to CONFIG_ACPI_DATA_SIZE and move to config.h
Use an alias (PORT_HD_DATA) for io port 0x03f6.

src/biosvar.h
src/config.h
src/disk.c
src/ioport.h
src/kbd.c
src/post.c
src/rombios32.c
src/system.c

index 494b6a8a8d76c7143fc26fd10e3ca5d759dfdd7e..fe957e57304365676d15036108ae864b19534d28 100644 (file)
@@ -102,9 +102,9 @@ struct bios_data_area_s {
 
 // Accessor functions
 #define GET_BDA(var) \
-    GET_FARVAR(0x0000, ((struct bios_data_area_s *)0)->var)
+    GET_FARVAR(SEG_BDA, ((struct bios_data_area_s *)0)->var)
 #define SET_BDA(var, val) \
-    SET_FARVAR(0x0000, ((struct bios_data_area_s *)0)->var, (val))
+    SET_FARVAR(SEG_BDA, ((struct bios_data_area_s *)0)->var, (val))
 #define CLEARBITS_BDA(var, val) do {                                    \
         typeof(((struct bios_data_area_s *)0)->var) __val = GET_BDA(var); \
         SET_BDA(var, (__val & ~(val)));                                 \
@@ -269,9 +269,9 @@ struct extended_bios_data_area_s {
 
 // Accessor functions
 #define GET_EBDA(var) \
-    GET_FARVAR(EBDA_SEG, ((struct extended_bios_data_area_s *)0)->var)
+    GET_FARVAR(SEG_EBDA, ((struct extended_bios_data_area_s *)0)->var)
 #define SET_EBDA(var, val) \
-    SET_FARVAR(EBDA_SEG, ((struct extended_bios_data_area_s *)0)->var, (val))
+    SET_FARVAR(SEG_EBDA, ((struct extended_bios_data_area_s *)0)->var, (val))
 
 
 /****************************************************************
@@ -331,8 +331,9 @@ extern struct bios_config_table_s BIOS_CONFIG_TABLE;
  ****************************************************************/
 
 #define SEG_BIOS     0xf000
+#define SEG_EBDA     0x9fc0
+#define SEG_BDA      0x0000
 
-#define EBDA_SEG           0x9FC0
 #define EBDA_SIZE          1              // In KiB
 #define BASE_MEM_IN_K   (640 - EBDA_SIZE)
 
index 206fffae7f3cdeb9f950324e5f4070f08525d165..57e2c56321636763707e5738b9ac33d5ebc045b6 100644 (file)
@@ -16,6 +16,8 @@
 #define CONFIG_STACK_SEGMENT 0x00
 #define CONFIG_STACK_OFFSET  0xfffe
 
+#define CONFIG_ACPI_DATA_SIZE 0x00010000L
+
 #define CONFIG_MODEL_ID      0xFC
 #define CONFIG_SUBMODEL_ID   0x00
 #define CONFIG_BIOS_REVISION 0x01
index effe226e47a0f91079d9b7be8dbf92f4a3dbe2ca..1f172406420c1ce875039ab9eb486ff0885307bf 100644 (file)
@@ -402,7 +402,7 @@ disk_1348(struct bregs *regs, u8 device)
 
     SET_INT13DPT(regs, size, 0x1e);
 
-    SET_INT13DPT(regs, dpte_segment, EBDA_SEG);
+    SET_INT13DPT(regs, dpte_segment, SEG_EBDA);
     SET_INT13DPT(regs, dpte_offset
                  , offsetof(struct extended_bios_data_area_s, ata.dpte));
 
@@ -442,7 +442,7 @@ disk_1348(struct bregs *regs, u8 device)
     else
         SET_EBDA(ata.dpte.revision, 0x10);
 
-    u8 *p = MAKE_FARPTR(EBDA_SEG
+    u8 *p = MAKE_FARPTR(SEG_EBDA
                         , offsetof(struct extended_bios_data_area_s, ata.dpte));
     u8 sum = checksum(p, 15);
     SET_EBDA(ata.dpte.checksum, ~sum);
index ba9117b845812c261b7d5d20ff5121fc9022e8c4..2392adffdff2284af45f6ffb0f54139f083febe8 100644 (file)
@@ -37,6 +37,7 @@
 #define PORT_FD_DOR            0x03f2
 #define PORT_FD_STATUS         0x03f4
 #define PORT_FD_DATA           0x03f5
+#define PORT_HD_DATA           0x03f6
 
 // PORT_PIC1 bitdefs
 #define PIC1_IRQ5  (1<<5)
index 29ef1b3b97c104bdb89ff7f6c47965fdc88f6c5d..0e0dd5b7a2f6b1e7f46ea7fb1310d67e64c05178 100644 (file)
--- a/src/kbd.c
+++ b/src/kbd.c
@@ -174,8 +174,8 @@ enqueue_key(u8 scan_code, u8 ascii_code)
     if (buffer_tail == buffer_head)
         return 0;
 
-    SET_FARVAR(0x0000, *(u8*)(temp_tail+0x400+0), ascii_code);
-    SET_FARVAR(0x0000, *(u8*)(temp_tail+0x400+1), scan_code);
+    SET_FARVAR(SEG_BDA, *(u8*)(temp_tail+0x400+0), ascii_code);
+    SET_FARVAR(SEG_BDA, *(u8*)(temp_tail+0x400+1), scan_code);
     SET_BDA(kbd_buf_tail, buffer_tail);
     return 1;
 }
@@ -196,8 +196,8 @@ dequeue_key(u8 *scan_code, u8 *ascii_code, u8 incr)
         nop();
     }
 
-    *ascii_code = GET_FARVAR(0x0000, *(u8*)(buffer_head+0x400+0));
-    *scan_code  = GET_FARVAR(0x0000, *(u8*)(buffer_head+0x400+1));
+    *ascii_code = GET_FARVAR(SEG_BDA, *(u8*)(buffer_head+0x400+0));
+    *scan_code  = GET_FARVAR(SEG_BDA, *(u8*)(buffer_head+0x400+1));
 
     if (incr) {
         u16 buffer_start = GET_BDA(kbd_buf_start_offset);
@@ -639,7 +639,8 @@ process_key(u8 scancode)
             break; /* toss key releases ... */
         }
         if (scancode > MAX_SCAN_CODE) {
-            BX_INFO("KBD: int09h_handler(): unknown scancode read: 0x%02x!\n", scancode);
+            BX_INFO("KBD: int09h_handler(): unknown scancode read: 0x%02x!\n"
+                    , scancode);
             return;
         }
         u8 asciicode;
@@ -650,7 +651,8 @@ process_key(u8 scancode)
         } else if (shift_flags & 0x04) { /* CONTROL */
             asciicode = GET_VAR(CS, info->control);
             scancode = GET_VAR(CS, info->control) >> 8;
-        } else if (((mf2_state & 0x02) > 0) && ((scancode >= 0x47) && (scancode <= 0x53))) {
+        } else if ((mf2_state & 0x02) > 0
+                   && scancode >= 0x47 && scancode <= 0x53) {
             /* extended keys handling */
             asciicode = 0xe0;
             scancode = GET_VAR(CS, info->normal) >> 8;
index e211bd45426bc1a576149de3953dc236936d91cd..5ba9a2926ed3dc3c46de43e2d5c9caffc819d5dc 100644 (file)
@@ -14,8 +14,8 @@
 #include "ata.h"
 #include "kbd.h"
 
-#define bda ((struct bios_data_area_s *)0)
-#define ebda ((struct extended_bios_data_area_s *)(EBDA_SEG<<4))
+#define bda ((struct bios_data_area_s *)MAKE_FARPTR(SEG_BDA, 0))
+#define ebda ((struct extended_bios_data_area_s *)MAKE_FARPTR(SEG_EBDA, 0))
 
 static void
 init_bda()
@@ -69,11 +69,11 @@ init_ebda()
 {
     memset(ebda, 0, sizeof(*ebda));
     ebda->size = EBDA_SIZE;
-    SET_BDA(ebda_seg, EBDA_SEG);
-    SET_BDA(ivecs[0x41].seg, EBDA_SEG);
+    SET_BDA(ebda_seg, SEG_EBDA);
+    SET_BDA(ivecs[0x41].seg, SEG_EBDA);
     SET_BDA(ivecs[0x41].offset
             , offsetof(struct extended_bios_data_area_s, fdpt0));
-    SET_BDA(ivecs[0x46].seg, EBDA_SEG);
+    SET_BDA(ivecs[0x46].seg, SEG_EBDA);
     SET_BDA(ivecs[0x41].offset
             , offsetof(struct extended_bios_data_area_s, fdpt1));
 }
@@ -254,7 +254,7 @@ fill_hdinfo(struct fdpt_s *info, u8 typecmos, u8 basecmos)
 static void
 hard_drive_post()
 {
-    outb(0x0a, 0x03f6); // 0000 1010 = reserved, disable IRQ 14
+    outb(0x0a, PORT_HD_DATA); // 0000 1010 = reserved, disable IRQ 14
     SET_BDA(disk_count, 1);
     SET_BDA(disk_control_byte, 0xc0);
 
@@ -269,7 +269,6 @@ hard_drive_post()
         fill_hdinfo(&ebda->fdpt0, CMOS_DISK_DRIVE2_TYPE, CMOS_DISK_DRIVE2_CYL);
 }
 
-
 static void
 init_boot_vectors()
 {
index f1c10d278cf5972c8a083517bab2a1ae26fc81d4..28a65969b021170e285444b91da1356273f5f30f 100644 (file)
 
 #define BX_APPNAME "Bochs"
 
-#define ACPI_DATA_SIZE    0x00010000L
+// Memory addresses used by this code.  (Note global variables (bss)
+// are at 0x40000).
+#define CPU_COUNT_ADDR    0xf000
+#define AP_BOOT_ADDR      0x10000
+#define BIOS_TMP_STORAGE  0x30000 /* 64 KB used to copy the BIOS to shadow RAM */
+
 #define PM_IO_BASE        0xb000
 #define SMB_IO_BASE       0xb100
-#define CPU_COUNT_ADDR    0xf000
 
 /* if true, put the MP float table and ACPI RSDT in EBDA and the MP
    table in RAM. Unfortunately, Linux has bugs with that, so we prefer
 
 #define APIC_ENABLED 0x0100
 
-#define AP_BOOT_ADDR 0x10000
-
 #define MPTABLE_MAX_SIZE  0x00002000
 #define SMI_CMD_IO_ADDR   0xb2
 
-#define BIOS_TMP_STORAGE  0x00030000 /* 64 KB used to copy the BIOS to shadow RAM */
-
 static inline void writel(void *addr, u32 val)
 {
     *(volatile u32 *)addr = val;
@@ -651,7 +651,7 @@ static void mptable_init(void)
 #endif
 
 #ifdef BX_USE_EBDA_TABLES
-    mp_config_table = (u8 *)(ram_size - ACPI_DATA_SIZE - MPTABLE_MAX_SIZE);
+    mp_config_table = (u8 *)(ram_size - CONFIG_ACPI_DATA_SIZE - MPTABLE_MAX_SIZE);
 #else
     bios_table_cur_addr = align(bios_table_cur_addr, 16);
     mp_config_table = (u8 *)bios_table_cur_addr;
@@ -1071,7 +1071,7 @@ void acpi_bios_init(void)
     bios_table_cur_addr += sizeof(*rsdp);
 #endif
 
-    addr = base_addr = ram_size - ACPI_DATA_SIZE;
+    addr = base_addr = ram_size - CONFIG_ACPI_DATA_SIZE;
     rsdt_addr = addr;
     rsdt = (void *)(addr);
     addr += sizeof(*rsdt);
index 0cd1c6e4dc8f35975ab49a80761faf8f46d23e63..51028f9cf895b4de27745f48ef1835fecbd70165 100644 (file)
@@ -278,8 +278,6 @@ handle_15e801(struct bregs *regs)
     set_success(regs);
 }
 
-#define ACPI_DATA_SIZE    0x00010000L
-
 static void
 set_e820_range(struct bregs *regs, u32 start, u32 end, u16 type, int last)
 {
@@ -344,12 +342,13 @@ handle_15e820(struct bregs *regs)
         set_e820_range(regs, 0x000e8000L, 0x00100000L, E820_RESERVED, 0);
         break;
     case 3:
-        set_e820_range(regs, 0x00100000L,
-                       extended_memory_size - ACPI_DATA_SIZE, E820_RAM, 0);
+        set_e820_range(regs, 0x00100000L
+                       , extended_memory_size - CONFIG_ACPI_DATA_SIZE
+                       , E820_RAM, 0);
         break;
     case 4:
         set_e820_range(regs,
-                       extended_memory_size - ACPI_DATA_SIZE,
+                       extended_memory_size - CONFIG_ACPI_DATA_SIZE,
                        extended_memory_size, E820_ACPI, 0);
         break;
     case 5: