/*
 * miscdev.c
 *
 * Copyright 2003, Minoru Murashima. All rights reserved.
 * Distributed under the terms of the BSD License.
 *
 * その他のデバイスドライバー
 */


#include <types.h>
#include <sys/param.h>
#include <device.h>
#include <sys/conf.h>


/************************************************************************************************
 *
 * Null device class
 *
 * 何もしない。
 *
 ************************************************************************************************/

static int open(dev_t dev, int oflags, int devtype, d_thread_t *proc)
{
	return 0;
}


static int close(dev_t dev, int fflag, int devtype, d_thread_t *proc)
{
	return 0;
}


static int read(dev_t dev, struct uio *uio, int ioflag)
{
	return 0;
}


static int write(dev_t dev, struct uio *uio, int ioflag)
{
	return 0;
}


static int ioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, d_thread_t *p)
{
	return 0;
}


static int poll(dev_t dev, int events, d_thread_t *p)
{
	return POLLIN | POLLRDNORM | POLLOUT | POLLWRNORM;
}


static struct cdevsw devsw = {
	open, 
	close, 
	read, 
	write, 
	ioctl, 
	poll, 
	NULL, 
	NULL, 
	"null",
	0,
	NULL, 
	NULL, 
	D_MEM,
};


int registNullDev()
{
	if (make_dev(&devsw, 0, 0, 0, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, "null") == NODEV){
		return -ENODEV;
	}
	return 0;
}
