*******************************************************************************
* PowerDOS, an operating system by Chris Latham, Copyright (C) 1992
* This file is the PowerDOS System global definitions
*
*     Begun on 01-10-92
*
* Completed on 04-04-92
*
* Revision history:
*   Date			Comment
****************************************************************************

	opt	C16-
	opt	O+
	opt	OW-

* The three OS vectors we are concerned with
v_trap1	equ	$84	BDOS vector
v_trap13	equ	$b4	BIOS vector
v_trap14	equ	$b8	XBIOS vector


* ST global system variables

etv_timer	equ	$400	AES timer (not used by PowerDOS)
etv_critic	equ	$404	Critical error handler vector
etv_term	equ	$408	AES terminate vector
*	equ	$40c
*	equ	$410
*	equ	$414	Expansion Vectors as defined by Atari
*	equ	$418
*	equ	$41c

* Globals used by PowerDOS (these must be located in an absolute location
* for quick access without the need for a base register)
Sys_vars	equ	$416	Points to global system variables
S_int_flag	equ	$41a	Interupt in progress flag
S_startproc	equ	$41b	Start next process flag
S_ticks	equ	$41c	#%0001000100010001 (tick rotate mask)
dmasem	equ	$41e	DMA semaphore

memvalid	equ	$420	Contains $752019f3 for validation
memctrl	equ	$424	Copy of mem controller config value
_resvalid	equ	$426	Contains $31415926 if reset vector valid
_resvector	equ	$42a	If $426 valid, jump through this vector
phystop	equ	$42e	Physical top of memory
_membot	equ	$432	Begin of TPA
_memtop	equ	$436	End of TPA
memval2	equ	$43a	Another magic number $237698aa
flock	equ	$43e	Disk access in progress
seekrate	equ	$440	Floppy seek rate
_timer_ms	equ	$442	Tick length in ms (20)
_fverify	equ	$444	If not zero, verify floppy
_bootdev	equ	$446	Device system was booted from
palmode	equ	$448	If not zero, set to 50hz pal mode
defshiftmod	equ	$44a	0=low, 1=medium (for color only)
sshiftmod	equ	$44c	$000,$100,$200 (low, med, high)
_v_bas_ad	equ	$44e	Logical screen base
vblsem	equ	$452	If zero, no vblank routine
nvbls	equ	$454	Number of vblank routines (8)
_vbqueue	equ	$456	Points to vblank vectors
colorptr	equ	$45a	Points to new color palette or 0
screenpt	equ	$45e	Points to new screen to set, or 0
_vbclock	equ	$462	Number of vbl interupts
_frclock	equ	$466	Number of vbl routines executed
hdv_init	equ	$46a	Vector for hard drive initialization
swv_vec	equ	$46e	Vector for change in screen res
hdv_bpb	equ	$472	Vector to fetch bpb for drives
hdv_rw	equ	$476	Vector for drive read/write
hdv_boot	equ	$47a	Vector for drive reboot
hdv_mediach	equ	$47e	Vector to test for drive change
_comload	equ	$482	If not 0, execute "COMMAND.PRG"
conterm	equ	$484	Byte defining console attributes
shiftstat	equ	$485	Byte containing shift/cntrl/alt status
trp14ret	equ	$486	Trap #14 return address (unused)
criticret	equ	$48a	Return address for critical error
themd	equ	$48e	Initial Memory discriptor
__md	equ	$49e	(???)
savptr	equ	$4a2	Points to reg save area for (x)bios calls
_nflops	equ	$4a6	Number of connected floppies
con_state	equ	$4a8	Vector for screen output
save_row	equ	$4ac	Temp storage for cursor
sav_context	equ	$4ae	Location of context after a crash
_bufl	equ	$4b2	Points to head of BCB list
cache_ptr	equ	$4b6	Points to first cashe header, or 0
_hz_200	equ	$4ba	Counter for 200 hz system clock
the_env	equ	$4be	Default environment string $00000000
_drvbits	equ	$4c2	Bit map of connected drives
_dskbufp	equ	$4c6	Points to a 1024 byte disk buffer
_autopath	equ	$4ca	Points to autoexec path (0)
_vbl_list	equ	$4ce	8 longs, vbl vectors
_dumpflg	equ	$4ee	Flag to start a screen dump
_prtabt	equ	$4f0	Printer abort flag
_sysbase	equ	$4f2	Start of the OS
_shell_p	equ	$4f6	Global shell info (???)
end_os	equ	$4fa	End of OS (if ram based), start of TPA
exec_os	equ	$4fe	Exec address of AES

