2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2006 Wojciech A. Koszek <wkoszek@FreeBSD.org>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
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>
58 #include <machine/clock.h>
59 #include <machine/cpu.h>
60 #include <machine/cpuregs.h>
61 #include <machine/hwfunc.h>
62 #include <machine/md_var.h>
63 #include <machine/pmap.h>
64 #include <machine/trap.h>
68 #include <machine/smp.h>
71 #include <mips/gxemul/mpreg.h>
87 for (i = 0; i < 10; i++) {
91 /* phys_avail regions are in bytes */
92 phys_avail[0] = MIPS_KSEG0_TO_PHYS(kernel_kseg0_end);
93 phys_avail[1] = ctob(realmem);
95 dump_avail[0] = phys_avail[0];
96 dump_avail[1] = phys_avail[1];
101 init_param2(physmem);
108 if (boothowto & RB_KDB)
109 kdb_enter(KDB_WHY_BOOTFLAGS, "Boot flags requested debugger");
114 * Perform a board-level soft-reset.
116 * XXXRW: Does gxemul have a moral equivalent to board-level reset?
122 panic("%s: not yet", __func__);
126 platform_start(__register_t a0, __register_t a1, __register_t a2,
130 uint64_t platform_counter_freq;
132 char **argv = (char **)a1;
133 char **envp = (char **)a2;
136 /* clear the BSS and SBSS segments */
137 kernend = (vm_offset_t)&end;
138 memset(&edata, 0, kernend - (vm_offset_t)(&edata));
140 mips_postboot_fixup();
145 * XXXRW: Support for the gxemul real-time clock required in order to
146 * usefully determine our emulated timer frequency. Go with something
147 * classic as the default in the mean time.
149 platform_counter_freq = MIPS_DEFAULT_HZ;
150 mips_timer_early_init(platform_counter_freq);
153 printf("entry: platform_start()\n");
157 printf("cmd line: ");
158 for (i = 0; i < argc; i++)
159 printf("%s ", argv[i]);
164 for (i = 0; envp[i]; i += 2)
165 printf("\t%s = %s\n", envp[i], envp[i+1]);
167 printf("no envp.\n");
171 realmem = btoc(GXEMUL_MP_DEV_READ(GXEMUL_MP_DEV_MEMORY));
174 mips_timer_init_params(platform_counter_freq, 0);
179 platform_ipi_send(int cpuid)
181 GXEMUL_MP_DEV_WRITE(GXEMUL_MP_DEV_IPI_ONE, (1 << 16) | cpuid);
185 platform_ipi_clear(void)
187 GXEMUL_MP_DEV_WRITE(GXEMUL_MP_DEV_IPI_READ, 0);
191 platform_ipi_hardintr_num(void)
194 return (GXEMUL_MP_DEV_IPI_INTERRUPT - 2);
198 platform_ipi_softintr_num(void)
205 platform_smp_topo(void)
207 return (smp_topo_none());
211 platform_init_ap(int cpuid)
213 int ipi_int_mask, clock_int_mask;
216 * Unmask the clock and ipi interrupts.
218 clock_int_mask = hard_int_mask(5);
219 ipi_int_mask = hard_int_mask(platform_ipi_hardintr_num());
220 set_intr_mask(ipi_int_mask | clock_int_mask);
224 platform_cpu_mask(cpuset_t *mask)
228 n = GXEMUL_MP_DEV_READ(GXEMUL_MP_DEV_NCPUS);
230 for (i = 0; i < n; i++)
235 platform_processor_id(void)
237 return (GXEMUL_MP_DEV_READ(GXEMUL_MP_DEV_WHOAMI));
241 platform_start_ap(int cpuid)
243 GXEMUL_MP_DEV_WRITE(GXEMUL_MP_DEV_STARTADDR, (intptr_t)mpentry);
244 GXEMUL_MP_DEV_WRITE(GXEMUL_MP_DEV_START, cpuid);