1 /* This is the C run-time start-off routine. It's job is to take the */
2 /* arguments as put on the stack by EXEC, and to parse them and set them up the */
3 /* way _main expects them. */
4 /* It also initializes environ when this variable isn't defined by the */
5 /* programmer. The detection of whether environ belong to us is rather */
6 /* simplistic. We simply check for some magic value, but there is no other */
9 #include <machine/vm.h>
12 .globl begtext, begdata, begbss
26 .globl crtso, __penviron, __penvp, __fpu_present
27 .globl __minix_datastart, __minix_mainjump, __minix_unmapzero
41 xorl %ebp, %ebp /* clear for backtrace of core files */
42 movl (%esp), %eax /* argc */
43 leal 4(%esp), %edx /* argv */
44 leal 8(%esp,%eax,4), %ecx /* envp */
46 /* Test if environ is in the initialized data area and is set to our */
47 /* magic number. If so then it is not redefined by the user. */
49 cmpl $__edata, %ebx /* within initialized data? */
51 testb $3, %bl /* aligned? */
53 cmpl $0x53535353, (%ebx) /* is it our environ? */
55 movl %ebx, __penviron /* _penviron = &environ; */
58 movl %ecx, (%ebx) /* *_penviron = envp; */
60 push %ecx /* push envp */
61 push %edx /* push argv */
62 push %eax /* push argc */
64 /* Test the EM bit of the MSW to determine if an FPU is present and */
65 /* set __fpu_present if one is found. */
67 testb $0x4, %al /* EM bit in MSW */
68 sete __fpu_present /* True if not set */
71 .balign I386_PAGE_SIZE
73 /* unmap zero pages */
74 call __minix_unmapzero
76 call _main /* main(argc, argv, envp) */
78 push %eax /* push exit status */
81 hlt /* force a trap if exit fails */
85 /* unmap 0-page code */
88 call _munmap_text /* unmap_text(crtso, I386_PAGE_SIZE) */
93 * ack uses separate segments for text and data by default. We have a
94 * common segment when compiling using any other compiler
97 /* unmap 0-page data */
100 call _munmap /* munmap(romstart, I386_PAGE_SIZE) */
109 .space I386_PAGE_SIZE
115 .long __penvp /* Pointer to environ, or hidden pointer */
118 .lcomm __penvp, 4 /* Hidden environment vector */
119 .lcomm __fpu_present, 4 /* FPU present flag */
121 .extern endtext /* Force loading of end labels. */