Difference between revisions of "OSWORD &62"

From BeebWiki
Jump to: navigation, search
m (1 revision)
Line 147: Line 147:
 
* http://mdfs.net/Docs/Comp/Disk/SCSICmds
 
* http://mdfs.net/Docs/Comp/Disk/SCSICmds
  
[[User:WikiSysop|WikiSysop]] ([[User talk:WikiSysop|talk]]) 13:41, 8 March 2015 (UTC)
+
[[User:WikiSysop|WikiSysop]] ([[User talk:WikiSysop|talk]]) 22:08, 8 March 2015 (UTC)

Revision as of 23:08, 8 March 2015

OSWORD &62 (98 ) - Access LVROM controller

Specification

   Same format as ADFS call &72 (114)
   On entry:
       XY?0  = 0, returned result
       XY!1  = data address
       XY?5  = command
       XY?6  = drive number in b5-b7, sector b16-b20 in b0-b4
       XY?7  = sector number b8-b15
       XY?8  = sector number b0-b7
       XY?9  = number of sectors or 0
       XY?10 = 0
       XY!11 = data length if X%?9=0

This is a standard SCSI command block. The drive number in XY?6 is ORed with the current drive. If VFS is not selected when the call is made, VFS is selected. Consequently, any code that calls OSWORD &62 must remember the current filing system and restore it afterwards. In practice it is easier to select VFS before calling OSWORD &62.

Commands

   &00 Test drive ready *
   &01 Restore to track zero *
   &02 reserved
   &03 Request sense status (SCSI result) *
   &04 Format drive
   &05 Check track format
   &06 Format track
   &07 Format bad track
   &08 Read data *
   &09 Read Verify
   &0A Write data
   &0B Seek track *
   &0C Initialise drive characteristics
   &0D Read ECC burst error length
   &0E Format Alternative Track
   &0F Write Sector Buffer
   &10 Read Sector Buffer
   &12 Read device identity string
   &15 Write drive characteristics
   &1A Read drive characteristics
   &1B Park heads/Start/stop unit; stop if XY?9=0, start if XY?9=1 *
   &2F Verify drive
   
   &70 RAM diagnostic
   &71 reserved
   &72 reserved
   &73 Drive diagnostic
   &74 Controller internal diagnostics
   &75 Read long
   &76 Write long
   
   &C8 Read F-code result from LVDOS *
   &CA Transmit F-code to LVDOS *
   
   &E0 RAM Diagnostic
   &E1 Reserved
   &E2 Reserved
   &E3 Drive Diagnostic
   &E4 Controller Internal Diagnostics
   &E5 Read Long
   &E6 Write Long
   &E7 Retry Statistics

Commands marked with * are listed in Acorn documentation.

Note that commands that would write data are not possible on read-only media used with LVFS.

Results

   &00 Ok
   &01 No index - is drive formatted?
   &02 Drive door open/Seek error/Seek not completed
   &03 Write fault/Media error (disc dirty)
   &04 Drive not ready
   &05 Malformed SCSI command
   &06 Track 0 not found
   
   &10 ID CRC error - ECC error in ID field - sector not found
   &11 Data CRC error - ECC error in data field
   &12 Address mark not found - sector found but no data
   &13 unused
   &14 Seek error - Sector not found
   &15 Seek error - Track not found
   &16 unused
   &17 unused
   &18 Correctable data error
   &19 Bad Track flag set in track accessed
   &1A Format error
   &1B unused
   &1C Unformatted or bad format
   &1D unused
   &1E unused
   &1F unused
   
   &20 Invalid command to controller
   &21 Illegal disc address - beyond end of drive
   &22 unused
   &23 Volume error
   &24 Invalid parameter to controller
   &25 Illegal drive number
   &26
   &27 Unsupported SCSI command
   &28 Media changed
   &29
   &2A
   &2B
   &2C Error count overflow
   &2D
   &2E
   &2F Abort
   
   &30 Controller RAM error
   &31 Controller program memory CRC error
   &33 Controller polynominal error
   
   &7F Unknown SCSI result

The result byte can be preloaded with a value to return if no OSWORD &62 routine exists. For instance, preloading the result with &00 makes all such failed calls appear to succeed, preloading with &10 makes all calls appear to return 'Sector not found'.

Acorn documentation is inconsistant about the range of returned SCSI results. What is not made clear is that bit 6 is used to indicate if the error is from the hard drive controller or the floppy controller. Floppy errors are the same as hard drive errors, ORed with &40. LVFS will only return errors with bit 6 clear as it has no floppy drivers.

Coding

The following routine can be used to perform an OSWORD &62 call. It requires X%=>15-byte control block, Y%=X%DIV256.

   DEFFNlvfs(cmd%,addr%,num%,sect%,drv%):LOCALfs%
   fs%=FNfs:IFfs%<>10:*FX143,18,10
   X%?0=0:X%!1=addr%:X%?5=cmd%:X%?6=drv%*32+((sect%AND&1F0000)DIV65536)
   X%?7=((sect%AND&FF00)DIV256):X%?8=sect%:X%!9=num%:X%!11=0
   A%=&62:CALL&FFF1:A%=?X%:IFfs%<>10:OSCLI"FX143,18,"+STR$fs%
   =A%
   DEFFNfs:LOCALA%,E%,Y%:=(USR&FFDA)AND&FF

See Also

WikiSysop (talk) 22:08, 8 March 2015 (UTC)