#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.25 2026/06/01 20:34:18 andvar Exp $");
#define __INTR_PRIVATE
#include "opt_multiprocessor.h"
#include "opt_ddb.h"
#include "opt_com.h"
#include "opt_execfmt.h"
#include "opt_memsize.h"
#include "rmixl_pcix.h"
#include "rmixl_pcie.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/buf.h>
#include <sys/cpu.h>
#include <sys/reboot.h>
#include <sys/mount.h>
#include <sys/kcore.h>
#include <sys/boot_flag.h>
#include <sys/termios.h>
#include <sys/ksyms.h>
#include <sys/bus.h>
#include <sys/device.h>
#include <sys/extent.h>
#include <uvm/uvm_extern.h>
#include <dev/cons.h>
#include "ksyms.h"
#if NKSYMS || defined(DDB) || defined(LKM)
#include <mips/db_machdep.h>
#include <ddb/db_extern.h>
#endif
#include <mips/cpu.h>
#include <mips/psl.h>
#include <mips/cache.h>
#include <mips/mips_opcode.h>
#include "com.h"
#if NCOM == 0
#error no serial console
#endif
#include <dev/ic/comreg.h>
#include <dev/ic/comvar.h>
#include <mips/include/intr.h>
#include <mips/rmi/rmixlreg.h>
#include <mips/rmi/rmixlvar.h>
#include <mips/rmi/rmixl_intr.h>
#include <mips/rmi/rmixl_firmware.h>
#include <mips/rmi/rmixl_comvar.h>
#include <mips/rmi/rmixl_pcievar.h>
#include <mips/rmi/rmixl_pcixvar.h>
#ifdef MACHDEP_DEBUG
int machdep_debug=MACHDEP_DEBUG;
# define DPRINTF(x) do { if (machdep_debug) printf x ; } while(0)
#else
# define DPRINTF(x)
#endif
#ifndef CONSFREQ
# define CONSFREQ 66000000
#endif
#ifndef CONSPEED
# define CONSPEED 38400
#endif
#ifndef CONMODE
# define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8)
#endif
#ifndef CONSADDR
# define CONSADDR RMIXL_IO_DEV_UART_1
#endif
int comcnfreq = CONSFREQ;
int comcnspeed = CONSPEED;
tcflag_t comcnmode = CONMODE;
bus_addr_t comcnaddr = (bus_addr_t)CONSADDR;
struct rmixl_config rmixl_configuration;
typedef struct rmiclfw_psb_id {
uint64_t psb_version;
rmixlfw_psb_type_t psb_type;
} rmiclfw_psb_id_t;
static rmiclfw_psb_id_t rmiclfw_psb_id[] = {
{ 0x4958d4fb00000056ULL, PSB_TYPE_RMI },
{ 0x4aacdb6a00000056ULL, PSB_TYPE_RMI },
{ 0x4b67d03200000056ULL, PSB_TYPE_RMI },
{ 0x4c17058b00000056ULL, PSB_TYPE_RMI },
{ 0x49a5a8fa00000056ULL, PSB_TYPE_DELL },
{ 0x4b8ead3100000056ULL, PSB_TYPE_DELL },
};
#define RMICLFW_PSB_VERSIONS_LEN \
(sizeof(rmiclfw_psb_id)/sizeof(rmiclfw_psb_id[0]))
static u_long rmixl_physaddr_storage[
EXTENT_FIXED_STORAGE_SIZE(32)/sizeof(u_long)
];
struct vm_map *phys_map = NULL;
int netboot;
phys_ram_seg_t mem_clusters[VM_PHYSSEG_MAX];
u_quad_t mem_cluster_maxaddr;
u_int mem_cluster_cnt;
void configure(void);
void mach_init(int, int32_t *, void *, int64_t);
static uint64_t rmixlfw_init(int64_t);
static uint64_t mem_clusters_init(rmixlfw_mmap_t *, rmixlfw_mmap_t *);
static void __attribute__((__noreturn__)) rmixl_reset(void);
static void rmixl_physaddr_init(void);
static u_int ram_seg_resv(phys_ram_seg_t *, u_int, u_quad_t, u_quad_t);
void rmixlfw_mmap_print(rmixlfw_mmap_t *);
#ifdef MULTIPROCESSOR
static bool rmixl_fixup_cop0_oscratch(int32_t, uint32_t [2], void *);
void rmixl_get_wakeup_info(struct rmixl_config *);
#ifdef MACHDEP_DEBUG
static void rmixl_wakeup_info_print(volatile rmixlfw_cpu_wakeup_info_t *);
#endif
#endif
static void rmixl_fixup_curcpu(void);
void
mach_init(int argc, int32_t *argv, void *envp, int64_t infop)
{
struct rmixl_config *rcp = &rmixl_configuration;
void *kernend;
uint64_t memsize;
extern char edata[], end[];
rmixl_pcr_init_core();
kernend = (void *)mips_round_page(end);
memset(edata, 0, (char *)kernend - edata);
#ifdef MULTIPROCESSOR
mips_vector_init(&rmixl_splsw, true);
#else
mips_vector_init(&rmixl_splsw, false);
#endif
cpu_setmodel("%s", mips_options.mips_cpu->cpu_name);
memsize = rmixlfw_init(infop);
uvm_md_init();
physmem = btoc(memsize);
rmixl_obio_eb_bus_mem_init(&rcp->rc_obio_eb_memt, rcp);
#if NCOM > 0
rmixl_com_cnattach(comcnaddr, comcnspeed, comcnfreq,
COM_TYPE_NORMAL, comcnmode);
#endif
printf("\nNetBSD/rmixl\n");
printf("memsize = %#"PRIx64"\n", memsize);
#ifdef MEMLIMIT
printf("memlimit = %#"PRIx64"\n", (uint64_t)MEMLIMIT);
#endif
#if defined(MULTIPROCESSOR) && defined(MACHDEP_DEBUG)
rmixl_wakeup_info_print(rcp->rc_cpu_wakeup_info);
rmixl_wakeup_info_print(rcp->rc_cpu_wakeup_info + 1);
printf("cpu_wakeup_info %p, cpu_wakeup_end %p\n",
rcp->rc_cpu_wakeup_info,
rcp->rc_cpu_wakeup_end);
printf("userapp_cpu_map: %#"PRIx64"\n",
rcp->rc_psb_info.userapp_cpu_map);
printf("wakeup: %#"PRIx64"\n", rcp->rc_psb_info.wakeup);
{
register_t sp;
asm volatile ("move %0, $sp\n" : "=r"(sp));
printf("sp: %#"PRIx64"\n", sp);
}
#endif
rmixl_physaddr_init();
curcpu()->ci_cpu_freq = rcp->rc_psb_info.cpu_frequency;
curcpu()->ci_cctr_freq = curcpu()->ci_cpu_freq;
curcpu()->ci_cycles_per_hz = (curcpu()->ci_cpu_freq + hz / 2) / hz;
curcpu()->ci_divisor_delay =
((curcpu()->ci_cpu_freq + 500000) / 1000000);
if (mips_options.mips_cpu_flags & CPU_MIPS_DOUBLE_COUNT)
curcpu()->ci_cpu_freq *= 2;
boothowto = RB_AUTOBOOT;
for (int i = 1; i < argc; i++) {
for (char *cp = (char *)(intptr_t)argv[i]; *cp; cp++) {
int howto;
if (*cp == '-')
continue;
howto = 0;
BOOT_FLAG(*cp, howto);
if (howto != 0)
boothowto |= howto;
#ifdef DIAGNOSTIC
else
printf("bootflag '%c' not recognised\n", *cp);
#endif
}
}
#ifdef DIAGNOSTIC
printf("boothowto %#x\n", boothowto);
#endif
mem_cluster_cnt = ram_seg_resv(mem_clusters, mem_cluster_cnt,
0, round_page(MIPS_KSEG0_TO_PHYS(kernend)));
mem_cluster_cnt = ram_seg_resv(mem_clusters, mem_cluster_cnt,
0x1FC00000, 0x1FC00000+NBPG);
#ifdef MULTIPROCEESOR
mem_cluster_cnt = ram_seg_resv(mem_clusters, mem_cluster_cnt,
(u_quad_t)trunc_page(rcp->rc_cpu_wakeup_info),
(u_quad_t)round_page(rcp->rc_cpu_wakeup_end));
#endif
#ifdef MEMLIMIT
mem_cluster_cnt = ram_seg_resv(mem_clusters, mem_cluster_cnt,
(u_quad_t)MEMLIMIT, (u_quad_t)~0);
#endif
mem_cluster_maxaddr = 0;
for (u_int i=0; i < mem_cluster_cnt; i++) {
u_quad_t tmp = round_page(
mem_clusters[i].start + mem_clusters[i].size);
if (tmp > mem_cluster_maxaddr)
mem_cluster_maxaddr = tmp;
}
DPRINTF(("mem_cluster_maxaddr %#"PRIx64"\n", mem_cluster_maxaddr));
mips_page_physload(MIPS_KSEG0_START, (vaddr_t) kernend,
mem_clusters, mem_cluster_cnt, NULL, 0);
mips_init_msgbuf();
pmap_bootstrap();
mips_init_lwp0_uarea();
#if defined(DDB)
if (boothowto & RB_KDB)
Debugger();
#endif
__asm __volatile("dmtc0 %0,$%1"
:: "r"(&cpu_info_store), "n"(MIPS_COP_0_OSSCRATCH));
#ifdef MULTIPROCESSOR
mips_fixup_exceptions(rmixl_fixup_cop0_oscratch, NULL);
#endif
rmixl_fixup_curcpu();
}
void
rmixl_pcr_init_core(void)
{
uint32_t r;
#ifdef MULTIPROCESSOR
rmixl_mtcr(RMIXL_PCR_MMU_SETUP, __BITS(2,0));
#else
rmixl_mtcr(RMIXL_PCR_THREADEN, 1);
rmixl_mtcr(RMIXL_PCR_MMU_SETUP, 0);
#endif
r = rmixl_mfcr(RMIXL_PCR_L1D_CONFIG0);
r &= ~__BIT(14);
rmixl_mtcr(RMIXL_PCR_L1D_CONFIG0, r);
#if defined(DDB) && defined(MIPS_DDB_WATCH)
r = rmixl_mfcr(RMIXL_PCR_IEU_DEFEATURE);
r &= ~__BIT(7);
rmixl_mtcr(RMIXL_PCR_IEU_DEFEATURE, r);
#endif
}
#ifdef MULTIPROCESSOR
static bool
rmixl_fixup_cop0_oscratch(int32_t load_addr, uint32_t new_insns[2], void *arg)
{
size_t offset = load_addr - (intptr_t)&cpu_info_store;
KASSERT(MIPS_KSEG0_P(load_addr));
KASSERT(offset < sizeof(struct cpu_info));
new_insns[0] = (020 << 26)
#ifdef _LP64
| (1 << 21)
#endif
| (new_insns[0] & 0x001f0000)
| (MIPS_COP_0_OSSCRATCH << 11) | (0 << 0);
new_insns[1] = (new_insns[1] & 0xffff0000) | offset;
return true;
}
#endif
#define LOAD_CURCPU_0 ((MIPS_CURLWP_REG << 21) | offsetof(lwp_t, l_cpu))
#define MFC0_CURCPU_0 ((OP_COP0 << 26) | (MIPS_COP_0_OSSCRATCH << 11))
#ifdef _LP64
#define LOAD_CURCPU ((uint32_t)(OP_LD << 26) | LOAD_CURCPU_0)
#define MFC0_CURCPU ((uint32_t)(OP_DMF << 21) | MFC0_CURCPU_0)
#else
#define LOAD_CURCPU ((uint32_t)(OP_LW << 26) | LOAD_CURCPU_0)
#define MFC0_CURCPU ((uint32_t)(OP_MF << 21) | MFC0_CURCPU_0)
#endif
#define LOAD_CURCPU_MASK 0xffe0ffff
static void
rmixl_fixup_curcpu(void)
{
extern uint32_t _ftext[];
extern uint32_t _etext[];
for (uint32_t *insnp = _ftext; insnp < _etext; insnp++) {
const uint32_t insn = *insnp;
if (__predict_false((insn & LOAD_CURCPU_MASK) == LOAD_CURCPU)) {
*insnp = insn ^ LOAD_CURCPU ^ MFC0_CURCPU;
mips_icache_sync_range((vaddr_t)insnp, 4);
}
}
}
static u_int
ram_seg_resv(phys_ram_seg_t *segs, u_int nsegs,
u_quad_t resv_first, u_quad_t resv_last)
{
u_quad_t first, last;
int new_nsegs=0;
int resv_flag;
phys_ram_seg_t new_segs[VM_PHYSSEG_MAX];
for (u_int i=0; i < nsegs; i++) {
resv_flag = 0;
first = trunc_page(segs[i].start);
last = round_page(segs[i].start + segs[i].size);
KASSERT(new_nsegs < VM_PHYSSEG_MAX);
if ((resv_first <= first) && (resv_last >= last)) {
continue;
}
if ((resv_first > first) && (resv_first < last)) {
u_quad_t new_last;
resv_flag = 1;
new_last = last - (last - resv_first);
KASSERT (new_last > first);
new_segs[new_nsegs].start = first;
new_segs[new_nsegs].size = new_last - first;
new_nsegs++;
}
if ((resv_last > first) && (resv_last < last)) {
u_quad_t new_first;
resv_flag = 1;
new_first = first + (resv_last - first);
KASSERT (last > (new_first + NBPG));
new_segs[new_nsegs].start = new_first;
new_segs[new_nsegs].size = last - new_first;
new_nsegs++;
}
if (resv_flag == 0) {
new_segs[new_nsegs].start = first;
new_segs[new_nsegs].size = last - first;
new_nsegs++;
}
}
memcpy(segs, new_segs, sizeof(new_segs));
return new_nsegs;
}
static void
rmixl_physaddr_init(void)
{
struct extent *ext;
unsigned long start = 0UL;
unsigned long end = (__BIT(40) / (1024 * 1024)) -1;
u_long base;
u_long size;
uint32_t r;
ext = extent_create("physaddr", start, end,
(void *)rmixl_physaddr_storage, sizeof(rmixl_physaddr_storage),
EX_NOWAIT | EX_NOCOALESCE);
if (ext == NULL)
panic("%s: extent_create failed", __func__);
for (u_int i=0; i < RMIXL_SBC_DRAM_NBARS; i++) {
r = RMIXL_IOREG_READ(RMIXL_SBC_DRAM_BAR(i));
if ((r & RMIXL_DRAM_BAR_STATUS) == 0)
continue;
base = (u_long)(DRAM_BAR_TO_BASE((uint64_t)r) / (1024 * 1024));
size = (u_long)(DRAM_BAR_TO_SIZE((uint64_t)r) / (1024 * 1024));
DPRINTF(("%s: %d: %d: 0x%08x -- 0x%010lx:%lu MB\n",
__func__, __LINE__, i, r, base * (1024 * 1024), size));
if (extent_alloc_region(ext, base, size, EX_NOWAIT) != 0)
panic("%s: extent_alloc_region(%p, %#lx, %#lx, %#x) "
"failed", __func__, ext, base, size, EX_NOWAIT);
}
switch(cpu_rmixl_chip_type(mips_options.mips_cpu)) {
case CIDFL_RMI_TYPE_XLR:
#if NRMIXL_PCIX
rmixl_physaddr_init_pcix(ext);
#endif
break;
case CIDFL_RMI_TYPE_XLS:
#if NRMIXL_PCIE
rmixl_physaddr_init_pcie(ext);
#endif
break;
case CIDFL_RMI_TYPE_XLP:
panic("%s: RMI XLP not yet supported", __func__);
}
rmixl_configuration.rc_phys_ex = ext;
#ifdef MACHDEP_DEBUG
extent_print(ext);
#endif
}
static uint64_t
rmixlfw_init(int64_t infop)
{
struct rmixl_config *rcp = &rmixl_configuration;
#ifdef MULTIPROCESSOR
rmixl_get_wakeup_info(rcp);
#endif
infop |= MIPS_KSEG0_START;
rcp->rc_psb_info = *(rmixlfw_info_t *)(intptr_t)infop;
rcp->rc_psb_type = PSB_TYPE_UNKNOWN;
for (int i=0; i < RMICLFW_PSB_VERSIONS_LEN; i++) {
if (rmiclfw_psb_id[i].psb_version ==
rcp->rc_psb_info.psb_version) {
rcp->rc_psb_type = rmiclfw_psb_id[i].psb_type;
goto found;
}
}
rcp->rc_io_pbase = RMIXL_IO_DEV_PBASE;
rmixl_putchar_init(rcp->rc_io_pbase);
#ifdef DIAGNOSTIC
rmixl_puts("\r\nWARNING: untested psb_version: ");
rmixl_puthex64(rcp->rc_psb_info.psb_version);
rmixl_puts("\r\n");
#endif
#ifdef MEMSIZE
mem_clusters[0].start = 0;
mem_clusters[0].size = MEMSIZE;
mem_cluster_cnt = 1;
return MEMSIZE;
#else
rmixl_puts("\r\nERROR: configure MEMSIZE\r\n");
cpu_reboot(RB_HALT, NULL);
#endif
found:
rcp->rc_io_pbase = MIPS_KSEG1_TO_PHYS(rcp->rc_psb_info.io_base);
rmixl_putchar_init(rcp->rc_io_pbase);
#ifdef MACHDEP_DEBUG
rmixl_puts("\r\ninfop: ");
rmixl_puthex64((uint64_t)(intptr_t)infop);
#endif
#ifdef DIAGNOSTIC
rmixl_puts("\r\nrecognized psb_version=");
rmixl_puthex64(rcp->rc_psb_info.psb_version);
rmixl_puts(", psb_type=");
rmixl_puts(rmixlfw_psb_type_name(rcp->rc_psb_type));
rmixl_puts("\r\n");
#endif
return mem_clusters_init(
(rmixlfw_mmap_t *)(intptr_t)rcp->rc_psb_info.psb_physaddr_map,
(rmixlfw_mmap_t *)(intptr_t)rcp->rc_psb_info.avail_mem_map);
}
void
rmixlfw_mmap_print(rmixlfw_mmap_t *map)
{
#ifdef MACHDEP_DEBUG
for (uint32_t i=0; i < map->nmmaps; i++) {
rmixl_puthex32(i);
rmixl_puts(", ");
rmixl_puthex64(map->entry[i].start);
rmixl_puts(", ");
rmixl_puthex64(map->entry[i].size);
rmixl_puts(", ");
rmixl_puthex32(map->entry[i].type);
rmixl_puts("\r\n");
}
#endif
}
static uint64_t
mem_clusters_init(
rmixlfw_mmap_t *psb_physaddr_map,
rmixlfw_mmap_t *avail_mem_map)
{
rmixlfw_mmap_t *map = NULL;
const char *mapname;
uint64_t sz;
uint64_t sum;
u_int cnt;
#ifdef MEMSIZE
uint64_t memsize = MEMSIZE;
#endif
#ifdef MACHDEP_DEBUG
rmixl_puts("psb_physaddr_map: ");
rmixl_puthex64((uint64_t)(intptr_t)psb_physaddr_map);
rmixl_puts("\r\n");
#endif
if (psb_physaddr_map != NULL) {
map = psb_physaddr_map;
mapname = "psb_physaddr_map";
rmixlfw_mmap_print(map);
}
#ifdef DIAGNOSTIC
else {
rmixl_puts("WARNING: no psb_physaddr_map\r\n");
}
#endif
#ifdef MACHDEP_DEBUG
rmixl_puts("avail_mem_map: ");
rmixl_puthex64((uint64_t)(intptr_t)avail_mem_map);
rmixl_puts("\r\n");
#endif
if (avail_mem_map != NULL) {
map = avail_mem_map;
mapname = "avail_mem_map";
rmixlfw_mmap_print(map);
}
#ifdef DIAGNOSTIC
else {
rmixl_puts("WARNING: no avail_mem_map\r\n");
}
#endif
if (map == NULL) {
#ifndef MEMSIZE
rmixl_puts("panic: no firmware memory map, "
"must configure MEMSIZE\r\n");
for(;;);
#else
#ifdef DIAGNOSTIC
rmixl_puts("WARNING: no avail_mem_map, "
"using MEMSIZE\r\n");
#endif
mem_clusters[0].start = 0;
mem_clusters[0].size = MEMSIZE;
mem_cluster_cnt = 1;
return MEMSIZE;
#endif
}
#ifdef DIAGNOSTIC
rmixl_puts("using ");
rmixl_puts(mapname);
rmixl_puts("\r\n");
#endif
#ifdef MACHDEP_DEBUG
rmixl_puts("memory clusters:\r\n");
#endif
sum = 0;
cnt = 0;
for (uint32_t i=0; i < map->nmmaps; i++) {
if (map->entry[i].type != RMIXLFW_MMAP_TYPE_RAM)
continue;
mem_clusters[cnt].start = map->entry[i].start;
sz = map->entry[i].size;
sum += sz;
mem_clusters[cnt].size = sz;
#ifdef MACHDEP_DEBUG
rmixl_puthex32(i);
rmixl_puts(": ");
rmixl_puthex64(mem_clusters[cnt].start);
rmixl_puts(", ");
rmixl_puthex64(sz);
rmixl_puts(": ");
rmixl_puthex64(sum);
rmixl_puts("\r\n");
#endif
#ifdef MEMSIZE
if (sum == memsize)
break;
if (sum > memsize) {
uint64_t tmp;
tmp = sum - memsize;
sz -= tmp;
sum -= tmp;
mem_clusters[cnt].size = sz;
cnt++;
break;
}
#endif
cnt++;
}
mem_cluster_cnt = cnt;
return sum;
}
#ifdef MULTIPROCESSOR
void
rmixl_get_wakeup_info(struct rmixl_config *rcp)
{
volatile rmixlfw_cpu_wakeup_info_t *wip;
int32_t scratch_7;
intptr_t end;
__asm__ volatile(
".set push" "\n"
".set noreorder" "\n"
".set mips64" "\n"
"dmfc0 %0, $22, 7" "\n"
".set pop" "\n"
: "=r"(scratch_7));
wip = (volatile rmixlfw_cpu_wakeup_info_t *)
(intptr_t)scratch_7;
end = wip->entry.gp - (wip->master_cpu & (PAGE_SIZE * 2));
if (wip->valid == 1) {
rcp->rc_cpu_wakeup_end = (const void *)end;
rcp->rc_cpu_wakeup_info = wip;
}
};
#ifdef MACHDEP_DEBUG
static void
rmixl_wakeup_info_print(volatile rmixlfw_cpu_wakeup_info_t *wip)
{
int i;
printf("%s: wip %p, size %lu\n", __func__, wip, sizeof(*wip));
printf("cpu_status %#x\n", wip->cpu_status);
printf("valid: %d\n", wip->valid);
printf("entry: addr %#x, args %#x, sp %#"PRIx64", gp %#"PRIx64"\n",
wip->entry.addr,
wip->entry.args,
wip->entry.sp,
wip->entry.gp);
printf("master_cpu %d\n", wip->master_cpu);
printf("master_cpu_mask %#x\n", wip->master_cpu_mask);
printf("buddy_cpu_mask %#x\n", wip->buddy_cpu_mask);
printf("psb_os_cpu_map %#x\n", wip->psb_os_cpu_map);
printf("argc %d\n", wip->argc);
printf("argv:");
for (i=0; i < wip->argc; i++)
printf(" %#x", wip->argv[i]);
printf("\n");
printf("valid_tlb_entries %d\n", wip->valid_tlb_entries);
printf("tlb_map:\n");
for (i=0; i < wip->valid_tlb_entries; i++) {
volatile const struct lib_cpu_tlb_mapping *m =
&wip->tlb_map[i];
printf(" %d", m->page_size);
printf(", %d", m->asid);
printf(", %d", m->coherency);
printf(", %d", m->coherency);
printf(", %d", m->attr);
printf(", %#x", m->virt);
printf(", %#"PRIx64"\n", m->phys);
}
printf("elf segs:\n");
for (i=0; i < MAX_ELF_SEGMENTS; i++) {
volatile const struct core_segment_info *e =
&wip->seg_info[i];
printf(" %#"PRIx64"", e->vaddr);
printf(", %#"PRIx64"", e->memsz);
printf(", %#x\n", e->flags);
}
printf("envc %d\n", wip->envc);
for (i=0; i < wip->envc; i++)
printf(" %#x \"%s\"", wip->envs[i],
(char *)(intptr_t)(int32_t)(wip->envs[i]));
printf("\n");
printf("app_mode %d\n", wip->app_mode);
printf("printk_lock %#x\n", wip->printk_lock);
printf("kseg_master %d\n", wip->kseg_master);
printf("kuseg_reentry_function %#x\n", wip->kuseg_reentry_function);
printf("kuseg_reentry_args %#x\n", wip->kuseg_reentry_args);
printf("app_shared_mem_addr %#"PRIx64"\n", wip->app_shared_mem_addr);
printf("app_shared_mem_size %#"PRIx64"\n", wip->app_shared_mem_size);
printf("app_shared_mem_orig %#"PRIx64"\n", wip->app_shared_mem_orig);
printf("loader_lock %#x\n", wip->loader_lock);
printf("global_wakeup_mask %#x\n", wip->global_wakeup_mask);
printf("unused_0 %#x\n", wip->unused_0);
}
#endif
#endif
void
consinit(void)
{
}
void
cpu_startup(void)
{
rmixl_configuration.rc_mallocsafe = 1;
cpu_startup_common();
}
int waittime = -1;
void
cpu_reboot(int howto, char *bootstr)
{
savectx(lwp_getpcb(curlwp));
if (cold) {
howto |= RB_HALT;
goto haltsys;
}
if (boothowto & RB_HALT)
howto |= RB_HALT;
boothowto = howto;
if ((howto & RB_NOSYNC) == 0 && (waittime < 0)) {
waittime = 0;
vfs_shutdown();
}
splhigh();
if (howto & RB_DUMP)
dumpsys();
haltsys:
doshutdownhooks();
if (howto & RB_HALT) {
printf("\n");
printf("The operating system has halted.\n");
printf("Please press any key to reboot.\n\n");
cnpollc(true);
cngetc();
cnpollc(false);
}
printf("rebooting...\n\n");
rmixl_reset();
}
void __attribute__((__noreturn__))
rmixl_reset(void)
{
uint32_t r;
r = RMIXL_IOREG_READ(RMIXL_IO_DEV_GPIO + RMIXL_GPIO_RESET);
r |= RMIXL_GPIO_RESET_RESET;
RMIXL_IOREG_WRITE(RMIXL_IO_DEV_GPIO + RMIXL_GPIO_RESET, r);
printf("soft reset failed, spinning...\n");
for (;;);
}