2 * Copyright (c) 2006 Wojciech A. Koszek <wkoszek@FreeBSD.org>
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 AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 #include <sys/cdefs.h>
27 __FBSDID("$FreeBSD$");
31 #include <sys/param.h>
33 #include <sys/kernel.h>
34 #include <sys/systm.h>
35 #include <sys/imgact.h>
42 #include <sys/ucontext.h>
45 #include <sys/ptrace.h>
46 #include <sys/reboot.h>
47 #include <sys/signalvar.h>
48 #include <sys/sysent.h>
49 #include <sys/sysproto.h>
53 #include <vm/vm_object.h>
54 #include <vm/vm_page.h>
56 #include <machine/clock.h>
57 #include <machine/cpu.h>
58 #include <machine/cpuregs.h>
59 #include <machine/hwfunc.h>
60 #include <machine/md_var.h>
61 #include <machine/pmap.h>
62 #include <machine/trap.h>
66 #include <machine/smp.h>
69 #include <mips/gxemul/mpreg.h>
85 for (i = 0; i < 10; i++) {
89 /* phys_avail regions are in bytes */
90 phys_avail[0] = MIPS_KSEG0_TO_PHYS(kernel_kseg0_end);
91 phys_avail[1] = ctob(realmem);
93 dump_avail[0] = phys_avail[0];
94 dump_avail[1] = phys_avail[1];
106 if (boothowto & RB_KDB)
107 kdb_enter(KDB_WHY_BOOTFLAGS, "Boot flags requested debugger");
112 * Perform a board-level soft-reset.
114 * XXXRW: Does gxemul have a moral equivalent to board-level reset?
120 panic("%s: not yet", __func__);
124 platform_start(__register_t a0, __register_t a1, __register_t a2,
128 uint64_t platform_counter_freq;
130 char **argv = (char **)a1;
131 char **envp = (char **)a2;
134 /* clear the BSS and SBSS segments */
135 kernend = (vm_offset_t)&end;
136 memset(&edata, 0, kernend - (vm_offset_t)(&edata));
138 mips_postboot_fixup();
143 * XXXRW: Support for the gxemul real-time clock required in order to
144 * usefully determine our emulated timer frequency. Go with something
145 * classic as the default in the mean time.
147 platform_counter_freq = MIPS_DEFAULT_HZ;
148 mips_timer_early_init(platform_counter_freq);
151 printf("entry: platform_start()\n");
155 printf("cmd line: ");
156 for (i = 0; i < argc; i++)
157 printf("%s ", argv[i]);
162 for (i = 0; envp[i]; i += 2)
163 printf("\t%s = %s\n", envp[i], envp[i+1]);
165 printf("no envp.\n");
169 realmem = btoc(GXEMUL_MP_DEV_READ(GXEMUL_MP_DEV_MEMORY));
172 mips_timer_init_params(platform_counter_freq, 0);
177 platform_ipi_send(int cpuid)
179 GXEMUL_MP_DEV_WRITE(GXEMUL_MP_DEV_IPI_ONE, (1 << 16) | cpuid);
183 platform_ipi_clear(void)
185 GXEMUL_MP_DEV_WRITE(GXEMUL_MP_DEV_IPI_READ, 0);
189 platform_ipi_intrnum(void)
191 return (GXEMUL_MP_DEV_IPI_INTERRUPT - 2);
195 platform_smp_topo(void)
197 return (smp_topo_none());
201 platform_init_ap(int cpuid)
203 int ipi_int_mask, clock_int_mask;
206 * Unmask the clock and ipi interrupts.
208 clock_int_mask = hard_int_mask(5);
209 ipi_int_mask = hard_int_mask(platform_ipi_intrnum());
210 set_intr_mask(ipi_int_mask | clock_int_mask);
214 platform_cpu_mask(cpuset_t *mask)
218 n = GXEMUL_MP_DEV_READ(GXEMUL_MP_DEV_NCPUS);
220 for (i = 0; i < n; i++)
225 platform_processor_id(void)
227 return (GXEMUL_MP_DEV_READ(GXEMUL_MP_DEV_WHOAMI));
231 platform_start_ap(int cpuid)
233 GXEMUL_MP_DEV_WRITE(GXEMUL_MP_DEV_STARTADDR, (intptr_t)mpentry);
234 GXEMUL_MP_DEV_WRITE(GXEMUL_MP_DEV_START, cpuid);