2010-04-25 22:42:02 +02:00
|
|
|
#include <cpu/x86/post_code.h>
|
2004-10-30 10:05:41 +02:00
|
|
|
|
2013-02-06 22:28:40 +01:00
|
|
|
/* Place the stack in the bss section. It's not necessary to define it in the
|
|
|
|
* the linker script. */
|
|
|
|
.section .bss, "aw", @nobits
|
|
|
|
.global _stack
|
|
|
|
.global _estack
|
|
|
|
|
|
|
|
.align CONFIG_STACK_SIZE
|
|
|
|
_stack:
|
|
|
|
.space CONFIG_MAX_CPUS*CONFIG_STACK_SIZE
|
|
|
|
_estack:
|
2013-05-06 19:22:23 +02:00
|
|
|
#if CONFIG_COOP_MULTITASKING
|
|
|
|
.global thread_stacks
|
|
|
|
thread_stacks:
|
|
|
|
.space CONFIG_STACK_SIZE*CONFIG_NUM_THREADS
|
|
|
|
#endif
|
2013-02-06 22:28:40 +01:00
|
|
|
|
New mechanism to define SRAM/memory map with automatic bounds checking
This patch creates a new mechanism to define the static memory layout
(primarily in SRAM) for a given board, superseding the brittle mass of
Kconfigs that we were using before. The core part is a memlayout.ld file
in the mainboard directory (although boards are expected to just include
the SoC default in most cases), which is the primary linker script for
all stages (though not rmodules for now). It uses preprocessor macros
from <memlayout.h> to form a different valid linker script for all
stages while looking like a declarative, boilerplate-free map of memory
addresses to the programmer. Linker asserts will automatically guarantee
that the defined regions cannot overlap. Stages are defined with a
maximum size that will be enforced by the linker. The file serves to
both define and document the memory layout, so that the documentation
cannot go missing or out of date.
The mechanism is implemented for all boards in the ARM, ARM64 and MIPS
architectures, and should be extended onto all systems using SRAM in the
future. The CAR/XIP environment on x86 has very different requirements
and the layout is generally not as static, so it will stay like it is
and be unaffected by this patch (save for aligning some symbol names for
consistency and sharing the new common ramstage linker script include).
BUG=None
TEST=Booted normally and in recovery mode, checked suspend/resume and
the CBMEM console on Falco, Blaze (both normal and vboot2), Pinky and
Pit. Compiled Ryu, Storm and Urara, manually compared the disassemblies
with ToT and looked for red flags.
Change-Id: Ifd2276417f2036cbe9c056f17e42f051bcd20e81
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: f1e2028e7ebceeb2d71ff366150a37564595e614
Original-Change-Id: I005506add4e8fcdb74db6d5e6cb2d4cb1bd3cda5
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/213370
Reviewed-on: http://review.coreboot.org/9283
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Tauner <stefan.tauner@gmx.at>
Reviewed-by: Aaron Durbin <adurbin@google.com>
2014-08-21 00:29:56 +02:00
|
|
|
.section ".text._start", "ax", @progbits
|
2015-06-18 10:23:48 +02:00
|
|
|
#ifdef __x86_64__
|
|
|
|
.code64
|
|
|
|
#else
|
2003-04-22 21:02:15 +02:00
|
|
|
.code32
|
2015-06-18 10:23:48 +02:00
|
|
|
#endif
|
2003-04-22 21:02:15 +02:00
|
|
|
.globl _start
|
|
|
|
_start:
|
|
|
|
cli
|
|
|
|
lgdt %cs:gdtaddr
|
2015-06-18 10:23:48 +02:00
|
|
|
#ifndef __x86_64__
|
2003-04-22 21:02:15 +02:00
|
|
|
ljmp $0x10, $1f
|
2015-06-18 10:23:48 +02:00
|
|
|
#endif
|
2003-04-22 21:02:15 +02:00
|
|
|
1: movl $0x18, %eax
|
|
|
|
movl %eax, %ds
|
|
|
|
movl %eax, %es
|
|
|
|
movl %eax, %ss
|
|
|
|
movl %eax, %fs
|
|
|
|
movl %eax, %gs
|
2015-06-18 10:23:48 +02:00
|
|
|
#ifdef __x86_64__
|
|
|
|
mov $0x48, %ecx
|
|
|
|
call SetCodeSelector
|
|
|
|
#endif
|
2003-04-22 21:02:15 +02:00
|
|
|
|
2011-04-11 22:17:22 +02:00
|
|
|
post_code(POST_ENTRY_C_START) /* post 13 */
|
2003-04-22 21:02:15 +02:00
|
|
|
|
2005-07-06 19:17:25 +02:00
|
|
|
cld
|
2003-04-22 21:02:15 +02:00
|
|
|
|
2013-02-06 22:28:40 +01:00
|
|
|
/** poison the stack. Code should not count on the
|
|
|
|
* stack being full of zeros. This stack poisoning
|
|
|
|
* recently uncovered a bug in the broadcast SIPI
|
|
|
|
* code.
|
|
|
|
*/
|
|
|
|
leal _stack, %edi
|
|
|
|
movl $_estack, %ecx
|
|
|
|
subl %edi, %ecx
|
|
|
|
shrl $2, %ecx /* it is 32 bit aligned, right? */
|
|
|
|
movl $0xDEADBEEF, %eax
|
|
|
|
rep
|
|
|
|
stosl
|
|
|
|
|
2003-04-22 21:02:15 +02:00
|
|
|
/* set new stack */
|
|
|
|
movl $_estack, %esp
|
|
|
|
|
2013-05-06 19:22:23 +02:00
|
|
|
#if CONFIG_COOP_MULTITASKING
|
|
|
|
/* Push the thread pointer. */
|
2015-06-18 10:23:48 +02:00
|
|
|
push $0
|
2013-05-06 19:22:23 +02:00
|
|
|
#endif
|
2004-10-14 22:54:17 +02:00
|
|
|
/* Push the cpu index and struct cpu */
|
2015-06-18 10:23:48 +02:00
|
|
|
push $0
|
|
|
|
push $0
|
2003-04-22 21:02:15 +02:00
|
|
|
|
2004-10-30 10:05:41 +02:00
|
|
|
/* Initialize the Interrupt Descriptor table */
|
|
|
|
leal _idt, %edi
|
|
|
|
leal vec0, %ebx
|
|
|
|
movl $(0x10 << 16), %eax /* cs selector */
|
|
|
|
|
|
|
|
1: movw %bx, %ax
|
|
|
|
movl %ebx, %edx
|
|
|
|
movw $0x8E00, %dx /* Interrupt gate - dpl=0, present */
|
|
|
|
movl %eax, 0(%edi)
|
|
|
|
movl %edx, 4(%edi)
|
|
|
|
addl $6, %ebx
|
|
|
|
addl $8, %edi
|
|
|
|
cmpl $_idt_end, %edi
|
|
|
|
jne 1b
|
|
|
|
|
|
|
|
/* Load the Interrupt descriptor table */
|
2015-06-18 10:23:48 +02:00
|
|
|
#ifndef __x86_64__
|
2004-10-30 10:05:41 +02:00
|
|
|
lidt idtarg
|
2015-06-18 10:23:48 +02:00
|
|
|
#else
|
|
|
|
// FIXME port table to x64 - lidt idtarg
|
|
|
|
#endif
|
2004-10-30 10:05:41 +02:00
|
|
|
|
2003-04-22 21:02:15 +02:00
|
|
|
/*
|
|
|
|
* Now we are finished. Memory is up, data is copied and
|
|
|
|
* bss is cleared. Now we call the main routine and
|
|
|
|
* let it do the rest.
|
2010-04-26 14:08:51 +02:00
|
|
|
*/
|
2011-04-11 22:17:22 +02:00
|
|
|
post_code(POST_PRE_HARDWAREMAIN) /* post fe */
|
2003-04-22 21:02:15 +02:00
|
|
|
|
2012-11-16 22:34:48 +01:00
|
|
|
#if CONFIG_GDB_WAIT
|
2014-04-04 14:05:28 +02:00
|
|
|
call gdb_hw_init
|
2012-06-22 15:56:37 +02:00
|
|
|
call gdb_stub_breakpoint
|
|
|
|
#endif
|
2013-05-10 01:30:06 +02:00
|
|
|
call main
|
2010-04-26 14:08:51 +02:00
|
|
|
/* NOTREACHED */
|
2003-04-22 21:02:15 +02:00
|
|
|
.Lhlt:
|
2011-04-11 22:17:22 +02:00
|
|
|
post_code(POST_DEAD_CODE) /* post ee */
|
2003-04-22 21:02:15 +02:00
|
|
|
hlt
|
|
|
|
jmp .Lhlt
|
2010-04-26 14:08:51 +02:00
|
|
|
|
2004-10-30 10:05:41 +02:00
|
|
|
vec0:
|
2015-06-18 10:23:48 +02:00
|
|
|
push $0 /* error code */
|
|
|
|
push $0 /* vector */
|
2004-10-30 10:05:41 +02:00
|
|
|
jmp int_hand
|
|
|
|
vec1:
|
2015-06-18 10:23:48 +02:00
|
|
|
push $0 /* error code */
|
|
|
|
push $1 /* vector */
|
2004-10-30 10:05:41 +02:00
|
|
|
jmp int_hand
|
2010-04-26 14:08:51 +02:00
|
|
|
|
2004-10-30 10:05:41 +02:00
|
|
|
vec2:
|
2015-06-18 10:23:48 +02:00
|
|
|
push $0 /* error code */
|
|
|
|
push $2 /* vector */
|
2004-10-30 10:05:41 +02:00
|
|
|
jmp int_hand
|
2010-04-26 14:08:51 +02:00
|
|
|
|
2004-10-30 10:05:41 +02:00
|
|
|
vec3:
|
2015-06-18 10:23:48 +02:00
|
|
|
push $0 /* error code */
|
|
|
|
push $3 /* vector */
|
2004-10-30 10:05:41 +02:00
|
|
|
jmp int_hand
|
2010-04-26 14:08:51 +02:00
|
|
|
|
2004-10-30 10:05:41 +02:00
|
|
|
vec4:
|
2015-06-18 10:23:48 +02:00
|
|
|
push $0 /* error code */
|
|
|
|
push $4 /* vector */
|
2004-10-30 10:05:41 +02:00
|
|
|
jmp int_hand
|
2010-04-26 14:08:51 +02:00
|
|
|
|
2004-10-30 10:05:41 +02:00
|
|
|
vec5:
|
2015-06-18 10:23:48 +02:00
|
|
|
push $0 /* error code */
|
|
|
|
push $5 /* vector */
|
2004-10-30 10:05:41 +02:00
|
|
|
jmp int_hand
|
2010-04-26 14:08:51 +02:00
|
|
|
|
2004-10-30 10:05:41 +02:00
|
|
|
vec6:
|
2015-06-18 10:23:48 +02:00
|
|
|
push $0 /* error code */
|
|
|
|
push $6 /* vector */
|
2004-10-30 10:05:41 +02:00
|
|
|
jmp int_hand
|
2010-04-26 14:08:51 +02:00
|
|
|
|
2004-10-30 10:05:41 +02:00
|
|
|
vec7:
|
2015-06-18 10:23:48 +02:00
|
|
|
push $0 /* error code */
|
|
|
|
push $7 /* vector */
|
2004-10-30 10:05:41 +02:00
|
|
|
jmp int_hand
|
2010-04-26 14:08:51 +02:00
|
|
|
|
2004-10-30 10:05:41 +02:00
|
|
|
vec8:
|
|
|
|
/* error code */
|
2015-06-18 10:23:48 +02:00
|
|
|
push $8 /* vector */
|
2004-10-30 10:05:41 +02:00
|
|
|
jmp int_hand
|
|
|
|
.word 0x9090
|
2010-04-26 14:08:51 +02:00
|
|
|
|
2004-10-30 10:05:41 +02:00
|
|
|
vec9:
|
2015-06-18 10:23:48 +02:00
|
|
|
push $0 /* error code */
|
|
|
|
push $9 /* vector */
|
2004-10-30 10:05:41 +02:00
|
|
|
jmp int_hand
|
2010-04-26 14:08:51 +02:00
|
|
|
|
2004-10-30 10:05:41 +02:00
|
|
|
vec10:
|
|
|
|
/* error code */
|
2015-06-18 10:23:48 +02:00
|
|
|
push $10 /* vector */
|
2004-10-30 10:05:41 +02:00
|
|
|
jmp int_hand
|
|
|
|
.word 0x9090
|
2010-04-26 14:08:51 +02:00
|
|
|
|
2004-10-30 10:05:41 +02:00
|
|
|
vec11:
|
|
|
|
/* error code */
|
2015-06-18 10:23:48 +02:00
|
|
|
push $11 /* vector */
|
2004-10-30 10:05:41 +02:00
|
|
|
jmp int_hand
|
|
|
|
.word 0x9090
|
2010-04-26 14:08:51 +02:00
|
|
|
|
2004-10-30 10:05:41 +02:00
|
|
|
vec12:
|
|
|
|
/* error code */
|
2015-06-18 10:23:48 +02:00
|
|
|
push $12 /* vector */
|
2004-10-30 10:05:41 +02:00
|
|
|
jmp int_hand
|
|
|
|
.word 0x9090
|
2010-04-26 14:08:51 +02:00
|
|
|
|
2004-10-30 10:05:41 +02:00
|
|
|
vec13:
|
|
|
|
/* error code */
|
2015-06-18 10:23:48 +02:00
|
|
|
push $13 /* vector */
|
2004-10-30 10:05:41 +02:00
|
|
|
jmp int_hand
|
|
|
|
.word 0x9090
|
2010-04-26 14:08:51 +02:00
|
|
|
|
2004-10-30 10:05:41 +02:00
|
|
|
vec14:
|
|
|
|
/* error code */
|
2015-06-18 10:23:48 +02:00
|
|
|
push $14 /* vector */
|
2004-10-30 10:05:41 +02:00
|
|
|
jmp int_hand
|
|
|
|
.word 0x9090
|
2010-04-26 14:08:51 +02:00
|
|
|
|
2004-10-30 10:05:41 +02:00
|
|
|
vec15:
|
2015-06-18 10:23:48 +02:00
|
|
|
push $0 /* error code */
|
|
|
|
push $15 /* vector */
|
2004-10-30 10:05:41 +02:00
|
|
|
jmp int_hand
|
2010-04-26 14:08:51 +02:00
|
|
|
|
2004-10-30 10:05:41 +02:00
|
|
|
vec16:
|
2015-06-18 10:23:48 +02:00
|
|
|
push $0 /* error code */
|
|
|
|
push $16 /* vector */
|
2004-10-30 10:05:41 +02:00
|
|
|
jmp int_hand
|
2010-04-26 14:08:51 +02:00
|
|
|
|
2004-10-30 10:05:41 +02:00
|
|
|
vec17:
|
|
|
|
/* error code */
|
2015-06-18 10:23:48 +02:00
|
|
|
push $17 /* vector */
|
2004-10-30 10:05:41 +02:00
|
|
|
jmp int_hand
|
|
|
|
.word 0x9090
|
2010-04-26 14:08:51 +02:00
|
|
|
|
2004-10-30 10:05:41 +02:00
|
|
|
vec18:
|
2015-06-18 10:23:48 +02:00
|
|
|
push $0 /* error code */
|
|
|
|
push $18 /* vector */
|
2004-10-30 10:05:41 +02:00
|
|
|
jmp int_hand
|
2010-04-26 14:08:51 +02:00
|
|
|
|
2004-10-30 10:05:41 +02:00
|
|
|
vec19:
|
2015-06-18 10:23:48 +02:00
|
|
|
push $0 /* error code */
|
|
|
|
push $19 /* vector */
|
2004-10-30 10:05:41 +02:00
|
|
|
jmp int_hand
|
2010-04-26 14:08:51 +02:00
|
|
|
|
2004-10-30 10:05:41 +02:00
|
|
|
int_hand:
|
2015-06-18 10:23:48 +02:00
|
|
|
/* At this point, on x86-32, on the stack there is:
|
2004-10-30 10:05:41 +02:00
|
|
|
* 0(%esp) vector
|
|
|
|
* 4(%esp) error code
|
|
|
|
* 8(%esp) eip
|
|
|
|
* 12(%esp) cs
|
|
|
|
* 16(%esp) eflags
|
|
|
|
*/
|
2015-06-18 10:23:48 +02:00
|
|
|
#ifdef __x86_64__
|
|
|
|
push %rdi
|
|
|
|
push %rsi
|
|
|
|
push %rbp
|
|
|
|
/* Original stack pointer */
|
|
|
|
lea 32(%rsp), %rbp
|
|
|
|
push %rbp
|
|
|
|
push %rbx
|
|
|
|
push %rdx
|
|
|
|
push %rcx
|
|
|
|
push %rax
|
|
|
|
|
|
|
|
push %rsp /* Pointer to structure on the stack */
|
|
|
|
call x86_exception
|
|
|
|
pop %rax /* Drop the pointer */
|
|
|
|
|
|
|
|
pop %rax
|
|
|
|
pop %rcx
|
|
|
|
pop %rdx
|
|
|
|
pop %rbx
|
|
|
|
pop %rbp /* Ignore saved %rsp value */
|
|
|
|
pop %rbp
|
|
|
|
pop %rsi
|
|
|
|
pop %rdi
|
|
|
|
|
|
|
|
add $8, %rsp /* pop of the vector and error code */
|
|
|
|
#else
|
2004-10-30 10:05:41 +02:00
|
|
|
pushl %edi
|
|
|
|
pushl %esi
|
|
|
|
pushl %ebp
|
2015-06-18 10:23:48 +02:00
|
|
|
|
2004-10-30 10:05:41 +02:00
|
|
|
/* Original stack pointer */
|
|
|
|
leal 32(%esp), %ebp
|
|
|
|
pushl %ebp
|
|
|
|
pushl %ebx
|
|
|
|
pushl %edx
|
|
|
|
pushl %ecx
|
|
|
|
pushl %eax
|
2003-04-22 21:02:15 +02:00
|
|
|
|
2004-10-30 10:05:41 +02:00
|
|
|
pushl %esp /* Pointer to structure on the stack */
|
|
|
|
call x86_exception
|
|
|
|
pop %eax /* Drop the pointer */
|
2003-04-22 21:02:15 +02:00
|
|
|
|
2004-10-30 10:05:41 +02:00
|
|
|
popl %eax
|
|
|
|
popl %ecx
|
|
|
|
popl %edx
|
|
|
|
popl %ebx
|
2004-11-04 19:36:06 +01:00
|
|
|
popl %ebp /* Ignore saved %esp value */
|
2004-10-30 10:05:41 +02:00
|
|
|
popl %ebp
|
|
|
|
popl %esi
|
|
|
|
popl %edi
|
|
|
|
|
|
|
|
addl $8, %esp /* pop of the vector and error code */
|
2015-06-18 10:23:48 +02:00
|
|
|
#endif
|
2004-10-30 10:05:41 +02:00
|
|
|
|
|
|
|
iret
|
|
|
|
|
2012-11-16 22:34:48 +01:00
|
|
|
#if CONFIG_GDB_WAIT
|
2004-10-30 10:05:41 +02:00
|
|
|
|
|
|
|
.globl gdb_stub_breakpoint
|
|
|
|
gdb_stub_breakpoint:
|
2015-06-18 10:23:48 +02:00
|
|
|
#ifdef __x86_64__
|
|
|
|
pop %rax /* Return address */
|
|
|
|
pushfl
|
|
|
|
push %cs
|
|
|
|
push %rax /* Return address */
|
|
|
|
push $0 /* No error code */
|
|
|
|
push $32 /* vector 32 is user defined */
|
|
|
|
#else
|
2004-10-30 10:05:41 +02:00
|
|
|
popl %eax /* Return address */
|
2010-04-26 14:08:51 +02:00
|
|
|
pushfl
|
2004-10-30 10:05:41 +02:00
|
|
|
pushl %cs
|
|
|
|
pushl %eax /* Return address */
|
|
|
|
pushl $0 /* No error code */
|
|
|
|
pushl $32 /* vector 32 is user defined */
|
2015-06-18 10:23:48 +02:00
|
|
|
#endif
|
2004-10-30 10:05:41 +02:00
|
|
|
jmp int_hand
|
|
|
|
#endif
|
|
|
|
|
2013-02-08 23:56:51 +01:00
|
|
|
.globl gdt, gdt_end, idtarg
|
2003-04-22 21:02:15 +02:00
|
|
|
|
|
|
|
gdtaddr:
|
2013-02-08 23:56:51 +01:00
|
|
|
.word gdt_end - gdt - 1
|
2015-06-18 10:23:48 +02:00
|
|
|
#ifdef __x86_64__
|
|
|
|
.quad gdt
|
|
|
|
#else
|
2004-11-04 19:36:06 +01:00
|
|
|
.long gdt /* we know the offset */
|
2015-06-18 10:23:48 +02:00
|
|
|
#endif
|
2003-04-22 21:02:15 +02:00
|
|
|
|
2004-10-30 10:05:41 +02:00
|
|
|
.data
|
2004-11-04 19:36:06 +01:00
|
|
|
|
2008-01-18 16:08:58 +01:00
|
|
|
/* This is the gdt for GCC part of coreboot.
|
|
|
|
* It is different from the gdt in ROMCC/ASM part of coreboot
|
2009-11-10 23:17:15 +01:00
|
|
|
* which is defined in entry32.inc
|
|
|
|
*
|
|
|
|
* When the machine is initially started, we use a very simple
|
|
|
|
* gdt from rom (that in entry32.inc) which only contains those
|
|
|
|
* entries we need for protected mode.
|
|
|
|
*
|
|
|
|
* When we're executing code from RAM, we want to do more complex
|
|
|
|
* stuff, like initializing PCI option roms in real mode, or doing
|
2010-04-26 14:08:51 +02:00
|
|
|
* a resume from a suspend to ram.
|
2009-11-10 23:17:15 +01:00
|
|
|
*/
|
2003-04-22 21:02:15 +02:00
|
|
|
gdt:
|
2004-11-04 19:36:06 +01:00
|
|
|
/* selgdt 0, unused */
|
2003-04-22 21:02:15 +02:00
|
|
|
.word 0x0000, 0x0000 /* dummy */
|
|
|
|
.byte 0x00, 0x00, 0x00, 0x00
|
|
|
|
|
2004-11-04 19:36:06 +01:00
|
|
|
/* selgdt 8, unused */
|
2003-04-22 21:02:15 +02:00
|
|
|
.word 0x0000, 0x0000 /* dummy */
|
|
|
|
.byte 0x00, 0x00, 0x00, 0x00
|
|
|
|
|
2010-04-26 14:08:51 +02:00
|
|
|
/* selgdt 0x10, flat code segment */
|
|
|
|
.word 0xffff, 0x0000
|
|
|
|
.byte 0x00, 0x9b, 0xcf, 0x00 /* G=1 and 0x0f, So we get 4Gbytes for limit */
|
2004-11-04 19:36:06 +01:00
|
|
|
|
|
|
|
/* selgdt 0x18, flat data segment */
|
2010-04-26 14:08:51 +02:00
|
|
|
.word 0xffff, 0x0000
|
2015-06-18 10:23:48 +02:00
|
|
|
#ifdef __x86_64__
|
|
|
|
.byte 0x00, 0x92, 0xcf, 0x00
|
|
|
|
#else
|
2010-04-26 14:08:51 +02:00
|
|
|
.byte 0x00, 0x93, 0xcf, 0x00
|
2015-06-18 10:23:48 +02:00
|
|
|
#endif
|
2003-04-22 21:02:15 +02:00
|
|
|
|
2004-11-04 19:36:06 +01:00
|
|
|
/* selgdt 0x20, unused */
|
2003-04-22 21:02:15 +02:00
|
|
|
.word 0x0000, 0x0000 /* dummy */
|
|
|
|
.byte 0x00, 0x00, 0x00, 0x00
|
|
|
|
|
2009-11-10 23:17:15 +01:00
|
|
|
/* The next two entries are used for executing VGA option ROMs */
|
|
|
|
|
2010-04-26 14:08:51 +02:00
|
|
|
/* selgdt 0x28 16 bit 64k code at 0x00000000 */
|
2009-05-29 15:08:27 +02:00
|
|
|
.word 0xffff, 0x0000
|
|
|
|
.byte 0, 0x9a, 0, 0
|
|
|
|
|
2010-04-26 14:08:51 +02:00
|
|
|
/* selgdt 0x30 16 bit 64k data at 0x00000000 */
|
2009-05-29 15:08:27 +02:00
|
|
|
.word 0xffff, 0x0000
|
|
|
|
.byte 0, 0x92, 0, 0
|
2009-11-10 23:17:15 +01:00
|
|
|
|
|
|
|
/* The next two entries are used for ACPI S3 RESUME */
|
|
|
|
|
2010-04-26 14:08:51 +02:00
|
|
|
/* selgdt 0x38, flat data segment 16 bit */
|
2009-11-10 23:17:15 +01:00
|
|
|
.word 0x0000, 0x0000 /* dummy */
|
2010-04-26 14:08:51 +02:00
|
|
|
.byte 0x00, 0x93, 0x8f, 0x00 /* G=1 and 0x0f, So we get 4Gbytes for limit */
|
2009-11-10 23:17:15 +01:00
|
|
|
|
2010-04-26 14:08:51 +02:00
|
|
|
/* selgdt 0x40, flat code segment 16 bit */
|
|
|
|
.word 0xffff, 0x0000
|
|
|
|
.byte 0x00, 0x9b, 0x8f, 0x00 /* G=1 and 0x0f, So we get 4Gbytes for limit */
|
2015-06-18 10:23:48 +02:00
|
|
|
|
|
|
|
#ifdef __x86_64__
|
|
|
|
/* selgdt 0x48, flat x64 code segment */
|
|
|
|
.word 0xffff, 0x0000
|
|
|
|
.byte 0x00, 0x9b, 0xaf, 0x00
|
|
|
|
#endif
|
2003-04-22 21:02:15 +02:00
|
|
|
gdt_end:
|
|
|
|
|
2004-10-30 10:05:41 +02:00
|
|
|
idtarg:
|
|
|
|
.word _idt_end - _idt - 1 /* limit */
|
|
|
|
.long _idt
|
2010-04-26 14:08:51 +02:00
|
|
|
.word 0
|
2004-10-30 10:05:41 +02:00
|
|
|
_idt:
|
2010-04-26 14:08:51 +02:00
|
|
|
.fill 20, 8, 0 # idt is uninitialized
|
2004-10-30 10:05:41 +02:00
|
|
|
_idt_end:
|
|
|
|
|
2015-06-18 10:23:48 +02:00
|
|
|
#ifdef __x86_64__
|
|
|
|
SetCodeSelector:
|
|
|
|
.intel_syntax noprefix
|
|
|
|
|
|
|
|
# save rsp because iret will align it to a 16 byte boundary
|
|
|
|
mov rdx, rsp
|
|
|
|
|
|
|
|
# use iret to jump to a 64-bit offset in a new code segment
|
|
|
|
# iret will pop cs:rip, flags, then ss:rsp
|
|
|
|
mov ax, ss # need to push ss..
|
|
|
|
push rax # push ss instuction not valid in x64 mode, so use ax
|
|
|
|
push rsp
|
|
|
|
pushfq
|
|
|
|
push rcx # cx is code segment selector from caller
|
|
|
|
mov rax, offset setCodeSelectorLongJump
|
|
|
|
push rax
|
|
|
|
|
|
|
|
# the iret will continue at next instruction, with the new cs value loaded
|
|
|
|
iretq
|
|
|
|
|
|
|
|
setCodeSelectorLongJump:
|
|
|
|
# restore rsp, it might not have been 16-byte aligned on entry
|
|
|
|
mov rsp, rdx
|
|
|
|
ret
|
|
|
|
.att_syntax prefix
|
|
|
|
|
|
|
|
.previous
|
|
|
|
.code64
|
|
|
|
#else
|
2004-10-30 10:05:41 +02:00
|
|
|
.previous
|
2003-04-22 21:02:15 +02:00
|
|
|
.code32
|
2015-06-18 10:23:48 +02:00
|
|
|
#endif
|