*/
#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/conf.h>
#include <sys/device.h>
+#include <sys/disklabel.h>
#include <sys/reboot.h>
-#include <sys/socket.h>
#include <sys/hibernate.h>
+#include <sys/systm.h>
#include <uvm/uvm.h>
+#if defined(NFSCLIENT)
#include <net/if.h>
#include <net/if_types.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
+#endif
#include <machine/bootconfig.h>
extern void dumpconf(void);
-void parsepmonbp(void);
-
-struct device *bootdv = NULL;
-enum devclass bootdev_class = DV_DULL;
void
unmap_startup(void)
void
cpu_configure(void)
{
- (void)splhigh();
+ splhigh();
softintr_init();
- (void)config_rootfound("mainbus", NULL);
+ config_rootfound("mainbus", NULL);
unmap_startup();
void
diskconf(void)
{
- size_t len;
- char *p;
- dev_t tmpdev;
+#if defined(NFSCLIENT)
extern uint8_t *bootmac;
-
- if (*boot_file != '\0')
- printf("bootfile: %s\n", boot_file);
-
-#if RAMDISK_HOOKS
- bootdv = parsedisk("rd", 2, 0, &tmpdev);
-#endif /* RAMDISK_HOOKS */
- if (bootdv == NULL) {
-
- // boot_file is of the format <device>:/bsd we want the device part
- if ((p = strchr(boot_file, ':')) != NULL)
- len = p - boot_file;
- else
- len = strlen(boot_file);
- bootdv = parsedisk(boot_file, len, 0, &tmpdev);
- }
+ dev_t tmpdev = NODEV;
+#endif
+ struct device *bootdv = NULL;
+ int part = 0;
#if defined(NFSCLIENT)
if (bootmac) {
}
#endif
- if (bootdv != NULL)
- printf("boot device: %s\n", bootdv->dv_xname);
- else
- printf("boot device: lookup %s failed \n", boot_file);
-
- setroot(bootdv, 0, RB_USERREQ);
+ setroot(bootdv, part, RB_USERREQ);
dumpconf();
#ifdef HIBERNATE
*/
#include <sys/param.h>
-#include <sys/timetc.h>
-#include <sys/sched.h>
#include <sys/systm.h>
+#include <sys/sched.h>
#include <sys/proc.h>
#include <sys/sysctl.h>
#include <sys/reboot.h>
#include <sys/buf.h>
#include <sys/termios.h>
#include <sys/sensors.h>
+#include <sys/malloc.h>
#include <sys/syscallargs.h>
#include <sys/stdarg.h>
#include <net/if.h>
#include <uvm/uvm.h>
#include <dev/cons.h>
-#include <dev/clock_subr.h>
#include <dev/ofw/fdt.h>
#include <dev/ofw/openfirm.h>
#include <machine/param.h>
#include <dev/softraidvar.h>
#endif
+extern vaddr_t virtual_avail;
+extern uint64_t esym;
+
char *boot_args = NULL;
-char *boot_file = "";
uint8_t *bootmac = NULL;
-extern uint64_t esym;
-
int stdout_node;
int stdout_speed;
/* the following is used externally (sysctl_hw) */
char machine[] = MACHINE; /* from <machine/param.h> */
-extern todr_chip_handle_t todr_handle;
int safepri = 0;
};
void
-cpu_idle_enter()
+cpu_idle_enter(void)
{
}
void
-cpu_idle_cycle()
+cpu_idle_cycle(void)
{
// Enable interrupts
enable_interrupts();
}
void
-cpu_idle_leave()
+cpu_idle_leave(void)
{
}
+/* Dummy trapframe for proc0. */
+struct trapframe proc0tf;
-// XXX what? - not really used
-struct trapframe proc0tf;
void
-cpu_startup()
+cpu_startup(void)
{
u_int loop;
paddr_t minaddr;
printf("%s", version);
printf("real mem = %lu (%luMB)\n", ptoa(physmem),
- ptoa(physmem)/1024/1024);
+ ptoa(physmem) / 1024 / 1024);
/*
* Allocate a submap for exec arguments. This map effectively
*/
minaddr = vm_map_min(kernel_map);
exec_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
- 16*NCARGS, VM_MAP_PAGEABLE, FALSE, NULL);
-
+ 16 * NCARGS, VM_MAP_PAGEABLE, FALSE, NULL);
/*
* Allocate a submap for physio
bufinit();
printf("avail mem = %lu (%luMB)\n", ptoa(uvmexp.free),
- ptoa(uvmexp.free)/1024/1024);
+ ptoa(uvmexp.free) / 1024 / 1024);
curpcb = &proc0.p_addr->u_pcb;
curpcb->pcb_flags = 0;
}
}
+/*
+ * machine dependent system variables.
+ */
+
int
cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
size_t newlen, struct proc *p)
{
+ char *compatible;
+ int node, len, error;
+
/* all sysctl names at this level are terminal */
if (namelen != 1)
return (ENOTDIR); /* overloaded */
switch (name[0]) {
- // none supported currently
+ case CPU_COMPATIBLE:
+ node = OF_finddevice("/");
+ len = OF_getproplen(node, "compatible");
+ if (len <= 0)
+ return (EOPNOTSUPP);
+ compatible = malloc(len, M_TEMP, M_WAITOK | M_ZERO);
+ OF_getprop(node, "compatible", compatible, len);
+ compatible[len - 1] = 0;
+ error = sysctl_rdstring(oldp, oldlenp, newp, compatible);
+ free(compatible, M_TEMP, len);
+ return error;
default:
return (EOPNOTSUPP);
}
}
-/// XXX ?
/*
* Size of memory segments, before any memory is stolen.
*/
phys_ram_seg_t mem_clusters[VM_PHYSSEG_MAX];
int mem_cluster_cnt;
-/// XXX ?
+
/*
* cpu_dumpsize: calculate size of machine-dependent kernel core dump headers.
*/
}
u_long
-cpu_dump_mempagecnt()
+cpu_dump_mempagecnt(void)
{
return 0;
}
uint32_t mmap_desc_size;
uint32_t mmap_desc_ver;
-void collect_kernel_args(char *);
+void collect_kernel_args(const char *);
void process_kernel_args(void);
void
if (node != NULL) {
char *prop;
int len;
- // static uint8_t lladdr[6]; //not yet used
+ static uint8_t lladdr[6];
len = fdt_node_property(node, "bootargs", &prop);
if (len > 0)
collect_kernel_args(prop);
-#if 0 //CMPE: yet not using these properties
+ len = fdt_node_property(node, "openbsd,boothowto", &prop);
+ if (len == sizeof(boothowto))
+ boothowto = bemtoh32((uint32_t *)prop);
len = fdt_node_property(node, "openbsd,bootduid", &prop);
if (len == sizeof(bootduid))
if (len > 0)
explicit_bzero(prop, len);
+#if 0 //CMPE: yet not using these properties
len = fdt_node_property(node, "openbsd,uefi-mmap-start", &prop);
if (len == sizeof(mmap_start))
mmap_start = bemtoh64((uint64_t *)prop);
len = fdt_node_property(node, "openbsd,uefi-mmap-desc-ver", &prop);
if (len == sizeof(mmap_desc_ver))
mmap_desc_ver = bemtoh32((uint32_t *)prop);
+
len = fdt_node_property(node, "openbsd,uefi-system-table", &prop);
if (len == sizeof(system_table))
system_table = bemtoh64((uint64_t *)prop);
vstart = pmap_bootstrap(kvo, rbp->kern_l1pt,
kernbase, esym, fdt_start, fdt_end, memstart, memend);
- // XX correctly sized?
proc0paddr = (struct user *)rbp->kern_stack;
msgbufaddr = (caddr_t)vstart;
map_func_save = riscv64_bs_tag._space_map;
riscv64_bs_tag._space_map = pmap_bootstrap_bs_map;
- // cninit
consinit();
#ifdef DEBUG_AUTOCONF
riscv64_bs_tag._space_map = map_func_save;
- /* XXX */
pmap_avail_fixup();
uvmexp.pagesize = PAGE_SIZE;
int i;
/*
- * Load all memory marked as EfiConventionalMemory.
+ * Load all memory marked as EfiConventionalMemory,
+ * EfiBootServicesCode or EfiBootServicesData.
* Don't bother with blocks smaller than 64KB. The
* initial 64MB memory block should be marked as
* EfiLoaderData so it won't be added again here.
desc->Type, desc->PhysicalStart,
desc->VirtualStart, desc->NumberOfPages,
desc->Attribute);
- if (desc->Type == EfiConventionalMemory &&
+ if ((desc->Type == EfiConventionalMemory ||
+ desc->Type == EfiBootServicesCode ||
+ desc->Type == EfiBootServicesData) &&
desc->NumberOfPages >= 16) {
uvm_page_physload(atop(desc->PhysicalStart),
atop(desc->PhysicalStart) +
*/
pmap_growkernel(VM_MIN_KERNEL_ADDRESS + 1024 * 1024 * 1024 +
physmem * sizeof(struct vm_page));
+
#ifdef DDB
db_machine_init();
if (boothowto & RB_KDB)
db_enter();
#endif
+
softintr_init();
splraise(IPL_IPI);
}
char bootargs[256];
void
-collect_kernel_args(char *args)
+collect_kernel_args(const char *args)
{
/* Make a local copy of the bootargs */
strlcpy(bootargs, args, sizeof(bootargs));
{
char *cp = bootargs;
- if (cp[0] == '\0') {
- boothowto = RB_AUTOBOOT;
+ if (*cp == 0)
return;
- }
-
- boothowto = 0;
- boot_file = bootargs;
/* Skip the kernel image filename */
while (*cp != ' ' && *cp != 0)
- ++cp;
+ cp++;
if (*cp != 0)
*cp++ = 0;
while (*cp == ' ')
- ++cp;
+ cp++;
boot_args = cp;
- printf("bootfile: %s\n", boot_file);
printf("bootargs: %s\n", boot_args);
/* Setup pointer to boot flags */
if (*cp++ == '\0')
return;
- for (;*++cp;) {
- int fl;
-
- fl = 0;
+ while (*cp != 0) {
switch(*cp) {
case 'a':
- fl |= RB_ASKNAME;
+ boothowto |= RB_ASKNAME;
break;
case 'c':
- fl |= RB_CONFIG;
+ boothowto |= RB_CONFIG;
break;
case 'd':
- fl |= RB_KDB;
+ boothowto |= RB_KDB;
break;
case 's':
- fl |= RB_SINGLE;
+ boothowto |= RB_SINGLE;
break;
default:
printf("unknown option `%c'\n", *cp);
break;
}
- boothowto |= fl;
+ cp++;
}
}
/*
- * allow bootstrap to steal KVA after machdep has given it back to pmap.
- * XXX - need a mechanism to prevent this from being used too early or late.
+ * Allow bootstrap to steal KVA after machdep has given it back to pmap.
*/
int
pmap_bootstrap_bs_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size,
u_long startpa, pa, endpa;
vaddr_t va;
- extern vaddr_t virtual_avail, virtual_end;
-
- va = virtual_avail; // steal memory from virtual avail.
-
- if (va == 0)
- panic("pmap_bootstrap_bs_map, no virtual avail");
+ va = virtual_avail; /* steal memory from virtual avail. */
startpa = trunc_page(bpa);
endpa = round_page((bpa + size));