; Copyright 2000 Pace Micro Technology plc
;
; 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.
;
; amg 7/12/96 Renaissance
; Forcibly ensure that options only intended for one class of platform
; stay there. Generally this involves combining switches with the STB
; switch. The exception is processor architectural stuff. 7500FE is
; included always, and StrongARM has an independed switch.
;
; When you want to migrate features from one platform to another you'll
; find that every occurence of feature switches has been qualified with
; the appropriate sense of the STB switch. This is to remind you to think
; about what you're about to do! Check whether the code actually will work
; at all on something that is or is not a STB class product.
;
; Using the STB switch this aggressively also help ensure that there's
; no unexpected code crossover in the initial merge.

; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; now the conditional flags for the version we want
; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

                GBLL    CacheOff
CacheOff        SETL    {FALSE}

; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; essential global variables
; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

                GET   Version
                GBLS  VersionNo
                [ Module_MinorVersion = "" :LOR: :LNOT: STB
VersionNo       SETS  "$VString ($Date)"
                |
VersionNo       SETS  "$VString ($Date) $Module_MinorVersion"
                ]

; SystemName moved to Machine.* header files.

                GBLS  MosTitle
MosTitle        SETS  "$SystemName $VersionNo"

                GBLL  AddTubeBashers
AddTubeBashers  SETL  {FALSE}

Tube_Normal     *       1
Tube_Simulator  *       2

                GBLA    TubeType
TubeType        SETA    Tube_Simulator

UserMemStart    * &8000

                GBLL  ExceptionsAreErrors
ExceptionsAreErrors SETL  1=1

AssemblingArthur SETL  {TRUE}
; defined in hdr.system to allow conditionals in macros

                GBLL    DoingVdu
DoingVdu        SETL    {FALSE}         ; so can get KeyWS!
                GBLL    Module
Module          SETL    {FALSE}

                GBLL    IncludeTestSrc  ; whether test code is included
IncludeTestSrc  SETL    :LNOT: HAL

;RISC OS 3.71 onwards assumed bus timings - if true, then ROM speeds atc are assumed according to IOMD ID regs. as follows:
;     if IOMD (Risc PC)     ROM ticks 5-3 (assumed bus 32 MHz)
;     if 7500 (A7000)       ROM ticks 5-3 (assumed bus 32 MHz), all clocks divide-by-1
;     if 7500FE (A7000+)    ROM ticks 5-3,half speed (asssumed bus 64 MHz), EDO memory, divide-by-2 I/O, divide-by-1 CPU and memory
;
                GBLL    RO371Timings
RO371Timings    SETL    :LNOT: STB

; For development on Customer M hardware only
                GBLL    ParallelFlashUpgrade
ParallelFlashUpgrade SETL {FALSE}

;whether we support running on the (Risc PC) emulator
                GBLL    EmulatorSupport
