Re: [edk2-devel] [edk2-platforms][PATCH v2 5/5] Platform/RPi3/PlatformSmbiosDxe: Derive RAM size from board revision
On Tue, Oct 08, 2019 at 01:38:41PM +0100, Pete Batard wrote: > The board revision is the proper channel to use to detect the amount of > RAM available as bits [20-22] report the effective RAM size for the board > starting with 256 MB (000b) and doubling in size for each value. > > Signed-off-by: Pete Batard Reviewed-by: Leif Lindholm > --- > Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c | 18 > -- > 1 file changed, 12 insertions(+), 6 deletions(-) > > diff --git > a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c > b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c > index 66ffadd0cade..540e3fd61f25 100644 > --- a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c > +++ b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c > @@ -863,16 +863,22 @@ MemArrMapInfoUpdateSmbiosType19 ( >) > { >EFI_STATUS Status; > - UINT32 Base; > - UINT32 Size; > + UINT32 BoardRevision = 0; > > - Status = mFwProtocol->GetArmMem (, ); > + // Note: Type 19 addresses are expressed in KB, not bytes > + mMemArrMapInfoType19.StartingAddress = 0; > + // The minimum RAM size used on any Raspberry Pi model is 256 MB > + mMemArrMapInfoType19.EndingAddress = 256 * 1024; > + Status = mFwProtocol->GetModelRevision (); >if (Status != EFI_SUCCESS) { > -DEBUG ((DEBUG_ERROR, "Couldn't get the ARM memory size: %r\n", Status)); > +DEBUG ((DEBUG_WARNING, "Couldn't get the board memory size - defaulting > to 256 MB: %r\n", Status)); >} else { > -mMemArrMapInfoType19.StartingAddress = Base / 1024; > -mMemArrMapInfoType19.EndingAddress = (Base + Size - 1) / 1024; > +// > www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md > +// Bits [20-22] indicate the amount of memory starting with 256MB (000b) > +// and doubling in size for each value (001b = 512 MB, 010b = 1GB, etc.) > +mMemArrMapInfoType19.EndingAddress <<= (BoardRevision >> 20) & 0x07; >} > + mMemArrMapInfoType19.EndingAddress -= 1; > >LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*), > mMemArrMapInfoType19Strings, NULL); > } > -- > 2.21.0.windows.1 > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#48716): https://edk2.groups.io/g/devel/message/48716 Mute This Topic: https://groups.io/mt/34441820/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [edk2-platforms][PATCH v2 5/5] Platform/RPi3/PlatformSmbiosDxe: Derive RAM size from board revision
The board revision is the proper channel to use to detect the amount of RAM available as bits [20-22] report the effective RAM size for the board starting with 256 MB (000b) and doubling in size for each value. Signed-off-by: Pete Batard --- Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c | 18 -- 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c index 66ffadd0cade..540e3fd61f25 100644 --- a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c +++ b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c @@ -863,16 +863,22 @@ MemArrMapInfoUpdateSmbiosType19 ( ) { EFI_STATUS Status; - UINT32 Base; - UINT32 Size; + UINT32 BoardRevision = 0; - Status = mFwProtocol->GetArmMem (, ); + // Note: Type 19 addresses are expressed in KB, not bytes + mMemArrMapInfoType19.StartingAddress = 0; + // The minimum RAM size used on any Raspberry Pi model is 256 MB + mMemArrMapInfoType19.EndingAddress = 256 * 1024; + Status = mFwProtocol->GetModelRevision (); if (Status != EFI_SUCCESS) { -DEBUG ((DEBUG_ERROR, "Couldn't get the ARM memory size: %r\n", Status)); +DEBUG ((DEBUG_WARNING, "Couldn't get the board memory size - defaulting to 256 MB: %r\n", Status)); } else { -mMemArrMapInfoType19.StartingAddress = Base / 1024; -mMemArrMapInfoType19.EndingAddress = (Base + Size - 1) / 1024; +// www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md +// Bits [20-22] indicate the amount of memory starting with 256MB (000b) +// and doubling in size for each value (001b = 512 MB, 010b = 1GB, etc.) +mMemArrMapInfoType19.EndingAddress <<= (BoardRevision >> 20) & 0x07; } + mMemArrMapInfoType19.EndingAddress -= 1; LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*), mMemArrMapInfoType19Strings, NULL); } -- 2.21.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#48573): https://edk2.groups.io/g/devel/message/48573 Mute This Topic: https://groups.io/mt/34441820/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-