; 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.
;
; > s.Workspace


;
;task node format
;
                   ^  0
AMBNode_HdrStart   #  0
AMBNode_id         #  4               ;magic identifier
AMBNode_handle     #  4               ;handle for external reference
AMBNode_prev       #  4               ;ptr to previous node
AMBNode_next       #  4               ;ptr to next node
AMBNode_pagetable  #  0               ;data comprising page table from here on
AMBNode_Npages     #  4               ;no. of pages in page list
AMBNode_startaddr  #  4               ;logical address of first page (-1 means nowhere)
AMBNode_PPL        #  4               ;Page flags, as limited by DynAreaFlags_AccessMask
AMBNode_pages      #  0               ;list of page numbers from here on (1 word per page)
AMBNode_HdrEnd     #  0
;
AMBNode_HdrSize    *  AMBNode_HdrEnd - AMBNode_HdrStart


;
;main workspace
;
                    ^  0,R12
AMBNhandles         #  4               ;total handles available
AMBNtasks           #  4               ;no. of tasks currently allocated
AMBMappedInNode     #  4               ;node ptr of mapped-in task, or 0 for none
AMBNodeHandles      #  4               ;ptr to node handle array (1 word per entry)
AMBPhysBin          #  4               ;ptr to physical page bin array
AMBPhysBinEntries   #  4               ;no. of entries in physical page bin array
  [ AMB_LazyMapIn
AMBPageFlags        #  4               ;L2PT page flags to use when (lazily) mapping in pages
  ]
AMBAnchorNode       #  AMBNode_HdrSize ;dummy node - see note (1) below
;
  [ ChocolateAMB
AMBFlags            #  4               ;bits defined as below
AMBNContextSwitches #  4               ;monotonic count of total no. of task map-in's (eg. for performance tracing)
    [ AMB_ChocTrace
AMBNmakeunsparse    #  4               ;count of no. of calls to AMB_MakeUnsparse
AMBNmemmoveshrink   #  4               ;count of no. of Service_MemoryMoved shrink fixups
AMBNmemmovegrow     #  4               ;count of no. of Service_MemoryMoved grow fixups
    ]
AMBMappedInNpages   #  4               ;no. of pages of MappedInNode really mapped in
AMBMappedInRegister #  AMBMIRegWords*4 ;1 bit per page - see note (2) below
  ]
;
AMBmaxwork          *  :INDEX:@        ;size of main workspace (assumed to be multiple of 4 bytes)


  [ ChocolateAMB
;
;definition of bits in AMBFlags
;
AMBFlag_LazyMapIn_disable  * &80000000 ;bit  31    LazyMapIn permanent disable (eg. not running on StrongARM)
AMBFlag_LazyMapIn_suspend  * &40000000 ;bit  30    LazyMapIn suspend (controlled via AMB SWI)
                                       ;bits 29..0 reserved (0)
;
  ]

;Notes:
;
; (1) AMBAnchorNode is a dummy node with 0 page entries that forms the anchor of a
;     circular node list. This averts the need for any special case for adding or
;     removing nodes.
;
; (2) AMBMappedInRegister is a 'bitmap' of the current page mapping status of the
;     MappedInNode. This supports AMB_LazyMapIn. Bit n corresponds to the n'th page
;     of the MappedInNode; if it is set, then that page is currently mapped in. The
;     bits are packed 'little endian', so bit 0 is the LSB of word 0, bit 31 is
;     the MSB of word 0, bit 32 is the LSB of word 1 and so on.


    END