> We also need to load the GDT, and segment registers with the values
> mknbi assumes are in use. A protected mode entry point can only
> sanely assume a flat 32bit address space with a base address of 0.
> I have played with the former and checked it into the developer etherboot
> CVS tree. But I had not identified the remaing stack issue.
I don't know if this is a problem in my scenario because I haven't
changed them from version 1.2-7. The first thing done when start32
receives control is load a new gdt.
> I would suggest making the protected mode stack behave. We don't
> need to touch it unless we return to etherboot.
What I did was abandon the ill conceived real-mode stack and setup a
new protected mode stack in .bss. It works for me.
========================================
--- ../mknbi-1.2.7-original/start32.S 2002-03-04 04:44:53.000000000 -0800
+++ ../mknbi-1.2.7/start32.S 2002-09-20 22:48:20.000000000 -0700
@@ -50,10 +50,26 @@
GDT will have the wrong descriptors for the real code segments */
sgdt gdtsave /* save old GDT */
lgdt gdtarg /* load ours */
- /* save the stack pointer and jump to the routine */
- movl %esp,%eax
+
+ movl %esp,%eax /* Save stack pointer so we can return */
movl %eax,initsp
- jmp first
+
+ movl $16, %ecx /* Number of parameters to copy */
+ movl %esp, %esi
+; movl $RELOC, %eax
+; addl $0x7ff0, %eax /* Put stack above this loader */
+ leal prot_stack, %eax
+ movl %eax, %esp
+ subl %ecx, %esp
+ movl %esp, %edi
+ rep movsl
+ popl %eax /* Remove old return address */
+ call first
+
+ movl initsp, %eax /* Return to sender, something's wrong */
+ movl %eax, %esp
+ ret
+
#else
.code16
/* We need this stack adjustment because this code runs from a different
@@ -443,3 +459,8 @@
initsp: .word 0
days: .long 0
#endif
+
+.bss
+prot_stack_top:
+ .skip 4096
+prot_stack:
|