Commit 4ab90446 authored by Neil Turton's avatar Neil Turton
Browse files

Import from cleaned 360 CD

parents
hdr/** gitlab-language=armasm linguist-language=armasm linguist-detectable=true
s/** gitlab-language=armasm linguist-language=armasm linguist-detectable=true
Bit settings for CDFSDriver: (bit numbering starts from 0, ie/ bit 0 = 1, bit 3 = 8 etc; )
Description Bit number Command Length of CDB
---------------------------------------------------------------------
SCSI_READ 6 &28 10
SCSI_SEEK 7 &2b 10
SCSI_INQUIRY 8 &12 6
SCSI_CAPACITY/DISCUSED 9 &25 10
SCSI_READY 10 &00 6
SCSI_STOPOPEN 11 &1b 6
SCSI_CHECK 12 &1d 6
SCSI_STATUS 13 &00 6
SCSI_CONTROL 14 --- -- this calls SWI SCSI_Control
SCSI_PREFETCH 15 &28 10 see SCSI_READ
SCSI_RESET 16 --- -- this calls SWI SCSI_Initialise
CDFSDriver history:
;-----------------------------------------------------------------------------------------------
2.15 01-Mar-93 MEW Eesox Totally rewritten to allow soft-loadable driver support
;-----------------------------------------------------------------------------------------------
2.16 24-Jun-93 MEW Eesox Bug fix: problem with more than one drive type - it didn't
send the discchanged command to the correct driver !
;-----------------------------------------------------------------------------------------------
2.21 05-Jul-94 MEW Eesox CD_ReadAudio added
;-----------------------------------------------------------------------------------------------
2.30 19-Jul-94 MEW Eesox CD_ReadUserData added. 'buffer' extended from 256 to 2340 bytes
;-----------------------------------------------------------------------------------------------
2.30a 19-Sep-94 MEW Eesox Bug fix - removed check to see if soft-load driver can support
the SWI.
;-----------------------------------------------------------------------------------------------
2.31 25-Jan-95 MEW Eesox Added support for CD_GetAudioParms and CD_SetAudioParms
;-----------------------------------------------------------------------------------------------
; CD_Routine Headers
; This contains details of entry and exit conditions for the general routines that all
; soft drivers may use
; Routines defined:
;
; cd_checkdrive
; cd_control
; cd_converttolba
; cd_converttomsf
; cd_discused
; cd_driveready
; cd_drivestatus
; cd_inquiry
; cd_lasterror
; cd_opendrawer
; cd_prefetch
; cd_readdata
; cd_reset
; cd_seekto
; cd_stopdisc
; cd_version
; cd_identify
; cd_register
; cd_unregister
;-----------------------------------------------------------------------------------------------
cd_version
;
; on entry:
; nothing needed
; on exit:
; r0 -> version string ( word 0 = version number * 100, word 1 .. = null term. string )
;
;-----------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------
cd_lasterror
;
; on entry:
; nothing needed
; on exit:
; r0 = number of last error, or 0 if none
;
;-----------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------
cd_prefetch
;
; on entry:
; r0 = addressing mode
; r1 = block number
; r7 -> control block
; on exit:
; if error then r0-> error block, else all regs preserved
;
;-----------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------
cd_readdata **** check this with Mark ****
;
; on entry:
; r0 = addressing mode
; r1 = block number
; r2 = number of blocks
; r3 -> where to put data
; r4 = number of bytes from each block wanted
; r7 -> control block
; r12 -> any workspace required
; r13 -> full descending stack
; on exit:
; if error then r0-> error block, else all regs preserved
;
; r8 = scsi device id
; r9 = card number
; r10 = lun
;-----------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------
cd_seekto
;
; on entry:
; r0 = addressing mode
; r1 = block number
; on exit:
; if error then r0-> error block, else all regs preserved
;
;-----------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------
cd_inquiry
;
; on entry:
; r0 -> place to put the inquiry data
; r7 -> control block
; on exit:
;
;-----------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------
cd_discused
;
; on entry:
; r0 = addressing mode that the disc length should be returned in
; r1 -> storage area to put data in
; r7 -> control block
; on exit:
;
;-----------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------
cd_driveready
;
; on entry:
; r7 -> control block
; on exit:
; r0 = 0 if drive is OK, else r0 = 1
;
;-----------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------
cd_stopdisc
;
; on entry:
; r7 -> control block
; on exit:
; usual error stuff
;
;-----------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------
cd_opendrawer
;
; on entry:
; r7 -> control block
; on exit:
; usual error stuff
;
;-----------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------
cd_converttolba
; on entry:
; r0 = address mode
; r1 = address
; on exit:
; if oVerflow set then r0 -> error block
; r1 = new address
;
;-----------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------
cd_converttomsf
; on entry:
; r0 = address mode
; r1 = address
; on exit:
; if oVerflow set then r0 -> error block
; r1 = new address
;
;-----------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------
cd_drivestatus
;
; on entry:
; r7 -> control block
; on exit:
; r0 = status { 1=OK, 2=BUSY, 4=NOTREADY, 8=UNAVAILABLE }
;-----------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------
cd_control
;
; on entry:
; r0 = 0, 1 or 2 to set the level of error response
; r7 -> control block
; on exit:
; usual error stuff
;-----------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------
cd_reset
;
; on entry:
; r7 -> control block
; on exit:
; if error then r0-> error block, else all regs preserved
;
;-----------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------
cd_checkdrive
;
; on entry:
; r7 -> control block
; on exit:
; usual error stuff
; r0 = drive status bits
;-----------------------------------------------------------------------------------------------
;----------------------------------------------------------------------------------------------
cd_identify
;
; 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
; r2 = drive type given by CDFS driver, else -1 if type not recognized
; 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
;--------------------------------------------------------------------------------------------
;----------------------------------------------------------------------------------------------
cd_register
;
; on entry:
; r0 -> block
; block + 0 = information word for CDFSDriver module
; block + 4 = number of times registered (should be set to zero
; and will be updated by CDFSDriver)
; block + 8 = number of drive types recognized by this driver
; r1 -> special tag (&EE50EE50 = 1 word) followed by the handler code
; r2 -> workspace for soft-loadable module (this will be R12 in the handler)
;
; r12 -> my workspace pointer
; on exit:
; Overflow flag clear if registered OK, else set and R0->error block.
;
;----------------------------------------------------------------------------------------------
;----------------------------------------------------------------------------------------------
cd_unregister
;
; on entry:
; r0 -> block
; block + 0 = information word for CDFSDriver module
; block + 4 = number of times registered (should be set to zero
; and will be updated by CDFSDriver)
; block + 8 = number of drive types recognized by this driver
; r1 -> special tag (&EE50EE50 = 1 word) followed by the handler code
;
; r12 -> my workspace pointer
; on exit:
; Overflow flag clear if registered OK, else set and R0->error block.
;
;----------------------------------------------------------------------------------------------
; r8 = registered count
;----------------------------------------------------------------------------------------------
REM -----------------------------------------------------------------------------------------------
REM >CDDemo
REM Provides basic details of how to use CD SWIs
REM Copyright Acorn Computers, 1994
REM
REM This code should be used in conjunction with the CDFS SWIs Application Note
REM available from Acorn Developer Support.
REM
REM For further details contact:
REM Technical Support
REM Acorn Computers Ltd
REM Acorn House
REM Vision Park
REM Histon
REM Cambs CB4 4AE
REM
REM Tel: +44 223 254254
REM -----------------------------------------------------------------------------------------------
DriveNumber% = 0 : REM 0 = first, 1 = second etc
END = &8000000
DIM ControlBlock 30
REM -----------------------------------------------------------------------------------------------
REM Initialise the Control Block for subsequent CDFS access
REM -----------------------------------------------------------------------------------------------
PROCInitControlBlock(DriveNumber%)
REM -----------------------------------------------------------------------------------------------
REM User code can be placed after this point eg,.......
REM -----------------------------------------------------------------------------------------------
REM -----------------------------------------------------------------------------------------------
REM Check the drive status 1=OK, 2=BUSY, 4=NOT READY, 5=UNAVAILABLE
REM -----------------------------------------------------------------------------------------------
SYS "CD_DriveStatus",,,,,,,,ControlBlock TO stat%
REM -----------------------------------------------------------------------------------------------
REM Eject the disc if the drive status is OK, otherwise print an error message
REM -----------------------------------------------------------------------------------------------
IF stat% = 1 THEN
SYS "CD_OpenDrawer",,,,,,,,ControlBlock
ELSE
PRINT "Drive status error : ", stat%
ENDIF
END
REM -----------------------------------------------------------------------------------------------
REM InitControlBlock(drive%)
REM
REM This routine calls the ConvertDriveToDevice SWI, then sets up
REM ControlBlock (defined globally) with the necesary data for further
REM CDFS calls
REM -----------------------------------------------------------------------------------------------
DEFPROCInitControlBlock(drive%)
LOCAL device%, a
SYS "CDFS_ConvertDriveToDevice", drive% TO a,device%
ControlBlock!0 = (device% AND &00000007)
ControlBlock!4 = ((device% >> 3) AND &00000003)
ControlBlock!8 = ((device% >> 5) AND &00000007)
ControlBlock!12 = ((device% >> 8) AND &000000FF)
ControlBlock!16 = ((device% >> 16) AND &0000FFFF)
ENDPROC
This diff is collapsed.
; -> Notes for CDFSDriver
General flow of driver:
-----------------------
eg/ after SWI CD_..
1. Entry with R11 = SWI number AND 63
R12 -> workspace
R13 -> stack
R14 = return address
2. Is SWI CD_.. a known SWI ? ( eg/ R11 is too big )
3. Check control block if needed
4. Clear Command Descriptor Block ( thats the bit sent through SCSI_Op )
5. Clear misc. vars.
6. Put opcode for Command Descriptor Block in.
7. Put parametersize, numberofbytesreturned, r/w/nodata and storagearea in
8. Jump to routine for each SWI, if nec.
9. Use either the Acorn conforming SCSI_Op or the Oak one
Either way registers need to be set
10. On error branch to error handler - see ( 13 )
11. Jump to routine for each SWI, if nec.
12. Go 'Home' or 'PreHome' END basically
Error !
13. If error is 'Unit attention' or 'Check condition' THEN setdischaschanged
14. If error THEN jump to routine for each SWI if nec.
15. Return error to caller of SWI with overflow set and R0 -> error block
Operating System works out the rest
( ie/ if XCD_.. was called instead of CD_.. )
Meaning of number returned by CD_Supported
Bits Description: ( if set )
---- -----------------------
0 - 2 Level to which CD_AudioControl is supported ( 0 to 7 )
0 = no support at all
1 = supported to level 0
7 = supported to level 6
3 CD_Prefetch supported
4 CD_CloseDrawer supported
5 CD_AudioLevel supported
6 - 31 RESERVED ( 0 )
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.
# 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.
#
# Makefile for CDFS Driver
#
# ***********************************
# *** C h a n g e L i s t ***
# ***********************************
# Date Name Description
# ---- ---- -----------
# 25-May-94 AMcC Created.
# 23-Feb-95 AMcC Resources now copied to CDFSRes
#
#
# Paths
#
EXP_HDR = <export$dir>
#
# Generic options:
#
MKDIR = cdir
AS = aasm
CP = copy
RM = remove
CFLAGS = -c -depend !Depend -IC:
AFLAGS = -depend !Depend -Stamp -quit -module
CPFLAGS = ~cfr~v
#
# Program specific options:
#
COMPONENT = CDFSDriver
EXPORTS = ${EXP_HDR}.CDROM ${EXP_HDR}.CDErrors
SOURCE = s.Main
TARGET = rm.CDFSDriver
RDIR = Resources
LDIR = ${RDIR}.${LOCALE}
CDFSRES = <src$dir>.OS_Core.FileSys.CDFS.CDFSRes
RESDIR = ${CDFSRES}.Resources.${Locale}.Resources.CDFSDriver.${COMPONENT}
#
# Generic rules:
#
rom: ${TARGET}
@echo ${COMPONENT}: rom module built
export: ${EXPORTS}
@echo ${COMPONENT}: export complete
install_rom: ${TARGET}
${CP} ${TARGET} ${INSTDIR}.${COMPONENT} ${CPFLAGS}
@echo ${COMPONENT}: rom module installed
resources:
@echo ${COMPONENT}: Resources are in CDFSRes
clean:
${RM} ${TARGET}
@echo ${COMPONENT}: cleaned
${TARGET}: ${SOURCE}
${AS} ${AFLAGS} -To $@ -From ${SOURCE}
${EXP_HDR}.CDROM: hdr.CDROM
${CP} hdr.CDROM $@ ${CPFLAGS}
${EXP_HDR}.CDErrors: hdr.CDErrors
${CP} hdr.CDErrors $@ ${CPFLAGS}
# Dynamic dependencies:
| 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.
|
Dir <Obey$Dir>
amu_machine clean
| 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.
|
Dir <Obey$Dir>
amu_machine rom
; > Version
GBLA Version
GBLS VString
GBLS Date
Version SETA 233 ; CDFSDriver
VString SETS "2.33"
Date SETS "03 Feb 1995"
END
; 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.
;
; >Hdr.CDFSErrors
; *********************************************************************************************
; ** CDFS Driver errors **
; *********************************************************************************************
^ &00803400
CDFSDRIVERERROR__UNUSED # 1 ; 0
CDFSDRIVERERROR__BAD_ALIGNMENT # 1 ; 1
CDFSDRIVERERROR__DRIVE_NOT_SUPPORTED # 1 ; 2
CDFSDRIVERERROR__BAD_MODE # 1 ; 3
CDFSDRIVERERROR__INVALID_PARAMETER # 1 ; 4
CDFSDRIVERERROR__NOT_AUDIO_TRACK # 1 ; 5
CDFSDRIVERERROR__NO_CADDY # 1 ; 6
CDFSDRIVERERROR__NO_DRIVE # 1 ; 7
CDFSDRIVERERROR__INVALID_FORMAT # 1 ; 8
CDFSDRIVERERROR__BAD_MINUTES # 1 ; 9
CDFSDRIVERERROR__BAD_SECONDS # 1 ; 10
CDFSDRIVERERROR__BAD_BLOCKS # 1 ; 11
CDFSDRIVERERROR__PHYSICAL_BLOCK_ERROR # 1 ; 12
CDFSDRIVERERROR__DRAWER_LOCKED # 1 ; 13
CDFSDRIVERERROR__WRONG_DATA_MODE # 1 ; 14
CDFSDRIVERERROR__CHANNEL_NOT_SUPPORTED # 1 ; 15
CDFSDRIVERERROR__BAD_DEVICE_ID # 1 ; 16
CDFSDRIVERERROR__BAD_CARD_NUMBER # 1 ; 17
CDFSDRIVERERROR__BAD_LUN_NUMBER # 1 ; 18
CDFSDRIVERERROR__NO_SUCH_TRACK # 1 ; 19
CDFSDRIVERERROR__FAULTY_DISC # 1 ; 20
CDFSDRIVERERROR__NO_SUCH_BLOCK # 1 ; 21
CDFSDRIVERERROR__DRIVE_DOES_NOT_SUPPORT_THAT # 1 ; 22
CDFSDRIVERERROR__DRIVER_NOT_PRESENT # 1 ; 23
CDFSDRIVERERROR__SWI_NOT_SUPPORTED # 1 ; 24
CDFSDRIVERERROR__TOO_MANY_DRIVERS # 1 ; 25
CDFSDRIVERERROR__NOT_REGISTERED # 1 ; 26
END
; 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.
;
;; -> macros
;; =============================================
;; Macros should be kept in ALPHABETICAL order !
;; =============================================
;;
;; CDFSDriverError
;; CLV
;; Debug
;; Debug0
;; DebugDisplay
;; DebugWaitForAKey
;;
;************************************
; This allows nice errors from CDFS driver
;************************************
MACRO
$label CDFSDriverError $name, $message
$name DCD CDFSDriverErrorNumber
= "$message"
= 0
CDFSDriverErrorNumber SETA CDFSDriverErrorNumber + 1
ALIGN
MEND
; *******************************************
; *** Clear overflow flag - will set nzCv ***
; *******************************************
; Note: (AMcC 02-Feb-95)
; Not the same as CLRV Macro in Global Hdr CPU.Generic26
;
MACRO
$label CLV $cond
$label EORVSS pc, pc, # Overflow_Flag
MEND
; **********************************************************
; This will print a message if 'debug' = ON.
; **********************************************************
MACRO
$label Debug $string,$nl
$label [ debug=ON
STASH r14
[ hostvdu=ON
SWI XHostFS_HostVdu
]
SWI XOS_WriteS
= "$string"
[ "$nl"="NL"
= 13,10
]
= 0
ALIGN
[ hostvdu=ON
SWI XHostFS_TubeVdu
]
GRAB r14
]
MEND
; **********************************************************
; This will perform a XOS_Write0 if 'debug' = ON.
; **********************************************************
MACRO
$label Debug0 $string,$nl
$label [ debug=ON
STASH r14
[ hostvdu=ON
SWI XHostFS_HostVdu
]
SWI XOS_Write0
[ "$nl"="NL"
SWI XOS_NewLine
]
[ hostvdu=ON
SWI XHostFS_TubeVdu
]
GRAB r14
]
MEND
; **********************************************************
; This will perform a Display if 'debug' = ON.
; **********************************************************
MACRO
$label DebugDisplay $string,$nl
$label [ debug=ON
STASH r14
[ hostvdu=ON
SWI XHostFS_HostVdu
]
Display $string,$nl
[ hostvdu=ON
SWI XHostFS_TubeVdu
]
GRAB r14
]
MEND
; **********************************************************
; This will perform a wait-for-key if 'debug' = ON.
; **********************************************************
MACRO
$label DebugWaitForAKey
$label [ debug=ON
STASH "r0-r2,r14"
MOV R0, #122
01
SWI XOS_Byte
CMP R1, #&FF
BEQ %BT01
GRAB "r0-r2,r14"
]
MEND
END
; 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.
;
SUBT Exported CDROM Driver constants
OldOpt SETA {OPT}
OPT OptNoList+OptNoP1List
; ***********************************
; *** C h a n g e L i s t ***
; ***********************************
; Date Name Description
; ---- ---- -----------
; 20-Dec-94 AMcC Created
; 04-Jan-95 AMcC Undocumented SWIs commented as Private
; (some may cause damage to drive if used incorrectly)
; Not marked as NOPs 'cause some are used by CDFSDriver
;
SWIClass SETS CDROMSWI_Name
^ CDROMSWI_Base ; &41240
AddSWI Version ; +0
AddSWI ReadData ; +1
AddSWI SeekTo ; +2
AddSWI DriveStatus ; +3
AddSWI DriveReady ; +4
AddSWI GetParameters ; +5 Private
AddSWI SetParameters ; +6 Private
AddSWI OpenDrawer ; +7
AddSWI EjectButton ; +8
AddSWI EnquireAddress ; +9
AddSWI EnquireDataMode ; +10 Private
AddSWI PlayAudio ; +11
AddSWI PlayTrack ; +12
AddSWI AudioPause ; +13
AddSWI EnquireTrack ; +14
AddSWI ReadSubChannel ; +15 Private
AddSWI CheckDrive ; +16
AddSWI DiscChanged ; +17 Private
AddSWI StopDisc ; +18
AddSWI DiscUsed ; +19
AddSWI AudioStatus ; +20
AddSWI Inquiry ; +21
AddSWI DiscHasChanged ; +22 Private
AddSWI Control ; +23
AddSWI Supported ; +24 Private
AddSWI Prefetch ; +25
AddSWI Reset ; +26
AddSWI CloseDrawer ; +27 Private
AddSWI IsDrawerLocked ; +28 Private
AddSWI AudioControl ; +29 Private
AddSWI LastError ; +30
AddSWI AudioLevel ; +31 Private
AddSWI Register ; +32
AddSWI Unregister ; +33
AddSWI ByteCopy ; +34 Private
AddSWI Identify ; +35
AddSWI ConvertToLBA ; +36
AddSWI ConvertToMSF ; +37
AddSWI ReadAudio ; +38
AddSWI ReadUserData ; +39
AddSWI SeekUserData ; +40
AddSWI GetAudioParms ; +41
AddSWI SetAudioParms ; +42
OPT OldOpt
END
; 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.
;
; Hash defines
X_bit * 1:SHL:17
XCD_BaseNumber * (CDROMSWI_Base:OR:X_bit)
; ***************************************************************************
; *** Reason codes passed to soft-load drivers ***
; ***************************************************************************
^ 0
DRIVER__ReadData # 1 ; 0
DRIVER__SeekTo # 1 ; 1
DRIVER__DriveStatus # 1 ; 2
DRIVER__DriveReady # 1 ; 3
DRIVER__GetParameters # 1 ; 4
DRIVER__SetParameters # 1 ; 5
DRIVER__OpenDrawer # 1 ; 6
DRIVER__EjectButton # 1 ; 7
DRIVER__EnquireAddress # 1 ; 8
DRIVER__EnquireDataMode # 1 ; 9
DRIVER__PlayAudio # 1 ; 10
DRIVER__PlayTrack # 1 ; 11
DRIVER__AudioPause # 1 ; 12
DRIVER__EnquireTrack # 1 ; 13
DRIVER__ReadSubChannel # 1 ; 14
DRIVER__CheckDrive # 1 ; 15
DRIVER__DiscChanged # 1 ; 16
DRIVER__StopDisc # 1 ; 17
DRIVER__DiscUsed # 1 ; 18
DRIVER__AudioStatus # 1 ; 19
DRIVER__Inquiry # 1 ; 20
DRIVER__DiscHasChanged # 1 ; 21
DRIVER__Control # 1 ; 22
DRIVER__Supported # 1 ; 23
DRIVER__Prefetch # 1 ; 24
DRIVER__Reset # 1 ; 25
DRIVER__CloseDrawer # 1 ; 26
DRIVER__IsDrawerLocked # 1 ; 27
DRIVER__AudioControl # 1 ; 28
DRIVER__AudioLevel # 1 ; 29
DRIVER__Identify # 1 ; 30
DRIVER__ReadAudio # 1 ; 31
DRIVER__ReadUserData # 1 ; 32
DRIVER__SeekUserData # 1 ; 33
DRIVER__GetAudioParms # 1 ; 34
DRIVER__SetAudioParms # 1 ; 35
;***************************************************************************
OAK * 1
ACORN * 0
ON * 1
OFF * 0
TRUE * 1
FALSE * 0
hostvdu * ON ; debug to host
debug * OFF ; prints debugging information
commanddebug * OFF ; Keeps a list of SWI's called
CheckConfiguredDrives * ON ; don't start up if no drives configured
;------------------------------------------------------------------
RESERVED * 0
CONTROLBYTE * 0
LBAFormat * 0
MSFFormat * 1
PBFormat * 2
SmallestMode * 1
LargestMode * 2
;*********************************************************************************************
; Details on data modes (mode 1, mode 2 form 1, mode 2 form 2)
;*********************************************************************************************
mode1datasize * 2048
mode2datasize * 2340
mode1datasizeHBLB * &00080000 ; high/byte low/byte of above
mode2datasizeHBLB * &20090000 ;
MODE2__HEADER_M * 0
MODE2__HEADER_S * 1
MODE2__HEADER_F * 2
MODE2__HEADER_MODE * 3
MODE2__HEADER_SIZE * 4
MODE2__SUB_HEADER_FILE * 0 ; These fields are repeated at 4,5,6,7
MODE2__SUB_HEADER_CHANNEL * 1 ;
MODE2__SUB_HEADER_SUBMODE * 2 ;
MODE2__SUB_HEADER_CODING * 3 ;
MODE2__SUB_HEADER_SIZE * 8
MODE2__TOTALHEADERSIZE * MODE2__HEADER_SIZE + MODE2__SUB_HEADER_SIZE
SUBMODE__FORM * (1:SHL:5)
USERDATA__MODE2FORM1 * 2048
USERDATA__MODE2FORM2 * 2324
;*********************************************************************************************
bit17 * 2_100000000000000000
MaxNumberOfSeconds * 59
MinNumberOfSeconds * 2
MaxNumberOfBlocks * 74
MaxSCSIcardnumber * 3
MaxLUN * 3
MaxSCSIdeviceID * 6
PhysicalBlockDifference * 2 * ( MaxNumberOfBlocks + 1 ) ; 2 seconds
SWIBaseNumber * CDROMSWI_Base
ErrorBlock * &00803400
HARDRAMLOCATION * &8A
BITSUSEDBYDRIVENUMBER * 2_11111
BITSUSEDBYBUFFER * 2_11100000
;******************* Used for macro to allow nice error blocks ***********
GBLA CDFSDriverErrorNumber
CDFSDriverErrorNumber SETA ErrorBlock
;******************* SCSI error numbers ***************************
SCSIErrorNumber * &00020100
^ SCSIErrorNumber
NoRoom # 1 ; 0
UnknownSCSISWI # 1 ; 1
UnknownReason # 1 ; 2
FailedBusReset # 1 ; 3
InvalidHostId # 1 ; 4
InvalidDeviceId # 1 ; 5
gap # 3 ; 6 - 8
DeviceNotIdle # 1 ; 9
TimeoutSelection # 1 ; 10
TimeoutOther # 1 ; 11
CommandQueueError # 1 ; 12
CommandQueFull # 1 ; 13
ReservationError # 1 ; 14
InvalidParameters # 1 ; 15
ParameterError # 1 ; 16
NotFromIRQ # 1 ; 17
OperationAborted # 1 ; 18
UnexpectedDisconnect # 1 ; 19
;***************** SCSI sense numbers ( TargetError )**********************
SCSISenseNumber * &201C0
^ SCSISenseNumber
NoSense # 1 ; 0
RecoveredError # 1 ; 1
NotReady # 1 ; 2
MediumError # 1 ; 3
HardwareError # 1 ; 4
IllegalRequest # 1 ; 5
UnitAttention # 1 ; 6
DataProtect # 1 ; 7
BlankCheck # 1 ; 8
VendorUnique # 1 ; 9
CopyAborted # 1 ; 10
AbortedCommand # 1 ; 11
Equal # 1 ; 12
VolumeOverflow # 1 ; 13
Miscompare # 1 ; 14
ReservedSenseKey # 1 ; 15
;***************** SCSI status byte numbers *******************************
SCSIStatusNumber * &20180
^ SCSIStatusNumber
CheckCondition # 1
Busy # 1
Unknown # 1
;***************************** Values for SCSI_Op ************************
accesskey * 1
readdata * 2_01000000000000000000000000
;writedata * 2_10000000000000000000000000
nodata * 2_00000000000000000000000000 ; = 0
scatterliston * 2_100000000000000000000000000
scatterlistoff * 2_000000000000000000000000000 ; = 0
escapepollon * 2_0000000000000000000000000000 ; = 0
escapepolloff * 1:SHL:27
retryoff * 2_00000000000000000000000000000 ; = 0
retryon * 2_10000000000000000000000000000
backgroundon * 2_100000000000000000000000000000
backgroundoff * 2_000000000000000000000000000000 ; = 0
;I_bit * &08000000
FIRQ_Flag * 1:ROL:26
IRQ_Flag * 1:ROL:27
Overflow_Flag * 1:ROL:28
Carry_Flag * 1:ROL:29
Zero_Flag * 1:ROL:30
Negative_Flag * 1:ROL:31
;------------------------------------------------------------------
; Structure of r7 -> control block
;------------------------------------------------------------------
^ 0
SdeviceIDoffset # 4
LScardnumberoffset # 4
LUNoffset # 4
drivetypeoffset # 4
control_block_size # 0
;------------------------------------------------------------------
; Structure of register control block
;------------------------------------------------------------------
^ 0
RCB_INFOWORD # 4
RCB_REGISTERED # 4
RCB_DRIVETYPES # 4
;----------------------------------------------------------------------------------------------
; The information word when registering
;----------------------------------------------------------------------------------------------
USE_SCSI_READ * 1<<6
USE_SCSI_SEEK * 1<<7
USE_SCSI_INQUIRY * 1<<8
USE_SCSI_CAPACITY * 1<<9
USE_SCSI_READY * 1<<10
USE_SCSI_STOPOPEN * 1<<11
USE_SCSI_CHECK * 1<<12
USE_SCSI_STATUS * 1<<13
USE_SCSI_CONTROL * 1<<14
USE_SCSI_PREFETCH * 1<<15
USE_SCSI_RESET * 1<<16
USE_PROPRIETARY_RUD * 1<<17 ; = 1 if support own method of reading data
USE_COMPLEX_RUD * 1<<18 ; = 1 if want SCSI scatter list method of reading data
USE_PROPRIETARY_SUD * 1<<19 ; = 1 if support own method of seeking to data
USE_COMPLEX_SUD * 1<<20 ; = 1 if want SCSI scatter list method of seeking to data
;----------------------------------------------------------------------------------------------
; Maximum number of soft-loadable device drivers
; REMEMBER that each soft-load driver can have 4 sub values and that all of this must fit into
; 1 byte (see PC driver and CDFS). ie/ 2 bits for sub-value, 6 bits for main value
;----------------------------------------------------------------------------------------------
MAX_NUMBER_OF_DRIVERS * 64
;----------------------------------------------------------------------------------------------
; CD_Supported values
;
; Meaning of number returned by CD_Supported
; Bits Description: ( if set )
; ---- -----------------------
; 0 - 2 Level to which CD_AudioControl is supported ( 0 to 7 )
; 0 = no support at all
; 1 = supported to level 0
; 7 = supported to level 6
; 3 CD_Prefetch supported
; 4 CD_CloseDrawer supported
; 5 CD_AudioLevel supported
; 6 - 13 Number of different speeds supported by the drive - 1.
; ie/ Standard drives support 1 speed, so will return 0.
; The Sony 561 supports 2 speeds, so will return 1.
; 14 CD_ReadAudio supported
; 15 CD_Get/Set AudioParms supported
; 16 - 31 RESERVED ( 0 )
;----------------------------------------------------------------------------------------------
NOAUDIOCONTROLSUPPORT * 0
AUDIOCONTROLSUPPORT1 * 2_1
AUDIOCONTROLSUPPORT2 * 2_10
AUDIOCONTROLSUPPORT3 * 2_11
AUDIOCONTROLSUPPORT4 * 2_100
AUDIOCONTROLSUPPORT5 * 2_101
AUDIOCONTROLSUPPORT6 * 2_110
AUDIOCONTROLSUPPORT7 * 2_111
SUPPORT__PREFETCH * 2_1000
SUPPORT__CLOSE_DRAWER * 2_10000
SUPPORT__AUDIO_LEVEL * 2_100000
SUPPORT__SPEED_MULTIPLIER * 2_1000000
SUPPORT__READ_AUDIO * 1:SHL:14
SUPPORT__AUDIO_PARMS * 1:SHL:15
;----------------------------------------------------------------------------------------------
END
*
!.gitignore
; 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.
;
; -> ByteCopy.s
; This provides the CD_ByteCopy routine
;**************************************************************************
; This is a highly optimised routine to move blocks of memory
; It will deal with unword-aligned source and destinations
; copied from pages 1000 to 1005 of PRM
; R1 -> source RCM was ere
; R2 -> destination
; R3 = number of bytes to copy
;**************************************************************************
cd_bytecopyinternal ROUT
STASH "r0-r11, r14"
cd_bytecopy
;--------------------------
; Any bytes to copy ?
;--------------------------
TEQ r3, #0
GRABS "r0-r11, pc", EQ
;--------------------------
copy_bytes
TST r2, #3
BNE MovByt100 ; destination not word aligned
MovByt20 ; destination now word aligned. branched back to from below
TST r1, #3
BNE MovByt200 ; source not word aligned
; source & destination are now both word aligned
; count is a byte value ( may not be a whole number of words )
; Quick sort out of what we've got left to do
SUBS r3, r3, #4 * 4 ; Four whole words to do (or more) ?
BLT MovByt40 ; no
SUBS r3, r3, #8 * 4 - 4 * 4 ; Eight whole words to do (or more) ?
BLT MovByt30
MovByt25
LDMIA r1!, { r0, r4 - r9, r14 } ; NB. Order ! (?)
STMIA r2!, { r0, r4 - r9, r14 }
SUBS r3, r3, #8 * 4
BGE MovByt25 ; do another 8 words
CMP r3, #-8 * 4 ; Quick test rather that chaining down
GRABS "r0-r11, pc", EQ ; finished
MovByt30
ADDS r3, r3, #8 * 4 - 4 * 4 ; Four whole words to do ?
BLT MovByt40
LDMIA r1!, { r0, r4 - r5, r14 } ; NB. Order ! (?)
STMIA r2!, { r0, r4 - r5, r14 }
GRABS "r0-r11, pc", EQ ; finished
SUB r3, r3, #4 * 4
MovByt40
ADDS r3, r3, #4 * 4 - 2 * 4 ; Two whole words to go ?
BLT MovByt50
LDMIA r1!, { r0, r14 } ; NB. Order ! (?)
STMIA r2!, { r0, r14 }
GRABS "r0-r11, pc", EQ ; finished
SUB r3, r3, #2 * 4
MovByt50
ADDS r3, r3, #2*4-1*4 ; One whole word to do ?
BLT MovByt60
LDR r0, [ r1 ], #4
STR r0, [ r2 ], #4
GRABS "r0-r11, pc", EQ ; finished
SUB r3, r3, #1 * 4
MovByt60
ADDS r3, r3, #1*4 - 0*4 ; No more to do ?
GRABS "r0-r11, pc", EQ ; finished
LDR r0, [ r1 ] ; store remaining 1,2 or 3 bytes
MovByt70
STRB r0, [ r2 ], #1
MOV r0, r0, LSR #8
SUBS r3, r3, #1
BGT MovByt70
GRABS "r0-r11, pc" ; finished
;Initial destination not word aligned.Loop doing bytes(1,2, or 3 )until it is
MovByt100
LDRB r0, [ r1 ], #1
STRB r0, [ r2 ], #1
SUBS r3, r3, #1
GRABS "r0-r11, pc", EQ ; finished
TST r2, #3
BNE MovByt100
B MovByt20 ; Back to mainline code
MovByt200;destination now word aligned,but source isn't. just r14 stacked here
AND r12, r1, #3 ; offset
BIC r1, r1, #3 ; Align source
MOV r12, r12, LSL #3 ; rshft = 0, *, 16 or 24 only
RSB r11, r12, #32 ; lshft = 32, 24, 16 or 8 only
LDR r0, [ r1 ], #4
MOV r0, r0, LSR r12 ; Always have r0 prepared
; Quick sort out of what we've got left to do
SUBS r3, r3, #4 * 4 ; Four whole words to do (or more) ?
BLT MovByt240 ; no
SUBS r3, r3, #8*4-4*4 ; Eight whole words to do (or more) ?
BLT MovByt230 ; no
MovByt225
LDMIA r1!, { r4 - r10, r14 } ; NB. Order !
ORR r0, r0, r4, LSL r11
MOV r4, r4, LSR r12
ORR r4, r4, r5, LSL r11
MOV r5, r5, LSR r12
ORR r5, r5, r6, LSL r11
MOV r6, r6, LSR r12
ORR r6, r6, r7, LSL r11
MOV r7, r7, LSR r12
ORR r7, r7, r8, LSL r11
MOV r8, r8, LSR r12
ORR r8, r8, r9, LSL r11
MOV r9, r9, LSR r12
ORR r9, r9, r10, LSL r11
MOV r10, r10, LSR r12
ORR r10, r10, r14, LSL r11
STMIA r2!, { r0, r4 - r10 }
MOV r0, r14, LSR r12 ; keep r0 prepared
SUBS r3, r3, #8 * 4
BGE MovByt225 ; do another 8 words
CMP r3, #-8 * 4 ; Quick test
GRABS "r0-r11, pc", EQ
MovByt230
ADDS r3, r3, #8*4 - 4*4 ; Four whole words to do ?
BLT MovByt240
LDMIA r1!, { r4 - r6, r14 } ; NB. Order !
ORR r0, r0, r4, LSL r11
MOV r4, r4, LSR r12
ORR r4, r4, r5, LSL r11
MOV r5, r5, LSR r12
ORR r5, r5, r6, LSL r11
MOV r6, r6, LSR r12
ORR r6, r6, r14, LSL r11
STMIA r2!, { r0, r4 - r6 }
GRABS "r0-r11, pc", EQ
SUB r3, r3, #4*4
MOV r0, r14, LSR r12 ; keep r0 prepared
MovByt240
ADDS r3, r3, #2*4 ; Two whole words to do ?
BLT MovByt250
LDMIA r1!, { r4, r14 } ; NB. Order !
ORR r0, r0, r4, LSL r11
MOV r4, r4, LSR r12
ORR r4, r4, r14, LSL r11
STMIA r2!, { r0, r4 }
GRABS "r0-r11, pc", EQ
SUB r3, r3, #2*4
MOV r0, r14, LSR r12 ; keep r0 prepared
MovByt250
ADDS r3, r3, #2*4 - 1*4 ; One whole word to go ?
BLT MovByt260
LDR r14, [ r1 ], #4
ORR r0, r0, r14, LSL r11
STR r0, [ r2 ], #4
GRABS "r0-r11, pc", EQ
SUB r3, r3, #1*4
MOV r0, r14, LSR r12 ; keep r0 prepared
MovByt260
ADDS r3, r3, #1*4 - 0*4
GRABS "r0-r11, pc", EQ
LDR r14, [ r1 ] ; store remaining 1..3 bytes
ORR r0, r0, r14, LSL r11
MovByt270
STRB r0, [ r2 ], #1
MOV r0, r0, LSR #8
SUBS r3, r3, #1
BGT MovByt270
GRABS "r0-r11, pc"
END
This diff is collapsed.
; 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.
;
;----------------------------------------------------------------------------------------------
; Convert addressing modes
;----------------------------------------------------------------------------------------------
; IF addressmode = LBAFormat THEN EXIT ( already done )
; IF addressmode = PBFormat THEN address = address - 2 seconds of data
; IF addressmode = MSFFormat THEN change address to minute,second,frame
;----------------------------------------------------------------------------------------------
;----------------------------------------------------------------------------------------------
ConvertToLBA ROUT
; on entry:
; r0 = address mode
; r1 = address
; on exit:
; if oVerflow set then r0 -> error block
; r1 = new address
;
; Errors can occur, eg/ invalid mode number
; When this is called, 'address' should contain the address on the disc
; in whatever format is being used. 'addressmode' should contain the number
; of the type of addressing being used. Eg LBAFormat, MSFFormat, PBFormat
;
;----------------------------------------------------------------------------------------------
BIC r14, r14, #Overflow_Flag
;--------------------------------------------------
; If already in LBA format then exit straight away
;--------------------------------------------------
TEQ r0, #LBAFormat
MOVEQS pc, r14
STASH "r0, r2 - r5, r14"
;--------------------------------------------------
; Check for allowable addressing mode
;--------------------------------------------------
CMP r0, #3
GRAB "r0, r2 - r5, r14", CS
addr r0, InvalidFormat, CS
ORRCSS pc, r14, #Overflow_Flag
;--------------------------------------------------
; Branch to routines to convert from each mode to LBA
;--------------------------------------------------
; R0 = address mode
; R1 = address
TEQ r0, #1
BEQ ChangeFromMSFFormat
;--------------------------------------------------
; Change from Physical Block TO Logical Block Address
; Subtract 2 seconds worth of blocks to give LBA
;--------------------------------------------------
ChangeFromPBFormat
SUBS r1, r1, #( MaxNumberOfBlocks + 1 ) * 2
GRAB "r0, r2 - r5, r14", LT
addr r0, PhysicalBlockError, LT
ORRLTS pc, r14, #Overflow_Flag
GRABS "r0, r2 - r5, pc"
;----------------------------------------------------------------------------------------------
; Change Minutes, Seconds, Frame TO LBA
ChangeFromMSFFormat ; R1 = address, RETURNS R1 = address
;----------------------------------------------------------------------------------------------
; R1 = address
;-----------------------------------------
; R3 = frames
;-----------------------------------------
MOV r14, #255
AND r3, r1, r14
;-----------------------------------------
; R4 = seconds
;-----------------------------------------
AND r4, r14, r1, LSR #8
;-----------------------------------------
; R5 = minutes
;-----------------------------------------
AND r5, r14, r1, LSR #16
;-----------------------------------------
; Make sure that seconds are ( 0 - 59 )
;-----------------------------------------
CMP r4, #MaxNumberOfSeconds + 1
GRAB "r0, r2 - r5, r14", CS
addr r0, BadSeconds, CS
ORRCSS pc, r14, #Overflow_Flag
;-----------------------------------------
; Make sure that frames are ( 0 - 74 )
;-----------------------------------------
CMP r3, #MaxNumberOfBlocks + 1
GRAB "r0, r2 - r5, r14", CS
addr r0, BadBlocks, CS
ORRCSS pc, r14, #Overflow_Flag
;-----------------------------------------
; minutes = minutes * 60 + seconds
;-----------------------------------------
MOV r14, r5, LSL #6 ; R14 = minutes * 64
SUB r5, r14, r5, LSL #2 ; R5 = R14 - ( minutes * 4 )
ADD r5, r5, r4
;-----------------------------------------
; minutes = minutes * 75 + blocks
;-----------------------------------------
MOV r14, #MaxNumberOfBlocks + 1
MLA r5, r14, r5, r3
;-----------------------------------------
; minutes = minutes - 2 seconds
;-----------------------------------------
SUB r1, r5, #( MaxNumberOfBlocks + 1 ) * 2
;-----------------------------------------
GRABS "r0, r2 - r5, pc"
;----------------------------------------------------------------------------------------------
ConvertToMSF ROUT
; Convert from LBA or PB to MSF format
; IF addressmode = MSFFormat THEN EXIT ( already done )
;
; IF addressmode = LBAFormat THEN ...
;
;
; on entry:
; r0 = address mode
; r1 = address
;
; on exit:
; if oVerflow clear THEN r1 = new address ELSE r0->error block
;
; flags preserved
;----------------------------------------------------------------------------------------------
BIC r14, r14, #Overflow_Flag
;-----------------------------------------
; If already in MSF format then exit straight away
;-----------------------------------------
TEQ r0, #MSFFormat
MOVEQS pc, r14
STASH "r0, r2 - r5, r14"
;-----------------------------------------
; Check for allowable addressing mode
;-----------------------------------------
CMP r0, #3
GRAB "r0, r2 - r5, r14", CS
addr r0, InvalidFormat, CS
ORRCSS pc, r14, #Overflow_Flag
;-----------------------------------------
; Branch to routines to convert from each mode to MSF
;-----------------------------------------
; r0 = address mode
; r1 = address
TEQ r0, #0
BEQ ConvertLBAtoMSF
;-----------------------------------------
ConvertPBtoMSF
; R1 = address
;-----------------------------------------
; address = address - 150 ( error if < 0 )
SUBS r1, r1, #( MaxNumberOfBlocks + 1 ) * 2
GRAB "r0, r2 - r5, r14", LT
addr r0, BadSeconds, LT
ORRLTS pc, r14, #Overflow_Flag
;-----------------------------------------
ConvertLBAtoMSF
; R1 = address
;-----------------------------------------
; R3 = Frames
; R4 = seconds
; R5 = minutes
;-----------------------------------------
; Frame = address MOD ( MaxNumberOfBlocks + 1 )
; R3 = R3 MOD ( MaxNumberOfBlocks + 1 )
;-----------------------------------------
;-----------------------------------------
; Seconds = ( address DIV 75 ) MOD 60
; R4
;-----------------------------------------
MOV r3, r1 ; r2 = address DIV 75
;
DivRem r2, r3, #MaxNumberOfBlocks + 1, r14 ; r3 = address MOD 75
DivRem r4, r2, #MaxNumberOfSeconds + 1, r14 ; r4 = r2 DIV 60
;
; r2 = r2 MOD 60
; R4 = minutes
; R3 = frames
; R2 = seconds
;-----------------------------------------
; Push results together into one word
; Minutes << 16 + Seconds << 8 + Frames
;-----------------------------------------
ORR r3, r3, r2, LSL #8
ORR r1, r3, r4, LSL #16
GRABS "r0, r2 - r5, pc"
;----------------------------------------------------------------------------------------------
;----------------------------------------------------------------------------------------------
;----------------------------------------------------------------------------------------------
;----------------------------------------------------------------------------------------------
;----------------------------------------------------------------------------------------------
END
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment