Skip to content

Commit 191d0d2

Browse files
committed
sh: Tidy up the sh bios VBR handling.
This moves the VBR handling out of the main trap handling code and in to the sh-bios helper code. A couple of accessors are added in order to permit other kernel code to get at the VBR value for state save/restore paths. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
1 parent ee2760e commit 191d0d2

4 files changed

Lines changed: 55 additions & 33 deletions

File tree

‎arch/sh/include/asm/sh_bios.h‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
11
#ifndef __ASM_SH_BIOS_H
22
#define __ASM_SH_BIOS_H
33

4+
#ifdef CONFIG_SH_STANDARD_BIOS
5+
46
/*
57
* Copyright (C) 2000 Greg Banks, Mitch Davis
68
* C API to interface to the standard LinuxSH BIOS
79
* usually from within the early stages of kernel boot.
810
*/
9-
10-
1111
extern void sh_bios_console_write(const char *buf, unsigned int len);
1212
extern void sh_bios_char_out(char ch);
1313
extern void sh_bios_gdb_detach(void);
1414

1515
extern void sh_bios_get_node_addr(unsigned char *node_addr);
1616
extern void sh_bios_shutdown(unsigned int how);
1717

18+
extern void sh_bios_vbr_init(void);
19+
extern void sh_bios_vbr_reload(void);
20+
21+
#else
22+
23+
static inline void sh_bios_vbr_init(void) { }
24+
static inline void sh_bios_vbr_reload(void) { }
25+
26+
#endif /* CONFIG_SH_STANDARD_BIOS */
27+
1828
#endif /* __ASM_SH_BIOS_H */

‎arch/sh/kernel/machine_kexec.c‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
#include <asm/mmu_context.h>
2222
#include <asm/io.h>
2323
#include <asm/cacheflush.h>
24+
#include <asm/sh_bios.h>
2425

2526
typedef void (*relocate_new_kernel_t)(unsigned long indirection_page,
2627
unsigned long reboot_code_buffer,
2728
unsigned long start_address);
2829

2930
extern const unsigned char relocate_new_kernel[];
3031
extern const unsigned int relocate_new_kernel_size;
31-
extern void *gdb_vbr_vector;
3232
extern void *vbr_base;
3333

3434
void machine_shutdown(void)
@@ -117,11 +117,7 @@ void machine_kexec(struct kimage *image)
117117
kexec_info(image);
118118
flush_cache_all();
119119

120-
#if defined(CONFIG_SH_STANDARD_BIOS)
121-
asm volatile("ldc %0, vbr" :
122-
: "r" (((unsigned long) gdb_vbr_vector) - 0x100)
123-
: "memory");
124-
#endif
120+
sh_bios_vbr_reload();
125121

126122
/* now call it */
127123
rnk = (relocate_new_kernel_t) reboot_code_buffer;

‎arch/sh/kernel/sh_bios.c‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,40 @@ void sh_bios_shutdown(unsigned int how)
5555
{
5656
sh_bios_call(BIOS_CALL_SHUTDOWN, how, 0, 0, 0);
5757
}
58+
59+
void *gdb_vbr_vector = NULL;
60+
61+
/*
62+
* Read the old value of the VBR register to initialise the vector
63+
* through which debug and BIOS traps are delegated by the Linux trap
64+
* handler.
65+
*/
66+
void sh_bios_vbr_init(void)
67+
{
68+
unsigned long vbr;
69+
70+
if (unlikely(gdb_vbr_vector))
71+
return;
72+
73+
__asm__ __volatile__ ("stc vbr, %0" : "=r" (vbr));
74+
75+
gdb_vbr_vector = (void *)(vbr + 0x100);
76+
printk(KERN_NOTICE "Setting GDB trap vector to %p\n", gdb_vbr_vector);
77+
}
78+
79+
/**
80+
* sh_bios_vbr_reload - Re-load the system VBR from the BIOS vector.
81+
*
82+
* This can be used by save/restore code to reinitialize the system VBR
83+
* from the fixed BIOS VBR. A no-op if no BIOS VBR is known.
84+
*/
85+
void sh_bios_vbr_reload(void)
86+
{
87+
if (gdb_vbr_vector)
88+
__asm__ __volatile__ (
89+
"ldc %0, vbr"
90+
:
91+
: "r" (((unsigned long) gdb_vbr_vector) - 0x100)
92+
: "memory"
93+
);
94+
}

‎arch/sh/kernel/traps_32.c‎

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <asm/uaccess.h>
3232
#include <asm/fpu.h>
3333
#include <asm/kprobes.h>
34+
#include <asm/sh_bios.h>
3435

3536
#ifdef CONFIG_CPU_SH2
3637
# define TRAP_RESERVED_INST 4
@@ -876,35 +877,10 @@ asmlinkage void do_exception_error(unsigned long r4, unsigned long r5,
876877
die_if_kernel("exception", regs, ex);
877878
}
878879

879-
#if defined(CONFIG_SH_STANDARD_BIOS)
880-
void *gdb_vbr_vector;
881-
882-
static inline void __init gdb_vbr_init(void)
883-
{
884-
register unsigned long vbr;
885-
886-
/*
887-
* Read the old value of the VBR register to initialise
888-
* the vector through which debug and BIOS traps are
889-
* delegated by the Linux trap handler.
890-
*/
891-
asm volatile("stc vbr, %0" : "=r" (vbr));
892-
893-
gdb_vbr_vector = (void *)(vbr + 0x100);
894-
printk("Setting GDB trap vector to 0x%08lx\n",
895-
(unsigned long)gdb_vbr_vector);
896-
}
897-
#endif
898-
899880
void __cpuinit per_cpu_trap_init(void)
900881
{
901882
extern void *vbr_base;
902883

903-
#ifdef CONFIG_SH_STANDARD_BIOS
904-
if (raw_smp_processor_id() == 0)
905-
gdb_vbr_init();
906-
#endif
907-
908884
/* NOTE: The VBR value should be at P1
909885
(or P2, virtural "fixed" address space).
910886
It's definitely should not in physical address. */
@@ -959,6 +935,9 @@ void __init trap_init(void)
959935
set_exception_table_vec(TRAP_UBC, break_point_trap);
960936
#endif
961937

938+
/* Save off the BIOS VBR, if there is one */
939+
sh_bios_vbr_init();
940+
962941
/* Setup VBR for boot cpu */
963942
per_cpu_trap_init();
964943
}

0 commit comments

Comments
 (0)