* Next is used to determine if an extended exception stack frame is used.
_longframe	equ	$59e	0 if 68000, else 020, 030, 040, etc.

* System cookie jar
_p_cookies	equ	$5a0	0 if no cookie jar, else ptr to jar

* Value used to validate reset vector
RESMAGIC	equ	$31415926

* The following are needed to determine the logical sector size if
* cache sectors are to be installed.
pun_ptr	equ	$516	Points to Physical Units info
Defsize	equ	512	Default sector size
maxunits	equ	16	Max units (at least for pun storeage)

	RSRESET
puns	rs.w	1	Total units in system
pun	rs.b	maxunits	Physical unit for each logical unit
part_start	rs.l	maxunits	Start of partition on the physical unit
P_cookie	rs.l	1	Cookie if AHDI 3.0 or later is installed
P_cookptr	rs.l	1	Points back to cookie to validate it
P_version	rs.w	1	Who knows?
P_max_sec	rs.w	1	Max sector size being handled

* Macro to allow interupt routines to perform an s_send function without
* causing unfreindly trap #1 grabbers to kill the system. What it does
* is to save the current trap #1 vector on the stack, then replace it
* with the known good vector of PowerDOS. After the call, the original vector
* is restored. Note: uses a0, so it should not be one of the parameters
* of the s_send call.
int_s_send	macro
	move.l	(v_trap1).w,-(sp)	Save original trap #1 vector
	move.l	(Sys_vars).w,a0	Get pointer to system vars
	move.l	G_trap1(a0),(v_trap1).w	Put safe trap #1
	s_send	\1,\2		Perform s_send call
	move.l	(sp)+,(v_trap1).w	Restore original trap #1 vector
	endm

* Error codes

Edskchg	equ	-14	Disk in drive was changed

Einvfn	equ	-32	Invalid function number
Efilnf	equ	-33	File not found
Epthnf	equ	-34	Pathname not found
Enhndl	equ	-35	No file handles left
Eaccdn	equ	-36	Access denied
Eihndl	equ	-37	Invalid handle number
Ensmem	equ	-39	Not enough memory left
Eimba	equ	-40	Invalid memory block address
Edrive	equ	-46	Invalid drive specification
Enmfil	equ	-49	No more matching files

Ebnam	equ	-52	Bad pathname element
Efaterr	equ	-53	Error with FAT table
Edskfull	equ	-54	Disk is full
Elpcl	equ	-55	Clusters looped
Erootful	equ	-56	Root directory is full
Edirex	equ	-57	Directory already exists
Elocked	equ	-58	Record is locked
Enslock	equ	-59	Can't find requested lock to remove
Eeof	equ	-60	End of file
Etime	equ	-61	Device timed out
Epermit	equ	-62	Permission violation
Enovol	equ	-63	No volume name, can't change attributes

Erange	equ	-64	Range error
Eintrn	equ	-65	Internal error
Eplfmt	equ	-66	Invalid program load format
Egsbf	equ	-67	Setblock failure

Eunknp	equ	-70	Unknown process
Edeadpr	equ	-71	ID is for dead process
Enochld	equ	-72	Process has no children
Etabfull	equ	-73	IO device table is full
Efmddne	equ	-74	File manager or device driver non-existant
Eprocnf	equ	-75	Process with this name not found
Eioqs	equ	-76	Process already part of this ioqueue chain
Eqnf	equ	-77	Queue not found (by name)
Eunknq	equ	-78	Unknown queue (by queue_id)
Eqinuse	equ	-79	Queue in use; can't delete
Eqempty	equ	-80	Queue has no message or count available
Eqexist	equ	-81	Can't create; queue w/ same name exists
Epipex	equ	-82	Can't create; pipe w/ same name exists
Epipenf	equ	-83	Named pipe not found for open
Epipewrt	equ	-84	Pipe write error: written data can't be read
Enodev	equ	-85	No device for given device number
Enomdev	equ	-86	No devices with given number or higher
Eorphan	equ	-87	Process is an orphan; it has no parent
Enosighand	equ	-88	Process has no signal handler installed

