TITLE   SDATA - OS/2 system data area
;/*static char *SCCSID = "@(#)sdata.asm 6.8 92/03/13";*/
;        IBM/Microsoft Confidential
;
;        Copyright (c) IBM Corporation 1987, 1989
;        Copyright (c) Microsoft Corporation 1987, 1989
;
;        All Rights Reserved
;***    SYSTEM DATA AREA for OS/2
;
;*    CHANGE ACTIVITY:
;*         73941       Preventing OS2KRNL code WriteEntry from being written
;*                     over by BIOS code by increasing size of real mode stack.
;          122427      Anchor Block Feature - initial implementation.
;          150371      Anchor Block Feature - File System portion.
;          150101      Added _ShutdownFlag
;          150281      Added hybernateSem and _pHybernateTCB
;          152533      Added suport for SET DOS_MODE= in CONFIG.SYS
;          153467      Set up anchor block selector correctly
;          153620      Added _hyberswapstart in order to determine where to
;                      start hybernate
;          156729      _smbmDF and _smFileSize must be kept together
;          156773      Remove _hyberswapstart since we are using SWAPPER2.DAT
;                      instead of SWAPPER.DAT to tuck away the system
;*        d159857      Cache align TSS - PentiumPro errata.


;;;;;W A R N I N G ;;; W A R N I N G ;;; W A R N I N G ;;; W A R N I N G
;;;;;W A R N I N G ;;; W A R N I N G ;;; W A R N I N G ;;; W A R N I N G
;             The System Anchor Block Feature F122427
;
;  Modifications to this module must observe the following caveats:
;
;
;  The order of data definitions within this module must be preserved
;  since external diagnostic tools depend upon the order.
;  New items added to existing segments must be added after existing
;  items.
;  New segments must have a DWORD pointer added to the end of the SAB.
;  Existing items being incorporated into the anchor block scheme must be
;  defined after the last anchored item of same segment.
;  Redundant or obsoleted items must be retained as dummy constants
;  so as not to disturb the relative possition of any items that
;  follow.
;
;  Richard Moore 11th March 96
;;;;;W A R N I N G ;;; W A R N I N G ;;; W A R N I N G ;;; W A R N I N G
;;;;;W A R N I N G ;;; W A R N I N G ;;; W A R N I N G ;;; W A R N I N G


.xlist
include dosseg.inc
include basemaca.inc
include osmaca.inc
include defdbug.inc
include osconst.inc
include dossymc.inc
include clkadj.inc
include devsym.inc
include pgexport.inc
include vmexport.inc
include infoseg.inc
include seldesc.inc
include protmode.inc
include virtsym.inc
include sas.inc                       ; @@
include screen.inc
include sigdef.inc
include sysinvar.inc
include sicg.inc
include selxport.inc
include error.inc
include proc.inc
include tkexport.inc
include curdir.inc
include dirent.inc
include find.inc
include sem.inc
include except.inc
include tkptda.inc
include semxport.inc

;       include for System Anchor Block - f122427

include bsexcpt.inc
include exmg.inc
include sysserv.inc
include harderr.inc
include timlib.inc
include sched.inc
include mi.inc
include ldrvars.inc
include ..\memory\pglocal.inc
include ..\memory\sellocal.inc
;include kmode.inc
;include sab.inc



ifdef mmioph
include perfhook.inc
endif ;mmioph
.list

;       PTDA alignment check macros:

PtdaAlignDW macro field
    ?PtdaAlign  field,<word>,1
endm

PtdaAlignDD macro field
    ?PtdaAlign  field,<dword>,3
endm

?PtdaAlign macro field, dwdd, alignmask
    ?align = offset field
    ??PtdaAlign field, %?align, %(?align and alignmask), dwdd, alignmask
endm

??PtdaAlign macro field, offst, lowoffst, dwdd, alignmask
if2
    if (lowoffst)
        %out sdata.asm: field not dwdd aligned in ptda_s (offst, lowoffst)
        .err
    endif
endif
endm

include tkptdaa.inc

        ReferGlobal DFTss,BYTE
        ReferGlobal DFStackBase,BYTE
        ReferGlobal NWDTss, BYTE
        ReferGlobal NWDStackBase, BYTE
        ReferGlobal IDT,BYTE

if RAS
        ReferGlobal ras_mec_table,BYTE
endif ;RAS

        ReferFlat _pPTDAFirst,DWORD
        ReferFlat _papTCBSlots,DWORD
        ReferFlat TaskNumber,DWORD
        ReferFlat _ThreadCount,DWORD
        ReferFlat _parvmOne,DWORD
        ReferFlat _pobvmOne,DWORD
        ReferFlat _pcovmOne,DWORD
        ReferFlat _DosModMte,BYTE
        ReferFlat _global_h,DWORD
        ReferFlat _mte_h,DWORD
        ReferFlat _pft,DWORD
        ReferFlat _apkh,byte
        ReferFlat _pgPageablePAI,DWORD
        ReferFlat _pgIdleList,DWORD
        ReferFlat _pgFreeList,DWORD
;156729 ReferFlat _smbmDF,DWORD

        EXTRN   IDTLEN:ABS
        EXTRN   DFSTKLEN:ABS
        EXTRN   NWDSTKLEN:ABS

;
;       System Anchor Block related references
;

        EXTRN   dynam_API_table:DWORD
        EXTRN   dynam_ret_table:DWORD

; RJM
        EXTRN   _mvdmglbl:DWORD
        EXTRN   _FS_SAB:DWORD

;
;       152914
;       Create a global variable that contains the value of DOSIODELAYCNT
;

        EXTRN   DOSIODELAYCNT:ABS


        FARCODE LOW
CODE    SEGMENT
        EXTRN   iCONdev:NEAR
        EXTRN   sCONdev:NEAR
        EXTRN   sNULdev:NEAR
        EXTRN   iNULdev:NEAR
CODE    ENDS

;***    DO NOT PUT ANY OTHER DATA IN THE SEGMENT START!!!

START   SEGMENT

        public DosGroupBase
DosGroupBase    label   byte    ; DO NOT PUT ANYTHING BEFORE THIS LABEL!

;       System Anchor Segment - This is the first data structure in DOSGROUP

;       Base section - This points to all of the other sections

sasinit macro   field, size, value
    .errnz ($ - SAS_base_area - offset field)
    size value
endm

        public  SAS_base_area
SAS_base_area label byte
ifdef SAS_SIG
sasinit SAS_signature   db      SAS_SIG
else
sasinit SAS_signature   db      'SAS '
endif
sasinit SAS_tables_data dw      <offset DOSGROUP:SAS_tables_area>
sasinit SAS_flat_sel    dw      <seg FLAT:DGROUP>
sasinit SAS_config_data dw      <offset DOSGROUP:SAS_config_area>
sasinit SAS_dd_data     dw      <offset DOSGROUP:SAS_dd_area>
sasinit SAS_vm_data     dw      <offset DOSGROUP:SAS_vm_area>
sasinit SAS_task_data   dw      <offset DOSGROUP:SAS_task_area>
sasinit SAS_RAS_data    dw      <offset DOSGROUP:SAS_RAS_area>
sasinit SAS_file_data   dw      <offset DOSGROUP:SAS_file_area>
sasinit SAS_info_data   dw      <offset DOSGROUP:SAS_info_area>
    .errnz ($ - SAS_base_area - size SAS)

