Ejemplo n.º 1
0
int 
main(void)
{
	struct open_file	f;
	void	*entry;
	char	*addr;
	int error;

#ifdef DEBUG
	printf("bootxx: open...\n");
#endif
	f.f_flags = F_RAW;
	if (devopen(&f, 0, &addr)) {
		putstr("bootxx: devopen failed\n");
		return 1;
	}

	addr = (char*)LOADADDR;
	error = copyboot(&f, addr);
	f.f_dev->dv_close(&f);
	if (!error) {
#ifdef DEBUG
		printf("bootxx: start 0x%x\n", (long)addr);
#endif
		entry = addr;
		chain_to(entry);
	}
	/* copyboot had a problem... */
	return 0;
}
Ejemplo n.º 2
0
void
xxboot_main(const char *boot_type)
{
	struct open_file	f;
	char **npp;
	char *file;
	void *entry;
	int fd;
	u_long marks[MARK_MAX];

	memset(marks, 0, sizeof(marks));
	if (_is2)
		marks[MARK_START] = sun2_map_mem_load();
	printf(">> %s %s [%s]\n", bootprog_name, boot_type, bootprog_rev);
	prom_get_boot_info();

	/*
	 * Hold the raw device open so it will not be
	 * closed and reopened on every attempt to
	 * load files that did not exist.
	 */
	f.f_flags = F_RAW;
	if (devopen(&f, 0, &file)) {
		printf("%s: devopen failed\n", boot_type);
		return;
	}

	/*
	 * Edit the "extended" kernel name based on
	 * the type of machine we are running on.
	 */
	if (_is2)
		extname[EXTNAMEX - 1] = '2';
	if (_is3x == 0)
		extname[EXTNAMEX] = 0;

	/* If we got the "-a" flag, ask for the name. */
	if (prom_boothow & RB_ASKNAME)
		goto just_ask;

	/*
	 * If the PROM gave us a file name,
	 * it means the user asked for that
	 * kernel name explicitly.
	 */
	file = prom_bootfile;
	if (file && *file) {
		fd = loadfile(file, marks, LOAD_KERNEL);
		if (fd == -1) {
			goto err;
		} else {
			goto gotit;
		}
	}

	/*
	 * Try the default kernel names.
	 */
	for (npp = kernelnames; *npp; npp++) {
		file = *npp;
		printf("%s: trying %s\n", boot_type, file);
		fd = loadfile(file, marks, LOAD_KERNEL);
		if (fd != -1)
			goto gotit;
	}

	/*
	 * Ask what kernel name to load.
	 */
	for (;;) {

	just_ask:
		file = kernelnames[0];
		printf("filename? [%s]: ", file);
		gets(line);
		if (line[0])
			file = line;

		fd = loadfile(file, marks, LOAD_KERNEL);
		if (fd != -1)
			break;

	err:
		printf("%s: %s: loadfile() failed.\n", boot_type, file);
	}

gotit:
	entry = (void *)marks[MARK_ENTRY];
	if (_is2) {
		printf("relocating program...");
		entry = sun2_map_mem_run(entry);
	}
	printf("starting program at 0x%x\n", entry);
	chain_to(entry);
}
Ejemplo n.º 3
0
int
main(void)
{
    char *cp, *file;
    void *entry;
    u_long marks[MARK_MAX];
    u_long mark_start;
    int fd;

    printf(">> %s tapeboot [%s]\n", bootprog_name, bootprog_rev);
    prom_get_boot_info();

    /*
     * Can not hold open the tape device as is done
     * in the other boot programs because it does
     * its position-to-segment on open.
     */

    /* Assume the Sun3/Sun3x load start. */
    memset(marks, 0, sizeof(marks));
    mark_start = 0;

    /* If running on a Sun3X, use segment 2. */
    if (_is3x)
        defname[0] = '2';

    /*
     * If running on a Sun2, use segment 4 and
     * do the special MMU setup.
     */
    else if (_is2) {
        defname[0] = '4';
        mark_start = sun2_map_mem_load();
    }

    file = defname;

    cp = prom_bootfile;
    if (cp && *cp)
        file = cp;

    for (;;) {
        if (prom_boothow & RB_ASKNAME) {
            printf("tapeboot: segment? [%s]: ", defname);
            gets(line);
            if (line[0])
                file = line;
            else
                file = defname;
        } else
            printf("tapeboot: loading segment %s\n", file);

        marks[MARK_START] = mark_start;
        if ((fd = loadfile(file, marks,
                           LOAD_KERNEL & ~LOAD_BACKWARDS)) != -1) {
            break;
        }
        printf("tapeboot: segment %s: %s\n", file, strerror(errno));
        prom_boothow |= RB_ASKNAME;
    }
    close(fd);

    entry = (void *)marks[MARK_ENTRY];
    if (_is2) {
        printf("relocating program...");
        entry = sun2_map_mem_run(entry);
    }
    printf("Starting program at 0x%x\n", (u_int)entry);
    chain_to(entry);

    return 0;
}