* Base page offsets

P_lowtpa	equ	0	Base address of the TPA
P_hitpa	equ	4	End of TPA+1
P_tbase	equ	8	Base address of text segment
P_tlen	equ	$C	Length of text segment
P_dbase	equ	$10	Base address of data segment
P_dlen	equ	$14	Length of data segment
P_bbase	equ	$18	Base address of BSS
P_blen	equ	$1C	Length of BSS
P_DTA	equ	$20	Points to programs DTA
P_parent	equ	$24	Points to parents base page
P_prgflags	equ	$28	Program flags from the file header 
P_env	equ	$2C	Pointer to environment string
P_fakeenv	equ	$68	If no env ptr, fake one is placed here
P_prgname	equ	$6c	Name of the program (ASCIIZ string)
P_neofix	equ	$7c	Pointer to caller's PC for p_exec #0 call
P_cmdlin	equ	$80	Start of command line

* File header format

H_flag	equ	0	Header type flag (601A)
H_tlen	equ	2	Length of text segment
H_dlen	equ	6	Length of data degment
H_blen	equ	$A	Length of BSS segment
H_slen	equ	$E	Length of symbol table
H_rsv1	equ	$12	Reserved 1
H_flags	equ	$16	Flags for altering loading conditions
H_nreloc	equ	$1A	Non zero if no relocation bytes
H_btext	equ	$1C	Beginning of text segment


* Process descriptor definitions

Num_files	equ	32	Number of open files per process

	RSRESET

PD_ID	rs.w	1	Process ID
PD_parent	rs.w	1	Parent's ID
PD_sibling	rs.w	1	Sibling's ID
PD_child	rs.w	1	First child's ID
PD_group	rs.w	1	Group ID
PD_user	rs.w	1	User ID
PD_priority	rs.w	1	Process priority
PD_age	rs.w	1	Process age
PD_status	rs.b	1	Process execution status
PD_queueID	rs.b	1	Current queue (sleep, wait or active)
PD_basepage	rs.l	1	First memory block of process (basepage)  
PD_max_mem	rs.l	1	Max mem size returned for Malloc #-1
PD_ucall	rs.w	1	Last user state function call executed
PD_scall	rs.w	1	Last system state function call executed
PD_uticks	rs.l	1	Number of user state ticks elapsed
PD_sticks	rs.l	1	Number of system state ticks elapsed
PD_sleep	rs.l	1	Count of ticks to remain sleeping
PD_datetime	rs.l	1	Date and time process started
PD_fcalls	rs.l	1	Number of function calls executed
PD_iocalls	rs.l	1	Number of i/o calls executed
PD_rbytes	rs.l	1	Number of bytes read
PD_wbytes	rs.l	1	Number of bytes written
PD_vector	rs.l	1	User defined vector
PD_dta	rs.l	1	Disk transfer address
PD_name	rs.b	14	Name of process
PD_devname	rs.b	8	Process current device name (currently only A, B, C, etc.)
PD_files	rs.w	Num_files	Process local path handles
PD_reentry	rs.b	1	Count of number of levels of reenterancy
PD_attrib	rs.b	1	Various attributes
PD_memblk	rs.w	1	Index of head of procs mdb's
PD_pqueue	rs.l	1	Previous process queue pointer
PD_nqueue	rs.l	1	Next process queue pointer
PD_pioq	rs.w	1	ID of previous process in i/o queue
PD_nioq	rs.w	1	ID of next process in i/o queue
PD_q_ptr	rs.l	1	Pointer or flag for queue functions
PD_intcpt	rs.l	1	Address of signal intercept routine
PD_intcptv	rs.l	1	Address of vars needed for intercept
PD_signal	rs.l	1	Signal code that caused death
PD_stack	rs.l	1	Process stack pointer
PD_reg_save	rs.l	1	Pointer to current (X)BIOS register save
PD_trap1	rs.l	1	Save area for "dirty" trap one vector
PD_macpath	rs.l	1	Pointer to a partial path to use
* See the Macro Path definitions further on. Set to zero if a macro is
* not being used, else is a pointer to the macro data structure.
PD_defdirs	rs.l	26	Default directory of up to 26 drives
* Dir's first cluster number, 0 for root. Copied from parent when created
* Most file managers that use this feature require only words; but a long
* is allocated because of the future possibility of an HCFS file manager.
PD_status2	rs.b	1	Place for new attributes to be stored
PD_reserve1	rs.b	1
PD_reserve2	rs.w	18	Space for additions in the future...
PD_stackbot	rs.b	1000	Process supervisor stack space
PD_sstack	equ	__RS	Top of process supervisor stack
	rs.b	162	Allow for 3 levels of reentrancy to (X)BIOS
