public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] RE: 回复: RE: [ECOS] how redboot get the parameter passed from its command?
       [not found] <759986.64653.qm@web92004.mail.cnb.yahoo.com>
@ 2007-04-17  1:48 ` jiang jet
  0 siblings, 0 replies; only message in thread
From: jiang jet @ 2007-04-17  1:48 UTC (permalink / raw)
  To: wangyue0921; +Cc: ecos-discuss

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=gb2312; format=flowed, Size: 5843 bytes --]




>From: Ô½ Íõ <wangyue0921@yahoo.com.cn>
>To: jiang jet <jetjiang@hotmail.com>
>CC: ecos-discuss@ecos.sourceware.org
>Subject: »Ø¸´£º RE: [ECOS] how redboot get the parameter passed from its 
command?
>Date: Tue, 17 Apr 2007 09:24:44 +0800 (CST)
>
>Sorry,I have red it and can't find key to this point.
>The file iomem.c said that the function "init_opts"
>made the parameter "base" and "value" got their
>values.The functions
>"HAL_READ_UINT32","HAL_READ_UINT16" and
>"HAL_READ_UINT8" realized the command iopeek.
>I searched the source and found the
>HAL_READ_UINT32(16,8) depended on the cpu's arch.And
>my cpu's function defined in the file
>/ixp425/../var_io.h.
>But still I can't find the definition of the
>"init_opts",and I don't know how these parameters
>passed.
>
>PS,I want to add a new command to redboot.So I want to
>find out how the command realized in details.

basically all the redboot cmds work the same way..
in main.c
  res = _rb_gets(line, sizeof(line), CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT);
you will get the cmd from tty into line buffer..
  expand_aliases(line, sizeof(line));
  cmd = parse(&command, &argc, &argv[0]);
the cmd will be passed to arcv;
      (cmd->fun)(argc, argv);  //the para is passed to concrete 
functions,say do_iopeek(int argc, char *argv[])
here the cmd will be excuted....

if you want to implement a new cmd ,what you need to do is just to use 
Macro Redboot_Cmd, which will add the cmd to table __RedBoot_CMD_TAB__,and 
then implement the concrete cmd,



>Thank you!
>--- jiang jet <jetjiang@hotmail.com>дµÀ:
>
> >
> >
> >
> > >From: Ô½ Íõ <wangyue0921@yahoo.com.cn>
> > >To: ecos-discuss@ecos.sourceware.org
> > >Subject: [ECOS] how redboot get the parameter
> > passed from its command?
> > >Date: Mon, 16 Apr 2007 09:52:15 +0800 (CST)
> > >
> > >Hi,all
> > >
> > >I want to add a new command to redboot,but i don't
> > >understand how redboot commands carry out?
> > >
> > >for exemple, the file iomem.c shows
> > >
> > >RedBoot_cmd("iopeek",                    //the
> > command
> > >iopeek declare here
> > >          "Read I/O location",
> > >          "[-b <location>] [-1|2|4]",
> > >          do_iopeek
> > >     );
> > >
> > >void
> > >//carry out this command
> > >
> > >do_iopeek(int argc, char *argv[])
> > >{
> > >     struct option_info opts[4];       //the struct
> > >option_info declared in redboot.h?
> > >
> > >     unsigned long base;
> > >     bool base_set;
> > >     bool set_32bit = false;
> > >     bool set_16bit = false;
> > >     bool set_8bit = false;
> > >     int size = 1, value;
> > >
> > >     init_opts(&opts[0], 'b', true,
> > >OPTION_ARG_TYPE_NUM,                   &base,
> > >&base_set, "base address");
> > >     init_opts(&opts[1], '4', false,
> > >OPTION_ARG_TYPE_FLG,
> > >               &set_32bit, 0, "output 32 bit
> > units");
> > >
> > >     init_opts(&opts[2], '2', false,
> > >OPTION_ARG_TYPE_FLG,
> > >               &set_16bit, 0, "output 16 bit
> > units");
> > >
> > >     init_opts(&opts[3], '1', false,
> > >OPTION_ARG_TYPE_FLG,
> > >               &set_8bit, 0, "output 8 bit units");
> > >     if (!scan_opts(argc, argv, 1, opts, 4, 0, 0,
> > ""))
> > >{
> > >         return;
> > >     }
> > >     if (!base_set) {
> > >         diag_printf("iopeek what <location>?\n");
> > >         return;
> > >     }
> > >     if (set_32bit) {
> > >       size = 4;
> > >     } else if (set_16bit) {
> > >         size = 2;
> > >     } else if (set_8bit) {
> > >         size = 1;
> > >     }
> > >
> > >     switch (size) {
> > >     case 4:
> > >         HAL_READ_UINT32 ( base, value );
> > >
> > >         diag_printf("0x%04lx = 0x%08x\n", base,
> > value
> > >);
> > >         break;
> > >
> > >
> > >     case 2:
> > >         HAL_READ_UINT16 ( base, value );
> > >         diag_printf("0x%04lx = 0x%04x\n", base,
> > value
> > >);
> > >         break;
> > >     case 1:
> > >         HAL_READ_UINT8 ( base, value );
> > >         diag_printf("0x%04lx = 0x%02x\n", base,
> > value
> > >);
> > >         break;
> > >     }
> > >}
> > >
> > >
> > >My question is how redboot get the parameter passed
> > >from the command iopeek to some function that
> > realize
> > >the command? I guess the init_opts did it.But how
> > it
> > >works? And I serched the redboot.h and
> > >cyg/hal/hal_io.h,can't find the definition of this
> > >function.
> > >
> > read redboot/version_no/src/main.c, you will find
> > the answer to ur
> > questions
> >
> > >Would someone kindly explain how the parameters
> > were
> > >passed to the function HAL_READ_UINT8 's variable
> > base
> > >in details?
> > >
> > >thanks a lot!
> > >
> > >
> > >
> > >
> >
>___________________________________________________________
> > >ÑÅ»¢Ãâ·ÑÓÊÏä-3.5GÈÝÁ¿£¬20M¸½¼þ
> > >http://cn.mail.yahoo.com/
> > >
> > >--
> > >Before posting, please read the FAQ:
> > http://ecos.sourceware.org/fom/ecos
> > >and search the list archive:
> > http://ecos.sourceware.org/ml/ecos-discuss
> > >
> >
> >
>_________________________________________________________________
> > ÓëÁª»úµÄÅóÓѽøÐн»Á÷£¬ÇëʹÓà MSN Messenger:
> > http://messenger.msn.com/cn
> >
> >
> > --
> > Before posting, please read the FAQ:
> > http://ecos.sourceware.org/fom/ecos
> > and search the list archive:
> > http://ecos.sourceware.org/ml/ecos-discuss
> >
> >
>
>
>
>       ___________________________________________________________
>ÇÀ×¢ÑÅ»¢Ãâ·ÑÓÊÏä-3.5GÈÝÁ¿£¬20M¸½¼þ£¡
>http://cn.mail.yahoo.com

_________________________________________________________________
ÓëÁª»úµÄÅóÓѽøÐн»Á÷£¬ÇëʹÓà MSN Messenger:  http://messenger.msn.com/cn  


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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-04-17  1:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <759986.64653.qm@web92004.mail.cnb.yahoo.com>
2007-04-17  1:48 ` [ECOS] RE: 回复: RE: [ECOS] how redboot get the parameter passed from its command? jiang jet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).