OS development 101 - How to make a bootloader part 3 - load kernel.c

preview_player
Показать описание
I made a discord server for everyone interested in low level programming and malware.
Check it out:

Whats up everyone, welcome to the third part of bootloader development mini-servies. In todays video we gonna load kernel from memory and setup cross compiler so that you we can use C to program the kernel. If you didnt watch part 1 and 2 definitly do that before continuing and subscribe so that you dont miss any new videos.

🖤 SUBSCRIBE 🖤
Twitter/X:
My github & cross compiler command:
OSDEV

Timestamps:
0:00 ▶ Preparing nececery files
1:10 ▶ Installing cross compiler
6:36 ▶ Kernel
8:43 ▶ Loading kernel from hard drive
11:29 ▶ Linker & Makefile
19:59 ▶ Let’s test it

How to write a bootloader from scratch
What happens during a PC boot sequence
Understanding the Power-On Self Test (POST)
How does the BIOS or UEFI work during boot
What is real mode in computing
How to write bootable code for a PC
Steps to create a simple bootloader
How does a BIOS initialize hardware components
What is the Master Boot Record (MBR)
Difference between MBR and GPT
How to load a 32-bit kernel with a bootloader
What are the first 512 bytes of a boot device
How does memory work in real mode
Writing a bootloader with a "Hello World" message
What are the last two bytes of the MBR
How does the boot order affect the boot process
What is the role of the PSU in the boot sequence
How does the BIOS/UEFI transfer control to the kernel
What is the purpose of the Power-On Self Test
Steps to load a kernel using a bootloader
Рекомендации по теме
Комментарии
Автор

This is the best video till now which i have found for OS development i wanted to make my own OS in my current semester. Please continue this series

jaiyadav
Автор

These are the best OS Dev tutorials on Youtube, please make more !

foamyadampower
Автор

i think changing the BitRate in OBS will help with the Pixelation in the video
BTW Nice Series

ShadowAmitendu
Автор

Great work! Maybe it would be nice to actually run some code from the kernel, e.g. write hello world using VGA memory.

Might be a good way to wrap this series if we could actually run some code with output from kernel without having to verify that it hits the kernel_main breakpoint.

oracle
Автор

Instead of installing cross compiler, you could install Zig and use it as a build tool (and if you have zig you may as well write your kernel in it ;) )

CallousCoder
Автор

BIOS leaves boot drive id in DL register. By replacing it with your own value (0x80) you break boot process if boot drive id is anything other than 0x80.

pvc
Автор

One thing that I don't understand is why everyone still uses the #ifndef style preprocessor macros. Yes, this is how K&R did it when they carved C into some stone plates. But for the last 20 years at least, all relevant compilers supported #pragma once as the first line in the .h file as a much cleaner alternative.
Every C tutorial lists this as "yeah, you can do this, but it's not widely supported"... Yes, this may have been true at some point, but it no longer is. The big advantage of #pragma once is that you don't create arbitrary C preprocessor defines, which clutter up your global preprocessor namespace. It gets even rose, when you imagine, your project grows, and you end up with two haders using the same #define. Let's say, you gut a defs.h file in two parts of your project, both use #ifndef DEFS_H... all works well, until somehow due to massive include chains, both end up being included by one compilation unit. And then you start to figure out why it doesn't work. With #pragma once you don't need to worry about it, as the preprocessor will keep track of what has been included and what hasn't so far.

Colaholiker
Автор

It would be cool to see a video, about UEFI, BIOS is a bit outdated and most computers already use it.

stopka
Автор

Instead of calling nasm for each and every .asm file it's better to define %.o: %.asm rule and add .asm to .SUFFIXES. Same goes for .c files (though GNU make has some builtin rules for those) as well as final binary. The way you do it is no different that calling it from .sh or .bat file. Also, it is a good practice to declare clean as .PHONY. This way it's always processed, no matter what.
CTRL + ` opens vscode builtin terminal.

pvc
Автор

I get the error: ./src/kernel.asm:4: error: parser: instruction expected
Please help

jannikwinkler
Автор

please upload faster I cannot waait for next part.

prashlovessamosa
Автор

Some issue I found: when you show the output of dd, the second output is 518 bytes, not 512. And all you os.bin file is 4 bytes greater than 5kB.

MegaTeXHaPb
Автор

gdb timeout when I use the "target-remote"

jamesharrison
Автор

Because I had the error:
-bash: ../binutils-2.43/configure: Permission denied
I had to make configure excecutable with:
chmod +x ../binutils-2.43/configure

Took me a long second to realize, might just happened to me because I use ubuntu through wsl.

metl_play
Автор

Hello, here are some typos I've noticed:
- linkerScirpt.ld -> linkerScript.ld
- KENREL_H -> KERNEL_H

Kinra_Jade
Автор

21:02 help! it will not work! i get:
nasm -f bin ./src/boot.asm -o ./bin/boot.bin
./src/boot.asm:75: error: label or instruction expected at start of line
make: *** [Makefile:5: all] Error 1
when trying to run the build.sh.

CrimsGT
Автор

ok just at the end I have ld segmentation fault at the line
i686-elf-gcc $(FLAGS) -T ./src/linkerScript.ld -o ./bin/kernel.bin -ffreestanding -O0 -nostdlib ./build/completeKernel.o

everything else worked fine now

metl_play
join shbcf.ru