PD_bios_sav	equ	__RS
PD_size	equ	__RS	Size of process descriptor

* Process descriptor block allocation size. First long is pointer to next
* block. Ten process descriptors per block allocated
PD_alloc	equ	4+PD_size*10

* Status flag bits (for PD_status)

Sys_state	equ	0	Executing in system state
Wake_sig	equ	1	Process has pending wakeup signal
Time_out	equ	2	Time slice has expired
Subtask	equ	3	Process is a subtask of parent
Pexec4	equ	4	Assign base memory to parent on exit
Condemn	equ	5	Process is condemned
Concurrent	equ	6	Task is running concurrently with parent
Deskthread	equ	7	Set if process is Desktop process or decendent

* Bit definitions for PD_attrib

B_redirect	equ	0	Have BIOS check for con redirection
N_redirect	equ	1	Make negative handles redirect
proc_trace	equ	3	If set, jump through trace vector on function call

* Status flag bits for PD_status2
s2_preempt	equ	0	Allow preemption when clear, even if process is in system state
s2_suspend	equ	1	Suspend process at next entry to user state

* Defined signals

S_kill	equ	0
S_wake	equ	1
S_abort	equ	2

* Queue ID codes (for PD_queueID)

Q_current	equ	0	No queue, currently running
Q_active	equ	1	Active process queue
Q_sleep	equ	2	Sleeping process queue
Q_wait	equ	3	Waiting process queue
Q_event	equ	4	Waiting for an event
Q_dead	equ	5	No queue, dead process

* The structure that is filled in when a p_procinf call is made
	RSRESET
pi_pid	rs.w	1	Process ID
pi_ppid	rs.w	1	Parent process ID
pi_sibling	rs.w	1	1st sibling's process ID
pi_child	rs.w	1	1st child's process ID
pi_gu	rs.l	1	Group.user ID
pi_priority	rs.w	1	Process priority
pi_age	rs.w	1	Process age
pi_status	rs.b	1	Process execution status
pi_queueID	rs.b	1	Current queue (sleep, wait or active)
pi_basepage	rs.l	1	First memory block of process (basepage)  
pi_max_mem	rs.l	1	Max mem size returned for Malloc #-1
pi_ucall	rs.w	1	Last user state function call executed
pi_scall	rs.w	1	Last system state function call executed
pi_ucpu	rs.l	1	Number of user state milliseconds used
pi_scpu	rs.l	1	Number of system state milliseconds used
pi_sleep	rs.l	1	Number of milliseconds left to sleep
pi_datetime	rs.l	1	Date and time process started
pi_fcalls	rs.l	1	Number of function calls executed
pi_iocalls	rs.l	1	Number of i/o calls executed
pi_rbytes	rs.l	1	Number of bytes read
pi_wbytes	rs.l	1	Number of bytes written
pi_vector	rs.l	1	User defined vector
pi_dta	rs.l	1	Disk transfer address
pi_name	rs.b	14	Name of process
pi_devname	rs.b	8	Process current device name
pi_totmem	rs.l	1	Total memory used by process
pi_stack	rs.l	1	Current process system stack

