sysOutLong and sysInLong [solved]

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Klakap
Member
Member
Posts: 299
Joined: Sat Mar 10, 2018 10:16 am

sysOutLong and sysInLong [solved]

Post 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?
Last edited by Klakap on Tue Sep 04, 2018 10:21 am, edited 1 time in total.
User avatar
zity
Member
Member
Posts: 99
Joined: Mon Jul 13, 2009 5:52 am
Location: Denmark

Re: sysOutLong and sysInLong

Post 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
Klakap
Member
Member
Posts: 299
Joined: Sat Mar 10, 2018 10:16 am

Re: sysOutLong and sysInLong

Post by Klakap »

So outl is it the same as outb? The function outb and inb I have.
User avatar
zity
Member
Member
Posts: 99
Joined: Mon Jul 13, 2009 5:52 am
Location: Denmark

Re: sysOutLong and sysInLong

Post 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.
Klakap
Member
Member
Posts: 299
Joined: Sat Mar 10, 2018 10:16 am

Re: sysOutLong and sysInLong

Post by Klakap »

And please what is code of method outl?
User avatar
zity
Member
Member
Posts: 99
Joined: Mon Jul 13, 2009 5:52 am
Location: Denmark

Re: sysOutLong and sysInLong

Post 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));
}
Klakap
Member
Member
Posts: 299
Joined: Sat Mar 10, 2018 10:16 am

Re: sysOutLong and sysInLong

Post by Klakap »

Very thank you! And please, what is code of Inl? Is similiar methods outw and inw?
User avatar
zity
Member
Member
Posts: 99
Joined: Mon Jul 13, 2009 5:52 am
Location: Denmark

Re: sysOutLong and sysInLong

Post 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.
Klakap
Member
Member
Posts: 299
Joined: Sat Mar 10, 2018 10:16 am

Re: sysOutLong and sysInLong

Post by Klakap »

Very thank you! For these methods, I was stuck with my os development.
Post Reply