diff options
Diffstat (limited to 'scripts/dtc/util.h')
| -rw-r--r-- | scripts/dtc/util.h | 97 |
1 files changed, 0 insertions, 97 deletions
diff --git a/scripts/dtc/util.h b/scripts/dtc/util.h index c8eb45d9f04..9cead842c11 100644 --- a/scripts/dtc/util.h +++ b/scripts/dtc/util.h | |||
| @@ -1,10 +1,7 @@ | |||
| 1 | #ifndef _UTIL_H | 1 | #ifndef _UTIL_H |
| 2 | #define _UTIL_H | 2 | #define _UTIL_H |
| 3 | 3 | ||
| 4 | #include <stdarg.h> | ||
| 5 | |||
| 6 | /* | 4 | /* |
| 7 | * Copyright 2011 The Chromium Authors, All Rights Reserved. | ||
| 8 | * Copyright 2008 Jon Loeliger, Freescale Semiconductor, Inc. | 5 | * Copyright 2008 Jon Loeliger, Freescale Semiconductor, Inc. |
| 9 | * | 6 | * |
| 10 | * This program is free software; you can redistribute it and/or | 7 | * This program is free software; you can redistribute it and/or |
| @@ -56,98 +53,4 @@ static inline void *xrealloc(void *p, size_t len) | |||
| 56 | extern char *xstrdup(const char *s); | 53 | extern char *xstrdup(const char *s); |
| 57 | extern char *join_path(const char *path, const char *name); | 54 | extern char *join_path(const char *path, const char *name); |
| 58 | 55 | ||
| 59 | /** | ||
| 60 | * Check a string of a given length to see if it is all printable and | ||
| 61 | * has a valid terminator. | ||
| 62 | * | ||
| 63 | * @param data The string to check | ||
| 64 | * @param len The string length including terminator | ||
| 65 | * @return 1 if a valid printable string, 0 if not */ | ||
| 66 | int util_is_printable_string(const void *data, int len); | ||
| 67 | |||
| 68 | /* | ||
| 69 | * Parse an escaped character starting at index i in string s. The resulting | ||
| 70 | * character will be returned and the index i will be updated to point at the | ||
| 71 | * character directly after the end of the encoding, this may be the '\0' | ||
| 72 | * terminator of the string. | ||
| 73 | */ | ||
| 74 | char get_escape_char(const char *s, int *i); | ||
| 75 | |||
| 76 | /** | ||
| 77 | * Read a device tree file into a buffer. This will report any errors on | ||
| 78 | * stderr. | ||
| 79 | * | ||
| 80 | * @param filename The filename to read, or - for stdin | ||
| 81 | * @return Pointer to allocated buffer containing fdt, or NULL on error | ||
| 82 | */ | ||
| 83 | char *utilfdt_read(const char *filename); | ||
| 84 | |||
| 85 | /** | ||
| 86 | * Read a device tree file into a buffer. Does not report errors, but only | ||
| 87 | * returns them. The value returned can be passed to strerror() to obtain | ||
| 88 | * an error message for the user. | ||
| 89 | * | ||
| 90 | * @param filename The filename to read, or - for stdin | ||
| 91 | * @param buffp Returns pointer to buffer containing fdt | ||
| 92 | * @return 0 if ok, else an errno value representing the error | ||
| 93 | */ | ||
| 94 | int utilfdt_read_err(const char *filename, char **buffp); | ||
| 95 | |||
| 96 | |||
| 97 | /** | ||
| 98 | * Write a device tree buffer to a file. This will report any errors on | ||
| 99 | * stderr. | ||
| 100 | * | ||
| 101 | * @param filename The filename to write, or - for stdout | ||
| 102 | * @param blob Poiner to buffer containing fdt | ||
| 103 | * @return 0 if ok, -1 on error | ||
| 104 | */ | ||
| 105 | int utilfdt_write(const char *filename, const void *blob); | ||
| 106 | |||
| 107 | /** | ||
| 108 | * Write a device tree buffer to a file. Does not report errors, but only | ||
| 109 | * returns them. The value returned can be passed to strerror() to obtain | ||
| 110 | * an error message for the user. | ||
| 111 | * | ||
| 112 | * @param filename The filename to write, or - for stdout | ||
| 113 | * @param blob Poiner to buffer containing fdt | ||
| 114 | * @return 0 if ok, else an errno value representing the error | ||
| 115 | */ | ||
| 116 | int utilfdt_write_err(const char *filename, const void *blob); | ||
| 117 | |||
| 118 | /** | ||
| 119 | * Decode a data type string. The purpose of this string | ||
| 120 | * | ||
| 121 | * The string consists of an optional character followed by the type: | ||
| 122 | * Modifier characters: | ||
| 123 | * hh or b 1 byte | ||
| 124 | * h 2 byte | ||
| 125 | * l 4 byte, default | ||
| 126 | * | ||
| 127 | * Type character: | ||
| 128 | * s string | ||
| 129 | * i signed integer | ||
| 130 | * u unsigned integer | ||
| 131 | * x hex | ||
| 132 | * | ||
| 133 | * TODO: Implement ll modifier (8 bytes) | ||
| 134 | * TODO: Implement o type (octal) | ||
| 135 | * | ||
| 136 | * @param fmt Format string to process | ||
| 137 | * @param type Returns type found(s/d/u/x), or 0 if none | ||
| 138 | * @param size Returns size found(1,2,4,8) or 4 if none | ||
| 139 | * @return 0 if ok, -1 on error (no type given, or other invalid format) | ||
| 140 | */ | ||
| 141 | int utilfdt_decode_type(const char *fmt, int *type, int *size); | ||
| 142 | |||
| 143 | /* | ||
| 144 | * This is a usage message fragment for the -t option. It is the format | ||
| 145 | * supported by utilfdt_decode_type. | ||
| 146 | */ | ||
| 147 | |||
| 148 | #define USAGE_TYPE_MSG \ | ||
| 149 | "<type>\ts=string, i=int, u=unsigned, x=hex\n" \ | ||
| 150 | "\tOptional modifier prefix:\n" \ | ||
| 151 | "\t\thh or b=byte, h=2 byte, l=4 byte (default)\n"; | ||
| 152 | |||
| 153 | #endif /* _UTIL_H */ | 56 | #endif /* _UTIL_H */ |