pi_size	equ	__RS	Total size of structure

************************************************************************
* I/O definitions
*
* Path descriptor definitions
sz_pt_opt	equ	40	Size of option vars (must be mul of 4)
	RSRESET
PT_descrip	rs.l	1	Points to device descriptor
PT_params	rs.l	1	Points to callers stacked parameters
PT_owner	rs.w	1	ID of current user (0 when done)
PT_lastusr	rs.w	1	Last user of path
PT_count	rs.b	1	# of local paths accessing this pd
PT_mode	rs.b	1	Mode of I/O (parameter from open call)
PT_flags	rs.b	1	Flags passed by OS (used by con routines)
PT_forfm	rs.b	1	Except bit 0, used by file manager
PT_opt	rs.b	sz_pt_opt	Optional file manager information
PT_size	equ	__RS

* bit definitions for PT_flags
PTF_ne	equ	1	If set, no echo
PTF_necntr	equ	2	If set, don't echo control codes
PTF_rawcnt	equ	4	If set, echo raw control codes
PTF_ncsq	equ	8	If set, ignor ^C, ^S or ^Q
PTF_ncntrl	equ	16	If set, ignor other control codes
PTF_stripcr	equ	32	If set, strip carriage rets & line feeds

* bit definitions for PT_forfm
d_io_bit	equ	0	If this bit is set, path is dio path

* Path block allocation size. First long is pointer to next block
* Twenty paths per block allocated
PT_alloc	equ	4+PT_size*20

* File manager information for SCF path descriptor
* These parameters may not be read or changed by the user
	RSSET	PT_opt
SC_link	rs.l	1	Link to next path using same device
SC_lastscan	rs.w	1	Last scan code (if required)
* These parameters may be read or set by the user
*SC_attribs	rs.b	1	Various attribute bits
SC_echo	rs.b	1	If set, echo input to output
SC_scan	rs.b	1	If set, return scan code
SC_send_lf	rs.b	1	If set, send lf after cr
SC_des_back	rs.b	1	If set, destructive backspace
SC_pause	rs.b	1	If set, pause at end of page
SC_eor	rs.b	1	Char recognized as end of record
SC_aeor	rs.b	1	Char recognized as alternate eor
SC_eof	rs.b	1	Char recognized as end of file
SC_backspc	rs.b	1	Char recognized as backspace
SC_clrl	rs.b	1	Char recognized as clear line
SC_rpl	rs.b	1	Char recognized as reprint line
SC_newl	rs.b	1	Char recognized as start new line
SC_dupl	rs.b	1	Char recognized as dup last line
SC_bell	rs.b	1	Char recognized as bell
SC_tab	rs.b	1	Char recognized as tab
SC_abort	rs.b	1	Char recognized as keyboard abort
SC_xon	rs.b	1	Char recognized as X-on
SC_xoff	rs.b	1	Char recognized as X-off
SC_tab_wid	rs.b	1	Width of tab field
SC_plength	rs.b	1	Lines per page
SC_timeout	rs.b	1	Number of seconds to wait for device

* Attribute bits for SC_attribs
*SC_echo	equ	0	If set, echo input to output
*SC_scan	equ	1	If set, return scan code
*SC_send_lf	equ	2	If set, send lf after cr
*SC_des_back	equ	3	If set, destructive backspace
*SC_pause	equ	4	If set, pause at end of page

* If SC_scan set, returns last scan code in SC_lastscan
* If SC_tab_wid = 0, let tabs pass through (default)
* SC_timeout is used on devices (like printers) that sould time out if
* no response is given in a certain period of time. This is set to the
* number of seconds (1 to 255) that the driver should wait for the
* device to respond. 0 means an indefinite wait.

*************************************************************************
* Following is information required by the system global variables section
*
* I/O device definition requirements
* When an I/O device is installed, pointers are created to its
* file manager and device driver jump tables and variables. When
* a path is created, a pointer to the device descriptor information
* is placed in the path descriptor.

	RSRESET
