diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2014-02-08 22:13:46 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2014-02-08 22:13:46 +0000 |
commit | 3167fe9eabc25a9a8e33ab10322aa2bde3c6cdc3 (patch) | |
tree | 5cc19af17405d787ae751756a0b3cd7e138b07db /sys/arch | |
parent | 4c8a48d1f62049fb1e5e9aaa385427b4cee41328 (diff) |
Replace ARC_Call2(), used to invoke the `return-to-PROM' routines with a
PROM-compatible stack, with a sligthly different ARC_Call_Via_Pointer(),
which uses a global function pointer variable instead of computing the
address from the ARCBios parameter block; said variable being set in
bios_ident().
No functional change... yet. Tested on IP22(24), IP30 and IP32.
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/mips64/include/arcbios.h | 36 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/arcbios.c | 63 |
2 files changed, 63 insertions, 36 deletions
diff --git a/sys/arch/mips64/include/arcbios.h b/sys/arch/mips64/include/arcbios.h index 8e42854c675..7e6cc580b8c 100644 --- a/sys/arch/mips64/include/arcbios.h +++ b/sys/arch/mips64/include/arcbios.h @@ -1,4 +1,4 @@ -/* $OpenBSD: arcbios.h,v 1.23 2012/09/29 21:39:28 miod Exp $ */ +/* $OpenBSD: arcbios.h,v 1.24 2014/02/08 22:13:45 miod Exp $ */ /*- * Copyright (c) 1996 M. Warner Losh. All rights reserved. * @@ -386,18 +386,18 @@ typedef struct arc_param_blk_32 u_int32_t length; /* Length of parameter block */ u_int16_t version; /* ?? */ u_int16_t revision; /* ?? */ - u_int32_t restart_block; /* ?? */ - u_int32_t debug_block; /* Debugging info -- unused */ - u_int32_t general_exp_vect; /* ?? */ - u_int32_t tlb_miss_exp_vect; /* ?? */ + int32_t restart_block; /* ?? */ + int32_t debug_block; /* Debugging info -- unused */ + int32_t general_exp_vect; /* ?? */ + int32_t tlb_miss_exp_vect; /* ?? */ u_int32_t firmware_length; /* Size of Firmware jumptable in bytes */ - u_int32_t firmware_vect; /* Firmware jumptable */ - u_int32_t vendor_length; /* Size of Vendor specific jumptable */ + int32_t firmware_vect; /* Firmware jumptable */ + int32_t vendor_length; /* Size of Vendor specific jumptable */ u_int32_t vendor_vect; /* Vendor specific jumptable */ u_int32_t adapter_count; /* ?? */ u_int32_t adapter0_type; /* ?? */ u_int32_t adapter0_length; /* ?? */ - u_int32_t adapter0_vect; /* ?? */ + int32_t adapter0_vect; /* ?? */ } arc_param_blk_32_t; typedef struct arc_param_blk_64 @@ -406,18 +406,18 @@ typedef struct arc_param_blk_64 u_int64_t length; /* Length of parameter block */ u_int16_t version; /* ?? */ u_int16_t revision; /* ?? */ - u_int64_t restart_block; /* ?? */ - u_int64_t debug_block; /* Debugging info -- unused */ - u_int64_t general_exp_vect; /* ?? */ - u_int64_t tlb_miss_exp_vect; /* ?? */ + int64_t restart_block; /* ?? */ + int64_t debug_block; /* Debugging info -- unused */ + int64_t general_exp_vect; /* ?? */ + int64_t tlb_miss_exp_vect; /* ?? */ u_int64_t firmware_length; /* Size of Firmware jumptable in bytes */ - u_int64_t firmware_vect; /* Firmware jumptable */ + int64_t firmware_vect; /* Firmware jumptable */ u_int64_t vendor_length; /* Size of Vendor specific jumptable */ - u_int64_t vendor_vect; /* Vendor specific jumptable */ + int64_t vendor_vect; /* Vendor specific jumptable */ u_int64_t adapter_count; /* ?? */ u_int64_t adapter0_type; /* ?? */ u_int64_t adapter0_length; /* ?? */ - u_int64_t adapter0_vect; /* ?? */ + int64_t adapter0_vect; /* ?? */ } arc_param_blk_64_t; #define ARCBIOS_BASE 0x0000001000 /* physical */ @@ -434,6 +434,12 @@ extern char bios_console[30]; extern char bios_graphics[6]; extern char bios_keyboard[6]; +extern void (*bios_halt)(void); +extern void (*bios_powerdown)(void); +extern void (*bios_restart)(void); +extern void (*bios_reboot)(void); +extern void (*bios_eim)(void); + int bios_getchar(void); void bios_putchar(char); void bios_putstring(char *); diff --git a/sys/arch/mips64/mips64/arcbios.c b/sys/arch/mips64/mips64/arcbios.c index 3666e42bdf9..5b2a43e2ac1 100644 --- a/sys/arch/mips64/mips64/arcbios.c +++ b/sys/arch/mips64/mips64/arcbios.c @@ -1,4 +1,4 @@ -/* $OpenBSD: arcbios.c,v 1.33 2012/09/29 21:39:30 miod Exp $ */ +/* $OpenBSD: arcbios.c,v 1.34 2014/02/08 22:13:45 miod Exp $ */ /*- * Copyright (c) 1996 M. Warner Losh. All rights reserved. * Copyright (c) 1996-2004 Opsycon AB. All rights reserved. @@ -57,6 +57,12 @@ char bios_console[30]; /* Primary console. */ char bios_graphics[6]; /* Graphics state. */ char bios_keyboard[6]; /* Keyboard layout. */ +void (*bios_halt)(void); +void (*bios_powerdown)(void); +void (*bios_restart)(void); +void (*bios_reboot)(void); +void (*bios_eim)(void); + extern int physmem; /* Total physical memory size */ extern int rsvdmem; /* Total reserved memory size */ @@ -120,11 +126,12 @@ __asm__("\n" \ " .end " #Name "\n" ); /* - * Same, which also forces the stack to be in CKSEG0 (actually, whatever area - * proc0 stack was allocated in), used for restart functions, which aren't - * supposed to return. + * Invoke an ARC routine through a function pointer (set up in bios_ident()), + * also forcing the stack to be in CKSEG0 (actually, whatever area proc0 stack + * was allocated in) if this is a 32-bit ARCBios; used by restart functions, + * which aren't supposed to return anyway. */ -#define ARC_Call2(Name,Offset) \ +#define ARC_Call_Via_Pointer(Name,fnptr) \ __asm__("\n" \ " .text\n" \ " .ent " #Name "\n" \ @@ -133,21 +140,14 @@ __asm__("\n" \ " .globl " #Name "\n" \ #Name":\n" \ " lw $3, bios_is_32bit\n"\ -" ld $2, bios_base\n"\ " beqz $3, 1f\n" \ -" nop\n" \ +" nop\n" \ " ld $3, proc0paddr\n" \ -" addi $29, $3, 16384 - 64\n" \ -"2:\n" \ -" lw $3, 0x20($2)\n" \ -" lw $2," #Offset "($3)\n"\ -" jr $2\n" \ -" nop\n" \ +" addi $29, $3, 16384 - 64\n" /* assumes USPACE >= 16384 */ \ "1:\n" \ -" ld $3, 2*0x20($2)\n"\ -" ld $2, 2*" #Offset "($3)\n"\ +" ld $2, " #fnptr "\n"\ " jr $2\n" \ -" nop\n" \ +" nop\n" \ " .end " #Name "\n"); #if 0 @@ -155,11 +155,11 @@ ARC_Call(Bios_Load, 0x00); ARC_Call(Bios_Invoke, 0x04); ARC_Call(Bios_Execute, 0x08); #endif -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_Via_Pointer(Bios_Halt, bios_halt); +ARC_Call_Via_Pointer(Bios_PowerDown, bios_powerdown); +ARC_Call_Via_Pointer(Bios_Restart, bios_restart); +ARC_Call_Via_Pointer(Bios_Reboot, bios_reboot); +ARC_Call_Via_Pointer(Bios_EnterInteractiveMode, bios_eim); #if 0 ARC_Call(Bios_Unused1, 0x20); #endif @@ -533,6 +533,27 @@ void bios_ident() { sys_config.system_type = bios_get_system_type(); + + if (bios_is_32bit) { +#define bios_fnptr(slot) \ + (int64_t)*(int32_t *)((int64_t)ArcBiosBase32->firmware_vect + (slot) * 4) + bios_halt = (void (*)(void))bios_fnptr(3); + bios_powerdown = (void (*)(void))bios_fnptr(4); + bios_restart = (void (*)(void))bios_fnptr(5); + bios_reboot = (void (*)(void))bios_fnptr(6); + bios_eim = (void (*)(void))bios_fnptr(7); +#undef bios_fnptr + } else { +#define bios_fnptr(slot) \ + *(int64_t *)(ArcBiosBase64->firmware_vect + (slot) * 8) + bios_halt = (void (*)(void))bios_fnptr(3); + bios_powerdown = (void (*)(void))bios_fnptr(4); + bios_restart = (void (*)(void))bios_fnptr(5); + bios_reboot = (void (*)(void))bios_fnptr(6); + bios_eim = (void (*)(void))bios_fnptr(7); +#undef bios_fnptr + } + bios_configure_memory(); #ifdef __arc__ displayinfo = *(arc_dsp_stat_t *)Bios_GetDisplayStatus(1); |