77e25ac2b6811eeea9743dad4f0215e9d0089714
[mirror_edk2.git] / EdkModulePkg / Universal / PCD / Test / PcdTest.c
1 /** @file
2 PCD TEST PEIM
3
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13
14 Module Name: PcdTest.c
15
16 **/
17 #define GUID1 \
18 {0xF9349C58, 0xB767, 0x42c8, 0xB3, 0x6B, 0x41, 0x25, 0xDE, 0x3A, 0xEF, 0xEB}
19
20 CONST GUID Guid1 = GUID1;
21
22
23 EFI_STATUS
24 EFIAPI
25 OnsetCallback1 (
26 IN UINT32 CallBackToken,
27 IN VOID *TokenData,
28 IN UINTN TokenDataSize
29 )
30 {
31 DebugPrint (0x80000000, "In CallbackOnSet %x %d\n", * ((UINT32 *)TokenData), TokenDataSize);
32 return EFI_SUCCESS;
33 }
34
35
36 VOID
37 DoTest(
38 VOID
39 )
40 {
41 PCD_TOKEN_NUMBER tn;
42 UINTN Size;
43 VOID * Ptr;
44 UINT32 Uint32;
45 UINT32 Uint32a;
46 UINT64 Uint64;
47 UINT64 Uint64a;
48 INTN i;
49
50 tn = 0x00001000;
51
52 Size = LibPcdGetSize (tn);
53 Ptr = LibPcdGetPtr (tn); /* a:RW;2880;512!e:RW;262144;512 */
54
55 tn = 0x00001001;
56 Size = LibPcdGetSize (tn); /* FW;40960;512 */
57
58 tn = 0x00001002;
59 Size = LibPcdGetSize (tn); /* FW;40960;512 */
60 Ptr = LibPcdGetPtr (tn);
61
62 LibPcdSetSku (0x0a);
63 tn = 0x2233;
64 Uint64 = LibPcdGet64 (tn);
65
66 LibPcdSetSku (0x0b);
67 Uint64 = LibPcdGet64 (tn);
68
69 LibPcdSetSku (0x0c);
70 Uint64a = LibPcdGet64 (tn);
71
72 LibPcdSetSku (0);
73 tn = 0x2233;
74 Uint64 = LibPcdGet64 (tn);
75
76
77 tn = 0xfaceface;
78 Size = LibPcdGetExSize (&Guid1, tn);
79 Uint32 = LibPcdGetEx32 (&Guid1, tn);
80
81 LibPcdCallBackOnSet (&Guid1, tn, OnsetCallback1);
82
83 LibPcdCancelCallBackOnSet (&Guid1, tn, OnsetCallback1);
84
85 for (i = 0; i < 2; i++) {
86 Uint32a = LibPcdSetEx32 (&Guid1, tn, Uint32 + i);
87 DebugPrint (0x80000000, "%x\n", Uint32a);
88 }
89
90
91
92 Uint32 = LibPcdGet32 (tn);
93
94
95 return;
96 }
97
98 EFI_STATUS
99 EFIAPI
100 PcdTestPeimInit (
101 IN EFI_FFS_FILE_HEADER *FfsHeader,
102 IN EFI_PEI_SERVICES **PeiServices
103 )
104 {
105
106 DoTest();
107
108 return EFI_SUCCESS;
109 }
110