EmulatorSupport SETL    {TRUE}

  [ :LNOT: RO371Timings

                GBLL    NormalSpeedROMS
 [ STB
NormalSpeedROMS SETL    {TRUE}           ;use FALSE for slow EPROMS
 |
NormalSpeedROMS SETL    {FALSE}          ;use FALSE for slow EPROMS
 ]

                GBLL    AutoSpeedROMS
AutoSpeedROMS   SETL    {TRUE} :LAND: :LNOT: STB

                GBLL    RISCPCBurstMode
RISCPCBurstMode SETL    {FALSE}
;>>>RCM says if the FRM approves the use of burst mode ROMS for
;>>>RISC PC (no reason why it shouldn't) all references to RISCPCBurstMode
;>>>could be replaced by NormalSpeedROMS

  ] ; :LNOT:RO371Timings

                GBLL    DoInitialiseMode
DoInitialiseMode SETL   {TRUE} :LAND: STB

 [ STB
                GBLL    Select16BitSound        ; STBs and pre-IOMD systems don't have this link
Select16BitSound SETL   {FALSE}
 |
                GBLL    Select16BitSound
Select16BitSound SETL   {TRUE}
 ]
                GBLL    Japanese16BitSound
Japanese16BitSound SETL {TRUE} :LAND: STB

                  GBLL   ChopOffTheGoolies
ChopOffTheGoolies SETL  {FALSE}

                GBLL   ChecksumCMOS
ChecksumCMOS    SETL   {TRUE}

                GBLL    SqueezeMods     ; whether squeezed modules are allowed
SqueezeMods     SETL    {TRUE}

                GBLL    International   ; whether text and error messages come from  messages file.
International   SETL    {TRUE}

                GBLL    CacheCommonErrors       ; whether common internationalised errors are cached in sysheap
CacheCommonErrors       SETL    International :LAND: {TRUE}

                GBLL    MouseBufferManager      ; Whether mouse uses buffer manager
MouseBufferManager      SETL    {TRUE}

                GBLL    IrqsInClaimRelease      ; Whether OS_Claim/Release restore IRQ's before releasing heap node
IrqsInClaimRelease      SETL  {TRUE}

                GBLL    TickIrqReenter          ; Whether TickEventChain processing re-enables IRQ's
TickIrqReenter  SETL    {TRUE}

                GBLL    SoftResets              ; If false, always force a hard reset
SoftResets      SETL    {FALSE}

                GBLL    AlwaysClearRAM          ; If true, clear RAM on every break/reset
AlwaysClearRAM  SETL    {TRUE}

                GBLL    CacheCMOSRAM            ; Whether to keep a RAM copy of CMOS RAM for faster access
CacheCMOSRAM    SETL    {TRUE}

                GBLL    LCDInvert
LCDInvert       SETL    {TRUE} :LAND: :LNOT: STB

                GBLL    ModeSelectors           ; whether mode selectors are understood
ModeSelectors   SETL    {TRUE}

                GBLL    MakeModeSelectorsForModeNumbers
MakeModeSelectorsForModeNumbers SETL    ModeSelectors :LAND: {FALSE}    ; not actually needed after all

                GBLL    IgnoreVRAM              ; if true, don't add VRAM to the RAM list (+ don't use for screen)
IgnoreVRAM      SETL    {FALSE}

                GBLL    UseGraphicsV            ; if true, use GraphicsV, rather than going straight
UseGraphicsV    SETL    {TRUE}                  ; to the hardware (or HAL)

                GBLL    LateAborts              ; if true, use late abort mode on ARM600 (compulsory on ARM700)
LateAborts      SETL    {TRUE}

                GBLL    ShrinkableDAs           ; if true, support Shrinkable Dynamic Areas (eg. CacheFS)
ShrinkableDAs   SETL    {TRUE}

                GBLL    ShadowROM               ; if true, the ROM is mirrored above
ShadowROM       SETL    {FALSE}                 ; &FF800000

                GBLL    Interruptible32bitModes
Interruptible32bitModes SETL {TRUE}             ;if true, limited 32-bit mode code support (interrupt handler does not assume
                                                ; 26-bit foreground), also allows faster, 32-bit APCS version of FPEmulator

                 GBLL   GSWorkspaceInKernelBuffers      ; Move gstrans workspace into the kernel buffers area to fix redirection
GSWorkspaceInKernelBuffers SETL   {TRUE}		; and everything else that suffers from the dodgy use of scratch space.


                GBLL    EarlierReentrancyInDAShrink
EarlierReentrancyInDAShrink SETL {TRUE}         ; fix for RAMFS and new FileCore (causes reentrant DA shrink/remove)

                GBLL    OnlyKernelCanAccessHardwareVectors
OnlyKernelCanAccessHardwareVectors SETL {TRUE}  ; if true, only the Kernel is permitted to write to the hardware vectors
                                                ; while in 26-bit mode. If false, the whole ROM can (including BASIC
                                                ; and the Shared C Library - eg any memcpy!)

                GBLL   LongCommandLines         ; first introduced for Ursula, merged into HAL kernel
LongCommandLines SETL   {TRUE}
  [ LongCommandLines
LongCLISize          * 1024                     ; buffer size for long commands
  ]

                GBLL    StrongARM
                GBLL    SAcleanflushbroken      ;whether StrongARM single MCR for DC clean+flush broken (is always for SA110)
                GBLL    SASTMhatbroken          ;whether ROM must support SA110's with broken STM^ (revision 3 should fix this)
                GBLL    StrongARM_POST          ;whether to run POST for StrongARM (and possibly ARM8)

                GBLL    ARM6support
                GBLL    XScaleMiniCache         ;is the XScale mini data-cache used (at all)
                GBLL    XScaleJTAGDebug
                GBLL    ECC                     ;use ECC on XScale. May compromise other ARM compatibility

