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