# HG changeset patch # User bartv # Date 1028503138 0 # Node ID 922ca26d90c4852cfbecf24aab6b762fbe10fd6d # Parent d3fa78927b0f6d4a66f232916072119ce1a0ddd0 Add variables cyg_hal_sys_argc/argv/environ, corresponding to the arguments and environment vector passed to the synthetic target application. diff --git a/packages/hal/synth/arch/current/ChangeLog b/packages/hal/synth/arch/current/ChangeLog --- a/packages/hal/synth/arch/current/ChangeLog +++ b/packages/hal/synth/arch/current/ChangeLog @@ -1,3 +1,7 @@ +2002-08-04 Bart Veer + + * include/hal_io.h: added argv/argv/environ definitions + 2002-05-23 Jesper Skov * cdl/hal_synth.cdl: Don't run cache tests. diff --git a/packages/hal/synth/arch/current/include/hal_io.h b/packages/hal/synth/arch/current/include/hal_io.h --- a/packages/hal/synth/arch/current/include/hal_io.h +++ b/packages/hal/synth/arch/current/include/hal_io.h @@ -409,6 +409,11 @@ externC int cyg_hal_sys_getc // mmap on the "host" system - this may be unportable. externC int cyg_hal_sys_mmap(struct cyg_hal_sys_mmap_args *); +// Access to environmental data +extern int cyg_hal_sys_argc; +extern const char** cyg_hal_sys_argv; +extern const char** cyg_hal_sys_environ; + // ---------------------------------------------------------------------------- // Interaction between the application and the auxiliary. // Not yet available, but there is a hardware-initialization routine. diff --git a/packages/hal/synth/i386linux/current/ChangeLog b/packages/hal/synth/i386linux/current/ChangeLog --- a/packages/hal/synth/i386linux/current/ChangeLog +++ b/packages/hal/synth/i386linux/current/ChangeLog @@ -1,3 +1,8 @@ +2002-08-04 Bart Veer + + * src/vectors.S (_start): + Store argv and environ in cyg_hal_sys_... variables + 2002-04-29 Jonathan Larmour * src/vectors.S: diff --git a/packages/hal/synth/i386linux/current/src/vectors.S b/packages/hal/synth/i386linux/current/src/vectors.S --- a/packages/hal/synth/i386linux/current/src/vectors.S +++ b/packages/hal/synth/i386linux/current/src/vectors.S @@ -47,20 +47,56 @@ ## Description: When running on real hardware vectors.S contains ## initialization code and usually the low-level interrupt and ## exception support. On the synthetic target the latter is -## handled by C code. The only initialization that is needed is +## handled by C code. The main initialization that is needed is ## to jump into the C startup. ## ######DESCRIPTIONEND#### ## ##============================================================================= +# According the SVR4/i386 ABI, most registers are undefined. However +# there is some interesting information on the stack: +# %esp argc +# %esp+4 argv[0] +# ... argv[1 onwards] +# %esp + (argc*4) NULL +# ... environ[0] +# ... ... +# ... NULL +# +# There are some other things that could be done, for example aligning +# the stack to a 16-byte boundary for SSE, but it is not clear which of +# those things are actually useful. The glibc source file +# sysdeps/i386/elf/start.S contains some relevant information. #============================================================================== -// .file "vectors.S" + .file "vectors.S" .extern _linux_entry + + .data + .global cyg_hal_sys_argc +cyg_hal_sys_argc: + .long 0 + .global cyg_hal_sys_argv +cyg_hal_sys_argv: + .long 0 + .global cyg_hal_sys_environ +cyg_hal_sys_environ: + .long 0 + .text .globl _start _start: + popl %eax + movl %eax, cyg_hal_sys_argc + movl %esp, %ebx + movl %ebx, cyg_hal_sys_argv + inc %eax + addl %eax, %eax + addl %eax, %eax + addl %eax, %ebx + movl %ebx, cyg_hal_sys_environ + jmp _linux_entry