📄 kernel.asm
字号:
; kernel startup stack global init_tos resw 512init_tos:; the last paragraph of conventional memory might become an MCB resb 16 global __init_end__init_end:init_end: segment _DATA; blockdev private stack global blk_stk_top times 192 dw 0blk_stk_top:; clockdev private stack global clk_stk_top times 64 dw 0clk_stk_top:; Dynamic data:; member of the DOS DATA GROUP; and marks definitive end of all used data in kernel data segment;segment _DATAEND_swap_indos:; we don't know precisely what needs to be swapped before this, so set it here.; this is just after FIXED_DATA+BSS+DATA and before (D)CONST+BSS; probably, the clock and block stacks and disktransferbuffer should go past; _swap_indos but only if int2a ah=80/81 (critical section start/end); are called upon entry and exit of the device drivers times 96 dw 0x9090 ; Process 0 Stack global _p_0_tos_p_0_tos:segment DYN_DATA global _Dyn_Dyn: DynAllocated dw 0 segment ID_B global __INIT_DATA_START__INIT_DATA_START:segment ID_E global __INIT_DATA_END__INIT_DATA_END:segment INIT_TEXT_START global __InitTextStart__InitTextStart: ; and c version;; start end end of HMA areasegment HMA_TEXT_START global __HMATextAvailable__HMATextAvailable global __HMATextStart__HMATextStart: ; ; the HMA area is filled with 1eh+3(=sizeof VDISK) = 33 byte dummy data,; so nothing will ever be below 0xffff:0031;segment HMA_TEXTbegin_hma: times 10h db 0 ; filler [ffff:0..ffff:10] times 20h db 0 db 0; to minimize relocations global _DGROUP__DGROUP_ dw DGROUP%ifdef WATCOM; 32 bit multiplication + divisionglobal __U4M__U4M: LMULUglobal __U4D__U4D: LDIVMODU%endif resb 0xd0 - ($-begin_hma) ; reserve space for far jump to cp/m routine resb 5;End of HMA segment segment HMA_TEXT_END global __HMATextEnd__HMATextEnd: ; and c version; The default stack (_TEXT:0) will overwrite the data area, so I create a dummy; stack here to ease debugging. -- ror4segment _STACK class=STACK stack segment CONST ; dummy interrupt return handlers global _int22_handler global _int28_handler global _int2a_handler global _empty_handler_int22_handler: _int28_handler:_int2a_handler:_empty_handler: iret global _initforceEnableA20initforceEnableA20: call near forceEnableA20 retf global __HMARelocationTableStart__HMARelocationTableStart: global _int2f_handler extern reloc_call_int2f_handler_int2f_handler: jmp 0:reloc_call_int2f_handler call near forceEnableA20 global _int20_handler extern reloc_call_int20_handler_int20_handler: jmp 0:reloc_call_int20_handler call near forceEnableA20 global _int21_handler extern reloc_call_int21_handler_int21_handler: jmp 0:reloc_call_int21_handler call near forceEnableA20 global _low_int25_handler extern reloc_call_low_int25_handler_low_int25_handler: jmp 0:reloc_call_low_int25_handler call near forceEnableA20 global _low_int26_handler extern reloc_call_low_int26_handler_low_int26_handler: jmp 0:reloc_call_low_int26_handler call near forceEnableA20 global _int27_handler extern reloc_call_int27_handler_int27_handler: jmp 0:reloc_call_int27_handler call near forceEnableA20 global _int0_handler extern reloc_call_int0_handler_int0_handler: jmp 0:reloc_call_int0_handler call near forceEnableA20 global _int6_handler extern reloc_call_int6_handler_int6_handler: jmp 0:reloc_call_int6_handler call near forceEnableA20 global _cpm_entry extern reloc_call_cpm_entry_cpm_entry: jmp 0:reloc_call_cpm_entry call near forceEnableA20 global _reloc_call_blk_driver extern _blk_driver_reloc_call_blk_driver: jmp 0:_blk_driver call near forceEnableA20 global _reloc_call_clk_driver extern _clk_driver_reloc_call_clk_driver: jmp 0:_clk_driver call near forceEnableA20 global _CharMapSrvc ; in _DATA (see AARD) extern _reloc_call_CharMapSrvc_CharMapSrvc: jmp 0:_reloc_call_CharMapSrvc call near forceEnableA20 global _init_call_p_0 extern reloc_call_p_0_init_call_p_0: jmp 0:reloc_call_p_0 call near forceEnableA20 global __HMARelocationTableEnd__HMARelocationTableEnd: ;; if we were lucky, we found all entries from the outside to the kernel.; if not, BUMS;;; this routine makes the HMA area available. PERIOD.; must conserve ALL registers; will be only ever called, if HMA (DOS=HIGH) is enabled.; for obvious reasons it should be located at the relocation table; global _XMSDriverAddress_XMSDriverAddress: dw 0 ; XMS driver, if detected dw 0 global _ENABLEA20_ENABLEA20: mov ah,5UsingXMSdriver: push bx call far [cs:_XMSDriverAddress] pop bx retf global _DISABLEA20_DISABLEA20: mov ah,6 jmp short UsingXMSdriverdslowmem dw 0eshighmem dw 0ffffh global forceEnableA20forceEnableA20: push ds push es push ax forceEnableA20retry: mov ds, [cs:dslowmem] mov es, [cs:eshighmem] mov ax, [ds:00000h] cmp ax, [es:00010h] jne forceEnableA20success mov ax, [ds:00002h] cmp ax, [es:00012h] jne forceEnableA20success mov ax, [ds:00004h] cmp ax, [es:00014h] jne forceEnableA20success mov ax, [ds:00006h] cmp ax, [es:00016h] jne forceEnableA20success;; ok, we have to enable A20 )at least seems so; call far _ENABLEA20 jmp short forceEnableA20retry forceEnableA20success: pop ax pop es pop ds ret ;; global f*cking compatibility issues:;; very old brain dead software (PKLITE, copyright 1990); forces us to execute with A20 disabled;global _ExecUserDisableA20_ExecUserDisableA20: cmp word [cs:_XMSDriverAddress],0 jne NeedToDisable cmp word [cs:_XMSDriverAddress+2],0 je noNeedToDisableNeedToDisable: push ax call far _DISABLEA20 pop axnoNeedToDisable: iret ;; Default Int 24h handler -- always returns fail; so we have not to relocate it (now);FAIL equ 03h global _int24_handler_int24_handler: mov al,FAIL iret;; this makes some things easier;segment _LOWTEXT global _TEXT_DGROUP_TEXT_DGROUP dw DGROUPsegment INIT_TEXT global _INIT_DGROUP_INIT_DGROUP dw DGROUP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -