xref: /haiku/src/system/boot/platform/openfirmware/support.cpp (revision d5cd4a9d51842c063a3273a6a88dbfb2fdc82f7e)
1 /*
2  * Copyright 2005, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
3  * Copyright 2006-2011, Haiku, Inc. All Rights Reserved.
4  * All rights reserved. Distributed under the terms of the MIT License.
5  *
6  * Authors:
7  *		Ingo Weinhold, bonefish@cs.tu-berlin.de
8  *		Alexander von Gluck, kallisti5@unixzen.com
9  */
10 
11 
12 #include "support.h"
13 #include <platform/openfirmware/openfirmware.h>
14 
15 
16 bigtime_t
system_time(void)17 system_time(void)
18 {
19 	int result = of_milliseconds();
20 	return (result == OF_FAILED ? 0 : bigtime_t(result) * 1000);
21 }
22 
23 
24 /** given the package provided, get the number of cells
25 +   in the reg property
26 + */
27 
28 int32
of_address_cells(intptr_t package)29 of_address_cells(intptr_t package) {
30 	uint32 address_cells;
31 	if (of_getprop(package, "#address-cells",
32 		&address_cells, sizeof(address_cells)) == OF_FAILED)
33 		return OF_FAILED;
34 
35 	return address_cells;
36 }
37 
38 
39 int32
of_size_cells(intptr_t package)40 of_size_cells(intptr_t package) {
41 	uint32 size_cells;
42 	if (of_getprop(package, "#size-cells",
43 		&size_cells, sizeof(size_cells)) == OF_FAILED)
44 		return OF_FAILED;
45 
46 	return size_cells;
47 }
48 
49 
50