Research V5 development
[unix-history] / usr / sys / dmr / mem.c
CommitLineData
ad970875
DR
1#
2/*
3 * Copyright 1973 Bell Telephone Laboratories Inc
4 */
5
6/*
7 * Memory special file
8 * minor device 0 is physical memory
9 * minor device 1 is kernel memory
10 * minor device 2 is EOF/RATHOLE
11 */
12
13#include "../param.h"
14#include "../user.h"
15#include "../conf.h"
16#include "../seg.h"
17
18mmread(dev)
19{
20 register c, bn, on;
21 int a;
22
23 if(dev.d_minor == 2)
24 return;
25 do {
26 bn = lshift(u.u_offset, -6);
27 on = u.u_offset[1] & 077;
28 a = UISA->r[0];
29 spl7();
30 UISA->r[0] = bn;
31 if(dev.d_minor == 1)
32 UISA->r[0] = KISA->r[(bn>>7)&07] + (bn & 0177);
33 c = fubyte(on);
34 UISA->r[0] = a;
35 spl0();
36 } while(u.u_error==0 && passc(c)>=0);
37}
38
39mmwrite(dev)
40{
41 register c, bn, on;
42 int a;
43
44 if(dev.d_minor == 2) {
45 c = u.u_count;
46 u.u_count = 0;
47 u.u_base =+ c;
48 dpadd(u.u_offset, c);
49 return;
50 }
51 for(;;) {
52 bn = lshift(u.u_offset, -6);
53 on = u.u_offset[1] & 077;
54 if ((c=cpass())<0 || u.u_error!=0)
55 break;
56 a = UISA->r[0];
57 spl7();
58 UISA->r[0] = bn;
59 if(dev.d_minor == 1)
60 UISA->r[0] = KISA->r[(bn>>7)&07] + (bn & 0177);
61 subyte(on, c);
62 UISA->r[0] = a;
63 spl0();
64 }
65}