1 | ; Project name : XTIDE Universal BIOS
|
---|
2 | ; Description : Command and port direction functions for different device types.
|
---|
3 |
|
---|
4 | ; Section containing code
|
---|
5 | SECTION .text
|
---|
6 |
|
---|
7 | ;--------------------------------------------------------------------
|
---|
8 | ; Device_FinalizeDPT
|
---|
9 | ; Parameters:
|
---|
10 | ; DS:DI: Ptr to Disk Parameter Table
|
---|
11 | ; ES:SI: Ptr to 512-byte ATA information read from the drive
|
---|
12 | ; CS:BP: Ptr to IDEVARS for the controller
|
---|
13 | ; Returns:
|
---|
14 | ; Nothing
|
---|
15 | ; Corrupts registers:
|
---|
16 | ; AX, BX, CX, DX
|
---|
17 | ;--------------------------------------------------------------------
|
---|
18 | %ifdef MODULE_SERIAL
|
---|
19 | Device_FinalizeDPT:
|
---|
20 | test BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
|
---|
21 | jnz SHORT .FinalizeDptForSerialPortDevice
|
---|
22 | jmp IdeDPT_Finalize
|
---|
23 |
|
---|
24 | .FinalizeDptForSerialPortDevice:
|
---|
25 | jmp SerialDPT_Finalize
|
---|
26 | %else
|
---|
27 | Device_FinalizeDPT EQU IdeDPT_Finalize
|
---|
28 | %endif
|
---|
29 |
|
---|
30 |
|
---|
31 | ;--------------------------------------------------------------------
|
---|
32 | ; Device_ResetMasterAndSlaveController
|
---|
33 | ; Parameters:
|
---|
34 | ; DS:DI: Ptr to DPT (in RAMVARS segment)
|
---|
35 | ; Returns:
|
---|
36 | ; AH: INT 13h Error Code
|
---|
37 | ; CF: Cleared if success, Set if error
|
---|
38 | ; Corrupts registers:
|
---|
39 | ; AL, BX, CX, DX
|
---|
40 | ;--------------------------------------------------------------------
|
---|
41 | %ifdef MODULE_SERIAL
|
---|
42 | Device_ResetMasterAndSlaveController:
|
---|
43 | test BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
|
---|
44 | jnz SHORT ReturnSuccessForSerialPort
|
---|
45 | jmp IdeCommand_ResetMasterAndSlaveController
|
---|
46 | %else
|
---|
47 | Device_ResetMasterAndSlaveController EQU IdeCommand_ResetMasterAndSlaveController
|
---|
48 | %endif
|
---|
49 |
|
---|
50 |
|
---|
51 | ;--------------------------------------------------------------------
|
---|
52 | ; Device_IdentifyToBufferInESSIwithDriveSelectByteInBH
|
---|
53 | ; Parameters:
|
---|
54 | ; BH: Drive Select byte for Drive and Head Select Register
|
---|
55 | ; DS: Segment to RAMVARS
|
---|
56 | ; ES:SI: Ptr to buffer to receive 512-byte IDE Information
|
---|
57 | ; CS:BP: Ptr to IDEVARS
|
---|
58 | ; Returns:
|
---|
59 | ; AH: INT 13h Error Code
|
---|
60 | ; CF: Cleared if success, Set if error
|
---|
61 | ; Corrupts registers:
|
---|
62 | ; AL, BL, CX, DX, SI, DI, ES
|
---|
63 | ;--------------------------------------------------------------------
|
---|
64 | %ifdef MODULE_SERIAL
|
---|
65 | Device_IdentifyToBufferInESSIwithDriveSelectByteInBH:
|
---|
66 | cmp BYTE [cs:bp+IDEVARS.bDevice], DEVICE_SERIAL_PORT
|
---|
67 | je SHORT .IdentifyDriveFromSerialPort
|
---|
68 | jmp IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
|
---|
69 |
|
---|
70 | .IdentifyDriveFromSerialPort:
|
---|
71 | jmp SerialCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
|
---|
72 | %else
|
---|
73 | Device_IdentifyToBufferInESSIwithDriveSelectByteInBH EQU IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
|
---|
74 | %endif
|
---|
75 |
|
---|
76 |
|
---|
77 | ;--------------------------------------------------------------------
|
---|
78 | ; Device_OutputCommandWithParameters
|
---|
79 | ; Parameters:
|
---|
80 | ; BH: Default system timer ticks for timeout (can be ignored)
|
---|
81 | ; BL: IDE Status Register bit to poll after command
|
---|
82 | ; ES:SI: Ptr to buffer (for data transfer commands)
|
---|
83 | ; DS:DI: Ptr to DPT (in RAMVARS segment)
|
---|
84 | ; SS:BP: Ptr to IDEPACK
|
---|
85 | ; Returns:
|
---|
86 | ; AH: INT 13h Error Code
|
---|
87 | ; CF: Cleared if success, Set if error
|
---|
88 | ; Corrupts registers:
|
---|
89 | ; AL, BX, CX, DX, (ES:SI for data transfer commands)
|
---|
90 | ;--------------------------------------------------------------------
|
---|
91 | %ifdef MODULE_SERIAL
|
---|
92 | ALIGN JUMP_ALIGN
|
---|
93 | Device_OutputCommandWithParameters:
|
---|
94 | test BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
|
---|
95 | jnz SHORT .OutputCommandToSerialPort
|
---|
96 | jmp IdeCommand_OutputWithParameters
|
---|
97 |
|
---|
98 | ALIGN JUMP_ALIGN
|
---|
99 | .OutputCommandToSerialPort:
|
---|
100 | jmp SerialCommand_OutputWithParameters
|
---|
101 | %else
|
---|
102 | Device_OutputCommandWithParameters EQU IdeCommand_OutputWithParameters
|
---|
103 | %endif
|
---|
104 |
|
---|
105 |
|
---|
106 | ;--------------------------------------------------------------------
|
---|
107 | ; Device_SelectDrive
|
---|
108 | ; Parameters:
|
---|
109 | ; DS:DI: Ptr to DPT (in RAMVARS segment)
|
---|
110 | ; SS:BP: Ptr to IDEPACK
|
---|
111 | ; Returns:
|
---|
112 | ; AH: INT 13h Error Code
|
---|
113 | ; CF: Cleared if success, Set if error
|
---|
114 | ; Corrupts registers:
|
---|
115 | ; AL, BX, CX, DX
|
---|
116 | ;--------------------------------------------------------------------
|
---|
117 | %ifdef MODULE_SERIAL
|
---|
118 | ALIGN JUMP_ALIGN
|
---|
119 | Device_SelectDrive:
|
---|
120 | test BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
|
---|
121 | jnz SHORT ReturnSuccessForSerialPort
|
---|
122 | jmp IdeCommand_SelectDrive
|
---|
123 |
|
---|
124 | ReturnSuccessForSerialPort:
|
---|
125 | xor ax, ax
|
---|
126 | ret
|
---|
127 | %else
|
---|
128 | Device_SelectDrive EQU IdeCommand_SelectDrive
|
---|
129 | %endif
|
---|
130 |
|
---|