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

Last change on this file since 130 was 88, checked in by Tomi Tilli, 14 years ago

Changes to XTIDE Universal BIOS:

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