KernelWS 70.7 KB
Newer Older
Neil Turton's avatar
Neil Turton committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
; Copyright 1996 Acorn Computers Ltd
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
;     http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
        SUBT    > Kernel WorkSpace

OldOpt  SETA    {OPT}
        OPT     OptNoList+OptNoP1List

; ***********************************
; ***    C h a n g e   L i s t    ***
; ***********************************

; Date       Name  Description
; ----       ----  -----------
; 02-Nov-87  APT   Added module SWI hash table
; 03-Nov-87  APT   Modo-fied module SWI hash table info, removed BRKLST
; 09-Nov-87  APT   Removed ESCCNT and ESFLG
; 12-Nov-87  APT   Added IRQsema
; 13-Nov-87  APT   Added DefaultIRQ1V codespace
; 16-Nov-87  APT   PIRQ chain heads
; 18-Nov-87  APT   Reordered EvtHan, EvtHan_ws
; 19-Nov-87  APT   Moved IRQsema
; 01-Dec-87  APT   Added interruptible heap manager workspace
; 08-Dec-87  TMD   Added ECFShift, ECFYOffset
; 14-Dec-87  TMD   Added DisplayNColour, DisplayModeFlags
; 15-Dec-87  TMD   Added KeyAlphabet
; 22-Dec-87  NDR   Using ScratchSpace
; 13-Jan-88  APT   General scratchspace bash, low workspace reordering.
;                  Removed spurious 32 bytes of osbyte wspace
; 14-Jan-88  APT   *type buffer in scratchspace.
;                  MOShasFIQ byte added
; 20-Jan-88  APT   Workspace juggling for speed & space; also discarded
;                  Level0 stuff.
; 28-Jan-88  APT   MetroGnome moved to "public" location for ADFS
; 02-Feb-88  APT   FIQclaim_interlock added
; 05-Feb-88  APT   CallBack_Vector
; 09-Feb-88  APT   RAM for SWI despatch
; 17-Feb-88  TMD   Added VduSaveArea, VduSaveAreaPtr, DisplayModeNo
; 26-Feb-88  APT   NoOfCamEntries manifest
; 03-Mar-88  APT   Shrank SVC despatch
; 03-Mar-88  APT   NoOfCamEntries manifest doubled
; 07-Mar-88  TMD   Added DisplayScreenStart, VduOutputCurrentState,
;                  SpriteMaskSelect, reordered mode variables
; 07-Mar-88  APT   Made CamEntries always at &164
; 07-Mar-88  TMD   Added GCharSizes, GCharSizeX, GCharSizeY
; 08-Mar-88  TMD   Added GCharSpacing, GCharSpaceX, GCharSpaceY
; 08-Mar-88  TMD   Moved GCharSizes..GCharSpaceY into first 1K of workspace
; 15-Mar-88  TMD   Added HLineAddr
; 18-Mar-88  TMD   Added DisplayXWindLimit, DisplayYWindLimit,
;                   DisplayXEigFactor, DisplayYEigFactor, PointerXEigFactor
; 18-Mar-88  APT   Setting variables scratchspace use revised.
; 21-Mar-88  TMD   Removed CursorIndex
; 22-Mar-88  TMD   Added TCharSizeX,TCharSizeY,TCharSpaceX,TCharSpaceY
; 29-Mar-88  TMD   Added GcolOraEorAddr
; 31-Mar-88  TMD   Removed WsFontPtr
; 07-Apr-88  SKS   Added HeapSort use of ScratchSpace
; 14-Apr-88  TMD   Added SerialFlags
; 28-Apr-88  TMD   Added XONXOFFChar
;  5-May-88  APT   Added MemorySpeed
; 18-May-88  APT   Added CannotReset sema at &107, removed pre-1.20 changes.
; 24-May-88  TMD   Added ClipBoxEnable, ClipBoxLCol..ClipBoxTRow, moved in
;                   ScrLoaSpriteCB, ScrLoaBuffer, SrcSavCommon
; 24-May-88  TMD   Flood fill uses ScratchSpace
; 01-Jun-88  TMD   Added AlignSpace for ClipBoxCoords
; 03-Jun-88  BCSKS Make Keyboard buffer into a useful part of the system
;                  Also PrinterBufferSize
; 09-Jun-88  DJS   Draw uses ScratchSpace
; 09-Jun-88  BC    Gave Econet some private debungling space
; 11-Jun-88  SKS   Align IRQ stack to make STMFD not cross two MEMC bdy's
;                  Made info condit'l on AsmArf; someone had commented it out!
; 15-Jun-88  SKS   Added two more instructions in SWIDespatch area
;                  Moved SLVK definition into kernel; it's not public
; 16-Jun-88  SKS   Added 3 more instructions in SWIDespatch area + nailed
;                  SvcTable address for compatibility
; 22-Jun-88  SKS   Moved MEMC_CR_SoftCopy into pubic ws
; 19-Jul-88  APT   Added UpCall handler stuff
; 20-Jul-88  SKS   Added above entry
;                  Amended comment about overlaid workspace in vdu
; 15-Aug-88  SKS   Inserted DomainId at FF8 (set by Wimp on task swap, used by
;                  FileSwitch to tag resources)
; 27-Sep-89  JSR   Added ColourTrans to users of scratch space
; 24-Oct-89  TMD   Added CamEntriesForBigMachines, CamEntriesPointer
; 26-Oct-89  TMD   Added MaxCamEntry, removed NoOfCamEntries symbol
; 27-Oct-89  TMD   Added VIDCClockSpeed
; 09-Nov-89  TMD   Added ResetIndirection
; 15-Jan-91  TMD   Added ROMModuleChain
; 04-Feb-91  DDV   Added DeviceFS as user of ScratchSpace.
; 04-Feb-91  DDV   Added ColourTrans use of ScratchSpace to build diff tables.
; 06-Mar-91  TMD   Added IOSystemType
; 07-Mar-91  LVR   ADFS uses scratch space for floppy formatting
; 07-Mar-91  TMD   Added MonitorLeadType
; 08-Mar-91  TMD   Added PrinterBufferAddr, PrinterBufferSize
; 11-Apr-91  TMD   Added SerialInHandle, SerialOutHandle
; 24-Apr-91  TMD   Added UniqueMachineID
; 09-Jun-91  RM    Added KernelMessagesBlock,ErrorSemaphore and MOSConvertBuffer
; 26-Jul-91  JSR   Extend GeneralMOSBuffer by 4 bytes to make it a valid
;                       length for the default error handler's error buffer
; 19-Aug-91  JSR   Added *If to list of GeneralMOSBuffer users
; 22-Aug-91  TMD   Reduced ErrorSemaphore to a byte, added PortableFlag
; 25-Aug-91  DDV   Updated to indicate correct usage of scratch space by ColourTrans
; 09-Jan-92  DDV   Added FgPattern, BgPattern and indicate use of ScratchSpace by OS_SetColour
; 20-Jan-92  TMD   OS_SetColour no longer uses ScratchSpace
; 17-Feb-92  ECN   Added CLibWord and RISCOSLibWord
; 02-Apr-92  TMD   Added ScreenBlankFlag
; 27-Jul-92  TMD   Create Victoria specific version
; 28-Jul-92  TMD   Moved RAMDiscAddress
; 29-Jul-92  TMD   Moved SpriteSpaceAddress
; 30-Jul-92  TMD   Moved FontCacheAddress
; 31-Jul-92  TMD   Moved ScreenEndAdr from source.vdudecl, and moved actual address!
; 03-Aug-92  TMD   Added PhysRam (moved from hdr:System)
; 24-Aug-92  TMD   Added AbortIndirection
; 26-Aug-92  TMD   Added PreVeneerRegDump
; 02-Sep-92  TMD   Added FirPalAddr, SecPalAddr
; 10-Sep-92  DDV   Added new Vdu Variables for new text expansion buffer
; 17-Sep-92  DDV   Moved NColour into the word initialised VDU workspace
; 17-Sep-92  DDV   Two new colour words added for text foreground and background.
; 27-Jan-93  TMD   Moved RMA to new position
; 29-Jan-93  TMD   Put RMA back to old position (you can't branch to above 32M!)
; 01-Feb-93  TMD   Added PhysRamTable
; 02-Feb-93  TMD   Added VInitSoftCopy and VEndSoftCopy
; 03-Feb-93  TMD   Added PhysRamTableEnd
; 04-Feb-93  TMD   Added extra slot in PhysRamTable (in case soft-loaded OS splits a bank)
; 08-Feb-93  TMD   Added VRAMWidth variable, and extra symbols for skipped bits
; 24-Feb-93  TMD   Changed VRAMPhysAddr to VideoPhysAddr, and split off VideoSize from VRAMSize, to allow for
;                   DRAM-only systems
; 05-Mar-93  TMD   Added CMOSRAMCache
; 19-Apr-93  TMD   Added DAList, AppSpaceDANode and DANode offset symbols
; 26-Apr-93  TMD   Added FreePoolAddress, FreePoolMaxSize, FreePoolSize
; 29-Apr-93  TMD   Changed FontCacheAddress, SpriteSpaceAddress, RAMDiscAddress and FreePoolAddress
;                   in order to make way for L2PT, which is moving above 64M
; 10-May-93  TMD   Added SoftCamMapSize
; 11-May-93  TMD   Moved SoftCamMapSize into area that's not zapped in clearing all memory routine
; 12-May-93  TMD   Added FreePoolDANode, removed FreePoolSize
; 20-May-93  TMD   Moved AplWorkSize into AppSpaceDANode
; 27-May-93  TMD   Added VideoBandwidth
; 04-Jun-93  TMD   Added CurrentMonitorType
; 09-Jun-93  TMD   Added CamMapCorruptDebugBlock
; 07-Jul-93  TMD   Increased FreePoolMaxSize to 64M (had to reduce RAMDiscMaxSize to 48M and
;                   move FreePoolAddress down to do this)
; 15-Jul-93  TMD   Added KernelModeSelector
; 26-Jul-93  SMC   Moved DefaultIRQ1V (had to accommodate IRQs for IOMD DMA)
; 04-Aug-93  TMD   Added L2PTSize, removed FreePoolMaxSize
; 14-Aug-93  TMD   Removed SpriteSpaceAddress, shuffled things down
; 16-Aug-93  TMD   Removed RAMDiscAddress, shuffled things down
; 17-Aug-93  TMD   Removed FontCacheAddress, shuffled things down
;                  Corrected maximum size of system heap to 2M-8K.
;                  Added node (in bottom 32K) for system heap.
; 25-Aug-93  SMC   Added processor vector table at ProcVec_Start
;                  Added ProcVecPreVeneers
; 02-Sep-93  SMC   Moved RMA to &02100000 and changed application space size to 28M.
; 03-Sep-93  TMD   Moved InitKbdWs into SkippedTables (was at start of screen originally)
; 07-Oct-93  TMD   Put in OldMemoryMap option so I can still use it
; 07-Oct-93  TMD   Added ScreenBlankDPMSState, HSWRSoftCopy, VSWRSoftCopy
; 10-Dec-93  BC    Added RawMachineID
; 13-Dec-93  BC    Removed UniqueMachineID
; 14-Jan-94  TMD   Added CDASemaphore
; 18-Jan-94  TMD   Added MMUControlSoftCopy
; 15-Jun-94  AMcC  Renamed file (was VickySpace)
;                  The following values are 'exported' to PublicWS:
;                        Name:                     Used by:
;                        ----------------------------------
;                        BgEcfOraEor               SprExtend
;                        FgEcfOraEor               SprExtend
;                        BranchToSWIExit           TaskWindow
;                        CannotReset               FileCore
;                        DomainId                  FileSwitch
;                        ESC_Status                ADFS, DeviceFS
;                        IRQsema                   Draw, MsgTrans
;                        LatchBSoftCopy            ADFS, Parallel
;                        MEMC_CR_SoftCopy          ADFS
;                        RedirectInHandle          TaskWindow
;                        RedirectOutHandle         TaskWindow
;                        ScratchSpace              ADFS, Colours, Draw, FileCore
;                                                  FileSwitch, FontManager, NetFiler
;                        SoundDMABufferSize        Sound0
;                        SoundDMABuffers           Sound0
;                        SoundWorkSpace            Portable, Sound1, Sound2, Voices
;                        SVCSTK                    FileSwitch
;                        SvcTable                  TaskWindow, Wimp
;                        SysHeapStart              FileSwitch
;                        VduDriverWorkSpace        SprExtend
;
; 31-Oct-94  AMcC/RM/WT  Added CLine_Softcopy for Morris monitor id
; 03-Nov-94  AMcC        Export ScreenBlankFlag and ScreenBlankDPMSState
;                        (for DPMSUtils: part of RISC OS releases 3.50 and 3.60)
Neil Turton's avatar
Neil Turton committed
197
; 28-Mar-95  JRH         Added NVRamSize and RTCFitted, conditioned on E2ROMSupport
Neil Turton's avatar
Neil Turton committed
198
; 06-Feb-95  SMC         Increased SVC stack size to 12K.
Neil Turton's avatar
Neil Turton committed
199 200 201 202 203 204 205 206 207
; 18-Jan-96  JRH         Removed CLine_Softcopy cos not needed
; 06-Feb-96  SMC         Increased DefIRQ1Vspace for IRQC registers
; amg 6/12/96 Renaissance. Merge in changes below from 3.70 version. Make changes conditional.
; 07-Feb-95  WT          Added LCD_Active for LCD/CRT dynamic switching support
; 07-Feb-95  WT          Added VStartSoftCopy for dual-panel LCD support
; 18-May-95  WT          Added LCD_Inverted for LCD inversion (well, surprise surprise!)
; 05-Dec-95  WT          Added ProcessorType and ProcessorFlags (1 byte each)
; amg 07/12/96 Renaissance. Shifted ResetType (which is a public export) so it'll
;              stay in the same place.
Kevin Bracey's avatar
Kevin Bracey committed
208
; 21-Jul-98  NDT         Added PixelRate.  Moved KernelModeSelector to make space.
209
; 19-Oct-99  KJB         Moved IOSystemType into SkippedTables.
Neil Turton's avatar
Neil Turton committed
210 211 212 213 214 215
;
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Memory map:

; Dynamic area node format

216
                  ^     0
217
DANode_Link       #     4               ; points to next node (in address order)
218 219 220
DANode_Number     #     4               ; number of this area
DANode_Base       #     4               ; base address of area (points in middle of doubly-mapped areas)
DANode_Flags      #     4               ; various flags
221 222
DANode_Size       #     4               ; current logical size of area (not counting holes, if Sparse/PMP area)
DANode_MaxSize    #     4               ; maximum logical size of area
223 224 225 226 227 228
DANode_Workspace  #     4               ; workspace pointer when calling handlers
DANode_Handler    #     4               ; pointer to handler routine for area
DANode_Title      #     4               ; pointer to area title
DANode_SubLink    #     4               ; next node in any disjoint sublist (currently used for Shrinkables only)
DANode_SparseHWM  #     4               ; high water mark, if Sparse area (highest base+size claimed for area)
DANode_SortLink   #     4               ; next node in alphabetically sorted list
229 230 231
DANode_PMP        #     4               ; pointer to physical memory pool - zero if not PMP or has been resized to zero
DANode_PMPSize    #     4               ; number of pages currently in phys pool
DANode_PMPMaxSize #     4               ; size of phys memory pool, in pages
232 233
DANode_NodeSize   #     0

234 235 236 237 238 239 240 241 242
; CAM entry format
                  ^     0
CAM_LogAddr       #     4               ; Logical address page is assigned to (lower address if doubly mapped, Nowhere/DuffEntry if not mapped)
CAM_PageFlags     #     4               ; DynAreaFlags_* and PageFlags_*
CAM_PMP           #     4               ; Pointer to PMP (DANode ptr) if DynAreaFlags_PMP. 0 if not.
CAM_PMPIndex      #     4               ; Index of page in PMP page list. Invalid if not in PMP.
CAM_EntrySize     #     0
CAM_EntrySizeLog2 *     4

Neil Turton's avatar
Neil Turton committed
243 244 245

; The addresses below are only temporary; eventually most of them will be allocated at run time (we hope!)

246
 [ HiProcVecs
247
ProcVecs            * &FFFF0000
248
 |
249
ProcVecs            * &00000000
250
 ]
251 252
; Currently, zero page must be located at the processor vectors
ZeroPage            * ProcVecs
253

254 255 256 257
 [ CompatibilityPage
        ASSERT ZeroPage != 0 :LAND: ProcVecs != 0
 ]

258
; Sort out 26/32 bit versions
259 260 261 262
SVCStackSize        *  32*1024
IRQStackSize        *   8*1024
ABTStackSize        *   8*1024
UNDStackSize        *   8*1024
263
KbuffsMaxSize       *  64*1024
264
ScreenMaxSize       * 480*1024
265
DCacheCleanSize     * 256*1024  ;should be multiple of 64k
Kevin Bracey's avatar
Kevin Bracey committed
266

267 268 269
AplWorkMaxSize      * &20000000 ; 512M - temporary (need to decide this at boot time)
RMAAddress          * AplWorkMaxSize ; temporary - run time allocate?
RMAMaxSize          * &10000000 ; 256M
270 271 272 273
SysHeapChunkAddress * RMAAddress + RMAMaxSize
SysHeapAddress      * SysHeapChunkAddress
SysHeapMaxSize      * 32:SHL:20
FreePoolAddress     * 0
274

Jeffrey Lee's avatar
Jeffrey Lee committed
275 276 277 278 279 280 281 282 283 284 285 286 287
        MACRO
$label  ASpace $size, $align
      [ "$align" <> ""
        AlignSpace $align
      ELIF $size >= &10000
        AlignSpace &10000 ; 64K align to make large page mapping a possibility
      ]
      [ "$label" <> "" :LAND: :DEF:ShowWS
        ! 0, "$label at ":CC::STR:@
      ]
$label  # $size
        MEND

288
                    ^ &B9000000
Jeffrey Lee's avatar
Jeffrey Lee committed
289 290 291
IOLimit             ASpace &41000000 ; initial lower limit on room for IO space (DA creation may move limit up)
                                     ; IO start will be placed just before CAM (calculated at runtime)
CAMTop              ASpace &00000000 ; top of CAM, will be allocated down from here
292
HALWorkspaceSize    * &00100000
Jeffrey Lee's avatar
Jeffrey Lee committed
293 294 295 296 297 298
HALWorkspace        ASpace HALWorkspaceSize
IRQStackAddress     ASpace IRQStackSize, &100000
SVCStackAddress     ASpace SVCStackSize, &100000
ABTStackAddress     ASpace ABTStackSize, &100000
UNDStackAddress     ASpace UNDStackSize, &100000
DCacheCleanAddress  ASpace &00040000, &10000 ; eg. for StrongARM, 256k of space
299
KbuffsBaseAddress   ASpace KbuffsMaxSize ; kernel buffers for long command lines
Jeffrey Lee's avatar
Jeffrey Lee committed
300
HALWorkspaceNCNB    ASpace &00008000 ; 32K of uncacheable HAL workspace (if requested)
Jeffrey Lee's avatar
Jeffrey Lee committed
301 302 303 304 305
 [ LongDesc
LL3PT               ASpace &00800000, &100000 ; 8MB of L3PT
LL2PT               ASpace &00004000 ; 16KB of L2PT
LL1PT               ASpace &00001000 ; 32 bytes of L1PT
 |
Jeffrey Lee's avatar
Jeffrey Lee committed
306 307
L2PT                ASpace &00400000, &400000
L1PT                ASpace &00004000
Jeffrey Lee's avatar
Jeffrey Lee committed
308
 ]
Jeffrey Lee's avatar
Jeffrey Lee committed
309 310 311 312 313
                    ASSERT &FAFF0000-@ < &80000000
                    # &FAFF0000-@    ; padding to ensure SoundWorkSpace export is correct (in CursorChunkAddress)
CursorChunkAddress  ASpace &00008000
DuffEntry           ASpace &00001000 ; No page ever mapped in here (L2PT entry always 0), also, all non mapped pages
Nowhere             * DuffEntry      ; use this as their CAM entry. There is only one 'Nowhere' (synonym).
Jeffrey Lee's avatar
Jeffrey Lee committed
314
PhysicalAccess      ASpace &01000000, &01000000 ; 16MB allocation to permit supersection mapping
315 316 317 318 319 320 321
WorkspaceLimit      # 0

                 GBLL ROMatTop
ROM                 * &FC000000
ROMatTop         SETL {TRUE}
        ASSERT ROM >= WorkspaceLimit

322 323 324 325

IRQSTK              * IRQStackAddress + IRQStackSize
ABTSTK              * ABTStackAddress + ABTStackSize
UNDSTK              * UNDStackAddress + UNDStackSize
Neil Turton's avatar
Neil Turton committed
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; system variables

        ^  0,R12

OSBYTEFirstVar  #  0

ByteVars  #  0                 ; The main osbyte variables, accessed
                               ; via calls &A6 to &FF

VarStart  #  2                 ; &A6,&A7
ROMPtr    #  2                 ; &A8,&A9
ROMInfo   #  2                 ; &AA,&AB
KBTran    #  2                 ; &AC,&AD
VDUvars   #  2                 ; &AE,&AF

CFStime   #  1                 ; &B0
InputStream #  1               ; &B1
KeyBdSema #  1                 ; &B2

ROMPollSema #  1               ; &B3
OSHWM     #  1                 ; &B4

RS423mode #  1                 ; &B5
NoIgnore  #  1                 ; &B6
CFSRFS    #  1                 ; &B7
VULAcopy  #  2                 ; &B8,&B9

ROMatBRK  #  1                 ; &BA
BASICROM  #  1                 ; &BB

ADCchanel #  1                 ; &BC
ADCmaxchn #  1                 ; &BD
ADCconv   #  1                 ; &BE

RS423use     #  1              ; &BF
RS423conflag #  1              ; &C0

FlashCount # 1                 ; &C1
SpacPeriod # 1                 ; &C2
MarkPeriod # 1                 ; &C3

KeyRepDelay # 1                ; &C4
KeyRepRate  # 1                ; &C5

ExecFileH   # 1                ; &C6
SpoolFileH  # 1                ; &C7

ESCBREAK    # 1                ; &C8 (200)

KeyBdDisable # 1               ; &C9
KeyBdStatus  # 1               ; &CA

RS423HandShake # 1             ; &CB
RS423InputSupr # 1             ; &CC
RS423CFSFlag   # 1             ; &CD

EconetOScall # 1               ; &CE
EconetOSrdch # 1               ; &CF
EconetOSwrch # 1               ; &D0

SpeechSupr # 1                 ; &D1
SoundSupr # 1                  ; &D2

BELLchannel # 1                ; &D3
BELLinfo    # 1                ; &D4
BELLfreq    # 1                ; &D5
BELLdur     # 1                ; &D6

StartMessSupr # 1              ; &D7

SoftKeyLen # 1                 ; &D8

PageModeLineCount # 1          ; &D9

VDUqueueItems # 1              ; &DA

TABch # 1                      ; &DB
ESCch # 1                      ; &DC

IPbufferCh # 4                 ; &DD,&DE,&DF,&E0
RedKeyCh   # 4                 ; &E1,&E2,&E3,&E4

ESCaction  # 1                 ; &E5
ESCeffect  # 1                 ; &E6

u6522IRQ # 1                   ; &E7
s6850IRQ # 1                   ; &E8
s6522IRQ # 1                   ; &E9

TubeFlag # 1                   ; &EA

SpeechFlag # 1                 ; &EB

WrchDest # 1                   ; &EC
CurEdit  # 1                   ; &ED

SoftResetVars # 0              ; Reset to here on soft reset

KeyBase # 1                    ; &EE
Shadow # 1                     ; &EF
Country # 1                    ; &F0

UserFlag # 1                   ; &F1

SerULAreg # 1                  ; &F2

TimerState # 1                 ; &F3

SoftKeyConsist # 1             ; &F4

PrinterDrivType   # 1          ; &F5
PrinterIgnore     # 1          ; &F6

BREAKvector # 3                ; &F7,&F8,&F9

MemDriver  # 1                 ; &FA - where the VDU drivers write to
MemDisplay # 1                 ; &FB - where we display from

LangROM # 1                    ; &FC

LastBREAK # 1                  ; &FD

KeyOpt # 1                     ; &FE

StartOptions # 1               ; &FF

Kevin Bracey's avatar
Kevin Bracey committed
454
HardResetVars # 0              ; Reset to here on hard reset
Neil Turton's avatar
Neil Turton committed
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519
PowerOnResetVars # 0           ; Reset to here on power-on reset

; These two can dovetail in here to use up 2 bytes before the AlignSpace!

SerialInHandle # 1              ; Handle for serial input stream  (0 if not open currently)
SerialOutHandle # 1             ; Handle for serial output stream (-----------""----------)

        AlignSpace

EventSemaphores # 32            ; One byte for each of 32 events

TimerAlpha # 8                  ; As used by time (bottom 5 bytes)
TimerBeta  # 8                  ; ................................
; both aligned to word boundaries

RealTime # 8                    ; 5-byte fast real-time

PrinterActive # 4               ; Handle/active flag for printer (word aligned)

IntervalTimer # 5               ; Up Counter synchronous with TIME.
; Event generated when Zero is reached
; bottom byte aligned to word boundary

SecondsTime # 1 ; the soft copy (centi-)seconds of the RTC
CentiTime   # 1 ; """"""""""""""""""""""""""""""""""""""""

FlashState # 1 ; which flash colours are we using

SecondsDirty # 1                ; the dirty flag for start up!

MinTick # 1                     ; the minutes odd/even state

DCDDSRCopy # 1                  ; copy of ACIA bits to check for change

TVVertical # 1                  ; *TV first parameter

TVInterlace # 1                 ; *TV second parameter

CentiCounter # 1                ; Counter for VDU CTRL timing

Alphabet # 1                    ; Current alphabet number

Keyboard # 1                    ; Current keyboard number

KeyAlphabet # 1                 ; Alphabet associated with current keyboard

                GBLS    PrinterPrefix
PrinterPrefix   SETS    "PrinterType$"

PrinterTypeName #       6 + :LEN: (PrinterPrefix)

        AlignSpace

SerialFlags # 4                 ; New serial flags

XONXOFFChar # 1                 ; Character to send before rest (0 if none)

        AlignSpace

OSBYTEVarSize * @-OSBYTEFirstVar

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

; End of variables' space

520 521 522 523 524 525 526 527 528 529 530 531 532 533 534
; *** layout of a descriptor block for a display pointer shape ***

                  ^  0
PointerBlkHAL     #  0  ; fields up to private part passed to HAL
PointerWidth      #  1  ; actual (unpadded) shape width in bytes (from OS_Word 21)
PointerHeight     #  1  ; shape height in pixels
                  #  2  ; alignment padding
PointerBuffLA     #  4  ; logical address of shape buffer (up to 8 * 32 bytes)
PointerBuffPA     #  4  ; physical address of shape buffer
PointerBlkPrivate #  0  ; fields below here not used by HAL
PointerActiveX    #  1  ; active x in pixels from left
PointerActiveY    #  1  ; active y in pixels from top
                  #  2  ; alignment padding
PointerBlkSize    #  0

Neil Turton's avatar
Neil Turton committed
535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596

; ***********************************
; ***  Main Vdu Driver Workspace  ***
; ***********************************

        ^ 0

FgEcf  # 4 * 8  ; Foreground Ecf, set by GCOL(a,0-127)
BgEcf  # 4 * 8  ; Background Ecf, set by GCOL(a,128-255)
GPLFMD # 4      ; Foreground action, set by GCOL(a,0-127)
GPLBMD # 4      ; Background action, set by GCOL(a,128-255)
GFCOL  # 4      ; Foreground colour, set by GCOL(a,0-127)
GBCOL  # 4      ; Background colour, set by GCOL(a,128-255)

GWLCol # 4      ; Graphics window left column  --
GWBRow # 4      ; Graphics window bottom row     |
GWRCol # 4      ; Graphics window right column   |
GWTRow # 4      ; Graphics window top row      --

qqqPad   # 3
QQ       # 17   ;Queue - QQ+1 is on a word boundary
QOffset  # 4    ;Value to add to VDUqueueItems to point to next queue posn.
JVec     # 4    ;Jump vector to internal routines

; Start of MODE table workspace

ScreenSize # 4  ; number of bytes needed for this mode (assumed 1st in list)

XWindLimit # 4  ; Maximum value of GWRCol (internal representation)

; LineLength must be immediately after YWindLimit

YWindLimit # 4  ; Maximum value of GWTRow (internal representation)

LineLength # 4  ; Length of one pixel row in bytes

NColour # 4     ; Number of colours minus 1

YShftFactor # 4 ; Number of places to shift YCoord in address generation after
                ; multiplying by 5, holds
                ; 7,6,5 or 4 for 8,4,2 or 1 bits per pixel (640x256 mode) or
                ; 6,5,4 or 3 for 8,4,2 or 1 bits per pixel (320x256 mode).

ModeFlags # 4   ; Bit 0 => non-graphic, Bit 1 => teletext, Bit 2 => gap mode

XEigFactor # 4  ; Number of places to shift XCoord in external to internal
                ; coordinate conversion, holds
                ; 1 for 640x256 mode
                ; 2 for 320x256 mode
                ; 3 for 160x256 (BBC micro mode 2)

YEigFactor # 4  ; number of shifts to convert between internal/external Y

Log2BPC # 4     ; Log to base 2 of BytesPerChar ie (0,1,2,3,4)

Log2BPP # 4     ; Log to base 2 of BitsPerPix ie (0,1,2,3)

ScrRCol # 4     ; Maximum column number in this screen mode
ScrBRow # 4     ; Maximum row number in this screen mode

; End of table-initialised workspace

597 598
         # 8    ; SPARE

Neil Turton's avatar
Neil Turton committed
599 600 601 602 603 604 605 606 607 608 609 610 611 612 613
; Next 3 must be together in this order !

XShftFactor # 4 ; Number of places to shift XCoord in address generation,
                ; holds 2,3,4 or 5 for 8,4,2,1 bits per pixel respectivly
GColAdr # 4     ; Address of Ecf to plot - either FgEcf or BgEcf

ScreenStart # 4         ; Start address of screen (for VDU drivers)

NPix # 4        ; Number of pixels per word minus 1, holds
                ; holds 3,7,15 or 31 for 8,4,2,1 bits per pixel modes

AspectRatio # 4 ; Pixel shape : 0 square, 1 horz rect, 2 vert rect

BitsPerPix # 4  ; Bits per pixel (1,2,4,8)

614
BytesPerChar # 4        ; Bytes per 8 pixels of character
Neil Turton's avatar
Neil Turton committed
615 616
                        ; (same as BitsPerPix except in double pixel modes)

617
DisplayLineLength # 4   ; LineLength of display. May include padding from ExtraBytes control list item, so needs manual preservation during screen redirection.
Neil Turton's avatar
Neil Turton committed
618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693

RowMult # 4     ; Row multiplier for text manipulation

RowLength # 4   ; Bytes per text row in this mode (eg 640,1280,5120)

; The following (up to and including NewPtY) must be together in this order
; (relied upon by DefaultWindows)

TWLCol # 4      ; Text window left column  --
TWBRow # 4      ; Text window bottom row     |
TWRCol # 4      ; Text window right column   |
TWTRow # 4      ; Text window top row      --

OrgX # 4        ; Screen origin (external representation)
OrgY # 4

GCsX # 4        ; Graphics cursor (external representation)
GCsY # 4

OlderCsX # 4    ; Very old X coordinate (internal)
OlderCsY # 4    ; Very old Y coordinate (internal)

OldCsX # 4      ; Old graphics cursor (internal representation) --
OldCsY # 4      ;                                                 |
                ;                                                 |
GCsIX  # 4      ; Graphics cursor (internal representation)       |
GCsIY  # 4      ;                                                 |
                ;                                                 |
NewPtX # 4      ; Newest point (internal representation)          |
NewPtY # 4      ;                                               --

; End of together block

TForeCol # 4    ; Text foreground colour
TBackCol # 4    ; Text background colour

CursorX # 4     ; Text cursor X position ; these 3 must be in same order as ...
CursorY # 4     ; Text cursor Y position
CursorAddr # 4  ; Screen address of (output) cursor

InputCursorX # 4        ; Input cursor X position ; ... these 3
InputCursorY # 4        ; Input cursor Y position
InputCursorAddr # 4     ; Screen address of input cursor

EORtoggle # 4   ; Toggle between gap and non-gap
RowsToDo  # 4   ; in the CLS

VduStatus # 4   ; Vdu2, Window, Shadow bits (others in CursorFlags)

CBWS # 8        ; Clear block (VDU 23,8..) workspace
CBStart # 2
CBEnd # 2

CursorDesiredState # 4
CursorStartOffset # 4
CursorEndOffset # 4
CursorCounter # 4
CursorSpeed # 4
Reg10Copy # 4

CursorFill # 4  ; Word to EOR cursor ; MUST be immediately before CursorNbit

CursorNbit # 4  ; Pointer to cursor code for current mode

DisplayStart # 4        ; Start address of screen (for display)
DriverBankAddr # 4      ; Default start address for VDU drivers
DisplayBankAddr # 4     ; Default start address for display
DisplayNColour # 4      ; No. of colours -1 for displayed mode
DisplayModeFlags # 4    ; ModeFlags for displayed mode
DisplayModeNo # 4       ; ModeNo for displayed mode
DisplayScreenStart # 4  ; Where VDU outputs to when outputting to screen

DisplayXWindLimit # 4   ; Used for pointer programming
DisplayYWindLimit # 4
DisplayXEigFactor # 4
DisplayYEigFactor # 4
694 695 696
DisplayLog2BPP # 1
PointerXEigFactor # 1
                  # 2
Neil Turton's avatar
Neil Turton committed
697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715

Ecf1 # 8        ; The Ecf patterns
Ecf2 # 8
Ecf3 # 8
Ecf4 # 8

DotLineStyle # 8        ; Dot dash line pattern

ModeNo # 4      ; Current mode number

TFTint # 4      ; Text foreground tint          (in bits 6,7)
TBTint # 4      ; Text background tint
GFTint # 4      ; Graphics foreground tint
GBTint # 4      ; Graphics background tint

TotalScreenSize # 4     ; Amount configured for screen (in bytes)

MaxMode # 4             ; Maximum mode number allowed (20 for now)

Kevin Bracey's avatar
Kevin Bracey committed
716
ScreenEndAddr # 4       ; Logical address of screen (start of 2nd copy)
Neil Turton's avatar
Neil Turton committed
717 718 719 720 721 722 723 724 725

CursorFlags # 4 ; Silly Master cursor movement flags

CursorStack # 4 ; Bit stack of nested cursor states (0 => on, 1 => off)
                ; (bit 31 = TOS)

ECFShift # 4    ; number of bits to rotate right ECF OR and EOR masks by
ECFYOffset # 4  ; vertical offset to ECF index

726 727 728 729 730
        ASSERT  ECFShift =  Legacy_ECFShift
        ASSERT ?ECFShift = ?Legacy_ECFShift
        ASSERT  ECFYOffset =  Legacy_ECFYOffset
        ASSERT ?ECFYOffset = ?Legacy_ECFYOffset

Neil Turton's avatar
Neil Turton committed
731 732 733 734 735 736 737 738 739 740
WsVdu5 # 0      ; Vdu 5 workspace
WsScr # 4
WsEcfPtr # 4
; WsFontPtr # 4 ; not needed any more, kept in register
EndVerti # 4
StartMask # 4
EndMask # 4
FontOffset # 4
TempPlain # 16  ; only used for MODE 10

741
VIDCClockSpeed # 4      ; current VIDC clock speed in kHz (now always zero)
742

Neil Turton's avatar
Neil Turton committed
743 744
CurrentMonitorType # 4  ; initialised from configured one

Kevin Bracey's avatar
Kevin Bracey committed
745
PixelRate # 4   ; Pixel Rate in kHz
Neil Turton's avatar
Neil Turton committed
746

Ben Avison's avatar
Ben Avison committed
747 748 749 750 751
BorderL # 4             ; Size of border
BorderB # 4
BorderR # 4
BorderT # 4

Neil Turton's avatar
Neil Turton committed
752 753 754
GraphicWs # 300 ; All graphics workspace is overlaid here
EndGraphicWs # 0

Jeffrey Lee's avatar
Jeffrey Lee committed
755
 [ :DEF: ShowWS
Neil Turton's avatar
Neil Turton committed
756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775
 ! 0,"16 ":CC::STR:@
 ]
        AlignSpace 16

GCharSizes  # 0
GCharSizeX  # 4         ; width of VDU 5 chars in pixels
GCharSizeY  # 4         ; height of VDU 5 chars in pixels

GCharSpacing # 0
GCharSpaceX  # 4        ; horizontal spacing between VDU 5 chars in pixels
GCharSpaceY  # 4        ; vertical   ------------------""-----------------

TCharSizes  # 0
TCharSizeX  # 4         ; width of VDU 4 chars in pixels
TCharSizeY  # 4         ; height of VDU 4 chars in pixels

TCharSpacing # 0
TCharSpaceX  # 4        ; horizontal spacing between VDU 4 chars in pixels
TCharSpaceY  # 4        ; vertical   ------------------""-----------------

776
HLineAddr      # 4      ; address of exported HLine
Neil Turton's avatar
Neil Turton committed
777 778
GcolOraEorAddr # 4      ; address of FgEcfOraEor etc

779 780 781 782
BlankPalAddr  # 4       ; address of block for blank palette
FirPalAddr    # 4       ; address of block for first flash state palette
SecPalAddr    # 4       ; address of block for second flash state palette

Jeffrey Lee's avatar
Jeffrey Lee committed
783 784
CurrentGraphicsVDriver # 4 ; Current driver number

785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801
PointerShapes      # 0
PointerShape1      # 4  ; pointers to defined shapes 1 to 4
PointerShape2      # 4
PointerShape3      # 4
PointerShape4      # 4
PointerShapesH     # 0
PointerShapeH1     # 4  ; pointers to holding shapes 1 and 2 (so updates never hit shape given to HAL)
PointerShapeH2     # 4

PointerShapeBlocks # 6*PointerBlkSize ; room for the 6 shape descriptors themselves

PointerShapeLA     # 4               ; logical address of current shape buffer (owned by HAL)
PointerShapeNumber # 1               ; includes bit 7 linkage flag
                   # 3               ; alignment padding
PointerX           # 4               ; co-ordinates of pointer (not always = mouse)
PointerY           # 4

802
 [ :DEF: ShowWS
803
  ! 0, "PointerShapes @ ":CC::STR:(PointerShapes)
804
 ]
805

Jeffrey Lee's avatar
Jeffrey Lee committed
806
GraphicsVFeatures  # 4               ; features word from current driver, refreshed each mode change
807
TrueVideoPhysAddr  # 4               ; VideoPhysAddr is a lie, use this instead
Jeffrey Lee's avatar
Jeffrey Lee committed
808 809 810
MaxGraphicsVDrivers * 8
GraphicsVDrivers # MaxGraphicsVDrivers*4 ; List of drivers
                # 4*4                ; SPARE (avoiding changes of exported addresses for now)
Neil Turton's avatar
Neil Turton committed
811 812 813 814 815 816 817 818 819 820 821 822

TextFgColour    # 4             ; Fg/Bg colour stored as a colour number, computed on VDU 18 and re-poked!
TextBgColour    # 4             ;

; In this brave new world there is a pointer to the text expansion
; buffer used for VDU 4 / 5 text plotting.

; This now lives in the system heap.

TextExpandArea # 4      ; Pointer to Text expand area (in system heap)
TextExpandArea_Size * (8*1024)

823
                 # 2*4   ; SPARE (avoiding changes of exported addresses for now)
Neil Turton's avatar
Neil Turton committed
824

825
ScreenBlankFlag # 1     ; 0 => unblanked, 1 => blanked
Neil Turton's avatar
Neil Turton committed
826

827 828
        ASSERT  ScreenBlankFlag =  Legacy_ScreenBlankFlag
        ASSERT ?ScreenBlankFlag = ?Legacy_ScreenBlankFlag
Neil Turton's avatar
Neil Turton committed
829

830 831 832 833
ScreenBlankDPMSState # 1       ; 0 => just blank video
                               ; 1 => blank to stand-by (hsync off)
                               ; 2 => blank to suspend (vsync off)
                               ; 3 => blank to off (H+V off)
834
                               ; 255 => no mode programmed yet
Neil Turton's avatar
Neil Turton committed
835

836 837
        ASSERT  ScreenBlankDPMSState =  Legacy_ScreenBlankDPMSState
        ASSERT ?ScreenBlankDPMSState = ?Legacy_ScreenBlankDPMSState
Neil Turton's avatar
Neil Turton committed
838 839


Jeffrey Lee's avatar
Jeffrey Lee committed
840
 [ :DEF: ShowWS
Neil Turton's avatar
Neil Turton committed
841 842 843 844
 ! 0,"64 ":CC::STR:@
 ]
        AlignSpace 64

845 846 847
FgEcfOraEor # 4*16      ; Interleaved zgora & zgeor
        ASSERT  FgEcfOraEor =  Legacy_FgEcfOraEor
        ASSERT ?FgEcfOraEor = ?Legacy_FgEcfOraEor
Neil Turton's avatar
Neil Turton committed
848

849 850 851
BgEcfOraEor # 4*16      ; Interleaved zgora & zgeor
        ASSERT  BgEcfOraEor =  Legacy_BgEcfOraEor
        ASSERT ?BgEcfOraEor = ?Legacy_BgEcfOraEor
Neil Turton's avatar
Neil Turton committed
852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867

BgEcfStore  # 4*16      ; Interleaved zgora & zgeor to store background

;Current state of pattern
LineDotCnt # 4          ; Count down to restarting pattern
LineDotPatLSW # 4       ; Current state of pattern LSWord
LineDotPatMSW # 4       ;    "      "   "     "    MSWord

DotLineLength # 4       ; Dot Pattern repeat length as given in *FX163,242,n

BBCcompatibleECFs # 4   ; 0 => BBC compatible, 1 => native

SpAreaStart # 4         ; Start of sprite area
SpChooseName # 16       ; No comment says Richard
SpChoosePtr # 4

868 869 870 871 872 873 874 875 876 877 878
SWP_W # 1               ; Width & height of image to restore
SWP_H # 1
SWP_Callback # 1        ; Nonzero if palette update callback registered
SWP_Mutex # 1           ; Mutex to prevent re-entrancy
SWP_Restore # 1         ; Nonzero if restore needed in RestorePointer
SWP_Dirty # 1           ; Nonzero if need replot due to palette change
          # 2
SWP_Coords # 4          ; Coordinates of last plot
SWP_Pos # 4             ; Address to restore pixels to, 0 if not displayed
SWP_Under # 4           ; Pointer to copy of screen pixels from under the pointer
SWP_Palette # 3*4       ; Pointer colours converted to pixel values for current mode
Neil Turton's avatar
Neil Turton committed
879 880 881 882 883 884 885

TeletextOffset # 4      ; Offset to current teletext flash bank

TeletextCount # 4       ; Number of vsyncs till next teletext flash

WrchNbit # 4            ; Pointer to char code for current mode

886
CharWidth # 4           ; Width of a character in bytes (same as BytesPerChar except
887 888 889 890 891 892 893
                        ; in HiResTTX MODE 7, where characters are 16 pixels wide)
                        ; This could also be defined as (TCharSizeX<<Log2BPC)/8

