From e910de8475e456dfee0d299b799f597a503d9766 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Fri, 14 Jul 2017 11:28:35 +0200 Subject: added a drafted version of the AbaOS intro --- content/blog/abaos-intro.md | 109 +++++++++++++++++++++++++++++++ static/images/blog/abaos-intro/abaos.png | Bin 0 -> 65349 bytes 2 files changed, 109 insertions(+) create mode 100644 content/blog/abaos-intro.md create mode 100644 static/images/blog/abaos-intro/abaos.png diff --git a/content/blog/abaos-intro.md b/content/blog/abaos-intro.md new file mode 100644 index 0000000..d92c7b7 --- /dev/null +++ b/content/blog/abaos-intro.md @@ -0,0 +1,109 @@ ++++ +title = "AbaOS - Intro" +categories = [ "Operating System", "AbaOS", "Development" ] +date = "2017-07-14T10:50:39+02:00" +thumbnail = "/images/blog/abaos-intro/abaos.png" +draft = true + ++++ + +## History + +It started with a question from a collegue at work: "Why +are all operating systems nowadays written in C?". + +I wanted to dig deeper... + +## Resources + +Some years ago it would have been extremly tedious to write +an operating system on your own. Don't get me wrong, it's still +a tremendous task, and I don't think anybody should do it for +the sake of proving the world, he is able to build the best +operating system ever. + +PC emulators like [Qemu](http://www.qemu.org) and +[Bochs](http://bochs.sourceforge.net) (to name two open-source ones) +make testing really easy compared to dual-booting. + +Tutorials are around everywhere, especially nice are video tutorials +of people who are actually implementing an operating system with +you "live". + +I used two of them: + +- [Writing a Simple Operating System - from Scratch, Nick Blundell](https://www.youtube.com/watch?v=YvZhgRO7hL4) +- [Write your own Operating System, Viktor Engelmann](http://wyoos.org/) + +Nice web page are, two pick two of them: + +- [OSDEV Wiki](http://wiki.osdev.org/Main_Page) +- [Lowlevel.eu](http://lowelevel.eu) + +## Details + +I'm using standard C99 with either gcc, clang, tcc or pcc currently for +the C parts. NASM for the assembly parts. No inline-assembly. I want +to see clearly where the CPU/machine-dependent parts are. + +One goal is to write a minimal self-hosting operating system. This is +a long way to go. Many tools like make, binutils, nasm, compilers require +some part of a POSIX environment. + +So far the simplest explanation I have for everybody using C is simple: + +- the operating system has been written in C ages ago +- every possible library build on top, and nobody wants to rewrite + everything all the time +- the most prominent platform is Intel, and Intel has some special + "features" like I/O ports and alignment, packing of structures which + requires some low-level features from a language. C has those features + (alignment and packing). Other platforms may be less quirky and old + and be less demanding on the language to provide such features. +- open API specification: Cdecl calling conversion is available everywhere. + The reason why so many scripting languages are popular, is that they + can reuse APIs via the Cdecl layer. +- there is a lot documentation about how to do operating system tasks + in C, there are not so many around for other languages. + +This said, C++, D, Ada, Pascal are valid alternatives for building an +operating system, to name two examples: + +- C++ has been used for [Haiku](https://www.haiku-os.org) +- Pascal for [Ultibo](https://ultibo.org/) on RaspberryPi + +For embedded or special purpose operating systems it's more feasable +to use another language than C. + +Don't be fooled, if I say C, this doesn't mean you cannot benefit early +with from an object oriented design, as soon PCI with loadable drivers +or a widget libary come into play. The following articles are useful +to build simple-inheritance with C: + +- http://www.drdobbs.com/extending-c-for-object-oriented-programm/184402731 +- https://www.state-machine.com/doc/AN_OOP_in_C.pdf +- https://www.cs.rit.edu/~ats/books/ooc.pdf +- https://dmitryfrank.com/articles/oop_in_c + +And, yes, the Linux kernel applies exactly this principle, as we can see +in https://lwn.net/Articles/444910/. + +## Status + +I'm following the Wyoss guide and try to do almost everything in C which +was done in C++ in the tutorial. I'm also deviating a little bit by: + +- having my own small little C library (src/libc) +- I wrote a boot loader (yes, I know the comments on OsDev regarding + writing one). Nevertheless it's informational and has some historic + value. +- I try to use as many compilers and cross-compilers as possible not + just one toolchain. + +## Sources + +As always you can find the sources of the project on my person git +repository at: + +http://git.andreasbaumann.cc/cgit/abaos/ + diff --git a/static/images/blog/abaos-intro/abaos.png b/static/images/blog/abaos-intro/abaos.png new file mode 100644 index 0000000..83364b7 Binary files /dev/null and b/static/images/blog/abaos-intro/abaos.png differ -- cgit v1.2.3-54-g00ecf