Page 1 of 1

sysOutLong and sysInLong [solved]

Posted: Tue Sep 04, 2018 9:10 am
by Klakap
Good day!
I wanted to implement a PCI but in the method pciConfigReadWord are the methods of sysOutLong and sysInLong and I non found how I should program it. Please, what is code methods sysOutLong and sysInLong?

Re: sysOutLong and sysInLong

Posted: Tue Sep 04, 2018 9:38 am
by zity
Hi Klakap,

When you need to write or read a long (in this case long means a 32-bit unsigned integer) to an I/O port you need to use the "inl" and "outl" instructions. These instructions work in exactly the same way as their 8- and 16-bit counterparts.

For an example of how to write these commands as inline assembly in GCC, see e.g.: https://wiki.osdev.org/Inline_Assembly/Examples#OUTx

Re: sysOutLong and sysInLong

Posted: Tue Sep 04, 2018 9:41 am
by Klakap
So outl is it the same as outb? The function outb and inb I have.

Re: sysOutLong and sysInLong

Posted: Tue Sep 04, 2018 10:01 am
by zity
No, they are not the same. "outb" is used for writing an 8-bit integer, while "outl" is used for writing a 32-bit integer, but they work in the same way.

Re: sysOutLong and sysInLong

Posted: Tue Sep 04, 2018 10:03 am
by Klakap
And please what is code of method outl?

Re: sysOutLong and sysInLong

Posted: Tue Sep 04, 2018 10:05 am
by zity
In GCC inline assembly you can use:

Code: Select all

void outportl(uint16_t port, uint32_t value)
{
	asm volatile("outl %0, %%dx" :: "a" (value), "d" (port));
}

Re: sysOutLong and sysInLong

Posted: Tue Sep 04, 2018 10:15 am
by Klakap
Very thank you! And please, what is code of Inl? Is similiar methods outw and inw?

Re: sysOutLong and sysInLong

Posted: Tue Sep 04, 2018 10:17 am
by zity
Yes, the code for "inl" is equivalent to the code for inb/inw, except that it takes a 32-bit integer as an argument instead.

Re: sysOutLong and sysInLong

Posted: Tue Sep 04, 2018 10:21 am
by Klakap
Very thank you! For these methods, I was stuck with my os development.