2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
26 #include <pexpert/protos.h>
28 #include "fakePPCStructs.h"
30 boot_args fakePPCBootArgs
= {
32 kBootArgsVersion
, // Version
34 {{0}}, // PhysicalDRAM
37 0, // deviceTreeLength
41 void * createdt(dt_init
* template, long * retSize
)
45 vm_address_t out
, saveout
;
48 // calc size of expanded data
49 for ( next
= template, allocSize
= 0;
53 if ( next
->nodeInit
.zero
== 0 )
55 if( next
->nodeInit
.nProps
== 0) break;
56 allocSize
+= 2 * sizeof( long);
58 else if ( next
->dataInit
.one
== 1 )
60 allocSize
+= *(next
->dataInit
.length
);
64 allocSize
+= (32 + 4 + 3 + next
->propInit
.length
) & (-4);
67 saveout
= out
= kalloc(allocSize
);
68 if ( out
== 0 ) return 0;
71 for ( next
= template; next
; next
++)
73 if ( next
->nodeInit
.zero
== 0 )
75 if ( next
->nodeInit
.nProps
== 0 ) break;
76 source
= &next
->nodeInit
.nProps
;
77 size
= 2 * sizeof( long);
79 else if ( next
->dataInit
.one
== 1 )
81 *(next
->dataInit
.address
) = out
;
83 size
= *(next
->dataInit
.length
);
87 bcopy( next
->propInit
.name
, (void *)out
, 32);
89 size
= next
->propInit
.length
;
93 source
= &next
->propInit
.value
;
95 source
= next
->propInit
.value
;
96 size
= (size
+ 3) & (-4);
100 bcopy(source
, (void *)out
, size
);
102 bzero((void *)out
, size
);
106 if( allocSize
!= (out
- saveout
))
107 printf("WARNING: DT corrupt (%x)\n", (out
- saveout
) - allocSize
);
109 *retSize
= allocSize
;
110 return( (void *)saveout
);
115 #define kPropNameLength 32
117 typedef struct property_t
{
118 char name
[kPropNameLength
]; // NUL terminated property name
119 unsigned long length
; // Length (bytes) of folloing prop value
120 unsigned long *value
; // Variable length value of property
123 typedef struct node_t
{
124 unsigned long nProperties
; // Number of props[] elements (0 => end)
125 unsigned long nChildren
; // Number of children[] elements
126 property_t
*props
; // array size == nProperties
127 struct node_t
*children
; // array size == nChildren
135 node_t
*nodeptr
= (node_t
*)nptr
;
136 long num_props
= nodeptr
->nProperties
;
141 nptr
= (unsigned char *)&nodeptr
->props
;
142 for (i
=0; i
< num_props
; i
++)
144 for (j
= 0; j
< indent
; j
++)
149 len
= *((long*)nptr
);
151 printf("'\t\t(%ld) '", len
);
153 for (j
= 0; j
< len
; j
++)
154 printf("%2.2x", *nptr
++);
155 printf("'\t('%s')\n", sptr
);
157 nptr
+= (4 - (len
% 4));
159 for (i
=0; i
<nodeptr
->nChildren
; i
++)