changeset 12:b045d733207e

README and bootstrap minor change
author Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
date Fri, 31 Aug 2012 07:05:44 +0900
parents 26b76ada8c13
children 812852f41fc0
files Makefile README.txt bootstrap.S multiboot2.h
diffstat 4 files changed, 42 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Thu Aug 30 21:31:23 2012 +0900
+++ b/Makefile	Fri Aug 31 07:05:44 2012 +0900
@@ -13,26 +13,31 @@
 			  -c \
 			  -o
 
-LDFLAGS		= -m elf_x86_64 \
+LDFLAGS64		= -melf_x86_64 \
 			  -nostdlib \
 			  -Ttext 0x100000 \
 			  --oformat elf64-x86-64 \
 			  -o 
 
+LDFLAGS32		= -melf_i386 \
+				  -nostdlib \
+				  -Ttext 0x100000 \
+				  --oformat elf32-i386 \
+				  -o
+
+LDFLAGS = $(LDFLAGS32)
+
 TARGET=cbc_os.elf
 
 all: $(TARGET)
 
 kernel.o: kernel.cbc 
-	$(CBC) -m64 $(CBCFLAGS) $@ $^ 
+	$(CBC) -m32 $(CBCFLAGS) $@ $^ 
 
 bootstrap.o: bootstrap.S 
-	$(CBC) -m64 $(CBCFLAGS) $@ $^
+	$(CBC) -m32 $(CBCFLAGS) $@ $^
 
-head32.o: head32.S
-	$(CBC) -m64 $(CBCFLAGS) $@ $^ 
-
-$(TARGET): bootstrap.o kernel.o head32.o
+$(TARGET): bootstrap.o kernel.o 
 	$(LD) $(LDFLAGS) $@ $^
 
 clean:
--- a/README.txt	Thu Aug 30 21:31:23 2012 +0900
+++ b/README.txt	Fri Aug 31 07:05:44 2012 +0900
@@ -1,5 +1,7 @@
 TODO
-grub2 から OS を起動するための multiboot header magic が認識されていないので、認識されて起動できるようにする。
+64bit だと、 grub2 から OS を起動するための multiboot header magic が認識されていないので、認識されて起動できるようにする。
+
+32bit では動く。
 
 
 【環境】
--- a/bootstrap.S	Thu Aug 30 21:31:23 2012 +0900
+++ b/bootstrap.S	Fri Aug 31 07:05:44 2012 +0900
@@ -1,18 +1,37 @@
 /*
  * This program is boot to kernel.
- * Change mode to 64bit mode and go to CbC kernel.
- */
+ * Change mode to 64bit mode and go to CbC kernel.  */
 
 .file "bootstrap.S"
 
+#include "multiboot2.h"
+#include "boot_header.h"
+
 .code32
+.text
 
-#include "boot_header.h"
+    /* Align 64 bit boundly. */
+    .align 8
+multiboot_header:
+    .long MULTIBOOT2_HEADER_MAGIC
+    .long MULTIBOOT_ARCHITECTURE_I386
+    .long multiboot_header_end - multiboot_header
+    .long -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT_ARCHITECTURE_I386 + (multiboot_header_end - multiboot_header))
+    .short MULTIBOOT_HEADER_TAG_END
+    .short 0
+    .long 8
+multiboot_header_end:
+
 
 /*
  * Prepare for entering 64bit-mode.
  */
 
+.globl _start
+
+_start:
+    jmp move_longmode
+
 move_longmode:
     /* load new GDT */
     leal gdt(%ebp), %eax
--- a/multiboot2.h	Thu Aug 30 21:31:23 2012 +0900
+++ b/multiboot2.h	Fri Aug 31 07:05:44 2012 +0900
@@ -1,3 +1,8 @@
+#ifndef MULTIBOOT2_HEADER
+#define MULTIBOOT2_HEADER
+
 #define MULTIBOOT2_HEADER_MAGIC 0xe85250d6
 #define MULTIBOOT_ARCHITECTURE_I386 0
 #define MULTIBOOT_HEADER_TAG_END 0
+
+#endif /* MULTIBOOT2_HEADER */