summaryrefslogtreecommitdiff
path: root/payloads/libpayload/include
diff options
context:
space:
mode:
authorStefan Reinauer <stepan@coresystems.de>2010-03-25 22:15:19 +0000
committerStefan Reinauer <stepan@openbios.org>2010-03-25 22:15:19 +0000
commite5d30b78b7720ba3e511819b7fc51c11d642153b (patch)
tree16e7be335542de064aef267c7c6095f5c8cd3496 /payloads/libpayload/include
parent516a2a7bfaee5d4aa4d1e7e5ff52d3038513c82f (diff)
downloadcoreboot-e5d30b78b7720ba3e511819b7fc51c11d642153b.tar.xz
libpayload update
* rework Config.in * add string_to_args function to actually make getopt usable. * add strchr * add strlcat * some malloc fixes (exposed by the USB stack) * add malloc debugging (thanks to Matthias Krause from Secunet!) * make LAR support optional, it's not really used anymore * (define htoX macros for ppc) Signed-off-by: Stefan Reinauer <stepan@coresystems.de> Acked-by: Joseph Smith <joe@settoplinux.org> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@5298 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'payloads/libpayload/include')
-rw-r--r--payloads/libpayload/include/getopt.h5
-rw-r--r--payloads/libpayload/include/libpayload.h80
-rw-r--r--payloads/libpayload/include/powerpc/arch/endian.h4
3 files changed, 88 insertions, 1 deletions
diff --git a/payloads/libpayload/include/getopt.h b/payloads/libpayload/include/getopt.h
index d5038c8e0f..d4d8135aff 100644
--- a/payloads/libpayload/include/getopt.h
+++ b/payloads/libpayload/include/getopt.h
@@ -75,4 +75,9 @@ extern char *suboptarg; /* getsubopt(3) external variable */
#endif
//__END_DECLS
+#define MAX_ARGS 16
+extern char *string_argv[MAX_ARGS];
+extern int string_argc;
+int string_to_args(char *caller, char *string);
+
#endif /* !_GETOPT_H_ */
diff --git a/payloads/libpayload/include/libpayload.h b/payloads/libpayload/include/libpayload.h
index 4e96c6690a..12897872c9 100644
--- a/payloads/libpayload/include/libpayload.h
+++ b/payloads/libpayload/include/libpayload.h
@@ -43,14 +43,17 @@
#ifndef _LIBPAYLOAD_H
#define _LIBPAYLOAD_H
+#include <libpayload-config.h>
#include <stddef.h>
#include <arch/types.h>
#include <arch/io.h>
#include <arch/virtual.h>
#include <sysinfo.h>
#include <stdarg.h>
-#include <lar.h>
#include <pci.h>
+#ifdef CONFIG_LAR
+#include <lar.h>
+#endif
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
@@ -253,11 +256,82 @@ unsigned short ipchksum(const void *ptr, unsigned long nbytes);
* @defgroup malloc Memory allocation functions
* @{
*/
+#if defined(CONFIG_DEBUG_MALLOC) && !defined(IN_MALLOC_C)
+#define free(p) \
+ ({ \
+ extern void print_malloc_map(void); \
+ extern void free(void *); \
+ printf("free(%p) called from %s:%s:%d...\n", p, __FILE__, __func__, \
+ __LINE__);\
+ printf("PRE free()\n"); \
+ print_malloc_map(); \
+ free(p); \
+ printf("POST free()\n"); \
+ print_malloc_map(); \
+ })
+#define malloc(s) \
+ ({ \
+ extern void print_malloc_map(void); \
+ extern void *malloc(size_t); \
+ void *ptr; \
+ printf("malloc(%u) called from %s:%s:%d...\n", s, __FILE__, __func__, \
+ __LINE__);\
+ printf("PRE malloc\n"); \
+ print_malloc_map(); \
+ ptr = malloc(s); \
+ printf("POST malloc (ptr = %p)\n", ptr); \
+ print_malloc_map(); \
+ ptr; \
+ })
+#define calloc(n,s) \
+ ({ \
+ extern void print_malloc_map(void); \
+ extern void *calloc(size_t,size_t); \
+ void *ptr; \
+ printf("calloc(%u, %u) called from %s:%s:%d...\n", n, s, __FILE__, \
+ __func__, __LINE__);\
+ printf("PRE calloc\n"); \
+ print_malloc_map(); \
+ ptr = calloc(n,s); \
+ printf("POST calloc (ptr = %p)\n", ptr); \
+ print_malloc_map(); \
+ ptr; \
+ })
+#define realloc(p,s) \
+ ({ \
+ extern void print_malloc_map(void); \
+ extern void *realloc(void*,size_t); \
+ void *ptr; \
+ printf("realloc(%p, %u) called from %s:%s:%d...\n", p, s, __FILE__, \
+ __func__, __LINE__);\
+ printf("PRE realloc\n"); \
+ print_malloc_map(); \
+ ptr = realloc(p,s); \
+ printf("POST realloc (ptr = %p)\n", ptr); \
+ print_malloc_map(); \
+ ptr; \
+ })
+#define memalign(a,s) \
+ ({ \
+ extern void print_malloc_map(void); \
+ extern void *memalign(size_t, size_t); \
+ void *ptr; \
+ printf("memalign(%u, %u) called from %s:%s:%d...\n", a, s, __FILE__, \
+ __func__, __LINE__);\
+ printf("PRE memalign\n"); \
+ print_malloc_map(); \
+ ptr = memalign(a,s); \
+ printf("POST realloc (ptr = %p)\n", ptr); \
+ print_malloc_map(); \
+ ptr; \
+ })
+#else
void free(void *ptr);
void *malloc(size_t size);
void *calloc(size_t nmemb, size_t size);
void *realloc(void *ptr, size_t size);
void *memalign(size_t align, size_t size);
+#endif
/** @} */
/**
@@ -341,7 +415,9 @@ int strncmp(const char *s1, const char *s2, size_t maxlen);
char *strncpy(char *d, const char *s, size_t n);
char *strcpy(char *d, const char *s);
char *strncat(char *d, const char *s, size_t n);
+size_t strlcat(char *d, const char *s, size_t n);
char *strchr(const char *s, int c);
+char *strrchr(const char *s, int c);
char *strdup(const char *s);
char *strstr(const char *h, const char *n);
char *strsep(char **stringp, const char *delim);
@@ -363,6 +439,7 @@ struct timeval {
int gettimeofday(struct timeval *tv, void *tz);
/** @} */
+#ifdef CONFIG_LAR
/**
* @defgroup lar LAR functions
* @{
@@ -421,6 +498,7 @@ int lfread(void *ptr, size_t size, size_t nmemb, struct LFILE *stream);
int lfseek(struct LFILE *stream, long offset, int whence);
int lfclose(struct LFILE *file);
/** @} */
+#endif
/**
* @defgroup info System information functions
diff --git a/payloads/libpayload/include/powerpc/arch/endian.h b/payloads/libpayload/include/powerpc/arch/endian.h
index 8ffad70f0b..1b8ff8a808 100644
--- a/payloads/libpayload/include/powerpc/arch/endian.h
+++ b/payloads/libpayload/include/powerpc/arch/endian.h
@@ -38,4 +38,8 @@
#define ntohll(in) (in)
+#define htonw(in) ntohw(in)
+#define htonl(in) ntohw(in)
+#define htonll(in) ntohll(in)
+
#endif