summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md7
-rw-r--r--asm/multiboot.h16
-rw-r--r--asm/multiboot.s6
-rw-r--r--doxy.cfg3
-rw-r--r--driver/serial.c1
-rw-r--r--kernel/mem.c4
-rw-r--r--linker.ld8
7 files changed, 35 insertions, 10 deletions
diff --git a/README.md b/README.md
index ac25532..0e108a9 100644
--- a/README.md
+++ b/README.md
@@ -3,6 +3,13 @@ Welcome to FoolOS
![FoolOS Logo](https://gitweb.softwarefools.com/?p=miguel/fool-os.git;a=blob_plain;f=img/logo.png;hb=HEAD)
+Multiboot
+---------
+The FoolOS Kernel is following the Multiboot Specification (0.6.96)
+providing a multiboot header and the entry point _start().
+
+This in turn calls the C function kernel_main().
+
Disclaimer
----------
diff --git a/asm/multiboot.h b/asm/multiboot.h
new file mode 100644
index 0000000..f2acaf1
--- /dev/null
+++ b/asm/multiboot.h
@@ -0,0 +1,16 @@
+/**
+ * @file
+ * _multiboot.s_ defines the following sections/functions, some are linked at
+ * specific addresses in the final ELF kernel binary.
+ * This is specified in the _linker.ld_ file.
+ *
+ * * 0x07000 .smp - entry point for application processors (16bit code)
+ * * 0x10000 .multiboot - the multiboot header
+ * * .text
+ * * .bootstrap_stack
+ * * _start() - main entry point for booting cpu, calls kernel_main().
+ */
+
+/** This will be called by a multiboot compilant boot-loader (i.e. grub2) */
+void _start();
+
diff --git a/asm/multiboot.s b/asm/multiboot.s
index 837aa0b..bb12a7c 100644
--- a/asm/multiboot.s
+++ b/asm/multiboot.s
@@ -16,7 +16,7 @@
# entry point for application processors at 0x7000
.section .smp
.code16
-call smp_go
+call smp_go # TODO: align later before going C
# Declare a header as in the Multiboot Standard. We put this into a special
# section so we can force the header to be in the start of the final program.
@@ -37,7 +37,8 @@ call smp_go
.long 0
.long 0
-.long 0 #gfx_stuff 0=enable!
+# we override this from grub anyway
+.long 0 #gfx_stuff 0=enable!
.long 640
.long 480
.long 32
@@ -66,6 +67,7 @@ _start:
# our stack (as it grows downwards).
movl $stack_top, %esp
+ sub $8, %esp #to align on 16byte before calling C
push %ebx #pass address of the multiboot information data structure
push %eax #pass eax, so kernel can check for magic number
diff --git a/doxy.cfg b/doxy.cfg
index 4df6982..f3662f3 100644
--- a/doxy.cfg
+++ b/doxy.cfg
@@ -858,7 +858,8 @@ FILE_PATTERNS = *.c \
*.vhd \
*.vhdl \
*.ucf \
- *.qsf
+ *.qsf
+// *.s
# The RECURSIVE tag can be used to specify whether or not subdirectories should
# be searched for input files as well.
diff --git a/driver/serial.c b/driver/serial.c
index db6599b..32479ae 100644
--- a/driver/serial.c
+++ b/driver/serial.c
@@ -1,4 +1,3 @@
-
#include "driver/serial.h"
#include "asm/x86.h" // provides x86_inb() and x86_outb()
diff --git a/kernel/mem.c b/kernel/mem.c
index e05ca3e..dea1284 100644
--- a/kernel/mem.c
+++ b/kernel/mem.c
@@ -173,10 +173,8 @@ uint32_t mem_init(multiboot_information *info)
uint64_t mem_start=mmap->base_addr;
uint64_t mem_end=mmap->base_addr+mmap->length;
- #ifdef MEM_PRINT_MEMORYMAP
klog("%08X - %08X / type: %s, (size: %d)",
(uint32_t)mem_start, (uint32_t)mem_end, memmap_type_to_string[mmap->type-1], mmap->size);
- #endif
uint32_t mem=mmap->length;
@@ -221,7 +219,7 @@ uint32_t mem_init(multiboot_information *info)
klog("Usable ~%d / %d MB ",mem_free_blocks*4096/1024/1024,total_mem/1024/1024);
klog(
- "Free 4K blocks: %d (first free: %d)",mem_free_blocks,mem_min_block);
+ "Free 4K blocks: %d (first free: 0x%08X)",mem_free_blocks,mem_min_block);
return mem_min_block;
diff --git a/linker.ld b/linker.ld
index 1352163..c5fa5f8 100644
--- a/linker.ld
+++ b/linker.ld
@@ -3,14 +3,16 @@ ENTRY(_start)
SECTIONS
{
. = 0x7000;
+ kernel_start = .;
+
+ /* smp code at 0x7000*/
.text BLOCK(4K) : ALIGN(4K)
{
*(.smp)
}
. = 1M;
- kernel_start = .;
-
+ /* _start code as 0x10000 and rest of code*/
.text BLOCK(4K) : ALIGN(4K)
{
*(.multiboot)
@@ -32,9 +34,9 @@ SECTIONS
/* Read-write data (uninitialized) and stack */
.bss BLOCK(4K) : ALIGN(4K)
{
+ *(.bootstrap_stack)
*(COMMON)
*(.bss)
- *(.bootstrap_stack)
}
kernel_end = .;