├── .gitignore ├── CHANGELOG.md ├── Operating_Systems_From_0_to_1.pdf ├── README.md ├── _config.yml ├── book_src ├── Operating Systems From 0 to 1.lyx ├── Operating Systems From 0 to 1.txt ├── images │ ├── .rid │ ├── 01 │ │ ├── domains_general.pdf │ │ ├── domains_general.svg │ │ ├── domains_os_example.pdf │ │ └── domains_os_example.svg │ ├── 02 │ │ ├── 4-bit-or-gate-layout.pdf │ │ ├── 4-bit-or-gate-layout.svg │ │ ├── 7400_bin_string1.pdf │ │ ├── 7400_bin_string1.svg │ │ ├── 7400_bin_string1_2.svg │ │ ├── 7400_block_diagram.png │ │ ├── 7400_logic_diagram.png │ │ ├── 7400_pin_configuration.pdf │ │ ├── 7400_pin_configuration.png │ │ ├── 7400_pin_configuration.svg │ │ ├── 74hc00_nxp_physical.jpg │ │ ├── Digital_logic_gates.svg │ │ ├── Digital_logic_gates_backup.svg │ │ ├── Nand-gate.svg │ │ ├── and-gate.pdf │ │ ├── and-gate.svg │ │ ├── asm_to_proglang.pdf │ │ ├── asm_to_proglang.svg │ │ ├── bulb.svg │ │ ├── decoder-ex.pdf │ │ ├── decoder-ex.svg │ │ ├── digraph.pdf │ │ ├── digraph.svg │ │ ├── inverter-0.png │ │ ├── inverter-1.png │ │ ├── layer_translation.graphml │ │ ├── layer_translation.pdf │ │ ├── layer_translation.svg │ │ ├── logic-gate-23330.svg │ │ ├── logic_gates.gif │ │ ├── logic_gates.svg │ │ ├── nand-00.png │ │ ├── nand-01.png │ │ ├── nand-10.png │ │ ├── nand-11.png │ │ ├── nor-gate.pdf │ │ ├── nor-gate.svg │ │ ├── not-gate.pdf │ │ ├── not-gate.svg │ │ ├── npn.svg │ │ ├── or-gate-ex.pdf │ │ ├── or-gate-ex.svg │ │ ├── or-gate-layout-ex.pdf │ │ ├── or-gate-layout-ex.svg │ │ ├── or-gate.pdf │ │ ├── or-gate.svg │ │ ├── proglang_to_asm.pdf │ │ ├── proglang_to_asm.svg │ │ └── transistor.svg │ ├── 03 │ │ ├── .rid │ │ ├── 128px-Apple_A5_Chip.jpg │ │ ├── 256px-Nintendo-DS-Lite-w-stylus.png │ │ ├── Cypress PSoC.jpg │ │ ├── Intel_82815_GMCH.jpg │ │ ├── Macbook__ipad__iphone.svg │ │ ├── Motherboard_diagram.svg │ │ ├── Motherboard_diagram_backup.svg │ │ ├── Motherboard_diagram_backup_backup.svg │ │ ├── PS4-Console-wDS4.jpg │ │ ├── PlayStation-Vita.png │ │ ├── Raspberry_Pi.svg │ │ ├── Raspberry_Pi_2_Model_B.jpg │ │ ├── Raspberry_Pi_B.pdf │ │ ├── Raspberry_Pi_backup.svg │ │ ├── Wii_U_Console_and_Gamepad.png │ │ ├── Wii_U_console_illustration.svg │ │ ├── Wikimedia_Foundation_Servers-8055_35.jpg │ │ ├── Xbox_One_Console_Set.jpg │ │ ├── computer-1295241.svg │ │ ├── computer-158675.svg │ │ ├── cpu_chipset_memory.pdf │ │ ├── cpu_chipset_memory.svg │ │ ├── cpu_memory_chipset.pdf │ │ ├── cpu_memory_chipset.svg │ │ ├── fpga_400x212.jpg │ │ ├── macbook.pdf │ │ ├── macbook.svg │ │ ├── medium-PIC18F4620-PDIP-40.png │ │ ├── mobile_phone.pdf │ │ ├── mobile_phone.svg │ │ ├── nintendo-30594.svg │ │ ├── pc.svg │ │ ├── q35_system_block_diagram.png │ │ ├── q35_system_block_diagram.svg │ │ ├── server.svg │ │ ├── tablet.pdf │ │ ├── tablet.svg │ │ ├── von_neumann_architecture.pdf │ │ ├── von_neumann_architecture.svg │ │ └── von_neumann_architecture_backup.svg │ ├── 04 │ │ ├── .rid │ │ ├── bit_field_data_type.pdf │ │ ├── bit_field_data_type.svg │ │ ├── far_jmp_ex.pdf │ │ ├── far_jmp_ex.svg │ │ ├── fundamental_data_types.pdf │ │ ├── fundamental_data_types.svg │ │ ├── modrm32.tex │ │ ├── pointer_data_type.pdf │ │ ├── pointer_data_type.svg │ │ ├── sar.pdf │ │ ├── sar.svg │ │ ├── shl_sal.pdf │ │ ├── shl_sal.svg │ │ ├── shr.pdf │ │ ├── shr.svg │ │ ├── x86_instruction_format.pdf │ │ └── x86_instruction_format.svg │ ├── 05 │ │ ├── .rid │ │ ├── Elf-layout--en.pdf │ │ └── Elf-layout--en.svg │ ├── 06 │ │ ├── .rid │ │ ├── dwarf_tree.png │ │ └── dwarf_tree.svg │ ├── 07 │ │ ├── .rid │ │ ├── Cylinder_Head_Sector.svg │ │ ├── Disk-structure.pdf │ │ ├── Disk-structure.svg │ │ ├── Disk_heads.pdf │ │ ├── Disk_heads.svg │ │ ├── boot_fail1.png │ │ ├── boot_succeeded.png │ │ ├── simple_boot_process.pdf │ │ └── simple_boot_process.svg │ └── 08 │ │ ├── .rid │ │ ├── bad_debug_mapping.svg │ │ ├── binary_layout_good.pdf │ │ ├── binary_layout_good.svg │ │ ├── debug_info_bad_position.pdf │ │ ├── debug_info_bad_position.svg │ │ ├── good_debug_mapping.svg │ │ ├── mem_after_load_os.pdf │ │ ├── mem_after_load_os.svg │ │ ├── no_FILEHDR.pdf │ │ ├── no_FILEHDR.svg │ │ ├── with_FILEHDR.pdf │ │ └── with_FILEHDR.svg └── references.bib └── code ├── chapter7 └── os │ ├── .gdbinit │ ├── Makefile │ ├── bootloader │ ├── Makefile │ ├── bootloader.asm │ └── debug.elf │ ├── build │ ├── bootloader │ │ └── bootloader.o │ └── os │ │ └── sample.o │ ├── disk.img │ └── os │ ├── Makefile │ └── sample.asm └── chapter8 └── os ├── .gdbinit ├── Makefile ├── bootloader ├── Makefile ├── bootloader.asm ├── bootloader.dbg └── bootloader.lds ├── build ├── bootloader │ ├── bootloader.elf │ ├── bootloader.o │ └── bootloader.o.elf ├── disk.img ├── main.o └── os │ ├── main.o │ ├── os │ ├── os.debug │ └── sample.o ├── disk.img └── os ├── .#os ├── Makefile ├── main ├── main.c ├── os ├── os.lds └── sample.asm /.gitignore: -------------------------------------------------------------------------------- 1 | *.png 2 | *.lyx~ 3 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.0.1 (2017-02-15) 2 | 3 | * [#6] Fix the figure `far_jmp_ex.svg` in chapter 4, where the segment and the offset in memory are reversed. 4 | * [#7] Fix example 5.3.1: change NULL section to .interp section. 5 | * [#8] Fix command output to reflect the source code. 6 | * [#9] abort(), not .abort(). A function call, not a section. 7 | * [#10] Use `__FUNCTION__` for consistency. 8 | * [#11] Fix incorrect filename. 9 | * [#12] Fix confusing sentence. 10 | * [#13] Fix a typo. 11 | -------------------------------------------------------------------------------- /Operating_Systems_From_0_to_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/Operating_Systems_From_0_to_1.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=tuhdo1710%40gmail%2ecom&lc=VN&item_number=tuhdo¤cy_code=USD&bn=PP%2dDonationsBF%3aDonate%2dPayPal%2dgreen%2esvg%3aNonHosted) 3 | 4 | [Operating Systems: From 0 to 1](https://tuhdo.github.io/os01/) 5 | ============================= 6 | 7 | This book helps you gain the foundational knowledge required to write an 8 | operating system from scratch. Hence the title, 0 to 1. 9 | 10 | After completing this book, at the very least you will learn: 11 | 12 | - How to write an operating system from scratch by reading hardware datasheets. 13 | In the real world, it works like that. You won't be able to consult Google for 14 | a quick answer. 15 | 16 | - A big picture of how each layer of a computer is related to the other, from hardware to software. 17 | 18 | - Write code independently. It's pointless to copy and paste code. Real learning 19 | happens when you solve problems on your own. Some examples are given to kick 20 | start, but most problems are yours to conquer. However, the solutions are 21 | available online for you to examine after giving it a good try. 22 | 23 | - Linux as a development environment and how to use common tools for low-level 24 | programming. 25 | 26 | - x86 assembly in-depth. 27 | 28 | - How a program is structured so that an operating system can run. 29 | 30 | - How to debug a program running directly on hardware with gdb and QEMU. 31 | 32 | - Linking and loading on bare metal x86_64, with pure C. No standard library. No 33 | runtime overhead. 34 | 35 | [Download the book](https://github.com/tuhdo/os01/blob/master/Operating_Systems_From_0_to_1.pdf) 36 | 37 | # The pedagogy of the book 38 | 39 | > You give a poor man a fish and you feed him for a day. You teach him to fish 40 | > and you give him an occupation that will feed him for a lifetime. 41 | 42 | This has been the guiding principle of the book when I was writing it. The book does 43 | not try to teach you everything, but enough to enable you to learn by yourself. 44 | The book itself, at this point, is quite "complete": once you master part 1 and 45 | part 2 (which consist of 8 chapters), you can drop the book and learn by 46 | yourself. At this point, smart readers should be able to continue on their own. 47 | For example, they can continue their journeys 48 | on [OSDev wiki](http://wiki.osdev.org/Main_Page); in fact, after you study 49 | everything in part 1 and part 2, you only meet 50 | the [minimum requirement](http://wiki.osdev.org/Required_Knowledge) by OSDev 51 | Wiki (well, not quite, the book actually goes deeper for the suggested topics). 52 | Or, if you consider developing an OS for fun is impractical, you can continue 53 | with a Linux-specific book, such as this free 54 | book [Linux Insides](https://0xax.gitbooks.io/linux-insides/content/), or other 55 | popular Linux kernel books. The book tries hard to provide you a strong 56 | foundation, and that's why part 1 and part 2 were released first. 57 | 58 | The book teaches you core concepts, such as x86 Assembly, ELF, linking and 59 | debugging on bare metal, etc., but more importantly, where such information 60 | come from. For example, instead of just teaching x86 Assembly, it also teaches 61 | how to use reference manuals from Intel. Learning to read the official 62 | manuals is important because only the hardware manufacturers themselves 63 | understand how their hardware work. If you only learn from the secondary 64 | resources because it is easier, you will never gain a complete understanding of 65 | the hardware you are programming for. Have you ever read a book on Assembly, and 66 | wondered where all the information came from? How does the author know 67 | everything he says is correct? And how one seems to magically know so much about 68 | hardware programming? This book gives pointers to such questions. 69 | 70 | As an example, you should skim through chapter 4, "x86 Assembly and C", to see 71 | how it makes use of the Intel manual, Volume 2. And in 72 | the process, it guides you how to use the official manuals. 73 | 74 | Part 3 is planned as a series of specifications that a reader will implement to 75 | complete each operating system component. It does not contain code aside from a 76 | few examples. Part 3 is just there to shorten the reader's time when reading the 77 | official manuals by giving hints where to read, explaining difficult concepts 78 | and how to use the manuals to debug. In short, the implementation is up to the 79 | reader to work on his or her own; the chapters are just like university assignments. 80 | 81 | # Prerequisites 82 | 83 | Know some circuit concepts: 84 | + Basic Concepts of Electricity: atoms, electrons, protons, neutrons, current flow. 85 | + Ohm's law 86 | 87 | However, if you know absolutely nothing about electricity, you can quickly learn it here: 88 | , by reading chapter 1 and chapter 2. 89 | 90 | C programming. In particular: 91 | 92 | + Variable and function declarations/definitions 93 | 94 | + While and for loops 95 | 96 | + Pointers and function pointers 97 | 98 | + Fundamental algorithms and data structures in C 99 | 100 | Linux basics: 101 | 102 | + Know how to navigate directory with the command line 103 | 104 | + Know how to invoke a command with options 105 | 106 | + Know how to pipe output to another program 107 | 108 | Touch typing. Since we are going to use Linux, touch typing helps. I know typing 109 | speed does not relate to problem-solving, but at least your typing speed should 110 | be fast enough not to let it get it the way and degrade the learning experience. 111 | 112 | In general, I assume that the reader has basic C programming knowledge, and can 113 | use an IDE to build and run a program. 114 | 115 | # Status: 116 | * Part 1 117 | - Chapter 1: Complete 118 | - Chapter 2: Complete 119 | - Chapter 3: Almost. Currently, the book relies on the Intel Manual for fully explaining x86 execution environment. 120 | - Chapter 4: Complete 121 | - Chapter 5: Complete 122 | - Chapter 6: Complete 123 | * Part 2 124 | - Chapter 7: Complete 125 | - Chapter 8: Complete 126 | * Part 3 127 | - Chapter 9: Incomplete 128 | - Chapter 10: Incomplete 129 | - Chapter 11: Incomplete 130 | - Chapter 12: Incomplete 131 | - Chapter 13: Incomplete 132 | 133 | ... and future chapters not included yet ... 134 | 135 | In the future, I hope to expand part 3 to cover more than the first 2 parts. But 136 | for the time being, I will try to finish the above chapters first. 137 | 138 | # Sample OS 139 | [This repository](https://github.com/tuhdo/sample-os) is the sample OS of the 140 | book that is intended as a reference material for part 3. It covers 10 chapters 141 | of the "System Programming Guide" (Intel Manual Volume 3), along with a simple 142 | keyboard and video driver for input and output. However, at the moment, only the 143 | following features are implemented: 144 | 145 | - Protected mode. 146 | - Creating and managing processes with TSS (Task State Structure). 147 | - Interrupts 148 | - LAPIC. 149 | 150 | Paging and I/O are not yet implemented. I will try to implement it as the book progresses. 151 | 152 | # Contributing 153 | 154 | If you find any grammatical issues, please report it using Github Issues. Or, if 155 | some sentence or paragraph is difficult to understand, feel free to open an 156 | issue with the following title format: `[page number][type] Descriptive Title`. 157 | 158 | For example: `[pg.9][grammar] Incorrect verb usage`. 159 | 160 | `type` can be one of the following: 161 | 162 | - `Typo`: indicates typing mistake. 163 | - `Grammar`: indicates incorrect grammar usage. 164 | - `Style`: indicates a style improvement. 165 | - `Content`: indicates problems with the content. 166 | 167 | Even better, you can make a pull request with the provided book source. The main 168 | content of the book is in the file "Operating Systems: From 0 to 1.lyx". You can 169 | edit the .txt file, then I will integrate the changes manually. It is a 170 | workaround for now since Lyx can cause a huge diff which makes it impossible to 171 | review changes. 172 | 173 | The book is in development, so please bear with me if the English irritates you. 174 | I really appreciate it. 175 | 176 | Finally, if you like the project and if it is possible, please donate to help 177 | this project and keep it going. 178 | 179 | # Got questions? 180 | If you have any question related to the material or the development of the book, 181 | feel free to [open a Github issue](https://github.com/tuhdo/os01/issues/new). 182 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-architect -------------------------------------------------------------------------------- /book_src/images/.rid: -------------------------------------------------------------------------------- 1 | 58f78e5b0bedbe9328c87d501e6feda8 -------------------------------------------------------------------------------- /book_src/images/01/domains_general.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/01/domains_general.pdf -------------------------------------------------------------------------------- /book_src/images/01/domains_general.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 43 | 45 | 46 | 48 | image/svg+xml 49 | 51 | 52 | 53 | 54 | 55 | 60 | 65 | 70 | 76 | Software Domain 87 | Non-software Domains 103 | ApplicationDomain 119 | 120 | 121 | -------------------------------------------------------------------------------- /book_src/images/01/domains_os_example.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/01/domains_os_example.pdf -------------------------------------------------------------------------------- /book_src/images/01/domains_os_example.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 43 | 45 | 46 | 48 | image/svg+xml 49 | 51 | 52 | 53 | 54 | 55 | 60 | 65 | 70 | 76 | Data Structure and Algorithms 92 | Electrical Engineering 108 | OperatingSystem 124 | 136 | 137 | -------------------------------------------------------------------------------- /book_src/images/02/4-bit-or-gate-layout.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/02/4-bit-or-gate-layout.pdf -------------------------------------------------------------------------------- /book_src/images/02/7400_bin_string1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/02/7400_bin_string1.pdf -------------------------------------------------------------------------------- /book_src/images/02/7400_block_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/02/7400_block_diagram.png -------------------------------------------------------------------------------- /book_src/images/02/7400_logic_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/02/7400_logic_diagram.png -------------------------------------------------------------------------------- /book_src/images/02/7400_pin_configuration.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/02/7400_pin_configuration.pdf -------------------------------------------------------------------------------- /book_src/images/02/7400_pin_configuration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/02/7400_pin_configuration.png -------------------------------------------------------------------------------- /book_src/images/02/74hc00_nxp_physical.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/02/74hc00_nxp_physical.jpg -------------------------------------------------------------------------------- /book_src/images/02/Digital_logic_gates.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 20 | 22 | 55 | 57 | 58 | 60 | image/svg+xml 61 | 63 | 64 | 65 | 66 | 72 | 82 | 86 | 90 | 94 | 98 | 102 | 106 | 110 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /book_src/images/02/Digital_logic_gates_backup.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 20 | 22 | 55 | 57 | 58 | 60 | image/svg+xml 61 | 63 | 64 | 65 | 66 | 72 | 82 | 86 | 90 | 94 | 98 | 102 | 106 | 110 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /book_src/images/02/Nand-gate.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 20 | 22 | 23 | 25 | image/svg+xml 26 | 28 | 29 | 30 | 31 | 33 | 50 | A 61 | B 72 | 76 | 84 | 92 | 97 | out 108 | 118 | 119 | -------------------------------------------------------------------------------- /book_src/images/02/and-gate.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/02/and-gate.pdf -------------------------------------------------------------------------------- /book_src/images/02/and-gate.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 44 | 46 | 47 | 49 | image/svg+xml 50 | 52 | 53 | 54 | 55 | 56 | 61 | 66 | 71 | 76 | 81 | A 92 | B 103 | Y 114 | 115 | 116 | -------------------------------------------------------------------------------- /book_src/images/02/asm_to_proglang.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/02/asm_to_proglang.pdf -------------------------------------------------------------------------------- /book_src/images/02/decoder-ex.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/02/decoder-ex.pdf -------------------------------------------------------------------------------- /book_src/images/02/digraph.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/02/digraph.pdf -------------------------------------------------------------------------------- /book_src/images/02/inverter-0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/02/inverter-0.png -------------------------------------------------------------------------------- /book_src/images/02/inverter-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/02/inverter-1.png -------------------------------------------------------------------------------- /book_src/images/02/layer_translation.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/02/layer_translation.pdf -------------------------------------------------------------------------------- /book_src/images/02/layer_translation.svg: -------------------------------------------------------------------------------- 1 | 2 | 21 | 23 | 24 | 26 | image/svg+xml 27 | 29 | 30 | 31 | 32 | 33 | 57 | 58 | 60 | 63 | 65 | 68 | 72 | 73 | 76 | 80 | 81 | 82 | 86 | 94 | 95 | 100 | 108 | Assembly Language 115 | 123 | Logic Gates 130 | 138 | Circuit 145 | 153 | Mathematics 160 | 168 | Problem Domain 175 | 183 | Programming Language 190 | 196 | 202 | 208 | 214 | 220 | 226 | 232 | 238 | 244 | 250 | 256 | 262 | 268 | 274 | 280 | 286 | 287 | 288 | 289 | -------------------------------------------------------------------------------- /book_src/images/02/logic_gates.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/02/logic_gates.gif -------------------------------------------------------------------------------- /book_src/images/02/logic_gates.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 20 | 22 | 23 | 25 | image/svg+xml 26 | 28 | 29 | 30 | 31 | 32 | 34 | 54 | 152 | 153 | -------------------------------------------------------------------------------- /book_src/images/02/nand-00.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/02/nand-00.png -------------------------------------------------------------------------------- /book_src/images/02/nand-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/02/nand-01.png -------------------------------------------------------------------------------- /book_src/images/02/nand-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/02/nand-10.png -------------------------------------------------------------------------------- /book_src/images/02/nand-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/02/nand-11.png -------------------------------------------------------------------------------- /book_src/images/02/nor-gate.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/02/nor-gate.pdf -------------------------------------------------------------------------------- /book_src/images/02/nor-gate.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 46 | 48 | 49 | 51 | image/svg+xml 52 | 54 | 55 | 56 | 57 | 58 | 63 | 68 | 73 | 78 | 83 | 88 | 93 | 99 | 104 | A 115 | A 126 | B 137 | B 148 | Y 159 | 170 | 181 | 182 | 183 | -------------------------------------------------------------------------------- /book_src/images/02/not-gate.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/02/not-gate.pdf -------------------------------------------------------------------------------- /book_src/images/02/not-gate.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 44 | 46 | 47 | 49 | image/svg+xml 50 | 52 | 53 | 54 | 55 | 56 | 61 | 66 | A 77 | A 88 | Y 99 | 100 | 101 | -------------------------------------------------------------------------------- /book_src/images/02/npn.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | nnp 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | ECB 21 | 22 | 23 | -------------------------------------------------------------------------------- /book_src/images/02/or-gate-ex.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/02/or-gate-ex.pdf -------------------------------------------------------------------------------- /book_src/images/02/or-gate-layout-ex.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/02/or-gate-layout-ex.pdf -------------------------------------------------------------------------------- /book_src/images/02/or-gate.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/02/or-gate.pdf -------------------------------------------------------------------------------- /book_src/images/02/or-gate.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 47 | 49 | 50 | 52 | image/svg+xml 53 | 55 | 56 | 57 | 58 | 59 | 64 | 70 | 75 | A 86 | 92 | 97 | 102 | A 113 | B 124 | 135 | B 146 | Y 157 | 158 | 159 | -------------------------------------------------------------------------------- /book_src/images/02/proglang_to_asm.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/02/proglang_to_asm.pdf -------------------------------------------------------------------------------- /book_src/images/02/transistor.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 132 58 | 59 | 60 | -------------------------------------------------------------------------------- /book_src/images/03/.rid: -------------------------------------------------------------------------------- 1 | f5ac4f7ffcf0c9cdf703fb078663fd4e -------------------------------------------------------------------------------- /book_src/images/03/128px-Apple_A5_Chip.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/03/128px-Apple_A5_Chip.jpg -------------------------------------------------------------------------------- /book_src/images/03/256px-Nintendo-DS-Lite-w-stylus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/03/256px-Nintendo-DS-Lite-w-stylus.png -------------------------------------------------------------------------------- /book_src/images/03/Cypress PSoC.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/03/Cypress PSoC.jpg -------------------------------------------------------------------------------- /book_src/images/03/Intel_82815_GMCH.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/03/Intel_82815_GMCH.jpg -------------------------------------------------------------------------------- /book_src/images/03/Macbook__ipad__iphone.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | IPAD 2 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /book_src/images/03/PS4-Console-wDS4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/03/PS4-Console-wDS4.jpg -------------------------------------------------------------------------------- /book_src/images/03/PlayStation-Vita.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/03/PlayStation-Vita.png -------------------------------------------------------------------------------- /book_src/images/03/Raspberry_Pi_2_Model_B.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/03/Raspberry_Pi_2_Model_B.jpg -------------------------------------------------------------------------------- /book_src/images/03/Raspberry_Pi_B.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/03/Raspberry_Pi_B.pdf -------------------------------------------------------------------------------- /book_src/images/03/Wii_U_Console_and_Gamepad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/03/Wii_U_Console_and_Gamepad.png -------------------------------------------------------------------------------- /book_src/images/03/Wikimedia_Foundation_Servers-8055_35.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/03/Wikimedia_Foundation_Servers-8055_35.jpg -------------------------------------------------------------------------------- /book_src/images/03/Xbox_One_Console_Set.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/03/Xbox_One_Console_Set.jpg -------------------------------------------------------------------------------- /book_src/images/03/cpu_chipset_memory.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/03/cpu_chipset_memory.pdf -------------------------------------------------------------------------------- /book_src/images/03/cpu_memory_chipset.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/03/cpu_memory_chipset.pdf -------------------------------------------------------------------------------- /book_src/images/03/fpga_400x212.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/03/fpga_400x212.jpg -------------------------------------------------------------------------------- /book_src/images/03/macbook.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/03/macbook.pdf -------------------------------------------------------------------------------- /book_src/images/03/macbook.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 27 | 31 | 36 | 46 | 51 | 52 | 53 | 75 | 77 | 78 | 80 | image/svg+xml 81 | 83 | 84 | 85 | 86 | 87 | 92 | 98 | 106 | 114 | 120 | 128 | 133 | 139 | 147 | 155 | 156 | 157 | -------------------------------------------------------------------------------- /book_src/images/03/medium-PIC18F4620-PDIP-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/03/medium-PIC18F4620-PDIP-40.png -------------------------------------------------------------------------------- /book_src/images/03/mobile_phone.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/03/mobile_phone.pdf -------------------------------------------------------------------------------- /book_src/images/03/mobile_phone.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 27 | 31 | 36 | 46 | 51 | 52 | 53 | 75 | 77 | 78 | 80 | image/svg+xml 81 | 83 | 84 | 85 | 86 | 87 | 92 | 98 | 106 | 113 | 120 | 128 | 136 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /book_src/images/03/pc.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 43 | 45 | 46 | 48 | image/svg+xml 49 | 51 | 52 | 53 | 54 | 55 | 60 | 64 | 69 | 74 | 79 | 84 | 91 | 100 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /book_src/images/03/q35_system_block_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/03/q35_system_block_diagram.png -------------------------------------------------------------------------------- /book_src/images/03/server.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 20 | 22 | 44 | 46 | 47 | 49 | image/svg+xml 50 | 52 | 53 | 54 | 55 | 56 | 61 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 104 | 107 | 112 | 117 | 122 | 127 | 134 | 143 | 150 | 151 | 152 | 153 | 154 | -------------------------------------------------------------------------------- /book_src/images/03/tablet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/03/tablet.pdf -------------------------------------------------------------------------------- /book_src/images/03/tablet.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 27 | 31 | 36 | 46 | 51 | 52 | 53 | 75 | 77 | 78 | 80 | image/svg+xml 81 | 83 | 84 | 85 | 86 | 87 | 92 | 98 | 106 | 113 | 121 | 129 | 134 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /book_src/images/03/von_neumann_architecture.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/03/von_neumann_architecture.pdf -------------------------------------------------------------------------------- /book_src/images/04/.rid: -------------------------------------------------------------------------------- 1 | 49527604b893e9c9a27465cd47b4ab70 -------------------------------------------------------------------------------- /book_src/images/04/bit_field_data_type.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/04/bit_field_data_type.pdf -------------------------------------------------------------------------------- /book_src/images/04/bit_field_data_type.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 39 | 42 | 43 | 45 | 46 | 48 | image/svg+xml 49 | 51 | 52 | 53 | 54 | 55 | 59 | 66 | LeastSignificantBit 87 | Bit Field 98 | Field Length 109 | 114 | 119 | 122 | 127 | 132 | 133 | 136 | 141 | 146 | 147 | 148 | 149 | -------------------------------------------------------------------------------- /book_src/images/04/far_jmp_ex.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/04/far_jmp_ex.pdf -------------------------------------------------------------------------------- /book_src/images/04/fundamental_data_types.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/04/fundamental_data_types.pdf -------------------------------------------------------------------------------- /book_src/images/04/pointer_data_type.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/04/pointer_data_type.pdf -------------------------------------------------------------------------------- /book_src/images/04/pointer_data_type.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 43 | 48 | 49 | 51 | 52 | 54 | image/svg+xml 55 | 57 | 58 | 59 | 60 | 61 | 66 | Near Pointer 77 | 84 | 0 95 | 31 106 | 113 | 32 124 | 47 135 | 142 | 0 153 | 31 164 | Far Pointer or Logical Address 175 | Segment Selector 186 | Offset 197 | Offset 208 | 209 | 210 | -------------------------------------------------------------------------------- /book_src/images/04/sar.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/04/sar.pdf -------------------------------------------------------------------------------- /book_src/images/04/shl_sal.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/04/shl_sal.pdf -------------------------------------------------------------------------------- /book_src/images/04/shr.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/04/shr.pdf -------------------------------------------------------------------------------- /book_src/images/04/x86_instruction_format.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/04/x86_instruction_format.pdf -------------------------------------------------------------------------------- /book_src/images/05/.rid: -------------------------------------------------------------------------------- 1 | a9ba32dde86cd02374a576cbb347870e -------------------------------------------------------------------------------- /book_src/images/05/Elf-layout--en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/05/Elf-layout--en.pdf -------------------------------------------------------------------------------- /book_src/images/06/.rid: -------------------------------------------------------------------------------- 1 | 978a2a6b43366794c5decbda95bf1e08 -------------------------------------------------------------------------------- /book_src/images/06/dwarf_tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/06/dwarf_tree.png -------------------------------------------------------------------------------- /book_src/images/07/.rid: -------------------------------------------------------------------------------- 1 | 58310471881fcc80a0b152521c5de8ae -------------------------------------------------------------------------------- /book_src/images/07/Disk-structure.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/07/Disk-structure.pdf -------------------------------------------------------------------------------- /book_src/images/07/Disk-structure.svg: -------------------------------------------------------------------------------- 1 | 2 | 16 | 18 | 19 | 21 | image/svg+xml 22 | 24 | 25 | 26 | 27 | 47 | 48 | 50 | 58 | 63 | 64 | 72 | 77 | 78 | 86 | 91 | 92 | 100 | 105 | 106 | 112 | 117 | 118 | 131 | 132 | 138 | 142 | 146 | 150 | 156 | 162 | 168 | 174 | 180 | 186 | 192 | 198 | 204 | 210 | 216 | 222 | 228 | 234 | 240 | 247 | 254 | 261 | 268 | 275 | 282 | 289 | 296 | 303 | 310 | 317 | 324 | 325 | 330 | 336 | Track 339 | 340 | 341 | 342 | 347 | 348 | 353 | 359 | Cluster 362 | 363 | 369 | Sector 372 | 373 | 374 | -------------------------------------------------------------------------------- /book_src/images/07/Disk_heads.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/07/Disk_heads.pdf -------------------------------------------------------------------------------- /book_src/images/07/Disk_heads.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 29 | 35 | 36 | 44 | 50 | 51 | 52 | 74 | 76 | 77 | 79 | image/svg+xml 80 | 82 | 83 | 84 | 85 | 86 | 91 | 96 | 104 | 109 | 113 | 121 | 129 | 136 | 137 | 142 | 147 | 153 | Head 0 156 | 157 | 163 | Head 1 166 | 167 | 188 | 189 | -------------------------------------------------------------------------------- /book_src/images/07/boot_fail1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/07/boot_fail1.png -------------------------------------------------------------------------------- /book_src/images/07/boot_succeeded.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/07/boot_succeeded.png -------------------------------------------------------------------------------- /book_src/images/07/simple_boot_process.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/07/simple_boot_process.pdf -------------------------------------------------------------------------------- /book_src/images/07/simple_boot_process.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 29 | 34 | 35 | 43 | 48 | 49 | 50 | 68 | 71 | 72 | 74 | 75 | 77 | image/svg+xml 78 | 80 | 81 | 82 | 83 | 84 | 88 | 95 | BIOS 106 | 113 | Bootloader 124 | 131 | OS 142 | 147 | 152 | 153 | 154 | -------------------------------------------------------------------------------- /book_src/images/08/.rid: -------------------------------------------------------------------------------- 1 | 1ba7fe42ddc5a44d1184e22d6c2fa796 -------------------------------------------------------------------------------- /book_src/images/08/binary_layout_good.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/08/binary_layout_good.pdf -------------------------------------------------------------------------------- /book_src/images/08/debug_info_bad_position.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/08/debug_info_bad_position.pdf -------------------------------------------------------------------------------- /book_src/images/08/mem_after_load_os.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/08/mem_after_load_os.pdf -------------------------------------------------------------------------------- /book_src/images/08/no_FILEHDR.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/08/no_FILEHDR.pdf -------------------------------------------------------------------------------- /book_src/images/08/with_FILEHDR.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/book_src/images/08/with_FILEHDR.pdf -------------------------------------------------------------------------------- /book_src/references.bib: -------------------------------------------------------------------------------- 1 | % This file was created with JabRef 2.10. 2 | % Encoding: UTF8 3 | 4 | 5 | @InBook{Hardy, 6 | Title = {A Mathematician's Apology}, 7 | Author = {G. H. Hardy}, 8 | Chapter = {10}, 9 | Pages = {13}, 10 | Publisher = {University of Alberta Mathematical Sciences Society}, 11 | Year = {2005}, 12 | 13 | Owner = {Tu Do}, 14 | Timestamp = {2016.10.05} 15 | } 16 | 17 | @Book{intel_opt_manual, 18 | Title = {Intel® 64 and IA-32 Architectures Optimization Reference Manual}, 19 | Author = {Intel}, 20 | Pages = {672}, 21 | Publisher = {Intel}, 22 | Year = {2016}, 23 | 24 | Owner = {Tu Do}, 25 | Timestamp = {2016.12.12} 26 | } 27 | 28 | @Book{Intel_volume1, 29 | Title = {Intel 64 and IA-32 Architectures Software Developer's Manual Volume 1: Basic Architecture}, 30 | Author = {Intel}, 31 | Pages = {482}, 32 | Publisher = {Intel}, 33 | Year = {2016}, 34 | 35 | Owner = {Tu Do}, 36 | Timestamp = {2016.12.15} 37 | } 38 | 39 | @InBook{Kovitz_psr, 40 | Title = {Practical Software Requirements}, 41 | Author = {Benjamin L. Kovitz}, 42 | Chapter = {3}, 43 | Pages = {53}, 44 | Publisher = {Manning}, 45 | Year = {1999}, 46 | 47 | __markedentry = {[Tu Do:]}, 48 | Owner = {Tu Do}, 49 | Timestamp = {2016.09.20} 50 | } 51 | 52 | @InBook{Peirce, 53 | Title = {Collected Papers v. 4}, 54 | Author = {Charles Sanders Peirce}, 55 | Chapter = {A Boolean Algebra with One Constant}, 56 | Year = {1933}, 57 | 58 | Owner = {Tu Do}, 59 | Timestamp = {2016.09.28} 60 | } 61 | 62 | @Manual{74hc00_data_sheet, 63 | Title = {74HC00; 74HCT00 Quad 2-input NAND gate}, 64 | Author = {NXP Semiconductors}, 65 | Edition = {7}, 66 | Month = {November}, 67 | Organization = {NXP Semiconductors}, 68 | Year = {2015}, 69 | 70 | Owner = {Tu Do}, 71 | Timestamp = {2017.01.16} 72 | } 73 | 74 | @InBook{John_digital, 75 | Title = {Digital Design: Principles and Practices}, 76 | Author = {John F. Wakerly}, 77 | Chapter = {3}, 78 | Pages = {86}, 79 | Publisher = {Prentice Hall}, 80 | Year = {1999}, 81 | 82 | Owner = {Tu Do}, 83 | Timestamp = {2016.09.27} 84 | } 85 | 86 | -------------------------------------------------------------------------------- /code/chapter7/os/.gdbinit: -------------------------------------------------------------------------------- 1 | define hook-stop 2 | # Translate the segment:offset into a physical address 3 | printf "[%4x:%4x] ", $cs, $eip 4 | end 5 | set architecture i8086 6 | layout asm 7 | layout reg 8 | set disassembly-flavor intel 9 | target remote localhost:26000 10 | symbol-file build/os/os 11 | b *0x7c00 12 | b main 13 | -------------------------------------------------------------------------------- /code/chapter7/os/Makefile: -------------------------------------------------------------------------------- 1 | BUILD_DIR=build 2 | BOOTLOADER=$(BUILD_DIR)/bootloader/bootloader.o 3 | OS=$(BUILD_DIR)/os/sample.o 4 | DISK_IMG=disk.img 5 | 6 | all: bootdisk 7 | 8 | .PHONY: bootdisk bootloader os 9 | 10 | bootloader: 11 | make -C bootloader 12 | 13 | os: 14 | make -C os 15 | 16 | bootdisk: bootloader os 17 | dd if=/dev/zero of=$(DISK_IMG) bs=512 count=2880 18 | dd conv=notrunc if=$(BOOTLOADER) of=$(DISK_IMG) bs=512 count=1 seek=0 19 | dd conv=notrunc if=$(OS) of=$(DISK_IMG) bs=512 count=1 seek=1 20 | 21 | qemu: 22 | qemu-system-i386 -machine q35 -fda $(DISK_IMG) -gdb tcp::26000 -S 23 | 24 | clean: 25 | make -C bootloader clean 26 | make -C os clean 27 | -------------------------------------------------------------------------------- /code/chapter7/os/bootloader/Makefile: -------------------------------------------------------------------------------- 1 | BUILD_DIR=../build/bootloader 2 | 3 | BOOTLOADER_SRCS := $(wildcard *.asm) 4 | BOOTLOADER_OBJS := $(patsubst %.asm, $(BUILD_DIR)/%.o, $(BOOTLOADER_SRCS)) 5 | 6 | all: $(BOOTLOADER_OBJS) 7 | 8 | $(BUILD_DIR)/%.o: %.asm 9 | nasm -f bin $< -o $@ 10 | 11 | clean: 12 | rm $(BUILD_DIR)/* 13 | -------------------------------------------------------------------------------- /code/chapter7/os/bootloader/bootloader.asm: -------------------------------------------------------------------------------- 1 | ;****************************************** 2 | ; Bootloader.asm 3 | ; A Simple Bootloader 4 | ;****************************************** 5 | bits 16 6 | start: jmp boot 7 | 8 | ;; constant and variable definitions 9 | msg db "Welcome to My Operating System!", 0ah, 0dh, 0h 10 | 11 | boot: 12 | cli ; no interrupts 13 | cld ; all that we need to init 14 | 15 | mov ax, 50h 16 | 17 | ; ;; set the buffer 18 | mov es, ax 19 | xor bx, bx 20 | 21 | mov al, 2 ; read 2 sector 22 | mov ch, 0 ; we are reading the second sector past us, so its still on track 0 23 | mov cl, 2 ; sector to read (The second sector) 24 | mov dh, 0 ; head number 25 | mov dl, 0 ; drive number. Remember Drive 0 is floppy drive. 26 | 27 | mov ah, 0x02 ; read floppy sector function 28 | int 0x13 ; call BIOS - Read the sector 29 | jmp 0x50:0x0 ; jump and execute the sector! 30 | 31 | hlt ; halt the system 32 | 33 | ; We have to be 512 bytes. Clear the rest of the bytes with 0 34 | times 510 - ($-$$) db 0 35 | dw 0xAA55 ; Boot Signiture 36 | -------------------------------------------------------------------------------- /code/chapter7/os/bootloader/debug.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/code/chapter7/os/bootloader/debug.elf -------------------------------------------------------------------------------- /code/chapter7/os/build/bootloader/bootloader.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/code/chapter7/os/build/bootloader/bootloader.o -------------------------------------------------------------------------------- /code/chapter7/os/build/os/sample.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/code/chapter7/os/build/os/sample.o -------------------------------------------------------------------------------- /code/chapter7/os/disk.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/code/chapter7/os/disk.img -------------------------------------------------------------------------------- /code/chapter7/os/os/Makefile: -------------------------------------------------------------------------------- 1 | BUILD_DIR=../build/os 2 | 3 | OS_SRCS := $(wildcard *.asm) 4 | OS_OBJS := $(patsubst %.asm, $(BUILD_DIR)/%.o, $(OS_SRCS)) 5 | 6 | all: $(OS_OBJS) 7 | 8 | $(BUILD_DIR)/%.o: %.asm 9 | nasm -f bin $< -o $@ 10 | 11 | clean: 12 | rm $(BUILD_DIR)/* 13 | -------------------------------------------------------------------------------- /code/chapter7/os/os/sample.asm: -------------------------------------------------------------------------------- 1 | ;****************************************** 2 | ; sample.asm 3 | ; A Sample Program 4 | ;****************************************** 5 | mov eax, 1 6 | add eax, 1 7 | -------------------------------------------------------------------------------- /code/chapter8/os/.gdbinit: -------------------------------------------------------------------------------- 1 | define hook-stop 2 | # Translate the segment:offset into a physical address 3 | printf "[%4x:%4x] ", $cs, $eip 4 | end 5 | set architecture i8086 6 | layout asm 7 | layout reg 8 | set disassembly-flavor intel 9 | target remote localhost:26000 10 | symbol-file build/os/os 11 | b *0x7c00 12 | b main 13 | -------------------------------------------------------------------------------- /code/chapter8/os/Makefile: -------------------------------------------------------------------------------- 1 | BUILD_DIR=build 2 | BOOTLOADER=$(BUILD_DIR)/bootloader/bootloader.o 3 | OS=$(BUILD_DIR)/os/os 4 | DISK_IMG=disk.img 5 | 6 | all: bootdisk 7 | 8 | .PHONY: bootloader os 9 | 10 | bootloader: 11 | make -C bootloader 12 | 13 | os: 14 | make -C os 15 | 16 | bootdisk: bootloader os 17 | # @echo "size is $(size)" 18 | # @echo "count is $(count)" 19 | dd if=/dev/zero of=$(DISK_IMG) bs=512 count=2880 20 | dd conv=notrunc if=$(BOOTLOADER) of=$(DISK_IMG) bs=512 count=1 seek=0 21 | # dd conv=notrunc if=$(OS) of=$(DISK_IMG) bs=512 count=1 seek=1 22 | dd conv=notrunc if=$(OS) of=$(DISK_IMG) bs=512 count=$$(($(shell stat --printf="%s" $(OS))/512)) seek=1 23 | 24 | qemu: 25 | qemu-system-i386 -machine q35 -fda $(DISK_IMG) -gdb tcp::26000 -S 26 | 27 | clean: 28 | make -C bootloader clean 29 | make -C os clean 30 | -------------------------------------------------------------------------------- /code/chapter8/os/bootloader/Makefile: -------------------------------------------------------------------------------- 1 | BUILD_DIR=../build/bootloader 2 | 3 | BOOTLOADER_SRCS := $(wildcard *.asm) 4 | BOOTLOADER_OBJS := $(patsubst %.asm, $(BUILD_DIR)/%.o, $(BOOTLOADER_SRCS)) 5 | 6 | all: $(BOOTLOADER_OBJS) 7 | 8 | $(BUILD_DIR)/%.o: %.asm 9 | nasm -f elf $< -F dwarf -g -o $@ 10 | ld -m elf_i386 -T bootloader.lds $@ -o $@.elf 11 | objcopy -O binary $(BUILD_DIR)/bootloader.o.elf $@ 12 | 13 | clean: 14 | rm $(BUILD_DIR)/* 15 | -------------------------------------------------------------------------------- /code/chapter8/os/bootloader/bootloader.asm: -------------------------------------------------------------------------------- 1 | ;****************************************** 2 | ; Bootloader.asm 3 | ; A Simple Bootloader 4 | ;****************************************** 5 | bits 16 6 | start: jmp boot 7 | 8 | ;; constant and variable definitions 9 | msg db "Welcome to My Operating System!", 0ah, 0dh, 0h 10 | 11 | boot: 12 | cli ; no interrupts 13 | cld ; all that we need to init 14 | 15 | mov ax, 50h 16 | 17 | ; ;; set the buffer 18 | mov es, ax 19 | xor bx, bx 20 | 21 | mov al, 17 ; read 2 sector 22 | mov ch, 0 ; we are reading the second sector past us, so its still on track 0 23 | mov cl, 2 ; sector to read (The second sector) 24 | mov dh, 0 ; head number 25 | mov dl, 0 ; drive number. Remember Drive 0 is floppy drive. 26 | 27 | mov ah, 0x02 ; read floppy sector function 28 | int 0x13 ; call BIOS - Read the sector 29 | jmp [500h + 0x18] ; jump and execute the sector! 30 | 31 | hlt ; halt the system 32 | 33 | ; We have to be 512 bytes. Clear the rest of the bytes with 0 34 | times 510 - ($-$$) db 0 35 | dw 0xAA55 ; Boot Signiture 36 | -------------------------------------------------------------------------------- /code/chapter8/os/bootloader/bootloader.dbg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/code/chapter8/os/bootloader/bootloader.dbg -------------------------------------------------------------------------------- /code/chapter8/os/bootloader/bootloader.lds: -------------------------------------------------------------------------------- 1 | OUTPUT(bootloader); 2 | 3 | PHDRS 4 | { 5 | headers PT_NULL; 6 | text PT_LOAD FILEHDR PHDRS ; 7 | data PT_LOAD ; 8 | } 9 | 10 | 11 | SECTIONS 12 | { 13 | . = SIZEOF_HEADERS; 14 | .text 0x7c00: { *(.text) } :text 15 | .data : { *(.data) } :data 16 | } 17 | -------------------------------------------------------------------------------- /code/chapter8/os/build/bootloader/bootloader.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/code/chapter8/os/build/bootloader/bootloader.elf -------------------------------------------------------------------------------- /code/chapter8/os/build/bootloader/bootloader.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/code/chapter8/os/build/bootloader/bootloader.o -------------------------------------------------------------------------------- /code/chapter8/os/build/bootloader/bootloader.o.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/code/chapter8/os/build/bootloader/bootloader.o.elf -------------------------------------------------------------------------------- /code/chapter8/os/build/disk.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/code/chapter8/os/build/disk.img -------------------------------------------------------------------------------- /code/chapter8/os/build/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/code/chapter8/os/build/main.o -------------------------------------------------------------------------------- /code/chapter8/os/build/os/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/code/chapter8/os/build/os/main.o -------------------------------------------------------------------------------- /code/chapter8/os/build/os/os: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/code/chapter8/os/build/os/os -------------------------------------------------------------------------------- /code/chapter8/os/build/os/os.debug: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/code/chapter8/os/build/os/os.debug -------------------------------------------------------------------------------- /code/chapter8/os/build/os/sample.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/code/chapter8/os/build/os/sample.o -------------------------------------------------------------------------------- /code/chapter8/os/disk.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/code/chapter8/os/disk.img -------------------------------------------------------------------------------- /code/chapter8/os/os/.#os: -------------------------------------------------------------------------------- 1 | tuhdo@vbuntu.1872:1486050267 -------------------------------------------------------------------------------- /code/chapter8/os/os/Makefile: -------------------------------------------------------------------------------- 1 | BUILD_DIR=../build/os 2 | OS=$(BUILD_DIR)/os 3 | 4 | CFLAGS+=-ffreestanding -nostdlib -m32 -gdwarf-4 -ggdb3 5 | 6 | OS_SRCS := $(wildcard *.c) 7 | OS_OBJS := $(patsubst %.c, $(BUILD_DIR)/%.o, $(OS_SRCS)) 8 | 9 | all: $(OS) 10 | 11 | $(BUILD_DIR)/%.o: %.c 12 | gcc $(CFLAGS) -m32 -c $< -o $@ 13 | 14 | $(OS): $(OS_OBJS) 15 | ld -m elf_i386 -nmagic -Tos.lds $(OS_OBJS) -o $@ 16 | # objcopy --only-keep-debug $(OS) $(OS).dbg 17 | # strip -g $(OS) 18 | 19 | clean: 20 | rm $(BUILD_DIR)/* 21 | -------------------------------------------------------------------------------- /code/chapter8/os/os/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/code/chapter8/os/os/main -------------------------------------------------------------------------------- /code/chapter8/os/os/main.c: -------------------------------------------------------------------------------- 1 | void main(){} 2 | -------------------------------------------------------------------------------- /code/chapter8/os/os/os: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuhdo/os01/a7587edc10c5c5c5dd822b0437f22419c54fe784/code/chapter8/os/os/os -------------------------------------------------------------------------------- /code/chapter8/os/os/os.lds: -------------------------------------------------------------------------------- 1 | ENTRY(main); 2 | 3 | PHDRS 4 | { 5 | headers PT_PHDR FILEHDR PHDRS; 6 | code PT_LOAD; 7 | } 8 | 9 | SECTIONS 10 | { 11 | .text 0x600: ALIGN(0x100) { *(.text) } :code 12 | .data : { *(.data) } 13 | .bss : { *(.bss) } 14 | /DISCARD/ : { *(.eh_frame) } 15 | } 16 | -------------------------------------------------------------------------------- /code/chapter8/os/os/sample.asm: -------------------------------------------------------------------------------- 1 | ;****************************************** 2 | ; sample.asm 3 | ; A Sample Program 4 | ;****************************************** 5 | mov eax, 1 6 | add eax, 1 7 | --------------------------------------------------------------------------------