TextOffset # 4          ; Byte offset into screen bank at which text window starts.
                        ; Keeps the text window centered when e.g. when mode 7 picks
                        ; a higher resolution mode than strictly necessary.

894 895 896 897 898 899 900 901 902 903 904 905 906 907 908
TTXFlags # 4            ; VDU 23,18 flags
TTXFlag_Suspend         * 1:SHL:0
TTXFlag_Conceal         * 1:SHL:1
TTXFlag_BlackEnable     * 1:SHL:2
TTXFlag_TransModeShift  * 3
TTXFlag_TransModeMask   * 3:SHL:TTXFlag_TransModeShift
                        ; bits 9-11 must be zero
TTXFlag_FgTransEOR      * 1:SHL:12
                        ; bits 13-15 must be zero
TTXFlag_BgTransEOR      * 1:SHL:16
                        ; bits 17-19 must be zero
TTXFlag_FgTransBIC      * 1:SHL:20
                        ; bits 21-23 must be zero
TTXFlag_BgTransBIC      * 1:SHL:24

Neil Turton's avatar
Neil Turton committed
909 910 911
BeepBlock # 8           ; OSWORD block for VDU 7

ScreenMemoryClaimed # 1 ; NZ => memory has been claimed or is unusable
Kevin Bracey's avatar
Kevin Bracey committed
912
ExternalFramestore # 1  ; NZ => using external framestore rather than screen memory DA
Neil Turton's avatar
Neil Turton committed
913

914
     AlignSpace
Neil Turton's avatar
Neil Turton committed
915

916 917 918 919
TTXDoubleCountsPtr # 4 ; Number of double height chars on each line
TTXMapPtr          # 4
TTXLineStartsPtr   # 4
TTXNewWorkspace    # 4 ; Temp variable to allow mode changes to fail gracefully if TTX workspace can't be allocated
Neil Turton's avatar
Neil Turton committed
920

Jeffrey Lee's avatar
Jeffrey Lee committed
921
 [ :DEF: ShowWS
Neil Turton's avatar
Neil Turton committed
922 923 924 925 926 927
 ! 0,"16 ":CC::STR:@
 ]
     AlignSpace 16      ; Align workspace to 16 bytes

RAMMaskTb # 32*4        ; Copy of MaskTb for this mode (up to 32 words)

Jeffrey Lee's avatar
Jeffrey Lee committed
928
 [ :DEF: ShowWS
Neil Turton's avatar
Neil Turton committed
929 930 931 932 933 934 935 936 937 938 939 940 941 942 943
 ! 0,"16 ":CC::STR:@
 ]
     AlignSpace 16      ; Align workspace to 16 bytes

VduOutputCurrentState # 0 ; values of R0-R3 to return from SwitchOutputToSprite
                        ; or Mask; next 4 must be in this order
SpriteMaskSelect # 4    ; value of R0 to be given to SWI OS_SpriteOp to set up
                        ; current state
VduSpriteArea # 4       ; Pointer to sprite area containing VDU output sprite
                        ; (0 if output is to screen)
VduSprite # 4           ; Pointer to VDU output sprite (0 if output to screen)

VduSaveAreaPtr # 4      ; Pointer to save area for VDU variables


Jeffrey Lee's avatar
Jeffrey Lee committed
944
 [ :DEF: ShowWS
Neil Turton's avatar
Neil Turton committed
945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960
 ! 0,"16,12 ":CC::STR:@
 ]
    AlignSpace 16, 12   ; Make ClipBoxCoords a valid immediate,
                        ; with ClipBoxEnable immediately before it
ClipBoxInfo # 0
ClipBoxEnable # 4       ; 0 => clip box disabled, 1 => enabled

ClipBoxCoords # 0       ; Internal coords of modified area of screen
ClipBoxLCol # 4
ClipBoxBRow # 4
ClipBoxRCol # 4
ClipBoxTRow # 4

FgPattern       # 4*8   ; foreground pattern as defined by OS_SetColour
BgPattern       # 4*8   ; background pattern as defined by OS_SetColour

961
                # 3*4   ; SPARE (avoiding changes of exported addresses for now)
