ia64/xen-unstable

changeset 18929:65bbc9ec3849

rombios: fix references to EBDA

Extended Bios Data Area (EBDA) can be relocated by the initialization
of PCI option ROM. The IPL boot table is also.
EBDA must be accessed via 0x40E after the initialization.

Signed-off-by: Kouya Shimura <kouya@jp.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Dec 15 11:23:22 2008 +0000 (2008-12-15)
parents 21bbb41f9af2
children f827181eadd4
files tools/firmware/rombios/rombios.c
line diff
     1.1 --- a/tools/firmware/rombios/rombios.c	Mon Dec 15 11:17:14 2008 +0000
     1.2 +++ b/tools/firmware/rombios/rombios.c	Mon Dec 15 11:23:22 2008 +0000
     1.3 @@ -181,8 +181,15 @@
     1.4    // EBDA is used for PS/2 mouse support, and IDE BIOS, etc.
     1.5  #define EBDA_SEG           0x9FC0
     1.6  #define EBDA_SIZE          1              // In KiB
     1.7 +#define EBDA_SEG_PTR       0x40E /* Find true EBDA segment at 0:40E */
     1.8  #define BASE_MEM_IN_K   (640 - EBDA_SIZE)
     1.9  
    1.10 +/* 256 bytes at 0x9ff00 -- 0x9ffff is used for the IPL boot table. */
    1.11 +#define IPL_TABLE_OFFSET     0x0300  /* offset from EBDA */
    1.12 +#define IPL_TABLE_ENTRIES    8
    1.13 +#define IPL_COUNT_OFFSET     0x0380  /* u16: number of valid table entries */
    1.14 +#define IPL_SEQUENCE_OFFSET  0x0382  /* u16: next boot device */
    1.15 +
    1.16    // Define the application NAME
    1.17  #ifdef HVMASSIST
    1.18  #  define BX_APPNAME "HVMAssist"
    1.19 @@ -1963,13 +1970,6 @@ print_bios_banner()
    1.20  // http://www.phoenix.com/en/Customer+Services/White+Papers-Specs/pc+industry+specifications.htm
    1.21  //--------------------------------------------------------------------------
    1.22  
    1.23 -/* 256 bytes at 0x9ff00 -- 0x9ffff is used for the IPL boot table. */
    1.24 -#define IPL_SEG              0x9ff0
    1.25 -#define IPL_TABLE_OFFSET     0x0000
    1.26 -#define IPL_TABLE_ENTRIES    8
    1.27 -#define IPL_COUNT_OFFSET     0x0080  /* u16: number of valid table entries */
    1.28 -#define IPL_SEQUENCE_OFFSET  0x0082  /* u16: next boot device */
    1.29 -
    1.30  struct ipl_entry {
    1.31    Bit16u type;
    1.32    Bit16u flags;
    1.33 @@ -1986,29 +1986,29 @@ init_boot_vectors()
    1.34    Bit16u ss = get_SS();
    1.35  
    1.36    /* Clear out the IPL table. */
    1.37 -  memsetb(IPL_SEG, IPL_TABLE_OFFSET, 0, 0xff);
    1.38 +  memsetb(EBDA_SEG, IPL_TABLE_OFFSET, 0, 0xff);
    1.39  
    1.40    /* Floppy drive */
    1.41    e.type = 1; e.flags = 0; e.vector = 0; e.description = 0; e.reserved = 0;
    1.42 -  memcpyb(IPL_SEG, IPL_TABLE_OFFSET + count * sizeof (e), ss, &e, sizeof (e));
    1.43 +  memcpyb(EBDA_SEG, IPL_TABLE_OFFSET + count * sizeof (e), ss, &e, sizeof (e));
    1.44    count++;
    1.45  
    1.46    /* First HDD */
    1.47    e.type = 2; e.flags = 0; e.vector = 0; e.description = 0; e.reserved = 0;
    1.48 -  memcpyb(IPL_SEG, IPL_TABLE_OFFSET + count * sizeof (e), ss, &e, sizeof (e));
    1.49 +  memcpyb(EBDA_SEG, IPL_TABLE_OFFSET + count * sizeof (e), ss, &e, sizeof (e));
    1.50    count++;
    1.51  
    1.52  #if BX_ELTORITO_BOOT
    1.53    /* CDROM */
    1.54    e.type = 3; e.flags = 0; e.vector = 0; e.description = 0; e.reserved = 0;
    1.55 -  memcpyb(IPL_SEG, IPL_TABLE_OFFSET + count * sizeof (e), ss, &e, sizeof (e));
    1.56 +  memcpyb(EBDA_SEG, IPL_TABLE_OFFSET + count * sizeof (e), ss, &e, sizeof (e));
    1.57    count++;
    1.58  #endif  
    1.59  
    1.60    /* Remember how many devices we have */
    1.61 -  write_word(IPL_SEG, IPL_COUNT_OFFSET, count);
    1.62 +  write_word(EBDA_SEG, IPL_COUNT_OFFSET, count);
    1.63    /* Not tried booting anything yet */
    1.64 -  write_word(IPL_SEG, IPL_SEQUENCE_OFFSET, 0xffff);
    1.65 +  write_word(EBDA_SEG, IPL_SEQUENCE_OFFSET, 0xffff);
    1.66  }
    1.67  
    1.68  static Bit8u
    1.69 @@ -2017,11 +2017,12 @@ Bit16u i; struct ipl_entry *e;
    1.70  {
    1.71    Bit16u count;
    1.72    Bit16u ss = get_SS();
    1.73 +  Bit16u ebda_seg = read_word(0x0040, 0x000E);
    1.74    /* Get the count of boot devices, and refuse to overrun the array */
    1.75 -  count = read_word(IPL_SEG, IPL_COUNT_OFFSET);
    1.76 +  count = read_word(ebda_seg, IPL_COUNT_OFFSET);
    1.77    if (i >= count) return 0;
    1.78    /* OK to read this device */
    1.79 -  memcpyb(ss, e, IPL_SEG, IPL_TABLE_OFFSET + i * sizeof (*e), sizeof (*e));
    1.80 +  memcpyb(ss, e, ebda_seg, IPL_TABLE_OFFSET + i * sizeof (*e), sizeof (*e));
    1.81    return 1;
    1.82  }
    1.83  
    1.84 @@ -2187,9 +2188,10 @@ int bootmenu(selected)
    1.85  {
    1.86      Bit8u scode;
    1.87      int max;
    1.88 +    Bit16u ebda_seg = read_word(0x0040, 0x000E);
    1.89  
    1.90      /* get the number of boot devices */
    1.91 -    max = read_word(IPL_SEG, IPL_COUNT_OFFSET);
    1.92 +    max = read_word(ebda_seg, IPL_COUNT_OFFSET);
    1.93  
    1.94      for(;;) {
    1.95          if (selected > max || selected < 1) selected = 1;
    1.96 @@ -2349,7 +2351,9 @@ s3_resume()
    1.97  ASM_START
    1.98      push ds
    1.99      push ax
   1.100 -    mov ax, #EBDA_SEG
   1.101 +    xor ax, ax
   1.102 +    mov ds, ax
   1.103 +    mov ax, word ptr [EBDA_SEG_PTR]
   1.104      mov ds, ax
   1.105      mov al, [EBDA_CMOS_SHUTDOWN_STATUS_OFFSET]
   1.106      mov .s3_resume.cmos_shutdown_status[bp], al
   1.107 @@ -8543,7 +8547,8 @@ int18_handler: ;; Boot Failure recovery:
   1.108    ;; Get the boot sequence number out of the IPL memory
   1.109    ;; The first time we do this it will have been set to -1 so 
   1.110    ;; we will start from device 0.
   1.111 -  mov  bx, #IPL_SEG 
   1.112 +  mov  ds, ax
   1.113 +  mov  bx, word ptr [EBDA_SEG_PTR]
   1.114    mov  ds, bx                     ;; Set segment
   1.115    mov  bx, IPL_SEQUENCE_OFFSET    ;; BX is now the sequence number
   1.116    inc  bx                         ;; ++
   1.117 @@ -8686,8 +8691,8 @@ hard_drive_post:
   1.118    SET_INT_VECTOR(0x76, #0xF000, #int76_handler)
   1.119    ;; INT 41h: hard disk 0 configuration pointer
   1.120    ;; INT 46h: hard disk 1 configuration pointer
   1.121 -  SET_INT_VECTOR(0x41, #EBDA_SEG, #0x003D)
   1.122 -  SET_INT_VECTOR(0x46, #EBDA_SEG, #0x004D)
   1.123 +  SET_INT_VECTOR(0x41, word ptr [EBDA_SEG_PTR], #0x003D)
   1.124 +  SET_INT_VECTOR(0x46, word ptr [EBDA_SEG_PTR], #0x004D)
   1.125  
   1.126    ;; move disk geometry data from CMOS to EBDA disk parameter table(s)
   1.127    mov  al, #0x12
   1.128 @@ -8716,7 +8721,9 @@ post_d0_type47:
   1.129    ;; 22    landing zone high        D
   1.130    ;; 23    sectors/track            E
   1.131  
   1.132 -  mov  ax, #EBDA_SEG
   1.133 +  xor  ax, ax
   1.134 +  mov  ds, ax
   1.135 +  mov  ax, word ptr [EBDA_SEG_PTR]
   1.136    mov  ds, ax
   1.137  
   1.138    ;;; Filling EBDA table for hard disk 0.
   1.139 @@ -8985,7 +8992,7 @@ ebda_post:
   1.140  #endif
   1.141    xor ax, ax            ; mov EBDA seg into 40E
   1.142    mov ds, ax
   1.143 -  mov word ptr [0x40E], #EBDA_SEG
   1.144 +  mov word ptr [EBDA_SEG_PTR], #EBDA_SEG
   1.145    ret;;
   1.146  
   1.147  ;--------------------
   1.148 @@ -9754,15 +9761,17 @@ no_bcv:
   1.149    je   no_bev
   1.150  
   1.151    ;; Found a device that thinks it can boot the system.  Record its BEV.
   1.152 -  mov  bx, #IPL_SEG            ;; Go to the segment where the IPL table lives 
   1.153 +  xor  bx, bx
   1.154    mov  ds, bx
   1.155 +  mov  bx, word ptr [EBDA_SEG_PTR]
   1.156 +  mov  ds, bx                  ;; Go to the segment where the IPL table lives 
   1.157    mov  bx, IPL_COUNT_OFFSET    ;; Read the number of entries so far
   1.158    cmp  bx, #IPL_TABLE_ENTRIES
   1.159    je   no_bev                  ;; Get out if the table is full
   1.160    shl  bx, #0x4                ;; Turn count into offset (entries are 16 bytes)
   1.161 -  mov  0[bx], #0x80            ;; This entry is a BEV device
   1.162 -  mov  6[bx], cx               ;; Build a far pointer from the segment...
   1.163 -  mov  4[bx], ax               ;; and the offset
   1.164 +  mov  IPL_TABLE_OFFSET+0[bx], #0x80 ;; This entry is a BEV device
   1.165 +  mov  IPL_TABLE_OFFSET+6[bx], cx    ;; Build a far pointer from the segment...
   1.166 +  mov  IPL_TABLE_OFFSET+4[bx], ax    ;; and the offset
   1.167    shr  bx, #0x4                ;; Turn the offset back into a count
   1.168    inc  bx                      ;; We have one more entry now
   1.169    mov  IPL_COUNT_OFFSET, bx    ;; Remember that.