source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Device/Device.asm@ 189

Last change on this file since 189 was 181, checked in by krille_n_@…, 13 years ago

Changes to all parts of the project:

  • Size optimizations.
  • Added a define (EXCLUDE_FROM_XTIDECFG) to exclude unused library code from XTIDECFG.
  • Tried to minimize time spent with interrupts disabled.
  • Some minor attempts to improve speed (reordering instructions etc).
  • Tried to improve readability, did some cleanup and fixed some errors in comments.
File size: 4.1 KB
RevLine 
[150]1; Project name : XTIDE Universal BIOS
2; Description : Command and port direction functions for different device types.
3
4; Section containing code
5SECTION .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
[160]12; CS:BP: Ptr to IDEVARS for the controller
[150]13; Returns:
14; Nothing
15; Corrupts registers:
16; AX, BX, CX, DX
17;--------------------------------------------------------------------
[181]18%ifdef MODULE_SERIAL
[150]19Device_FinalizeDPT:
[158]20 test BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
[175]21 jnz SHORT .FinalizeDptForSerialPortDevice
[150]22 jmp IdeDPT_Finalize
[181]23
[175]24.FinalizeDptForSerialPortDevice:
[181]25 jmp SerialDPT_Finalize
26%else
27 Device_FinalizeDPT EQU IdeDPT_Finalize
[175]28%endif
[150]29
[181]30
[150]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;--------------------------------------------------------------------
[181]41%ifdef MODULE_SERIAL
[150]42Device_ResetMasterAndSlaveController:
[158]43 test BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
[150]44 jnz SHORT ReturnSuccessForSerialPort
[181]45 jmp IdeCommand_ResetMasterAndSlaveController
46%else
47 Device_ResetMasterAndSlaveController EQU IdeCommand_ResetMasterAndSlaveController
[175]48%endif
[150]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;--------------------------------------------------------------------
[181]64%ifdef MODULE_SERIAL
[150]65Device_IdentifyToBufferInESSIwithDriveSelectByteInBH:
66 cmp BYTE [cs:bp+IDEVARS.bDevice], DEVICE_SERIAL_PORT
67 je SHORT .IdentifyDriveFromSerialPort
68 jmp IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
[181]69
[150]70.IdentifyDriveFromSerialPort:
71 jmp SerialCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
[181]72%else
73 Device_IdentifyToBufferInESSIwithDriveSelectByteInBH EQU IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
[175]74%endif
[150]75
[181]76
[150]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;--------------------------------------------------------------------
[181]91%ifdef MODULE_SERIAL
[150]92ALIGN JUMP_ALIGN
93Device_OutputCommandWithParameters:
[158]94 test BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
[150]95 jnz SHORT .OutputCommandToSerialPort
96 jmp IdeCommand_OutputWithParameters
[181]97
[150]98ALIGN JUMP_ALIGN
99.OutputCommandToSerialPort:
100 jmp SerialCommand_OutputWithParameters
[181]101%else
102 Device_OutputCommandWithParameters EQU IdeCommand_OutputWithParameters
[175]103%endif
[150]104
[181]105
[150]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;--------------------------------------------------------------------
[181]117%ifdef MODULE_SERIAL
[150]118ALIGN JUMP_ALIGN
119Device_SelectDrive:
[158]120 test BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
[150]121 jnz SHORT ReturnSuccessForSerialPort
122 jmp IdeCommand_SelectDrive
[181]123
[150]124ReturnSuccessForSerialPort:
125 xor ax, ax
126 ret
[181]127%else
128 Device_SelectDrive EQU IdeCommand_SelectDrive
[175]129%endif
[181]130
Note: See TracBrowser for help on using the repository browser.