#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: locore.c,v 1.84 2017/05/22 16:53:05 ragge Exp $");
#include "opt_compat_netbsd.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/cpu.h>
#include <sys/device.h>
#include <sys/proc.h>
#include <sys/reboot.h>
#include <uvm/uvm_extern.h>
#include <machine/sid.h>
#include <machine/nexus.h>
#include <machine/rpb.h>
#include "opt_cputype.h"
void _start(struct rpb *);
void main(void);
extern paddr_t avail_end;
paddr_t esym;
extern const struct cpu_dep ka780_calls;
extern const struct cpu_dep ka750_calls;
extern const struct cpu_dep ka730_calls;
extern const struct cpu_dep ka860_calls;
extern const struct cpu_dep ka820_calls;
extern const struct cpu_dep ka6400_calls;
extern const struct cpu_dep ka88_calls;
extern const struct cpu_dep ka43_calls;
extern const struct cpu_dep ka46_calls;
extern const struct cpu_dep ka48_calls;
extern const struct cpu_dep vxt_calls;
extern const struct cpu_dep ka49_calls;
extern const struct cpu_dep ka53_calls;
extern const struct cpu_dep ka410_calls;
extern const struct cpu_dep ka610_calls;
extern const struct cpu_dep ka630_calls;
extern const struct cpu_dep ka650_calls;
extern const struct cpu_dep ka660_calls;
extern const struct cpu_dep ka670_calls;
extern const struct cpu_dep ka680_calls;
void
_start(struct rpb *prpb)
{
extern uintptr_t scratch;
struct pte *pt;
vaddr_t uv;
const char *mv;
#if VAX410 || VAXANY
const char *md;
#endif
mtpr(AST_NO, PR_ASTLVL);
findcpu();
if (vax_confdata & 0x80)
mv = "MicroVAX";
else
mv = "VAXstation";
switch (vax_boardtype) {
#if VAX780 || VAXANY
case VAX_BTYP_780:
dep_call = &ka780_calls;
cpu_setmodel("VAX 11/78%c", vax_cpudata & 0x100 ? '5' : '0');
mv = NULL;
break;
#endif
#if VAX750 || VAXANY
case VAX_BTYP_750:
dep_call = &ka750_calls;
mv = "VAX 11/750";
break;
#endif
#if VAX730 || VAXANY
case VAX_BTYP_730:
dep_call = &ka730_calls;
mv = "VAX 11/730";
break;
#endif
#if VAX8600 || VAXANY
case VAX_BTYP_790:
dep_call = &ka860_calls;
cpu_setmodel("VAX 86%c0", vax_cpudata & 0x800000 ? '5' : '0');
mv = NULL;
break;
#endif
#if VAX410 || VAXANY
case VAX_BTYP_420:
dep_call = &ka410_calls;
if (((vax_siedata >> 8) & 0xff) == 1)
md = "/m{38,48}";
else if (((vax_siedata >> 8) & 0xff) == 0)
md = "/m{30,40}";
else
md = "";
cpu_setmodel("%s 3100%s", mv, md);
mv = NULL;
break;
case VAX_BTYP_410:
dep_call = &ka410_calls;
cpu_setmodel("%s 2000", mv);
mv = NULL;
break;
#endif
#if VAX43 || VAXANY
case VAX_BTYP_43:
dep_call = &ka43_calls;
cpu_setmodel("%s 3100/m76", mv);
mv = NULL;
break;
#endif
#if VAX46 || VAXANY
case VAX_BTYP_46:
dep_call = &ka46_calls;
switch(vax_siedata & 0x3) {
case 1: mv = "MicroVAX 3100/80"; break;
case 2: mv = "VAXstation 4000/60"; break;
default: mv = "unknown"; break;
}
break;
#endif
#if VAX48 || VAXANY
case VAX_BTYP_48:
dep_call = &ka48_calls;
switch (vax_siedata & 3) {
case 1: mv = "MicroVAX 3100/m{30,40}"; break;
case 2: mv = "VAXstation 4000 VLC"; break;
default: mv = "unknown SOC"; break;
}
break;
#endif
#if 0 && (VXT2000 || VAXANY)
case VAX_BTYP_VXT:
dep_call = &vxt_calls;
mv = "VXT 2000 X terminal";
break;
#endif
#if VAX49 || VAXANY
case VAX_BTYP_49:
dep_call = &ka49_calls;
cpu_setmodel("%s 4000/{90,90A,96}", mv);
mv = NULL;
break;
#endif
#if VAX53 || VAXANY
case VAX_BTYP_53:
dep_call = &ka53_calls;
switch((vax_siedata & 0xff00) >> 8) {
case VAX_STYP_51:
mv = "MicroVAX 3100/m{90,95}"; break;
case VAX_STYP_52:
mv = "VAX 4000/100"; break;
case VAX_STYP_53:
mv = "VAX 4000/{105A,106A,108}"; break;
case VAX_STYP_55:
mv = "MicroVAX 3100/m85"; break;
default:
mv = "unknown 1303"; break;
}
break;
#endif
#if VAX610 || VAXANY
case VAX_BTYP_610:
dep_call = &ka610_calls;
mv = "MicroVAX I";
break;
#endif
#if VAX630 || VAXANY
case VAX_BTYP_630:
dep_call = &ka630_calls;
mv = "MicroVAX II";
break;
#endif
#if VAX650 || VAXANY
case VAX_BTYP_650:
dep_call = &ka650_calls;
switch ((vax_siedata >> 8) & 255) {
case VAX_SIE_KA640:
mv = "3300/3400";
break;
case VAX_SIE_KA650:
mv = "3500/3600";
break;
case VAX_SIE_KA655:
mv = "3800/3900";
break;
default:
mv = "III";
break;
}
cpu_setmodel("MicroVAX %s", mv);
mv = NULL;
break;
#endif
#if VAX660 || VAXANY
case VAX_BTYP_660:
dep_call = &ka660_calls;
mv = "VAX 4000/200";
break;
#endif
#if VAX670 || VAXANY
case VAX_BTYP_670:
dep_call = &ka670_calls;
mv = "VAX 4000/300";
break;
#endif
#if VAX680 || VAXANY
case VAX_BTYP_680:
dep_call = &ka680_calls;
switch((vax_siedata & 0xff00) >> 8) {
case VAX_STYP_675:
mv = "VAX 4000/400"; break;
case VAX_STYP_680:
mv = "VAX 4000/500"; break;
default:
mv = "unknown 1301";
}
break;
case VAX_BTYP_681:
dep_call = &ka680_calls;
switch((vax_siedata & 0xff00) >> 8) {
case VAX_STYP_681:
mv = "VAX 4000/500A"; break;
case VAX_STYP_691:
mv = "VAX 4000/600A"; break;
case VAX_STYP_694:
cpu_setmodel("VAX 4000/70%cA",
vax_cpudata & 0x1000 ? '5' : '0');
mv = NULL;
break;
default:
mv = "unknown 1305";
}
break;
#endif
#if VAX8200 || VAXANY
case VAX_BTYP_8000:
dep_call = &ka820_calls;
mv = "VAX 8200";
break;
#endif
#if VAX8800 || VAXANY
case VAX_BTYP_8PS:
case VAX_BTYP_8800:
mv = "VAX 8800";
dep_call = &ka88_calls;
break;
#endif
#if VAX6400 || VAXANY
case VAX_BTYP_9RR:
dep_call = &ka6400_calls;
break;
#endif
default:
__asm("halt");
}
if (mv != NULL)
cpu_setmodel("%s", mv);
uv = uvm_lwp_getuarea(&lwp0);
uv += REDZONEADDR;
#if defined(COMPAT_14)
if (prpb == 0) {
memset((void *)uv, 0, sizeof(struct rpb));
prpb = (struct rpb *)uv;
prpb->pfncnt = avail_end >> VAX_PGSHIFT;
prpb->rpb_base = (void *)-1;
} else
#endif
memcpy((void *)uv, prpb, sizeof(struct rpb));
if (prpb->pfncnt)
avail_end = prpb->pfncnt << VAX_PGSHIFT;
else
while (badaddr((void *)avail_end, 4) == 0)
avail_end += VAX_NBPG * 128;
boothowto = prpb->rpb_bootr5;
avail_end &= ~PGOFSET;
pmap_bootstrap();
pt = kvtopte(uv);
pt->pg_v = 0;
lwp0.l_md.md_utf = (void *)scratch;
main();
}