Тёмный

Making an OS (x86) Chapter 6 - Entering Protected mode, GDT 

Daedalus Community
Подписаться 26 тыс.
Просмотров 56 тыс.
50% 1

Corrections:
- You could actually use colors in real mode as well, by setting the bl register
- I wrote binary values as 010010 instead of 0b010010
Hostinger link: www.hostinger....
Coupon code: DAEDALUS
New Website: www.mrdalliard...
Full Code:
github.com/mel...
OSDev articles for exercise:
wiki.osdev.org...
wiki.osdev.org...
0:00 - Intro
0:09 - Sponsored Segment
1:57 - Protected mode
2:57 - GDT
8:50 - Switching to PM

Опубликовано:

 

8 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 96   
@jlhs-xb8wo
@jlhs-xb8wo 3 года назад
Please don't stop this series. Follow through to the end! I really liked Poncho's OS series, but he decided to drop it. This is a good quality series!
@DaedalusCommunity
@DaedalusCommunity 3 года назад
There are still a couple of videos left to it, then I'd like to move to other topics, while posting an update about this project from time to time
@xulum1299
@xulum1299 Год назад
@@DaedalusCommunity It does not owrk for me (the code.) I copied the same from github to make sure but it does not work.
@ferdinanderiksen5715
@ferdinanderiksen5715 Год назад
@@xulum1299 remove the first jmp $, it gets stuck
@maheswaranparameswaran8532
@maheswaranparameswaran8532 3 года назад
Finally understood how the gdt works.... Thanks a lot man..
@graveyard4790
@graveyard4790 7 месяцев назад
You may not finish the series but it definitely helped alot of people to put them on the track of os development. this is by far the most informative video series I've ever watched .
@cangozpinar
@cangozpinar Год назад
This playlist was awesome. You delivered what I’ve been looking for in a very concise illustrative and digestible way. Thank you very very much !
@MrDimonsky
@MrDimonsky 2 года назад
Молоток, все разложено по полочкам, язык понятен. Скачал весь плейлист.
@martinojalill5493
@martinojalill5493 8 месяцев назад
I like people that make thing like this it really helps me out
@GDT-Studio
@GDT-Studio Месяц назад
Thanks for the name drop brother
@nightjolt
@nightjolt 3 года назад
maan those series are must watch
@justanormalperson
@justanormalperson 3 года назад
Can't wait! :D
@JE-sz9yb
@JE-sz9yb 2 года назад
Great content! Thank you for sharing your knowledge to us. God bless you sir!
@flochforster2675
@flochforster2675 2 года назад
what a perfect incredible fantastic tutorial. please continue with it
@Rudolf215
@Rudolf215 Год назад
Thank you for making this video, it was very helpful and informationally!
@zee63976
@zee63976 3 года назад
I like how you casually went through privilege levels ;)
@elpapichulo4046
@elpapichulo4046 2 года назад
Love this series it's amazing
@natykg713
@natykg713 3 года назад
Can't wait for it 😁
@abhisekashirbad5649
@abhisekashirbad5649 3 года назад
Love from🇮🇳, bro
@Kitsuinox
@Kitsuinox 3 года назад
aw hell yeah 32-bit time
@sflux4593
@sflux4593 3 года назад
Reminder gang
@EdgarPatron
@EdgarPatron 2 года назад
I can´t wait for the next vidio thanks
@worldender4430
@worldender4430 3 года назад
First, and can't wait for iiiit
@Kitsuinox
@Kitsuinox 3 года назад
i second this lol
@danusminimus9557
@danusminimus9557 2 года назад
Amazing, just amazing.
@elliot557
@elliot557 3 года назад
yeahhh!!!
@agoogleuser3853
@agoogleuser3853 3 года назад
Ok, question Does the CPU always threat the video as memory? Why did the code there make an white A instead of just one pixel Im exited for the time we'll finally write something on c/c++
@DaedalusCommunity
@DaedalusCommunity 3 года назад
In this case we are in text mode, so a couple of bytes in video memory represents a coloured character. There are several other modes, among which various graphics modes, that let you set coloured pixels in a similar way. Check out the links in the description to know more :)
@agoogleuser3853
@agoogleuser3853 3 года назад
Thanks
@cirkulx
@cirkulx Год назад
This video may be a year old, but I accidentally made a great animation in VGA graphics mode. It may be 16 bit, but I guess it can be called before entering protected mode as a nice boot screen of sort. I implemented it into the real mode version of my OS and the start of my 32 bit OS - as a boot screen. I may post the code (it will exit graphics mode and go back to text mode since my brain is not working well enough to print a font) but I may only do that if there's demand :P
@DaedalusCommunity
@DaedalusCommunity Год назад
Yeah post it, I'm a big fan of accidental animations :))
@agoogleuser3853
@agoogleuser3853 3 года назад
Lets goooooooooooooo
@jultomten3739
@jultomten3739 2 года назад
it's a bit late but I made a black A with blue background (not that intresting) insted of mov ah, 0x0f I did 0x10
@harveykyle3690
@harveykyle3690 3 года назад
noice UwU so whats next?
@jacobdavidcunningham1440
@jacobdavidcunningham1440 Год назад
2:07 lol this part's great
@BlackneeedWasHere
@BlackneeedWasHere Год назад
In GDT you make CODE_SEG equ … but in switching to protected mode you typed jmp CODESEG:… (where is the underscore?)??
@kingundead4310
@kingundead4310 3 года назад
Gonna be a good video
@nihoncraft2205
@nihoncraft2205 3 года назад
what editor are you using? your videos are great.
@DaedalusCommunity
@DaedalusCommunity 3 года назад
Hitfilm express, it's a free video editor whit a fairly rich compositing tool. I'd love to write some code to animate some of my stuff faster though, like 3b1b did with Manim.
@nihoncraft2205
@nihoncraft2205 3 года назад
@@DaedalusCommunity thanks a lot!
@user-sw1bi7kh5q
@user-sw1bi7kh5q Год назад
I dont understand this line jmp CODE_SEG:start_protected_mode both were declared as offsets in the code, so in which segment is this even making a jump to?
@DaedalusCommunity
@DaedalusCommunity Год назад
start_protected_mode is a label, "located" in the code segment. Once the gdt is loaded, the new code segment is set, and in order to jump to the absolute address of start_protected_mode you need to perform a far jump, by specifying the segment.
@user-sw1bi7kh5q
@user-sw1bi7kh5q Год назад
@@DaedalusCommunity I am having trouble understanding how CODE_SEG is a real segment? Generally in a far jump we specify the start address (segment address) where we want to calculate the offset from. But CODE_SEG is just a difference between the gdt_start and code_descriptor. How is that number supposed to be the start of any segment? seems very arbitrary. Thanks
@rusdzo
@rusdzo Год назад
Is the data segment descriptor consists of 8 bytes = 64 bits?
@trucookieq4469
@trucookieq4469 2 года назад
i may or may not have accidentally made it so it prints A (color of blue on red) over the entire video ram and probably go into normal memory
@MrDimonsky
@MrDimonsky 2 года назад
10:04 - what is jmp CODESEG:start_protected_mode - where do we have CODESEG from, and why we do not jump simply to start_protected_mode?
@DaedalusCommunity
@DaedalusCommunity 2 года назад
I defined CODESEG at 8:42 We extend with CODESEG because we need to jump to the new code segment, offset by the start_protected_mode label (we want to execute code in real mode)
@VaporGame404
@VaporGame404 2 года назад
@@DaedalusCommunity i know im late but didint you define CODE_SEG and now you wanna use CODESEG?
@rhysbaker2595
@rhysbaker2595 9 месяцев назад
@@VaporGame404 I think he made a mistake there. You should use CODE_SEG:start_protected_mode You are right that he never defined CODESEG
@rhysbaker2595
@rhysbaker2595 9 месяцев назад
Hey, I know this is kinda old now but I hope you still read these. When jumping to protected mode, qemu always triple faults instantly. Is there a simple way to avoid this? Last time I tried to do some x86 stuff, I got tripped up with a triple fault too. Hoping to get past this hurdle
@DaedalusCommunity
@DaedalusCommunity 9 месяцев назад
Uhm, check out the code on the OS-Reference github repo, maybe there's some bug in your code
@rhysbaker2595
@rhysbaker2595 9 месяцев назад
@@DaedalusCommunity I've been messing with your code on GitHub. Yours works great but mine wasn't working. I think the issue was that I put all this code in the next sector. If I jump to 32 bit mode while staying in the boot sector it seems to work just fine. I can then jump to the next sector/s. I have to say, thank you for being active on a 2 year old video, so many tutorials are abandoned or don't maintain support. I'm curious if you plan on continuing the series in video format? (I've read the text version of part 8 and it's pretty good
@xxxxxxx9430
@xxxxxxx9430 2 года назад
Why did you subtract 1 from gdt size?
@derman447
@derman447 6 дней назад
because GDT size starts at 0
@sameenasulthanashaik498
@sameenasulthanashaik498 2 года назад
Can we have a video like this which get back to real mode from protected mode
@sharpnerw1093
@sharpnerw1093 5 месяцев назад
Xor that bit from cr0 Set "bits 16"
@koussayhajlaoui9440
@koussayhajlaoui9440 3 года назад
it's been 84 yeears. oh my god let's gooooooooo.
@toothyeye
@toothyeye 3 года назад
Didnt work for me. (No letter showing up on qemu).
@DaedalusCommunity
@DaedalusCommunity 3 года назад
Could you share your code?
@agoogleuser3853
@agoogleuser3853 3 года назад
That happened to me too, i checked the os reference and could fix it (The code was after the GDT_Descriptor, it worked when i put it before)
@rubiks7196
@rubiks7196 3 года назад
У меня Bochs перезагружается вообще
@rubiks7196
@rubiks7196 3 года назад
start_protected_mode: mov ax, DATA_SEG mov ds, ax mov ss, ax mov es, ax mov fs, ax mov gs, ax
@jebsl8923
@jebsl8923 2 года назад
[9:43] If we need to change the last bit of a register from 0 to 1, why not just increment it?
@DaedalusCommunity
@DaedalusCommunity 2 года назад
When writing a program, one should think in terms of general approaches. Yes, if you're sure each and every time you're going to change the last bit it will be a zero, which is indeed the case here, you can simply increment the register. But I'd say, unless the performance is dramatically worsened by the general approach, it is not a bad idea to keep the code general and intuitive to the others reading it :)
@jebsl8923
@jebsl8923 2 года назад
@@DaedalusCommunity Thanks :D
@mikozak2
@mikozak2 2 года назад
Why do we set the same base and limit to code and data segments. Shouldn't we set it to different locations or is it because of flat model?
@agoogleuser3853
@agoogleuser3853 3 года назад
RIP bios It had to happen at some point
@friedrichbrauer5912
@friedrichbrauer5912 2 года назад
arent you ylready in 32 mode before you reach to jump CODESEG:start_protected_mode? wont it be be read wrong now?
@sgt-Badger
@sgt-Badger 2 года назад
+1 subscriber
@idiotontheweb
@idiotontheweb 3 года назад
Is there any way to add a simple text based game to Mell Os?
@DaedalusCommunity
@DaedalusCommunity 3 года назад
Sure! It wouldn't be that hard to code in C
@pretzel7247
@pretzel7247 2 года назад
Whenever I run "mov [0xb8000], ax" in protected mode this system just restarts
@PCGxt-c4g
@PCGxt-c4g 4 месяца назад
How do I Activate the A20 Line?
@ptaahfr
@ptaahfr 3 года назад
I don't understand why protected mode allow to print text in color, it implicitely changes the video mode ? this was also possible in real mode ..
@DaedalusCommunity
@DaedalusCommunity 3 года назад
You're right, it could be done in real mode too, by setting the register bl. My bad, I'll add it to the corrections
@sonuaryan5287
@sonuaryan5287 2 года назад
Enabling A20 Line
@adrian_sp6def
@adrian_sp6def 3 месяца назад
wait, how You can use 32bit GPR before jump to 32-bit?
@DaedalusCommunity
@DaedalusCommunity 3 месяца назад
You can use those registers even when in 16-bit mode. E.g. if you move a value to to eax in 16 bit mode, in practice it's the same as moving to ax. Sometimes it's necessary to use registers such as eax in 16 bit mode, due to constraints of the machine language, as for certain instructions using only half of the register is not allowed.
@sameenasulthanashaik498
@sameenasulthanashaik498 2 года назад
Can you do it
@therandomsomeone.
@therandomsomeone. 2 года назад
is gdt_end supposed to be empty? also it doesn't print out the character
@DaedalusCommunity
@DaedalusCommunity 2 года назад
It's a label at the end of the GDT, it's used to compute its length
@randomguy-gb9ge
@randomguy-gb9ge 2 года назад
Help, letter A doens't print!
@user-ng8rl3jb1i
@user-ng8rl3jb1i 2 года назад
nice video , i have an issue though . it doesnt boot . im using nasm and qemu ...
@user-ng8rl3jb1i
@user-ng8rl3jb1i 2 года назад
ok everything fine . my bad
@DaedalusCommunity
@DaedalusCommunity 2 года назад
@@user-ng8rl3jb1i glad you sorted it out, if you have any questions let me know :)
@user-ng8rl3jb1i
@user-ng8rl3jb1i 2 года назад
@@DaedalusCommunity sure , thanks :)
@lincon_shark
@lincon_shark 11 месяцев назад
Glo Tablbal eDesk
@jackmarley32
@jackmarley32 2 года назад
When I try to run it on real hardware it's starting but it shut downs in ~1sec
@DaedalusCommunity
@DaedalusCommunity 2 года назад
Uhm, weird.. does it shut down or restart? If it restarts it might be some sort of overflow
@jackmarley32
@jackmarley32 2 года назад
@@DaedalusCommunity Sorry, yes it restarting
@jackmarley32
@jackmarley32 2 года назад
Why is this happening?
@Cool-Linux-Penguin
@Cool-Linux-Penguin 6 месяцев назад
I have no idea what I just watched and didn't understand it.
@alooyeg
@alooyeg 3 года назад
42 minutes late
@AkifKudretYasar
@AkifKudretYasar 16 часов назад
How dare u give us homework!🤬
@madhusudhanan9278
@madhusudhanan9278 Год назад
bro you need to be more detailed when explaining why you do it. you just say "we are gonna do this and that", but you don't say why you do it. for eg: at 10:15 you said we need to do a far jump but u didn't say why. we need to to do it because modern CPUs have pipelining so it shouldn't execute incorrect instructions in its pipeline. so far jump forces cpu to flush instructions and jmp to target so that we are sure that it is executing the correct 32 bit instructions instead of incorrect 16-bit real mode instructions.
@ananttiwari1337
@ananttiwari1337 3 года назад
the
Далее
Я ЖЕ БЕРЕМЕННА#cat
00:13
Просмотров 484 тыс.
кого отпустят гулять чееек
00:53
The Legend of YouAreAnIdiot.org
18:01
Просмотров 10 млн
before you code, learn how computers work
7:05
Просмотров 294 тыс.
Protected mode: how your OS can protect itself
40:42
Просмотров 15 тыс.
Fast Inverse Square Root - A Quake III Algorithm
20:08
Making an OS (x86) Chapter 1 - CPU, Assembly, Booting
6:56