This is the mail archive of the ecos-discuss@sources.redhat.com 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]

RE: Adding commands to RedBoot



Here is a version of redboot/current/src/main.c that supports 2 new
functions:

edit -b <address> -v <value> [-s <size>]
fill -b <address> -l <length> -v <value>

size is the size in bytes of the value, either 1, 2, or 4 (sorry, no 64 bit
support yet).
If the -s option is omitted, the default is 4 (32 bits)

The function that does all the work is called diag_edit().  I'm not sure it
should
go in main.c, so I've just included it here.  I put it in
infra/current/src/diag.cxx at the bottom, next to the dump utilities. From
the email
Jonathan suggests otherwise.

#include <cyg/hal/hal_io.h>

externC void
diag_edit(void *p, unsigned long x, unsigned long s)
{
  switch(s) {
    case 1:
      HAL_WRITE_UINT8(p,(unsigned char) x);
      break;
    case 2:
      HAL_WRITE_UINT16(p,(unsigned short) x);
      break;
    case 4:
      HAL_WRITE_UINT32(p,(unsigned long) x);
      break;
  }
}

Enjoy,

Warren

-----Original Message-----
From: Jonathan Larmour [mailto:jlarmour@redhat.com]
Sent: Tuesday, September 18, 2001 4:30 PM
To: Warren Jasper
Cc: ecos-discuss@sources.redhat.com
Subject: Re: [ECOS] Adding commands to RedBoot


Warren Jasper wrote:
> 
> What is the preferred way to add/extend commands to RedBoot?

If you've looked at the sources, you've probably already seen RedBoot_Cmd.

> Specifically, it would be nice to have 2 command to augment dump, namely:
> 
> edit -b <location> -v <value>
> 
> fill -b <location> -l <length> -v <value>
> 
> Should these functions reside in diag.cxx and just put the calls in
> /redboot/current/main.c?

diag.cxx? Surely not. Put them in main.c beside dump. Although once we
reach that point, we may choose to break some of the commands out of main.c
as it's getting quite big...

> Somewhere they should call the macro HAL_WRITE_UINT32.

Yep, or whatever HAL macros are appropriate. There should probably be a
size argument to edit (byte, halfword, word, or perhaps instead just the
length in bytes).

Jifl
-- 
Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223) 271062
Maybe this world is another planet's Hell -Aldous Huxley || Opinions==mine

main.c


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