smdk2800_machdep.c revision 1.43 1 1.43 cherry /* $NetBSD: smdk2800_machdep.c,v 1.43 2016/12/22 14:47:56 cherry Exp $ */
2 1.1 bsh
3 1.1 bsh /*
4 1.20 bsh * Copyright (c) 2002, 2003, 2005 Fujitsu Component Limited
5 1.20 bsh * Copyright (c) 2002, 2003, 2005 Genetec Corporation
6 1.1 bsh * All rights reserved.
7 1.1 bsh *
8 1.1 bsh * Redistribution and use in source and binary forms, with or without
9 1.1 bsh * modification, are permitted provided that the following conditions
10 1.1 bsh * are met:
11 1.1 bsh * 1. Redistributions of source code must retain the above copyright
12 1.1 bsh * notice, this list of conditions and the following disclaimer.
13 1.1 bsh * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 bsh * notice, this list of conditions and the following disclaimer in the
15 1.1 bsh * documentation and/or other materials provided with the distribution.
16 1.1 bsh * 3. Neither the name of The Fujitsu Component Limited nor the name of
17 1.1 bsh * Genetec corporation may not be used to endorse or promote products
18 1.1 bsh * derived from this software without specific prior written permission.
19 1.1 bsh *
20 1.1 bsh * THIS SOFTWARE IS PROVIDED BY FUJITSU COMPONENT LIMITED AND GENETEC
21 1.1 bsh * CORPORATION ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22 1.1 bsh * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 1.1 bsh * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 1.1 bsh * DISCLAIMED. IN NO EVENT SHALL FUJITSU COMPONENT LIMITED OR GENETEC
25 1.1 bsh * CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 1.1 bsh * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 1.1 bsh * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
28 1.1 bsh * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 1.1 bsh * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 1.1 bsh * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 1.1 bsh * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 1.1 bsh * SUCH DAMAGE.
33 1.1 bsh */
34 1.1 bsh
35 1.1 bsh /*
36 1.1 bsh * Copyright (c) 2001,2002 ARM Ltd
37 1.1 bsh * All rights reserved.
38 1.1 bsh *
39 1.1 bsh * Redistribution and use in source and binary forms, with or without
40 1.1 bsh * modification, are permitted provided that the following conditions
41 1.1 bsh * are met:
42 1.1 bsh * 1. Redistributions of source code must retain the above copyright
43 1.1 bsh * notice, this list of conditions and the following disclaimer.
44 1.1 bsh * 2. Redistributions in binary form must reproduce the above copyright
45 1.1 bsh * notice, this list of conditions and the following disclaimer in the
46 1.1 bsh * documentation and/or other materials provided with the distribution.
47 1.1 bsh * 3. The name of the company may not be used to endorse or promote
48 1.1 bsh * products derived from this software without specific prior written
49 1.1 bsh * permission.
50 1.1 bsh *
51 1.1 bsh * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND
52 1.1 bsh * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
53 1.1 bsh * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
54 1.1 bsh * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARM LTD
55 1.1 bsh * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
56 1.1 bsh * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
57 1.1 bsh * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
58 1.1 bsh * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
59 1.1 bsh * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
60 1.1 bsh * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
61 1.1 bsh * POSSIBILITY OF SUCH DAMAGE.
62 1.1 bsh *
63 1.1 bsh */
64 1.1 bsh
65 1.1 bsh /*
66 1.1 bsh * Copyright (c) 1997,1998 Mark Brinicombe.
67 1.1 bsh * Copyright (c) 1997,1998 Causality Limited.
68 1.1 bsh * All rights reserved.
69 1.1 bsh *
70 1.1 bsh * Redistribution and use in source and binary forms, with or without
71 1.1 bsh * modification, are permitted provided that the following conditions
72 1.1 bsh * are met:
73 1.1 bsh * 1. Redistributions of source code must retain the above copyright
74 1.1 bsh * notice, this list of conditions and the following disclaimer.
75 1.1 bsh * 2. Redistributions in binary form must reproduce the above copyright
76 1.1 bsh * notice, this list of conditions and the following disclaimer in the
77 1.1 bsh * documentation and/or other materials provided with the distribution.
78 1.1 bsh * 3. All advertising materials mentioning features or use of this software
79 1.1 bsh * must display the following acknowledgement:
80 1.1 bsh * This product includes software developed by Mark Brinicombe
81 1.1 bsh * for the NetBSD Project.
82 1.1 bsh * 4. The name of the company nor the name of the author may be used to
83 1.1 bsh * endorse or promote products derived from this software without specific
84 1.1 bsh * prior written permission.
85 1.1 bsh *
86 1.1 bsh * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
87 1.1 bsh * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
88 1.1 bsh * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
89 1.1 bsh * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
90 1.1 bsh * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
91 1.1 bsh * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
92 1.1 bsh * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
93 1.1 bsh * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
94 1.1 bsh * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
95 1.1 bsh * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
96 1.1 bsh * SUCH DAMAGE.
97 1.1 bsh *
98 1.36 wiz * Machine dependent functions for kernel setup for integrator board
99 1.1 bsh *
100 1.1 bsh * Created : 24/11/97
101 1.1 bsh */
102 1.1 bsh
103 1.9 bsh /*
104 1.36 wiz * Machine dependent functions for kernel setup for Samsung SMDK2800
105 1.9 bsh * derived from integrator_machdep.c
106 1.9 bsh */
107 1.15 lukem
108 1.15 lukem #include <sys/cdefs.h>
109 1.43 cherry __KERNEL_RCSID(0, "$NetBSD: smdk2800_machdep.c,v 1.43 2016/12/22 14:47:56 cherry Exp $");
110 1.9 bsh
111 1.1 bsh #include "opt_ddb.h"
112 1.1 bsh #include "opt_kgdb.h"
113 1.1 bsh #include "opt_pmap_debug.h"
114 1.1 bsh #include "opt_md.h"
115 1.1 bsh #include "pci.h"
116 1.1 bsh
117 1.1 bsh #include <sys/param.h>
118 1.1 bsh #include <sys/device.h>
119 1.1 bsh #include <sys/systm.h>
120 1.1 bsh #include <sys/kernel.h>
121 1.1 bsh #include <sys/exec.h>
122 1.1 bsh #include <sys/proc.h>
123 1.1 bsh #include <sys/msgbuf.h>
124 1.1 bsh #include <sys/reboot.h>
125 1.1 bsh #include <sys/termios.h>
126 1.3 ragge #include <sys/ksyms.h>
127 1.41 matt #include <sys/bus.h>
128 1.41 matt #include <sys/cpu.h>
129 1.41 matt #include <sys/intr.h>
130 1.1 bsh
131 1.2 thorpej #include <uvm/uvm_extern.h>
132 1.2 thorpej
133 1.1 bsh #include <dev/cons.h>
134 1.1 bsh #include <dev/md.h>
135 1.1 bsh
136 1.1 bsh #include <machine/db_machdep.h>
137 1.1 bsh #include <ddb/db_sym.h>
138 1.1 bsh #include <ddb/db_extern.h>
139 1.1 bsh #ifdef KGDB
140 1.1 bsh #include <sys/kgdb.h>
141 1.1 bsh #endif
142 1.1 bsh
143 1.1 bsh #include <machine/bootconfig.h>
144 1.41 matt #include <arm/locore.h>
145 1.1 bsh #include <arm/undefined.h>
146 1.1 bsh
147 1.1 bsh #include <arm/arm32/machdep.h>
148 1.1 bsh
149 1.1 bsh #include <arm/s3c2xx0/s3c2800reg.h>
150 1.1 bsh #include <arm/s3c2xx0/s3c2800var.h>
151 1.20 bsh #include <evbarm/smdk2xx0/smdk2800var.h>
152 1.1 bsh
153 1.3 ragge #include "ksyms.h"
154 1.3 ragge
155 1.7 thorpej /* Kernel text starts 2MB in from the bottom of the kernel address space. */
156 1.7 thorpej #define KERNEL_TEXT_BASE (KERNEL_BASE + 0x00200000)
157 1.11 thorpej #define KERNEL_VM_BASE (KERNEL_BASE + 0x01000000)
158 1.12 thorpej
159 1.12 thorpej /*
160 1.12 thorpej * The range 0xc1000000 - 0xccffffff is available for kernel VM space
161 1.12 thorpej * Core-logic registers and I/O mappings occupy 0xfd000000 - 0xffffffff
162 1.12 thorpej */
163 1.12 thorpej #define KERNEL_VM_SIZE 0x0C000000
164 1.1 bsh
165 1.9 bsh /* Memory disk support */
166 1.9 bsh #if defined(MEMORY_DISK_DYNAMIC) && defined(MEMORY_DISK_ROOT_ADDR)
167 1.9 bsh #define DO_MEMORY_DISK
168 1.9 bsh /* We have memory disk image outside of the kernel on ROM. */
169 1.9 bsh #ifdef MEMORY_DISK_ROOT_ROM
170 1.9 bsh /* map the image directory and use read-only */
171 1.9 bsh #else
172 1.9 bsh /* copy the image to RAM */
173 1.9 bsh #endif
174 1.9 bsh #endif
175 1.9 bsh
176 1.1 bsh BootConfig bootconfig; /* Boot config storage */
177 1.1 bsh char *boot_args = NULL;
178 1.1 bsh char *boot_file = NULL;
179 1.1 bsh
180 1.42 matt vaddr_t physical_start;
181 1.42 matt vaddr_t physical_freestart;
182 1.42 matt vaddr_t physical_freeend;
183 1.42 matt vaddr_t physical_end;
184 1.1 bsh u_int free_pages;
185 1.1 bsh
186 1.1 bsh /*int debug_flags;*/
187 1.1 bsh #ifndef PMAP_STATIC_L1S
188 1.1 bsh int max_processes = 64; /* Default number */
189 1.1 bsh #endif /* !PMAP_STATIC_L1S */
190 1.1 bsh
191 1.42 matt paddr_t msgbufphys;
192 1.1 bsh
193 1.1 bsh #ifdef PMAP_DEBUG
194 1.1 bsh extern int pmap_debug_level;
195 1.1 bsh #endif
196 1.1 bsh
197 1.1 bsh #define KERNEL_PT_SYS 0 /* L2 table for mapping zero page */
198 1.1 bsh #define KERNEL_PT_KERNEL 1 /* L2 table for mapping kernel */
199 1.1 bsh #define KERNEL_PT_KERNEL_NUM 2 /* L2 tables for mapping kernel VM */
200 1.1 bsh
201 1.1 bsh #define KERNEL_PT_VMDATA (KERNEL_PT_KERNEL + KERNEL_PT_KERNEL_NUM)
202 1.1 bsh
203 1.1 bsh #define KERNEL_PT_VMDATA_NUM 4 /* start with 16MB of KVM */
204 1.1 bsh #define NUM_KERNEL_PTS (KERNEL_PT_VMDATA + KERNEL_PT_VMDATA_NUM)
205 1.1 bsh
206 1.1 bsh pv_addr_t kernel_pt_table[NUM_KERNEL_PTS];
207 1.1 bsh
208 1.1 bsh /* Prototypes */
209 1.1 bsh
210 1.1 bsh void consinit(void);
211 1.1 bsh void kgdb_port_init(void);
212 1.1 bsh
213 1.1 bsh /* A load of console goo. */
214 1.1 bsh #include "vga.h"
215 1.1 bsh #if NVGA > 0
216 1.1 bsh #include <dev/ic/mc6845reg.h>
217 1.1 bsh #include <dev/ic/pcdisplayvar.h>
218 1.1 bsh #include <dev/ic/vgareg.h>
219 1.1 bsh #include <dev/ic/vgavar.h>
220 1.1 bsh #endif
221 1.1 bsh
222 1.1 bsh #include "com.h"
223 1.1 bsh #if NCOM > 0
224 1.1 bsh #include <dev/ic/comreg.h>
225 1.1 bsh #include <dev/ic/comvar.h>
226 1.1 bsh #endif
227 1.1 bsh
228 1.1 bsh #include "sscom.h"
229 1.1 bsh #if NSSCOM > 0
230 1.1 bsh #include "opt_sscom.h"
231 1.1 bsh #include <arm/s3c2xx0/sscom_var.h>
232 1.1 bsh #endif
233 1.1 bsh
234 1.1 bsh /*
235 1.1 bsh * Define the default console speed for the board. This is generally
236 1.1 bsh * what the firmware provided with the board defaults to.
237 1.1 bsh */
238 1.1 bsh #ifndef CONSPEED
239 1.1 bsh #define CONSPEED B115200 /* TTYDEF_SPEED */
240 1.1 bsh #endif
241 1.1 bsh #ifndef CONMODE
242 1.1 bsh #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
243 1.1 bsh #endif
244 1.1 bsh
245 1.1 bsh int comcnspeed = CONSPEED;
246 1.1 bsh int comcnmode = CONMODE;
247 1.1 bsh
248 1.1 bsh /*
249 1.1 bsh * void cpu_reboot(int howto, char *bootstr)
250 1.1 bsh *
251 1.1 bsh * Reboots the system
252 1.1 bsh *
253 1.1 bsh * Deal with any syncing, unmounting, dumping and shutdown hooks,
254 1.1 bsh * then reset the CPU.
255 1.1 bsh */
256 1.1 bsh void
257 1.1 bsh cpu_reboot(int howto, char *bootstr)
258 1.1 bsh {
259 1.1 bsh
260 1.39 matt cpu_reset_address_paddr = vtophys((u_int)s3c2800_softreset);
261 1.1 bsh
262 1.1 bsh /*
263 1.1 bsh * If we are still cold then hit the air brakes
264 1.1 bsh * and crash to earth fast
265 1.1 bsh */
266 1.1 bsh if (cold) {
267 1.1 bsh doshutdownhooks();
268 1.27 dyoung pmf_system_shutdown(boothowto);
269 1.1 bsh printf("The operating system has halted.\n");
270 1.1 bsh printf("Please press any key to reboot.\n\n");
271 1.1 bsh cngetc();
272 1.1 bsh printf("rebooting...\n");
273 1.1 bsh cpu_reset();
274 1.1 bsh /* NOTREACHED */
275 1.1 bsh }
276 1.1 bsh /* Disable console buffering */
277 1.1 bsh
278 1.1 bsh /*
279 1.1 bsh * If RB_NOSYNC was not specified sync the discs.
280 1.1 bsh * Note: Unless cold is set to 1 here, syslogd will die during the
281 1.1 bsh * unmount. It looks like syslogd is getting woken up only to find
282 1.1 bsh * that it cannot page part of the binary in as the filesystem has
283 1.1 bsh * been unmounted.
284 1.1 bsh */
285 1.1 bsh if (!(howto & RB_NOSYNC))
286 1.1 bsh bootsync();
287 1.1 bsh
288 1.1 bsh /* Say NO to interrupts */
289 1.1 bsh splhigh();
290 1.1 bsh
291 1.1 bsh /* Do a dump if requested. */
292 1.1 bsh if ((howto & (RB_DUMP | RB_HALT)) == RB_DUMP)
293 1.1 bsh dumpsys();
294 1.1 bsh
295 1.1 bsh /* Run any shutdown hooks */
296 1.1 bsh doshutdownhooks();
297 1.1 bsh
298 1.27 dyoung pmf_system_shutdown(boothowto);
299 1.27 dyoung
300 1.1 bsh /* Make sure IRQ's are disabled */
301 1.1 bsh IRQdisable;
302 1.1 bsh
303 1.1 bsh if (howto & RB_HALT) {
304 1.1 bsh printf("The operating system has halted.\n");
305 1.1 bsh printf("Please press any key to reboot.\n\n");
306 1.1 bsh cngetc();
307 1.1 bsh }
308 1.1 bsh printf("rebooting...\n");
309 1.1 bsh cpu_reset();
310 1.1 bsh /* NOTREACHED */
311 1.1 bsh }
312 1.21 bsh
313 1.21 bsh /*
314 1.21 bsh * All built-in peripheral registers are statically mapped in start up
315 1.21 bsh * routine. This table tells pmap subsystem about it, and to map them
316 1.21 bsh * at the same position.
317 1.21 bsh */
318 1.21 bsh static const struct pmap_devmap smdk2800_devmap[] = {
319 1.21 bsh {
320 1.21 bsh SMDK2800_IO_AREA_VBASE,
321 1.21 bsh S3C2800_PERIPHERALS,
322 1.21 bsh S3C2800_PERIPHERALS_SIZE,
323 1.21 bsh VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE,
324 1.21 bsh },
325 1.21 bsh { 0, 0, 0, 0 }
326 1.21 bsh };
327 1.21 bsh
328 1.21 bsh #define ioreg_vaddr(pa) ((pa) - S3C2800_PERIPHERALS + SMDK2800_IO_AREA_VBASE)
329 1.21 bsh #define ioreg32(pa) (*(volatile uint32_t *)ioreg_vaddr(pa))
330 1.1 bsh
331 1.1 bsh /*
332 1.1 bsh * u_int initarm(...)
333 1.1 bsh *
334 1.1 bsh * Initial entry point on startup. This gets called before main() is
335 1.1 bsh * entered.
336 1.1 bsh * It should be responsible for setting up everything that must be
337 1.1 bsh * in place when main is called.
338 1.1 bsh * This includes
339 1.1 bsh * Taking a copy of the boot configuration structure.
340 1.1 bsh * Initialising the physical console so characters can be printed.
341 1.1 bsh * Setting up page tables for the kernel
342 1.1 bsh * Relocating the kernel to the bottom of physical memory
343 1.1 bsh */
344 1.1 bsh
345 1.1 bsh u_int
346 1.1 bsh initarm(void *arg)
347 1.1 bsh {
348 1.1 bsh int loop;
349 1.1 bsh int loop1;
350 1.1 bsh u_int l1pagetable;
351 1.23 perry extern int etext __asm("_etext");
352 1.23 perry extern int end __asm("_end");
353 1.1 bsh int progress_counter = 0;
354 1.9 bsh
355 1.9 bsh #ifdef DO_MEMORY_DISK
356 1.42 matt vaddr_t md_root_start;
357 1.9 bsh #define MD_ROOT_SIZE (MEMORY_DISK_ROOT_SIZE * DEV_BSIZE)
358 1.1 bsh #endif
359 1.1 bsh
360 1.21 bsh #define gpio8(reg) (*(volatile uint8_t *)(ioreg_vaddr(S3C2800_GPIO_BASE) + (reg)))
361 1.9 bsh
362 1.1 bsh #define LEDSTEP() __LED(progress_counter++)
363 1.1 bsh
364 1.21 bsh #define pdatc gpio8(GPIO_PDATC)
365 1.1 bsh #define __LED(x) (pdatc = (pdatc & ~0x07) | (~(x) & 0x07))
366 1.1 bsh
367 1.1 bsh LEDSTEP();
368 1.1 bsh /*
369 1.1 bsh * Heads up ... Setup the CPU / MMU / TLB functions
370 1.1 bsh */
371 1.1 bsh if (set_cpufuncs())
372 1.17 wiz panic("CPU not recognized!");
373 1.1 bsh
374 1.1 bsh LEDSTEP();
375 1.9 bsh
376 1.1 bsh
377 1.1 bsh /* Disable all peripheral interrupts */
378 1.21 bsh ioreg32(S3C2800_INTCTL_BASE + INTCTL_INTMSK) = 0;
379 1.9 bsh
380 1.1 bsh consinit();
381 1.10 thorpej #ifdef VERBOSE_INIT_ARM
382 1.1 bsh printf("consinit done\n");
383 1.10 thorpej #endif
384 1.1 bsh
385 1.1 bsh #ifdef KGDB
386 1.1 bsh LEDSTEP();
387 1.1 bsh kgdb_port_init();
388 1.1 bsh #endif
389 1.1 bsh LEDSTEP();
390 1.1 bsh
391 1.10 thorpej #ifdef VERBOSE_INIT_ARM
392 1.1 bsh /* Talk to the user */
393 1.1 bsh printf("\nNetBSD/evbarm (SMDK2800) booting ...\n");
394 1.10 thorpej #endif
395 1.1 bsh
396 1.1 bsh /*
397 1.1 bsh * Ok we have the following memory map
398 1.1 bsh *
399 1.1 bsh * Physical Address Range Description
400 1.1 bsh * ----------------------- ----------------------------------
401 1.1 bsh * 0x00000000 - 0x00ffffff Intel flash Memory (16MB)
402 1.1 bsh * 0x02000000 - 0x020fffff AMD flash Memory (1MB)
403 1.1 bsh * or (depend on DIPSW setting)
404 1.1 bsh * 0x00000000 - 0x000fffff AMD flash Memory (1MB)
405 1.1 bsh * 0x02000000 - 0x02ffffff Intel flash Memory (16MB)
406 1.1 bsh *
407 1.1 bsh * 0x08000000 - 0x09ffffff SDRAM (32MB)
408 1.1 bsh * 0x20000000 - 0x3fffffff PCI space
409 1.1 bsh *
410 1.1 bsh * The initarm() has the responsibility for creating the kernel
411 1.1 bsh * page tables.
412 1.1 bsh * It must also set up various memory pointers that are used
413 1.1 bsh * by pmap etc.
414 1.1 bsh */
415 1.1 bsh
416 1.1 bsh /* Fake bootconfig structure for the benefit of pmap.c */
417 1.1 bsh /* XXX must make the memory description h/w independent */
418 1.1 bsh bootconfig.dramblocks = 1;
419 1.1 bsh bootconfig.dram[0].address = SDRAM_START;
420 1.2 thorpej bootconfig.dram[0].pages = SDRAM_SIZE / PAGE_SIZE;
421 1.1 bsh
422 1.1 bsh /*
423 1.1 bsh * Set up the variables that define the availablilty of
424 1.1 bsh * physical memory. For now, we're going to set
425 1.1 bsh * physical_freestart to 0x08200000 (where the kernel
426 1.1 bsh * was loaded), and allocate the memory we need downwards.
427 1.1 bsh * If we get too close to the bottom of SDRAM, we
428 1.1 bsh * will panic. We will update physical_freestart and
429 1.1 bsh * physical_freeend later to reflect what pmap_bootstrap()
430 1.1 bsh * wants to see.
431 1.1 bsh *
432 1.1 bsh * XXX pmap_bootstrap() needs an enema.
433 1.1 bsh */
434 1.1 bsh physical_start = bootconfig.dram[0].address;
435 1.2 thorpej physical_end = physical_start + (bootconfig.dram[0].pages * PAGE_SIZE);
436 1.9 bsh
437 1.9 bsh #if DO_MEMORY_DISK
438 1.9 bsh #ifdef MEMORY_DISK_ROOT_ROM
439 1.9 bsh md_root_start = MEMORY_DISK_ROOT_ADDR;
440 1.9 bsh boothowto |= RB_RDONLY;
441 1.9 bsh #else
442 1.9 bsh /* Reserve physmem for ram disk */
443 1.9 bsh md_root_start = ((physical_end - MD_ROOT_SIZE) & ~(L1_S_SIZE-1));
444 1.9 bsh printf("Reserve %ld bytes for memory disk\n",
445 1.9 bsh physical_end - md_root_start);
446 1.9 bsh /* copy fs contents */
447 1.9 bsh memcpy((void *)md_root_start, (void *)MEMORY_DISK_ROOT_ADDR,
448 1.9 bsh MD_ROOT_SIZE);
449 1.9 bsh physical_end = md_root_start;
450 1.9 bsh #endif
451 1.1 bsh #endif
452 1.1 bsh
453 1.1 bsh physical_freestart = 0x08000000UL; /* XXX */
454 1.1 bsh physical_freeend = 0x08200000UL;
455 1.1 bsh
456 1.2 thorpej physmem = (physical_end - physical_start) / PAGE_SIZE;
457 1.1 bsh
458 1.10 thorpej #ifdef VERBOSE_INIT_ARM
459 1.1 bsh /* Tell the user about the memory */
460 1.1 bsh printf("physmemory: %d pages at 0x%08lx -> 0x%08lx\n", physmem,
461 1.1 bsh physical_start, physical_end - 1);
462 1.10 thorpej #endif
463 1.1 bsh
464 1.1 bsh /*
465 1.1 bsh * XXX
466 1.1 bsh * Okay, the kernel starts 2MB in from the bottom of physical
467 1.1 bsh * memory. We are going to allocate our bootstrap pages downwards
468 1.1 bsh * from there.
469 1.1 bsh *
470 1.1 bsh * We need to allocate some fixed page tables to get the kernel
471 1.1 bsh * going. We allocate one page directory and a number of page
472 1.1 bsh * tables and store the physical addresses in the kernel_pt_table
473 1.1 bsh * array.
474 1.1 bsh *
475 1.1 bsh * The kernel page directory must be on a 16K boundary. The page
476 1.19 abs * tables must be on 4K boundaries. What we do is allocate the
477 1.1 bsh * page directory on the first 16K boundary that we encounter, and
478 1.1 bsh * the page tables on 4K boundaries otherwise. Since we allocate
479 1.1 bsh * at least 3 L2 page tables, we are guaranteed to encounter at
480 1.1 bsh * least one 16K aligned region.
481 1.1 bsh */
482 1.1 bsh
483 1.1 bsh #ifdef VERBOSE_INIT_ARM
484 1.1 bsh printf("Allocating page tables\n");
485 1.1 bsh #endif
486 1.1 bsh
487 1.2 thorpej free_pages = (physical_freeend - physical_freestart) / PAGE_SIZE;
488 1.1 bsh
489 1.1 bsh #ifdef VERBOSE_INIT_ARM
490 1.1 bsh printf("freestart = 0x%08lx, free_pages = %d (0x%08x)\n",
491 1.1 bsh physical_freestart, free_pages, free_pages);
492 1.1 bsh #endif
493 1.1 bsh
494 1.1 bsh /* Define a macro to simplify memory allocation */
495 1.1 bsh #define valloc_pages(var, np) \
496 1.1 bsh alloc_pages((var).pv_pa, (np)); \
497 1.1 bsh (var).pv_va = KERNEL_BASE + (var).pv_pa - physical_start;
498 1.1 bsh
499 1.1 bsh #define alloc_pages(var, np) \
500 1.2 thorpej physical_freeend -= ((np) * PAGE_SIZE); \
501 1.1 bsh if (physical_freeend < physical_freestart) \
502 1.1 bsh panic("initarm: out of memory"); \
503 1.1 bsh (var) = physical_freeend; \
504 1.1 bsh free_pages -= (np); \
505 1.2 thorpej memset((char *)(var), 0, ((np) * PAGE_SIZE));
506 1.1 bsh
507 1.1 bsh loop1 = 0;
508 1.1 bsh for (loop = 0; loop <= NUM_KERNEL_PTS; ++loop) {
509 1.1 bsh /* Are we 16KB aligned for an L1 ? */
510 1.1 bsh if (((physical_freeend - L1_TABLE_SIZE) & (L1_TABLE_SIZE - 1)) == 0
511 1.1 bsh && kernel_l1pt.pv_pa == 0) {
512 1.2 thorpej valloc_pages(kernel_l1pt, L1_TABLE_SIZE / PAGE_SIZE);
513 1.1 bsh } else {
514 1.4 thorpej valloc_pages(kernel_pt_table[loop1],
515 1.4 thorpej L2_TABLE_SIZE / PAGE_SIZE);
516 1.1 bsh ++loop1;
517 1.1 bsh }
518 1.1 bsh }
519 1.1 bsh
520 1.1 bsh /* This should never be able to happen but better confirm that. */
521 1.9 bsh if (!kernel_l1pt.pv_pa || (kernel_l1pt.pv_pa & (L1_TABLE_SIZE-1)) != 0)
522 1.1 bsh panic("initarm: Failed to align the kernel page directory\n");
523 1.1 bsh
524 1.1 bsh /*
525 1.1 bsh * Allocate a page for the system page mapped to V0x00000000
526 1.1 bsh * This page will just contain the system vectors and can be
527 1.1 bsh * shared by all processes.
528 1.1 bsh */
529 1.1 bsh alloc_pages(systempage.pv_pa, 1);
530 1.1 bsh
531 1.1 bsh /* Allocate stacks for all modes */
532 1.1 bsh valloc_pages(irqstack, IRQ_STACK_SIZE);
533 1.1 bsh valloc_pages(abtstack, ABT_STACK_SIZE);
534 1.1 bsh valloc_pages(undstack, UND_STACK_SIZE);
535 1.1 bsh valloc_pages(kernelstack, UPAGES);
536 1.1 bsh
537 1.1 bsh #ifdef VERBOSE_INIT_ARM
538 1.1 bsh printf("IRQ stack: p0x%08lx v0x%08lx\n", irqstack.pv_pa,
539 1.1 bsh irqstack.pv_va);
540 1.1 bsh printf("ABT stack: p0x%08lx v0x%08lx\n", abtstack.pv_pa,
541 1.1 bsh abtstack.pv_va);
542 1.1 bsh printf("UND stack: p0x%08lx v0x%08lx\n", undstack.pv_pa,
543 1.1 bsh undstack.pv_va);
544 1.1 bsh printf("SVC stack: p0x%08lx v0x%08lx\n", kernelstack.pv_pa,
545 1.1 bsh kernelstack.pv_va);
546 1.1 bsh #endif
547 1.1 bsh
548 1.2 thorpej alloc_pages(msgbufphys, round_page(MSGBUFSIZE) / PAGE_SIZE);
549 1.1 bsh
550 1.1 bsh LEDSTEP();
551 1.1 bsh
552 1.1 bsh /*
553 1.1 bsh * Ok we have allocated physical pages for the primary kernel
554 1.1 bsh * page tables
555 1.1 bsh */
556 1.1 bsh
557 1.1 bsh #ifdef VERBOSE_INIT_ARM
558 1.1 bsh printf("Creating L1 page table at 0x%08lx\n", kernel_l1pt.pv_pa);
559 1.1 bsh #endif
560 1.1 bsh
561 1.1 bsh /*
562 1.1 bsh * Now we start construction of the L1 page table
563 1.1 bsh * We start by mapping the L2 page tables into the L1.
564 1.1 bsh * This means that we can replace L1 mappings later on if necessary
565 1.1 bsh */
566 1.1 bsh l1pagetable = kernel_l1pt.pv_pa;
567 1.1 bsh
568 1.1 bsh /* Map the L2 pages tables in the L1 page table */
569 1.1 bsh pmap_link_l2pt(l1pagetable, 0x00000000,
570 1.1 bsh &kernel_pt_table[KERNEL_PT_SYS]);
571 1.1 bsh for (loop = 0; loop < KERNEL_PT_KERNEL_NUM; loop++)
572 1.1 bsh pmap_link_l2pt(l1pagetable, KERNEL_BASE + loop * 0x00400000,
573 1.1 bsh &kernel_pt_table[KERNEL_PT_KERNEL + loop]);
574 1.1 bsh for (loop = 0; loop < KERNEL_PT_VMDATA_NUM; loop++)
575 1.1 bsh pmap_link_l2pt(l1pagetable, KERNEL_VM_BASE + loop * 0x00400000,
576 1.1 bsh &kernel_pt_table[KERNEL_PT_VMDATA + loop]);
577 1.1 bsh
578 1.1 bsh /* update the top of the kernel VM */
579 1.1 bsh pmap_curmaxkvaddr =
580 1.1 bsh KERNEL_VM_BASE + (KERNEL_PT_VMDATA_NUM * 0x00400000);
581 1.1 bsh
582 1.1 bsh #ifdef VERBOSE_INIT_ARM
583 1.1 bsh printf("Mapping kernel\n");
584 1.1 bsh #endif
585 1.1 bsh
586 1.1 bsh /* Now we fill in the L2 pagetable for the kernel static code/data */
587 1.1 bsh {
588 1.8 bsh size_t textsize = (uintptr_t)&etext - KERNEL_TEXT_BASE;
589 1.8 bsh size_t totalsize = (uintptr_t)&end - KERNEL_TEXT_BASE;
590 1.1 bsh u_int logical;
591 1.1 bsh
592 1.1 bsh textsize = (textsize + PGOFSET) & ~PGOFSET;
593 1.1 bsh totalsize = (totalsize + PGOFSET) & ~PGOFSET;
594 1.1 bsh
595 1.1 bsh logical = 0x00200000; /* offset of kernel in RAM */
596 1.1 bsh
597 1.1 bsh logical += pmap_map_chunk(l1pagetable, KERNEL_BASE + logical,
598 1.1 bsh physical_start + logical, textsize,
599 1.1 bsh VM_PROT_READ | VM_PROT_WRITE, PTE_CACHE);
600 1.1 bsh logical += pmap_map_chunk(l1pagetable, KERNEL_BASE + logical,
601 1.1 bsh physical_start + logical, totalsize - textsize,
602 1.1 bsh VM_PROT_READ | VM_PROT_WRITE, PTE_CACHE);
603 1.1 bsh }
604 1.1 bsh
605 1.1 bsh #ifdef VERBOSE_INIT_ARM
606 1.1 bsh printf("Constructing L2 page tables\n");
607 1.1 bsh #endif
608 1.1 bsh
609 1.1 bsh /* Map the stack pages */
610 1.1 bsh pmap_map_chunk(l1pagetable, irqstack.pv_va, irqstack.pv_pa,
611 1.2 thorpej IRQ_STACK_SIZE * PAGE_SIZE, VM_PROT_READ | VM_PROT_WRITE,
612 1.2 thorpej PTE_CACHE);
613 1.1 bsh pmap_map_chunk(l1pagetable, abtstack.pv_va, abtstack.pv_pa,
614 1.2 thorpej ABT_STACK_SIZE * PAGE_SIZE, VM_PROT_READ | VM_PROT_WRITE,
615 1.2 thorpej PTE_CACHE);
616 1.1 bsh pmap_map_chunk(l1pagetable, undstack.pv_va, undstack.pv_pa,
617 1.2 thorpej UND_STACK_SIZE * PAGE_SIZE, VM_PROT_READ | VM_PROT_WRITE,
618 1.2 thorpej PTE_CACHE);
619 1.1 bsh pmap_map_chunk(l1pagetable, kernelstack.pv_va, kernelstack.pv_pa,
620 1.2 thorpej UPAGES * PAGE_SIZE, VM_PROT_READ | VM_PROT_WRITE, PTE_CACHE);
621 1.1 bsh
622 1.4 thorpej pmap_map_chunk(l1pagetable, kernel_l1pt.pv_va, kernel_l1pt.pv_pa,
623 1.4 thorpej L1_TABLE_SIZE, VM_PROT_READ | VM_PROT_WRITE, PTE_PAGETABLE);
624 1.1 bsh
625 1.4 thorpej for (loop = 0; loop < NUM_KERNEL_PTS; ++loop) {
626 1.4 thorpej pmap_map_chunk(l1pagetable, kernel_pt_table[loop].pv_va,
627 1.4 thorpej kernel_pt_table[loop].pv_pa, L2_TABLE_SIZE,
628 1.4 thorpej VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE);
629 1.4 thorpej }
630 1.1 bsh
631 1.1 bsh /* Map the vector page. */
632 1.1 bsh #if 1
633 1.1 bsh /* MULTI-ICE requires that page 0 is NC/NB so that it can download the
634 1.1 bsh * cache-clean code there. */
635 1.1 bsh pmap_map_entry(l1pagetable, vector_page, systempage.pv_pa,
636 1.1 bsh VM_PROT_READ | VM_PROT_WRITE, PTE_NOCACHE);
637 1.1 bsh #else
638 1.1 bsh pmap_map_entry(l1pagetable, vector_page, systempage.pv_pa,
639 1.1 bsh VM_PROT_READ | VM_PROT_WRITE, PTE_CACHE);
640 1.1 bsh #endif
641 1.1 bsh
642 1.1 bsh #ifdef MEMORY_DISK_DYNAMIC
643 1.9 bsh /* map MD root image */
644 1.21 bsh pmap_map_chunk(l1pagetable, SMDK2800_MEMORY_DISK_VADDR, md_root_start,
645 1.21 bsh MD_ROOT_SIZE, VM_PROT_READ | VM_PROT_WRITE, PTE_CACHE);
646 1.1 bsh
647 1.9 bsh md_root_setconf((void *)md_root_start, MD_ROOT_SIZE);
648 1.9 bsh #endif /* MEMORY_DISK_DYNAMIC */
649 1.1 bsh /*
650 1.1 bsh * map integrated peripherals at same address in l1pagetable
651 1.1 bsh * so that we can continue to use console.
652 1.1 bsh */
653 1.21 bsh pmap_devmap_bootstrap(l1pagetable, smdk2800_devmap);
654 1.1 bsh
655 1.1 bsh /*
656 1.1 bsh * Now we have the real page tables in place so we can switch to them.
657 1.1 bsh * Once this is done we will be running with the REAL kernel page
658 1.1 bsh * tables.
659 1.1 bsh */
660 1.1 bsh
661 1.1 bsh /*
662 1.1 bsh * Update the physical_freestart/physical_freeend/free_pages
663 1.1 bsh * variables.
664 1.1 bsh */
665 1.1 bsh {
666 1.1 bsh physical_freestart = physical_start +
667 1.8 bsh (((((uintptr_t)&end) + PGOFSET) & ~PGOFSET) - KERNEL_BASE);
668 1.1 bsh physical_freeend = physical_end;
669 1.2 thorpej free_pages =
670 1.2 thorpej (physical_freeend - physical_freestart) / PAGE_SIZE;
671 1.1 bsh }
672 1.1 bsh
673 1.1 bsh /* Switch tables */
674 1.1 bsh #ifdef VERBOSE_INIT_ARM
675 1.1 bsh printf("freestart = 0x%08lx, free_pages = %d (0x%x)\n",
676 1.1 bsh physical_freestart, free_pages, free_pages);
677 1.1 bsh printf("switching to new L1 page table @%#lx...", kernel_l1pt.pv_pa);
678 1.1 bsh #endif
679 1.1 bsh LEDSTEP();
680 1.4 thorpej cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | DOMAIN_CLIENT);
681 1.40 matt cpu_setttb(kernel_l1pt.pv_pa, true);
682 1.1 bsh cpu_tlb_flushID();
683 1.4 thorpej cpu_domains(DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2));
684 1.4 thorpej
685 1.4 thorpej /*
686 1.4 thorpej * Moved from cpu_startup() as data_abort_handler() references
687 1.4 thorpej * this during uvm init
688 1.4 thorpej */
689 1.33 rmind uvm_lwp_setuarea(&lwp0, kernelstack.pv_va);
690 1.1 bsh
691 1.1 bsh #ifdef VERBOSE_INIT_ARM
692 1.1 bsh printf("done!\n");
693 1.1 bsh #endif
694 1.1 bsh
695 1.1 bsh #if 0
696 1.1 bsh /*
697 1.1 bsh * The IFPGA registers have just moved.
698 1.1 bsh * Detach the diagnostic serial port and reattach at the new address.
699 1.1 bsh */
700 1.1 bsh plcomcndetach();
701 1.1 bsh /*
702 1.1 bsh * XXX this should only be done in main() but it useful to
703 1.1 bsh * have output earlier ...
704 1.1 bsh */
705 1.1 bsh consinit();
706 1.1 bsh #endif
707 1.1 bsh
708 1.1 bsh LEDSTEP();
709 1.1 bsh #ifdef VERBOSE_INIT_ARM
710 1.1 bsh printf("bootstrap done.\n");
711 1.1 bsh #endif
712 1.1 bsh
713 1.1 bsh arm32_vector_init(ARM_VECTORS_LOW, ARM_VEC_ALL);
714 1.1 bsh
715 1.1 bsh /*
716 1.1 bsh * Pages were allocated during the secondary bootstrap for the
717 1.1 bsh * stacks for different CPU modes.
718 1.1 bsh * We must now set the r13 registers in the different CPU modes to
719 1.1 bsh * point to these stacks.
720 1.1 bsh * Since the ARM stacks use STMFD etc. we must set r13 to the top end
721 1.1 bsh * of the stack memory.
722 1.1 bsh */
723 1.10 thorpej #ifdef VERBOSE_INIT_ARM
724 1.1 bsh printf("init subsystems: stacks ");
725 1.10 thorpej #endif
726 1.1 bsh
727 1.2 thorpej set_stackptr(PSR_IRQ32_MODE,
728 1.2 thorpej irqstack.pv_va + IRQ_STACK_SIZE * PAGE_SIZE);
729 1.2 thorpej set_stackptr(PSR_ABT32_MODE,
730 1.2 thorpej abtstack.pv_va + ABT_STACK_SIZE * PAGE_SIZE);
731 1.2 thorpej set_stackptr(PSR_UND32_MODE,
732 1.2 thorpej undstack.pv_va + UND_STACK_SIZE * PAGE_SIZE);
733 1.1 bsh
734 1.1 bsh LEDSTEP();
735 1.1 bsh
736 1.1 bsh /*
737 1.1 bsh * Well we should set a data abort handler.
738 1.1 bsh * Once things get going this will change as we will need a proper
739 1.1 bsh * handler.
740 1.1 bsh * Until then we will use a handler that just panics but tells us
741 1.1 bsh * why.
742 1.1 bsh * Initialisation of the vectors will just panic on a data abort.
743 1.18 abs * This just fills in a slightly better one.
744 1.1 bsh */
745 1.10 thorpej #ifdef VERBOSE_INIT_ARM
746 1.1 bsh printf("vectors ");
747 1.10 thorpej #endif
748 1.1 bsh data_abort_handler_address = (u_int)data_abort_handler;
749 1.1 bsh prefetch_abort_handler_address = (u_int)prefetch_abort_handler;
750 1.1 bsh undefined_handler_address = (u_int)undefinedinstruction_bounce;
751 1.1 bsh
752 1.1 bsh /* Initialise the undefined instruction handlers */
753 1.10 thorpej #ifdef VERBOSE_INIT_ARM
754 1.1 bsh printf("undefined ");
755 1.10 thorpej #endif
756 1.1 bsh undefined_init();
757 1.1 bsh
758 1.1 bsh LEDSTEP();
759 1.1 bsh
760 1.1 bsh /* Load memory into UVM. */
761 1.10 thorpej #ifdef VERBOSE_INIT_ARM
762 1.1 bsh printf("page ");
763 1.10 thorpej #endif
764 1.43 cherry uvm_md_init();
765 1.1 bsh uvm_page_physload(atop(physical_freestart), atop(physical_freeend),
766 1.1 bsh atop(physical_freestart), atop(physical_freeend),
767 1.1 bsh VM_FREELIST_DEFAULT);
768 1.1 bsh
769 1.1 bsh LEDSTEP();
770 1.1 bsh /* Boot strap pmap telling it where the kernel page table is */
771 1.10 thorpej #ifdef VERBOSE_INIT_ARM
772 1.1 bsh printf("pmap ");
773 1.10 thorpej #endif
774 1.26 matt pmap_bootstrap(KERNEL_VM_BASE, KERNEL_VM_BASE + KERNEL_VM_SIZE);
775 1.1 bsh
776 1.1 bsh LEDSTEP();
777 1.1 bsh
778 1.1 bsh /* Setup the IRQ system */
779 1.10 thorpej #ifdef VERBOSE_INIT_ARM
780 1.1 bsh printf("irq ");
781 1.10 thorpej #endif
782 1.1 bsh /* XXX irq_init(); */
783 1.1 bsh
784 1.10 thorpej #ifdef VERBOSE_INIT_ARM
785 1.1 bsh printf("done.\n");
786 1.10 thorpej #endif
787 1.1 bsh
788 1.9 bsh #ifdef BOOTHOWTO_INIT
789 1.9 bsh boothowto |= BOOTHOWTO_INIT;
790 1.9 bsh #endif
791 1.9 bsh {
792 1.21 bsh uint8_t gpio = ~gpio8(GPIO_PDATF);
793 1.9 bsh
794 1.9 bsh if (gpio & (1<<5)) /* SW3 */
795 1.9 bsh boothowto ^= RB_SINGLE;
796 1.9 bsh if (gpio & (1<<7)) /* SW7 */
797 1.9 bsh boothowto ^= RB_KDB;
798 1.10 thorpej #ifdef VERBOSE_INIT_ARM
799 1.9 bsh printf( "sw: %x boothowto: %x\n", gpio, boothowto );
800 1.10 thorpej #endif
801 1.9 bsh }
802 1.1 bsh
803 1.1 bsh #ifdef KGDB
804 1.1 bsh if (boothowto & RB_KDB) {
805 1.1 bsh kgdb_debug_init = 1;
806 1.1 bsh kgdb_connect(1);
807 1.1 bsh }
808 1.1 bsh #endif
809 1.1 bsh
810 1.1 bsh #ifdef DDB
811 1.1 bsh db_machine_init();
812 1.1 bsh if (boothowto & RB_KDB)
813 1.1 bsh Debugger();
814 1.1 bsh #endif
815 1.1 bsh
816 1.1 bsh /* We return the new stack pointer address */
817 1.1 bsh return (kernelstack.pv_va + USPACE_SVC_STACK_TOP);
818 1.1 bsh }
819 1.1 bsh
820 1.1 bsh void
821 1.1 bsh consinit(void)
822 1.1 bsh {
823 1.1 bsh static int consinit_done = 0;
824 1.21 bsh bus_space_tag_t iot = &s3c2xx0_bs_tag;
825 1.21 bsh int pclk;
826 1.1 bsh
827 1.1 bsh if (consinit_done != 0)
828 1.1 bsh return;
829 1.1 bsh
830 1.1 bsh consinit_done = 1;
831 1.1 bsh
832 1.21 bsh pmap_devmap_register(smdk2800_devmap);
833 1.21 bsh
834 1.29 cliff s3c2800_clock_freq2(ioreg_vaddr(S3C2800_CLKMAN_BASE), NULL, NULL, &pclk);
835 1.21 bsh
836 1.1 bsh #if NSSCOM > 0
837 1.1 bsh #ifdef SSCOM0CONSOLE
838 1.1 bsh if (0 == s3c2800_sscom_cnattach(iot, 0, comcnspeed,
839 1.9 bsh pclk, comcnmode))
840 1.1 bsh return;
841 1.1 bsh #endif
842 1.1 bsh #ifdef SSCOM1CONSOLE
843 1.1 bsh if (0 == s3c2800_sscom_cnattach(iot, 1, comcnspeed,
844 1.9 bsh pclk, comcnmode))
845 1.1 bsh return;
846 1.1 bsh #endif
847 1.1 bsh #endif /* NSSCOM */
848 1.1 bsh #if NCOM>0 && defined(CONCOMADDR)
849 1.1 bsh if (comcnattach(&isa_io_bs_tag, CONCOMADDR, comcnspeed,
850 1.13 thorpej COM_FREQ, COM_TYPE_NORMAL, comcnmode))
851 1.1 bsh panic("can't init serial console @%x", CONCOMADDR);
852 1.1 bsh return;
853 1.1 bsh #endif
854 1.1 bsh
855 1.1 bsh consinit_done = 0;
856 1.1 bsh }
857 1.1 bsh
858 1.1 bsh
859 1.1 bsh #ifdef KGDB
860 1.1 bsh
861 1.1 bsh #if (NSSCOM > 0)
862 1.1 bsh
863 1.1 bsh #ifdef KGDB_DEVNAME
864 1.1 bsh const char kgdb_devname[] = KGDB_DEVNAME;
865 1.1 bsh #else
866 1.1 bsh const char kgdb_devname[] = "";
867 1.1 bsh #endif
868 1.1 bsh
869 1.1 bsh #ifndef KGDB_DEVMODE
870 1.1 bsh #define KGDB_DEVMODE ((TTYDEF_CFLAG & ~(CSIZE|CSTOPB|PARENB))|CS8) /* 8N1 */
871 1.1 bsh #endif
872 1.1 bsh int kgdb_sscom_mode = KGDB_DEVMODE;
873 1.1 bsh
874 1.1 bsh #endif /* NSSCOM */
875 1.1 bsh
876 1.1 bsh void
877 1.1 bsh kgdb_port_init(void)
878 1.1 bsh {
879 1.1 bsh #if (NSSCOM > 0)
880 1.1 bsh int unit = -1;
881 1.21 bsh int pclk;
882 1.1 bsh
883 1.1 bsh if (strcmp(kgdb_devname, "sscom0") == 0)
884 1.1 bsh unit = 0;
885 1.1 bsh else if (strcmp(kgdb_devname, "sscom1") == 0)
886 1.1 bsh unit = 1;
887 1.1 bsh
888 1.1 bsh if (unit >= 0) {
889 1.29 cliff s3c2800_clock_freq2(ioreg_vaddr(S3C2800_CLKMAN_BASE),
890 1.21 bsh NULL, NULL, &pclk);
891 1.21 bsh
892 1.21 bsh s3c2800_sscom_kgdb_attach(&s3c2xx0_bs_tag,
893 1.9 bsh unit, kgdb_rate, pclk, kgdb_sscom_mode);
894 1.1 bsh }
895 1.1 bsh #endif
896 1.1 bsh }
897 1.1 bsh #endif
898