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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since cf155ed was 40898df, checked in by Martin Decky <martin@…>, 14 years ago

allow the boot framebuffer to be optional again

  • Property mode set to 100644
File size: 4.7 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 <arch/boot/boot.h>
30#include <arch/pm.h>
31#include <arch/cpuid.h>
32#include <genarch/multiboot/multiboot2.h>
33
34#define START_STACK (BOOT_OFFSET - BOOT_STACK_SIZE)
35
36.section K_TEXT_START, "ax"
37
38.code32
39
40.align 8
41.global multiboot2_image_start
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 tag_info_req_start:
50 .word MULTIBOOT2_TAG_INFO_REQ
51 .word MULTIBOOT2_FLAGS_REQUIRED
52 .long tag_info_req_end - tag_info_req_start
53 .long MULTIBOOT2_TAG_MODULE
54 .long MULTIBOOT2_TAG_MEMMAP
55#ifdef CONFIG_FB
56 .long MULTIBOOT2_TAG_FBINFO
57#endif
58 tag_info_req_end:
59
60 /* Address tag */
61 tag_address_start:
62 .word MULTIBOOT2_TAG_ADDRESS
63 .word MULTIBOOT2_FLAGS_REQUIRED
64 .long tag_address_end - tag_address_start
65 .long multiboot2_header_start
66 .long unmapped_ktext_start
67 .long 0
68 .long 0
69 tag_address_end:
70
71 /* Entry address tag */
72 tag_entry_address_start:
73 .word MULTIBOOT2_TAG_ENTRY_ADDRESS
74 .word MULTIBOOT2_FLAGS_REQUIRED
75 .long tag_entry_address_end - tag_entry_address_start
76 .long multiboot2_image_start
77 tag_entry_address_end:
78
79 /* Flags tag */
80 tag_flags_start:
81 .word MULTIBOOT2_TAG_FLAGS
82 .word MULTIBOOT2_FLAGS_REQUIRED
83 .long tag_flags_end - tag_flags_start
84 .long MULTIBOOT2_FLAGS_CONSOLE
85 tag_flags_end:
86
87#ifdef CONFIG_FB
88 /* Framebuffer tag */
89 tag_framebuffer_start:
90 .word MULTIBOOT2_TAG_FRAMEBUFFER
91 .word MULTIBOOT2_FLAGS_REQUIRED
92 .long tag_framebuffer_end - tag_framebuffer_start
93 .long CONFIG_BFB_WIDTH
94 .long CONFIG_BFB_HEIGHT
95 .long CONFIG_BFB_BPP
96 tag_framebuffer_end:
97#endif
98
99 /* Module alignment tag */
100 tag_module_align_start:
101 .word MULTIBOOT2_TAG_MODULE_ALIGN
102 .word MULTIBOOT2_FLAGS_REQUIRED
103 .long tag_module_align_end - tag_module_align_start
104 .long 0
105 tag_module_align_end:
106
107 /* Tag terminator */
108 tag_terminator_start:
109 .word MULTIBOOT2_TAG_TERMINATOR
110 .word MULTIBOOT2_FLAGS_REQUIRED
111 .long tag_terminator_end - tag_terminator_start
112 tag_terminator_end:
113multiboot2_header_end:
114
115multiboot2_image_start:
116 cld
117
118 /* Initialize stack pointer */
119 movl $START_STACK, %esp
120
121 /* Initialize Global Descriptor Table register */
122 lgdtl bootstrap_gdtr
123
124 /* Kernel data + stack */
125 movw $GDT_SELECTOR(KDATA_DES), %cx
126 movw %cx, %es
127 movw %cx, %fs
128 movw %cx, %gs
129 movw %cx, %ds
130 movw %cx, %ss
131
132 jmpl $GDT_SELECTOR(KTEXT_DES), $multiboot2_meeting_point
133 multiboot2_meeting_point:
134
135 /* Save multiboot arguments */
136 movl %eax, multiboot_eax
137 movl %ebx, multiboot_ebx
138
139#ifndef PROCESSOR_i486
140
141 movl $(INTEL_CPUID_LEVEL), %eax
142 cpuid
143 cmp $0x0, %eax /* any function > 0? */
144 jbe pse_unsupported
145
146 movl $(INTEL_CPUID_STANDARD), %eax
147 cpuid
148 bt $(INTEL_PSE), %edx
149 jnc pse_unsupported
150
151 /* Map kernel and turn paging on */
152 call map_kernel_pse
153 jmp stack_init
154
155#endif /* PROCESSOR_i486 */
156
157 pse_unsupported:
158
159 /* Map kernel and turn paging on */
160 call map_kernel_non_pse
161
162 stack_init:
163
164 /* Create the first stack frame */
165 pushl $0
166 movl %esp, %ebp
167
168 /* Call arch_pre_main(multiboot_eax, multiboot_ebx) */
169 pushl multiboot_ebx
170 pushl multiboot_eax
171 call arch_pre_main
172
173 /* Call main_bsp() */
174 call main_bsp
175
176 /* Not reached */
177 cli
178 hlt0:
179 hlt
180 jmp hlt0
Note: See TracBrowser for help on using the repository browser.