109 lines
3.3 KiB
NASM
Executable File
109 lines
3.3 KiB
NASM
Executable File
; ==================================================================
|
|
; MikeOS -- The Mike Operating System kernel
|
|
; Copyright (C) 2006 - 2022 MikeOS Developers -- see doc/LICENSE.TXT
|
|
;
|
|
; This is loaded from the drive by BOOTLOAD.BIN, as KERNEL.BIN.
|
|
; First we have the system call vectors, which start at a static point
|
|
; for programs to use. Following that is the main kernel code and
|
|
; then additional system call code is included.
|
|
; ==================================================================
|
|
|
|
|
|
BITS 16
|
|
CPU 386 ; pusha offsets depends on a 386 or better
|
|
; FS and GS require a 386 or better
|
|
|
|
%DEFINE CRAWOS_VER '0.0.2' ; OS version number
|
|
%DEFINE CRAWOS_API_VER 1 ; API version for programs to check
|
|
|
|
|
|
; This is the location in RAM for kernel disk operations, 24K
|
|
; after the point where the kernel has loaded; it's 8K in size,
|
|
; because external programs load after it at the 32K point:
|
|
|
|
disk_buffer equ 24576
|
|
|
|
|
|
; ------------------------------------------------------------------
|
|
; OS CALL VECTORS -- Static locations for system call vectors
|
|
; Note: these cannot be moved, or it'll break the calls!
|
|
|
|
; The comments show exact locations of instructions in this section,
|
|
; and are used in programs/mikedev.inc so that an external program can
|
|
; use a CrawOS system call without having to know its exact position
|
|
; in the kernel source code...
|
|
|
|
os_call_vectors:
|
|
jmp os_main ; 0000h -- Called from bootloader
|
|
jmp os_print_string ; 0003h
|
|
jmp os_read_input
|
|
jmp os_display_input
|
|
jmp os_start_cli
|
|
|
|
|
|
; ------------------------------------------------------------------
|
|
; START OF MAIN KERNEL CODE
|
|
|
|
os_main:
|
|
cli ; Clear interrupts
|
|
mov ax, 0
|
|
mov ss, ax ; Set stack segment and pointer
|
|
mov sp, 0FFFFh
|
|
sti ; Restore interrupts
|
|
|
|
cld ; The default direction for string operations
|
|
; will be 'up' - incrementing address in RAM
|
|
|
|
mov ax, 2000h ; Set all segments to match where kernel is loaded
|
|
mov ds, ax ; After this, we don't need to bother with
|
|
mov es, ax ; segments ever again, as MikeOS and its programs
|
|
mov fs, ax ; live entirely in 64K
|
|
mov gs, ax
|
|
|
|
cmp dl, 0
|
|
je no_change
|
|
mov [bootdev], dl ; Save boot device number
|
|
push es
|
|
mov ah, 8 ; Get drive parameters
|
|
int 13h
|
|
pop es
|
|
and cx, 3Fh ; Maximum sector number
|
|
mov [SecsPerTrack], cx ; Sector numbers start at 1
|
|
movzx dx, dh ; Maximum head number
|
|
add dx, 1 ; Head numbers start at 0 - add 1 for total
|
|
mov [Sides], dx
|
|
|
|
no_change:
|
|
call os_clear_screen
|
|
call os_start_cli
|
|
|
|
bootdev db 0
|
|
SecsPerTrack dw 18
|
|
Sides dw 2
|
|
|
|
; ------------------------------------------------------------------
|
|
; SYSTEM VARIABLES -- Settings for programs and system calls
|
|
|
|
|
|
; Time and date formatting
|
|
|
|
fmt_12_24 db 0 ; Non-zero = 24-hr format
|
|
|
|
fmt_date db 0, '/' ; 0, 1, 2 = M/D/Y, D/M/Y or Y/M/D
|
|
; Bit 7 = use name for months
|
|
; If bit 7 = 0, second byte = separator character
|
|
|
|
|
|
; ------------------------------------------------------------------
|
|
; FEATURES -- Code to pull into the kernel
|
|
|
|
%INCLUDE "features/screen.asm"
|
|
%INCLUDE "features/cli.asm"
|
|
%INCLUDE "features/power.asm"
|
|
%INCLUDE "features/strings.asm"
|
|
|
|
; ==================================================================
|
|
; END OF KERNEL
|
|
; ==================================================================
|
|
|