Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Hello, I am following James Malloy's, Everything went fine until I got to the usermode chapter.
Note: I fixed every bug I found listed in the wiki page about his tutorial's bugs.
I think it faults when tss_flush is called.
Here is the definition of tss_flush
tss_flush:
mov ax, 0x2B ; Load the index of our TSS structure - The index is
; 0x28, as it is the 5th selector and each is 8 bytes
; long, but we set the bottom two bits (making 0x2B)
; so that it has an RPL of 3, not zero.
ltr ax ; Load 0x2B into the task state register.
ret
You think it faults? Set a breakpoint right before "ltr ax" and check if your GDT/TSS contains what it should.
Do you have exception handling? Are your page tables accessible by user mode? What's in your GDT? What's in your TSS?
You know your OS is advanced when you stop using the Intel programming guide as a reference.
I don't recommend following JamesM's tutorial, it's very buggy and does horrible things that you should never do, such as trying to "move" a stack and search for vlaues on it that need to be modified, disabling paging to copy a page table, etc. The wiki has a full list. I can't remember exactly what it was, but I recall there being a problem with the usermode switch too.