⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pcmif.a86

📁 一个dos操作系统DRDOS的源码
💻 A86
📖 第 1 页 / 共 3 页
字号:
;				01= File Allocation Table
;				10= Directory
;				11= Data
;			AH/0	0 = Read, 1 = Write
;
;			AL	1 Retry the Operation
;			BP:SI	Device Header Control Block
;			DI	High Byte Undefined, Low Byte Error Code 
;
;	    On Exit:-	AL	0 = IGNORE Error
;				1 = RETRY the Operation
;				2 = TERMINATE using INT 23
;				3 = FAIL the current DOS function
;
	Public	do_int24
do_int24:
	cmp	error_flag,0		; Skip the critical error routine
	jz	di24_05			; if the handler is active
	mov	al,ERR_FAIL		; Then return the FAIL condition
	ret				; to the calling routine
di24_05:
	push ax ! push bp		; Save our Base Pointer and then the
	cli				; Disable Interupts

	mov	bp,es			; BP:SI points to dev header
	mov	es,current_psp		; Get the current PSP and USER Stack

	push	PSP_USERSS		; Save the Users Real SS and SP
	push	PSP_USERSP		; on the internal Stack
	push	retry_sp		; also the retry info
	push	retry_off
	push	remote_call
	push	machine_id

	mov	critical_sp,sp		; Internal Stack Pointer Offset

	inc	error_flag		; Entering Critical Error Handler
	dec	indos_flag		; I may be gone some time....
					; (an application error handler need
					; never return so tidy up first)

	mov	ss,PSP_USERSS		; Switch to the Users Stack
	mov	sp,PSP_USERSP

	int	24h			; Call the Critical Error Handler

	cld
	cli				; paranioa.....
	call	get_dseg		; Reload DS just in case someone at
					; A-T or Lotus cannot read

	push ds ! pop ss		; Swap back to the Internal stack
	mov	sp,critical_sp		; and process the returned info.

	pop	machine_id
	pop	remote_call
	pop	retry_off		; restore retry info
	pop	retry_sp
	mov	es,current_psp		; Restore the Users original SS and
	pop	PSP_USERSP		; SP registers from the Stack
	pop	PSP_USERSS

	pop bp ! pop bx			; Restore BP and original AX
	sti

	mov	error_flag,0
    inc indos_flag  

	cmp al,ERR_IGNORE ! jnz di24_10	; Check for IGNORE and force
	test bh,OK_IGNORE ! jnz di24_10 ; to become a FAIL if its an 
	mov	al,ERR_FAIL		; invalid response.

di24_10:
	cmp al,ERR_RETRY ! jnz di24_20	; Check for RETRY and force
	test bh,OK_RETRY ! jnz di24_20	; to become a FAIL if its an
	mov	al,ERR_FAIL		; invalid response.	

di24_20:
	cmp al,ERR_FAIL ! jnz di24_30	; Check for FAIL and force
	test bh,OK_FAIL ! jnz di24_30	; to become a ABORT if its an
	mov	al,ERR_ABORT		; invalid response.	

di24_30:
	cmp	al,ERR_ABORT		; Do not return if the ABORT option
	jz	di24_abort		; has been selected but execute
					; INT 23 directly
	cmp	al,ERR_FAIL		; All invalid reponses are converted
	ja	di24_abort		; to ABORT
di24_40:
	ret

di24_abort:				; Abort this Process
	mov	ax,current_psp		; check not root application because
	mov	es,ax			; it must not be terminated so force
	cmp	ax,PSP_PARENT		; Is this the root Process
	mov	al,ERR_FAIL		; convert the error to FAIL
	 je	di24_40			; if not we terminate
	mov	exit_type,TERM_ERROR	; Set the correct exit Type
	mov	ax,04C00h		; and return code.
	mov	int21AX,ax
	jmp	func4C			; Then terminate

eject
;
;	Get the PCMODE Emulator data Segment from the PD
;
	Public	get_dseg
get_dseg:
	mov	ds,pcmode_dseg		; get CS relative Data Segment
	test	pcmode_dseg,0FFFFh	; If Data Segment is zero then get
	jz	get_d10			; the Data segment address from
	ret				; the segment portion of INT 31
get_d10:
	mov	ds,word ptr .INT31_SEGMENT
	ret


;
;INVALID_FUNCTION is called when any unsupported function has been executed
;
	Public	invalid_function
invalid_function:
	mov	ax,ED_FUNCTION		; Mark as Invalid Function
	jmp	error_exit		; and Exit


eject
	Public	reload_registers
