Page 4 of 4

Re: accessing the network card

Posted: Fri May 21, 2010 3:14 am
by montrom
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));
So, you were using that inportl function and you weren't returning anything, and you don't know why?

Re: accessing the network card

Posted: Fri May 21, 2010 3:29 am
by aloktiagi
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

Posted: Fri May 21, 2010 3:35 am
by montrom

Re: accessing the network card

Posted: Fri May 21, 2010 5:18 am
by eddyb
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));
}

You realize int is signed 32-bit, do you?

Re: accessing the network card

Posted: Fri May 21, 2010 10:51 pm
by aloktiagi
@eddyb:my return value should be unsigned int 16bit

and

@montrom : my return value should be of unsigned char type

:?: :?: :?:

Re: accessing the network card

Posted: Sat May 22, 2010 12:47 am
by montrom
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.

Re: accessing the network card

Posted: Sun May 23, 2010 10:03 pm
by aloktiagi
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??

Re: accessing the network card

Posted: Mon May 24, 2010 12:45 am
by montrom
Does the specification state that there is supposed to be a value in each BAR?

Re: accessing the network card

Posted: Mon May 24, 2010 9:04 am
by ehenkes
PrettyOS, util.c:

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));
}
look at pci.c how we manage this.

Re: accessing the network card

Posted: Thu Jun 03, 2010 10:18 am
by ehenkes
@aloktiagi: how are things going on? :D