Date: Tue, 16 Feb 1999 15:26:04 -0700 From: Wes Peters <wes@softweyr.com> To: Donn Miller <dmm125@bellatlantic.net> Cc: hackers@FreeBSD.ORG Subject: Re: Systems programming for FreeBSD Message-ID: <36C9F07C.7F2C9367@softweyr.com> References: <36C8C170.4AA85CA@bellatlantic.net>
next in thread | previous in thread | raw e-mail | index | archive | help
Donn Miller wrote: > > I'm looking for some info on how to use functions like inb() and outb() > to do systems-level programming on FreeBSD. > > 1.) I need to know the FreeBSD equiv. of the Linux function ioperm(). > I would think you just use open() on /dev/pio or /dev/io with the > appropriate permissions. "man io" tells us: IO(4) FreeBSD Kernel Interfaces Manual (i386 Architecture) IO(4) NAME io - I/O privilege file DESCRIPTION The special file /dev/io is a controlled security hole that allows a pro- cess to gain I/O privileges (which are normally reserved for kernel- internal code). Any process that holds a file descriptor on /dev/io open will get its IOPL bits in the flag register set, thus allowing it to per- form direct I/O operations. This can be useful in order to write user- land programs that handle some hardware directly. The entire access control is handled by the file access permissions of /dev/io, so care should be taken in granting rights for this device. Note that even read/only access will grant the full I/O privileges. FILES /dev/io SEE ALSO mem(4) HISTORY The io file appeared in FreeBSD 1.0. > > 2.) what include files do I need to use to use inb() and outb()? In > Linux it's <asm/io.h> machine/cpufunc.h > Is using ports my only/best option for doing systems-level programming > for writing drivers for video cards, or should I use assembly? Ports are your only choice when doing port-mapped I/O. Using assembler will make your driver run faster, IF you are a good assembly programmer. If not, you'll probably be better off writing C. If you want to write a driver for a video card, start with one of the existing drivers for a similar device. > There's a Linux howto on systems programming, maybe FreeBSD is similar > in that respect. so I can just use the Linux howto for FreeBSD. What > are ports anyway, is it like you're writing to a special part of memory? No, I/O ports are a separate address space from memory. I strongly suggest a good book on x86 architecture, but don't have any idea what one might be. Mine is ages old and probably isn't published anymore. Suggestions, hackers? -- Where am I, and what am I doing in this handbasket? Wes Peters +1.801.915.2061 Softweyr LLC wes@softweyr.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?36C9F07C.7F2C9367>