;       Protected Mode Tables section
;       BUGBUG: Don't try using GDT_GDT or LDTAlias, they are invalid

SAS_tables_area  SAS_tables_section <GSEL GDT_SAB,      \
                                     GSEL 0,            \
                                     GSEL GDT_IDT,      \
                                     GSEL GDT_POOL>

;       Configuration section

SAS_config_area SAS_config_section <DevConfigTbl>

;       Device Driver section

        public  SAS_dd_area
        public  ABIOS_CDA_anchor_p
        public  ABIOS_CDA_anchor_r
ifdef SAS_SIG
SAS_dd_area SAS_dd_section <DevHead,0,0,0,0,GSEL GDT_FSC>
else
SAS_dd_area SAS_dd_section <DevHead,0,0,0,0>
        dw      GSEL GDT_FSC
endif
ABIOS_CDA_anchor_p equ SAS_dd_area.SAS_dd_CDA_anchor_p
ABIOS_CDA_anchor_r equ SAS_dd_area.SAS_dd_CDA_anchor_r

;       Virtual Memory Management section

        public  SAS_vm_area
ifdef SAS_SIG
SAS_vm_area SAS_vm_section <offset FLAT:_parvmOne,\
offset FLAT:_pobvmOne,      \
offset FLAT:_pcovmOne,      \
offset FLAT:_DosModMte,     \
offset FLAT:_global_h,      \
offset FLAT:_pft,           \
offset FLAT:_pgPageablePAI, \
offset FLAT:_smbmDF,        \
offset FLAT:_pgIdleList,    \
offset FLAT:_pgFreeList,    \
offset FLAT:_apkh,          \
offset FLAT:_mte_h>
else
SAS_vm_area SAS_vm_section <offset FLAT:_parvmOne,\
offset FLAT:_pobvmOne,      \
offset FLAT:_pcovmOne,      \
offset FLAT:_DosModMte,     \
offset FLAT:_global_h,      \
offset FLAT:_pft,           \
offset FLAT:_prt,           \
offset FLAT:_smSF,          \
offset FLAT:_pgIdleHead,    \
offset FLAT:_pgFreeHead,    \
offset FLAT:_apkh,          \
offset FLAT:_mte_h>
endif

;       Tasking section

        public  SAS_task_area
SAS_task_area SAS_task_section <GSEL GDT_PTDA,                  \
                                offset FLAT:_pPTDAFirst,        \
                                offset FLAT:_papTCBSlots,       \
                                offset FLAT:TaskNumber, \
                                offset FLAT:_ThreadCount>

;       RAS section

        public  SAS_RAS_area

if RAS
SAS_RAS_area SAS_RAS_section <0,0,ras_mec_table>
else ;RAS
SAS_RAS_area SAS_RAS_section <0,0,0>
endif ;RAS

;       File System section

        public  SAS_file_area
SAS_file_area SAS_file_section <0,0,0,0,0>

;       Information Segment section

        public  SysInfoSeg
        public  _SysInfoSeg
        public  LocInfoSeg
        public  _LocInfoSeg
        public  LocInfoSegRM
        public  CDIB_selector
SAS_info_area SAS_info_section <0,0,-1,0>
CDIB_selector equ SAS_info_area.SAS_info_CDIB    ; selector for CDIB
SysInfoSeg    equ SAS_info_area.SAS_info_global  ; selector for global infoseg
_SysInfoSeg    equ SAS_info_area.SAS_info_global ; accessible by C code
LocInfoSeg    equ SAS_info_area.SAS_info_local   ; address of current task's infoseg
_LocInfoSeg    equ SAS_info_area.SAS_info_local  ; accessible by C code
LocInfoSegRM  equ SAS_info_area.SAS_info_localRM ; address of real mode task's infoseg

;       Note: The System Anchor Segment must end on a 128 byte boundary
;             so that the Global Information Segment may be tiled

        if      ($-DosGroupBase) mod 128
        org     ($-DosGroupBase)+128-(($-DosGroupBase) mod 128)
        endif

;       Note that RAS_BIOS_data has been chosen to go here
;       because its length is a multiple of 128 bytes.  This
;       allows easy tiling of the global infoseg.

        PUBLIC  RAS_BIOS_data
        .errnz  (RAS_DATA_LEN MOD 128)
RAS_BIOS_data   DB      RAS_DATA_LEN DUP(?)


;***    InfoSeg Structure declaration (M000)
;
;  NOTE: The only items initialized in the InfoSeg structure are:
;
;       o Free-running milliseconds counter             00
;       o Hundredths of seconds counter                 00
;       o Time zone                                     -1 (default)
;       o Clock periodic interrupt interval             Actual interval
;       o Version                                       Actual version
;       o Huge segment shift count                      4
;       o Protect-mode only indicator                   0
;

;       InfoSegGDT MUST be aligned on a tileable boundary within DOSGROUP.

        PUBLIC  SISData                 ; InfoSeg data structure

        .errnz  (($ - DosGroupBase) AND 07fh)

        PUBLIC  _SISData
_SISData    label   byte                ; C interface

;defect 71936: define the revison letter field

SISData InfoSegGDT <,0,,,,0,-1,INTRVL*10,,,,,MAJOR_VERSION,MINOR_VERSION,REVISION_LETTER,,NSCRN,HUGESHIFT,1,0,,,,,,,NSCRN,NSCRN>

align 16
        .errnz  (($ - DosGroupBase) AND 0fh)

; Definition of the mode switch (formerly "hack") stack

        public  MSSTACKSIZE
;73941 MSSTACKSIZE     equ     160
MSSTACKSIZE     equ     1024                                              ;73941
        public  MSStack
align 16
MSStack         db      MSSTACKSIZE dup(?)


;RJM The start of the SAB f122427
; WARNING: do not alter the order of the following pointers
;          new additions should be appended to the end of the
;          SAB.

                public _SAB
                public SAB
_SAB            label byte
SAB             label byte
                EXTRN Header:byte
SAB_signature   db      'SAB '           ;Start with the signature
ifdef ALLSTRICT
                db      'KNLD'
else
ifdef PMDEBUG
                db      'KNLB'
else
                db      'KNLR'
endif
endif
                dd      Header           ;then add a pointer to the revision
                dd      _SAB_Constants   ;Far ptr to CONSTANTS segment
                dd      _SAB_ABD         ;Far ptr to ABIOS DATA segment
                dd      offset FLAT:_SAB__Data ;Flat ptr to _DATA 32-bit segment
                dd      _SAB_Data        ; Far ptr to DATA segment
                dd      offset FLAT:_SAB_c_common ;Flat ptr to c_common segment
                dd      offset FLAT:_SAB_VDDMTE ;Flat ptr to VDDModMte
                dd      offset FLAT:_mvdmglbl ;Flat ptr to MVDM Anchor Block
                dd      offset FLAT:_FS_SAB    ; Flat ptr to File System Anchor Block  D150371

