File tree Expand file tree Collapse file tree 4 files changed +54
-6
lines changed Expand file tree Collapse file tree 4 files changed +54
-6
lines changed Original file line number Diff line number Diff line change @@ -7,8 +7,7 @@ OBJ = ${C_SOURCES:.c=.o cpu/interrupt.o}
7
7
CC = /usr/local/i386elfgcc/bin/i386-elf-gcc
8
8
GDB = /usr/local/i386elfgcc/bin/i386-elf-gdb
9
9
# -g: Use debugging symbols in gcc
10
- CFLAGS = -g -m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles -nodefaultlibs \
11
- -Wall -Wextra -Werror
10
+ CFLAGS = -g -ffreestanding -Wall -Wextra -fno-exceptions
12
11
13
12
# First rule is run by default
14
13
os-image.bin : boot/bootsect.bin kernel.bin
Original file line number Diff line number Diff line change @@ -7,4 +7,50 @@ JamesM's tutorial](http://wiki.osdev.org/James_Molloy%27s_Tutorial_Known_Bugs).
7
7
Since we followed his tutorial for lessons 18-22 (interrupts through malloc), we'll
8
8
need to make sure we fix any of the issues before moving on.
9
9
10
+ 1 . Wrong CFLAGS
11
+ ---------------
12
+
13
+ We add ` -ffreestanding ` when compiling ` .o ` files, which includes ` kernel_entry.o ` and thus
14
+ ` kernel.bin ` and ` os-image.bin ` .
15
+
16
+ Before, we disabled libgcc (not libc) through the use of ` -nostdlib ` and we didn't re-enable
17
+ it for linking. Since this is tricky, we'll delete ` -nostdlib `
18
+
19
+
20
+ 2 . Not setting a stack
21
+ ----------------------
22
+
23
+
24
+
25
+ 3 . kernel.c ` main() ` function
26
+ -----------------------------
27
+
28
+ Modify ` kernel/kernel.c ` and change ` main() ` to ` kernel_main() ` since gcc recognizes "main" as
29
+ a special keyword and we don't want to mess with that.
30
+
31
+ Change ` boot/kernel_entry.asm ` to point to the new name accordingly.
32
+
33
+ To fix the ` i386-elf-ld: warning: cannot find entry symbol _start; defaulting to 0000000000001000 `
34
+ warning message, add a ` global _start; ` and define the ` _start: ` label in ` boot/kernel_entry.asm ` .
35
+
36
+ 4 . Reinvented datatypes
37
+ -----------------------
38
+ <stddef.h> to provide size\_ t
39
+
40
+
41
+
42
+ 5 . Missing functions
43
+ --------------------
44
+
45
+ 6 . Interrupt handlers
46
+ ---------------------
47
+ - also cli, sti in interrupt handlers
48
+
49
+
50
+ 7 . Structs and attributes
51
+ -------------------------
52
+
53
+ 8 . Improperly aligned ` kmalloc `
54
+ -------------------------------
55
+
10
56
Original file line number Diff line number Diff line change
1
+ global _start ;
1
2
[bits 32]
2
- [extern main] ; Define calling point. Must have same name as kernel.c 'main' function
3
- call main ; Calls the C function. The linker will know where it is placed in memory
4
- jmp $
3
+
4
+ _start:
5
+ [ extern kernel_main ] ; Define calling point. Must have same name as kernel.c 'main' function
6
+ call kernel_main ; Calls the C function. The linker will know where it is placed in memory
7
+ jmp $
Original file line number Diff line number Diff line change 4
4
#include "../libc/string.h"
5
5
#include "../libc/mem.h"
6
6
7
- void main () {
7
+ void kernel_main () {
8
8
isr_install ();
9
9
irq_install ();
10
10
You can’t perform that action at this time.
0 commit comments