Page 1 of 1

Protected Mode & Errors & Question

Posted: Fri Aug 28, 2015 6:22 am
by Octacone
I've learned a lot since my last post. Now I understand the whole thing better. But I've got a big dilemma:

Pre-Info About My Setup and OS: I am using GRUB for a bootloader because I don't want to write my own, I am using Linux + GCC and QEMU. I have kernel.asm file and kernel.c file and linker.ld that links that whole thing + some other folders with #include files. That I what I have.

1.Can I enter protected mode from my kernel.asm? - >>>read Pre-Info text if you are asking yourself why I don't have a bootloader

2.When I copy/paste osdevWiki protected mode code into my kernel.asm and ofc I make sure there are no errors, I get an error saying: symbol `gdtr' undefined. When I disable that ->((((lgdt [gdtr])))) I get infinite reboot loop.

3.How do I fix that? Can I use protected mode with GRUB? How can I tell if my os is in protected mode. What do i need to write inside protected_mode_main function?

4.Offtopic question: lets say I have paging code ready now how many times do I need to initialize that paging like I initialize it once and that is forever or I need to initialize it every time I do anything???

Re: Protected Mode & Errors & Question

Posted: Fri Aug 28, 2015 6:54 am
by Combuster
I don't think you have read the first chapter of the GRUB page.

Re: Protected Mode & Errors & Question

Posted: Fri Aug 28, 2015 7:06 am
by Octacone
Combuster wrote:I don't think you have read the first chapter of the GRUB page.
I can't find anything useful in there that could help me with my problem.

Re: Protected Mode & Errors & Question

Posted: Fri Aug 28, 2015 7:18 am
by Combuster
Homework: Read chapter 1, second paragraph, first sentence. Please cite the last six words in here for all of us, and explain what it means.

Re: Protected Mode & Errors & Question

Posted: Fri Aug 28, 2015 7:29 am
by Octacone
Combuster wrote:Homework: Read chapter 1, second paragraph, first sentence. Please cite the last six words in here for all of us, and explain what it means.
One major advantage of GRUB (or more precisely, a Multiboot-compliant bootloader) is that the kernel will be entered in a known state, which includes the A20 Line having been enabled, and Protected mode having been entered. This takes a lot of the pain out of writing a kernel, rendering GRUB a very useful tool for the amateur, or anyone who wants to spend more time on the intricacies of the kernel rather than worrying about these generic start-up procedures.

That means GRUB==alreadyInProtectedModeByDefault; It is good for amatuers.

OK What about other questions. Leave GRUB alone for now.

Re: Protected Mode & Errors & Question

Posted: Fri Aug 28, 2015 7:42 am
by Combuster
Since you really want to go on to the next question instead of really understanding what's happening, I guess I'm obliged to help you with my opinion.

...
I make sure there are no errors, I get an error
Image

Re: Protected Mode & Errors & Question

Posted: Fri Aug 28, 2015 7:46 am
by Roman
symbol `gdtr' undefined
That tells you exactly about the error.
Offtopic question: lets say I have paging code ready now how many times do I need to initialize that paging like I initialize it once and that is forever or I need to initialize it every time I do anything???
I just can't understand what are you asking about. BTW, triple question marks won't make it clear.
How do I fix that?
RTFM. Not the wiki, go grab a copy of Intel manuals, they won't bite you and don't make you read them all, just use the table of contents.

Re: Protected Mode & Errors & Question

Posted: Fri Aug 28, 2015 8:04 am
by Octacone
Combuster wrote:Since you really want to go on to the next question instead of really understanding what's happening, I guess I'm obliged to help you with my opinion.

...
I make sure there are no errors, I get an error
Image

...make sure there are no syntax errors... that is what I meant

Re: Protected Mode & Errors & Question