Neil Turton's avatar
Neil Turton committed
962

Kevin Bracey's avatar
Kevin Bracey committed
963 964 965
KernelModeSelector # 4  ; pointer to block in system heap where
                        ; current mode selector is copied

Jeffrey Lee's avatar
Jeffrey Lee committed
966
 [ :DEF: ShowWS
Neil Turton's avatar
Neil Turton committed
967 968 969 970 971 972 973 974 975
 ! 0,"16 ":CC::STR:@
 ]
     AlignSpace 16      ; Align workspace to 16 bytes

TextExpand # 4*1024     ; Tim's massive text expansion table for whizzy WRCH
; TextPlain is now always hard against the end of TextExpand for this mode

TTXSoftFonts * TextExpand + 2*1024      ; Soft fonts in teletext mode

Jeffrey Lee's avatar
Jeffrey Lee committed
976
 [ :DEF: ShowWS
Neil Turton's avatar
Neil Turton committed
977 978 979 980
 ! 0,"64 ":CC::STR:@
 ]
     AlignSpace 64      ; Align workspace to 64 bytes

981
; Some infrequently used buffers which can be overlaid
Neil Turton's avatar
Neil Turton committed
982

983
LargeCommon     # SpriteAreaCBsize + SpriteCBsize + MaxSpritePaletteSize ; the largest area
Neil Turton's avatar
Neil Turton committed
984 985

