Identify 4.68 KB
Newer Older
Neil Turton's avatar
Neil Turton committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
; Copyright 1996 Acorn Computers Ltd
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
;     http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
; -> Identify.s















;       This contains code for the CD_Identify SWI

















; by MEW of Eesox 28-Apr-93


;----------------------------------------------------------------------------------------------
cd_identify ROUT
;
; on entry:
;          r7 -> control block
;                control block + 0  = SCSI device id
;                control block + 4  = SCSI card number
;                control block + 8  = Logical unit number
;                control block + 12 = 0 - drive type not needed
; on exit:
;          if oVerflow clear:
;                r0 - r1 preserved
64
;                r2 = drive type given by CDFS driver, else -1 if type not recognised
Neil Turton's avatar
Neil Turton committed
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
;          if oVerflow set:
;                r0 -> error block, could be because no drivers loaded
;                r1 - r9 preserved
;
;----------------------------------------------------------------------------------------------

; the 'buffer' in workspace is to be used as follows:
; bytes 0  to  7 are to build the inquiry command up
; bytes 8  to 44 are for the returned inquiry data

 Debug "cd_identify",NL

;--------------------------------
; Are there any drivers loaded ?
;--------------------------------
 LDR       r14, number_of_drivers
 TEQ       r14, #0
 addr      r0, driver_not_present, EQ
 BEQ       error_handler_lookup  ; [ no - so error ]

;----------------------------------------------------------------
; Make up a new control block for the driver with its drive type
;----------------------------------------------------------------
 LDMIA     r7, { r8, r9, r10 }
 MOV       r14, #0
 ADR       r7, control_block
 STMIA     r7, { r8, r9, r10, r14 }

;--------------------------------
; SCSI Inquiry command
;--------------------------------
 BL       space_saver

 ORR       r0, r0, #escapepolloff + readdata   ; prevent 'escape key'

 ADR       r3, cdb_inquiry
 LDMIA     r3, { r4, r5 }
 ORR       r4, r4, r10, LSL #8+5
 STMIA     r2, { r4, r5 }

 ADR       r3, buffer + 8

 MOV       r4, #36

 MOV       r5, #0

 SWI       XSCSI_Op

;          r0  -> 36 byte SCSI inquiry data or 0
;          r1  -> if r0 =0 THEN this -> an error block ie/ the reason inquiry data failed
;          r7  -> control block, ignore the driver type, ie/ control block + 20
;          r11 =  reason code for CD_Identify
;          r12 -> their workspace
;          r13 -> full descending stack

 ADRVC     r0, buffer + 8
 MOVVS     r1, r0
 MOVVS     r0, #0

 ADR       r7, control_block

;--------------------------------
; Prepare for jump to hs
;--------------------------------
 ADR       r4, sld_list
 MOV       r3, #MAX_NUMBER_OF_DRIVERS

02
 LDR       r5, [ r4 ], #4
 SUBS      r3, r3, #1
135
 BEQ       not_recognised
Neil Turton's avatar
Neil Turton committed
136 137 138 139 140 141 142 143 144 145 146 147

 TEQ       r5, #0
 BEQ       %BT02

;--------------------------------
; Jump to each of the drivers
;--------------------------------
 RSB       r6, r3, #MAX_NUMBER_OF_DRIVERS - 1
 ADR       r2, wsp_list



John Beranek's avatar
John Beranek committed
148
 Push      "r0, r1, r3, r4, r6, r7, r12"
Neil Turton's avatar
Neil Turton committed
149 150 151
 LDR       r12, [ r2, r6, LSL #2 ]

;------------------------------------------
Ben Avison's avatar
Ben Avison committed
152 153
; Build a return address including PC flags (if in 26-bit mode)
; Actually doesn't matter if you preserve flags, since CMP will splat them all
Neil Turton's avatar
Neil Turton committed
154
;------------------------------------------
155
 MOV       r11, #DRIVER__Identify
Neil Turton's avatar
Neil Turton committed
156

Ben Avison's avatar
Ben Avison committed
157
 MOV       r14, pc
Neil Turton's avatar
Neil Turton committed
158 159 160 161
 ADD       pc, r5, #4

back_from_identify

162
; r2 = drive type or -1 if not recognised
Neil Turton's avatar
Neil Turton committed
163

John Beranek's avatar
John Beranek committed
164
 Pull      "r0, r1, r3, r4, r6, r7, r12"
Neil Turton's avatar
Neil Turton committed
165 166 167 168 169 170 171 172 173

 CMP       r2, #-1
 BEQ       %BT02

;--------------------------------
; Add my drive type and return
;--------------------------------
 ADD       r12, r2, r6, LSL #2

Ben Avison's avatar
Ben Avison committed
174 175
 STR       r12, [sp, #2*4]
 SWIExitVC
Neil Turton's avatar
Neil Turton committed
176 177 178 179 180 181 182

;----------------------------------------------------------------------------------------------
;----------------------------------------------------------------------------------------------
cdb_inquiry = &12, 0, 0, 0, 36, 0
 ALIGN

;----------------------------------------------------------------------------------------------
183
not_recognised
Neil Turton's avatar
Neil Turton committed
184
 MOV       r2, #-1
Ben Avison's avatar
Ben Avison committed
185 186
 STR       r2, [sp, #2*4]
 SWIExitVC
Neil Turton's avatar
Neil Turton committed
187 188 189 190 191 192

;----------------------------------------------------------------------------------------------

;----------------------------------------------------------------------------------------------

 END