LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Do i need integer to hex conversion, if yes how??? (https://www.linuxquestions.org/questions/linux-newbie-8/do-i-need-integer-to-hex-conversion-if-yes-how-722713/)

payu21 04-30-2009 09:08 AM

Do i need integer to hex conversion, if yes how???
 
hie all,

-------------------------------------------------
void Clear_ControlPort_bit(int a)

{
int t;
printf("a=%i\n",a);

if(a<8)

{

if(a==0||a==1||a==3)
{
printf("reading controlport\n");
printf("identifier = %d \n",_BV(a));
printf("p = %d \n",p);
a = p|_BV(a);

/* not going to read loop but taking p value*/
printf("a=%i\n",a);

Write_ControlPort(a);


}
//else

//Write_ControlPort(t&~_BV(a));

}
return;

-----------------------------------------------------------------*/

void Write_ControlPort(int a)

{
printf("writing to port\n");
outb(a,ControlPort);
return;

}
------------------------
Do i need to convert the value of a to hex before writing to control port??? Because its showing a segmentation fault at "outb"

please help me

johnsfine 04-30-2009 09:30 AM

How about a little context of what you are trying to do?

I don't know what weird device you might be trying to control, so I'm a tiny bit short of 100% certain no form of conversion to hex is required before writing to its port. (That answers your explicit question).

Linux is a protected OS, so ordinary code can't ordinarily write to ports. So that is probably the source of the fault.

If you have done something to make writing to that port valid, that should have been part of the context you should have provided for your question.

If you haven't done anything to make writing to that port valid, here is the first link I found just now googling the topic:
http://www.faqs.org/docs/Linux-mini/...ing.html#ss2.1
It seems to be a good explanation of the basics.


All times are GMT -5. The time now is 06:46 AM.