;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; RDOS operating system
; Copyright (C) 1988-2000, Leif Ekblad
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version. The only exception to this rule
; is for commercial usage in embedded systems. For information on
; usage in commercial embedded systems, contact embedded@rdos.net
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
;
; The author of this program may be contacted at leif@rdos.net
;
; SYSTEM.DEF
; System-wide structure & constant definitions
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;
; rom modules in RDOS
;

BootMemSign		EQU 675E4B72h
AllocMemSign	EQU 9AE58C5Dh

RdosSign EQU 5A1E75D4h

RdosKernel = 0
RdosFont = 1
RdosSimpleDevice = 2
RdosShutDown = 3
RdosOldFile = 6
RdosCommand = 7
RdosSet = 8
RdosPath = 9

RdosDosDevice = 16
RdosFile = 17

RdosDevice16 = 18
RdosDevice32 = 19

RdosEnd = 0E5E5h

adapter_typ	STRUC
adapter_base	DD ?
adapter_size	DD ?
adapter_crc		DW ?
adapter_typ	ENDS

rdos_header  STRUC

sign    DD ?
len     DD ?
typ     DW ?
crc     DW ?

rdos_header  ENDS

simple_device_header   STRUC

init_ip DW ?

simple_device_header   ENDS

dos_device_header   STRUC

dos_dev_size        DW ?
dos_dev_sel         DW ?
dos_dev_init_ip     DW ?
dos_dev_name_parm   DB ?

dos_device_header   ENDS

device16_header   STRUC

dev16_size          DD ?
dev16_code_size     DW ?
dev16_code_sel      DW ?
dev16_data_size     DW ?
dev16_data_sel      DW ?
dev16_init_ip       DW ?

device16_header   ENDS

device32_header   STRUC

dev32_size          DD ?
dev32_code_size     DD ?
dev32_code_sel      DW ?
dev32_data_size     DD ?
dev32_data_sel      DW ?
dev32_init_ip       DD ?

device32_header   ENDS

system_seg	STRUC

dummy_pad1          DW ?

phys_free_pages		DD ?

free_phys_list		DD ?
free_dma_phys_list	DD ?
unused_phys_list	DD ?

dummy_pad2          DW 4 DUP(?)

debug_list			DW ?

thread_arr			DW 256 DUP(?)

next_pid			DW ?

rom_shadow			DW ?
ram1_size			DD ?
ram2_base			DD ?
ram2_size			DD ?
rom1_base			DD ?
rom1_size			DD ?
rom2_base			DD ?
rom2_size			DD ?

alloc_base			DD ?

rom_modules			DW ?
rom_adapters		DD 16 DUP(?,?,?)

check_point			DW ?

cpu_type            DB ?
cpu_vendor          DB 13 DUP(?)
cpu_feature_flags   DD ?
max_cpuid           DD ?

last_time           DD ?,?
time_drift          DD ?

debug_thread        DW ?

flat_base           DD ?

sys_tsc_tics        DD ?
sys_tsc_rest        DW ?

phys_spinlock		spinlock_typ <>
gdt_section			section_typ <>

enter_patch_proc    DW ?
leave_patch_proc    DW ?

patch_spinlock      DW ?
shut_spinlock       DW ?

patch_section		section_typ <>

system_size			DB ?

system_seg	ENDS

app_seg	STRUC

app_next			        DW ?

app_get_cmd_line_proc	    DD ?
app_get_exe_proc		    DD ?
app_get_env_proc		    DD ?
app_set_options_proc        DD ?
app_get_options_proc        DD ?
app_allocate_mem_proc	    DD ?
app_free_mem_proc		    DD ?
app_debug_allocate_mem_proc	DD ?
app_debug_free_mem_proc		DD ?
app_init_thread_proc	    DD ?
app_free_thread_proc	    DD ?
app_spawn_proc			    DD ?
app_clone_proc	            DD ?
app_close_proc			    DD ?
app_load_dll_proc           DD ?
app_loader_name			    DD ?

app_exit_code			    DW ?
app_fork_id                 DW ?

app_handle                  DW ?
app_mod_sel                 DW ?
app_lib_section             section_typ <>

app_env                     DD ?
app_name                    DD ?
app_cmd_line                DD ?
app_options                 DD ?
app_mem_blocks              DW ?

app_vm_psp_seg		        DW ?
app_pm_psp_sel		        DW ?
app_vm_mem_strat	        DW ?
app_vm_dta_seg		        DW ?
app_pm_dta_sel		        DW ?
app_dta_offset		        DD ?
app_psp_mode		        DB ?
app_dta_mode		        DB ?
app_find_sel		        DW ?

app_ldt_section		        section_typ <>
app_ldt_data_sel	        DW ?
app_ldt_free		        DW ?
app_ldt_sel			        DW ?
app_parent_ldt		        DW ?

app_context			        DW ?
app_bitness			        DB ?
app_key                     DB ?

app_pm_int			        DD 100h DUP(?,?)
app_pm_exc			        DD 20h DUP(?,?)

app_exe_name                DB 100h DUP(?)

app_seg	ENDS

block_seg	STRUC
	b_next			DW ?
	b_prev			DW ?
block_seg	ENDS


THREAD_FLAG_CREATE  = 1
THREAD_FLAG_BP      = 2
THREAD_FLAG_SUSPEND = 4

thread_seg	STRUC

; this should be first (TSS)

p_tss_back_link	    DD ?
p_tss_esp0		    DD ?
p_tss_ess0		    DW ?,?
p_tss_esp1		    DD ?
p_tss_ess1		    DW ?,?
p_tss_esp2		    DD ?
p_tss_ess2		    DW ?,?
p_tss_cr3			DD ?
p_tss_eip			DD ?
p_tss_eflags		DD ?
p_tss_eax			DD ?
p_tss_ecx			DD ?
p_tss_edx			DD ?
p_tss_ebx			DD ?
p_tss_esp			DD ?
p_tss_ebp			DD ?
p_tss_esi			DD ?
p_tss_edi			DD ?
p_tss_es			DW ?,?
p_tss_cs			DW ?,?
p_tss_ss			DW ?,?
p_tss_ds			DW ?,?
p_tss_fs			DW ?,?
p_tss_gs			DW ?,?
p_tss_ldt			DW ?,?
p_tss_t			    DW ?
p_tss_bitmap		DW ?

p_tss_dr0			DD ?
p_tss_dr1			DD ?
p_tss_dr2			DD ?
p_tss_dr3			DD ?
p_tss_dr7			DD ?
p_math_control	    DW ?,?
p_math_status		DW ?,?
p_math_tag		    DW ?,?
p_math_eip		    DD ?
p_math_cs			DW ?
p_math_op			DB ?,?
p_math_data_offs	DD ?
p_math_data_sel	    DW ?,?
p_math_st0		    DT ?
p_math_st1		    DT ?
p_math_st2		    DT ?
p_math_st3		    DT ?
p_math_st4		    DT ?
p_math_st5		    DT ?
p_math_st6		    DT ?
p_math_st7		    DT ?
p_math_prev_op	    DB ?,?

p_tss_end           DW ?

p_next			    DW ?
p_prev			    DW ?
p_prio			    DW ?
p_lsb_tics		    DD ?
p_msb_tics		    DD ?
p_data			    DD ?
p_thread_sel	    DW ?
p_tss_sel           DW ?
p_app_sel		    DW ?
p_cli_spinlock      DW ?
p_sti_spinlock      DW ?
p_free_proc		    DD ?
p_cr3			    DD ?
p_vm_deb_sel	    DW ?
p_vm_deb_offs	    DD ?
p_pm_deb_sel	    DW ?
p_pm_deb_offs	    DD ?
p_id			    DW ?
p_flags             DW ?
p_events		    DW ?
p_process_sel	    DW ?
p_ldt_sel		    DW ?
p_signal		    DB ?
p_parent_switch	    DB ?
p_lib_sel		    DW ?
p_stack_sel		    DW ?
p_sleep_sel		    DW ?
p_sleep_offset	    DD ?
p_wait_list		    DW ?
p_kill			    DB ?
p_is_waiting	    DB ?
p_ref_count		    DW ?

p_int_locked_stack	DW ? 
p_int_prot16_stack	DW ?
p_int_prot32_stack	DW ?
p_int_real_stack	DD ?

p_fault_vector      DB ?
p_fault_space       DB ?
p_fault_code        DD ?

p_mailslot_sel      DW ?

p_forecolor	        DB ?
p_backcolor	        DB ?
p_row			    DW ?
p_col			    DW ?

p_debug_proc        DD ?
p_debug_event       DW ?
    
thread_name		    DB 32 DUP(?)

; this should be last!

p_tss_io_bitmap     DW 40h DUP(?)

thread_seg	ENDS

proc_descr_seg  STRUC

pd_proc_sel     DW ?
pd_exit_code    DW ?
pd_wait         DW ?
pd_dr0          DD ?
pd_dr1          DD ?
pd_dr2          DD ?
pd_dr3          DD ?
pd_dr7          DD ?
pd_ref_count    DB ?
pd_section		section_typ <>    

proc_descr_seg  ENDS

process_seg	STRUC

ms_virt_flags	DW ?
ms_wait_sti		DW ?
ms_cli_thread	DW ?
ms_thread_count	DW ?
ms_pd_sel       DW ?

process_seg	ENDS

core_tss_seg		STRUC

c_tss_back_link	    DD ?
c_tss_esp0		    DD ?
c_tss_ess0		    DW ?,?
c_tss_esp1		    DD ?
c_tss_ess1		    DW ?,?
c_tss_esp2		    DD ?
c_tss_ess2		    DW ?,?
c_tss_cr3			DD ?
c_tss_eip			DD ?
c_tss_eflags		DD ?
c_tss_eax			DD ?
c_tss_ecx			DD ?
c_tss_edx			DD ?
c_tss_ebx			DD ?
c_tss_esp			DD ?
c_tss_ebp			DD ?
c_tss_esi			DD ?
c_tss_edi			DD ?
c_tss_es			DW ?,?
c_tss_cs			DW ?,?
c_tss_ss			DW ?,?
c_tss_ds			DW ?,?
c_tss_fs			DW ?,?
c_tss_gs			DW ?,?
c_tss_ldt			DW ?,?
c_tss_t			    DW ?
c_tss_bitmap		DW ?

c_tss_io_bitmap     DW 40h DUP(?)

c_tss_bitmap_space  DW ?

core_tss_seg		ENDS
