This source file includes following definitions.
- ideinit
- ideintr
- iderw
1
2
3
4 #include "types.h"
5 #include "defs.h"
6 #include "param.h"
7 #include "mmu.h"
8 #include "proc.h"
9 #include "x86.h"
10 #include "traps.h"
11 #include "spinlock.h"
12 #include "sleeplock.h"
13 #include "fs.h"
14 #include "buf.h"
15
16 extern uchar _binary_fs_img_start[], _binary_fs_img_size[];
17
18 static int disksize;
19 static uchar *memdisk;
20
21 void
22 ideinit(void)
23 {
24 memdisk = _binary_fs_img_start;
25 disksize = (uint)_binary_fs_img_size/BSIZE;
26 }
27
28
29 void
30 ideintr(void)
31 {
32
33 }
34
35
36
37
38 void
39 iderw(struct buf *b)
40 {
41 uchar *p;
42
43 if(!holdingsleep(&b->lock))
44 panic("iderw: buf not locked");
45 if((b->flags & (B_VALID|B_DIRTY)) == B_VALID)
46 panic("iderw: nothing to do");
47 if(b->dev != 1)
48 panic("iderw: request not for disk 1");
49 if(b->blockno >= disksize)
50 panic("iderw: block out of range");
51
52 p = memdisk + b->blockno*BSIZE;
53
54 if(b->flags & B_DIRTY){
55 b->flags &= ~B_DIRTY;
56 memmove(p, b->data, BSIZE);
57 } else
58 memmove(b->data, p, BSIZE);
59 b->flags |= B_VALID;
60 }