From 302538b8ff4ddbd58bc7b4cbbb0c265d337cee52 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 10 Mar 2004 22:00:00 -0500 Subject: [PATCH] Import backup from 2004-03-10 --- Makefile | 6 +- boot/bootdef.inc | 52 +- kernel/Makefile | 142 +++--- kernel/Makefile.ms | 71 +++ kernel/asmfuncs.asm | 1024 ++++++++++++++++++++-------------------- kernel/asmfuncs.h | 3 + kernel/block/fdc.h | 46 +- kernel/char/keyboard.c | 16 +- kernel/char/mouse.c | 2 + kernel/functions.h | 18 +- kernel/idt.inc | 4 +- kernel/kernel.asm | 8 +- kernel/kernel.c | 20 +- kernel/kio.c | 23 +- kernel/kio.h | 3 +- kernel/mm/vmm.c | 14 +- kernel/search.sh | 2 + kernel/string/string.c | 2 + kernel/sys/cmos.c | 1 + kernel/sys/io.h | 12 +- kernel/sys/pic.c | 1 + kernel/sys/pic.h | 21 +- kernel/sys/rtc.c | 1 + kernel/video/video.c | 1 + 24 files changed, 799 insertions(+), 694 deletions(-) create mode 100644 kernel/Makefile.ms create mode 100644 kernel/search.sh diff --git a/Makefile b/Makefile index 4e4315b..2fefe96 100644 --- a/Makefile +++ b/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..." diff --git a/boot/bootdef.inc b/boot/bootdef.inc index 771a115..ca45f57 100644 --- a/boot/bootdef.inc +++ b/boot/bootdef.inc @@ -1,26 +1,26 @@ - -%define VERSION "0.13" ;HOS version - -%define BOOT_FAT_SEG 0x07E0 ;right after boot sector -%define BOOT_ROOT_SEG 0x0900 ;right after FAT -%define BOOT_KERNEL_SEG 0x0AC0 ;right after ROOT_DIR -%define BOOT_STAGE2_SEG 0x0B00 ;right after KERNEL_SEG -%define BOOT_STAGE2_ADD 0xB000 ;address of stage2 to jump to, org at -%define BOOT_KERNEL_ADD 0x106000 ;final pmode kernel destination - physical -%define BOOT_RD_ADD 0x200000 ;2mb for ram disk - -%define BOOT_DATA_SEG 0x9000 ;data gathered by stage2 loader goes here - -%define BOOT_HASRD 0x0000 ;1 -%define BOOT_VESA 0x0002 ;2 - 0 for console, otherwise VESA mode -%define BOOT_VESA_OEM 0x0004 ;258 - null-terminated OEM identification string -%define BOOT_VESA_VBE 0x0106 ;512 - copy of VESA VBEInfoBlock -%define BOOT_VESA_INFO 0x0306 ;256 - copy of VESA ModeInfoBlock for selected mode -%define BOOT_MEMENTRIES 0x040A ;4 - dword = number of memmap entries -%define BOOT_MEMMAP 0x2000 ;? - memory map information - - - -%define BOOT_DRIVE 0x7C24 ;1 - boot drive - - + +%define VERSION "0.14" ;HOS version + +%define BOOT_FAT_SEG 0x07E0 ;right after boot sector +%define BOOT_ROOT_SEG 0x0900 ;right after FAT +%define BOOT_KERNEL_SEG 0x0AC0 ;right after ROOT_DIR +%define BOOT_STAGE2_SEG 0x0B00 ;right after KERNEL_SEG +%define BOOT_STAGE2_ADD 0xB000 ;address of stage2 to jump to, org at +%define BOOT_KERNEL_ADD 0x106000 ;final pmode kernel destination - physical +%define BOOT_RD_ADD 0x200000 ;2mb for ram disk + +%define BOOT_DATA_SEG 0x9000 ;data gathered by stage2 loader goes here + +%define BOOT_HASRD 0x0000 ;1 +%define BOOT_VESA 0x0002 ;2 - 0 for console, otherwise VESA mode +%define BOOT_VESA_OEM 0x0004 ;258 - null-terminated OEM identification string +%define BOOT_VESA_VBE 0x0106 ;512 - copy of VESA VBEInfoBlock +%define BOOT_VESA_INFO 0x0306 ;256 - copy of VESA ModeInfoBlock for selected mode +%define BOOT_MEMENTRIES 0x040A ;4 - dword = number of memmap entries +%define BOOT_MEMMAP 0x2000 ;? - memory map information + + + +%define BOOT_DRIVE 0x7C24 ;1 - boot drive + + diff --git a/kernel/Makefile b/kernel/Makefile index 1624ec8..9cb6109 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,71 +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. - -# 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 fdc.o functions.o kernel.o keyboard.o kio.o mm.o mouse.o stdfont.o video.o vmm.o asmfuncs.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 +##################################################################### +# 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 rtc.o pic.o io.o string.o cmos.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 diff --git a/kernel/Makefile.ms b/kernel/Makefile.ms new file mode 100644 index 0000000..7b50011 --- /dev/null +++ b/kernel/Makefile.ms @@ -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 diff --git a/kernel/asmfuncs.asm b/kernel/asmfuncs.asm index b3beb20..b37eda2 100644 --- a/kernel/asmfuncs.asm +++ b/kernel/asmfuncs.asm @@ -1,514 +1,510 @@ -; asmfuncs.asm -; Josh Holtrop -; Created: 10/23/03 -; Modified: 02/26/04 - -[extern _putc] -[extern _console_memory] -[extern _cursorPosition] -[extern _video_drawConsole] -[extern _videoMode] - -%macro jzfar 1 - jnz %%skip - jmp %1 -%%skip: - -%endmacro - -;stores the parameter to the CR0 register -;extern dword write_cr0(dword cr0); -[global _write_cr0] -_write_cr0: - push ebp - mov ebp, esp - mov eax, [ebp+8] - mov cr0, eax - pop ebp - ret - -;returns the value in the CR0 register -;extern dword 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: - push ebp - mov ebp, esp - mov eax, [ebp+8] - mov cr3, eax - pop ebp - ret - - -;returns the value in the CR2 register -;extern dword read_cr2(); -[global _read_cr2] -_read_cr2: - mov eax, cr2; - ret - - - -;returns the value in the CR3 register -;extern dword read_cr3(); -[global _read_cr3] -_read_cr3: - mov eax, cr3; - ret - - -;compares one string to another -;returns 0 if the strings are different -;extern dword strcmp(char *str1, char *str2); -[global _strcmp] -_strcmp: - push ebp - mov ebp, esp - push esi - push edi - - mov esi, [ebp+8] - mov edi, [ebp+12] -strcmp_loop1: - lodsb - mov ah, [edi] - inc edi - cmp ah, al - jnz strcmp_ne - or al, al - jz strcmp_e - jmp strcmp_loop1 -strcmp_e: - mov eax, 1 - jmp short strcmp_done -strcmp_ne: - xor eax, eax -strcmp_done: - - pop edi - pop esi - pop ebp - ret - -;copies a string from the source to the destination parameter -;extern void strcpy(char *dest, char *src); -[global _strcpy] -_strcpy: - push ebp - mov ebp, esp - push esi - push edi - mov edi, [ebp+8] - mov esi, [ebp+12] -strcpyloop: - lodsb - stosb - or al, al - jnz strcpyloop - pop edi - pop esi - pop ebp - ret - -;copies memory of n bytes from src to destination -;void memcpy(void *dest, void *src, dword n); -[global _memcpy] -_memcpy: - push ebp - mov ebp, esp - push esi - push edi - push ecx - mov edi, [ebp+8] - mov esi, [ebp+12] - mov ecx, [ebp+16] - - rep movsb - - pop ecx - pop edi - pop esi - pop ebp - ret - - -;copies memory of n dwords (n*4 bytes) from src to destination -;void memcpyd(void *dest, void *src, dword n); -[global _memcpyd] -_memcpyd: - push ebp - mov ebp, esp - push esi - push edi - push ecx - mov edi, [ebp+8] - mov esi, [ebp+12] - mov ecx, [ebp+16] - - rep movsd - - pop ecx - pop edi - pop esi - pop ebp - ret - - -;sets num bytes at buffer to the value of c -;void *memset(void *buffer, int c, int num); -[global _memset] -_memset: - push ebp - mov ebp, esp - push esi - push edi - push ecx - mov edi, [ebp+8] - push edi ;save for return address - mov eax, [ebp+12] - mov ecx, [ebp+16] - - rep stosb - - 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: - push ebp - mov ebp, esp - push esi - push edi - push ecx - mov edi, [ebp+8] - push edi ;save for return address - mov eax, [ebp+12] - mov ecx, [ebp+16] - - rep stosw - - 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: - push ebp - mov ebp, esp - push esi - push edi - push ecx - mov edi, [ebp+8] - push edi ;save for return address - mov eax, [ebp+12] - mov ecx, [ebp+16] - - rep stosd - - 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: - push ebp - mov ebp, esp - push esi - push ebx - mov esi, [ebp+8] - xor ebx, ebx -strlenloop: - lodsb - or al, al - jz strlendone - inc ebx - jmp strlenloop -strlendone: - mov eax, ebx - pop ebx - pop esi - pop ebp - ret - -;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: - mov eax, [esp+4] - invlpg [eax] - ret - - -; -;void writeCursorPosition(word pos) -; -[global _writeCursorPosition] -_writeCursorPosition: - push ebp - mov ebp, esp - - push eax - push ebx - push edx - - mov eax, [ebp+8] ;cursor position in ax - - mov bl, al - mov dx, 0x03D4 - mov al, 0x0E - out dx, al - - inc dx - mov al, ah - out dx, al - - dec dx - mov al, 0x0F - out dx, al - - inc dx - mov al, bl - out dx, al - - pop edx - pop ebx - pop eax - pop ebp - - ret - - -; -;word getCursorPosition() -; -[global _getCursorPosition] -_getCursorPosition: - push ebx - push edx - - xor eax, eax - mov dx, 0x03D4 - mov al, 0x0E - out dx, al - - inc dx - in al, dx - mov bl, al - - dec dx - mov al, 0x0F - out dx, al - - inc dx - in al, dx - mov ah, bl - - pop edx - pop ebx - - ret - - -; -;int puts(char *str) -; -[global _puts] -_puts: - push ebp - mov ebp, esp - push esi - push eax - mov esi, [ebp+8] ;esi = to string -puts_loop: - lodsb - cmp al, 0 - jz puts_done - push eax - call _putc - add esp, 4 - jmp puts_loop - -puts_done: - pop eax - pop esi - pop ebp - ret - - - - -[global _putDecu] -_putDecu: - push ebp - mov ebp, esp - sub esp, 24 - mov DWORD [ebp-4], 1 - mov BYTE [ebp-5], 0 -L2: - mov edx, DWORD [ebp+8] - mov eax, -858993459 - mul edx - mov eax, edx - shr eax, 3 - cmp eax, DWORD [ebp-4] - jae L4 - jmp L3 -L4: - mov eax, DWORD [ebp-4] - mov edx, eax - sal edx, 2 - add edx, eax - lea eax, [edx+edx] - mov DWORD [ebp-4], eax - jmp L2 -L3: - nop -L5: - cmp DWORD [ebp-4], 1 - ja L7 - jmp L6 -L7: - mov edx, DWORD [ebp+8] - mov eax, edx - mov edx, 0 - div DWORD [ebp-4] - mov DWORD [ebp-12], eax - mov al, BYTE [ebp-12] - mov BYTE [ebp-5], al - mov eax, 0 - mov al, BYTE [ebp-5] - imul eax, DWORD [ebp-4] - sub DWORD [ebp+8], eax - mov edx, DWORD [ebp-4] - mov eax, -858993459 - mul edx - mov eax, edx - shr eax, 3 - mov DWORD [ebp-4], eax - lea eax, [ebp-5] - add BYTE [eax], 48 - sub esp, 12 - mov eax, 0 - mov al, BYTE [ebp-5] - push eax - call _putc - add esp, 16 - jmp L5 -L6: - sub esp, 12 - mov al, BYTE [ebp+8] - add eax, 48 - and eax, 255 - push eax - call _putc - add esp, 16 - leave - ret - - - - -[global _putDec] -_putDec: - push ebp - mov ebp, esp - sub esp, 24 - cmp DWORD [ebp+8], 0 - jns L9 - sub esp, 12 - push 45 - call _putc - add esp, 16 - neg DWORD [ebp+8] -L9: - mov DWORD [ebp-4], 1 - mov BYTE [ebp-5], 0 -L10: - mov eax, DWORD [ebp+8] - cmp eax, DWORD [ebp-4] - jae L12 - jmp L11 -L12: - mov eax, DWORD [ebp-4] - mov edx, eax - sal edx, 2 - add edx, eax - lea eax, [edx+edx] - mov DWORD [ebp-4], eax - jmp L10 -L11: - mov edx, DWORD [ebp-4] - mov eax, -858993459 - mul edx - mov eax, edx - shr eax, 3 - mov DWORD [ebp-4], eax -L13: - cmp DWORD [ebp-4], 1 - ja L15 - jmp L14 -L15: - mov edx, DWORD [ebp+8] - mov eax, edx - mov edx, 0 - div DWORD [ebp-4] - mov DWORD [ebp-12], eax - mov al, BYTE [ebp-12] - mov BYTE [ebp-5], al - mov eax, 0 - mov al, BYTE [ebp-5] - imul eax, DWORD [ebp-4] - sub DWORD [ebp+8], eax - mov edx, DWORD [ebp-4] - mov eax, -858993459 - mul edx - mov eax, edx - shr eax, 3 - mov DWORD [ebp-4], eax - lea eax, [ebp-5] - add BYTE [eax], 48 - sub esp, 12 - mov eax, 0 - mov al, BYTE [ebp-5] - push eax - call _putc - add esp, 16 - jmp L13 -L14: - sub esp, 12 - mov al, BYTE [ebp+8] - add eax, 48 - and eax, 255 - push eax - call _putc - add esp, 16 - leave - ret - - +; asmfuncs.asm +; Josh Holtrop +; Created: 10/23/03 +; Modified: 02/26/04 + +[extern putc] +[extern console_memory] +[extern cursorPosition] +[extern video_drawConsole] +[extern videoMode] + +%macro jzfar 1 + jnz %%skip + jmp %1 +%%skip: + +%endmacro + +;stores the parameter to the CR0 register +;extern dword write_cr0(dword cr0); +[global write_cr0] +write_cr0: + push ebp + mov ebp, esp + mov eax, [ebp+8] + mov cr0, eax + pop ebp + ret + +;returns the value in the CR0 register +;extern dword 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: + push ebp + mov ebp, esp + mov eax, [ebp+8] + mov cr3, eax + pop ebp + ret + + +;returns the value in the CR2 register +;extern dword read_cr2(); +[global read_cr2] +read_cr2: + mov eax, cr2; + ret + + + +;returns the value in the CR3 register +;extern dword read_cr3(); +[global read_cr3] +read_cr3: + mov eax, cr3; + ret + + +;compares one string to another +;returns 0 if the strings are different +;extern dword strcmp(char *str1, char *str2); +[global strcmp] +strcmp: + push ebp + mov ebp, esp + push esi + push edi + + mov esi, [ebp+8] + mov edi, [ebp+12] +strcmp_loop1: + lodsb + mov ah, [edi] + inc edi + cmp ah, al + jnz strcmp_ne + or al, al + jz strcmp_e + jmp strcmp_loop1 +strcmp_e: + mov eax, 1 + jmp short strcmp_done +strcmp_ne: + xor eax, eax +strcmp_done: + + pop edi + pop esi + pop ebp + ret + +;copies a string from the source to the destination parameter +;extern void strcpy(char *dest, char *src); +[global strcpy] +strcpy: + push ebp + mov ebp, esp + push esi + push edi + mov edi, [ebp+8] + mov esi, [ebp+12] +strcpyloop: + lodsb + stosb + or al, al + jnz strcpyloop + pop edi + pop esi + pop ebp + ret + +;copies memory of n bytes from src to destination +;void memcpy(void *dest, void *src, dword n); +[global memcpy] +memcpy: + push ebp + mov ebp, esp + push esi + push edi + push ecx + mov edi, [ebp+8] + mov esi, [ebp+12] + mov ecx, [ebp+16] + + cld + rep movsb + + pop ecx + pop edi + pop esi + pop ebp + ret + + +;copies memory of n dwords (n*4 bytes) from src to destination +;void memcpyd(void *dest, void *src, dword n); +[global memcpyd] +memcpyd: + push ebp + mov ebp, esp + push esi + push edi + push ecx + mov edi, [ebp+8] + mov esi, [ebp+12] + mov ecx, [ebp+16] + + cld + rep movsd + + pop ecx + pop edi + pop esi + pop ebp + ret + + +;sets num bytes at buffer to the value of c +;void *memset(void *buffer, int c, int num); +[global memset] +memset: + push ebp + mov ebp, esp + push edi + push ecx + mov edi, [ebp+8] + push edi ;save for return address + mov eax, [ebp+12] + mov ecx, [ebp+16] + + rep stosb + + pop eax + pop ecx + pop edi + pop ebp + ret + + +;sets num words at buffer to the value of c +;void *memsetw(void *buffer, int c, int num); +[global memsetw] +memsetw: + push ebp + mov ebp, esp + push edi + push ecx + mov edi, [ebp+8] + push edi ;save for return address + mov eax, [ebp+12] + mov ecx, [ebp+16] + + rep stosw + + pop eax + pop ecx + pop edi + pop ebp + ret + + +;sets num dwords at buffer to the value of c +;void *memsetd(void *buffer, int c, int num); +[global memsetd] +memsetd: + push ebp + mov ebp, esp + push edi + push ecx + mov edi, [ebp+8] + push edi ;save for return address + mov eax, [ebp+12] + mov ecx, [ebp+16] + + rep stosd + + pop eax + pop ecx + pop edi + pop ebp + ret + + +;returns the number of characters in a string +;extern dword strlen(char *str); +[global strlen] +strlen: + push ebp + mov ebp, esp + push esi + push ebx + mov esi, [ebp+8] + xor ebx, ebx +strlenloop: + lodsb + or al, al + jz strlendone + inc ebx + jmp strlenloop +strlendone: + mov eax, ebx + pop ebx + pop esi + pop ebp + ret + +;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_: + mov eax, [esp+4] + invlpg [eax] + ret + + +; +;void writeCursorPosition(word pos) +; +[global writeCursorPosition] +writeCursorPosition: + push ebp + mov ebp, esp + + push eax + push ebx + push edx + + mov eax, [ebp+8] ;cursor position in ax + + mov bl, al + mov dx, 0x03D4 + mov al, 0x0E + out dx, al + + inc dx + mov al, ah + out dx, al + + dec dx + mov al, 0x0F + out dx, al + + inc dx + mov al, bl + out dx, al + + pop edx + pop ebx + pop eax + pop ebp + + ret + + +; +;word getCursorPosition() +; +[global getCursorPosition] +getCursorPosition: + push ebx + push edx + + xor eax, eax + mov dx, 0x03D4 + mov al, 0x0E + out dx, al + + inc dx + in al, dx + mov bl, al + + dec dx + mov al, 0x0F + out dx, al + + inc dx + in al, dx + mov ah, bl + + pop edx + pop ebx + + ret + + +; +;int puts(char *str) +; +[global puts] +puts: + push ebp + mov ebp, esp + push esi + push eax + mov esi, [ebp+8] ;esi = to string +puts_loop: + lodsb + cmp al, 0 + jz puts_done + push eax + call putc + add esp, 4 + jmp puts_loop + +puts_done: + pop eax + pop esi + pop ebp + ret + + + + +[global putDecu] +putDecu: + push ebp + mov ebp, esp + sub esp, 24 + mov DWORD [ebp-4], 1 + mov BYTE [ebp-5], 0 +L2: + mov edx, DWORD [ebp+8] + mov eax, -858993459 + mul edx + mov eax, edx + shr eax, 3 + cmp eax, DWORD [ebp-4] + jae L4 + jmp L3 +L4: + mov eax, DWORD [ebp-4] + mov edx, eax + sal edx, 2 + add edx, eax + lea eax, [edx+edx] + mov DWORD [ebp-4], eax + jmp L2 +L3: + nop +L5: + cmp DWORD [ebp-4], 1 + ja L7 + jmp L6 +L7: + mov edx, DWORD [ebp+8] + mov eax, edx + mov edx, 0 + div DWORD [ebp-4] + mov DWORD [ebp-12], eax + mov al, BYTE [ebp-12] + mov BYTE [ebp-5], al + mov eax, 0 + mov al, BYTE [ebp-5] + imul eax, DWORD [ebp-4] + sub DWORD [ebp+8], eax + mov edx, DWORD [ebp-4] + mov eax, -858993459 + mul edx + mov eax, edx + shr eax, 3 + mov DWORD [ebp-4], eax + lea eax, [ebp-5] + add BYTE [eax], 48 + sub esp, 12 + mov eax, 0 + mov al, BYTE [ebp-5] + push eax + call putc + add esp, 16 + jmp L5 +L6: + sub esp, 12 + mov al, BYTE [ebp+8] + add eax, 48 + and eax, 255 + push eax + call putc + add esp, 16 + leave + ret + + + + +[global putDec] +putDec: + push ebp + mov ebp, esp + sub esp, 24 + cmp DWORD [ebp+8], 0 + jns L9 + sub esp, 12 + push 45 + call putc + add esp, 16 + neg DWORD [ebp+8] +L9: + mov DWORD [ebp-4], 1 + mov BYTE [ebp-5], 0 +L10: + mov eax, DWORD [ebp+8] + cmp eax, DWORD [ebp-4] + jae L12 + jmp L11 +L12: + mov eax, DWORD [ebp-4] + mov edx, eax + sal edx, 2 + add edx, eax + lea eax, [edx+edx] + mov DWORD [ebp-4], eax + jmp L10 +L11: + mov edx, DWORD [ebp-4] + mov eax, -858993459 + mul edx + mov eax, edx + shr eax, 3 + mov DWORD [ebp-4], eax +L13: + cmp DWORD [ebp-4], 1 + ja L15 + jmp L14 +L15: + mov edx, DWORD [ebp+8] + mov eax, edx + mov edx, 0 + div DWORD [ebp-4] + mov DWORD [ebp-12], eax + mov al, BYTE [ebp-12] + mov BYTE [ebp-5], al + mov eax, 0 + mov al, BYTE [ebp-5] + imul eax, DWORD [ebp-4] + sub DWORD [ebp+8], eax + mov edx, DWORD [ebp-4] + mov eax, -858993459 + mul edx + mov eax, edx + shr eax, 3 + mov DWORD [ebp-4], eax + lea eax, [ebp-5] + add BYTE [eax], 48 + sub esp, 12 + mov eax, 0 + mov al, BYTE [ebp-5] + push eax + call putc + add esp, 16 + jmp L13 +L14: + sub esp, 12 + mov al, BYTE [ebp+8] + add eax, 48 + and eax, 255 + push eax + call putc + add esp, 16 + leave + ret + + diff --git a/kernel/asmfuncs.h b/kernel/asmfuncs.h index 4432238..312a2ae 100644 --- a/kernel/asmfuncs.h +++ b/kernel/asmfuncs.h @@ -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 diff --git a/kernel/block/fdc.h b/kernel/block/fdc.h index 874f431..a941f68 100644 --- a/kernel/block/fdc.h +++ b/kernel/block/fdc.h @@ -1,23 +1,23 @@ -//fdc.h -//Author: Josh Holtrop -//Date: 10/30/03 -//Modified: 02/26/04 - -#ifndef __HOS_FDC__ -#define __HOS_FDC__ __HOS_FDC__ - -#include "sys/io.h" - -#define FDC_DOR 0x3f2 -#define FDC_MSR 0x3f4 - -inline void fdc_sendDOR(byte dor); - -inline void fdc_sendDOR(byte dor) -{ - outportb(FDC_DOR, dor); -} - -#endif - - +//fdc.h +//Author: Josh Holtrop +//Date: 10/30/03 +//Modified: 02/26/04 + +#ifndef __HOS_FDC__ +#define __HOS_FDC__ __HOS_FDC__ + +#include "sys/io.h" + +#define FDC_DOR 0x3f2 +#define FDC_MSR 0x3f4 + +//inline void fdc_sendDOR(byte dor); + +static inline void fdc_sendDOR(byte dor) +{ + outportb(FDC_DOR, dor); +} + +#endif + + diff --git a/kernel/char/keyboard.c b/kernel/char/keyboard.c index bf8c26d..6767b1e 100644 --- a/kernel/char/keyboard.c +++ b/kernel/char/keyboard.c @@ -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(); } diff --git a/kernel/char/mouse.c b/kernel/char/mouse.c index adf8f2a..817c50d 100644 --- a/kernel/char/mouse.c +++ b/kernel/char/mouse.c @@ -4,6 +4,8 @@ #include "mouse.h" #include "hos_defines.h" +#include "video/video.h" +#include "sys/io.h" #define MOUSE_BUFFER_LENGTH 16 diff --git a/kernel/functions.h b/kernel/functions.h index d4c5393..783b153 100644 --- a/kernel/functions.h +++ b/kernel/functions.h @@ -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); } diff --git a/kernel/idt.inc b/kernel/idt.inc index ddabf24..711c7c8 100644 --- a/kernel/idt.inc +++ b/kernel/idt.inc @@ -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: diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 4ca707b..ed25cfb 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -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... diff --git a/kernel/kernel.c b/kernel/kernel.c index ee22db7..7002148 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -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); diff --git a/kernel/kio.c b/kernel/kio.c index 3680134..34f027a 100644 --- a/kernel/kio.c +++ b/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); } diff --git a/kernel/kio.h b/kernel/kio.h index 8f2addb..c66fd02 100644 --- a/kernel/kio.h +++ b/kernel/kio.h @@ -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 diff --git a/kernel/mm/vmm.c b/kernel/mm/vmm.c index 616ebfc..16f6cad 100644 --- a/kernel/mm/vmm.c +++ b/kernel/mm/vmm.c @@ -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); } diff --git a/kernel/search.sh b/kernel/search.sh new file mode 100644 index 0000000..a7c458a --- /dev/null +++ b/kernel/search.sh @@ -0,0 +1,2 @@ +#!/bin/sh +grep -R -n -i $1 * \ No newline at end of file diff --git a/kernel/string/string.c b/kernel/string/string.c index 197e6c8..b1b4301 100644 --- a/kernel/string/string.c +++ b/kernel/string/string.c @@ -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; } diff --git a/kernel/sys/cmos.c b/kernel/sys/cmos.c index f27919d..e789c34 100644 --- a/kernel/sys/cmos.c +++ b/kernel/sys/cmos.c @@ -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() diff --git a/kernel/sys/io.h b/kernel/sys/io.h index daa3dcf..b77bef1 100644 --- a/kernel/sys/io.h +++ b/kernel/sys/io.h @@ -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; diff --git a/kernel/sys/pic.c b/kernel/sys/pic.c index 9380686..310ff60 100644 --- a/kernel/sys/pic.c +++ b/kernel/sys/pic.c @@ -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) diff --git a/kernel/sys/pic.h b/kernel/sys/pic.h index 941451a..c363732 100644 --- a/kernel/sys/pic.h +++ b/kernel/sys/pic.h @@ -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); diff --git a/kernel/sys/rtc.c b/kernel/sys/rtc.c index c97c012..cbf3947 100644 --- a/kernel/sys/rtc.c +++ b/kernel/sys/rtc.c @@ -7,6 +7,7 @@ #include "hos_defines.h" #include "rtc.h" +#include "sys/io.h" unsigned char rtc_readDay() { diff --git a/kernel/video/video.c b/kernel/video/video.c index 70fce7c..e4cb730 100644 --- a/kernel/video/video.c +++ b/kernel/video/video.c @@ -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