SABLEN  equ $-SAB
;RJM End of SAB f122427


START   ENDS

CONSTANTS       SEGMENT

;       System Anchor Block material from the CONSTANTS segment


                PUBLIC  _SAB_Constants
                PUBLIC  pdynam_API_table
                PUBLIC  pdynam_ret_table
                public  _flGlobalActions
                public  _Resched, Resched
                public  InDos
                public  _cInDos ; C Interface
        PUBLIC  CDSAddr
        PUBLIC          state_nmi
;if RAS
;        PUBLIC          ras_systr_flags
;endif
        PUBLIC  _DynTimeSlice           ; DCR1203
        PUBLIC  DynTimeSlice            ; DCR1203
        PUBLIC  _MaxThreads
        PUBLIC  MaxThreads
        PUBLIC  _TCResched
        PUBLIC  TCResched
        PUBLIC  _ptcbTKEvap
        PUBLIC  TaskData

                ALIGN   4
_SAB_Constants  label   dword

pdynam_API_table        DD      dynam_API_table
pdynam_ret_table        DD      dynam_ret_table
_ptcbTKEvap     dd      0               ; Pointer to TCB to evaporate

        PUBLIC  DPBHead
DPBHead         DD      0               ; Ptr to head of DPB-FAT list

        PUBLIC  _SFT_FreeHead, SFT_FreeHead
_SFT_FreeHead   label   DWORD           ; D150371
SFT_FreeHead    DD      0               ; Head of SF entry free list

        PUBLIC  _MFT_hPTree, MFT_hPTree
_MFT_hPTree     label   dword           ; C interface
MFT_hPTree      DD      0               ; handle to MFT PTree
        public  _pVPBBuf, pVPBBuf       ; pointer to temp buffer for VPB determination
_pVPBBuf        label   DWORD           ; D150371
pVPBBuf         dd      ?

        public  _CpuType, _CpuStepping
_CpuType        dd      CPU_386         ; cpu type flag
_CpuStepping    dd      0               ; cpu stepping

     public _Pentium_Vendor_ID, _Pentium_Stepping, _Pentium_Feature_Flags
_Pentium_Vendor_ID      dd   3 dup (0)   ; Pentium Vendor ID string
_Pentium_Stepping       dd   0           ; Pentium Stepping/Model/Family
_Pentium_Feature_Flags  dd   0           ; Pentium Feature Flags

        PUBLIC  SigFocus, _SigFocus
_SigFocus label dword
SigFocus        SigFoci NSCRN dup(<0, 0>) ; Asynch keyboard signal recipients

        PUBLIC  _CDSAddr, CDSAddr
_CDSAddr        label   WORD            ; D150371
CDSAddr         DW      0               ; Handle of curdir struct. seg. *REDIR*
                DW      0               ; UNUSED
        PUBLIC  Serial
Serial          DW      0

        public  _hVPBFirst, hVPBFirst   ; handle to linked list of VPBs
_hVPBFirst      label   WORD            ; D150371
hVPBFirst       dw      0

                EVEN
TaskData        DW      0               ; Paragraph current task data *REDIR*
_MaxThreads     LABEL   WORD    ; "C" alias for MaxThreads
MaxThreads      dw      4096    ; maximum number of threads

                ALIGN   4
_flGlobalActions label  dword
Resched         label   byte
_Resched        db      0       ;reschedule flag
                dd      0       ;hi byte of dword must always be zero!!!!

_cInDos         label   byte
InDos           db      0
_TCResched      LABEL   BYTE
TCResched       db      0       ; time-critical reschedule flag
_DynTimeSlice   LABEL   BYTE    ;                                       DCR1203
DynTimeSlice    db      1       ; initialize as dynamic time slicing    DCR1203
state_nmi       db    1

        public  _pVPBSem, pVPBSem       ; semaphore for exclusion into the buffer
_pVPBSem        label   BYTE            ; D150371
pVPBSem         db      ?

        PUBLIC  LstDPBDrv
        PUBLIC  _LstDPBDrv
_LstDPBDrv       label   byte           ; 'C' interface
LstDPBDrv       DB      0               ; Last drive that has a DPB allocated

        PUBLIC  uchLastDrive
        PUBLIC  _uchLastDrive
_uchLastDrive   label   byte            ; 'C' interface
uchLastDrive    DB      'z'-'a'         ; Lastdrive set by CONFIG parameter
                                        ; default= 26 drives in system

        PUBLIC  DevHead
DevHead LABEL   DWORD

        PUBLIC  NULdev
NULdev  DD      CONdev                  ; Point to CON resident driver.
        DW      DEV_CHAR_DEV + DEV_NULL + DEVLEV_1
        DW      OFFSET DOSCODE:sNULdev  ; NUL device strategy
        DW      OFFSET DOSCODE:iNULdev  ; NUL device interrupt
NULnam  DB      "NUL"
        DB      (8 - ($ - NULnam)) dup(' ')
        DW      DOSCODE
        DW      DOSGROUP
        DW      DOSCODE
        DW      DOSGROUP
        .errnz  (($ - NULdev) - SIZE SysDev)

        PUBLIC  PendingSignals
PendingSignals  DW      0               ; Pending signal flags

        PUBLIC  PendingSigArg
PendingSigArg   DW      NSIG dup(0)     ; Pending signal arguments


;*  Character device RMP handle/selector block.
;
;   We keep the list of all character devices in the system in an RMP
;   segment. This includes all physical devices that are installed at
;   INIT time, and any pseudo character devices that may be installed on
;   the fly.
;
        public  CharDevRMPRec
CharDevRMPRec   dd      0

        public  CharDevSem              ; semaphore for exclusion into RMP segment
CharDevSem   KSEMMTX  <>

        public  CNotifySem              ; semaphore for exclusion into RMP segment
CNotifySem   KSEMMTX  <>

        public  _UdelSem                ; semaphore for exclusion into delete control file
_UdelSem     KSEMMTX  <>

        public  SpoolDevRMPRec          ; Segment of Spooler objects
SpoolDevRMPRec    dd    0

        public  SpoolDevSem             ; semaphore for spooler exclusion
SpoolDevSem     KSEMMTX <>

        PUBLIC  ProtOnlySystem
ProtOnlySystem  DB      1               ; Indicates if system is Protect Only
                                        ;    0 => 3xBox exists
                                        ;   !0 => No 3xBox

;       DevConfigTbl is used with DosDevConfig.  See this call in
;       the Dos 5 spec for the values of the fields.

        PUBLIC DevConfigTbl, numPtr, numSerial, numDisk
        PUBLIC devConReser, pcType, displAdap, mathCop

DevConfigTbl    label   byte
numPtr          DB      11              ; number of printer cards in the system
numSerial       DB      22              ; number of RS232 cards in the system
numDisk         DB      33              ; number of diskette drives
        PUBLIC _mathcop
_mathcop        label   byte
mathCop         DB      44              ; emulator/coprocessor flag
devConReser     DB      55              ;   -- reserved --
pcType          DB      66              ; type of PC -- zero for AT
displAdap       DB      77              ; type of display adapter
centuryLocation DB      88              ; location of century byte if ABIOS not present 64012

        PUBLIC  ABIOS_present
        PUBLIC  _ABIOS_present
_ABIOS_present  label   byte            ; 'C' interface
ABIOS_present           db      0       ; ABIOS presence flag

        public  _Sis2
_Sis2   infoseg_s <0, HOBNULL, 0, 0>    ; system infoseg data structure

        public  _Lis2
_Lis2   infoseg_s <0, HOBNULL, 0, 0>    ; local infoseg data structure

        public  rwSysInfoSeg
rwSysInfoSeg    dw      GSEL GDT_SYSINFOSEG

        public  SMHotKeyQ, CtrlNumLkQ, SMDosSessionQ                    ;26159;

SMHotKeyQ       label   SysServQueue
                DefSysServQ 4
CtrlNumLkQ      label   SysServQueue
                DefSysServQ 4
SMDosSessionQ   label   SysServQueue                                    ;26159;
                DefSysServQ 4                                           ;26159;

;       Hard Error Services

                public  HardErrPkt
HardErrPkt      label   SysServRespPkt
                dw      1               ; Semaphore (initially set)
                dw      size HE_Packet  ; Packet length
                HE_Packet <0,0,0,0,0,0> ; The packet

;       Print screen services

        public  CtrlPrtScQ

CtrlPrtScQ      label   SysServQueue
                DefSysServQ 4

        public  VideoPauseFlag          ;
VideoPauseFlag  db      0               ; flag for VideoPause

        PUBLIC  _DOSCALL1
_DOSCALL1       DB      DOSCALL1STRING

;       end System Anchor Block Material - f122427

        PUBLIC  Sctmask
Sctmask DW      0ffffh                  ; system call trace submask

;**     DBCS_Codepg
;
;       There can be zero or one codepage with DBCS characters in the
;       system at any one time.  This varible hold the number of that
;       codepage.  If no codepages  have DBCS character the variable
;       is set to -1.
;
        PUBLIC  DBCS_Codepg
DBCS_Codepg     DW      0FFFFh


; 99999 New array that tracks the current status of a drive letter
        public  DriveLetter             ; Drive Letter Assignment Table
DriveLetter db  26 DUP (0)


        PUBLIC  DiffNam
DiffNam         DB      1       ; Indicates when MyName has changed     3.10

        PUBLIC  MyName
                EVEN
MyName          DB      16 DUP (' ')    ; My network name *REDIR*

        PUBLIC  MyNum
MyNum           DW      0       ; A number that goes with MyName        3.10


        PUBLIC  _RLRHead, RLRHead
_RLRHead        label   DWORD           ; D150371
RLRHead         DW      0               ; used in lock.asm

; The following address points to the CLOCK device
        PUBLIC  BClock
; DO NOT change the order of the following DD,DW.                       ;@@
BClock  DD      0                       ; Ptr to clock device header
        dw      0                       ;paragraph for it, also         ;@@

; EGAPresent - True if EGAINT10 driver is loaded (EGA.SYS)
        public  EGAPresent
EGAPresent      db      0               ; Assume not loaded

; EGADevice - Far pointer to EGAINT10 device driver header (EGA.SYS)
        public  EGADevice
EGADevice       dd      0

; The following addresses point to the prot-mode CON device header.
        PUBLIC  ConInpDev,ConOutDev
; DO NOT change the order of the following DD,DW.                       ;@@
ConInpDev       DD      0               ; Console Input device header ptr
                dw      0               ;paragraph for it, also         ;@@
; DO NOT change the order of the following DD,DW.                       ;@@
ConOutDev       DD      0               ; Console Output device header ptr
                dw      0               ;paragraph for it, also         ;@@

        PUBLIC  _MaxSec, MaxSec
_MaxSec         label   WORD            ; D150371
MaxSec          DW      128             ; Maximum allowed sector size *REDIR*

        PUBLIC  NumIO
        PUBLIC  _NumIO
_NumIO          label   byte            ; 'C' interface
NumIO           DB      0               ; Number of disk tables

        PUBLIC  NumIORipl
        PUBLIC  _NumIORipl
_NumIORipl      label   byte            ; 'C' interface
NumIORipl       DB      0               ; Number of RIPL reserved drives

        PUBLIC  NumIOReserveDriveLetter            ;99999 start
        PUBLIC  _NumIOReserveDriveLetter
_NumIOReserveDriveLetter   label   byte ; 'C' interface
NumIOReserveDriveLetter    DB      0    ; drive number of last loadable
                                        ; (DEVICE=) block devices
        PUBLIC  ReserveDriveLetterStart
        PUBLIC  _ReserveDriveLetterStart
_ReserveDriveLetterStart   label   byte ; 'C' interface
ReserveDriveLetterStart    DB      0    ; Starting drive letter for ReserveDriveLetter
                                        ;99999 end
        PUBLIC  DevHlp
DevHlp      DD      0                   ; tiled DeviceHelp address
        PUBLIC  Splices
Splices DB      0                       ; TRUE => splices being done

        PUBLIC  CONdev
        EVEN
CONdev  DD      OEMdev                  ; Set to list given by BIOS     ;@@
        DW      DEV_CIN+DEV_COUT+DEV_CHAR_DEV+DEVLEV_1
        DW      offset DOSCODE:sCONdev  ; Console device strategy
        DW      offset DOSCODE:iCONdev  ; CON device interrupt - "never called"
CONnam  DB      "CON"
        DB      (8 - ($ - CONnam)) dup(' ')
        DW      DOSCODE
        DW      DOSGROUP
        DW      DOSCODE
        DW      DOSGROUP
        .errnz  (($ - CONdev) - SIZE SysDev)

        PUBLIC  OEMdev
        EVEN
OEMdev  DD      -1                      ; Set to list given by BIOS
        DW      DEV_GIOCTL+DEV_CHAR_DEV+DEVLEV_1+DEV_IOCTL+DEV_30
        DW      0                       ; Will be initialized by sysinit
        DW      0                       ; Will be initialized by sysinit
        DB      "OEMHLP$ "              ; Oemhlp driver name
        DW      ?                       ; Prot mode CS
        DW      ?                       ; Prot mode DS
        DW      ?                       ; Real mode CS
        DW      ?                       ; Real mode DS
        .errnz  (($ - OEMdev) - SIZE SysDev)

        PUBLIC  MUF_Pid,HDE_Pid
MUF_Pid         DW      0               ; PID of screen manager
HDE_Pid         DW      0               ; PID of hard error handler

        PUBLIC  Day,Month,Year,DayCnt,WeekDay
Day             DB      0
Month           DB      0
Year            DW      0               ; *REDIR*
DayCnt          DW      -1
WeekDay         DB      0

; NOTE: We include the decl of OEM_Handler in IBM DOS even though it is not
;       used.  This allows the REDIRector to work on either IBM or MS-DOS.

        PUBLIC  OEM_handler
OEM_handler     DD      -1              ; Pointer to OEM handler code


