示例#1
0
void
OF_init(int (*openfirm)(void *))
{
	phandle_t options;
	char	  mode[sizeof("true")];

	openfirmware = openfirm;

	if ((chosen = OF_finddevice("/chosen")) == -1)
		OF_exit();
	if (OF_getprop(chosen, "memory", &memory, sizeof(memory)) == -1) {
		memory = OF_open("/memory");
		if (memory == -1)
			memory = OF_open("/memory@0");
		if (memory == -1)
			OF_exit();
	}
	if (OF_getprop(chosen, "mmu", &mmu, sizeof(mmu)) == -1)
		OF_exit();

	/*
	 * Check if we run in real mode. If so, we do not need to map
	 * memory later on.
	 */
	options = OF_finddevice("/options");
	if (OF_getprop(options, "real-mode?", mode, sizeof(mode)) > 0 &&
	    strcmp(mode, "true") == 0)
		real_mode = 1;
}
示例#2
0
static vm_offset_t
init_heap(void)
{
	if ((pmemh = OF_finddevice("/memory")) == (phandle_t)-1)
		OF_exit();
	if (OF_getprop(pmemh, "available", memslices, sizeof(memslices)) <= 0)
		OF_exit();

	/* There is no need for continuous physical heap memory. */
	heapva = (vm_offset_t)OF_claim((void *)HEAPVA, HEAPSZ, 32);
	return heapva;
}
示例#3
0
static void
setup(void)
{
	int chosen;

	if ((chosen = OF_finddevice("/chosen")) == -1)
		OF_exit();
	if (OF_getprop(chosen, "stdin", &stdin, sizeof(stdin)) !=
	    sizeof(stdin) ||
	    OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) !=
	    sizeof(stdout))
		OF_exit();
}
示例#4
0
static int
command_halt(int argc, char *argv[])
{

	OF_exit();
	return (CMD_OK);
}
示例#5
0
static void
startup(void *vpd, int res, int (*openfirm)(void *), char *arg, int argl)
{

	openfirmware = openfirm;
	setup();
	main();
	OF_exit();
}
示例#6
0
static int
command_reboot(int argc, char *argv[])
{
	int i;

	for (i = 0; devsw[i] != NULL; ++i)
		if (devsw[i]->dv_cleanup != NULL)
			(devsw[i]->dv_cleanup)();

	printf("Rebooting...\n");
	OF_exit();
}
示例#7
0
static void
parseargs(char *str, int *howtop)
{
	char *cp;

	/* Allow user to drop back to the PROM. */
	if (strcmp(str, "exit") == 0)
		OF_exit();

	*howtop = 0;

	for (cp = str; *cp; cp++)
		if (*cp == ' ' || *cp == '-')
			goto found;
	
	return;

 found:
	*cp++ = '\0';
	while (*cp)
		BOOT_FLAG(*cp++, *howtop);
}
示例#8
0
void
exit(int code)
{
	OF_exit();
}
示例#9
0
int
main(int (*openfirm)(void *))
{
	phandle_t	root;
	int		i;
	char		bootpath[64];
	char		*ch;
	int		bargc;
	char		**bargv;

	/*
	 * Initialize the Open Firmware routines by giving them the entry point.
	 */
	OF_init(openfirm);

	root = OF_finddevice("/");

	scells = acells = 1;
	OF_getprop(root, "#address-cells", &acells, sizeof(acells));
	OF_getprop(root, "#size-cells", &scells, sizeof(scells));

	/*
	 * Initialise the heap as early as possible.  Once this is done,
	 * alloc() is usable. The stack is buried inside us, so this is
	 * safe.
	 */
	init_heap();

	/*
         * Set up console.
         */
	cons_probe();

	/*
	 * March through the device switch probing for things.
	 */
	for (i = 0; devsw[i] != NULL; i++)
		if (devsw[i]->dv_init != NULL)
			(devsw[i]->dv_init)();

	printf("\n");
	printf("%s, Revision %s\n", bootprog_name, bootprog_rev);
	printf("(%s, %s)\n", bootprog_maker, bootprog_date);
	printf("Memory: %lldKB\n", memsize() / 1024);

	OF_getprop(chosen, "bootpath", bootpath, 64);
	ch = strchr(bootpath, ':');
	*ch = '\0';
	printf("Booted from: %s\n", bootpath);

	printf("\n");

	/*
	 * Only parse the first bootarg if present. It should
	 * be simple to handle extra arguments
	 */
	OF_getprop(chosen, "bootargs", bootargs, sizeof(bootargs));
	bargc = 0;
	parse(&bargc, &bargv, bootargs);
	if (bargc == 1)
		env_setenv("currdev", EV_VOLATILE, bargv[0], ofw_setcurrdev,
		    env_nounset);
	else
		env_setenv("currdev", EV_VOLATILE, bootpath,
			   ofw_setcurrdev, env_nounset);
	env_setenv("loaddev", EV_VOLATILE, bootpath, env_noset,
	    env_nounset);
	setenv("LINES", "24", 1);		/* optional */

	archsw.arch_getdev = ofw_getdev;
	archsw.arch_copyin = ofw_copyin;
	archsw.arch_copyout = ofw_copyout;
	archsw.arch_readin = ofw_readin;
	archsw.arch_autoload = ofw_autoload;

	interact(NULL);				/* doesn't return */

	OF_exit();

	return 0;
}
void
ppc_exit(void)
{
	OF_exit();
}
示例#11
0
void
main(void)
{
	extern char bootprog_name[], bootprog_rev[];
	int chosen;
	char bootline[512];		/* Should check size? */
	char *cp, *startbuf, *endbuf;
	u_long marks[MARK_MAX], size;
	u_int32_t entry;
	void *ssym, *esym;

	printf("\n");
	printf(">> %s, Revision %s\n", bootprog_name, bootprog_rev);

	/*
	 * Get the boot arguments from Openfirmware
	 */
	if ((chosen = OF_finddevice("/chosen")) == -1 ||
	    OF_getprop(chosen, "bootpath", bootdev, sizeof bootdev) < 0 ||
	    OF_getprop(chosen, "bootargs", bootline, sizeof bootline) < 0) {
		printf("Invalid Openfirmware environment\n");
		OF_exit();
	}

	prom2boot(bootdev);
	parseargs(bootline, &boothowto);
	DPRINTF("bootline=%s\n", bootline);

	/*
	 * Per the ARM OpenFirmware bindings, the firmware must
	 * allocate and map at least 6MB of physical memory starting
	 * at VA 0xf0000000.  We have been loaded at 0xf0000000,
	 * and the memory after us has been unmapped and freed.
	 * We expect to load the kernel at 0xf0100000, so we will
	 * allocate 5MB of virtual memory starting there, and
	 * unmap/free what we don't use.
	 */
	startbuf = OF_claim((void *) 0xf0100000, (5 * 1024 * 1024), 0);
	if (startbuf != (void *) 0xf0100000) {
		printf("Unable to claim buffer for kernel\n");
		OF_exit();
	}
	endbuf = startbuf + (5 * 1024 * 1024);

	for (;;) {
		int i;

		if (boothowto & RB_ASKNAME) {
			printf("Boot: ");
			gets(bootline);
			parseargs(bootline, &boothowto);
		}

		if (bootline[0]) {
			kernels[0] = bootline;
			kernels[1] = NULL;
		}

		for (i = 0; kernels[i]; i++) {
			DPRINTF("Trying %s\n", kernels[i]);

			marks[MARK_START] = 0xf0100000;
			if (loadfile(kernels[i], marks, LOAD_KERNEL) >= 0)
				goto loaded;
		}

		boothowto |= RB_ASKNAME;
	}
 loaded:
	/*
	 * Okay, kernel is loaded, free the extra memory at the end.
	 * Round to the ARM OpenFirmare page size (4k).
	 */
	cp = (char *) ((marks[MARK_END] + 0xfff) & ~0xfff);
	size = (u_long) (endbuf - cp);
	if (size)
		OF_release(cp, size);

#ifdef	__notyet__
	OF_setprop(chosen, "bootpath", opened_name, strlen(opened_name) + 1);
	cp = bootline;
#else
	strcpy(bootline, opened_name);
	cp = bootline + strlen(bootline);
	*cp++ = ' ';
#endif
	*cp = '-';
	if (boothowto & RB_ASKNAME)
		*++cp = 'a';
	if (boothowto & RB_SINGLE)
		*++cp = 's';
	if (boothowto & RB_KDB)
		*++cp = 'd';
	if (*cp == '-')
#ifdef	__notyet__
		*cp = 0;
#else
		*--cp = 0;
#endif
	else
示例#12
0
__dead void
_rtt(void)
{

	OF_exit();
}