Revision ce36252c

b/device_tree.c
25 25

  
26 26
#include <libfdt.h>
27 27

  
28
#define FDT_MAX_SIZE  0x10000
29

  
30
void *create_device_tree(int *sizep)
31
{
32
    void *fdt;
33
    int ret;
34

  
35
    *sizep = FDT_MAX_SIZE;
36
    fdt = g_malloc0(FDT_MAX_SIZE);
37
    ret = fdt_create(fdt, FDT_MAX_SIZE);
38
    if (ret < 0) {
39
        goto fail;
40
    }
41
    ret = fdt_begin_node(fdt, "");
42
    if (ret < 0) {
43
        goto fail;
44
    }
45
    ret = fdt_end_node(fdt);
46
    if (ret < 0) {
47
        goto fail;
48
    }
49
    ret = fdt_finish(fdt);
50
    if (ret < 0) {
51
        goto fail;
52
    }
53
    ret = fdt_open_into(fdt, fdt, *sizep);
54
    if (ret) {
55
        fprintf(stderr, "Unable to copy device tree in memory\n");
56
        exit(1);
57
    }
58

  
59
    return fdt;
60
fail:
61
    fprintf(stderr, "%s Couldn't create dt: %s\n", __func__, fdt_strerror(ret));
62
    exit(1);
63
}
64

  
28 65
void *load_device_tree(const char *filename_path, int *sizep)
29 66
{
30 67
    int dt_size;
b/device_tree.h
14 14
#ifndef __DEVICE_TREE_H__
15 15
#define __DEVICE_TREE_H__
16 16

  
17
void *create_device_tree(int *sizep);
17 18
void *load_device_tree(const char *filename_path, int *sizep);
18 19

  
19 20
int qemu_devtree_setprop(void *fdt, const char *node_path,

Also available in: Unified diff