StrongARM          SETL {TRUE}
SAcleanflushbroken SETL {TRUE}  :LAND: StrongARM
SASTMhatbroken     SETL {TRUE}  :LAND: StrongARM
StrongARM_POST     SETL {TRUE}  :LAND: StrongARM

ARM6support        SETL {TRUE}

XScaleMiniCache    SETL {FALSE}

XScaleJTAGDebug    SETL {TRUE}

ECC                SETL {FALSE}


                ;mjs
                ;concept of sparsely mapped dynamic areas introduced for Ursula
                GBLL    DA_Batman               ;Holey dynamic areas Batman!

                ;mjs
                ;Chocolate flavours implemented for Ursula, but they are generally useful performance enhancements
                ;(not all Ursula performance improvements are flagged with Chocolate - eg. simple changes such as slicker SWI
                ;despatch and wider SWI hashing)
                ;
                ;any ARM
                ;
                GBLL    ChocolateSysHeap        ;whether to save cost of SysHeap block claim/release for common cases (eg. callback blocks)
                                                ;also reduces SysHeap stress by using fewer blocks in total
                GBLL    ChocolateOSMod          ;whether to reduce SysHeap stress in module handling
                GBLL    ChocolateSysVars        ;whether to do performance improvements in system variable handling
                GBLL    ChocolateOscli          ;whether to do performance improvements in Oscli command stuff
                GBLL    ChocolateService        ;whether to implement fast module service call distribution (uses table introduced
                                                ;into module format by Ursula API)

                ;possibly enabled at run time for some ARMs only
                ;
                GBLL    ChocolateAMB            ;whether to compile support for Lazy task swapping

DA_Batman              SETL {TRUE}

ChocolateSysHeap       SETL {TRUE}
ChocolateOSMod         SETL {TRUE}
ChocolateSysVars       SETL {TRUE}
ChocolateOscli         SETL {TRUE}
ChocolateService       SETL {TRUE}
ChocolateAMB           SETL {TRUE} :LAND: No26bitCode   ; not implemented for 26bit kernel at present
  [ ChocolateSysHeap
                       GBLA  MaxChocolateCBBlocks  ;max quick CallBack blocks available at any one time (else ordinary heap nodes used)
                       GBLA  MaxChocolateSVBlocks  ;max quick Software Vector blocks available at any one time (else ordinary heap nodes used)
                       GBLA  MaxChocolateTKBlocks  ;max quick Ticker blocks available at any one time (else ordinary heap nodes used)
                       GBLA  MaxChocolateMRBlocks  ;max module ROM blocks before ordinary heap nodes are used (reduces total no. nodes in SysHeap)
                       GBLA  MaxChocolateMABlocks  ;max module Active blocks before ordinary heap nodes are used
                       GBLA  MaxChocolateMSBlocks  ;max module SWI Hash blocks before ordinary heap nodes are used
MaxChocolateCBBlocks   SETA   32
MaxChocolateSVBlocks   SETA  128
MaxChocolateTKBlocks   SETA   32
MaxChocolateMRBlocks   SETA  150
MaxChocolateMABlocks   SETA  150
MaxChocolateMSBlocks   SETA  150
  ]

                          GBLL    Oscli_QuickAliases
                          GBLL    Oscli_HashedCommands
Oscli_QuickAliases        SETL    {TRUE} :LAND: ChocolateOscli   ;try to do a better job of checking for aliases
Oscli_HashedCommands      SETL    {TRUE} :LAND: ChocolateOscli   ;try to do a better job of finding commands


                GBLL    VCOstartfix              ;code in early kernel to fix VCO start problem on A7000 (esp. 7500FE)
VCOstartfix     SETL    {TRUE}


                     GBLL    mjsServiceTrace          ;for statistics gathering on service calls only
