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 | Device_FinalizeDPT:
|
---|
19 | %ifdef MODULE_SERIAL
|
---|
20 | test BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
|
---|
21 | jnz SHORT .FinalizeDptForSerialPortDevice
|
---|
22 | %endif
|
---|
23 | jmp IdeDPT_Finalize
|
---|
24 | %ifdef MODULE_SERIAL
|
---|
25 | .FinalizeDptForSerialPortDevice:
|
---|
26 | jmp SerialDPT_Finalize
|
---|
27 | %endif
|
---|
28 |
|
---|
29 | ;--------------------------------------------------------------------
|
---|
30 | ; Device_ResetMasterAndSlaveController
|
---|
31 | ; Parameters:
|
---|
32 | ; DS:DI: Ptr to DPT (in RAMVARS segment)
|
---|
33 | ; Returns:
|
---|
34 | ; AH: INT 13h Error Code
|
---|
35 | ; CF: Cleared if success, Set if error
|
---|
36 | ; Corrupts registers:
|
---|
37 | ; AL, BX, CX, DX
|
---|
38 | ;--------------------------------------------------------------------
|
---|
39 | Device_ResetMasterAndSlaveController:
|
---|
40 | %ifdef MODULE_SERIAL
|
---|
41 | test BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
|
---|
42 | jnz SHORT ReturnSuccessForSerialPort
|
---|
43 | %endif
|
---|
44 | jmp IdeCommand_ResetMasterAndSlaveController
|
---|
45 |
|
---|
46 |
|
---|
47 | ;--------------------------------------------------------------------
|
---|
48 | ; Device_IdentifyToBufferInESSIwithDriveSelectByteInBH
|
---|
49 | ; Parameters:
|
---|
50 | ; BH: Drive Select byte for Drive and Head Select Register
|
---|
51 | ; DS: Segment to RAMVARS
|
---|
52 | ; ES:SI: Ptr to buffer to receive 512-byte IDE Information
|
---|
53 | ; CS:BP: Ptr to IDEVARS
|
---|
54 | ; Returns:
|
---|
55 | ; AH: INT 13h Error Code
|
---|
56 | ; CF: Cleared if success, Set if error
|
---|
57 | ; Corrupts registers:
|
---|
58 | ; AL, BL, CX, DX, SI, DI, ES
|
---|
59 | ;--------------------------------------------------------------------
|
---|
60 | Device_IdentifyToBufferInESSIwithDriveSelectByteInBH:
|
---|
61 | %ifdef MODULE_SERIAL
|
---|
62 | cmp BYTE [cs:bp+IDEVARS.bDevice], DEVICE_SERIAL_PORT
|
---|
63 | je SHORT .IdentifyDriveFromSerialPort
|
---|
64 | %endif
|
---|
65 | jmp IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
|
---|
66 | %ifdef MODULE_SERIAL
|
---|
67 | .IdentifyDriveFromSerialPort:
|
---|
68 | jmp SerialCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
|
---|
69 | %endif
|
---|
70 |
|
---|
71 | ;--------------------------------------------------------------------
|
---|
72 | ; Device_OutputCommandWithParameters
|
---|
73 | ; Parameters:
|
---|
74 | ; BH: Default system timer ticks for timeout (can be ignored)
|
---|
75 | ; BL: IDE Status Register bit to poll after command
|
---|
76 | ; ES:SI: Ptr to buffer (for data transfer commands)
|
---|
77 | ; DS:DI: Ptr to DPT (in RAMVARS segment)
|
---|
78 | ; SS:BP: Ptr to IDEPACK
|
---|
79 | ; Returns:
|
---|
80 | ; AH: INT 13h Error Code
|
---|
81 | ; CF: Cleared if success, Set if error
|
---|
82 | ; Corrupts registers:
|
---|
83 | ; AL, BX, CX, DX, (ES:SI for data transfer commands)
|
---|
84 | ;--------------------------------------------------------------------
|
---|
85 | ALIGN JUMP_ALIGN
|
---|
86 | Device_OutputCommandWithParameters:
|
---|
87 | %ifdef MODULE_SERIAL
|
---|
88 | test BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
|
---|
89 | jnz SHORT .OutputCommandToSerialPort
|
---|
90 | %endif
|
---|
91 | jmp IdeCommand_OutputWithParameters
|
---|
92 | %ifdef MODULE_SERIAL
|
---|
93 | ALIGN JUMP_ALIGN
|
---|
94 | .OutputCommandToSerialPort:
|
---|
95 | jmp SerialCommand_OutputWithParameters
|
---|
96 | %endif
|
---|
97 |
|
---|
98 | ;--------------------------------------------------------------------
|
---|
99 | ; Device_SelectDrive
|
---|
100 | ; Parameters:
|
---|
101 | ; DS:DI: Ptr to DPT (in RAMVARS segment)
|
---|
102 | ; SS:BP: Ptr to IDEPACK
|
---|
103 | ; Returns:
|
---|
104 | ; AH: INT 13h Error Code
|
---|
105 | ; CF: Cleared if success, Set if error
|
---|
106 | ; Corrupts registers:
|
---|
107 | ; AL, BX, CX, DX
|
---|
108 | ;--------------------------------------------------------------------
|
---|
109 | ALIGN JUMP_ALIGN
|
---|
110 | Device_SelectDrive:
|
---|
111 | %ifdef MODULE_SERIAL
|
---|
112 | test BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
|
---|
113 | jnz SHORT ReturnSuccessForSerialPort
|
---|
114 | %endif
|
---|
115 | jmp IdeCommand_SelectDrive
|
---|
116 | %ifdef MODULE_SERIAL
|
---|
117 | ReturnSuccessForSerialPort:
|
---|
118 | xor ax, ax
|
---|
119 | ret
|
---|
120 | %endif
|
---|