

* All DOS processes have this STRUCTure
* Create and DeviceProc returns pointer to the MsgPort in this STRUCTure
* Process_addr = DeviceProc(..) - TC_SIZE

; STRUCTURE Process,0
pr_Task		EQU	0	;TC_SIZE	92
pr_MsgPort	EQU	92	;MP_SIZE	34  * This is BPTR address from DOS functions
pr_Pad    	EQU	126         * Remaining variables on 4 byte boundaries
pr_Padshort
pr_SegList  	EQU	128        *B Array of seg lists used by this process
pr_SegListint
pr_StackSize	EQU	132        * Size of process stack in bytes
pr_StackSizeint
pr_GlobVec	EQU	136          * Global vector for this process (BCPL)
pr_GlobVecint
pr_TaskNum  	EQU	140        * CLI task number of zero if not a CLI
pr_TaskNumint
pr_StackBase	EQU	144        *B Ptr to high memory end of process stack
pr_StackBaseint
pr_Result2	EQU	148          * Value of secondary result from last call
pr_Result2int
pr_CurrentDir	EQU	152       *B Lock associated with current directory
pr_CurrentDirint
pr_CIS		EQU	156              *B Current CLI Input Stream
pr_CISint
pr_COS		EQU	160              *B Current CLI Output Stream
pr_COSint
pr_ConsoleTask	EQU	164      * Console handler process for current window
pr_ConsoleTaskint
pr_FileSystemTask	EQU	168   * File handler process for current drive
pr_FileSystemTaskint
pr_CLI		EQU	172              *B pointer to ConsoleLineInterpreter
pr_CLIint
pr_ReturnAddr	EQU	176       * pointer to previous stack frame
pr_ReturnAddrint
pr_PktWait	EQU	180         * Function to be called when awaiting msg
pr_PkWaitint
pr_WindowPtr	EQU	184        * Window pointer for errors
pr_WindowPtrint
pr_SIZEOF	SET	188           * Process

* The long word address (BPTR) of this STRUCTure is returned by
* Open() and other routines that return a file.  You need only worry
* about this STRUCT to do async io's via PutMsg() instead of
* standard file system calls

; STRUCTURE FileHandle,0
fh_Link		EQU	0               * pointer to EXEC message
fh_Linkint
fh_Interactive	EQU	4        * Boolean; TRUE if interactive handle
fh_Interactiveint
fh_Type		EQU	8               * Port to do PutMsg() to
fh_Typeint
fh_Buf		EQU	12
fh_Bufint
fh_Pos		EQU	16
fh_Posint
fh_End		EQU	20
fh_Endint
fh_Funcs	EQU	24	
fh_Funcsint
fh_Func1 	EQU fh_Funcs
fh_Funcs1int
fh_Func2	EQU	28
fh_Func2int
fh_Func3	EQU	32
fh_Funcs3int
fh_Args		EQU	36
fh_Argsint
fh_Arg1 EQU fh_Args
fh_Args1int
fh_Arg2		EQU	40
fh_Args2int
fh_SIZEOF	SET	44	 * FileHandle

* This is the extension to EXEC Messages used by DOS
; STRUCTURE DosPacket,0
dp_Link	EQU	0         * pointer to EXEC message
dp_Linkint
dp_Port	EQU	4         * pointer to Reply port for the packet
dp_Portint
*                         * Must be filled in each send.
dp_Type	EQU	8         * See ACTION_... below and
dp_Typeint
*                         * 'R' means Read, 'W' means Write to the file system
dp_Res1	EQU	12         * For file system calls this is the result
dp_Res1int
*                         * that would have been returned by the
*                         * function, e.g. Write ('W') returns actual
*                         * length written
dp_Res2	EQU	16         * For file system calls this is what would
dp_Res2int
*                         * have been returned by IoErr()
dp_Arg1	EQU	20
dp_Arg1int
*  Device packets common equivalents
dp_Action  EQU  dp_Type
dp_Actionint
dp_Status  EQU  dp_Res1
dp_Statusint
dp_Status2 EQU  dp_Res2
dp_Status2int
dp_BufAddr EQU  dp_Arg1
dp_Arg2	EQU	24
dp_Arg2int
dp_Arg3	EQU	28
dp_Arg3int
dp_Arg4	EQU	32
dp_Arg4int
dp_Arg5	EQU	36
dp_Arg5int
dp_Arg6	EQU	40
dp_Arg6int
dp_Arg7	EQU	44
dp_Arg7int
dp_SIZEOF 	SET	48	* DosPacket

* A Packet does not require the Message to before it in memory, but
* for convenience it is useful to associate the two.
* Also see the function init_std_pkt for initializing this STRUCTure

MN_SIZE		SET	20
ds_SIZEOF	SET	12
; STRUCTURE StandardPacket,0
sp_Msg	EQU	0	;MN_SIZE
sp_Pkt	EQU	20	;dp_SIZEOF  
sp_SIZEOF	SET	32	 * StandardPacket


* Packet types
ACTION_NIL              EQU     0
ACTION_GET_BLOCK        EQU     2
ACTION_SET_MAP          EQU     4
ACTION_DIE              EQU     5
ACTION_EVENT            EQU     6
ACTION_CURRENT_VOLUME   EQU     7
ACTION_LOCATE_OBJECT    EQU     8
ACTION_RENAME_DISK      EQU     9
ACTION_WRITE            EQU     'W'
ACTION_READ             EQU     'R'
ACTION_FREE_LOCK        EQU     15
ACTION_DELETE_OBJECT    EQU     16
ACTION_RENAME_OBJECT    EQU     17
ACTION_MORE_CACHE       EQU     18
ACTION_COPY_DIR         EQU     19
ACTION_WAIT_CHAR        EQU     20
ACTION_SET_PROTECT      EQU     21
ACTION_CREATE_DIR       EQU     22
ACTION_EXAMINE_OBJECT   EQU     23
ACTION_EXAMINE_NEXT     EQU     24
ACTION_DISK_INFO        EQU     25
ACTION_INFO             EQU     26
ACTION_FLUSH            EQU     27
ACTION_SET_COMMENT      EQU     28
ACTION_PARENT           EQU     29
ACTION_TIMER            EQU     30
ACTION_INHIBIT          EQU     31
ACTION_DISK_TYPE        EQU     32
ACTION_DISK_CHANGE      EQU     33
ACTION_SET_DATE         EQU     34

