Source
...
Target
Commits (6)
  • Jeffrey Lee's avatar
    Don't flag 26bit builds as being 32bit compatible · 68427e8a
    Jeffrey Lee authored
    Detail:
      s/Module - Make sure module flags word is 0 when No32bitCode
    Admin:
      Builds, untested
    
    
    Version 1.17. Tagged as 'SharedSnd-1_17'
    68427e8a
  • Jeffrey Lee's avatar
    Expand tabs · 2ab86b5f
    Jeffrey Lee authored
    Detail:
      s/* - Expand all tabs, to avoid space/tab use inconsistencies within some files and to match general ROOL code formatting
    Admin:
      Binary unchanged
    
    
    Version 1.17. Not tagged
    2ab86b5f
  • Jeffrey Lee's avatar
    Use constants from build system · a441d185
    Jeffrey Lee authored
    Detail:
      s/Gets - GET Hdr:Services
      s/Vars - Remove some locally defined constants which we can get from Hdr: instead
      s/Module - SWI base and Service_Sound subreason tokens renamed to match those used in Hdr:
    Admin:
      Binary unchanged
    
    
    Version 1.17. Not tagged
    a441d185
  • Jeffrey Lee's avatar
    Use Entry/EXIT, Push/Pull macros · 89139d90
    Jeffrey Lee authored
    Detail:
      s/* - Code updated to use Entry/EXIT and Push/Pull macros where possible instead of manual STM/LDM. Also add ROUTs for safety (although most routines use named local labels rather than numbered ones). A few obvious cases also fixed to reduce number of regs pushed onto stack.
      A few other changes and fixes of note:
      s/Log - Trim empty, unused installLogDriver routine when doLog is {FALSE}
      s/Module - Add a veneer to swiHandler to deal with 26bit and 26/32bit neutral cases; avoids the need for individual SWI handlers to preserve NZC
      s/SWIs:
      - Remove 26/32bit neutral SWI exit code, now handled by veneers. CLRV on most SWI exits to replace the implicit CLRV from CMP pc,pc.
      - swiHandlerVolume and swiDriverMixer were popping the wrong regs from the stack for most error cases; now fixed via the switch to Entry/EXIT
    Admin:
      Tested on Raspberry Pi
    
    
    Version 1.18. Tagged as 'SharedSnd-1_18'
    89139d90
  • Jeffrey Lee's avatar
    Use PSR manipulation macros. Macroise driver calling. Simplify error checks. · 65377222
    Jeffrey Lee authored
    Detail:
      s/Drivers - Macroise driver calling to reduce amount of duplicate code. Also avoid NOP if storing PC stores PC+8 and not PC+12.
      s/Handler - Use PSR manipulation macros for switching modes and controlling IRQs. Remove redundant IRQ disabling around atomic store of one word in doHandlerCallBack.
      s/Module - Use PSR manipulation macros for switching modes
      s/SWIS - Simplify range checking on handler and driver numbers; treat as unsigned numbers instead of signed.
      s/Vars - Remove local definitions of IRQ flags & SVC mode
    Admin:
      Tested on Raspberry Pi
    
    
    Version 1.19. Tagged as 'SharedSnd-1_19'
    65377222
  • Jeffrey Lee's avatar
    ARMv5E, ARMv6 optimisations · 8287e52c
    Jeffrey Lee authored
    Detail:
      s/FillCode - Buffer fill & mix fragments optimised to use SMULWB/T, PKH, QADD16 and QDADD where possible, resulting in new variants optimised for ARMv5E and ARMv6
      s/Handler - Remove old, unoptimised callback buffer mixing code. Add new optimisated code for ARMv6 (SHADD16)
    Admin:
      Tested on Raspberry Pi, Iyonix
    
    
    Version 1.20. Tagged as 'SharedSnd-1_20'
    8287e52c
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "1.16"
Module_Version SETA 116
Module_MajorVersion SETS "1.20"
Module_Version SETA 120
Module_MinorVersion SETS ""
Module_Date SETS "06 Jan 2015"
Module_ApplicationDate SETS "06-Jan-15"
Module_Date SETS "18 Jun 2016"
Module_ApplicationDate SETS "18-Jun-16"
Module_ComponentName SETS "SharedSnd"
Module_ComponentPath SETS "bsd/RiscOS/Sources/Audio/SharedSnd"
Module_FullVersion SETS "1.16"
Module_HelpVersion SETS "1.16 (06 Jan 2015)"
Module_FullVersion SETS "1.20"
Module_HelpVersion SETS "1.20 (18 Jun 2016)"
END
/* (1.16)
/* (1.20)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 1.16
#define Module_MajorVersion_CMHG 1.20
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 06 Jan 2015
#define Module_Date_CMHG 18 Jun 2016
#define Module_MajorVersion "1.16"
#define Module_Version 116
#define Module_MajorVersion "1.20"
#define Module_Version 120
#define Module_MinorVersion ""
#define Module_Date "06 Jan 2015"
#define Module_Date "18 Jun 2016"
#define Module_ApplicationDate "06-Jan-15"
#define Module_ApplicationDate "18-Jun-16"
#define Module_ComponentName "SharedSnd"
#define Module_ComponentPath "bsd/RiscOS/Sources/Audio/SharedSnd"
#define Module_FullVersion "1.16"
#define Module_HelpVersion "1.16 (06 Jan 2015)"
#define Module_LibraryVersionInfo "1:16"
#define Module_FullVersion "1.20"
#define Module_HelpVersion "1.20 (18 Jun 2016)"
#define Module_LibraryVersionInfo "1:20"
......@@ -33,326 +33,311 @@
; -------------------------------- Driver routines ---------------------------
installDefaultDriver
; The default driver will either be (in order of preference)
; Sound_LinearHandler
; or Sound_ChannelHandler
; This routine looks to see what is available and installs
; the appropriate driver.
Push "lr"
MACRO
CallDriver $drivertbl, $entry, $extraregs
LCLS regs
[ "$extraregs"=""
regs SETS "ws"
|
regs SETS "$extraregs,ws"
]
Push "$regs" ; Stack ws and any other regs
LDR ws, [$drivertbl, #driver_Parameter] ; Called with ws = parameter
Push "pc" ; Put return address on the stack
MOV pc, $entry ; And call driver install entry
[ NoARMv4
MOV r0, r0
]
Pull "$regs" ; Retrieve ws
MEND
installDefaultDriver ROUT
; The default driver will either be (in order of preference)
; Sound_LinearHandler
; or Sound_ChannelHandler
; This routine looks to see what is available and installs
; the appropriate driver.
Entry
Debug gn,"installDefaultDriver: entered"
[ doDMI :LAND: ( :LNOT: forceLog)
; See if the DMI is loaded and if so install SharedSound into it's linear handler
MOV R0,#0
ADR R1,%FT10
SWI XOS_SWINumberFromString
BVS installDefaultDriver_NoDMI
; See if the DMI is loaded and if so install SharedSound into it's linear handler
MOV R0,#0
ADR R1,%FT10
SWI XOS_SWINumberFromString
BVS installDefaultDriver_NoDMI
MOV R0,#3
STR R0,[R12,#work_currentDriver]
MOV R0,#3
STR R0,[R12,#work_currentDriver]
BL installDMIDriver
BL installDMIDriver
Pull "PC"
EXIT
10
DCB "PowerWAVE_LinearHandler", 0 ; Name of a SWI from the module
ALIGN
DCB "PowerWAVE_LinearHandler", 0 ; Name of a SWI from the module
ALIGN
installDefaultDriver_NoDMI
]
; First see if Sound_LinearHandler exists
; First see if Sound_LinearHandler exists
; This relies on the fact that the old SoundDMA module will respond to all
; SWI's outside its range with a 0
; but the 16 bit SoundDMA will respond with a 1 if 16 bit is on
; This relies on the fact that the old SoundDMA module will respond to all
; SWI's outside its range with a 0
; but the 16 bit SoundDMA will respond with a 1 if 16 bit is on
MOV r0,#0
MOV r0,#0
[ :LNOT: forceLog
SWI XSound_Mode ; Check configured for 16 Bit support
MOVVS r0,#0 ; if not supported, explicitly say it's log
SWI XSound_Mode ; Check configured for 16 Bit support
MOVVS r0,#0 ; if not supported, explicitly say it's log
]
Debug gn,"Sound mode =", r0
CMP r0,#0 ; r0 = 1 If 16 bit support is on
CMP r0,#0 ; r0 = 1 If 16 bit support is on
MOVEQ r1,#1 ; Log
MOVNE r1,#2 ; Linear
MOVEQ r1,#1 ; Log
MOVNE r1,#2 ; Linear
STR r1,[ws,#work_currentDriver]
STR r1,[ws,#work_currentDriver]
[ doLog
BNE installDefaultDriverNotLog ; 32 bit change
BL installLogDriver
Pull "pc"
BNE installDefaultDriverNotLog ; 32 bit change
BL installLogDriver
EXIT
]
installDefaultDriverNotLog
BL installLinearDriver
BL installLinearDriver
Pull "pc"
EXIT
; -----------
installDriver
; Install driver
; r0 = Pointer to driver table, or 0 if it's not really valid
; r1 = parameter to pass driver in ws when called
; r2 = flags
; r3 ->Driver name
Push "r0-r6,lr"
installDriver ROUT
; Install driver
; r0 = Pointer to driver table, or 0 if it's not really valid
; r1 = parameter to pass driver in ws when called
; r2 = flags
; r3 ->Driver name
Entry "r0-r6"
BL releaseDriver ; release the currently active driver
BL releaseDriver ; release the currently active driver
ADD r6,ws,#work_driverTable ; Get pointer to driver table
ADD r6,ws,#work_driverTable ; Get pointer to driver table
STR r0,[r6,#driver_Address] ; Table address
STR r1,[r6,#driver_Parameter] ; Driver ws parameter
STR r2,[r6,#driver_Flags]
STR r0,[r6,#driver_Address] ; Table address
STR r1,[r6,#driver_Parameter] ; Driver ws parameter
STR r2,[r6,#driver_Flags]
ADD r4,r6,#driver_Name
ADD r5,r4,#?driver_Name - 1 ; Buffer end (inclusive)
ADD r4,r6,#driver_Name
ADD r5,r4,#?driver_Name - 1 ; Buffer end (inclusive)
10
LDRB r14,[r3],#1
CMP r14,#31 ; Control terminate
CMPHI r5,r4 ; Check buffer end
MOVLS r14,#0
STRB r14,[r4],#1
BHI %BT10
LDRB r14,[r3],#1
CMP r14,#31 ; Control terminate
CMPHI r5,r4 ; Check buffer end
MOVLS r14,#0
STRB r14,[r4],#1
BHI %BT10
MVN r0,#0 ; Initialise driver vol to LR = &FFFFFFFF
STR r0,[r6,#driver_Volume]
MVN r0,#0 ; Initialise driver vol to LR = &FFFFFFFF
STR r0,[r6,#driver_Volume]
BL driverInitialise ; Initialise this driver
BL driverInitialise ; Initialise this driver
LDR r0,[r6,#driver_Volume]
MOV r1,r6 ; Driver table
BL driverVolume ; Initialise driver volume
LDR r0,[r6,#driver_Volume]
MOV r1,r6 ; Driver table
BL driverVolume ; Initialise driver volume
Pull "r0-r6,pc"
EXIT
; -----------
driverInitialise
; Initialise a new driver
; r0 = driver table slot
; Return with r0 = 0 if failed
driverInitialise ROUT
; Initialise a new driver
; r0 = driver table slot
; Return with r0 = 0 if failed
Push "r1-r11,ws,lr"
Entry "r1-r11,ws"
ADD r6,ws,#work_driverTable ; driver Table slot
ADD r6,ws,#work_driverTable ; driver Table slot
LDR r0,[r6,#driver_Address]
LDR r2,[r0,#driverEntry_Install] ; r2 = Call address
LDR r0,[r6,#driver_Address]
LDR r2,[r0,#driverEntry_Install] ; r2 = Call address
BL clearCallBackBuffer
BL clearCallBackBuffer
ADRL r0,fill ; Main fill call address
ADRL r0,fill ; Main fill call address
LDR r1,[ws,#work_privateWord] ; r1 = parameter
Push "ws" ; Stack ws
LDR ws,[r6,#driver_Parameter] ; Called with ws = parameter
Push "pc" ; Put return address on the stack
MOV pc,r2 ; And call driver install entry
MOV r0,r0
Pull "ws" ; Retrieve ws
LDR r1,[ws,#work_privateWord] ; r1 = parameter
CallDriver r6, r2 ; Call r2 on driver r6
CMP r0,#0 ; = 0 if install failed
CMP r0,#0 ; = 0 if install failed
MOVNE r0,#0
BLNE newSampleRate ; Get rate and set up sample period &
; fractions
MOVNE r0,#0
BLNE newSampleRate ; Get rate and set up sample period &
; fractions
BL startSound ; Make sure that sound is active
BL startSound ; Make sure that sound is active
Pull "r1-r11,ws,pc"
EXIT
; ------------
; ------------
driverCheck
; Call initialise to make sure that the current driver is still active
driverCheck ROUT
; Call initialise to make sure that the current driver is still active
Push "r0-r11,ws,lr"
Entry "r0-r11,ws"
ADD r6,ws,#work_driverTable ; driver Table slot
LDR r0,[r6,#driver_Address]
ADD r6,ws,#work_driverTable ; driver Table slot
LDR r0,[r6,#driver_Address]
CMP r0,#0 ; Is there a driver installed?
BEQ driverCheckExit
CMP r0,#0 ; Is there a driver installed?
BEQ driverCheckExit
LDR r2,[r0,#driverEntry_Install] ; r2 = Call address
LDR r2,[r0,#driverEntry_Install] ; r2 = Call address
ADRL r0,fill ; r0 = Handler address
LDR r1,[ws,#work_privateWord] ; r1 = parameter
Push "ws" ; Stack ws
LDR ws,[r6,#driver_Parameter] ; Called with ws = parameter
Push "pc" ; Put return address on the stack
MOV pc,r2 ; And call driver install entry
MOV r0,r0
Pull "ws" ; Retrieve ws
ADRL r0,fill ; r0 = Handler address
LDR r1,[ws,#work_privateWord] ; r1 = parameter
CallDriver r6, r2 ; Call r2 on driver r6
MOV r0,#0
STR r0,[ws,#work_SoundPause] ; Clear the pause flag
MOV r0,#0
STR r0,[ws,#work_SoundPause] ; Clear the pause flag
driverCheckExit
CMP PC,PC ; Clears V flag and checks processor mode
Pull "r0-r11,ws,pc", EQ ; 32 bit exit
Pull "r0-r11,ws,pc",, ^ ; 26 bit exit
CLRV
EXIT
;-------------
;-------------
releaseDriver
Push "r0-r11,ws,lr"
releaseDriver ROUT
Entry "r0-r11,ws"
BL stopSound
BL stopSound
ADD r0,ws,#work_driverTable ; driver Table slot
LDR r1,[r0,#driver_Address]
ADD r0,ws,#work_driverTable ; driver Table slot
LDR r1,[r0,#driver_Address]
CMP r1,#0
BEQ releaseDriverExit
CMP r1,#0
BEQ releaseDriverExit
LDR r1,[r1,#driverEntry_Remove]
Push "ws" ; Stack ws
LDR ws,[r0,#driver_Parameter] ; Get driver's ws
Push "pc" ; Stack return address
MOV pc,r1 ; Call driver, no other parameters
MOV r0,r0
Pull "ws" ; Retrieve ws
LDR r1,[r1,#driverEntry_Remove]
CallDriver r0, r1 ; Call r1 on driver r0, no other parameters
; forget the driver we're using
ADD r0,ws,#work_driverTable ; driver Table slot
MOV r1,#0
STR r1,[r0,#driver_Address]
ADD r0,ws,#work_driverTable ; driver Table slot
MOV r1,#0
STR r1,[r0,#driver_Address]
releaseDriverExit
Pull "r0-r11,ws,pc"
; ----------------
driverSampleRate
; Call driver sample rate entry
; On entry:
; r0 = 0 to read
; > 0 for sample frequency required
; On exit:
; r0 = current frequency
Push "lr"
; Get or set current frequency
ADD r1,ws,#work_driverTable ; driver Table slot
LDR r2,[r1,#driver_Address]
CMP r2,#0 ; Return 0 for failed
MOVEQ r0,#0
BEQ driverSampleRateExit
LDR r2,[r1,#driver_Address]
LDR r2,[r2,#driverEntry_SampleRate]
Push "ws" ; Stack ws
LDR ws,[r1,#driver_Parameter] ; Get driver's ws
Push "pc" ; Stack return address
MOV pc,r2 ; Call driver, no other parameters
MOV r0,r0
Pull "ws" ; Retrieve ws
; r0 = current frequency
EXIT
driverSampleRateExit
; ----------------
driverSampleRate ROUT
; Call driver sample rate entry
; On entry:
; r0 = 0 to read
; > 0 for sample frequency required
; On exit:
; r0 = current frequency
Entry
; Get or set current frequency
ADD r1,ws,#work_driverTable ; driver Table slot
LDR r2,[r1,#driver_Address]
Pull "pc"
CMP r2,#0 ; Return 0 for failed
MOVEQ r0,#0
BEQ driverSampleRateExit
LDR r2,[r1,#driver_Address]
LDR r2,[r2,#driverEntry_SampleRate]
CallDriver r1, r2 ; Call r2 on driver r1, no other parameters
; r0 = current frequency
driverSampleRateExit
EXIT
; ----------
driverVolume
; Set the new volume for a driver
; On entry:
; r0 = new LR volume
; r1 = driver table
; On exit:
; r0 = volume scaling required by handler to achieve this volume
; So if driver cannot scale volume then r0 = entry value and handler
; will have to do all the work
; If driver can scale then typically it will return &FFFFFFFF to
; tell handler not to scale volume at all
Push "r1-r11,ws,lr"
; Get or set current volume
ADD r1,ws,#work_driverTable ; driver Table slot
LDR r2,[r1,#driver_Address]
CMP r2,#0
BEQ driverVolumeExit
LDR r2,[r2,#driverEntry_Volume] ; There may not be an entry
CMP r2,#0
STR r0,[r1,#driver_Volume] ; Store it
BEQ driverVolumeStore ; Return with r0 as set
Push "r1,ws" ; Stack ws
LDR ws,[r1,#driver_Parameter] ; Get driver's ws
Push "pc" ; Stack return address
MOV pc,r2 ; Call driver, no other parameters
MOV r0,r0
Pull "r1,ws" ; Retrieve ws
driverVolume ROUT
; Set the new volume for a driver
; On entry:
; r0 = new LR volume
; r1 = driver table
; On exit:
; r0 = volume scaling required by handler to achieve this volume
; So if driver cannot scale volume then r0 = entry value and handler
; will have to do all the work
; If driver can scale then typically it will return &FFFFFFFF to
; tell handler not to scale volume at all
Entry "r1-r11,ws"
; Get or set current volume
ADD r1,ws,#work_driverTable ; driver Table slot
LDR r2,[r1,#driver_Address]
CMP r2,#0
BEQ driverVolumeExit
LDR r2,[r2,#driverEntry_Volume] ; There may not be an entry
CMP r2,#0
STR r0,[r1,#driver_Volume] ; Store it
BEQ driverVolumeStore ; Return with r0 as set
CallDriver r1, r2, "r1" ; Call r2 on driver r1, no other parameters
driverVolumeStore
Debug gn,"Store scaled driver volume: ", r0
; r0 = actual volume
; r0 = actual volume
STR r0,[r1,#driver_VolumeScaled] ; The volume to use when scaling handlers
STR r0,[r1,#driver_VolumeScaled] ; The volume to use when scaling handlers
driverVolumeExit
Pull "r1-r11,ws,pc"
EXIT
; -----------
; -----------
driverMixer
; Call driver's mixer entry
; On entry:
; r0 = Function code, 0 = read, 1 = set
; r1 = mixer number
; r2 = value if to set
; r3 = driver pointer
; On exit:
; r1 = number of mixers
; r2 = current value
; r3 = mixer name
driverMixer ROUT
; Call driver's mixer entry
; On entry:
; r0 = Function code, 0 = read, 1 = set
; r1 = mixer number
; r2 = value if to set
; r3 = driver pointer
; On exit:
; r1 = number of mixers
; r2 = current value
; r3 = mixer name
Push "r4-r11,ws,lr"
Entry "r4-r11,ws"
CMP r3,#0
BEQ driverMixerExit
CMP r3,#0
BEQ driverMixerExit
LDR r4,[r3,#driver_Address]
LDR r4,[r4,#driverEntry_Mixer] ; There may not be an entry
CMP r4,#0
BEQ driverMixerExit ; No mixer entry
LDR r4,[r3,#driver_Address]
LDR r4,[r4,#driverEntry_Mixer] ; There may not be an entry
CMP r4,#0
BEQ driverMixerExit ; No mixer entry
Push "ws" ; Stack ws
LDR ws,[r1,#driver_Parameter] ; Get driver's ws
Push "pc" ; Stack return address
MOV pc,r4 ; Call driver, no other parameters
MOV r0,r0
Pull "ws" ; Retrieve ws
CallDriver r3, r4 ; Call r4 on driver r3, no other parameters
driverMixerExit
Pull "r4-r11,ws,pc"
EXIT
END
END
......@@ -31,7 +31,7 @@
; routine, or the interface description should be updated
fill_silence
TST r3,#1 ; If we are being asked to mix, then nothing to do.
MOVNE r1,r2 ; Pretend we filled!
MOVNE r1,r2 ; Pretend we filled!
MOVNE r0, r3 ; return the flags too!
MOVNE PC,R14
CMP R1,R2 ; check whether already complete
......@@ -79,7 +79,7 @@ fs_lp_small
ORR R0,R3,#1 ; R0 = flags + MIX set
MOV PC,R14
; Just fill the buffer with 0s.
; On Entry:
; r1 = Pointer to buffer to fill
; r2 = Pointer to byte after end of buffer to fill
......@@ -112,7 +112,7 @@ fs_lp_small
; R (*) = reversed
; (* = Not yet implemented as the bits can never be set by SharedSound)
fill_data
STMFD r13!,{r5,r14}
Entry "R5"
; How many stereo samples (4 bytes) will this fill routine use?
; We are never going to be asked to fill more than 256K.
SUBS R2,R2,R1 ; R2 = number of output bytes required.
......@@ -183,7 +183,7 @@ fill_code_table
fill_return
ORR r0,r3,#1 ; r0 = flags on entry + MIX.
LDMFD r13!,{r5,PC}
EXIT
; --------------------------------------------------------------------------------
; OK. Of the 32 cases above, half are muted, so resolve to just one case, leaving 16 others.
......@@ -220,7 +220,7 @@ ssh_lp0_$name
UnMakeSpace$name
ORR r0,r3,#1 ; r0 = flags on entry + MIX.
LDMFD r13!,{r5,PC}
EXIT
MEND
......@@ -239,7 +239,7 @@ sshD_lp0_$name
UnMakeSpace$name
ORR r0,r3,#1 ; r0 = flags on entry + MIX.
LDMFD r13!,{r5,PC}
EXIT
MEND
......@@ -289,6 +289,7 @@ sshD_lp0_$name
AND r14,r9,#&FF000000 ; r14 = integer inc
LDR R0,[R4],r14,LSR#22
BIC r9,r9,#&FF000000 ; keep just the fractional bit
[ NoARME
MOV R14,R0,ASR#16
MUL R14,R10,R14 ; R14= LLLLxxxx = Scaled L volume
MOV R0,R0,LSL#16
......@@ -297,6 +298,17 @@ sshD_lp0_$name
MOV R14,R14,LSR#16
MOV R0,R0,LSR#16
ORR R0,R0,R14,LSL#16
|
SMULWT R14,R10,R0 ; R14 = ssssLLLL (signed)
SMULWB R0,R11,R0 ; R0 = ssssRRRR
[ NoARMv6
MOV R14,R14,LSL #16
MOV R0,R0,LSL #16
ORR R0,R14,R0,LSR #16
|
PKHBT R0,R0,R14,LSL #16 ; R0 = LLLLRRRR
]
]
STR R0,[R1],#4
MEND
......@@ -310,7 +322,9 @@ sshD_lp0_$name
MACRO
MakeSpaceML
[ NoARMv6
MOV R10,#1<<31
]
MEND
MACRO
......@@ -321,13 +335,17 @@ sshD_lp0_$name
LDR R0,[R4],r14,LSR#22 ; R0 = AAAABBBB = Our samples
LDR R14,[R1] ; R14= CCCCDDDD = Current samples
BIC R9,R9,#&FF000000 ; keep just the fractional bit
MOV R0,R0,ROR#16 ; R0 = BBBBAAAA
[ NoARMv6
MOV R0,R0,ROR#16 ; R0 = BBBBAAAA
ADDS R11,R14,R0,LSL#16 ; T2 = eeeexxxx (where eeee = AAAA+CCCC)
SBCVS R11,R10,#0 ; T2 = EEEExxxx (where EEEE = Clip[AAAA+CCCC])
ADDS R0,R0,R14,LSL#16 ; R0 = DDDD0000+BBBB000
SBCVS R0,R10,#0 ; R0 = FFFF0000 (where FFFF = Clip[DDDD+CCCC])
AND R11,R11,R10,ASR#15 ; T2 = EEEE0000
ORR R0,R11,R0,LSR#16 ; R0 = EEEEFFFF
|
QADD16 R0,R0,R14 ; Signed saturating halfword addition
]
STR R0,[R1],#4
MEND
......@@ -350,10 +368,23 @@ sshD_lp0_$name
MACRO
MakeSpaceVML
STMFD r13!,{R7,R12}
MOV R10,#1<<31
MOV R11,r7,LSR#16 ; R11= Left vol
BIC R7,r7,R11,LSL#16 ; R7 = Right vol
[ NoARME
MOV r10,R7,LSR#16 ; r10 = Left Vol
BIC r11,r7,r10,LSL#16 ; r11 = Right Vol
Push "R7,R12"
MOV R12,#1<<31
|
[ NoARMv6
Push "R7,R12"
LDR r12,=&ffff<<15
AND r10,r12,r7,LSR #1 ; r10 = Left Vol
AND r11,r12,r7,LSL #15 ; r11 = Right Vol
|
MOV r10,R7,LSR#16 ; r10 = Left Vol
BIC r11,r7,r10,LSL#16 ; r11 = Right Vol
Push "R12"
]
]
MEND
MACRO
......@@ -363,24 +394,48 @@ sshD_lp0_$name
AND R14,R9,#&FF000000 ; r14= integer inc
LDR R0,[R4],r14,LSR#22 ; R0 = AAAABBBB = Our samples
BIC R9,R9,#&FF000000 ; keep just the fractional bit
[ NoARME
MOV r14,R0,ASR#16
MUL R12,R11,R14 ; R12= AAAAxxxx
MUL R7,R10,R14 ; R7 = AAAAxxxx
LDR R14,[R1] ; R14= CCCCDDDD = Current samples
MOV R0,R0,LSL#16
MOV R0,R0,ASR#16
MUL R0,R7,R0 ; R0 = BBBBxxxx
ADDS R12,R14,R12 ; T2 = eeeexxxx (where eeee = AAAA+CCCC)
SBCVS R12,R10,#0 ; T2 = EEEExxxx (where EEEE = Clip[AAAA+CCCC])
MUL R0,R11,R0 ; R0 = BBBBxxxx
ADDS R7,R14,R7 ; R7 = eeeexxxx (where eeee = AAAA+CCCC)
SBCVS R7,R12,#0 ; R7 = EEEExxxx (where EEEE = Clip[AAAA+CCCC])
ADDS R0,R0,R14,LSL#16 ; R0 = DDDD0000+BBBB000
SBCVS R0,R10,#0 ; R0 = FFFF0000 (where FFFF = Clip[DDDD+CCCC])
AND R12,R12,R10,ASR#15 ; T2 = EEEE0000
ORR R0,R12,R0,LSR#16 ; R0 = EEEEFFFF
SBCVS R0,R12,#0 ; R0 = FFFF0000 (where FFFF = Clip[DDDD+BBBB])
AND R7,R7,R12,ASR#15 ; R7 = EEEE0000
ORR R0,R7,R0,LSR#16 ; R0 = EEEEFFFF
|
[ NoARMv6
SMULWT R14,R10,R0 ; R14= AAAAxxxx >> 1
LDR R7,[R1] ; R7 = CCCCDDDD = Current samples
SMULWB R0,R11,R0 ; R0 = BBBBxxxx >> 1
BIC R14,R14,R12,LSR #16 ; R14= AAAA0000 >> 1 (must mask off to avoid potential overflow from interaction with low bits of R7)
QDADD R14,R7,R14 ; R14= EEEExxxx (where EEEE = Clip[AAAA+CCCC])
MOV R7,R7,LSL #16
QDADD R0,R7,R0 ; R0 = FFFFxxxx (where FFFF = Clip[DDDD+BBBB])
AND R14,R14,R12,LSL #1 ; R14= EEEE0000
ORR R0,R14,R0,LSR #16 ; R0 = EEEEFFFF
|
SMULWT R14,R10,R0 ; R14= ssssAAAA
LDR R7,[R1] ; R7 = CCCCDDDD = Current samples
SMULWB R0,R11,R0 ; R0 = ssssBBBB
PKHBT R0,R0,R14,LSL #16 ; R0 = AAAABBBB
QADD16 R0,R0,R7 ; R0 = EEEEFFFF
]
]
STR R0,[R1],#4
MEND
MACRO
UnMakeSpaceVML
LDMFD r13!,{R7,R12}
[ NoARMv6
Pull "R7,R12"
|
Pull "R12"
]
MEND
; Fmute = zero fill
......
......@@ -57,19 +57,20 @@
GET Hdr:MsgTrans
GET Hdr:Proc
GET Hdr:NdrDebug
GET Hdr:Services
GET VersionAsm
GET VersionAsm
GBLS copyRightS
GBLS ackS
GBLS variantS
GBLS titleS
GBLS swiNameS
copyRightS SETS " Expressive Software Projects, Nottingham."
ackS SETS "Copyright 1995-2002 Expressive Software Projects"
variantS SETS ""
titleS SETS "SharedSound"
swiNameS SETS "SharedSound"
GBLS copyRightS
GBLS ackS
GBLS variantS
GBLS titleS
GBLS swiNameS
copyRightS SETS " Expressive Software Projects, Nottingham."
ackS SETS "Copyright 1995-2002 Expressive Software Projects"
variantS SETS ""
titleS SETS "SharedSound"
swiNameS SETS "SharedSound"
GBLL forceLog
GBLL doLogDirect
......@@ -78,23 +79,23 @@ swiNameS SETS "SharedSound"
GBLL doCBAI
[ :LNOT::DEF: standalone
GBLL standalone
standalone SETL {FALSE}
standalone SETL {FALSE}
]
[ :LNOT::DEF: doLog
GBLL doLog
doLog SETL {FALSE}
doLog SETL {FALSE}
|
doLog SETL doLog :LAND: standalone ; Uses PC relative workspace!
doLog SETL doLog :LAND: standalone ; Uses PC relative workspace!
]
forceLog SETL {FALSE}
doLogDirect SETL {FALSE}
doDMI SETL {TRUE}
doCallBack SETL {TRUE}
doCBAI SETL {FALSE}
forceLog SETL {FALSE}
doLogDirect SETL {FALSE}
doDMI SETL {TRUE}
doCallBack SETL {TRUE}
doCBAI SETL {FALSE}
GBLL debugxc
GBLL debugsw
GBLL debuggn
GBLL debugxc
GBLL debugsw
GBLL debuggn
debug SETL {FALSE}
debuggn SETL {FALSE} ; General debug
debugsw SETL {FALSE} ; SWI entries
......@@ -102,29 +103,29 @@ debugxc SETL {FALSE} ; Extra commands
ws RN 12
AREA |!!Module$$Code|, CODE, READONLY
AREA |!!Module$$Code|, CODE, READONLY
MODULE_START
GET Vars.s
GET Module.s
GET SWIS.s
GET Memory.s
GET SampleRate.s
GET Volume.s
GET Drivers.s
GET Linear.s
GET Vars.s
GET Module.s
GET SWIS.s
GET Memory.s
GET SampleRate.s
GET Volume.s
GET Drivers.s
GET Linear.s
[ doLog
GET Log.s
GET Log.s
]
[ doDMI
GET PowerWave.s
GET PowerWave.s
]
GET SoundDrv.s
GET Handler.s
GET FillCode.s
GET SoundDrv.s
GET Handler.s
GET FillCode.s
[ debug
InsertNDRDebugRoutines
]
END
END
This diff is collapsed.
......@@ -26,38 +26,37 @@
; ------------------------- Linear driver --------------------------
; ---------
installLinearDriver
; Set up the registers and table for
; Sound_LinearHandler and call installDriver
Push "lr"
SUB sp,sp,#32
installLinearDriver ROUT
; Set up the registers and table for
; Sound_LinearHandler and call installDriver
Entry , 32
MOV r0,#32
ADR r1,linearDriverToken
MOV r2,sp
BL msgLookupToken
MOV r3,sp ; Driver name
MOV r0,#32
ADR r1,linearDriverToken
MOV r2,sp
BL msgLookupToken
MOV r3,sp ; Driver name
ADD r0,ws,#work_DriverEntryTable ; Get table address
ADD r0,ws,#work_DriverEntryTable ; Get table address
ADR r1,linearDriverInstall ; Install entry
STR r1,[r0,#driverEntry_Install]
ADR r1,linearDriverInstall ; Install entry
STR r1,[r0,#driverEntry_Install]
ADR r1,linearDriverRemove ; Remove entry
STR r1,[r0,#driverEntry_Remove]
ADR r1,linearDriverRemove ; Remove entry
STR r1,[r0,#driverEntry_Remove]
ADR r1,linearDriverSampleRate ; Sample rate entry
STR r1,[r0,#driverEntry_SampleRate]
ADR r1,linearDriverSampleRate ; Sample rate entry
STR r1,[r0,#driverEntry_SampleRate]
MOV r1,#0 ; No volume entry
STR r1,[r0,#driverEntry_Volume]
MOV r1,#0 ; No volume entry
STR r1,[r0,#driverEntry_Volume]
MOV r1,#0
STR r1,[r0,#driverEntry_Mixer] ; No mixer entry
MOV r1,#0
STR r1,[r0,#driverEntry_Mixer] ; No mixer entry
LDR r1,[ws,#work_privateWord] ; Parameter
LDR r1,[ws,#work_privateWord] ; Parameter
MOV r2,#0 ; Flags
MOV r2,#0 ; Flags
Debug gn, "Install linear driver....."
Debug gn, " Table =",r0
......@@ -65,131 +64,128 @@ installLinearDriver
Debug gn, " Flags =",r2
DebugS gn, " Name =",r3
BL installDriver
BL installDriver
ADD sp,sp,#32
Pull "pc"
EXIT
linearDriverToken
DCB "NmLin",0
ALIGN
DCB "NmLin",0
ALIGN
; ------
linearDriverInstall
; Install driver using Sound_LinearHandler
; r0 = Handler address
; r1 = Parameter to pass
; ws = parameter for driver
; lr already on stack
STMDB sp!,{r1-r11,ws}
linearDriverInstall ROUT
; Install driver using Sound_LinearHandler
; r0 = Handler address
; r1 = Parameter to pass
; ws = parameter for driver
; lr already on stack
Push "r1-r11,ws"
MOV r5,r0 ; Temorary store r0 and r1
MOV r6,r1
MOV r5,r0 ; Temorary store r0 and r1
MOV r6,r1
MOV r0,#0 ; Get current handler to see if already installed
SWI XSound_LinearHandler
MOV r0,#0 ; Get current handler to see if already installed
SWI XSound_LinearHandler
CMP r1,r5 ; Same handler?
CMPEQ r2,r6 ; Same parameter?
CMP r1,r5 ; Same handler?
CMPEQ r2,r6 ; Same parameter?
BEQ linearDriverInstallExit ; Jump out 'cos already there
BEQ linearDriverInstallExit ; Jump out 'cos already there
; Now install new driver
; Now install new driver
MOV r0,#1 ; Function code install
MOV r1,r5 ; Address
MOV r2,r6 ; Parameter
SWI XSound_LinearHandler
MOV r0,#1 ; Function code install
MOV r1,r5 ; Address
MOV r2,r6 ; Parameter
SWI XSound_LinearHandler
MOV r0,r5 ; Restore r0 if successful
MOVVS r0,#0 ; Or 0 if error
MOV r0,r5 ; Restore r0 if successful
MOVVS r0,#0 ; Or 0 if error
linearDriverInstallExit
LDMIA sp!,{r1-r11,ws,pc}
Pull "r1-r11,ws,pc"
; -----------
linearDriverRemove
; Remove driver using Sound_LinearHandler
; lr already on stack
STMDB sp!,{r0-r2}
linearDriverRemove ROUT
; Remove driver using Sound_LinearHandler
; lr already on stack
Push "r0-r2"
; To remove handler set new handler to 0
MOV r0,#1 ; Function code install
MOV r1,#0 ; Null handler
MOV r2,#0
SWI XSound_LinearHandler
; To remove handler set new handler to 0
MOV r0,#1 ; Function code install
MOV r1,#0 ; Null handler
MOV r2,#0
SWI XSound_LinearHandler
LDMIA sp!,{r0-r2,pc}
Pull "r0-r2,pc"
; -----------
linearDriverSampleRate
; Choose rate and/or return current rate
; r0 = 0 to read
; > 0 to set to r0 = frequency
; On exit:
; r0 = current frequency
STMDB sp!,{r1-r11,ws}
linearDriverSampleRate ROUT
; Choose rate and/or return current rate
; r0 = 0 to read
; > 0 to set to r0 = frequency
; On exit:
; r0 = current frequency
Push "r1-r11,ws"
CMP r0,#0
BEQ linearDriverSampleRateRead
; Set the rate to r0
; Find the nearest
MOV r4,r0 ; r4 = rate required
CMP r0,#0
BEQ linearDriverSampleRateRead
; Set the rate to r0
; Find the nearest
MOV r4,r0 ; r4 = rate required
MOV r0,#0 ; Read number of rates available
SWI XSound_SampleRate ; r1 = number of rates available
BVS linearDriverSampleRateFailed
MOV r0,#0 ; Read number of rates available
SWI XSound_SampleRate ; r1 = number of rates available
BVS linearDriverSampleRateFailed
MOV r5,r1 ; r5 = Upper limit
MOV r5,r1 ; r5 = Upper limit
linearDriverSampleRateLoop
MOV r0,#2 ; Convert from index to rate
SWI XSound_SampleRate ; r2 = rate
BVS linearDriverSampleRateFailed
CMP r2,r4
BLT linearDriverSampleRateClosest ; Best rate is between r1 and r5
CMP r1,#1 ; Are there any more rates
MOVNE r5,r1 ; Change upper limit
MOVNE r6,r2 ; Store upper rate
SUBNE r1,r1,#1 ; decrement index
BNE linearDriverSampleRateLoop ; Try again
MOV r0,#2 ; Convert from index to rate
SWI XSound_SampleRate ; r2 = rate
BVS linearDriverSampleRateFailed
CMP r2,r4
BLT linearDriverSampleRateClosest ; Best rate is between r1 and r5
CMP r1,#1 ; Are there any more rates
MOVNE r5,r1 ; Change upper limit
MOVNE r6,r2 ; Store upper rate
SUBNE r1,r1,#1 ; decrement index
BNE linearDriverSampleRateLoop ; Try again
linearDriverSampleRateClosest
; Check for nearest between r1 and r5
; Check for nearest between r1 and r5
CMP r1,r5 ; No range to check
BEQ linearDriverSampleRateSet
CMP r1,r5 ; No range to check
BEQ linearDriverSampleRateSet
; r2 = lower rate, r1 = index
; r6 = upper rate, r5 = index
; r2 = lower rate, r1 = index
; r6 = upper rate, r5 = index
SUB r2,r4,r2
SUB r6,r6,r4
SUB r2,r4,r2
SUB r6,r6,r4
CMP r2,r6 ; Who is nearest
MOVGT r1,r5 ; If nearest to r6 then set index to r5
CMP r2,r6 ; Who is nearest
MOVGT r1,r5 ; If nearest to r6 then set index to r5
linearDriverSampleRateSet
; Chosen index is r1
MOV r0,#3 ; Select rate from index in r1
SWI XSound_SampleRate
BVS linearDriverSampleRateFailed
; Chosen index is r1
MOV r0,#3 ; Select rate from index in r1
SWI XSound_SampleRate
BVS linearDriverSampleRateFailed
linearDriverSampleRateRead
MOV r0,#1
SWI XSound_SampleRate ; Frequency returned in r2
BVS linearDriverSampleRateFailed
MOV r0,#1
SWI XSound_SampleRate ; Frequency returned in r2
BVS linearDriverSampleRateFailed
MOV r0,r2 ; Return it in r0
MOV r0,r2 ; Return it in r0
linearDriverSampleRateExit
LDMIA sp!,{r1-r11,ws,pc}
Pull "r1-r11,ws,pc"
linearDriverSampleRateFailed
MOV r0, #0 ; indicates failure
......@@ -197,4 +193,4 @@ linearDriverSampleRateFailed
; -----------
END
END
This diff is collapsed.
......@@ -25,98 +25,98 @@
;
memoryStartVal
DCD memoryStart
DCD memoryStart
;----
startMem
Push "lr"
Entry
LDR r3,memoryStartVal
LDR r3,memoryStartVal
MOV r0,#ModHandReason_Claim
SWI XOS_Module
Pull "pc", VS ; Flag an error - and don't start module
MOV r0,#ModHandReason_Claim
SWI XOS_Module
EXIT VS ; Flag an error - and don't start module
STR r2,[ws]
STR r2,[ws]
MOV r10,ws ; Use r10 as tempory private word pointer, for sound installation
MOV ws,r2
STR r3,[ws,#work_memSize]
STR r10,[ws,#work_privateWord]
MOV r10,ws ; Use r10 as tempory private word pointer, for sound installation
MOV ws,r2
STR r3,[ws,#work_memSize]
STR r10,[ws,#work_privateWord]
Pull "pc"
EXIT
; -------------------------------- Workspace routines ------------------------
initWorkspace
Push "lr"
initWorkspace ROUT
Entry
; Clear memory
ADD r1,ws,#:INDEX:work_privateWord + 4
LDR r2,memoryStartVal
ADD r2,r2,ws
MOV r0,#0
; Clear memory
ADD r1,ws,#:INDEX:work_privateWord + 4
LDR r2,memoryStartVal
ADD r2,r2,ws
MOV r0,#0
initWorkspace_Loop
STR r0,[r1],#4
CMP r1,r2
BCC initWorkspace_Loop
STR r0,[r1],#4
CMP r1,r2
BCC initWorkspace_Loop
; Specific values......
MOV r0,#0
STR r0,[ws,#work_currentDriver] ; No driver installed yet
; Specific values......
MOV r0,#0
STR r0,[ws,#work_currentDriver] ; No driver installed yet
STR r0,[ws,#work_SampleFrequency]
STR r0,[ws,#work_SamplePeriod]
STR r0,[ws,#work_SampleFrequency]
STR r0,[ws,#work_SamplePeriod]
STR r0,[ws,#work_SoundActive] ; No sound currently active
STR r0,[ws,#work_SoundActive] ; No sound currently active
STR r0,[ws,#work_ControlWord] ; Control word for Replay
STR r0,[ws,#work_ControlWord] ; Control word for Replay
STR r0,[ws,#work_ImmediateHandlers]
STR r0,[ws,#work_CallBackHandlers]
STR r0,[ws,#work_ProcessHandlers]
STR r0,[ws,#work_ImmediateHandlers]
STR r0,[ws,#work_CallBackHandlers]
STR r0,[ws,#work_ProcessHandlers]
; Initialise the fillcode table
MOV r0,#0
ADRL r1,fill_silence
ADRL r2,fill_data
ADD lr,ws,#work_FillcodeTable
STMIA lr,{r0-r2}
; Initialise the fillcode table
MOV r0,#0
ADRL r1,fill_silence
ADRL r2,fill_data
ADD lr,ws,#work_FillcodeTable
STMIA lr,{r0-r2}
; .. Initialise handler table by setting handler_Address entries to 0
ADD r0,ws,#work_handlerTable ; Position of table
MOV r1,#handlerMax ; Number in table
MOV r2,#0
; .. Initialise handler table by setting handler_Address entries to 0
ADD r0,ws,#work_handlerTable ; Position of table
MOV r1,#handlerMax ; Number in table
MOV r2,#0
initWorkHandlerTableLoop
STR r2,[r0,#handler_Address] ; Store 0 in handler_Address
ADD r0,r0,#handlerTableLen ; Increment to next table entry
SUBS r1,r1,#1 ; Decrement count
BNE initWorkHandlerTableLoop ; Branch to start of loop
STR r2,[r0,#handler_Address] ; Store 0 in handler_Address
ADD r0,r0,#handlerTableLen ; Increment to next table entry
SUBS r1,r1,#1 ; Decrement count
BNE initWorkHandlerTableLoop ; Branch to start of loop
; .. Initialise driver table by setting driver_Address entries to 0
ADD r0,ws,#work_driverTable ; Position of table
MOV r1,#driverMax ; Number in table
MOV r2,#0
; .. Initialise driver table by setting driver_Address entries to 0
ADD r0,ws,#work_driverTable ; Position of table
MOV r1,#driverMax ; Number in table
MOV r2,#0
initWorkDriverTableLoop
STR r2,[r0,#driver_Address] ; Store 0 in handler_Address
ADD r0,r0,#driverTableLen ; Increment to next table entry
SUBS r1,r1,#1 ; Decrement count
BNE initWorkDriverTableLoop ; Branch to start of loop
STR r2,[r0,#driver_Address] ; Store 0 in handler_Address
ADD r0,r0,#driverTableLen ; Increment to next table entry
SUBS r1,r1,#1 ; Decrement count
BNE initWorkDriverTableLoop ; Branch to start of loop
MOV r0,#0
STR r0,[ws,#work_callBack_Active]
STR r0,[ws,#work_callBack_Count]
STR r0,[ws,#work_CallBack_BufferFullCount]
STR r0,[ws,#work_CallBack_CurrentSoundBuffer]
STR r0,[ws,#work_CallBack_CurrentOutBuffer]
MOV r0,#0
STR r0,[ws,#work_callBack_Active]
STR r0,[ws,#work_callBack_Count]
STR r0,[ws,#work_CallBack_BufferFullCount]
STR r0,[ws,#work_CallBack_CurrentSoundBuffer]
STR r0,[ws,#work_CallBack_CurrentOutBuffer]
MOV r0,#defaultNumCallBackBuffers
STR r0,[ws,#work_CallBack_numCallBackBuffers]
MOV r0,#defaultNumCallBackBuffers
STR r0,[ws,#work_CallBack_numCallBackBuffers]
Pull "pc"
EXIT
END
END
This diff is collapsed.
......@@ -27,39 +27,38 @@
; ---------
[ doDMI
installDMIDriver
; Set up the registers and table for
; PowerWAVE_LinearHandler and call installDriver
Push "lr"
SUB sp,sp,#32
installDMIDriver ROUT
; Set up the registers and table for
; PowerWAVE_LinearHandler and call installDriver
Entry , 32
MOV r0,#32
ADR r1,DMIDriverToken
MOV r2,sp
BL msgLookupToken
MOV r3,sp ; Driver name
MOV r0,#32
ADR r1,DMIDriverToken
MOV r2,sp
BL msgLookupToken
MOV r3,sp ; Driver name
ADD R0,R12,#work_DriverEntryTable ; Get table address
ADD R0,R12,#work_DriverEntryTable ; Get table address
ADR R1,DMIDriverInstall ; Install entry
STR R1,[R0,#driverEntry_Install]
ADR R1,DMIDriverInstall ; Install entry
STR R1,[R0,#driverEntry_Install]
ADR R1,DMIDriverRemove ; Remove entry
STR R1,[R0,#driverEntry_Remove]
ADR R1,DMIDriverRemove ; Remove entry
STR R1,[R0,#driverEntry_Remove]
ADR R1,DMIDriverSampleRate ; Sample rate entry
STR R1,[R0,#driverEntry_SampleRate]
ADR R1,DMIDriverSampleRate ; Sample rate entry
STR R1,[R0,#driverEntry_SampleRate]
MOV R1,#0 ; No volume entry
STR R1,[R0,#driverEntry_Volume]
MOV R1,#0 ; No volume entry
STR R1,[R0,#driverEntry_Volume]
MOV R1,#0
STR R1,[R0,#driverEntry_Mixer] ; No mixer entry
MOV R1,#0
STR R1,[R0,#driverEntry_Mixer] ; No mixer entry
LDR R1,[R12,#work_privateWord] ; Parameter
LDR R1,[R12,#work_privateWord] ; Parameter
MOV R2,#0 ; Flags
MOV R2,#0 ; Flags
Debug gn,"Install DMI driver....."
Debug gn, " Table =",r0
......@@ -67,133 +66,132 @@ installDMIDriver
Debug gn, " Flags =",r2
DebugS gn, " Name =",r3
BL installDriver
BL installDriver
ADD sp,sp,#32
Pull "PC"
EXIT
DMIDriverToken
DCB "NmPow",0
ALIGN
DCB "NmPow",0
ALIGN
; ------
DMIDriverInstall
; Install driver using PowerWAVE_LinearHandler
; R0 = Handler address
; R1 = Parameter to pass
; R12 = parameter for driver
; R14 already on stack
STMDB R13!,{R1-R12}
DMIDriverInstall ROUT
; Install driver using PowerWAVE_LinearHandler
; R0 = Handler address
; R1 = Parameter to pass
; R12 = parameter for driver
; R14 already on stack
Push "R1-R12"
MOV R5,R0 ; Temorary store R0 and R1
MOV R6,R1
MOV R5,R0 ; Temorary store R0 and R1
MOV R6,R1
MOV R0,#0 ; Get current handler to see if already installed
SWI XPowerWAVE_LinearHandler
MOV R0,#0 ; Get current handler to see if already installed
SWI XPowerWAVE_LinearHandler
Debug gn," Current handler =",r1
CMP R1,R5 ; Same handler?
CMPEQ R2,R6 ; Same parameter?
CMP R1,R5 ; Same handler?
CMPEQ R2,R6 ; Same parameter?
BEQ DMIDriverInstallExit ; Jump out 'cos already there
BEQ DMIDriverInstallExit ; Jump out 'cos already there
Debug gn, " Install new handler =",r5
; Now install new driver
MOV R0,#1 ; Function code install
MOV R1,R5 ; Address
MOV R2,R6 ; Parameter
SWI XPowerWAVE_LinearHandler
; Now install new driver
MOV R0,#1 ; Function code install
MOV R1,R5 ; Address
MOV R2,R6 ; Parameter
SWI XPowerWAVE_LinearHandler
MOV R0,R5 ; Restore R0 if successful
MOVVS R0,#0 ; Or 0 if error
MOV R0,R5 ; Restore R0 if successful
MOVVS R0,#0 ; Or 0 if error
DMIDriverInstallExit
LDMIA R13!,{R1-R12,PC}
Pull "R1-R12,PC"
; -----------
DMIDriverRemove
; Remove driver using PowerWAVE_LinearHandler
; R14 already on stack
DMIDriverRemove ROUT
; Remove driver using PowerWAVE_LinearHandler
; R14 already on stack
STMDB R13!,{R0-R2}
Push "R0-R2"
; To remove handler set new handler to 0
MOV R0,#1 ; Function code install
MOV R1,#0 ; Null handler
MOV R2,#0
SWI XPowerWAVE_LinearHandler
; To remove handler set new handler to 0
MOV R0,#1 ; Function code install
MOV R1,#0 ; Null handler
MOV R2,#0
SWI XPowerWAVE_LinearHandler
LDMIA R13!,{R0-R2,PC}
Pull "R0-R2,PC"
; -----------
DMIDriverSampleRate
; Choose rate and/or return current rate
; R0 = 0 to read
; > 0 to set to R0 = frequency
; On exit:
; R0 = current frequency
STMDB R13!,{R1-R12}
DMIDriverSampleRate ROUT
; Choose rate and/or return current rate
; R0 = 0 to read
; > 0 to set to R0 = frequency
; On exit:
; R0 = current frequency
Push "R1-R12"
CMP R0,#0
BEQ DMIDriverSampleRateRead
CMP R0,#0
BEQ DMIDriverSampleRateRead
; Set the rate to R0
; Find the nearest
MOV R4,R0 ; R4 = rate required
; Set the rate to R0
; Find the nearest
MOV R4,R0 ; R4 = rate required
MOV R0,#0 ; Read number of rates available
SWI XPowerWAVE_SampleRate ; R1 = number of rates available
MOV R0,#0 ; Read number of rates available
SWI XPowerWAVE_SampleRate ; R1 = number of rates available
MOV R5,R1 ; R5 = Upper limit
MOV R5,R1 ; R5 = Upper limit
DMIDriverSampleRateLoop
MOV R0,#2 ; Convert from index to rate
SWI XPowerWAVE_SampleRate ; R2 = rate
CMP R2,R4
BLT DMIDriverSampleRateClosest ; Best rate is between R1 and R5
MOV R0,#2 ; Convert from index to rate
SWI XPowerWAVE_SampleRate ; R2 = rate
CMP R2,R4
BLT DMIDriverSampleRateClosest ; Best rate is between R1 and R5
CMP R1,#1 ; Are there any more rates
MOVNE R5,R1 ; Change upper limit
MOVNE R6,R2 ; Store upper rate
SUBNE R1,R1,#1 ; decrement index
BNE DMIDriverSampleRateLoop ; Try again
CMP R1,#1 ; Are there any more rates
MOVNE R5,R1 ; Change upper limit
MOVNE R6,R2 ; Store upper rate
SUBNE R1,R1,#1 ; decrement index
BNE DMIDriverSampleRateLoop ; Try again
DMIDriverSampleRateClosest ; Check for nearest between R1 and R5
CMP R1,R5 ; No range to check
BEQ DMIDriverSampleRateSet
CMP R1,R5 ; No range to check
BEQ DMIDriverSampleRateSet
; R2 = lower rate, R1 = index
; R6 = upper rate, R5 = index
SUB R2,R4,R2
SUB R6,R6,R4
; R2 = lower rate, R1 = index
; R6 = upper rate, R5 = index
SUB R2,R4,R2
SUB R6,R6,R4
CMP R2,R6 ; Who is nearest
MOVGT R1,R5 ; If nearest to R6 then set index to R5
CMP R2,R6 ; Who is nearest
MOVGT R1,R5 ; If nearest to R6 then set index to R5
DMIDriverSampleRateSet
; Chosen index is R1
; Chosen index is R1
MOV R0,#3 ; Select rate from index in R1
SWI XPowerWAVE_SampleRate
MOV R0,#3 ; Select rate from index in R1
SWI XPowerWAVE_SampleRate
DMIDriverSampleRateRead
MOV R0,#1
SWI XPowerWAVE_SampleRate ; Frequency returned in R2
MOV R0,#1
SWI XPowerWAVE_SampleRate ; Frequency returned in R2
MOV R0,R2 ; Return it in R0
MOV R0,R2 ; Return it in R0
LDMIA R13!,{R1-R12,PC}
Pull "R1-R12,PC"
; -----------
DMIDriverName
= "PowerWAVE Linear Handler",0
ALIGN
= "PowerWAVE Linear Handler",0
ALIGN
]
END
END
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.