2 Copyright © 2008-2014, The AROS Development Team. All rights reserved.
9 #include <aros/kernel.h>
10 #include <aros/symbolsets.h>
11 #include <aros/debug.h>
12 #include <exec/nodes.h>
13 #include <exec/lists.h>
14 #include <utility/tagitem.h>
15 #include <proto/kernel.h>
16 #include <proto/utility.h>
18 #include "of_intern.h"
19 #include LC_LIBDEFS_FILE
21 AROS_LH1(void *, OF_OpenKey
,
22 AROS_LHA(char *, Key
, A0
),
23 struct OpenFirmwareBase
*, OpenFirmwareBase
, 1, Openfirmware
)
29 of_node_t
*node
, *root
= NULL
;
31 D(bug("[OF] OpenKey('%s')\n", Key
));
35 D(bug("[OF] Key must have absolute path\n"));
39 root
= LIBBASE
->of_Root
;
44 for (i
=0; i
< 63; i
++)
46 if (*Key
== '/' || *Key
== 0)
54 D(bug("[OF] looking for child '%s'\n", ptrbuf
));
56 ForeachNode(&root
->on_children
, node
)
58 if (!strcmp(node
->on_name
, ptrbuf
))
72 AROS_LH1I(void, OF_CloseKey
,
73 AROS_LHA(void *, Key
, A0
),
74 struct OpenFirmwareBase
*, OpenFirmwareBase
, 2, Openfirmware
)
81 AROS_LH2I(void *, OF_GetChild
,
82 AROS_LHA(void *, Key
, A0
),
83 AROS_LHA(void *, Prev
, A1
),
84 struct OpenFirmwareBase
*, OpenFirmwareBase
, 3, Openfirmware
)
88 of_node_t
*node
= (of_node_t
*)Key
;
89 of_node_t
*last
= (of_node_t
*)Prev
;
94 return GetHead(&node
->on_children
);
99 AROS_LH2I(void *, OF_FindProperty
,
100 AROS_LHA(void *, Key
, A0
),
101 AROS_LHA(char *, name
, A1
),
102 struct OpenFirmwareBase
*, OpenFirmwareBase
, 4, Openfirmware
)
106 of_node_t
*node
= (of_node_t
*)Key
;
107 of_property_t
*p
, *prop
= NULL
;
109 ForeachNode(&node
->on_properties
, p
)
111 if (!strcmp(p
->op_name
, name
))
123 AROS_LH2I(void *, OF_GetProperty
,
124 AROS_LHA(void *, Key
, A0
),
125 AROS_LHA(void *, Prev
, A1
),
126 struct OpenFirmwareBase
*, OpenFirmwareBase
, 5, Openfirmware
)
130 of_node_t
*node
= (of_node_t
*)Key
;
131 of_property_t
*last
= (of_property_t
*)Prev
;
134 return GetSucc(last
);
136 return GetHead(&node
->on_properties
);
141 AROS_LH1I(uint32_t, OF_GetPropLen
,
142 AROS_LHA(void *, Key
, A0
),
143 struct OpenFirmwareBase
*, OpenFirmwareBase
, 6, Openfirmware
)
147 of_property_t
*prop
= (of_property_t
*)Key
;
150 return prop
->op_length
;
157 AROS_LH1I(char *, OF_GetPropName
,
158 AROS_LHA(void *, Key
, A0
),
159 struct OpenFirmwareBase
*, OpenFirmwareBase
, 8, Openfirmware
)
163 of_property_t
*prop
= (of_property_t
*)Key
;
166 return prop
->op_name
;
173 AROS_LH1I(void *, OF_GetPropValue
,
174 AROS_LHA(void *, Key
, A0
),
175 struct OpenFirmwareBase
*, OpenFirmwareBase
, 7, Openfirmware
)
179 of_property_t
*prop
= (of_property_t
*)Key
;
182 return prop
->op_value
;
190 static int OF_Init(LIBBASETYPEPTR LIBBASE
)
192 void *KernelBase
= OpenResource("kernel.resource");
194 D(bug("[OF] OpenFirmware_Init\n"));
198 struct TagItem
*tags
= KrnGetBootInfo();
203 D(bug("[OF] BootInto @ %08x\n", tags
));
205 oftree
= GetTagData(KRN_OpenFirmwareTree
, 0, tags
);
209 D(bug("[OF] OpenFirmware root at %08x\n", oftree
));
210 LIBBASE
->of_Root
= (of_node_t
*)oftree
;
214 D(else bug("[OF] No OpenFirmware tree passed from bootloader\n"));
216 D(else bug("[OF] No BootInfo found\n"));
222 ADD2INITLIB(OF_Init
, 0)