[3] | 1 | ; File name : AH8h_HParams.asm
|
---|
| 2 | ; Project name : IDE BIOS
|
---|
| 3 | ; Created date : 27.9.2007
|
---|
| 4 | ; Last update : 12.4.2010
|
---|
| 5 | ; Author : Tomi Tilli
|
---|
| 6 | ; Description : Int 13h function AH=8h, Read Disk Drive Parameters.
|
---|
| 7 |
|
---|
| 8 | ; Section containing code
|
---|
| 9 | SECTION .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 | ;--------------------------------------------------------------------
|
---|
| 32 | ALIGN JUMP_ALIGN
|
---|
| 33 | AH8h_HandlerForReadDiskDriveParameters:
|
---|
| 34 | push bx
|
---|
| 35 | call AH8h_GetDriveParameters
|
---|
| 36 | pop bx
|
---|
| 37 | jmp Int13h_ReturnWithoutSwappingDrives
|
---|
| 38 |
|
---|
| 39 |
|
---|
| 40 | ;--------------------------------------------------------------------
|
---|
| 41 | ; Returns L-CHS parameters for drive and total hard disk count.
|
---|
| 42 | ;
|
---|
| 43 | ; AH8h_HParams
|
---|
| 44 | ; Parameters:
|
---|
| 45 | ; DL: Drive number
|
---|
| 46 | ; DS: RAMVARS segment
|
---|
| 47 | ; Returns:
|
---|
| 48 | ; CH: Maximum cylinder number, bits 7...0
|
---|
| 49 | ; CL: Bits 7...6: Cylinder number bits 9...8
|
---|
| 50 | ; Bits 5...0: Maximum sector number (1...63)
|
---|
| 51 | ; DH: Maximum head number (0...255)
|
---|
| 52 | ; DL: Number of drives
|
---|
| 53 | ; DS:DI: Ptr to DPT
|
---|
| 54 | ; AH: Int 13h/40h floppy return status
|
---|
| 55 | ; CF: 0 if successfull, 1 if error
|
---|
| 56 | ; Corrupts registers:
|
---|
| 57 | ; AL, BX
|
---|
| 58 | ;--------------------------------------------------------------------
|
---|
| 59 | ALIGN JUMP_ALIGN
|
---|
| 60 | AH8h_GetDriveParameters:
|
---|
| 61 | call FindDPT_ForDriveNumber
|
---|
| 62 | call AccessDPT_GetLCHSfromPCHS ; AX=sectors, BX=cylinders, DX=heads
|
---|
| 63 | call AH8h_ReserveCylinders
|
---|
| 64 | call AH8h_PackReturnValues
|
---|
| 65 | xor ax, ax ; Clear AH and CF
|
---|
| 66 | ret
|
---|
| 67 |
|
---|
| 68 |
|
---|
| 69 | ;--------------------------------------------------------------------
|
---|
| 70 | ; Reserves diagnostic cylinder if so configured.
|
---|
| 71 | ;
|
---|
| 72 | ; AH8h_ReserveCylinders
|
---|
| 73 | ; Parameters:
|
---|
| 74 | ; BX: Total number of L-CHS cylinders available
|
---|
| 75 | ; DS:DI: Ptr to DPT
|
---|
| 76 | ; Returns:
|
---|
| 77 | ; BX: Number of L-CHS cylinders available after reserving
|
---|
| 78 | ; Corrupts registers:
|
---|
| 79 | ; CX
|
---|
| 80 | ;--------------------------------------------------------------------
|
---|
| 81 | ALIGN JUMP_ALIGN
|
---|
| 82 | AH8h_ReserveCylinders:
|
---|
| 83 | test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_MAXSIZE
|
---|
| 84 | jnz SHORT .Return
|
---|
| 85 | dec bx ; Reserve diagnostic cylinder
|
---|
| 86 | ALIGN JUMP_ALIGN
|
---|
| 87 | .Return:
|
---|
| 88 | ret
|
---|
| 89 |
|
---|
| 90 |
|
---|
| 91 | ;--------------------------------------------------------------------
|
---|
| 92 | ; Packs L-CHS values to INT 13h, AH=08h return values.
|
---|
| 93 | ;
|
---|
| 94 | ; AH8h_PackReturnValues
|
---|
| 95 | ; Parameters:
|
---|
| 96 | ; AX: Number of L-CHS sectors per track (1...63)
|
---|
| 97 | ; BX: Number of L-CHS cylinders available (1...1024)
|
---|
| 98 | ; DX: Number of L-CHS heads (1...256)
|
---|
| 99 | ; Returns:
|
---|
| 100 | ; CH: Maximum cylinder number, bits 7...0
|
---|
| 101 | ; CL: Bits 7...6: Cylinder number bits 9...8
|
---|
| 102 | ; Bits 5...0: Maximum sector number (1...63)
|
---|
| 103 | ; DH: Maximum head number (0...255)
|
---|
| 104 | ; DL: Number of drives
|
---|
| 105 | ; Corrupts registers:
|
---|
| 106 | ; AX, BX
|
---|
| 107 | ;--------------------------------------------------------------------
|
---|
| 108 | ALIGN JUMP_ALIGN
|
---|
| 109 | AH8h_PackReturnValues:
|
---|
| 110 | dec bx ; Cylinder count to last cylinder
|
---|
| 111 | dec dx ; Head count to max head number
|
---|
| 112 | mov dh, dl ; Max head number to DH
|
---|
| 113 | push ax
|
---|
| 114 | call RamVars_GetDriveCounts ; Hard disk count to CX
|
---|
| 115 | pop ax
|
---|
| 116 | mov dl, cl ; Hard disk count to DL
|
---|
| 117 | mov ch, bl ; Cylinder bits 7...0 to CH
|
---|
| 118 | mov cl, bh ; Cylinder bits 9...8 to CL
|
---|
| 119 | eROR_IM cl, 2 ; Cylinder bits 9...8 to CL bits 7...6
|
---|
| 120 | or cl, al ; Sectors per track to CL bits 5...0
|
---|
| 121 | ret
|
---|