Live data from Hacker News

Operating Systems: From 0 to 1

tuhdo.github.io

11–20 of 82 posts

Re: Operating Systems: From 0 to 1

#11
Seems to be for a x86 operating system. I'd have preferred some other architecture because so much of OSdev for x86 that I remember was working around quirks of the architecture (A20 gate etc.). I guess it's a valuable lesson but I'd really enjoy a fork of the book for the hardware you find in a Beagle Bone or Pi3 or something. Maybe this could be crowdfunded if the x86 version is popular?

Re: Operating Systems: From 0 to 1

#12
post #11

Seems to be for a x86 operating system. I'd have preferred some other architecture because so much of OSdev for x86 that I remember was working around quirks of the architecture (A20 gate etc.). I guess it's a valuable lesson but I'd really enjoy a fork of the book for the hardware you find in a Beagle Bone or Pi3 or something. Maybe this could be crowdfunded if the x86 version is popular?

Author here. Yes, it's a x86 operating system. However, rather than getting around A20, it focused on protected mode instead.

The book not only teaches x86, but how to use the official resources from the hardware manufacturer to write the OS. In sum, a reader when reaching part 3 for writing the OS, he will need to use the official document, in this case, the "System Programming Guide" manual from Intel to write C code that complies with the documents. Once he learned how to do so, learning other platforms will be much easier given how complex x86 is.

Re: Operating Systems: From 0 to 1

#13

I have on my list to read something along the lines like this, but this seems incomplete. Does anyone have anything similar?

This is what I'm planning to read as soon as I've learned assembly: http://www.brokenthorn.com/Resources/OSDevIndex.html

I graduated from that guide :) You can see the repo here, written entirely in NASM: https://github.com/tuhdo/os-study

The problem is that the guide is out of date in terms of toolchain, and you need to figure out many things by yourself, especially if you want to develop on Linux. My book helps you to understand how to learn and write x86 with Intel manuals (this is really important!), understand how to craft a custom ELF binary that is debuggable on bare metal, which in turn requires you to understand a bit of how debugger works.

Once you get gdb working, it is much easier to learn how to write an operating system.

Re: Operating Systems: From 0 to 1

#14

I have on my list to read something along the lines like this, but this seems incomplete. Does anyone have anything similar?

It is complete, if you finish the first 2 parts, which consists of 8 chapters. Then you can work on your own by reading the Intel manual volume 3 "System Programming Guide", or learning from OSDev wiki. The first two parts provide a foundation to use such resources, which I think is more important than a step by step guiding how to write an OS.

Re: Operating Systems: From 0 to 1

#15
From the book:

"If a programmer writes software for a living, he should better be specialized in one or two problem domains outside of software if he does not want his job taken by domain experts who learn programming in their spare time."

Seems a bizarre sentiment, but after reading this sentence, I feel like I really wanna donate some money to the guy. If he gives a way I will surely do.

Re: Operating Systems: From 0 to 1

#16
post #12
post #11

Seems to be for a x86 operating system. I'd have preferred some other architecture because so much of OSdev for x86 that I remember was working around quirks of the architecture (A20 gate etc.). I guess it's a valuable lesson but I'd really enjoy a fork of the book for the hardware you find in a Beagle Bone or Pi3 or something. Maybe this could be crowdfunded if the x86 version is popular?

Author here. Yes, it's a x86 operating system. However, rather than getting around A20, it focused on protected mode instead. The book not only teaches x86, but how to use the official resources from the hardware manufacturer to write the OS. In sum, a reader when reaching part 3 for writing the OS, he will need to use the official document, in this case, the "System Programming Guide" manual from Intel to write C co…

> Author here. Yes, it's a x86 operating system. However, rather than getting around A20, it focused on protected mode instead.

You still have to open the A20 gate in the bootloader if you want to access a memory adress that has bit 20 (counting from 0) be set to 1 (you probably want) - even if you switch to protected mode. The only exception is if you boot from UEFI instead of BIOS - in this case the A20 gate is already set. But the book uses BIOS as far as I see it.

Re: Operating Systems: From 0 to 1

#17
post #15

From the book: "If a programmer writes software for a living, he should better be specialized in one or two problem domains outside of software if he does not want his job taken by domain experts who learn programming in their spare time." Seems a bizarre sentiment, but after reading this sentence, I feel like I really wanna donate some money to the guy. If he gives a way I will surely do.

I think the entire section 1.1 can be removed as it seems a bit pompous. Other than that, it seems like a reasonable guide.

Re: Operating Systems: From 0 to 1

#18
post #17
post #15

From the book: "If a programmer writes software for a living, he should better be specialized in one or two problem domains outside of software if he does not want his job taken by domain experts who learn programming in their spare time." Seems a bizarre sentiment, but after reading this sentence, I feel like I really wanna donate some money to the guy. If he gives a way I will surely do.

I think the entire section 1.1 can be removed as it seems a bit pompous. Other than that, it seems like a reasonable guide.

I can see your point, but the section created a nice "atmosphere" for me and it was not too long. I dont know how to express it clearly.

Re: Operating Systems: From 0 to 1

#19
post #16
post #12

Earlier quoted context omitted.

Author here. Yes, it's a x86 operating system. However, rather than getting around A20, it focused on protected mode instead. The book not only teaches x86, but how to use the official resources from the hardware manufacturer to write the OS. In sum, a reader when reaching part 3 for writing the OS, he will need to use the official document, in this case, the "System Programming Guide" manual from Intel to write C co…

> Author here. Yes, it's a x86 operating system. However, rather than getting around A20, it focused on protected mode instead. You still have to open the A20 gate in the bootloader if you want to access a memory adress that has bit 20 (counting from 0) be set to 1 (you probably want) - even if you switch to protected mode. The only exception is if you boot from UEFI instead of BIOS - in this case the A20 gate is alr…

In the Volume 3, it is said that:

"In protected mode, the IA-32 architecture provides a normal physical address space of 4 GBytes (2 32 bytes). This is the address space that the processor can address on its address bus. This address space is flat (unsegmented), with addresses ranging continuously from 0 to FFFFFFFFH. This physical address space can be mapped to read- write memory, read-only memory, and memory mapped I/O. The memory mapping facilities described in this chapter can be used to divide this physical memory up into segments and/or pages."

It correlates to my experience of developing in protected mode in QEMU. Once entered protected mode, I can access to any address above 0x10000 without being wrapped around. When I was writing my first kernel (https://github.com/tuhdo/os-study) in real-mode, indeed A20 must be enabled.

Post reply on HN