This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
Re: [ECOS] arguments to main
- From: Andrew Lunn <andrew dot lunn at ascom dot ch>
- To: Gary Thomas <gary at chez-thomas dot org>
- Cc: Wouter Cloetens <wouter at mind dot be>, ecos-patches at sources dot redhat dot com
- Date: Wed, 31 Jul 2002 19:41:52 +0200
- Subject: Re: [ECOS] arguments to main
- References: <02072602521900.01647@c1830598-a> <20020730224422.GI1607@roadkill.intern.mind.be> <20020731074631.GC3392@biferten.ma.tech.ascom.ch> <1028117420.28587.127.camel@hermes.chez-thomas.org>
> Additionally, these variables should be exported via some HAL .h file,
> possibly <cyg/hal/hal.h> or maybe <cyg/hal/hal_arch.h>.
>
> Finally, there should be appropriate ChangeLog entries.
>
I could not work out how to get access to the environment. I can see
it on the stack, but i cannot find an obvious pointer to it anywhere.
Does anyone know of any documentation of how the linux kernel sets up
the stack before handing it over to the new process?
The patch below add cyg_hal_argv and cyg_hal_argc.
Andrew
Index: packages/hal/synth/arch/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/synth/arch/current/ChangeLog,v
retrieving revision 1.6
diff -u -5 -p -r1.6 ChangeLog
--- packages/hal/synth/arch/current/ChangeLog 23 May 2002 23:05:24 -0000 1.6
+++ packages/hal/synth/arch/current/ChangeLog 31 Jul 2002 17:37:17 -0000
@@ -1,5 +1,11 @@
+2002-07/31 Wouter Cloetens <wouter@mind.be>
+ Andrew Lunn <Andrew.Lunn@ascom.ch>
+
+ * include/hal_arch.h: Global variables cyg_hal_arg[vc] from synth process
+ * src/synth_entry.c: Initialse cyg_hal_arg[vc] from the process arg[cv]
+
2002-05-23 Jesper Skov <jskov@redhat.com>
* cdl/hal_synth.cdl: Don't run cache tests.
2002-04-10 Jonathan Larmour <jlarmour@redhat.com>
Index: packages/hal/synth/arch/current/include/hal_arch.h
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/synth/arch/current/include/hal_arch.h,v
retrieving revision 1.3
diff -u -5 -p -r1.3 hal_arch.h
--- packages/hal/synth/arch/current/include/hal_arch.h 23 May 2002 23:05:27 -0000 1.3
+++ packages/hal/synth/arch/current/include/hal_arch.h 31 Jul 2002 17:37:17 -0000
@@ -84,7 +84,15 @@ externC void cyg_hal_deliver_exception(
externC void hal_idle_thread_action(cyg_uint32 loop_count);
#define HAL_IDLE_THREAD_ACTION(_count_) hal_idle_thread_action(_count_)
//--------------------------------------------------------------------------
+// The synthetic target has the opertunity to have argc & argv from
+// command line arguments when the target is started. Make these values
+// available in two HAL global variables.
+
+externC int cyg_hal_argc;
+externC char ** cyg_hal_argv;
+//--------------------------------------------------------------------------
+
#endif // CYGONCE_HAL_HAL_ARCH_H
// End of hal_arch.h
Index: packages/hal/synth/arch/current/src/synth_entry.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/synth/arch/current/src/synth_entry.c,v
retrieving revision 1.3
diff -u -5 -p -r1.3 synth_entry.c
--- packages/hal/synth/arch/current/src/synth_entry.c 23 May 2002 23:05:28 -0000 1.3
+++ packages/hal/synth/arch/current/src/synth_entry.c 31 Jul 2002 17:37:17 -0000
@@ -98,11 +98,16 @@ cyg_hal_invoke_constructors (void)
// The HAL specification defines clearly what should happen during
// startup.
externC void cyg_start( void );
-void _linux_entry( void )
+// Global variables for the command line arguments
+
+int cyg_hal_argc;
+char ** cyg_hal_argv;
+
+void __attribute__((regparm(2)))_linux_entry(int argc, char **argv)
{
void* new_top = (void*) 0;
// "Initialize various cpu status registers, including disabling interrupts."
// That is a no-op for the synthetic target, in particular interrupts are
@@ -143,10 +148,14 @@ void _linux_entry( void )
// .data section.
// "Zero the .bss section". Linux will have done this for us.
// "Create a suitable C stack frame". Already done.
+
+ // Allow access to command line parameters.
+ cyg_hal_argc = argc;
+ cyg_hal_argv = argv;
// Invoke the C++ constructors.
cyg_hal_invoke_constructors();
// "Call cyg_start()". OK.
Index: packages/hal/synth/i386linux/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/synth/i386linux/current/ChangeLog,v
retrieving revision 1.6
diff -u -5 -p -r1.6 ChangeLog
--- packages/hal/synth/i386linux/current/ChangeLog 23 May 2002 23:05:28 -0000 1.6
+++ packages/hal/synth/i386linux/current/ChangeLog 31 Jul 2002 17:37:17 -0000
@@ -1,5 +1,9 @@
+2002-07-31 Wouter Cloetens <wouter@mind.be>
+ Andrew Lunn <Andrew.Lunn@ascom.ch>
+ * src/vectors.s: Pass argc,argv into the C entry function
+
2002-04-29 Jonathan Larmour <jlarmour@redhat.com>
* src/vectors.S:
Don't use .file as it can confuse debugging since the .file
doesn't contain the path and therefore the debugger will never
Index: packages/hal/synth/i386linux/current/src/vectors.S
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/synth/i386linux/current/src/vectors.S,v
retrieving revision 1.3
diff -u -5 -p -r1.3 vectors.S
--- packages/hal/synth/i386linux/current/src/vectors.S 23 May 2002 23:05:31 -0000 1.3
+++ packages/hal/synth/i386linux/current/src/vectors.S 31 Jul 2002 17:37:17 -0000
@@ -61,6 +61,9 @@
.extern _linux_entry
.text
.globl _start
_start:
+ movl (%esp),%eax # argc
+ mov %esp,%edx
+ addl $4,%edx # &argv
jmp _linux_entry