reload_registers:
;----------------
; This routine is called to reload the registers we expect to have correct
; at the start of a PCMODE function.
	push	ds
	lds	bp,int21regs_ptr
	mov	ax,ds:reg_AX[bp]
	mov	bx,ds:reg_BX[bp]
	mov	cx,ds:reg_CX[bp]
	mov	dx,ds:reg_DX[bp]
	mov	si,ds:reg_SI[bp]
	mov	di,ds:reg_DI[bp]
	les	bp,ds:dword ptr reg_BP[bp]
	pop	ds
	ret

PCMODE_DATA	DSEG	WORD

	extrn	retry_sp:word
	extrn	retry_off:word

	extrn	break_flag:byte
	extrn	current_psp:word
	extrn	current_dsk:byte
	extrn	dma_offset:word
	extrn	dma_segment:word
	extrn	error_flag:byte
	extrn	error_stack:word
	extrn	exit_type:byte
	extrn	int21regs_ptr:dword
	extrn	int21regs_off:word
	extrn	int21regs_seg:word
	extrn	prev_int21regs_ptr:dword
	extrn	prev_int21regs_off:word
	extrn	prev_int21regs_seg:word
	extrn	indos_flag:byte
	extrn	indos_stack:word
	extrn	LocalMachineID:word
	extrn	machine_id:word
	extrn	int21AX:word
	extrn	normal_stack:word
	extrn	owning_psp:word
	extrn	remote_call:word
if DOS5
	extrn	WindowsHandleCheck:byte
else
	extrn	win386_local_machine:dword
endif

if IDLE_DETECT
	extrn	active_cnt:word
	extrn	idle_max:word
	extrn	idle_flags:word
	extrn	idle_vec:dword
	extrn	int28_delay:word
	extrn	int28_reload:word
endif
	
	extrn	critical_sp:word
	extrn	internal_flag:byte
	extrn	int28_flag:byte

PCM_CODE	CSEG	BYTE
;
;	The following Function tables are forced onto a word boundary
;	because of the word alignment of the PCMODE_RODATE segment.
;	Only word based Read Only data is held in this segment.
;
	extrn	func00:near, func01:near, func02:near, func03:near
	extrn	func04:near, func05:near, func06:near, func07:near
	extrn	func08:near, func09:near, func0A:near, func0B:near
	extrn	func0C:near, func0D:near, func0E:near, func0F:near
	extrn	func10:near, func11:near, func12:near, func13:near
	extrn	func14:near, func15:near, func16:near, func17:near
	extrn	func19:near, func1A:near, func1B:near, func1C:near
	extrn	func1F:near, func21:near, func22:near, func23:near
	extrn	func24:near, func25:near, func26:near, func27:near
	extrn	func28:near, func29:near, func2A:near, func2B:near
	extrn	func2C:near, func2D:near, func2E:near, func2F:near
	extrn	func30:near, func31:near, func32:near, func33:near
	extrn	func34:near, func35:near, func36:near, func37:near
	extrn	func38:near, func39:near, func3A:near, func3B:near
	extrn	func3C:near, func3D:near, func3E:near, func3F:near
	extrn	func40:near, func41:near, func42:near, func43:near
	extrn	func44:near, func45:near, func46:near, func47:near
	extrn	func48:near, func49:near, func4A:near, func4B:near
	extrn	func4C:near, func4D:near, func4E:near, func4F:near
	extrn	func50:near, func51:near, func52:near, func53:near
	extrn	func54:near, func55:near, func56:near, func57:near
	extrn	func58:near, func59:near, func5A:near, func5B:near
	extrn	func5C:near, func5D:near, func5E:near, func5F:near
	extrn	func60:near, func62:near, func63:near, func65:near
	extrn	func66:near, func67:near, func68:near, func69:near
	extrn	func6C:near

PCM_RODATA	CSEG	WORD		
	Public	pcmode_ft, pcmode_ftl
pcmode_ft	rw	0
	dw	func00			; (00) Terminate Program
	dw	func01			; (01) Read Keyboard and Echo
	dw	func02			; (02) Display Character
	dw	func03			; (03) Auxilary Input
	dw	func04			; (04) Auxilary Output
	dw	func05			; (05) Print Character
	dw	func06			; (06) Direct Console I/O
	dw	func07			; (07) Direct Console Input
	dw	func08			; (08) Read Keyboard
	dw	func09			; (09) Display String
	dw	func0A			; (0A) Buffered Keyboard Input
	dw	func0B			; (0B) Check Keyboard Status
	dw	func0C			; (0C) Flush Buffer, Read Keyboard
	dw	func0D			; (0D) Reset Disk
	dw	func0E			; (0E) Select Disk
	dw	func0F			; (0F) Open File
	dw	func10			; (10) Close File
	dw	func11			; (11) Search for First
	dw	func12			; (12) Search for Next
	dw	func13			; (13) Delete File
	dw	func14			; (14) Sequential Read
	dw	func15			; (15) Sequential Write
	dw	func16			; (16) Create File
	dw	func17			; (17) Rename File
	dw	ms_zero_AL		; (18) Unused DOS function (AL = 0)
	dw	func19			; (19) Current Disk
	dw	func1A			; (1A) Set Disk Transfer Address
	dw	func1B			; (1B) *Get Default Drive Data
	dw	func1C 			; (1C) *Get Drive Data
	dw	ms_zero_AL		; (1D) Unused DOS function (AL = 0)
	dw	ms_zero_AL		; (1E) Unused DOS function (AL = 0)
	dw	func1F 			; (1F) Get Default DPB
	dw	ms_zero_AL		; (20) Unused DOS function (AL = 0)
	dw	func21			; (21) Random Read
	dw	func22			; (22) Random Write
	dw	func23			; (23) File Size
	dw	func24			; (24) Set Relative Record
	dw	func25			; (25) Set Interrupt Vector
	dw	func26			; (26) Duplicate PSP
	dw	func27			; (27) Random Block Read
	dw	func28			; (28) Random Block Write
	dw	func29			; (29) Parse File Name
	dw	func2A			; (2A) Get Date
	dw	func2B			; (2B) Set Date
	dw	func2C			; (2C) Get Time
	dw	func2D			; (2D) Set Time
	dw	func2E			; (2E) Set/Reset Verify Flag
	dw	func2F			; (2F) Get Disk Transfer Address
	dw	func30			; (30) Get Version Number
	dw	func31 			; (31) Keep Process
	dw	func32			; (32) Get DPB
	dw	func33			; (33) CONTROL-C Check
	dw	func34			; (34) Get the Indos Flag
	dw	func35			; (35) Get Interrupt Vector
	dw	func36			; (36) Get Disk Free Space
	dw	func37			; (37) Get/Set Switch Character
	dw	func38			; (38) Return Country Dependant Info
	dw	func39			; (39) Create Sub-directory
	dw	func3A			; (3A) Remove Sub-directory
	dw	func3B			; (3B) Change Sub-directory
	dw	func3C			; (3C) Create a File
	dw	func3D			; (3D) Open a File Handle
	dw	func3E			; (3E) Close a File Handle
	dw	func3F			; (3F) Read from a File/Device
	dw	func40			; (40) Write to a File/Device
	dw	func41			; (41) Delete a Directory Entry
	dw	func42			; (42) Move a File Pointer
	dw	func43			; (43) Change Attributes
	dw	func44			; (44) I/O Control
	dw	func45			; (45) Duplicate File Handle
	dw	func46			; (46) Force a Duplicate File Handle
	dw	func47			; (47) Return Text of Current Directory
	dw	func48			; (48) Allocate Memory
	dw	func49			; (49) Free Allocated Memory
	dw	func4A			; (4A) Modify Allocated Memory
	dw	func4B			; (4B) Load and Execute Program
	dw	func4C			; (4C) Terminate a Process
	dw	func4D			; (4D) Get Return Code
	dw	func4E			; (4E) Find Matching File
	dw	func4F			; (4F) Find Next Matching File
	dw	func50			; (50) Set Current PSP
	dw	func51			; (51) Get Current PSP
	dw	func52			; (52) *Get In Vars
	dw	func53			; (53) *Build DPB from BPB
	dw	func54			; (54) Return Verify State
	dw	func55			; (55) Create a New PSP
	dw	func56			; (56) Move a Directory Entry
	dw	func57			; (57) Get/Set File Date and Time
	dw	func58			; (58) Memory Allocation Strategy
	dw	func59			; (59) Get Extended Error
	dw	func5A			; (5A) Create Temporary File
	dw	func5B			; (5B) Create New File
	dw	func5C			; (5C) File Lock Control
	dw	func5D			; (5D) Internal DOS Function
	dw	func5E			; (5E) Control Local Machine Data
	dw	func5F			; (5F) Get Network Assignments
	dw	func60			; (60) Perform Name Processing
	dw	ms_zero_AL		; (61) ?? Parse Path (AL = 0)
	dw	func62			; (62) Get Current PSP
	dw	func63			; (63) Get Lead Byte Table
	dw	invalid_function	; (64) *Saves AL and Returns
	dw	func65			; (65) Get Extended Country Information
	dw	func66			; (66) Get/Set Global Code Page
	dw	func67			; (67) Set Handle Count
	dw	func68			; (68) Commit File
	dw	func69			; (69) Get Serial number
	dw	func68			; (6A) Commit File (again)
	dw	invalid_function	; (6B) Unknown DOS 4
	dw	func6C			; (6C) Extended Open/Create
pcmode_ftl	equ	(offset $ - offset pcmode_ft)/2
	;**************************
	;* Do Not Move This Entry *
	;**************************
	dw	ms_zero_AL		; Illegal Function Handler

	end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -