[edk2-devel] Correct value for PCD_DATABASE_OFFSET_MASK

Konstantin Aladyshev aladyshev22 at gmail.com
Wed Jun 30 12:54:25 UTC 2021


Hello!
I was investigating implementation of the PCD database
(https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Include/Guid/PcdDataBaseSignatureGuid.h).

According to my understanding LocalTokenNumber is implemented this way:
```
|31 30 29 28|27 26 25 24|23 22 21 20|19 18 17 16 15 14 13 12 11  9  8
7  6  5  4  3  2  1  0
| X  X  X  X| X  X  X  X| X  X  X  X| X  X  X  X  X  X  X  X  X  X  X
X  X  X  X  X  X  X  X
\___________/\__________/\__________/\______________________________________________________/
  PCD_TYPE   PCD_DATUM   PCD_DATUM_2           PCD_DATABASE_OFFSET_MASK
```

PCD_DATABASE_OFFSET_MASK is defined as follows:
```
#define PCD_DATABASE_OFFSET_MASK (~(PCD_TYPE_ALL_SET |
PCD_DATUM_TYPE_ALL_SET | PCD_DATUM_TYPE_UINT8_BOOLEAN))
```
But PCD_DATUM_TYPE_UINT8_BOOLEAN is only 1 bit:
```
#define PCD_DATUM_TYPE_UINT8_BOOLEAN (0x1U << PCD_DATUM_TYPE_SHIFT2)
```
Therefore PCD_DATABASE_OFFSET_MASK is getting assigned to bits [(0-19),(21-23)].

Shouldn't it be something like this:
```
#define PCD_DATUM_TYPE_2_ALL_SET (PCD_DATUM_TYPE_UINT8_BOOLEAN    | \
                                  (0x2U << PCD_DATUM_TYPE_SHIFT2) | \
                                  (0x4U << PCD_DATUM_TYPE_SHIFT2) | \
                                  (0x8U << PCD_DATUM_TYPE_SHIFT2))
#define PCD_DATABASE_OFFSET_MASK (~(PCD_TYPE_ALL_SET |
PCD_DATUM_TYPE_ALL_SET | PCD_DATUM_TYPE_2_ALL_SET))
```

If it is really an error, I can make a patch.

Best regards.
Konstantin Aladyshev


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#77375): https://edk2.groups.io/g/devel/message/77375
Mute This Topic: https://groups.io/mt/83899306/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-





More information about the edk2-devel-archive mailing list