2011-01-11 18:27:45 +00:00
|
|
|
# Multiboot header, for multiboot boot loaders like GNU Grub.
|
|
|
|
# http://www.gnu.org/software/grub/manual/multiboot/multiboot.html
|
|
|
|
#
|
|
|
|
# Using GRUB 2, you can boot xv6 from a file stored in a
|
|
|
|
# Linux file system by copying kernel or kernelmemfs to /boot
|
|
|
|
# and then adding this menu entry:
|
|
|
|
#
|
|
|
|
# menuentry "xv6" {
|
|
|
|
# insmod ext2
|
|
|
|
# set root='(hd0,msdos1)'
|
|
|
|
# set kernel='/boot/kernel'
|
|
|
|
# echo "Loading ${kernel}..."
|
|
|
|
# multiboot ${kernel} ${kernel}
|
|
|
|
# boot
|
|
|
|
# }
|
|
|
|
|
|
|
|
#include "asm.h"
|
2011-07-29 11:31:27 +00:00
|
|
|
#include "memlayout.h"
|
2011-08-08 17:30:08 +00:00
|
|
|
#include "mmu.h"
|
2011-01-11 18:27:45 +00:00
|
|
|
|
|
|
|
#define STACK 4096
|
|
|
|
|
|
|
|
# Multiboot header. Data to direct multiboot loader.
|
|
|
|
.p2align 2
|
|
|
|
.text
|
|
|
|
.globl multiboot_header
|
|
|
|
multiboot_header:
|
|
|
|
#define magic 0x1badb002
|
|
|
|
#define flags (1<<16 | 1<<0)
|
|
|
|
.long magic
|
|
|
|
.long flags
|
|
|
|
.long (-magic-flags)
|
|
|
|
.long multiboot_header # beginning of image
|
|
|
|
.long multiboot_header
|
|
|
|
.long edata
|
|
|
|
.long end
|
2011-08-16 00:11:13 +00:00
|
|
|
.long entry
|
2011-01-11 18:27:45 +00:00
|
|
|
|
2011-08-16 00:11:13 +00:00
|
|
|
# Entering xv6 on boot processor. Machine is mostly set up.
|
|
|
|
.globl entry
|
|
|
|
entry:
|
2011-08-15 21:41:58 +00:00
|
|
|
# Turn on page size extension for 4Mbyte pages
|
|
|
|
movl %cr4, %eax
|
|
|
|
orl $(CR4_PSE), %eax
|
|
|
|
movl %eax, %cr4
|
|
|
|
# Set page directory
|
2011-08-31 00:50:19 +00:00
|
|
|
movl $(V2P_WO(entrypgdir)), %eax
|
2011-08-10 01:37:35 +00:00
|
|
|
movl %eax, %cr3
|
|
|
|
# Turn on paging.
|
|
|
|
movl %cr0, %eax
|
2011-08-31 00:50:19 +00:00
|
|
|
orl $(CR0_PG|CR0_WP), %eax
|
2011-08-10 01:37:35 +00:00
|
|
|
movl %eax, %cr0
|
|
|
|
|
2011-08-31 09:38:05 +00:00
|
|
|
# Set up the stack pointer.
|
2011-01-11 18:27:45 +00:00
|
|
|
movl $(stack + STACK), %esp
|
2011-08-31 09:38:05 +00:00
|
|
|
|
|
|
|
# Call main(), which switches to executing at
|
|
|
|
# high addresses. The indirect call is needed because
|
|
|
|
# the assembler produces a PC-relative instruction
|
|
|
|
# for a direct call.
|
|
|
|
mov $main, %eax
|
|
|
|
jmp *%eax
|
2011-01-11 18:27:45 +00:00
|
|
|
|
|
|
|
.comm stack, STACK
|