Message ID | 20181121115828.3026-2-ard.biesheuvel@linaro.org |
---|---|
State | Accepted |
Commit | 4ef113583978c6a385c82cbbe1ed9cc754a5ffdc |
Headers | show |
Series | ArmPlatformPkg, ArmVirtPkg: discover NOR flash banks from DTB | expand |
On 11/21/18 12:58, Ard Biesheuvel wrote: > A subsequent patch will change the layout of devicepath nodes > produced by this driver. In preparation, make some tweaks to > the code to use a packed struct for the devicepath and to pass > the device index to NorFlashCreateInstance(). These are cosmetic > changes only, the resulting binaries should be identical. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> > Reviewed-by: Laszlo Ersek <lersek@redhat.com> > --- > ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c | 9 ++++++--- > ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h | 2 ++ > 2 files changed, 8 insertions(+), 3 deletions(-) > > diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c > index 46e815beb343..53753a4721ac 100644 > --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c > +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c > @@ -82,7 +82,10 @@ NOR_FLASH_INSTANCE mNorFlashInstanceTemplate = { > { > HARDWARE_DEVICE_PATH, > HW_VENDOR_DP, > - { (UINT8)sizeof(VENDOR_DEVICE_PATH), (UINT8)((sizeof(VENDOR_DEVICE_PATH)) >> 8) } > + { > + (UINT8)(OFFSET_OF (NOR_FLASH_DEVICE_PATH, End)), > + (UINT8)(OFFSET_OF (NOR_FLASH_DEVICE_PATH, End) >> 8) > + } > }, > { 0x0, 0x0, 0x0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }, // GUID ... NEED TO BE FILLED > }, > @@ -99,7 +102,7 @@ NorFlashCreateInstance ( > IN UINTN NorFlashDeviceBase, > IN UINTN NorFlashRegionBase, > IN UINTN NorFlashSize, > - IN UINT32 MediaId, > + IN UINT32 Index, > IN UINT32 BlockSize, > IN BOOLEAN SupportFvb, > IN CONST GUID *NorFlashGuid, > @@ -121,7 +124,7 @@ NorFlashCreateInstance ( > Instance->Size = NorFlashSize; > > Instance->BlockIoProtocol.Media = &Instance->Media; > - Instance->Media.MediaId = MediaId; > + Instance->Media.MediaId = Index; > Instance->Media.BlockSize = BlockSize; > Instance->Media.LastBlock = (NorFlashSize / BlockSize)-1; > > diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h > index 5c07694fbfaa..910681fd4412 100644 > --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h > +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h > @@ -122,10 +122,12 @@ > > typedef struct _NOR_FLASH_INSTANCE NOR_FLASH_INSTANCE; > > +#pragma pack(1) > typedef struct { > VENDOR_DEVICE_PATH Vendor; > EFI_DEVICE_PATH_PROTOCOL End; > } NOR_FLASH_DEVICE_PATH; > +#pragma pack() > > struct _NOR_FLASH_INSTANCE { > UINT32 Signature; > We tend to insert a space character between "pack" and "(1)"/"()" too. Feel free to update the patch when you push it, or not at all. My R-b stands either way. Thanks! Laszlo _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
On 21/11/18 12:58, Ard Biesheuvel wrote: > A subsequent patch will change the layout of devicepath nodes > produced by this driver. In preparation, make some tweaks to > the code to use a packed struct for the devicepath and to pass > the device index to NorFlashCreateInstance(). These are cosmetic > changes only, the resulting binaries should be identical. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> > Reviewed-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> > --- > ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c | 9 ++++++--- > ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h | 2 ++ > 2 files changed, 8 insertions(+), 3 deletions(-) > > diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c > index 46e815beb343..53753a4721ac 100644 > --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c > +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c > @@ -82,7 +82,10 @@ NOR_FLASH_INSTANCE mNorFlashInstanceTemplate = { > { > HARDWARE_DEVICE_PATH, > HW_VENDOR_DP, > - { (UINT8)sizeof(VENDOR_DEVICE_PATH), (UINT8)((sizeof(VENDOR_DEVICE_PATH)) >> 8) } > + { > + (UINT8)(OFFSET_OF (NOR_FLASH_DEVICE_PATH, End)), > + (UINT8)(OFFSET_OF (NOR_FLASH_DEVICE_PATH, End) >> 8) > + } > }, > { 0x0, 0x0, 0x0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }, // GUID ... NEED TO BE FILLED > }, > @@ -99,7 +102,7 @@ NorFlashCreateInstance ( > IN UINTN NorFlashDeviceBase, > IN UINTN NorFlashRegionBase, > IN UINTN NorFlashSize, > - IN UINT32 MediaId, > + IN UINT32 Index, > IN UINT32 BlockSize, > IN BOOLEAN SupportFvb, > IN CONST GUID *NorFlashGuid, > @@ -121,7 +124,7 @@ NorFlashCreateInstance ( > Instance->Size = NorFlashSize; > > Instance->BlockIoProtocol.Media = &Instance->Media; > - Instance->Media.MediaId = MediaId; > + Instance->Media.MediaId = Index; > Instance->Media.BlockSize = BlockSize; > Instance->Media.LastBlock = (NorFlashSize / BlockSize)-1; > > diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h > index 5c07694fbfaa..910681fd4412 100644 > --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h > +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h > @@ -122,10 +122,12 @@ > > typedef struct _NOR_FLASH_INSTANCE NOR_FLASH_INSTANCE; > > +#pragma pack(1) > typedef struct { > VENDOR_DEVICE_PATH Vendor; > EFI_DEVICE_PATH_PROTOCOL End; > } NOR_FLASH_DEVICE_PATH; > +#pragma pack() > > struct _NOR_FLASH_INSTANCE { > UINT32 Signature; >
diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c index 46e815beb343..53753a4721ac 100644 --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c @@ -82,7 +82,10 @@ NOR_FLASH_INSTANCE mNorFlashInstanceTemplate = { { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, - { (UINT8)sizeof(VENDOR_DEVICE_PATH), (UINT8)((sizeof(VENDOR_DEVICE_PATH)) >> 8) } + { + (UINT8)(OFFSET_OF (NOR_FLASH_DEVICE_PATH, End)), + (UINT8)(OFFSET_OF (NOR_FLASH_DEVICE_PATH, End) >> 8) + } }, { 0x0, 0x0, 0x0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }, // GUID ... NEED TO BE FILLED }, @@ -99,7 +102,7 @@ NorFlashCreateInstance ( IN UINTN NorFlashDeviceBase, IN UINTN NorFlashRegionBase, IN UINTN NorFlashSize, - IN UINT32 MediaId, + IN UINT32 Index, IN UINT32 BlockSize, IN BOOLEAN SupportFvb, IN CONST GUID *NorFlashGuid, @@ -121,7 +124,7 @@ NorFlashCreateInstance ( Instance->Size = NorFlashSize; Instance->BlockIoProtocol.Media = &Instance->Media; - Instance->Media.MediaId = MediaId; + Instance->Media.MediaId = Index; Instance->Media.BlockSize = BlockSize; Instance->Media.LastBlock = (NorFlashSize / BlockSize)-1; diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h index 5c07694fbfaa..910681fd4412 100644 --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h @@ -122,10 +122,12 @@ typedef struct _NOR_FLASH_INSTANCE NOR_FLASH_INSTANCE; +#pragma pack(1) typedef struct { VENDOR_DEVICE_PATH Vendor; EFI_DEVICE_PATH_PROTOCOL End; } NOR_FLASH_DEVICE_PATH; +#pragma pack() struct _NOR_FLASH_INSTANCE { UINT32 Signature;