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

Last change on this file since 148 was 148, checked in by aitotat, 13 years ago

Changes to XTIDE Universal BIOS:

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