* Copyright (c) 1988 University of Utah.
* Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* %sccs.include.redist.c%
* from: Utah $Hdr: mem.c 1.14 90/10/12$
* @(#)mem.c 7.9 (Berkeley) %G%
#include "../include/cpu.h"
register struct iovec
*iov
;
while (uio
->uio_resid
> 0 && error
== 0) {
/* minor device 0 is physical memory */
/* allow reads only in RAM (except for DEBUG) */
if (v
>= 0xFFFFFFFC || v
< lowram
)
pmap_enter(kernel_pmap
, (vm_offset_t
)vmmap
,
trunc_page(v
), uio
->uio_rw
== UIO_READ
?
VM_PROT_READ
: VM_PROT_WRITE
, TRUE
);
o
= (int)uio
->uio_offset
& PGOFSET
;
c
= (u_int
)(NBPG
- ((int)iov
->iov_base
& PGOFSET
));
c
= MIN(c
, (u_int
)(NBPG
- o
));
c
= MIN(c
, (u_int
)iov
->iov_len
);
error
= uiomove((caddr_t
)&vmmap
[o
], (int)c
, uio
);
pmap_remove(kernel_pmap
, (vm_offset_t
)vmmap
,
(vm_offset_t
)&vmmap
[NBPG
]);
/* minor device 1 is kernel memory */
c
= MIN(iov
->iov_len
, MAXPHYS
);
if (!kernacc((caddr_t
)uio
->uio_offset
, c
,
uio
->uio_rw
== UIO_READ
? B_READ
: B_WRITE
))
error
= uiomove((caddr_t
)uio
->uio_offset
, (int)c
, uio
);
/* minor device 2 is EOF/RATHOLE */
if (uio
->uio_rw
== UIO_WRITE
)
/* minor device 12 (/dev/zero) is source of nulls on read, rathole on write */
if (uio
->uio_rw
== UIO_WRITE
) {
malloc(CLBYTES
, M_TEMP
, M_WAITOK
);
c
= MIN(iov
->iov_len
, CLBYTES
);
error
= uiomove(zbuf
, (int)c
, uio
);