diff options
author | Denis Orlov <denorl2009@gmail.com> | 2023-07-25 08:05:17 +0300 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2023-07-27 07:08:29 +0200 |
commit | 384fc20493b48e9e82f63a7130f9ae81e6326a34 (patch) | |
tree | a5e33bccefee2c1a99486ecf6ccb94fd6ccd1faa /arch/mips/boot/main_entry.c | |
parent | 7fb6a4535a97bfcebde42c49cd5eb4a92be4c9b9 (diff) | |
download | barebox-384fc20493b48e9e82f63a7130f9ae81e6326a34.tar.gz barebox-384fc20493b48e9e82f63a7130f9ae81e6326a34.tar.xz |
MIPS: main_entry: remove exception vector array
This code must have been taken from Linux, where such a mechanism allows
for an efficient exception vector replacement for board-specific code.
We don't really need that. If some extensions for exception vector are
to be required, this may be done inside the generic handler code anyway.
As we are not using this code, it seems reasonable to just remove it.
Also properly calculate the size of the handler that we are copying into
the designated vectors. Originally, we just made a copy of a fixed size,
copying more than actually needed. We could have just hardcoded this
value there, as the code to copy now consists of just two instructions.
However it feels more safe to calculate that in code instead, so that we
don't have to update this value if some code is added there in the
future.
Signed-off-by: Denis Orlov <denorl2009@gmail.com>
Link: https://lore.barebox.org/20230725050618.3451-17-denorl2009@gmail.com
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/mips/boot/main_entry.c')
-rw-r--r-- | arch/mips/boot/main_entry.c | 39 |
1 files changed, 8 insertions, 31 deletions
diff --git a/arch/mips/boot/main_entry.c b/arch/mips/boot/main_entry.c index 237288a337..d0c69f3c82 100644 --- a/arch/mips/boot/main_entry.c +++ b/arch/mips/boot/main_entry.c @@ -14,45 +14,22 @@ #include <asm/addrspace.h> #include <linux/sizes.h> -extern void handle_reserved(void); +extern void exception_vec(void); +extern void exception_vec_end(void); void main_entry(void *fdt, u32 fdt_size); -unsigned long exception_handlers[32]; - -static void set_except_vector(int n, void *addr) -{ - unsigned long handler = (unsigned long) addr; - - exception_handlers[n] = handler; -} - static void trap_init(void) { - extern char except_vec3_generic; - int i; - - unsigned long ebase; - - ebase = CKSEG1; - - /* - * Copy the generic exception handlers to their final destination. - * This will be overriden later as suitable for a particular - * configuration. - */ - memcpy((void *)(ebase + 0x180), &except_vec3_generic, 0x80); + const unsigned long vec_size = exception_vec_end - exception_vec; + const unsigned long ebase = CKSEG1; - /* - * Setup default vectors - */ - for (i = 0; i <= 31; i++) { - set_except_vector(i, &handle_reserved); - } + /* copy the generic exception handlers to their final destination */ + memcpy((void *)(ebase + 0x180), &exception_vec, vec_size); /* FIXME: handle tlb */ - memcpy((void *)(ebase), &except_vec3_generic, 0x80); - memcpy((void *)(ebase + 0x080), &except_vec3_generic, 0x80); + memcpy((void *)(ebase), &exception_vec, vec_size); + memcpy((void *)(ebase + 0x80), &exception_vec, vec_size); /* unset BOOT EXCEPTION VECTOR bit */ write_c0_status(read_c0_status() & ~ST0_BEV); |