summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2009-12-07 18:51:27 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2009-12-07 18:51:27 +0000
commit540d0528b4e6ce271320bf2b4ee2462a3950b970 (patch)
treed74006f4b364937beb449fb1119fc77a764f2a7e /sys
parent2b409ca024cf9f7a5fcbc9918777409b10403ba1 (diff)
When trying to return to ARCBios on a 32 bit ARCBios machine (such as the O2),
disable interrupts and unconditionnaly use proc0 u area as the stack, so that once ARCBios loses the upper 32 bits of the stack pointer, accessing the stack does not fault (proc0 u area is allocated in CKSEG0 for this reason).
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/mips64/mips64/arcbios.c46
-rw-r--r--sys/arch/sgi/sgi/machdep.c13
2 files changed, 50 insertions, 9 deletions
diff --git a/sys/arch/mips64/mips64/arcbios.c b/sys/arch/mips64/mips64/arcbios.c
index b96cacb96a7..449e621b533 100644
--- a/sys/arch/mips64/mips64/arcbios.c
+++ b/sys/arch/mips64/mips64/arcbios.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: arcbios.c,v 1.25 2009/11/19 06:06:51 miod Exp $ */
+/* $OpenBSD: arcbios.c,v 1.26 2009/12/07 18:51:24 miod Exp $ */
/*-
* Copyright (c) 1996 M. Warner Losh. All rights reserved.
* Copyright (c) 1996-2004 Opsycon AB. All rights reserved.
@@ -87,8 +87,35 @@ static struct systypes {
/*
* ARC Bios trampoline code.
*/
+
#define ARC_Call(Name,Offset) \
-__asm__("\n" \
+__asm__("\n" \
+" .text\n" \
+" .ent " #Name "\n" \
+" .align 3\n" \
+" .set noreorder\n" \
+" .globl " #Name "\n" \
+#Name":\n" \
+" lw $2, bios_is_32bit\n"\
+" beqz $2, 1f\n" \
+" nop\n" \
+" lw $2, 0xffffffff80001020\n"\
+" lw $2," #Offset "($2)\n"\
+" jr $2\n" \
+" nop\n" \
+"1:\n" \
+" ld $2, 0xffffffff80001040\n"\
+" ld $2, 2*" #Offset "($2)\n"\
+" jr $2\n" \
+" nop\n" \
+" .end " #Name "\n");
+
+/*
+ * Same, which also forces the stack to be in CKSEG0, used for
+ * restart functions, which aren't supposed to return.
+ */
+#define ARC_Call2(Name,Offset) \
+__asm__("\n" \
" .text\n" \
" .ent " #Name "\n" \
" .align 3\n" \
@@ -98,6 +125,9 @@ __asm__("\n" \
" lw $2, bios_is_32bit\n"\
" beqz $2, 1f\n" \
" nop\n" \
+" ld $2, proc0paddr\n" \
+" addi $29, $2, 16384 - 64\n" \
+"2:\n" \
" lw $2, 0xffffffff80001020\n"\
" lw $2," #Offset "($2)\n"\
" jr $2\n" \
@@ -107,16 +137,16 @@ __asm__("\n" \
" ld $2, 2*" #Offset "($2)\n"\
" jr $2\n" \
" nop\n" \
-" .end " #Name "\n" );
+" .end " #Name "\n");
ARC_Call(Bios_Load, 0x00);
ARC_Call(Bios_Invoke, 0x04);
ARC_Call(Bios_Execute, 0x08);
-ARC_Call(Bios_Halt, 0x0c);
-ARC_Call(Bios_PowerDown, 0x10);
-ARC_Call(Bios_Restart, 0x14);
-ARC_Call(Bios_Reboot, 0x18);
-ARC_Call(Bios_EnterInteractiveMode, 0x1c);
+ARC_Call2(Bios_Halt, 0x0c);
+ARC_Call2(Bios_PowerDown, 0x10);
+ARC_Call2(Bios_Restart, 0x14);
+ARC_Call2(Bios_Reboot, 0x18);
+ARC_Call2(Bios_EnterInteractiveMode, 0x1c);
ARC_Call(Bios_Unused1, 0x20);
ARC_Call(Bios_GetPeer, 0x24);
ARC_Call(Bios_GetChild, 0x28);
diff --git a/sys/arch/sgi/sgi/machdep.c b/sys/arch/sgi/sgi/machdep.c
index 769e6804d61..7ec8a85cace 100644
--- a/sys/arch/sgi/sgi/machdep.c
+++ b/sys/arch/sgi/sgi/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.91 2009/12/03 06:02:38 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.92 2009/12/07 18:51:26 miod Exp $ */
/*
* Copyright (c) 2003-2004 Opsycon AB (www.opsycon.se / www.opsycon.com)
@@ -897,6 +897,15 @@ haltsys:
void
arcbios_halt(int howto)
{
+ uint32_t sr;
+
+ sr = disableintr();
+
+#if 0
+ /* restore ARCBios page size... */
+ tlb_set_page_mask(PG_SIZE_4K);
+#endif
+
if (howto & RB_HALT) {
if (howto & RB_POWERDOWN)
Bios_PowerDown();
@@ -904,6 +913,8 @@ arcbios_halt(int howto)
Bios_EnterInteractiveMode();
} else
Bios_Reboot();
+
+ setsr(sr);
}
u_long dumpmag = 0x8fca0101; /* Magic number for savecore. */