Sync usage with man page.
[netbsd-mini2440.git] / sys / arch / alpha / pci / irongate_bus_mem.c
blobd871e4952108bcd00b9adbaa6672802723e78c50
1 /* $NetBSD: irongate_bus_mem.c,v 1.7 2001/04/17 21:52:00 thorpej Exp $ */
3 /*-
4 * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
34 __KERNEL_RCSID(1, "$NetBSD: irongate_bus_mem.c,v 1.7 2001/04/17 21:52:00 thorpej Exp $");
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/malloc.h>
39 #include <sys/syslog.h>
40 #include <sys/device.h>
42 #include <uvm/uvm_extern.h>
44 #include <machine/bus.h>
46 #include <alpha/pci/irongatereg.h>
47 #include <alpha/pci/irongatevar.h>
49 #define CHIP irongate
51 #define CHIP_EX_MALLOC_SAFE(v) (((struct irongate_config *)(v))->ic_mallocsafe)
52 #define CHIP_MEM_EXTENT(v) (((struct irongate_config *)(v))->ic_mem_ex)
54 #define CHIP_MEM_SYS_START(v) IRONGATE_MEM_BASE
56 /*
57 * AMD 751 core logic appears on EV6. We require at least EV56
58 * support for the assembler to emit BWX opcodes.
60 __asm(".arch ev6");
62 #include <alpha/pci/pci_bwx_bus_mem_chipdep.c>
64 #include <sys/kcore.h>
66 #include <dev/isa/isareg.h>
68 extern phys_ram_seg_t mem_clusters[];
69 extern int mem_cluster_cnt;
71 void
72 irongate_bus_mem_init2(bus_space_tag_t t, void *v)
74 u_long size, start, end;
75 int i, error;
78 * Since the AMD 751 doesn't have DMA windows, we need to
79 * allocate RAM out of the extent map.
81 for (i = 0; i < mem_cluster_cnt; i++) {
82 start = mem_clusters[i].start;
83 size = mem_clusters[i].size & ~PAGE_MASK;
84 end = mem_clusters[i].start + size;
86 if (start <= IOM_BEGIN && end >= IOM_END) {
88 * The ISA hole lies somewhere in this
89 * memory cluster. The UP1000 firmware
90 * doesn't report this to us properly,
91 * so we have to cope, since devices are
92 * mapped into the ISA hole, but RAM is
93 * not.
95 * Sigh, the UP1000 is a really cool machine,
96 * but it is sometimes too PC-like for my
97 * taste.
99 if (start < IOM_BEGIN) {
100 error = extent_alloc_region(CHIP_MEM_EXTENT(v),
101 start, (IOM_BEGIN - start),
102 EX_NOWAIT |
103 (CHIP_EX_MALLOC_SAFE(v) ? EX_MALLOCOK : 0));
104 if (error) {
105 printf("WARNING: unable to reserve "
106 "chunk from mem cluster %d "
107 "(0x%lx - 0x%lx)\n", i,
108 start, (u_long) IOM_BEGIN - 1);
111 if (end > IOM_END) {
112 error = extent_alloc_region(CHIP_MEM_EXTENT(v),
113 IOM_END, (end - IOM_END),
114 EX_NOWAIT |
115 (CHIP_EX_MALLOC_SAFE(v) ? EX_MALLOCOK : 0));
116 if (error) {
117 printf("WARNING: unable to reserve "
118 "chunk from mem cluster %d "
119 "(0x%lx - 0x%lx)\n", i,
120 (u_long) IOM_END, end - 1);
123 } else {
124 error = extent_alloc_region(CHIP_MEM_EXTENT(v),
125 start, size,
126 EX_NOWAIT |
127 (CHIP_EX_MALLOC_SAFE(v) ? EX_MALLOCOK : 0));
128 if (error) {
129 printf("WARNING: unable reserve mem cluster %d "
130 "(0x%lx - 0x%lx)\n", i, start,
131 start + (size - 1));