1 // Rom layout and bios assembler to C interface.
3 // Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net>
4 // Copyright (C) 2002 MandrakeSoft S.A.
6 // This file may be distributed under the terms of the GNU GPLv3 license.
12 .globl bios16c_start, bios16c_end
14 .include "out/blob.proc.16.s"
25 // Set entry point of rombios32 code - the actual instruction
26 // is altered later in the build process.
31 // init the stack pointer
32 movl $ CONFIG_STACK32_OFFSET , %esp
43 // Set segment descriptors
44 lidt %cs:pmode_IDT_info
45 lgdt %cs:rombios32_gdt_48
52 // start protected mode code
53 .word 0xea66, 1f, 0x000f, 0x0010 // ljmpl $0x10, $(1f | 0xf0000)
72 // We need a copy of this string, but we are not actually a PnP BIOS,
73 // so make sure it is *not* aligned, so OSes will not see it if they
80 // Return from 32bit code to 16bit code - must pass in destination
81 // code segment,offset (%ebx) and the return stack position (%esp).
85 // restore data segment limits to 0xffff
93 // reset PE bit in CR0
98 // far jump to flush CPU queue after transition to real mode
101 // restore IDT to normal real-mode defaults
102 lidt %cs:rmode_IDT_info
104 // Setup segment registers
112 movw $ CONFIG_STACK16_SEGMENT , %ax
115 movl $ CONFIG_STACK16_OFFSET , %esp
124 // Restore stack and jump back to 32bit mode.
128 // Set resume point of rombios32 code - the actual instruction
129 // is altered later in the build process.
132 mov $0xf0000000, %ebx
137 // Protected mode IDT descriptor
139 // I just make the limit 0, so the machine will shutdown
140 // if an exception occurs during protected mode memory
143 // Set base to f0000 to correspond to beginning of BIOS,
144 // in case I actually define an IDT later
147 .word 0x0000 // limit 15:00
148 .word 0x0000 // base 15:00
149 .byte 0x0f // base 23:16
151 // Real mode IDT descriptor
153 // Set to typical real-mode values.
157 .word 0x03ff // limit 15:00
158 .word 0x0000 // base 15:00
159 .byte 0x00 // base 23:16
169 .word 0xffff, 0, 0x9b00, 0x00cf // 32 bit flat code segment (0x10)
170 .word 0xffff, 0, 0x9300, 0x00cf // 32 bit flat data segment (0x18)
171 .word 0xffff, 0, 0x9b0f, 0x0000 // 16 bit code segment base=0xf0000 limit=0xffff
172 .word 0xffff, 0, 0x9300, 0x0000 // 16 bit data segment base=0x0 limit=0xffff
214 // XXX - Fixed Disk Parameter Table
220 .include "out/cbt.proc.16.s"
224 // XXX - Baud Rate Generator Table
242 // XXX - Diskette Controller Parameter Table
268 .include "out/font.proc.16.s"
278 // XXX - Initial Interrupt Vector Offsets Loaded by POST
281 // XXX - BIOS_COPYRIGHT_STRING
282 .ascii "(c) 2002 MandrakeSoft S.A. Written by Kevin Lawton & the Bochs team."
285 .globl dummy_iret_handler
292 .org 0xfff0 // Power-up Entry Point
293 ljmpw $0xf000, $post16
300 // model byte 0xFC = AT