Commit 1033074e authored by Robert Sprowson's avatar Robert Sprowson

Recover gracefully from a completely blank set of CMOS

Newly born boards have all 0xFF's in their CMOS (EEPROM), but the new order of keyboard scan did
  Init -> Scan keyboard -> Check (or wipe) CMOS
and would therefore leave 0xFF's in a select few kernel workspace areas and OS_Byte values.
Defer the init which reads CMOS until after the check/wipe step. Only the screen area size is now done early, but MassageScreenSize clamps that properly anyway.

Arthur3.s: Relocate stranded function SetupPrinterBuffer to osinit.
PMF/key.s: Drop support for SoftReset.
PMF/osinit.s: Stuff in hardcoded defaults at early init. Retrieve the proper ones later. Take ownership of SystemSprite/RamFS/Font Manager dynamic areas (deferrable).
vdudriver.s: Use symbolic name.
NewReset.s: Defer SystemSprite/RamFS/Font Manager area creation, MouseInit, Read(Hard)CMOSDefaults until later.
hdr/Options: Delete unused IgnoreVRAM. Remove MaxRAMFS_Size now PMPs make it not useful. Shuffle ARM6Support/XScaleMiniCache/XScaleJTAGDebug to be adjacent to their definitions.

Tested by filling first 256 bytes with 0xFF and powering up. Reset now completes, OS_Byte variables look sensible.

