Skip to content

Commit 7ec4a23

Browse files
committed
Correct hex formatting in L25
Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
1 parent 0cda460 commit 7ec4a23

3 files changed

Lines changed: 24 additions & 24 deletions

File tree

Lessons/Lesson_25/README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,9 @@ Now let's try to access the PCD, this is done via `PcdGetEx32`/`PcdSetEx32S` fun
278278
```
279279
As you can see, API in this case a little bit different. The `Guid` in these defines is a pointer to the GUID, so we need to use `&gUefiLessonsPkgTokenSpaceGuid` in our case. Here is the code:
280280
```
281-
Print(L"PcdDynamicExInt32=%x\n", PcdGetEx32(&gUefiLessonsPkgTokenSpaceGuid, PcdDynamicExInt32));
281+
Print(L"PcdDynamicExInt32=0x%x\n", PcdGetEx32(&gUefiLessonsPkgTokenSpaceGuid, PcdDynamicExInt32));
282282
PcdSet32S(gUefiLessonsPkgTokenSpaceGuid, PcdDynamicExInt32, 0x77777777);
283-
Print(L"PcdDynamicExInt32=%x\n", PcdGetEx32(&gUefiLessonsPkgTokenSpaceGuid, PcdDynamicExInt32));
283+
Print(L"PcdDynamicExInt32=0x%x\n", PcdGetEx32(&gUefiLessonsPkgTokenSpaceGuid, PcdDynamicExInt32));
284284
```
285285
We don't need to do anything to import `gUefiLessonsPkgTokenSpaceGuid` as it is already in its `AutoGen.c` file:
286286
```
@@ -309,25 +309,25 @@ The behaviour is similar to the Dynamic PCD. For the first time you'll get initi
309309
```
310310
FS0:\> PCDLesson.efi
311311
...
312-
PcdDynamicExInt32=BABEBABE
313-
PcdDynamicExInt32=77777777
312+
PcdDynamicExInt32=0xBABEBABE
313+
PcdDynamicExInt32=0x77777777
314314
```
315315
But since the program updates PCD, at the next launches it would start with the updated value:
316316
```
317317
FS0:\> PCDLesson.efi
318318
...
319-
PcdDynamicExInt32=77777777
320-
PcdDynamicExInt32=77777777
319+
PcdDynamicExInt32=0x77777777
320+
PcdDynamicExInt32=0x77777777
321321
```
322322
And QEMU re-launch takes things to the start.
323323

324324
# Using Dynamic API functions to access Dynamic Ex PCDs
325325

326326
It is important to notice that the `PcdGet32`/`PcdSet32S` functions are not specific Dynamic API functions. These functons are generic API that can be used with all types of PCD including the Dynamic Ex PCDs. For an example add this code to our application:
327327
```
328-
Print(L"PcdDynamicExInt32=%x\n", PcdGet32(PcdDynamicExInt32));
328+
Print(L"PcdDynamicExInt32=0x%x\n", PcdGet32(PcdDynamicExInt32));
329329
PcdSet32S(PcdDynamicExInt32, 0x88888888);
330-
Print(L"PcdDynamicExInt32=%x\n", PcdGet32(PcdDynamicExInt32));
330+
Print(L"PcdDynamicExInt32=0x%x\n", PcdGet32(PcdDynamicExInt32));
331331
```
332332

333333
If you are interested how it works check `Build/OvmfX64/RELEASE_GCC5/X64/UefiLessonsPkg/PCDLesson/PCDLesson/DEBUG/AutoGen.h`:
@@ -355,10 +355,10 @@ You can rebuild our application and verify that it still works:
355355
```
356356
FS0:\> PCDLesson.efi
357357
...
358-
PcdDynamicExInt32=BABEBABE
359-
PcdDynamicExInt32=77777777
360-
PcdDynamicExInt32=77777777
361-
PcdDynamicExInt32=88888888
358+
PcdDynamicExInt32=0xBABEBABE
359+
PcdDynamicExInt32=0x77777777
360+
PcdDynamicExInt32=0x77777777
361+
PcdDynamicExInt32=0x88888888
362362
```
363363

