arch/x86/*.S: use defines instead of hardcoded values

As preparation for x86_64 clean the assembly code and introduce
arch/ram_segs.h similar to existing arch/rom_segs.h.

Replace open coded segment values with the defines from the new
header.

Change-Id: Ib006cd4df59951335506b8153e9347450ec3403e
Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/36321
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Patrick Rudolph
2019-10-25 08:09:33 +02:00
committed by Aaron Durbin
parent 5f2576089f
commit 776da0872e
5 changed files with 50 additions and 24 deletions

View File

@@ -14,6 +14,8 @@
#define REALMODE_BASE 0x600
#define RELOCATED(x) (x - __realmode_code + REALMODE_BASE)
#include <arch/ram_segs.h>
/* CR0 bits */
#define PE (1 << 0)
@@ -106,7 +108,7 @@ __realmode_call:
movl %eax, __registers + 20 /* edi */
/* 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... */
@@ -116,7 +118,7 @@ __realmode_call:
* 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
@@ -186,10 +188,10 @@ __lcall_instr = RELOCATED(.)
/* Now that we are in protected mode
* jump to a 32 bit code segment.
*/
ljmpl $0x10, $RELOCATED(1f)
ljmpl $RAM_CODE_SEG, $RELOCATED(1f)
1:
.code32
mov $0x18, %ax
mov $RAM_DATA_SEG, %ax
mov %ax, %ds
mov %ax, %es
mov %ax, %fs
@@ -242,7 +244,7 @@ __realmode_interrupt:
movl %eax, __registers + 20 /* edi */
/* This configures CS properly for real mode. */
ljmp $0x28, $RELOCATED(1f)
ljmp $RAM_CODE16_SEG, $RELOCATED(1f)
1:
.code16 /* 16 bit code from here on... */
@@ -250,7 +252,7 @@ __realmode_interrupt:
* descriptors. They will retain these 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
@@ -314,10 +316,10 @@ __intXX_instr = RELOCATED(.)
movl %eax, %cr0
/* Now that we are in protected mode jump to a 32-bit code segment. */
ljmpl $0x10, $RELOCATED(1f)
ljmpl $RAM_CODE_SEG, $RELOCATED(1f)
1:
.code32
mov $0x18, %ax
mov $RAM_DATA_SEG, %ax
mov %ax, %ds
mov %ax, %es
mov %ax, %fs
@@ -363,10 +365,10 @@ __interrupt_handler_16bit = RELOCATED(.)
movl %eax, %cr0
/* ... and jump to a 32 bit code segment. */
ljmpl $0x10, $RELOCATED(1f)
ljmpl $RAM_CODE_SEG, $RELOCATED(1f)
1:
.code32
mov $0x18, %ax
mov $RAM_DATA_SEG, %ax
mov %ax, %ds
mov %ax, %es
mov %ax, %fs
@@ -380,14 +382,14 @@ __interrupt_handler_16bit = RELOCATED(.)
call *%eax
/* Now return to real mode ... */
ljmp $0x28, $RELOCATED(1f)
ljmp $RAM_CODE16_SEG, $RELOCATED(1f)
1:
.code16
/* Load the segment registers with properly configured segment
* descriptors. They will retain these 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