OSWORD &62

From BeebWiki
Revision as of 00:25, 18 March 2014 by Jgh (talk)
Jump to: navigation, search

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=Seek track 0
   &03=Request status
   &08=Read data
   &0B=Seek track
   &1B=Stop/Start drive; stop if XY?9=0, start if XY?9=1
   &C8=Read F-code result from LVDOS
   &CA=Transmit F-code to LVDOS

Results

   &00=Ok
   &02=Drive door open
   &03=Media error, eg disk dirty
   &05=Bad SCSI command
   &04=Not ready
   &40=Write protected
   &48=CRC error
   &50=Sector not found
   &60=Bad command
   &61=Bad address
   &63=Volume error
   &65=Bad drive
   &6F=Abort

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 &50 makes all calls appear to return 'Sector not found'.

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=0:X%!11=num%
   A%=&62:CALL&FFF1:A%=?X%:IFfs%<>10:OSCLI"FX143,18,"+STR$fs%
   =A%
   DEFFNfs:LOCALA%,E%,Y%:=(USR&FFDA)AND&FF

See Also

Jgharston 14:00, 26 May 2009 (UTC)