Commit 5fa74be7 authored by Ben Avison's avatar Ben Avison
Browse files

HAL device support, and a couple of new service calls.

Detail:
  * Rejigged documented meaning of device "Location" field so that we can
    fit full PCI locations in.
  * Defined lots of device "Type" values in Hdr:HALDevice.
  * Removed obsolete DMA-related HAL entries in Hdr:HALEntries (no longer
    required by DMAManager 0_15-4_4_2_6, no longer provided by Tungsten HAL
    0.07).
  * OS_Hardware 2 and 3 actually work now.
  * Changed OS_Hardware 4 to take a maximum major version number to match.
  * HAL workspace is now USR mode readable.
  * Service calls issued after module initialisation/finalisation (see
    Docs.ModPostServ).
Admin:
  OS_Hardware tested, service calls not tested.

Version 5.35, 4.79.2.52. Tagged as 'Kernel-5_35-4_79_2_52'
parent 9664c93b
......@@ -94,12 +94,13 @@ Location
The location describes the location of the device in terms of the bus architecture
of the computer. Again, it is grouped by bytes.
Bits 31-24: Bus type
Bits 31-28: Bus type
0 => processor (0 = core, 1 = coprocessor)
1 => main system bus (0 = AHB, 1 = ASB)
2 => peripheral bus (0 = APB)
3 => expansion bus (0 = Acorn Expansion Card, 1 = ISA, 2 = PCI)
Bits 23-16: Bus
Bits 27-24: Bus sub-type (see above)
Bits 23-16: Bus number
Bits 15-8: Card number (PCI, expansion card etc) / chip select number
Bits 7-0: Unit number
......@@ -207,7 +208,8 @@ providing a call to enumerate devices of a particular type.
SWI OS_Hardware 4 (SWI &7A)
---------------------------
On entry: R0 = type to match
On entry: R0 bits 0-15 = type to match
bits 16-31 = maximum major version number to match
R1 = 0 to start an enumeration, else preserved from last call
R8 = 4
On exit: R1 = -1 if there are no (more) devices of this type
......@@ -215,10 +217,10 @@ On exit: R1 = -1 if there are no (more) devices of this type
Other registers preserved
Service_Device (Service Call &??)
----------------------------------
Service_Hardware (Service Call &D9)
------------------------------------
On entry: R0 bits 0-7 = sub-reason code, bits 8-31 flags (undefined, ignore)
R1 = reason code (&??)
R1 = reason code (&D9)
R2 -> device
On exit: Depends on sub-reason code
......
Service_ModulePostInit (Service call &DA)
A module has been successfully initialised
On entry
R0 = module address
R1 = &DA (reason code)
R2 = pointer to module title
R3 = 0 for the base instantiation, else R3 = pointer to postfix string
R4 = BCD version number (derived from module's help string)
On exit
All registers must be preserved
Use
This service call is made after a module has been (re)initialised and
after it has been linked into the module chain. This means that any
SWIs etc provided by the module are available (in contrast, during any
service calls issued by the module's own initialisation code, the module
is not yet linked into the chain).
This service call is intended to allow clients of a module to
(re)register themselves with it.
Service_ModulePostFinal (Service call &DB)
A module has been successfully finalised
On entry
R0 = module address
R1 = &DB (reason code)
R2 = pointer to module title
R3 = 0 for the base instantiation, else R3 = pointer to postfix string
R4 = BCD version number (derived from module's help string)
On exit
All registers must be preserved
Use
This service call is made after a module has been finalised, including
during a reinitialisation. The module is not linked into the module
chain, so its SWIs etc are not available.
This service call is intended to inform clients of a module that any
registrations they made with it are no longer active, and any associated
handles are stale.
BJGA 13-Dec-2002
......@@ -13,11 +13,11 @@
GBLS Module_ComponentPath
Module_MajorVersion SETS "5.35"
Module_Version SETA 535
Module_MinorVersion SETS "4.79.2.51"
Module_Date SETS "30 Nov 2002"
Module_ApplicationDate SETS "30-Nov-02"
Module_MinorVersion SETS "4.79.2.52"
Module_Date SETS "13 Dec 2002"
Module_ApplicationDate SETS "13-Dec-02"
Module_ComponentName SETS "Kernel"
Module_ComponentPath SETS "RiscOS/Sources/Kernel"
Module_FullVersion SETS "5.35 (4.79.2.51)"
Module_HelpVersion SETS "5.35 (30 Nov 2002) 4.79.2.51"
Module_FullVersion SETS "5.35 (4.79.2.52)"
Module_HelpVersion SETS "5.35 (13 Dec 2002) 4.79.2.52"
END
......@@ -5,19 +5,19 @@
*
*/
#define Module_MajorVersion_CMHG 5.35
#define Module_MinorVersion_CMHG 4.79.2.51
#define Module_Date_CMHG 30 Nov 2002
#define Module_MinorVersion_CMHG 4.79.2.52
#define Module_Date_CMHG 13 Dec 2002
#define Module_MajorVersion "5.35"
#define Module_Version 535
#define Module_MinorVersion "4.79.2.51"
#define Module_Date "30 Nov 2002"
#define Module_MinorVersion "4.79.2.52"
#define Module_Date "13 Dec 2002"
#define Module_ApplicationDate "30-Nov-02"
#define Module_ApplicationDate "13-Dec-02"
#define Module_ComponentName "Kernel"
#define Module_ComponentPath "RiscOS/Sources/Kernel"
#define Module_FullVersion "5.35 (4.79.2.51)"
#define Module_HelpVersion "5.35 (30 Nov 2002) 4.79.2.51"
#define Module_FullVersion "5.35 (4.79.2.52)"
#define Module_HelpVersion "5.35 (13 Dec 2002) 4.79.2.52"
#define Module_LibraryVersionInfo "5:35"
......@@ -22,6 +22,7 @@ OldOpt SETA {OPT}
GBLL Included_Hdr_HALDevice
Included_Hdr_HALDevice SETL {TRUE}
^ 0
HALDevice_Type # 2
HALDevice_ID # 2
......@@ -39,6 +40,47 @@ HALDevice_TestIRQ # 4
# 8
HALDeviceSize * :INDEX: @
HALDeviceType_Video * 1 :SHL: 8
^ 1
HALDeviceVideo_VDU # 1 ; VDU display
HALDeviceType_Audio * 2 :SHL: 8
^ 1
HALDeviceAudio_PCM16 # 1 ; 16-bit PCM sound output
HALDeviceType_SysPeri * 3 :SHL: 8
^ 1
HALDeviceSysPeri_IntC # 1 ; Interrupt controller
HALDeviceSysPeri_DMAC # 1 ; DMA controller
HALDeviceSysPeri_DMAB # 1 ; DMA channel - buffer type
HALDeviceSysPeri_DMAL # 1 ; DMA channel - list type
HALDeviceType_Comms * 4 :SHL: 8
^ 1
HALDeviceComms_UART # 1 ; UART
HALDeviceBus_Pro * 0 :SHL: 28
^ 0
HALDeviceProBus_Core # 1 :SHL: 24
HALDeviceProBus_CoPro # 1 :SHL: 24
HALDeviceBus_Sys * 1 :SHL: 28
^ 0
HALDeviceSysBus_AHB # 1 :SHL: 24
HALDeviceSysBus_ASB # 1 :SHL: 24
HALDeviceBus_Peri * 2 :SHL: 28
^ 0
HALDevicePeriBus_APB # 1 :SHL: 24
HALDeviceBus_Exp * 3 :SHL: 28
^ 0
HALDeviceExpBus_Acorn # 1 :SHL: 24
HALDeviceExpBus_ISA # 1 :SHL: 24
HALDeviceExpBus_PCI # 1 :SHL: 24
]
OPT OldOpt
......
......@@ -142,27 +142,6 @@ EntryNo_HAL_ATACableID # 1
EntryNo_HAL_InitDevices # 1
; Quick bodge until devices are working...
EntryNo_HAL_DMA_Activate # 1
EntryNo_HAL_DMA_Deactivate # 1
EntryNo_HAL_DMA_Reset # 1
EntryNo_HAL_DMA_Sleep # 1
EntryNo_HAL_DMA_TestIRQ # 1
EntryNo_HAL_DMA_DMA_EnumeratePhysical # 1
EntryNo_HAL_DMA_DMA_EnumerateLogical # 1
EntryNo_HAL_DMA_DMA_Allocate # 1
EntryNo_HAL_DMA_DMA_Deallocate # 1
EntryNo_HAL_DMA_DMA_Features # 1
EntryNo_HAL_DMA_DMA_SetOptions # 1
EntryNo_HAL_DMA_DMA_SetCurrentTransfer # 1
EntryNo_HAL_DMA_DMA_SetNextTransfer # 1
EntryNo_HAL_DMA_DMA_TransferState # 1
EntryNo_HAL_DMA_DMA_SetCurrentTransfer2 # 1
EntryNo_HAL_DMA_DMA_SetNextTransfer2 # 1
EntryNo_HAL_DMA_DMA_TransferState2 # 1
EntryNo_HAL_DMA_DMA_IRQClear # 1
EntryNo_HAL_DMA_DMA_Status # 1
; Various flags and constants
; NVMemory
......
......@@ -437,7 +437,7 @@ RISCOS_Start
ADD a4, v3, #DRAMOffset_PageZero - DRAMOffset_L1PT
LDR a3, [sp, #8] ; recover pushed HAL header
LDR a1, =HALWorkspace
LDR a2, =(AP_None * L2X_APMult) + L2_C + L2_B
LDR a2, =(AP_Read * L2X_APMult) + L2_C + L2_B
LDR lr, [a3, #HALDesc_Workspace] ; their workspace
LDR ip, [a3, #HALDesc_NumEntries] ; plus 1 word per entry
ADD lr, lr, ip, LSL #2
......@@ -1908,19 +1908,19 @@ HardwareLookup
ExitSWIHandler
HardwareDeviceAdd
Push "lr"
Push "r1-r3,lr"
BL HardwareDeviceAdd_Common
Pull "lr"
Pull "r1-r3,lr"
B SLVK_TestV
HardwareDeviceRemove
Push "lr"
Push "r1-r3,lr"
BL HardwareDeviceRemove_Common
Pull "lr"
Pull "r1-r3,lr"
B SLVK_TestV
HardwareDeviceAdd_Common
Entry "r1-r3"
Entry
BL HardwareDeviceRemove_Common ; first try to remove any device already at the same address
EXIT VS
MOV lr, #0
......@@ -1928,10 +1928,14 @@ HardwareDeviceAdd_Common
LDR r2, [lr, #DeviceTable]
TEQ r2, #0
BEQ %FT80
LDR lr, [r2, #-4] ; word before heap block is length
ADD r1, r1, #1 ; increment DeviceCount
LDR lr, [r2, #-4] ; word before heap block is length including length word
TEQ r1, lr, LSR #2 ; block already full?
BEQ %FT81
10 ADD lr, r2, r1, LSL #2
MOV lr, #0
10 STR r1, [lr, #DeviceCount]
ADD lr, r2, r1, LSL #2
SUB lr, lr, #4
11 LDR r1, [lr, #-4]! ; copy existing devices up, so new ones get enumerated first
STR r1, [lr, #4]
CMP lr, r2
......@@ -1945,33 +1949,41 @@ HardwareDeviceAdd_Common
EXIT
80 ; Claim a system heap block for the device table
Push "r0"
MOV r3, #16
BL ClaimSysHeapNode
ADDVS sp, sp, #4
EXIT VS
MOV r1, #0
STR r2, [r1, #DeviceTable]
Pull "r0"
MOV lr, #0
MOV r1, #1
STR r2, [lr, #DeviceTable]
B %BT10
81 ; Extend the system heap block
Push "r0"
MOV r0, #HeapReason_ExtendBlock
MOV r3, #16
BL DoSysHeapOpWithExtension
ADDVS sp, sp, #4
EXIT VS
Pull "r0"
MOV lr, #0
LDR r1, [lr, #DeviceCount]
STR r2, [lr, #DeviceTable]
ADD r1, r1, #1
B %BT10
HardwareDeviceRemove_Common
Entry "r1-r4"
Entry "r4"
MOV lr, #0
LDR r3, [lr, #DeviceCount]
LDR r4, [lr, #DeviceTable]
TEQ r3, #0
EXIT EQ ; no devices registered
01 LDR r2, [r4], #4
TEQ r2, r0
SUBNES r3, r3, #1
SUBS r3, r3, #1
TEQNE r2, r0
BNE %BT01
TEQ r2, r0
EXIT NE ; this device not registered
......@@ -1979,14 +1991,18 @@ HardwareDeviceRemove_Common
MOV r1, #Service_Hardware
BL Issue_Service
CMP r1, #0 ; if service call claimed
CMPEQ r1, #1:SHL:31 ; then set V
CMPEQ r1, #1:SHL:31 ; then set V (r0 already points to error block)
EXIT VS ; and exit
MOV r0, r2
SUBS r3, r3, #1
02 LDRNE r2, [r4], #4 ; copy down remaining devices
STRNE r2, [r4, #-8]
SUBS r3, r3, #1
BNE %BT02
02 LDRCS r2, [r4], #4 ; copy down remaining devices
STRCS r2, [r4, #-8]
SUBCSS r3, r3, #1
BCS %BT02
MOV lr, #0
LDR r3, [lr, #DeviceCount]
SUB r3, r3, #1
STR r3, [lr, #DeviceCount]
EXIT
HardwareDeviceEnumerate
......@@ -2000,13 +2016,18 @@ HardwareDeviceEnumerate
ADD r3, r3, r1, LSL #2
10 ADD r1, r1, #1
LDR r2, [r3], #4
LDR lr, [r2, #HALDevice_Type + 2]
MOV lr, lr, LSR #16
TEQ lr, r0
LDR lr, [r2, #HALDevice_Type]
EOR lr, lr, r0
MOVS lr, lr, LSL #16 ; EQ if types match
SUBNES r4, r4, #1
BNE %BT10
TEQ lr, r0
TEQ lr, #0
MOVNE r1, #-1
BNE %FT90
LDR lr, [r2, #HALDevice_Version]
MOV lr, lr, LSR #16
CMP lr, r0, LSR #16 ; newer than our client understands?
BHI %BT10
90
Pull "r3-r4,lr"
ExitSWIHandler
......
......@@ -22,6 +22,8 @@ ExtraRMANeeded * 24*1024 ; Amount you get extra on top of what you configured
GBLL ModHand_IntrinsicBI
ModHand_IntrinsicBI SETL {TRUE} :LAND: ChocolateOSMod ;base module incarnation 'node' is in module node
GBLL ModHand_InitDieServices
ModHand_InitDieServices SETL {TRUE} :LAND: ModHand_IntrinsicBI
; Test version, incorporating multiple incarnation attempt
......@@ -655,6 +657,9 @@ Module_ReInit ROUT
MOV R10, #1 ; fatal die
BL CallDie
BVS %FT03
[ ModHand_InitDieServices
BL IssueServicePostFinal
]
SUB R10, R1, #1
BL EnvStringSkipName
......@@ -662,6 +667,9 @@ Module_ReInit ROUT
BL CallInit
BLVS LoseModuleSpace_if_its_the_only_incarnation
STRVC R12, [R3, #Incarnation_Link]
[ ModHand_InitDieServices
BLVC IssueServicePostInit
]
03 STRVS R0, [stack]
Pull "R0-R4, R9, lr"
B SLVK_TestV
......@@ -1981,6 +1989,9 @@ Add_Incarnation_AltEntry
LDRVC R3, [R9, #Module_incarnation_list]
STRVC R3, [R2, #Incarnation_Link]
STRVC R2, [R9, #Module_incarnation_list]
[ ModHand_InitDieServices
BLVC IssueServicePostInit
]
Pull "R0-R3, PC"
;*************************************************************
......@@ -3009,6 +3020,9 @@ KillIncarnation ROUT
BLNE CallDie ; tidy up anyway
STRVS R0, [stack]
Pull "R0-R2, R6, R10, PC", VS
[ ModHand_InitDieServices
BL IssueServicePostFinal
]
[ ModHand_IntrinsicBI
SUB R2, R12, R9
CMP R2, #ModInfo
......@@ -3711,6 +3725,70 @@ RMInsert_Code ALTENTRY
MakeErrorBlock RMNotFoundInROM
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[ ModHand_InitDieServices
; IssueServicePostInit
; On entry
; R9 -> module chain node
; R12 -> incarnation node
; On exit
; R0-R3 corrupted
; flags preserved
IssueServicePostInit
Push "R4-R5, lr"
MRS R5, CPSR
ASSERT ModHand_IntrinsicBI ; can't be bothered to support old world
LDR R2, [R9, #Module_code_pointer]
LDR R0, [R2, #Module_HelpStr]
ADD R0, R2, R0
BL GetVerNoFromHelpString
MOV R0, R2
LDR R2, [R0, #Module_Title]
ADD R2, R0, R2
MOV R4, R1
MOV R1, #Service_ModulePostInit
SUB R3, R12, R9
SUBS R3, R3, #ModInfo ; R3 = 0 if intrinsic base incarnation
ADDNE R3, R12, #Incarnation_Postfix
SWI XOS_ServiceCall
MSR CPSR_f, R5
Pull "R4-R5, pc"
; IssueServicePostFinal
; On entry
; R9 -> module chain node
; R12 -> incarnation node (incarnation workspace is already freed)
; On exit
; R0 corrupted
; flags corrupted
IssueServicePostFinal
Push "R1-R4, lr"
ASSERT ModHand_IntrinsicBI ; can't be bothered to support old world
LDR R2, [R9, #Module_code_pointer]
LDR R0, [R2, #Module_HelpStr]
ADD R0, R2, R0
BL GetVerNoFromHelpString
MOV R0, R2
LDR R2, [R0, #Module_Title]
ADD R2, R0, R2
MOV R4, R1
MOV R1, #Service_ModulePostFinal
SUB R3, R12, R9
SUBS R3, R3, #ModInfo ; R3 = 0 if intrinsic base incarnation
ADDNE R3, R12, #Incarnation_Postfix
SWI XOS_ServiceCall
Pull "R1-R4, 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