ScrLoaSpriteCB  * LargeCommon   ; (size = SpriteCBsize + MaxSpritePaletteSize)
986
        ASSERT ?LargeCommon >= SpriteCBsize + MaxSpritePaletteSize
Neil Turton's avatar
Neil Turton committed
987 988
ScrSavCommon    * LargeCommon   ; (size = SpriteAreaCBsize + SpriteCBsize
                                ;  + MaxSpritePaletteSize)
989
        ASSERT ?LargeCommon >= SpriteAreaCBsize + SpriteCBsize + MaxSpritePaletteSize
990 991 992 993 994 995 996

VIDCList3BaseSize * VIDCList3_ControlList
VIDCList3Size * (VIDCList3BaseSize + ControlList_InvalidReason*8 + 4) ; primary params, up to 16 video control params, terminator

TempModeSelector * LargeCommon  ; (size = ModeSelector_MaxSize + VIDCList3Size)
        ASSERT ?LargeCommon >= ModeSelector_MaxSize + VIDCList3Size
TempVIDCList * TempModeSelector+ModeSelector_MaxSize
Neil Turton's avatar
Neil Turton committed
997 998 999 1000

FldQueueSize    * ScratchSpaceSize
FldQueueStart   * ScratchSpace

Jeffrey Lee's avatar
Jeffrey Lee committed
1001
 [ :DEF: ShowWS
Neil Turton's avatar
Neil Turton committed
1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015
 ! 0,"64 ":CC::STR:@
 ]
     AlignSpace 64      ; Align workspace to 64 bytes

Font # &700             ; 7 pages of (soft) font

SaveAreaSize * 12*1024-@

VduSaveArea # SaveAreaSize      ; save area for switching output to sprites

VDWSSize # 0

                ASSERT  VDWSSize <= 12 * 1024

