#define MULTIBOOT_STACK_SIZE 0x4000
-.text
-.code32
-.align 32
+.section .kernel_entry_text
kernel_entry:
main:
cli
+ jmp real_kernel_entry
+#
+# 这之间放multiboot2_header
+#
+
+.text
+.code32
+.align 4
+real_kernel_entry:
# Load GDT's Information To GDTR
lgdt GDTR-KRNLADDR
.section .multiboot2_header
-# section align 64 bits boundary
-.align 64
+# An OS image must contain an additional header called Multiboot2 header,
+# besides the headers of the format used by the OS image.
+# The Multiboot2 header must be contained completely within the first 32768 bytes of the OS image,
+# and must be 64-bit aligned.
+# In general, it should come as early as possible,
+# and may be embedded in the beginning of the text segment after the real executable header.
+# 64-bit 对齐 就是 8 字节对齐
+.align 8
multiboot2_header_bgn:
# magic
.long MULTIBOOT2_HEADER_MAGIC
/*
*--------------------------------------------------------------------------
* File Name: link.ld
- *
+ *
* Description: Link All Object Files to KERNEL ...
- *
- *
+ *
+ *
* Author: Zhao Yanbai [zhaoyanbai@126.com]
- *
+ *
* Version: 1.1
* Create Date: Mon Mar 2 12:21:03 2009
* Last Update: Mon Mar 2 12:21:03 2009
- *
+ *
*--------------------------------------------------------------------------
*/
{
code = .;
phys_addr = . - kernel_virtual_addr_start;
- boot/multiboot.S.o(.text)
+ *(.kernel_entry_text)
*(.multiboot2_header)
+ /* 单独把 multiboot.S 的 .text 放在这个位置是为了便于调试,实际是可以不写这一句的 */
+ boot/multiboot.S.o(.text)
*(.text)
*(.ring3.text);
*(.sysexit) /* last */
}
etext = .;
- .data : AT(phys_addr) ALIGN(0x1000)
+ .data : AT(phys_addr) ALIGN(0x1000)
{
data = .;
phys_addr = . - kernel_virtual_addr_start;