* [ECOS] how redboot get the parameter passed from its command?
@ 2007-04-16 1:52 越 王
2007-04-16 2:43 ` jiang jet
0 siblings, 1 reply; 2+ messages in thread
From: 越 王 @ 2007-04-16 1:52 UTC (permalink / raw)
To: ecos-discuss
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=gb2312, Size: 2620 bytes --]
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.
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* RE: [ECOS] how redboot get the parameter passed from its command?
2007-04-16 1:52 [ECOS] how redboot get the parameter passed from its command? 越 王
@ 2007-04-16 2:43 ` jiang jet
0 siblings, 0 replies; 2+ messages in thread
From: jiang jet @ 2007-04-16 2:43 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: 3216 bytes --]
>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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-04-16 2:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-16 1:52 [ECOS] how redboot get the parameter passed from its command? 越 王
2007-04-16 2:43 ` 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).