618
edits
[unchecked revision] | [unchecked revision] |
(Added a Next Steps section about writing new drivers) |
m (Reverted edits by Strokegmd (talk) to last revision by Khaledhammouda) |
||
(10 intermediate revisions by 7 users not shown) | |||
Line 8:
=== Separate Sources ===
Your kernel will have functions that contain what is called '''generic''' and '''targeted''' code. For example: a puts() implementation will be generic, while the screen driver that puts() uses to draw the string to the output device would be targeted to a specific implementation. Before you begin trying to code for more than one platform, separate your sources so any targeted functions are in a different location than generics. This creates an abstraction layer between hardware drivers and pure software.
Targeted code can be further divided into two categories: architecture-specific code and machine-specific code. Architecture-specific code is code that differs between different processor architectures, like I/O, trap dispatching, and paging. Machine-specific code is code that differs between machines with the same processor architectures, like IRQ controllers, system timers, real time clocks, and multiprocessor information. The NT kernel has a module containing machine-specific code called the Hardware Abstraction Layer, or HAL.
=== Code! ===▼
After the targeted files are separated, you can make new targeted functions for each platform you want to port to. The generic code will (usually) run without issue on top of the targeted code. A brief side note, make sure to delete the object files after you re-target, as object files are not cross compatible.
Line 17 ⟶ 19:
== Example Targeted Functions ==
*
* CPU Specific functions (
* Timers (PIT, RTC, APIC Timer, HPET)
== Example Generic Functions ==
Line 26 ⟶ 28:
* String parsing functions
* Buffered I/O (gets, putchar, etc)
[[Category:Porting]]
[[Category:OS theory]]
[[Category:FAQ]]
|