Skip to contentSkip to conversation

inb() and outb()

DISCUSSION Belinda 2 participants 2 messages Sep 30, 2001

lore
Share & tools
lore

Belinda

author
#0 lore raw

Hi, all

I wrote a simple program with inb() and outb().
However, it reports the segmentation error when
running it.

The code follows as:
---------------------------------
#include <asm/io.h>

#define LPT 0x378

void write_LPT(unsigned char byte)

{
    outb(byte, LPT);
}

int main()
{
write_LPT(LPT);
printf("Value:%c", inb(LPT));

}
------------------------------------------------------

Thanks,

Belinda

__________________________________________________
Do You Yahoo!?
Listen to your Yahoo! Mail messages from any phone.
http://phone.yahoo.com

#1 lore raw
Quoted 7 lines · Belinda

Hi, all

I wrote a simple program with inb() and outb().
However, it reports the segmentation error when
running it.

Quoted 6 lines

The code follows as:
---------------------------------
#include <asm/io.h>

#define LPT 0x378

You need to add something like this in your main method before calling write_LPT.

See 'man ioperm' for more info..

if (ioperm(LPT, 3, 1)) {
      printf("Sorry, you were not able to gain access to the ports\n");
      printf("You must be root to run this program\n");
      exit(1);
}
Quoted 26 lines

void write_LPT(unsigned char byte)

{
    outb(byte, LPT);
}

int main()

{
   write_LPT(LPT);
   printf("Value:%c", inb(LPT));

}
------------------------------------------------------

Thanks,

Belinda

__________________________________________________
Do You Yahoo!?
Listen to your Yahoo! Mail messages from any phone.
http://phone.yahoo.com
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Signature · 3 lines
Ben Greear <[email protected]>          <[email protected]>
President of Candela Technologies Inc      http://www.candelatech.com
ScryMUD:  http://scry.wanfear.com     http://scry.wanfear.com/~greear