Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / arch / powerpc / oea / prep_machdep.c
blob670a17166e0e197d92a6a385bf2b86fa3307afbd
1 /* $NetBSD: prep_machdep.c,v 1.5 2008/11/30 18:21:35 martin Exp $ */
3 /*-
4 * Copyright (c) 2007 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Tim Rightnour
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.
33 * This is a set of general routines that most PReP-similar machines have
34 * in common. Machines that use these routines do not have to be fully
35 * PReP compliant, the only requirement is that they use a PReP memory map.
36 * IE, io at 0x80000000 and mem at 0xc0000000.
39 #include <sys/cdefs.h>
40 __KERNEL_RCSID(0, "$NetBSD: prep_machdep.c,v 1.5 2008/11/30 18:21:35 martin Exp $");
42 #include "opt_modular.h"
44 #include <sys/param.h>
45 #include <sys/extent.h>
46 #include <sys/kernel.h>
47 #include <sys/malloc.h>
48 #include <sys/reboot.h>
49 #include <sys/ksyms.h>
51 #include <uvm/uvm_extern.h>
52 #include <machine/powerpc.h>
53 #include <machine/bus.h>
54 #include <machine/pmap.h>
55 #include <powerpc/oea/bat.h>
57 #include "opt_ddb.h"
58 #ifdef DDB
59 #include <machine/db_machdep.h>
60 #include <ddb/db_extern.h>
61 #endif
63 #include "ksyms.h"
65 #if NKSYMS || defined(DDB) || defined(MODULAR)
66 extern void *endsym, *startsym;
67 #endif
68 extern struct mem_region physmemr[2], availmemr[2];
70 struct powerpc_bus_space prep_io_space_tag = {
71 .pbs_flags = _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
72 .pbs_offset = PREP_BUS_SPACE_IO,
73 .pbs_base = 0x00000000,
74 .pbs_limit = PREP_PHYS_SIZE_IO,
77 struct powerpc_bus_space genppc_isa_io_space_tag = {
78 .pbs_flags = _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
79 .pbs_offset = PREP_BUS_SPACE_IO,
80 .pbs_base = 0x00000000,
81 .pbs_limit = PREP_ISA_SIZE_IO,
84 struct powerpc_bus_space prep_mem_space_tag = {
85 .pbs_flags = _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
86 .pbs_offset = PREP_BUS_SPACE_MEM,
87 .pbs_base = 0x00000000,
88 .pbs_limit = PREP_PHYS_SIZE_MEM,
91 struct powerpc_bus_space genppc_isa_mem_space_tag = {
92 .pbs_flags = _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
93 .pbs_offset = PREP_BUS_SPACE_MEM,
94 .pbs_base = 0x00000000,
95 .pbs_limit = PREP_ISA_SIZE_MEM,
98 static char ex_storage[2][EXTENT_FIXED_STORAGE_SIZE(8)]
99 __attribute__((aligned(8)));
101 void
102 prep_bus_space_init(void)
104 int error;
106 error = bus_space_init(&prep_io_space_tag, "ioport",
107 ex_storage[0], sizeof(ex_storage[0]));
108 if (error)
109 panic("prep_bus_space_init: can't init io tag");
111 error = extent_alloc_region(prep_io_space_tag.pbs_extent,
112 PREP_PHYS_RESVD_START_IO, PREP_PHYS_RESVD_SIZE_IO, EX_NOWAIT);
113 if (error)
114 panic("prep_bus_space_init: can't block out reserved I/O"
115 " space 0x10000-0x7fffff: error=%d", error);
117 error = bus_space_init(&prep_mem_space_tag, "iomem",
118 ex_storage[1], sizeof(ex_storage[1]));
119 if (error)
120 panic("prep_bus_space_init: can't init mem tag");
122 genppc_isa_io_space_tag.pbs_extent = prep_io_space_tag.pbs_extent;
123 error = bus_space_init(&genppc_isa_io_space_tag, "isa-ioport", NULL, 0); if (error)
124 panic("prep_bus_space_init: can't init isa io tag");
126 genppc_isa_mem_space_tag.pbs_extent = prep_mem_space_tag.pbs_extent;
127 error = bus_space_init(&genppc_isa_mem_space_tag, "isa-iomem", NULL, 0);
128 if (error)
129 panic("prep_bus_space_init: can't init isa mem tag");
133 * just a few calls used in initppc() all in one place so everything gets
134 * done the same across the ports
137 void
138 prep_initppc(u_long startkernel, u_long endkernel, u_int args)
142 * Now setup fixed bat registers
143 * We setup the memory BAT, the IO space BAT, and a special
144 * BAT for certain machines that have rs6k style PCI bridges
145 * (only on port-prep)
147 oea_batinit(
148 PREP_BUS_SPACE_MEM, BAT_BL_256M,
149 PREP_BUS_SPACE_IO, BAT_BL_256M,
150 #ifdef prep
151 0xbf800000, BAT_BL_8M,
152 #endif
155 /* Install vectors and interrupt handler. */
156 oea_init(NULL);
158 /* Initialize bus_space. */
159 prep_bus_space_init();
161 /* Initialize the console asap. */
162 consinit();
164 /* Set the page size */
165 uvm_setpagesize();
167 /* Initialize pmap module */
168 pmap_bootstrap(startkernel, endkernel);
170 #if NKSYMS || defined(DDB) || defined(MODULAR)
171 ksyms_addsyms_elf((int)((u_long)endsym - (u_long)startsym), startsym, endsym);
172 #endif
174 #ifdef DDB
175 boothowto = args;
176 if (boothowto & RB_KDB)
177 Debugger();
178 #endif
181 void
182 mem_regions(struct mem_region **mem, struct mem_region **avail)
185 *mem = physmemr;
186 *avail = availmemr;