root / prex-0.9.0 / bsp / hal / ppc / prep / machdep.c @ 03e9c04a
History | View | Annotate | Download (3.21 KB)
1 | 03e9c04a | Brad Neuman | /*-
|
---|---|---|---|
2 | * Copyright (c) 2009, Kohsuke Ohtani
|
||
3 | * All rights reserved.
|
||
4 | *
|
||
5 | * Redistribution and use in source and binary forms, with or without
|
||
6 | * modification, are permitted provided that the following conditions
|
||
7 | * are met:
|
||
8 | * 1. Redistributions of source code must retain the above copyright
|
||
9 | * notice, this list of conditions and the following disclaimer.
|
||
10 | * 2. Redistributions in binary form must reproduce the above copyright
|
||
11 | * notice, this list of conditions and the following disclaimer in the
|
||
12 | * documentation and/or other materials provided with the distribution.
|
||
13 | * 3. Neither the name of the author nor the names of any co-contributors
|
||
14 | * may be used to endorse or promote products derived from this software
|
||
15 | * without specific prior written permission.
|
||
16 | *
|
||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||
27 | * SUCH DAMAGE.
|
||
28 | */
|
||
29 | |||
30 | /*
|
||
31 | * machdep.c - machine-dependent routines for PPC PReP
|
||
32 | */
|
||
33 | |||
34 | #include <machine/syspage.h> |
||
35 | #include <sys/power.h> |
||
36 | #include <sys/bootinfo.h> |
||
37 | #include <kernel.h> |
||
38 | #include <page.h> |
||
39 | #include <mmu.h> |
||
40 | #include <cpu.h> |
||
41 | #include <io.h> |
||
42 | #include <cpufunc.h> |
||
43 | #include <locore.h> |
||
44 | |||
45 | extern void *exception_vector; |
||
46 | extern void *exception_vector_end; |
||
47 | |||
48 | #ifdef CONFIG_MMU
|
||
49 | /*
|
||
50 | * Virtual and physical address mapping
|
||
51 | *
|
||
52 | * { virtual, physical, size, type }
|
||
53 | */
|
||
54 | struct mmumap mmumap_table[] =
|
||
55 | { |
||
56 | /*
|
||
57 | * Physical memory
|
||
58 | */
|
||
59 | { 0x80000000, 0x00000000, 0x9000000, VMT_RAM }, |
||
60 | |||
61 | /*
|
||
62 | * ISA I/O space
|
||
63 | */
|
||
64 | { 0xf0000000, 0x80000000, 0xf000, VMT_IO }, |
||
65 | |||
66 | { 0,0,0,0 } |
||
67 | }; |
||
68 | #endif
|
||
69 | |||
70 | /*
|
||
71 | * Idle
|
||
72 | */
|
||
73 | void
|
||
74 | machine_idle(void)
|
||
75 | { |
||
76 | |||
77 | cpu_idle(); |
||
78 | } |
||
79 | |||
80 | /*
|
||
81 | * Cause PReP machine reset.
|
||
82 | */
|
||
83 | static void |
||
84 | machine_reset(void)
|
||
85 | { |
||
86 | u_char val; |
||
87 | |||
88 | val = inb(0x92);
|
||
89 | val &= ~1UL;
|
||
90 | outb(0x92, val);
|
||
91 | |||
92 | val = inb(0x92);
|
||
93 | val |= 1;
|
||
94 | outb(0x92, val);
|
||
95 | |||
96 | /* NOTREACHED */
|
||
97 | } |
||
98 | |||
99 | /*
|
||
100 | * Set system power
|
||
101 | */
|
||
102 | void
|
||
103 | machine_powerdown(int state)
|
||
104 | { |
||
105 | |||
106 | DPRINTF(("Power down machine\n"));
|
||
107 | |||
108 | splhigh(); |
||
109 | |||
110 | switch (state) {
|
||
111 | case PWR_SUSPEND:
|
||
112 | case PWR_OFF:
|
||
113 | for (;;)
|
||
114 | cpu_idle(); |
||
115 | /* NOTREACHED */
|
||
116 | break;
|
||
117 | case PWR_REBOOT:
|
||
118 | machine_reset(); |
||
119 | /* NOTREACHED */
|
||
120 | break;
|
||
121 | } |
||
122 | } |
||
123 | |||
124 | /*
|
||
125 | * Return pointer to the boot information.
|
||
126 | */
|
||
127 | void
|
||
128 | machine_bootinfo(struct bootinfo **bip)
|
||
129 | { |
||
130 | |||
131 | *bip = (struct bootinfo *)BOOTINFO;
|
||
132 | } |
||
133 | |||
134 | void
|
||
135 | machine_abort(void)
|
||
136 | { |
||
137 | |||
138 | for (;;) ;
|
||
139 | } |
||
140 | |||
141 | /*
|
||
142 | * Machine-dependent startup code
|
||
143 | */
|
||
144 | void
|
||
145 | machine_startup(void)
|
||
146 | { |
||
147 | void *vector_offset = 0; |
||
148 | |||
149 | /*
|
||
150 | * Reserve system pages.
|
||
151 | */
|
||
152 | page_reserve(kvtop(SYSPAGE), SYSPAGESZ); |
||
153 | |||
154 | /*
|
||
155 | * Copy exception vectors.
|
||
156 | */
|
||
157 | memcpy(vector_offset, &exception_vector, 0x3000);
|
||
158 | |||
159 | #ifdef CONFIG_MMU
|
||
160 | /*
|
||
161 | * Initialize MMU
|
||
162 | */
|
||
163 | mmu_init(mmumap_table); |
||
164 | #endif
|
||
165 | } |