source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HDrvSel.asm@ 38

Last change on this file since 38 was 3, checked in by Tomi Tilli, 15 years ago
File size: 3.5 KB
Line 
1; File name : HDrvSel.asm
2; Project name : IDE BIOS
3; Created date : 25.2.2010
4; Last update : 13.4.2010
5; Author : Tomi Tilli
6; Description : Functions for selecting Master or Slave drive.
7
8; Section containing code
9SECTION .text
10
11;--------------------------------------------------------------------
12; Selects Master or Slave drive for transferring data.
13; This means that interrupts will be enabled if so configured in
14; IDEVARS. This function returns after drive is ready to accept commands.
15;
16; HDrvSel_SelectDriveForDataTransfer
17; Parameters:
18; DS:DI: Ptr to DPT
19; Returns:
20; AH: BIOS Error code
21; CF: 0 if drive selected successfully
22; 1 if any error
23; Corrupts registers:
24; AL, BX
25;--------------------------------------------------------------------
26ALIGN JUMP_ALIGN
27HDrvSel_SelectDriveForDataTransfer:
28 mov al, [di+DPT.bDrvCtrl] ; Load Device Control Byte
29 ; Fall to HDrvSel_SelectDriveAndSetControlByte
30
31;--------------------------------------------------------------------
32; Selects Master or Slave drive.
33; Device Control Byte can be used to enable or disable interrupts.
34; This function returns only after drive is ready to accept commands.
35;
36; HDrvSel_SelectDriveAndSetControlByte
37; Parameters:
38; AL: Device Control Byte (to enable/disable interrupts)
39; DS:DI: Ptr to DPT
40; Returns:
41; AH: BIOS Error code
42; CF: 0 if drive selected successfully
43; 1 if any error
44; Corrupts registers:
45; AL, BX
46;--------------------------------------------------------------------
47;ALIGN JUMP_ALIGN
48HDrvSel_SelectDriveAndSetControlByte:
49 push dx
50 push cx
51
52 ; Output Device Control Register to enable/disable interrupts
53 call HDrvSel_OutputDeviceControlByte
54
55 ; Select Master or Slave drive
56 mov dx, [RAMVARS.wIdeBase]
57 add dx, BYTE REG_IDE_DRVHD
58 mov al, [di+DPT.bDrvSel] ; Load Master/Slave selection byte
59 out dx, al ; Select drive
60
61 ; Wait until drive is ready to accept commands
62 call SoftDelay_BeforePollingStatusRegister
63 call HStatus_WaitRdyDefTime
64 pop cx
65 pop dx
66 ret
67
68
69;--------------------------------------------------------------------
70; Outputs Device Control Byte to Device Control Register.
71;
72; HDrvSel_OutputDeviceControlByte
73; Parameters:
74; AL: Device Control Byte
75; DS:DI: Ptr to Disk Parameter Table
76; Returns:
77; DX: Device Control Register address
78; Corrupts registers:
79; BX
80;--------------------------------------------------------------------
81ALIGN JUMP_ALIGN
82HDrvSel_OutputDeviceControlByte:
83 eMOVZX bx, BYTE [di+DPT.bIdeOff] ; CS:BX now points to IDEVARS
84 mov dx, [cs:bx+IDEVARS.wPortCtrl] ; Load Control Block base address
85 add dx, BYTE REGW_IDEC_CTRL ; Add offset to Device Control Register
86 out dx, al ; Output Device Control byte
87 ret
88
89
90;--------------------------------------------------------------------
91; Selects Master or Slave drive and disables interrupts. Interrupts should
92; be disabled for commands that do not transfer data.
93; This function returns after drive is ready to accept commands.
94;
95; HDrvSel_SelectDriveAndDisableIRQ
96; Parameters:
97; DS:DI: Ptr to DPT
98; Returns:
99; AH: BIOS Error code
100; CF: 0 if drive selected successfully
101; 1 if any error
102; Corrupts registers:
103; AL
104;--------------------------------------------------------------------
105ALIGN JUMP_ALIGN
106HDrvSel_SelectDriveAndDisableIRQ:
107 push bx
108 mov al, [di+DPT.bDrvCtrl] ; Load Device Control Byte
109 or al, FLG_IDE_CTRL_nIEN ; Disable interrupts
110 call HDrvSel_SelectDriveAndSetControlByte
111 pop bx
112 ret
Note: See TracBrowser for help on using the repository browser.