Re: inb & outb woes...
jahurt_at_hotmail.com
Date: 07/11/03
- Next message: Lee W: "Linux compatible 4"-6" TFT Touchscreen available in the UK"
- Previous message: Pankajkumar Chauhan: "Re: help"
- In reply to: Jens.Toerring_at_physik.fu-berlin.de: "Re: inb & outb woes..."
- Next in thread: Jens.Toerring_at_physik.fu-berlin.de: "Re: inb & outb woes..."
- Reply: Jens.Toerring_at_physik.fu-berlin.de: "Re: inb & outb woes..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 11 Jul 2003 14:59:12 -0700
Jens.Toerring@physik.fu-berlin.de wrote in message news:<bemvbe$6pjn0$1@uni-berlin.de>...
> In comp.os.linux.development.apps jahurt@hotmail.com wrote:
> > I'm trying to write a short program that will display/modify I/O ports
> > depending on the number of command line args... this is for a PC104
> > board I'm tinkering with. It's not working as expected and I can't
> > find documentation more in depth than the man page... here's the
> > code... yeah, it's crude...
>
> > int main(int argc, char **argv)
> > {
> > unsigned int addr, val;
> > switch (argc) {
> > case 2:
> > addr = strtol(argv[1], (char**)NULL, 16);
> > if (addr < 0x400 && ioperm(addr, 1, 1) < 0) {
>
> If addr >= 0x400, ioperm() is never called and then the iopl() in
> the else-if clause will fail. If you change the '&&' to '||' (which
> also would make more sense) it probably will work.
This is by design... ioperm sets the port access permission bits for
the first 0x3ff i/o ports. If I have an address > 0x3ff, then the
plan is to call iopl (rather than ioperm), which, according to the man
page, grants access to all the i/o ports. At least this is my
understanding from the man pages...
>
> > printf("ioperm failed: %s\n", strerror(errno));
> > return -1;
> > } else if (iopl(3) < 0) {
> > printf("iopl failed: %s\n", strerror(errno));
> > return -1;
> > }
> > printf("address 0x%x : value 0x%02x\n", addr, inb(addr));
>
> Regards, Jens
- Next message: Lee W: "Linux compatible 4"-6" TFT Touchscreen available in the UK"
- Previous message: Pankajkumar Chauhan: "Re: help"
- In reply to: Jens.Toerring_at_physik.fu-berlin.de: "Re: inb & outb woes..."
- Next in thread: Jens.Toerring_at_physik.fu-berlin.de: "Re: inb & outb woes..."
- Reply: Jens.Toerring_at_physik.fu-berlin.de: "Re: inb & outb woes..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|