Move pir table offset from ebda to a global variable.

Also, make sure the pir table is defined with the 16bit code.
diff --git a/Makefile b/Makefile
index 8faa1f4..24c67c2 100644
--- a/Makefile
+++ b/Makefile
@@ -10,11 +10,10 @@
 # Source files
 SRCBOTH=output.c util.c floppy.c ata.c system.c mouse.c kbd.c pci.c \
         serial.c clock.c pic.c cdrom.c ps2port.c smpdetect.c resume.c \
-        pnpbios.c
+        pnpbios.c pirtable.c
 SRC16=$(SRCBOTH) disk.c apm.c pcibios.c vgahooks.c
 SRC32=$(SRCBOTH) post.c shadow.c post_menu.c memmap.c coreboot.c boot.c \
-      acpi.c pirtable.c smm.c mptable.c smbios.c pciinit.c \
-      optionroms.c
+      acpi.c smm.c mptable.c smbios.c pciinit.c optionroms.c
 TABLESRC=font.c cbt.c floppy_dbt.c
 
 cc-option = $(shell if test -z "`$(1) $(2) -S -o /dev/null -xc \
diff --git a/src/biosvar.h b/src/biosvar.h
index 84c4628..bac978c 100644
--- a/src/biosvar.h
+++ b/src/biosvar.h
@@ -255,8 +255,6 @@
     u8 checksum;
 } PACKED;
 
-struct pir_header;
-
 struct extended_bios_data_area_s {
     u8 size;
     u8 reserved1[0x21];
@@ -279,7 +277,6 @@
     // Physical memory available.
     u32 ram_size;        // Amount of continuous ram under 4Gig
     u64 ram_size_over4G; // Amount of continuous ram >4Gig
-    struct pir_header *pir_loc;
 
     // ATA Driver data
     struct ata_s ata;
diff --git a/src/coreboot.c b/src/coreboot.c
index 8610d75..ac8cf33 100644
--- a/src/coreboot.c
+++ b/src/coreboot.c
@@ -21,7 +21,7 @@
     struct pir_header *p = pos;
     if (p->signature != PIR_SIGNATURE)
         return;
-    if (GET_EBDA(pir_loc))
+    if (PirOffset)
         return;
     if (p->size < sizeof(*p))
         return;
@@ -34,7 +34,7 @@
     }
     dprintf(1, "Copying PIR from %p to %x\n", pos, bios_table_cur_addr);
     memcpy((void*)bios_table_cur_addr, pos, p->size);
-    SET_EBDA(pir_loc, (void*)bios_table_cur_addr);
+    PirOffset = bios_table_cur_addr - BUILD_BIOS_ADDR;
     bios_table_cur_addr += p->size;
 }
 
diff --git a/src/pci.h b/src/pci.h
index 6623fd9..ab7cb9e 100644
--- a/src/pci.h
+++ b/src/pci.h
@@ -40,6 +40,8 @@
  * PIR table
  ****************************************************************/
 
+extern u16 PirOffset;
+
 struct link_info {
     u8 link;
     u16 bitmap;
diff --git a/src/pcibios.c b/src/pcibios.c
index e310b18..cdda347 100644
--- a/src/pcibios.c
+++ b/src/pcibios.c
@@ -127,15 +127,15 @@
 static void
 handle_1ab10e(struct bregs *regs)
 {
-    struct pir_header *pirtable_far = GET_EBDA(pir_loc);
-    if (! pirtable_far) {
+    struct pir_header *pirtable_g = (void*)(GET_GLOBAL(PirOffset) + 0);
+    if (! pirtable_g) {
         set_code_fail(regs, RET_FUNC_NOT_SUPPORTED);
         return;
     }
 
     // Validate and update size.
     u16 size = GET_FARVAR(regs->es, *(u16*)(regs->di+0));
-    u16 pirsize = (GET_FARPTR(pirtable_far->size)
+    u16 pirsize = (GET_GLOBAL(pirtable_g->size)
                    - sizeof(struct pir_header));
     SET_FARVAR(regs->es, *(u16*)(regs->di+0), pirsize);
     if (size < pirsize) {
@@ -148,10 +148,12 @@
     u16 destseg = GET_FARVAR(regs->es, *(u16*)(regs->di+4));
 
     // Memcpy pir table slots to dest buffer.
-    memcpy_far(MAKE_FARPTR(destseg, d), pirtable_far, pirsize);
+    memcpy_far(MAKE_FARPTR(destseg, d)
+               , MAKE_FARPTR(SEG_BIOS, pirtable_g)
+               , pirsize);
 
     // XXX - bochs bios sets bx to (1 << 9) | (1 << 11)
-    regs->bx = GET_FARPTR(pirtable_far->exclusive_irqs);
+    regs->bx = GET_GLOBAL(pirtable_g->exclusive_irqs);
     set_code_success(regs);
 }
 
diff --git a/src/pirtable.c b/src/pirtable.c
index 8e3c366..f776ee9 100644
--- a/src/pirtable.c
+++ b/src/pirtable.c
@@ -9,11 +9,16 @@
 #include "util.h" // checksum
 #include "biosvar.h" // SET_EBDA
 
+u16 PirOffset VAR16;
+
 struct pir_table {
     struct pir_header pir;
     struct pir_slot slots[6];
-} PACKED PIR_TABLE __aligned(16) = {
-#if CONFIG_PIRTABLE
+} PACKED;
+
+extern struct pir_table PIR_TABLE;
+#if CONFIG_PIRTABLE && !CONFIG_COREBOOT
+struct pir_table PIR_TABLE __aligned(16) VAR16 = {
     .pir = {
         .version = 0x0100,
         .size = sizeof(struct pir_table),
@@ -83,8 +88,8 @@
             .slot_nr = 5,
         },
     }
-#endif // CONFIG_PIRTABLE
 };
+#endif // CONFIG_PIRTABLE && !CONFIG_COREBOOT
 
 void
 create_pirtable()
@@ -96,5 +101,5 @@
 
     PIR_TABLE.pir.signature = PIR_SIGNATURE;
     PIR_TABLE.pir.checksum = -checksum((u8*)&PIR_TABLE, sizeof(PIR_TABLE));
-    SET_EBDA(pir_loc, &PIR_TABLE.pir);
+    PirOffset = (u32)&PIR_TABLE.pir - BUILD_BIOS_ADDR;
 }