From owner-freebsd-hackers Tue Feb 16 14:29:54 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from xylan.com (postal.xylan.com [208.8.0.248]) by hub.freebsd.org (Postfix) with ESMTP id D4FDA10EA2 for ; Tue, 16 Feb 1999 14:29:40 -0800 (PST) (envelope-from wes@softweyr.com) Received: from mailhub.xylan.com by xylan.com (8.8.7/SMI-SVR4 (xylan-mgw 2.2 [OUT])) id OAA01173; Tue, 16 Feb 1999 14:26:14 -0800 (PST) Received: from utah.XYLAN.COM by mailhub.xylan.com (SMI-8.6/SMI-SVR4 (mailhub 2.1 [HUB])) id OAA24963; Tue, 16 Feb 1999 14:26:14 -0800 Received: from softweyr.com by utah.XYLAN.COM (SMI-8.6/SMI-SVR4 (xylan utah [SPOOL])) id PAA04841; Tue, 16 Feb 1999 15:26:04 -0700 Message-ID: <36C9F07C.7F2C9367@softweyr.com> Date: Tue, 16 Feb 1999 15:26:04 -0700 From: Wes Peters Organization: Softweyr LLC X-Mailer: Mozilla 4.5 [en] (X11; U; FreeBSD 2.2.7-RELEASE i386) X-Accept-Language: en MIME-Version: 1.0 To: Donn Miller Cc: hackers@FreeBSD.ORG Subject: Re: Systems programming for FreeBSD References: <36C8C170.4AA85CA@bellatlantic.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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 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