Re: PowerPC port for company

Posted by Martin Guy on
URL: http://elua-development.15.s1.nabble.com/PowerPC-port-for-company-tp7578410p7578428.html

On 21/05/2014, Will Johnson <[hidden email]> wrote:

> On Wed, May 21, 2014 at 1:23 PM, James Snyder <[hidden email]>wrote:
>> On Tue, May 20, 2014 at 8:32 AM, billson555 <[hidden email]>wrote:
>>> Are you saying that it would be
>>> impossible to run eLua without dynamic memory allocation, even if our Lua
>>> script tests didn't use any dynamic memory allocation?
>>
>> You certainly don't need an MMU (most of our targets don't have one).  Is
>> there a reason why you might not be able to set aside a heap for Lua and
>> point an existing malloc implementation at it (like the dlmalloc included
>> with eLua)?

Hi
   Your system doesn't need to supply dynamic memory allocation as
eLua does this for you. It has an internal version of _sbrk() which
replaces the operating system's one and gives out the requested memory
from a static list of available memory regions.
   So all you need to do is to say where the available heap mempry is
and the allcoator you choose (simple,multiple or newlib) should do the
rest.
   Actually, this area could be improved, since Lua calls malloc(),
malloc() calls sbrk() asking for ever-increasing amounts of memory for
its heap and sbrk() returns a pointer to the predefined RAM areas.
malloc(), for its version of the heap, asks for more and more memory
from sbrk() using an algorithm with an increasing increment until the
call fails, then thinks it has all the memory, whereas the three
allocators would be happier to be allocated all the available RAM at
startup, which would also mean they got all of it, not all of it
execpt the last fragment.

   The available mamory regions are defined, for example, in the generated file
boards/headers/board_mizar32b.h

// Configuration for element 'ram'
#define MEM_START_ADDRESS                { ( u32 )(
INTERNAL_RAM1_FIRST_FREE ),( ( u32 )( SDRAM + ELUA_FIRMWARE_SIZE ) ) }
#define MEM_END_ADDRESS                  { ( u32 )(
INTERNAL_RAM1_LAST_FREE ),( ( u32 )( SDRAM + ELUA_FIRMWARE_SIZE ) + (
u32 )( SDRAM_SIZE - ELUA_FIRMWARE_SIZE ) - 1 ) }

As for re-entrancy, I'd guess that as long as your system doesn't use
Lua interrupts you may be OK, as the Lua interpreter is
single-threaded.  For any interrupt routines you need, you'll just
have to be careful what function calls they make, ideally none!

Hope this gives you somewhere to start

   M
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev