summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2005-10-03 04:40:10 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2005-10-03 04:40:10 +0000
commit05188fe8ea7fd92f7f650cfeca692344f90b4078 (patch)
tree7da271151807e9f8f4860d2256a65ce0f1fd17d4 /sys
parentdd234590e7d303f7c797830c6cbe8da31e92c724 (diff)
pretty up the instruction whacker code; ok drahn
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/macppc/macppc/cpu.c37
-rw-r--r--sys/arch/macppc/macppc/locore.S36
2 files changed, 33 insertions, 40 deletions
diff --git a/sys/arch/macppc/macppc/cpu.c b/sys/arch/macppc/macppc/cpu.c
index 87261ea6b3c..7914f69b001 100644
--- a/sys/arch/macppc/macppc/cpu.c
+++ b/sys/arch/macppc/macppc/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.26 2005/10/03 02:57:07 deraadt Exp $ */
+/* $OpenBSD: cpu.c,v 1.27 2005/10/03 04:40:09 deraadt Exp $ */
/*
* Copyright (c) 1997 Per Fogelstrom
@@ -99,15 +99,13 @@ ppc_cpuspeed(int *freq)
int ppc_proc_is_64b;
extern u_int32_t rfi_inst, rfid_inst, nop_inst;
-extern u_int32_t *rfi_whack[], *rfi_whackend[];
-struct noppatch{
+struct patch {
u_int32_t *s;
u_int32_t *e;
};
-extern struct noppatch nop32_start;
-extern struct noppatch nop32_end;
-extern struct noppatch nop64_start;
-extern struct noppatch nop64_end;
+extern struct patch rfi_start;
+extern struct patch nop32_start;
+extern struct patch nop64_start;
void
@@ -115,8 +113,7 @@ ppc_check_procid()
{
u_int32_t cpu, pvr;
u_int32_t *inst;
- int i;
- struct noppatch *pnop;
+ struct patch *p;
pvr = ppc_mfpvr();
cpu = pvr >> 16;
@@ -124,26 +121,24 @@ ppc_check_procid()
switch (cpu) {
case PPC_CPU_IBM970:
ppc_proc_is_64b = 1;
- for (i = 0; &rfi_whack[i] < &rfi_whackend[0]; i++) {
- inst = rfi_whack[i];
- *inst = rfid_inst;
- syncicache(inst, 4);
+ for (p = &rfi_start; p->s; p++) {
+ for (inst = p->s; inst < p->e; inst++)
+ *inst = rfid_inst;
+ syncicache(p->s, (p->e - p->s) * sizeof(*p->e));
}
- for (pnop = &nop64_start; pnop < &nop64_end; pnop++) {
- for (inst = pnop->s; inst < pnop->e; inst++) {
+ for (p = &nop64_start; p->s; p++) {
+ for (inst = p->s; inst < p->e; inst++)
*inst = nop_inst;
- syncicache(inst, 4);
- }
+ syncicache(p->s, (p->e - p->s) * sizeof(*p->e));
}
break;
default:
ppc_proc_is_64b = 0;
- for (pnop = &nop32_start; pnop < &nop32_end; pnop++) {
- for (inst = pnop->s; inst < pnop->e; inst++) {
+ for (p = &nop32_start; p->s; p++) {
+ for (inst = p->s; inst < p->e; inst++)
*inst = nop_inst;
- syncicache(inst, 4);
- }
+ syncicache(p->s, (p->e - p->s) * sizeof(p->e));
}
}
}
diff --git a/sys/arch/macppc/macppc/locore.S b/sys/arch/macppc/macppc/locore.S
index 4d71a774a08..9cfaab04552 100644
--- a/sys/arch/macppc/macppc/locore.S
+++ b/sys/arch/macppc/macppc/locore.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.S,v 1.23 2005/10/03 02:16:10 drahn Exp $ */
+/* $OpenBSD: locore.S,v 1.24 2005/10/03 04:40:09 deraadt Exp $ */
/* $NetBSD: locore.S,v 1.2 1996/10/16 19:33:09 ws Exp $ */
/*
@@ -1284,32 +1284,30 @@ _C_LABEL(rfi_inst):
.globl _C_LABEL(rfid_inst)
_C_LABEL(rfid_inst):
rfid
- .globl _C_LABEL(rfi_whack)
-_C_LABEL(rfi_whack):
+ .globl _C_LABEL(nop_inst)
+ _C_LABEL(nop_inst):
+ nop
+
+ .globl _C_LABEL(rfi_start)
+_C_LABEL(rfi_start):
#if 0
/* rfi1 and rfi2 are currently inside if 0ed code */
- .long rfi1
- .long rfi2
+ .long rfi1, rfi1 + 4
+ .long rfi2, rfi2 + 4
#endif
- .long rfi3
- .long rfi4
- .long rfi5
- .long rfi6
- .globl _C_LABEL(rfi_whackend)
-_C_LABEL(rfi_whackend):
+ .long rfi3, rfi3 + 4
+ .long rfi4, rfi4 + 4
+ .long rfi5, rfi5 + 4
+ .long rfi6, rfi6 + 4
+ .long 0, 0
- .globl _C_LABEL(nop_inst)
- _C_LABEL(nop_inst):
- nop
.globl _C_LABEL(nop64_start)
- .globl _C_LABEL(nop64_end)
_C_LABEL(nop64_start):
- .long nop64_1s, nop64_1e
-_C_LABEL(nop64_end):
+ .long nop64_1s, nop64_1e
+ .long 0, 0
.globl _C_LABEL(nop32_start)
- .globl _C_LABEL(nop32_end)
_C_LABEL(nop32_start):
.long nop32_1s, nop32_1e
.long nop32_2s, nop32_2e
@@ -1318,4 +1316,4 @@ _C_LABEL(nop32_start):
.long nop32_5s, nop32_5e
.long nop32_6s, nop32_6e
.long nop32_7s, nop32_7e
-_C_LABEL(nop32_end):
+ .long 0, 0