Version 5.95. Tagged as 'Kernel-5_95'
parent 155897b8
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "5.94"
Module_Version SETA 594
Module_MajorVersion SETS "5.95"
Module_Version SETA 595
Module_MinorVersion SETS ""
Module_Date SETS "26 Jan 2018"
Module_ApplicationDate SETS "26-Jan-18"
Module_Date SETS "03 Feb 2018"
Module_ApplicationDate SETS "03-Feb-18"
Module_ComponentName SETS "Kernel"
Module_ComponentPath SETS "castle/RiscOS/Sources/Kernel"
Module_FullVersion SETS "5.94"
Module_HelpVersion SETS "5.94 (26 Jan 2018)"
Module_FullVersion SETS "5.95"
Module_HelpVersion SETS "5.95 (03 Feb 2018)"
END
/* (5.94)
/* (5.95)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 5.94
#define Module_MajorVersion_CMHG 5.95
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 26 Jan 2018
#define Module_Date_CMHG 03 Feb 2018
#define Module_MajorVersion "5.94"
#define Module_Version 594
#define Module_MajorVersion "5.95"
#define Module_Version 595
#define Module_MinorVersion ""
#define Module_Date "26 Jan 2018"
#define Module_Date "03 Feb 2018"
#define Module_ApplicationDate "26-Jan-18"
#define Module_ApplicationDate "03-Feb-18"
#define Module_ComponentName "Kernel"
#define Module_ComponentPath "castle/RiscOS/Sources/Kernel"
#define Module_FullVersion "5.94"
#define Module_HelpVersion "5.94 (26 Jan 2018)"
#define Module_LibraryVersionInfo "5:94"
#define Module_FullVersion "5.95"
#define Module_HelpVersion "5.95 (03 Feb 2018)"
#define Module_LibraryVersionInfo "5:95"
......@@ -60,9 +60,6 @@ ValidateCMOS SETL {TRUE} ; and do minimal default setting
GBLL ChecksumCMOS ; Inspect the CMOS checksum byte, and act like a CMOS reset if it's
ChecksumCMOS SETL {TRUE} ; invalid. Also, calculate CMOS checksum and write it when needed.
GBLL IgnoreVRAM ; if true, don't add VRAM to the RAM list (+ don't use for screen)
IgnoreVRAM SETL {FALSE}
GBLL ShrinkableDAs ; if true, support Shrinkable Dynamic Areas (eg. CacheFS)
ShrinkableDAs SETL {TRUE}
......@@ -72,18 +69,16 @@ DA_Batman SETL {TRUE} ; concept of sparsely mapped dyn
LongCLISize * 1024 ; buffer size for long commands
GBLL SASTMhatbroken ; whether ROM must support SA110's with broken STM^ (revision 3 should fix this)
GBLL ARM6support
GBLL XScaleMiniCache ; is the XScale mini data-cache used (at all)
GBLL XScaleJTAGDebug
SASTMhatbroken SETL SupportARMv4 :LAND: NoARMv5
SASTMhatbroken SETL SupportARMv4 :LAND: NoARMv5
GBLL CacheCleanerHack ; Cache clean hack in ClearPhysRAM for platforms that use DCacheCleanAddress. Does not work with all CPUs!
GBLL InterruptDelay ; True if we might be running on a CPU with CPUFlag_InterruptDelay set (e.g. StrongARM)
CacheCleanerHack SETL {TRUE}
InterruptDelay SETL SupportARMv4 :LAND: NoARMv5
GBLL ARM6support
GBLL XScaleMiniCache ; is the XScale mini data-cache used (at all)
GBLL XScaleJTAGDebug
ARM6support SETL (MEMM_Type = "ARM600") :LAND: NoARMv4
XScaleMiniCache SETL {FALSE}
XScaleJTAGDebug SETL {TRUE}
......@@ -183,13 +178,7 @@ PMPParanoid SETL {FALSE} ; Validate PMPs after most ops
GBLL PMPRAMFS
PMPRAMFS SETL {TRUE} ; Whether RAMFS DA is a PMP (requires compatible RAMFS module)
[ PMPRAMFS
PMPRAMFS_Size * 256 ; Number of logical pages (physical size is unlimited)
|
GBLA MaxRAMFS_Size
MaxRAMFS_Size SETA 128 ; Max size available for RAM Disc
]
GBLL CacheablePageTables
CacheablePageTables SETL {TRUE} ; Use cacheable page tables where possible
......
......@@ -2528,23 +2528,4 @@ Read_Configd_Sync Entry
BL ReadMultiField
EXIT
SetUpPrinterBuffer Entry "r1-r3"
MOV r0, #PrinterBufferCMOS
BL Read
LDR r2, =ZeroPage
LDR r2, [r2, #Page_Size]
MULS r3, r2, r0
BEQ %FT10 ; if zero, then use default area & size
BL ClaimSysHeapNode ; else claim space from system heap
BVC %FT20 ; if no error then OK, else use default
10
LDR r2, =PrintBuff ; use default buffer
MOV r3, #PrintBuffSize
20
LDR r0, =ZeroPage
STR r2, [r0, #PrinterBufferAddr]
STR r3, [r0, #PrinterBufferSize]
EXIT
END
......@@ -271,13 +271,12 @@ conversionSWIfill
LDR R1, =DuffEntry ; nothing will be here!!
STR R1, [R0, #Curr_Active_Object]
; let's boogie with the CMOS for a bit
; read info and move as much memory as we can
; Get creating the essential areas
DebugTX "InitDynamicAreas"
BL InitDynamicAreas
; RMA
; RMA
Push "r0-r12"
MOV r1, #ChangeDyn_RMA ; Area number
MOV r2, #4096 ; Initial size
......@@ -291,7 +290,7 @@ conversionSWIfill
BL DynArea_Create ; ignore any error, we're stuffed if we get one!
Pull "r0-r12"
; Screen
; Screen
Push "r0-r12"
MOV r0, #ScreenSizeCMOS
BL Read
......@@ -302,7 +301,8 @@ conversionSWIfill
LDR r5, [r5, #VideoSizeFlags] ; maximum size
MOV r5, r5, LSR #12
MOV r5, r5, LSL #12
BL MassageScreenSize
BL MassageScreenSize ; Clamps the initial size regardless of the
; contents of the ScreenSizeCMOS
MOV r1, #ChangeDyn_Screen ; area number
MOV r2, r0 ; initial size
......@@ -318,84 +318,9 @@ conversionSWIfill
STR r3, [r7, #ScreenEndAddr]
Pull "r0-r12"
; SpriteArea
Push "r0-r12"
MOV r0, #0 ; initialise SpriteSize to zero
[ ZeroPage = 0
STR r0, [r0, #SpriteSize] ; (fixes bug MED-00811)
|
LDR r1, =ZeroPage
STR r0, [r1, #SpriteSize] ; (fixes bug MED-00811)
]
MOV r0, #SpriteSizeCMOS ; find out how much spritesize configured
BL GetConfiguredSize ; in: r0 = CMOS address, out: r2 = size
MOV r1, #ChangeDyn_SpriteArea ; Area number
MOV r3, #-1 ; Base address dynamic
MOV r4, #AreaFlags_Sprites ; Area flags
MOV r5, #16*1024*1024 ; Maximum size (changed from -1, address space preservation)
ADRL r6, DynAreaHandler_Sprites ; Pointer to handler
MOV r7, #-1 ; Use base address as workspace ptr
ADRL r8, AreaName_SpriteArea ; Title string - node will have to be reallocated
; after module init, to internationalise it
BL DynArea_Create ; ignore any error, we're stuffed if we get one!
Pull "r0-r12"
; RAMDisc
Push "r0-r12"
MOV r1, #ChangeDyn_RamFS ; Area number
MOV r3, #-1 ; Base address dynamic
ARM_read_ID r4
AND r4, r4, #&F000
CMP r4, #&A000
MOVEQ r4, #AreaFlags_RAMDisc_SA ; Area flags, if StrongARM (introduced for Ursula)
MOVNE r4, #AreaFlags_RAMDisc ; Area flags
[ PMPRAMFS
MOV r5, #PMPRAMFS_Size*4096
ORR r4, r4, #DynAreaFlags_PMP
MOV r2, #0
ORR r4, r4, #DynAreaFlags_NeedsSpecificPages
MOV r9, #0
|
MOV r0, #RAMDiscCMOS ; find out how much RAM disc configured
BL GetConfiguredSize ; in: r0 = CMOS address, out: r2 = size
MOV r5, #MaxRAMFS_Size*1024*1024 ; A trade off between nice big disc and complete waste of address space
]
ADRL r6, DynAreaHandler_RAMDisc ; Pointer to handler
MOV r7, #-1 ; Use base address as workspace ptr
ADRL r8, AreaName_RAMDisc ; Title string - node will have to be reallocated
; after module init, to internationalise it
BL DynArea_Create ; ignore any error, we're stuffed if we get one!
[ PMPRAMFS
; Currently, physical memory pools must be created with 0 size, then resized afterwards
MOV r0, #RAMDiscCMOS ; find out how much RAM disc configured
BL GetConfiguredSize ; in: r0 = CMOS address, out: r2 = size
MOVS r1, r2
MOV r0, #ChangeDyn_RamFS
SWINE XOS_ChangeDynamicArea
]
Pull "r0-r12"
; FontArea
Push "r0-r12"
MOV r0, #FontCMOS ; find out how much font cache configured
BL GetConfiguredSize ; in: r0 = CMOS address, out: r2 = size
MOV r1, #ChangeDyn_FontArea ; Area number
MOV r3, #-1 ; Base address dynamic
MOV r4, #AreaFlags_FontArea ; Area flags
MOV r5, #32*1024*1024 ; Maximum size changed from -1 for Ursula (limit address
; space usage on large memory machines)
ADRL r6, DynAreaHandler_FontArea ; Pointer to handler
MOV r7, #-1 ; Use base address as workspace ptr
ADRL r8, AreaName_FontArea ; Title string - node will have to be reallocated
; after module init, to internationalise it
BL DynArea_Create ; ignore any error, we're stuffed if we get one!
Pull "r0-r12"
LDR R0, =(512*1024):SHR:12 ; 512k of RAM in aplspace should be plenty for ROM init. Theoretically we don't need any at all, but having some there should make it easier to debug any ROM init failures.
LDR R0, =(512*1024):SHR:12 ; 512k of RAM in aplspace should be plenty for ROM init.
; Theoretically we don't need any at all, but having some there
; should make it easier to debug any ROM init failures.
MOV R3, #AppSpaceStart ; aplwork start
LDR R1, =ZeroPage+AplWorkSize ; aplwork size
MOV r11, #AreaFlags_AppSpace
......@@ -500,8 +425,6 @@ clearmswis
BL ExecuteInit
DebugTX "KeyInit"
BL KeyInit
DebugTX "MouseInit"
BL MouseInit
DebugTX "OscliInit"
BL OscliInit ; before initialising modules
......@@ -602,7 +525,6 @@ clearmswis
; everything from InitDynamicAreas
; RMA => not cleared, it's in use
; Screen => not cleared, the next CLS will do that
; SpriteArea, RAMDisc, FontArea => not cleared, clients write their own data structures
; and
; Application space (from FudgeSomeAppSpace) => cleared unconditionally
; Free pool => clear now if HAL didn't
......@@ -647,6 +569,7 @@ cmos_checks
LDR R1, [R0]
TST R1, #OSStartFlag_NoCMOS ; If no CMOS, reset for sensible cache
BNE cmos_reset
TST R1, #OSStartFlag_POR
BEQ no_cmos_reset ; not a power on reset
DebugTX "POR detected"
......@@ -720,6 +643,16 @@ no_cmos_reset
init_other_modules
; init that's deferrable until the CMOS is sanitised
DebugTX "ReadDefaults"
BYTEWS WsPtr
BL ReadHardCMOSDefaults
BL ReadCMOSDefaults
DebugTX "InitHostedDAs"
BL InitHostedDAs
DebugTX "MouseInit"
BL MouseInit
; now go back and load the other modules, scan podules, accounting for frugal bits
DebugTX "ModuleInit"
BL ModuleInit
......@@ -745,6 +678,13 @@ init_other_modules
MOV R0, #FSControl_SelectFS ; set configured filing system
SWI XOS_FSControl
; Update territory in case it changed after ModuleInitForKbdScan
MOV R0, #ReadCMOS
MOV R1, #TerritoryCMOS
SWI XOS_Byte
EOR R0, R2, #1 ; encoded so that 0 => TerritoryNum_UK
SWI XTerritory_Select
; Update RTC now all the modules are running
SWI XOS_ResyncTime
......
......@@ -99,10 +99,6 @@ KeyPostInit ROUT
Pull R14 ; restore I_bit indication
PLP ; set I_bit from this
LDROSB R1, LastBREAK ; is it a soft reset ?
TEQ R1, #SoftReset
Pull PC, EQ ; if so, then exit
MOV R0, #OsByte_Country
LDROSB R1, Country
SWI XOS_Byte
......
......@@ -25,7 +25,9 @@ ExecuteInit ROUT
BYTEWS WsPtr
LDRB R1, LastBREAK ; 0 => soft, 1 => power-on, 2 => hard
CMP R1, #1
CMP R1, #PowerOnReset
ASSERT SoftReset < PowerOnReset
ASSERT PowerOnReset < ControlReset
ADRCC R2, SoftResetVars
ADREQ R2, PowerOnResetVars
ADRHI R2, HardResetVars
......@@ -38,6 +40,11 @@ ExecuteInit ROUT
STRCS R3, TimerBeta +4
MOV R4, R1 ; preserve LastBREAK
MOV R1, #32 ; default FX11 and FX12
STRB R1, KeyRepDelay
MOV R1, #8
STRB R1, KeyRepRate
MOV R1, WsPtr ; start at the beginning
ADR R11, ByteVarInitTable
......@@ -66,6 +73,11 @@ BuffPtrInitLoop
STR R1, PrinterActive ; (R1=0)
; initialise SpriteSize to zero (fixes bug MED-00811)
LDR R2, =ZeroPage
STR R1, [R2, #SpriteSize]
; Initialise event semaphores
ADR R0, EventSemaphores
......@@ -85,15 +97,11 @@ BuffPtrInitLoop
MOV R0, #0 ; EOR with 0
BL UpdateLatchB
LDRB R0, LastBREAK
TEQ R0, #0
BEQ %FT20
LDR R1, =ZeroPage
MOV R0, #4_3330 ; Assume VGA during osinit
STRB R0, [R1, #MonitorLeadType]
BL ReadMachineType
BL ReadUniqueID
BL ReadHardCMOSDefaults
20
BL ReadCMOSDefaults
Push "r9,r12"
AddressHAL
......@@ -119,10 +127,82 @@ secs0070 * (86400*(365*70+18)) ; from time() in risc_oslib.c.armsys
LTORG
; *****************************************************************************
;
; InitHostedDAs - Set up the dynamic areas that we kindly host on
; behalf of other parts of the OS (SpriteUtils, RamFS, Font Manager)
InitHostedDAs
Push "r0-r12, lr"
; SpriteArea
MOV r0, #SpriteSizeCMOS ; find out how much spritesize configured
BL GetConfiguredSize ; in: r0 = CMOS address, out: r2 = size
MOV r1, #ChangeDyn_SpriteArea ; Area number
MOV r3, #-1 ; Base address dynamic
MOV r4, #AreaFlags_Sprites ; Area flags
MOV r5, #16*1024*1024 ; Maximum size (changed from -1, address space preservation)
ADRL r6, DynAreaHandler_Sprites ; Pointer to handler
MOV r7, #-1 ; Use base address as workspace ptr
ADRL r8, AreaName_SpriteArea ; Title string - node will have to be reallocated
; after module init, to internationalise it
BL DynArea_Create ; ignore any error, we're stuffed if we get one!
; RAMDisc
MOV r1, #ChangeDyn_RamFS ; Area number
MOV r3, #-1 ; Base address dynamic
ARM_read_ID r4
AND r4, r4, #&F000
CMP r4, #&A000
MOVEQ r4, #AreaFlags_RAMDisc_SA ; Area flags, if StrongARM (introduced for Ursula)
MOVNE r4, #AreaFlags_RAMDisc ; Area flags
[ PMPRAMFS
MOV r5, #PMPRAMFS_Size*4096
ORR r4, r4, #DynAreaFlags_PMP
MOV r2, #0
ORR r4, r4, #DynAreaFlags_NeedsSpecificPages
MOV r9, #0
|
MOV r0, #RAMDiscCMOS ; find out how much RAM disc configured
BL GetConfiguredSize ; in: r0 = CMOS address, out: r2 = size
MOV r5, #128*1024*1024 ; A trade off between nice big disc and complete waste of address space
]
ADRL r6, DynAreaHandler_RAMDisc ; Pointer to handler
MOV r7, #-1 ; Use base address as workspace ptr
ADRL r8, AreaName_RAMDisc ; Title string - node will have to be reallocated
; after module init, to internationalise it
BL DynArea_Create ; ignore any error, we're stuffed if we get one!
[ PMPRAMFS
; Currently, physical memory pools must be created with 0 size, then resized afterwards
MOV r0, #RAMDiscCMOS ; find out how much RAM disc configured
BL GetConfiguredSize ; in: r0 = CMOS address, out: r2 = size
MOVS r1, r2
MOV r0, #ChangeDyn_RamFS
SWINE XOS_ChangeDynamicArea
]
; FontArea
MOV r0, #FontCMOS ; find out how much font cache configured
BL GetConfiguredSize ; in: r0 = CMOS address, out: r2 = size
MOV r1, #ChangeDyn_FontArea ; Area number
MOV r3, #-1 ; Base address dynamic
MOV r4, #AreaFlags_FontArea ; Area flags
MOV r5, #32*1024*1024 ; Maximum size changed from -1 for Ursula (limit address
; space usage on large memory machines)
ADRL r6, DynAreaHandler_FontArea ; Pointer to handler
MOV r7, #-1 ; Use base address as workspace ptr
ADRL r8, AreaName_FontArea ; Title string - node will have to be reallocated
; after module init, to internationalise it
BL DynArea_Create ; ignore any error, we're stuffed if we get one!
Pull "r0-r12, pc"
; *****************************************************************************
;
; ReadHardCMOSDefaults - Read CMOS values for a hard/power-on reset
; NB must be called in supervisor mode
; On entry WsPtr -> BYTEWS
ReadHardCMOSDefaults
Push R14
......@@ -173,7 +253,7 @@ ReadHardCMOSDefaults
; *****************************************************************************
;
; ReadCMOSDefaults - Read CMOS values for any reset
; NB must be called in supervisor mode
; On entry WsPtr -> BYTEWS
ReadCMOSDefaults
Push R14
......@@ -235,7 +315,7 @@ PostInit ROUT
Push R14
BYTEWS WsPtr
LDRB R0, LastBREAK ; get reset type
TEQ R0, #0
TEQ R0, #SoftReset
BEQ %FT10 ; [soft reset, skip]
SWI XPortable_ReadFeatures
......@@ -253,6 +333,29 @@ PostInit ROUT
10
Pull PC
; *****************************************************************************
;
; SetUpPrinterBuffer - create the printer buffer
SetUpPrinterBuffer Entry "r1-r3"
MOV r0, #PrinterBufferCMOS
BL Read
LDR r2, =ZeroPage
LDR r2, [r2, #Page_Size]
MULS r3, r2, r0
BEQ %FT10 ; if zero, then use default area & size
BL ClaimSysHeapNode ; else claim space from system heap
BVC %FT20 ; if no error then OK, else use default
10
LDR r2, =PrintBuff ; use default buffer
MOV r3, #PrintBuffSize
20
LDR r0, =ZeroPage
STR r2, [r0, #PrinterBufferAddr]
STR r3, [r0, #PrinterBufferSize]
EXIT
; *****************************************************************************
;
; UpdateLatchB - update latch B and soft copy
......@@ -407,18 +510,6 @@ ByteVarInitTableSize * ByteVarInitTableEnd - ByteVarInitTable
oldirqowner & IRQ
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;
; ReadMachineType - Determine machine type and store it in IOSystemType
;
ReadMachineType Entry "r0-r12"
LDR r1, =ZeroPage
MOV r0, #4_3330 ; Assume VGA during osinit
STRB r0, [r1, #MonitorLeadType]
EXIT
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;
; TranslateMonitorLeadType - Determine monitor type and default mode + sync from monitor lead type
......
......@@ -149,7 +149,7 @@ VduInit ROUT
LDROSB R0, LastBREAK ; is it a hard reset ?
TEQ R0, #0
TEQ R0, #SoftReset
BEQ %FT10 ; [no, don't reset font]
......
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