Autobuild Filetable & ATA PIO Refactors - Amateur OS Dev (C/x86 asm/sh)
Automating the build/run process, refactoring disk code, and
fixing some bugs.
OS Dev playlist:
https://www.youtube.com/playlist?list=PLT7NbkyNWaqajsw8Xh7SP9KJwjfpP8TNX
Source code as of the end of this video:
https://git.sr.ht/~queso_fuego/amateur_os_video_sources/tree/master/item/39_autobuild_filetable
Repos for this OS:
Sourcehut: https://git.sr.ht/~queso_fuego/quesos
Github mirror: https://github.com/queso-fuego/amateuros
Notes:
- Loading the kernel to 50000h was mainly to get other compiler flags to work, since any -O flag that made the kernel too big had it overrun the bootloader and other stuff. Adding -fPIE to CFLAGS should make everything _except_ -O0 work, and allow building and running correctly on other OSes, or at least FreeBSD. Not sure why no optimizations at all is the broken one, but it now works on pretty much any other -O flag (tested fine with -O1/2/3/g/s/fast) and maybe more Oses than just one! Which is good :)
Hopefully future changes are a little easier, as the kernel can now use memory from 50000h up to (90000h - current stack pointer),
which is a bit more room to grow into. I might still change the stack to start from FFFFFh instead, or move the kernel to 100000h or higher in the 2ndstage bootloader after the switch to 32bit. The 16bit real mode address limit for x286 and later should be around 0xFFFFh:0xFFFF = 0xFFFF0 + 0xFFFF = 0x10FFEF, so it's maybe even doable in the bootsector.
- Currently gcc does not compile everything due to needing "-mno-general-regs" for the interrupt service routine code, among other things. This will need some work to change and fix, though maybe only breaking out the ISR code to separate makefile/compilation targets.
- The low amount of memory blocks in bochs is due to the .bochsrc config specifying 1 for "megs", or only 1MB (MiB?) of memory.
Increasing megs to 128 gives a roughly similar amount to the default qemu 128MB.
- The disk code changes aren't good, more of a temporary patch. I do have a first draft plan for changing to LBA instead of CHS, and that would involve using different, larger file table entries, but not needing to translate a sector to CHS, other than maybe in the bootsector or for a possible floppy driver. Maybe that will coincide with adding directory support to the filetable, or larger changes to make more of a filesystem. Right now the limit for starting sector is 1 byte, 0xFF. That will be constraining soon.
Also, ideally PIO would be dropped in favor of DMA, but I have to learn how DMA works first.
Next video:
Some PIC interrupts, probably IRQ0 for PIT ticks, IRQ1 for the keyboard, and IRQ8 to get date/time values from the CMOS real time clock.
- Let me know if there's anything specific you'd like to see
Outline:
0:00 - makefile changes, add code to build file table
14:34 - create add_filetable_entry.sh
31:34 - fix makefile to build all file table entries correctly
38:34 - change bootSect.asm to dynamically load from file table
1:09:54 - move kernel to higher memory location
1:17:18 - file_ops.h changes and fixes and refactors and things
1:59:24 - fix bochs issues
2:07:16 - strncmp bug
2:13:41 - change reboot command
2:17:27 - fix del command & 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/
clang - https://clang.llvm.org/
davinci resolve - https://www.blackmagicdesign.com/products/davinciresolve/
OBS Studio - https://obsproject.com/
Peripherals:
Camera: Sony ZV-1, Elgato Camlink 4k
Microphone: Shure SM7B, Cloudlifter CL-1, Focusrite Scarlett Solo
Keyboard: HHKB Pro Hybrid Type S, white/blank keycaps
Mouse: Logitech M590
Contact:
email - fuegoqueso@gmail.com
twitter - @Queso_Fuego
twitch - https://www.twitch.tv/queso_fuego
Thoughts/Notes/Suggestions/Other - Drop a message in the video comments, twitter, or email
Updates for these videos and other things will be on twitter, the YouTube channel community tab, or mailing lists, if I remember.
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/
#osdev #filetable #refactors