| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: stubs.c,v 1.20 2009/01/21 16:24:34 he Exp $ */ | | 1 | /* $NetBSD: stubs.c,v 1.21 2009/03/15 22:20:10 cegger Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1994-1998 Mark Brinicombe. | | 4 | * Copyright (c) 1994-1998 Mark Brinicombe. |
5 | * Copyright (c) 1994 Brini. | | 5 | * Copyright (c) 1994 Brini. |
6 | * All rights reserved. | | 6 | * All rights reserved. |
7 | * | | 7 | * |
8 | * This code is derived from software written for Brini by Mark Brinicombe | | 8 | * This code is derived from software written for Brini by Mark Brinicombe |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -31,27 +31,27 @@ | | | @@ -31,27 +31,27 @@ |
31 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | | 31 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
33 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 33 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
34 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 34 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
35 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 35 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
36 | * SUCH DAMAGE. | | 36 | * SUCH DAMAGE. |
37 | * | | 37 | * |
38 | * Routines that are temporary or do not have a home yet. | | 38 | * Routines that are temporary or do not have a home yet. |
39 | * | | 39 | * |
40 | * Created : 17/09/94 | | 40 | * Created : 17/09/94 |
41 | */ | | 41 | */ |
42 | | | 42 | |
43 | #include <sys/cdefs.h> | | 43 | #include <sys/cdefs.h> |
44 | __KERNEL_RCSID(0, "$NetBSD: stubs.c,v 1.20 2009/01/21 16:24:34 he Exp $"); | | 44 | __KERNEL_RCSID(0, "$NetBSD: stubs.c,v 1.21 2009/03/15 22:20:10 cegger Exp $"); |
45 | | | 45 | |
46 | #include <sys/param.h> | | 46 | #include <sys/param.h> |
47 | #include <sys/systm.h> | | 47 | #include <sys/systm.h> |
48 | #include <sys/errno.h> | | 48 | #include <sys/errno.h> |
49 | #include <sys/proc.h> | | 49 | #include <sys/proc.h> |
50 | #include <sys/conf.h> | | 50 | #include <sys/conf.h> |
51 | #include <sys/msgbuf.h> | | 51 | #include <sys/msgbuf.h> |
52 | #include <uvm/uvm_extern.h> | | 52 | #include <uvm/uvm_extern.h> |
53 | #include <machine/cpu.h> | | 53 | #include <machine/cpu.h> |
54 | #include <machine/intr.h> | | 54 | #include <machine/intr.h> |
55 | #include <machine/bootconfig.h> | | 55 | #include <machine/bootconfig.h> |
56 | #include <machine/pcb.h> | | 56 | #include <machine/pcb.h> |
57 | #include <arm/arm32/machdep.h> | | 57 | #include <arm/arm32/machdep.h> |
| @@ -74,27 +74,27 @@ int dumpsize = 0; /* pages */ | | | @@ -74,27 +74,27 @@ int dumpsize = 0; /* pages */ |
74 | long dumplo = 0; /* blocks */ | | 74 | long dumplo = 0; /* blocks */ |
75 | | | 75 | |
76 | struct pcb dumppcb; | | 76 | struct pcb dumppcb; |
77 | | | 77 | |
78 | /* | | 78 | /* |
79 | * This is called by main to set dumplo and dumpsize. | | 79 | * This is called by main to set dumplo and dumpsize. |
80 | * Dumps always skip the first PAGE_SIZE of disk space | | 80 | * Dumps always skip the first PAGE_SIZE of disk space |
81 | * in case there might be a disk label stored there. | | 81 | * in case there might be a disk label stored there. |
82 | * If there is extra space, put dump at the end to | | 82 | * If there is extra space, put dump at the end to |
83 | * reduce the chance that swapping trashes it. | | 83 | * reduce the chance that swapping trashes it. |
84 | */ | | 84 | */ |
85 | | | 85 | |
86 | void | | 86 | void |
87 | cpu_dumpconf() | | 87 | cpu_dumpconf(void) |
88 | { | | 88 | { |
89 | const struct bdevsw *bdev; | | 89 | const struct bdevsw *bdev; |
90 | int nblks, dumpblks; /* size of dump area */ | | 90 | int nblks, dumpblks; /* size of dump area */ |
91 | | | 91 | |
92 | if (dumpdev == NODEV) | | 92 | if (dumpdev == NODEV) |
93 | return; | | 93 | return; |
94 | bdev = bdevsw_lookup(dumpdev); | | 94 | bdev = bdevsw_lookup(dumpdev); |
95 | if (bdev == NULL) | | 95 | if (bdev == NULL) |
96 | panic("dumpconf: bad dumpdev=0x%"PRIx64"", dumpdev); | | 96 | panic("dumpconf: bad dumpdev=0x%"PRIx64"", dumpdev); |
97 | if (bdev->d_psize == NULL) | | 97 | if (bdev->d_psize == NULL) |
98 | return; | | 98 | return; |
99 | nblks = (*bdev->d_psize)(dumpdev); | | 99 | nblks = (*bdev->d_psize)(dumpdev); |
100 | if (nblks <= ctod(1)) | | 100 | if (nblks <= ctod(1)) |
| @@ -114,27 +114,27 @@ cpu_dumpconf() | | | @@ -114,27 +114,27 @@ cpu_dumpconf() |
114 | | | 114 | |
115 | /* dumpsize is in page units, and doesn't include headers. */ | | 115 | /* dumpsize is in page units, and doesn't include headers. */ |
116 | dumpsize = cpu_dump_mempagecnt(); | | 116 | dumpsize = cpu_dump_mempagecnt(); |
117 | return; | | 117 | return; |
118 | | | 118 | |
119 | bad: | | 119 | bad: |
120 | dumpsize = 0; | | 120 | dumpsize = 0; |
121 | } | | 121 | } |
122 | | | 122 | |
123 | /* | | 123 | /* |
124 | * cpu_dump: dump the machine-dependent kernel core dump headers. | | 124 | * cpu_dump: dump the machine-dependent kernel core dump headers. |
125 | */ | | 125 | */ |
126 | int | | 126 | int |
127 | cpu_dump() | | 127 | cpu_dump(void) |
128 | { | | 128 | { |
129 | int (*dump)(dev_t, daddr_t, void *, size_t); | | 129 | int (*dump)(dev_t, daddr_t, void *, size_t); |
130 | char bf[dbtob(1)]; | | 130 | char bf[dbtob(1)]; |
131 | kcore_seg_t *segp; | | 131 | kcore_seg_t *segp; |
132 | cpu_kcore_hdr_t *cpuhdrp; | | 132 | cpu_kcore_hdr_t *cpuhdrp; |
133 | phys_ram_seg_t *memsegp; | | 133 | phys_ram_seg_t *memsegp; |
134 | const struct bdevsw *bdev; | | 134 | const struct bdevsw *bdev; |
135 | int i; | | 135 | int i; |
136 | | | 136 | |
137 | bdev = bdevsw_lookup(dumpdev); | | 137 | bdev = bdevsw_lookup(dumpdev); |
138 | if (bdev == NULL) | | 138 | if (bdev == NULL) |
139 | return (ENXIO); | | 139 | return (ENXIO); |
140 | dump = bdev->d_dump; | | 140 | dump = bdev->d_dump; |
| @@ -165,68 +165,68 @@ cpu_dump() | | | @@ -165,68 +165,68 @@ cpu_dump() |
165 | */ | | 165 | */ |
166 | for (i = 0; i < bootconfig.dramblocks; i++) { | | 166 | for (i = 0; i < bootconfig.dramblocks; i++) { |
167 | memsegp[i].start = bootconfig.dram[i].address; | | 167 | memsegp[i].start = bootconfig.dram[i].address; |
168 | memsegp[i].size = bootconfig.dram[i].pages * PAGE_SIZE; | | 168 | memsegp[i].size = bootconfig.dram[i].pages * PAGE_SIZE; |
169 | } | | 169 | } |
170 | | | 170 | |
171 | return (dump(dumpdev, dumplo, bf, dbtob(1))); | | 171 | return (dump(dumpdev, dumplo, bf, dbtob(1))); |
172 | } | | 172 | } |
173 | | | 173 | |
174 | /* | | 174 | /* |
175 | * cpu_dumpsize: calculate size of machine-dependent kernel core dump headers. | | 175 | * cpu_dumpsize: calculate size of machine-dependent kernel core dump headers. |
176 | */ | | 176 | */ |
177 | int | | 177 | int |
178 | cpu_dumpsize() | | 178 | cpu_dumpsize(void) |
179 | { | | 179 | { |
180 | int size; | | 180 | int size; |
181 | | | 181 | |
182 | size = ALIGN(sizeof(kcore_seg_t)) + ALIGN(sizeof(cpu_kcore_hdr_t)) + | | 182 | size = ALIGN(sizeof(kcore_seg_t)) + ALIGN(sizeof(cpu_kcore_hdr_t)) + |
183 | ALIGN( bootconfig.dramblocks * sizeof(phys_ram_seg_t)); | | 183 | ALIGN( bootconfig.dramblocks * sizeof(phys_ram_seg_t)); |
184 | if (roundup(size, dbtob(1)) != dbtob(1)) | | 184 | if (roundup(size, dbtob(1)) != dbtob(1)) |
185 | return (-1); | | 185 | return (-1); |
186 | | | 186 | |
187 | return (1); | | 187 | return (1); |
188 | } | | 188 | } |
189 | | | 189 | |
190 | | | 190 | |
191 | /* | | 191 | /* |
192 | * cpu_dump_mempagecnt: calculate the size of RAM (in pages) to be dumped. | | 192 | * cpu_dump_mempagecnt: calculate the size of RAM (in pages) to be dumped. |
193 | */ | | 193 | */ |
194 | u_long | | 194 | u_long |
195 | cpu_dump_mempagecnt() | | 195 | cpu_dump_mempagecnt(void) |
196 | { | | 196 | { |
197 | u_long i, n; | | 197 | u_long i, n; |
198 | | | 198 | |
199 | n = 0; | | 199 | n = 0; |
200 | for (i = 0; i < bootconfig.dramblocks; i++) { | | 200 | for (i = 0; i < bootconfig.dramblocks; i++) { |
201 | n += bootconfig.dram[i].pages; | | 201 | n += bootconfig.dram[i].pages; |
202 | } | | 202 | } |
203 | | | 203 | |
204 | return (n); | | 204 | return (n); |
205 | } | | 205 | } |
206 | | | 206 | |
207 | /* This should be moved to machdep.c */ | | 207 | /* This should be moved to machdep.c */ |
208 | | | 208 | |
209 | extern vaddr_t memhook; /* XXX */ | | 209 | extern vaddr_t memhook; /* XXX */ |
210 | | | 210 | |
211 | /* | | 211 | /* |
212 | * Doadump comes here after turning off memory management and | | 212 | * Doadump comes here after turning off memory management and |
213 | * getting on the dump stack, either when called above, or by | | 213 | * getting on the dump stack, either when called above, or by |
214 | * the auto-restart code. | | 214 | * the auto-restart code. |
215 | */ | | 215 | */ |
216 | void dodumpsys(void); | | 216 | void dodumpsys(void); |
217 | | | 217 | |
218 | void | | 218 | void |
219 | dodumpsys() | | 219 | dodumpsys(void) |
220 | { | | 220 | { |
221 | const struct bdevsw *bdev; | | 221 | const struct bdevsw *bdev; |
222 | daddr_t blkno; | | 222 | daddr_t blkno; |
223 | int psize; | | 223 | int psize; |
224 | int error; | | 224 | int error; |
225 | int addr; | | 225 | int addr; |
226 | int block; | | 226 | int block; |
227 | int len; | | 227 | int len; |
228 | vaddr_t dumpspace; | | 228 | vaddr_t dumpspace; |
229 | | | 229 | |
230 | /* flush everything out of caches */ | | 230 | /* flush everything out of caches */ |
231 | cpu_dcache_wbinv_all(); | | 231 | cpu_dcache_wbinv_all(); |
232 | | | 232 | |