summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Idziorek <m.i@gmx.at>2014-11-25 01:40:50 +0100
committerMichal Idziorek <m.i@gmx.at>2014-11-25 01:40:50 +0100
commitbad8fa17adf4d9609343fe86feabe05188023bc1 (patch)
treed9298a6bc2c6f0a3880ba2dbd3dda662f00e098c
parent7230b118e3a8f6b25bc2d525999b815c30490c81 (diff)
memory and buildsys improvements
-rw-r--r--Makefile28
-rw-r--r--boot2/disk_load_16.asm2
-rw-r--r--boot2/stage2.asm10
-rw-r--r--fs/fs.h2
-rw-r--r--kernel/console.c5
-rw-r--r--kernel/kernel.c2
-rw-r--r--linker.ld24
7 files changed, 44 insertions, 29 deletions
diff --git a/Makefile b/Makefile
index e33c0fb..3469bce 100644
--- a/Makefile
+++ b/Makefile
@@ -23,9 +23,6 @@ FOOLOS_VDI=FoolOS.vdi
#take care to set this properly!
USB_STICK=/dev/sdf
-#here our kernel will be loaded by the bootloader.
-KERNEL_START=0x100000
-
#use our cross compiler
CC=i686-foolos-gcc
@@ -122,29 +119,19 @@ $(CLEANDIRS):
# the kernel_entry.o needs to be FIRST!!
$(BIN_KERNEL): $(KERNEL_ENTRY) $(ASM_OBJECTS) $(OBJECTS)
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ -Wl,-Ttext,$(KERNEL_START),--oformat,binary $^
-
-
-
-######## generate empty image ~25MB ###############
-
-$(IMG_FILLUP):
- dd if=/dev/zero of=$(IMG_FILLUP) bs=512 count=50000
-
+ $(CC) $(CFLAGS) $(LDFLAGS) -T linker.ld -o $@ $^
############ assembling of final image ############
# master boot record, kernel binary and fool-font
-$(FOOLOS): $(IMG_FILLUP) $(BIN_KERNEL) $(SUBDIRS)
- cp $(IMG_FILLUP) $@
+$(FOOLOS): $(BIN_KERNEL) $(SUBDIRS)
dd if=$(BIN_MBR) of=$@ bs=512 seek=0 conv=notrunc
dd if=$(BIN_STAGE2) of=$@ bs=512 seek=1 conv=notrunc
- dd if=kernel.bin of=$@ bs=512 seek=10 conv=notrunc #will end up at 0x100000 in ram (this is what the booloader starts loading secotr: 10)
- #data starts at 0x168000
- dd if=$(BIN_MP) of=$@ bs=512 seek=842 conv=notrunc
- dd if=$(BIN_FOOLFONT) of=$@ bs=512 seek=843 conv=notrunc
- dd if=$(IMG_USERSPACE) of=$@ bs=512 seek=2894 conv=notrunc
+ # kernel will start at 0x100000 in ram (this is what the booloader starts loading secotr: 10)
+ dd if=$(BIN_KERNEL) of=$@ bs=512 seek=10 conv=notrunc # kernel can be about 128KB (incl bss)
+ # the data will starts at 0x120000 in ram
+ dd if=$(IMG_USERSPACE) of=$@ bs=512 seek=266 conv=notrunc
############ virtual machines stuff ############
@@ -161,15 +148,12 @@ run: all
newrun: clean run
-
############ create bootable usb image ############
stick: $(FOOLOS)
cat $< > $(USB_STICK) && sync
xxd $(USB_STICK) | head -n 50
-
-
############ cleanup ############
clean: $(CLEANDIRS)
diff --git a/boot2/disk_load_16.asm b/boot2/disk_load_16.asm
index f326bec..65b1bff 100644
--- a/boot2/disk_load_16.asm
+++ b/boot2/disk_load_16.asm
@@ -226,7 +226,7 @@ disk_read_error:
mov bx, STR_ERROR
call print_string
call print_nextline
- jmp $
+ ;jmp $
disk_load_finish:
diff --git a/boot2/stage2.asm b/boot2/stage2.asm
index d4abbca..e5ce600 100644
--- a/boot2/stage2.asm
+++ b/boot2/stage2.asm
@@ -37,10 +37,12 @@
;;where we will load our kernel into memory and some
;;other memory locations
;
-MEMMAP_SIZE_OFFSET equ 0x7c00
-MEMMAP_OFFSET equ 0x7c01
-VESA_MODES equ 0x9300 ; do NOT overwrite yourself! be careful!
-VESA_MODE_INFO equ 0x9400
+MEMMAP_SIZE_OFFSET equ 0xa000
+MEMMAP_OFFSET equ 0xa001
+
+VESA_MODES equ 0xb000 ; do NOT overwrite yourself! be careful!
+VESA_MODE_INFO equ 0xc000
+
VESA_MODE_SELECT equ 0x4114
CHUNKS_TO_LOAD equ 0x0a ;number of 0x8000 * 512 byte chunks to load into ram
;
diff --git a/fs/fs.h b/fs/fs.h
index 7ced0a7..0194093 100644
--- a/fs/fs.h
+++ b/fs/fs.h
@@ -4,7 +4,7 @@
#include <stdint.h>
-#define EXT2_RAM_ADDRESS (0x168800+0x100000)
+#define EXT2_RAM_ADDRESS 0x120000 // here the bootloader puts our image
enum FS_FILE_TYPE{
diff --git a/kernel/console.c b/kernel/console.c
index 2fdd3c1..80e2157 100644
--- a/kernel/console.c
+++ b/kernel/console.c
@@ -1,3 +1,8 @@
+// http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
+// http://invisible-island.net/vttest/
+// http://www.xfree86.org/4.7.0/ctlseqs.html
+
+
#include "kernel/config.h"
#ifdef FOOLOS_CONSOLE
diff --git a/kernel/kernel.c b/kernel/kernel.c
index 828f663..59ad130 100644
--- a/kernel/kernel.c
+++ b/kernel/kernel.c
@@ -44,7 +44,7 @@ void kernel_main(uint32_t initial_stack, int mp)
// we know that here, the bootloader placed the memory map and
// the number of entries.
//
- mem_init(0x7c00+1,*((uint16_t *)(0x7c00)));
+ mem_init(0xa001,*((uint16_t *)(0xa000)));
//
// Configuring the PIT timer.
diff --git a/linker.ld b/linker.ld
new file mode 100644
index 0000000..52a32ef
--- /dev/null
+++ b/linker.ld
@@ -0,0 +1,24 @@
+OUTPUT_FORMAT(binary)
+
+SECTIONS
+{
+ . = 0x100000;
+
+ .text BLOCK(4K) : ALIGN(4K)
+ {
+ *(.text)
+ }
+
+ .bss BLOCK(4K) : ALIGN(4K)
+ {
+ *(.bss)
+ }
+
+ .data BLOCK(4K) : ALIGN(4K)
+ {
+ *(.data)
+ }
+
+ kernel_end = .;
+
+}