Inportb and reboot:

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
Tom

Inportb and reboot:

Post 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?
Tim

Re:Inportb and reboot:

Post by Tim »

Because it's wrong somehow.

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

Re:Inportb and reboot:

Post by Tom »

[attachment deleted by admin]
Zi

Re:Inportb and reboot:

Post 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
Tom

Re:Inportb and reboot:

Post 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...
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Inportb and reboot:

Post 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 ...
Tom

Re:Inportb and reboot:

Post 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....
Post Reply