diff options
author | Dale Rahn <drahn@cvs.openbsd.org> | 2004-02-26 04:58:39 +0000 |
---|---|---|
committer | Dale Rahn <drahn@cvs.openbsd.org> | 2004-02-26 04:58:39 +0000 |
commit | 165120c8065df61cf8223659f01ecb0ab4ec415d (patch) | |
tree | d0d62b0fe1f91e36f226d70fbdef9c3023d98fc9 /sys/arch | |
parent | c18a44d171bbdf30255ebee2c7fad6e5b921f6a4 (diff) |
add APERTURE support.
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/arm/arm/arm32_machdep.c | 20 | ||||
-rw-r--r-- | sys/arch/arm/arm/mem.c | 32 | ||||
-rw-r--r-- | sys/arch/arm/include/cpu.h | 6 |
3 files changed, 52 insertions, 6 deletions
diff --git a/sys/arch/arm/arm/arm32_machdep.c b/sys/arch/arm/arm/arm32_machdep.c index fd3b37a3259..af49de21787 100644 --- a/sys/arch/arm/arm/arm32_machdep.c +++ b/sys/arch/arm/arm/arm32_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: arm32_machdep.c,v 1.3 2004/02/12 04:13:02 drahn Exp $ */ +/* $OpenBSD: arm32_machdep.c,v 1.4 2004/02/26 04:58:38 drahn Exp $ */ /* $NetBSD: arm32_machdep.c,v 1.42 2003/12/30 12:33:15 pk Exp $ */ /* @@ -113,6 +113,13 @@ struct user *proc0paddr; /* exported variable to be filled in by the bootloaders */ char *booted_kernel; +#ifdef APERTURE +#ifdef INSECURE +int allowaperture = 1; +#else +int allowaperture = 0; +#endif +#endif /* Prototypes */ @@ -412,6 +419,17 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) return (EOPNOTSUPP); } + case CPU_ALLOWAPERTURE: +#ifdef APERTURE + if (securelevel > 0) + return (sysctl_rdint(oldp, oldlenp, newp, + allowaperture)); + else + return (sysctl_int(oldp, oldlenp, newp, newlen, + &allowaperture)); +#else + return (sysctl_rdint(oldp, oldlenp, newp, 0)); +#endif default: return (EOPNOTSUPP); } diff --git a/sys/arch/arm/arm/mem.c b/sys/arch/arm/arm/mem.c index 73e04542226..2492d0755ba 100644 --- a/sys/arch/arm/arm/mem.c +++ b/sys/arch/arm/arm/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.2 2004/02/01 06:10:33 drahn Exp $ */ +/* $OpenBSD: mem.c,v 1.3 2004/02/26 04:58:38 drahn Exp $ */ /* $NetBSD: mem.c,v 1.11 2003/10/16 12:02:58 jdolecek Exp $ */ /* @@ -91,6 +91,13 @@ extern char *memhook; /* poor name! */ caddr_t zeropage; int physlock; +/* open counter for aperture */ +#ifdef APERTURE +static int ap_open_count = 0; +extern int allowaperture; +#endif + + /*ARGSUSED*/ int mmopen(dev, flag, mode, p) @@ -99,8 +106,24 @@ mmopen(dev, flag, mode, p) struct proc *p; { switch (minor(dev)) { - default: + case 0: + case 1: + case 2: + case 12: + break; +#ifdef APERTURE + case 4: + if (suser(p, 0) != 0 || !allowaperture) + return (EPERM); + + /* authorize only one simultaneous open() */ + if (ap_open_count > 0) + return(EPERM); + ap_open_count++; break; +#endif + default: + return (ENXIO); } return (0); } @@ -112,7 +135,10 @@ mmclose(dev, flag, mode, p) int flag, mode; struct proc *p; { - +#ifdef APERTURE + if (minor(dev) == 4) + ap_open_count--; +#endif return (0); } #define DEV_MEM 0 diff --git a/sys/arch/arm/include/cpu.h b/sys/arch/arm/include/cpu.h index e46dfa10336..d552d6ec4c4 100644 --- a/sys/arch/arm/include/cpu.h +++ b/sys/arch/arm/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.2 2004/02/23 19:09:57 drahn Exp $ */ +/* $OpenBSD: cpu.h,v 1.3 2004/02/26 04:58:38 drahn Exp $ */ /* $NetBSD: cpu.h,v 1.34 2003/06/23 11:01:08 martin Exp $ */ /* @@ -59,7 +59,8 @@ #define CPU_BOOTED_KERNEL 3 /* string: kernel we booted */ #define CPU_CONSDEV 4 /* struct: dev_t of our console */ #define CPU_POWERSAVE 5 /* int: use CPU powersave mode */ -#define CPU_MAXID 6 /* number of valid machdep ids */ +#define CPU_ALLOWAPERTURE 6 /* int: allow mmap of /dev/xf86 */ +#define CPU_MAXID 7 /* number of valid machdep ids */ #define CTL_MACHDEP_NAMES { \ { 0, 0 }, \ @@ -68,6 +69,7 @@ { "booted_kernel", CTLTYPE_STRING }, \ { "console_device", CTLTYPE_STRUCT }, \ { "powersave", CTLTYPE_INT }, \ + { "allowaperture", CTLTYPE_INT }, \ } #ifdef _KERNEL |