*******************************************************************************
*
* Common equates for GS/OS
*
* Created:	4/7/87
* Modified:	See Revision History below
* Author:	GS/OS Team
*
* Copyright (C) 1987-1988 Apple Computer, Inc.	All rights reserved.
*
* REVISION HISTORY:
*
* DATE	   BY	DESCRIPTION
*
* 04/27/87 RBM	Correction: drvr_blk_size is a word wide parameter.
*
* 04/16/87 JJ	Correction: changed error number for duplicate volume
*			    from $55 to $57
* 04/29/87 GRT	Addition:   added definition of path flag
*			    and defined "span1" and "span2"
*
* 05/18/87 RBM	Addition:   Added "boot_slot", "dev_id_ref",
*			    "drvr_char_config" & "drvr_pro_config"
*			    These parameters are passed from the F_Loader
*			    to the device dispatcher during boot init.
*
* 06/04/87 JJ	Addition:   Add global equates for system direct page base,
*			    stack top, and ProDOS FST header.
*
* 06/11/87 JJ	Change:     Direct page locations used by SCM to pass
*			    parameters to FST's fundamentally changed. Look
*			    between labels dev_num and span2, inclusive.
*
* 06/30/87 RM/RC Addition:  Added cache manager equates.
*			    Cache priority now cache enable.
*
* 07/20/87 RM/AS Addition:  Equates for control/status list pointers.
*			    Equates for control/status codes.
*
* 07/22/87 RM/RC Change:    Cache enable now cache priority.
*
* 07/24/87 MSA	 Addition:  System Service Table Equates & FCR Equates
*
* 07/29/87 RC	 Addition:  Added cache header equates.
*
* 08/03/87 RC	 Addition:  Added 4 byte pointer in direct page
*
* 08/05/87 MSA	 Change:    System Service Table chgd to make GRT happy
*			    Added Parameter Block Equates
*
* 08/10/87 RC/RM Change:    Changed c_volumeid in cache equates into c_devnum.
*
* 08/12/87 FAB	 Addition:  Added gquit_stack_top
*
*	   MSA	 Addition:  Added pblk equate for Get Boot Volume
*			     Star prefix equate added
*
* 08/13/87 RBM	 Deletion:  Removed status and control codes for
*			    driver newline since it's not ported.
*
* 08/14/87 MSA	 Addition:  Added pblk equate for SetLevel, GetLevel
*
* 08/18/87 RBM	 Deletion:  Drvr_vol_id is now Drvr_reserved.
*
* 09/15/87 RBM	 Change:    Moved control/status code location on direct page
*
* 09/24/87 MSA	 Addition:  Added pblk equate for Close, Flush
*
* 10/02/87 ADS	 Deletion:  Removed pro_fst_entry
*
* 10/06/87 MSA	 Addition:  Added pblk equate for Expand_Path
*
* 10/29/87 MSA	 Addition:  Added debug call flag, debug.calls
*			     and debug.type for SCM
*
* 11/12/87 RBM	 Change:    Device dispatcher cmd numbers
*
* 11/13/87 MSA	 Addition:  GS/OS System Death Error Codes
*
* 11/15/87 RBM	 Addition:  Added 'DRVR_VOL_ID' on direct page.
*
* 11/17/87 RC	 Addition:  Added 'c_volumeid' to cache header
*
* 12/6/87  JJ	 Addition:  Added system call error codes $64, $65, and $66
*
* 1/5/88   fab	 addition:  move commands word for moveinfo system service call
*
* 1/5/88   RBM	 addition:  status and control codes.
*
* 1/13/88  fab	 addition:  movevaliditymask equate added
*
* 1/14/88  RBM	 change:    moved status/control code
*
* 1/14/88  BPA	 change:    made all equ's gequ's
*
* 1/15/88  fab	 replace:   move_block to move_info
*
* 1/19/88  rc	 addition:  default_cache_size
*
* 1/20/88  MSA	 addition:  system service table equates
*
* 1/23/88  RBM	 Addition:  System service table equates
*
* 2/08/88  RBM	 Addition:  driver busy error code ($0029)
*		 Addition:  Supervisory driver direct page equates
*
* 3/04/88  MSA	 Addition:  get, set boot_vol equates
*
*******************************************************************************

****************************************************************
*
* The following are direct page equates on the GS/OS
* direct page for driver usage.
*
****************************************************************

stack_top	equ	$00BFFF 	; initial value of system stack pointer
direct_base	equ	$00BD00 	; base address of system direct page
gquit_stack_top equ	$00BCFF 	; gquit sets stk here for boot/switching

drvr_start	equ	$0000		; start location of driver parameters
gs_start	equ	$0030		; start of GS/OS parameters
fst_start	equ	$0080		; start of FST parameters
cache_wspace	equ	$005A		; beginning addr of cache mgr w/space
drvr_wspace	equ	$006A		; ***** NUKE THIS LATER ****
sup_wspace	equ	$0070		; supervisory driver workspace

drvr_dev_num	equ	drvr_start	; (w)  device number
drvr_call_num	equ	drvr_dev_num+2	; (w)  call number
drvr_buf_ptr	equ	drvr_call_num+2 ; (lw) buffer pointer
drvr_slist_ptr	equ	drvr_call_num+2 ; (lw) buffer pointer
drvr_clist_ptr	equ	drvr_call_num+2 ; (lw) buffer pointer
boot_slot	equ	drvr_buf_ptr	; (w)  boot slot for dispatcher only
dev_id_ref	equ	drvr_buf_ptr	; (w)  indirect device ID
dev_char_config equ	drvr_buf_ptr+2	; (w)  BASIC/Pascal1.1 configuration
dev_pro_config	equ	drvr_buf_ptr+4	; (w)  ProDOS configuration
drvr_req_cnt	equ	drvr_buf_ptr+4	; (lw) request count
drvr_tran_cnt	equ	drvr_req_cnt+4	; (lw) transfer count
drvr_blk_num	equ	drvr_tran_cnt+4 ; (lw) block number
drvr_blk_size	equ	drvr_blk_num+4	; (w)  block size
drvr_fst_num	equ	drvr_blk_size+2 ; (w)  File System Translator Number
drvr_stat_code	equ	drvr_fst_num	; (b)  status code for status call
drvr_ctrl_code	equ	drvr_fst_num	; (b)  control code for control call
drvr_vol_id	equ	drvr_fst_num+2	; (w)  volume id
drvr_cache	equ	drvr_vol_id+2	; (w)  Cache Priority
drvr_cach_ptr	equ	drvr_cache+2	; (lw) pointer to cached block
drvr_dib_ptr	equ	drvr_cach_ptr+4 ; (lw) pointer to active DIB
drvr_dev_ptr	equ	drvr_dib_ptr+4	; (lw) pointer to device list

****************************************************************
*
* The following are equates for the DIB.
*
****************************************************************

link_ptr	equ	$0000		; (lw) pointer to next DIB
entry_ptr	equ	$0004		; (lw) pointer to driver
dev_char	equ	$0008		; (w) device characteristics
blk_cnt		equ	$000A		; (lw) number of blocks
dev_name	equ	$000E		; (32) count and ascii name
slot_num	equ	$002E		; (w) slot number
unit_num	equ	$0030		; (w) unit number
ver_num		equ	$0032		; (w) version number
dev_id_num	equ	$0034		; (w) device ID number
head_link	equ	$0036		; (w) backward device link
forward_link	equ	$0038		; (w) forward device link
reserved_1	equ	$003A		; (w) dib reserved field #1
reserved_2	equ	$003C		; (w) dib reserved field #2
dib_dev_num	equ	$003E		; (w) device number of this device

dib_specific	equ	$0040		;
afpn_session	equ	$0042
afpn_volname	equ	$0044
afpn_volID	equ	$0060
afpn_status	equ	$0062
first_free	equ	$0064

specific_size	equ	first_free-dib_specific

****************************************************************
*
* Cache Manager Direct Page
*
****************************************************************

cache_cur_ptr	equ	cache_wspace	; (lw) pointer to current cache cell
cache_nxt_ptr	equ	cache_cur_ptr+4 ; (lw) pointer to next cache cell
cache_pre_ptr	equ	cache_nxt_ptr+4 ; (lw) pointer to prev cache cell
cache_bkt_ptr	equ	cache_pre_ptr+4 ; (lw) pointer to bucket list

default_cache_size equ $0040		;16k is default cache size


****************************************************************
*
* Supervisory Driver Direct Page
*
****************************************************************

sup_drvr_ptr	equ	sup_wspace	; (lw) ptr to supervisor driver list
sib_ptr 	equ	sup_wspace+4	; (lw) ptr to SIB
sup_parm_ptr	equ	sib_ptr+4	; (lw) ptr to supervisor parameters

****************************************************************
*
* The following are absolute zero page equates for use by
* slot resident firmware based ProDOS block device drivers.
*
****************************************************************

pcmd		equ	$0042		; (b)  ProDOS device command
punit		equ	$0043		; (b)  ProDOS unit number
pbuffer 	equ	$0044		; (w)  ProDOS buffer address
pblock		equ	$0046		; (w)  ProDOS block number

****************************************************************
*
* The following are equates for driver command types.
*
****************************************************************

drvr_startup	equ	$0000		; driver startup command
drvr_open	equ	$0001		; driver open command
drvr_read	equ	$0002		; driver read command
drvr_write	equ	$0003		; driver write command
drvr_close	equ	$0004		; driver close command
drvr_status	equ	$0005		; driver status command
drvr_control	equ	$0006		; driver control command
drvr_flush	equ	$0007		; driver flush command
drvr_shutdn	equ	$0008		; driver shutdown command

****************************************************************
*
* The following are equates for dispatcher command types.
*
****************************************************************

dsptch_bootinit equ	$0000		; dispatcher boot init command
get_dib_ptr	equ	$0001		; return a drivers DIB pointer
dsptch_shutdn	equ	$0002		; dispatcher shutdown command

****************************************************************
*
* GS/OS Direct Page Equates
*
****************************************************************

call_number	equ	gs_start	; FST call number
param_blk_ptr	equ	call_number+2	; pointer to user's parameter block
dev_num 	equ	param_blk_ptr+4 ; device number from parameter block
dev1_num	equ	dev_num 	; alias name for dev_num
dev2_num	equ	dev1_num+2	; second device number
path1_ptr	equ	dev2_num+2	; ptr to 1st partial/entire pathname
fcr_ptr 	equ	path1_ptr	; pointer to file control record
path2_ptr	equ	path1_ptr+4	; ptr to 2nd partial/entire pathname
vcr_ptr 	equ	path2_ptr	; pointer to volume control record
path_flag	equ	path2_ptr+4	; flag for path information
*					;
*					; bit  14: 0 = pathname1 is null
*					;      14: 1 = pathname1 is non-null
*					;
*					;      06: 0 = pathname2 is null
*					;      06: 1 = pathname2 is non-null
*					;
span1		equ	path_flag+2	; largest distance between path1 term.
span2		equ	span1+2 	; maxdist. between seperators for path2

****************************************************************
*
* The following are equates for GS/OS error codes.
*
****************************************************************

no_error	equ	$00		; no error has occured
bad_system_call equ	$01		; bad system call number
invalid_pcount	equ	$04		; invalid parameter count
gsos_active	equ	$07		; gsos already active
dev_not_found	equ	$10		; device not found
invalid_dev_num equ	$11		; invalid device number
drvr_bad_req	equ	$20		; bad request or command
drvr_bad_code	equ	$21		; bad control or status code
drvr_bad_parm	equ	$22		; bad call parameter
drvr_not_open	equ	$23		; character device not open
drvr_prior_open equ	$24		; character device already open
irq_table_full	equ	$25		; interrupt table full
drvr_no_resrc	equ	$26		; resources not available
drvr_io_error	equ	$27		; I/O error
drvr_no_dev	equ	$28		; device not connected
drvr_busy	equ	$29		; driver is busy & not available
drvr_wr_prot	equ	$2B		; device is write protected
drvr_bad_count	equ	$2C		; invalid byte count
drvr_bad_block	equ	$2D		; invalid block number
drvr_disk_sw	equ	$2E		; disk has been switched
drvr_off_line	equ	$2F		; device off line / no media present
bad_path_syntax equ	$40		; invalid pathname syntax
invalid_ref_num equ	$43		; invalid reference number
path_not_found	equ	$44		; subdirectory does not exist
vol_not_found	equ	$45		; volume not found
file_not_found	equ	$46		;
dup_pathname	equ	$47		; create or rename with existing name
volume_full	equ	$48		;
vol_dir_full	equ	$49		; volume directory full
version_error	equ	$4A		;
bad_store_type	equ	$4B		; bad storage type
end_of_file	equ	$4C		;
out_of_range	equ	$4D		; position out of range
invalid_access	equ	$4E		; access not allowed
buff_too_small	equ	$4F		; buffer too small
file_busy	equ	$50		; file is already open
dir_error	equ	$51		; directory error
unknown_vol	equ	$52		; unknown volume type
parm_range_err	equ	$53		; parameter out of range
out_of_mem	equ	$54		; out of memory
dup_volume	equ	$57		; duplicate volume name
not_block_dev	equ	$58		; not a block device
invalid_level	equ	$59		; specified level outside legal range
damaged_bitmap	equ	$5A		; block number too large
bad_path_names	equ	$5B		; invalid pathnames for change_path
not_system_file equ	$5C		; not an executable file
os_unsupported	equ	$5D		; operating system not supported
stack_overflow	equ	$5F		; too many applications on stack
data_unavail	equ	$60		; data unavailable
end_of_dir	equ	$61		; end of directory has been reached
invalid_class	equ	$62		; invalid FST call class
res_not_found	equ	$63		; file does not contain req. resource
invalid_fst_id	equ	$64		; specified FST is not present in system
invalid_fst_op	equ	$65		; FST does not handle this type of call
fst_caution	equ	$66		; FST handled call, but result is weird
network_error	equ	$88

****************************************************************
*
* Fatal Errors:
*
****************************************************************

unclaimed_irq	equ	$01		; unclaimed interrupt
sd_scm_dealloc	equ	$02		; deallocation error
sd_scm_alloc	equ	$03		; allocation error
wrong_os_ver	equ	$11		; wrong operating system version

****************************************************************
*
* FST equates: to be removed when lou loader is working!!!!!!!!!
*
****************************************************************

char_fst_entry	equ	$095000 	;address of Character FST header


****************************************************************
*
* DRIVER Equates:
*
****************************************************************

drvr_dev_stat	equ	$0000		; device status code
drvr_ctrl_stat	equ	$0001		; return control parms
drvr_get_wait	equ	$0002		; return wait/no-wait mode
drvr_get_format equ	$0003		; get format options

drvr_reset	equ	$0000		; reset the device
drvr_format	equ	$0001		; physically format the device
drvr_eject	equ	$0002		; eject the media
drvr_set_ctrl	equ	$0003		; set control parms
drvr_set_wait	equ	$0004		; set wait/no-wait mode
drvr_set_format equ	$0005		; set format options
drvr_set_ptn	equ	$0006		; assign partition owner
drvr_insert	equ	$0007		; logical media insertion

****************************************************************
*
* System Service Table Equates:
*
****************************************************************

dev_dispatcher	equ	$01FC00 	;dev_dispatch
cache_find_blk	equ	$01FC04 	;cash_find
cache_add_blk	equ	$01FC08 	;cash_add
cache_init	equ	$01FC0C 	;cache initialization
cache_shutdn	equ	$01FC10 	;cash_shutdown
cache_del_blk	equ	$01FC14 	;cash_delete
cache_del_vol	equ	$01FC18 	;cash_del_vol
alloc_seg	equ	$01FC1C 	;alloc_zero
release_seg	equ	$01FC20 	;deallocate
alloc_vcr	equ	$01FC24 	;allocvcr
release_vcr	equ	$01FC28 	;releasevcr
alloc_fcr	equ	$01FC2C 	;allocfcr
release_fcr	equ	$01FC30 	;releasefcr
swap_out	equ	$01FC34 	;swapout
deref		equ	$01FC38 	;deref2
get_sys_gbuf	equ	$01FC3C 	;s_get_sys_gbuf
sys_exit	equ	$01FC40 	;s_sys_exit
sys_death	equ	$01FC44 	;s_sys_death
find_vcr	equ	$01FC48 	;findvcr
find_fcr	equ	$01FC4C 	;findfcr
set_sys_speed	equ	$01FC50 	; set system speed
cache_flsh_def	equ	$01FC54 	; flush deferred blocks from cache
rename_vcr	equ	$01FC58 	;renamevcr
rename_fcr	equ	$01FC5C 	;renamefcr
get_vcr 	equ	$01FC60 	;getvcr
get_fcr 	equ	$01FC64 	;getfcr
lock_mem	equ	$01FC68 	;lockmem
unlock_mem	equ	$01FC6C 	;unlockmem
move_info	equ	$01FC70 	;block move routines
cvt_0to1	equ	$01FC74 	;cvt0to1
cvt_1to0	equ	$01FC78 	;cvt1to0
replace_80	equ	$01FC7C 	;replace80
to_b0_core	equ	$01FC80 	;to_bank0_core
gen_dispatch	equ	$01FC84 	;g_dispatch
signal		equ	$01FC88 	;signal_event
get_sys_buf	equ	$01FC8C 	;get_b0_buf
set_disksw	equ	$01FC90 	;set_disk_sw
report_error	equ	$01FC94 	;s_report_error
mount_message	equ	$01FC98 	;s_mount_msg
full_error	equ	$01FC9C 	;s_full_error
report_fatal	equ	$01FCA0 	;s_report_fatal
sup_drvr_disp	equ	$01FCA4 	; supervisory dispatcher
install_driver	equ	$01FCA8 	; install device driver
get_boot_pfx	equ	$01FCAC 	;s_get_boot_vol
set_boot_pfx	equ	$01FCB0 	;s_set_boot_vol


****************************************************************
*
* Volume Control Record (VCR) Equates
*
****************************************************************

vcr_size	equ	18		;Currently 18 bytes in length

vcr_id		equ	$0000		;offset to volume ID
vcr_name	equ	vcr_id+2	;offset to volume name pointer
vcr_status	equ	vcr_name+4	;offset volume status
vcr_open_cnt	equ	vcr_status+2	;offset to number of open files on vol.
vcr_fst_id	equ	vcr_open_cnt+2	;offset to owner ID number
vcr_dev 	equ	vcr_fst_id+2	;offset to where volume was last seen
vcr_fst_ptr	equ	vcr_dev+2	;offset to where volume was last seen

vcr_swapped	equ	$4000		;FLAG:Volume is swapped out (1 = true)
vcr_swapped_in	equ	$BFFF		;FLAG:Volume is swapped in

vcr_wr_enable	equ	$2000		;FLAG:Volume has been seen write enabled
vcr_wr_unknown	equ	$DFFF		;FLAG:Volume has not been seen wrenbld

****************************************************************
*
* File Control Record Equates:
*
****************************************************************

fcr_ref_num	equ	$0000
fcr_path_name	equ	fcr_ref_num+2
fcr_fst_id	equ	fcr_path_name+4
fcr_vol_id	equ	fcr_fst_id+2
fcr_level	equ	fcr_vol_id+2
fcr_newline	equ	fcr_level+2
fcr_newline_len equ	fcr_newline+4
fcr_mask	equ	fcr_newline_len+2
fcr_access	equ	fcr_mask+2

;--------------------------------------------------------------------------
; cache header equates
;
; Copyright (c) 1987 Apple Computer Inc. All rights reserved.
; author: Ray (Rowdy Yates) Chiang
;--------------------------------------------------------------------------

c_lru_fwd	equ	$0000		;vp to	forward LRU vp link
c_lru_bwd	equ	c_lru_fwd+4	;vp to backward LRU vp link
c_bkt_fwd	equ	c_lru_bwd+4	;vp to	forward bucket vp link
c_bkt_bwd	equ	c_bkt_fwd+4	;vp to backward bucket vp link
c_blknum	equ	c_bkt_bwd+4	;block number  of cached block
c_blksize	equ	c_blknum+4	;block	 size  of cached block
c_fstnum	equ	c_blksize+2	;FST number    of cached block
c_volumeid	equ	c_fstnum+2	;volume id     of cached block
c_devnum	equ	c_volumeid+2	;device number of cached block
c_priority	equ	c_devnum+2	;cache priority
c_cellsize	equ	c_priority+2	;size of this cache cell
c_reserved	equ	c_cellsize+2	;reserved
c_headerlen	equ	c_reserved+4	;length of cache header
c_cached_data	equ	c_reserved+4	;offset to cached data block

;--------------------------------------------------------------------------
; general and miscellaneous equates
;--------------------------------------------------------------------------

ram_cache_size	equ	$0081		;battery ram location for this

star_pfx_num	equ	32		;Prefix #32 is the star prefix

sys_version	equ	$8200		;Unreleased Version 2.00
debug_calls	equ	$0001		;Turn on debugging calls
debug_type	equ	$0010		;Highest numbered type


****************************************************************
*
* Parameter Block Equates
*
****************************************************************

pblk_09_pfxnum	equ	$0000		;Set and Get Prefix
pblk_09_pname	equ	$0002

pblk_0E_pname1	equ	$0000		;Expand Path
pblk_0E_pname2	equ	$0004

pblk_14_refnum	equ	$0000		;Close and Flush

pblk_1a_level	equ	$0000		;Set and Get Level

pblk_28_pname	equ	$0000		;Get Boot Volume

pblk_2a_version equ	$0000		;Get Version Number


*****************************************************************
*
* Emulation mode stack pointer
*
*****************************************************************

emulstack	equ	$010100

*****************************************************************
*
* command word for the moveinfo routine
*
*****************************************************************

moveblkcmd	equ	$0800		;tell hardware to do block move option

; the movevaliditymask is a mask used to determine if a user's command word
;   is using any invalid (reserved bits or not).  this value changes as reserved
;   bits become active!!!!!!!

movevaliditymask equ	$f7f0		;invalid move if any of these bits =1

; most common command

move_sinc_dinc	equ	$05+moveblkcmd	;source incs - destination incs

; less common commands

move_sinc_ddec	equ	$09+moveblkcmd	;source incs - destination decs
move_sdec_dinc	equ	$06+moveblkcmd	;source decs - destination incs
move_sdec_ddec	equ	$0a+moveblkcmd	;source decs - destination decs

move_scon_dcon	equ	$00+moveblkcmd	;source constant - destination constant
move_sinc_dcon	equ	$01+moveblkcmd	;source incs - destination constant
move_sdec_dcon	equ	$02+moveblkcmd	;source decs - destination constant
move_scon_dinc	equ	$04+moveblkcmd	;source constant - destination incs
move_scon_ddec	equ	$08+moveblkcmd	;source constant - destination decs
