Page 1 of 1

Inportb and reboot:

Posted: Sun Nov 10, 2002 11:35 am
by Tom
Hello, when I use this code with ints ENabled, the computer reboots:

__inline__ unsigned inportb(unsigned port)
{
   unsigned ret_val;

   __asm__ __volatile__("inb %w1,%b0"
      : "=a"(ret_val)
      : "d"(port));

   return ret_val;
}

why?

Re:Inportb and reboot:

Posted: Mon Nov 11, 2002 6:50 am
by Tim
Because it's wrong somehow.

We can't tell why though. That single function looks correct to me.

Re:Inportb and reboot:

Posted: Mon Nov 11, 2002 9:11 pm
by Tom
[attachment deleted by admin]

Re:Inportb and reboot:

Posted: Mon Nov 11, 2002 11:33 pm
by Zi
Tom wrote: Hello, when I use this code with ints ENabled, the computer reboots:

__inline__ unsigned inportb(unsigned port)
{
unsigned ret_val;

__asm__ __volatile__("inb %w1,%b0"
: "=a"(ret_val)
: "d"(port));

return ret_val;
}

why?
there are 2 % in registers.
Try like this :

Code: Select all

__inline__ unsigned inportb(unsigned port)
{
   unsigned ret_val;

   __asm__ __volatile__("inb %%w1,%%b0"
      : "=a"(ret_val)
      : "d"(port));

   return ret_val;
}
ans say if it works. You can see my OS at : http://www.boost.ht.st/indexo.php
and download it at : http://boost.zaphebergeur.net/indexo.php?page=dl

Re:Inportb and reboot:

Posted: Tue Nov 12, 2002 10:00 am
by Tom
why would the %'s have to do anything if it works With Out ints disabled? I think it's just my silly IDT I had...trying a new IDT...

Re:Inportb and reboot:

Posted: Tue Nov 12, 2002 10:09 am
by Pype.Clicker
i don't know how your code is relocated, but the DW IRQx in your IDT table is likely to trouble most linkers ... maybe you should check your loaded IDT is looking like what you expect ...

Re:Inportb and reboot:

Posted: Tue Nov 12, 2002 10:30 am
by Tom
I found this one that nu...(forgot the rest of is post name) uses on some OS dev site...testing that...I think it works but I forgot to put code to print a message if the IDT was loaded :-[

Anyway...i'll test it in a bit....