Add the minimalist elan-mmcr device driver.

This driver allows a userland program to mmap the MMCR of the AMD
Elan sc520 CPU.
This commit is contained in:
Poul-Henning Kamp 2002-08-02 15:53:04 +00:00
parent 4fd65a06f9
commit 927b6b099d
3 changed files with 87 additions and 0 deletions

View File

@ -192,6 +192,7 @@ i386/i386/db_disasm.c optional ddb
i386/i386/db_interface.c optional ddb
i386/i386/db_trace.c optional ddb
i386/i386/dump_machdep.c standard
i366/i386/elan-mmcr.c optional elan-mmcr
i386/i386/elf_machdep.c standard
i386/i386/exception.s standard
i386/i386/i386-gdbstub.c optional ddb

View File

@ -183,6 +183,10 @@ options GPL_MATH_EMULATE #Support for x87 emulation via
#
options PERFMON
#
# Stuff specific to the AMD Elan Sc520 cpu.
device elan-mmcr # Support mapping MMCR in userland.
#####################################################################
# NETWORKING OPTIONS

82
sys/i386/i386/elan-mmcr.c Normal file
View File

@ -0,0 +1,82 @@
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
* $FreeBSD$
*
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/conf.h>
#include <machine/md_var.h>
/*
* Device driver initialization stuff
*/
static d_open_t elan_open;
static d_close_t elan_close;
static d_ioctl_t elan_ioctl;
static d_mmap_t elan_mmap;
#define CDEV_MAJOR 100 /* Share with xrpu */
static struct cdevsw elan_cdevsw = {
/* open */ elan_open,
/* close */ elan_close,
/* read */ noread,
/* write */ nowrite,
/* ioctl */ elan_ioctl,
/* poll */ nopoll,
/* mmap */ elan_mmap,
/* strategy */ nostrategy,
/* name */ "elan",
/* maj */ CDEV_MAJOR,
/* dump */ nodump,
/* psize */ nopsize,
/* flags */ 0,
};
static int
elan_open(dev_t dev, int flag, int mode, struct thread *td)
{
return (0);
}
static int
elan_close(dev_t dev, int flag, int mode, struct thread *td)
{
return (0);
}
static int
elan_mmap(dev_t dev, vm_offset_t offset, int nprot)
{
if (offset >= 0x1000)
return (-1);
return (i386_btop(0xfffef000));
}
static int
elan_ioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct thread *tdr)
{
return(ENOENT);
}
static void
elan_drvinit(void)
{
if (elan_mmcr == NULL)
return;
make_dev(&elan_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "elan-mmcr");
return;
}
SYSINIT(elan, SI_SUB_DRIVERS, SI_ORDER_MIDDLE+CDEV_MAJOR,elan_drvinit,NULL);