[150] | 1 | ; Project name : XTIDE Universal BIOS
|
---|
| 2 | ; Description : Serial Device Command functions.
|
---|
| 3 |
|
---|
| 4 | ; Section containing code
|
---|
| 5 | SECTION .text
|
---|
| 6 |
|
---|
[292] | 7 | %define SERIALSERVER_AH_ALREADY_HAS_COMMAND_BYTE
|
---|
| 8 | %define SERIALSERVER_NO_ZERO_SECTOR_COUNTS
|
---|
| 9 |
|
---|
[150] | 10 | ;--------------------------------------------------------------------
|
---|
[179] | 11 | ; SerialCommand_OutputWithParameters
|
---|
[150] | 12 | ; Parameters:
|
---|
[179] | 13 | ; BH: Non-zero if 48-bit addressing used
|
---|
| 14 | ; (ignored at present as 48-bit addressing is not supported)
|
---|
| 15 | ; BL: IDE Status Register bit to poll after command
|
---|
| 16 | ; (ignored at present, since there is no IDE status register to poll)
|
---|
| 17 | ; ES:SI: Ptr to buffer (for data transfer commands)
|
---|
| 18 | ; DS:DI: Ptr to DPT (in RAMVARS segment)
|
---|
| 19 | ; SS:BP: Ptr to IDEREGS_AND_INTPACK
|
---|
[150] | 20 | ; Returns:
|
---|
| 21 | ; AH: INT 13h Error Code
|
---|
[258] | 22 | ; CX: Number of successfully transferred sectors (for transfer commands)
|
---|
[150] | 23 | ; CF: Cleared if success, Set if error
|
---|
| 24 | ; Corrupts registers:
|
---|
[179] | 25 | ; AL, BX, CX, DX, (ES:SI for data transfer commands)
|
---|
[150] | 26 | ;--------------------------------------------------------------------
|
---|
| 27 | ALIGN JUMP_ALIGN
|
---|
[179] | 28 | SerialCommand_OutputWithParameters:
|
---|
[181] | 29 |
|
---|
[277] | 30 | mov ah,SerialServer_Command_Read
|
---|
[181] | 31 |
|
---|
[179] | 32 | mov al,[bp+IDEPACK.bCommand]
|
---|
[150] | 33 |
|
---|
[179] | 34 | cmp al,20h ; Read Sectors IDE command
|
---|
| 35 | jz .readOrWrite
|
---|
[277] | 36 | inc ah ; now SerialServer_Protocol_Write
|
---|
[179] | 37 | cmp al,30h ; Write Sectors IDE command
|
---|
| 38 | jz .readOrWrite
|
---|
[181] | 39 |
|
---|
[179] | 40 | ; all other commands return success
|
---|
| 41 | ; including function 0ech which should return drive information, this is handled with the identify functions
|
---|
[216] | 42 | ;
|
---|
[179] | 43 | xor ah,ah ; also clears carry
|
---|
| 44 | ret
|
---|
[181] | 45 |
|
---|
| 46 | .readOrWrite:
|
---|
[179] | 47 | mov [bp+IDEPACK.bFeatures],ah ; store protocol command
|
---|
[292] | 48 |
|
---|
[233] | 49 | mov dx, [di+DPT_SERIAL.wSerialPortAndBaud]
|
---|
[181] | 50 |
|
---|
[292] | 51 | ALIGN JUMP_ALIGN
|
---|
| 52 | SerialCommand_FallThroughToSerialServer_SendReceive:
|
---|
[150] | 53 |
|
---|
[292] | 54 | %include "SerialServer.asm"
|
---|
[181] | 55 |
|
---|
[334] | 56 | %ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
|
---|
| 57 | %if SerialCommand_FallThroughToSerialServer_SendReceive <> SerialServer_SendReceive
|
---|
| 58 | %error "SerialServer_SendReceive must be the first routine at the top of SerialServer.asm in the Assembly_Library"
|
---|
| 59 | %endif
|
---|
[292] | 60 | %endif
|
---|
| 61 |
|
---|
| 62 | ALIGN JUMP_ALIGN
|
---|
| 63 | SerialCommand_ReturnError:
|
---|
| 64 | stc
|
---|
| 65 | ret
|
---|
| 66 |
|
---|
[150] | 67 | ;--------------------------------------------------------------------
|
---|
[179] | 68 | ; SerialCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
|
---|
| 69 | ; Parameters:
|
---|
| 70 | ; BH: Drive Select byte for Drive and Head Select Register
|
---|
| 71 | ; DS: Segment to RAMVARS
|
---|
| 72 | ; ES:SI: Ptr to buffer to receive 512-byte IDE Information
|
---|
| 73 | ; CS:BP: Ptr to IDEVARS
|
---|
| 74 | ; Returns:
|
---|
| 75 | ; CF: Cleared if success, Set if error
|
---|
| 76 | ; Corrupts registers:
|
---|
| 77 | ; AL, BL, CX, DX, SI, DI, ES
|
---|
| 78 | ;--------------------------------------------------------------------
|
---|
| 79 | ALIGN JUMP_ALIGN
|
---|
| 80 | SerialCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH:
|
---|
[203] | 81 | ;
|
---|
[223] | 82 | ; To improve boot time, we do our best to avoid looking for slave serial drives when we already know the results
|
---|
| 83 | ; from the looking for a master. This is particularly true when doing a COM port scan, as we will end up running
|
---|
| 84 | ; through all the COM ports and baud rates a second time.
|
---|
[203] | 85 | ;
|
---|
[223] | 86 | ; But drive detection isn't the only case - we also need to get the right drive when called on int13h/25h.
|
---|
[203] | 87 | ;
|
---|
| 88 | ; The decision tree:
|
---|
| 89 | ;
|
---|
| 90 | ; Master:
|
---|
[234] | 91 | ; wSerialPortAndBaud Non-Zero: -> Continue with wSerialPortAndBaud (1)
|
---|
| 92 | ; wSerialPortAndBaud Zero:
|
---|
| 93 | ; previous serial drive not found: -> Scan (2)
|
---|
| 94 | ; previous serial drive found: -> Continue with previous serial drive info (3)
|
---|
[223] | 95 | ;
|
---|
[203] | 96 | ; Slave:
|
---|
[234] | 97 | ; wSerialPortAndBaud Non-Zero:
|
---|
| 98 | ; previous serial drive not found: -> Error - Not Found (4)
|
---|
[242] | 99 | ; previous serial drive found: -> Continue with wSerialPackedAndBaud (5)
|
---|
[234] | 100 | ; wSerialPortAndBaud Zero:
|
---|
| 101 | ; previous serial drive not found: -> Error - Not Found (4)
|
---|
| 102 | ; previous serial drive found: -> Continue with previous serial drive info (6)
|
---|
[203] | 103 | ;
|
---|
[223] | 104 | ; (1) This was a port/baud that was explicitly set with the configurator. In the drive detection case, as this
|
---|
[234] | 105 | ; is the Master, we are checking out a new controller, and so don't care if we already have a serial drive.
|
---|
[203] | 106 | ; And as with the int13h/25h case, we just go off and get the needed information using the user's setting.
|
---|
[223] | 107 | ; (2) We are using the special .ideVarsSerialAuto structure. During drive detection, we would only be here
|
---|
[242] | 108 | ; if we hadn't already seen a serial drive (since we only scan if no explicit drives are set),
|
---|
[234] | 109 | ; so we go off to scan.
|
---|
[223] | 110 | ; (3) We are using the special .ideVarsSerialAuto structure. We won't get here during drive detection, but
|
---|
[203] | 111 | ; we might get here on an int13h/25h call. If we have scanned COM drives, they are the ONLY serial drives
|
---|
[234] | 112 | ; in use, and so we use the values from the previously seen serial drive DPT.
|
---|
[223] | 113 | ; (4) No master has been found yet, therefore no slave should be found. Avoiding the slave reduces boot time,
|
---|
[203] | 114 | ; especially in the full COM port scan case. Note that this is different from the hardware IDE, where we
|
---|
| 115 | ; will scan for a slave even if a master is not present. Note that if ANY master had been previously found,
|
---|
[223] | 116 | ; we will do the slave scan, which isn't harmful, it just wastes time. But the most common case (by a wide
|
---|
[203] | 117 | ; margin) will be just one serial controller.
|
---|
| 118 | ; (5) A COM port scan for a master had been previously completed, and a drive was found. In a multiple serial
|
---|
[223] | 119 | ; controller scenario being called with int13h/25h, we need to use the value in bSerialPackedPortAndBaud
|
---|
[203] | 120 | ; to make sure we get the proper drive.
|
---|
[223] | 121 | ; (6) A COM port scan for a master had been previously completed, and a drive was found. We would only get here
|
---|
| 122 | ; if no serial drive was explicitly set by the user in the configurator or that drive had not been found.
|
---|
| 123 | ; Instead of performing the full COM port scan for the slave, use the port/baud value stored during the
|
---|
[203] | 124 | ; master scan.
|
---|
[223] | 125 | ;
|
---|
[233] | 126 | mov dx,[cs:bp+IDEVARS.wSerialPortAndBaud]
|
---|
| 127 | xor ax,ax
|
---|
[277] | 128 |
|
---|
[233] | 129 | push si
|
---|
| 130 | call FindDPT_ToDSDIforSerialDevice
|
---|
| 131 | pop si
|
---|
[258] | 132 | %ifdef MODULE_SERIAL_FLOPPY
|
---|
[262] | 133 | jnc .founddpt
|
---|
[258] | 134 | ;
|
---|
| 135 | ; If not found above with FindDPT_ToDSDIforSerialDevice, DI will point to the DPT after the last hard disk DPT
|
---|
[277] | 136 | ; So, if there was a previously found floppy disk, DI will point to that DPT and we use that value for the slave.
|
---|
[258] | 137 | ;
|
---|
| 138 | cmp byte [RAMVARS.xlateVars+XLATEVARS.bFlopCntAndFirst], 0
|
---|
| 139 | jz .notfounddpt
|
---|
| 140 | .founddpt:
|
---|
| 141 | %else
|
---|
[277] | 142 | jc .notfounddpt
|
---|
[258] | 143 | %endif
|
---|
[242] | 144 | mov ax, [di+DPT_SERIAL.wSerialPortAndBaud]
|
---|
| 145 | .notfounddpt:
|
---|
[223] | 146 |
|
---|
[203] | 147 | test bh, FLG_DRVNHEAD_DRV
|
---|
| 148 | jz .master
|
---|
[179] | 149 |
|
---|
[233] | 150 | test ax,ax ; Take care of the case that is different between master and slave.
|
---|
[292] | 151 | jz SerialCommand_ReturnError
|
---|
[203] | 152 |
|
---|
| 153 | ; fall-through
|
---|
[223] | 154 | .master:
|
---|
[233] | 155 | test dx,dx
|
---|
| 156 | jnz .identifyDeviceInDX
|
---|
[179] | 157 |
|
---|
[277] | 158 | xchg dx, ax ; move ax to dx (move previously found serial drive to dx, could be zero)
|
---|
[223] | 159 |
|
---|
[292] | 160 | .identifyDeviceInDX:
|
---|
[179] | 161 |
|
---|
[292] | 162 | ALIGN JUMP_ALIGN
|
---|
| 163 | SerialCommand_FallThroughToSerialServerScan_ScanForServer:
|
---|
| 164 |
|
---|
| 165 | %include "SerialServerScan.asm"
|
---|
| 166 |
|
---|
[334] | 167 | %ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
|
---|
| 168 | %if SerialCommand_FallThroughToSerialServerScan_ScanForServer <> SerialServerScan_ScanForServer
|
---|
| 169 | %error "SerialServerScan_ScanForServer must be the first routine at the top of SerialServerScan.asm in the Assembly_Library"
|
---|
| 170 | %endif
|
---|
| 171 | %endif
|
---|
[292] | 172 |
|
---|
| 173 |
|
---|