Esempio n. 1
0
/*
 * Function to create and attach null:
 */
void
devnull_create(void)
{
	int result;
	struct device *dev;

	dev = kmalloc(sizeof(*dev));
	if (dev==NULL) {
		panic("Could not add null device: out of memory\n");
	}

	
	dev->d_open = nullopen;
	dev->d_close = nullclose;
	dev->d_io = nullio;
	dev->d_ioctl = nullioctl;

	dev->d_blocks = 0;
	dev->d_blocksize = 1;

	dev->d_data = NULL;

	result = vfs_adddev("null", dev, 0);
	if (result) {
		panic("Could not add null device: %s\n", strerror(result));
	}
}
Esempio n. 2
0
/*
 * Setup routine called by autoconf.c when an lhd is found.
 */
int
config_lhd(struct lhd_softc *lh, int lhdno)
{
	char name[32];

	/* Figure out what our name is. */
	snprintf(name, sizeof(name), "lhd%d", lhdno);

	/* Get a pointer to the on-chip buffer. */
	lh->lh_buf = bus_map_area(lh->lh_busdata, lh->lh_buspos, LHD_BUFFER);

	/* Create the semaphores. */
	lh->lh_clear = sem_create("lhd-clear", 1);
	if (lh->lh_clear == NULL) {
		return ENOMEM;
	}
	lh->lh_done = sem_create("lhd-done", 0);
	if (lh->lh_done == NULL) {
		sem_destroy(lh->lh_clear);
		lh->lh_clear = NULL;
		return ENOMEM;
	}

	/* Set up the VFS device structure. */
	lh->lh_dev.d_ops = &lhd_devops;
	lh->lh_dev.d_blocks = bus_read_register(lh->lh_busdata, lh->lh_buspos,
						LHD_REG_NSECT);
	lh->lh_dev.d_blocksize = LHD_SECTSIZE;
	lh->lh_dev.d_data = lh;

	/* Add the VFS device structure to the VFS device list. */
	return vfs_adddev(name, &lh->lh_dev, 1);
}
Esempio n. 3
0
static
int
attach_console_to_vfs(struct con_softc *cs)
{
	struct device *dev;
	int result;

	dev = kmalloc(sizeof(*dev));
	if (dev==NULL) {
		return ENOMEM;
	}

	dev->d_ops = &console_devops;
	dev->d_blocks = 0;
	dev->d_blocksize = 1;
	dev->d_data = cs;

	result = vfs_adddev("con", dev, 0);
	if (result) {
		kfree(dev);
		return result;
	}

	return 0;
}
Esempio n. 4
0
/*
 * Function to create and attach null:
 */
void
devnull_create(void)
{
	int result;
	struct device *dev;

	dev = kmalloc(sizeof(*dev));
	if (dev==NULL) {
		panic("Could not add null device: out of memory\n");
	}

	dev->d_ops = &null_devops;

	dev->d_blocks = 0;
	dev->d_blocksize = 1;

	dev->d_devnumber = 0; /* assigned by vfs_adddev */

	dev->d_data = NULL;

	result = vfs_adddev("null", dev, 0);
	if (result) {
		panic("Could not add null device: %s\n", strerror(result));
	}
}