diegor2 / self

Meta repo for my projects
0 stars 0 forks source link

RPython boot #2

Open diegor2 opened 7 years ago

diegor2 commented 7 years ago

Simple hello world bootable kernel using pypy's RPython.

diegor2 commented 7 years ago

http://tratt.net/laurie/blog/entries/fast_enough_vms_in_fast_enough_time.html

http://wiki.osdev.org/Tutorials

https://rpython.readthedocs.io/en/latest/examples.html

diegor2 commented 7 years ago

This idea came from this blog post, years ago.

https://jvns.ca/blog/2014/03/12/the-rust-os-story/

Why you can’t write a kernel in Python

So you want to write an operating system, let’s say for x86. You need to write this in a programming language!

Can you write your operating system in Python (using CPython, say)? You cannot. This is not being curmudgeonly! It is actually just not possible.

What happens when you write print "Hello!" in Python?

Well, many things happen. But the last thing that happens is that the CPython interpreter will do something like printf("Hello"). And you might think, well, maybe I could link against the code for printf somehow!

But what printf does is it calls the write() system call. The write() system call is implemented IN YOUR KERNEL.

OH WAIT YOU DON’T HAVE A KERNEL YET. YOU ARE WRITING ONE.

This also means that you can’t write a kernel as a “normal” C program which includes C libraries. Any C libraries. All C libraries for Linux are built on top of some version of libc, which makes calls to the Linux kernel! So if you’re writing a kernel, this doesn’t work.

diegor2 commented 7 years ago

https://hub.docker.com/r/pwootage/gcc5-i686-elf/