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

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

Changes to XTIDE Universal BIOS:

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