;*      RmSelLst - Real Mode Segment Alias Selector List
;
;       This is an array of selectors used to point to real mode objects
;       which don't have physical arena handles.  This array is initialized
;       at init time via a call to GDTAllocN.
;
;       ALL ENTRIES IN THIS ARRAY MUST BE WORDS!
;
;       These selectors are used by GoProt* during system initialization
;

                public  RmSelLst
                public  RSL_SelDS
                public  RSL_SelES
                public  RSL_SelDMAAdd
                public  RSL_SelJFN1


                EVEN
RmSelLst        label   word

RSL_SelDS       dw      ?               ; DS's alias selector
RSL_SelES       dw      ?               ; ES's alias selector
RSL_SelDMAAdd   dw      ?               ; DMAAdd alias selector
RSL_SelJFN1     dw      ?               ; Selector for 3xBox JFN pointer

RmSelLstEnd     label   word


;       RmSelLstNum is the number of ENTRIES (words) in RmSelLSt

                public  RmSelLstNum
RmSelLstNum     =       (RmSelLstEnd-RmSelLst)/2


;
; Definition of the Global Descriptor Table (GDT)
;
GDTSTART segment

; Note: it is important that no other sources put anything in GDTSTART,
;       and it is crucial that all GDT entries be exactly eight bytes.
;       The absolute position of some descriptor definitions within
;       GDTSTART is extremely important to support tiling (40h, 80h).

;       GDTSEL - for static initialization of a GDT entry

GDTSEL macro    size, blo, bhi, acc, attr, name, tilesel
local   l
    ifnb <tilesel>
        .errnz ($ - GDT - tilesel)
    endif
    ifnb <name>
            public name
        name label qword
    endif
    ifidn <size>,<0>
        l = 0                   ;; size was zero, use limit of 0 also
    else
        l equ (size) - 1        ;; convert size to limit only if size != 0
    endif
    desctab <l, blo, (bhi) and 0ffh, acc, attr, (bhi) shr 8>
endm

;       GDTSEL32 - for static initialization of a 32 bit GDT entry
;       If an expand down descriptor is passed, make sure the D_GRAN4K
;       bit is set/cleared correctly and the size is converted accordingly.
;       (size <= 1 Meg)

GDTSEL32 macro    sizehi, sizelo, blo, bhi, acc, attr, name, tile
local   llo
local   lhi
local   l
local   lattr
    ifnb <tile>
        .errnz  ($ - GDT - tile)
    endif
    ifnb <name>
            public name
        name label qword
    endif
    if sizelo EQ 0
        llo = 0ffffh              ;; size multiple of 64K
        if sizehi EQ 0
            lhi = 0ffffh
        else
            lhi = (sizehi) - 1
        endif
        if  lhi GT 10h  ;; is size greater than 1 Meg??
            l = (((lhi and PAGEMASK) shl 4) or 0fh) ;; 0fh is high 4 bits of llo
            lhi = (lhi shr PAGESHIFT) and D_EXTLIMIT
            llo = (attr) and (not D_EXTLIMIT)
            lattr = ((llo or lhi) or D_GRAN4K )
        else
            l = llo
            llo = (attr) and (not D_EXTLIMIT)
            lhi = lhi and D_EXTLIMIT
            lattr = (llo or lhi)
        endif
    else
        llo = (sizelo) - 1
        lhi = (sizehi)
        if  sizehi GE 010h          ;; limit larger than 1 Meg?
            l = (((llo  shr PAGESHIFT) and D_EXTLIMIT) or ((lhi and PAGEMASK) shl 4))
            llo = (attr) and (not D_EXTLIMIT)
            lhi = (lhi shr PAGESHIFT) and D_EXTLIMIT
            lattr = ((lhi or llo) or D_GRAN4K)
        else
            l = llo
            llo = (attr) and (not D_EXTLIMIT)
            lattr = (llo or (lhi and D_EXTLIMIT))
        endif
    endif
    desctab <l, blo, (bhi) and 0ffh, acc, lattr, (bhi) shr 8>
endm

GDTSEL  0, 0, 0, 0, 0, GDT                              ; entry 0 is reserved
GDTSEL  0, 0, 0, 0, D_UVIRT, GDT_GDT                    ; entry 8 used to be GDT
GDTSEL  TSSLEN, <offset DOSGROUP:_tssTK>, 0, D_TSS032, 0, GDT_TSS
GDTSEL  IDTLEN, <offset DOSGROUP:IDT>, 0, D_DATA0, D_UVIRT, GDT_IDT
GDTSEL  400H, 0, 0, D_DATA0, D_UVIRT, GDT_RM_IDT        ; Selector for 1st 1K

; these next three selectors are updated at context switch time
;   and their order is very important.  See the comments in tkexport.h
;   concerning related TSD fields (such as TSDdescTaskCopy) and in
;   PGSwitchContext.
GDTSEL  0, 0, 0, D_LDT0, 0, GDT_LDT                     ; Selector for LDT
GDTSEL  0, 0, 0, 0, 0, GDT_PTDA                         ; PTDA selector
GDTSEL  0, 0, 0, 0, 0, GDT_FPEM                         ; reserved selector

GDTSEL  3c0h, 400h, 0, D_DATA3, D_UVIRT, GDT_ROMDATA, 40h ; ROM data at 40h!

; Ring 2 data, flat user selector with Big attribute
; Ring 3 data, flat user selector with Big attribute
; Ring 2 conforming code, flat user selector

GDTSEL32  1c00h, 0, 0, 0, D_DATA2,           D_UVIRT+D_DBIG,    GDT_R2DS
GDTSEL32  1c00h, 0, 0, 0, D_DATA3,           D_UVIRT+D_DBIG,    GDT_R3DS
GDTSEL32  1c00h, 0, 0, 0, D_CODE2+D_CONFORM, D_UVIRT+D_COPER32, GDT_R3CS
GDTSEL32  2000h, 0, 0, 0, D_DATA3,           D_UVIRT+D_DBIG,    GDT_R3PDS
GDTSEL32  1c00h, 0, 0, 0, D_DATA3,           D_UVIRT+D_DBIG, GDT_R3THKDS, 68h

GDTSEL  0, 0, 0, <D_DATA0-D_W>, 0, GDT_SAS, SAS_selector; System Anchor Segment
GDTSEL  0, 0, 0, D_DATA0, 0, GDT_DOSALIAS       ; DOSGROUP alias
GDTSEL  SIS_LEN,<offset DOSGROUP:SISData>,0,<D_DATA0>,D_UVIRT,GDT_SYSINFOSEG
GDTSEL  TSSLEN, <offset DOSGROUP:DFTss>, 0, D_TSS032, 0, GDT_DFTSS
GDTSEL  DFSTKLEN, <offset DOSGROUP:DFStackBase>, 0, D_DATA0, 0, GDT_DFSTACK
GDTSEL  0, 0, 0, 0, 0, GDT_VPB          ; VPB BMP Segment
GDTSEL  0, 0, 0, 0, 0, GDT_RDR1         ; RESERVED
GDTSEL  0, 0, 0, 0, 0, GDT_Buffers      ; Buffer Pool Segment
;GDTSEL  0, 0, 0, 0, 0, GDT_Unused       ; unused selector (used to be MFT)
; RJM SAB anchor F122427
GDTSEL  SABLEN, <offset DOSGROUP:SAB>, 0, <D_DATA0-D_W>, 0, GDT_SAB ; entry b0 reused for SAB
GDTSEL  0, 0, 0, 0, 0, GDT_RLR          ; RLR selector
GDTSEL  0, 0, 0, 0, 0, GDT_SFT          ; SFT selector of first SFT segment
GDTSEL  0, 0, 0, 0, 0, GDT_FSC          ; FSC array segment selector
GDTSEL  0, 0, 0, 0, 0, GDT_mFSD         ; mini-FSD
GDTSEL  0, 0, 0, 0, 0, GDT_RIPL         ; Remote IPL data
GDTSEL  0, 0, 0, 0, 0, GDT_NULLIDT      ; Invalid descriptor for mode switch
GDTSEL  0, 0, 0, D_DATA0, 0, GDT_INTSTACK ; Interrupt stack alias

