This is the mail archive of the ecos-discuss@sourceware.org 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: 回复: RE: [ECOS] how redboot get the par ameter passed from its command?





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


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