Hi all,
I am trying to obtain information regarding the RAM size installed on a box,
having a Core i7 processor. To do that, I am reading the MCHBAR register from
the PCI configuration space in order to obtain the MCHBAR base address. Before
obtaining the MCHBAR base address, I am checking the MCHBAR Enable bit to make
sure that MCHBAR memory mapped accesses are claimed and decoded appropriately.
The issue happen when I am trying to access the MCHBAR Registers in Memory
Controller – Common, because I am always getting the value 0 (zero).
I am pasting some code snippets to show you how am I doing:
...
do
{
...
/// Read the MCHBAR register from the PCI configuration space.
Status = pPciIo->Pci.Read (
pPciIo,// Pointer to EFI_PCI_IO_PROTOCOL instance.
EfiPciIoWidthUint8,// Width: 8 x 8 = 64-bits.
D0F0_REG_OFFSET_MCHBAR,// Offset.
8,// Count.
&unMchbarRegVal// Pointer to data to store the read value.
);
if ( EFI_ERROR( Status ) )
{
/// Can not read MCHBAR register.
Status = EFI_DEVICE_ERROR;
break;
}
/// Calculate Host Memory Mapped Base Address from the MCHBAR register;
/// obtain the 38:15 bits from MCHBAR register.
unMchbarBaseAddr = ( unMchbarRegVal & 0x7FFFFF8000 ) >> 15;
nbOfBytes = 4;
Status = pPciIo->Map(
pPciIo,// Pointer to EFI_PCI_IO_PROTOCOL instance.
EfiPciIoOperationBusMasterRead,// Operation.
&unMchbarBaseAddr,// Host address.
&nbOfBytes,// Number of bytes.
&DeviceAddress,// Device Address
&pvMapping // Mapping.
);
/// Calculate the offset for Address Decode Channel 0 register value.
unOffset = DeviceAddress + 0x5004;
/// Read Address Decode Channel 0 register value.
Status = pPciIo->Mem.Read(
pPciIo,// Pointer to EFI_PCI_IO_PROTOCOL instance.
EfiPciIoWidthUint8,// Width: 8 x 4 = 32-bits.
EFI_PCI_IO_PASS_THROUGH_BAR,// BarIndex.
DeviceAddress,// Offset.
4,// Count.
&unMadDimmCh0RegVal// Pointer to data to store the read value.
);
if ( EFI_ERROR( Status ) )
{
/// Could not read the register.
Status = EFI_DEVICE_ERROR;
break;
}
else
{
/// Obtain the size of the CH0 DIMM A memory, from bits 7:0, and add it to
total RAM memory.
/// the obtained size is 256 MB multiples.
unRamSizeDetected += ( ( unMadDimmCh0RegVal & 0xFF ) * 256 );
/// Obtain the size of the CH0 DIMM B memory, from bits 15:8, and add it to
total RAM memory.
/// the obtained size is 256 MB multiples.
unRamSizeDetected += ( ( ( unMadDimmCh0RegVal & 0xFF00 ) >> 0x8 ) * 256 );
}
...
}
while ( FALSE );
...
I don't know what am I doing wrong, because the unMadDimmCh0RegVal variable is
always zero.
Thank you,
Sorin.------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel