File indexing completed on 2025-05-11 08:24:33
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 #ifdef HAVE_CONFIG_H
0029 #include "config.h"
0030 #endif
0031
0032 #include "tmacros.h"
0033
0034 #include <libfdt.h>
0035 #include <string.h>
0036
0037 #include "some.h"
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048 const char rtems_test_name[] = "LIBFDT 1";
0049
0050 static void test(void)
0051 {
0052 const void *fdt = some_bin;
0053 int status;
0054 uint32_t size;
0055 const char *alias;
0056 int root;
0057 int cells;
0058 const char *prop;
0059 fdt32_t *prop_32;
0060 int len;
0061 int d;
0062 int m;
0063 int t;
0064 int node;
0065 uint32_t phandle;
0066 uint32_t cell;
0067
0068 status = fdt_check_header(fdt);
0069 rtems_test_assert(status == 0);
0070
0071 size = fdt_totalsize(fdt);
0072 rtems_test_assert(size == some_bin_size);
0073
0074 alias = fdt_get_alias(fdt, "nix");
0075 rtems_test_assert(alias == NULL);
0076
0077 alias = fdt_get_alias(fdt, "k");
0078 rtems_test_assert(strcmp(alias, "/m@1248") == 0);
0079
0080 root = fdt_path_offset(fdt, "nix");
0081 rtems_test_assert(root == -FDT_ERR_BADPATH);
0082
0083 root = fdt_path_offset(fdt, "/");
0084 rtems_test_assert(root >= 0);
0085
0086 cells = fdt_address_cells(fdt, root);
0087 rtems_test_assert(cells == 1);
0088
0089 cells = fdt_size_cells(fdt, root);
0090 rtems_test_assert(cells == 2);
0091
0092 status = fdt_node_check_compatible(fdt, root, "a,b");
0093 rtems_test_assert(status == 0);
0094
0095 status = fdt_node_check_compatible(fdt, root, "blub");
0096 rtems_test_assert(status == 1);
0097
0098 prop = fdt_getprop(fdt, root, "model", &len);
0099 rtems_test_assert(len == 2);
0100 rtems_test_assert(memcmp(prop, "c", 2) == 0);
0101
0102 d = fdt_subnode_offset(fdt, root, "slurf");
0103 rtems_test_assert(d == -FDT_ERR_NOTFOUND);
0104
0105 d = fdt_subnode_offset(fdt, root, "d");
0106 rtems_test_assert(d >= 0);
0107
0108 prop = fdt_getprop(fdt, d, "e", &len);
0109 rtems_test_assert(len == 2);
0110 rtems_test_assert(memcmp(prop, "f", 2) == 0);
0111
0112 prop = fdt_getprop(fdt, d, "g", &len);
0113 rtems_test_assert(len == 0);
0114 rtems_test_assert(prop != NULL);
0115
0116 m = fdt_subnode_offset(fdt, root, "m@1248");
0117 rtems_test_assert(m >= 0);
0118
0119 t = fdt_subnode_offset(fdt, root, "t");
0120 rtems_test_assert(t >= 0);
0121
0122 prop_32 = (fdt32_t *) fdt_getprop(fdt, t, "u", &len);
0123 rtems_test_assert(len == 4);
0124 phandle = fdt32_to_cpu(*prop_32);
0125
0126 node = fdt_node_offset_by_phandle(fdt, phandle);
0127 rtems_test_assert(node == m);
0128
0129 prop_32 = (fdt32_t *) fdt_getprop(fdt, m, "n", &len);
0130 rtems_test_assert(len == 8);
0131 cell = fdt32_to_cpu(prop_32[0]);
0132 rtems_test_assert(cell == 0xdeadbeef);
0133 cell = fdt32_to_cpu(prop_32[1]);
0134 rtems_test_assert(cell == 0x12345678);
0135 }
0136
0137 static void Init(rtems_task_argument arg)
0138 {
0139 TEST_BEGIN();
0140
0141 test();
0142
0143 TEST_END();
0144 rtems_test_exit(0);
0145 }
0146
0147 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
0148 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
0149
0150 #define CONFIGURE_MAXIMUM_TASKS 1
0151
0152 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
0153
0154 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
0155
0156 #define CONFIGURE_INIT
0157
0158 #include <rtems/confdefs.h>