Minor cleanups.

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.
diff --git a/src/biosvar.h b/src/biosvar.h
index 494b6a8..fe957e5 100644
--- a/src/biosvar.h
+++ b/src/biosvar.h
@@ -102,9 +102,9 @@
 
 // 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 @@
 
 // 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 @@
  ****************************************************************/
 
 #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)
 
diff --git a/src/config.h b/src/config.h
index 206fffa..57e2c56 100644
--- a/src/config.h
+++ b/src/config.h
@@ -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
diff --git a/src/disk.c b/src/disk.c
index effe226..1f17240 100644
--- a/src/disk.c
+++ b/src/disk.c
@@ -402,7 +402,7 @@
 
     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 @@
     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);
diff --git a/src/ioport.h b/src/ioport.h
index ba9117b..2392adf 100644
--- a/src/ioport.h
+++ b/src/ioport.h
@@ -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)
diff --git a/src/kbd.c b/src/kbd.c
index 29ef1b3..0e0dd5b 100644
--- a/src/kbd.c
+++ b/src/kbd.c
@@ -174,8 +174,8 @@
     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 @@
         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 @@
             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 @@
         } 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;
diff --git a/src/post.c b/src/post.c
index e211bd4..5ba9a29 100644
--- a/src/post.c
+++ b/src/post.c
@@ -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 @@
 {
     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 @@
 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 @@
         fill_hdinfo(&ebda->fdpt0, CMOS_DISK_DRIVE2_TYPE, CMOS_DISK_DRIVE2_CYL);
 }
 
-
 static void
 init_boot_vectors()
 {
diff --git a/src/rombios32.c b/src/rombios32.c
index f1c10d2..28a6596 100644
--- a/src/rombios32.c
+++ b/src/rombios32.c
@@ -26,10 +26,14 @@
 
 #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
@@ -56,13 +60,9 @@
 
 #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 @@
 #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 @@
     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);
diff --git a/src/system.c b/src/system.c
index 0cd1c6e..51028f9 100644
--- a/src/system.c
+++ b/src/system.c
@@ -278,8 +278,6 @@
     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 @@
         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: