GDT and 32bit Protected Mode - Amateur OS Dev (x86 asm)
Adding a Global Descriptor Table (GDT) to the bootsector and moving everything to 32 bit protected mode! With all the issues that brings...
Playlist for this series:
https://www.youtube.com/playlist?list=PLT7NbkyNWaqajsw8Xh7SP9KJwjfpP8TNX
Repos for this OS:
Sourcehut: https://git.sr.ht/~queso_fuego/quesos
Github mirror: https://github.com/queso-fuego/amateuros
Notes:
- This is a long video! Did not mean for it to be this long, but I like to show all changed lines of code and keep all content involving the whole "session" together. Most people will probably only care for the first 30-40min at most, adding the GDT and jumping to the kernel.
!! Important !! Interrupts should be disabled when jumping to 32 bit protected mode, the real mode IVT is no longer used, and an IDT needs to be set up to handle interrupts. Keyboard or timer ints will probably crash and reset your system if you don't have 'cli' to turn off hardware interrupts!
Get some naps in (because I'm boring!), or have snacks and drinks ready. The timestamps help for coming back later or skipping around.
- I did not remember to set noise removal in OBS so you can hear the keyboard at times, albeit muffled. Sorry about that! I have to redo some settings from getting an audio interface.
- A TSS segment descriptor, Interrupt descriptor table and service routines, A20 line enable, and other things are not shown in this video but might be added in the future.
OS Dev wiki page on GDT:
https://wiki.osdev.org/Global_Descriptor_Table
Wikipedia page on GDT:
https://en.wikipedia.org/wiki/Global_Descriptor_Table
GDT and jump to Protected Mode Tutorial in assembly (has a few errors):
http://www.osdever.net/tutorials/view/the-world-of-protected-mode
Next video(s) should be:
- Adding/Using Vesa Bios Extensions to set a 'proper' graphics mode, such as 1920x1080 32bpp with a linear framebuffer, with a 2nd stage bootloader for this VBE and initial disk loading code, if it doesn't all fit in the bootsector.
- Fixing bugs and printing issues (probably) from switching to this new graphics mode, and maybe changing how printing works again.
Outline:
0:00 - Small makefile change
0:16 - Pass filename length to load_file for bugfix
7:25 - Show/explain web pages on GDT setup
20:41 - Add GDT to boot sector
33:04 - Changes for loading kernel
40:53 - Convert clear screen
42:47 - Convert move cursor
52:16 - Convert print char
55:32 - Convert print string & other fixes
1:05:37 - Get prompt to print
1:10:00 - Fix print char
1:12:19 - Convert and fix get_key
1:18:30 - Convert rest of kernel
1:29:28 - Convert delete file
1:34:02 - Convert print_fileTable
1:40:15 - Convert load_file, rename_file, save_file
1:51:57 - Fixes for printing fileTable
1:54:35 - Convert print_hex
1:57:04 - Convert print_registers
2:07:25 - Convert calculator
2:16:29 - Debug loading & running calculator
2:28:27 - Convert editor
2:55:13 - Debug editor and file_ops
3:07:29 - Fixes for saving & txt file printing
3:17:21 - Add 32 bit to kernel message
3:18:33 - Coming up & Outro
Software used:
VMware Workstation Player - https://www.vmware.com/products/workstation-player/workstation-player-evaluation.html
openBSD - https://www.openbsd.org/
qemu - https://www.qemu.org/
vim - https://www.vim.org/ (neovim is better)
fasm - https://flatassembler.net/
fasm docs - https://flatassembler.net/docs.php?article=manual
davinci resolve - https://www.blackmagicdesign.com/products/davinciresolve/
OBS Studio - https://obsproject.com/
Contact:
email - fuegoqueso@gmail.com
twitter - @Queso_Fuego
Thoughts/Notes/Suggestions/Other - Drop a message in the video comments, by twitter, or by email
Credits:
Music from https://incompetech.com:
"Your Call" Kevin MacLeod (incompetech.com)
Licensed under Creative Commons: By Attribution 4.0 License
http://creativecommons.org/licenses/by/4.0/
The blue title tags:
#osdev #programming #assembly