mjsServiceTrace      SETL    {FALSE}
                     GBLL    mjsSysHeapNodesTrace     ;for statistics gathering on some SysHeap nodes only
mjsSysHeapNodesTrace SETL    {FALSE}

                GBLL    NoSPSRcorruption              ;set to true if IRQ dispatcher
NoSPSRcorruption SETL   {FALSE}                       ;preserves SPSR_SVC

                GBLL    CheckProtectionLink     ; if true, disallow CMOS RAM changes if link in protected position
CheckProtectionLink     SETL {TRUE}             ; NB affects Delete/Copy/R/T and 0-9/.

                GBLL    RMTidyDoesNowt          ; if true, RMTidy does nothing
RMTidyDoesNowt  SETL    {TRUE}                  ; should really be "machine has FSLock in ROM"

                GBLL    RogerEXEY               ; if true, use Roger's new algorithm for XEigFactor, YEigFactor
RogerEXEY       SETL    {FALSE}                 ; Marketing don't like it!

                GBLL    DebugROMInit
DebugROMInit    SETL    {FALSE}

                GBLL    DebugROMPostInit ; Displays when the PostInit service call is sent to each ROM module (currently works on vanilla service call handling only)
DebugROMPostInit SETL    (:LNOT: ChocolateService) :LAND: {FALSE}

                GBLL    DebugROMErrors
DebugROMErrors  SETL    {FALSE}

                GBLL    DebugTerminal           ; default WRCH and RDCH through HAL
DebugTerminal   SETL    {FALSE}

                GBLL    DebugHALTX
DebugHALTX      SETL    {FALSE}

                GBLL    DebugHeaps              ; initialise claimed and freed blocks
DebugHeaps      SETL    {FALSE}                 ; (may slow things down unacceptably)
              [ DebugHeaps
                ! 0, "*** WARNING *** Heap debugging assembled in"
              ]

; ChangeDynamicArea and related options

                GBLL    DebugCDA
DebugCDA        SETL    {FALSE}

                GBLL    DebugCDA2
DebugCDA2       SETL    {FALSE}

                GBLL    StorkPowerSave  ;True => power saving for Stork AND A4
StorkPowerSave  SETL    MorrisSupport   ;False=> older A4 code only

                GBLL    LCDSupport      ;Whether LCD Support is assembled in or not
