📄 mosedf.inc
字号:
; MMURTL Operating System Source Code
; Copyright 1991,1992,1993, Richard A. Burgess
; ALL RIGHTS RESERVED
; Version x0.8
;=============================================================================
; EQUates for the OS
;=============================================================================
TRUE EQU 1
FALSE EQU 0
;Error and Status Codes
;1-199 OS Kernel and Resource Management (general, used by all)
ErcOk EQU 0 ;Normal Status, No errors
ErcEOF EQU 1
ErcOpCancel EQU 4 ;Operator cancel
ErcNullPtr EQU 6 ;Null ptr passed into call or service
;10 - 19 Exchange Errors for Allocation and Use
ErcOutOfRange EQU 10 ;
ErcNotAlloc EQU 11 ;Bad exchange (not allocated)
ErcNotOwner EQU 12 ;Attempt to deallocate an Exch that's not yours
;20 - 29 Message Management
ErcNoMsg EQU 20 ;Returned by Check primitive when no msg waiting
;30 - 39 System Service Management
ErcNoSuchSvc EQU 30 ;No service by that name
ErcBadSvcCode EQU 32 ;Service doesn't handle that code
ErcNotRqBlk EQU 34 ;Service received a NON RqBlock at it's exchange
ErcOutOfSvcDesc EQU 36 ;No more empty Service Descriptors
ErcOwnerAbort EQU 37 ;Service received SvcCode 0 on owner of this RqBlk
;OS Resource Management Errors
ErcNoMoreExch EQU 40 ;
ErcNoMoreLBs EQU 41 ;Out of Link Blocks
;ErcMsgMissing EQU 42
ErcNoSvcBlks EQU 43 ;No more servcice can install
ErcNoMoreTBs EQU 44 ;Out of timer blocks
ErcNoMoreTSSs EQU 45 ;Out of TSSs
ErcNoMoreRqBlks EQU 46 ;Out of Request Blocks
ErcNoMoreJCBs EQU 47 ;Out of Job Control Blocks
;OS Call Gate Management
ErcBadGateNum EQU 48 ;tried to add an invalid GDT call gate
ErcBadCallGate EQU 49 ;Called an UNinitialized Call Gate!!
;OS Task Management
ErcBadPriority EQU 50
;OS Job Management
ErcBadJobNum EQU 70 ;A Bad job number was specified in an OS call
ErcInvalidJCB EQU 71 ;The Job number specifies an unassigned JCB
ErcBadRunFile EQU 74 ;The run file you specified is NOT a run file!
ErcNoExitJob EQU 76 ;No exit job was specified on ExitJob(n)
ErcBadParams EQU 80 ;Invalid or bad params were passed to a command
;Memory Management
ErcNoGdtSlots EQU 100 ;No more free rgMemDesc GDT slots!
ErcNoMem EQU 101 ;Not enough memory (no more pages!!!)
ErcBadMemPage EQU 102 ;Bad physical page specified in Mem call
ErcBadMemReq EQU 104 ;Invalid size for memory request
ErcInternalMem EQU 106 ;An error has occurred that shouldn't, this indicates
;an internal inconsistancy. AddPage can't!
ErcNoRuns EQU 107 ;No free runs large enough in PTs (temporary)
ErcBadLinAdd EQU 108 ;Bad linear address was passed to DeallocMem
ErcShortMem EQU 109 ;Passed in too many pages to Dealloc, but
;as many as possible were deallocated
ErcBadAlias EQU 111 ;Address passed in WASN't an alias (it should be)
;File System 200 - 299 See DOSFS.C for complete description
;Character Video Management 300 -399
ErcVidNum EQU 300 ;Bad video number passed as param to vid call
ErcVidparam EQU 301 ;A param was out of range to a Vid call
ErcEditParam EQU 300 ;Bad param to EditLine
ErcBadString EQU 302 ;Invalid sting passed to Math Cnvrt Func
;OS hardware Resource Management
ErcDMAChannel EQU 400 ;Invalid DMA channel specified as param
ErcDMAMode EQU 401 ;Bad mode specified
;500-599 Device Management (General)
ErcBadDevNum EQU 500 ;DCB number too large ( > max DCBs)
ErcDevInUse EQU 501 ;DCB already in use
ErcBadDevName EQU 502 ;Size of device name incorrect
ErcBadOpNum EQU 503 ;OpNum to DD that it doesn't handle!
ErcNoDevice EQU 504 ;Driver's installed but NO device is
ErcNoDriver EQU 505 ;No driver installed for that Device Num
ErcDCBInUse EQU 506 ;Attempt to install driver over valid FDC
;600-649 Floppy Device Driver (See FDD.c)
;650-699 Hard Disk Device Driver (See HDD.c)
;700-749 Keyboard Service
ErcNoKeyAvail EQU 700
;800-899 Async Comms Device Driver (COMx)
;900-949 Parallel Comms Device Driver (LPTx)
;----------------------------------------------------------------
;OS Constants
OSCodeSel EQU 0008h ;OS code is 0 based on this selector
DataSel EQU 0010h ;All data is 0 based on this selector
JobCodeSel EQU 0018h ;All User Code is 0 based on this selector
NIL EQU 0 ;Duh...
nTSS EQU 66 ;2 static and 64 dynamic
nLB EQU 512 ;Number of link blocks
nDynEXCH EQU 256 ;number of dynamic exchanges (fills one page)
nPRI EQU 32 ;Task priorities (0 to 31)
nRQBs EQU 128 ;number of request blocks (All Dynamic)
nSVC EQU 64 ;max services that can be installed
nJCBs EQU 32 ;max Job Contol Blocks (excluding 2 static JCBs)
nTmrBlks EQU 32 ;max outstanding timer blocks
nCallGates EQU 694 ;Number of call gates (Max!)
;6144 (6Kb) of GDT slots - 768 total
nGDTSlots EQU 8 + nCallGates + nTSS
;=============================================================================
;8042 Status Byte, Port Hex 0064 Read
;=============================================================================
STATUSPORT EQU 64h
COMMANDPORT EQU 64h
DATAPORT EQU 60h
PARITYERROR EQU 10000000b
GENERALTIMEOUT EQU 01000000b
AUXOUTBUFFFULL EQU 00100000b
INHIBITSWITCH EQU 00010000b
COMMANDDATA EQU 00001000b
SYSTEMFLAG EQU 00000100b
INPUTBUFFFULL EQU 00000010b
OUTPUTBUFFFULL EQU 00000001b
;=============================================================================
; The following are structures for the MOS KERNEL
;=============================================================================
;
; Job Control Block (all tasks are associated with a JOB)
; The JOB NUMBER is how the job is identifed by many OS functions.
; Each JCB is assigned a number when the it is initialized.
; Job 1 is always reserved for the OS Monitor and 2 for the debugger.
; (even though the debugger isn't really a job...)
;
; The JCB keeps job related information such as the current path
; of the job, Linear address of it's PD, virtual video info, Cmd line
; when executed, Job path, etc...
;
sJCB EQU 512 ;
JCBType STRUC
JobNum DD 0 ;
sbJobName DB 14 DUP (0h) ; 13 bytes w/1 length
JcbPD DD 0 ; Linear address of Job's Page Directory
pJcbCode DD 0 ;User Address of code segment
sJcbCode DD 0 ;Size of user code segment
pJcbData DD 0 ;User Adresss of data segment
sJcbData DD 0 ;Size of user data segment
pJcbStack DD 0 ;User Addrees of first stack
sJcbStack DD 0 ;Size of user first stack
JcbUserName DB 30 DUP (0h) ; User Name for Job - LString
JcbPath DB 70 DUP (0h) ; path name (prefix) - LString
JcbExitRF DB 80 DUP (0h) ; Exit Run file (if any) - LString
JcbCmdLine DB 80 DUP (0h) ; Command Line string - LString
JcbSysIn DB 50 DUP (0h) ; Standard input (KBD)
JcbSysOut DB 50 DUP (0h) ; Standard output (VID)
ExitError DD 0 ;Error passed by ExitJob
pVidMem DD 0 ;pointer to crnt video (real or virtual)
pVirtVid DD 0 ;Virtual Video Buffer Address
CrntX DD 0 ;Current cursor position
CrntY DD 0
nCols DD 80 ;Screen size
nLines DD 25
VidMode DD 0 ;0 = 80x25 VGA color text
NormAttr DD 07 ;Normal Video Attr
fCursOn DB 0 ;Is cursor visible on this screen
fCursType DB 0 ;Cursor type (0=UL, 1 = Block)
ScrlCnt DB 0 ;Count since last pause (or Kbd)
fVidPause DB 0 ;Full screen pause (Text mode)
NextJCB DD 0 ;
JcbRsvd1 DB (512-22-24-360-36-8) DUP (0h) ; Pad to 512
JCBType ENDS
;
;
; Each Task State Segment (Structure) is 512 bytes long
; Space is reserved for Math Coprocessor registers
; which will be used when we add support for management of tasks
; using the co processor. They are DWORD aligned for
; best efficiency.
;
sTSS EQU 512
TSSTYPE STRUC
TSS_BackLink DW 0000h,0000h ; Task Selector of Interrupted TASK
TSS_ESP0 DD 00000000h ; Top of Stack for Prot Level 0
TSS_SS0 DW 0000h,0000h ; Selector for Prot Level 0 Stack
TSS_ESP1 DD 00000000h ; Top of Stack for Prot Level 1
TSS_SS1 DW 0000h,0000h ; Selector for Prot Level 1 Stack
TSS_ESP2 DD 00000000h ; Top of Stack for Prot Level 2
TSS_SS2 DW 0000h,0000h ; Selector for Prot Level 2 Stack
TSS_CR3 DD 00000000h ; Physical Address of Page Directory
TSS_EIP DD 00000000h ; Extended Instruction Pointer
TSS_EFlags DD 00000000h ; Extended Flags
TSS_EAX DD 00000000h ; General Purpose Registers
TSS_ECX DD 00000000h ;
TSS_EDX DD 00000000h ;
TSS_EBX DD 00000000h ;
TSS_ESP DD 00000000h ; Top of Stack for Current Prot Level
TSS_EBP DD 00000000h ; Base Frame Pointer (64 bytes to here)
TSS_ESI DD 00000000h ; Source Index Register
TSS_EDI DD 00000000h ; Destination Index Register
TSS_ES DW 0000h,0000h ; E Selector (Extra)
TSS_CS DW 0000h,0000h ; C Selector (Code)
TSS_SS DW 0000h,0000h ; S Selector (Stack Curr Prot Level)
TSS_DS DW 0000h,0000h ; D Selector (Data)
TSS_FS DW 0000h,0000h ; F Selector (Extra)
TSS_GS DW 0000h,0000h ; G Selector (Extra)
TSS_LDT DW 0000h,0000h ; LDT Selector ( ALWAYS 0) (100)
TSS_TrapBit DW 0000h ; 1 = DEBUG; 0 = NODEBUG
TSS_IOBitBase DW 1111111111111111b ; NULL I/O Permission Bit Map
TSS_Exch DD 00000000h ; Task Exchange used by OS ONLY
TSS_pJCB DD 00000000h ; pointer to Job Control Blk (Owner)
Tid DW 0000h ; 1 word Task Id (Selector)
Priority DB 00h ; 1 byte Priority (0..31)
TSS_Rsvd1 DB 00h ; For alignment
TSS_MSG DD 00000000h,00000000h ; 8 Byte OS Msg Block
pLBRet DD 00000000h ; pLB containing MessageRet (128)
NextTSS DD 00000000h ; Near Pointer to next TSS (132)
TSSNum DW 0000h ; Sequential Number of this TSS
TSS_Rsvd2 DB 122 dup (00h) ; Math Registers (future)
TSS_Rsvd3 DD 64 dup (00000000h) ; Future Expansion
TSSTYPE ENDS
;
; Each link block is 16 bytes long
;
DATALB EQU 00h
REQLB EQU 01h
RESPLB EQU 02h
sLINKBLOCK EQU 16
LINKBLOCK STRUC
DataLo DD 00000000h ; Data Low DWord or pRqBlk
DataHi DD 00000000h ; Data High DWord or CR3
NextLB DD 00000000h ; Pointer to next LB (Free, or in Link)
LBType DB 00h ; SEND REQUEST
LBResvd DB 0,0,0
LINKBLOCK ENDS
;
; Each Queue Type is 8 bytes long
; NOTE: If this size sQUEUE changes you must change the enQueueRdy
; code because it uses a shift instruction (SHL 3) for speed
; instead of multiplying by the size. It is unlikely that this
; size will change, but you never know.
;
sQUEUE EQU 8
QUEUE STRUC
Head DD 00000000h ; head Queue Pointer
Tail DD 00000000h ; tail Queue Pointer
QUEUE ENDS
;
; Each Exchange is 16 bytes long
; NOTE: We use shift instructions for multiplying to calculate
; a pointer to an exchange. The size of the Exch structure
; should always be a power of 2. It's a speed issue...
;
sEXCH EQU 16
WAITQUEUE STRUC
EHead DD 00000000h ; Struct for the msg/Task queue
ETail DD 00000000h ;
fEMsg DD 00000000h ; True if this holds messages (vice tasks)
Owner DD 00000000h ; pointer to JCB
WAITQUEUE ENDS
;
;------------------------------------
; Request Blocks are 64 bytes long. 64 RqBlks per page.
;
sRQB EQU 64
RQBLK STRUC
ServiceExch DD 0h ; System Exchange (OS Fill from name supplied)
RespExch DD 0h ; Exchange to respond to (User Fill)
RqOwnerJob DD 0h ; JobNum of Owner of the RqBlk - (OS Fill)
ServiceRoute DD 0h ; Used for net routing (Rsvd for now)
pRqHndlRet DD 0h ; For User to identify Rq at Wait
dData0 DD 0h ; User fill / Srvc Defined (No Pointers)
dData1 DD 0h ; User fill / Srvc Defined (No Pointers)
dData2 DD 0h ; User fill / Srvc Defined (No Pointers)
ServiceCode DW 0h ; System Service Command Number (User Fill)
npSend DB 0h ; Number of Send PbCbs
npRecv DB 0h ; Number of Recv PbCbs
pData1 DD 0h ; User fill / Srvc Defined
cbData1 DD 0h ; User fill / Srvc Defined
pData2 DD 0h ; User fill / Srvc Defined
cbData2 DD 0h ; User fill / Srvc Defined
Rsvd2 DD 0h ;
Rsvd3 DD 0h ;
pNextRQB DD 0h ; Pointer to next Free Rq Blk (NIL if last)
RQBLK ENDS
;
; Each System Service Descriptor is 12 bytes long
;
sSVC EQU 12
SVCDESC STRUC
SvcName DD 00000000h ; System Service Name
DD 00000000h
SvcExch DD 00000000h ; System Service Exchange
SVCDESC ENDS
;
; Each TimerBlock is 9 Bytes long (Used by OS Delay proc and timer Int)
;
sTmrBlk EQU 12
TmrBlk STRUC
fInUse DD 00000000h
TmrRespExch DD 00000000h
CountDown DD 00000000h
TmrBlk ENDS
;
;================= END of Module ==================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -