From 3e4ced315214f1ab1cc51b408ffaa486b648482e Mon Sep 17 00:00:00 2001 From: hannken Date: Sat, 31 Dec 2005 14:09:02 +0000 Subject: [PATCH] Use our own function to copy traps. We cannot use memcpy() anymore because the destination may be zero. --- sys/arch/evbppc/explora/machdep.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/sys/arch/evbppc/explora/machdep.c b/sys/arch/evbppc/explora/machdep.c index 6ca5b15a87c0..866ec18a0303 100644 --- a/sys/arch/evbppc/explora/machdep.c +++ b/sys/arch/evbppc/explora/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.9 2005/12/24 22:45:35 perry Exp $ */ +/* $NetBSD: machdep.c,v 1.10 2005/12/31 14:09:02 hannken Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.9 2005/12/24 22:45:35 perry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.10 2005/12/31 14:09:02 hannken Exp $"); #include "opt_explora.h" #include "ksyms.h" @@ -153,6 +153,22 @@ set_tlb(int idx, u_int addr, u_int flags) : : "r" (idx), "r" (lo), "r" (hi) ); } +/* + * Install a trap vector. We cannot use memcpy because the + * destination may be zero. + */ +static void +trap_copy(void *src, int dest, size_t len) +{ + uint32_t *src_p = src; + uint32_t *dest_p = (void *)dest; + + while (len > 0) { + *dest_p++ = *src_p++; + len -= sizeof(uint32_t); + } +} + void bootstrap(u_int startkernel, u_int endkernel) { @@ -240,10 +256,10 @@ bootstrap(u_int startkernel, u_int endkernel) */ for (i = EXC_RSVD; i <= EXC_LAST; i += 0x100) - memcpy((void *)i, &defaulttrap, (size_t)&defaultsize); + trap_copy(&defaulttrap, i, (size_t)&defaultsize); for (i = 0; i < sizeof(trap_table)/sizeof(trap_table[0]); i++) { - memcpy((void *)trap_table[i].vector, trap_table[i].addr, + trap_copy(trap_table[i].addr, trap_table[i].vector, (size_t)trap_table[i].size); }