2007-03-31 15:59:59 +00:00
|
|
|
/*
|
|
|
|
* libfdt - Flat Device Tree manipulation
|
|
|
|
* Copyright (C) 2006 David Gibson, IBM Corporation.
|
2013-07-26 23:12:38 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+ BSD-2-Clause
|
2007-03-31 15:59:59 +00:00
|
|
|
*/
|
2016-05-23 09:40:55 +00:00
|
|
|
#include <libfdt_env.h>
|
2007-03-31 15:59:59 +00:00
|
|
|
|
2008-02-29 15:00:24 +00:00
|
|
|
#ifndef USE_HOSTCC
|
2007-03-31 15:59:59 +00:00
|
|
|
#include <fdt.h>
|
|
|
|
#include <libfdt.h>
|
2008-02-29 15:00:24 +00:00
|
|
|
#else
|
|
|
|
#include "fdt_host.h"
|
|
|
|
#endif
|
2007-03-31 15:59:59 +00:00
|
|
|
|
|
|
|
#include "libfdt_internal.h"
|
|
|
|
|
2008-07-09 04:10:24 +00:00
|
|
|
struct fdt_errtabent {
|
2007-03-31 15:59:59 +00:00
|
|
|
const char *str;
|
|
|
|
};
|
|
|
|
|
2008-07-09 04:10:24 +00:00
|
|
|
#define FDT_ERRTABENT(val) \
|
2007-03-31 15:59:59 +00:00
|
|
|
[(val)] = { .str = #val, }
|
|
|
|
|
2008-07-09 04:10:24 +00:00
|
|
|
static struct fdt_errtabent fdt_errtable[] = {
|
|
|
|
FDT_ERRTABENT(FDT_ERR_NOTFOUND),
|
|
|
|
FDT_ERRTABENT(FDT_ERR_EXISTS),
|
|
|
|
FDT_ERRTABENT(FDT_ERR_NOSPACE),
|
2007-03-31 15:59:59 +00:00
|
|
|
|
2008-07-09 04:10:24 +00:00
|
|
|
FDT_ERRTABENT(FDT_ERR_BADOFFSET),
|
|
|
|
FDT_ERRTABENT(FDT_ERR_BADPATH),
|
2016-10-17 20:50:18 +00:00
|
|
|
FDT_ERRTABENT(FDT_ERR_BADPHANDLE),
|
2008-07-09 04:10:24 +00:00
|
|
|
FDT_ERRTABENT(FDT_ERR_BADSTATE),
|
2007-03-31 15:59:59 +00:00
|
|
|
|
2008-07-09 04:10:24 +00:00
|
|
|
FDT_ERRTABENT(FDT_ERR_TRUNCATED),
|
|
|
|
FDT_ERRTABENT(FDT_ERR_BADMAGIC),
|
|
|
|
FDT_ERRTABENT(FDT_ERR_BADVERSION),
|
|
|
|
FDT_ERRTABENT(FDT_ERR_BADSTRUCTURE),
|
|
|
|
FDT_ERRTABENT(FDT_ERR_BADLAYOUT),
|
2017-03-28 16:23:31 +00:00
|
|
|
FDT_ERRTABENT(FDT_ERR_INTERNAL),
|
|
|
|
FDT_ERRTABENT(FDT_ERR_BADNCELLS),
|
|
|
|
FDT_ERRTABENT(FDT_ERR_BADVALUE),
|
2016-10-17 20:50:18 +00:00
|
|
|
FDT_ERRTABENT(FDT_ERR_BADOVERLAY),
|
|
|
|
FDT_ERRTABENT(FDT_ERR_NOPHANDLES),
|
2007-03-31 15:59:59 +00:00
|
|
|
};
|
2008-07-09 04:10:24 +00:00
|
|
|
#define FDT_ERRTABSIZE (sizeof(fdt_errtable) / sizeof(fdt_errtable[0]))
|
2007-03-31 15:59:59 +00:00
|
|
|
|
|
|
|
const char *fdt_strerror(int errval)
|
|
|
|
{
|
|
|
|
if (errval > 0)
|
|
|
|
return "<valid offset/length>";
|
|
|
|
else if (errval == 0)
|
|
|
|
return "<no error>";
|
2008-07-09 04:10:24 +00:00
|
|
|
else if (errval > -FDT_ERRTABSIZE) {
|
|
|
|
const char *s = fdt_errtable[-errval].str;
|
2007-03-31 15:59:59 +00:00
|
|
|
|
|
|
|
if (s)
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
return "<unknown error>";
|
|
|
|
}
|