On Friday 06 December 2002 06:53, brian.sm...@tekelek.com.au wrote:
> I have a lot of data to write to the information memory and want to use the
> Block write rather than single byte write. This means I have to execute out
> of RAM while the write is happening. Any clues as to how to do this?

You can execute a code located in RAM at any time. But first, you have to copy 
this func there. To copy the function to RAM, you need to know its size and a 
pointer.

Consider the following:
---------------------------------------------------------------------------
type_f func_to_be_execed_from_ram(params p1, ...)
{
  // func body.
  // make sure there are no long branches
  // or _relative_ (pc) calls (gcc does not issue them).
}

void dummy_func() {
  // must exists and be empty cause we need this function to
  // determine previous' one size.
}

void this_func_copies_another_to_ram(void *dst, void *src, size_t size)
{
//  memcpy(dst,src,size) can be a good choise
}

void *prepare_copy()
{
  void *dst;
  size_t size;
  extern char __bss_end;        // this var defined by linker. read docs for 
more 
info.
  size = (char *)&dummy_func - (char *)&func_to_be_execed_from_ram;
  dst = (char *)&__bss_end + size;
  this_func_copies_another_to_ram(dst, &func_to_be_execed_from_ram, size);
  return dst;
}

void (*copier)();

int main()
{
  copier = prepare_copy();
  copier();
  return 240;
}


> My plan is to define a function pointer to the writing function in ROM and
> use that to copy the function to a location in RAM. The location in RAM
> will also be a function pointer so it is just a matter of executing the
> function in RAM at the pointer. My problem is, how do I know how big the
> function is to work out the copy size? Has anyone managed this?
>

Do not pass -ffunction-sections flag to compiler.


Hope this helps,
~d

> Brian Smith
> Australia
>
>
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Mspgcc-users mailing list
> Mspgcc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users

-- 
/********************************************************************
     ("`-''-/").___..--''"`-._     (\   Dimmy the Wild      UA1ACZ
      `6_ 6  )   `-.  (     ).`-.__.`)  Enterprise Information Sys 
      (_Y_.)'  ._   )  `._ `. ``-..-'   Nevsky prospekt,   20 / 44
    _..`--'_..-_/  /--'_.' ,'           Saint Petersburg,   Russia
   (il),-''  (li),'  ((!.-'             +7 (812)  3468202, 5585314
 ********************************************************************/


Reply via email to