From owner-freebsd-hackers@FreeBSD.ORG Sun Oct 17 13:01:03 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 25A7416A4CE for ; Sun, 17 Oct 2004 13:01:03 +0000 (GMT) Received: from kane.otenet.gr (kane.otenet.gr [195.170.0.27]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5597543D39 for ; Sun, 17 Oct 2004 13:01:02 +0000 (GMT) (envelope-from keramida@freebsd.org) Received: from gothmog.gr (patr530-b205.otenet.gr [212.205.244.213]) i9HD0woZ029887; Sun, 17 Oct 2004 16:00:59 +0300 Received: from gothmog.gr (gothmog [127.0.0.1]) by gothmog.gr (8.13.1/8.13.1) with ESMTP id i9HD0v2p001294; Sun, 17 Oct 2004 16:00:57 +0300 (EEST) (envelope-from keramida@freebsd.org) Received: (from giorgos@localhost) by gothmog.gr (8.13.1/8.13.1/Submit) id i9HD0v6N001293; Sun, 17 Oct 2004 16:00:57 +0300 (EEST) (envelope-from keramida@freebsd.org) Date: Sun, 17 Oct 2004 16:00:57 +0300 From: Giorgos Keramidas To: Jan Opacki Message-ID: <20041017130057.GA1132@gothmog.gr> References: <6.0.1.1.1.20041016135943.0353fb90@adamsatoms.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6.0.1.1.1.20041016135943.0353fb90@adamsatoms.com> cc: freebsd-hackers@freebsd.org Subject: Re: Freebsd assembly programming - IN/OUT commands. X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Oct 2004 13:01:03 -0000 On 2004-10-16 14:03, Jan Opacki wrote: > I had a short look at your fbd assembly tutorial. I'm have a such > problem useing IN, OUT commands. In my case i want to "speak" with cmos > by port 70 and 71. We both know that fbsd as same as linux works in safe > mode. So we need a permission to use each port. In linux it's a system > call sys_ioperm (http://www.die.net/doc/linux/man/man2/ioperm.2.html). > How to ask FreeBSD to allow us to use those ports ? And then we could > simply do: > mov al, 0 > out 70h, al > nop > nop > nop > nop > in al, 71h > Do you haveny any idea ? Look at the io(4) manpage. You need superuser access to work with /dev/io and even then your program should be very careful about not messing up badly with the hardware, but I think it does what you need. A typical use of /dev/io would look like: if ((iofd = open("/dev/io", O_RDONLY)) == -1) err(1, "open: /dev/io"); __asm__("insert your inline asm here"); if (close(iofd) == -1) err(1, "close: /dev/io");