source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Device/Idepack.asm@ 162

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

Changes to XTIDE Universal BIOS:

  • Optimized few bytes.
File size: 3.3 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Functions for managing IDEPACK struct.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; Idepack_FakeToSSBP
9; Parameters:
10; Nothing
11; Returns:
12; SS:BP: Ptr to IDEPACK
13; Corrupts registers:
14; AX
15;--------------------------------------------------------------------
16Idepack_FakeToSSBP:
17 pop ax
18 sub sp, BYTE EXTRA_BYTES_FOR_INTPACK
19 mov bp, sp
20 jmp ax
21
22
23;--------------------------------------------------------------------
24; Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH
25; Parameters:
26; AH: IDE command to issue
27; AL: Number of sectors to transfer (1...255, 0=256)
28; BH: Timeout ticks
29; BL: IDE Status Register flag to wait after command
30; CH: Cylinder number, bits 7...0
31; CL: Bits 7...6: Cylinder number bits 9 and 8
32; Bits 5...0: Starting sector number (1...63)
33; DH: Starting head number (0...255)
34; ES:SI: Ptr to data buffer
35; DS:DI: Ptr to DPT (in RAMVARS segment)
36; SS:BP: Ptr to IDEPACK
37; Returns:
38; AH: INT 13h Error Code
39; CF: Cleared if success, Set if error
40; Corrupts registers:
41; AL, BX, CX, DX
42;--------------------------------------------------------------------
43ALIGN JUMP_ALIGN
44Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH:
45 mov [bp+IDEPACK.bSectorCount], al
46 mov [bp+IDEPACK.bCommand], ah
47 mov BYTE [bp+IDEPACK.bSectorCountHighExt], 0
48
49 push bx
50 call Address_OldInt13hAddressToIdeAddress
51 call AccessDPT_GetDriveSelectByteToAL
52 or al, bh ; AL now has Drive and Head Select Byte
53 mov [bp+IDEPACK.bDrvAndHead], al
54 mov [bp+IDEPACK.bLbaLow], bl
55 mov [bp+IDEPACK.wLbaMiddleAndHigh], cx
56 pop bx
57
58 call AccessDPT_GetDeviceControlByteToAL
59 mov [bp+IDEPACK.bDeviceControl], al
60 jmp Device_OutputCommandWithParameters
61
62
63;--------------------------------------------------------------------
64; Idepack_StoreNonExtParametersAndIssueCommandFromAL
65; Parameters:
66; BH: Timeout ticks
67; BL: IDE Status Register flag to wait after command
68; AL: IDE command to issue
69; AH: Parameter to Drive and Head Select Register (Head bits only)
70; DL: Parameter to Sector Count Register
71; DH: Parameter to LBA Low / Sector Number Register
72; CL: Parameter to LBA Middle / Cylinder Low Register
73; CH: Parameter to LBA High / Cylinder High Register
74; SI: Parameter to Features Register
75; DS:DI: Ptr to DPT (in RAMVARS segment)
76; SS:BP: Ptr to IDEPACK
77; Returns:
78; AH: INT 13h Error Code
79; CF: Cleared if success, Set if error
80; Corrupts registers:
81; AL, BX, CX, DX
82;--------------------------------------------------------------------
83ALIGN JUMP_ALIGN
84Idepack_StoreNonExtParametersAndIssueCommandFromAL:
85 mov [bp+IDEPACK.bFeatures], si
86 mov [bp+IDEPACK.bCommand], al
87 mov [bp+IDEPACK.wSectorCountAndLbaLow], dx
88 mov [bp+IDEPACK.wLbaMiddleAndHigh], cx
89 mov BYTE [bp+IDEPACK.bSectorCountHighExt], 0
90
91 ; Drive and Head select byte
92 and ah, MASK_DRVNHEAD_HEAD ; Keep head bits only
93 call AccessDPT_GetDriveSelectByteToAL
94 or al, ah
95 mov [bp+IDEPACK.bDrvAndHead], al
96
97 ; Device Control byte with interrupts disabled
98 call AccessDPT_GetDeviceControlByteToAL
99 or al, FLG_DEVCONTROL_nIEN ; Disable interrupt
100 mov [bp+IDEPACK.bDeviceControl], al
101
102 jmp Device_OutputCommandWithParameters
Note: See TracBrowser for help on using the repository browser.