So, you were using that inportl function and you weren't returning anything, and you don't know why?aloktiagi wrote: Yes true it shud be 32 bit and inl and outl need to be used but when i had used them the result of my BAR0 was empty.
Code: Select all
__asm__ volatile ("in %%dx,%%eax" : "=a" (ret_val) : "d"(port));
accessing the network card
Re: accessing the network card
Visit the Montrom user page for more info.
Re: accessing the network card
I'm returning a value right!!!
Code: Select all
int inportl(int port)
{
int ret_val;
__asm__ volatile ("in %%dx,%%eax" : "=a" (ret_val) : "d"(port));
return ret_val;
}
Re: accessing the network card
Visit the Montrom user page for more info.
Re: accessing the network card
You realize int is signed 32-bit, do you?aloktiagi wrote:Hi,
inl and outl look like this
Code: Select all
int inportl(int port) { int ret_val; __asm__ volatile ("in %%dx,%%eax" : "=a" (ret_val) : "d"(port)); return ret_val; } void outportl(int port, int val) { __asm__ volatile ("outl %%eax,%%dx" : : "a"(val), "d"(port)); }
Re: accessing the network card
@eddyb:my return value should be unsigned int 16bit
and
@montrom : my return value should be of unsigned char type
and
@montrom : my return value should be of unsigned char type
Re: accessing the network card
This is a waste of time. Here: Use unsigned and inl. Now, I hope you know what to do with that. And, please make a better effort to form proper sentences. I have no idea if you are telling me or asking me those things you wrote in your last reply. It would also be helpful if you would step back and take a moment to better understand what it is you are doing. And, better yet, discover why it is you are in such a hurry to complete something most likely meaningless beyond your own personal desire. Oh, and it wouldn't hurt to spend some time in a C forum.
Visit the Montrom user page for more info.
Re: accessing the network card
You see when i had put unsigned int and inl i was getting the device id and all the registers after it till BAR0. But the value for BAR0 is empty.
So my only question is that how is BAR0 different from all the other registers before it, in terms of reading its value??
So my only question is that how is BAR0 different from all the other registers before it, in terms of reading its value??
Re: accessing the network card
Does the specification state that there is supposed to be a value in each BAR?
Visit the Montrom user page for more info.
Re: accessing the network card
PrettyOS, util.c:
look at pci.c how we manage this.
Code: Select all
uint8_t inportb(uint16_t port)
{
uint8_t ret_val;
__asm__ volatile ("in %%dx,%%al" : "=a"(ret_val) : "d"(port));
return ret_val;
}
uint16_t inportw(uint16_t port)
{
uint16_t ret_val;
__asm__ volatile ("in %%dx,%%ax" : "=a" (ret_val) : "d"(port));
return ret_val;
}
uint32_t inportl(uint16_t port)
{
uint32_t ret_val;
__asm__ volatile ("in %%dx,%%eax" : "=a" (ret_val) : "d"(port));
return ret_val;
}
void outportb(uint16_t port, uint8_t val)
{
__asm__ volatile ("out %%al,%%dx" :: "a"(val), "d"(port));
}
void outportw(uint16_t port, uint16_t val)
{
__asm__ volatile ("out %%ax,%%dx" :: "a"(val), "d"(port));
}
void outportl(uint16_t port, uint32_t val)
{
__asm__ volatile ("outl %%eax,%%dx" : : "a"(val), "d"(port));
}
http://www.henkessoft.de/OS_Dev/OS_Dev3.htm (OSDEV)
http://www.c-plusplus.de/forum/viewforu ... is-62.html
irc.euirc.net #PrettyOS
http://www.c-plusplus.de/forum/viewforu ... is-62.html
irc.euirc.net #PrettyOS
Re: accessing the network card
@aloktiagi: how are things going on?
http://www.henkessoft.de/OS_Dev/OS_Dev3.htm (OSDEV)
http://www.c-plusplus.de/forum/viewforu ... is-62.html
irc.euirc.net #PrettyOS
http://www.c-plusplus.de/forum/viewforu ... is-62.html
irc.euirc.net #PrettyOS