-
Notifications
You must be signed in to change notification settings - Fork 0
/
devices.h
48 lines (37 loc) · 1.27 KB
/
devices.h
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
#ifndef __DEVICES_H__
#define __DEVICES_H__
#define MAX_DEVICES 64
/* devices types */
#define DEVTYPE_CHAR 0
#define DEVTYPE_BLOCK 1
/* Major numbers */
#define DEV_RAMDEV 0
#define DEV_FLOPPY 1
#define DEV_IDE 2
#define DEV_CPMIO 0xFF
/* this crappy interface needs a rewrite */
#define MAX_CACHE_BLOCKS 10
typedef struct _device {
unsigned char name[16];
unsigned char type;
unsigned int maj;
unsigned int min;
unsigned long offset;
unsigned long addr;
unsigned long size;
// int (*seek)();
int (*seek)(struct _device *, uint32_t);
// int (*read)();
int (*read)(struct _device *, unsigned char *, long unsigned int);
// int (*write)();
int (*write)(struct _device *, unsigned char *, long unsigned int);
/* super stupid block cache */
uint32_t cache_index[MAX_CACHE_BLOCKS];
unsigned char cache_blocks[MAX_CACHE_BLOCKS][128];
} _device;
int dev_list();
int dev_register(char *name, int type, int maj, int min, unsigned long addr, unsigned long size,
int (*seek)(struct _device *, uint32_t),
int (*read)(struct _device *, unsigned char *, long unsigned int),
int (*write)(struct _device *, unsigned char *, long unsigned int));
#endif /* __DEVICES_H__ */