Deleted Added
full compact
mem.c (924) mem.c (1549)
1/*-
2 * Copyright (c) 1988 University of Utah.
3 * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
4 * All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * the Systems Programming Group of the University of Utah Computer
8 * Science Department, and code derived from software contributed to

--- 31 unchanged lines hidden (view full) ---

40 * from: @(#)mem.c 7.2 (Berkeley) 5/9/91
41 * $Id: mem.c,v 1.6 1993/12/19 00:50:06 wollman Exp $
42 */
43
44/*
45 * Memory special file
46 */
47
1/*-
2 * Copyright (c) 1988 University of Utah.
3 * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
4 * All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * the Systems Programming Group of the University of Utah Computer
8 * Science Department, and code derived from software contributed to

--- 31 unchanged lines hidden (view full) ---

40 * from: @(#)mem.c 7.2 (Berkeley) 5/9/91
41 * $Id: mem.c,v 1.6 1993/12/19 00:50:06 wollman Exp $
42 */
43
44/*
45 * Memory special file
46 */
47
48#include "param.h"
49#include "conf.h"
50#include "buf.h"
51#include "systm.h"
52#include "uio.h"
53#include "malloc.h"
54#include "proc.h"
48#include <sys/param.h>
49#include <sys/conf.h>
50#include <sys/buf.h>
51#include <sys/systm.h>
52#include <sys/uio.h>
53#include <sys/malloc.h>
54#include <sys/proc.h>
55
55
56#include "machine/cpu.h"
57#include "machine/psl.h"
56#include <machine/cpu.h>
57#include <machine/psl.h>
58
58
59#include "vm/vm_param.h"
60#include "vm/lock.h"
61#include "vm/vm_statistics.h"
62#include "vm/vm_prot.h"
63#include "vm/pmap.h"
59#include <vm/vm_param.h>
60#include <vm/lock.h>
61#include <vm/vm_prot.h>
62#include <vm/pmap.h>
64
63
65extern char *vmmap; /* poor name! */
64extern char *ptvmmap; /* poor name! */
66/*ARGSUSED*/
67int
68mmclose(dev, uio, flags)
69 dev_t dev;
70 struct uio *uio;
71 int flags;
72{
73 struct trapframe *fp;
74
75 switch (minor(dev)) {
76 case 14:
65/*ARGSUSED*/
66int
67mmclose(dev, uio, flags)
68 dev_t dev;
69 struct uio *uio;
70 int flags;
71{
72 struct trapframe *fp;
73
74 switch (minor(dev)) {
75 case 14:
77 fp = (struct trapframe *)curproc->p_regs;
76 fp = (struct trapframe *)curproc->p_md.md_regs;
78 fp->tf_eflags &= ~PSL_IOPL;
79 break;
80 default:
81 break;
82 }
83 return(0);
84}
85/*ARGSUSED*/
86int
87mmopen(dev, uio, flags)
88 dev_t dev;
89 struct uio *uio;
90 int flags;
91{
92 struct trapframe *fp;
93
94 switch (minor(dev)) {
95 case 14:
77 fp->tf_eflags &= ~PSL_IOPL;
78 break;
79 default:
80 break;
81 }
82 return(0);
83}
84/*ARGSUSED*/
85int
86mmopen(dev, uio, flags)
87 dev_t dev;
88 struct uio *uio;
89 int flags;
90{
91 struct trapframe *fp;
92
93 switch (minor(dev)) {
94 case 14:
96 fp = (struct trapframe *)curproc->p_regs;
95 fp = (struct trapframe *)curproc->p_md.md_regs;
97 fp->tf_eflags |= PSL_IOPL;
98 break;
99 default:
100 break;
101 }
102 return(0);
103}
104/*ARGSUSED*/

--- 18 unchanged lines hidden (view full) ---

123 panic("mmrw");
124 continue;
125 }
126 switch (minor(dev)) {
127
128/* minor device 0 is physical memory */
129 case 0:
130 v = uio->uio_offset;
96 fp->tf_eflags |= PSL_IOPL;
97 break;
98 default:
99 break;
100 }
101 return(0);
102}
103/*ARGSUSED*/

--- 18 unchanged lines hidden (view full) ---

