README for XFree86 3.3.2 on NetBSD : Kernel Support for X : Aperture Driver
Previous: Kernel Support for X
Next: MIT-SHM

## 7.1. Aperture Driver

By default NetBSD 0.9C and higher include the BSD 4.4 kernel security feature that disable access to the `/dev/mem` device when in multi-users mode. But XFree86 servers can take advantage (or require) linear access to the display memory.

The P9000, Mach64 and AGX servers require linear memory access, other accelerated servers can take advantage of it, but do not require it.

There are two ways to allow XFree86 to access linear memory:

1. Disable the kernel security feature by adding `option INSECURE' in the kernel configuration file and build a new kernel. On NetBSD-1.0 you have to disable kernel security by initializing the ``securelevel'' variable to -1 in `/sys/kern/kern_sysctl.c`, line 205. For more informations, see the comments in `/usr/include/sys/systm.h`.
2. Install the aperture driver:
   1. The first step is highly dependent from your exact operating system version:
      - NetBSD 1.0, 1.1, 1.2, 1.2.1:

        Add the following lines to the end of `/etc/rc.local`:

        > `

        >      KERNDIR=/usr/X11R6/lib/X11/kernel
        >      if [ -f ${KERNDIR}/ap.o ]; then
        >        modload -o ${KERNDIR}/ap -e ap -p ${KERNDIR}/apinstall ${KERNDIR}/ap.o
        >      fi

        > `

      - NetBSD 1.2D and later

        Add the following line to `/etc/lkm.conf`:

        > `

        >     /usr/X11R6/lib/X11/kernel/ap.o  -  ap /usr/X11R6/lib/X11/kernel/apinstall -

        > `

      - NetBSD 1.2G, 1.3 and later

        The `lkm.conf` format changed in 1.2G. Add the following line to `/etc/lkm.conf`:

        > `

        >     /usr/X11R6/lib/X11/kernel/ap.o  -  ap /usr/X11R6/lib/X11/kernel/apinstall - -AFTERMOUNT

        > `

   2. Reboot your system. XFree86 will auto-detect the aperture driver if available.
   Warning: if you boot another kernel than `/netbsd` or `/bsd`, loadable kernel modules can crash your system. Always boot in single user mode when you want to run another kernel.

   > Caveat: the aperture driver only allows one access at a time (so that the system is in the same security state once X is launched). This means that if you run multiple servers on multiples VT, only the first one will have linear memory access. Use 'option INSECURE' if you need more that one X server at a time.

README for XFree86 3.3.2 on NetBSD : Kernel Support for X : Aperture Driver
Previous: Kernel Support for X
Next: MIT-SHM