These patches make it easier to set up a memalloc heap in RedBoot. Used mainly to allow things like file systems to work in RedBoot.
Index: redboot/current/ChangeLog =================================================================== RCS file: /cvs/ecos/ecos/packages/redboot/current/ChangeLog,v retrieving revision 1.273 diff -u -5 -r1.273 ChangeLog --- redboot/current/ChangeLog 3 Jun 2009 20:56:34 -0000 1.273 +++ redboot/current/ChangeLog 24 Jun 2009 14:53:13 -0000 @@ -1,5 +1,14 @@ +2009-06-24 Nick Garnett <[email protected]> + + * cdl/redboot.cdl: + * src/main.c (cyg_start): Added options and code to reinitialize + the heap, if it exists, to an arena cut off the end of the + workspace. + [Imported from eCosPro sources, mainly to support use of + filesystems in RedBoot]. + 2009-06-02 Ross Younger <[email protected]> * redboot.cdl: REDBOOT_IO_FILEIO requires CYGPKG_IO 2009-04-20 Andrew Lunn <[email protected]> Index: redboot/current/cdl/redboot.cdl =================================================================== RCS file: /cvs/ecos/ecos/packages/redboot/current/cdl/redboot.cdl,v retrieving revision 1.84 diff -u -5 -r1.84 redboot.cdl --- redboot/current/cdl/redboot.cdl 3 Jun 2009 20:56:34 -0000 1.84 +++ redboot/current/cdl/redboot.cdl 24 Jun 2009 14:53:13 -0000 @@ -1282,10 +1282,36 @@ description " Size of common buffer to allocate. Must be at least the size of one flash sector." } } + + cdl_component CYGMEM_REDBOOT_WORKSPACE_HEAP { + display "Allocate heap in RedBoot workspace" + flavor bool + active_if CYGPKG_MEMALLOC + active_if CYGPKG_MEMALLOC_MALLOC_ALLOCATORS + default_value 0 + description " + If the MEMALLOC package is present, it usually allocates + the whole of memory not used by the program to the heap. + In RedBoot this is not a good idea, since we need space to + load application programs. Setting this option causes RedBoot + to allocate the heap at the top of RAM by reserving part of + RedBoot's workspace memory, leaving the rest of memory free." + + cdl_option CYGMEM_REDBOOT_WORKSPACE_HEAP_SIZE { + display "Size of RedBoot heap" + flavor data + default_value 0x10000 + legal_values 0x4000 to 0x80000000 + description " + Size of RedBoot heap. This defines how much memory is to be + allocated for the heap." + } + } + cdl_option CYGNUM_REDBOOT_GETC_BUFFER { display "Buffer size in getc when loading images" flavor data default_value { CYGPKG_REDBOOT_FILEIO ? 4096 : 256 } description " Index: redboot/current/src/main.c =================================================================== RCS file: /cvs/ecos/ecos/packages/redboot/current/src/main.c,v retrieving revision 1.73 diff -u -5 -r1.73 main.c --- redboot/current/src/main.c 25 Mar 2009 10:34:39 -0000 1.73 +++ redboot/current/src/main.c 24 Jun 2009 14:53:13 -0000 @@ -299,10 +299,21 @@ // when *less* SDRAM is installed than the possible maximum, // but the heap1 region remains greater... workspace_end = ram_end; } +#if defined(CYGMEM_REDBOOT_WORKSPACE_HEAP) + { + extern cyg_bool cyg_memalloc_heap_reinit( cyg_uint8 *base, cyg_uint32 size ); + + workspace_end -= CYGMEM_REDBOOT_WORKSPACE_HEAP_SIZE; + + if( !cyg_memalloc_heap_reinit( (cyg_uint8 *)workspace_end, CYGMEM_REDBOOT_WORKSPACE_HEAP_SIZE ) ) + diag_printf("Heap reinitialization failed\n"); + } +#endif + workspace_end_init=workspace_end; // Nothing has ever been loaded into memory entry_address = (unsigned long)NO_MEMORY; Index: services/memalloc/common/current/ChangeLog =================================================================== RCS file: /cvs/ecos/ecos/packages/services/memalloc/common/current/ChangeLog,v retrieving revision 1.49 diff -u -5 -r1.49 ChangeLog --- services/memalloc/common/current/ChangeLog 17 Feb 2009 00:39:42 -0000 1.49 +++ services/memalloc/common/current/ChangeLog 24 Jun 2009 14:53:14 -0000 @@ -1,5 +1,15 @@ +2009-06-24 Nick Garnett <[email protected]> + + * src/malloc.cxx (cyg_memalloc_heap_reinit): Added this function + to reinitialize the heap to a new arena. This should be done + during system startup and is present mainly for the use of + RedBoot. + Permit configurations with multi-region heaps to build. + [Imported from eCosPro sources, mainly to support use of + filesystems in RedBoot]. + 2009-02-03 Simon Kallweit <[email protected]> * include/mvarimpl.inl: * include/sepmetaimpl.inl: Fixed a few compiler warnings. @@ -393,11 +403,11 @@ //=========================================================================== // ####GPLCOPYRIGHTBEGIN#### // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. -// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2009 Free Software Foundation, Inc. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 or (at your option) any // later version. Index: services/memalloc/common/current/src/malloc.cxx =================================================================== RCS file: /cvs/ecos/ecos/packages/services/memalloc/common/current/src/malloc.cxx,v retrieving revision 1.9 diff -u -5 -r1.9 malloc.cxx --- services/memalloc/common/current/src/malloc.cxx 29 Jan 2009 17:50:09 -0000 1.9 +++ services/memalloc/common/current/src/malloc.cxx 24 Jun 2009 14:53:14 -0000 @@ -6,11 +6,11 @@ // //======================================================================== // ####ECOSGPLCOPYRIGHTBEGIN#### // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. -// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2009 Free Software Foundation, Inc. // // eCos is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free // Software Foundation; either version 2 or (at your option) any later // version. @@ -282,8 +282,29 @@ CYG_REPORT_RETURN(); return ret; } // mallinfo() + +inline void * +operator new(size_t size, CYGCLS_MEMALLOC_MALLOC_IMPL *ptr) +{ return (void *)ptr; }; + +externC cyg_bool +cyg_memalloc_heap_reinit( cyg_uint8 *base, cyg_uint32 size ) +{ +#if CYGMEM_HEAP_COUNT == 0 + CYGCLS_MEMALLOC_MALLOC_IMPL *m = new(&cyg_memalloc_mallocpool) + CYGCLS_MEMALLOC_MALLOC_IMPL( base, size ); + return true; +#elif CYGMEM_HEAP_COUNT == 1 + cygmem_memalloc_heaps[0] = new(cygmem_memalloc_heaps[0]) + CYGCLS_MEMALLOC_MALLOC_IMPL( base, size ); + return true; +#else + return false; +#endif +} + #endif // ifdef CYGPKG_MEMALLOC_MALLOC_ALLOCATORS // EOF malloc.cxx -- Nick Garnett eCos Kernel Architect eCosCentric Limited http://www.eCosCentric.com The eCos experts Barnwell House, Barnwell Drive, Cambridge, UK. Tel: +44 1223 245571 Registered in England and Wales: Reg No: 4422071