1016 1017 1018 1019 1020 1021 1022 1023
; IIC bus info block

               ^ 0
IICBus_Type    # 4 ; Bus type (HAL_IICType)
IICBus_Status  # 4 ; Bus status (HAL_IICMonitorTransfer)
IICBus_Device  # 4 ; Bus device (HAL_IICDevice)
IICBus_Size    # 0

Neil Turton's avatar
Neil Turton committed
1024 1025 1026 1027 1028
; *****************************************************************************
;                 Space in the first 32K is allocated below
; *****************************************************************************
; Real workspace definition

1029
; locations used during reset only. Not cleared by ClearWkspRAM, but
1030 1031
; cleared later (just before DEFHAN).

1032 1033 1034
; Note that these are all relative to ZeroPage!

                ^       &80             ; steer clear of FIQ code
1035
InitWsStart     #       0
Kevin Bracey's avatar
Kevin Bracey committed
1036 1037
InitIRQHandler  #       4               ; pointer to IRQ handler (LDR PC'ed from IRQ HW vector)
InitIRQWs       #       16              ; workspace for IRQ handler
1038 1039
InitUsedStart   #       4               ; start of used pages (L2PT etc) not to be cleared
InitUsedEnd     #       4               ; end of used pages
1040
InitUsedBlock   #       4               ; current block in PhysRamTable
1041
InitClearRamWs  #       10*4            ; preserve registers during ClearPhysRAM
1042 1043 1044
InitDMABlock    #       8               ; block of DMAable memory extracted from PhysRamTable
InitDMAOffset   #       4               ; offset+8 into PhysRamTable where memory was taken
InitDMAEnd      #       4               ; current DMA alloc pos
1045 1046 1047
                AlignSpace 32           ; because we clear 32 at a time
InitWsEnd       #       0

Neil Turton's avatar
Neil Turton committed
1048 1049
; Basic kernel space - defined locations for external modules

1050
                       ^       &100
Neil Turton's avatar
Neil Turton committed
1051 1052
IRQ1V                  #       4       ; &100

1053 1054 1055
ESC_Status             #       1       ; &104
        ASSERT  ESC_Status =  Legacy_ESC_Status
        ASSERT ?ESC_Status = ?Legacy_ESC_Status
Neil Turton's avatar
Neil Turton committed
1056

1057 1058 1059
LatchBSoftCopy         #       1       ; &105
        ASSERT  LatchBSoftCopy =  Legacy_LatchBSoftCopy
        ASSERT ?LatchBSoftCopy = ?Legacy_LatchBSoftCopy
Neil Turton's avatar
Neil Turton committed
1060 1061 1062

IOCControlSoftCopy     #       1       ; &106

1063 1064 1065
CannotReset            #       1       ; &107
        ASSERT  CannotReset =  Legacy_CannotReset
        ASSERT ?CannotReset = ?Legacy_CannotReset
Neil Turton's avatar
Neil Turton committed
1066

1067 1068 1069
IRQsema                #       4       ; &108
        ASSERT  IRQsema =  Legacy_IRQsema
        ASSERT ?IRQsema = ?Legacy_IRQsema
Neil Turton's avatar
Neil Turton committed
1070 1071

MetroGnome             #       4       ; &10C
1072 1073 1074
        ASSERT  MetroGnome =  Legacy_MetroGnome
        ASSERT ?MetroGnome = ?Legacy_MetroGnome

Neil Turton's avatar
Neil Turton committed
1075 1076
MemorySpeed            #       4       ; &110

1077 1078 1079
MEMC_CR_SoftCopy       #      4       ; &114
        ASSERT  MEMC_CR_SoftCopy =  Legacy_MEMC_CR_SoftCopy
        ASSERT ?MEMC_CR_SoftCopy = ?Legacy_MEMC_CR_SoftCopy
Neil Turton's avatar
Neil Turton committed
1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116

ResetIndirection        #      4       ; &118

; Now all internal definitions

; Up to here is initialized on reset

; Next come handler variables

MemLimit        #       4
UndHan          #       4
PAbHan          #       4
DAbHan          #       4
AdXHan          #       4

ErrHan          #       4
ErrBuf          #       4
ErrHan_ws       #       4

CallAd_ws       #       4     ; smart Rs ordering:
CallAd          #       4     ; can do LDMIA of r12, pc
CallBf          #       4

BrkAd_ws        #       4
BrkAd           #       4
BrkBf           #       4

EscHan_ws       #       4
EscHan          #       4

EvtHan_ws       #       4
EvtHan          #       4

; The next lot of workspace is in the space vacated by the small soft CAM map area
; (256 words) which is no longer adequate, so we can reuse it

JordanWS        #       0
1117 1118 1119 1120 1121 1122 1123 1124 1125 1126

Serv_SysChains          # 4          ;anchor for block handling 'system' service numbers, in range 1 to 255
Serv_UsrChains          # 4          ;anchor for block handling 'user' service numbers, > 255
Serv_AwkwardChain       # 4          ;anchor for chain handling non-compliant modules (no service table)
 [ :DEF: ShowWS
      ! 0, "Serv_SysChains        at ":CC::STR:(Serv_SysChains)
      ! 0, "Serv_UsrChains        at ":CC::STR:(Serv_UsrChains)
      ! 0, "Serv_AwkwardChain     at ":CC::STR:(Serv_AwkwardChain)
 ]

Neil Turton's avatar
Neil Turton committed
1127 1128
DAList          #       4       ; Pointer to first node on dynamic area list

Neil Turton's avatar
Neil Turton committed
1129 1130 1131

                AlignSpace 16
AMBControl_ws   #       4       ; workspace anchor word for AMBControl
1132
DynArea_ws      #       4       ; workspace anchor word for data structures to accelerate OS SWIs for dynamic areas
1133
 [ :DEF: ShowWS
1134 1135
 ! 0, "AMBControl_ws         at ":CC::STR:(AMBControl_ws)
 ! 0, "DynArea_ws            at ":CC::STR:(DynArea_ws)
1136
 ]
1137

1138 1139
Oscli_CmdHashSum        # 4          ;for hashed command lookup
Oscli_CmdHashLists      # 4          ;anchor for hashed command lists structure
1140
 [ :DEF: ShowWS
1141 1142
      ! 0, "Oscli_CmdHashSum      at ":CC::STR:(Oscli_CmdHashSum)
      ! 0, "Oscli_CmdHashLists    at ":CC::STR:(Oscli_CmdHashLists)
1143
 ]
1144

Neil Turton's avatar
Neil Turton committed
1145

1146
                AlignSpace 16   ; skipped bit must start on 16-byte boundary (ClearPhysRAM does 4 words at a time for skipped areas)
Neil Turton's avatar
Neil Turton committed
1147
SkippedTables   #       0
1148

1149 1150 1151
PhysRamTable    #       0       ; Pairs of words (physaddr, size+flags)
                                ; indicating RAM present in machine
                                ; Unused entries have size of zero
Neil Turton's avatar
Neil Turton committed
1152
VideoPhysAddr   #       4       ; Address of video RAM (in the case of DRAM-only machines,
1153 1154 1155 1156
VideoSizeFlags  #       4       ; this is actually a chunk out of DRAM)
DRAMPhysAddrA   #       4       ; Next the DRAM
DRAMSizeFlagsA  #       4
                #       8 * 16  ; Space for 17 DRAM banks + 1 VRAM bank total
Neil Turton's avatar
Neil Turton committed
1157
PhysRamTableEnd #       0
1158 1159
DRAMPhysTableSize *     (PhysRamTableEnd-DRAMPhysAddrA) / 8

1160
 [ :DEF: ShowWS
Neil Turton's avatar
Neil Turton committed
1161
 ! 0, "VideoPhysAddr held at  ":CC::STR:(VideoPhysAddr)
1162
 ]
Neil Turton's avatar
Neil Turton committed
1163

Jeffrey Lee's avatar
Jeffrey Lee committed
1164
LxPTUsed        #       4       ; Amount of memory used for L2PT (short desc) or L3PT (long desc)
Neil Turton's avatar
Neil Turton committed
1165 1166
SoftCamMapSize  #       4       ; Amount of memory (in bytes) used for soft CAM map
                                ; (whole number of pages)
1167

1168
                AlignSpace
1169
HAL_StartFlags  #       4
1170 1171
HAL_Descriptor  #       4
HAL_Workspace   #       4
1172
HAL_WsSize      #       4
1173

1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187
ICache_Info              #  0
ICache_NSets             #  4
ICache_Size              #  4
ICache_LineLen           #  1
ICache_Associativity     #  1

Cache_Type               #  1
Cache_Flags              #  1

