|
|
1.1 root 1: #include "u.h"
2: #include "../port/lib.h"
3: #include "mem.h"
4: #include "dat.h"
5: #include "fns.h"
6: #include "../port/error.h"
7: #include "devtab.h"
8:
9: enum{
10: Qdir,
11: Qboot,
12: Qmem,
13: };
14:
15: Dirtab bootdir[]={
16: "boot", {Qboot}, 0, 0666,
17: "mem", {Qmem}, 0, 0666,
18: };
19:
20: #define NBOOT (sizeof bootdir/sizeof(Dirtab))
21:
22: void
23: bootreset(void)
24: {
25: }
26:
27: void
28: bootinit(void)
29: {
30: }
31:
32: Chan*
33: bootattach(char *spec)
34: {
35: return devattach('B', spec);
36: }
37:
38: Chan*
39: bootclone(Chan *c, Chan *nc)
40: {
41: return devclone(c, nc);
42: }
43:
44: int
45: bootwalk(Chan *c, char *name)
46: {
47: return devwalk(c, name, bootdir, NBOOT, devgen);
48: }
49:
50: void
51: bootstat(Chan *c, char *dp)
52: {
53: devstat(c, dp, bootdir, NBOOT, devgen);
54: }
55:
56: Chan*
57: bootopen(Chan *c, int omode)
58: {
59: return devopen(c, omode, bootdir, NBOOT, devgen);
60: }
61:
62: void
63: bootcreate(Chan *c, char *name, int omode, ulong perm)
64: {
65: USED(c, name, omode, perm);
66: error(Eperm);
67: }
68:
69: void
70: bootclose(Chan *c)
71: {
72: USED(c);
73: }
74:
75: long
76: bootread(Chan *c, void *buf, long n, ulong offset)
77: {
78: switch(c->qid.path & ~CHDIR){
79:
80: case Qdir:
81: return devdirread(c, buf, n, bootdir, NBOOT, devgen);
82:
83: case Qmem:
84: /* kernel memory */
85: if(offset>=KZERO && offset<KZERO+conf.npage*BY2PG){
86: if(offset+n > KZERO+conf.npage*BY2PG)
87: n = KZERO+conf.npage*BY2PG - offset;
88: memmove(buf, (char*)offset, n);
89: return n;
90: }
91: error(Ebadarg);
92: }
93:
94: error(Egreg);
95: return 0; /* not reached */
96: }
97:
98: long
99: bootwrite(Chan *c, void *buf, long n, ulong offset)
100: {
101: ulong pc;
102:
103: switch(c->qid.path & ~CHDIR){
104: case Qmem:
105: /* kernel memory */
106: if(offset>=KZERO && offset<KZERO+conf.npage*BY2PG){
107: if(offset+n > KZERO+conf.npage*BY2PG)
108: n = KZERO+conf.npage*BY2PG - offset;
109: memmove((char*)offset, buf, n);
110: return n;
111: }
112: error(Ebadarg);
113:
114: case Qboot:
115: pc = *(ulong*)buf;
116: splhi();
117: gotopc(pc);
118: }
119: error(Ebadarg);
120: return 0; /* not reached */
121: }
122:
123: void
124: bootremove(Chan *c)
125: {
126: USED(c);
127: error(Eperm);
128: }
129:
130: void
131: bootwstat(Chan *c, char *dp)
132: {
133: USED(c, dp);
134: error(Eperm);
135: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.