int
devopen(struct open_file *f, const char *fname, char **file)
{
	struct devsw   *dp;
	int             error = 0;

	dp = &devsw[0];
	f->f_dev = dp;

	if(fname)
		strncpy(bootfile, fname, FNAME_SIZE);

	error = net_open(f);

	if (bootfile[0])
		*file = bootfile;
	else
		*file = (char *) fname;

#ifdef _STANDALONE
	strncpy(bibp.bootpath, *file, sizeof(bibp.bootpath));
	BI_ADD(&bibp, BTINFO_BOOTPATH, sizeof(bibp));
#endif

	return (error);
}
示例#2
0
void
bi_getmemmap()
{
    int buf[5], i, nranges, n;
    struct btinfo_memmap *bimm;

    nranges = 0;
    i = 0;
    do {
        if (getmementry(&i, buf))
            break;
        nranges++;
    } while (i);

    bimm = alloc(sizeof(struct btinfo_memmap)
                 + (nranges - 1) * sizeof(struct bi_memmap_entry));

    i = 0;
    for (n = 0; n < nranges; n++) {
        getmementry(&i, buf);
        memcpy(&bimm->entry[n], buf, sizeof(struct bi_memmap_entry));
    }
    bimm->num = nranges;

    BI_ADD(bimm, BTINFO_MEMMAP, sizeof(struct btinfo_memmap)
           + (nranges - 1) * sizeof(struct bi_memmap_entry));
}
示例#3
0
int
EtherInit(unsigned char *myadr)
{
	int iobase, dmachan, i;

	if (isapnp_finddev(ISAPNPID, &iobase, &dmachan)) {
		printf("cannot find PCNET\n");
		return 0;
	}

	printf("printf using PCNET @ %x\n", iobase);

	lance_rap = iobase + 0x12;
	lance_rdp = iobase + 0x10;

	/* make sure it's stopped */
	am7990_stop();

	for (i = 0; i < 6; i++)
		myadr[i] = eth_myaddr[i] = inb(iobase + i);

	isa_dmacascade(dmachan);

	am7990_init();

	strncpy(bi_netif.ifname, "le", sizeof(bi_netif.ifname));
	bi_netif.bus = BI_BUS_ISA;
	bi_netif.addr.iobase = iobase;

	BI_ADD(&bi_netif, BTINFO_NETIF, sizeof(bi_netif));

	return 1;
}
示例#4
0
void
consinit(int dev, int speed)
{
	struct linux_termios termios;
	int fd;

	switch (dev) {
	case CONSDEV_COM0:
		iodev = dev;
		break;

	case CONSDEV_GLASS:
	default:
 glass_console:
		iodev = CONSDEV_GLASS;
		break;
	}

	if (infd >= 0 && infd == outfd) {
		uclose(infd);
		infd = 0;
		outfd = 1;
	}

	if (iodev == CONSDEV_GLASS) {
		infd = 0;
		outfd = 1;

		strlcpy(bi_cons.devname, "glass", sizeof(bi_cons.devname));
		bi_cons.addr = -1;
		bi_cons.speed = -1;
	} else {
		fd = uopen(comdevname[iodev - CONSDEV_COM0], LINUX_O_RDWR);
		if (fd < 0)
			goto glass_console;
		infd = outfd = fd;

		/* set speed */
		linux_tcgetattr(fd, &termios);
		if (linux_cfsetspeed(&termios, speed) < 0) {
			speed = 9600;
			if (linux_cfsetspeed(&termios, speed) < 0)
				goto glass_console;
		}
		if (linux_tcsetattr(fd, LINUX_TCSETS, &termios) < 0)
			goto glass_console;

		snprintf(bi_cons.devname, sizeof(bi_cons.devname), "com%d",
		    iodev - CONSDEV_COM0);
		bi_cons.addr = -1;
		bi_cons.speed = speed;
	}
	BI_ADD(&bi_cons, BTINFO_CONSDEV, sizeof(bi_cons));
}
示例#5
0
文件: biosdisk.c 项目: Hooman3/minix
static void
add_biosdisk_bootinfo(void)
{
	static bool done;

	if (bootinfo == NULL) {
		done = false;
		return;
	}
	
	if (done)
		return;

	BI_ADD(&bi_disk, BTINFO_BOOTDISK, sizeof(bi_disk));
	BI_ADD(&bi_wedge, BTINFO_BOOTWEDGE, sizeof(bi_wedge));

	done = true;

	return;
}
示例#6
0
文件: boot.c 项目: ryo/netbsd-src
static int
exec_netbsd(const char *file, int howto)
{
	u_long marks[MARK_MAX];

	BI_ALLOC(BTINFO_MAX);

	bi_howto.howto = howto;
	BI_ADD(&bi_howto, BTINFO_HOWTO, sizeof(bi_howto));

	if (loadfile_zboot(file, marks, LOAD_KERNEL) == -1)
		goto out;

	/*NOTREACHED*/
	return 0;

out:
	BI_FREE();
	bootinfo = 0;
	return -1;
}
示例#7
0
void bi_getbiosgeom()
{
	struct btinfo_biosgeom *bibg;
	int i, j, nvalid;
	unsigned char nhd;
	unsigned int cksum;

	pvbcopy((void *)(0x400 + 0x75), &nhd, 1);
#ifdef GEOM_DEBUG
	printf("nhd %d\n", (int)nhd);
#endif

	bibg = alloc(sizeof(struct btinfo_biosgeom)
		     + (nhd - 1) * sizeof(struct bi_biosgeom_entry));
	if (!bibg)
		return;

	for (i = nvalid = 0; i < MAX_BIOSDISKS && nvalid < (int)nhd; i++) {
		struct biosdisk_ll d;
		struct biosdisk_ext13info ed;
		char buf[BIOSDISK_SECSIZE];

		d.dev = 0x80 + i;

		if (set_geometry(&d, &ed))
			continue;
		bzero(&bibg->disk[nvalid], sizeof(bibg->disk[nvalid]));

		bibg->disk[nvalid].sec = d.sec;
		bibg->disk[nvalid].head = d.head;
		bibg->disk[nvalid].cyl = d.cyl;
		bibg->disk[nvalid].dev = d.dev;

		if (readsects(&d, 0, 1, buf, 0)) {
			bibg->disk[nvalid].flags |= BI_GEOM_INVALID;
			nvalid++;
			continue;
		}

#ifdef GEOM_DEBUG
		printf("#%d: %x: C %d H %d S %d\n", nvalid,
		    d.dev, d.cyl, d.head, d.sec);
#endif

		if (d.flags & BIOSDISK_EXT13) {
			if (ed.flags & EXT13_GEOM_VALID)
				bibg->disk[nvalid].totsec = ed.totsec;
			else
				bibg->disk[nvalid].totsec = 0;
			bibg->disk[nvalid].flags |= BI_GEOM_EXTINT13;
		}
		for (j = 0, cksum = 0; j < BIOSDISK_SECSIZE; j++)
			cksum += buf[j];
		bibg->disk[nvalid].cksum = cksum;
		bcopy(&buf[MBR_PARTOFF], bibg->disk[nvalid].dosparts,
		      sizeof(bibg->disk[nvalid].dosparts));
		nvalid++;
	}

	bibg->num = nvalid;

	BI_ADD(bibg, BTINFO_BIOSGEOM, sizeof(struct btinfo_biosgeom)
	       + nvalid * sizeof(struct bi_biosgeom_entry));
}
示例#8
0
文件: exec.c 项目: DragonQuan/minix3
int
exec_netbsd(const char *file, physaddr_t loadaddr, int boothowto, int floppy,
	    void (*callback)(void))
{
	u_long          boot_argv[BOOT_NARGS];
	u_long		marks[MARK_MAX];
	struct btinfo_symtab btinfo_symtab;
	u_long		extmem;
	u_long		basemem;

#ifdef	DEBUG
	printf("exec: file=%s loadaddr=0x%lx\n",
	       file ? file : "NULL", loadaddr);
#endif

	BI_ALLOC(32); /* ??? */

	BI_ADD(&btinfo_console, BTINFO_CONSOLE, sizeof(struct btinfo_console));

	howto = boothowto;

	if (common_load_kernel(file, &basemem, &extmem, loadaddr, floppy, marks))
		goto out;

	boot_argv[0] = boothowto;
	boot_argv[1] = 0;
	boot_argv[2] = vtophys(bootinfo);	/* old cyl offset */
	boot_argv[3] = marks[MARK_END];
	boot_argv[4] = extmem;
	boot_argv[5] = basemem;

	/* pull in any modules if necessary */
	if (boot_modules_enabled) {
		module_init(file);
		if (btinfo_modulelist) {
			BI_ADD(btinfo_modulelist, BTINFO_MODULELIST,
			    btinfo_modulelist_size);
		}
	}

	userconf_init();
	if (btinfo_userconfcommands != NULL)
		BI_ADD(btinfo_userconfcommands, BTINFO_USERCONFCOMMANDS,
	btinfo_userconfcommands_size);

#ifdef DEBUG
	printf("Start @ 0x%lx [%ld=0x%lx-0x%lx]...\n", marks[MARK_ENTRY],
	    marks[MARK_NSYM], marks[MARK_SYM], marks[MARK_END]);
#endif

	btinfo_symtab.nsym = marks[MARK_NSYM];
	btinfo_symtab.ssym = marks[MARK_SYM];
	btinfo_symtab.esym = marks[MARK_END];
	BI_ADD(&btinfo_symtab, BTINFO_SYMTAB, sizeof(struct btinfo_symtab));

	/* set new video mode if necessary */
	vbe_commit();
	BI_ADD(&btinfo_framebuffer, BTINFO_FRAMEBUFFER,
	    sizeof(struct btinfo_framebuffer));

	if (callback != NULL)
		(*callback)();
	startprog(marks[MARK_ENTRY], BOOT_NARGS, boot_argv,
		  x86_trunc_page(basemem*1024));
	panic("exec returned");

out:
	BI_FREE();
	bootinfo = 0;
	return -1;
}
示例#9
0
int
EtherInit(unsigned char *myadr)
{
	uint32_t pcicsr;
	uint16_t val;
	volatile struct ex_upd *upd;
#ifndef _STANDALONE
	uint32_t id;
#endif

	if (pcicheck()) {
		printf("pcicheck failed\n");
		return 0;
	}
#ifndef _STANDALONE
	pcicfgread(&mytag, 0, &id);
#endif
	for (excard = &excards[0]; excard->did != -1; excard++) {
#ifdef _STANDALONE
		if (pcifinddev(0x10b7, excard->did, &mytag) == 0)
			goto found;
#else
		if (id == (0x10b7 | (excard->did << 16)))
			goto found;
#endif
	}
	printf("no ex\n");
	return 0;

found:
	pcicfgread(&mytag, 0x10, &iobase);
	iobase &= ~3;

#ifndef _STANDALONE
	dmamem = mapmem(DMABASE, DMASIZE);
	if (!dmamem)
		return 0;
#endif

	/* enable bus mastering in PCI command register */
	if (pcicfgread(&mytag, 0x04, (int *)&pcicsr)
	    || pcicfgwrite(&mytag, 0x04, pcicsr | 4)) {
		printf("cannot enable DMA\n");
		return 0;
	}

	ex_reset();

	if (excard->mii)
		ether_medium = ETHERMEDIUM_MII;
	else {
		ex_probemedia();
		if (ether_medium < 0)
			return 0;
	}

	val = ex_read_eeprom(EEPROM_OEM_ADDR0);
	myethaddr[0] = val >> 8;
	myethaddr[1] = val & 0xff;
	val = ex_read_eeprom(EEPROM_OEM_ADDR1);
	myethaddr[2] = val >> 8;
	myethaddr[3] = val & 0xff;
	val = ex_read_eeprom(EEPROM_OEM_ADDR2);
	myethaddr[4] = val >> 8;
	myethaddr[5] = val & 0xff;
	memcpy(myadr, myethaddr, 6);

	upd = RECVBUF_VIRT;
	upd->upd_nextptr = RECVBUF_PHYS;
	upd->upd_pktstatus = 1500;
	upd->upd_frags[0].fr_addr = RECVBUF_PHYS + 100;
	upd->upd_frags[0].fr_len = 1500 | EX_FR_LAST;

	ex_init();

#if defined(_STANDALONE) && !defined(SUPPORT_NO_NETBSD)
	strncpy(bi_netif.ifname, "ex", sizeof(bi_netif.ifname));
	bi_netif.bus = BI_BUS_PCI;
	bi_netif.addr.tag = mytag;

	BI_ADD(&bi_netif, BTINFO_NETIF, sizeof(bi_netif));
#endif

	return 1;
}