DCache_Info              #  0
DCache_NSets             #  4
DCache_Size              #  4
DCache_LineLen           #  1
DCache_Associativity     #  1
1188 1189 1190

ProcessorArch            #  1
ProcessorType            #  1   ; Processor type (handles 600 series onwards)
1191 1192 1193 1194 1195 1196

DCache_CleanBaseAddress  #  0   ; word used either for IndexBit or CleanBaseAddress
DCache_IndexBit          #  4
DCache_CleanNextAddress  #  0   ; word used either for IndexSegStart or CleanNextAddress
DCache_IndexSegStart     #  4
DCache_RangeThreshold    #  4
1197 1198 1199 1200 1201 1202
                AlignSpace
ProcessorFlags           #  4    ; Processor flags (IMB, Arch4 etc)
 [ :DEF: ShowWS
 ! 0, "ProcessorType  at  ":CC::STR:(ProcessorType)
 ! 0, "ProcessorFlags at  ":CC::STR:(ProcessorFlags)
 ]
1203 1204 1205

                AlignSpace

1206
MMU_PPLTrans             #  4
Kevin Bracey's avatar
Kevin Bracey committed
1207
MMU_PCBTrans             #  4
1208
MMU_PPLAccess            #  4
Kevin Bracey's avatar
Kevin Bracey committed
1209

1210
Proc_Cache_CleanInvalidateAll     #       4
Jeffrey Lee's avatar
Jeffrey Lee committed
1211
Proc_Cache_CleanInvalidateRange   #       4
1212
Proc_Cache_CleanAll               #       4
1213
Proc_Cache_CleanRange             #       4
1214
Proc_Cache_InvalidateAll          #       4
1215
Proc_Cache_InvalidateRange        #       4
1216
Proc_Cache_RangeThreshold         #       4
1217
Proc_Cache_Examine                #       4
1218 1219
Proc_ICache_InvalidateAll         #       4
Proc_ICache_InvalidateRange       #       4
1220 1221
Proc_TLB_InvalidateAll            #       4
Proc_TLB_InvalidateEntry          #       4
1222 1223 1224 1225 1226 1227
Proc_DSB_ReadWrite                #       4
Proc_DSB_Write                    #       4
Proc_DSB_Read                     #       4
Proc_DMB_ReadWrite                #       4
Proc_DMB_Write                    #       4
Proc_DMB_Read                     #       4
1228 1229
Proc_IMB_Full                     #       4
Proc_IMB_Range                    #       4
1230
Proc_IMB_List                     #       4
1231 1232 1233 1234 1235 1236
Proc_MMU_Changing                 #       4
Proc_MMU_ChangingEntry            #       4
Proc_MMU_ChangingUncached         #       4
Proc_MMU_ChangingUncachedEntry    #       4
Proc_MMU_ChangingEntries          #       4
Proc_MMU_ChangingUncachedEntries  #       4
1237

1238
Cache_Lx_Info                     #       4       ; Cache level ID register
1239 1240 1241
Cache_Lx_MaxLevel                 *       2       ; Current machines have max of 2 cache levels
Cache_Lx_DTable                   #       4*Cache_Lx_MaxLevel ; Data/unified cache layout for all supported levels
Cache_Lx_ITable                   #       4*Cache_Lx_MaxLevel ; Instruction cache layout for all supported levels
1242
Cache_HALDevice                   #       4       ; Pointer to any HAL cache device we're using
Neil Turton's avatar
Neil Turton committed
1243 1244


1245 1246
IOAllocPtr      #       4               ; current lowpoint of mapped I/O space (also upper limit on DAs)
IOAllocLimit    #       4               ; current lowest allowed I/O space (DA creation may move this up)
Jeffrey Lee's avatar
Jeffrey Lee committed
1247
IOAllocTop      #       4               ; high end of I/O space
1248

1249 1250
PhysIllegalMask #       4               ; mask of invalid bits in upper word of physical addresses

Neil Turton's avatar
Neil Turton committed
1251

1252
  [ :DEF: ShowWS
1253
        ! 0, "Free space before DebuggerSpace = ":CC::STR:(&300-@)
1254
 ]
1255

1256 1257
        ASSERT  @ <= &300
                        #       (&300-@)
1258
 [ :LNOT: HiProcVecs
1259 1260 1261 1262
; Note that this is currently located within the skipped region, even though it
; doesn't need to be. It was just an easy way of adding the IIC bus info to the
; region. The debugger will initialise DebuggerSpace on startup, so it doesn't
; matter that it doesn't get cleared during the main RAM clear.
1263 1264 1265 1266 1267 1268 1269 1270
DebuggerSpace           #       16*8    ; Debugger module needs some zero page
DebuggerSpace_Size      *       ?DebuggerSpace

        ASSERT  DebuggerSpace =  Legacy_DebuggerSpace
        ASSERT ?DebuggerSpace = ?Legacy_DebuggerSpace
 |
DebuggerSpace           *       &2000   ; Debugger gets a page all to itself!
DebuggerSpace_Size      *       &1000
1271 1272 1273 1274 1275

   [ CompatibilityPage
CompatibilityPageEnabled #      1       ; 0 or 1 as appropriate
   ]
                AlignSpace
1276
 ]
Kevin Bracey's avatar
Kevin Bracey committed
1277

1278
IICBus_Count       *    5 ; 5 buses is enough for all current machines
1279 1280
IICBus_Base        #    IICBus_Size*IICBus_Count

1281 1282
PageTable_PageFlags #   4               ; Page flags used for page tables. L2PT uses this directly, L1PT adds in PageFlags_Unavailable.

1283
                AlignSpace 16   ; skipped bit must end on 16-byte boundary (ClearPhysRAM does 4 words at a time for skipped areas)
1284 1285
SkippedTablesEnd #      0

Dan Ellis's avatar
Dan Ellis committed
1286
; NVRAM support
Kevin Bracey's avatar
Kevin Bracey committed
1287

Kevin Bracey's avatar
Kevin Bracey committed
1288 1289
NVRamSize          #    1               ; Size of NVRam (E2ROM & CMOS) fitted in 256byte units
NVRamBase          #    1               ; Base of NVRam
1290
NVRamSpeed         #    1               ; Clock hold time in 0.5us units
Kevin Bracey's avatar
Kevin Bracey committed
1291 1292
NVRamPageSize      #    1               ; Page size for writing (log2)
NVRamWriteSize     #    1               ; Size of writable region (256byte units)
Kevin Bracey's avatar
Kevin Bracey committed
1293

Kevin Bracey's avatar
Kevin Bracey committed
1294 1295
                   AlignSpace

Kevin Bracey's avatar
Kevin Bracey committed
1296

Kevin Bracey's avatar
Kevin Bracey committed
1297 1298 1299 1300
AppSpaceDANode     #    DANode_NodeSize ; Dummy area node for application space (not on list)
FreePoolDANode     #    DANode_NodeSize ; Area node for free pool
SysHeapDANode      #    DANode_NodeSize ; Area node for system heap
CDASemaphore       #    4               ; Semaphore for OS_ChangeDynamicArea - non-zero => routine threaded
1301
MMUControlSoftCopy #    4               ; Soft copy of ARM control register
1302
IRQMax             #    4               ; from HAL_IRQMax
Ben Avison's avatar
Ben Avison committed
1303 1304
DeviceCount     #       4       ; size of our table of devices in the system heap
DeviceTable     #       4       ; pointer to table
1305

1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318
ProcVec_Start           #       0       ; Start of processor vector table
ProcVec_Branch0         #       4       ; Branch through zero
ProcVec_UndInst         #       4       ; Undefined instruction vector
ProcVec_SWI             #       4       ; SWI vector
ProcVec_PrefAb          #       4       ; Prefetch abort vector
ProcVec_DataAb          #       4       ; Data abort vector
ProcVec_AddrEx          #       4       ; not used (was Address exception vector on 26-bit-only ARMs)
ProcVec_IRQ             #       4       ; IRQ vector
ProcVec_End             #       0

ProcVecPreVeneersSize   *       4*4     ; Space for preveneers for loading handler addresses from 0 page.
ProcVecPreVeneers       #       ProcVecPreVeneersSize

1319
AplWorkSize * AppSpaceDANode + DANode_Size
1320
SoftAplWorkMaxSize * AppSpaceDANode + DANode_MaxSize
1321

1322 1323
ExtendedROMFooter # 4 ; Pointer to the extended ROM footer structure. 0 if not initialised, -1 if not found.

1324 1325
CPUFeatures # 2*4

1326
 [ :DEF: ShowWS
1327
        ! 0, "Free space after EnvString = ":CC::STR:(&500-@)