Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 1 Jun 2000 13:44:14 +0100
From:      Ben Smithurst <ben@scientia.demon.co.uk>
To:        Mac <mac@ngo.org.uk>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Writing a value to an IO (mem mapped) port
Message-ID:  <20000601134414.U99925@strontium.scientia.demon.co.uk>
In-Reply-To: <200006010857.JAA20643@ngo.org.uk>
References:  <20000531192931.Q99925@strontium.scientia.demon.co.uk> <200006010857.JAA20643@ngo.org.uk>

next in thread | previous in thread | raw e-mail | index | archive | help
Mac wrote:

> I can't get i386_{set,get}_ioperm to work.  All attempts at calling these functions
> result in a return value of -1 (errno=22 (EINVAL)).
> 
> 
> Code I'm using looks like this:-
> 
>     #include <errno.h>
>     #include <machine/sysarch.h>
> 
>     main()
>     {
>     unsigned int port;
>     unsigned int *length;
>     int *enable;
>     
>     int res;
> 
>     port = 0x180;
> 
>     res = i386_get_ioperm(port,length,enable);

First, you're passing uninitialized pointers to i386_get_ioperm()
(length and enable).  You shouldn't declare them as pointers, then you
pass their address (e.g. with &enable) in the ioperm call.  But even
after changing that, it still fails.  As I said, I've never used this
function, and I guess it shows. :-)

I think another way is to open /dev/io before doing your outb.  As long
as you have /dev/io open (you don't need to read or write anything
to it) your process is allowed direct IO access, AFAIK.  I think
i386_set_ioperm is the newer method though, so hopefully someone who has
used it can explain how it's done.

Aha!  I think I see why, after reading the source.  It appears you'll
need 'options VM86' in your kernel config for these to work.  The manual
page should probably tell you this.  If it still doesn't work then, I
don't know.

-- 
Ben Smithurst / ben@scientia.demon.co.uk / PGP: 0x99392F7D


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000601134414.U99925>