mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-01 00:49:43 +00:00
abuf: Support use from tools
Update the code slightly so that abuf can be used in U-Boot tools. It will soon be needed for proftool. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
c33425c6f9
commit
90ad4e28e8
1 changed files with 20 additions and 1 deletions
21
lib/abuf.c
21
lib/abuf.c
|
@ -6,11 +6,14 @@
|
|||
* Written by Simon Glass <sjg@chromium.org>
|
||||
*/
|
||||
|
||||
#ifndef USE_HOSTCC
|
||||
#include <common.h>
|
||||
#include <abuf.h>
|
||||
#include <malloc.h>
|
||||
#include <mapmem.h>
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#include <abuf.h>
|
||||
|
||||
void abuf_set(struct abuf *abuf, void *data, size_t size)
|
||||
{
|
||||
|
@ -19,10 +22,26 @@ void abuf_set(struct abuf *abuf, void *data, size_t size)
|
|||
abuf->size = size;
|
||||
}
|
||||
|
||||
#ifndef USE_HOSTCC
|
||||
void abuf_map_sysmem(struct abuf *abuf, ulong addr, size_t size)
|
||||
{
|
||||
abuf_set(abuf, map_sysmem(addr, size), size);
|
||||
}
|
||||
#else
|
||||
/* copied from lib/string.c for convenience */
|
||||
static char *memdup(const void *src, size_t len)
|
||||
{
|
||||
char *p;
|
||||
|
||||
p = malloc(len);
|
||||
if (!p)
|
||||
return NULL;
|
||||
|
||||
memcpy(p, src, len);
|
||||
|
||||
return p;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool abuf_realloc(struct abuf *abuf, size_t new_size)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue