arch/x86: Use defines for GDT segments

Stop using magic values and use defines for Global Descriptor Table
(GDT) offsets. Use the existing defines from the corresponding headers.

Change-Id: I40c15f6341bdef9cd457619ec81e7ac624ec2d63
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/87254
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Patrick Rudolph 2025-04-10 08:26:40 +02:00 committed by Matt DeVillier
commit 816d956dfd
3 changed files with 9 additions and 6 deletions

View file

@ -1,5 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <arch/ram_segs.h>
#define WAKEUP_BASE 0x600
#define RELOCATED(x) (x - __wakeup + WAKEUP_BASE)
@ -29,7 +31,7 @@ __wakeup:
add $8, %rax
push %rax
pushfq
push $0x10
push $RAM_CODE_SEG
lea 3(%rip), %rax
push %rax
iretq
@ -58,7 +60,7 @@ __wakeup:
movw %ax, (__wakeup_segment)
/* Activate the right segment descriptor real mode. */
ljmp $0x28, $RELOCATED(1f)
ljmp $RAM_CODE16_SEG, $RELOCATED(1f)
1:
.code16
/* 16 bit code from here on... */
@ -68,7 +70,7 @@ __wakeup:
* configurations (limits, writability, etc.) once
* protected mode is turned off.
*/
mov $0x30, %ax
mov $RAM_DATA16_SEG, %ax
mov %ax, %ds
mov %ax, %es
mov %ax, %fs

View file

@ -9,6 +9,7 @@
* found in smm.h.
*/
#include <arch/rom_segs.h>
#include <cpu/x86/cr.h>
#include <cpu/x86/msr.h>
#include <cpu/x86/lapic_def.h>
@ -93,7 +94,7 @@ untampered_lapic:
movl %eax, %cr0
/* Enable protected mode */
ljmpl $0x8, $smm_trampoline32
ljmpl $ROM_CODE_SEG, $smm_trampoline32
.align 4
smm_relocate_gdt:
@ -124,7 +125,7 @@ smm_relocate_gdt_end:
.global smm_trampoline32
smm_trampoline32:
/* Use flat data segment */
movw $0x10, %ax
movw $ROM_DATA_SEG, %ax
movw %ax, %ds
movw %ax, %es
movw %ax, %ss

View file

@ -150,7 +150,7 @@ __realmode_call:
mov %ax, %es
mov %ax, %fs
mov %ax, %gs
mov $0x40, %ax
mov $RAM_DATA_ACPI_SEG, %ax
mov %ax, %ds
pop %ax