source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH8h_HParams.asm @ 43

Last change on this file since 43 was 43, checked in by aitotat, 14 years ago

Errors are now being checked when calling previous INT 13h handler on AH=08h Read Disk Drive Parameters. This fixes infinite drive checking loop on unofficial MS-DOS 7.10 installer.

File size: 4.0 KB
RevLine 
[3]1; File name     :   AH8h_HParams.asm
2; Project name  :   IDE BIOS
3; Created date  :   27.9.2007
[43]4; Last update   :   24.9.2010
[3]5; Author        :   Tomi Tilli
6; Description   :   Int 13h function AH=8h, Read Disk Drive Parameters.
7
8; Section containing code
9SECTION .text
10
11;--------------------------------------------------------------------
12; Int 13h function AH=8h, Read Disk Drive Parameters.
13;
14; AH8h_HandlerForReadDiskDriveParameters
15;   Parameters:
16;       AH:     Bios function 8h
17;       DL:     Drive number
18;   Parameters loaded by Int13h_Jump:
19;       DS:     RAMVARS segment
20;   Returns:
21;       CH:     Maximum cylinder number, bits 7...0
22;       CL:     Bits 7...6: Cylinder number bits 9...8
23;               Bits 5...0: Maximum sector number (1...63)
24;       DH:     Maximum head number (0...255)
25;       DL:     Number of drives
26;       AH:     Int 13h/40h floppy return status
27;       CF:     0 if successfull, 1 if error
28;       IF:     1
29;   Corrupts registers:
30;       Flags
31;--------------------------------------------------------------------
32ALIGN JUMP_ALIGN
33AH8h_HandlerForReadDiskDriveParameters:
[32]34    call    RamVars_IsDriveHandledByThisBIOS
35    jnc     SHORT .GetDriveParametersForForeignHardDiskInDL
36
[3]37    push    bx
38    call    AH8h_GetDriveParameters
39    pop     bx
[35]40    jmp     Int13h_ReturnWithValueInDL
[3]41
[32]42ALIGN JUMP_ALIGN
43.GetDriveParametersForForeignHardDiskInDL:
44    call    Int13h_CallPreviousInt13hHandler
[43]45    jc      SHORT .ReturnErrorFromPreviousInt13hHandler
[32]46    call    RamVars_GetCountOfKnownDrivesToDL
[35]47    jmp     Int13h_ReturnWithValueInDL
[43]48.ReturnErrorFromPreviousInt13hHandler:
49    jmp     Int13h_PopDiDsAndReturn
[3]50
[32]51
[3]52;--------------------------------------------------------------------
53; Returns L-CHS parameters for drive and total hard disk count.
54;
[28]55; AH8h_GetDriveParameters
[3]56;   Parameters:
57;       DL:     Drive number
58;       DS:     RAMVARS segment
59;   Returns:
60;       CH:     Maximum cylinder number, bits 7...0
61;       CL:     Bits 7...6: Cylinder number bits 9...8
62;               Bits 5...0: Maximum sector number (1...63)
63;       DH:     Maximum head number (0...255)
64;       DL:     Number of drives
65;       DS:DI:  Ptr to DPT
66;       AH:     Int 13h/40h floppy return status
67;       CF:     0 if successfull, 1 if error
68;   Corrupts registers:
69;       AL, BX
70;--------------------------------------------------------------------
71ALIGN JUMP_ALIGN
72AH8h_GetDriveParameters:
73    call    FindDPT_ForDriveNumber
74    call    AccessDPT_GetLCHSfromPCHS   ; AX=sectors, BX=cylinders, DX=heads
75    call    AH8h_ReserveCylinders
76    call    AH8h_PackReturnValues
77    xor     ax, ax                      ; Clear AH and CF
78    ret
79
80
81;--------------------------------------------------------------------
82; Reserves diagnostic cylinder if so configured.
83;
84; AH8h_ReserveCylinders
85;   Parameters:
86;       BX:     Total number of L-CHS cylinders available
87;       DS:DI:  Ptr to DPT
88;   Returns:
89;       BX:     Number of L-CHS cylinders available after reserving
90;   Corrupts registers:
91;       CX
92;--------------------------------------------------------------------
93ALIGN JUMP_ALIGN
94AH8h_ReserveCylinders:
95    test    BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_MAXSIZE
96    jnz     SHORT .Return
97    dec     bx                          ; Reserve diagnostic cylinder
98ALIGN JUMP_ALIGN
99.Return:
100    ret
101
102
103;--------------------------------------------------------------------
104; Packs L-CHS values to INT 13h, AH=08h return values.
105;
106; AH8h_PackReturnValues
107;   Parameters:
108;       AX:     Number of L-CHS sectors per track (1...63)
109;       BX:     Number of L-CHS cylinders available (1...1024)
110;       DX:     Number of L-CHS heads (1...256)
[32]111;       DS:     RAMVARS segment
[3]112;   Returns:
113;       CH:     Maximum cylinder number, bits 7...0
114;       CL:     Bits 7...6: Cylinder number bits 9...8
115;               Bits 5...0: Maximum sector number (1...63)
116;       DH:     Maximum head number (0...255)
117;       DL:     Number of drives
118;   Corrupts registers:
119;       AX, BX
120;--------------------------------------------------------------------
121ALIGN JUMP_ALIGN
122AH8h_PackReturnValues:
123    dec     bx                      ; Cylinder count to last cylinder
124    dec     dx                      ; Head count to max head number
125    mov     dh, dl                  ; Max head number to DH
126    mov     ch, bl                  ; Cylinder bits 7...0 to CH
127    mov     cl, bh                  ; Cylinder bits 9...8 to CL
128    eROR_IM cl, 2                   ; Cylinder bits 9...8 to CL bits 7...6
129    or      cl, al                  ; Sectors per track to CL bits 5...0
[32]130    jmp     RamVars_GetCountOfKnownDrivesToDL
Note: See TracBrowser for help on using the repository browser.