Skip to content

Commit 67cea9f

Browse files
author
Ian Seyler
committed
Updates
1 parent 586f6c2 commit 67cea9f

File tree

1 file changed

+76
-15
lines changed

1 file changed

+76
-15
lines changed

src/drivers/nvs/virtio-scsi.asm

Lines changed: 76 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,22 @@ virtio_scsi_init_pop2:
219219
mov al, VIRTIO_STATUS_ACKNOWLEDGE | VIRTIO_STATUS_DRIVER | VIRTIO_STATUS_DRIVER_OK | VIRTIO_STATUS_FEATURES_OK
220220
mov [rsi+VIRTIO_DEVICE_STATUS], al
221221

222+
; REPORT LUNS 0xA0 - 124
223+
224+
; INQUIRY 0x12 - 144
225+
226+
; TEST UNIT READY 0x00 - 108
227+
228+
; REQUEST SENSE 0x03 - 126
229+
230+
; TEST UNIT READY 0x00 - 108
231+
232+
; READ CAPACITY (10) 0x25 - 116
233+
234+
; MODE SENSE (10) 0x5A - 135
235+
236+
; READ (10) 0x28
237+
222238
mov rcx, 1
223239
mov rdi, 0x600000
224240
call virtio_scsi_io
@@ -279,28 +295,29 @@ virtio_scsi_io:
279295
; Add Request to Descriptor Entry 0
280296
mov rax, req ; Address of the request
281297
stosq ; 64-bit address
282-
mov eax, 52
298+
mov eax, 51 ; 19 byte REQ Header + 32 byte CDB
283299
stosd ; 32-bit length
284300
mov ax, VIRTQ_DESC_F_NEXT
285301
stosw ; 16-bit Flags
286302
add rdi, 2 ; Skip Next as it is pre-populated
287303

288-
; Add data to Descriptor Entry 1
304+
; Add Response to Descriptor Entry 1
305+
mov rax, resp ; Address of the response
306+
stosq ; 64-bit address
307+
mov eax, 108
308+
stosd ; 32-bit length
309+
mov eax, VIRTQ_DESC_F_NEXT | VIRTQ_DESC_F_WRITE
310+
stosw ; 16-bit Flags
311+
add rdi, 2 ; Skip Next as it is pre-populated
312+
313+
; Add data to Descriptor Entry 2
289314
mov rax, r9 ; Address to store the data
290315
stosq
291316
shl rcx, 12 ; Covert count to 4096B sectors
292317
mov eax, ecx ; Number of bytes
318+
mov eax, 512 ; TODO remote hardcoded length
293319
stosd
294-
mov ax, VIRTQ_DESC_F_NEXT | VIRTQ_DESC_F_WRITE
295-
stosw ; 16-bit Flags
296-
add rdi, 2 ; Skip Next as it is pre-populated
297-
298-
; Add Response to Descriptor Entry 3
299-
mov rax, resp ; Address of the response
300-
stosq ; 64-bit address
301-
mov eax, 108
302-
stosd ; 32-bit length
303-
mov eax, VIRTQ_DESC_F_WRITE
320+
mov ax, VIRTQ_DESC_F_WRITE
304321
stosw ; 16-bit Flags
305322
add rdi, 2 ; Skip Next as it is pre-populated
306323

@@ -374,13 +391,45 @@ virtio_scsi_id:
374391
; -----------------------------------------------------------------------------
375392

376393
align 16
377-
req:
378-
lun: db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
394+
req: ; 19 bytes
395+
lun: db 0x01, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00
379396
id: dq 0x0000000000000000
380397
task_attr: db 0x00
381398
prio: db 0x00
382399
crn: db 0x00 ;
383-
cdb: db 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;times 32 db 0x00
400+
401+
; 10-byte Command Descriptor Block
402+
cdb: db 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00
403+
404+
blank: db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
405+
406+
; 16-byte Command Descriptor Block
407+
;cdb_opcode: db 0x28
408+
;cdb_blank: db 0x00
409+
;cdb_addr: dq 0x0000000000000000
410+
;cdb_length: dd 0x00000001
411+
;cdb_resv: db 0x00
412+
;cdb_ctrl: db 0x00
413+
414+
415+
; 32-byte Command Descriptor Block
416+
;cdb_opcode: db 0x28
417+
;cdb_ctrl: db 0x00
418+
;cdb_misc1: db 0x00
419+
;cdb_misc2: db 0x00
420+
;cdb_misc3: db 0x00
421+
;cdb_misc4: db 0x00
422+
;cdb_misc5: db 0x00
423+
;cdb_len: db 0x09
424+
;cdb_srvact: dw 0x0000
425+
;cdb_misc6: db 0x00
426+
;cdb_misc7: db 0x00
427+
;cdb_addr: dq 0x0000000000000000
428+
;cdb_misc8: dq 0x0000000000000000
429+
;cdb_length: dd 0x00000200
430+
431+
432+
;cdb: db 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ;times 32 db 0x00
384433

385434
align 16
386435
resp:
@@ -410,5 +459,17 @@ VIRTIO_SCSI_F_HOTPLUG equ 1 ; The host SHOULD enable reporting of hot-plug and
410459
VIRTIO_SCSI_F_CHANGE equ 2 ; The host will report changes to LUN parameters via a VIRTIO_SCSI_T_-PARAM_CHANGE event; the guest SHOULD handle them
411460
VIRTIO_SCSI_F_T10_PI equ 3 ; The extended fields for T10 protection information (DIF/DIX) are included in the SCSI request header
412461

462+
; VIRTIO SCSI command-specific response values
463+
VIRTIO_SCSI_S_OK equ 0
464+
VIRTIO_SCSI_S_OVERRUN equ 1
465+
VIRTIO_SCSI_S_ABORTED equ 2
466+
VIRTIO_SCSI_S_BAD_TARGET equ 3
467+
VIRTIO_SCSI_S_RESET equ 4
468+
VIRTIO_SCSI_S_BUSY equ 5
469+
VIRTIO_SCSI_S_TRANSPORT_FAILURE equ 6
470+
VIRTIO_SCSI_S_TARGET_FAILURE equ 7
471+
VIRTIO_SCSI_S_NEXUS_FAILURE equ 8
472+
VIRTIO_SCSI_S_FAILURE equ 9
473+
413474
; =============================================================================
414475
; EOF

0 commit comments

Comments
 (0)