搜尋此網誌

2013年9月15日 星期日

How to use FlagTypeSingle/FlagTypeNeedVar/FlagTypeNeedSet/FlagTypeSkipUnknown for design a UEFI Shell program?

SHELL_VAR_CHECK_ITEM TestCheckList[] = {
  {
    L"+a",
    0x01,
    0x02,
    FlagTypeSingle /*example: +a(nothing is behind this parameter.)*/
  },
  {
    L"-a",
    0x02,
    0x01,
    FlagTypeSingle /*example: -a(nothing is behind this parameter.)*/
  },
  {
    L"-b",
    0x03,
    0,
    FlagTypeNeedVar /*example: -b 20(that has space between the two parameters.)*/
  },
  {
    L"-c",
    0x04,
    0,
    FlagTypeNeedSet /*example: -c20(that doesn't has any space between the two parameters.)*/
  },
  {
    L"-z",
    0x05,
    0,
    FlagTypeSkipUnknown /*This flag would cause system hang currently. -z */
  },
  {
    L"-?",
    0x02,
    0,
    FlagTypeSingle
  },
  {
    NULL,
    0,
    0,
    0 /*List End*/
  }
};

2013年9月11日 星期三

How to get HD capacity form int13h?

INT 13 48-- - IBM/MS INT 13 Extensions - GET DRIVE PARAMETERS
Inp.:
    AH = 48h
    DL = drive (80h-FFh)
    DS:SI -> buffer for drive parameters (see Table #00273)
Return: CF clear if successful
        AH = 00h
        DS:SI buffer filled
    CF set on error
        AH = error code (see #00234)
BUGS:  several different Compaq BIOSes incorrectly report high-numbered drives (such as 90h, B0h, D0h, and F0h) as present, giving them the same geometry as drive 80h; as a workaround, scan through disk numbers, stopping as soon as the number of valid drives encountered equals the value in 0040h:0075h 
Dell machines using PhoenixBIOS 4.0 Release 6.0 fail to correctly handle this function if the flag word at DS:[SI+2] is not 0000h on entry
  
[Table 00273]
Format of IBM/MS INT 13 Extensions drive parameters:

Offset        Size  Description     
00h   WORD     (call) size of buffer
          (001Ah for v1.x, 001Eh for v2.x, 42h for v3.0)
          (ret) size of returned data
02h   WORD     information flags (see #00274)
04h   DWORD   number of physical cylinders on drive
08h   DWORD   number of physical heads on drive
0Ch   DWORD   number of physical sectors per track
10h   QWORD  total number of sectors on drive ==> Max LBA
18h   WORD     bytes per sector
---v2.0+ ---
1Ah   DWORD   -> EDD configuration parameters (see #00278)

FFFFh:FFFFh if not available
---v3.0 ---
1Eh   WORD     signature BEDDh to indicate presence of Device Path info
20h   BYTE        length of Device Path information, including signature and this
            byte (24h for v3.0)
21h  3 BYTEs    reserved (0)
24h  4 BYTEs    ASCIZ name of host bus ("ISA" or "PCI")
28h  8 BYTEs    ASCIZ name of interface type
          "ATA"
          "ATAPI"
          "SCSI"
          "USB"
          "1394" IEEE 1394 (FireWire)
          "FIBRE" Fibre Channel
30h  8 BYTEs    Interface Path (see #00275)

38h  8 BYTEs    Device Path (see #00276)
40h   BYTE        reserved (0)
41h   BYTE        checksum of bytes 1Eh-40h (two's complement of sum, which makes
            the 8-bit sum of bytes 1Eh-41h equal 00h)
Note: if the size is less than 30 on call, the final DWORD will not be returned by a v2.x implementation; similarly for the Device Path info


[Table 00274]
Bitfields for IBM/MS INT 13 Extensions information flags:

Bit(s)  Description     
0       DMA boundary errors handled transparently
1       cylinder/head/sectors-per-track information is valid
2       removable drive
3       write with verify supported
4       drive has change-line support (required if drive >= 80h is removable)
5       drive can be locked (required if drive >= 80h is removable)
6       CHS information set to maximum supported values, not current media
15-7  reserved (0)


The HD size(bytes) =  (total number of sectors on drive(Offset = 10h, Size = QWORD)) x (bytes per sector(Offset = 18h, Size = WORD))