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