svn commit: r258696 - in head/sys/powerpc: aim booke powermac
Nathan Whitehorn
nwhitehorn at FreeBSD.org
Wed Nov 27 22:01:11 UTC 2013
Author: nwhitehorn
Date: Wed Nov 27 22:01:09 2013
New Revision: 258696
URL: http://svnweb.freebsd.org/changeset/base/258696
Log:
badaddr() is used only in the grackle PCI driver, so move its definition
there. Clean up a spurious setfault() declaration as well.
Modified:
head/sys/powerpc/aim/machdep.c
head/sys/powerpc/aim/trap.c
head/sys/powerpc/booke/trap.c
head/sys/powerpc/powermac/grackle.c
Modified: head/sys/powerpc/aim/machdep.c
==============================================================================
--- head/sys/powerpc/aim/machdep.c Wed Nov 27 21:55:43 2013 (r258695)
+++ head/sys/powerpc/aim/machdep.c Wed Nov 27 22:01:09 2013 (r258696)
@@ -157,8 +157,6 @@ SYSCTL_INT(_machdep, CPU_CACHELINE, cach
uintptr_t powerpc_init(vm_offset_t, vm_offset_t, vm_offset_t, void *);
-int setfault(faultbuf); /* defined in locore.S */
-
long Maxmem = 0;
long realmem = 0;
Modified: head/sys/powerpc/aim/trap.c
==============================================================================
--- head/sys/powerpc/aim/trap.c Wed Nov 27 21:55:43 2013 (r258695)
+++ head/sys/powerpc/aim/trap.c Wed Nov 27 22:01:09 2013 (r258696)
@@ -87,12 +87,6 @@ static int handle_user_slb_spill(pmap_t
extern int n_slbs;
#endif
-int setfault(faultbuf); /* defined in locore.S */
-
-/* Why are these not defined in a header? */
-int badaddr(void *, size_t);
-int badaddr_read(void *, size_t, int *);
-
struct powerpc_exception {
u_int vector;
char *name;
@@ -690,59 +684,6 @@ trap_pfault(struct trapframe *frame, int
return (SIGSEGV);
}
-int
-badaddr(void *addr, size_t size)
-{
- return (badaddr_read(addr, size, NULL));
-}
-
-int
-badaddr_read(void *addr, size_t size, int *rptr)
-{
- struct thread *td;
- faultbuf env;
- int x;
-
- /* Get rid of any stale machine checks that have been waiting. */
- __asm __volatile ("sync; isync");
-
- td = curthread;
-
- if (setfault(env)) {
- td->td_pcb->pcb_onfault = 0;
- __asm __volatile ("sync");
- return 1;
- }
-
- __asm __volatile ("sync");
-
- switch (size) {
- case 1:
- x = *(volatile int8_t *)addr;
- break;
- case 2:
- x = *(volatile int16_t *)addr;
- break;
- case 4:
- x = *(volatile int32_t *)addr;
- break;
- default:
- panic("badaddr: invalid size (%zd)", size);
- }
-
- /* Make sure we took the machine check, if we caused one. */
- __asm __volatile ("sync; isync");
-
- td->td_pcb->pcb_onfault = 0;
- __asm __volatile ("sync"); /* To be sure. */
-
- /* Use the value to avoid reorder. */
- if (rptr)
- *rptr = x;
-
- return (0);
-}
-
/*
* For now, this only deals with the particular unaligned access case
* that gcc tends to generate. Eventually it should handle all of the
Modified: head/sys/powerpc/booke/trap.c
==============================================================================
--- head/sys/powerpc/booke/trap.c Wed Nov 27 21:55:43 2013 (r258695)
+++ head/sys/powerpc/booke/trap.c Wed Nov 27 22:01:09 2013 (r258696)
@@ -87,12 +87,6 @@ static int fix_unaligned(struct thread *
static int handle_onfault(struct trapframe *frame);
static void syscall(struct trapframe *frame);
-int setfault(faultbuf); /* defined in locore.S */
-
-/* Why are these not defined in a header? */
-int badaddr(void *, size_t);
-int badaddr_read(void *, size_t, int *);
-
struct powerpc_exception {
u_int vector;
char *name;
@@ -461,60 +455,6 @@ trap_pfault(struct trapframe *frame, int
return ((rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV);
}
-int
-badaddr(void *addr, size_t size)
-{
-
- return (badaddr_read(addr, size, NULL));
-}
-
-int
-badaddr_read(void *addr, size_t size, int *rptr)
-{
- struct thread *td;
- faultbuf env;
- int x;
-
- /* Get rid of any stale machine checks that have been waiting. */
- __asm __volatile ("sync; isync");
-
- td = curthread;
-
- if (setfault(env)) {
- td->td_pcb->pcb_onfault = 0;
- __asm __volatile ("sync");
- return (1);
- }
-
- __asm __volatile ("sync");
-
- switch (size) {
- case 1:
- x = *(volatile int8_t *)addr;
- break;
- case 2:
- x = *(volatile int16_t *)addr;
- break;
- case 4:
- x = *(volatile int32_t *)addr;
- break;
- default:
- panic("badaddr: invalid size (%d)", size);
- }
-
- /* Make sure we took the machine check, if we caused one. */
- __asm __volatile ("sync; isync");
-
- td->td_pcb->pcb_onfault = 0;
- __asm __volatile ("sync"); /* To be sure. */
-
- /* Use the value to avoid reorder. */
- if (rptr)
- *rptr = x;
-
- return (0);
-}
-
/*
* For now, this only deals with the particular unaligned access case
* that gcc tends to generate. Eventually it should handle all of the
Modified: head/sys/powerpc/powermac/grackle.c
==============================================================================
--- head/sys/powerpc/powermac/grackle.c Wed Nov 27 21:55:43 2013 (r258695)
+++ head/sys/powerpc/powermac/grackle.c Wed Nov 27 22:01:09 2013 (r258696)
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/kernel.h>
+#include <sys/proc.h>
#include <dev/ofw/openfirm.h>
#include <dev/ofw/ofw_pci.h>
@@ -59,8 +60,6 @@ __FBSDID("$FreeBSD$");
#include "pcib_if.h"
-int badaddr(void *, size_t); /* XXX */
-
/*
* Device interface.
*/
@@ -81,6 +80,9 @@ static void grackle_write_config(device
static int grackle_enable_config(struct grackle_softc *, u_int,
u_int, u_int, u_int);
static void grackle_disable_config(struct grackle_softc *);
+static int badaddr(void *, size_t);
+
+int setfault(faultbuf); /* defined in locore.S */
/*
* Driver methods.
@@ -238,6 +240,50 @@ grackle_disable_config(struct grackle_so
out32rb(sc->sc_addr, 0);
}
+static int
+badaddr(void *addr, size_t size)
+{
+ struct thread *td;
+ faultbuf env, *oldfaultbuf;
+ int x;
+
+ /* Get rid of any stale machine checks that have been waiting. */
+ __asm __volatile ("sync; isync");
+
+ td = curthread;
+
+ oldfaultbuf = td->td_pcb->pcb_onfault;
+ if (setfault(env)) {
+ td->td_pcb->pcb_onfault = oldfaultbuf;
+ __asm __volatile ("sync");
+ return 1;
+ }
+
+ __asm __volatile ("sync");
+
+ switch (size) {
+ case 1:
+ x = *(volatile int8_t *)addr;
+ break;
+ case 2:
+ x = *(volatile int16_t *)addr;
+ break;
+ case 4:
+ x = *(volatile int32_t *)addr;
+ break;
+ default:
+ panic("badaddr: invalid size (%zd)", size);
+ }
+
+ /* Make sure we took the machine check, if we caused one. */
+ __asm __volatile ("sync; isync");
+
+ td->td_pcb->pcb_onfault = oldfaultbuf;
+ __asm __volatile ("sync"); /* To be sure. */
+
+ return (0);
+}
+
/*
* Driver to swallow Grackle host bridges from the PCI bus side.
*/
More information about the svn-src-all
mailing list