/*
 *               Copyright (C) 2005, BroadOn Communications Corp.
 *
 *  These coded instructions, statements, and computer programs contain
 *  unpublished  proprietary information of BroadOn Communications Corp.,
 *  and  are protected by Federal copyright law. They may not be disclosed
 *  to  third  parties or copied or duplicated in any form, in whole or in
 *  part, without the prior written consent of BroadOn Communications Corp.
 *
 */

#include <iostypes.h>
#include <hw.h>
#include <ioslibc.h>
#include <apputils.h>
#include <elf.h>

int
m_binload(char *args, char *d)
{
    char *name;
    char *saddr;
    char *slen;
    int rv = -1;
    u32 addr, len;
    if (   getNextToken(&name, &args)
        && getNextToken(&saddr, &args)
        && getNextToken(&slen, &args)) {
        addr = atou32(saddr);
        len = atou32(slen);
        rv = binload(name, addr, len);
        if ( rv > 0 ) {
            printf("Loaded BIN file: %s [size = %u bytes]\n", name, len);
            printf("Load address: 0x%08x\n", addr);
        }
        else  {
           printf("Failed to load BIN file: %s or size = 0\n", name);
           rv = -1;
        }
    }
    else
        printf("Usage: binload file load_address len\n");
    return rv;
}
