summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile19
-rw-r--r--README.md16
-rw-r--r--bochsrc52
-rw-r--r--boot/boot16_entry.asm11
-rw-r--r--boot/mbr.asm99
-rw-r--r--boot/mbr16.asm79
-rw-r--r--boot/memmap.asm2
-rw-r--r--boot/print16.asm28
-rwxr-xr-xbootloader/boot.binbin0 -> 68 bytes
-rw-r--r--bootloader/boot.obin0 -> 848 bytes
-rwxr-xr-xbootloader/boot16.binbin0 -> 72 bytes
-rw-r--r--bootloader/boot16.c7
-rw-r--r--bootloader/boot16.obin0 -> 852 bytes
-rw-r--r--font_monofool1.bmpbin0 -> 180138 bytes
-rw-r--r--font_monofool1.xcfbin0 -> 13724 bytes
-rw-r--r--kernel/console.c6
-rw-r--r--kernel/font.h0
-rw-r--r--kernel/kernel.c26
-rw-r--r--kernel/mem.c14
-rw-r--r--kernel/vesa.c111
-rw-r--r--kernel/x86.h11
21 files changed, 405 insertions, 76 deletions
diff --git a/Makefile b/Makefile
index 9cea089..5c14650 100644
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,7 @@
IMAGE_SIZE=1474560
#final image
-all: FoolOS.img
+all: FoolOS.img
#assembling of final image
FoolOS.img: mbr.bin kernel.bin fill.bin
@@ -59,15 +59,30 @@ interrupts.o: kernel/interrupts.c kernel/interrupts.h
keyboard.o: kernel/keyboard.c
gcc -ffreestanding -m32 -o $@ -c $< -fno-asynchronous-unwind-tables -O0
+vesa.o: kernel/vesa.c
+ gcc -ffreestanding -m32 -o $@ -c $< -fno-asynchronous-unwind-tables -O0
+
timer.o: kernel/timer.c
gcc -ffreestanding -m32 -o $@ -c $< -fno-asynchronous-unwind-tables -O0
shell.o: kernel/shell.c
gcc -ffreestanding -m32 -o $@ -c $< -fno-asynchronous-unwind-tables -O0
-kernel.bin: kernel_entry.o kernel.o console.o interrupts.o keyboard.o timer.o floppy.o x86.o shell.o mem.o vmem.o pci.o e1000.o
+kernel.bin: kernel_entry.o kernel.o console.o interrupts.o keyboard.o timer.o floppy.o x86.o shell.o mem.o vmem.o pci.o e1000.o vesa.o
ld -o $@ -Ttext 0x1000 --oformat binary -melf_i386 $^ -O0
+#16bit bootloader!
+FoolBoot.img: mbr16.bin boot.bin fill.bin
+ cat $^ | head -c $(IMAGE_SIZE) > $@
+boot.bin: boot16_entry.o boot16.o
+ ld -o $@ -Ttext 0x1000 --oformat binary -melf_i386 $^ -O0
+mbr16.bin: boot/mbr16.asm
+ nasm -f bin $^ -o $@
+boot16_entry.o: boot/boot16_entry.asm
+ nasm -f elf $^ -o $@
+boot16.o: bootloader/boot16.c
+ gcc -ffreestanding -m32 -o $@ -c $< -fno-asynchronous-unwind-tables -O0
+
# dump from vbox
dump: FoolOS.img
diff --git a/README.md b/README.md
index 0bd2a18..99e5d97 100644
--- a/README.md
+++ b/README.md
@@ -75,23 +75,33 @@ FLOPPY IMAGE
RAM
---
0x1000
- boot loader puts the kernel here.
+ boot loader puts the kernel binary here.
0x7c00
first stage boot loader (loaded by bios) boot/mbr.asm
includes initial Global Descriptor Table!
-0x7c00 + 3
+0x7c00 + 3 (after jmp boot_16)
boot loader puts number of boot floppy disk here.
-0x7c00 + 0x140
+0x7c00 + 0x600
+ boot loader puts number of records in memory map in here!
+
+0x7c00 + 0x400
the boot loader puts the memory map obtained from the
bios here before switching to protected mode.
+0x8300
+ boot loader puts the vesa modes here!
+
+0x9000
+ physical memory manager bitmap!!!
+
0xb000
memory above this is used for dma (by our floppy.c driver)
+
REFERENCES
==========
diff --git a/bochsrc b/bochsrc
index 732b716..76790db 100644
--- a/bochsrc
+++ b/bochsrc
@@ -19,7 +19,7 @@
# the "wx" display library.
#=======================================================================
#config_interface: textconfig
-config_interface: wx
+#config_interface: wx
#=======================================================================
# DISPLAY_LIBRARY
@@ -49,11 +49,13 @@ config_interface: wx
#=======================================================================
#display_library: nogui
#display_library: rfb, options="timeout=60" # time to wait for client
-#display_library: sdl, options="fullscreen" # startup in fullscreen mode
+#display_library: sdl #, options="fullscreen" # startup in fullscreen mode
#display_library: term
-display_library: wx
+#display_library: wx
#display_library: x, options="hideIPS" # disable IPS output in status bar
#display_library: x, options="gui_debug" # use GTK debugger gui
+#display_library: x
+
#=======================================================================
# ROMIMAGE:
@@ -68,9 +70,11 @@ display_library: wx
# now supported, but we still recommend to use the BIOS distributed with
# Bochs. The start address optional, since it can be calculated from image size.
#=======================================================================
-romimage: file=/usr/share/bochs/BIOS-bochs-latest
+#romimage: file=/usr/share/bochs/BIOS-bochs-latest
#romimage: file=bios/seabios-0.5.1.bin
#romimage: file=mybios.bin, address=0xfff80000 # 512k at memory top
+romimage: file=/home/miguel/temp/bochs-2.6.6/bios/BIOS-bochs-latest
+
#=======================================================================
# CPU:
@@ -124,7 +128,7 @@ romimage: file=/usr/share/bochs/BIOS-bochs-latest
# 2.2.6 2.1Ghz Athlon XP with Linux 2.6/g++ 3.4 12 to 15 Mips
# 2.0.1 1.6Ghz Intel P4 with Win2000/g++ 3.3 5 to 7 Mips
#=======================================================================
-cpu: count=1, ips=50000000, reset_on_triple_fault=1, ignore_bad_msrs=1, msrs="msrs.def"
+#cpu: count=1, ips=5000000, reset_on_triple_fault=1, ignore_bad_msrs=1, msrs="msrs.def"
#=======================================================================
# CPUID:
@@ -195,9 +199,9 @@ cpu: count=1, ips=50000000, reset_on_triple_fault=1, ignore_bad_msrs=1, msrs="ms
# Determine whether to limit maximum CPUID function to 3. This mode is
# required to workaround WinNT installation and boot issues.
#=======================================================================
-cpuid: mmx=1, sep=1, sse=sse4_2, xapic=1, aes=1, movbe=1, xsave=1
-cpuid: stepping=5
-cpuid: cpuid_limit_winnt=0
+#cpuid: mmx=1, sep=1, sse=sse4_2, xapic=1, aes=1, movbe=1, xsave=1
+#cpuid: stepping=5
+#cpuid: cpuid_limit_winnt=0
#=======================================================================
# MEMORY
@@ -216,7 +220,7 @@ cpuid: cpuid_limit_winnt=0
# used all allocated host memory and wants more.
#
#=======================================================================
-memory: guest=512, host=256
+memory: guest=1024, host=1024
#=======================================================================
# OPTROMIMAGE[1-4]:
@@ -243,8 +247,16 @@ memory: guest=512, host=256
# VGAROMIMAGE
# You now need to load a VGA ROM BIOS into C0000.
#=======================================================================
-vgaromimage: file=/usr/share/vgabios/vgabios.bin
+#vgaromimage: file=/usr/share/vgabios/vgabios.bin
+#vgaromimage: file=/usr/share/vgabios/vgabios.qxl.bin
+#vgaromimage: file=/home/miguel/temp/vgabios-0.7a.bin
+#vgaromimage: file=/home/miguel/temp/vgabios-0.7a.cirrus.bin
+#
+#vgaromimage: file=/usr/share/vgabios/vgabios.qxl.bin
#vgaromimage: file=/usr/share/vgabios/vgabios.debug.bin
+#vgaromimage: file=/usr/share/vgabios/vgabios.cirrus.bin
+#vgaromimage: file=/usr/share/bochs/VGABIOS-lgpl-latest
+vgaromimage: file=/home/miguel/temp/bochs-2.6.6/bios/VGABIOS-lgpl-latest-cirrus
#=======================================================================
# VGA:
@@ -252,8 +264,8 @@ vgaromimage: file=/usr/share/vgabios/vgabios.bin
# 'none' you can use standard VGA with no extension. Other supported
# values are 'vbe' for Bochs VBE and 'cirrus' for Cirrus SVGA support.
#=======================================================================
-#vga: extension=cirrus
-vga: extension=vbe
+#vga: extension=vbe
+vga: extension=cirrus
#=======================================================================
# FLOPPYA:
@@ -450,7 +462,7 @@ floppy_bootsig_check: disabled=0
# log: ./bochs.out
# log: /dev/tty
#=======================================================================
-log: /dev/stdout
+#log: /dev/stdout
log: ./bochs.log
#=======================================================================
@@ -598,7 +610,7 @@ debugger_log: -
# sb16: midimode=1, midi="", wavemode=1, wave="" # win32
# sb16: midimode=1, midi=alsa:128:0, wavemode=1, wave=alsa # Linux with ALSA
#=======================================================================
-sb16: midimode=1, midi=/dev/midi00, wavemode=1, wave=/dev/dsp, loglevel=2, log=/dev/stdout, dmatimer=600000
+#sb16: midimode=1, midi=/dev/midi00, wavemode=1, wave=/dev/dsp, loglevel=2, log=/dev/stdout, dmatimer=600000
#=======================================================================
# VGA_UPDATE_INTERVAL:
@@ -611,7 +623,8 @@ sb16: midimode=1, midi=/dev/midi00, wavemode=1, wave=/dev/dsp, loglevel=2, log=/
# Examples:
# vga_update_interval: 250000
#=======================================================================
-vga_update_interval: 300000
+#vga_update_interval: 300000
+#vga_update_interval: 40000
# using for Winstone '98 tests
#vga_update_interval: 100000
@@ -797,7 +810,7 @@ private_colormap: enabled=0
# Example:
# i440fxsupport: enabled=1, slot1=pcivga, slot2=ne2k
#=======================================================================
-i440fxsupport: enabled=1
+#i440fxsupport: enabled=1
#=======================================================================
# USB_UHCI:
@@ -936,3 +949,10 @@ i440fxsupport: enabled=1
# See the example in the Bochs sources how to write a plugin device.
#=======================================================================
#user_plugin: name=testdev
+#
+#
+#
+##
+pci: enabled=1, chipset=i440fx, slot1=cirrus
+#i440fxsupport: enabled=1, slot1=cirrus
+
diff --git a/boot/boot16_entry.asm b/boot/boot16_entry.asm
new file mode 100644
index 0000000..e8d63be
--- /dev/null
+++ b/boot/boot16_entry.asm
@@ -0,0 +1,11 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;; Miguel's FoolOS Helper Functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+; this will be compiled to an object file and linked with the boot loader
+; to simplify the entrance!
+;
+;
+[bits 16]
+[extern boot_main]
+call boot_main ; jumps in the world of C
diff --git a/boot/mbr.asm b/boot/mbr.asm
index 3406b55..32f1a6f 100644
--- a/boot/mbr.asm
+++ b/boot/mbr.asm
@@ -21,6 +21,12 @@
;define where we will load our kernel into memory
KERNEL_OFFSET equ 0x1000
+MEMMAP_SIZE_OFFSET equ 0x7c00+0x600
+MEMMAP_OFFSET equ 0x7c00+0x400
+VESA_MODES equ 0x8300
+VESA_MODE_INFO equ 0x8400
+VESA_MODE_SELECT equ 0x4114
+;VESA_MODE_SELECT equ 0x411A
[bits 16]
jmp boot_16 ;start boot process
@@ -32,6 +38,9 @@ BOOT_DRIVE:
STR_VERSION:
db "v0.2~",0
+VESA_CHECK:
+ db "vesa check.",0
+
;STR_PROT:
; db "32-bit PM",0
;STR_LOADED:
@@ -40,8 +49,9 @@ STR_VERSION:
;lets put our temporary GDT (Global Descriptor Table) here
%include "boot/GDT.asm"
-;include 16-bit real mode routines (print_string, print_hex, disk_load)
+;include 16-bit real mode routines (print_string, disk_load)
%include "boot/common.asm"
+%include "boot/print16.asm"
;include 32-bit Protected Mode routines (print_string_pm,print_hex_pm)
;%include "boot/common_pm.asm"
@@ -60,35 +70,6 @@ STR_VERSION:
;lets start
[bits 16]
-;print_string routine ([bx])
-;this routine will print a null terminated string at [bx] to the screen.
-print_string:
-
- pusha ;push all registers
- mov ah,0x0e
-
- print_string_loop:
-
- ;check if value at [bx] is "\0" (end of string)
- mov cl,[bx]
- cmp cl,0
- je print_string_finish
-
- ;otherwise instruct BIOS to print the current char
- mov al,cl
- int 0x10
-
- ;proceed with next char
- inc bx
- jmp print_string_loop
-
- print_string_finish:
-
- popa ;pop all registers
- ret ;return to caller
-
-
-
boot_16:
mov bx, STR_VERSION
@@ -107,7 +88,7 @@ boot_16:
;Load the KERNEL
mov bx,KERNEL_OFFSET
- mov dh, 50
+ mov dh, 50 ;50 sectors!
mov dl, [BOOT_DRIVE]
call disk_load
@@ -116,11 +97,47 @@ boot_16:
; call print_string
- ;get memory map from biso before we enter 32 bit protected mode
- ; todo: how to set es!?!?
- ;mov es,0
- mov di,MEMMAP
- call BiosGetMemoryMap
+ ;get memory map from bios before we enter 32 bit protected mode
+ mov ax,0 ; set target address in es:di (0:offset)
+ mov es,ax
+ mov di,MEMMAP_OFFSET
+ call BiosGetMemoryMap ; this will also put the number of entries
+ ; of the memory map at MEMMAP_SIZE_OFFSET
+
+ ;get vesa modes!
+ mov ax,0 ; set target address in es:di (0:offset)
+ mov es,ax
+ mov di,VESA_MODES
+ mov ax,0x4f00 ;vesa function: Get Controller Info
+ int 0x10 ; call the interrupt to get the data from the bios!
+ vesa_err:
+ mov bx, VESA_CHECK
+ call print_string
+ cmp ax,0x004f
+ je vesa_ok
+ jmp vesa_err
+ vesa_ok:
+ ;
+
+ ;get info on mode of interest
+ mov ax,0 ; set target address in es:di (0:offset)
+ mov es,ax
+ mov di,VESA_MODE_INFO
+ mov ax,0x4f01 ;vesa function: Get Mode Info
+ mov cx,VESA_MODE_SELECT
+ int 0x10 ; call the interrupt to get the data from the bios!
+ vesa_err2:
+ mov bx, VESA_CHECK
+ call print_string
+ cmp ax,0x004f
+ je vesa_ok2
+ jmp vesa_err2
+ vesa_ok2:
+
+ ;finally switch to the mode of choice!
+ mov ax,0x4f02 ;vesa function: Set Mode
+ mov bx,VESA_MODE_SELECT
+ int 0x10
;finally lets enter Protected mode!!!
call switch_to_pm
@@ -129,7 +146,7 @@ boot_16:
[bits 32]
boot_32_pm:
-; we could do ALL This inside the kernel!!!
+; we could do ALL This inside the kernel!!!!!! TODO
;print info message that we are in protected mode!
; mov ecx,160
@@ -145,15 +162,8 @@ boot_32_pm:
;pic setup
call pic_setup
-
call KERNEL_OFFSET ;jump into our Kernel it
-db 'X'
-db 'X'
-MEMMAP:
-
-
-
;idt_descriptor:
; dw idt_end-idt_start-1
; dd KERNEL_OFFSET
@@ -166,6 +176,7 @@ MEMMAP:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
;so we get identified as MBR
times 510-($-$$) db 0
dw 0xaa55
diff --git a/boot/mbr16.asm b/boot/mbr16.asm
new file mode 100644
index 0000000..1abc97d
--- /dev/null
+++ b/boot/mbr16.asm
@@ -0,0 +1,79 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+; FoolOS Boot Loader for 16bit entry in C
+;
+; Copyright 2014 M.Idziorek <m.i@gmx.at>
+;
+; we have just been loaded by the BIOS and are in 16-bits real mode!
+;
+; THIS IS THE CENTRAL FILE OF THE 16bit BOOTLOADER, after we finished we
+; are inside 16bit C code!
+;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;we want 16-bit instructions, before we switch to 32-bit protected mode.
+
+;define origin of boot record in memory: 0x7c00
+;this is where the BIOS per definition will put the first
+;512 bytes of data from the boot device
+;The Boot record is identified by the last 2 magic bytes: 0xaa55 (?)
+[org 0x7c00]
+
+;define where we will load our "C binary"
+BOOT_OFFSET equ 0x1000
+
+[bits 16]
+jmp boot_16 ;start boot process
+
+BOOT_DRIVE:
+ db 0xff
+
+;SOME Global Data, mainly strings
+STR_VERSION:
+ db "~ Fool Loader 16-bit, v0.1 ~",0
+
+;include 16-bit real mode routines (print_string, print_hex, disk_load)
+%include "boot/common.asm"
+%include "boot/print16.asm"
+
+;;;;;;;; BOOT 16-bit real ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;lets start
+
+boot_16:
+
+ ;print version info
+ mov bx, STR_VERSION
+ call print_string
+
+ ;setup the stack
+ mov bp,0x8000
+ mov sp,bp
+
+ ;remember BOOT_DRIVE (as was set by BIOS)
+ mov [BOOT_DRIVE],dl
+
+ ;Load BOOT LOADER from second sector (max 50 sectors)
+ mov bx,BOOT_OFFSET ;destination in ram
+ mov dh, 50 ;50 sectors
+ mov dl, [BOOT_DRIVE] ;source drive
+ call disk_load
+
+ call BOOT_OFFSET ;jump into our C code
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;so we get identified as MBR
+times 510-($-$$) db 0
+dw 0xaa55
+
+;interrupt descriptor table (hardcoded address of interrupts:)
+;idt_start:
+;times 33 db 0x50,0x7c,0x08,0x00,0x00,10001110b,0x0,0x0
+;db 0x59,0x7c,0x08,0x00,0x00,10001110b,0x0,0x0
+;times 253 db 0x50,0x7c,0x08,0x00,0x00,10001110b,0x0,0x0
+;idt_end:
+
+
+
+
diff --git a/boot/memmap.asm b/boot/memmap.asm
index 29d48f3..d101557 100644
--- a/boot/memmap.asm
+++ b/boot/memmap.asm
@@ -51,5 +51,7 @@ BiosGetMemoryMap:
.error:
stc
.done:
+
+ mov [MEMMAP_SIZE_OFFSET],bp
popad
ret
diff --git a/boot/print16.asm b/boot/print16.asm
new file mode 100644
index 0000000..5d8ad5c
--- /dev/null
+++ b/boot/print16.asm
@@ -0,0 +1,28 @@
+[bits 16]
+
+;print_string routine ([bx])
+;this routine will print a null terminated string at [bx] to the screen.
+print_string:
+
+ pusha ;push all registers
+ mov ah,0x0e
+
+ print_string_loop:
+
+ ;check if value at [bx] is "\0" (end of string)
+ mov cl,[bx]
+ cmp cl,0
+ je print_string_finish
+
+ ;otherwise instruct BIOS to print the current char
+ mov al,cl
+ int 0x10
+
+ ;proceed with next char
+ inc bx
+ jmp print_string_loop
+
+ print_string_finish:
+
+ popa ;pop all registers
+ ret ;return to caller
diff --git a/bootloader/boot.bin b/bootloader/boot.bin
new file mode 100755
index 0000000..6c24d16
--- /dev/null
+++ b/bootloader/boot.bin
Binary files differ
diff --git a/bootloader/boot.o b/bootloader/boot.o
new file mode 100644
index 0000000..6d64850
--- /dev/null
+++ b/bootloader/boot.o
Binary files differ
diff --git a/bootloader/boot16.bin b/bootloader/boot16.bin
new file mode 100755
index 0000000..bde368e
--- /dev/null
+++ b/bootloader/boot16.bin
Binary files differ
diff --git a/bootloader/boot16.c b/bootloader/boot16.c
new file mode 100644
index 0000000..a906858
--- /dev/null
+++ b/bootloader/boot16.c
@@ -0,0 +1,7 @@
+#ifdef TEST16
+asm(".code16");
+#endif
+
+int test(int x) { return x*2; }
+
+
diff --git a/bootloader/boot16.o b/bootloader/boot16.o
new file mode 100644
index 0000000..b40786d
--- /dev/null
+++ b/bootloader/boot16.o
Binary files differ
diff --git a/font_monofool1.bmp b/font_monofool1.bmp
new file mode 100644
index 0000000..c5e4eb9
--- /dev/null
+++ b/font_monofool1.bmp
Binary files differ
diff --git a/font_monofool1.xcf b/font_monofool1.xcf
new file mode 100644
index 0000000..3a1627d
--- /dev/null
+++ b/font_monofool1.xcf
Binary files differ
diff --git a/kernel/console.c b/kernel/console.c
index 42dc5d0..b1a9125 100644
--- a/kernel/console.c
+++ b/kernel/console.c
@@ -1,5 +1,7 @@
#include "console.h"
+#define FOOLOS_CONSOLE
+
static int posx=0;
static int posy=0;
@@ -7,9 +9,11 @@ static int posy=0;
void print_char_col(int x, int y, char c, char col)
{
+#ifdef FOOLOS_CONSOLE
char* video_mem=(char *)SCR_VIDEOMEM+(x+y*SCR_REAL_WIDTH)*2;
video_mem[0]=c;
video_mem[1]=col;
+#endif
}
void print_char(int x, int y, char c)
@@ -67,6 +71,7 @@ void scr_put_string_nl(char *str)
void scr_nextline()
{
+#ifdef FOOLOS_CONSOLE
int i,x;
posx=0;
@@ -95,6 +100,7 @@ void scr_nextline()
posy--;
}
+#endif
}
void scr_put_char(char ch,char col)
diff --git a/kernel/font.h b/kernel/font.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/kernel/font.h
diff --git a/kernel/kernel.c b/kernel/kernel.c
index 16028fd..f1ba6b7 100644
--- a/kernel/kernel.c
+++ b/kernel/kernel.c
@@ -42,7 +42,8 @@ void kernel_main()
//timer_init();
// we know that here the bootloader placed the mamory map!
- mem_init(0x7c00+0x140);
+ mem_init(0x7c00+0x400,*((uint16_t *)(0x7c00+0x600)));
+ //mem_init(0x9000);
// we know that here the bootloader placed the mamory map!
vmem_init();
@@ -78,8 +79,11 @@ void kernel_main()
// pci
pci_init();
+ // vesa init
+ vesa_init(0x8300,0x8400);
+
// floppy
- floppy_init();
+ //floppy_init();
scr_put_string_nl("");
@@ -87,11 +91,27 @@ void kernel_main()
shell_init();
// kernel main loop
+ uint8_t t=0;
+
+// while(1)
+ // {
+ //}
+
+
while(1)
{
-
+ int i;
+ int j;
+ for(i=0;i<1024;i++)
+
+ for(j=0;j<768;j++)
+ {
+ PutPixel(i,j,t);
+ }
+ t+=125;
}
+
}
diff --git a/kernel/mem.c b/kernel/mem.c
index 28e05eb..68880be 100644
--- a/kernel/mem.c
+++ b/kernel/mem.c
@@ -205,20 +205,27 @@ void mem_test(int start, int end, int steps)
}
*/
-void mem_init(uint16_t *memmap)
+void mem_init(uint16_t *memmap,uint16_t entries)
{
+ scr_put_string("mem: the memory map contains ");
+ scr_put_hex(entries);
+ scr_put_string_nl(" entries.");
+
+ // hardcoded memory bitmap!!??!
_mmngr_memory_map=0x9000;
mem_free_blocks=0;
pmmngr_init ();
// count available memory
uint32_t avail_mem=0;
+ int i;
//print memory map and init regions!
- while(1)
+ for(i=0;i<entries;i++)
{
- if(memmap[8]==0)break;
+
+// if(memmap[8]==0)break;
#ifdef MEM_PRINT_MEMORYMAP
@@ -247,6 +254,7 @@ void mem_init(uint16_t *memmap)
}
memmap+=12;
+
}
scr_put_string("mem: Total Available Mem: ");
diff --git a/kernel/vesa.c b/kernel/vesa.c
new file mode 100644
index 0000000..93a42f3
--- /dev/null
+++ b/kernel/vesa.c
@@ -0,0 +1,111 @@
+//http://wiki.osdev.org/GUI
+#include "kernel.h"
+
+typedef struct vbeinfo_struct{
+ char VbeSignature[4]; // == "VESA"
+ uint16_t VbeVersion; // == 0x0300 for VBE 3.0
+ uint16_t OemStringPtr[2]; // isa vbeFarPtr
+ uint8_t Capabilities[4];
+ uint16_t VideoModePtr[2]; // isa vbeFarPtr
+ uint16_t TotalMemory; // as # of 64KB blocks
+}vbeinfo;
+
+typedef struct ModeInfoBlock {
+ uint16_t attributes;
+ uint8_t winA,winB;
+ uint16_t granularity;
+ uint16_t winsize;
+ uint16_t segmentA, segmentB;
+ uint16_t realFctPtr[2];
+// VBE_FAR(realFctPtr);
+ uint16_t pitch; // bytes per scanline
+
+ uint16_t Xres, Yres;
+ uint8_t Wchar, Ychar, planes, bpp, banks;
+ uint8_t memory_model, bank_size, image_pages;
+ uint8_t reserved0;
+
+ uint8_t red_mask, red_position;
+ uint8_t green_mask, green_position;
+ uint8_t blue_mask, blue_position;
+ uint8_t rsv_mask, rsv_position;
+ uint8_t directcolor_attributes;
+
+ uint32_t physbase; // your LFB (Linear Framebuffer) address ;)
+ uint32_t reserved1;
+ uint16_t reserved2;
+}vbemodeinfo;
+
+static vbemodeinfo *VbeModeInfoBlock;
+
+void vesa_init(vbeinfo *info,vbemodeinfo *mode)
+{
+ int i=0;
+
+// while(info[i].VbeSignature[0]=='V')
+ // {
+ scr_put_string("vesa: init vbe version: ");
+ scr_put_hex(info[i].VbeVersion);
+ scr_put_string(" / videomode ptr: ");
+ scr_put_hex(info[i].VideoModePtr[0]);
+ scr_put_hex(info[i].VideoModePtr[1]);
+ scr_put_string_nl("");
+
+// i++;
+ // }
+ //
+ int *modeptr=info[i].VideoModePtr[0]; // 0x8322; // do not hardcode !!! take from vbeinfo!
+
+ while(*modeptr!=0xffff&&*modeptr!=0)
+ {
+
+ scr_put_string("vesa: mode supported: ");
+ scr_put_hex(*modeptr);
+ scr_put_string_nl("");
+
+ modeptr++;
+ }
+
+ scr_put_string("vesa: selected mode res: ");
+ scr_put_hex(mode->Xres);
+ scr_put_string(" x ");
+ scr_put_hex(mode->Yres);
+ scr_put_string_nl("");
+ scr_put_string("vesa: selected mode banks: ");
+ scr_put_hex(mode->banks);
+ scr_put_string_nl("");
+ scr_put_string("vesa: attribs: ");
+ scr_put_hex(mode->attributes);
+ scr_put_string_nl("");
+ scr_put_string("vesa: physbase: ");
+ scr_put_hex32(mode->physbase);
+ scr_put_string_nl("");
+ scr_put_string("vesa: bpp: ");
+ scr_put_hex(mode->bpp);
+ scr_put_string_nl("");
+/*
+uint8_t *videomem=mode->physbase;
+for(i=0;i<0xffffff;i++)
+{
+ videomem[i]=i;
+}
+*/
+
+ VbeModeInfoBlock=mode;
+
+
+}
+
+void PutPixel(int x,int y, int color){
+
+ //do not write memory outside the screen buffer, check parameters against the VBE mode info
+ if (x<0 || x>VbeModeInfoBlock->Xres|| y<0 || y>VbeModeInfoBlock->Yres) return;
+//
+ if (x) x = (x*(VbeModeInfoBlock->bpp>>3)); // get bytes (divide by 8)
+ if (y) y = (y*VbeModeInfoBlock->pitch);
+ uint8_t *cTemp=VbeModeInfoBlock->physbase;
+ cTemp[x+y] = (uint8_t)(color & 0xff);
+ cTemp[x+y+1] = (uint8_t)((color>>8) & 0xff);
+ cTemp[x+y+2] = (uint8_t)((color>>16) & 0xff);
+ }
+
diff --git a/kernel/x86.h b/kernel/x86.h
index 1e80405..2b7572c 100644
--- a/kernel/x86.h
+++ b/kernel/x86.h
@@ -3,12 +3,13 @@
#include "kernel.h"
-#define X86_IRQ_BEGIN asm("cli\npusha");
-#define X86_IRQ_END asm("mov $0x20, %al\nout %al, $0x20\npopa\nsti\nleave\niret");
-//#define X86_IRQ_BEGIN asm("pusha");
-//#define X86_IRQ_END asm("mov $0x20, %al\nout %al, $0x20\npopa\nleave\niret");
-//
+// todo: cli/sti??
+// http://wiki.osdev.org/Interrupt_Service_Routines
+// Black Magic: Strongly Discouraged!
+#define X86_IRQ_BEGIN asm("\npusha");
+#define X86_IRQ_END asm("mov $0x20, %al\nout %al, $0x20\npopa\nleave\niret");
+
void x86_outb(int port, uint8_t data);
uint8_t x86_inb(int port);
void x86_outw(int port, uint16_t data);