svn commit: r198354 - in projects/mips/sys/mips: include mips
Neel Natu
neel at FreeBSD.org
Thu Oct 22 02:51:32 UTC 2009
Author: neel
Date: Thu Oct 22 02:51:31 2009
New Revision: 198354
URL: http://svn.freebsd.org/changeset/base/198354
Log:
Get rid of the hardcoded constants to define cacheable memory:
SDRAM_ADDR_START, SDRAM_ADDR_END and SDRAM_MEM_SIZE
Instead we now keep a copy of the memory regions enumerated by
platform-specific code and use that to determine whether an address
is cacheable or not.
Approved by: imp (mentor)
Deleted:
projects/mips/sys/mips/include/pltfm.h
Modified:
projects/mips/sys/mips/include/md_var.h
projects/mips/sys/mips/include/pmap.h
projects/mips/sys/mips/mips/machdep.c
projects/mips/sys/mips/mips/mem.c
projects/mips/sys/mips/mips/pmap.c
projects/mips/sys/mips/mips/vm_machdep.c
Modified: projects/mips/sys/mips/include/md_var.h
==============================================================================
--- projects/mips/sys/mips/include/md_var.h Thu Oct 22 00:32:01 2009 (r198353)
+++ projects/mips/sys/mips/include/md_var.h Thu Oct 22 02:51:31 2009 (r198354)
@@ -52,8 +52,8 @@ uintptr_t MipsEmulateBranch(struct trapf
void MipsSwitchFPState(struct thread *, struct trapframe *);
u_long kvtop(void *addr);
int is_physical_memory(vm_offset_t addr);
-int is_cacheable_mem(vm_offset_t pa);
-int is_coherent_mem(vm_offset_t pa);
+
+#define is_cacheable_mem(pa) is_physical_memory((pa))
#define MIPS_DEBUG 0
Modified: projects/mips/sys/mips/include/pmap.h
==============================================================================
--- projects/mips/sys/mips/include/pmap.h Thu Oct 22 00:32:01 2009 (r198353)
+++ projects/mips/sys/mips/include/pmap.h Thu Oct 22 02:51:31 2009 (r198354)
@@ -145,7 +145,21 @@ typedef struct pv_entry {
#define PMAP_DIAGNOSTIC
#endif
-extern vm_offset_t phys_avail[];
+/*
+ * physmem_desc[] is a superset of phys_avail[] and describes all the
+ * memory present in the system.
+ *
+ * phys_avail[] is similar but does not include the memory stolen by
+ * pmap_steal_memory().
+ *
+ * Each memory region is described by a pair of elements in the array
+ * so we can describe up to (PHYS_AVAIL_ENTRIES / 2) distinct memory
+ * regions.
+ */
+#define PHYS_AVAIL_ENTRIES 10
+extern vm_offset_t phys_avail[PHYS_AVAIL_ENTRIES + 2];
+extern vm_offset_t physmem_desc[PHYS_AVAIL_ENTRIES + 2];
+
extern char *ptvmmap; /* poor name! */
extern vm_offset_t virtual_avail;
extern vm_offset_t virtual_end;
Modified: projects/mips/sys/mips/mips/machdep.c
==============================================================================
--- projects/mips/sys/mips/mips/machdep.c Thu Oct 22 00:32:01 2009 (r198353)
+++ projects/mips/sys/mips/mips/machdep.c Thu Oct 22 02:51:31 2009 (r198354)
@@ -79,7 +79,6 @@ __FBSDID("$FreeBSD$");
#include <sys/syslog.h>
#include <machine/cache.h>
#include <machine/cpu.h>
-#include <machine/pltfm.h>
#include <net/netisr.h>
#include <machine/md_var.h>
#include <machine/clock.h>
@@ -120,7 +119,9 @@ struct pcpu pcpu;
struct pcpu *pcpup = &pcpu;
#endif
-vm_offset_t phys_avail[10];
+vm_offset_t phys_avail[PHYS_AVAIL_ENTRIES + 2];
+vm_offset_t physmem_desc[PHYS_AVAIL_ENTRIES + 2];
+
#ifdef UNIMPLEMENTED
struct platform platform;
#endif
@@ -426,3 +427,16 @@ cpu_idle_wakeup(int cpu)
return (0);
}
+
+int
+is_physical_memory(vm_offset_t addr)
+{
+ int i;
+
+ for (i = 0; physmem_desc[i + 1] != 0; i += 2) {
+ if (addr >= physmem_desc[i] && addr < physmem_desc[i + 1])
+ return (1);
+ }
+
+ return (0);
+}
Modified: projects/mips/sys/mips/mips/mem.c
==============================================================================
--- projects/mips/sys/mips/mips/mem.c Thu Oct 22 00:32:01 2009 (r198353)
+++ projects/mips/sys/mips/mips/mem.c Thu Oct 22 02:51:31 2009 (r198354)
@@ -65,7 +65,6 @@ __FBSDID("$FreeBSD$");
#include <machine/cpu.h>
#include <machine/md_var.h>
#include <machine/atomic.h>
-#include <machine/pltfm.h>
#include <machine/memdev.h>
@@ -101,17 +100,8 @@ memrw(dev, uio, flags)
vm_paddr_t pa;
register int o;
-#ifdef CPU_SB1
- if (!is_physical_memory(v) ||
- !is_physical_memory(roundup2(v, PAGE_SIZE) - 1)) {
- return (EFAULT);
- }
-#else
- if (v + c > (SDRAM_ADDR_START + ctob(physmem)))
- return (EFAULT);
-#endif
-
- if (is_cacheable_mem(v) && is_cacheable_mem(v + c)) {
+ if (is_cacheable_mem(v) &&
+ is_cacheable_mem(v + c - 1)) {
struct fpage *fp;
struct sysmaps *sysmaps;
Modified: projects/mips/sys/mips/mips/pmap.c
==============================================================================
--- projects/mips/sys/mips/mips/pmap.c Thu Oct 22 00:32:01 2009 (r198353)
+++ projects/mips/sys/mips/mips/pmap.c Thu Oct 22 02:51:31 2009 (r198354)
@@ -96,7 +96,6 @@ __FBSDID("$FreeBSD$");
#endif
#include <machine/cache.h>
-#include <machine/pltfm.h>
#include <machine/md_var.h>
#if defined(DIAGNOSTIC)
@@ -313,6 +312,14 @@ again:
}
}
+ /*
+ * Copy the phys_avail[] array before we start stealing memory from it.
+ */
+ for (i = 0; phys_avail[i + 1] != 0; i += 2) {
+ physmem_desc[i] = phys_avail[i];
+ physmem_desc[i + 1] = phys_avail[i + 1];
+ }
+
Maxmem = atop(phys_avail[i - 1]);
if (bootverbose) {
Modified: projects/mips/sys/mips/mips/vm_machdep.c
==============================================================================
--- projects/mips/sys/mips/mips/vm_machdep.c Thu Oct 22 00:32:01 2009 (r198353)
+++ projects/mips/sys/mips/mips/vm_machdep.c Thu Oct 22 02:51:31 2009 (r198354)
@@ -57,7 +57,6 @@ __FBSDID("$FreeBSD$");
#include <machine/cpu.h>
#include <machine/md_var.h>
#include <machine/pcb.h>
-#include <machine/pltfm.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
@@ -400,34 +399,6 @@ kvtop(void *addr)
#define ZIDLE_HI(v) ((v) * 4 / 5)
/*
- * Tell whether this address is in some physical memory region.
- * Currently used by the kernel coredump code in order to avoid
- * dumping non-memory physical address space.
- */
-int
-is_physical_memory(vm_offset_t addr)
-{
- if (addr >= SDRAM_ADDR_START && addr <= SDRAM_ADDR_END)
- return 1;
- else
- return 0;
-}
-
-int
-is_cacheable_mem(vm_offset_t pa)
-{
- if ((pa >= SDRAM_ADDR_START && pa <= SDRAM_ADDR_END) ||
-#ifdef FLASH_ADDR_START
- (pa >= FLASH_ADDR_START && pa <= FLASH_ADDR_END))
-#else
- 0)
-#endif
- return 1;
- else
- return 0;
-}
-
-/*
* Allocate a pool of sf_bufs (sendfile(2) or "super-fast" if you prefer. :-))
*/
static void
More information about the svn-src-projects
mailing list