For some reason im getting a GPF. The stack is setup perfectly fine from what i can see..
stack = (ulong32 *) kmalloc(1024) ;
ptr = (ulong32 *) (stack - 20);
ptr[0] = eip (task function addr)
ptr[1] = 8; (sys code sel)
ptr[2] = 0x0200; (ints enabled)
__asm__("mov %0, %%esp"::"m"(stack));
__asm__("mov %0, %%ebp"::"m"(stack - 1024));
__asm__("iret");
Task Switching
Re:Task Switching
No it's not. You need to set ESP to the end of the stack area. EBP is irrelevant here.
Re:Task Switching
I can't say for sure. But those lines won't be broken if you have esp = kmalloc(1024) + 1024 (note: 1024 not 1023).
Re:Task Switching
I notice that when i attempt to "manually" put these values on the new stack, no matter what i get a GPF. But if i swithc the stack 1st and then push the values, it works fine... but thats no good
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Task Switching
hey, watch out! you allocated 1024 bytes of stack and are trying to access ((ulong*) stack) - 1024 ... remember C will multiply 1024 by sizeof(ulong) which is 4, so you're writing out of your data area !!
Nothing good can result of this, imho.
Run gcc -S and study the assembler that results of your C code, you'll better see what you're doing than if you were blindly typing C code
ot: use [ code ] ... [ /code ] when you're posting code so that it doesn't get messed up by YaBB.
Nothing good can result of this, imho.
Run gcc -S and study the assembler that results of your C code, you'll better see what you're doing than if you were blindly typing C code
ot: use [ code ] ... [ /code ] when you're posting code so that it doesn't get messed up by YaBB.
Re:Task Switching
Nay shad, do not give up! It isn't difficult, it is just a question of going down to the nitty gritty in the right order - kinda chicken and egg thing it is.
Now tell, where exactly lies your problem gosh?
Now tell, where exactly lies your problem gosh?