DD_name	rs.b	8	Name of the device
DD_fm_globl	rs.l	1	File manager var ptr (might not be used)
DD_fm_jump	rs.l	1	File manager jump table
DD_dr_globl	rs.l	1	Device driver var ptr (might not be used)
DD_dr_jump	rs.l	1	Device driver jump table
DD_type	rs.b	1	File manager type
* 0 = RBF, 1 = PIPE, 2 = SCF, 3 = NET, 4 = NULL
DD_share	rs.b	1	If set, device not sharable
DD_dev_vars	rs.b	40	Device vars required by file manager
DD_options	rs.b	sz_pt_opt	Variables for path descriptor
* The optional static vars are copied to the path descriptor when first
* linked to the device descriptor.
DD_size	equ	__RS
iodevs	equ	40	Max number of i/o devices in system

* When installing a file manager, three pointers and a word are passed.
* The first pointer is to the name of the file manager, the second to
* its jump table, and the third is its global var ptr (if required).
* The word is the file managers type.
	RSRESET
Mfm_name	rs.l	1	Points to name
Mfm_entry	rs.l	1	Points to jump table
Mfm_vars	rs.l	1	Points to any required ram storage
Mfm_type	rs.w	1	File manager type word
Mfm_size	equ	__RS

* When installing a device driver, three pointers are passed. The first
* pointer is to the name of the device driver, the second to its jump
* table, and the third is its global var ptr (if required).
	RSRESET
Mdd_name	rs.l	1	Points to name
Mdd_entry	rs.l	1	Points to jump table
Mdd_vars	rs.l	1	Points to any required ram storage
Mdd_size	equ	__RS

num_fms	equ	10	Max number of file managers
num_dds	equ	30	Max number of device drivers

* Offsets used to get pointers to name and jump table of fm or dd.
	RSRESET
offs_name	rs.w	1	Offset to name string
offs_jump	rs.w	1	Offset to jump table
* Next is only necessary for file managers
offs_fm	rs.w	1	Offset to fm type byte

* File manager routine offset definitions
	RSRESET
FM_create	rs.w	1	Create a file
FM_open	rs.w	1	Open an exisitng file
FM_close	rs.w	1	Close the file
FM_read	rs.w	1	Read from the file
FM_write	rs.w	1	Write to the file
FM_readln	rs.w	1	Read a line (generally CR terminated)
FM_status	rs.w	1	Get/set device/file status
FM_makedir	rs.w	1	Create a directory              (RBFM)
FM_deldir	rs.w	1	Delete a directory	        (RBFM)
FM_chngdir	rs.w	1	Change current dir of drive     (RBFM)
FM_getdir	rs.w	1	Get current dir of drive        (RBFM)
FM_chgatt	rs.w	1	Change attributes of file       (RBFM)
FM_rename	rs.w	1	Rename the file/folder          (RBFM)
FM_delete	rs.w	1	Delete the file/folder          (RBFM)
FM_seek	rs.w	1	Seek the file pointer           (RBFM)
FM_sfirst	rs.w	1	Search for filespec             (RBFM)
FM_snext	rs.w	1	Search for next filespec        (RBFM)
FM_gsdt	rs.w	1	Get/set date/time of file       (RBFM)
FM_dskfree	rs.w	1	Get free space on a disk        (RBFM)

* Opcodes used for status operations. These are all status operations that
* may be performed on open files. Not all file managers support all of the
* available operations.
	RSRESET
st_input	rs.b	1	Test for input data available
st_output	rs.b	1	Test for device output ready
st_size	rs.b	1	Get size of file
st_pos	rs.b	1	Get r/w pointer position
st_eof	rs.b	1	Test for end of file
st_rlock	rs.b	1	Change record lock attributes
st_extfile	rs.b	1	Extend the files length
st_readopt	rs.b	1	Read options section of path desc
st_wrtopt	rs.b	1	Write options section of path desc
st_name	rs.b	1	Copy name of open file to buffer
st_type	rs.b	1	Return the file manager type for the file

* File manager types
	RSRESET
fmtyp_rbf	rs.b	1	Random block (disk) file manager
fmtyp_pipe	rs.b	1	Pipe (interprocess)
fmtyp_scf	rs.b	1	Sequencial character
fmtyp_net	rs.b	1	Network
fmtyp_null	rs.b	1	The 'do nothing' file manager

* Queue directory structure.
	RSRESET
qd_name	rs.b	13	Name of the message queue (12 char + 0)
qd_type	rs.b	1	Type of queue
* 0=message queue 1=event queue, 2=data queue
qd_link	rs.w	1	Number of users linked to queue (0 if free)
qd_pid	rs.w	1	PID of first waiting process
qd_index	rs.w	1	Index to buffer, count for event queue
qd_size	equ	__RS
qd_alloc	equ	4+(qd_size*5) Size of allocation

* Message queue buffer definitions
	RSRESET
qb_next	rs.w	1	Index of next; -1 if free, 0 if end
qb_message	rs.l	4	Four longs make up actual message
* For data buffers, first long points to memory block, second long is
* length of block
qb_size	equ	__RS
qb_alloc	equ	4+(qb_size*10) Size of allocation

* Memory Definition Block structure
	RSRESET
mem_next	rs.w	1	Index of next MDB (in ascending order)
mem_prev	rs.w	1	Index of previous MDB
mem_start	rs.l	1	Start of memory block
mem_length	rs.l	1	Length of memory block
mem_owner	rs.w	1	PID of owner, 0 for system, -1 for free or -2 if was tsr memory
mem_link	rs.w	1	Index of next MDB owned by process or system
mem_size	equ	__RS
mem_blksiz	equ	4+(50*mem_size) Size of allocation block

* Macro path structure definition. These are used to create pseudo drives
* that represent other drives to the file system. For example, a macro,
* called G:, could be created to represent C:\FOLDER1\FOLDER2 to the
* file system. Then, when a path such as G:\FILENAME.EXT was used, the
* file system would actually use C:\FOLDER1\FOLDER2\FILENAME.EXT.
	RSRESET
mp_next	rs.l	1	Next macro path in chain, or 0 for end
mp_devname	rs.b	1	Device name of macro (e.g. G, P, Z)
mp_devnum	rs.b	1	Device number of macro (0, 1, 2)
mp_flag	rs.b	1	Flag: set to zero when created or changed
mp_reserved	rs.b	1
mp_rootdir	rs.l	1	Place for file manager to store root dir info
mp_realname	rs.b	8	Device name of real device
mp_path	rs.b	64	Path to use on real device
mp_size	equ	__RS

*
* The following are the variables that are used by the kernal. These variables
* are accessed off the A6 register, which is loaded with the start of the 
* table on entry. These are the global variables, but note that each 
* process has a table of variables associated with it.
*
	RSRESET

G_active	rs.l	1	Head of active queue
G_sleep	rs.l	1	Head of sleeping queue
G_wait	rs.l	1	Head of waiting queue
G_event	rs.l	1	Head of event queue
G_cur_pd	rs.l	1	Process descriptor of current process
G_totram	rs.l	1	Total ram found in system (TPA size)
G_bottpa	rs.l	1	Bottom of TPA
G_toptpa	rs.l	1	Top of TPA
G_maxtpa	rs.l	1	Maximum tpa size given to process
G_rsvmem	rs.l	1	High water mark of m_(s)alloc(-1) calls
G_rsvmaxbl	rs.l	1	Max block size returned in G_rsvmem area
G_mem_mdb	rs.l	1	Points to 1st block of memory descriptor blocks
G_hmem_st	rs.w	1	Index of head of memory segment list (ST ram)
G_tmem_st	rs.w	1	Index of tail of memory segment list
G_sys_mem	rs.w	1	Index of linked system memory blocks
G_memblks	rs.w	1	Number of free memory block descriptors
* Extra ram that may be added to the system is allways considered fastram.
* When a block is added for the first time, the index to the head and tail
* of the memory (the next two variables) are defined. If any more memory
* is added after this, it will be added in to the same structure. (If it
* is not contiguous with previous added ram, there will be a gap, but the
* memory allocate and free routines deal with this situation properly.)
G_hmem_alt	rs.w	1	Head of alternate (TT) memory
G_tmem_alt	rs.w	1	Obviously the tail of said memory
G_pd	rs.l	1	Points to 1st process descriptor block
G_pthd	rs.l	1	Points to 1st path descriptor block
G_queue_dir	rs.l	1	Points to 1st queue directory block
G_queue_buf	rs.l	1	Points to 1st queue buffer block
G_max_age	rs.w	1	Max age to age a process
G_min_pty	rs.w	1	Min priority of ageable process
G_timeslice	rs.w	1	Number of milliseconds per tick (20)
G_ticks	rs.w	1	Number of ticks per second (50)
G_timeout	rs.l	1	Global timeout added to 200 hz clock
G_idlecnt	rs.l	1	Used to keep track of idle time in 5 ms periods
G_idlecntdn	rs.w	1	Count till next increment
G_fastload	rs.l	1	Number of k of heap to clear on prg load
G_aes_stack	rs.l	1	Current aes stack top
G_term	rs.l	1	Vector to jump through on proc term
G_pexec	rs.l	1	Vector to jump through on proc create
G_trace	rs.l	1	Vector to jump through to trace a process' function calls
G_macropath	rs.l	1	Pointer to any drive/path replacements
G_pathcheck	rs.l	1	Vector to jump through before path parsing
* To allow PowerDOS to be expanded (or to emulate other OS's), a pointer
* to another table of vectors is available (zero when not used). The first
* long in this table is a pointer to another such table. The third word
* is the lowest sevice number in the table, and the fourth word is the
* highest service number. Following this is the long word pointers to
* the service functions. If a vector in this tables is not used (an unused
* function) it should be set to zero.
G_extservic	rs.l	1	Pointer to a table of extended services
G_p_run	rs.l	1	GemDOS p_run pointer; points to basepage
G_version	rs.w	1	Version number of GemDOS we are replacing
G_sysver	rs.w	1	Version of PowerDOS
G_sysdate	rs.l	1	Date of PowerDOS build (YYYYMMDD)
G_flags	rs.b	1	Various flags bits that may be needed
* Definitions for the bits in G_flags.
Gf_cookjar	equ	0	Set if PowerDOS installed the cookie jar
Gf_server	equ	1	Set if system is being used as a network server
G_reserve	rs.b	1
* When we launch a concurrent task, we give it clean OS vectors so no tsr
* programs will also be in the vectors. Such programs tend to fail when
* used in a multitasking environment. The following are the original
* vectors set when PowerDOS was installed.
G_trap1	rs.l	1	Vector for BDOS
G_trap13	rs.l	1	Vector for BIOS
G_trap14	rs.l	1	Vector for XBIOS
* The following is the special reserved block of memory used for video ram. Both
* its start address and index are given.
G_videomem	rs.l	1	Start address of special videomem block
G_videoidx	rs.w	1	Index of MDB of video memory

* The following are the non-public part of the system variables
G_service	rs.l	$c0	Space for 192 BDOS service routines
G_bservice	rs.w	1	Number of BIOS routines
	rs.l	20	Space for 20 BIOS service routines
G_xbservice	rs.w	1	Number of XBIOS routines
	rs.l	140	Space for 140 XBIOS service routines
	rs.b	1000	Space for aes/accessory super stack
G_stackaes	equ	__RS	Top of aes stack space
G_iodev	rs.b	DD_size*iodevs   Space for IO devices
G_fm	rs.b	Mfm_size*num_fms  Space for file manager links
G_drvr	rs.b	Mdd_size*num_dds  Space for device driver links
G_initmblk	rs.b	mem_blksiz*2 Initial memory definition blocks
G_initpth	rs.b	PT_alloc	Initial path block
G_initproc	rs.b	PD_alloc	Initial process descriptor block
G_initqdir	rs.b	qd_alloc	Initial queue directory block
G_initqbuf	rs.b	qb_alloc	Initial queue buffer block
G_size	equ	__RS

