ia64/xen-unstable

changeset 16669:7fbc521b07a9

x86, hvm, rombios: INT13 LBA48 support for disks bigger than 128GB.
The new limit should be 2TB.

Signed-off-by: Samuel Thibault <samuel.thibault@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Dec 27 13:00:40 2007 +0000 (2007-12-27)
parents 50bd5d2c15cf
children 4624795a2346
files tools/firmware/rombios/rombios.c
line diff
     1.1 --- a/tools/firmware/rombios/rombios.c	Thu Dec 27 12:56:32 2007 +0000
     1.2 +++ b/tools/firmware/rombios/rombios.c	Thu Dec 27 13:00:40 2007 +0000
     1.3 @@ -2538,7 +2538,10 @@ void ata_detect( )
     1.4          case ATA_TYPE_ATA:
     1.5            printf("ata%d %s: ",channel,slave?" slave":"master");
     1.6            i=0; while(c=read_byte(get_SS(),model+i++)) printf("%c",c);
     1.7 -          printf(" ATA-%d Hard-Disk (%d MBytes)\n",version,(Bit16u)sizeinmb);
     1.8 +          if (sizeinmb < 1UL<<16)
     1.9 +            printf(" ATA-%d Hard-Disk (%04u MBytes)\n",version,(Bit16u)sizeinmb);
    1.10 +          else
    1.11 +            printf(" ATA-%d Hard-Disk (%04u GBytes)\n",version,(Bit16u)(sizeinmb>>10));
    1.12            break;
    1.13          case ATA_TYPE_ATAPI:
    1.14            printf("ata%d %s: ",channel,slave?" slave":"master");
    1.15 @@ -2671,15 +2674,6 @@ Bit32u lba;
    1.16    if (mode == ATA_MODE_PIO32) blksize>>=2;
    1.17    else blksize>>=1;
    1.18  
    1.19 -  // sector will be 0 only on lba access. Convert to lba-chs
    1.20 -  if (sector == 0) {
    1.21 -    sector = (Bit16u) (lba & 0x000000ffL);
    1.22 -    lba >>= 8;
    1.23 -    cylinder = (Bit16u) (lba & 0x0000ffffL);
    1.24 -    lba >>= 16;
    1.25 -    head = ((Bit16u) (lba & 0x0000000fL)) | 0x40;
    1.26 -    }
    1.27 -
    1.28    // Reset count of transferred data
    1.29    write_word(ebda_seg, &EbdaData->ata.trsfsectors,0);
    1.30    write_dword(ebda_seg, &EbdaData->ata.trsfbytes,0L);
    1.31 @@ -2689,6 +2683,26 @@ Bit32u lba;
    1.32    if (status & ATA_CB_STAT_BSY) return 1;
    1.33  
    1.34    outb(iobase2 + ATA_CB_DC, ATA_CB_DC_HD15 | ATA_CB_DC_NIEN);
    1.35 +
    1.36 +  // sector will be 0 only on lba access. Convert to lba-chs
    1.37 +  if (sector == 0) {
    1.38 +    if ((count >= 1 << 8) || (lba + count >= 1UL << 28)) {
    1.39 +      outb(iobase1 + ATA_CB_FR, 0x00);
    1.40 +      outb(iobase1 + ATA_CB_SC, (count >> 8) & 0xff);
    1.41 +      outb(iobase1 + ATA_CB_SN, lba >> 24);
    1.42 +      outb(iobase1 + ATA_CB_CL, 0);
    1.43 +      outb(iobase1 + ATA_CB_CH, 0);
    1.44 +      command |= 0x04;
    1.45 +      count &= (1UL << 8) - 1;
    1.46 +      lba &= (1UL << 24) - 1;
    1.47 +      }
    1.48 +    sector = (Bit16u) (lba & 0x000000ffL);
    1.49 +    lba >>= 8;
    1.50 +    cylinder = (Bit16u) (lba & 0x0000ffffL);
    1.51 +    lba >>= 16;
    1.52 +    head = ((Bit16u) (lba & 0x0000000fL)) | 0x40;
    1.53 +    }
    1.54 +
    1.55    outb(iobase1 + ATA_CB_FR, 0x00);
    1.56    outb(iobase1 + ATA_CB_SC, count);
    1.57    outb(iobase1 + ATA_CB_SN, sector);
    1.58 @@ -2814,15 +2828,6 @@ Bit32u lba;
    1.59    if (mode == ATA_MODE_PIO32) blksize>>=2;
    1.60    else blksize>>=1;
    1.61  
    1.62 -  // sector will be 0 only on lba access. Convert to lba-chs
    1.63 -  if (sector == 0) {
    1.64 -    sector = (Bit16u) (lba & 0x000000ffL);
    1.65 -    lba >>= 8;
    1.66 -    cylinder = (Bit16u) (lba & 0x0000ffffL);
    1.67 -    lba >>= 16;
    1.68 -    head = ((Bit16u) (lba & 0x0000000fL)) | 0x40;
    1.69 -    }
    1.70 -
    1.71    // Reset count of transferred data
    1.72    write_word(ebda_seg, &EbdaData->ata.trsfsectors,0);
    1.73    write_dword(ebda_seg, &EbdaData->ata.trsfbytes,0L);
    1.74 @@ -2832,6 +2837,26 @@ Bit32u lba;
    1.75    if (status & ATA_CB_STAT_BSY) return 1;
    1.76  
    1.77    outb(iobase2 + ATA_CB_DC, ATA_CB_DC_HD15 | ATA_CB_DC_NIEN);
    1.78 +
    1.79 +  // sector will be 0 only on lba access. Convert to lba-chs
    1.80 +  if (sector == 0) {
    1.81 +    if ((count >= 1 << 8) || (lba + count >= 1UL << 28)) {
    1.82 +      outb(iobase1 + ATA_CB_FR, 0x00);
    1.83 +      outb(iobase1 + ATA_CB_SC, (count >> 8) & 0xff);
    1.84 +      outb(iobase1 + ATA_CB_SN, lba >> 24);
    1.85 +      outb(iobase1 + ATA_CB_CL, 0);
    1.86 +      outb(iobase1 + ATA_CB_CH, 0);
    1.87 +      command |= 0x04;
    1.88 +      count &= (1UL << 8) - 1;
    1.89 +      lba &= (1UL << 24) - 1;
    1.90 +      }
    1.91 +    sector = (Bit16u) (lba & 0x000000ffL);
    1.92 +    lba >>= 8;
    1.93 +    cylinder = (Bit16u) (lba & 0x0000ffffL);
    1.94 +    lba >>= 16;
    1.95 +    head = ((Bit16u) (lba & 0x0000000fL)) | 0x40;
    1.96 +    }
    1.97 +
    1.98    outb(iobase1 + ATA_CB_FR, 0x00);
    1.99    outb(iobase1 + ATA_CB_SC, count);
   1.100    outb(iobase1 + ATA_CB_SN, sector);