forked from EtchedPixels/FUZIX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevices.c
43 lines (40 loc) · 1.34 KB
/
devices.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <kernel.h>
#include <version.h>
#include <kdata.h>
#include <devsys.h>
#include <blkdev.h>
#include <tty.h>
#include <devtty.h>
struct devsw dev_tab[] = /* The device driver switch table */
{
// minor open close read write ioctl
// -----------------------------------------------------------------
/* 0: /dev/hd - block device interface */
#ifdef CONFIG_IDE
{ blkdev_open, no_close, blkdev_read, blkdev_write, blkdev_ioctl},
#else
{ no_open, no_close, no_rdwr, no_rdwr, no_ioctl},
#endif
/* 1: /dev/fd - Floppy disk block devices */
#ifdef CONFIG_FLOPPY
{ fd_open, fd_close, fd_read, fd_write, no_ioctl},
#else
{ no_open, no_close, no_rdwr, no_rdwr, no_ioctl},
#endif
/* 2: /dev/tty TTY devices */
{ tty_open, tty_close, tty_read, tty_write, tty_ioctl },
/* 3: /dev/lpr Printer devices */
{ no_open, no_close, no_rdwr, no_rdwr, no_ioctl },
/* 4: /dev/mem etc System devices (one offs) */
{ no_open, no_close, sys_read, sys_write, sys_ioctl },
/* Pack to 7 with nxio if adding private devices and start at 8 */
};
bool validdev(uint16_t dev)
{
/* This is a bit uglier than needed but the right hand side is
a constant this way */
if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
return false;
else
return true;
}