source: mainline/kernel/arch/ia32/src/boot/multiboot2.S@ 83dab11

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 83dab11 was 36df4109, checked in by Jakub Jermar <jakub@…>, 9 years ago

Introduce architecure-specific operations

This replaces the arch_*_init() functions with an arch_ops_t structure
defined for each architecture. Undefined operations are treated as NOPs.

  • Property mode set to 100644
File size: 4.9 KB
Line 
1/*
2 * Copyright (c) 2011 Martin Decky
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <abi/asmtool.h>
30#include <arch/boot/boot.h>
31#include <arch/pm.h>
32#include <arch/cpuid.h>
33#include <genarch/multiboot/multiboot2.h>
34
35#define START_STACK (BOOT_OFFSET - BOOT_STACK_SIZE)
36
37.section K_TEXT_START, "ax"
38
39.code32
40
41.align 8
42multiboot2_header_start:
43 .long MULTIBOOT2_HEADER_MAGIC
44 .long MULTIBOOT2_HEADER_ARCH_I386
45 .long multiboot2_header_end - multiboot2_header_start
46 .long -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT2_HEADER_ARCH_I386 + (multiboot2_header_end - multiboot2_header_start))
47
48 /* Information request tag */
49 .align 8
50 tag_info_req_start:
51 .word MULTIBOOT2_TAG_INFO_REQ
52 .word MULTIBOOT2_FLAGS_REQUIRED
53 .long tag_info_req_end - tag_info_req_start
54 .long MULTIBOOT2_TAG_MODULE
55 .long MULTIBOOT2_TAG_MEMMAP
56#ifdef CONFIG_FB
57 .long MULTIBOOT2_TAG_FBINFO
58#endif
59 tag_info_req_end:
60
61 /* Address tag */
62 .align 8
63 tag_address_start:
64 .word MULTIBOOT2_TAG_ADDRESS
65 .word MULTIBOOT2_FLAGS_REQUIRED
66 .long tag_address_end - tag_address_start
67 .long multiboot2_header_start
68 .long unmapped_ktext_start
69 .long 0
70 .long 0
71 tag_address_end:
72
73 /* Entry address tag */
74 .align 8
75 tag_entry_address_start:
76 .word MULTIBOOT2_TAG_ENTRY_ADDRESS
77 .word MULTIBOOT2_FLAGS_REQUIRED
78 .long tag_entry_address_end - tag_entry_address_start
79 .long multiboot2_image_start
80 tag_entry_address_end:
81
82 /* Flags tag */
83 .align 8
84 tag_flags_start:
85 .word MULTIBOOT2_TAG_FLAGS
86 .word MULTIBOOT2_FLAGS_REQUIRED
87 .long tag_flags_end - tag_flags_start
88 .long MULTIBOOT2_FLAGS_CONSOLE
89 tag_flags_end:
90
91#ifdef CONFIG_FB
92 /* Framebuffer tag */
93 .align 8
94 tag_framebuffer_start:
95 .word MULTIBOOT2_TAG_FRAMEBUFFER
96 .word MULTIBOOT2_FLAGS_REQUIRED
97 .long tag_framebuffer_end - tag_framebuffer_start
98 .long CONFIG_BFB_WIDTH
99 .long CONFIG_BFB_HEIGHT
100 .long CONFIG_BFB_BPP
101 tag_framebuffer_end:
102#endif
103
104 /* Module alignment tag */
105 .align 8
106 tag_module_align_start:
107 .word MULTIBOOT2_TAG_MODULE_ALIGN
108 .word MULTIBOOT2_FLAGS_REQUIRED
109 .long tag_module_align_end - tag_module_align_start
110 .long 0
111 tag_module_align_end:
112
113 /* Tag terminator */
114 .align 8
115 tag_terminator_start:
116 .word MULTIBOOT2_TAG_TERMINATOR
117 .word MULTIBOOT2_FLAGS_REQUIRED
118 .long tag_terminator_end - tag_terminator_start
119 tag_terminator_end:
120multiboot2_header_end:
121
122SYMBOL(multiboot2_image_start)
123 cli
124 cld
125
126 /* Initialize stack pointer */
127 movl $START_STACK, %esp
128
129 /*
130 * Initialize Global Descriptor Table and
131 * Interrupt Descriptor Table registers
132 */
133 lgdtl bootstrap_gdtr
134 lidtl bootstrap_idtr
135
136 /* Kernel data + stack */
137 movw $GDT_SELECTOR(KDATA_DES), %cx
138 movw %cx, %es
139 movw %cx, %fs
140 movw %cx, %gs
141 movw %cx, %ds
142 movw %cx, %ss
143
144 jmpl $GDT_SELECTOR(KTEXT_DES), $multiboot2_meeting_point
145 multiboot2_meeting_point:
146
147 /* Save multiboot arguments */
148 movl %eax, multiboot_eax
149 movl %ebx, multiboot_ebx
150
151#ifndef PROCESSOR_i486
152
153 movl $(INTEL_CPUID_LEVEL), %eax
154 cpuid
155 cmp $0x0, %eax /* any function > 0? */
156 jbe pse_unsupported
157
158 movl $(INTEL_CPUID_STANDARD), %eax
159 cpuid
160 bt $(INTEL_PSE), %edx
161 jnc pse_unsupported
162
163 /* Map kernel and turn paging on */
164 call map_kernel_pse
165 jmp stack_init
166
167#endif /* PROCESSOR_i486 */
168
169 pse_unsupported:
170
171 /* Map kernel and turn paging on */
172 call map_kernel_non_pse
173
174 stack_init:
175
176 /* Create the first stack frame */
177 pushl $0
178 movl %esp, %ebp
179
180 /* Call ia32_pre_main(multiboot_eax, multiboot_ebx) */
181 pushl multiboot_ebx
182 pushl multiboot_eax
183 call ia32_pre_main
184
185 /* Call main_bsp() */
186 call main_bsp
187
188 /* Not reached */
189 cli
190 hlt0:
191 hlt
192 jmp hlt0
Note: See TracBrowser for help on using the repository browser.