New Filesystem p2: Booting The Disk Image | 32 Bit OS Dev (x86 asm / C)

Channel:
Subscribers:
5,840
Published on ● Video Link: https://www.youtube.com/watch?v=Q9Uf8TGcrOE



Duration: 1:26:18
1,153 views
48


Changing the boot sector, 2nd stage, and 3rd stage boot loaders for the new disk image (and debugging).
This continues from the last video over making the disk image: https://www.youtube.com/watch?v=OC9lD4MqxzQ

OS Dev playlist:
https://www.youtube.com/playlist?list=PLT7NbkyNWaqajsw8Xh7SP9KJwjfpP8TNX

Source code for this video:
https://git.sr.ht/~queso_fuego/amateur_os_video_sources/tree/master/item/44_filesys_disk_img_boot

Git Repos:
Sourcehut: https://git.sr.ht/~queso_fuego/quesos
Github mirror: https://github.com/queso-fuego/amateuros

NOTE: Depending on certain commits, the OS will be broken from new filesystem changes until completed. Loading/running a program like the calculator/editor, printing a directory, or other things may not work at all in the interim.
The last commit before breaking changes can be used after git clone with:
git checkout 08d3416cf5edbbab9684b8f911350e03ca9fe8af

Misc. links:
https://en.wikipedia.org/wiki/Hexspeak#Notable_magic_numbers

Join the Community Discord: https://discord.gg/yKm4T89QFn

Contact:
email: fuegoqueso@gmail.com
twitter: @Queso_Fuego
twitch: https://www.twitch.tv/queso_fuego

Notes:
- Due to laziness and not knowing how it would work, I didn't read from the inode single/double indirect blocks in fs_load_file() (or other places).
After thinking on it, that shouldn't be too hard to do, and could be accomplished with some nested loops.
FS_BLOCK_SIZE / sizeof(extent_t) = max number of extents to read from 1 single indirect block.
FS_BLOCK_SIZE / sizeof(uint32_t) = max number of single indirect block values to read from 1 double indirect block.

Given this, a rough outline to read the file data from a single indirect block would be:
Read that single indirect block to memory, and for each of the extents in the block, while current_extent.first_block != 0 (or length_blocks != 0) && current_extent less than max_extents, read the current extent to memory by loading disk sectors for length_blocks starting at first_block, appended to the memory from the end state of reading the inode's 4 direct extents.

Reading the double indirect block would add another outer loop to the single indirect block loop, where each 4 byte value in the double indirect block would be a single indirect block. So you could read the double indirect block to memory, loop over each single indirect block value while current_single_indirect_block != 0 && current_single_indirect_block less than max_indirect_blocks, and run the single indirect block loop for each value.
I might add this in the next video, even if it won't be used for a while.

Next video:
- Adding open/close/read/write/seek syscalls; open file table & inode table; inode or file path helper functions; file system saving/creating/deleting functions; kernel malloc/printf; printing dir entries; adding field width to printf; other things? However much gets done in an hour or two.

- Let me know if there's anything specific you'd like to see!

Outline:
0:00 Intro, small make_disk changes
2:10 change bootSect, load boot block/superblock/3rd stage bootloader
26:08 change makefile
32:25 change 2ndstage
41:39 make_disk bugfix
44:24 change 3rdstage
58:01 create fs_impl.h, fs_load_file()
1:11:09 print debugging, change kernel
1:23:20 it boots now, Coming up & Outro

Questions about setup/software/etc.? Check the FAQ: https://queso_fuego.srht.site/about.html

Music credits:
Downtown Glow by Ghostrifter & Devyzed
Creative Commons — Attribution-NoDerivs 3.0 Unported — CC BY-ND 3.0
Music promoted by https://www.chosic.com/free-music/all/

#osdev #filesystem #programming







Tags:
queso fuego
programming
os dev
operating systems
kernel dev
file system
booting
boot loader
low level
systems programming
inodes