Chameleon

Chameleon Svn Source Tree

Root/branches/cparm/i386/libsaio/device_tree.h

1/*
2 * Copyright (c) 2005 Apple Computer, Inc. All Rights Reserved.
3 */
4
5#ifndef __DEVICE_TREE_H
6#define __DEVICE_TREE_H
7
8#include <stdbool.h>
9#include <stdint.h>
10
11typedef struct _Property {
12 char * name;
13 uint32_t length;
14 void * value;
15
16 struct _Property * next;
17} Property;
18
19typedef struct _Node {
20 struct _Property * properties;
21 struct _Property * last_prop;
22
23 struct _Node * children;
24
25 struct _Node * next;
26} Node;
27
28#define MAX_PCI_DEV_PATHS 4
29#define MAX_STRING_NUM_ENTRIES 100
30
31#define DEV_PATH_HEADER\
32uint8_ttype;\
33uint8_tsubtype;\
34uint16_tlength;
35
36struct ACPIDevPath {
37//uint8_ttype;// = 2 ACPI device-path
38//uint8_tsubtype;// = 1 ACPI Device-path
39//uint16_t length;// = 0x0c
40DEV_PATH_HEADER
41uint32_t_HID;// = 0xD041030A ?
42uint32_t_UID;// = 0x00000000 PCI ROOT
43};
44
45struct PCIDevPath {
46//uint8_ttype;// = 1 Hardware device-path
47//uint8_tsubtype;// = 1 PCI
48//uint16_t length;// = 6
49DEV_PATH_HEADER
50uint8_tfunction;// pci func number
51uint8_tdevice;// pci dev number
52};
53
54struct DevicePathEnd {
55//uint8_ttype;// = 0x7f
56//uint8_tsubtype;// = 0xff
57//uint16_tlength;// = 4;
58DEV_PATH_HEADER
59};
60
61struct DevPropDevice {
62uint32_t length;
63uint16_t numentries;
64uint16_t WHAT2;// 0x0000 ?
65struct ACPIDevPath acpi_dev_path;// = 0x02010c00 0xd041030a
66struct PCIDevPath pci_dev_path[MAX_PCI_DEV_PATHS]; // = 0x01010600 func dev
67struct DevicePathEnd path_end;// = 0x7fff0400
68uint8_t *data;
69
70// ------------------------
71uint8_t num_pci_devpaths;
72struct DevPropString *string;
73// ------------------------
74};
75
76struct DevPropString {
77uint32_t length;
78uint32_t WHAT2;// 0x01000000 ?
79uint16_t numentries;
80uint16_t WHAT3;// 0x0000 ?
81struct DevPropDevice *entries;
82};
83
84
85extern Property *
86DT__AddProperty(Node *node, const char *name, uint32_t length, void *value);
87
88extern Node *
89DT__AddChild(Node *parent, const char *name);
90
91Node *
92DT__FindNode(const char *path, bool createIfMissing);
93
94extern void
95DT__FreeProperty(Property *prop);
96
97extern void
98DT__FreeNode(Node *node);
99
100extern char *
101DT__GetName(Node *node);
102
103void
104DT__Initialize(void);
105
106/*
107 * Free up memory used by in-memory representation
108 * of device tree.
109 */
110extern void
111DT__Finalize(void);
112
113void
114DT__FlattenDeviceTree(void **result, uint32_t *length);
115
116#endif /* __DEVICE_TREE_H */
117

Archive Download this file

Revision: 2118