Author: stepan Date: 2009-09-25 23:59:57 +0200 (Fri, 25 Sep 2009) New Revision: 4677
Modified: trunk/coreboot-v2/src/boot/selfboot.c trunk/coreboot-v2/src/include/stdlib.h trunk/coreboot-v2/src/include/string.h trunk/coreboot-v2/src/lib/malloc.c Log: drop some dead code, clarify small comments and small cleanups to malloc.c Signed-off-by: Stefan Reinauer <[email protected]> Acked-by: Stefan Reinauer <[email protected]> Modified: trunk/coreboot-v2/src/boot/selfboot.c =================================================================== --- trunk/coreboot-v2/src/boot/selfboot.c 2009-09-25 21:57:25 UTC (rev 4676) +++ trunk/coreboot-v2/src/boot/selfboot.c 2009-09-25 21:59:57 UTC (rev 4677) @@ -394,6 +394,7 @@ segment++; + // FIXME: Explain what this is for(ptr = head->next; ptr != head; ptr = ptr->next) { if (new->s_srcaddr < ntohl((u32) segment->load_addr)) break; Modified: trunk/coreboot-v2/src/include/stdlib.h =================================================================== --- trunk/coreboot-v2/src/include/stdlib.h 2009-09-25 21:57:25 UTC (rev 4676) +++ trunk/coreboot-v2/src/include/stdlib.h 2009-09-25 21:59:57 UTC (rev 4677) @@ -12,13 +12,8 @@ #define MAX(a,b) ((a) > (b) ? (a) : (b)) #ifndef __ROMCC__ -extern void *malloc(size_t size); +void *malloc(size_t size); void free(void *ptr); - -/* Extensions to malloc... */ -typedef size_t malloc_mark_t; -void malloc_mark(malloc_mark_t *place); -void malloc_release(malloc_mark_t *place); #endif #endif /* STDLIB_H */ Modified: trunk/coreboot-v2/src/include/string.h =================================================================== --- trunk/coreboot-v2/src/include/string.h 2009-09-25 21:57:25 UTC (rev 4676) +++ trunk/coreboot-v2/src/include/string.h 2009-09-25 21:59:57 UTC (rev 4677) @@ -8,15 +8,12 @@ void *memmove(void *dest, const void *src, size_t n); void *memset(void *s, int c, size_t n); int memcmp(const void *s1, const void *s2, size_t n); +#ifndef __ROMCC__ int sprintf(char * buf, const char *fmt, ...); +#endif -// yes, linux has fancy ones. We don't care. This stuff gets used -// hardly at all. And the pain of including those files is just too high. +// simple string functions -//extern inline void strcpy(char *dst, char *src) {while (*src) *dst++ = *src++;} - -//extern inline int strlen(char *src) { int i = 0; while (*src++) i++; return i;} - static inline size_t strnlen(const char *src, size_t max) { size_t i = 0; Modified: trunk/coreboot-v2/src/lib/malloc.c =================================================================== --- trunk/coreboot-v2/src/lib/malloc.c 2009-09-25 21:57:25 UTC (rev 4676) +++ trunk/coreboot-v2/src/lib/malloc.c 2009-09-25 21:59:57 UTC (rev 4677) @@ -10,36 +10,27 @@ static void *free_mem_ptr = &_heap; /* Start of heap */ static void *free_mem_end_ptr = &_eheap; /* End of heap */ - -void malloc_mark(malloc_mark_t *place) -{ - *place = (malloc_mark_t)free_mem_ptr; - printk_spew("malloc_mark %p\n", free_mem_ptr); -} - -void malloc_release(malloc_mark_t *ptr) -{ - free_mem_ptr = (void *)*ptr; - printk_spew("malloc_release %p\n", free_mem_ptr); -} - void *malloc(size_t size) { void *p; MALLOCDBG("%s Enter, size %ld, free_mem_ptr %p\n", __func__, size, free_mem_ptr); + + /* Checking arguments */ if (size < 0) - die("Error! malloc: Size < 0"); + die("Error! malloc: size < 0"); + + /* Overzealous linker check */ if (free_mem_ptr <= 0) die("Error! malloc: Free_mem_ptr <= 0"); - free_mem_ptr = (void *)(((unsigned long)free_mem_ptr + 3) & ~3); /* Align */ + free_mem_ptr = (void *)ALIGN((unsigned long)free_mem_ptr, 4); p = (void *) free_mem_ptr; free_mem_ptr += size; if (free_mem_ptr >= free_mem_end_ptr) - die("Error! malloc: free_mem_ptr >= free_mem_end_ptr"); + die("Error! malloc: Out of memory (free_mem_ptr >= free_mem_end_ptr)"); MALLOCDBG("malloc %p\n", p); @@ -49,4 +40,5 @@ void free(void *where) { /* Don't care */ + MALLOCDBG("free %p\n", where); } -- coreboot mailing list: [email protected] http://www.coreboot.org/mailman/listinfo/coreboot

