patches from Julian Elischer -

Added support for mmapping /dev/mem
This commit is contained in:
David Greenman 1993-11-22 09:46:45 +00:00
parent 9d08e5f2ce
commit b513c26294
3 changed files with 57 additions and 5 deletions

View File

@ -38,7 +38,7 @@
*
* from: Utah $Hdr: mem.c 1.13 89/10/08$
* from: @(#)mem.c 7.2 (Berkeley) 5/9/91
* $Id$
* $Id: mem.c,v 1.3 1993/10/16 14:15:06 rgrimes Exp $
*/
/*
@ -228,3 +228,29 @@ mmrw(dev, uio, flags)
free(zbuf, M_TEMP);
return (error);
}
/*******************************************************\
* allow user processes to MMAP some memory sections *
* instead of going through read/write *
\*******************************************************/
int memmmap(dev_t dev, int offset, int nprot)
{
switch (minor(dev))
{
/* minor device 0 is physical memory */
case 0:
return i386_btop(offset);
/* minor device 1 is kernel memory */
case 1:
return i386_btop(vtophys(offset));
default:
return -1;
}
}

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)conf.c 5.8 (Berkeley) 5/12/91
* $Id: conf.c,v 1.14 1993/11/03 18:07:32 nate Exp $
* $Id: conf.c,v 1.15 1993/11/18 05:01:51 rgrimes Exp $
*/
#include "param.h"
@ -188,7 +188,7 @@ extern struct tty pccons;
int cttyopen(), cttyread(), cttywrite(), cttyioctl(), cttyselect();
int mmopen(), mmclose(), mmrw();
int mmopen(), mmclose(), mmrw(), memmmap();
#define mmselect seltrue
#include "pty.h"
@ -393,7 +393,7 @@ struct cdevsw cdevsw[] =
cttyselect, enodev, NULL },
{ mmopen, mmclose, mmrw, mmrw, /*2*/
enodev, nullop, nullop, NULL, /* memory */
mmselect, enodev, NULL },
mmselect, memmmap, NULL },
{ wdopen, wdclose, rawread, rawwrite, /*3*/
wdioctl, enodev, nullop, NULL, /* wd */
seltrue, enodev, wdstrategy },

View File

@ -38,7 +38,7 @@
*
* from: Utah $Hdr: mem.c 1.13 89/10/08$
* from: @(#)mem.c 7.2 (Berkeley) 5/9/91
* $Id$
* $Id: mem.c,v 1.3 1993/10/16 14:15:06 rgrimes Exp $
*/
/*
@ -228,3 +228,29 @@ mmrw(dev, uio, flags)
free(zbuf, M_TEMP);
return (error);
}
/*******************************************************\
* allow user processes to MMAP some memory sections *
* instead of going through read/write *
\*******************************************************/
int memmmap(dev_t dev, int offset, int nprot)
{
switch (minor(dev))
{
/* minor device 0 is physical memory */
case 0:
return i386_btop(offset);
/* minor device 1 is kernel memory */
case 1:
return i386_btop(vtophys(offset));
default:
return -1;
}
}