blob: 9e3e3bae83a7939a0a4b9a5cabb69d1a2f1eb8c6 [file] [log] [blame]
Kevin O'Connorf076a3e2008-02-25 22:25:15 -05001// 32bit code to Power On Self Test (POST) a machine.
2//
3// Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net>
4// Copyright (C) 2002 MandrakeSoft S.A.
5//
6// This file may be distributed under the terms of the GNU GPLv3 license.
7
8#include "ioport.h" // PORT_*
Kevin O'Connorf076a3e2008-02-25 22:25:15 -05009#include "config.h" // CONFIG_*
10#include "cmos.h" // CMOS_*
11#include "util.h" // memset
12#include "biosvar.h" // struct bios_data_area_s
Kevin O'Connor2ad37442008-05-06 19:49:01 -040013#include "ata.h" // hard_drive_setup
Kevin O'Connor3bbcc142008-04-13 17:07:33 -040014#include "disk.h" // floppy_drive_setup
Kevin O'Connorc7812932008-06-08 23:08:12 -040015#include "memmap.h" // add_e820
Kevin O'Connorf54c1502008-06-14 15:56:16 -040016#include "pic.h" // pic_setup
Kevin O'Connor0525d292008-07-04 06:18:30 -040017#include "pci.h" // create_pirtable
18#include "acpi.h" // acpi_bios_init
Kevin O'Connor9521e262008-07-04 13:04:29 -040019#include "bregs.h" // struct bregs
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050020
Kevin O'Connor438f6352008-03-30 21:46:53 -040021#define bda ((struct bios_data_area_s *)MAKE_FARPTR(SEG_BDA, 0))
22#define ebda ((struct extended_bios_data_area_s *)MAKE_FARPTR(SEG_EBDA, 0))
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050023
24static void
Kevin O'Connor2fda7cb2008-07-05 20:41:53 -040025set_irq(int vector, void *loc)
Kevin O'Connore3677b12008-07-04 15:29:23 -040026{
27 SET_BDA(ivecs[vector].seg, SEG_BIOS);
Kevin O'Connor2fda7cb2008-07-05 20:41:53 -040028 SET_BDA(ivecs[vector].offset, (u32)loc - BUILD_BIOS_ADDR);
Kevin O'Connore3677b12008-07-04 15:29:23 -040029}
30
Kevin O'Connor2fda7cb2008-07-05 20:41:53 -040031// Symbols defined in romlayout.S
32extern void dummy_iret_handler();
33extern void entry_08();
34extern void entry_09();
35extern void entry_hwirq();
36extern void entry_0e();
37extern void entry_10();
38extern void entry_11();
39extern void entry_12();
40extern void entry_13();
41extern void entry_14();
42extern void entry_15();
43extern void entry_16();
44extern void entry_17();
45extern void entry_18();
46extern void entry_19();
47extern void entry_1a();
48extern void entry_1c();
49extern void entry_40();
50extern void entry_70();
51extern void entry_74();
52extern void entry_75();
53extern void entry_76();
54
Kevin O'Connore3677b12008-07-04 15:29:23 -040055static void
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050056init_bda()
57{
Kevin O'Connor35192dd2008-06-08 19:18:33 -040058 dprintf(3, "init bda\n");
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050059 memset(bda, 0, sizeof(*bda));
60
Kevin O'Connorf54c1502008-06-14 15:56:16 -040061 SET_BDA(mem_size_kb, BASE_MEM_IN_K);
62
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050063 int i;
Kevin O'Connore3677b12008-07-04 15:29:23 -040064 for (i=0; i<256; i++)
Kevin O'Connor2fda7cb2008-07-05 20:41:53 -040065 set_irq(i, &dummy_iret_handler);
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050066
Kevin O'Connor2fda7cb2008-07-05 20:41:53 -040067 set_irq(0x08, &entry_08);
68 set_irq(0x09, &entry_09);
69 //set_irq(0x0a, &entry_hwirq);
70 //set_irq(0x0b, &entry_hwirq);
71 //set_irq(0x0c, &entry_hwirq);
72 //set_irq(0x0d, &entry_hwirq);
73 set_irq(0x0e, &entry_0e);
74 //set_irq(0x0f, &entry_hwirq);
75 set_irq(0x10, &entry_10);
76 set_irq(0x11, &entry_11);
77 set_irq(0x12, &entry_12);
78 set_irq(0x13, &entry_13);
79 set_irq(0x14, &entry_14);
80 set_irq(0x15, &entry_15);
81 set_irq(0x16, &entry_16);
82 set_irq(0x17, &entry_17);
83 set_irq(0x18, &entry_18);
84 set_irq(0x19, &entry_19);
85 set_irq(0x1a, &entry_1a);
86 set_irq(0x1c, &entry_1c);
87 set_irq(0x40, &entry_40);
88 set_irq(0x70, &entry_70);
89 //set_irq(0x71, &entry_hwirq);
90 //set_irq(0x72, &entry_hwirq);
91 //set_irq(0x73, &entry_hwirq);
92 set_irq(0x74, &entry_74);
93 set_irq(0x75, &entry_75);
94 set_irq(0x76, &entry_76);
95 //set_irq(0x77, &entry_hwirq);
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050096
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050097 // set vector 0x79 to zero
98 // this is used by 'gardian angel' protection system
Kevin O'Connore9061492008-03-11 21:54:18 -040099 SET_BDA(ivecs[0x79].seg, 0);
100 SET_BDA(ivecs[0x79].offset, 0);
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500101
Kevin O'Connor2fda7cb2008-07-05 20:41:53 -0400102 set_irq(0x1E, &diskette_param_table2);
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500103}
104
105static void
106init_ebda()
107{
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500108 memset(ebda, 0, sizeof(*ebda));
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500109 ebda->size = EBDA_SIZE;
Kevin O'Connor438f6352008-03-30 21:46:53 -0400110 SET_BDA(ebda_seg, SEG_EBDA);
111 SET_BDA(ivecs[0x41].seg, SEG_EBDA);
Kevin O'Connore9061492008-03-11 21:54:18 -0400112 SET_BDA(ivecs[0x41].offset
Kevin O'Connor9f0d94d2008-04-13 17:25:30 -0400113 , offsetof(struct extended_bios_data_area_s, fdpt[0]));
Kevin O'Connor438f6352008-03-30 21:46:53 -0400114 SET_BDA(ivecs[0x46].seg, SEG_EBDA);
Kevin O'Connore9061492008-03-11 21:54:18 -0400115 SET_BDA(ivecs[0x41].offset
Kevin O'Connor9f0d94d2008-04-13 17:25:30 -0400116 , offsetof(struct extended_bios_data_area_s, fdpt[1]));
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500117}
118
119static void
Kevin O'Connor9571ac22008-05-17 22:20:27 -0400120ram_probe(void)
121{
Kevin O'Connor35192dd2008-06-08 19:18:33 -0400122 dprintf(3, "Find memory size\n");
Kevin O'Connorf64f0db2008-05-18 02:42:58 -0400123 if (CONFIG_COREBOOT) {
Kevin O'Connorc7812932008-06-08 23:08:12 -0400124 coreboot_fill_map();
Kevin O'Connorf64f0db2008-05-18 02:42:58 -0400125 } else {
126 // On emulators, get memory size from nvram.
Kevin O'Connorc7812932008-06-08 23:08:12 -0400127 u32 rs = (inb_cmos(CMOS_MEM_EXTMEM2_LOW)
128 | (inb_cmos(CMOS_MEM_EXTMEM2_HIGH) << 8)) * 65536;
Kevin O'Connorf64f0db2008-05-18 02:42:58 -0400129 if (rs)
130 rs += 16 * 1024 * 1024;
131 else
132 rs = ((inb_cmos(CMOS_MEM_EXTMEM_LOW)
133 | (inb_cmos(CMOS_MEM_EXTMEM_HIGH) << 8)) * 1024
134 + 1 * 1024 * 1024);
Kevin O'Connorc7812932008-06-08 23:08:12 -0400135 SET_EBDA(ram_size, rs);
136 add_e820(0, rs, E820_RAM);
137
138 /* reserve 256KB BIOS area at the end of 4 GB */
139 add_e820(0xfffc0000, 256*1024, E820_RESERVED);
Kevin O'Connorf64f0db2008-05-18 02:42:58 -0400140 }
Kevin O'Connor9571ac22008-05-17 22:20:27 -0400141
Kevin O'Connorb8d7a472008-06-21 11:43:32 -0400142 // Don't declare any memory between 0xa0000 and 0x100000
143 add_e820(0xa0000, 0x50000, E820_HOLE);
144
Kevin O'Connorc7812932008-06-08 23:08:12 -0400145 // Mark known areas as reserved.
146 add_e820((u32)MAKE_FARPTR(SEG_EBDA, 0), EBDA_SIZE * 1024, E820_RESERVED);
Kevin O'Connore3677b12008-07-04 15:29:23 -0400147 add_e820(BUILD_BIOS_ADDR, BUILD_BIOS_SIZE, E820_RESERVED);
Kevin O'Connorc7812932008-06-08 23:08:12 -0400148
149 dprintf(1, "ram_size=0x%08x\n", GET_EBDA(ram_size));
Kevin O'Connor9571ac22008-05-17 22:20:27 -0400150}
151
152static void
Kevin O'Connor0525d292008-07-04 06:18:30 -0400153init_bios_tables(void)
154{
155 if (CONFIG_COREBOOT)
156 // XXX - not supported on coreboot yet.
157 return;
158
159 smm_init();
160
161 create_pirtable();
162
163 mptable_init();
164
165 smbios_init();
166
167 acpi_bios_init();
168}
169
170static void
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500171init_boot_vectors()
172{
Kevin O'Connor35192dd2008-06-08 19:18:33 -0400173 dprintf(3, "init boot device ordering\n");
174
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500175 // Floppy drive
Kevin O'Connor56a506d2008-03-29 13:15:36 -0400176 struct ipl_entry_s *ip = &ebda->ipl.table[0];
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500177 ip->type = IPL_TYPE_FLOPPY;
178 ip++;
179
180 // First HDD
181 ip->type = IPL_TYPE_HARDDISK;
182 ip++;
183
184 // CDROM
Kevin O'Connor180a9592008-03-04 22:50:53 -0500185 if (CONFIG_CDROM_BOOT) {
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500186 ip->type = IPL_TYPE_CDROM;
187 ip++;
188 }
189
Kevin O'Connor56a506d2008-03-29 13:15:36 -0400190 ebda->ipl.count = ip - ebda->ipl.table;
191 ebda->ipl.sequence = 0xffff;
Kevin O'Connorf64f0db2008-05-18 02:42:58 -0400192 if (CONFIG_COREBOOT) {
193 // XXX - hardcode defaults for coreboot.
194 ebda->ipl.bootorder = 0x00000231;
Kevin O'Connorabc75972008-05-18 00:20:53 -0400195 ebda->ipl.checkfloppysig = 1;
Kevin O'Connorf64f0db2008-05-18 02:42:58 -0400196 } else {
197 // On emulators, get boot order from nvram.
198 ebda->ipl.bootorder = (inb_cmos(CMOS_BIOS_BOOTFLAG2)
199 | ((inb_cmos(CMOS_BIOS_BOOTFLAG1) & 0xf0) << 4));
200 if (!(inb_cmos(CMOS_BIOS_BOOTFLAG1) & 1))
201 ebda->ipl.checkfloppysig = 1;
202 }
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500203}
204
Kevin O'Connorda4a6482008-06-08 13:48:06 -0400205// Execute a given option rom.
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500206static void
207callrom(u16 seg, u16 offset)
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500208{
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500209 struct bregs br;
210 memset(&br, 0, sizeof(br));
Kevin O'Connor44c631d2008-03-02 11:24:36 -0500211 br.es = SEG_BIOS;
Kevin O'Connore3677b12008-07-04 15:29:23 -0400212 // starts 1 past for alignment
Kevin O'Connor2fda7cb2008-07-05 20:41:53 -0400213 extern char pnp_string[];
214 br.di = (u32)pnp_string - BUILD_BIOS_ADDR + 1;
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500215 br.cs = seg;
216 br.ip = offset;
217 call16(&br);
Kevin O'Connor61d6b062008-06-21 12:15:10 -0400218
219 debug_serial_setup();
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500220}
221
Kevin O'Connorda4a6482008-06-08 13:48:06 -0400222// Find and run any "option roms" found in the given address range.
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500223static void
Kevin O'Connora2e73802008-02-27 10:27:00 -0500224rom_scan(u32 start, u32 end)
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500225{
Kevin O'Connora2e73802008-02-27 10:27:00 -0500226 u8 *p = (u8*)start;
227 for (; p <= (u8*)end; p += 2048) {
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500228 u8 *rom = p;
229 if (*(u16*)rom != 0xaa55)
230 continue;
231 u32 len = rom[2] * 512;
Kevin O'Connor61d6b062008-06-21 12:15:10 -0400232 u8 sum = checksum(rom, len);
233 if (sum != 0) {
234 dprintf(1, "Found option rom with bad checksum:"
235 " loc=%p len=%d sum=%x\n"
236 , rom, len, sum);
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500237 continue;
Kevin O'Connor61d6b062008-06-21 12:15:10 -0400238 }
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500239 p = (u8*)(((u32)p + len) / 2048 * 2048);
Kevin O'Connorc1adedc2008-06-07 10:24:48 -0400240 dprintf(1, "Running option rom at %p\n", rom+3);
Kevin O'Connor070231b2008-03-22 20:44:37 -0400241 callrom(FARPTR_TO_SEG(rom), FARPTR_TO_OFFSET(rom + 3));
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500242
Kevin O'Connorc1adedc2008-06-07 10:24:48 -0400243 if (GET_BDA(ebda_seg) != SEG_EBDA)
244 BX_PANIC("Option rom at %p attempted to move ebda from %x to %x\n"
245 , rom, SEG_EBDA, GET_BDA(ebda_seg));
246
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500247 // Look at the ROM's PnP Expansion header. Properly, we're supposed
248 // to init all the ROMs and then go back and build an IPL table of
249 // all the bootable devices, but we can get away with one pass.
250 if (rom[0x1a] != '$' || rom[0x1b] != 'P'
251 || rom[0x1c] != 'n' || rom[0x1d] != 'P')
252 continue;
253 // 0x1A is also the offset into the expansion header of...
254 // the Bootstrap Entry Vector, or zero if there is none.
255 u16 entry = *(u16*)&rom[0x1a+0x1a];
256 if (!entry)
257 continue;
258 // Found a device that thinks it can boot the system. Record
259 // its BEV and product name string.
260
Kevin O'Connor56a506d2008-03-29 13:15:36 -0400261 if (ebda->ipl.count >= ARRAY_SIZE(ebda->ipl.table))
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500262 continue;
263
Kevin O'Connor56a506d2008-03-29 13:15:36 -0400264 struct ipl_entry_s *ip = &ebda->ipl.table[ebda->ipl.count];
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500265 ip->type = IPL_TYPE_BEV;
Kevin O'Connor070231b2008-03-22 20:44:37 -0400266 ip->vector = (FARPTR_TO_SEG(rom) << 16) | entry;
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500267
268 u16 desc = *(u16*)&rom[0x1a+0x10];
269 if (desc)
Kevin O'Connore0113c92008-04-05 15:51:12 -0400270 ip->description = (u32)MAKE_FARPTR(FARPTR_TO_SEG(rom), desc);
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500271
Kevin O'Connor56a506d2008-03-29 13:15:36 -0400272 ebda->ipl.count++;
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500273 }
274}
275
Kevin O'Connorda4a6482008-06-08 13:48:06 -0400276// Main setup code.
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500277static void
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500278post()
279{
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500280 init_bda();
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500281 init_ebda();
282
Kevin O'Connorf54c1502008-06-14 15:56:16 -0400283 pic_setup();
Kevin O'Connore6eb3f52008-04-13 17:37:41 -0400284 timer_setup();
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500285 kbd_setup();
286 lpt_setup();
287 serial_setup();
Kevin O'Connorf54c1502008-06-14 15:56:16 -0400288 mouse_setup();
289 mathcp_setup();
Kevin O'Connora2e73802008-02-27 10:27:00 -0500290
Kevin O'Connorc7812932008-06-08 23:08:12 -0400291 memmap_setup();
292
Kevin O'Connor9571ac22008-05-17 22:20:27 -0400293 ram_probe();
294
Kevin O'Connorac8df8c2008-05-24 23:46:33 -0400295 dprintf(1, "Scan for VGA option rom\n");
Kevin O'Connora2e73802008-02-27 10:27:00 -0500296 rom_scan(0xc0000, 0xc7800);
297
298 printf("BIOS - begin\n\n");
299
Kevin O'Connor0525d292008-07-04 06:18:30 -0400300 pci_bios_setup();
301
302 init_bios_tables();
Kevin O'Connora4d35762008-03-08 15:43:03 -0500303
Kevin O'Connorc7812932008-06-08 23:08:12 -0400304 memmap_finalize();
305
Kevin O'Connor3bbcc142008-04-13 17:07:33 -0400306 floppy_drive_setup();
Kevin O'Connor9f0d94d2008-04-13 17:25:30 -0400307 hard_drive_setup();
Kevin O'Connora2e73802008-02-27 10:27:00 -0500308
309 init_boot_vectors();
Kevin O'Connora4d35762008-03-08 15:43:03 -0500310
Kevin O'Connorac8df8c2008-05-24 23:46:33 -0400311 dprintf(1, "Scan for option roms\n");
Kevin O'Connora2e73802008-02-27 10:27:00 -0500312 rom_scan(0xc8000, 0xe0000);
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500313}
314
Kevin O'Connorda4a6482008-06-08 13:48:06 -0400315// Clear .bss section for C code.
316static void
317clear_bss()
318{
319 dprintf(3, "clearing .bss section\n");
320 extern char __bss_start[], __bss_end[];
321 memset(__bss_start, 0, __bss_end - __bss_start);
322}
323
324// Reset DMA controller
Kevin O'Connor95576e72008-03-01 09:57:51 -0500325static void
326init_dma()
327{
328 // first reset the DMA controllers
329 outb(0, PORT_DMA1_MASTER_CLEAR);
330 outb(0, PORT_DMA2_MASTER_CLEAR);
331
332 // then initialize the DMA controllers
333 outb(0xc0, PORT_DMA2_MODE_REG);
334 outb(0x00, PORT_DMA2_MASK_REG);
335}
336
Kevin O'Connorda4a6482008-06-08 13:48:06 -0400337// Check if the machine was setup with a special restart vector.
Kevin O'Connor95576e72008-03-01 09:57:51 -0500338static void
339check_restart_status()
340{
341 // Get and then clear CMOS shutdown status.
342 u8 status = inb_cmos(CMOS_RESET_CODE);
343 outb_cmos(0, CMOS_RESET_CODE);
344
345 if (status == 0x00 || status == 0x09 || status >= 0x0d)
346 // Normal post
347 return;
348
Kevin O'Connorad4ec342008-03-02 23:25:11 -0500349 if (status != 0x05) {
350 BX_PANIC("Unimplemented shutdown status: %02x\n", status);
351 return;
352 }
Kevin O'Connor95576e72008-03-01 09:57:51 -0500353
Kevin O'Connorad4ec342008-03-02 23:25:11 -0500354 // XXX - this is supposed to jump without changing any memory -
355 // but the stack has been altered by the time the code gets here.
Kevin O'Connorf54c1502008-06-14 15:56:16 -0400356 eoi_pic2();
Kevin O'Connorad4ec342008-03-02 23:25:11 -0500357 struct bregs br;
358 memset(&br, 0, sizeof(br));
Kevin O'Connore9061492008-03-11 21:54:18 -0400359 br.cs = GET_BDA(jump_cs_ip) >> 16;
360 br.ip = GET_BDA(jump_cs_ip);
Kevin O'Connorad4ec342008-03-02 23:25:11 -0500361 call16(&br);
Kevin O'Connor95576e72008-03-01 09:57:51 -0500362}
363
Kevin O'Connorda4a6482008-06-08 13:48:06 -0400364// 32-bit entry point.
Kevin O'Connor19786762008-03-05 21:09:59 -0500365void VISIBLE32
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500366_start()
367{
Kevin O'Connor95576e72008-03-01 09:57:51 -0500368 init_dma();
369 check_restart_status();
370
Kevin O'Connor61d6b062008-06-21 12:15:10 -0400371 debug_serial_setup();
Kevin O'Connorda4a6482008-06-08 13:48:06 -0400372 dprintf(1, "Start bios\n");
373
374 // Setup for .bss and .data sections
375 clear_bss();
376 make_bios_writable();
377
378 // Perform main setup code.
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500379 post();
Kevin O'Connorda4a6482008-06-08 13:48:06 -0400380
381 // Present the user with a bootup menu.
382 interactive_bootmenu();
383
Kevin O'Connore90f2642008-06-28 12:18:39 -0400384 // Setup bios checksum.
Kevin O'Connor2fda7cb2008-07-05 20:41:53 -0400385 extern char bios_checksum;
386 bios_checksum = -checksum((u8*)BUILD_BIOS_ADDR, BUILD_BIOS_SIZE - 1);
Kevin O'Connore90f2642008-06-28 12:18:39 -0400387
Kevin O'Connorda4a6482008-06-08 13:48:06 -0400388 // Prep for boot process.
389 make_bios_readonly();
390 clear_bss();
391
392 // Invoke int 19 to start boot process.
393 dprintf(3, "Jump to int19\n");
394 struct bregs br;
395 memset(&br, 0, sizeof(br));
396 call16_int(0x19, &br);
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500397}
Kevin O'Connor4b39b822008-05-08 21:47:33 -0400398
Kevin O'Connor2fda7cb2008-07-05 20:41:53 -0400399// Ughh - some older gcc compilers have a bug which causes VISIBLE32
400// functions to not be exported as a global variable - force _start
401// to be global here.
402asm(".global _start");
403
Kevin O'Connor4b39b822008-05-08 21:47:33 -0400404// Externally visible 32bit entry point.
405asm(
406 ".global post32\n"
407 "post32:\n"
408 "cli\n"
409 "cld\n"
Kevin O'Connor2fda7cb2008-07-05 20:41:53 -0400410 "lidtl pmode_IDT_info\n"
411 "lgdtl rombios32_gdt_48\n"
Kevin O'Connor276d4a92008-06-11 22:47:01 -0400412 "movl $" __stringify(BUILD_STACK_ADDR) ", %esp\n"
Kevin O'Connor59fead62008-05-10 15:49:20 -0400413 "ljmp $0x10, $_start\n"
Kevin O'Connor4b39b822008-05-08 21:47:33 -0400414 );