12
12
#include <Library/BaseMemoryLib.h>
13
13
#include <Library/MemoryAllocationLib.h>
14
14
#include <Library/DebugLib.h>
15
+ #include <Library/FdtLib.h>
15
16
#include <Library/HobLib.h>
16
17
#include <Library/PcdLib.h>
17
18
#include <Library/PeiServicesLib.h>
18
19
#include <Library/FdtSerialPortAddressLib.h>
19
- #include <libfdt.h>
20
20
21
21
#include <Guid/EarlyPL011BaseAddress.h>
22
22
#include <Guid/FdtHob.h>
@@ -59,13 +59,13 @@ PlatformPeim (
59
59
60
60
Base = (VOID * )(UINTN )PcdGet64 (PcdDeviceTreeInitialBaseAddress );
61
61
ASSERT (Base != NULL );
62
- ASSERT (fdt_check_header (Base ) == 0 );
62
+ ASSERT (FdtCheckHeader (Base ) == 0 );
63
63
64
- FdtSize = fdt_totalsize (Base ) + PcdGet32 (PcdDeviceTreeAllocationPadding );
64
+ FdtSize = FdtTotalSize (Base ) + PcdGet32 (PcdDeviceTreeAllocationPadding );
65
65
FdtPages = EFI_SIZE_TO_PAGES (FdtSize );
66
66
NewBase = AllocatePages (FdtPages );
67
67
ASSERT (NewBase != NULL );
68
- fdt_open_into (Base , NewBase , EFI_PAGES_TO_SIZE (FdtPages ));
68
+ FdtOpenInto (Base , NewBase , EFI_PAGES_TO_SIZE (FdtPages ));
69
69
70
70
FdtHobData = BuildGuidHob (& gFdtHobGuid , sizeof * FdtHobData );
71
71
ASSERT (FdtHobData != NULL );
@@ -132,7 +132,7 @@ PlatformPeim (
132
132
Parent = 0 ;
133
133
134
134
for (Prev = Depth = 0 ; ; Prev = Node ) {
135
- Node = fdt_next_node (Base , Prev , & Depth );
135
+ Node = FdtNextNode (Base , Prev , & Depth );
136
136
if (Node < 0 ) {
137
137
break ;
138
138
}
@@ -141,7 +141,7 @@ PlatformPeim (
141
141
Parent = Node ;
142
142
}
143
143
144
- Compatible = fdt_getprop (Base , Node , "compatible" , & Len );
144
+ Compatible = FdtGetProp (Base , Node , "compatible" , & Len );
145
145
146
146
//
147
147
// Iterate over the NULL-separated items in the compatible string
@@ -152,12 +152,12 @@ PlatformPeim (
152
152
if (FeaturePcdGet (PcdTpm2SupportEnabled ) &&
153
153
(AsciiStrCmp (CompItem , "tcg,tpm-tis-mmio" ) == 0 ))
154
154
{
155
- RegProp = fdt_getprop (Base , Node , "reg" , & Len );
155
+ RegProp = FdtGetProp (Base , Node , "reg" , & Len );
156
156
ASSERT (Len == 8 || Len == 16 );
157
157
if (Len == 8 ) {
158
- TpmBase = fdt32_to_cpu (RegProp [0 ]);
158
+ TpmBase = Fdt32ToCpu (RegProp [0 ]);
159
159
} else if (Len == 16 ) {
160
- TpmBase = fdt64_to_cpu (ReadUnaligned64 ((UINT64 * )RegProp ));
160
+ TpmBase = Fdt64ToCpu (ReadUnaligned64 ((UINT64 * )RegProp ));
161
161
}
162
162
163
163
if (Depth > 1 ) {
@@ -168,7 +168,7 @@ PlatformPeim (
168
168
// tuple, where the child base and the size use the same number of
169
169
// cells as the 'reg' property above, and the parent base uses 2 cells
170
170
//
171
- RangesProp = fdt_getprop (Base , Parent , "ranges" , & RangesLen );
171
+ RangesProp = FdtGetProp (Base , Parent , "ranges" , & RangesLen );
172
172
ASSERT (RangesProp != NULL );
173
173
174
174
//
@@ -189,16 +189,16 @@ PlatformPeim (
189
189
}
190
190
191
191
if (Len == 8 ) {
192
- TpmBase -= fdt32_to_cpu (RangesProp [0 ]);
192
+ TpmBase -= Fdt32ToCpu (RangesProp [0 ]);
193
193
} else {
194
- TpmBase -= fdt64_to_cpu (ReadUnaligned64 ((UINT64 * )RangesProp ));
194
+ TpmBase -= Fdt64ToCpu (ReadUnaligned64 ((UINT64 * )RangesProp ));
195
195
}
196
196
197
197
//
198
198
// advance RangesProp to the parent bus address
199
199
//
200
200
RangesProp = (UINT32 * )((UINT8 * )RangesProp + Len / 2 );
201
- TpmBase += fdt64_to_cpu (ReadUnaligned64 ((UINT64 * )RangesProp ));
201
+ TpmBase += Fdt64ToCpu (ReadUnaligned64 ((UINT64 * )RangesProp ));
202
202
}
203
203
}
204
204
0 commit comments