summaryrefslogtreecommitdiff
path: root/core/mem
Commit message (Collapse)AuthorAgeFilesLines
* core: dprintf on malloc/free if -DDEBUG_MALLOCErwan Velu2015-09-022-0/+6
| | | | | | | | | | | When dynamic debug is engaged, the output is pretty flooded by malloc/free messages while you are looking at other traces. As devel.mk have a DEBUG_MALLOC option, it seems pretty logical to enable the malloc/free dprintf() only if this option is engaged. That patch make the dynamic debug output less floody while letting the choice to get the malloc/free dprintf() messages.
* tests: unit tests for core/memMatt Fleming2013-07-242-0/+132
| | | | | | | | | | | | | | | | | | | We can exercise the memory subsystem through unit tests with a little bit of coaxing. We need to create a number of fake data objects in order to get it to build. This is less than ideal, but once we've got good test coverage and confidence in our tests we can begin refactoring. Had this unit test already been in place, commit 33c4ab1b ("mem: fix regression in recent memscan changes") would have never been required because buggy commit a1331f8d ("memscan: pass enum syslinux_memmap_types around") would have broke the unit test. Ordinarily, this unit test would have been part of the bugfix commit 33c4ab1b, but the bugfix needs to be backported to 5.xx on its own. test_mem_init_reserved() tests whether SMT_RESERVED regions are incorrectly added to the memory subsystems's freelist. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* mem: explicitly include dprintf.hMatt Fleming2013-07-241-0/+1
| | | | | | | | | | It is good practice to explicitly include required header files as it clearly highlights dependencies. This practice also makes it easier to write unit tests since we explicitly include dummy header files from unittest/include. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* mem: fix regression in recent memscan changessyslinux-6.02-pre10Matt Fleming2013-07-231-1/+1
| | | | | | | | | | A thinko in commit a1331f8d ("memscan: pass enum syslinux_memmap_types around") causes many machines not to boot because the expression "!SMT_FREE" always evaluates to "false", regardless of the value of 'type', which means that mem_init() may use reserved memory regions for general allocation. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* memscan: pass enum syslinux_memmap_types aroundMatt Fleming2013-07-171-3/+4
| | | | | | | | The memscan interface should be using SMT_* to describe the types of memory regions as SMT_* are platform agnostic values. This will allow us to be much more descriptive about the type of memory regions in future. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* Merge tag 'syslinux-5.10-pre2' into for-hpa/elflink/firmwareMatt Fleming2013-03-224-2/+55
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | syslinux-5.10-pre2 Conflicts: NEWS com32/include/netinet/in.h com32/include/sys/cpu.h com32/lib/Makefile core/Makefile core/fs/diskio.c core/fs/pxe/pxe.h core/init.c core/mem/free.c core/mem/malloc.c mk/devel.mk version
| * Merge branch 'lwip' into elflinkMatt Fleming2013-02-263-0/+20
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Welcome to Syslinux 5.10. Conflicts: NEWS com32/lib/Makefile com32/lib/sys/open.c com32/lib/syslinux/ipappend.c com32/modules/Makefile com32/modules/prdhcp.c core/Makefile core/cmdline.inc core/com32.inc core/comboot.inc core/configinit.inc core/fs/chdir.c core/fs/fs.c core/fs/pxe/dnsresolv.c core/fs/pxe/pxe.c core/fs/pxe/pxe.h core/idle.c core/include/ctype.h core/init.inc core/mem/init.c core/parseconfig.inc core/runkernel.inc core/syslinux.ld core/ui.inc doc/comboot.txt version
| | * core: dynamically size the heapH. Peter Anvin2011-04-251-4/+10
| | | | | | | | | | | | | | | | | | Dynamically size the heap to 1/16 of available high memory. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
| | * core: Make the core malloc and free thread safe.Eric W. Biederman2011-04-093-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | Add a single semaphore to make malloc and free thread safe. This is code I extracted from hpa's earlier effort at importing lwip into syslinux. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
| * | mem: Add magic field to detect memory corruptionMatt Fleming2013-02-214-2/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Very little checking is performed on the validity of freelist metadata. Add a magic field to struct arena_header which can be used to detect memory corruption or whether a user tries to free something that isn't a malloc pointer. This feature can be enabled with -DDEBUG_MALLOC. Turn it on for development in mk/devel.mk. Cc: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* | | Merge tag 'syslinux-5.01' into firmwaresyslinux-6.00-pre4Matt Fleming2013-01-291-0/+2
|\ \ \ | |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: Makefile NEWS com32/cmenu/Makefile com32/elflink/ldlinux/Makefile com32/gfxboot/Makefile com32/gpllib/Makefile com32/include/sys/module.h com32/lib/Makefile com32/lib/sys/module/elf_module.c com32/menu/Makefile com32/rosh/Makefile com32/samples/Makefile core/init.c mk/elf.mk Signed-off-by: Matt Fleming <matt.fleming@intel.com>
| * | realloc: Set the HEAP when splitting a blockMatt Fleming2013-01-231-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Failure to do so means we may put a free block in some random location because ARENA_HEAP_GET() can return something invalid when used to find the correct free list in __free_block(). This bug manifested as running out of available free memory. Cc: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* | | Merge tag 'syslinux-5.00' into firmwaresyslinux-6.00-pre3Matt Fleming2012-12-072-5/+5
|\ \ \ | |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: Makefile com32/elflink/ldlinux/Makefile com32/lib/sys/module/elf_module.c core/cleanup.c core/comboot.inc core/conio.c core/fs/fs.c core/init.c core/mem/free.c core/mem/malloc.c core/timer.inc diag/geodsp/Makefile extlinux/main.c mk/embedded.mk modules/Makefile Signed-off-by: Matt Fleming <matt.fleming@intel.com>
| * | Symbol export whitelistMatt Fleming2012-12-052-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before modules were dynamically loaded the boundary between GPL and non-GPL code was implicit because of the separate link domains for each module. With dynamic modules we need an explicit whitelist of core symbols that non-GPL code can link against at runtime without needing to be re-licensed under the GPL. Mark such symbols with __export, so that it is explicitly clear which symbols in the core can be linked against by non-GPL code. Reduce the visibility of symbols in both the core and ldlinux.c32 with -fvisibility=hidden. __export changes the visibility to 'default'. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* | | firmware: Move memory operations into firmwareMatt Fleming2012-11-152-27/+33
| | | | | | | | | | | | | | | | | | | | | | | | Instead of littering core/mem with #ifdef SYSLINUX_EFI move memory operations into the 'firmware' structure so that they can be implemented differently for BIOS and EFI. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* | | Merge tag 'syslinux-5.00-pre10' into for-hpa/elflink/firmwareMatt Fleming2012-11-141-2/+2
|\ \ \ | |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | Pull in the latest prerelease that includes some bug fixes for ldlinux and a realloc() bug in core/. Conflicts: com32/cmenu/Makefile com32/elflink/ldlinux/Makefile com32/lib/Makefile core/pxelinux.asm
| * | core: Fix realloc() code transcription errorShao Miller2012-11-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 79459f631546eea83d4158f535c20ebd4ac18987 copied portions of com32/lib/realloc.c into core/mem/malloc.c, with minor changes for accessing allocation arena header attributes. The previous code used structure members and the current code uses bitmask macros. On a particular line in the original realloc(), there were two assignments in a single expression that included a compound assignment. This fact was missed when the code was copied and modified to use the bitmask macros. Signed-off-by: Shao Miller <sha0.miller@gmail.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* | | Merge remote-tracking branch 'mfleming/elflink' into for-hpa/elflink/firmwareMatt Fleming2012-07-302-3/+6
|\ \ \ | |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: Makefile com32/elflink/ldlinux/adv.c com32/elflink/ldlinux/kernel.c com32/elflink/ldlinux/ldlinux.c com32/include/bitsize/stddef.h com32/include/bitsize/stdint.h com32/include/stdint.h com32/include/sys/module.h com32/include/sys/x86_64/bitops.h com32/include/syslinux/linux.h com32/lib/Makefile com32/lib/sys/ansicon_write.c com32/lib/sys/module/elfutils.h com32/lib/sys/vesa/efi/fill.h com32/lib/syslinux/load_linux.c com32/lib/syslinux/serial.c com32/lib/syslinux/shuffle.c core/conio.c core/elflink/config.c core/elflink/load_env32.c core/graphics.c core/include/graphics.h core/init.c core/pxelinux.asm mk/elf.mk mk/lib.mk
| * | core: remove unused variable in scan_highmem_area()H. Peter Anvin2012-05-291-2/+0
| | | | | | | | | | | | | | | | | | | | | Remove a completely unused variable giving a "set but not used" warning. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
| * | core: Partial revert of commit 9333426b and unify lmalloc()Matt Fleming2012-04-171-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The reason behind commit 9333426b ("elflink: fix the global naming for lmalloc") seems to be that we need to avoid having two 'lmalloc' symbols, one in the core and one in the com32 library. Unfortunately, this commit introduced the following warning in multiple places, meminfo.c:47:2: warning: implicit declaration of function ‘lmalloc’ meminfo.c:47:9: warning: assignment makes pointer from integer without a cast meminfo.c:93:5: warning: implicit declaration of function ‘free’ meminfo.c:93:5: warning: incompatible implicit declaration of built-in function ‘free’ Consolidate the implementations of lmalloc() so that it's suitable for use both in the com32 library code and the core. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* | | core, efi: Return new pointer in realloc()Chandramouli Narayanan2012-02-241-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Instead of returning the pointer to the newly allocated memory, relloc() currently returns garbage. Return the correct pointer. Signed-off-by: Chandramouli Narayanan <chandramouli.narayanan@intel.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* | | EFI: Implement malloc with {Allocate/Free}Pool()Matt Fleming2011-12-162-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | We actually need to AllocatePool() the memory we want, otherwise the firmware can use it behind our backs. Since EFI firmware doesn't provide an interface for allocating memory at a specific address if the requested size isn't a multiple of PAGE_SIZE, use the pool functions.
* | | core: Add firmware backend supportMatt Fleming2011-12-161-1/+1
|/ / | | | | | | | | | | | | | | In an upcoming patch series we're going to need to abstract the firmware operations because they will be provided by both BIOS and EFI. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* | Revert "core: remove redundant zalloc() definition"H. Peter Anvin2011-12-151-0/+11
| | | | | | | | | | | | | | | | This reverts commit 46b993449264a2332427a165b4c77e400a053178. Build failure was due to a non-clean tree. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* | core: remove redundant zalloc() definitionH. Peter Anvin2011-12-141-11/+0
| | | | | | | | | | | | | | Remove a redundant definition of zalloc() which causes a compile failure. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* | core: fix warnings in core/mem/init.cH. Peter Anvin2011-05-271-6/+6
| | | | | | | | | | | | Fix warnings (that block -Werror) in core/mem/init.c Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* | Convert mp() to dprintf()Matt Fleming2011-03-091-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | There's only one function required for printing debugging information and that is dprintf() - there is no need to invent another. dprintf() is also superior to mp() because it can be enabled/disabled on a per-file basis via the DEBUG symbol. Switch all users of mp() to dprintf() and leave them disabled (don't define the DEBUG) so we have a less verbose boot by default. Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
* | core: Be less verbose at bootMatt Fleming2011-03-081-2/+1
| | | | | | | | | | | | | | Change some printf() calls to dprintf() so that we stop printing debugging information that is only useful for developers. Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
* | Merge branch 'master' into elflink-mergeH. Peter Anvin2010-08-121-1/+1
|\ \ | |/ | | | | | | | | | | | | Resolved Conflicts: core/diskfs.inc core/mem/free.c Signed-off-by: H. Peter Anvin <hpa@zytor.com>
| * Make __free_tagged actually free memorySebastian Herbszt2010-07-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | __free_tagged called by comboot_cleanup_lowmem (core/mem/free.c) doesn't seem to work correctly. Memory allocated with lmalloc() isn't marked as free after the allocating module exits: boot: mem lowmem_buf: 0x000353e0 boot: mem lowmem_buf: 0x000553f0 boot: mem lowmem_buf: 0x00075400 boot: mem lowmem_buf: 0x00000000 boot: The expected behaviour boot: mem lowmem_buf: 0x000353e0 boot: mem lowmem_buf: 0x000353e0 boot: mem lowmem_buf: 0x000353e0 can be achieved with the following patch.
* | elflink: some cleanupFeng Tang2010-07-201-8/+6
| |
* | elflink: malloc cleanupFeng Tang2010-07-201-20/+0
| | | | | | | | | | * remove com32/lib/malloc.h * remove com32/elflink/test_memalign.c
* | elflink: remove hmalloc which is not needed after core/com32 malloc mergedFeng Tang2010-07-201-5/+0
| |
* | elflink: remove the malloc.c/free.c/realloc.c/zalloc.c from com32Feng Tang2010-07-201-1/+31
| |
* | elflink: move realloc() to core/mem/malloc.cFeng Tang2010-07-203-38/+157
| | | | | | | | | | | | | | * remove most of the functinal codes from com32 malloc/realloc code * next step will be remove those codes from com32 * one left item is posix memalign problem and memory tag problem which is usded by elf module load code
* | June 22: new mem_init worksFeng Tang2010-07-201-20/+59
| |
* | elflink: make linux kernel bootingFeng Tang2010-07-201-1/+2
| | | | | | | | | | | | | | | | * modify execute.c to not using __com32.cs_bounce but lmalloc/lfree * give core/malloc 32M memory Now the kernel is loading ok, but "memdisk initrd=doshd.img" is not working, need ask hpa if he has a new doshd.img
* | elflink: use core/malloc as the malloc system, enlarge buffer to 1MBfeng.tang@intel.com2010-07-201-1/+2
| |
* | elflink: make malloc worksFeng Tang2010-07-203-2/+16
| | | | | | | | | | mask the malloc of com32, will still need to change its way of calling inject_free_block
* | 0613 temp debugFeng Tang2010-07-202-2/+4
| |
* | elflink: differentiate the 2 malloc systemFeng Tang2010-07-204-8/+8
|/ | | | | core and com32 both have their own malloc system, change the name to make them co-exist
* core: don't bother zeroing the disk cache and heapH. Peter Anvin2010-03-061-1/+1
| | | | | | | No point in zeroing out the disk cache and the heap. Put those in a .hugebss section which we align, but don't zero. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* mem: increase the heap size to 128KH. Peter Anvin2010-03-061-1/+1
| | | | | | Use 128K for the heap, to allow TFTP buffers to be allocated there. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* core/mem: better dprintf()H. Peter Anvin2010-02-242-3/+4
| | | | | | | Add a few dprintf() statements to the core malloc/free which makes it easier to track down bugs. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* core: fix lowmem mallocH. Peter Anvin2010-02-242-0/+3
| | | | | | | | | | | | a) initialize *all* the head nodes b) the lowmem heap needs to be paragraph (16 byte) aligned c) use a dedicated tag value for headnodes. The type code should be removed and replaced with special tag values for head node and free. d) for libcom32 code called from the core, do NOT present a usable bounce buffer; we should only ever use lmalloc/lfree. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* core: use better malloc; add low memory malloc; fix com32 exitH. Peter Anvin2010-02-234-0/+369
Use a better malloc for the core. In particular, use the same core that we should eventually be able to use for the entire system in Syslinux 5 -- with module awareness, etc. This code can also accommodate multiple heaps. Set up a separate heap for lowmem; the intent is to use explicit lowmem allocations instead of the static bounce buffer. The lowmem allocation is also exported via the pmapi mechanism, so modules can safely allocate lowmem. Signed-off-by: H. Peter Anvin <hpa@zytor.com>