Import backup from 2004-03-10
This commit is contained in:
parent
7f886e44e1
commit
302538b8ff
6
Makefile
6
Makefile
@ -99,12 +99,12 @@ install_img: $(FLOPPY_IMAGE)
|
||||
@echo "Writing boot sector to image..."
|
||||
dd if=stage1.bin of=$(FLOPPY_IMAGE) seek=0
|
||||
|
||||
@echo "Mounting floppy image..."
|
||||
mount $(FLOPPY_IMAGE) $(FLOPPY_MOUNT) -o loop
|
||||
|
||||
#################################
|
||||
# Copy the files onto the image #
|
||||
#################################
|
||||
@echo "Mounting floppy image..."
|
||||
mount $(FLOPPY_IMAGE) $(FLOPPY_MOUNT) -o loop
|
||||
|
||||
@echo "Copying stage 2 bootloader to the floppy image..."
|
||||
$(COPY_BIN) stage2.bin $(FLOPPY_MOUNT)
|
||||
@echo "Copying kernel to the floppy image..."
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
%define VERSION "0.13" ;HOS version
|
||||
%define VERSION "0.14" ;HOS version
|
||||
|
||||
%define BOOT_FAT_SEG 0x07E0 ;right after boot sector
|
||||
%define BOOT_ROOT_SEG 0x0900 ;right after FAT
|
||||
|
@ -19,7 +19,7 @@ NASM_FLAGS=-f $(KERNEL_FORMAT)
|
||||
|
||||
# C Compile Information:
|
||||
CC=gcc
|
||||
CC_FLAGS=-ffreestanding -fno-builtin -nostdlib -nodefaultlibs -I.
|
||||
CC_FLAGS=-ffreestanding -fno-builtin -nostdlib -nodefaultlibs -I. -Wall
|
||||
|
||||
# Linker Information:
|
||||
LD=ld
|
||||
@ -30,7 +30,7 @@ LD_FLAGS=-nodefaultlibs -nostdlib -T link.ld
|
||||
# Linking the kernel together #
|
||||
###############################
|
||||
all: Asm_Kernel Asm_Functions C_Kernel
|
||||
$(LD) $(LD_FLAGS) -o kernel.bin -Map ./lst/LDout.doc ks.o fdc.o functions.o kernel.o keyboard.o kio.o mm.o mouse.o stdfont.o video.o vmm.o asmfuncs.o
|
||||
$(LD) $(LD_FLAGS) -o kernel.bin -Map ./lst/LDout.doc ks.o kernel.o asmfuncs.o fdc.o functions.o keyboard.o kio.o mm.o mouse.o stdfont.o video.o vmm.o rtc.o pic.o io.o string.o cmos.o
|
||||
|
||||
##########################
|
||||
# Assembly Kernel Loader #
|
||||
|
71
kernel/Makefile.ms
Normal file
71
kernel/Makefile.ms
Normal file
@ -0,0 +1,71 @@
|
||||
#####################################################################
|
||||
# Author: Benjamen R. Meyer #
|
||||
# Date: 2004-2-15 #
|
||||
# Purpose: To build Josh Holtrop's OS (HOS) using GNU make #
|
||||
# Note: This makefile is for use on Linux & other Unix-like systems #
|
||||
#####################################################################
|
||||
|
||||
##############
|
||||
# Variables: #
|
||||
##############
|
||||
|
||||
# Format of kernel object files:
|
||||
# Do not change unless you know what you are doing
|
||||
KERNEL_FORMAT=aout
|
||||
|
||||
# Assembler information:
|
||||
NASM_BIN=nasm
|
||||
NASM_FLAGS=-f $(KERNEL_FORMAT)
|
||||
|
||||
# C Compile Information:
|
||||
CC=gcc
|
||||
CC_FLAGS=-ffreestanding -fno-builtin -nostdlib -nodefaultlibs -I. -Wall
|
||||
|
||||
# Linker Information:
|
||||
LD=ld
|
||||
LD_FLAGS=-nodefaultlibs -nostdlib -T link.ld
|
||||
|
||||
|
||||
###############################
|
||||
# Linking the kernel together #
|
||||
###############################
|
||||
all: Asm_Kernel Asm_Functions C_Kernel
|
||||
$(LD) $(LD_FLAGS) -o kernel.bin -Map ./lst/LDout.doc ks.o kernel.o asmfuncs.o fdc.o functions.o keyboard.o kio.o mm.o mouse.o stdfont.o video.o vmm.o
|
||||
|
||||
##########################
|
||||
# Assembly Kernel Loader #
|
||||
##########################
|
||||
Asm_Kernel: kernel.asm
|
||||
$(NASM_BIN) $(NASM_FLAGS) -o ks.o -l ./lst/kernel.lst kernel.asm
|
||||
|
||||
#################################
|
||||
# Assembly Functions for Kernel #
|
||||
#################################
|
||||
Asm_Functions: asmfuncs.asm
|
||||
$(NASM_BIN) $(NASM_FLAGS) -o asmfuncs.o -l ./lst/asmfuncs.lst asmfuncs.asm
|
||||
|
||||
############
|
||||
# C Kernel #
|
||||
############
|
||||
C_Kernel:
|
||||
$(CC) $(CC_FLAGS) -c kernel.c -o kernel.o
|
||||
$(CC) $(CC_FLAGS) -c kio.c -o kio.o
|
||||
$(CC) $(CC_FLAGS) -c functions.c -o functions.o
|
||||
$(CC) $(CC_FLAGS) -c sys/rtc.c -o rtc.o
|
||||
$(CC) $(CC_FLAGS) -c sys/pic.c -o pic.o
|
||||
$(CC) $(CC_FLAGS) -c sys/io.c -o io.o
|
||||
$(CC) $(CC_FLAGS) -c sys/cmos.c -o cmos.o
|
||||
$(CC) $(CC_FLAGS) -c string/string.c -o string.o
|
||||
$(CC) $(CC_FLAGS) -c video/stdfont.c -o stdfont.o
|
||||
$(CC) $(CC_FLAGS) -c video/video.c -o video.o
|
||||
$(CC) $(CC_FLAGS) -c block/fdc.c -o fdc.o
|
||||
$(CC) $(CC_FLAGS) -c char/keyboard.c -o keyboard.o
|
||||
$(CC) $(CC_FLAGS) -c char/mouse.c -o mouse.o
|
||||
$(CC) $(CC_FLAGS) -c mm/mm.c -o mm.o
|
||||
$(CC) $(CC_FLAGS) -c mm/vmm.c -o vmm.o
|
||||
|
||||
#################################################
|
||||
# Clean up the source directory of any binaries #
|
||||
#################################################
|
||||
clean:
|
||||
- rm *.o ./lst/*.lst ./lst/*.doc *.bin
|
@ -3,11 +3,11 @@
|
||||
; Created: 10/23/03
|
||||
; Modified: 02/26/04
|
||||
|
||||
[extern _putc]
|
||||
[extern _console_memory]
|
||||
[extern _cursorPosition]
|
||||
[extern _video_drawConsole]
|
||||
[extern _videoMode]
|
||||
[extern putc]
|
||||
[extern console_memory]
|
||||
[extern cursorPosition]
|
||||
[extern video_drawConsole]
|
||||
[extern videoMode]
|
||||
|
||||
%macro jzfar 1
|
||||
jnz %%skip
|
||||
@ -18,8 +18,8 @@
|
||||
|
||||
;stores the parameter to the CR0 register
|
||||
;extern dword write_cr0(dword cr0);
|
||||
[global _write_cr0]
|
||||
_write_cr0:
|
||||
[global write_cr0]
|
||||
write_cr0:
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
mov eax, [ebp+8]
|
||||
@ -29,15 +29,15 @@ _write_cr0:
|
||||
|
||||
;returns the value in the CR0 register
|
||||
;extern dword read_cr0();
|
||||
[global _read_cr0]
|
||||
_read_cr0:
|
||||
[global read_cr0]
|
||||
read_cr0:
|
||||
mov eax, cr0;
|
||||
ret
|
||||
|
||||
;stores the parameter to the CR3 register
|
||||
;extern dword write_cr3(dword cr3);
|
||||
[global _write_cr3]
|
||||
_write_cr3:
|
||||
[global write_cr3]
|
||||
write_cr3:
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
mov eax, [ebp+8]
|
||||
@ -48,8 +48,8 @@ _write_cr3:
|
||||
|
||||
;returns the value in the CR2 register
|
||||
;extern dword read_cr2();
|
||||
[global _read_cr2]
|
||||
_read_cr2:
|
||||
[global read_cr2]
|
||||
read_cr2:
|
||||
mov eax, cr2;
|
||||
ret
|
||||
|
||||
@ -57,8 +57,8 @@ _read_cr2:
|
||||
|
||||
;returns the value in the CR3 register
|
||||
;extern dword read_cr3();
|
||||
[global _read_cr3]
|
||||
_read_cr3:
|
||||
[global read_cr3]
|
||||
read_cr3:
|
||||
mov eax, cr3;
|
||||
ret
|
||||
|
||||
@ -66,8 +66,8 @@ _read_cr3:
|
||||
;compares one string to another
|
||||
;returns 0 if the strings are different
|
||||
;extern dword strcmp(char *str1, char *str2);
|
||||
[global _strcmp]
|
||||
_strcmp:
|
||||
[global strcmp]
|
||||
strcmp:
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
push esi
|
||||
@ -98,8 +98,8 @@ strcmp_done:
|
||||
|
||||
;copies a string from the source to the destination parameter
|
||||
;extern void strcpy(char *dest, char *src);
|
||||
[global _strcpy]
|
||||
_strcpy:
|
||||
[global strcpy]
|
||||
strcpy:
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
push esi
|
||||
@ -118,8 +118,8 @@ strcpyloop:
|
||||
|
||||
;copies memory of n bytes from src to destination
|
||||
;void memcpy(void *dest, void *src, dword n);
|
||||
[global _memcpy]
|
||||
_memcpy:
|
||||
[global memcpy]
|
||||
memcpy:
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
push esi
|
||||
@ -129,6 +129,7 @@ _memcpy:
|
||||
mov esi, [ebp+12]
|
||||
mov ecx, [ebp+16]
|
||||
|
||||
cld
|
||||
rep movsb
|
||||
|
||||
pop ecx
|
||||
@ -140,8 +141,8 @@ _memcpy:
|
||||
|
||||
;copies memory of n dwords (n*4 bytes) from src to destination
|
||||
;void memcpyd(void *dest, void *src, dword n);
|
||||
[global _memcpyd]
|
||||
_memcpyd:
|
||||
[global memcpyd]
|
||||
memcpyd:
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
push esi
|
||||
@ -151,6 +152,7 @@ _memcpyd:
|
||||
mov esi, [ebp+12]
|
||||
mov ecx, [ebp+16]
|
||||
|
||||
cld
|
||||
rep movsd
|
||||
|
||||
pop ecx
|
||||
@ -162,11 +164,10 @@ _memcpyd:
|
||||
|
||||
;sets num bytes at buffer to the value of c
|
||||
;void *memset(void *buffer, int c, int num);
|
||||
[global _memset]
|
||||
_memset:
|
||||
[global memset]
|
||||
memset:
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
push esi
|
||||
push edi
|
||||
push ecx
|
||||
mov edi, [ebp+8]
|
||||
@ -179,18 +180,16 @@ _memset:
|
||||
pop eax
|
||||
pop ecx
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
|
||||
;sets num words at buffer to the value of c
|
||||
;void *memsetw(void *buffer, int c, int num);
|
||||
[global _memsetw]
|
||||
_memsetw:
|
||||
[global memsetw]
|
||||
memsetw:
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
push esi
|
||||
push edi
|
||||
push ecx
|
||||
mov edi, [ebp+8]
|
||||
@ -203,18 +202,16 @@ _memsetw:
|
||||
pop eax
|
||||
pop ecx
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
|
||||
;sets num dwords at buffer to the value of c
|
||||
;void *memsetd(void *buffer, int c, int num);
|
||||
[global _memsetd]
|
||||
_memsetd:
|
||||
[global memsetd]
|
||||
memsetd:
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
push esi
|
||||
push edi
|
||||
push ecx
|
||||
mov edi, [ebp+8]
|
||||
@ -227,15 +224,14 @@ _memsetd:
|
||||
pop eax
|
||||
pop ecx
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
|
||||
;returns the number of characters in a string
|
||||
;extern dword strlen(char *str);
|
||||
[global _strlen]
|
||||
_strlen:
|
||||
[global strlen]
|
||||
strlen:
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
push esi
|
||||
@ -257,9 +253,9 @@ strlendone:
|
||||
|
||||
;this function invalidates the page directory/table entry that
|
||||
; would be used to access the memory address given in the parameter
|
||||
;extern void invlpg(dword addr);
|
||||
[global _invlpg]
|
||||
_invlpg:
|
||||
;extern void invlpg_(dword addr);
|
||||
[global invlpg_]
|
||||
invlpg_:
|
||||
mov eax, [esp+4]
|
||||
invlpg [eax]
|
||||
ret
|
||||
@ -268,8 +264,8 @@ _invlpg:
|
||||
;
|
||||
;void writeCursorPosition(word pos)
|
||||
;
|
||||
[global _writeCursorPosition]
|
||||
_writeCursorPosition:
|
||||
[global writeCursorPosition]
|
||||
writeCursorPosition:
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
|
||||
@ -307,8 +303,8 @@ _writeCursorPosition:
|
||||
;
|
||||
;word getCursorPosition()
|
||||
;
|
||||
[global _getCursorPosition]
|
||||
_getCursorPosition:
|
||||
[global getCursorPosition]
|
||||
getCursorPosition:
|
||||
push ebx
|
||||
push edx
|
||||
|
||||
@ -338,8 +334,8 @@ _getCursorPosition:
|
||||
;
|
||||
;int puts(char *str)
|
||||
;
|
||||
[global _puts]
|
||||
_puts:
|
||||
[global puts]
|
||||
puts:
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
push esi
|
||||
@ -350,7 +346,7 @@ puts_loop:
|
||||
cmp al, 0
|
||||
jz puts_done
|
||||
push eax
|
||||
call _putc
|
||||
call putc
|
||||
add esp, 4
|
||||
jmp puts_loop
|
||||
|
||||
@ -363,8 +359,8 @@ puts_done:
|
||||
|
||||
|
||||
|
||||
[global _putDecu]
|
||||
_putDecu:
|
||||
[global putDecu]
|
||||
putDecu:
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
sub esp, 24
|
||||
@ -417,7 +413,7 @@ L7:
|
||||
mov eax, 0
|
||||
mov al, BYTE [ebp-5]
|
||||
push eax
|
||||
call _putc
|
||||
call putc
|
||||
add esp, 16
|
||||
jmp L5
|
||||
L6:
|
||||
@ -426,7 +422,7 @@ L6:
|
||||
add eax, 48
|
||||
and eax, 255
|
||||
push eax
|
||||
call _putc
|
||||
call putc
|
||||
add esp, 16
|
||||
leave
|
||||
ret
|
||||
@ -434,8 +430,8 @@ L6:
|
||||
|
||||
|
||||
|
||||
[global _putDec]
|
||||
_putDec:
|
||||
[global putDec]
|
||||
putDec:
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
sub esp, 24
|
||||
@ -443,7 +439,7 @@ _putDec:
|
||||
jns L9
|
||||
sub esp, 12
|
||||
push 45
|
||||
call _putc
|
||||
call putc
|
||||
add esp, 16
|
||||
neg DWORD [ebp+8]
|
||||
L9:
|
||||
@ -497,7 +493,7 @@ L15:
|
||||
mov eax, 0
|
||||
mov al, BYTE [ebp-5]
|
||||
push eax
|
||||
call _putc
|
||||
call putc
|
||||
add esp, 16
|
||||
jmp L13
|
||||
L14:
|
||||
@ -506,7 +502,7 @@ L14:
|
||||
add eax, 48
|
||||
and eax, 255
|
||||
push eax
|
||||
call _putc
|
||||
call putc
|
||||
add esp, 16
|
||||
leave
|
||||
ret
|
||||
|
@ -5,6 +5,8 @@
|
||||
#ifndef __HOS_ASMFUNCS__
|
||||
#define __HOS_ASMFUNCS__ __HOS_ASMFUNCS__
|
||||
|
||||
#include "hos_defines.h"
|
||||
|
||||
dword write_cr0(dword cr0);
|
||||
dword read_cr0();
|
||||
dword write_cr3(dword cr3);
|
||||
@ -22,6 +24,7 @@ void *memset(void *buffer, int c, int num);
|
||||
void *memsetw(void *buffer, int c, int num);
|
||||
void *memsetd(void *buffer, int c, int num);
|
||||
dword strlen(char *str);
|
||||
void invlpg_(dword addr);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -11,9 +11,9 @@
|
||||
#define FDC_DOR 0x3f2
|
||||
#define FDC_MSR 0x3f4
|
||||
|
||||
inline void fdc_sendDOR(byte dor);
|
||||
//inline void fdc_sendDOR(byte dor);
|
||||
|
||||
inline void fdc_sendDOR(byte dor)
|
||||
static inline void fdc_sendDOR(byte dor)
|
||||
{
|
||||
outportb(FDC_DOR, dor);
|
||||
}
|
||||
|
@ -5,6 +5,10 @@
|
||||
|
||||
#include "hos_defines.h"
|
||||
#include "keyboard.h"
|
||||
#include "sys/io.h"
|
||||
#include "sys/pic.h"
|
||||
#include "functions.h"
|
||||
#include "kio.h"
|
||||
|
||||
#define KBD_BUFFER_LENGTH 64
|
||||
|
||||
@ -49,13 +53,13 @@ void isr_keyboard()
|
||||
if (kbdScan == 224) //extended key
|
||||
{
|
||||
kbdExt = 1;
|
||||
eoi();
|
||||
pic_eoi();
|
||||
return;
|
||||
}
|
||||
if (kbdScan == 225) //2nd-set-extended key
|
||||
{
|
||||
kbdExt2 = 2;
|
||||
eoi();
|
||||
pic_eoi();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -117,7 +121,7 @@ void isr_keyboard()
|
||||
{
|
||||
if (kbdExt > 0)
|
||||
kbdExt--;
|
||||
eoi();
|
||||
pic_eoi();
|
||||
return;
|
||||
}
|
||||
//====determine ASCII value of key::
|
||||
@ -182,14 +186,14 @@ void isr_keyboard()
|
||||
}
|
||||
if (kbdAscii == 2) //unknown key / ignore key
|
||||
{
|
||||
eoi();
|
||||
pic_eoi();
|
||||
return;
|
||||
}
|
||||
if (kbdScan < KBD_SCAN_RELEASED) //a key was pressed, save it
|
||||
{
|
||||
if (kbdBufferLen >= KBD_BUFFER_LENGTH) //no key slots available
|
||||
{
|
||||
eoi();
|
||||
pic_eoi();
|
||||
return;
|
||||
}
|
||||
else
|
||||
@ -199,7 +203,7 @@ void isr_keyboard()
|
||||
}
|
||||
}
|
||||
|
||||
eoi();
|
||||
pic_eoi();
|
||||
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "mouse.h"
|
||||
#include "hos_defines.h"
|
||||
#include "video/video.h"
|
||||
#include "sys/io.h"
|
||||
|
||||
#define MOUSE_BUFFER_LENGTH 16
|
||||
|
||||
|
@ -13,6 +13,7 @@ extern dword _code;
|
||||
extern dword _bss;
|
||||
extern dword _end;
|
||||
|
||||
/*
|
||||
inline void enable_ints();
|
||||
inline void disable_ints();
|
||||
inline void restart();
|
||||
@ -21,21 +22,22 @@ inline dword kernel_size();
|
||||
inline void timer_init();
|
||||
inline byte bcd2byte(byte bcd);
|
||||
inline byte byte2bcd(byte bite);
|
||||
*/
|
||||
|
||||
//Enables (SeTs) Interrupt Flag on the processor
|
||||
inline void enable_ints()
|
||||
static inline void enable_ints()
|
||||
{
|
||||
asm("sti");
|
||||
}
|
||||
|
||||
//Disables (CLears) Interrupt Flag on the processor
|
||||
inline void disable_ints()
|
||||
static inline void disable_ints()
|
||||
{
|
||||
asm("cli");
|
||||
}
|
||||
|
||||
//Restarts the computer
|
||||
inline void restart()
|
||||
static inline void restart()
|
||||
{
|
||||
enable_ints();
|
||||
byte temp;
|
||||
@ -54,7 +56,7 @@ inline void restart()
|
||||
}
|
||||
|
||||
//Halts (freezes) the computer
|
||||
inline void halt()
|
||||
static inline void halt()
|
||||
{
|
||||
asm("cli");
|
||||
asm("hlt");
|
||||
@ -63,7 +65,7 @@ inline void halt()
|
||||
}
|
||||
|
||||
//Initializes 8253 Programmable Interrupt Timer
|
||||
inline void timer_init()
|
||||
static inline void timer_init()
|
||||
{
|
||||
//set timer : 2e9c = 100hz
|
||||
outportb(0x43, 0x34);
|
||||
@ -75,19 +77,19 @@ inline void timer_init()
|
||||
// - this does not include the bss section
|
||||
// - this should be 4kb aligned per the linker script
|
||||
// - this should be the size of kernel.bin
|
||||
inline dword kernel_size()
|
||||
static inline dword kernel_size()
|
||||
{
|
||||
return (dword)(&_bss)-(dword)(&_code);
|
||||
}
|
||||
|
||||
//converts a binary-coded-decimal byte to its decimal equivalent
|
||||
inline byte bcd2byte(byte bcd)
|
||||
static inline byte bcd2byte(byte bcd)
|
||||
{
|
||||
return (10* ((bcd & 0xF0) >> 4)) + (bcd & 0x0F);
|
||||
}
|
||||
|
||||
//converts a binary-coded-decimal byte to its decimal equivalent
|
||||
inline byte byte2bcd(byte bite)
|
||||
static inline byte byte2bcd(byte bite)
|
||||
{
|
||||
return ((bite / 10) << 4) | (bite % 10);
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ isr_main:
|
||||
|
||||
push eax
|
||||
|
||||
call _isr
|
||||
call isr
|
||||
|
||||
add esp, 4
|
||||
|
||||
@ -98,7 +98,7 @@ sc1:
|
||||
cmp eax, 1 ;syscall 1 - putc
|
||||
jnz sc2
|
||||
push ebx
|
||||
call _putc
|
||||
call putc
|
||||
add esp, 4
|
||||
jmp scdone
|
||||
sc2:
|
||||
|
@ -15,9 +15,9 @@
|
||||
%define KERNEL_V KERNEL_P+0xC0000000 ;3gb+1mb+24kb, the virtual address of the kernel
|
||||
|
||||
[global start]
|
||||
[extern _isr]
|
||||
[extern _k_init]
|
||||
[extern _putc]
|
||||
[extern isr]
|
||||
[extern k_init]
|
||||
[extern putc]
|
||||
|
||||
bits 32
|
||||
|
||||
@ -91,7 +91,7 @@ newgdtcontinue:
|
||||
mov esp, 0xc0200000 ;stack just under 3gb+2mb, moves downward
|
||||
lidt [idtr] ;load idt
|
||||
|
||||
call _k_init
|
||||
call k_init
|
||||
haltit:
|
||||
hlt ;halt processor when k_init is done
|
||||
jmp haltit ;shouldn't get here...
|
||||
|
@ -32,29 +32,29 @@ void k_init()
|
||||
{
|
||||
// ===== Initialization
|
||||
fdc_sendDOR(0x0C); //turn off floppy motor!!
|
||||
console_cls();
|
||||
kio_console_cls();
|
||||
video_init();
|
||||
mm_init();
|
||||
vmm_init();
|
||||
remap_pics(0x20, 0x28);
|
||||
init_timer();
|
||||
pic_remap(0x20, 0x28);
|
||||
timer_init();
|
||||
mouse_init();
|
||||
pic1_mask(0); //unmask IRQ's 0-7
|
||||
pic2_mask(0); //unmask IRQ's 8-15
|
||||
pic_mask1(0); //unmask IRQ's 0-7
|
||||
pic_mask2(0); //unmask IRQ's 8-15
|
||||
enable_ints();
|
||||
kbd_resetLEDs(); //after enabling interrupts!!
|
||||
if (video_Mode())
|
||||
{
|
||||
int p = video_getWidth()*video_getHeight()-1;
|
||||
for (; p >= 0; p--)
|
||||
video_psetp(p, 0x00000077);
|
||||
video_pseti(p, 0x00000066);
|
||||
kio_drawConsole();
|
||||
}
|
||||
|
||||
printf("HOS 0.13 - Kernel File Size: %u kb\tData Size: %u bytes\n", kernel_size()>>10, (dword)(&_end)-(dword)(&_code));
|
||||
printf("HOS 0.14 - Kernel File Size: %u kb\tData Size: %u bytes\n", kernel_size()>>10, (dword)(&_end)-(dword)(&_code));
|
||||
printf("Memory available to OS: %u MB (%u bytes)\n", mm_getTotalMegs(), mm_getTotalMem());
|
||||
printf("Free memory: %u bytes (%u pages)\n", mm_freemem(), mm_freemem()>>12);
|
||||
printf("%d/%d/%d\t%d:%d:%d\n", rtc_readMonth(), rtc_readDay(), rtc_readYear(), rtc_readHour(), rtc_readMinute(), rtc_readSecond());
|
||||
printf("%b/%b/%b\t%b:%b:%b\n", rtc_readMonth(), rtc_readDay(), rtc_readYear(), rtc_readHour(), rtc_readMinute(), rtc_readSecond());
|
||||
|
||||
dword key = 0;
|
||||
for (;;)
|
||||
@ -77,14 +77,14 @@ void isr(dword num)
|
||||
case 0x20: // IRQ0 - timer interrupt
|
||||
timer++;
|
||||
(*(byte *)(0xc00b8000))++;
|
||||
eoi();
|
||||
pic_eoi();
|
||||
break;
|
||||
case 0x21: // IRQ1 - keyboard interrupt
|
||||
isr_keyboard(); //isr_keybard() takes care of calling eoi()
|
||||
break;
|
||||
case 0x2C: // IRQ12 - PS/2 mouse
|
||||
isr_mouse();
|
||||
eoi2();
|
||||
pic_eoi2();
|
||||
break;
|
||||
default:
|
||||
printf("Interrupt %d (0x%x) Unhandled!!\n", num, num);
|
||||
|
23
kernel/kio.c
23
kernel/kio.c
@ -5,6 +5,8 @@
|
||||
|
||||
#include "hos_defines.h"
|
||||
#include "kio.h"
|
||||
#include "asmfuncs.h"
|
||||
#include "video/video.h"
|
||||
|
||||
dword cursorPosition = 0; //Caches the current cursor position
|
||||
word console_memory[2000]; //holds a copy of the console's memory
|
||||
@ -48,6 +50,10 @@ void printf(char *fmt, ...)
|
||||
putHex(*params);
|
||||
params++;
|
||||
break;
|
||||
case 'b': case 'B':
|
||||
kio_putBCD(*params);
|
||||
params++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -91,7 +97,7 @@ void putc(dword chr)
|
||||
if (video_Mode())
|
||||
{
|
||||
console_memory[cursorPosition] = charac | 0x0700;
|
||||
video_drawConsoleChar(cursorPosition);
|
||||
kio_drawConsoleChar(cursorPosition);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -111,7 +117,7 @@ void putc(dword chr)
|
||||
|
||||
|
||||
// This function displays a number in hexadecimal
|
||||
int putHex(dword number)
|
||||
void putHex(dword number)
|
||||
{
|
||||
int hitNum = 0;
|
||||
int i;
|
||||
@ -131,14 +137,21 @@ int putHex(dword number)
|
||||
}
|
||||
|
||||
|
||||
void kio_putBCD(dword bcd)
|
||||
{
|
||||
putDecu((bcd & 0xF) >> 4);
|
||||
putDecu(bcd & 0xF);
|
||||
}
|
||||
|
||||
|
||||
void kio_console_scroll()
|
||||
{
|
||||
memcpyd(console_memory + 80, console_memory, 960);
|
||||
memcpyd(console_memory, console_memory + 80, 960);
|
||||
memsetw(console_memory + 1920, 0x0720, 80);
|
||||
if (video_Mode())
|
||||
kio_drawConsole();
|
||||
else
|
||||
memcpyd(console_memory, 0xC00B8000, 1000);
|
||||
memcpyd((void *)0xC00B8000, console_memory, 1000);
|
||||
}
|
||||
|
||||
|
||||
@ -148,7 +161,7 @@ void kio_console_cls()
|
||||
if (video_Mode())
|
||||
kio_drawConsole();
|
||||
else
|
||||
memcpyd(console_memory, 0xC00B8000, 1000);
|
||||
memcpyd((void *)0xC00B8000, console_memory, 1000);
|
||||
writeCursorPosition(0);
|
||||
}
|
||||
|
||||
|
@ -10,11 +10,12 @@
|
||||
|
||||
void printf(char *fmt, ...);
|
||||
void putc(dword chr);
|
||||
int putHex(dword number);
|
||||
void putHex(dword number);
|
||||
void kio_drawConsole();
|
||||
void kio_drawConsoleChar(dword position);
|
||||
void kio_console_scroll();
|
||||
void kio_console_cls();
|
||||
void kio_putBCD(dword bcd);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -6,6 +6,10 @@
|
||||
|
||||
#include "hos_defines.h"
|
||||
#include "vmm.h"
|
||||
#include "video/video.h"
|
||||
#include "asmfuncs.h"
|
||||
#include "mm/mm.h"
|
||||
#include "video/stdfont.h"
|
||||
|
||||
HeapEntry *firstHeapEntry = (HeapEntry *)0xD0000000; //this is where heap memory starts
|
||||
|
||||
@ -16,7 +20,7 @@ void vmm_init()
|
||||
unsigned int *pageTables = (unsigned int *)0xC0104000; //this is the location of the page directory
|
||||
pageTables[0x3FF] = 0x104000|0x03; //the last page directory entry points to the page directory itself
|
||||
pageTables[0] = 0;
|
||||
invlpg(0);
|
||||
invlpg_(0);
|
||||
if (video_Mode()) //we are in a graphical mode
|
||||
{
|
||||
unsigned int vidPages = video_getWidth() * video_getHeight() * (video_getBitsPerPixel() >> 3);
|
||||
@ -35,7 +39,7 @@ void vmm_init()
|
||||
heb->entry[0].attributes = VMM_HE_HEB; //this is a HeapEntryBlock
|
||||
heb->entry[1].base = (unsigned int)firstHeapEntry+4096; //this is the start of the rest of the kernel's heap memory
|
||||
heb->entry[1].size = 0x10000000-4096; //the rest of the kernel's heap memory: 256mb - 4kb
|
||||
heb->entry[1].attributes = VMM_HE_HOLE; //this is a hold - an unmapped section of heap memory
|
||||
heb->entry[1].attributes = VMM_HE_HOLE; //this is a hole - an unmapped section of heap memory
|
||||
}
|
||||
|
||||
|
||||
@ -64,7 +68,7 @@ void vmm_map1(unsigned int virt, unsigned int physical)
|
||||
{
|
||||
unsigned int *newpagetable = (dword *)mm_palloc();
|
||||
pageTables[pde] = ((unsigned int)newpagetable) | 0x03;
|
||||
invlpg(virt);
|
||||
invlpg_(virt);
|
||||
unsigned int *newpteptr = (unsigned int *)(0xFFC00000 | (pde << 12)); //points to first unsigned int of newly allocated page table
|
||||
int a;
|
||||
for (a = 0; a < 1024; a++)
|
||||
@ -74,7 +78,7 @@ void vmm_map1(unsigned int virt, unsigned int physical)
|
||||
}
|
||||
unsigned int *pteptr = (unsigned int *)(0xFFC00000 | (pde << 12) | (pte << 2));
|
||||
*pteptr = physical | 0x03;
|
||||
invlpg(virt);
|
||||
invlpg_(virt);
|
||||
}
|
||||
|
||||
|
||||
@ -95,7 +99,7 @@ void vmm_unmap1(unsigned int virt)
|
||||
{
|
||||
unsigned int *pteptr = (unsigned int *)(0xFFC00000 | ((virt & 0xFFC00000) >> 10) | ((virt & 0x003FF000) >> 10));
|
||||
*pteptr = 0;
|
||||
invlpg(virt);
|
||||
invlpg_(virt);
|
||||
}
|
||||
|
||||
|
||||
|
2
kernel/search.sh
Normal file
2
kernel/search.sh
Normal file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
grep -R -n -i $1 *
|
@ -4,10 +4,12 @@
|
||||
// Implements string functions
|
||||
|
||||
#include "string.h"
|
||||
#include "asmfuncs.h"
|
||||
|
||||
char *strcat(char *dest, char *src)
|
||||
{
|
||||
strcpy(dest+strlen(dest), src);
|
||||
return dest;
|
||||
}
|
||||
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "hos_defines.h"
|
||||
#include "cmos.h"
|
||||
#include "sys/io.h"
|
||||
|
||||
//Returns the cmos type of floppy disk drive 0 (0 = not present)
|
||||
unsigned char cmos_getfd0()
|
||||
|
@ -8,24 +8,24 @@
|
||||
|
||||
#include "hos_defines.h"
|
||||
|
||||
inline void outportb(unsigned int port, unsigned char value);
|
||||
inline void outportw(unsigned int port, unsigned int value);
|
||||
inline unsigned char inportb(unsigned short port);
|
||||
//void outportb(unsigned int port, unsigned char value);
|
||||
//inline void outportw(unsigned int port, unsigned int value);
|
||||
//inline unsigned char inportb(unsigned short port);
|
||||
|
||||
//Writes a byte out to a port
|
||||
inline void outportb(unsigned int port, unsigned char value) // Output a byte to a port
|
||||
static inline void outportb(unsigned int port, unsigned char value) // Output a byte to a port
|
||||
{
|
||||
asm volatile ("outb %%al,%%dx"::"d" (port), "a" (value));
|
||||
}
|
||||
|
||||
//Writes a word out to a port
|
||||
inline void outportw(unsigned int port, unsigned int value) // Output a word to a port
|
||||
static inline void outportw(unsigned int port, unsigned int value) // Output a word to a port
|
||||
{
|
||||
asm volatile ("outw %%ax,%%dx"::"d" (port), "a" (value));
|
||||
}
|
||||
|
||||
//Reads a byte from a port
|
||||
inline unsigned char inportb(unsigned short port)
|
||||
static inline unsigned char inportb(unsigned short port)
|
||||
{
|
||||
unsigned char ret_val;
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "hos_defines.h"
|
||||
#include "pic.h"
|
||||
#include "sys/io.h"
|
||||
|
||||
//Re-maps the Programmable Interrupr Controllers so IRQ0->pic1 base address, IRG8->pic2 base address
|
||||
void pic_remap(int pic1, int pic2)
|
||||
|
@ -2,11 +2,12 @@
|
||||
// Author: Josh Holtrop
|
||||
// Created: 02/26/04
|
||||
|
||||
#include "hos_defines.h"
|
||||
|
||||
#ifndef __HOS_PIC__
|
||||
#define __HOS_PIC__ __HOS_PIC__
|
||||
|
||||
#include "hos_defines.h"
|
||||
#include "sys/io.h"
|
||||
|
||||
#define PIC1 0x20
|
||||
#define PIC2 0xA0
|
||||
#define PIC1_COMMAND PIC1
|
||||
@ -28,32 +29,32 @@
|
||||
#define ICW4_SFNM 0x10 /* Special fully nested (not) */
|
||||
|
||||
void pic_remap(int pic1, int pic2);
|
||||
inline void pic_mask1(byte mask);
|
||||
inline void pic_mask2(byte mask);
|
||||
inline void pic_eoi();
|
||||
inline void pic_eoi2();
|
||||
//inline void pic_mask1(byte mask);
|
||||
//inline void pic_mask2(byte mask);
|
||||
//inline void pic_eoi();
|
||||
//inline void pic_eoi2();
|
||||
|
||||
//Masks interrupts on first Programmable Interrupt Controller
|
||||
inline void pic_mask1(byte mask)
|
||||
static inline void pic_mask1(byte mask)
|
||||
{
|
||||
outportb(PIC1_DATA, mask); //0x21, maskfield *OCW1*
|
||||
}
|
||||
|
||||
//Masks interrupts on second Programmable Interrupt Controller
|
||||
inline void pic_mask2(byte mask)
|
||||
static inline void pic_mask2(byte mask)
|
||||
{
|
||||
outportb(PIC2_DATA, mask); //0xA1, maskfield *OCW1*
|
||||
}
|
||||
|
||||
|
||||
//Signals an End Of Interrupt signal to the first PIC
|
||||
inline void pic_eoi()
|
||||
static inline void pic_eoi()
|
||||
{
|
||||
outportb(0x20, 0x20);
|
||||
}
|
||||
|
||||
//Signals an End Of Interrupt signal to both the second and first PIC unit
|
||||
inline void pic_eoi2()
|
||||
static inline void pic_eoi2()
|
||||
{
|
||||
outportb(0xA0, 0x20);
|
||||
outportb(0x20, 0x20);
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "hos_defines.h"
|
||||
#include "rtc.h"
|
||||
#include "sys/io.h"
|
||||
|
||||
unsigned char rtc_readDay()
|
||||
{
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "hos_defines.h"
|
||||
#include "video.h"
|
||||
#include "video/stdfont.h"
|
||||
|
||||
ModeInfoBlock video_mode;
|
||||
dword videoMode = 0; //what video mode # we are in, 0 for console mode
|
||||
|
Loading…
x
Reference in New Issue
Block a user