📄 kernel.asm
字号:
;; File:; kernel.asm; Description:; kernel start-up code;; Copyright (c) 1995, 1996; Pasquale J. Villani; All Rights Reserved;; This file is part of DOS-C.;; DOS-C 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, or (at your option) any later version.;; DOS-C 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 DOS-C; see the file COPYING. If not,; write to the Free Software Foundation, 675 Mass Ave,; Cambridge, MA 02139, USA.;; $Id: kernel.asm,v 1.54 2004/04/24 15:09:34 bartoldeman Exp $; %include "segs.inc" %include "ludivmul.inc"segment PSP extern _ReqPktPtr:wrt LGROUPSTACK_SIZE equ 384/2 ; stack allocated in words;************************************************************ ; KERNEL BEGINS HERE, i.e. this is byte 0 of KERNEL.SYS;************************************************************ ..start:entry: jmp short realentry;************************************************************ ; KERNEL CONFIGURATION AREA; this is copied up on the very beginning; it's a good idea to keep this in sync with KConfig.h;************************************************************ global _LowKernelConfig _LowKernelConfig: db 'CONFIG' ; constant dw configend-configstart; size of config area ; to be checked !!!configstart:DLASortByDriveNo db 0 ; sort disks by drive orderInitDiskShowDriveAssignment db 1 ;SkipConfigSeconds db 2 ;ForceLBA db 0 ;GlobalEnableLBAsupport db 1 ;BootHarddiskSeconds db 0 ;configend:;************************************************************ ; KERNEL CONFIGURATION AREA END;************************************************************ ;************************************************************ ; KERNEL real entry (at ~60:20); ; moves the INIT part of kernel.sys to high memory (~9000:0); then jumps there; to aid debugging, some '123' messages are output; this area is discardable and used as temporary PSP for the; init sequence;************************************************************ realentry: ; execution continues here push ax push bx pushf mov ax, 0e31h ; '1' Tracecode - kernel entered mov bx, 00f0h int 010h popf pop bx pop ax jmp far kernel_startbeyond_entry: resb 256-(beyond_entry-entry) ; scratch area for data (DOS_PSP)segment INIT_TEXT extern _FreeDOSmain ; ; kernel start-up ;kernel_start: push bx pushf mov ax, 0e32h ; '2' Tracecode - kernel entered mov bx, 00f0h int 010h popf pop bx mov ax,seg init_tos cli mov ss,ax mov sp,init_tos int 12h ; move init text+data to higher memory mov cl,6 shl ax,cl ; convert kb to para mov dx,15 + init_end wrt INIT_TEXT mov cl,4 shr dx,cl sub ax,dx mov es,ax mov dx,__INIT_DATA_START wrt INIT_TEXT ; para aligned shr dx,cl add ax,dx mov ss,ax ; set SS to init data segment sti ; now enable them mov ax,cs mov dx,__InitTextStart wrt HMA_TEXT ; para aligned shr dx,cl%ifdef WATCOM add ax,dx%endif mov ds,ax mov si,-2 + init_end wrt INIT_TEXT ; word aligned lea cx,[si+2] mov di,si shr cx,1 std ; if there's overlap only std is safe rep movsw ; move HMA_TEXT to higher memory sub ax,dx mov ds,ax ; ds = HMA_TEXT mov ax,es sub ax,dx mov es,ax ; es = new HMA_TEXT mov si,-2 + __InitTextStart wrt HMA_TEXT lea cx,[si+2] mov di,si shr cx,1 rep movsw cld%ifndef WATCOM ; for WATCOM: CS equal for HMA and INIT add ax,dx mov es,ax ; otherwise CS -> init_text%endif push es mov ax,cont push ax retfcont: ; Now set up call frame mov ds,[cs:_INIT_DGROUP] mov bp,sp ; and set up stack frame for c push bx pushf mov ax, 0e33h ; '3' Tracecode - kernel entered mov bx, 00f0h int 010h popf pop bx mov byte [_BootDrive],bl ; tell where we came from;!! int 11h;!! mov cl,6;!! shr al,cl;!! inc al;!! mov byte [_NumFloppies],al ; and how many mov ax,ss mov ds,ax mov es,ax jmp _FreeDOSmainsegment INIT_TEXT_END;************************************************************ ; KERNEL CODE AREA END; the NUL device;************************************************************ segment CONST ; ; NUL device strategy ; global _nul_strtgy_nul_strtgy: mov word [cs:_ReqPktPtr],bx ;save rq headr mov word [cs:_ReqPktPtr+2],es retf ; ; NUL device interrupt ; global _nul_intr_nul_intr: push es push bx les bx,[cs:_ReqPktPtr] ;es:bx--> rqheadr or word [es:bx+3],100h ;set "done" flag pop bx pop es retfsegment _LOWTEXT ; floppy parameter table global _int1e_table_int1e_table: times 0eh db 0;************************************************************ ; KERNEL FIXED DATA AREA ;************************************************************ segment _FIXED_DATA; Because of the following bytes of data, THIS MODULE MUST BE THE FIRST; IN THE LINK SEQUENCE. THE BYTE AT DS:0004 determines the SDA format in; use. A 0 indicates MS-DOS 3.X style, a 1 indicates MS-DOS 4.0-6.X style. global DATASTARTDATASTART: global _DATASTART_DATASTART:dos_data db 0 dw kernel_start db 0 ; padding dw 1 ; Hardcoded MS-DOS 4.0+ style times (0eh - ($ - DATASTART)) db 0 global _NetBios_NetBios dw 0 ; NetBios Number times (26h - 0ch - ($ - DATASTART)) db 0; Globally referenced variables - WARNING: DO NOT CHANGE ORDER; BECAUSE THEY ARE DOCUMENTED AS UNDOCUMENTED (?) AND HAVE; MANY MULTIPLEX PROGRAMS AND TSR'S ACCESSING THEM global _NetRetry_NetRetry dw 3 ;-000c network retry count global _NetDelay_NetDelay dw 1 ;-000a network delay count global _DskBuffer_DskBuffer dd -1 ;-0008 current dos disk buffer global _inputptr_inputptr dw 0 ;-0004 Unread con input global _first_mcb_first_mcb dw 0 ;-0002 Start of user memory global _DPBp global MARK0026H; A reference seems to indicate that this should start at offset 26h.MARK0026H equ $_DPBp dd 0 ; 0000 First drive Parameter Block global _sfthead_sfthead dd 0 ; 0004 System File Table head global _clock_clock dd 0 ; 0008 CLOCK$ device global _syscon_syscon dw _con_dev,seg _con_dev ; 000c console device global _maxbksize_maxbksize dw 512 ; 0010 maximum bytes/sector of any block device dd 0 ; 0012 pointer to buffers info structure global _CDSp_CDSp dd 0 ; 0016 Current Directory Structure global _FCBp_FCBp dd 0 ; 001a FCB table pointer global _nprotfcb_nprotfcb dw 0 ; 001e number of protected fcbs global _nblkdev_nblkdev db 0 ; 0020 number of block devices global _lastdrive_lastdrive db 0 ; 0021 value of last drive global _nul_dev_nul_dev: ; 0022 device chain root extern _con_dev:wrt LGROUP dw _con_dev, seg _con_dev ; next is con_dev at init time. dw 8004h ; attributes = char device, NUL bit set dw _nul_strtgy dw _nul_intr db 'NUL ' global _njoined_njoined db 0 ; 0034 number of joined devices dw 0 ; 0035 DOS 4 pointer to special names (always zero in DOS 5)setverPtr dw 0,0 ; 0037 setver list dw 0 ; 003B cs offset for fix a20 dw 0 ; 003D psp of last umb exec global _LoL_nbuffers_LoL_nbuffers dw 1 ; 003F number of buffers dw 1 ; 0041 size of pre-read buffer global _BootDrive_BootDrive db 1 ; 0043 drive we booted from %IF XCPU < 386 db 0 ; 0044 cpu type (1 if >=386)%ELSE db 1 ; 0044 cpu type (1 if >=386)%ENDIF dw 0 ; 0045 Extended memory in KBytesbuf_info:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -