Octacone wrote:What is the next step? Do you think it is paging caused or kernel caused?
It seems to be caused by you setting CR3 to zero (or not setting it all and it's set to zero during system reset). Or did I miss some replies? So either single step thru the whole code or set breakpoints to where you're supposed to set CR3, then single step (or use breakpoints) until the triple fault, by that time CR3 should be zero. Now you know during which code sequence it's zeroed, find where that happens and fix it.
Octacone wrote:LtG wrote:Octacone wrote:
page_directory = (page_directory_t*) page_directory_address;
so TUI.Put_Hex((uint32_t) & page_directory, 0x0E); should return 0x11D000 right? No! It returns 0x11E050. Stuff likely getting overwritten. Right?
page_directory is a pointer, would you want to print that, not the _address_ of the pointer (the ampersand "&" in the second line).
Also I don't really get the point in your page_directory_t, why are there some virtual page tables? Also, I think customarily the "typedef struct X {..} X_t" stuff has the _t only on the latter "name", not the first one (X vs X_t)..
Because for some reason when I do (uint32_t) page_directory instead of (uint32_t) & page_directory it returns 0x0.
But then again something is horribly wrong. Even if I set it to 0xDEAD it returns 0x0.
Don't worry I know that:
pointer address = (uint32_t) that pointer
variable address = (uint32_t) & that variable
Not sure if this is a communication issue or something else, but I think everything you said in that quote is wrong. I'm not sure if you understand how pointers work.
When you take the pointer of a pointer, that may very well be at 0x11E050. Given that in practice pointers alias with addresses (though the two are different things we can relatively safely assume they fully alias each other here):
0x11E050 is where the compiler has decided to hold the pointer towards your page_directory variable (which IIRC is itself a pointer).
Note also that if you set _the pointer_ to random values (0xDEAD) and then print the value at the pointed to address (0xDEAD in VM) then it's entirely possible that there's nothing there and you would get 0x0. Virtual machine may very well have zeroed out the memory.
Given all this, I suggested above that it's entirely possible that this is either a communication issue or you don't really understand pointers.
But in any case unless the CR3 is shown to be valid at the time (immediately before) of the triple fault, then I'd concentrate on why CR3 is invalid (zero).
Octacone wrote:
The other thing you asked is just my personal pedantic preference. My code looked at altogether is very clean, "pixel" perfect in a way. I have a very personal coding style.
I'm assuming this refers to the typedef stuff (and not the virtual page stuff)? Having the struct named the same as the typedef doesn't seem like pedantic to me, I mean you are giving two _different_ things the same name, it just seems confusing. Also of note, the _t at the end is used to signify it's a typedef, the first occurrence isn't a typedef.. But to each their own I guess.
Btw, I also asked about the virtual page tables in your structs, what are they about?