364364
# `PCD_DYNAMIC_AS_DYNAMICEX`
@@ -746,10 +746,10 @@ FS0:\> PCDLesson.efi
746746
...
747747
PcdDynamicInt32=0xCAFECAFE
748748
PcdDynamicInt32=0xBEEFBEEF
749-
PcdDynamicExInt32=BABEBABE
750-
PcdDynamicExInt32=77777777
751-
PcdDynamicExInt32=77777777
752-
PcdDynamicExInt32=88888888
749+
PcdDynamicExInt32=0xBABEBABE
750+
PcdDynamicExInt32=0x77777777
751+
PcdDynamicExInt32=0x77777777
752+
PcdDynamicExInt32=0x88888888
753753
```
754754

755755
# `PCD_INFO_GENERATION`

Lessons/Lesson_25/UefiLessonsPkg/PCDLesson/PCDLesson.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ UefiMain (
6565
Print(L"PcdDynamicInt32 token is unassigned\n");
6666
}
6767

68-
Print(L"PcdDynamicExInt32=%x\n", PcdGetEx32(&gUefiLessonsPkgTokenSpaceGuid, PcdDynamicExInt32));
68+
Print(L"PcdDynamicExInt32=0x%x\n", PcdGetEx32(&gUefiLessonsPkgTokenSpaceGuid, PcdDynamicExInt32));
6969
PcdSetEx32S(&gUefiLessonsPkgTokenSpaceGuid, PcdDynamicExInt32, 0x77777777);
70-
Print(L"PcdDynamicExInt32=%x\n", PcdGetEx32(&gUefiLessonsPkgTokenSpaceGuid, PcdDynamicExInt32));
70+
Print(L"PcdDynamicExInt32=0x%x\n", PcdGetEx32(&gUefiLessonsPkgTokenSpaceGuid, PcdDynamicExInt32));
7171

72-
Print(L"PcdDynamicExInt32=%x\n", PcdGet32(PcdDynamicExInt32));
72+
Print(L"PcdDynamicExInt32=0x%x\n", PcdGet32(PcdDynamicExInt32));
7373
PcdSet32S(PcdDynamicExInt32, 0x88888888);
74-
Print(L"PcdDynamicExInt32=%x\n", PcdGet32(PcdDynamicExInt32));
74+
Print(L"PcdDynamicExInt32=0x%x\n", PcdGet32(PcdDynamicExInt32));
7575
return EFI_SUCCESS;
7676
}

UefiLessonsPkg/PCDLesson/PCDLesson.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ UefiMain (
6565
Print(L"PcdDynamicInt32 token is unassigned\n");
6666
}
6767

68-
Print(L"PcdDynamicExInt32=%x\n", PcdGetEx32(&gUefiLessonsPkgTokenSpaceGuid, PcdDynamicExInt32));
68+
Print(L"PcdDynamicExInt32=0x%x\n", PcdGetEx32(&gUefiLessonsPkgTokenSpaceGuid, PcdDynamicExInt32));
6969
PcdSetEx32S(&gUefiLessonsPkgTokenSpaceGuid, PcdDynamicExInt32, 0x77777777);
70-
Print(L"PcdDynamicExInt32=%x\n", PcdGetEx32(&gUefiLessonsPkgTokenSpaceGuid, PcdDynamicExInt32));
70+
Print(L"PcdDynamicExInt32=0x%x\n", PcdGetEx32(&gUefiLessonsPkgTokenSpaceGuid, PcdDynamicExInt32));
7171

72-
Print(L"PcdDynamicExInt32=%x\n", PcdGet32(PcdDynamicExInt32));
72+
Print(L"PcdDynamicExInt32=0x%x\n", PcdGet32(PcdDynamicExInt32));
7373
PcdSet32S(PcdDynamicExInt32, 0x88888888);
74-
Print(L"PcdDynamicExInt32=%x\n", PcdGet32(PcdDynamicExInt32));
74+
Print(L"PcdDynamicExInt32=0x%x\n", PcdGet32(PcdDynamicExInt32));
7575
return EFI_SUCCESS;
7676
}

0 commit comments

Comments
 (0)