Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/powerpc Make ibm4xx kernels compiled by clang.
details: https://anonhg.NetBSD.org/src/rev/04344d9365ef
branches: trunk
changeset: 370007:04344d9365ef
user: rin <rin%NetBSD.org@localhost>
date: Mon Sep 12 08:02:44 2022 +0000
description:
Make ibm4xx kernels compiled by clang.
As clang cannot correctly assemble m[ft]pid:
- for asm sources, use m[ft]spr from/to SPR_PID
- for C sources, use M[FT]PID macros (see include/ibm4xx/spr.h)
This is ugly...
No binary changes for GCC-compiled kernels.
diffstat:
sys/arch/powerpc/ibm4xx/4xx_trap_subr.S | 8 ++++----
sys/arch/powerpc/ibm4xx/copyinstr.c | 16 ++++++++++------
sys/arch/powerpc/ibm4xx/copyoutstr.c | 16 ++++++++++------
sys/arch/powerpc/ibm4xx/pmap.c | 26 +++++++++++++-------------
sys/arch/powerpc/ibm4xx/trap.c | 24 ++++++++++++------------
sys/arch/powerpc/ibm4xx/trap_subr.S | 10 +++++-----
sys/arch/powerpc/include/ibm4xx/spr.h | 10 +++++++++-
sys/arch/powerpc/powerpc/db_interface.c | 10 +++++-----
8 files changed, 68 insertions(+), 52 deletions(-)
diffs (truncated from 408 to 300 lines):
diff -r 22165fb9a7b2 -r 04344d9365ef sys/arch/powerpc/ibm4xx/4xx_trap_subr.S
--- a/sys/arch/powerpc/ibm4xx/4xx_trap_subr.S Mon Sep 12 07:38:32 2022 +0000
+++ b/sys/arch/powerpc/ibm4xx/4xx_trap_subr.S Mon Sep 12 08:02:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: 4xx_trap_subr.S,v 1.9 2020/07/12 21:16:23 rin Exp $ */
+/* $NetBSD: 4xx_trap_subr.S,v 1.10 2022/09/12 08:02:44 rin Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@@ -95,12 +95,12 @@
.globl _C_LABEL(pmap_tlbmiss)
/* If the kernel stack would fault, don't use it. */
- mfpid %r30
+ mfspr %r30,SPR_PID
li %r31,KERNEL_PID
- mtpid %r31
+ mtspr SPR_PID,%r31
li %r31,-FRAMELEN
tlbsx. %r31,%r31,%r1
- mtpid %r30
+ mtspr SPR_PID,%r30
beq 1f
/*
diff -r 22165fb9a7b2 -r 04344d9365ef sys/arch/powerpc/ibm4xx/copyinstr.c
--- a/sys/arch/powerpc/ibm4xx/copyinstr.c Mon Sep 12 07:38:32 2022 +0000
+++ b/sys/arch/powerpc/ibm4xx/copyinstr.c Mon Sep 12 08:02:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: copyinstr.c,v 1.14 2020/06/19 07:31:59 rin Exp $ */
+/* $NetBSD: copyinstr.c,v 1.15 2022/09/12 08:02:44 rin Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@@ -36,10 +36,11 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: copyinstr.c,v 1.14 2020/06/19 07:31:59 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: copyinstr.c,v 1.15 2022/09/12 08:02:44 rin Exp $");
#include <sys/param.h>
#include <uvm/uvm_extern.h>
+#include <powerpc/ibm4xx/spr.h>
#include <machine/pcb.h>
int
@@ -76,20 +77,23 @@
"li %1,0x20;"
"andc %1,%0,%1; mtmsr %1;" /* Disable IMMU */
"isync;"
- "mfpid %1;" /* Save old PID */
+ MFPID(%1) /* Save old PID */
"1: "
- "mtpid %4; isync;" /* Load user ctx */
+ MTPID(%4) /* Load user ctx */
+ "isync;"
"lbz %2,0(%5); addi %5,%5,1;" /* Load byte */
"sync;"
- "mtpid %1; isync;"
+ MTPID(%1)
+ "isync;"
"stb %2,0(%6); dcbst 0,%6; addi %6,%6,1;"
/* Store kernel byte */
"or. %2,%2,%2;"
"sync;"
"bdnzf 2,1b;" /* while(ctr-- && !zero) */
- "mtpid %1; mtmsr %0;" /* Restore PID, MSR */
+ MTPID(%1) /* Restore PID, MSR */
+ "mtmsr %0;"
"isync;"
"mfctr %3;" /* Restore resid */
: "=&r" (msr), "=&r" (pid), "=&r" (data), "+r" (resid)
diff -r 22165fb9a7b2 -r 04344d9365ef sys/arch/powerpc/ibm4xx/copyoutstr.c
--- a/sys/arch/powerpc/ibm4xx/copyoutstr.c Mon Sep 12 07:38:32 2022 +0000
+++ b/sys/arch/powerpc/ibm4xx/copyoutstr.c Mon Sep 12 08:02:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: copyoutstr.c,v 1.14 2020/06/19 07:31:59 rin Exp $ */
+/* $NetBSD: copyoutstr.c,v 1.15 2022/09/12 08:02:44 rin Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@@ -36,10 +36,11 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: copyoutstr.c,v 1.14 2020/06/19 07:31:59 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: copyoutstr.c,v 1.15 2022/09/12 08:02:44 rin Exp $");
#include <sys/param.h>
#include <uvm/uvm_extern.h>
+#include <powerpc/ibm4xx/spr.h>
#include <machine/pcb.h>
int
@@ -76,20 +77,23 @@
"li %1,0x20;"
"andc %1,%0,%1; mtmsr %1;" /* Disable IMMU */
"isync;"
- "mfpid %1;" /* Save old PID */
+ MFPID(%1) /* Save old PID */
"1:"
- "mtpid %1; isync;"
+ MTPID(%1)
+ "isync;"
"lbz %2,0(%6); addi %6,%6,1;" /* Store kernel byte */
"sync;"
- "mtpid %4; isync;" /* Load user ctx */
+ MTPID(%4) /* Load user ctx */
+ "isync;"
"stb %2,0(%5); dcbst 0,%5; addi %5,%5,1;"
/* Load byte */
"or. %2,%2,%2;"
"sync;"
"bdnzf 2,1b;" /* while(ctr-- && !zero) */
- "mtpid %1; mtmsr %0;" /* Restore PID, MSR */
+ MTPID(%1) /* Restore PID, MSR */
+ "mtmsr %0;"
"isync;"
"mfctr %3;" /* Restore resid */
: "=&r" (msr), "=&r" (pid), "=&r" (data), "+r" (resid)
diff -r 22165fb9a7b2 -r 04344d9365ef sys/arch/powerpc/ibm4xx/pmap.c
--- a/sys/arch/powerpc/ibm4xx/pmap.c Mon Sep 12 07:38:32 2022 +0000
+++ b/sys/arch/powerpc/ibm4xx/pmap.c Mon Sep 12 08:02:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.105 2021/09/08 00:17:21 rin Exp $ */
+/* $NetBSD: pmap.c,v 1.106 2022/09/12 08:02:44 rin Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.105 2021/09/08 00:17:21 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.106 2022/09/12 08:02:44 rin Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -1184,8 +1184,8 @@
"ori %1,%1,0x10;" /* Turn on DMMU for sure */
"mtmsr %1;"
"isync;"
- "mfpid %1;"
- "mtpid %2;"
+ MFPID(%1)
+ MTPID(%2)
"isync;"
"1:"
"dcbst 0,%3;"
@@ -1194,7 +1194,7 @@
"sub. %4,%4,%5;"
"bge 1b;"
"sync;"
- "mtpid %1;"
+ MTPID(%1)
"mtmsr %0;"
"isync;"
: "=&r"(msr), "=&r"(opid)
@@ -1239,11 +1239,11 @@
"mfmsr %0;"
"li %1,0;"
"mtmsr %1;"
- "mfpid %1;"
+ MFPID(%1)
"tlbre %2,%3,0;"
"andc %2,%2,%4;"
"tlbwe %2,%3,0;"
- "mtpid %1;"
+ MTPID(%1)
"mtmsr %0;"
"isync;"
: "=&r"(msr), "=&r"(pid), "=&r"(hi)
@@ -1273,16 +1273,16 @@
return;
__asm volatile (
- "mfpid %1;" /* Save PID */
+ MFPID(%1) /* Save PID */
"mfmsr %2;" /* Save MSR */
"li %0,0;" /* Now clear MSR */
"mtmsr %0;"
"isync;"
- "mtpid %4;" /* Set PID */
+ MTPID(%4) /* Set PID */
"isync;"
"tlbsx. %0,0,%3;" /* Search TLB */
"isync;"
- "mtpid %1;" /* Restore PID */
+ MTPID(%1) /* Restore PID */
"mtmsr %2;" /* Restore MSR */
"isync;"
"li %1,1;"
@@ -1373,13 +1373,13 @@
"mtmsr %1;" /* Clear MSR */
"isync;"
"tlbwe %1,%3,0;" /* Invalidate old entry. */
- "mfpid %1;" /* Save old PID */
- "mtpid %2;" /* Load translation ctx */
+ MFPID(%1) /* Save old PID */
+ MTPID(%2) /* Load translation ctx */
"isync;"
"tlbwe %4,%3,1;" /* Set TLB */
"tlbwe %5,%3,0;"
"isync;"
- "mtpid %1;" /* Restore PID */
+ MTPID(%1) /* Restore PID */
"mtmsr %0;" /* and MSR */
"isync;"
: "=&r"(msr), "=&r"(pid)
diff -r 22165fb9a7b2 -r 04344d9365ef sys/arch/powerpc/ibm4xx/trap.c
--- a/sys/arch/powerpc/ibm4xx/trap.c Mon Sep 12 07:38:32 2022 +0000
+++ b/sys/arch/powerpc/ibm4xx/trap.c Mon Sep 12 08:02:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.97 2022/09/12 06:23:29 rin Exp $ */
+/* $NetBSD: trap.c,v 1.98 2022/09/12 08:02:44 rin Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@@ -69,7 +69,7 @@
#define __UFETCHSTORE_PRIVATE
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.97 2022/09/12 06:23:29 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.98 2022/09/12 08:02:44 rin Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -455,13 +455,13 @@
"andc %[tmp],%[msr],%[tmp];"
"mtmsr %[tmp];"
"isync;"
- "mfpid %[pid];" /* Save old PID */
+ MFPID(%[pid]) /* Save old PID */
"srwi. %[tmp],%[len],0x2;" /* How many words? */
"beq- 2f;" /* No words. Go do bytes */
"mtctr %[tmp];"
- "1:" "mtpid %[ctx];"
+ "1:" MTPID(%[ctx])
"isync;"
#ifdef PPC_IBM403
"lswi %[tmp],%[uaddr],4;" /* Load user word */
@@ -471,7 +471,7 @@
"addi %[uaddr],%[uaddr],0x4;" /* next uaddr word */
"sync;"
- "mtpid %[pid];"
+ MTPID(%[pid])
"isync;"
#ifdef PPC_IBM403
"stswi %[tmp],%[kaddr],4;" /* Store kernel word */
@@ -487,12 +487,12 @@
"beq 10f;"
"mtxer %[tmp];"
- "mtpid %[ctx];"
+ MTPID(%[ctx])
"isync;"
"lswx %[tmp],0,%[uaddr];" /* Load user bytes */
"sync;"
- "mtpid %[pid];"
+ MTPID(%[pid])
"isync;"
"stswx %[tmp],0,%[kaddr];" /* Store kernel bytes */
"dcbst 0,%[kaddr];" /* flush cache */
@@ -570,7 +570,7 @@
"andc %[tmp],%[msr],%[tmp];"
"mtmsr %[tmp];"
"isync;"
- "mfpid %[pid];" /* Save old PID */
+ MFPID(%[pid]) /* Save old PID */
"srwi. %[tmp],%[len],0x2;" /* How many words? */
"beq- 2f;" /* No words. Go do bytes */
@@ -585,7 +585,7 @@
"addi %[kaddr],%[kaddr],0x4;" /* next kaddr word */
"sync;"
- "mtpid %[ctx];"
+ MTPID(%[ctx])
"isync;"
#ifdef PPC_IBM403
"stswi %[tmp],%[uaddr],4;" /* Store user word */
@@ -596,7 +596,7 @@
"addi %[uaddr],%[uaddr],0x4;" /* next uaddr word */
"sync;"
- "mtpid %[pid];"
+ MTPID(%[pid])
"isync;"
"bdnz 1b;" /* repeat */
@@ -607,13 +607,13 @@
Home |
Main Index |
Thread Index |
Old Index