/*
 *               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.
 *
 * $Id: memory.c,v 1.2 2008/04/08 18:18:03 cnguyen Exp $
 */

#include <stdlib.h>
#include <iostypes.h>
#include <ios.h>
#include <ioslibc.h>
#include <apputils.h>
#include <elf.h>
#include <iostypes.h>
#include <iop.h>

/*
 * peek
 *
 *    % peek address
 */
int
peek (char *args, char *d)
{
    s32 rc = 0;
    u32 address, value;
    char *ptr;

    if (getNextToken(&ptr, &args) == 0) {
        printf ("Usage: peek address\n");
        goto peek_out;
    }
    address = asciiToInt(ptr);

    value = *(u32 *)address;

    printf ("@0x%08x = 0x%08x\n", address, value);

peek_out:

    return rc;
}

/*
 * poke
 *
 *    % poke address value
 */
int
poke (char *args, char *d)
{
    s32 rc = 0;
    u32 address, value;
    char *ptr;

    if (getNextToken(&ptr, &args) == 0) {
        printf ("Usage: poke address value\n");
        goto poke_out;
    }
    address = asciiToInt(ptr);

    if (getNextToken(&ptr, &args) == 0) {
        printf ("Usage: poke address value\n");
        goto poke_out;
    }
    value = asciiToInt(ptr);

    *(u32 *)address = value;

    printf ("@0x%08x = 0x%08x\n", address, *(u32 *)address);

poke_out:

    return rc;
}

/* eof */
