source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HCommand.asm@ 61

Last change on this file since 61 was 3, checked in by Tomi Tilli, 15 years ago
File size: 3.6 KB
Line 
1; File name : HCommand.asm
2; Project name : IDE BIOS
3; Created date : 28.3.2010
4; Last update : 16.4.2010
5; Author : Tomi Tilli
6; Description : Functions for outputting IDE commands and parameters.
7
8; Section containing code
9SECTION .text
10
11;--------------------------------------------------------------------
12; Outputs sector count, L-CHS address and command to IDE registers.
13; This function does not wait until command has been completed.
14;
15; HCommand_OutputCountAndLCHSandCommand
16; Parameters:
17; AH: Seek or data transfer command
18; AL: Sector count (1...255, 0=256)
19; CH: Cylinder number, bits 7...0
20; CL: Bits 7...6: Cylinder number bits 9 and 8
21; Bits 5...0: Starting sector number (1...63)
22; DH: Starting head number (0...255)
23; DS:DI: Ptr to DPT
24; Returns:
25; AH: BIOS Error code (if error)
26; CF: 0 if succesfull
27; 1 if any error
28; Corrupts registers:
29; CX, DX
30;--------------------------------------------------------------------
31ALIGN JUMP_ALIGN
32HCommand_OutputCountAndLCHSandCommand:
33 push bx
34 push ax ; Store sector count and command
35 call HDrvSel_SelectDriveForDataTransfer
36 jc SHORT .ReturnError
37 call HIRQ_ClearTaskFlag
38 call HAddress_ConvertParamsFromBiosLCHStoIDE
39 mov dx, [RAMVARS.wIdeBase] ; Load IDE Base Port address
40 call HCommand_OutputTranslatedLCHSaddress ; DX to Sector count register
41 pop ax ; Restore sector count and command
42 call HCommand_OutputSectorCountAndCommand
43
44 clc ; Clear CF since success
45 pop bx
46 ret
47.ReturnError:
48 pop bx ; Discard pushed AX
49 pop bx
50 ret
51
52
53;--------------------------------------------------------------------
54; Outputs L-CHS address that has been translated P-CHS or LBA28
55; when necessary.
56;
57; HCommand_OutputTranslatedLCHSaddress
58; Parameters:
59; BL: LBA Low Register / Sector Number Register (LBA 7...0)
60; CL: LBA Mid Register / Low Cylinder Register (LBA 15...8)
61; CH: LBA High Register / High Cylinder Register (LBA 23...16)
62; BH: Drive and Head Register (LBA 27...24)
63; DX: IDE Base Port address
64; DS:DI: Ptr to DPT
65; Returns:
66; DX: IDE Sector Count Register address
67; Corrupts registers:
68; AX, CX
69;--------------------------------------------------------------------
70ALIGN JUMP_ALIGN
71HCommand_OutputTranslatedLCHSaddress:
72 add dx, BYTE REG_IDE_LBA_LOW
73 mov al, bl
74 out dx, al ; Output LBA 7...0
75
76 ; Some (VLB) controllers fail to accept WORD write to cylinder
77 ; registers so we must output two bytes instead.
78 inc dx ; REG_IDE_LBA_MID
79 mov al, cl
80 out dx, al ; Output LBA 8...15
81
82 inc dx ; REG_IDE_LBA_HIGH
83 mov al, ch
84 out dx, al ; Output LBA 16...23
85
86 inc dx ; REG_IDE_DRVHD
87 mov al, [di+DPT.bDrvSel] ; Load other bits for Drive and Head Register
88 or al, bh
89 out dx, al ; Output LBA 27...24
90
91 sub dx, BYTE REG_IDE_DRVHD-REG_IDE_CNT
92 ret
93
94
95;--------------------------------------------------------------------
96; Outputs sector count and seek or data transfer command.
97;
98; HCommand_OutputSectorCountAndCommand
99; Parameters:
100; AH: Seek or data transfer command
101; AL: Sector count (1...255, 0=256)
102; DX: IDE Sector Count Register address
103; Returns:
104; Nothing
105; Corrupts registers:
106; AH, DX
107;--------------------------------------------------------------------
108ALIGN JUMP_ALIGN
109HCommand_OutputSectorCountAndCommand:
110 out dx, al ; Output sector count
111 add dx, BYTE REGW_IDE_CMD-REG_IDE_CNT
112 xchg al, ah ; AL=Command, AH=Sector count
113 out dx, al
114 mov al, ah ; Restore sector count to AL
115 jmp SoftDelay_BeforePollingStatusRegister
Note: See TracBrowser for help on using the repository browser.