; These two descriptors are used to set all segment registers
; to 64K limits and appropriate attributes before a 386 modeswitch.

GDTSEL32 1, 0, 0, 0, D_CODE0, D_UVIRT, GDT_RMCODE ; 386 modesw
GDTSEL32 1, 0, 0, 0, D_DATA0, D_UVIRT, GDT_RMDATA ; 386 modesw

;**     NOTE    Additional static GDT selectors go in GDTPUBSEG.  See below.

        public  GDT_POOL, GDT_POOLEND
GDT_POOL        label byte

GDTSEL  0, 0, 0, 0, 0, , DOSHLP_CODESEL         ; dummy TILED selector

        db      GDTPOOLSIZE * size desctab dup(0)
GDT_POOLEND     label byte
GDTSEL  0, 0, 0, 0, 0, GDT_TIB                          ; TIB selector

GDTSTART ends

;**     Additional static (public) GDT selectors go HERE:
;
GDTPUBSEG segment

; mode switch stack alias
GDTSEL  MSSTACKSIZE, <offset DOSGROUP:MSStack>, 0, D_DATA0, D_UVIRT,GDT_MSSTACK

GDTSEL  0, 0, 0, 0, 0, GDT_OS2LDR       ; os2ldr's data

IFDEF   MMIOPH
GDTSEL  0, 0, 0, 0, 0, GDT_MMIOPH       ; Dekko card address Segment
ENDIF ; MMIOPH

; selectors for NWD tss and NWD stack
GDTSEL  TSSLEN, <offset DOSGROUP:NWDTss>, 0, D_TSS032, 0, GDT_NWDTSS
GDTSEL  NWDSTKLEN, <offset DOSGROUP:NWDStackBase>, 0, D_DATA0, 0, GDT_NWDSTACK

; Following is the conforming Ring 0 selector for use by Init time DDs.

GDTSEL32  0, 0, 0, 0, D_CODE0+D_CONFORM, D_UVIRT+D_COPER32, GDT_R0CSC

GDTPUBSEG ends

; GDT and IDT descriptors for lgdt and lidt in real mode

        PUBLIC  GDTDesc, IDTDesc
GDTDesc DF      ?
IDTDesc DF      ?


; Task State Segment.  Because of an as yet un-numbered 486 b-step erratum,
;  the tss must be dword aligned, or else we get bogus double faults
;  during ring transitions.

; d159857 DWORDDATA segment
START segment

ALIGN 32                            ; d159857
pad         db   7 dup(0)           ; d159857
        public  _tssTK, TSS
TSS     label   tss_s
_tssTK  tss_s   <0, 0, \
TKOTSD + TSDPMStack, GSEL GDT_PTDA, 0, \
0, 0, 0, \
0, 0, 0, \
0, \
0, \
0, \
0, \
0, \
0, \
0, \
0, \
0, \
0, \
0, \
0, 0, \
0, 0, \
0, 0, \
0, 0, \
0, 0, \
0, 0, \
GSEL GDT_LDT, 0, \
0, \
0dfffh>                 ; Intel docs say must be <= 0dfffh
TSSLEN  EQU     SIZE tss_s

; d159857 DWORDDATA ends
START ends

INITCODE segment

; GDT initialization table.  Consists of an array of GDT selectors, each
; followed by segment address.  The physical address of the segment must
; be added to the physical address field stored in the corresponding GDT
; descriptor.  The descriptor is initialized via static declaration, except
; that the physical address field contains only the offset of the code or
; data item relative the segment in the below table.

        public  GDTInitTab
GDTInitTab label word
        dw      GSEL GDT_DFTSS, DOSGROUP
        dw      GSEL GDT_DFSTACK, DOSGROUP
        dw      GSEL GDT_NWDTSS, DOSGROUP
        dw      GSEL GDT_NWDSTACK, DOSGROUP
        dw      GSEL GDT_IDT, DOSGROUP
        dw      GSEL GDT_SAS, DOSGROUP
        dw      GSEL GDT_TSS, DOSGROUP
        dw      GSEL GDT_DOSALIAS, DOSGROUP
        dw      GSEL GDT_MSSTACK, DOSGROUP
        dw      GSEL GDT_SYSINFOSEG, DOSGROUP
        dw      GSEL GDT_RMCODE, DOSCODE ;GDT entry for 386 mode switch.
        dw      GSEL GDT_SAB, DOSGROUP ; RJM anchor block
        dw      0

INITCODE ends

ifdef MMIOPH
INITDATA segment

    public _MMPHSel
_MMPHSel dw GDT_MMIOPH

INITDATA ends
endif

        PUBLIC  NoInt21Flag
NoInt21Flag             db      0       ; Sanity check set by int10_filter

;
;       152914
;       Create a global variable that contains the value of DOSIODELAYCNT
;

         PUBLIC _IODELAYCOUNT
        _IODELAYCOUNT dd DOSIODELAYCNT

        public  _CpuVendor                      ; 157841
        _CpuVendor      dd      0               ; 157841 cpu vendor

CONSTANTS       ENDS

ABIOSDATA       SEGMENT

        PUBLIC  _SAB_ABD
_SAB_ABD        label   byte

;       System Anchor Block material from the ABIOSDATA segment

        PUBLIC  ABIOS_System_Parameter_Table
ABIOS_System_Parameter_Table    db 32 dup (0)

        PUBLIC  RealCDASel
RealCDASel              dw      0       ; Selector to Real Mode ABIOS Segment

; end System Anchor Block

        PUBLIC  ProtSegSize
ProtSegSize             dw      0       ; Size of Protect Mode ABIOS Segment
ABIOSDATA       ENDS

;       Make sure DOSMVDMINSTDATA is not zero length

        CpuMode 386

MVDMINSTDATA    SEGMENT
                dd      -1
MVDMINSTDATA    ENDS

DOSMTEAUX       segment
        org     0
        public  _ldrMteAux
_ldrMteAux      label byte
DOSMTEAUX       ends

_DATA           SEGMENT

;       System Anchor Block material from the _DATA segment

                PUBLIC  _SAB__Data
_SAB__Data      label   byte

                PUBLIC  _pdcbHead
_pdcbHead       DD      0
                PUBLIC  _pSemListHead