LCDSupport      SETL    {TRUE} :LAND: :LNOT: STB
                                        ;(First intro'd for Stork)

                GBLL    FixR9CorruptionInExtensionSWI   ; whether R9 corruption by ExtensionSWI handler is fixed
FixR9CorruptionInExtensionSWI   SETL    No26bitCode     ; currently FALSE as CC's !SpellMod (possibly others) rely on it being broken

                GBLL    FixCallBacks            ; see Docs.CallbackChange
FixCallBacks    SETL    {TRUE}                  ; also addresses some atomicity problems

                GBLL    InterlacedPointer
InterlacedPointer SETL {TRUE} :LAND: STB                ; enable code to do proper interlaced pointer

                GBLL    ValidateCMOS            ; Apply special CMOS-corruption detection code,
ValidateCMOS    SETL    {TRUE}                  ; and do minimal default settings.

                GBLS    GetMessages
              [ International
GetMessages     SETS    "GET s.MsgCode"
              |
GetMessages     SETS    ""
              ]

                GBLL    DebugForcedReset        ; debug forced hard resets
DebugForcedReset SETL   {FALSE}

                GBLA    ConfiguredLang
ConfiguredLang  SETA    11                      ; default configured language

                GBLA    FirstUnpluggableModule
FirstUnpluggableModule  SETA 8                  ; Podule, FileSwitch, ResourceFS, Messages, MessageTrans,
                                                ; TerritoryManager, UKTerritory

 [ DebugForcedReset
Reset_CannotResetFlag           * 1
Reset_SysHeapCorrupt            * 2
Reset_WrongCamMapAddress        * 3
Reset_WrongNumberOfPages        * 4
Reset_CamMapCorrupt             * 5
Reset_VectorChainCorrupt        * 6
Reset_TickNodesCorrupt          * 7
Reset_DeviceVectorCorrupt       * 8
Reset_PoduleOrCallBackCorrupt   * 9
 ]

; Flags for RISC OS Blue changes
;
                        GBLL    AssembleKEYV
AssembleKEYV            SETL    {TRUE}          ; Use KEYV.
                        GBLL    AssemblePointerV
AssemblePointerV        SETL    {TRUE}          ; Use PointerV.
                        GBLL    PollMouse
PollMouse               SETL    {FALSE}         ; Poll mouse.

                        GBLL    ProcessorVectors
ProcessorVectors        SETL    {TRUE}          ; Processor vectors indirected through 0 page.

                    GBLS  GetUnsqueeze
 [ SqueezeMods
GetUnsqueeze        SETS  "GET s.Unsqueeze"
 |
GetUnsqueeze        SETS  ""
 ]
                    GBLS  GetFlashROM
 [ ParallelFlashUpgrade
GetFlashROM         SETS  "GET s.FlashROM"
 |
GetFlashROM         SETS  ""
 ]
                    GBLS  GetKernelMEMC
                    GBLS  GetPalette
                    GBLS  GetMemInfo
                    GBLS  GetHAL
GetKernelMEMC       SETS  "GET s.ARM600"
GetMemInfo          SETS  "GET s.MemInfo"

GetPalette          SETS  "GET s.vdu.vdupalxx"
 [ HAL
GetHAL              SETS  "GET s.HAL"
 |
GetHAL              SETS   ""
 ]


                    GBLS  GetKbdDrA1
 [ Keyboard_Type = "A1A500"
GetKbdDrA1          SETS  "GET s.PMF.KbdDrA1"
 |
GetKbdDrA1          SETS  ""
 ]

                    GBLS  GetKbdRes
 [ :LNOT: HAL
 [ Keyboard_Type = "A1A500"
GetKbdRes           SETS  "GET s.KbdResA1"
 |
GetKbdRes           SETS  "GET s.KbdRes" :CC: Keyboard_Type
 ]
 ]

; control switches for med_00001 (the flood fill routines 1024 line limit).
; Switches have the following effects:
;
; _userma     Will use rma if >48K is free, up to a maximum of 128K. It will
;             try to acheive the latter by growing the rma if possible.
; _twowords   Use two word entries in the queue. This overcomes the limitation
;             of the original packed word format.
; _debug      Store the queue start, end and 'amount to change the rma dynamic
;             area by' in the first three words of OldIRQ1VSpace

                    GBLL  med_00001_userma
                    GBLL  med_00001_twowords
                    GBLL  med_00001_debug

med_00001_userma    SETL  {TRUE}
med_00001_twowords  SETL  {TRUE}
;med_00001_debug     SETL  {TRUE}

;med_00001_userma    SETL  {FALSE}
;med_00001_twowords  SETL  {FALSE}
med_00001_debug     SETL  {FALSE}

 [ med_00001_userma
smallest_rma_size   * (48*1024)                  ; define the low threshold for rma use
largest_rma_size    * (128*1024)                 ; and the ceiling for rma use
 ]

 [ med_00001_debug
 ! 0,""
 ! 0,",-----------------------------------------------------------------,"
 ! 0,"| **** WARNING ****                                               |"
 ! 0,"|                                                                 |"
 ! 0,"| Audit trail debugging for MED-00001 is enabled. This reuses the |"
 ! 0,"| first three words of OldIRQ1Vspace. This should be turned off   |"
 ! 0,"| once MED-00001 has been tested and marked 'fixed'.              |"
 ! 0,"|                                                                 |"
 ! 0,"| Usage:                                                          |"
 ! 0,"|   +0   start of area used by flood fill                         |"
 ! 0,"|   +4   end+1 of area used by flood fill                         |"
 ! 0,"|   +8   amount the rma was grown by                              |"
 ! 0,"'-----------------------------------------------------------------'"
 ! 0,""
 ]

; Ickle macros. We want to be able to turn IRQs on and off fast in the
; code in various places. To do this easily, have a name for the
; SVC26/32 mode we run in.

 [ No26bitCode
USR2632 * USR32_mode
SVC2632 * SVC32_mode
 |
USR2632 * USR26_mode
SVC2632 * SVC26_mode
 ]

MaxSwi  * OS_HeapSort32+1

        END