2 * Copyright (C) 2010-2011 by Aleksandr Rybalko. All rights reserved.
3 * Copyright (C) 2007 by Oleksandr Tymoshenko. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
18 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
22 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
23 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24 * THE POSSIBILITY OF SUCH DAMAGE.
28 #include <sys/cdefs.h>
29 __FBSDID("$FreeBSD$");
33 #include <sys/param.h>
35 #include <sys/kernel.h>
36 #include <sys/systm.h>
37 #include <sys/imgact.h>
44 #include <sys/ucontext.h>
47 #include <sys/ptrace.h>
48 #include <sys/reboot.h>
49 #include <sys/signalvar.h>
50 #include <sys/sysent.h>
51 #include <sys/sysproto.h>
55 #include <vm/vm_object.h>
56 #include <vm/vm_page.h>
57 #include <vm/vm_pager.h>
59 #include <machine/cache.h>
60 #include <machine/clock.h>
61 #include <machine/cpu.h>
62 #include <machine/cpuinfo.h>
63 #include <machine/cpufunc.h>
64 #include <machine/cpuregs.h>
65 #include <machine/hwfunc.h>
66 #include <machine/intr_machdep.h>
67 #include <machine/locore.h>
68 #include <machine/md_var.h>
69 #include <machine/pte.h>
70 #include <machine/sigframe.h>
71 #include <machine/trap.h>
72 #include <machine/vmparam.h>
74 #include <mips/rt305x/rt305xreg.h>
78 static char boot1_env[0x1000];
92 printf("entry: mips_init()\n");
95 realmem = btoc(32 << 20);
97 for (i = 0; i < 10; i++) {
101 /* phys_avail regions are in bytes */
102 dump_avail[0] = phys_avail[0] = MIPS_KSEG0_TO_PHYS(kernel_kseg0_end);
103 dump_avail[1] = phys_avail[1] = ctob(realmem);
108 init_param2(physmem);
115 if (boothowto & RB_KDB)
116 kdb_enter(KDB_WHY_BOOTFLAGS, "Boot flags requested debugger");
128 platform_identify(void)
137 __asm __volatile("li $25, 0xbf000000");
138 __asm __volatile("j $25");
142 platform_trap_enter(void)
148 platform_trap_exit(void)
154 platform_start(__register_t a0 __unused, __register_t a1 __unused,
155 __register_t a2 __unused, __register_t a3 __unused)
158 uint64_t platform_counter_freq = PLATFORM_COUNTER_FREQ;
161 char **argv = (char **)MIPS_PHYS_TO_KSEG0(a1);
162 char **envp = (char **)MIPS_PHYS_TO_KSEG0(a2);
164 /* clear the BSS and SBSS segments */
165 kernend = (vm_offset_t)&end;
166 memset(&edata, 0, kernend - (vm_offset_t)(&edata));
168 mips_postboot_fixup();
170 /* Initialize pcpu stuff */
173 /* initialize console so that we have printf */
174 boothowto |= (RB_SERIAL | RB_MULTIPLE); /* Use multiple consoles */
175 boothowto |= (RB_VERBOSE);
178 init_static_kenv(boot1_env, sizeof(boot1_env));
180 printf("U-Boot args (from %d args):\n", argc - 1);
185 for (i = 1; i < argc; i++) {
186 char *n = "argv ", *arg;
193 arg = (char *)(intptr_t)MIPS_PHYS_TO_KSEG0(argv[i]);
194 printf("\targv[%d] = %s\n", i, arg);
195 sprintf(n, "argv%d", i);
200 printf("Environment:\n");
202 for (i = 0; envp[i] ; i++) {
205 arg = (char *)(intptr_t)MIPS_PHYS_TO_KSEG0(envp[i]);
206 printf("\t%s\n", arg);
207 n = strsep(&arg, "=");
216 mips_timer_init_params(platform_counter_freq, 2);