_pSemListHead   DD      0
                PUBLIC  _hookheadGlobal
_hookheadGlobal DD      offset  FLAT:_hookheadGlobal
                DD      offset  FLAT:_hookheadGlobal

        PUBLIC  runner
        PUBLIC  _FgndSGID
        PUBLIC  _tkFgndPID                        ; 26215
        PUBLIC  fIdle

runner          dd      0       ; runner TCB pointer
_FgndSGID       dw      0       ; Foreground Screen Group ID.
_tkFgndPID        LABEL   WORD    ; "C" alias for Foreground Process ID.   26215
tkFgndPID         dw      0       ; Foreground Process ID.                 26215
fIdle           db      0       ; TRUE => inside idle loop

        extrn   _TKLibiCur:byte
        PUBLIC  _pTKLibiCur
_pTKLibiCur     dd      offset FLAT:_TKLibiCur
        PUBLIC  _pptdaTKEvap
_pptdaTKEvap    dd      0
        PUBLIC  _ctkScanners
_ctkScanners    dd      0
        PUBLIC  _ctkScannerOwner
_ctkScannerOwner dd     0
        PUBLIC  _tkTSDSwapRateMax
_tkTSDSwapRateMax dd    DefaultMaxSlice

        EXTRN   _schPriClassTbl:dword
        PUBLIC  _pschPriClassTbl
_pschPriClassTbl dd offset FLAT:_schPriClassTbl

        public  _pPortHoleMte
_pPortHoleMte   dd      0       ; pointer to PortHole mte
        public  _BasicHWConfig
_BasicHWConfig dw  0
        PUBLIC  _pldrdldHeadKernel
_pldrdldHeadKernel      dd      0

        PUBLIC  _pNonResNamTbl
_pNonResNamTbl          dd      0       ; pointer to Non-resdient name table
        PUBLIC  _program_h
_program_h              dd      0       ; head of list of program modules
        PUBLIC  _program_l
_program_l              dd      0       ; tail of list of program modules
        PUBLIC  _global_l
_global_l               dd      0       ; tail of list of global modules
        PUBLIC  _specific_h
_specific_h             dd      0       ; head of list of specific modules
        PUBLIC  _specific_l
_specific_l             dd      0       ; tail of list of specific modules
        PUBLIC  _swapping
_swapping               dd      FALSE   ; flag for swapping or not
        PUBLIC  _cNonResNamTbl
_cNonResNamTbl          dd      0       ; count of non-resident name entries
        PUBLIC  _PGGlobalFlags
_PGGlobalFlags          dd      0
        PUBLIC  _smMinSwapFile
_smMinSwapFile          dd      0
        PUBLIC  _SMcDFInuse
_SMcDFInuse             dd      0
        PUBLIC  _SMcInMemFile
_SMcInMemFile           dd      0
        PUBLIC  _SMpInMemFile
_SMpInMemFile           dd      0
        PUBLIC  _SMSwapSpace
_SMSwapSpace            dd      0

;** smbmDF and _smFilsSize MUST be kept together                        ;156729
        PUBLIC  _smbmDF                                                 ;156729
_smbmDF                 dd      0                                       ;156729
        PUBLIC  _smFileSize
_smFileSize             dd      0

        PUBLIC  _smSizeHistory
_smSizeHistory          dd      0
        PUBLIC  _smDFMac
_smDFMac                dd      0
        PUBLIC  _smcBrokenDF
_smcBrokenDF            dd      0
        PUBLIC  _SMMinFree
_SMMinFree              dd      0
        PUBLIC  _smPendingShrink
_smPendingShrink        db      FALSE
        public _smSFTOwner              ; slot #s of current SFTs owners
_smSFTOwner     dw MAXSIMULSWAP dup(0)
        PUBLIC  _hkhCurrMax
_hkhCurrMax     VMHKH   <0>

; pointer to atvm structure in memory\vmdata.c
        extrn   _atvm:byte
        PUBLIC  _patvm
_patvm          dd      offset FLAT:_atvm

; pointers to tables in memory\vmdevhlp.c
        extrn   _vmdhL_Flags:dword
        extrn   _vmdhA_Flags:dword
        PUBLIC  _pvmdhl_Flags
_pvmdhl_Flags   dd      offset FLAT:_vmdhL_Flags
        PUBLIC  _pvmdhA_Flags
_pvmdhA_Flags   dd      offset FLAT:_vmdhA_Flags
        PUBLIC  _vmInitFlags
_vmInitFlags    dd      0
        public _vmNamShrSem
_vmNamShrSem    dd      0                       ; shared memory semaphore
        PUBLIC  _pHybernateTCB                                          ;150281
_pHybernateTCB  dd      0           ; hybernation thread's TCB          ;150281
        PUBLIC  _hybernateSem                                           ;150281
ifndef  MISCSTRICT                                                      ;150281
_hybernateSem   KSEMEVT <>          ; event sem for hybernation         ;150281
else                                                                    ;150281
_hybernateSem   krnlsemevt_s <KSEM_SIGNATURE,,,>                        ;150281
endif
        PUBLIC  _fhybernation                                           ;152533
_fhybernation   dd      1           ; hybernation default is ENABLE     ;152533
;156773         PUBLIC  _hyberswapstart                                         ;153620
;156773 _hyberswapstart dd      0           ; hybernation default is ENABLE     ;153620

; end System Anchor Block

                         public CallGate_Debug_SymWinOS2
CallGate_Debug_SymWinOS2 dw     0

_DATA           ENDS

DATA            SEGMENT

                extrn   MuxTable:BYTE
;       System Anchor Block material from the DATA segment

                ALIGN   4
                PUBLIC  _SAB_Data
_SAB_Data       label   byte

                PUBLIC  pMuxTable
pMuxTable       DD      MuxTable

                PUBLIC  cMaxNMI,cMaxKNMI,cNMI
cMaxNMI         dd      0               ; # of nmis before process termination
cMaxKNMI        dd      0               ; # of nmis allowed in kernel
cNMI            dd      0               ; # of nmis that have occured

                PUBLIC  _ctcbTKInUse
_ctcbTKInUse    dd      0               ; Count of active threads in system
        EVEN

;ifdef PMDEBUG // RJM keep anchor block same uniform for all builds
        public  fDebugOnly
fDebugOnly      db      0               ; if !0, ByteToScrnDM to debugger only
;endif         // RJM

fResetVideoMode db      0               ; if 0, reset video mode
        public _tkPanicActive
_tkPanicActive  db      -1
        public  nPanic                                                 ;F78693
nPanic          dd      0               ; Count panics                 ;F78693
        public  fPanicToScreen                                         ;F78693
fPanicToScreen   dd      0                                             ;F78693
EVEN                                    ;
        public VPUserSelector           ;
        public VPUserOffset             ;
VPUserOffset    dw 0                    ; User ring 3 offset for flag
VPUserSelector  dw 0                    ; User ring 3 selector for flag
        PUBLIC          CurrentRamSemID
CurrentRamSemID dw      0       ; Current ram semaphore block/run ID

                PUBLIC  fNWDEnabled,fNWD
