forked from EtchedPixels/FUZIX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevices.c
48 lines (45 loc) · 1.47 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
43
44
45
46
47
48
#include <kernel.h>
#include <version.h>
#include <kdata.h>
#include <devfd.h>
#include <blkdev.h>
#include <devide.h>
#include <devfhd.h>
#include <devsys.h>
#include <devlpr.h>
#include <devtty.h>
#include <tty.h>
#include <vt.h>
struct devsw dev_tab[] = /* The device driver switch table */
{
// minor open close read write ioctl
// -----------------------------------------------------------------
/* 0: /dev/hd Hard disc block devices (UIDE or FIDHD) */
{ blkdev_open, no_close, blkdev_read, blkdev_write, blkdev_ioctl }, /* 0: /dev/hd -- standard block device interface */
/* 1: /dev/fd Floppy disc block devices */
{ fd_open, no_close, fd_read, fd_write, no_ioctl },
/* 2: /dev/tty TTY devices */
{ tty_open, tty_close, tty_read, tty_write, vt_ioctl },
/* 3: /dev/lpr Printer devices */
{ lpr_open, lpr_close, no_rdwr, lpr_write, 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;
}
void device_init(void)
{
tty_init_port();
fd_probe();
/* See what we are attaching */
if (devfhd_init() == 0)
devide_init();
}