1 | ; Project name : XTIDE Universal BIOS |
---|
2 | ; Description : Int 13h function AH=15h, Read Disk Drive Size. |
---|
3 | |
---|
4 | ; Section containing code |
---|
5 | SECTION .text |
---|
6 | |
---|
7 | ;-------------------------------------------------------------------- |
---|
8 | ; Int 13h function AH=15h, Read Disk Drive Size. |
---|
9 | ; |
---|
10 | ; AH15h_HandlerForReadDiskDriveSize |
---|
11 | ; Parameters: |
---|
12 | ; DL: Translated Drive number |
---|
13 | ; DS:DI: Ptr to DPT (in RAMVARS segment) |
---|
14 | ; SS:BP: Ptr to IDEPACK |
---|
15 | ; Returns with INTPACK: |
---|
16 | ; If succesfull: |
---|
17 | ; AH: 3 (Hard disk accessible) |
---|
18 | ; CX:DX: Total number of sectors |
---|
19 | ; CF: 0 |
---|
20 | ; If failed: |
---|
21 | ; AH: 0 (Drive not present) |
---|
22 | ; CX:DX: 0 |
---|
23 | ; CF: 1 |
---|
24 | ;-------------------------------------------------------------------- |
---|
25 | ALIGN JUMP_ALIGN |
---|
26 | AH15h_HandlerForReadDiskDriveSize: |
---|
27 | call AH15h_GetSectorCountToDXAX |
---|
28 | mov [bp+IDEPACK.intpack+INTPACK.cx], dx ; HIWORD to CX |
---|
29 | mov [bp+IDEPACK.intpack+INTPACK.dx], ax ; LOWORD to DX |
---|
30 | |
---|
31 | xor ah, ah |
---|
32 | call Int13h_SetErrorCodeToIntpackInSSBPfromAH ; Store success to BDA and CF |
---|
33 | mov BYTE [bp+IDEPACK.intpack+INTPACK.ah], 3 ; Type code = Hard disk |
---|
34 | jmp Int13h_ReturnFromHandlerWithoutStoringErrorCode |
---|
35 | |
---|
36 | |
---|
37 | ;-------------------------------------------------------------------- |
---|
38 | ; AH15h_GetSectorCountFromForeignDriveToDXAX: |
---|
39 | ; AH15h_GetSectorCountToDXAX: |
---|
40 | ; Parameters: |
---|
41 | ; DL: Drive number |
---|
42 | ; DS: RAMVARS segment |
---|
43 | ; DS:DI: Ptr to DPT (AH15h_GetSectorCount only) |
---|
44 | ; Returns: |
---|
45 | ; DX:AX: Total sector count |
---|
46 | ; BX: Zero |
---|
47 | ; Corrupts registers: |
---|
48 | ; CX |
---|
49 | ;-------------------------------------------------------------------- |
---|
50 | AH15h_GetSectorCountFromForeignDriveToDXAX: |
---|
51 | mov ah, GET_DRIVE_PARAMETERS |
---|
52 | call Int13h_CallPreviousInt13hHandler |
---|
53 | jmp SHORT ConvertAH08hReturnValuesToSectorCount |
---|
54 | |
---|
55 | ALIGN JUMP_ALIGN |
---|
56 | AH15h_GetSectorCountToDXAX: |
---|
57 | call AH8h_GetDriveParameters |
---|
58 | ; Fall to ConvertAH08hReturnValuesToSectorCount |
---|
59 | |
---|
60 | ConvertAH08hReturnValuesToSectorCount: |
---|
61 | call HAddress_ExtractLCHSparametersFromOldInt13hAddress |
---|
62 | xor ax, ax ; Zero AX |
---|
63 | inc cx ; Max cylinder number to cylinder count |
---|
64 | xchg al, bh ; AX=Max head number, BX=Sectors per track |
---|
65 | inc ax ; AX=Head count |
---|
66 | mul bx ; AX=Head count * Sectors per track |
---|
67 | mul cx ; DX:AX = Total sector count |
---|
68 | xor bx, bx ; Zero BX for 48-bit sector count (and clear CF) |
---|
69 | ret |
---|