fNWDEnabled     db      FALSE           ; indicates that the system has
                                        ; enable NWD, not the current state
                                        ; note: NWD will only be disabled
                                        ;       at boot time, and by debugger

fNWD            db      FALSE           ; nwd timed out

        PUBLIC  _cTKNoBlock
_cTKNoBlock     db      0       ; TRUE => ProcBlocks illegal

;* Global system semaphore data table. Note that most of the
;  code that uses this table depends on it being in DOSGROUP. If
;  this table is every moved to a seperate segment carefully
;  check all the code.

        PUBLIC          SysSemDataTable
SysSemDataTable SysSemTblStruc SYSSEM_MAXIMUM dup(<>)

        PUBLIC          SysSemRmpHdl
SysSemRmpHdl    dd      ?       ; system semaphore rmp handle

        PUBLIC  handler_list
        PUBLIC  handler_max
        PUBLIC  semaphore
        PUBLIC  semaphore_handle

semaphore       db      0       ; used in Tick_handler
                EVEN
handler_list    db      max_handlers * SIZE handler DUP (0)

handler_max     dw      1       ; index of highest occupied handler_list slot
                                ; (init to 1 to prevent loop blowup)

semaphore_handle        dd      0               ; lower part of semaphore

        public  _pgPhysPageDir
_pgPhysPageDir  dd      ?               ; physical address of page directory
                                        ;  (must be accessible from real mode)

PTOV_NUMSELS            equ     33*2    ; number of selectors needed for ptov
        public PtoV_Selectors
PtoV_Selectors  dw      PTOV_NUMSELS dup(?)

        public  hDiscSegRmpStruc
        public  DiscSegRmpRec
     hDiscSegRmpStruc   dd  0                 ; rmp handle to discardable
                                              ;    segment records.
     DiscSegRmpRec      selDiscSegRmpRec_s <> ; discarable segments rmp record

        public  _SMswapping
_SMswapping     dw      0
        public  _SMCFGMinFree
_SMCFGMinFree dd        0
        public _SMCommit
_SMCommit     db       0
        public  ShareRmpStruc
ShareRmpStruc   dd      0                       ; rmp handle to shared memory
                                                ;       records segment.
        public  _ShutdownFlag                                           ;150101
_ShutdownFlag   dd      0               ; Shutdown flag                 ;150101
; end System Anchor Block

DATA            ENDS

c_common        SEGMENT

;       System Anchor Block material from the c_common segment

        PUBLIC  _SAB_c_common
_SAB_c_common   label   byte

        PUBLIC  _PopUpSem
_PopUpSem    KSEMMTX  <>

        PUBLIC  _fpregs
_fpregs      FPSTATE  <>

        PUBLIC  _ulShTblSize
_ulShTblSize            DD      ?
        PUBLIC  _ulShSemStrTblUsed
_ulShSemStrTblUsed      DD      ?
        PUBLIC  _ulShSemStrTblSize
_ulShSemStrTblSize      DD      ?
        PUBLIC  _ulShTotUsed
_ulShTotUsed            DD      ?
        PUBLIC  _pShSemStrTbl
_pShSemStrTbl           DD      ?
        PUBLIC  _pShSemTbl
_pShSemTbl              DD      ?
        PUBLIC  _hksSemRec
_hksSemRec              HKSEM   <>
        PUBLIC  _hksStrTbl
_hksStrTbl              HKSEM   <>
        PUBLIC  _pPTDAFirstZombie
_pPTDAFirstZombie       DD      ?
        PUBLIC  _paPTDA
_paPTDA                 DD      ?       ;PTDA array (BMP object)
        PUBLIC  _paTCB
_paTCB                  DD      ?       ;TCB array (BMP object)
        PUBLIC  _ptcbPriQDelayed
_ptcbPriQDelayed        DD      ?       ;STATE_DELAYED
        PUBLIC  _ptcbPriQGetStack
_ptcbPriQGetStack       DD      ?       ;STATE_GETSTACK

        PUBLIC  _aptcbSleep
TKSLEEPSIZE     equ     257             ; The Prime Number nearest 256.
_aptcbSleep     dd      TKSLEEPSIZE dup (?)     ; Sleep Hash Table
        PUBLIC  _ptcbPriQTSD
_ptcbPriQTSD    dd      ?               ; STATE_TSD
        PUBLIC  _LdrSem
_LdrSem KSEMMTX <>                      ; allocate loader semaphore
        PUBLIC  _DosModHdl
_DosModHdl      dw      ?               ; DOSCALLS pseudo handle
        PUBLIC  _hMteDoscall1
_hMteDoscall1   VMHOB   <>
        PUBLIC  _pmteDoscall1
_pmteDoscall1   dd      ?
        PUBLIC  _pgpVPBase
_pgpVPBase      dd      ?
        PUBLIC  _pgpVPEnd
_pgpVPEnd       dd      ?
        PUBLIC  _pgVPEndPg
_pgVPEndPg      dd      ?
        PUBLIC  _PGSwapEnabled
_PGSwapEnabled  dd      ?
        PUBLIC  _pgVPBasePg
_pgVPBasePg     dd      ?
        PUBLIC  _smpHeap
_smpHeap        dd      ?
        PUBLIC  _smpHeapEnd
_smpHeapEnd     dd      ?
        PUBLIC  _pgVPHead
_pgVPHead       vp_s    <>
        PUBLIC  _pgListHeadVP
_pgListHeadVP   vp_s    <>
        PUBLIC  _smHobheap
_smHobheap      VMHOB   <>
        PUBLIC  _SMSwapperSem
_SMSwapperSem   KSEMMTX <>
        PUBLIC  _smSwapDisk
_smSwapDisk     db      ?
        PUBLIC  _parGlobalShrSearchStart
_parGlobalShrSearchStart        dd      ?
        PUBLIC  _vmGlobalShrLBDRY
_vmGlobalShrLBDRY       dd      ?
        PUBLIC  _vmGlobalShrUBDRY
_vmGlobalShrUBDRY       dd      ?
; end System Anchor Block

c_common        ENDS

VDDMTE          SEGMENT

VDInit macro field, size, value
    .errnz (($ - _VDDModMte) - offset field)
    size  value
endm

;       System Anchor Block material from the VDDMTE segment

        extrn   VDDModMteSwappable:byte

        PUBLIC  _SAB_VDDMTE
_SAB_VDDMTE     label   byte

        public  _VDDModMte
_VDDModMte label byte

VDInit  mte_flags2      dw      <MTEFORMATLX>
VDInit  mte_handle      dw      0
VDInit  mte_swapmte     dd      <offset FLAT:VDDModMteSwappable>
VDInit  mte_link        dd      0

VDInit  mte_flags1      dd      <NOAUTODS+MVDMMOD+LIBRARYMOD+MTEVALID+CLASS_GLOBAL+MTE_MEDIAFIXED>
VDInit  mte_impmodcnt   dd      0
VDInit  mte_sfn         dw      0
VDInit  mte_usecnt      dw      1       ; make sure it never goes to zero
VDInit  mte_modname     db      <'MVDM',0,0,0,0>

; end System Anchor Block

VDDMTE          ENDS
                END
