; 0x0000:0x6c00 -> 0x0000:0x7400 IDT, 256 descriptors\r
; 0x0000:0x7400 -> 0x0000:0x7c00 GDT, 256 descriptors\r
; 0x0000:0x7c00 -> 0x0000:0x7e00 bootsector\r
-; 0x0000:0x7e00 <- 0x0000:0xffff ~32,5kb stack for boot\r
-; 0x1000:0x0000 -> 0x9000:0xffff 576kb kernel/free space\r
-; 0xa000:0x0000 -> ............. VGA mem etc.\r
+; 0x0000:0x7e00 <- 0x0000:0x8000 512b stack for boot\r
+; 0x0000:0x8000 -> 0x9000:0xffff 608kb kernel/free space\r
+;;;; 0x0000:0x7e00 <- 0x0000:0xffff ~32,5kb stack for boot\r
+;;;; 0x1000:0x0000 -> 0x9000:0xffff 576kb kernel/free space\r
+; 0xA000:0x0000 -> ............. VGA mem etc.\r
\r
use16\r
org 0x7C00\r
\r
-boot: jmp near start\r
+boot:\r
+ jmp short start\r
nop\r
\r
;------------------------------------------;\r
; Standard BIOS Parameter Block, "BPB". ;\r
;------------------------------------------;\r
- bpbOEM db 'BOS 0.04'\r
+ bpbOEM db 'BOS 0.04'\r
bpbSectSize dw 512\r
bpbClustSize db 1\r
bpbReservedSec dw 1\r
- bpbFats db 2\r
+ bpbFats db 2\r
bpbRootSize dw 224\r
bpbTotalSect dw 2880\r
- bpbMedia db 240\r
+ bpbMedia db 240\r
bpbFatSize dw 9\r
bpbTrackSect dw 18\r
- bpbHeads dw 2\r
+ bpbHeads dw 2\r
bpbHiddenSect dd 0\r
bpbLargeSect dd 0\r
;---------------------------------;\r
bpbDriveNo db 0\r
bpbReserved db 0\r
bpbSignature db 41 ; 0 = nothing more. 41 = three more (below)..\r
- bpbID dd 1\r
+ bpbID dd 1\r
bpbVolumeLabel db 'BOOT FLOPPY'\r
bpbFileSystem db 'FAT12 '\r
\r
mov ds, ax ; registers.\r
mov es, ax\r
mov ss, ax\r
- mov sp, 0xFFFF ; Stack..\r
+ mov sp, 0x8000 ; Stack..\r
\r
mov [bpbDriveNo], dl\r
\r
;-----------------------------------;\r
found:\r
mov bp, [bx+26] ; bp=cluster number from directory entry\r
- mov di, 0x1000 ; 1000 (segment)\r
+ mov di, 0x800 ; 1000 (segment)\r
\r
.next_block:\r
xor cx, cx\r
; the file is loaded ;\r
;-----------------------;\r
quit:\r
- jmp 0x1000:0x0000 ; jump to loaded file (64kb in mem)\r
+ jmp 0x0000:0x8000 ; jump to loaded file (64kb in mem)\r
\r
\r
;-------------------------------------;\r
--- /dev/null
+#######################################
+# #
+# BOCHS config file for BOS #
+# #
+#######################################
+
+#display_library: term
+romimage: file=/usr/local/Cellar/bochs/2.6.2/share/bochs/BIOS-bochs-latest
+megs: 32
+vgaromimage: file=/usr/local/Cellar/bochs/2.6.2/share/bochs/VGABIOS-elpin-2.40
+floppya: 1_44=/Volumes/BOS, status=inserted
+boot: a
+floppy_bootsig_check: disabled=0
+log: bochsout.txt
+panic: action=ask
+error: action=report
+info: action=report
+debug: action=ignore
+debugger_log: debugger.out
+keyboard_serial_delay: 250
+keyboard_paste_delay: 100000
+mouse: enabled=0
+keyboard_mapping: enabled=0, map=
+user_shortcut: keys=ctrlaltdel
\ No newline at end of file
;-------------------------------------------------------;\r
-; BOS kernel ;\r
+; BOS kernel ;\r
;-------------------------------------------------------;\r
-; BOS 32-bit kernel, expects to be loaded at 64kb ;\r
-; in mem. Small amount of 16-bit code included. ;\r
-; ;\r
-; For any comments on this code, mail me. ;\r
-; http://bos.asmhackers.net/ asmhacker@gmail.com ;\r
-; ;\r
-; by: Christoffer Bubach, 2003-2005 ;\r
+; BOS 32-bit kernel, expects to be loaded at 64kb ;\r
+; in mem. Small amount of 16-bit code included. ;\r
+; ;\r
+; For any comments on this code, mail me. ;\r
+; http://bos.asmhackers.net/ asmhacker@gmail.com ;\r
+; ;\r
+; by: Christoffer Bubach, 2003-2005 ;\r
;-------------------------------------------------------;\r
use16\r
-org 0x10000\r
+org 0x8000\r
\r
;---------------------------;\r
; jump to starting point ;\r
;---------------------------;\r
- jmp start\r
+ jmp start\r
\r
;----------------------------------------;\r
-; 16-bit include files ;\r
+; 16-bit include files ;\r
;----------------------------------------;\r
include 'realmode/a20.inc' ; Function to set the a20-gate.\r
include 'realmode/gdt.inc' ; Global Description Table.\r
\r
\r
;--------------------------;\r
-; 16-bit entry point ;\r
+; 16-bit entry point ;\r
;--------------------------;\r
start:\r
cli\r
\r
cli\r
mov ax, cs ; save cs\r
- mov [realmode_cs - 0x10000], ax ; in variables.inc\r
+ mov [realmode_cs], ax ; in variables.inc\r
\r
- lgdt [gdtr - 0x10000] ; Load the GDT descriptor\r
- lidt [idtr - 0x10000] ; Load the IDT descriptor\r
+ lgdt [gdtr] ; Load the GDT descriptor\r
+ lidt [idtr] ; Load the IDT descriptor\r
\r
mov eax, cr0\r
or al, 1\r
\r
\r
;--------------------------;\r
-; 32-bit entry point ;\r
+; 32-bit entry point ;\r
;--------------------------;\r
use32\r
flush:\r
call init_cmd\r
jmp shell\r
\r
- ;int 0x32\r
+ ;int 0x32\r
\r
.hang:\r
cli\r
\r
\r
;----------------------------------------;\r
-; 32-bit include files ;\r
+; 32-bit include files ;\r
;----------------------------------------;\r
include 'krl_incs/idt.inc' ; The Interrupt Description Table.\r
include 'krl_incs/text.inc' ; The default textmode functions.\r
include 'krl_incs/time_date.inc' ; Print time and date.\r
include 'krl_incs/timer.inc' ; Timer IRQ.\r
include 'krl_incs/vga.inc' ; VGA functions.\r
- ; include 'krl_incs/font8x16.inc' ; Standard font.\r
+ ; include 'krl_incs/font8x16.inc' ; Standard font.\r
include 'krl_incs/dma.inc' ; DMA code.\r
include 'krl_incs/fdc.inc' ; Floppy code.\r
include 'krl_incs/mario.inc' ; Mario sprite.\r
;----------------------------------------------------------;\r
-; BOS kernel Christoffer Bubach, 2003-2005. ;\r
+; BOS kernel Christoffer Bubach, 2003-2005. ;\r
;----------------------------------------------------------;\r
-; ;\r
-; set/modify IDT entries ;\r
-; ;\r
+; ;\r
+; set/modify IDT entries ;\r
+; ;\r
;----------------------------------------------------------;\r
\r
\r
\r
;--------------------------------------------------;\r
-; set up IDT ;\r
+; set up IDT ;\r
; in: edi = pointer to "unhandled int"-function. ;\r
;--------------------------------------------------;\r
init_idt:\r
\r
\r
;--------------------------------------;\r
-; modify IDT, set any int ;\r
-; in: cl = int number ;\r
-; edi = int function pointer ;\r
+; modify IDT, set any int ;\r
+; in: cl = int number ;\r
+; edi = int function pointer ;\r
;--------------------------------------;\r
set_int:\r
push eax\r
mov al, 8 ; 8 bytes for each int\r
mul cl ; cl * al = ax\r
movzx ecx, ax ; ecx = offset in IDT (1/2 for dword list)\r
- mov [(idt_list+ecx/2)], edi ; add new int to idt entry list\r
+ ;;mov [(idt_list+ecx/2)], edi ; add new int to idt entry list\r
+ mov dword [(idt_list+ecx)], edi ; add new int to idt entry list\r
\r
mov eax, edi\r
mov [(0x6c00+ecx)], ax\r
\r
\r
;------------------------------------------------;\r
-; get int address ;\r
-; in: cl = int number ;\r
-; out: esi = address or 0 if none present ;\r
+; get int address ;\r
+; in: cl = int number ;\r
+; out: esi = address or 0 if none present ;\r
;------------------------------------------------;\r
get_int:\r
push eax\r
\r
\r
;----------------------------------------;\r
-; sets ints from list ;\r
-; in: esi = pointer to int list ;\r
+; sets ints from list ;\r
+; in: esi = pointer to int list ;\r
;----------------------------------------;\r
set_idt_list:\r
push eax\r
\r
;------------------------------;\r
; list of idt entries. ;\r
-; 0 = not handled ;\r
+; 0 = not handled ;\r
;------------------------------;\r
idt_list: dd isr00\r
dd isr01\r
mov word [realmode_cx], cx\r
mov word [realmode_dx], dx\r
call disable_irqs\r
- jmp pword 0x18:do_16pmode-0x10000 ; must substract 0x10000 from\r
+ jmp pword 0x18:do_16pmode ; must substract 0x10000 from\r
; data addresses becasue of\r
; fasm strict "org" behavior\r
use16\r
and al, 0xFE\r
mov cr0, eax\r
\r
- jmp 0x1000:(do_realm-0x10000)\r
+ jmp 0x1000:(do_realm)\r
\r
do_realm:\r
mov ax, cs\r
mov gs, ax\r
mov ss, ax\r
\r
- lidt [ridtr - 0x10000] ; realmode/variables.inc\r
+ lidt [ridtr] ; realmode/variables.inc\r
sti\r
\r
- mov ax, word [realmode_ax - 0x10000]\r
- mov bx, word [realmode_bx - 0x10000]\r
- mov cx, word [realmode_cx - 0x10000]\r
- mov dx, word [realmode_dx - 0x10000]\r
+ mov ax, word [realmode_ax]\r
+ mov bx, word [realmode_bx]\r
+ mov cx, word [realmode_cx]\r
+ mov dx, word [realmode_dx]\r
\r
push ax ; this is some cool shit.. ;)\r
- mov al, [int_number - 0x10000] ; interrupt to preform\r
- mov [$+5 - 0x10000], al ; move it to right pos.\r
+ mov al, [int_number] ; interrupt to preform\r
+ mov [$+5], al ; move it to right pos.\r
pop ax\r
db 0xCD ; opcode for int.\r
db 0x00 ; move int_number here\r
\r
jnc .no_error\r
- mov byte [realmode_error - 0x10000], 1\r
+ mov byte [realmode_error], 1\r
\r
.no_error:\r
- mov word [realmode_ax - 0x10000], ax\r
- mov word [realmode_bx - 0x10000], bx\r
- mov word [realmode_cx - 0x10000], cx\r
- mov word [realmode_dx - 0x10000], dx\r
+ mov word [realmode_ax], ax\r
+ mov word [realmode_bx], bx\r
+ mov word [realmode_cx], cx\r
+ mov word [realmode_dx], dx\r
\r
cli\r
\r
- lgdt [gdtr - 0x10000]\r
- lidt [idtr - 0x10000]\r
+ lgdt [gdtr]\r
+ lidt [idtr]\r
mov eax, cr0\r
or al, 1\r
mov cr0, eax\r
;----------------------------------------------------------;\r
-; BOS 0.04 Christoffer Bubach, 2005. ;\r
+; BOS 0.04 Christoffer Bubach, 2005. ;\r
;----------------------------------------------------------;\r
-; ;\r
-; Realmode functions to set a20-gate. ;\r
-; ;\r
+; ;\r
+; Realmode functions to set a20-gate. ;\r
+; ;\r
;----------------------------------------------------------;\r
\r
;----------------------;\r
ret\r
\r
;------------------------;\r
-; test if A20 is set ;\r
+; test if A20 is set ;\r
;------------------------;\r
a20_test:\r
mov al, byte [fs:0]\r
;---------------------;\r
do_all_16bit:\r
call getmem ; realmode/mem.inc\r
- mov [ram_amount - 0x10000], eax\r
+ mov [ram_amount], eax\r
\r
xor eax, eax ; clear mem for IDT and GDT\r
mov edi, 0x6c00 ; IDT address\r
\r
mov eax, cs\r
shl eax, 4\r
- mov [gdt.BOS_16code - 0x10000 + 2], ax ; Prepare GDT by\r
- mov [gdt.BOS_16data - 0x10000 + 2], ax ; setting 16-bit base.\r
+ mov [gdt.BOS_16code + 2], ax ; Prepare GDT by\r
+ mov [gdt.BOS_16data + 2], ax ; setting 16-bit base.\r
shr eax, 16\r
- mov [gdt.BOS_16code - 0x10000 + 4], al\r
- mov [gdt.BOS_16data - 0x10000 + 4], al\r
- mov [gdt.BOS_16code - 0x10000 + 7], ah\r
- mov [gdt.BOS_16data - 0x10000 + 7], ah\r
+ mov [gdt.BOS_16code + 4], al\r
+ mov [gdt.BOS_16data + 4], al\r
+ mov [gdt.BOS_16code + 7], ah\r
+ mov [gdt.BOS_16data + 7], ah\r
\r
- lea esi, [gdt - 0x10000]\r
+ lea esi, [gdt]\r
mov edi, 0x7400 ; GDT address\r
mov ecx, (gdt_end - gdt)/4\r
rep movsd ; Move it to final pos.\r
--- /dev/null
+#! /bin/sh
+
+# BOS MacOS X Installer version 0.2
+# You must be root to run this script because of the floppy/loopback device
+
+echo
+echo " BOS - MacOS X installer"
+echo "-------------------------"
+echo "Requires: Homebrew mtools"
+echo
+
+if [ `id -u` != "0" ]; then
+ echo "You must be root to use this installer!"
+ echo
+fi
+
+if [ -z "$1" ]; then
+ echo "Usage is:"
+ echo "$0 image - Creates a floppy image called bos.img"
+ echo "$0 floppy - Install BOS into a floppy ( must be inserted )"
+ echo
+ echo "Note: this installer will create a bootable image/floppy."
+ echo "Floppy creation is not tested ( I don't have a floppy reader ) and it should be already formatted"
+ exit
+fi
+
+echo "Compiling BOS..."
+./utils/osxfasm kernel/kernel.asm kernel/kernel.sys
+./utils/osxfasm boot/BOS_boot.asm boot/BOS_boot.bin
+
+if [ "$1" = "floppy" ]; then
+ echo "Starting floppy installation..."
+
+ #Install BOS_boot.bin as bootsector into bos.img
+ dd if=boot/BOS_boot.bin of=/dev/fd0 bs=1 count=512
+ mount /mnt/floppy
+
+ #Insert kernel.sys into image
+ cp kernel/kernel.sys /mnt/floppy
+
+ #Umount & cleanup
+ umount /mnt/floppy
+
+ echo "BOS installed."
+
+else
+ echo "Starting image creation..."
+
+ #Create image
+ rm -rf ./bos.img
+ mformat -C -f 1440 -v BOS -i bos.img ::
+
+ #Erhm, it isn't pretty....
+ DISKNAME=`hdiutil attach -nomount bos.img`
+ diskutil mount $DISKNAME
+ MOUNTNAME=`diskutil info $DISKNAME | grep 'Mount Point' | cut -d : -f 2 | sed 's/^ *//g' | sed 's/ *$//g';`
+
+ #Mounted, copy kernel.sys
+ cp kernel/kernel.sys $MOUNTNAME
+
+ #Install BOS_boot.bin as bootsector into bos.img
+ umount $DISKNAME
+ dd if=boot/BOS_boot.bin of=$DISKNAME bs=1 count=512
+
+ #Detach
+ hdiutil detach $DISKNAME
+ chmod 0777 bos.img
+
+ echo "BOS image created!"
+fi
\ No newline at end of file