
;*****************************************************
;*
;*	RTM Interface Routines
;*
;*****************************************************

	cseg
	org 0

	jmp init		;RTM initialization
	jmp entry		;RTM entry point

sysdat		dw	0	;SYSDAT segment
supervisor	equ	offset $
		rw	2	;SUP entry point

		db	'COPYRIGHT (C) 1981,'
		db	' DIGITAL RESEARCH '
serial		db	'654321'

;====		===========================
init:		; RTM module Initialization
;====		===========================
	mov sysdat,ds			;save sysdat
	mov bx,offset supmod		;init supif
	mov si,offset supervisor
	mov ax,[bx]
	mov cs:[si],ax
	mov ax,2[bx]
	mov cs:2[si],ax
	mov bx,(offset dispatcher)	;init interrupt pdisp
	mov word ptr [bx],offset fdisp
	mov word ptr 2[bx],cs
	mov bx,(offset rtm_pdisp)	;init intermodule pdisp
	mov word ptr [bx],offset farpdisp
	mov word ptr 2[bx],cs
		;create tick and idle process
	mov bx,offset tickpd		;Tick
	mov ax,p_uda[bx]
	add ax,sysdat
	push es ! mov es,ax
	mov si,supervisor
	mov ax,cs:2[si]
	mov u_initcs,ax ! pop es
	mov bx,offset idlepd		;IDLE
	mov ax,p_uda[bx]
	add ax,sysdat
	push es ! mov es,ax
	mov si,supervisor
	mov ax,cs:2[si]
	mov u_initcs,ax ! pop es
	mov dx,bx ! call proc_creat
		;init is now a process and can run
		;concurrently with idle process
	retf

;*****************************************************
;*
;*	RTM Function Table
;*
;*****************************************************

function	dw	sysreset_entry	;0
		dw	poll_entry	;1
		dw	flag_wait_entry	;2
		dw	flag_set_entry	;3
		dw	makeq_entry	;4
		dw	openq_entry	;5
		dw	deleteq_entry	;6
		dw	readq_entry	;7
		dw	creadq_entry	;8-conditional readq
		dw	writeq_entry	;9
		dw	cwriteq_entry	;10-conditional writeq
		dw	delay_entry	;11
		dw	dispatch_entry	;12
		dw	terminate_entry	;13
		dw	creat_proc_entry;14
		dw	set_prior_entry	;15
		dw	pd_entry	;16-get PD address
		dw	abort_spec_entry;17-abort process
		dw	sleep_entry	;18
		dw	wakeup_entry	;19
		dw	findpdname_entry;20

;=====		=================
entry:		; RTM Entry Point
;=====		=================
	mov ch,0 ! shl cx,1 ! mov si,cx
	call cs:function[si]
rtm_ret:retf

;=====		===============
mpmif:		; MPM Interface
;=====		===============
	callf cs:dword ptr .supervisor ! ret

;======		================
xiosif:		; XIOS Interface
;======		================
	mov si,mod_entry
	callf dword ptr xiosmod[si] ! ret
