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.
guest
Post
by guest » Thu Oct 06, 2005 8:08 am
Hello, i have a problem with GCC inline assembler.
This code does work when i use NASM:
Code: Select all
pushf
push 0x08
push abc
iret
abc:
jmp $
But when i use this code in gcc inline assembler:
Code: Select all
asm(
"pushfl;"
"pushw $0x08;"
"pushl xxx;"
"iret;"
"xxx:"
);
my kernel hangs.
Please help me.
AR
Post
by AR » Thu Oct 06, 2005 8:37 am
What do you mean by "does not work"?
As for the second one:
"pushw $0x08;"
This is wrong, it should be "pushl", all stack items are 32bit aligned.
guest
Post
by guest » Thu Oct 06, 2005 8:48 am
Hello, i fixed the problem.
I had to change:
pushw $0x08 to pushl $0x08
and
pushl xxx to pushl $xxx
And now i have another problem.
I want to change to ring3 from ring0 without TSS.
I use this code:
Code: Select all
// 0x18 => ring3 code
// 0x20 => ring3 data
__asm__ __volatile__
(
"movl %esp, %eax;"
"pushl $0x23;"
"pushl %eax;"
"pushfl;"
"pushl $0x1b;"
"pushl $xxx;"
"iret;"
"xxx:"
"jmp xxx;"
);
But QEMU just closes the window when executing this code.
guest
Post
by guest » Thu Oct 06, 2005 8:59 am
ok i fixed ;D
I thought when U/S bit in paging stuff is cleared its for user ;D
I set and works now ;D
AR
Post
by AR » Thu Oct 06, 2005 9:06 am
You can't switch to Ring 3 without a TSS (well you can but it will crash when an interrupt occurs). The TSS is the only way for the CPU to get the kernel stack.
Guest
Post
by Guest » Thu Oct 06, 2005 11:08 am
Yes, i see ;D