ioperm question

ioperm question

Post by spyro » Mon, 16 Jun 2003 21:10:38



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

hi all,
   i'd like to ask a simple, yet confusing to me, question about
ioperm.ioperm is like this:

  #include <unistd.h> /* for libc5 */
  #include <sys/io.h> /* for glibc */

  int ioperm(unsigned long from, unsigned long num, int turn_on);

where from is the address of the beginning port, num is the number of
bytes and turn_on it the value of the permissions.(but i suppose you
already knew that).
My question is: can someone explain to me what a port is? How many bytes
does it have? How do I know how many ports a device has? Is there a
difference between the ports of my ,say, parallel connector and my
serial one? Differences between my serial connector and my sound card
port? (ok, that's not ONE question but...) I'm totally confused...

So, any ideas? ...someone...plz?
I'd really appreciate if you gave me something like a schematic or
something...

thnx in advance
spyros

- --


pub-key: http://dalab.ee.duth.gr/~spyros/my_pub.asc

-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0 - not licensed for commercial use: www.pgp.com

iQEVAwUBPuxiOz2QMCA0LA8jAQIZJggAhefYD5CohUQk7u0IJKeNx1ZlxIo14pI/
JktRNNFBb98EAnYpslKZEh3xzFXZiCxKPAMGX1DOlGehZjj1NdD6XUtCFBtTO6Nq
960M9/xWlNMIR/L32gxDjZzY+xipJWdKjsMcYBtHOVjcraBcV6eXNcwF32Pjyj4V
j89qyhcRYh6PWUnsotkRfCmTAw0X2EuJDDj/DjmAnueameAYAwynjBhQ7GYIMC1h
dSKmzVW2K3fLQLrxDybGG/UvgUx/+CrZn2q7ozB1Vtrq/ruh/jIumhtCtltojkE0
oLB6LJ6Kwigjlas4N9ciA4ls/mRdAphG2/lG34N3flotJXzTy1qcJw==
=mmJx
-----END PGP SIGNATURE-----

 
 
 

ioperm question

Post by Antoine Mathy » Sat, 21 Jun 2003 06:18:26


Quote:> ...
>  int ioperm(unsigned long from, unsigned long num, int turn_on);
> ...
> My question is: can someone explain to me what a port is?

A port is an adress in the separate address space used for devices
communicating over the system bus.

Quote:> How many bytes
> does it have?

1 to 4.

Quote:> How do I know how many ports a device has?

This vary for every device. Consult the documentation. Usually, if a
device use, say, three ports, there will be consecutive but the number
of the first one may be set to anything (though there are defaults).

Quote:> Is there a
> difference between the ports of my ,say, parallel connector and my
> serial one? Differences between my serial connector and my sound card
> port?

No.

Quote:> I'm totally confused...

Indeed. What are you trying to do ?

A.M.

 
 
 

ioperm question

Post by spyro » Sat, 21 Jun 2003 18:43:34


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

hi,
nothing really.Just playing around and found out that i'm completely
useless in hw programming (using c language of course..).I tried to read
TFMs (aka serial/parallel-programming howtos) but i guess i'm not *that*
smart after all :))

I need to study more computer architecture before i dive in hw
programming i suppose, huh?

anyway, thanx for the reply...
spyros

 >> I'm totally confused...
 >
 > Indeed. What are you trying to do ?
 >
 > A.M.
 >

- --


pub-key: http://dalab.ee.duth.gr/~spyros/my_pub.asc

-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0 - not licensed for commercial use: www.pgp.com

iQEVAwUBPvLXQT2QMCA0LA8jAQKuJwf9FAaU8juRowkdCg3saSyXGAPWrgTO9+Kp
94LEsIqawzeYireFFqCTkjhpOukGBX+e4iMgUswYmK+yieP7TO/Js1445+UGDTb0
xmcViYZi9f19FuN2jAU1+j31HYh6AujoJVTtS51XWlAXWFfJ5PMSlSANk6eab2ee
EMipohND+yX4aaol70fMGnwF11oC1DmusZWOjGwhLZNy5JR/WAvMvCVWvFugHsXp
eirUYPuy4k+nub65zVjkCjGEfGwKMRATIEqA9GMHgdSTBZntEY1kDQuBNxMC+TpP
BK82pGroyKxdFj5FQJ6AmFVGG2RghlbPoy2wr6dUYtThvvhj7vYskw==
=YdFX
-----END PGP SIGNATURE-----

 
 
 

1. Urgent!! iopl() ioperm() questions

I'm writing a program under linux, but I'm new to it.
Experts, please help!

My program has to work with a add-on card designed by our lab.
Mainly, it uses two commands to control the i/o
with the card, namely outb() and inb() to the port addresses
0xa000 and 0xa001.

The following is a sample program to test the card.
#include <stdlib.h>
#include <stdio.h>
#include <linux/signal.h>
#include <linux/errno.h>
#include <linux/sched.h>

#include <asm/io.h>
#include <asm/segment.h>
#include <asm/system.h>
#include <asm/irq.h>

void main()
{
        if(iopl(3)== -1) printf("problem iopl()\n");
        if(ioperm(PCI_DATA_ADD,1,1)== -1) printf("problem ioperm()");
        ioperm(PCI_STATUS_ADD,1,1);
        outb(0x01,0xf001);
        outb(0x01,0xf000);

        outb(0x80,0xf001);
        outb(0x01,0xf001);
        outb(0x80,0xf001);
        c=inb(0xf001);
        c=inb(0xf001);

        printf("%2X\n",c);
        printf("end here\n");  

The problem is that ioperm() returns -1 (thus the error message is
printed),
but the output of the whole program is correct. Then I go on coding a
bigger
program but at run time, the new program always say "Segmentation
Fault".
My question is :

1. In the above program, is that anything wrong?
2. If you have experience using iopl(), ioperm(), would you please
   tell me in depth how these functions work. ( I have come across the
   manpages and hecker's guide but still not understand. Please mail
   your experience & examples to me).
3. When will the system warns by saying "Segmentation Fault"?

Any help are welcomed. Thank you very much for your concern.

Lin Hon Man
CUHK.IE

2. PackardBell Legend 812CD

3. ioperm(), iocl() question

4. File name completion in csh?

5. RH 5.2 ioperm() not in unistd.h?

6. Starting Apachessl from Cron

7. implicit declaration... int ioperm()

8. Can cron script do shutdown and bootup???

9. Serious "ioperm" bug?

10. can't write/read to isa-card using ioperm, iow, ior

11. ioperm problem

12. ioperm exploit

13. X-Trident,ioperm,newbee