-
Notifications
You must be signed in to change notification settings - Fork 10
/
devicefile.c
53 lines (42 loc) · 916 Bytes
/
devicefile.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
49
50
51
52
53
// Console input and output.
// Input is from the keyboard or serial port.
// Output is written to the screen and serial port.
#include <sys/types.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <xv6/param.h>
#include <xv6/fs.h>
#include <termios.h>
#include "defs.h"
#include "traps.h"
#include "spinlock.h"
#include "memlayout.h"
#include "mmu.h"
#include "proc.h"
#include "gaia.h"
extern char _binary__min_rt_start[];
extern char _binary__min_rt_size[];
int
minrtread(struct inode *ip, char *dst, int n)
{
static unsigned offset = 0;
unsigned sz = *(int*)(_binary__min_rt_start);
int i;
for(i=0; i<n; ++i) {
dst[i] = _binary__min_rt_start[offset];
offset = (offset + 1) % ((unsigned)_binary__min_rt_size);
}
return n;
}
void
minrtinit(void)
{
devsw[MINRT].write = 0;
devsw[MINRT].read = minrtread;
devsw[MINRT].ioctl = 0;
}
void
deviceinit(void)
{
minrtinit();
}