Posted: Fri Aug 28, 2015 8:08 am
by Octacone
Roman wrote:
symbol `gdtr' undefined
That tells you exactly about the error.
Offtopic question: lets say I have paging code ready now how many times do I need to initialize that paging like I initialize it once and that is forever or I need to initialize it every time I do anything???
I just can't understand what are you asking about. BTW, triple question marks won't make it clear.
How do I fix that?
RTFM. Not the wiki, go grab a copy of Intel manuals, they won't bite you and don't make you read them all, just use the table of contents.
1.I am a Superman and my brain is overclocked
2.I open code text editor
3.I start writing paging in .c code
4.I press ctrl+s, my code is saved
5.Now how do I call that paging from my kernel.c do I need to call it only once or I need to call it after every function?

Re: Protected Mode & Errors & Question

Posted: Fri Aug 28, 2015 8:26 am
by Combuster
Remember my little test?
Please cite the last six words
I suppose it's no use to try and help someone who both objectively and practically proved himself unable to read.


Seriously, I expect more of a programmer mindset here. OS Development is not a hobby to randomly stack things together and fire 101 unrelated expert-looking questions when you don't know the basics and fail because of that. For instance, posting that GRUB enables protected mode, then insisting on your own code that also enables protected mode just fails the basic intelligence tests. If that has to be the norm, I'm sorry but I won't be able to help with such deficiencies.

Re: Protected Mode & Errors & Question

Posted: Fri Aug 28, 2015 10:08 am
by Octacone
Combuster wrote:Remember my little test?
Please cite the last six words
I suppose it's no use to try and help someone who both objectively and practically proved himself unable to read.


Seriously, I expect more of a programmer mindset here. OS Development is not a hobby to randomly stack things together and fire 101 unrelated expert-looking questions when you don't know the basics and fail because of that. For instance, posting that GRUB enables protected mode, then insisting on your own code that also enables protected mode just fails the basic intelligence tests. If that has to be the norm, I'm sorry but I won't be able to help with such deficiencies.
I did not ask you guys to give me bunch of metaphors, I asked you 5 or 6 questions that I need answer for.

Re: Protected Mode & Errors & Question

Posted: Fri Aug 28, 2015 11:06 am
by BASICFreak
thehardcoreOS wrote:1.Can I enter protected mode from my kernel.asm? - >>>read Pre-Info text if you are asking yourself why I don't have a bootloader

2.When I copy/paste osdevWiki protected mode code into my kernel.asm and ofc I make sure there are no errors, I get an error saying: symbol `gdtr' undefined. When I disable that ->((((lgdt [gdtr])))) I get infinite reboot loop.

3.How do I fix that? Can I use protected mode with GRUB? How can I tell if my os is in protected mode. What do i need to write inside protected_mode_main function?

4.Offtopic question: lets say I have paging code ready now how many times do I need to initialize that paging like I initialize it once and that is forever or I need to initialize it every time I do anything???
Simply put:
1. No, not with Grub
2. define gdtr... (it is a data structure)
3. See 2. Yes. Are you over 1MB, is your code SEGMENT:OFFSET? Nothing, you are in PMode.
4. Once, per page directory - (where you are once and only once)

ALSO: DO NOT COPY AND PAST CODE FROM WIKI!!! <- It is usually wrong in some way (especially if you implement it and nothing else it relies on)



You have been given great advice by some of the best OSDevers on this site, and have spit it back in their faces. Learn what you are doing and how it is done. RTFM!

Re: Protected Mode & Errors & Question

Posted: Fri Aug 28, 2015 11:25 am
by Octacone
BASICFreak wrote:
thehardcoreOS wrote:1.Can I enter protected mode from my kernel.asm? - >>>read Pre-Info text if you are asking yourself why I don't have a bootloader

2.When I copy/paste osdevWiki protected mode code into my kernel.asm and ofc I make sure there are no errors, I get an error saying: symbol `gdtr' undefined. When I disable that ->((((lgdt [gdtr])))) I get infinite reboot loop.

3.How do I fix that? Can I use protected mode with GRUB? How can I tell if my os is in protected mode. What do i need to write inside protected_mode_main function?

4.Offtopic question: lets say I have paging code ready now how many times do I need to initialize that paging like I initialize it once and that is forever or I need to initialize it every time I do anything???
Simply put:
1. No, not with Grub
2. define gdtr... (it is a data structure)
3. See 2. Yes. Are you over 1MB, is your code SEGMENT:OFFSET? Nothing, you are in PMode.
4. Once, per page directory - (where you are once and only once)

ALSO: DO NOT COPY AND PAST CODE FROM WIKI!!! <- It is usually wrong in some way (especially if you implement it and nothing else it relies on)



You have been given great advice by some of the best OSDevers on this site, and have spit it back in their faces. Learn what you are doing and how it is done. RTFM!
Thank you for giving me real answers. =D>