ACTION_SCREEN_MODE      EQU     994


* DOS library node structure.
* This is the data at positive offsets from the library node.
* Negative offsets from the node is the jump table to DOS functions
* node = (STRUCT DosLibrary *) OpenLibrary( "dos.library" .. )
LIB_SIZE	SET	36
 STRUCTURE DosLibrary,0
    STRUCT  dl_lib,LIB_SIZE
    APTR    dl_Root          * Pointer to RootNode, described below
    APTR    dl_GV            * Pointer to BCPL global vector
    LONG    dl_A2            * Private register dump of DOS
    LONG    dl_A5
    LONG    dl_A6
    LABEL   dl_SIZEOF *  DosLibrary

*

 STRUCTURE RootNode,0
    BPTR    rn_TaskArray       * [0] is max number of CLI's
*                              * [1] is APTR to process id of CLI 1
*                              * [n] is APTR to process id of CLI n
    BPTR    rn_ConsoleSegment  * SegList for the CLI
    STRUCT  rn_Time,ds_SIZEOF  * Current time
    LONG    rn_RestartSeg      * SegList for the disk validator process
    BPTR    rn_Info            * Pointer ot the Info structure
    BPTR    rn_FileHandlerSegment * code for file handler 
    LABEL   rn_SIZEOF * RootNode

 STRUCTURE DosInfo,0
    BPTR    di_McName          * Network name of this machine currently 0
    BPTR    di_DevInfo         * Device List
    BPTR    di_Devices         * Currently zero
    BPTR    di_Handlers        * Currently zero
    APTR    di_NetHand         * Network handler processid currently zero
    LABEL   di_SIZEOF * DosInfo

* DOS Processes started from the CLI via RUN or NEWCLI have this additional
* set to data associated with them

 STRUCTURE CommandLineInterface,0
    LONG   cli_Result2         * Value of IoErr from last command
    BSTR   cli_SetName         * Name of current directory
    BPTR   cli_CommandDir      * Lock associated with command directory
    LONG   cli_ReturnCode      * Return code from last command
    BSTR   cli_CommandName     * Name of current command
    LONG   cli_FailLevel       * Fail level (set by FAILAT)
    BSTR   cli_Prompt          * Current prompt (set by PROMPT)
    BPTR   cli_StandardInput   * Default (terminal) CLI input
    BPTR   cli_CurrentInput    * Current CLI input
    BSTR   cli_CommandFile     * Name of EXECUTE command file
    LONG   cli_Interactive     * Boolean True if prompts required
    LONG   cli_Background      * Boolean True if CLI created by RUN
    BPTR   cli_CurrentOutput   * Current CLI output
    LONG   cli_DefaultStack    * Stack size to be obtained in long words
    BPTR   cli_StandardOutput  * Default (terminal) CLI output
    BPTR   cli_Module          * SegList of currently loaded command
    LABEL  cli_SIZEOF  * CommandLineInterface


*
* this structure needs some work.  It should really be a union, because
* it can take on different valued depending on whether it is a device,
* an assigned directory, or a volume.
* For now, it reflects a volume.
*
 STRUCTURE DevList,0
    BPTR        dl_Next                 ; bptr to next device list
    LONG        dl_Type                 ; see DLT below
    APTR        dl_Task                 ; ptr to handler task
    BPTR        dl_Lock                 ; not for volumes
    STRUCT      dl_VolumeDate,ds_SIZEOF ; creation date
    BPTR        dl_LockList             ; outstanding locks
    LONG        dl_DiskType             ; 'DOS', etc
    LONG        dl_unused
    BSTR        dl_Name                 ; bptr to bcpl name
    LABEL       DevList_SIZEOF

* definitions for dl_Type
DLT_DEVICE      EQU     0
DLT_DIRECTORY   EQU     1
DLT_VOLUME      EQU     2


* a lock structure, as returned by Lock() or DupLock()
 STRUCTURE FileLock,0
    BPTR        fl_Link                 ; bcpl pointer to next lock
    LONG        fl_Key                  ; disk block number
    LONG        fl_Access               ; exclusive or shared
    APTR        fl_Task                 ; handler task's port
    BPTR        fl_Volume               ; bptr to a DeviceList
    LABEL       fl_SIZEOF

* DevInfo structure
 STRUCTURE DevInfo,0
    BPTR        dvi_Next        ; Next list entry or 0
    LONG        dvi_Type        ; Entry type 0=device,1=dir,2=vol?
    APTR        dvi_Task        ; Handler process msgport or 0
    BPTR        dvi_Lock        ; File system lock or 0
    BSTR        dvi_Handler     ; File name of handler or 0
    LONG        dvi_Stacksize   ; Stack size for handler process
    LONG        dvi_Priority    ; Priority for handler process
    LONG        dvi_Startup     ; Startup value passed to handler
    BPTR        dvi_SegList     ; Seglist for handler process or 0
    BPTR        dvi_GlobVec     ; Global vector, 0, or -1
    BSTR        dvi_Name        ; Name of device or ASSIGN'd name
    LABEL       dvi_SIZEOF

   ENDC  LIBRARIES_DOSEXTENS_I
