;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; 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
RdosDevice = 2
RdosShutDown = 3
RdosFile = 6
RdosCommand = 7
RdosSet = 8
RdosPath = 9
RdosDll = 10

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

device_header   STRUC

init_ip DW ?

device_header   ENDS

system_seg	STRUC

math_tss			DW ?

phys_free_pages		DD ?

free_phys_list		DD ?
free_dma_phys_list	DD ?
unused_phys_list	DD ?
phys_section		section_typ <>
gdt_section			section_typ <>

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 ?

tsc_tics            DD ?
tsc_rest            DW ?

apic_tics           DD ?
apic_rest           DW ?

; EDX   Linear address
; ECX   Pages
tlb_flush_proc      DD ?

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_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
	p_next			    DW ?
	p_prev			    DW ?
	p_prio			    DW ?
	p_lsb_tics		    DD ?
	p_msb_tics		    DD ?
	p_data			    DD ?
	p_tss_sel		    DW ?
	p_tss_data_sel	    DW ?
	p_387_sel		    DW ?
	p_thread_sel	    DW ?
	p_app_sel		    DW ?
	p_free_proc		    DD ?
	p_cr3			    DD ?
	p_error_code	    DW ?
	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_mailslot_sel      DW ?

    p_forecolor	        DB ?
    p_backcolor	        DB ?
    p_row			    DW ?
    p_col			    DW ?
	
	thread_name		    DB 32 DUP(?)

thread_seg	ENDS

proc_descr_seg  STRUC
    pd_proc_sel     DW ?
    pd_exit_code    DW ?
    pd_wait         DW ?
    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

tss_seg		STRUC
tss_back_link	DW ?,?
tss_esp0		DW ?,?
tss_ess0		DW ?,?
tss_esp1		DW ?,?
tss_ess1		DW ?,?
tss_esp2		DW ?,?
tss_ess2		DW ?,?
tss_cr3			DW ?,?
tss_eip			DW ?,?
tss_eflags		DW ?,?
tss_eax			DW ?,?
tss_ecx			DW ?,?
tss_edx			DW ?,?
tss_ebx			DW ?,?
tss_esp			DW ?,?
tss_ebp			DW ?,?
tss_esi			DW ?,?
tss_edi			DW ?,?
tss_es			DW ?,?
tss_cs			DW ?,?
tss_ss			DW ?,?
tss_ds			DW ?,?
tss_fs			DW ?,?
tss_gs			DW ?,?
tss_ldt			DW ?,?
tss_t			DW ?
tss_bitmap		DW ?
tss_dr0			DD ?
tss_dr1			DD ?
tss_dr2			DD ?
tss_dr3			DD ?
tss_dr7			DD ?
math_control	DW ?,?
math_status		DW ?,?
math_tag		DW ?,?
math_eip		DD ?
math_cs			DW ?
math_op			DB ?,?
math_data_offs	DD ?
math_data_sel	DW ?,?
math_st0		DT ?
math_st1		DT ?
math_st2		DT ?
math_st3		DT ?
math_st4		DT ?
math_st5		DT ?
math_st6		DT ?
math_st7		DT ?
math_prev_op	DB ?,?
tss_thread		DW ?
tss_error_code	DW ?
tss_res_space	DB 18 DUP(?)
tss_bitmap_space DW ?
tss_seg		ENDS
