Bran's Kernel Development Tutorial Known Bugs: Difference between revisions

no edit summary
[unchecked revision][unchecked revision]
m (Added category)
No edit summary
Line 32:
 
If you still have problems, you may need to change the output format of the nasm command in the build.bat to make an [[ELF]] file instead of [[a.out]].
 
===timer_wait never returns===
The provided method to wait a number of timer ticks never returns because the <code>timer_ticks</code> variable is not defined as volatile. Changing its definition to <code>volatile unsigned int timer_ticks = 0;</code> will make the <code>timer_wait()</code> function work.
 
Also, instead of busy waiting, the processor could be put into sleep in order to save power. It can be done like this:
<syntaxhighlight lang="c">
void timer_wait(int ticks)
{
unsigned int eticks;
 
eticks = timer_ticks + ticks;
while(timer_ticks < eticks)
{
__asm__ __volatile__ ("sti//hlt//cli");
}
}
</syntaxhighlight>
 
===References===
Anonymous user