source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm@ 356

Last change on this file since 356 was 324, checked in by aitotat@…, 13 years ago

Changes to XTIDE Universal BIOS:

  • Boot Menu now displays correct capacity when using user defined LBA.
File size: 2.4 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Functions for accessing ATA information read with
3; IDENTIFY DEVICE command.
4
5; Section containing code
6SECTION .text
7
8;--------------------------------------------------------------------
9; AtaID_GetPCHStoAXBLBHfromAtaInfoInESSI
10; Parameters:
11; ES:SI: Ptr to 512-byte ATA information read from the drive
12; Returns:
13; AX: Number of user specified P-CHS cylinders
14; BH: Number of user specified P-CHS sectors per track
15; BL: Number of user specified P-CHS heads
16; Corrupts registers:
17; Nothing
18;--------------------------------------------------------------------
19AtaID_GetPCHStoAXBLBHfromAtaInfoInESSI:
20 mov ax, [es:si+ATA1.wCylCnt] ; Cylinders (1...16383)
21 mov bl, [es:si+ATA1.wHeadCnt] ; Heads (1...16)
22 mov bh, [es:si+ATA1.wSPT] ; Sectors per Track (1...63)
23 ret
24
25
26;--------------------------------------------------------------------
27; AtaID_GetTotalSectorCountToBXDXAXfromAtaInfoInESSI
28; Parameters:
29; ES:SI: Ptr to 512-byte ATA information read from the drive
30; Returns:
31; BX:DX:AX: 48-bit sector count
32; Corrupts registers:
33; Nothing
34;--------------------------------------------------------------------
35AtaID_GetTotalSectorCountToBXDXAXfromAtaInfoInESSI:
36 mov bx, Registers_ExchangeDSSIwithESDI
37 call bx ; ATA info now in DS:DI
38 push bx ; We will return via Registers_ExchangeDSSIwithESDI
39 xor bx, bx
40 test BYTE [di+ATA1.wCaps+1], A1_wCaps_LBA>>8
41 jz SHORT .GetChsSectorCount
42 ; Fall to .GetLbaSectorCount
43
44;--------------------------------------------------------------------
45; .GetLbaSectorCount
46; .GetLba28SectorCount
47; .GetChsSectorCount
48; Parameters:
49; BX: Zero
50; DS:DI: Ptr to 512-byte ATA information read from the drive
51; Returns:
52; BX:DX:AX: 48-bit sector count
53; Corrupts registers:
54; Nothing
55;--------------------------------------------------------------------
56.GetLbaSectorCount:
57 test BYTE [di+ATA6.wSetSup83+1], A6_wSetSup83_LBA48>>8
58 jz SHORT .GetLba28SectorCount
59 mov ax, [di+ATA6.qwLBACnt]
60 mov dx, [di+ATA6.qwLBACnt+2]
61 mov bx, [di+ATA6.qwLBACnt+4]
62 ret
63
64.GetLba28SectorCount:
65 mov ax, [di+ATA1.dwLBACnt]
66 mov dx, [di+ATA1.dwLBACnt+2]
67 ret
68
69.GetChsSectorCount:
70 mov al, [di+ATA1.wSPT] ; AL=Sectors per track
71 mul BYTE [di+ATA1.wHeadCnt] ; AX=Sectors per track * number of heads
72 mul WORD [di+ATA1.wCylCnt] ; DX:AX=Sectors per track * number of heads * number of cylinders
73 ret
Note: See TracBrowser for help on using the repository browser.