Anonymous user
James Molloy's Tutorial Known Bugs: Difference between revisions
James Molloy's Tutorial Known Bugs (view source)
Revision as of 01:49, 23 January 2017
, 7 years ago→Inline assembly optimiser problem with gcc 4.8
[unchecked revision] | [unchecked revision] |
Line 107:
It is strongly recommended that you write your own implementation of this and disregard the tutorial. The tutorial attempts to implement forking kernel threads by searching for magic values on the stack, which is insanity. If you wish to create a new kernel thread, simply decide which registers it should have and point its stack pointer at its freshly allocated stack. It will then start executing at your desired entry point. The part where it disables paging is bad and you should just map the source and destination physical frames at appropriate virtual addresses and memcpy with paging on at all times. Section 9.3 in particular is insanity and has blown up at least one well-established hobby operating system.
=== Inline
As mentioned above, writing
<nowiki>
Line 133:
10388c: ff e1 jmp *%ecx</nowiki>
Note how the
A way to fix this is to remove the
<nowiki>
; Here we:
Line 143:
; * Set the base and stack pointers
; * Set the page directory
; * Put a dummy value (0x12345) in EAX so that above we can
; switched task.
; * Restart interrupts. The STI instruction has a delay - it doesn't take effect until after
Line 152:
perform_task_switch:
cli;
mov ecx, [esp+4] ;
mov eax, [esp+8] ; physical address of current directory
mov ebp, [esp+12] ;
mov esp, [esp+16] ;
mov cr3, eax ; set the page directory
mov eax, 0x12345 ; magic number to detect a task switch
Line 164:
<nowiki>
extern void perform_task_switch(u32int, u32int, u32int, u32int);</nowiki>
and replace the
<nowiki>
perform_task_switch(eip, current_directory->physicalAddr, ebp, esp);</nowiki>
|