blob: 09de3223ffb09a918f2ad3641a2f2b0435f1d4d3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
/* $OpenBSD: aperture.c,v 1.1 1996/03/05 11:25:29 mickey Exp $ */
/*
* Copyright 1994 the XFree86 Project Inc.
*/
/*
* linear framebuffer aperture driver for NetBSD
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/errno.h>
#define VGA_START 0xA0000
#define VGA_END 0xBFFFF
/* open counter */
static int ap_open_count = 0;
/*
* Open the device
*/
int
apopen(dev_t dev, int oflags, int devtype, struct proc *p)
{
struct pcred *pc = p->p_cred;
if (suser(p->p_ucred, &p->p_acflag) != 0) {
return(EPERM);
}
/* authorize only one simultaneous open() */
if (ap_open_count > 0) {
return(EPERM);
}
ap_open_count++;
return(0);
}
/*
* Close the device
*/
int
apclose(dev_t dev, int cflags, int devtype, struct proc *p)
{
ap_open_count--;
return(0);
}
/*
* mmap() physical memory sections
*
* allow only section in the vga framebuffer and above main memory
* to be mapped
*/
int
apmmap(dev_t dev, int offset, int length)
{
#ifdef AP_DEBUG
printf("apmmap: addr 0x%x\n", offset);
#endif
if ((minor(dev) == 0)
&& (offset >= VGA_START && offset <= VGA_END
|| (unsigned)offset > (unsigned)ctob(physmem))) {
return i386_btop(offset);
} else {
return(-1);
}
}
|