Hi all,
I am implementing SMM on K8/vt8237r, and I have problem with switching
from real mode to protected mode in smm handler.
I followed the smmhandler.S code in /src/cpu/x86/smm/ directory
If I put my rsm instruction before ljmp instruction, I could invoke SMI
successfully.
/* Enable protected mode */
data32 ljmp $0x08, $1f
but if I put rsm instruction below that(even commented out the C
procedure), my machine will freeze after the invoking.
The only difference between my code and ICH4 implementation is:
I didn't copy the smm bin file(include smmhandler.S smihandler.c
smm.ld), to location 0xa0000, I just copied the smmhandler.S file to
location 0xa0000 and wrote a jmp statement at 0xa8000.
In order to make it simple, I commented out the C procedure, and only
assembly in smmhandler.
I may didn't set global descriptor table correctly.
I understand ljmp $0x08, $1f is going to use first entry of gdt, and
traslate the logical address to linear address.
smmhandler.S code has setted up correct smm_gdt, and I also copied the
code to location 0xa0000 (since it is in smmhander.S file).
.code16
.align 4, 0xff
smm_gdtptr16:
.word smm_gdt_end - smm_gdt - 1
.long smm_gdt - smm_handler_start + 0xa0000 + SMM_HANDLER_OFFSET
.code32
smm_gdt:
/* The first GDT entry can not be used. Keep it zero */
.long 0x00000000, 0x00000000
/* gdt selector 0x08, flat code segment */
.word 0xffff, 0x0000
.byte 0x00, 0x9b, 0xcf, 0x00 /* G=1 and 0x0f, 4GB limit */
/* gdt selector 0x10, flat data segment */
.word 0xffff, 0x0000
.byte 0x00, 0x93, 0xcf, 0x00
smm_gdt_end:
I would appreciate it if someone could help me out.
Best,
Fengwei