2 FDT client library for ARM's TimerDxe
4 Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 #include <Library/BaseLib.h>
19 #include <Library/DebugLib.h>
20 #include <Library/PcdLib.h>
21 #include <Library/UefiBootServicesTableLib.h>
23 #include <Protocol/FdtClient.h>
35 ArmVirtTimerFdtClientLibConstructor (
40 FDT_CLIENT_PROTOCOL
*FdtClient
;
41 CONST INTERRUPT_PROPERTY
*InterruptProp
;
43 INT32 SecIntrNum
, IntrNum
, VirtIntrNum
, HypIntrNum
;
45 Status
= gBS
->LocateProtocol (&gFdtClientProtocolGuid
, NULL
,
47 ASSERT_EFI_ERROR (Status
);
49 Status
= FdtClient
->FindCompatibleNodeProperty (FdtClient
, "arm,armv7-timer",
50 "interrupts", (CONST VOID
**)&InterruptProp
,
52 if (Status
== EFI_NOT_FOUND
) {
53 Status
= FdtClient
->FindCompatibleNodeProperty (FdtClient
,
54 "arm,armv8-timer", "interrupts",
55 (CONST VOID
**)&InterruptProp
,
59 if (EFI_ERROR (Status
)) {
64 // - interrupts : Interrupt list for secure, non-secure, virtual and
65 // hypervisor timers, in that order.
67 ASSERT (PropSize
== 36 || PropSize
== 48);
69 SecIntrNum
= SwapBytes32 (InterruptProp
[0].Number
)
70 + (InterruptProp
[0].Type
? 16 : 0);
71 IntrNum
= SwapBytes32 (InterruptProp
[1].Number
)
72 + (InterruptProp
[1].Type
? 16 : 0);
73 VirtIntrNum
= SwapBytes32 (InterruptProp
[2].Number
)
74 + (InterruptProp
[2].Type
? 16 : 0);
75 HypIntrNum
= PropSize
< 48 ? 0 : SwapBytes32 (InterruptProp
[3].Number
)
76 + (InterruptProp
[3].Type
? 16 : 0);
78 DEBUG ((EFI_D_INFO
, "Found Timer interrupts %d, %d, %d, %d\n",
79 SecIntrNum
, IntrNum
, VirtIntrNum
, HypIntrNum
));
81 PcdSet32 (PcdArmArchTimerSecIntrNum
, SecIntrNum
);
82 PcdSet32 (PcdArmArchTimerIntrNum
, IntrNum
);
83 PcdSet32 (PcdArmArchTimerVirtIntrNum
, VirtIntrNum
);
84 PcdSet32 (PcdArmArchTimerHypIntrNum
, HypIntrNum
);