forked from EtchedPixels/FUZIX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevices.c
36 lines (33 loc) · 1.08 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
#include <kernel.h>
#include <version.h>
#include <kdata.h>
#include <tty.h>
#include <devsys.h>
#include <devtty.h>
#include <devsd.h>
#include <blkdev.h>
#include <ds1302.h>
#include "n8.h"
struct devsw dev_tab[] = /* The device driver switch table */
{
/* open close read write ioctl */
{ blkdev_open, no_close, blkdev_read, blkdev_write, blkdev_ioctl }, /* 0: /dev/hd -- standard block device interface */
{ no_open, no_close, no_rdwr, no_rdwr, no_ioctl }, /* 1: unused slot */
{ tty_open, n8tty_close,tty_read, tty_write, n8tty_ioctl }, /* 2: /dev/tty -- serial ports */
{ no_open, no_close, no_rdwr, no_rdwr, no_ioctl }, /* 3: /dev/rd? */
{ no_open, no_close, sys_read, sys_write, sys_ioctl }, /* 4: /dev/mem etc System devices (one offs) */
};
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;
}
void device_init(void)
{
devsd_init();
ds1302_init();
}