122 panic("mmrw");
123 continue;
124 }
125 switch (minor(dev)) {
126
127/* minor device 0 is physical memory */
128 case 0:
129 v = uio->uio_offset;
131 pmap_enter(pmap_kernel(), (vm_offset_t)vmmap, v,
130 pmap_enter(kernel_pmap, (vm_offset_t)ptvmmap, v,
132 uio->uio_rw == UIO_READ ? VM_PROT_READ : VM_PROT_WRITE,
133 TRUE);
134 o = (int)uio->uio_offset & PGOFSET;
135 c = (u_int)(NBPG - ((int)iov->iov_base & PGOFSET));
131 uio->uio_rw == UIO_READ ? VM_PROT_READ : VM_PROT_WRITE,
132 TRUE);
133 o = (int)uio->uio_offset & PGOFSET;
134 c = (u_int)(NBPG - ((int)iov->iov_base & PGOFSET));
136 c = MIN(c, (u_int)(NBPG - o));
137 c = MIN(c, (u_int)iov->iov_len);
138 error = uiomove((caddr_t)&vmmap[o], (int)c, uio);
139 pmap_remove(pmap_kernel(), (vm_offset_t)vmmap,
140 (vm_offset_t)&vmmap[NBPG]);
135 c = min(c, (u_int)(NBPG - o));
136 c = min(c, (u_int)iov->iov_len);
137 error = uiomove((caddr_t)&ptvmmap[o], (int)c, uio);
138 pmap_remove(kernel_pmap, (vm_offset_t)ptvmmap,
139 (vm_offset_t)&ptvmmap[NBPG]);
141 continue;
142
143/* minor device 1 is kernel memory */
144 case 1:
145 c = iov->iov_len;
140 continue;
141
142/* minor device 1 is kernel memory */
143 case 1:
144 c = iov->iov_len;
146 if (!kernacc((caddr_t)uio->uio_offset, c,
145 if (!kernacc((caddr_t)(int)uio->uio_offset, c,
147 uio->uio_rw == UIO_READ ? B_READ : B_WRITE))
148 return(EFAULT);
146 uio->uio_rw == UIO_READ ? B_READ : B_WRITE))
147 return(EFAULT);
149 error = uiomove((caddr_t)uio->uio_offset, (int)c, uio);
148 error = uiomove((caddr_t)(int)uio->uio_offset, (int)c, uio);
150 continue;
151
152/* minor device 2 is EOF/RATHOLE */
153 case 2:
154 if (uio->uio_rw == UIO_READ)
155 return (0);
156 c = iov->iov_len;
157 break;

--- 4 unchanged lines hidden (view full) ---

162 c = iov->iov_len;
163 break;
164 }
165 if (zbuf == NULL) {
166 zbuf = (caddr_t)
167 malloc(CLBYTES, M_TEMP, M_WAITOK);
168 bzero(zbuf, CLBYTES);
169 }
149 continue;
150
151/* minor device 2 is EOF/RATHOLE */
152 case 2:
153 if (uio->uio_rw == UIO_READ)
154 return (0);
155 c = iov->iov_len;
156 break;

--- 4 unchanged lines hidden (view full) ---

161 c = iov->iov_len;
162 break;
163 }
164 if (zbuf == NULL) {
165 zbuf = (caddr_t)
166 malloc(CLBYTES, M_TEMP, M_WAITOK);
167 bzero(zbuf, CLBYTES);
168 }
170 c = MIN(iov->iov_len, CLBYTES);
169 c = min(iov->iov_len, CLBYTES);
171 error = uiomove(zbuf, (int)c, uio);
172 continue;
173
174#ifdef notyet
175/* 386 I/O address space (/dev/ioport[bwl]) is a read/write access to seperate
176 i/o device address bus, different than memory bus. Semantics here are
177 very different than ordinary read/write, as if iov_len is a multiple
178 an implied string move from a single port will be done. Note that lseek

--- 82 unchanged lines hidden ---
170 error = uiomove(zbuf, (int)c, uio);
171 continue;
172
173#ifdef notyet
174/* 386 I/O address space (/dev/ioport[bwl]) is a read/write access to seperate
175 i/o device address bus, different than memory bus. Semantics here are
176 very different than ordinary read/write, as if iov_len is a multiple
177 an implied string move from a single port will be done. Note that lseek

--- 82 unchanged lines hidden ---