2 * Copyright (c) 2006 Wojciech A. Koszek <wkoszek@FreeBSD.org>
3 * Copyright (c) 2012 Robert N. M. Watson
6 * This software was developed by SRI International and the University of
7 * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
8 * ("CTSRD"), as part of the DARPA CRASH research programme.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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 AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 #include <sys/cdefs.h>
32 __FBSDID("$FreeBSD$");
35 #include "opt_platform.h"
37 #include <sys/param.h>
39 #include <sys/kernel.h>
40 #include <sys/systm.h>
41 #include <sys/imgact.h>
48 #include <sys/linker.h>
49 #include <sys/ucontext.h>
52 #include <sys/ptrace.h>
53 #include <sys/reboot.h>
54 #include <sys/signalvar.h>
55 #include <sys/sysent.h>
56 #include <sys/sysproto.h>
60 #include <dev/fdt/fdt_common.h>
61 #include <dev/ofw/openfirm.h>
65 #include <vm/vm_object.h>
66 #include <vm/vm_page.h>
68 #include <machine/clock.h>
69 #include <machine/cpu.h>
70 #include <machine/cpuregs.h>
71 #include <machine/hwfunc.h>
72 #include <machine/md_var.h>
73 #include <machine/metadata.h>
74 #include <machine/pmap.h>
75 #include <machine/trap.h>
91 for (i = 0; i < 10; i++) {
95 /* phys_avail regions are in bytes */
96 phys_avail[0] = MIPS_KSEG0_TO_PHYS(kernel_kseg0_end);
97 phys_avail[1] = ctob(realmem);
99 dump_avail[0] = phys_avail[0];
100 dump_avail[1] = phys_avail[1];
105 init_param2(physmem);
112 if (boothowto & RB_KDB)
113 kdb_enter(KDB_WHY_BOOTFLAGS, "Boot flags requested debugger");
118 * Perform a board-level soft-reset.
120 * XXXRW: BERI doesn't yet have a board-level soft-reset.
126 panic("%s: not yet", __func__);
130 platform_start(__register_t a0, __register_t a1, __register_t a2,
134 uint64_t platform_counter_freq;
136 char **argv = (char **)a1;
137 char **envp = (char **)a2;
138 unsigned int memsize = a3;
145 /* clear the BSS and SBSS segments */
146 kernend = (vm_offset_t)&end;
147 memset(&edata, 0, kernend - (vm_offset_t)(&edata));
149 mips_postboot_fixup();
155 * Find the dtb passed in by the boot loader (currently fictional).
157 kmdp = preload_search_by_type("elf kernel");
159 dtbp = MD_FETCH(kmdp, MODINFOMD_DTBP, vm_offset_t);
161 dtbp = (vm_offset_t)NULL;
163 #if defined(FDT_DTB_STATIC)
165 * In case the device tree blob was not retrieved (from metadata) try
166 * to use the statically embedded one.
168 if (dtbp == (vm_offset_t)NULL)
169 dtbp = (vm_offset_t)&fdt_static_dtb;
171 #error "Non-static FDT not yet supported on BERI"
174 if (OF_install(OFW_FDT, 0) == FALSE)
176 if (OF_init(&fdt_static_dtb) != 0)
181 * XXXRW: We have no way to compare wallclock time to cycle rate on
182 * BERI, so for now assume we run at the MALTA default (100MHz).
184 platform_counter_freq = MIPS_DEFAULT_HZ;
185 mips_timer_early_init(platform_counter_freq);
188 printf("entry: platform_start()\n");
192 printf("cmd line: ");
193 for (i = 0; i < argc; i++)
194 printf("%s ", argv[i]);
198 for (i = 0; envp[i]; i += 2)
199 printf("\t%s = %s\n", envp[i], envp[i+1]);
201 printf("memsize = %08x\n", memsize);
204 realmem = btoc(memsize);
207 mips_timer_init_params(platform_counter_freq, 0);