+#
! This is the C run-time start-off routine. It's job is to take the
! arguments as put on the stack by EXEC, and to parse them and set them up the
! way _main expects them.
! simplistic. We simply check for some magic value, but there is no other
! way.
+#include <sys/vm_i386.h>
+
.sect .text; .sect .rom; .sect .data; .sect .bss
.define begtext, begdata, begbss
begbss:
.define crtso, __penviron, __penvp, __fpu_present
+.define __minix_datastart, __minix_mainjump, __minix_unmapzero
.extern _main, _exit
.sect .text
crtso:
smsw ax
testb al, 0x4 ! EM bit in MSW
setz (__fpu_present) ! True if not set
+ jmp __minix_mainjump
+
+.align I386_PAGE_SIZE
+__minix_mainjump:
+ ! unmap zero pages
+ call __minix_unmapzero
call _main ! main(argc, argv, envp)
hlt ! force a trap if exit fails
+__minix_unmapzero:
+
+ ! unmap 0-page code
+ push I386_PAGE_SIZE
+ push crtso
+ call _munmap_text ! munmap_text(crtso, I386_PAGE_SIZE)
+ add esp, 8
+
+ ! unmap 0-page data
+ push I386_PAGE_SIZE
+ push romstart
+ call _munmap ! munmap(romstart, I386_PAGE_SIZE)
+ add esp, 8
+
+ ret
+
.sect .rom
- .data4 0 ! Separate I&D: *NULL == 0
- ! Also keeps the first string in the
- ! program from appearing at location 0!
+romstart:
+ .space I386_PAGE_SIZE
+__minix_datastart:
+ .space 4
.sect .data
__penviron:
.data4 __penvp ! Pointer to environ, or hidden pointer