From owner-svn-src-projects@FreeBSD.ORG Thu Oct 22 02:51:32 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6B17B106566C; Thu, 22 Oct 2009 02:51:32 +0000 (UTC) (envelope-from neel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5995F8FC0C; Thu, 22 Oct 2009 02:51:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9M2pWSj017162; Thu, 22 Oct 2009 02:51:32 GMT (envelope-from neel@svn.freebsd.org) Received: (from neel@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9M2pVin017155; Thu, 22 Oct 2009 02:51:31 GMT (envelope-from neel@svn.freebsd.org) Message-Id: <200910220251.n9M2pVin017155@svn.freebsd.org> From: Neel Natu Date: Thu, 22 Oct 2009 02:51:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198354 - in projects/mips/sys/mips: include mips X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Oct 2009 02:51:32 -0000 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 #include #include -#include #include #include #include @@ -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 #include #include -#include #include @@ -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 -#include #include #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 #include #include -#include #include #include @@ -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