This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: arguments to main


On Fri, Jul 26, 2002 at 02:52:19AM -0700, NavEcos wrote:
> On Friday 26 July 2002 00:47, Martin Buck wrote:
> > Tracy Jones wrote:
> > > available.  I understand that the synthetic target does not make an
> > > attempt to
> > > preserve command line args, but is there a way to "hack" it in there?
> 
> The code is essentially GPL..
> 
> go ahead and do it :)

That's the spirit. I just did it for ecos 1.3.1 last week. The patch is
attached. My approach was to actually pick up argc and argv properly
in the entry code, and setting the global variables linux_argc and
linux_argv to hold them.
Here's the patch:

--- ecos-1.3.1/packages/hal/i386/arch/v1_3_1/src/vectors.S      Mon Mar
27 14:17:07 2000
+++ ecos-1.3.1-patched/packages/hal/i386/arch/v1_3_1/src/vectors.S
Thu Jul 18 14:09:48 2002
@@ -68,6 +68,9 @@
        .globl  _start
 
 _start:
+       movl    (%esp),%eax             # argc
+       mov     %esp,%edx               # &argv
+       addl    $4,%edx
        jmp     _linux_entry
 
 #else  ## ifdef CYGPKG_HAL_I386_LINUX

--- ecos-1.3.1/packages/hal/i386/linux/v1_3_1/src/entry.c       Mon Mar
27 14:17:08 2000
+++ ecos-1.3.1-patched/packages/hal/i386/linux/v1_3_1/src/entry.c
Thu Jul 18 14:09:48 2002
@@ -47,9 +47,13 @@
 externC void cyg_start( void );
 externC void cyg_hal_hardware_init( void );
 
-void _linux_entry( void )
+int linux_argc;
+char **linux_argv;
+
+void __attribute__((regparm(2))) _linux_entry( int argc, char **argv )
 {
-    // Should get argc argv
+    linux_argc = argc;
+    linux_argv = argv;
     cyg_hal_hardware_init();
     cyg_hal_isr_init();
     cyg_hal_invoke_constructors();


-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]