1 /* $NetBSD: amiga_init.c,v 1.3 2000/07/01 03:34:05 mrg Exp $ */ 2 3 /* 4 * Copyright (c) 1994 Michael L. Hitch 5 * Copyright (c) 1993 Markus Wild 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. All advertising materials mentioning features or use of this software 17 * must display the following acknowledgement: 18 * This product includes software developed by Markus Wild. 19 * 4. The name of the author may not be used to endorse or promote products 20 * derived from this software without specific prior written permission 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 #include <sys/param.h> 35 #include <sys/systm.h> 36 #include <sys/proc.h> 37 #include <uvm/uvm_extern.h> 38 #include <sys/user.h> 39 #include <sys/ioctl.h> 40 #include <sys/select.h> 41 #include <sys/tty.h> 42 #include <sys/proc.h> 43 #include <sys/buf.h> 44 #include <sys/msgbuf.h> 45 #include <sys/mbuf.h> 46 #include <sys/protosw.h> 47 #include <sys/domain.h> 48 #include <sys/dkbad.h> 49 #include <sys/reboot.h> 50 #include <sys/exec.h> 51 #include <amiga/amiga/cc.h> 52 53 u_long boot_fphystart, boot_fphysize, cphysize; 54 55 vaddr_t z2mem_start; /* XXX */ 56 static vaddr_t z2mem_end; /* XXX */ 57 int use_z2_mem = 1; /* XXX */ 58 59 void * 60 chipmem_steal(amount) 61 long amount; 62 { 63 /* 64 * steal from top of chipmem, so we don't collide with 65 * the kernel loaded into chipmem in the not-yet-mapped state. 66 */ 67 vaddr_t p = chipmem_end - amount; 68 if (p & 1) 69 p = p - 1; 70 chipmem_end = p; 71 if(chipmem_start > chipmem_end) 72 panic("not enough chip memory"); 73 return((void *)p); 74 } 75 76 77 /* 78 * XXX 79 * used by certain drivers currently to allocate zorro II memory 80 * for bounce buffers, if use_z2_mem is NULL, chipmem will be 81 * returned instead. 82 * XXX 83 */ 84 void * 85 alloc_z2mem(amount) 86 long amount; 87 { 88 if (use_z2_mem && z2mem_end && (z2mem_end - amount) >= z2mem_start) { 89 z2mem_end -= amount; 90 return ((void *)z2mem_end); 91 } 92 return (alloc_chipmem(amount)); 93 } 94