mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-19 21:46:47 +07:00
4201d057ea
This adds the following commits from upstream: b1a60033c110 tests: Add a test for overlays syntactic sugar 737b2df39cc8 overlay: Add syntactic sugar version of overlays 497432fd2131 checks: Use proper format modifier for size_t 22a65c5331c2 dtc: Bump version to v1.4.5 c575d8059fff Add fdtoverlay to .gitignore b6a6f9490d19 fdtoverlay: Sanity check blob size 8c1eb1526d2d pylibfdt: Use Python2 explicitly ee3d26f6960b checks: add interrupts property check c1e7738988f5 checks: add gpio binding properties check b3bbac02d5e3 checks: add phandle with arg property checks fe50bd1ecc1d fdtget: Split out cell list display into a new function 62d812308d11 README: Add a note about test_tree1.dts 5bed86aee9e8 pylibfdt: Add support for fdt_subnode_offset() 46f31b65b3b3 pylibfdt: Add support for fdt_node_offset_by_phandle() a3ae43723687 pylibfdt: Add support for fdt_parent_offset() a198af80344c pylibfdt: Add support for fdt_get_phandle() b9eba92ea50f tests: Return a failure code when any tests fail 155faf6cc209 pylibfdt: Use local pylibfdt module 50e5cd07f325 pylibfdt: Add a test for use of uint32_t ab78860f09f5 pylibfdt: Add stdint include to fix uint32_t 36f511fb1113 tests: Add stacked overlay tests on fdtoverlay 1bb00655d3e5 fdt: Allow stacked overlays phandle references a33c2247ac8d Introduce fdt_setprop_placeholder() method 0016f8c2aa32 dtc: change default phandles to ePAPR style instead of both e3b9a9588a35 tests: fdtoverlay unit test 42409146f2db fdtoverlay: A tool that applies overlays aae22722fc8d manual: Document missing options 13ce6e1c2fc4 dtc: fix sprintf() format string error, again d990b8013889 Makefile: Fix build on MSYS2 and Cygwin 51f56dedf8ea Clean up shared library compile/link options 21a2bc896e3d Suppress expected error message in fdtdump test 2a42b14d0d03 dtc: check.c fix compile error a10cb3c818d3 Fix get_node_by_path string equality check 548aea2c436a fdtdump: Discourage use of fdtdump c2258841a785 fdtdump: Fix over-zealous version check 9067ee4be0e6 Fix a few whitespace and style nits e56f2b07be38 pylibfdt: Use setup.py to build the swig file 896f1c133265 pylibfdt: Use Makefile constructs to implement NO_PYTHON 90db6d9989ca pylibfdt: Allow setup.py to operate stand-alone e20d9658cd8f Add Coverity Scan support b04a2cf08862 pylibfdt: Fix code style in setup.py 1c5170d3a466 pylibfdt: Rename libfdt.swig to libfdt.i 580a9f6c2880 Add a libfdt function to write a property placeholder ab15256d8d02 pylibfdt: Use the call function to simplify the Makefile 9f2e3a3a1f19 pylibfdt: Use the correct libfdt version in the module e91c652af215 pylibfdt: Enable installation of Python module 8a892fd85d94 pylibfdt: Allow building to be disabled 741cdff85d3e .travis.yml: Add builds with and without Python library prerequisites 14c4171f4f9a pylibfdt: Use package_dir to set the package directory 89a5062ab231 pylibfdt: Use environment to pass C flags and files 4e0e0d049757 pylibfdt: Allow pkg-config to be supplied in the environment 6afd7d9688f5 Correct typo: s/pylibgfdt/pylibfdt/ Signed-off-by: Rob Herring <robh@kernel.org>
293 lines
8.3 KiB
C
293 lines
8.3 KiB
C
#ifndef _DTC_H
|
|
#define _DTC_H
|
|
|
|
/*
|
|
* (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
|
|
*
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License as
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
* License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
* USA
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include <stdarg.h>
|
|
#include <assert.h>
|
|
#include <ctype.h>
|
|
#include <errno.h>
|
|
#include <unistd.h>
|
|
#include <inttypes.h>
|
|
|
|
#include <libfdt_env.h>
|
|
#include <fdt.h>
|
|
|
|
#include "util.h"
|
|
|
|
#ifdef DEBUG
|
|
#define debug(...) printf(__VA_ARGS__)
|
|
#else
|
|
#define debug(...)
|
|
#endif
|
|
|
|
#define DEFAULT_FDT_VERSION 17
|
|
|
|
/*
|
|
* Command line options
|
|
*/
|
|
extern int quiet; /* Level of quietness */
|
|
extern int reservenum; /* Number of memory reservation slots */
|
|
extern int minsize; /* Minimum blob size */
|
|
extern int padsize; /* Additional padding to blob */
|
|
extern int alignsize; /* Additional padding to blob accroding to the alignsize */
|
|
extern int phandle_format; /* Use linux,phandle or phandle properties */
|
|
extern int generate_symbols; /* generate symbols for nodes with labels */
|
|
extern int generate_fixups; /* generate fixups */
|
|
extern int auto_label_aliases; /* auto generate labels -> aliases */
|
|
|
|
#define PHANDLE_LEGACY 0x1
|
|
#define PHANDLE_EPAPR 0x2
|
|
#define PHANDLE_BOTH 0x3
|
|
|
|
typedef uint32_t cell_t;
|
|
|
|
|
|
#define streq(a, b) (strcmp((a), (b)) == 0)
|
|
#define strneq(a, b, n) (strncmp((a), (b), (n)) == 0)
|
|
|
|
#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
|
|
|
|
/* Data blobs */
|
|
enum markertype {
|
|
REF_PHANDLE,
|
|
REF_PATH,
|
|
LABEL,
|
|
};
|
|
|
|
struct marker {
|
|
enum markertype type;
|
|
int offset;
|
|
char *ref;
|
|
struct marker *next;
|
|
};
|
|
|
|
struct data {
|
|
int len;
|
|
char *val;
|
|
struct marker *markers;
|
|
};
|
|
|
|
|
|
#define empty_data ((struct data){ 0 /* all .members = 0 or NULL */ })
|
|
|
|
#define for_each_marker(m) \
|
|
for (; (m); (m) = (m)->next)
|
|
#define for_each_marker_of_type(m, t) \
|
|
for_each_marker(m) \
|
|
if ((m)->type == (t))
|
|
|
|
void data_free(struct data d);
|
|
|
|
struct data data_grow_for(struct data d, int xlen);
|
|
|
|
struct data data_copy_mem(const char *mem, int len);
|
|
struct data data_copy_escape_string(const char *s, int len);
|
|
struct data data_copy_file(FILE *f, size_t len);
|
|
|
|
struct data data_append_data(struct data d, const void *p, int len);
|
|
struct data data_insert_at_marker(struct data d, struct marker *m,
|
|
const void *p, int len);
|
|
struct data data_merge(struct data d1, struct data d2);
|
|
struct data data_append_cell(struct data d, cell_t word);
|
|
struct data data_append_integer(struct data d, uint64_t word, int bits);
|
|
struct data data_append_re(struct data d, uint64_t address, uint64_t size);
|
|
struct data data_append_addr(struct data d, uint64_t addr);
|
|
struct data data_append_byte(struct data d, uint8_t byte);
|
|
struct data data_append_zeroes(struct data d, int len);
|
|
struct data data_append_align(struct data d, int align);
|
|
|
|
struct data data_add_marker(struct data d, enum markertype type, char *ref);
|
|
|
|
bool data_is_one_string(struct data d);
|
|
|
|
/* DT constraints */
|
|
|
|
#define MAX_PROPNAME_LEN 31
|
|
#define MAX_NODENAME_LEN 31
|
|
|
|
/* Live trees */
|
|
struct label {
|
|
bool deleted;
|
|
char *label;
|
|
struct label *next;
|
|
};
|
|
|
|
struct bus_type {
|
|
const char *name;
|
|
};
|
|
|
|
struct property {
|
|
bool deleted;
|
|
char *name;
|
|
struct data val;
|
|
|
|
struct property *next;
|
|
|
|
struct label *labels;
|
|
};
|
|
|
|
struct node {
|
|
bool deleted;
|
|
char *name;
|
|
struct property *proplist;
|
|
struct node *children;
|
|
|
|
struct node *parent;
|
|
struct node *next_sibling;
|
|
|
|
char *fullpath;
|
|
int basenamelen;
|
|
|
|
cell_t phandle;
|
|
int addr_cells, size_cells;
|
|
|
|
struct label *labels;
|
|
const struct bus_type *bus;
|
|
};
|
|
|
|
#define for_each_label_withdel(l0, l) \
|
|
for ((l) = (l0); (l); (l) = (l)->next)
|
|
|
|
#define for_each_label(l0, l) \
|
|
for_each_label_withdel(l0, l) \
|
|
if (!(l)->deleted)
|
|
|
|
#define for_each_property_withdel(n, p) \
|
|
for ((p) = (n)->proplist; (p); (p) = (p)->next)
|
|
|
|
#define for_each_property(n, p) \
|
|
for_each_property_withdel(n, p) \
|
|
if (!(p)->deleted)
|
|
|
|
#define for_each_child_withdel(n, c) \
|
|
for ((c) = (n)->children; (c); (c) = (c)->next_sibling)
|
|
|
|
#define for_each_child(n, c) \
|
|
for_each_child_withdel(n, c) \
|
|
if (!(c)->deleted)
|
|
|
|
void add_label(struct label **labels, char *label);
|
|
void delete_labels(struct label **labels);
|
|
|
|
struct property *build_property(char *name, struct data val);
|
|
struct property *build_property_delete(char *name);
|
|
struct property *chain_property(struct property *first, struct property *list);
|
|
struct property *reverse_properties(struct property *first);
|
|
|
|
struct node *build_node(struct property *proplist, struct node *children);
|
|
struct node *build_node_delete(void);
|
|
struct node *name_node(struct node *node, char *name);
|
|
struct node *chain_node(struct node *first, struct node *list);
|
|
struct node *merge_nodes(struct node *old_node, struct node *new_node);
|
|
void add_orphan_node(struct node *old_node, struct node *new_node, char *ref);
|
|
|
|
void add_property(struct node *node, struct property *prop);
|
|
void delete_property_by_name(struct node *node, char *name);
|
|
void delete_property(struct property *prop);
|
|
void add_child(struct node *parent, struct node *child);
|
|
void delete_node_by_name(struct node *parent, char *name);
|
|
void delete_node(struct node *node);
|
|
void append_to_property(struct node *node,
|
|
char *name, const void *data, int len);
|
|
|
|
const char *get_unitname(struct node *node);
|
|
struct property *get_property(struct node *node, const char *propname);
|
|
cell_t propval_cell(struct property *prop);
|
|
cell_t propval_cell_n(struct property *prop, int n);
|
|
struct property *get_property_by_label(struct node *tree, const char *label,
|
|
struct node **node);
|
|
struct marker *get_marker_label(struct node *tree, const char *label,
|
|
struct node **node, struct property **prop);
|
|
struct node *get_subnode(struct node *node, const char *nodename);
|
|
struct node *get_node_by_path(struct node *tree, const char *path);
|
|
struct node *get_node_by_label(struct node *tree, const char *label);
|
|
struct node *get_node_by_phandle(struct node *tree, cell_t phandle);
|
|
struct node *get_node_by_ref(struct node *tree, const char *ref);
|
|
cell_t get_node_phandle(struct node *root, struct node *node);
|
|
|
|
uint32_t guess_boot_cpuid(struct node *tree);
|
|
|
|
/* Boot info (tree plus memreserve information */
|
|
|
|
struct reserve_info {
|
|
uint64_t address, size;
|
|
|
|
struct reserve_info *next;
|
|
|
|
struct label *labels;
|
|
};
|
|
|
|
struct reserve_info *build_reserve_entry(uint64_t start, uint64_t len);
|
|
struct reserve_info *chain_reserve_entry(struct reserve_info *first,
|
|
struct reserve_info *list);
|
|
struct reserve_info *add_reserve_entry(struct reserve_info *list,
|
|
struct reserve_info *new);
|
|
|
|
|
|
struct dt_info {
|
|
unsigned int dtsflags;
|
|
struct reserve_info *reservelist;
|
|
uint32_t boot_cpuid_phys;
|
|
struct node *dt; /* the device tree */
|
|
const char *outname; /* filename being written to, "-" for stdout */
|
|
};
|
|
|
|
/* DTS version flags definitions */
|
|
#define DTSF_V1 0x0001 /* /dts-v1/ */
|
|
#define DTSF_PLUGIN 0x0002 /* /plugin/ */
|
|
|
|
struct dt_info *build_dt_info(unsigned int dtsflags,
|
|
struct reserve_info *reservelist,
|
|
struct node *tree, uint32_t boot_cpuid_phys);
|
|
void sort_tree(struct dt_info *dti);
|
|
void generate_label_tree(struct dt_info *dti, char *name, bool allocph);
|
|
void generate_fixups_tree(struct dt_info *dti, char *name);
|
|
void generate_local_fixups_tree(struct dt_info *dti, char *name);
|
|
|
|
/* Checks */
|
|
|
|
void parse_checks_option(bool warn, bool error, const char *arg);
|
|
void process_checks(bool force, struct dt_info *dti);
|
|
|
|
/* Flattened trees */
|
|
|
|
void dt_to_blob(FILE *f, struct dt_info *dti, int version);
|
|
void dt_to_asm(FILE *f, struct dt_info *dti, int version);
|
|
|
|
struct dt_info *dt_from_blob(const char *fname);
|
|
|
|
/* Tree source */
|
|
|
|
void dt_to_source(FILE *f, struct dt_info *dti);
|
|
struct dt_info *dt_from_source(const char *f);
|
|
|
|
/* FS trees */
|
|
|
|
struct dt_info *dt_from_fs(const char *dirname);
|
|
|
|
#endif /* _DTC_H */
|