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: how redboot get the parameter passed from its command?





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


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