2010-07-23 16:24:34 +02:00
|
|
|
#include "kernel/kernel.h" /* configures the kernel */
|
|
|
|
#include <minix/config.h>
|
|
|
|
#include <minix/const.h>
|
|
|
|
#include <minix/com.h>
|
2010-08-17 18:44:07 +02:00
|
|
|
#include <machine/asm.h>
|
2010-07-23 16:24:34 +02:00
|
|
|
#include <machine/interrupt.h>
|
|
|
|
#include "archconst.h"
|
|
|
|
#include "kernel/const.h"
|
|
|
|
#include "kernel/proc.h"
|
|
|
|
#include "sconst.h"
|
|
|
|
#include "multiboot.h"
|
|
|
|
|
|
|
|
#define GDT_SET_ENTRY(selector, base, limit) \
|
|
|
|
mov %ebp, %edi; \
|
2010-08-17 18:44:07 +02:00
|
|
|
add $(_C_LABEL(gdt) + selector), %edi; \
|
2010-07-23 16:24:34 +02:00
|
|
|
mov base, %eax; \
|
|
|
|
movw %ax, 2(%edi); \
|
|
|
|
shr $16, %eax; \
|
|
|
|
movb %al, 4(%edi); \
|
|
|
|
and $0xff00, %ax; \
|
|
|
|
andw $0xff, 6(%edi); \
|
|
|
|
or %ax, 6(%edi); \
|
|
|
|
mov limit, %eax; \
|
|
|
|
movw %ax, (%edi); \
|
|
|
|
shr $16, %eax; \
|
|
|
|
and $0xf, %ax; \
|
|
|
|
andb $0xf0, 6(%edi); \
|
|
|
|
or %ax, 6(%edi); \
|
2011-05-04 18:51:43 +02:00
|
|
|
|
2010-08-17 18:44:07 +02:00
|
|
|
IMPORT(pre_init)
|
|
|
|
.extern kernel_init
|
2010-07-23 16:24:34 +02:00
|
|
|
|
2011-05-04 18:51:43 +02:00
|
|
|
ENTRY(multiboot_init)
|
2010-07-23 16:24:34 +02:00
|
|
|
mov $(GDT_SIZE*DESC_SIZE), %eax
|
2011-05-04 18:51:43 +02:00
|
|
|
mov $(_C_LABEL(gdt) + GDT_SELECTOR), %edi
|
2010-07-23 16:24:34 +02:00
|
|
|
mov %ax, (%edi)
|
2011-05-04 18:51:43 +02:00
|
|
|
mov $_C_LABEL(gdt), %eax
|
2010-07-23 16:24:34 +02:00
|
|
|
mov %eax, 2(%edi)
|
|
|
|
lgdt (%edi)
|
|
|
|
ljmp $(CS_SELECTOR), $reload_cs
|
2011-05-04 18:51:43 +02:00
|
|
|
|
2010-07-23 16:24:34 +02:00
|
|
|
reload_cs:
|
|
|
|
mov $DS_SELECTOR, %eax
|
|
|
|
mov %eax, %ds
|
|
|
|
mov %eax, %ss
|
|
|
|
mov %eax, %es
|
|
|
|
|
|
|
|
mov $(multiboot_stack + MULTIBOOT_STACK_SIZE), %esp
|
|
|
|
|
|
|
|
push %ebx
|
2010-08-17 18:44:07 +02:00
|
|
|
call _C_LABEL(pre_init)
|
2010-07-23 16:24:34 +02:00
|
|
|
|
|
|
|
add $4, %esp
|
2011-05-04 18:51:43 +02:00
|
|
|
|
2010-07-23 16:24:34 +02:00
|
|
|
/* return to old boot code of kernel */
|
|
|
|
push %eax
|
|
|
|
push $MULTIBOOT_PARAM_BUF_SIZE
|
2010-08-17 18:44:07 +02:00
|
|
|
push $_C_LABEL(multiboot_param_buf)
|
2010-07-23 16:24:34 +02:00
|
|
|
push $0
|
2011-05-04 18:51:43 +02:00
|
|
|
|
2010-07-23 16:24:34 +02:00
|
|
|
mov $ES_SELECTOR, %eax
|
|
|
|
mov %eax, %es
|
2011-05-04 18:51:43 +02:00
|
|
|
|
2010-07-23 16:24:34 +02:00
|
|
|
jmp kernel_init
|
|
|
|
|
|
|
|
.data
|
2010-08-17 18:44:07 +02:00
|
|
|
LABEL(multiboot_param_buf)
|
|
|
|
.space MULTIBOOT_PARAM_BUF_SIZE
|
2010-07-23 16:24:34 +02:00
|
|
|
|
|
|
|
multiboot_stack:
|
|
|
|
.space MULTIBOOT_STACK_SIZE + 4
|