This is the mail archive of the crossgcc@cygnus.com mailing list for the crossgcc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Direct I/O reads/writes from C programs


I haven't had the pleasure of dealing with Intel architecture since the 8086
days (thank the deity of your choice), but if they still insist on having a
seaprate I/O address space, then I believe you are SOL, unless your C library
has some I/O port access functions.

As far as memory mapped I/O, there have been some recent posts here on that
subject, but one possibility is something like this:

unsigned char * addr = (unsigned char *) 0x12345678;
unsigned char ch;

/* to write 0x10 */
*addr = 0x10;

/* to read a byte */
ch = *addr;



Dave wrote:

> How does one directly access an I/O address from C?
>
> For example if I want to write a char to port 0x80 (or read a char from a
> port) what is the statement?
>
> How about memory mapped I/O? If one wants to directly access a specific
> memory address what are the statements?
>
> Is direct I/O and direct memory access part of ANSI C?
>
> I have an embedded X86 project that has to directly access the hardware. I
> would prefer doing it in C rather than ASM.
>
> TIA
> Dave
>
> _______________________________________________
> New CrossGCC FAQ: http://www.objsw.com/CrossGCC
> _______________________________________________
> To remove yourself from the crossgcc list, send
> mail to crossgcc-request@cygnus.com with the
> text 'unsubscribe' (without the quotes) in the
> body of the message.

_______________________________________________
New CrossGCC FAQ: http://www.objsw.com/CrossGCC
_______________________________________________
To remove yourself from the crossgcc list, send
mail to crossgcc-request@cygnus.com with the
text 'unsubscribe' (without the quotes) in the
body of the message.