@@ -658,42 +658,65 @@ SYM_DATA(efi_is64, .byte 1)
658
658
.text
659
659
.code32
660
660
SYM_FUNC_START(efi32_pe_entry)
661
+ /*
662
+ * efi_status_t efi32_pe_entry(efi_handle_t image_handle,
663
+ * efi_system_table_32_t *sys_table)
664
+ */
665
+
661
666
pushl %ebp
667
+ movl %esp , %ebp
668
+ pushl %eax // dummy push to allocate loaded_image
662
669
663
- pushl %ebx
670
+ pushl %ebx // save callee-save registers
664
671
pushl %edi
672
+
665
673
call verify_cpu // check for long mode support
666
- popl %edi
667
- popl %ebx
668
674
testl %eax , %eax
669
675
movl $0x80000003 , %eax // EFI_UNSUPPORTED
670
- jnz 3f
676
+ jnz 2f
671
677
672
678
call 1f
673
- 1: pop %ebp
674
- subl $1b, %ebp
679
+ 1: pop %ebx
680
+ subl $1b, %ebx
675
681
676
682
/* Get the loaded image protocol pointer from the image handle */
677
- subl $12 , %esp // space for the loaded image pointer
678
- pushl %esp // pass its address
679
- leal loaded_image_proto(%ebp ), %eax
683
+ leal -4 ( %ebp ) , %eax
684
+ pushl %eax // &loaded_image
685
+ leal loaded_image_proto(%ebx ), %eax
680
686
pushl %eax // pass the GUID address
681
- pushl 28 ( %esp ) // pass the image handle
687
+ pushl 8 ( %ebp ) // pass the image handle
682
688
683
- movl 36 (%esp ), %eax // sys_table
689
+ /*
690
+ * Note the alignment of the stack frame.
691
+ * sys_table
692
+ * handle <-- 16-byte aligned on entry by ABI
693
+ * return address
694
+ * frame pointer
695
+ * loaded_image <-- local variable
696
+ * saved %ebx <-- 16-byte aligned here
697
+ * saved %edi
698
+ * &loaded_image
699
+ * &loaded_image_proto
700
+ * handle <-- 16-byte aligned for call to handle_protocol
701
+ */
702
+
703
+ movl 12 (%ebp ), %eax // sys_table
684
704
movl ST32_boottime(%eax ), %eax // sys_table->boottime
685
705
call *BS32_handle_protocol(%eax ) // sys_table->boottime->handle_protocol
686
- cmp $0 , %eax
706
+ addl $12 , %esp // restore argument space
707
+ testl %eax , %eax
687
708
jnz 2f
688
709
689
- movl 32 ( %esp ), %ecx // image_handle
690
- movl 36 ( %esp ), %edx // sys_table
691
- movl 12 ( %esp ), %esi // loaded_image
710
+ movl 8 ( %ebp ), %ecx // image_handle
711
+ movl 12 ( %ebp ), %edx // sys_table
712
+ movl -4 ( %ebp ), %esi // loaded_image
692
713
movl LI32_image_base(%esi ), %esi // loaded_image->image_base
714
+ movl %ebx , %ebp // startup_32 for efi32_pe_stub_entry
693
715
jmp efi32_pe_stub_entry
694
716
695
- 2: addl $24 , %esp
696
- 3: popl %ebp
717
+ 2: popl %edi // restore callee-save registers
718
+ popl %ebx
719
+ leave
697
720
ret
698
721
SYM_FUNC_END(efi32_pe_entry)
699
722
0 commit comments