Thanks, Dan "Hoysch" Heuschele
E-mail hoy...@manta.nosc.mil
/* map.c : Device Driver to provide access to shared memory on */
/* smart I/O card */
#include <sys/types.h> /* required for physmap */
#include <sys/kmem.h> /* required for physmap */
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/dir.h>
#include <sys/user.h>
#include <sys/file.h>
#include <sys/immu.h>
#include <sys/cmn_err.h>
#include <sys/tty.h>
#include <sys/errno.h>
#include <sys/conf.h>
#include <sys/cred.h>
#include <sys/ddi.h>
#define PHYS_ADDR 0xD0000L; /* System Memory boundry */
#define MEM_SIZE 0x8000L; /* 8 Kb of space */
/*#define DEBUG*/
int mmapdevflag = D_NEW; /* Indicates a "new" style driver */
mmapinit()
{
printf ("Initialize MAP Driver\n");
}
mmapopen(dev, flag, open)
int dev, flag, open;
{
#ifdef DEBUG
/*printf ("DEVICE: MAP opened\n");*/
cmn_err (CE_CONT, "DEVICE: MAP opened\n");
#endif DEBUG
return 0;
}
mmapclose()
{
#ifdef DEBUG
/*printf ("DEVICE: MAP closed\n");*/
cmn_err (CE_CONT, "DEVICE: MAP closeded\n");
#endif DEBUG
return 0;
}
void *mmapioctl(dev, cmd, argp)
dev_t dev;
int cmd;
int *argp;
{
*argp = physmap (0xD0000, 0x8000, KM_NOSLEEP);
#ifdef DEBUG
cmn_err (CE_CONT, "DEVICE: MAP ioctl returning %x\n", *argp);
#endif DEBUG
return *argp;
} /* mmapioctl */
/************* tmap.c : used to test mmap device driver *****************/
#include <sys/types.h>
#include <sys/param.h>
#include <fcntl.h>
#define DEVICE "/dev/mmap"
#define PARAM 0
main()
{
int fd; /* File descriptor to open device */
char *my_point;
char *my_point2;
printf ("PROCESS: opening device\n");
if ((fd = open(DEVICE, O_RDWR)) == -1)
perror ("tmap: error opening /dev/mmap");
/*
* Do an ioctl() to get the selector from the driver
*/
printf ("PROCESS: Before got address : my_point2 = %x\n", my_point2);
my_point = (char *) ioctl(fd, PARAM, &my_point2);
printf ("PROCESS: After got address : my_point = %x\n", my_point);
printf ("PROCESS: After got address : my_point2 = %x\n", my_point2);
printf ("Before assignment to my_point2\n");
*my_point2 = 0xde;
printf ("After assignment to my_point2\n"); /* <== Never prints this */
printf("PROCESS: Closing device\n");
close (fd);
printf("PROCESS: Test completed\n");
}
Thanks Again, Dan "Hoysch" Heuschele