User:Alexander/Combining Bran's Kernel Development and the Barebones Tutorials: Difference between revisions

Content deleted Content added
Alexander (talk | contribs)
Create Page
 
m Bot: Replace deprecated source tag with syntaxhighlight
 
(6 intermediate revisions by 4 users not shown)
Line 1:
{{Template:In Progress}}
<!--{{Rating|1}}-->
{{
{{Rating|1}}
This guide is aimed to help you combine the [http://www.osdever.net/tutorials/view/brans-kernel-development-tutorial Bran's Kernel Development] and the [[Barebones]] tutorials. This way you get the more modern gcc arguments, etc. and the clear explanation of interupts and nasm syntax assembly. This guide will also implement the fixes found in [[Bran's Known Bugs]]. It is recommended that you read both tutorials fully first as this guide will only tell you what to change some of the instructions in Bran's into. The sections of this guide are the same as the pages of Bran's tutorial
 
 
== Getting Started ==
Make sure you are using a [[GCC Cross Compiler]]. Using DJGPP is not officially supported on newer systems than Windows XP. So sticking with the GCC Cross Compiler(i686) used in the Barebones tutorial is advised.
 
 
== The Basic Kernel ==
Line 21 ⟶ 18:
== Creating Main and Linking C Sources ==
The tutorial wants you to add:
<sourcesyntaxhighlight lang="asm">
extern _main
call _main
</syntaxhighlight>
</source>
into the correct place in your start.asm file. Use this instead:
<sourcesyntaxhighlight lang="asm">
extern main
call main
</syntaxhighlight>
</source>
Compiling the C sources in this tutorial should be done with:
<pre>
Line 38 ⟶ 35:
== Printing to the screen ==
I recommend you use the terminal/vga functions from the [[Barebones]] tutorial. You can use Bran's <code>cls()</code>, <code>move_csr()</code> and <code>scroll()</code> functions as long as you replace <code>csr_x</code> and <code>csr_y</code> to <code>terminal_column</code> and <code>terminal_row</code>. You also want to make sure you have a global <code>unsigned short *textmemptr</code> and you set it's adress in your <code>terminal_initialize</code> by adding this line:
<sourcesyntaxhighlight lang="c">textmemptr = (unsigned short *)0xB8000;</sourcesyntaxhighlight>
 
== The GDT ==
Line 54 ⟶ 51:
== The PIT: A System Clock ==
Make sure you replace:
<sourcesyntaxhighlight lang="c">
int timer_ticks = 0;
</syntaxhighlight>
</source>
with:
<sourcesyntaxhighlight lang="c">
volatile inint timer_ticks = 0;
</syntaxhighlight>
</source>
And that you also replace:
<sourcesyntaxhighlight lang="c">
irq_install_handler(0, timer_handler);
</syntaxhighlight>
</source>
with:
<sourcesyntaxhighlight lang="c">
irq_install_handler(0, (unsigned) timer_handler);
</syntaxhighlight>
</source>
To preserve power when waiting with the <code>timer_wait()</code> function you can replace:
<sourcesyntaxhighlight lang="c">
while(timer_ticks < eticks);
</syntaxhighlight>
</source>
with:
<sourcesyntaxhighlight lang="c">
while(timer_ticks < eticks)__asm__ __volatile__("hlt");{
__asm__ __volatile__("hlt");
</source>
}
</syntaxhighlight>