
How a computer boots up - randhckr
http://duartes.org/gustavo/blog/post/how-computers-boot-up
======
scott_s
Back in grad school, I put together a presentation that talks about the boot
process for a Linux machine, with a focus on what happens after the kernel
takes over: <http://people.cs.vt.edu/~scschnei/papers/boot_2up.pdf>

~~~
mcdillon
That just brought me back to McBryde 226 where I took OS, thanks for the good
read!

------
dclowd9901
One thing has always perplexed me: What is the very first thing that happens?
The thing that tells the firmware to initialize? In other words, how does does
the firmware "know" to initialize?

~~~
jbert
Old 8bit processors just start with the instruction pointer at a known value
(e.g. 0x0000).

If you arrange matters so that until the CPU tells you differently, memory
address 0x0000 holds your firmware, then all can proceed from there.

~~~
joshu
Wouldnt 0 cause problems? You accidentally branch to null, machine reboots.

~~~
msarnoff
In C, a "null pointer" (NULL, (void *)0, etc.) does not necessarily correspond
to an address with all bits zero.[1] The compiler translates any pointer
constants with a value of 0 to an invalid address appropriate for that
machine.

I haven't verified this, but I could see this being used by microcontroller
compilers, where address 0x0000 is often a memory-mapped register.

[1] <http://c-faq.com/null/index.html>

~~~
dkersten
Also the C null pointer on modern system is the logical (virtual memory)
address which is not necessarily mapped to 0x0 physical address - in fact, to
trap the null pointer access, this page would be left unmapped so the OS
receives a page fault. This means that before virtual memory is set up (or if
a page is mapped for logical address 0x0), 0x0 is a perfectly valid memory
location, both for data storage and executing instructions from. Basically,
the null pointer "error" is trapped by the OS at a higher level.

~~~
scott_s
In fact, there's an entire class of kernel exploits where if you know a
certain kind of behavior will cause the kernel to dereference 0x0, _and_ that
system allows you to mmap the lowest page in your virtual address space, you
can take over the machine.

See
[https://blogs.oracle.com/ksplice/entry/much_ado_about_null_a...](https://blogs.oracle.com/ksplice/entry/much_ado_about_null_an1)
and
[https://blogs.oracle.com/ksplice/entry/much_ado_about_null_e...](https://blogs.oracle.com/ksplice/entry/much_ado_about_null_exploiting1)

(dkersten, I assume you know this, I'm pointing it out for the benefit of
others.)

------
sounds
Nice article/blog post from 2008. If you want to keep reading, the next
article is <http://duartes.org/gustavo/blog/post/kernel-boot-process>

------
sciurus
Gustavo Duarte has a lot of well-written (and illustrated!) blog posts. With a
little bit of effort they could be combined into a nice ebook.

~~~
samaraga
Some time back, people here referred[1][2] to his posts as one of the
interesting programming blogs they read.

[1] <http://news.ycombinator.com/item?id=3120706> [2]
<http://news.ycombinator.com/item?id=3131380>

------
agumonkey
For alternative knowledge, check Coreboot aka linux as BIOS.

Here's a video talking about inner workings of the boot process
<http://www.youtube.com/watch?v=X72LgcMpM9k#t=438s>

url linked at 7min, but it's actually 3x15min talks. have fun watching them
all :p

------
iRobot
A Few times I have prised out the Eprom off the motherboard and re-flashed it
with my own small programs for a super-fast embedded system or game. (the
eprom is ussally the only socketed item on the motherboard apart from the CPU)

The main problem is not overwritting the BIOS routines which, unless you
rewrite them all (like linux of windows do) you still need to use (nothing
here has really changed since 1981 and you can use anything that produces 16
bit code such as Turbo C, Assembler or Pascal)

Usually there is plenty of spare EPROM space you can find and as your running
in 16 bit mode this is enough for something like space invaders :-)

PC Motherboards can usually be blagged for nothing, so its a great way to do
low level experimenting.

------
sebastianavina
nice

------
InclinedPlane
(Normally I try to avoid joke posts, but I'll just leave this here and let
people up or down vote to their preference.)

How a computer boots up:

LI1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010

