1 | ; File name : AH2h_HRead.asm
|
---|
2 | ; Project name : IDE BIOS
|
---|
3 | ; Created date : 27.9.2007
|
---|
4 | ; Last update : 24.8.2010
|
---|
5 | ; Author : Tomi Tilli
|
---|
6 | ; Description : Int 13h function AH=2h, Read Disk Sectors.
|
---|
7 |
|
---|
8 | ; Section containing code
|
---|
9 | SECTION .text
|
---|
10 |
|
---|
11 | ;--------------------------------------------------------------------
|
---|
12 | ; Int 13h function AH=2h, Read Disk Sectors.
|
---|
13 | ;
|
---|
14 | ; AH2h_HandlerForReadDiskSectors
|
---|
15 | ; Parameters:
|
---|
16 | ; AH: Bios function 2h
|
---|
17 | ; AL: Number of sectors to read (1...255)
|
---|
18 | ; CH: Cylinder number, bits 7...0
|
---|
19 | ; CL: Bits 7...6: Cylinder number bits 9 and 8
|
---|
20 | ; Bits 5...0: Starting sector number (1...63)
|
---|
21 | ; DH: Starting head number (0...255)
|
---|
22 | ; DL: Drive number (8xh)
|
---|
23 | ; ES:BX: Pointer to buffer recieving data
|
---|
24 | ; Parameters loaded by Int13h_Jump:
|
---|
25 | ; DS: RAMVARS segment
|
---|
26 | ; Returns:
|
---|
27 | ; AH: Int 13h/40h floppy return status
|
---|
28 | ; AL: Burst error length if AH=11h, undefined otherwise
|
---|
29 | ; CF: 0 if successfull, 1 if error
|
---|
30 | ; IF: 1
|
---|
31 | ; Corrupts registers:
|
---|
32 | ; Flags
|
---|
33 | ;--------------------------------------------------------------------
|
---|
34 | ALIGN JUMP_ALIGN
|
---|
35 | AH2h_HandlerForReadDiskSectors:
|
---|
36 | test al, al ; Invalid sector count?
|
---|
37 | jz SHORT AH2h_ZeroCntErr ; If so, return with error
|
---|
38 |
|
---|
39 | ; Save registers
|
---|
40 | push dx
|
---|
41 | push cx
|
---|
42 | push bx
|
---|
43 | push ax
|
---|
44 |
|
---|
45 | ; Select sector or block mode command
|
---|
46 | call FindDPT_ForDriveNumber ; DS:DI now points to DPT
|
---|
47 | mov ah, HCMD_READ_SECT ; Load sector mode command
|
---|
48 | cmp BYTE [di+DPT.bSetBlock], 1 ; Block mode enabled?
|
---|
49 | jbe SHORT .XferData ; If not, jump to transfer
|
---|
50 | mov ah, HCMD_READ_MUL ; Load block mode command
|
---|
51 |
|
---|
52 | ; Transfer data
|
---|
53 | ALIGN JUMP_ALIGN
|
---|
54 | .XferData:
|
---|
55 | call HCommand_OutputCountAndLCHSandCommand
|
---|
56 | jc SHORT .Return ; Return if error
|
---|
57 | call HPIO_ReadBlock ; Read data from IDE-controller
|
---|
58 | .Return:
|
---|
59 | jmp Int13h_PopXRegsAndReturn
|
---|
60 |
|
---|
61 | ; Invalid sector count (also for AH=3h and AH=4h)
|
---|
62 | AH2h_ZeroCntErr:
|
---|
63 | mov ah, RET_HD_INVALID ; Invalid value passed
|
---|
64 | stc ; Set CF since error
|
---|
65 | jmp Int13h_PopDiDsAndReturn
|
---|