diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2007-12-19 21:51:30 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2007-12-19 21:51:30 +0000 |
commit | aa8faebc6ff9cd54054ba36125aeddf8fdf61692 (patch) | |
tree | ca3058dc4bff30f798e6c1164b9a9292023a88aa /sys/arch | |
parent | 4cdfd5155109e087574b3d4d13323efcdce6d3ac (diff) |
Allocate memory for the onboard le interface using uvm functions, instead of
stealing pages in pmap_bootstrap. While there, use up to four times more
memory for these buffers if the machine has enough physical memory.
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/aviion/aviion/pmap_bootstrap.c | 80 | ||||
-rw-r--r-- | sys/arch/aviion/conf/files.aviion | 3 | ||||
-rw-r--r-- | sys/arch/aviion/dev/if_le_syscon.c | 80 | ||||
-rw-r--r-- | sys/arch/aviion/include/pmap.h | 4 |
4 files changed, 66 insertions, 101 deletions
diff --git a/sys/arch/aviion/aviion/pmap_bootstrap.c b/sys/arch/aviion/aviion/pmap_bootstrap.c deleted file mode 100644 index 6cafe97822b..00000000000 --- a/sys/arch/aviion/aviion/pmap_bootstrap.c +++ /dev/null @@ -1,80 +0,0 @@ -/* $OpenBSD: pmap_bootstrap.c,v 1.1 2006/05/07 15:55:55 miod Exp $ */ -/* - * Copyright (c) 2001-2004, Miodrag Vallat - * Copyright (c) 1998-2001 Steve Murphree, Jr. - * Copyright (c) 1996 Nivas Madhur - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Nivas Madhur. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ -/* - * Mach Operating System - * Copyright (c) 1991 Carnegie Mellon University - * Copyright (c) 1991 OMRON Corporation - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - */ - -#include <sys/param.h> -#include <sys/systm.h> - -#include <uvm/uvm.h> - -extern vaddr_t pmap_map(vaddr_t, paddr_t, paddr_t, vm_prot_t, u_int); -extern vaddr_t avail_start; -extern vaddr_t virtual_avail; - -#define ETHERPAGES 16 /* 64 KB */ -void *etherbuf = NULL; -size_t etherlen; - -vaddr_t -pmap_bootstrap_md(vaddr_t vaddr) -{ - /* - * Get ethernet buffer - need ETHERPAGES pages physically contiguous - * below 16MB. - */ - if (vaddr < 0x01000000 - ptoa(ETHERPAGES)) { - etherlen = ptoa(ETHERPAGES); - etherbuf = (void *)vaddr; - - vaddr = pmap_map(vaddr, avail_start, avail_start + etherlen, - UVM_PROT_RW, CACHE_INH); - - virtual_avail += etherlen; - avail_start += etherlen; - } - - return vaddr; -} diff --git a/sys/arch/aviion/conf/files.aviion b/sys/arch/aviion/conf/files.aviion index 48a702166b9..46973bad806 100644 --- a/sys/arch/aviion/conf/files.aviion +++ b/sys/arch/aviion/conf/files.aviion @@ -1,4 +1,4 @@ -# $OpenBSD: files.aviion,v 1.3 2007/03/01 21:44:02 miod Exp $ +# $OpenBSD: files.aviion,v 1.4 2007/12/19 21:51:29 miod Exp $ # maxpartitions 16 @@ -69,7 +69,6 @@ file arch/aviion/aviion/av5000_machdep.c av5000 file arch/aviion/aviion/av6280_machdep.c av6280 file arch/aviion/aviion/m8820x.c m88100 file arch/aviion/aviion/mem.c -file arch/aviion/aviion/pmap_bootstrap.c file arch/aviion/aviion/pmap_table.c file arch/aviion/aviion/prom.c file arch/aviion/dev/mainbus.c diff --git a/sys/arch/aviion/dev/if_le_syscon.c b/sys/arch/aviion/dev/if_le_syscon.c index 404dff6ff90..e49f34bc1fe 100644 --- a/sys/arch/aviion/dev/if_le_syscon.c +++ b/sys/arch/aviion/dev/if_le_syscon.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_le_syscon.c,v 1.2 2006/05/21 12:22:02 miod Exp $ */ +/* $OpenBSD: if_le_syscon.c,v 1.3 2007/12/19 21:51:29 miod Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -43,6 +43,8 @@ #include <sys/socket.h> #include <sys/device.h> +#include <uvm/uvm.h> + #include <net/if.h> #ifdef INET @@ -117,35 +119,79 @@ le_syscon_rdcsr(sc, port) int le_syscon_match(parent, cf, aux) - struct device *parent; - void *cf, *aux; + struct device *parent; + void *cf, *aux; { - return (1); + if (avtyp != AV_400) + return (0); + + return (1); } void le_syscon_attach(parent, self, aux) - struct device *parent, *self; - void *aux; + struct device *parent, *self; + void *aux; { struct le_softc *lesc = (struct le_softc *)self; struct am7990_softc *sc = &lesc->sc_am7990; - struct confargs *ca = aux; - extern void *etherbuf; - extern size_t etherlen; + struct confargs *ca = aux; + u_int etherpages; + struct pglist pglist; + vm_page_t pg; + int rc; + paddr_t pa; + vaddr_t va; + + /* + * Allocate contiguous pages in the first 16MB to use as buffers. + */ + if (physmem >= atop(32 * 1024 * 1024)) + etherpages = 64; + else if (physmem >= atop(16 * 1024 * 1024)) + etherpages = 32; + else + etherpages = 16; + for (;;) { + TAILQ_INIT(&pglist); + rc = uvm_pglistalloc(ptoa(etherpages), 0, 1 << 24, + 0, 0, &pglist, 1, 0); + if (rc == 0) + break; + + etherpages >>= 1; + if (etherpages == 2) { + printf(": no available memory, kernel is too large\n"); + return; + } + } - if (etherbuf == NULL) { - printf(": no available memory, kernel is too large\n"); + va = uvm_km_valloc(kernel_map, ptoa(etherpages)); + if (va == NULL) { + printf(": could not map descriptor memory\n"); + uvm_pglistfree(&pglist); return; } - lesc->sc_r1 = (struct av_lereg *)ca->ca_paddr; + pa = VM_PAGE_TO_PHYS(TAILQ_FIRST(&pglist)); + + sc->sc_mem = (void *)va; + sc->sc_addr = (u_long)pa & 0x00ffffff; + sc->sc_memsize = ptoa(etherpages); + + TAILQ_FOREACH(pg, &pglist, pageq) { + pmap_enter(pmap_kernel(), va, pa, + UVM_PROT_RW, UVM_PROT_RW | PMAP_WIRED); + va += PAGE_SIZE; + pa += PAGE_SIZE; + } + pmap_cache_ctrl(pmap_kernel(), (vaddr_t)sc->sc_mem, + (vaddr_t)sc->sc_mem + sc->sc_memsize, CACHE_INH); + pmap_update(pmap_kernel()); + + lesc->sc_r1 = (struct av_lereg *)ca->ca_paddr; - sc->sc_mem = (void *)etherbuf; - etherbuf = NULL; - sc->sc_conf3 = LE_C3_BSWP; - sc->sc_addr = (u_long)sc->sc_mem & 0x00ffffff; - sc->sc_memsize = etherlen; + sc->sc_conf3 = LE_C3_BSWP; myetheraddr(sc->sc_arpcom.ac_enaddr); diff --git a/sys/arch/aviion/include/pmap.h b/sys/arch/aviion/include/pmap.h index 000b1c04f7b..2b974390f73 100644 --- a/sys/arch/aviion/include/pmap.h +++ b/sys/arch/aviion/include/pmap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.h,v 1.1 2006/05/09 18:32:33 miod Exp $ */ +/* $OpenBSD: pmap.h,v 1.2 2007/12/19 21:51:29 miod Exp $ */ /* public domain */ #ifndef _AVIION_PMAP_H_ @@ -7,7 +7,7 @@ #include <m88k/pmap.h> #ifdef _KERNEL -vaddr_t pmap_bootstrap_md(vaddr_t); +#define pmap_bootstrap_md(va) (va) #endif #endif _AVIION_PMAP_H_ |