1*433d6423SLionel Sambuc#include "kernel/kernel.h" /* configures the kernel */ 2*433d6423SLionel Sambuc 3*433d6423SLionel Sambuc/* sections */ 4*433d6423SLionel Sambuc 5*433d6423SLionel Sambuc#include <machine/vm.h> 6*433d6423SLionel Sambuc#include "kernel/kernel.h" 7*433d6423SLionel Sambuc#include <minix/config.h> 8*433d6423SLionel Sambuc#include <minix/const.h> 9*433d6423SLionel Sambuc#include <minix/com.h> 10*433d6423SLionel Sambuc#include <machine/asm.h> 11*433d6423SLionel Sambuc#include <machine/interrupt.h> 12*433d6423SLionel Sambuc#include "archconst.h" 13*433d6423SLionel Sambuc#include "sconst.h" 14*433d6423SLionel Sambuc#include <machine/multiboot.h> 15*433d6423SLionel Sambuc 16*433d6423SLionel Sambuc#include "arch_proto.h" /* K_STACK_SIZE */ 17*433d6423SLionel Sambuc 18*433d6423SLionel Sambuc#ifdef CONFIG_SMP 19*433d6423SLionel Sambuc#include "kernel/smp.h" 20*433d6423SLionel Sambuc#endif 21*433d6423SLionel Sambuc 22*433d6423SLionel Sambuc/* Selected 386 tss offsets. */ 23*433d6423SLionel Sambuc#define TSS3_S_SP0 4 24*433d6423SLionel Sambuc 25*433d6423SLionel SambucIMPORT(copr_not_available_handler) 26*433d6423SLionel SambucIMPORT(params_size) 27*433d6423SLionel SambucIMPORT(params_offset) 28*433d6423SLionel SambucIMPORT(mon_ds) 29*433d6423SLionel SambucIMPORT(switch_to_user) 30*433d6423SLionel SambucIMPORT(multiboot_init) 31*433d6423SLionel Sambuc 32*433d6423SLionel Sambuc.text 33*433d6423SLionel Sambuc/*===========================================================================*/ 34*433d6423SLionel Sambuc/* MINIX */ 35*433d6423SLionel Sambuc/*===========================================================================*/ 36*433d6423SLionel Sambuc.global MINIX 37*433d6423SLionel SambucMINIX: 38*433d6423SLionel Sambuc/* this is the entry point for the MINIX kernel */ 39*433d6423SLionel Sambuc jmp multiboot_init 40*433d6423SLionel Sambuc 41*433d6423SLionel Sambuc/* Multiboot header here*/ 42*433d6423SLionel Sambuc 43*433d6423SLionel Sambuc.balign 8 44*433d6423SLionel Sambuc 45*433d6423SLionel Sambuc#define MULTIBOOT_FLAGS (MULTIBOOT_HEADER_WANT_MEMORY | MULTIBOOT_HEADER_MODS_ALIGNED) 46*433d6423SLionel Sambuc 47*433d6423SLionel Sambucmultiboot_magic: 48*433d6423SLionel Sambuc .long MULTIBOOT_HEADER_MAGIC 49*433d6423SLionel Sambucmultiboot_flags: 50*433d6423SLionel Sambuc .long MULTIBOOT_FLAGS 51*433d6423SLionel Sambucmultiboot_checksum: 52*433d6423SLionel Sambuc .long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_FLAGS) 53*433d6423SLionel Sambuc .long 0 54*433d6423SLionel Sambuc .long 0 55*433d6423SLionel Sambuc .long 0 56*433d6423SLionel Sambuc .long 0 57*433d6423SLionel Sambuc .long 0 58*433d6423SLionel Sambuc/* Video mode */ 59*433d6423SLionel Sambucmultiboot_mode_type: 60*433d6423SLionel Sambuc .long MULTIBOOT_VIDEO_MODE_EGA 61*433d6423SLionel Sambucmultiboot_width: 62*433d6423SLionel Sambuc .long MULTIBOOT_CONSOLE_COLS 63*433d6423SLionel Sambucmultiboot_height: 64*433d6423SLionel Sambuc .long MULTIBOOT_CONSOLE_LINES 65*433d6423SLionel Sambucmultiboot_depth: 66*433d6423SLionel Sambuc .long 0 67*433d6423SLionel Sambuc 68*433d6423SLionel Sambucmultiboot_init: 69*433d6423SLionel Sambuc mov $load_stack_start, %esp /* make usable stack */ 70*433d6423SLionel Sambuc mov $0, %ebp 71*433d6423SLionel Sambuc push $0 /* set flags to known good state */ 72*433d6423SLionel Sambuc popf /* esp, clear nested task and int enable */ 73*433d6423SLionel Sambuc push $0 74*433d6423SLionel Sambuc 75*433d6423SLionel Sambuc push %ebx /* multiboot information struct */ 76*433d6423SLionel Sambuc push %eax /* multiboot magic number */ 77*433d6423SLionel Sambuc call _C_LABEL(pre_init) 78*433d6423SLionel Sambuc 79*433d6423SLionel Sambuc /* Kernel is mapped high now and ready to go, with 80*433d6423SLionel Sambuc * the boot info pointer returnd in %eax. Set the 81*433d6423SLionel Sambuc * highly mapped stack, initialize it, push the boot 82*433d6423SLionel Sambuc * info pointer and jump to the highly mapped kernel. 83*433d6423SLionel Sambuc */ 84*433d6423SLionel Sambuc mov $k_initial_stktop, %esp 85*433d6423SLionel Sambuc push $0 /* Terminate stack */ 86*433d6423SLionel Sambuc push %eax 87*433d6423SLionel Sambuc call _C_LABEL(kmain) 88*433d6423SLionel Sambuc 89*433d6423SLionel Sambuc /* not reached */ 90*433d6423SLionel Sambuchang: 91*433d6423SLionel Sambuc jmp hang 92*433d6423SLionel Sambuc 93*433d6423SLionel Sambuc.data 94*433d6423SLionel Sambucload_stack: 95*433d6423SLionel Sambuc .space 4096 96*433d6423SLionel Sambucload_stack_start: 97