public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
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 01:52:00 -0000	[thread overview]
Message-ID: <2722.90989.qm@web92006.mail.cnb.yahoo.com> (raw)

[-- 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

             reply	other threads:[~2007-04-16  1:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-16  1:52 越 王 [this message]
2007-04-16  2:43 ` jiang jet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2722.90989.qm@web92006.mail.cnb.yahoo.com \
    --to=wangyue0921@yahoo.com.cn \
    --cc=ecos-discuss@ecos.sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).