aboutsummaryrefslogtreecommitdiff
path: root/src/stacks.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2012-05-13 12:10:30 -0400
committerKevin O'Connor <kevin@koconnor.net>2012-05-20 18:10:38 -0400
commit46b82624c95b951e8825fab117d9352faeae0ec8 (patch)
tree02e6dfd8ab8dcacd86ef7b6b08bd2a67d45d6410 /src/stacks.c
parent9c98517c938d20c38f537d516c71b30bb60c3ea0 (diff)
downloadseabios-hppa-46b82624c95b951e8825fab117d9352faeae0ec8.zip
seabios-hppa-46b82624c95b951e8825fab117d9352faeae0ec8.tar.gz
seabios-hppa-46b82624c95b951e8825fab117d9352faeae0ec8.tar.bz2
Add mechanism to declare variables as "low mem" and use for extra stack.
Add a mechanism (VARLOW declaration) to make a variable reside in the low memory (e-segment) area. This is useful for runtime variables that need to be accessed from 16bit code and need to be modifiable during runtime. Move the 16bit "extra stack" from the EBDA to the low memory area using this declaration mechanism. Also increase the size of this stack from 512 bytes to 2048 bytes. This also reworks tools/layoutrom.py a bit. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/stacks.c')
-rw-r--r--src/stacks.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/stacks.c b/src/stacks.c
index 17f1a4a..0371330 100644
--- a/src/stacks.c
+++ b/src/stacks.c
@@ -4,7 +4,7 @@
//
// This file may be distributed under the terms of the GNU LGPLv3 license.
-#include "biosvar.h" // get_ebda_seg
+#include "biosvar.h" // GET_GLOBAL
#include "util.h" // dprintf
#include "bregs.h" // CR0_PE
@@ -149,21 +149,24 @@ wait_irq(void)
/****************************************************************
- * Stack in EBDA
+ * Extra 16bit stack
****************************************************************/
-// Switch to the extra stack in ebda and call a function.
+// Space for a stack for 16bit code.
+u8 ExtraStack[BUILD_EXTRA_STACK_SIZE+1] VARLOW __aligned(8);
+
+// Switch to the extra stack and call a function.
inline u32
stack_hop(u32 eax, u32 edx, void *func)
{
ASSERT16();
- u16 ebda_seg = get_ebda_seg(), bkup_ss;
+ u16 stack_seg = SEG_LOW, bkup_ss;
u32 bkup_esp;
asm volatile(
// Backup current %ss/%esp values.
"movw %%ss, %w3\n"
"movl %%esp, %4\n"
- // Copy ebda seg to %ds/%ss and set %esp
+ // Copy stack seg to %ds/%ss and set %esp
"movw %w6, %%ds\n"
"movw %w6, %%ss\n"
"movl %5, %%esp\n"
@@ -174,7 +177,7 @@ stack_hop(u32 eax, u32 edx, void *func)
"movw %w3, %%ss\n"
"movl %4, %%esp"
: "+a" (eax), "+d" (edx), "+c" (func), "=&r" (bkup_ss), "=&r" (bkup_esp)
- : "i" (EBDA_OFFSET_TOP_STACK), "r" (ebda_seg)
+ : "i" (&ExtraStack[BUILD_EXTRA_STACK_SIZE]), "r" (stack_seg)
: "cc", "memory");
return eax;
}