📄 init.asm
字号:
; File : $Workfile$
;
; Description :
;
; Original Author : DIGITAL RESEARCH
;
; Last Edited By : $CALDERA$
;
;-----------------------------------------------------------------------;
; Copyright Work of Caldera, Inc. All Rights Reserved.
;
; THIS WORK IS A COPYRIGHT WORK AND CONTAINS CONFIDENTIAL,
; PROPRIETARY AND TRADE SECRET INFORMATION OF CALDERA, INC.
; ACCESS TO THIS WORK IS RESTRICTED TO (I) CALDERA, INC. EMPLOYEES
; WHO HAVE A NEED TO KNOW TO PERFORM TASKS WITHIN THE SCOPE OF
; THEIR ASSIGNMENTS AND (II) ENTITIES OTHER THAN CALDERA, INC. WHO
; HAVE ACCEPTED THE CALDERA OPENDOS SOURCE LICENSE OR OTHER CALDERA LICENSE
; AGREEMENTS. EXCEPT UNDER THE EXPRESS TERMS OF THE CALDERA LICENSE
; AGREEMENT NO PART OF THIS WORK MAY BE USED, PRACTICED, PERFORMED,
; COPIED, DISTRIBUTED, REVISED, MODIFIED, TRANSLATED, ABRIDGED,
; CONDENSED, EXPANDED, COLLECTED, COMPILED, LINKED, RECAST,
; TRANSFORMED OR ADAPTED WITHOUT THE PRIOR WRITTEN CONSENT OF
; CALDERA, INC. ANY USE OR EXPLOITATION OF THIS WORK WITHOUT
; AUTHORIZATION COULD SUBJECT THE PERPETRATOR TO CRIMINAL AND
; CIVIL LIABILITY.
;-----------------------------------------------------------------------;
;
; *** Current Edit History ***
; *** End of Current Edit History ***
;
; $Log$
; INIT.ASM 1.25 93/12/07 15:51:27
; Move int13pointer to offset 0B4h as some app expects it there
; INIT.ASM 1.24 93/11/18 18:57:20
; Increase amount reserved for COMMAND.COM by 256 bytes
; INIT.ASM 1.23 93/11/17 19:29:26
; Change default DEBLOCK seg to FFFF for performance reasons
; INIT.ASM 1.19 93/07/22 19:43:59
; switch over to REQUEST.EQU
; ENDLOG
include BIOSGRPS.EQU
include DRMACROS.EQU
include IBMROS.EQU
include MSDOS.EQU
include REQUEST.EQU ; request header equates
include BPB.EQU
include UDSC.EQU
include DRIVER.EQU
; IBM AT Hardware equates
COMPRESSED equ TRUE ; enables compressed changes.
; a little macro to help locate things
; it warns us when the ORG get trampled on
orgabs MACRO address
local was,is
was = offset $
org address
is = offset $
if was GT is
if2
%OUT ERROR - absolute data overwritten !! moving it
endif
org was
endif
ENDM
jmpfar MACRO address, fixup
db 0EAh ; jmpf opcode
dw CG:address ; offset of destination
fixup dw 0EDCh ; segment of destination
ENDM
callfar MACRO address, fixup
db 09Ah ; callf opcode
dw CG:address ; offset of destination
fixup dw 0EDCh ; segment of destination
ENDM
F5KEY equ 3F00h
F8KEY equ 4200h
IVECT segment at 0000h
org 0000h*4
i0off dw ?
i0seg dw ?
org 0001h*4
i1off dw ?
i1seg dw ?
org 0003h*4
i3off dw ?
i3seg dw ?
org 0004h*4
i4off dw ?
i4seg dw ?
org 0015h*4
i15off dw ?
i15seg dw ?
org 0019h*4
i19off dw ?
i19seg dw ?
org 001Eh*4
i1Eptr label dword
i1Eoff dw ?
i1Eseg dw ?
org 002Fh*4
i2Fptr label dword
i2Foff dw ?
i2Fseg dw ?
org 006Ch*4
i6Cptr label dword
i6Coff dw ?
i6Cseg dw ?
IVECT ends
CGROUP group CODE, RCODE, ICODE
CG equ offset CGROUP
CODE segment 'CODE'
Assume CS:CGROUP, DS:Nothing, ES:Nothing, SS:Nothing
public strat
extrn ConsoleTable:word
extrn ClockTable:word
extrn SerParCommonTable:word
extrn DiskTable:near
extrn Int13Deblock:near
extrn Int13Unsure:near
extrn Int2FHandler:near
extrn ResumeHandler:near
extrn biosinit_end:byte ; End of the BIOS Init Code and Data
extrn biosinit:near
extrn boot_options:word
extrn rcode_fixups:word
extrn rcode_seg:word
extrn rcode_offset:word
extrn rcode_len:word
extrn icode_len:word
extrn current_dos:word
extrn device_root:dword
extrn mem_size:word
extrn ext_mem_size:word
extrn init_buf:byte
extrn init_drv:byte
extrn init_runit:byte
extrn comspec_drv:byte
extrn init_flags:word
include biosmsgs.def ; Include TFT Header File
Public A20Enable
A20Enable proc near
;========
; This location is fixed up at run time to be a RET
; If the BIOS is relocated to the HMA then it is fixed up again to be
; CALLF IBMDOS:A20Enable; RET
; Calling this location at run time will ensure that the HMA is mapped
; in so we can access the HMA code.
;
A20Enable endp
init proc near ; this is at BIOSCODE:0000h
ifndef COPYPROT
jmp init0 ; jump to reusable init space
else
extrn protect:near ; Jump to Copy protection code
jmp protect ; which will return control to
endif ; INIT0 on completion
init endp
compflg label word
ifdef COPYPROT
dw ' ' ; stops any compression working
else
dw offset CGROUP:INITDATA ; compresses from INITDATA onwards
endif ; this word set to 0 when compressed
orgabs 06h
db 'COMPAQCompatible'
dw offset CGROUP:RCODE ; lets find offset of RCODE
MemFixup dw 0 ; and its relocated segment
Public cleanup
cleanup PROC far ; BIOSINIT will call here later
ret
cleanup endp
; Local single character buffer for Ctrl-Break handling
public serparFlag, serparChar
serparFlag db 4 dup (FALSE) ; we haven't got any yet
serparChar db 4 dup (?) ; will store one character
; Device driver headers for serial/parallel devices
con_drvr dw CG:aux_drvr, 0 ; link to next device driver
dw DA_CHARDEV+DA_SPECIAL+DA_ISCOT+DA_ISCIN+DA_IOCTL
dw CG:strat, CG:IntCon
db 'CON '
aux_drvr dw CG:prn_drvr, 0 ; link to next device driver
dw DA_CHARDEV
dw CG:strat, CG:IntCOM1
db 'AUX '
prn_drvr dw CG:clock_drvr, 0 ; link to next device driver
dw DA_CHARDEV
dw CG:strat, CG:IntLPT1
db 'PRN '
clock_drvr dw disk_drvr, 0 ; link to next device driver
dw DA_CHARDEV+DA_ISCLK
dw CG:strat, CG:IntClock
db 'CLOCK$ '
com1_drvr dw CG:lpt1_drvr, 0 ; link to next device driver
dw DA_CHARDEV
dw CG:strat, CG:IntCOM1
db 'COM1 '
com2_drvr dw CG:com3_drvr, 0 ; link to next device driver
dw DA_CHARDEV
dw CG:strat, CG:IntCOM2
db 'COM2 '
com3_drvr dw CG:com4_drvr, 0 ; link to next device driver
dw DA_CHARDEV
dw CG:strat, CG:IntCOM3
db 'COM3 '
IFDEF EMBEDDED
extrn rdisk_drvr:near
com4_drvr dw CG:rdisk_drvr, 0 ; link to next device driver
ELSE
com4_drvr dw -1, -1 ; link to next device driver
ENDIF
dw DA_CHARDEV
dw CG:strat, CG:IntCOM4
db 'COM4 '
orgabs 0b4h ; save address at fixed location
; for dirty apps
Public i13pointer, i13off_save, i13seg_save
i13pointer label dword ; address of ROS Int 13h entry
i13off_save dw ?
i13seg_save dw ?
orgabs 0b8h ; REQ_HDR
public req_ptr, req_off, req_seg
req_ptr label dword
req_off dw 0 ;** fixed location **
req_seg dw 0 ;** fixed location **
strat proc far
mov cs:req_off,bx
mov cs:req_seg,es
ret
strat endp
lpt1_drvr dw CG:lpt2_drvr, 0 ; link to next device driver
dw DA_CHARDEV
dw CG:strat, CG:IntLPT1
db 'LPT1 '
lpt2_drvr dw CG:lpt3_drvr, 0 ; link to next device driver
dw DA_CHARDEV
dw CG:strat, CG:IntLPT2
db 'LPT2 '
lpt3_drvr dw CG:com2_drvr, 0 ; link to next device driver
dw DA_CHARDEV
dw CG:strat, CG:IntLPT3
db 'LPT3 '
orgabs 100h ; save vectors at fixed location
; for dirty apps
Public orgInt13
NUM_SAVED_VECS equ 5
vecSave db 10h
dw 0,0
db 13h
orgInt13 dw 0,0
db 15h
dw 0,0
db 19h
dw 0,0
db 1Bh
dw 0,0
Int19Trap:
cld
cli ; be sure...
push cs
pop ds
lea si,vecSave
mov cx,NUM_SAVED_VECS ; restore this many vectors
Int19Trap10:
xor ax,ax ; zero AH for lodsb
mov es,ax ; ES -> interrupt vectors
lodsb ; AX = vector to restore
shl ax,1
shl ax,1 ; point at address
xchg ax,di ; ES:DI -> location to restore
movsw
movsw ; restore this vector
loop Int19Trap10 ; go and do another
int 19h ; and go to original int 19...
orgabs 16ch ; PRN:/AUX: the device number
devno db 0,0 ;** fixed location **
Public NumDiskUnits, DeblockSeg
disk_drvr dw CG:com1_drvr, 0 ; link to next driver
dw DA_NONIBM+DA_GETSET+DA_REMOVE+DA_BIGDRV
dw CG:strat, CG:IntDisk
NumDiskUnits db 5, 7 dup (?)
dw 0EDCh ; checked by DRIVER.SYS
dw 0 ; was allocate UDSC
DeblockSeg dw 0A000h ; segment we start deblocking
IntLPT1: ; LPT1
call DeviceDriver
dw 0
IntLPT2: ; LPT2
call DeviceDriver
dw 1
IntLPT3: ; LPT3
call DeviceDriver
dw 2
IntCOM1: ; AUX = COM1
call DeviceDriver
dw 3
IntCOM2: ; COM2
call DeviceDriver
dw 4
IntCOM3: ; COM3
call DeviceDriver
dw 5
IntCOM4: ; COM4
call DeviceDriver
dw 6
IntCon:
call DeviceDriver
dw offset CGROUP:ConsoleTable
IntClock:
call DeviceDriver
dw offset CGROUP:ClockTable
Public IntDiskTable
IntDisk:
call DeviceDriver
IntDiskTable:
dw offset CGROUP:DiskTable
DeviceDriver proc near
call A20Enable ; make sure A20 is on
jmpfar DriverFunction, DriverFunctionFixup
DeviceDriver endp
extrn i13_AX:word
Public Int13Trap
Int13Trap proc far
;--------
; The Int 13 code is in low memory for speed, with unusual conditions
; having the overhead of A20Enable calls
;
cmp ah,ROS_FORMAT ; ROS format function?
je Int13TrapFormat
Int13Trap10:
mov cs:i13_AX,ax ; save Op/Count in case of error
clc
pushf ; fake an Int
call cs:i13pointer ; call the ROM BIOS
jc Int13Trap20 ; check for error
ret 2 ; none, so return to caller
Int13Trap20:
cmp ah,9 ; it it a DMA error ?
je Int13TrapDMA ; then deblock it
call Int13TrapUnsure ; else declare floppy drive unsure
stc ; restore error flag
ret 2 ; return to user
Int13TrapFormat:
call Int13TrapUnsure ; mark media as unsure
jmps Int13Trap10 ; and resume
Int13TrapDMA:
call A20Enable ; make sure A20 is on
jmpfar Int13Deblock, Int13DeblockFixup
Int13TrapUnsure proc near
call A20Enable ; make sure A20 is on
callfar Int13Unsure, Int13UnsureFixup
ret
Int13TrapUnsure endp
Int13Trap endp
Public Int2FTrap
Int2FTrap proc far
;--------
jmpfar Int2FHandler, Int2FFixup
Int2FTrap endp
Resume proc far
;-----
call A20Enable ; make sure A20 is on
jmpfar ResumeHandler, ResumeFixup
Resume endp
Int0Trap proc far
;-------
call A20Enable ; make sure A20 is on
jmpfar Int0Handler, Int0Fixup
Int0Trap endp
Public FastConsole
FastConsole proc far
;----------
; RAM entry to ensure INT29 vector is below INT20 vector
; We keep the normal path low to maxmimise performance, but on backspace we
; take the A20Enable hit and call high for greater TPA.
;
pushx <ax, bx, si, di, bp> ; old ROS corrupts these
cmp al,8 ; back space character
je Fastcon30 ; special case
Fastcon10:
mov ah,0Eh ; use ROS TTY-like output function
mov bx,7 ; use the normal attribute
int VIDEO_INT ; output the character in AL
Fastcon20:
popx <bp, di, si, bx, ax>
iret
Fastcon30:
call A20Enable ; make sure A20 is on
jmpfar OutputBS, OutputBSFixup ; call up to the HMA
FastConsole endp
Public ControlBreak
ControlBreak proc far
;-----------
mov cs:word ptr local_char,'C'-40h + (256*TRUE)
;; mov local_char,'C'-40h ; force ^C into local buffer
;; mov local_flag,TRUE ; indicate buffer not empty
Int1Trap:
Int3Trap:
Int4Trap:
iret
ControlBreak endp
public daycount
daycount dw 0
; More Disk Data
public local_buffer,local_id,local_pt
local_buffer db 512 dup (?) ; local deblocking buffer
SECSIZE equ 512
IDOFF equ SECSIZE-2 ; last word in boot sector is ID
PTOFF equ IDOFF-40h ; 4*16 bytes for partition def's
local_id equ word ptr local_buffer + IDOFF
local_pt equ word ptr local_buffer + PTOFF
public bpbs,bpb160,bpb360,bpb720,NBPBS
; List of BPBs that we usually support
bpb160 BPB <512,1,1,2, 64, 40*1*8,0FEh,1, 8,1,0,0>
bpb180 BPB <512,1,1,2, 64, 40*1*9,0FCh,2, 9,1,0,0>
bpb320 BPB <512,2,1,2,112, 40*2*8,0FFh,1, 8,2,0,0>
bpb360 BPB <512,2,1,2,112, 40*2*9,0FDh,2, 9,2,0,0>
bpb1200 BPB <512,1,1,2,224,80*2*15,0F9h,7,15,2,0,0>
bpb720 BPB <512,2,1,2,112, 80*2*9,0F9h,3, 9,2,0,0>
bpb1440 BPB <512,1,1,2,224,80*2*18,0F0h,9,18,2,0,0>
bpb2880 BPB <512,2,1,2,240,80*2*36,0F0h,9,36,2,0,0>
NBPBS equ 8
; The following is a template, that gets overwritten
; with the real parameters and is used while formatting
public local_parms,parms_spt,parms_gpl
public layout_table,bpbtbl
local_parms db 11011111b ; step rate
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -