Re: [edk2-devel] [edk2-platforms][PATCH v2 1/5] Platform/RPi3/RpiFirmwareDxe: Add more query functions

2019-10-10 Thread Pete Batard

Hi Leif,

On 2019.10.10 09:39, Leif Lindholm wrote:

On Tue, Oct 08, 2019 at 01:38:37PM +0100, Pete Batard wrote:

This patch introduces the capability to also query the Model Name/
Manufacturer Name/CPU Name/Firmware Revision using the RpiFirmware
protocol. This is aims at making the driver more suitable to cater
for platforms other than the Raspberry Pi 3 as well as simplifying
the population of entries in PlatformSmbiosDxe.

Signed-off-by: Pete Batard 
---
  Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c | 155 
+++-
  Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h  |  58 
++--
  2 files changed, 196 insertions(+), 17 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c 
b/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
index 9b5ee1946279..378c99bcba05 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
+++ b/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
@@ -461,7 +461,7 @@ typedef struct {
RPI_FW_TAG_HEAD   TagHead;
RPI_FW_MODEL_REVISION_TAG TagBody;
UINT32EndTag;
-} RPI_FW_GET_MODEL_REVISION_CMD;
+} RPI_FW_GET_REVISION_CMD;
  #pragma pack()
  
  STATIC

@@ -471,7 +471,7 @@ RpiFirmwareGetModelRevision (
OUT   UINT32 *Revision
)
  {
-  RPI_FW_GET_MODEL_REVISION_CMD *Cmd;
+  RPI_FW_GET_REVISION_CMD   *Cmd;
EFI_STATUSStatus;
UINT32Result;
  
@@ -506,6 +506,153 @@ RpiFirmwareGetModelRevision (

return EFI_SUCCESS;
  }
  
+STATIC

+EFI_STATUS
+EFIAPI
+RpiFirmwareGetFirmwareRevision (
+  OUT   UINT32 *Revision
+  )
+{
+  RPI_FW_GET_REVISION_CMD   *Cmd;
+  EFI_STATUSStatus;
+  UINT32Result;
+
+  if (!AcquireSpinLockOrFail ()) {
+DEBUG ((DEBUG_ERROR, "%a: failed to acquire spinlock\n", __FUNCTION__));
+return EFI_DEVICE_ERROR;
+  }
+
+  Cmd = mDmaBuffer;
+  ZeroMem (Cmd, sizeof (*Cmd));
+
+  Cmd->BufferHead.BufferSize  = sizeof (*Cmd);
+  Cmd->BufferHead.Response= 0;
+  Cmd->TagHead.TagId  = RPI_MBOX_GET_REVISION;
+  Cmd->TagHead.TagSize= sizeof (Cmd->TagBody);
+  Cmd->TagHead.TagValueSize   = 0;
+  Cmd->EndTag = 0;
+
+  Status = MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_CHANNEL, 
);
+
+  ReleaseSpinLock ();
+
+  if (EFI_ERROR (Status) ||
+  Cmd->BufferHead.Response != RPI_MBOX_RESP_SUCCESS) {
+DEBUG ((DEBUG_ERROR,
+  "%a: mailbox transaction error: Status == %r, Response == 0x%x\n",
+  __FUNCTION__, Status, Cmd->BufferHead.Response));
+return EFI_DEVICE_ERROR;
+  }
+
+  *Revision = Cmd->TagBody.Revision;
+  return EFI_SUCCESS;
+}
+
+STATIC
+CHAR8*
+EFIAPI
+RpiFirmwareGetModelName (
+  IN INTN ModelId
+  )
+{
+  UINT32  Revision;
+
+  // If a negative ModelId is passed, detect it.
+  if ((ModelId < 0) && (RpiFirmwareGetModelRevision () == 
EFI_SUCCESS))


Style-wise, please always use {} with if-statements.


Will do.


Beyond that, this pattern repeats identcally in three functions in
this file. Meanwhile, there is never any error handling of
RpiFirmwareGetModelRevision other than if not successful, we leave it
as negative.


Yes, because then we'll get the default case (that returns "Unknown 
..."), which is precisely what we want if we can't access the model 
revision for any reason.



Are there other intended uses of that function, or could
we move this logic there?


I'm not sure how that would work, since ModelId, ManufacturerId, and 
CpuId are for different parts of the bit fields, so, if I understand 
what you're suggesting correctly (but I'm not really sure I do) trying 
to move the check for negative value into RpiFirmwareGetModelRevision () 
wouldn't work that great. Plus then the function name would become a 
misnommer.


Are you really seeing a functional issue with the current code, or 
something that would make a possible contributor wanting to modify this 
section puzzled as to what we're trying to accomplish here (which I 
think is pretty clear, but then again, I wrote the code so maybe I'm not 
the most impartial? Because if not, I'd rather save my limited supply of 
time, and just go with a v3 that only adds the {} suggested.


Regards,

/Pete



/
 Leif


+ModelId = (Revision >> 4) & 0xFF;
+
+  switch (ModelId) {
+  // 
www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md
+  case 0x00:
+return "Raspberry Pi Model A";
+  case 0x01:
+return "Raspberry Pi Model B";
+  case 0x02:
+return "Raspberry Pi Model A+";
+  case 0x03:
+return "Raspberry Pi Model B+";
+  case 0x04:
+return "Raspberry Pi 2 Model B";
+  case 0x06:
+return "Raspberry Pi Compute Module 1";
+  case 0x08:
+return "Raspber

Re: [edk2-devel] [edk2-platforms][PATCH v2 2/5] Platform/RPi3/RpiFirmwareDxe: Improve serial number population

2019-10-10 Thread Pete Batard

Hi Leif,

It's a disagreement. And the same goes for 3/5 & 4/5. Please see the 
note I wrote in 0/5 for the v2, because the cover letter this is usually 
the place I try to clarify elements that may throw off a maintainer, and 
that don't belong in a commit message.


Not so sound flippant here, but as long as there isn't an MTV award for 
"Most atomic codebase ever", I just don't have the time to split what I 
consider to be frivolous commits. The reasoning behind that is that I 
realistically don't consider that people are actually going to be thrown 
off by a "while I was here I also fixed an obvious typo" that got added 
into an existing commit or, most important, that even if they do, the 
amount of time that is going to be collectively wasted by people who 
might be thrown of by not having uber atomicity is not going to exceed 
the amount of time it will cost *me* to split it.


Therefore, while I do understand the desire to have an atomic commit 
history, I'm afraid that if we can't strike a balance between how much 
extra time contributors are expected to waste vs how  atomic a 
*real-life* codebase is enforced to be, if I have to split every little 
typo and stylistic fix into yet another commit, I'm simply not going to 
bother fixing typos or low hanging fruits I see any more.


Regards,

/Pete


On 2019.10.10 09:43, Leif Lindholm wrote:

On Tue, Oct 08, 2019 at 01:38:38PM +0100, Pete Batard wrote:

Improve RpiFirmwareGetSerial() to derive a serial number from the
MAC address, in case the platform returns 0 for the serial number.

Also fix a typo where "%s" was used instead of "%a".


I did not see a reply to my feedback on the previous round, so I'm
unsure if this is a mistake or a disagreement?


Signed-off-by: Pete Batard 
---
  Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c | 11 
+--
  1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c 
b/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
index 378c99bcba05..c2344252d2c0 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
+++ b/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
@@ -219,7 +219,7 @@ RpiFirmwareSetPowerState (
  
if (!EFI_ERROR (Status) &&

PowerState ^ (Cmd->TagBody.PowerState & RPI_MBOX_POWER_STATE_ENABLE)) {
-DEBUG ((DEBUG_ERROR, "%a: failed to %sable power for device %d\n",
+DEBUG ((DEBUG_ERROR, "%a: failed to %aable power for device %d\n",


This is clearly a bugfix, but I don't see it as being part of "Improve
serial number population", which is what it claims to be if I view it
wih git blame.

/
 Leif


__FUNCTION__, PowerState ? "en" : "dis", DeviceId));
  Status = EFI_DEVICE_ERROR;
}
@@ -393,7 +393,14 @@ RpiFirmwareGetSerial (
}
  
*Serial = Cmd->TagBody.Serial;

-  return EFI_SUCCESS;
+  // Some platforms return 0 for serial. For those, try to use the MAC address.
+  if (*Serial == 0) {
+Status = RpiFirmwareGetMacAddress ((UINT8*) Serial);
+// Convert to a more user-friendly value
+*Serial = SwapBytes64 (*Serial << 16);
+  }
+
+  return Status;
  }
  
  #pragma pack()

--
2.21.0.windows.1




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#48729): https://edk2.groups.io/g/devel/message/48729
Mute This Topic: https://groups.io/mt/34441817/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 3/5] Platform/RPi3/PlatformSmbiosDxe: Improve population of SMBIOS entries

2019-10-08 Thread Pete Batard
This patch cleans up the population SMBIOS entries by removing elements
that we don't have data for, as well as properly filling the ones for
which we do, through the newly added queries from RpiFirmwareDxe.

Additional minor improvements are also applied, such as consistent use
of uppercase values.

Signed-off-by: Pete Batard 
---
 Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c   | 
153 ++--
 Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf |   
1 +
 Platform/RaspberryPi/RPi3/RPi3.dsc|   
2 +-
 3 files changed, 76 insertions(+), 80 deletions(-)

diff --git 
a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c 
b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c
index bc35175279f2..8a4840267780 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c
+++ b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c
@@ -35,12 +35,13 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 
-STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL *mFwProtocol;
+static RASPBERRY_PI_FIRMWARE_PROTOCOL *mFwProtocol;
 
 /***
 SMBIOS data definition  TYPE0  BIOS Information
@@ -49,7 +50,7 @@ SMBIOS_TABLE_TYPE0 mBIOSInfoType0 = {
   { EFI_SMBIOS_TYPE_BIOS_INFORMATION, sizeof (SMBIOS_TABLE_TYPE0), 0 },
   1,// Vendor String
   2,// BiosVersion String
-  0x0,  // BiosSegment
+  0,// BiosSegment
   3,// BiosReleaseDate String
   0x1F, // BiosSize
   { // BiosCharacteristics
@@ -97,23 +98,25 @@ SMBIOS_TABLE_TYPE0 mBIOSInfoType0 = {
   //  Boot1394IsSupported   :1;
   //  SmartBatteryIsSupported   :1;
   //  BIOSCharacteristicsExtensionBytes[1]
-0x0e, //  BiosBootSpecIsSupported  :1;
+0x0E, //  BiosBootSpecIsSupported  :1;
   //  FunctionKeyNetworkBootIsSupported:1;
   //  TargetContentDistributionEnabled :1;
   //  UefiSpecificationSupported   :1;
   //  VirtualMachineSupported  :1;
   //  ExtensionByte2Reserved   :3;
   },
-  0xFF,// SystemBiosMajorRelease
-  0xFF,// SystemBiosMinorRelease
-  0xFF,// EmbeddedControllerFirmwareMajorRelease
-  0xFF,// EmbeddedControllerFirmwareMinorRelease
+  0,   // SystemBiosMajorRelease
+  0,   // SystemBiosMinorRelease
+  0,   // EmbeddedControllerFirmwareMajorRelease
+  0,   // EmbeddedControllerFirmwareMinorRelease
 };
 
+CHAR8 mBiosVersion[128] = "EDK2-DEV";
+
 CHAR8 *mBIOSInfoType0Strings[] = {
-  "https://github.com/andreiw/RaspberryPiPkg;, // Vendor String
-  "Raspberry Pi 64-bit UEFI (" __DATE__ " " __TIME__ ")",  // BiosVersion 
String
-  __DATE__,
+  "TianoCore",// Vendor
+  mBiosVersion,   // Version
+  __DATE__ " " __TIME__,  // Release Date
   NULL
 };
 
@@ -132,42 +135,19 @@ SMBIOS_TABLE_TYPE1 mSysInfoType1 = {
   6,// Family String
 };
 
-#define PROD_BASE 8
-#define PROD_KNOWN   13
-#define PROD_UNKNOWN 11
-CHAR8 *ProductNames[] = {
-  /* 8 */ "3",
-  /* 9 */ "Zero",
-  /* 10 */ "CM3",
-  /* 11 */ "???",
-  /* 12 */ "Zero W",
-  /* 13 */ "3B+"
-};
-
-#define MANU_UNKNOWN 0
-#define MANU_KNOWN   4
-#define MANU_BASE1
-CHAR8 *ManufNames[] = {
-  "???",
-  /* 0 */ "Sony",
-  /* 1 */ "Egoman",
-  /* 2 */ "Embest",
-  /* 3 */ "Sony Japan",
-  /* 4 */ "Embest"
-};
-
-CHAR8 mSysInfoManufName[sizeof ("Sony Japan")];
-CHAR8 mSysInfoProductName[sizeof ("64-bit Raspberry Pi XX (rev. 
)")];
+CHAR8 mSysInfoManufName[128];
+CHAR8 mSysInfoProductName[128];
+CHAR8 mSysInfoVersionName[128];
 CHAR8 mSysInfoSerial[sizeof (UINT64) * 2 + 1];
 CHAR8 mSysInfoSKU[sizeof (UINT64) * 2 + 1];
 
 CHAR8 *mSysInfoType1Strings[] = {
   mSysInfoManufName,
   mSysInfoProductName,
-  mSysInfoProductName,
+  mSysInfoVersionName,
   mSysInfoSerial,
   mSysInfoSKU,
-  "edk2",
+  "Raspberry Pi",
   NULL
 };
 
@@ -180,7 +160,7 @@ SMBIOS_TABLE_TYPE2 mBoardInfoType2 = {
   2,// ProductName String
   3,// Version String
   4,// SerialNumber String
-  5,// AssetTag String
+  0,// AssetTag String
   { // FeatureFlag
 1,//  Motherboard   :1;
 0,//  RequiresDaughterCard  :1;
@@ -189,7 +169,7 @@ SMBIOS_TABLE_TYPE2 mBoardInfoType2 = {
  

[edk2-devel] [edk2-platforms][PATCH v2 1/5] Platform/RPi3/RpiFirmwareDxe: Add more query functions

2019-10-08 Thread Pete Batard
This patch introduces the capability to also query the Model Name/
Manufacturer Name/CPU Name/Firmware Revision using the RpiFirmware
protocol. This is aims at making the driver more suitable to cater
for platforms other than the Raspberry Pi 3 as well as simplifying
the population of entries in PlatformSmbiosDxe.

Signed-off-by: Pete Batard 
---
 Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c | 155 
+++-
 Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h  |  58 
++--
 2 files changed, 196 insertions(+), 17 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c 
b/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
index 9b5ee1946279..378c99bcba05 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
+++ b/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
@@ -461,7 +461,7 @@ typedef struct {
   RPI_FW_TAG_HEAD   TagHead;
   RPI_FW_MODEL_REVISION_TAG TagBody;
   UINT32EndTag;
-} RPI_FW_GET_MODEL_REVISION_CMD;
+} RPI_FW_GET_REVISION_CMD;
 #pragma pack()
 
 STATIC
@@ -471,7 +471,7 @@ RpiFirmwareGetModelRevision (
   OUT   UINT32 *Revision
   )
 {
-  RPI_FW_GET_MODEL_REVISION_CMD *Cmd;
+  RPI_FW_GET_REVISION_CMD   *Cmd;
   EFI_STATUSStatus;
   UINT32Result;
 
@@ -506,6 +506,153 @@ RpiFirmwareGetModelRevision (
   return EFI_SUCCESS;
 }
 
+STATIC
+EFI_STATUS
+EFIAPI
+RpiFirmwareGetFirmwareRevision (
+  OUT   UINT32 *Revision
+  )
+{
+  RPI_FW_GET_REVISION_CMD   *Cmd;
+  EFI_STATUSStatus;
+  UINT32Result;
+
+  if (!AcquireSpinLockOrFail ()) {
+DEBUG ((DEBUG_ERROR, "%a: failed to acquire spinlock\n", __FUNCTION__));
+return EFI_DEVICE_ERROR;
+  }
+
+  Cmd = mDmaBuffer;
+  ZeroMem (Cmd, sizeof (*Cmd));
+
+  Cmd->BufferHead.BufferSize  = sizeof (*Cmd);
+  Cmd->BufferHead.Response= 0;
+  Cmd->TagHead.TagId  = RPI_MBOX_GET_REVISION;
+  Cmd->TagHead.TagSize= sizeof (Cmd->TagBody);
+  Cmd->TagHead.TagValueSize   = 0;
+  Cmd->EndTag = 0;
+
+  Status = MailboxTransaction (Cmd->BufferHead.BufferSize, 
RPI_MBOX_VC_CHANNEL, );
+
+  ReleaseSpinLock ();
+
+  if (EFI_ERROR (Status) ||
+  Cmd->BufferHead.Response != RPI_MBOX_RESP_SUCCESS) {
+DEBUG ((DEBUG_ERROR,
+  "%a: mailbox transaction error: Status == %r, Response == 0x%x\n",
+  __FUNCTION__, Status, Cmd->BufferHead.Response));
+return EFI_DEVICE_ERROR;
+  }
+
+  *Revision = Cmd->TagBody.Revision;
+  return EFI_SUCCESS;
+}
+
+STATIC
+CHAR8*
+EFIAPI
+RpiFirmwareGetModelName (
+  IN INTN ModelId
+  )
+{
+  UINT32  Revision;
+
+  // If a negative ModelId is passed, detect it.
+  if ((ModelId < 0) && (RpiFirmwareGetModelRevision () == 
EFI_SUCCESS))
+ModelId = (Revision >> 4) & 0xFF;
+
+  switch (ModelId) {
+  // 
www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md
+  case 0x00:
+return "Raspberry Pi Model A";
+  case 0x01:
+return "Raspberry Pi Model B";
+  case 0x02:
+return "Raspberry Pi Model A+";
+  case 0x03:
+return "Raspberry Pi Model B+";
+  case 0x04:
+return "Raspberry Pi 2 Model B";
+  case 0x06:
+return "Raspberry Pi Compute Module 1";
+  case 0x08:
+return "Raspberry Pi 3 Model B";
+  case 0x09:
+return "Raspberry Pi Zero";
+  case 0x0A:
+return "Raspberry Pi Compute Module 3";
+  case 0x0C:
+return "Raspberry Pi Zero W";
+  case 0x0D:
+return "Raspberry Pi 3 Model B+";
+  case 0x0E:
+return "Raspberry Pi 3 Model A+";
+  case 0x11:
+return "Raspberry Pi 4 Model B";
+  default:
+return "Unknown Raspberry Pi Model";
+  }
+}
+
+STATIC
+CHAR8*
+EFIAPI
+RpiFirmwareGetManufacturerName (
+  IN INTN ManufacturerId
+  )
+{
+  UINT32  Revision;
+
+  // If a negative ModelId is passed, detect it.
+  if ((ManufacturerId < 0) && (RpiFirmwareGetModelRevision () == 
EFI_SUCCESS))
+ManufacturerId = (Revision >> 16) & 0x0F;
+
+  switch (ManufacturerId) {
+  // 
www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md
+  case 0x00:
+return "Sony UK";
+  case 0x01:
+return "Egoman";
+  case 0x02:
+  case 0x04:
+return "Embest";
+  case 0x03:
+return "Sony Japan";
+  case 0x05:
+return "Stadium";
+  default:
+return "Unknown Manufacturer";
+  }
+}
+
+STATIC
+CHAR8*
+EFIAPI
+RpiFirmwareGetCpuName (
+  IN INTN CpuId
+  )
+{
+  UINT32  Revision;
+
+  // If a negative CpuId is passed, detect it.
+  if ((CpuId < 0) && (RpiFirmwareGetModelRevision () == EFI_SUCCESS))
+CpuId = (Revision >> 12) & 0

[edk2-devel] [edk2-platforms][PATCH v2 5/5] Platform/RPi3/PlatformSmbiosDxe: Derive RAM size from board revision

2019-10-08 Thread Pete Batard
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]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-platforms][PATCH v2 2/5] Platform/RPi3/RpiFirmwareDxe: Improve serial number population

2019-10-08 Thread Pete Batard
Improve RpiFirmwareGetSerial() to derive a serial number from the
MAC address, in case the platform returns 0 for the serial number.

Also fix a typo where "%s" was used instead of "%a".

Signed-off-by: Pete Batard 
---
 Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c | 11 
+--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c 
b/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
index 378c99bcba05..c2344252d2c0 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
+++ b/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
@@ -219,7 +219,7 @@ RpiFirmwareSetPowerState (
 
   if (!EFI_ERROR (Status) &&
   PowerState ^ (Cmd->TagBody.PowerState & RPI_MBOX_POWER_STATE_ENABLE)) {
-DEBUG ((DEBUG_ERROR, "%a: failed to %sable power for device %d\n",
+DEBUG ((DEBUG_ERROR, "%a: failed to %aable power for device %d\n",
   __FUNCTION__, PowerState ? "en" : "dis", DeviceId));
 Status = EFI_DEVICE_ERROR;
   }
@@ -393,7 +393,14 @@ RpiFirmwareGetSerial (
   }
 
   *Serial = Cmd->TagBody.Serial;
-  return EFI_SUCCESS;
+  // Some platforms return 0 for serial. For those, try to use the MAC address.
+  if (*Serial == 0) {
+Status = RpiFirmwareGetMacAddress ((UINT8*) Serial);
+// Convert to a more user-friendly value
+*Serial = SwapBytes64 (*Serial << 16);
+  }
+
+  return Status;
 }
 
 #pragma pack()
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#48570): https://edk2.groups.io/g/devel/message/48570
Mute This Topic: https://groups.io/mt/34441817/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 0/5] Platform/RPi3: Various SMBIOS improvements

2019-10-08 Thread Pete Batard
v1 can be found at https://edk2.groups.io/g/devel/message/46806 - 46808

Changes for v2:
- Split *functional* changes into multipe commits
- Spell out serial number
- *NEW* Derive Type 19 addresses from board revision (RPi4 improvement)

Also, with regards to further splitting that was requested and while I
appreciate that I already got some leniency in that respect, I must state
that my time is limited, therefore, unless I suspect a typo or style fix,
that got corrected in a "while I'm here" fashion, to result in a potential
CVE or make people browsing the codebase genuinely puzzled, I'm afraid that
I will continue to shove those as Also's into the commits I submit, so that
I can at least try to reclaim some valuable time...

Pete Batard (5):
  Platform/RPi3/RpiFirmwareDxe: Add more query functions
  Platform/RPi3/RpiFirmwareDxe: Improve serial number population
  Platform/RPi3/PlatformSmbiosDxe: Improve population of SMBIOS entries
  Platform/RPi3/PlatformSmbiosDxe: Populate BIOS major/minor from PCD
  Platform/RPi3/PlatformSmbiosDxe: Derive RAM size from board revision

 Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c   | 
211 
 Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf |   
1 +
 Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c | 
166 ++-
 Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h  |  
58 --
 Platform/RaspberryPi/RPi3/RPi3.dsc|   
2 +-
 5 files changed, 334 insertions(+), 104 deletions(-)

-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#48568): https://edk2.groups.io/g/devel/message/48568
Mute This Topic: https://groups.io/mt/34441815/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 4/5] Platform/RPi3/PlatformSmbiosDxe: Populate BIOS major/minor from PCD

2019-10-08 Thread Pete Batard
String parsing code is added to BIOSInfoUpdateSmbiosType0() so that
any numeric "x.y" value being passed in PcdFirmwareVersionString is
now used to populate the BIOS major and minor.

Signed-off-by: Pete Batard 
---
 Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c | 44 
+++-
 1 file changed, 43 insertions(+), 1 deletion(-)

diff --git 
a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c 
b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c
index 8a4840267780..66ffadd0cade 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c
+++ b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c
@@ -41,7 +41,9 @@
 #include 
 #include 
 
-static RASPBERRY_PI_FIRMWARE_PROTOCOL *mFwProtocol;
+#define SMB_IS_DIGIT(c)  (((c) >= '0') && ((c) <= '9'))
+
+STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL *mFwProtocol;
 
 /***
 SMBIOS data definition  TYPE0  BIOS Information
@@ -618,6 +620,46 @@ BIOSInfoUpdateSmbiosType0 (
   UnicodeStrToAsciiStrS ((CHAR16*)PcdGetPtr (PcdFirmwareVersionString),
 mBiosVersion, sizeof (mBiosVersion));
 
+  // Look for a "x.y" numeric string anywhere in mBiosVersion and
+  // try to parse it to populate the BIOS major and minor.
+  for (i = 0; (i < AsciiStrLen (mBiosVersion)) && (State < 4); i++) {
+switch (State) {
+case 0:
+  if (!SMB_IS_DIGIT (mBiosVersion[i]))
+break;
+  Value[0] = Value[1] = 0;
+  State++;
+  // Fall through
+case 1:
+case 3:
+  if (SMB_IS_DIGIT (mBiosVersion[i])) {
+Value[State / 2] = (Value[State / 2] * 10) + (mBiosVersion[i] - '0');
+if (Value[State / 2] > 255) {
+  while (SMB_IS_DIGIT (mBiosVersion[i + 1]))
+i++;
+  // Reset our state (we may have something like "Firmware X83737.1 
v1.23")
+  State = 0;
+}
+  } else {
+State++;
+  }
+  if (State != 2)
+break;
+  // Fall through
+case 2:
+  if ((mBiosVersion[i] == '.') && (SMB_IS_DIGIT (mBiosVersion[i + 1]))) {
+State++;
+  } else {
+State = 0;
+  }
+  break;
+}
+  }
+  if ((State == 3) || (State == 4)) {
+mBIOSInfoType0.SystemBiosMajorRelease = (UINT8)Value[0];
+mBIOSInfoType0.SystemBiosMinorRelease = (UINT8)Value[1];
+  }
+
   LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*), 
mBIOSInfoType0Strings, NULL);
 }
 
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#48572): https://edk2.groups.io/g/devel/message/48572
Mute This Topic: https://groups.io/mt/34441819/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [edk2-platforms PATCH 1/1] Platforms/RPi3: DisplayDxe virtual resolution improvements

2019-09-30 Thread Pete Batard

Hi Leif,

On 2019.09.29 00:05, Leif Lindholm wrote:

On Fri, Sep 27, 2019 at 10:20:15AM +0100, Pete Batard wrote:

From: Andrei Warkentin 

The Pi GPU decouples requested resolution from actual physical resolution
and can perform scaling of virtual resolutions. This enables platform users
to do something like ask for 1024x768 and get a framebuffer of that size,
regardless of the actual output (which could be a very blurry SDTV).

Specifically, this patch allows selecting which specific virtual
resolutions to enable, thus replacing the old all-or-nothing behaviour
with either all virtual resolutions supported, or just the native one.

This patch also adds enables the common 7" Pi (800x480) screen to be used
at 800x600 resolution, instead of forcing 640x480 as the only usable
resolution.


I am basically OK with this patch, but I note that the change in
variable name/content means existing users will end up with stale
variables.

So I wonder if it would be worth explicitly adding a stanza deleting
the old variable if found?


That would be a valid point *if* the Pi 3 was using actual NVRAM storage 
to write those variables.


However, we have no such thing on the hardware, so we currently store 
those variables on the SD card, within the firmware file itself.


Which means, the minute you "install" a new firmware (by replacing the 
existing RPI_EFI.fd on your SD card with a new one), you're losing all 
your existing variables anyway, including stale ones.


Maybe with the Pi 4 and its 512 KB EEPROM, we'll be able to look into 
preserving the variables. Or we may also look into writing variables to 
a separate virtual NVRAM file on the SD card, instead of just reusing 
the .fd (which we are doing for convenience). But for our current model, 
what you highlight is a non issue, as the only "upgrade" path forces 
users to always start with a virtual NVRAM that has been reset and that 
is therefore free from any stale variable.


Regards,

/Pete



/
     Leif.


Signed-off-by: Pete Batard 
---
  Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c  |  9 +--
  Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf|  2 +-
  Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni | 17 +++--
  Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr | 71 

  Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/DisplayDxe.c| 53 
+--
  Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/DisplayDxe.inf  |  2 +-
  Platform/RaspberryPi/RPi3/RPi3.dec   |  2 +-
  Platform/RaspberryPi/RPi3/RPi3.dsc   |  2 +-
  8 files changed, 125 insertions(+), 33 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c 
b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c
index fcb4ce6935b6..98e58a560ed4 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c
+++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c
@@ -92,6 +92,7 @@ SetupVariables (
)
  {
UINTN Size;
+  UINT8 Var8;
UINT32 Var32;
EFI_STATUS Status;
  
@@ -180,12 +181,12 @@ SetupVariables (

  PcdSet32 (PcdDebugShowUEFIExit, PcdGet32 (PcdDebugShowUEFIExit));
}
  
-  Size = sizeof (UINT32);

-  Status = gRT->GetVariable (L"DisplayEnableVModes",
+  Size = sizeof (UINT8);
+  Status = gRT->GetVariable (L"DisplayEnableScaledVModes",
,
-  NULL, , );
+  NULL, , );
if (EFI_ERROR (Status)) {
-PcdSet32 (PcdDisplayEnableVModes, PcdGet32 (PcdDisplayEnableVModes));
+PcdSet8 (PcdDisplayEnableScaledVModes, PcdGet8 
(PcdDisplayEnableScaledVModes));
}
  
Size = sizeof (UINT32);

diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf 
b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
index 2fc4302526a1..24112d517467 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
+++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
@@ -64,7 +64,7 @@ [Pcd]
gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti
gRaspberryPiTokenSpaceGuid.PcdDebugEnableJTAG
gRaspberryPiTokenSpaceGuid.PcdDebugShowUEFIExit
-  gRaspberryPiTokenSpaceGuid.PcdDisplayEnableVModes
+  gRaspberryPiTokenSpaceGuid.PcdDisplayEnableScaledVModes
gRaspberryPiTokenSpaceGuid.PcdDisplayEnableSShot
  
  [FeaturePcd]

diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni 
b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni
index 65b45f3e6496..9b4076635f05 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni
+++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni
@@ -71,10 +71,19 @@
  #string STR_DISPLAY_FORM_TITLE  #language en-US "Display"
  #string STR_DISPLAY_FORM_SUBTITLE   #language en-US "UEFI video driver 
settings"
  
-#string STR_DISPLAY_VMODES_PROMPT   #language en-US "Resolutions"

-#

Re: [edk2-devel] [edk2-platforms PATCH 1/1] Platforms/RPi3: DisplayDxe virtual resolution improvements

2019-09-27 Thread Pete Batard
Try this after making sure that you have edk2/, edk2-platforms/ and 
edk-non-osi/ in /home/phil/source:


cd /home/phil/source
export GCC5_AARCH64_PREFIX=aarch64-linux-gnu-
export WORKSPACE=$PWD
export 
PACKAGES_PATH=$WORKSPACE/edk2:$WORKSPACE/edk2-platforms:$WORKSPACE/edk2-non-osi

source edk2/edksetup.sh --reconfig
build -a AARCH64 -t GCC5 -p 
edk2-platforms/Platform/RaspberryPi/RPi3/RPi3.dsc -b DEBUG


Regards,

/Pete


On 2019.09.27 21:23, Philippe Mathieu-Daudé wrote:

On 9/27/19 7:49 PM, Leif Lindholm wrote:

On Fri, Sep 27, 2019 at 06:38:07PM +0200, Philippe Mathieu-Daudé wrote:

Hi Pete,

On 9/27/19 11:20 AM, Pete Batard wrote:

From: Andrei Warkentin 

The Pi GPU decouples requested resolution from actual physical resolution
and can perform scaling of virtual resolutions. This enables platform users
to do something like ask for 1024x768 and get a framebuffer of that size,
regardless of the actual output (which could be a very blurry SDTV).

Specifically, this patch allows selecting which specific virtual
resolutions to enable, thus replacing the old all-or-nothing behaviour
with either all virtual resolutions supported, or just the native one.

This patch also adds enables the common 7" Pi (800x480) screen to be used
at 800x600 resolution, instead of forcing 640x480 as the only usable
resolution.


I tried to build the RPi3 platform but I get errors because it seems to
use an older edk2 repository. What tag should I use?


edk2-platforms master should always build against edk2 - if it does
not, that's a bug. But I can't see any issues when building rpi3 with
the current master branches.
Any platform that is not willing to commit to this state of things can
live on stable- or devel- branches in the edk-platforms repository.
This process is described in
https://github.com/tianocore/edk2-platforms/blob/about/Readme.md

But please provide some more information than "I get errors". It is a
much better use of maintainer time than sending me off verifying that
something I expected to work still works (for me).


Yes, sorry :/

So the first error was:

: error 000E: File/directory not found in workspace
   Platform/RaspberryPi/RPi3/Drivers/LogoDxe/LogoDxe.inf is not found in
packages path:

And as you noted on IRC, I was missing edk2-non-osi, silly me :S

Using it I now get:

/home/phil/source/edk2$ GCC5_AARCH64_PREFIX=aarch64-linux-gnu- build -a
AARCH64 -t GCC5 -b DEBUG -p Platform/RaspberryPi/RPi3/RPi3.dsc -D
ATF_BUILD_DIR=$ATF_BUILD_DIR -n 1
Build environment:
Linux-5.2.11-100.fc29.x86_64-x86_64-with-Ubuntu-16.04-xenial
Build start time: 20:10:25, Sep.27 2019

WORKSPACE= /home/phil/source/edk2
PACKAGES_PATH=
/home/phil/source/edk2:/home/phil/source/edk2-platforms:/home/phil/source/edk2-non-osi
EDK_TOOLS_PATH   = /home/phil/source/edk2/BaseTools
CONF_PATH= /home/phil/source/edk2/Conf


Architecture(s)  = AARCH64
Build target = DEBUG

Processing meta-data .Toolchain= GCC5

Active Platform  =
/home/phil/source/edk2-platforms/Platform/RaspberryPi/RPi3/RPi3.dsc
. done!
Building ...
/home/phil/source/edk2/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
[AARCH64]
make: Nothing to be done for 'tbuild'.
Building ...
/home/phil/source/edk2/MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
[AARCH64]
make: Nothing to be done for 'tbuild'.
Building ...
/home/phil/source/edk2/MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
[AARCH64]
make: Nothing to be done for 'tbuild'.
Building ... /home/phil/source/edk2/MdePkg/Library/UefiLib/UefiLib.inf
[AARCH64]
make: Nothing to be done for 'tbuild'.
Building ...
/home/phil/source/edk2/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
[AARCH64]
make: Nothing to be done for 'tbuild'.
Building ...
/home/phil/source/edk2/MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
[AARCH64]
make: Nothing to be done for 'tbuild'.
Building ...
/home/phil/source/edk2/MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
[AARCH64]
make: Nothing to be done for 'tbuild'.
Building ...
/home/phil/source/edk2/MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
[AARCH64]
make: Nothing to be done for 'tbuild'.
Building ...
/home/phil/source/edk2/MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
[AARCH64]
make: Nothing to be done for 'tbuild'.
Building ...
/home/phil/source/edk2/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf
[AARCH64]
make: Nothing to be done for 'tbuild'.
Building ...
/home/phil/source/edk2/MdePkg/Library/BasePrintLib/BasePrintLib.inf
[AARCH64]
make: Nothing to be done for 'tbuild'.
Building ...
/home/phil/source/edk2/MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
[AARCH64]
make: Nothing to be done for 'tbuild'.
Building ...
/home/phil/source/edk2/MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull.inf
[AARCH64]
make: Nothing to be done for 'tb

Re: [edk2-devel] [edk2-platforms PATCH 1/1] Platforms/RPi3: DisplayDxe virtual resolution improvements

2019-09-27 Thread Pete Batard

Hi Philippe,

On 2019.09.27 17:38, Philippe Mathieu-Daudé wrote:

Hi Pete,

On 9/27/19 11:20 AM, Pete Batard wrote:

From: Andrei Warkentin 

The Pi GPU decouples requested resolution from actual physical resolution
and can perform scaling of virtual resolutions. This enables platform users
to do something like ask for 1024x768 and get a framebuffer of that size,
regardless of the actual output (which could be a very blurry SDTV).

Specifically, this patch allows selecting which specific virtual
resolutions to enable, thus replacing the old all-or-nothing behaviour
with either all virtual resolutions supported, or just the native one.

This patch also adds enables the common 7" Pi (800x480) screen to be used
at 800x600 resolution, instead of forcing 640x480 as the only usable
resolution.


I tried to build the RPi3 platform but I get errors because it seems to
use an older edk2 repository. What tag should I use?


I just re-built against very latest edk2/edk2-platforms/edk2-non-osi 
(pulled a couple minutes ago) and I'm not seeing any issue. It should 
build against latest.


What error are you getting?



Signed-off-by: Pete Batard 


Hmm shouldn't this patch have a S-o-b from Andrei Warkentin too?


We discussed this before with Leif (who has since replied), and agreed 
that it makes no sense to use a S-o-b unless it's the actual person 
sending the e-mail.


Regards,

/Pete



Thanks,

Phil.


---
  Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c  |  9 +--
  Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf|  2 +-
  Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni | 17 +++--
  Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr | 71 

  Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/DisplayDxe.c| 53 
+--
  Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/DisplayDxe.inf  |  2 +-
  Platform/RaspberryPi/RPi3/RPi3.dec   |  2 +-
  Platform/RaspberryPi/RPi3/RPi3.dsc   |  2 +-
  8 files changed, 125 insertions(+), 33 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c 
b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c
index fcb4ce6935b6..98e58a560ed4 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c
+++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c
@@ -92,6 +92,7 @@ SetupVariables (
)
  {
UINTN Size;
+  UINT8 Var8;
UINT32 Var32;
EFI_STATUS Status;
  
@@ -180,12 +181,12 @@ SetupVariables (

  PcdSet32 (PcdDebugShowUEFIExit, PcdGet32 (PcdDebugShowUEFIExit));
}
  
-  Size = sizeof (UINT32);

-  Status = gRT->GetVariable (L"DisplayEnableVModes",
+  Size = sizeof (UINT8);
+  Status = gRT->GetVariable (L"DisplayEnableScaledVModes",
,
-  NULL, , );
+  NULL, , );
if (EFI_ERROR (Status)) {
-PcdSet32 (PcdDisplayEnableVModes, PcdGet32 (PcdDisplayEnableVModes));
+PcdSet8 (PcdDisplayEnableScaledVModes, PcdGet8 
(PcdDisplayEnableScaledVModes));
}
  
Size = sizeof (UINT32);

diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf 
b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
index 2fc4302526a1..24112d517467 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
+++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
@@ -64,7 +64,7 @@ [Pcd]
gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti
gRaspberryPiTokenSpaceGuid.PcdDebugEnableJTAG
gRaspberryPiTokenSpaceGuid.PcdDebugShowUEFIExit
-  gRaspberryPiTokenSpaceGuid.PcdDisplayEnableVModes
+  gRaspberryPiTokenSpaceGuid.PcdDisplayEnableScaledVModes
gRaspberryPiTokenSpaceGuid.PcdDisplayEnableSShot
  
  [FeaturePcd]

diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni 
b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni
index 65b45f3e6496..9b4076635f05 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni
+++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni
@@ -71,10 +71,19 @@
  #string STR_DISPLAY_FORM_TITLE  #language en-US "Display"
  #string STR_DISPLAY_FORM_SUBTITLE   #language en-US "UEFI video driver 
settings"
  
-#string STR_DISPLAY_VMODES_PROMPT   #language en-US "Resolutions"

-#string STR_DISPLAY_VMODES_HELP #language en-US "Support for non-native 
modes"
-#string STR_DISPLAY_VMODES_ENABLE   #language en-US "Also support 640x480, 800x600, 
1024x768, 720p and 1080p"
-#string STR_DISPLAY_VMODES_DISABLE  #language en-US "Only native resolution"
+#string STR_DISPLAY_VMODES_640_PROMPT  #language en-US "Virtual 640x480"
+#string STR_DISPLAY_VMODES_640_HELP#language en-US "Enable scaled 640x480 
mode"
+#string STR_DISPLAY_VMODES_800_PROMPT  #language en-US "Virtual 800x600"
+#string STR_DISPLAY_VMODES_800_HELP#languag

[edk2-devel] [edk2-platforms PATCH 1/1] Platforms/RPi3: DisplayDxe virtual resolution improvements

2019-09-27 Thread Pete Batard
From: Andrei Warkentin 

The Pi GPU decouples requested resolution from actual physical resolution
and can perform scaling of virtual resolutions. This enables platform users
to do something like ask for 1024x768 and get a framebuffer of that size,
regardless of the actual output (which could be a very blurry SDTV).

Specifically, this patch allows selecting which specific virtual
resolutions to enable, thus replacing the old all-or-nothing behaviour
with either all virtual resolutions supported, or just the native one.

This patch also adds enables the common 7" Pi (800x480) screen to be used
at 800x600 resolution, instead of forcing 640x480 as the only usable
resolution.

Signed-off-by: Pete Batard 
---
 Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c  |  9 +--
 Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf|  2 +-
 Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni | 17 +++--
 Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr | 71 

 Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/DisplayDxe.c| 53 
+--
 Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/DisplayDxe.inf  |  2 +-
 Platform/RaspberryPi/RPi3/RPi3.dec   |  2 +-
 Platform/RaspberryPi/RPi3/RPi3.dsc   |  2 +-
 8 files changed, 125 insertions(+), 33 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c 
b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c
index fcb4ce6935b6..98e58a560ed4 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c
+++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c
@@ -92,6 +92,7 @@ SetupVariables (
   )
 {
   UINTN Size;
+  UINT8 Var8;
   UINT32 Var32;
   EFI_STATUS Status;
 
@@ -180,12 +181,12 @@ SetupVariables (
 PcdSet32 (PcdDebugShowUEFIExit, PcdGet32 (PcdDebugShowUEFIExit));
   }
 
-  Size = sizeof (UINT32);
-  Status = gRT->GetVariable (L"DisplayEnableVModes",
+  Size = sizeof (UINT8);
+  Status = gRT->GetVariable (L"DisplayEnableScaledVModes",
   ,
-  NULL, , );
+  NULL, , );
   if (EFI_ERROR (Status)) {
-PcdSet32 (PcdDisplayEnableVModes, PcdGet32 (PcdDisplayEnableVModes));
+PcdSet8 (PcdDisplayEnableScaledVModes, PcdGet8 
(PcdDisplayEnableScaledVModes));
   }
 
   Size = sizeof (UINT32);
diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf 
b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
index 2fc4302526a1..24112d517467 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
+++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
@@ -64,7 +64,7 @@ [Pcd]
   gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti
   gRaspberryPiTokenSpaceGuid.PcdDebugEnableJTAG
   gRaspberryPiTokenSpaceGuid.PcdDebugShowUEFIExit
-  gRaspberryPiTokenSpaceGuid.PcdDisplayEnableVModes
+  gRaspberryPiTokenSpaceGuid.PcdDisplayEnableScaledVModes
   gRaspberryPiTokenSpaceGuid.PcdDisplayEnableSShot
 
 [FeaturePcd]
diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni 
b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni
index 65b45f3e6496..9b4076635f05 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni
+++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni
@@ -71,10 +71,19 @@
 #string STR_DISPLAY_FORM_TITLE  #language en-US "Display"
 #string STR_DISPLAY_FORM_SUBTITLE   #language en-US "UEFI video driver 
settings"
 
-#string STR_DISPLAY_VMODES_PROMPT   #language en-US "Resolutions"
-#string STR_DISPLAY_VMODES_HELP #language en-US "Support for non-native 
modes"
-#string STR_DISPLAY_VMODES_ENABLE   #language en-US "Also support 640x480, 
800x600, 1024x768, 720p and 1080p"
-#string STR_DISPLAY_VMODES_DISABLE  #language en-US "Only native resolution"
+#string STR_DISPLAY_VMODES_640_PROMPT  #language en-US "Virtual 640x480"
+#string STR_DISPLAY_VMODES_640_HELP#language en-US "Enable scaled 640x480 
mode"
+#string STR_DISPLAY_VMODES_800_PROMPT  #language en-US "Virtual 800x600"
+#string STR_DISPLAY_VMODES_800_HELP#language en-US "Enable scaled 800x600 
mode"
+#string STR_DISPLAY_VMODES_1024_PROMPT #language en-US "Virtual 1024x768"
+#string STR_DISPLAY_VMODES_1024_HELP   #language en-US "Enable scaled 1024x768 
mode"
+#string STR_DISPLAY_VMODES_720_PROMPT  #language en-US "Virtual 720p"
+#string STR_DISPLAY_VMODES_720_HELP#language en-US "Enable scaled 720p 
mode"
+#string STR_DISPLAY_VMODES_1080_PROMPT #language en-US "Virtual 1080p"
+#string STR_DISPLAY_VMODES_1080_HELP   #language en-US "Enable scaled 1080p 
mode"
+
+#string STR_DISPLAY_VMODES_REAL_PROMPT #language en-US "Native resolution"
+#string STR_DISPLAY_VMODES_REAL_HELP   #language en-US "Native resolution"

[edk2-devel] [PATCH 1/1] MdeModulePkg/BdsDxe: Also call PlatformBootManagerWaitCallback on 0

2019-09-25 Thread Pete Batard
The existing loop is set to call PlatformBootManagerWaitCallback every
second except the last one. We believe this is a mistake as it prevents
the called code from performing timeout expiration tasks such as, for
instance, ensuring that the last segment of a progress bar is displayed
before continuing (which is a current issue for the RPi3 platform).

Signed-off-by: Pete Batard 
---
 MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c 
b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
index f3d5e5ac0615..7968a58f3454 100644
--- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
+++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
@@ -341,6 +341,7 @@ BdsWait (
   TimeoutRemain--;
 }
   }
+  PlatformBootManagerWaitCallback (0);
   DEBUG ((EFI_D_INFO, "[Bds]Exit the waiting!\n"));
 }
 
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#48037): https://edk2.groups.io/g/devel/message/48037
Mute This Topic: https://groups.io/mt/34288971/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v2 1/2] Add VS2019 Toolchain def

2019-09-17 Thread Pete Batard

On 2019.09.17 04:16, Cheng, Ching JenX wrote:

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2182

In order to support VS2019,
the first thing need to do is add 2019 toolchain on tools_def.template

v2: add ARM/AARCH64/EBC Definitions, Combine VS2017_HOST and VS2019_HOST to 
VS_HOST


Both patches look good to me now. Thanks.

Reviewed-by: Pete Batard 



Cc: Amy Chan 
Cc: Bob Feng 
Cc: Liming Gao 
Signed-off-by: Ching JenX Cheng 
---
  BaseTools/Conf/tools_def.template | 220 
+---
  1 file changed, 201 insertions(+), 19 deletions(-)

diff --git a/BaseTools/Conf/tools_def.template 
b/BaseTools/Conf/tools_def.template
index 8f0e6cb6c2..88a6764f43 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -55,35 +55,43 @@ DEFINE VS2015x86_BIN= ENV(VS2015_PREFIX)Vc\bin
  DEFINE VS2015x86_DLL= ENV(VS2015_PREFIX)Common7\IDE;DEF(VS2015x86_BIN)
  DEFINE VS2015x86_BINX64 = DEF(VS2015x86_BIN)\x86_amd64

-DEFINE VS2017_BIN = ENV(VS2017_PREFIX)bin
-DEFINE VS2017_HOST= x86
-DEFINE VS2017_BIN_HOST= 
DEF(VS2017_BIN)\HostDEF(VS2017_HOST)\DEF(VS2017_HOST)
-DEFINE VS2017_BIN_IA32= DEF(VS2017_BIN)\HostDEF(VS2017_HOST)\x86
-DEFINE VS2017_BIN_X64 = DEF(VS2017_BIN)\HostDEF(VS2017_HOST)\x64
-DEFINE VS2017_BIN_ARM = DEF(VS2017_BIN)\HostDEF(VS2017_HOST)\arm
-DEFINE VS2017_BIN_AARCH64 = DEF(VS2017_BIN)\HostDEF(VS2017_HOST)\arm64
+DEFINE VS_HOST= x86

-DEFINE WINSDK_BIN   = ENV(WINSDK_PREFIX)
-DEFINE WINSDKx86_BIN= ENV(WINSDKx86_PREFIX)
+DEFINE VS2017_BIN = ENV(VS2017_PREFIX)bin
+DEFINE VS2017_BIN_HOST= DEF(VS2017_BIN)\HostDEF(VS_HOST)\DEF(VS_HOST)
+DEFINE VS2017_BIN_IA32= DEF(VS2017_BIN)\HostDEF(VS_HOST)\x86
+DEFINE VS2017_BIN_X64 = DEF(VS2017_BIN)\HostDEF(VS_HOST)\x64
+DEFINE VS2017_BIN_ARM = DEF(VS2017_BIN)\HostDEF(VS_HOST)\arm
+DEFINE VS2017_BIN_AARCH64 = DEF(VS2017_BIN)\HostDEF(VS_HOST)\arm64
+
+DEFINE VS2019_BIN = ENV(VS2019_PREFIX)bin
+DEFINE VS2019_BIN_HOST= DEF(VS2019_BIN)\HostDEF(VS_HOST)\DEF(VS_HOST)
+DEFINE VS2019_BIN_IA32= DEF(VS2019_BIN)\HostDEF(VS_HOST)\x86
+DEFINE VS2019_BIN_X64 = DEF(VS2019_BIN)\HostDEF(VS_HOST)\x64
+DEFINE VS2019_BIN_ARM = DEF(VS2019_BIN)\HostDEF(VS_HOST)\arm
+DEFINE VS2019_BIN_AARCH64 = DEF(VS2019_BIN)\HostDEF(VS_HOST)\arm64
+
+DEFINE WINSDK_BIN   = ENV(WINSDK_PREFIX)
+DEFINE WINSDKx86_BIN= ENV(WINSDKx86_PREFIX)

  # Microsoft Visual Studio 2010
-DEFINE WINSDK7_BIN   = ENV(WINSDK7_PREFIX)
-DEFINE WINSDK7x86_BIN= ENV(WINSDK7x86_PREFIX)
+DEFINE WINSDK7_BIN  = ENV(WINSDK7_PREFIX)
+DEFINE WINSDK7x86_BIN   = ENV(WINSDK7x86_PREFIX)

  # Microsoft Visual Studio 2012 Update 1 (required for rc.exe that was not 
included in the initial release)
-DEFINE WINSDK71_BIN   = ENV(WINSDK71_PREFIX)
-DEFINE WINSDK71x86_BIN= ENV(WINSDK71x86_PREFIX)
+DEFINE WINSDK71_BIN = ENV(WINSDK71_PREFIX)
+DEFINE WINSDK71x86_BIN  = ENV(WINSDK71x86_PREFIX)

  # Microsoft Visual Studio 2013 Professional Edition
-DEFINE WINSDK8_BIN   = ENV(WINSDK8_PREFIX)x86\
-DEFINE WINSDK8x86_BIN= ENV(WINSDK8x86_PREFIX)x64
+DEFINE WINSDK8_BIN  = ENV(WINSDK8_PREFIX)x86\
+DEFINE WINSDK8x86_BIN   = ENV(WINSDK8x86_PREFIX)x64

  # Microsoft Visual Studio 2015 Professional Edition
-DEFINE WINSDK81_BIN   = ENV(WINSDK81_PREFIX)x86\
-DEFINE WINSDK81x86_BIN= ENV(WINSDK81x86_PREFIX)x64
+DEFINE WINSDK81_BIN = ENV(WINSDK81_PREFIX)x86\
+DEFINE WINSDK81x86_BIN  = ENV(WINSDK81x86_PREFIX)x64

-# Microsoft Visual Studio 2017 Professional Edition
-DEFINE WINSDK10_BIN   = ENV(WINSDK10_PREFIX)DEF(VS2017_HOST)
+# Microsoft Visual Studio 2017/2019 Professional Edition
+DEFINE WINSDK10_BIN = ENV(WINSDK10_PREFIX)DEF(VS_HOST)

  # These defines are needed for certain Microsoft Visual Studio tools that
  # are used by other toolchains.  An example is that ICC on Windows normally
@@ -218,6 +226,17 @@ DEFINE DTC_BIN = ENV(DTC_PREFIX)dtc
  #Note:
  # Building of XIP firmware images for ARM/ARM64 
is not currently supported (only applications).
  # /FILEALIGN:4096 and other changes are needed 
for ARM firmware builds.
+#   VS2019  -win32-  Requires:
+# Microsoft Visual Studio 2019 version 16.2 or 
later
+#Optional:
+# Required to build EBC drivers:
+#   Intel(r) Compiler for Efi Byte Code (Intel(r) 
EBC Compiler)
+# Required to build platforms or ACPI tables:
+#   Intel(r) ACPI Compiler (iasl.exe) from
+#   https://acpica.org

Re: [edk2-devel] [PATCH 1/2] Add VS2019 Toolchain def

2019-09-16 Thread Pete Batard
S2019_AARCH64_ASM_FLAGS   = /nologo /g
RELEASE_VS2019_AARCH64_ASM_FLAGS   = /nologo
NOOPT_VS2019_AARCH64_ASM_FLAGS = /nologo

  DEBUG_VS2019_AARCH64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 
/OPT:REF /OPT:ICF=10 /MAP /SECTION:.xdata,D /SECTION:.pdata,D 
/MACHINE:ARM64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) 
/SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /DRIVER /DEBUG
RELEASE_VS2019_AARCH64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 
/IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /SECTION:.xdata,D 
/SECTION:.pdata,D /MACHINE:ARM64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) 
/SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /DRIVER /MERGE:.rdata=.data
NOOPT_VS2019_AARCH64_DLINK_FLAGS   = /NOLOGO /NODEFAULTLIB /IGNORE:4001 
/OPT:REF /OPT:ICF=10 /MAP /SECTION:.xdata,D /SECTION:.pdata,D 
/MACHINE:ARM64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) 
/SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /DRIVER /DEBUG


##
# EBC definitions
##
*_VS2019_EBC_*_FAMILY= INTEL

*_VS2019_EBC_PP_PATH = DEF(EBC_BINx86)\iec.exe
*_VS2019_EBC_VFRPP_PATH  = DEF(EBC_BINx86)\iec.exe
*_VS2019_EBC_CC_PATH = DEF(EBC_BINx86)\iec.exe
*_VS2019_EBC_SLINK_PATH  = DEF(VS2019_BIN_IA32)\link.exe
*_VS2019_EBC_DLINK_PATH  = DEF(VS2019_BIN_IA32)\link.exe

*_VS2019_EBC_MAKE_FLAGS  = /nologo
*_VS2019_EBC_PP_FLAGS= /nologo /E /TC /FIAutoGen.h
*_VS2019_EBC_CC_FLAGS= /nologo /c /WX /W3 /FIAutoGen.h 
/D$(MODULE_ENTRY_POINT)=$(ARCH_ENTRY_POINT)
*_VS2019_EBC_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE 
/FI$(MODULE_NAME)StrDefs.h

*_VS2019_EBC_SLINK_FLAGS = /lib /NOLOGO /MACHINE:EBC
*_VS2019_EBC_DLINK_FLAGS = "C:\Program Files 
(x86)\Intel\EBC\Lib\EbcLib.lib" /NOLOGO /NODEFAULTLIB /MACHINE:EBC 
/OPT:REF /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER 
/MAP /ALIGN:32 /DRIVER


## END COPY HERE ##


3. With the above completed, you should e able to compile something like 
ShellPkg for ARM/AARCH64 by issuing:


# ARM
C:\Program Files (x86)\Microsoft Visual 
Studio\2019\Community\VC\Auxiliary\Build\vcvarsamd64_arm.bat"

edksetup.bat reconfig
build -a ARM -b RELEASE -t VS2019 -p ShellPkg/ShellPkg.dsc

# AARCH64
C:\Program Files (x86)\Microsoft Visual 
Studio\2019\Community\VC\Auxiliary\Build\vcvarsamd64_arm64.bat"

edksetup.bat reconfig
build -a AARCH64 -b RELEASE -t VS2019 -p ShellPkg/ShellPkg.dsc


I have tested ShellPkg as well as other custom applications 
recompilation with VS2019 for ARM/AARCH64 on my platform, and found no 
issues.


If you need more details, please let me know.

Regards,

/Pete



Thank you,
Best Regards,
Allen


-Original Message-
From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
Pete Batard
Sent: Wednesday, September 11, 2019 11:43 PM
To: devel@edk2.groups.io; Cheng, Ching JenX

Cc: Chan, Amy ; Feng, Bob C ;
Gao, Liming 
Subject: Re: [edk2-devel] [PATCH 1/2] Add VS2019 Toolchain def

Hi Ching JenX,

Please see two comments inline.

On 2019.09.11 07:08, Cheng, Ching JenX wrote:

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2182

In order to support VS2019,
the first thing need to do is add 2019 toolchain on tools_def.template

Change-Id: Id52abdc9762cf06bb9a38bbfd1153608c878d839
Cc: Amy Chan 
Cc: Bob Feng 
Cc: Liming Gao 
Signed-off-by: Ching JenX Cheng 
---
   BaseTools/Conf/tools_def.template | 134

++
++
++

   1 file changed, 122 insertions(+), 12 deletions(-)

diff --git a/BaseTools/Conf/tools_def.template
b/BaseTools/Conf/tools_def.template
index 8f0e6cb6c2..7585a3e5db 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -63,27 +63,35 @@ DEFINE VS2017_BIN_X64 =

DEF(VS2017_BIN)\HostDEF(VS2017_HOST)\x64

   DEFINE VS2017_BIN_ARM =

DEF(VS2017_BIN)\HostDEF(VS2017_HOST)\arm

   DEFINE VS2017_BIN_AARCH64 =
DEF(VS2017_BIN)\HostDEF(VS2017_HOST)\arm64

-DEFINE WINSDK_BIN   = ENV(WINSDK_PREFIX)
-DEFINE WINSDKx86_BIN= ENV(WINSDKx86_PREFIX)
+DEFINE VS2019_BIN = ENV(VS2019_PREFIX)bin
+DEFINE VS2019_HOST= x86
+DEFINE VS2019_BIN_HOST=

DEF(VS2019_BIN)\HostDEF(VS2019_HOST)\DEF(VS2019_HOST)

+DEFINE VS2019_BIN_IA32=

DEF(VS2019_BIN)\HostDEF(VS2019_HOST)\x86

+DEFINE VS2019_BIN_X64 =

DEF(VS2019_BIN)\HostDEF(VS2019_HOST)\x64

+DEFINE VS2019_BIN_ARM =

DEF(VS2019_BIN)\HostDEF(VS2019_HOST)\arm

+DEFINE VS2019_BIN_AARCH64 =
+DEF(VS2019_BIN)\HostDEF(VS2019_HOST)\arm64
+
+DEFINE WINSDK_BIN   = ENV(WINSDK_PREFIX)
+DEFINE WINSDKx86_BIN= ENV(WINSDKx86_PREFIX)

   # Microsoft Visual Studio 2010
-DEFINE WINSDK7_BIN   = ENV(WINSDK7_PREFIX)
-DEFINE WINSDK7x86_BIN= ENV(WINSDK7x86_PREFIX)
+DEFINE WINSDK7_BIN  = ENV(WINSDK7_PREFIX)
+DEFINE WINSDK7x86_BIN   = ENV(WIN

Re: [edk2-devel] [PATCH 1/2] Add VS2019 Toolchain def

2019-09-11 Thread Pete Batard

Hi Ching JenX,

Please see two comments inline.

On 2019.09.11 07:08, Cheng, Ching JenX wrote:

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2182

In order to support VS2019,
the first thing need to do is add 2019 toolchain on tools_def.template

Change-Id: Id52abdc9762cf06bb9a38bbfd1153608c878d839
Cc: Amy Chan 
Cc: Bob Feng 
Cc: Liming Gao 
Signed-off-by: Ching JenX Cheng 
---
  BaseTools/Conf/tools_def.template | 134 
++
  1 file changed, 122 insertions(+), 12 deletions(-)

diff --git a/BaseTools/Conf/tools_def.template 
b/BaseTools/Conf/tools_def.template
index 8f0e6cb6c2..7585a3e5db 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -63,27 +63,35 @@ DEFINE VS2017_BIN_X64 = 
DEF(VS2017_BIN)\HostDEF(VS2017_HOST)\x64
  DEFINE VS2017_BIN_ARM = DEF(VS2017_BIN)\HostDEF(VS2017_HOST)\arm
  DEFINE VS2017_BIN_AARCH64 = DEF(VS2017_BIN)\HostDEF(VS2017_HOST)\arm64
  
-DEFINE WINSDK_BIN   = ENV(WINSDK_PREFIX)

-DEFINE WINSDKx86_BIN= ENV(WINSDKx86_PREFIX)
+DEFINE VS2019_BIN = ENV(VS2019_PREFIX)bin
+DEFINE VS2019_HOST= x86
+DEFINE VS2019_BIN_HOST= 
DEF(VS2019_BIN)\HostDEF(VS2019_HOST)\DEF(VS2019_HOST)
+DEFINE VS2019_BIN_IA32= DEF(VS2019_BIN)\HostDEF(VS2019_HOST)\x86
+DEFINE VS2019_BIN_X64 = DEF(VS2019_BIN)\HostDEF(VS2019_HOST)\x64
+DEFINE VS2019_BIN_ARM = DEF(VS2019_BIN)\HostDEF(VS2019_HOST)\arm
+DEFINE VS2019_BIN_AARCH64 = DEF(VS2019_BIN)\HostDEF(VS2019_HOST)\arm64
+
+DEFINE WINSDK_BIN   = ENV(WINSDK_PREFIX)
+DEFINE WINSDKx86_BIN= ENV(WINSDKx86_PREFIX)
  
  # Microsoft Visual Studio 2010

-DEFINE WINSDK7_BIN   = ENV(WINSDK7_PREFIX)
-DEFINE WINSDK7x86_BIN= ENV(WINSDK7x86_PREFIX)
+DEFINE WINSDK7_BIN  = ENV(WINSDK7_PREFIX)
+DEFINE WINSDK7x86_BIN   = ENV(WINSDK7x86_PREFIX)
  
  # Microsoft Visual Studio 2012 Update 1 (required for rc.exe that was not included in the initial release)

-DEFINE WINSDK71_BIN   = ENV(WINSDK71_PREFIX)
-DEFINE WINSDK71x86_BIN= ENV(WINSDK71x86_PREFIX)
+DEFINE WINSDK71_BIN = ENV(WINSDK71_PREFIX)
+DEFINE WINSDK71x86_BIN  = ENV(WINSDK71x86_PREFIX)
  
  # Microsoft Visual Studio 2013 Professional Edition

-DEFINE WINSDK8_BIN   = ENV(WINSDK8_PREFIX)x86\
-DEFINE WINSDK8x86_BIN= ENV(WINSDK8x86_PREFIX)x64
+DEFINE WINSDK8_BIN  = ENV(WINSDK8_PREFIX)x86\
+DEFINE WINSDK8x86_BIN   = ENV(WINSDK8x86_PREFIX)x64
  
  # Microsoft Visual Studio 2015 Professional Edition

-DEFINE WINSDK81_BIN   = ENV(WINSDK81_PREFIX)x86\
-DEFINE WINSDK81x86_BIN= ENV(WINSDK81x86_PREFIX)x64
+DEFINE WINSDK81_BIN = ENV(WINSDK81_PREFIX)x86\
+DEFINE WINSDK81x86_BIN  = ENV(WINSDK81x86_PREFIX)x64
  
-# Microsoft Visual Studio 2017 Professional Edition

-DEFINE WINSDK10_BIN   = ENV(WINSDK10_PREFIX)DEF(VS2017_HOST)
+# Microsoft Visual Studio 2017/2019 Professional Edition
+DEFINE WINSDK10_BIN = ENV(WINSDK10_PREFIX)DEF(VS2017_HOST)


The above line does not use the VS2019_HOST defined above, so I think we 
want to fix that.


I wouldn't expect many people to use both VS2017 and VS2019 toolchains 
with a different host platform (e.g. x64 for VS2019 and x86 for VS2017) 
so I'd suggest that we use a single "VS_HOST" that applies to both 
platforms.


  
  # These defines are needed for certain Microsoft Visual Studio tools that

  # are used by other toolchains.  An example is that ICC on Windows normally
@@ -218,6 +226,17 @@ DEFINE DTC_BIN = ENV(DTC_PREFIX)dtc
  #Note:
  # Building of XIP firmware images for ARM/ARM64 
is not currently supported (only applications).
  # /FILEALIGN:4096 and other changes are needed 
for ARM firmware builds.
+#   VS2019  -win32-  Requires:
+# Microsoft Visual Studio 2019 version 16.2 or 
later
+#Optional:
+# Required to build EBC drivers:
+#   Intel(r) Compiler for Efi Byte Code (Intel(r) 
EBC Compiler)
+# Required to build platforms or ACPI tables:
+#   Intel(r) ACPI Compiler (iasl.exe) from
+#   https://acpica.org/downloads
+#Note:
+# Building of XIP firmware images for ARM/ARM64 is 
not currently supported (only applications).
+# /FILEALIGN:4096 and other changes are needed for 
ARM firmware builds.
  #   GCC48   -Linux,Windows-  Requires:
  # GCC 4.8 targeting x86_64-linux-gnu, 
aarch64-linux-gnu, or arm-linux-gnueabi
  #Optional:
@@ -1691,6 +1710,97 @@ NOOPT_VS2017_AARCH64_DLINK_FLAGS   = /NOLOGO 
/NODEFAULTLIB /IGNORE:4001 /OPT:REF
  *_VS2017_EBC_SLINK_FLAGS 

[edk2-devel] [edk2-platforms PATCH 0/2] Platform/RPi3: PlatformSmbios improvements

2019-09-04 Thread Pete Batard
ual Memory
Bank Locator: malloc
Type: DRAM
Type Detail: Unknown
Speed: Unknown
Manufacturer: OSV
Serial Number: Not Specified
Asset Tag: Not Specified
Part Number: Not Specified
Rank: Unknown
Configured Memory Speed: Unknown
Minimum Voltage: Unknown
Maximum Voltage: Unknown
Configured Voltage: Unknown
Memory Technology: 
Memory Operating Mode Capability: None
Firmware Version: Not Specified
Module Manufacturer ID: Unknown
Module Product ID: Unknown
Memory Subsystem Controller Manufacturer ID: Unknown
Memory Subsystem Controller Product ID: Unknown
Non-Volatile Size: None
Volatile Size: None
Cache Size: None
Logical Size: None

Handle 0x0009, DMI type 19, 31 bytes
Memory Array Mapped Address
Starting Address: 0x000
Ending Address: 0x0003B3F
Range Size: 948 MB
Physical Array Handle: 0x
Partition Width: 1

Handle 0x000A, DMI type 32, 11 bytes
System Boot Information
Status: No errors detected

Handle 0xFEFF, DMI type 127, 4 bytes
End Of Table
------

Pete Batard (2):
  Platform/RPi3: Add more query functions in RpiFirmwareDxe
  Platform/RPi3: Improve the population of PlatformSmbiosDxe elements

 Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c   | 
193 
 Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf |   
1 +
 Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c | 
166 -
 Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h  |  
58 --
 Platform/RaspberryPi/RPi3/RPi3.dsc|   
2 +-
 5 files changed, 322 insertions(+), 98 deletions(-)

-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#46806): https://edk2.groups.io/g/devel/message/46806
Mute This Topic: https://groups.io/mt/33137772/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 2/2] Platform/RPi3: Improve the population of PlatformSmbiosDxe elements

2019-09-04 Thread Pete Batard
This patch cleans up the population SMBIOS entries by removing elements
that we don't have data for, as well as properly filling the ones for
which we do, through the newly added queries from RpiFirmwareDxe.

String parsing code is also added to BIOSInfoUpdateSmbiosType0() so
that any numeric "x.y" value being passed in PcdFirmwareVersionString
will now be used to populate the BIOS major and minor.

Additional minor improvements are also applied, such as consistent use
of uppercase values.

Signed-off-by: Pete Batard 
---
 Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c   | 
193 
 Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf |   
1 +
 Platform/RaspberryPi/RPi3/RPi3.dsc|   
2 +-
 3 files changed, 117 insertions(+), 79 deletions(-)

diff --git 
a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c 
b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c
index bc35175279f2..66ffadd0cade 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c
+++ b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c
@@ -35,11 +35,14 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 
+#define SMB_IS_DIGIT(c)  (((c) >= '0') && ((c) <= '9'))
+
 STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL *mFwProtocol;
 
 /***
@@ -49,7 +52,7 @@ SMBIOS_TABLE_TYPE0 mBIOSInfoType0 = {
   { EFI_SMBIOS_TYPE_BIOS_INFORMATION, sizeof (SMBIOS_TABLE_TYPE0), 0 },
   1,// Vendor String
   2,// BiosVersion String
-  0x0,  // BiosSegment
+  0,// BiosSegment
   3,// BiosReleaseDate String
   0x1F, // BiosSize
   { // BiosCharacteristics
@@ -97,23 +100,25 @@ SMBIOS_TABLE_TYPE0 mBIOSInfoType0 = {
   //  Boot1394IsSupported   :1;
   //  SmartBatteryIsSupported   :1;
   //  BIOSCharacteristicsExtensionBytes[1]
-0x0e, //  BiosBootSpecIsSupported  :1;
+0x0E, //  BiosBootSpecIsSupported  :1;
   //  FunctionKeyNetworkBootIsSupported:1;
   //  TargetContentDistributionEnabled :1;
   //  UefiSpecificationSupported   :1;
   //  VirtualMachineSupported  :1;
   //  ExtensionByte2Reserved   :3;
   },
-  0xFF,// SystemBiosMajorRelease
-  0xFF,// SystemBiosMinorRelease
-  0xFF,// EmbeddedControllerFirmwareMajorRelease
-  0xFF,// EmbeddedControllerFirmwareMinorRelease
+  0,   // SystemBiosMajorRelease
+  0,   // SystemBiosMinorRelease
+  0,   // EmbeddedControllerFirmwareMajorRelease
+  0,   // EmbeddedControllerFirmwareMinorRelease
 };
 
+CHAR8 mBiosVersion[128] = "EDK2-DEV";
+
 CHAR8 *mBIOSInfoType0Strings[] = {
-  "https://github.com/andreiw/RaspberryPiPkg;, // Vendor String
-  "Raspberry Pi 64-bit UEFI (" __DATE__ " " __TIME__ ")",  // BiosVersion 
String
-  __DATE__,
+  "TianoCore",// Vendor
+  mBiosVersion,   // Version
+  __DATE__ " " __TIME__,  // Release Date
   NULL
 };
 
@@ -132,42 +137,19 @@ SMBIOS_TABLE_TYPE1 mSysInfoType1 = {
   6,// Family String
 };
 
-#define PROD_BASE 8
-#define PROD_KNOWN   13
-#define PROD_UNKNOWN 11
-CHAR8 *ProductNames[] = {
-  /* 8 */ "3",
-  /* 9 */ "Zero",
-  /* 10 */ "CM3",
-  /* 11 */ "???",
-  /* 12 */ "Zero W",
-  /* 13 */ "3B+"
-};
-
-#define MANU_UNKNOWN 0
-#define MANU_KNOWN   4
-#define MANU_BASE1
-CHAR8 *ManufNames[] = {
-  "???",
-  /* 0 */ "Sony",
-  /* 1 */ "Egoman",
-  /* 2 */ "Embest",
-  /* 3 */ "Sony Japan",
-  /* 4 */ "Embest"
-};
-
-CHAR8 mSysInfoManufName[sizeof ("Sony Japan")];
-CHAR8 mSysInfoProductName[sizeof ("64-bit Raspberry Pi XX (rev. 
)")];
+CHAR8 mSysInfoManufName[128];
+CHAR8 mSysInfoProductName[128];
+CHAR8 mSysInfoVersionName[128];
 CHAR8 mSysInfoSerial[sizeof (UINT64) * 2 + 1];
 CHAR8 mSysInfoSKU[sizeof (UINT64) * 2 + 1];
 
 CHAR8 *mSysInfoType1Strings[] = {
   mSysInfoManufName,
   mSysInfoProductName,
-  mSysInfoProductName,
+  mSysInfoVersionName,
   mSysInfoSerial,
   mSysInfoSKU,
-  "edk2",
+  "Raspberry Pi",
   NULL
 };
 
@@ -180,7 +162,7 @@ SMBIOS_TABLE_TYPE2 mBoardInfoType2 = {
   2,// ProductName String
   3,// Version String
   4,// SerialNumber String
-  5,// AssetTag String
+  0,// AssetTag String
   {

[edk2-devel] [edk2-platforms PATCH 1/2] Platform/RPi3: Add more query functions in RpiFirmwareDxe

2019-09-04 Thread Pete Batard
This patch introduces the capability to also query the Model Name/
Manufacturer Name/CPU Name/Firmware Revision using the RpiFirmware
protocol. This is aims at making the driver more suitable to cater
for platforms other than the Raspberry Pi 3 as well as simplifying
the population of entries in PlatformSmbiosDxe.

Also fixes a typo where "%s" was used instead of "%a" and improves
RpiFirmwareGetSerial() to derive a serial from the the MAC address
in case the platform returns 0 for the serial.

Signed-off-by: Pete Batard 
---
 Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c | 166 
+++-
 Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h  |  58 +--
 2 files changed, 205 insertions(+), 19 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c 
b/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
index 9b5ee1946279..c2344252d2c0 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
+++ b/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
@@ -219,7 +219,7 @@ RpiFirmwareSetPowerState (
 
   if (!EFI_ERROR (Status) &&
   PowerState ^ (Cmd->TagBody.PowerState & RPI_MBOX_POWER_STATE_ENABLE)) {
-DEBUG ((DEBUG_ERROR, "%a: failed to %sable power for device %d\n",
+DEBUG ((DEBUG_ERROR, "%a: failed to %aable power for device %d\n",
   __FUNCTION__, PowerState ? "en" : "dis", DeviceId));
 Status = EFI_DEVICE_ERROR;
   }
@@ -393,7 +393,14 @@ RpiFirmwareGetSerial (
   }
 
   *Serial = Cmd->TagBody.Serial;
-  return EFI_SUCCESS;
+  // Some platforms return 0 for serial. For those, try to use the MAC address.
+  if (*Serial == 0) {
+Status = RpiFirmwareGetMacAddress ((UINT8*) Serial);
+// Convert to a more user-friendly value
+*Serial = SwapBytes64 (*Serial << 16);
+  }
+
+  return Status;
 }
 
 #pragma pack()
@@ -461,7 +468,7 @@ typedef struct {
   RPI_FW_TAG_HEAD   TagHead;
   RPI_FW_MODEL_REVISION_TAG TagBody;
   UINT32EndTag;
-} RPI_FW_GET_MODEL_REVISION_CMD;
+} RPI_FW_GET_REVISION_CMD;
 #pragma pack()
 
 STATIC
@@ -471,7 +478,7 @@ RpiFirmwareGetModelRevision (
   OUT   UINT32 *Revision
   )
 {
-  RPI_FW_GET_MODEL_REVISION_CMD *Cmd;
+  RPI_FW_GET_REVISION_CMD   *Cmd;
   EFI_STATUSStatus;
   UINT32Result;
 
@@ -506,6 +513,153 @@ RpiFirmwareGetModelRevision (
   return EFI_SUCCESS;
 }
 
+STATIC
+EFI_STATUS
+EFIAPI
+RpiFirmwareGetFirmwareRevision (
+  OUT   UINT32 *Revision
+  )
+{
+  RPI_FW_GET_REVISION_CMD   *Cmd;
+  EFI_STATUSStatus;
+  UINT32Result;
+
+  if (!AcquireSpinLockOrFail ()) {
+DEBUG ((DEBUG_ERROR, "%a: failed to acquire spinlock\n", __FUNCTION__));
+return EFI_DEVICE_ERROR;
+  }
+
+  Cmd = mDmaBuffer;
+  ZeroMem (Cmd, sizeof (*Cmd));
+
+  Cmd->BufferHead.BufferSize  = sizeof (*Cmd);
+  Cmd->BufferHead.Response= 0;
+  Cmd->TagHead.TagId  = RPI_MBOX_GET_REVISION;
+  Cmd->TagHead.TagSize= sizeof (Cmd->TagBody);
+  Cmd->TagHead.TagValueSize   = 0;
+  Cmd->EndTag = 0;
+
+  Status = MailboxTransaction (Cmd->BufferHead.BufferSize, 
RPI_MBOX_VC_CHANNEL, );
+
+  ReleaseSpinLock ();
+
+  if (EFI_ERROR (Status) ||
+  Cmd->BufferHead.Response != RPI_MBOX_RESP_SUCCESS) {
+DEBUG ((DEBUG_ERROR,
+  "%a: mailbox transaction error: Status == %r, Response == 0x%x\n",
+  __FUNCTION__, Status, Cmd->BufferHead.Response));
+return EFI_DEVICE_ERROR;
+  }
+
+  *Revision = Cmd->TagBody.Revision;
+  return EFI_SUCCESS;
+}
+
+STATIC
+CHAR8*
+EFIAPI
+RpiFirmwareGetModelName (
+  IN INTN ModelId
+  )
+{
+  UINT32  Revision;
+
+  // If a negative ModelId is passed, detect it.
+  if ((ModelId < 0) && (RpiFirmwareGetModelRevision () == 
EFI_SUCCESS))
+ModelId = (Revision >> 4) & 0xFF;
+
+  switch (ModelId) {
+  // 
www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md
+  case 0x00:
+return "Raspberry Pi Model A";
+  case 0x01:
+return "Raspberry Pi Model B";
+  case 0x02:
+return "Raspberry Pi Model A+";
+  case 0x03:
+return "Raspberry Pi Model B+";
+  case 0x04:
+return "Raspberry Pi 2 Model B";
+  case 0x06:
+return "Raspberry Pi Compute Module 1";
+  case 0x08:
+return "Raspberry Pi 3 Model B";
+  case 0x09:
+return "Raspberry Pi Zero";
+  case 0x0A:
+return "Raspberry Pi Compute Module 3";
+  case 0x0C:
+return "Raspberry Pi Zero W";
+  case 0x0D:
+return "Raspberry Pi 3 Model B+";
+  case 0x0E:
+return "Raspberry Pi 3 Model A+";
+  case 0x11:
+return "Raspberry Pi 4 Model B";
+  default:
+re

[edk2-devel] [edk2-non-osi PATCH 1/1] Platform/RaspberryPi/RPi3: Use official Device Tree binaries

2019-08-31 Thread Pete Batard
With commit 5f003136c2bf86620c0caaef0ad146b5e7fd2f6b having been applied to
edk2-platforms, we can use the official Raspberry Pi 3 Device Trees from
https://github.com/raspberrypi/firmware/tree/master/boot, as the FdtDxe
driver for that platform can insert missing elements, if required.

This patch replaces the existing .dtb's with the most recent official ones
and also removes the custom .dts from which previous .dtb's were produced.

Signed-off-by: Pete Batard 
---
 Platform/RaspberryPi/RPi3/DeviceTree/Readme.md|6 +
 Platform/RaspberryPi/RPi3/DeviceTree/bcm2710-rpi-3-b-plus.dtb |  Bin 25617 -> 
27082 bytes
 Platform/RaspberryPi/RPi3/DeviceTree/bcm2710-rpi-3-b-plus.dts | 1263 

 Platform/RaspberryPi/RPi3/DeviceTree/bcm2710-rpi-3-b.dtb  |  Bin 25354 -> 
26463 bytes
 Platform/RaspberryPi/RPi3/DeviceTree/bcm2710-rpi-3-b.dts  | 1259 
---
 5 files changed, 6 insertions(+), 2522 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/DeviceTree/Readme.md 
b/Platform/RaspberryPi/RPi3/DeviceTree/Readme.md
new file mode 100644
index ..45edcf555eec
--- /dev/null
+++ b/Platform/RaspberryPi/RPi3/DeviceTree/Readme.md
@@ -0,0 +1,6 @@
+Device Tree for Raspberry Pi 3
+==
+
+This directory contains a copy of the official Device Trees for the
+Raspberry Pi 3 as published by the Raspberry Pi Foundation at:
+https://github.com/raspberrypi/firmware/tree/master/boot
diff --git a/Platform/RaspberryPi/RPi3/DeviceTree/bcm2710-rpi-3-b-plus.dtb 
b/Platform/RaspberryPi/RPi3/DeviceTree/bcm2710-rpi-3-b-plus.dtb
index 
d1b37bd1375de4fe4b5f26fe611e40a5a09d9327..bdc7e43f05cfe1f2d4001627672783f06ed9a155
 100644
GIT binary patch
literal 27082
zcmd5_eT*bWb?@2T+q*r-;jquxI0nz%9=^lA_Rh@i-t8G2HW18*F*(cy3eZ`P@4b5Us=BJH<{xhS!G8on`>7xZUK<4UNANs@`}w$!
z;l_1z0Jsesh)dF_d6sN+8c)&)28|?Miw1+Mar^9I*zLEXPPi7vovkET8#KFT*P7kh
z%HnyVGS6+eZ+KYqlrOf+i{*!ysr<@&6lVqj^2V~5hw+oSc-6*BjZV9fLKsm`TB-OrHvs1$!D(!@+I_@K-kb1zvxV1GFlY^NtD9n#UbUdb>A-inron*zEU)
zgMOzI4J5-_%@$7lTX8=s_UD=StxEazt2zbZHzak~!$Frh@4PW`@D($hM~>z91|hAF4p6cQu?ATH8i`fu-(
z{t-!U*AmIUIFkQ&4G(c!(z9}s{>N>8Q~q)$KV|rY$v@VPNaK@!889?oPfY)GF1?wP
z@y{i_D>|SAz7CEf|6gi)j}@L`sE)2ndb>s$R$%6SewP2Yne?oTOn*w!w~{sFzp#=m
ze-`PVU+6?FXOUdtvK>C&?-@@*n(;UrAD^h5u{2re5hJrBWec<~n@OrDqy
zU6sNg{_y)>3ua$;*}_1hbRWVs+@$7ZX>oTmb}a_a#?plTJ$SH((cBcC|rYY
z<)u8GMA-M0>KmC3e_MLx9s;khNUM1Aw*H+sKLMQAT_*?^@o-t%!Yk{iG~A70A{EcX
z1n2og_8k3k2t>kgkp^{eY0s2c_F(LT$TQ_4-W;OMRy%2|!QK$(<@2zFxaefmRgU2U
zh(aa92U$av8Q3+HseBv*jQmg@KG`<-yxBh478$2s;FErmPx@Rw*{|{WLi@bkK7VST
z=N(9=oONV>6f9Q){8af<xEC+{gc~^tpL8JU2k_A8
zJGT_H6WV~_;8FU54QsnRgSg1tjN!?8F!`$Mx=5FHkd@CM63lec`8u8|pRxaA6sU|_
zaA3#TE@2#KJ3L=UrZC;N4s`O8*QsVL>^wuYk6H|
zoD3_BZG?1H*Q%?RT6n2=s37^-jcLnhFV!Q<{JsGRUFCu8
zOJp7$ii|0rh=!2LcWJLIfY0EUFvu=`fpn=eJ}C#@?@ZUUmw0Kc6HS9|
zryguY>y53>5Ma$O{*?}?)Qa16vQ}ZLNsp1|Z6+#uP+Dp?vYFW?fPa%0Pd195>q!+X~wa+KTwC+wr76DGSPr?VcN5`Ynkj9Jr=5Jr7^EN$|X=#P|
zh@&#

[edk2-devel] [edk2-platforms PATCH 1/1] Platform/RPi3: Add missing header files in INF file

2019-08-31 Thread Pete Batard
The header files are used but missing in INF, which causes
warning message when building them.

Signed-off-by: Pete Batard 
---
 Platform/RaspberryPi/RPi3/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.inf
 | 1 +
 Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf  
 | 1 +
 Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/DisplayDxe.inf
 | 1 +
 Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.inf
 | 2 ++
 Platform/RaspberryPi/RPi3/Drivers/MmcDxe/MmcDxe.inf
 | 1 +
 Platform/RaspberryPi/RPi3/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
 | 1 +
 
Platform/RaspberryPi/RPi3/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
 | 1 +
 7 files changed, 8 insertions(+)

diff --git 
a/Platform/RaspberryPi/RPi3/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.inf 
b/Platform/RaspberryPi/RPi3/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.inf
index 3da379b99bbb..487b7e3592ab 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.inf
+++ b/Platform/RaspberryPi/RPi3/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.inf
@@ -16,6 +16,7 @@ [Defines]
   ENTRY_POINT= MMCInitialize
 
 [Sources.common]
+  ArasanMmcHostDxe.h
   ArasanMmcHostDxe.c
 
 [Packages]
diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf 
b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
index 6d6c90b78408..2fc4302526a1 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
+++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
@@ -23,6 +23,7 @@ [Defines]
 
 [Sources]
   ConfigDxe.c
+  ConfigDxeFormSetGuid.h
   ConfigDxeHii.vfr
   ConfigDxeHii.uni
 
diff --git a/Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/DisplayDxe.inf 
b/Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/DisplayDxe.inf
index 652f6827f351..11271045bdd9 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/DisplayDxe.inf
+++ b/Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/DisplayDxe.inf
@@ -26,6 +26,7 @@ [Defines]
 #
 
 [Sources]
+  DisplayDxe.h
   DisplayDxe.c
   Screenshot.c
   ComponentName.c
diff --git a/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.inf 
b/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.inf
index 6eaca35aef55..f86480c035ba 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.inf
+++ b/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.inf
@@ -16,6 +16,8 @@ [Defines]
   ENTRY_POINT= DwUsbHostEntryPoint
 
 [Sources.common]
+  DwcHw.h
+  DwUsbHostDxe.h
   DwUsbHostDxe.c
   DriverBinding.c
   ComponentName.c
diff --git a/Platform/RaspberryPi/RPi3/Drivers/MmcDxe/MmcDxe.inf 
b/Platform/RaspberryPi/RPi3/Drivers/MmcDxe/MmcDxe.inf
index 2c71bb624387..0690f9da9c4f 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/MmcDxe/MmcDxe.inf
+++ b/Platform/RaspberryPi/RPi3/Drivers/MmcDxe/MmcDxe.inf
@@ -18,6 +18,7 @@ [Defines]
 
 [Sources.common]
   ComponentName.c
+  Mmc.h
   Mmc.c
   MmcBlockIo.c
   MmcIdentification.c
diff --git 
a/Platform/RaspberryPi/RPi3/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf 
b/Platform/RaspberryPi/RPi3/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
index 8f99528f8963..394a4f61a5b8 100644
--- 
a/Platform/RaspberryPi/RPi3/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
+++ 
b/Platform/RaspberryPi/RPi3/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
@@ -27,6 +27,7 @@ [Defines]
 
 [Sources]
   FvbInfo.c
+  VarBlockService.h
   VarBlockService.c
   VarBlockServiceDxe.c
   FileIo.c
diff --git 
a/Platform/RaspberryPi/RPi3/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
 
b/Platform/RaspberryPi/RPi3/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
index 7ce3e95c80d6..e1b132a0ae3a 100644
--- 
a/Platform/RaspberryPi/RPi3/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
+++ 
b/Platform/RaspberryPi/RPi3/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
@@ -25,6 +25,7 @@ [Defines]
 #
 
 [Sources]
+  PlatformBm.h
   PlatformBm.c
 
 [Packages]
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#46644): https://edk2.groups.io/g/devel/message/46644
Mute This Topic: https://groups.io/mt/33090523/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH 1/1] ArmPlatformPkg: Add missing header files in INF file

2019-08-31 Thread Pete Batard
The header files are used but missing in INF, which causes
warning message when building them.

Signed-off-by: Pete Batard 
---
 ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.inf | 1 +
 ArmPlatformPkg/Library/HdLcd/HdLcd.inf | 1 +
 ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.inf   | 1 +
 ArmPlatformPkg/PrePi/PeiMPCore.inf | 1 +
 ArmPlatformPkg/PrePi/PeiUniCore.inf| 1 +
 5 files changed, 5 insertions(+)

diff --git a/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.inf 
b/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.inf
index c3f2eb03f01c..d9d9bbd30e4c 100644
--- a/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.inf
+++ b/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.inf
@@ -16,6 +16,7 @@ [Defines]
   LIBRARY_CLASS  = LcdHwLib
 
 [Sources.common]
+  ArmMaliDp.h
   ArmMaliDp.c
 
 [Packages]
diff --git a/ArmPlatformPkg/Library/HdLcd/HdLcd.inf 
b/ArmPlatformPkg/Library/HdLcd/HdLcd.inf
index c14f387b57d0..bc80e1adea27 100644
--- a/ArmPlatformPkg/Library/HdLcd/HdLcd.inf
+++ b/ArmPlatformPkg/Library/HdLcd/HdLcd.inf
@@ -17,6 +17,7 @@ [Defines]
   LIBRARY_CLASS  = LcdHwLib
 
 [Sources.common]
+  HdLcd.h
   HdLcd.c
 
 [Packages]
diff --git a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.inf 
b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.inf
index 8b7cc48bd60d..757348c19659 100644
--- a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.inf
+++ b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.inf
@@ -16,6 +16,7 @@ [Defines]
   LIBRARY_CLASS  = LcdHwLib
 
 [Sources.common]
+  PL111Lcd.h
   PL111Lcd.c
 
 [Packages]
diff --git a/ArmPlatformPkg/PrePi/PeiMPCore.inf 
b/ArmPlatformPkg/PrePi/PeiMPCore.inf
index 8be222893e2a..9c5da0d42a7b 100644
--- a/ArmPlatformPkg/PrePi/PeiMPCore.inf
+++ b/ArmPlatformPkg/PrePi/PeiMPCore.inf
@@ -15,6 +15,7 @@ [Defines]
   VERSION_STRING = 1.0
 
 [Sources]
+  PrePi.h
   PrePi.c
   MainMPCore.c
 
diff --git a/ArmPlatformPkg/PrePi/PeiUniCore.inf 
b/ArmPlatformPkg/PrePi/PeiUniCore.inf
index 95919b784185..ee9b05b25337 100644
--- a/ArmPlatformPkg/PrePi/PeiUniCore.inf
+++ b/ArmPlatformPkg/PrePi/PeiUniCore.inf
@@ -15,6 +15,7 @@ [Defines]
   VERSION_STRING = 1.0
 
 [Sources]
+  PrePi.h
   PrePi.c
   MainUniCore.c
 
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#46643): https://edk2.groups.io/g/devel/message/46643
Mute This Topic: https://groups.io/mt/33090510/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [edk2-platforms: PATCH v2 1/1] Platform/Rpi3: Add compatible property to the "usb" Device Tree node

2019-08-29 Thread Pete Batard

Hi Leif,

On 2019.08.29 14:54, Leif Lindholm wrote:

On Fri, Aug 23, 2019 at 01:20:50PM +0100, Pete Batard wrote:

Some Linux kernels (e.g. Debian) require "bcm,bcm2835-usb" to be present in


Is the typo here or in the code? ('bcm,' vs. 'brcm,')


Sorry, should have been 'brcm,bcm2835-usb' above.

As mentioned in the cover letter, we're basically adding to the 
compatible string list so that:

  compatible = "brcm,bcm2708-usb";
becomes:
  compatible = "brcm,bcm2708-usb", "brcm,bcm2835-usb";

So the part before the comma should always be "brcm", and it's only the 
part after that should be "bcm" (which, alas, makes it easy to introduce 
typos).


In other words, the typo is in the commit message only.

I did validate the changes proposed by this patch on real hardware, so I 
can vouch for the code being correct, insofar as the compatible strings 
there are concerned.



If here, I can fix up on committing.


If you can fix the typo in the commit message, that would be great.

Regards,

/Pete



/
 Leif


the list of compatible properties for the "usb" node, else they are unable
to handle some USB devices.

This patch ensures that the compatible property is added if not present.

Signed-off-by: Pete Batard 
---
  Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c | 75 
  1 file changed, 75 insertions(+)

diff --git a/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c 
b/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c
index 45ffe2e394a2..eb8048930c30 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c
+++ b/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c
@@ -135,6 +135,76 @@ UpdateMacAddress (
return EFI_SUCCESS;
  }
  
+//

+// Add "bcm2835-usb" to the USB compatible property list, if not present.
+// Required because some Linux kernels can't handle USB devices otherwise.
+//
+STATIC
+EFI_STATUS
+AddUsbCompatibleProperty (
+  VOID
+  )
+{
+  CONST CHAR8   Prop[]= "brcm,bcm2708-usb";
+  CONST CHAR8   NewProp[] = "brcm,bcm2835-usb";
+  CONST CHAR8   *List;
+  CHAR8 *NewList;
+  INT32 ListSize;
+  INTN  Node;
+  INTN  Retval;
+
+  // Locate the node that the 'usb' alias refers to
+  Node = fdt_path_offset (mFdtImage, "usb");
+  if (Node < 0) {
+DEBUG ((DEBUG_ERROR, "%a: failed to locate 'usb' alias\n", __FUNCTION__));
+return EFI_NOT_FOUND;
+  }
+
+  // Get the property list. This is a list of NUL terminated strings.
+  List = fdt_getprop (mFdtImage, Node, "compatible", );
+  if (List == NULL) {
+DEBUG ((DEBUG_ERROR, "%a: failed to locate properties\n", __FUNCTION__));
+return EFI_NOT_FOUND;
+  }
+
+  // Check if the compatible value we plan to add is already present
+  if (fdt_stringlist_contains (List, ListSize, NewProp)) {
+DEBUG ((DEBUG_INFO, "%a: property '%a' is already set.\n",
+  __FUNCTION__, NewProp));
+return EFI_SUCCESS;
+  }
+
+  // Make sure the compatible device is what we expect
+  if (!fdt_stringlist_contains (List, ListSize, Prop)) {
+DEBUG ((DEBUG_ERROR, "%a: property '%a' is missing!\n",
+  __FUNCTION__, Prop));
+return EFI_NOT_FOUND;
+  }
+
+  // Add the new NUL terminated entry to our list
+  DEBUG ((DEBUG_INFO, "%a: adding '%a' to the properties\n",
+__FUNCTION__, NewProp));
+
+  NewList = AllocatePool (ListSize + sizeof (NewProp));
+  if (NewList == NULL) {
+DEBUG ((DEBUG_ERROR, "%a: failed to allocate memory\n", __FUNCTION__));
+return EFI_OUT_OF_RESOURCES;;
+  }
+  CopyMem (NewList, List, ListSize);
+  CopyMem ([ListSize], NewProp, sizeof (NewProp));
+
+  Retval = fdt_setprop (mFdtImage, Node, "compatible", NewList,
+ ListSize + sizeof (NewProp));
+  FreePool (NewList);
+  if (Retval != 0) {
+DEBUG ((DEBUG_ERROR, "%a: failed to update properties (%d)\n",
+  __FUNCTION__, Retval));
+return EFI_NOT_FOUND;
+  }
+
+  return EFI_SUCCESS;
+}
+
  STATIC
  EFI_STATUS
  CleanMemoryNodes (
@@ -486,6 +556,11 @@ FdtDxeInitialize (
  Print (L"Failed to update MAC address: %r\n", Status);
}
  
+  Status = AddUsbCompatibleProperty ();

+  if (EFI_ERROR (Status)) {
+Print (L"Failed to update USB compatible properties: %r\n", Status);
+  }
+
if (Internal) {
  /*
   * A GPU-provided DTB already has the full command line.
--
2.21.0.windows.1




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#46573): https://edk2.groups.io/g/devel/message/46573
Mute This Topic: https://groups.io/mt/33000474/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 0/1] Platform/Rpi3: Add compatible property to the "usb" Device Tree node

2019-08-23 Thread Pete Batard
(v2 as the previous patch had a FreePool call missing).

The following patch adds automatic the insertion of "bcm,bcm2835-usb" into the
"usb" Device Tree node for the Raspberry Pi 3, if not already present.

In terms of DTS structure, this patch basically alters:
  compatible = "brcm,bcm2708-usb";
to:
  compatible = "brcm,bcm2708-usb", "brcm,bcm2835-usb";

The reason we require this is because the official DT published by the Raspberry
Pi Foundation (https://github.com/raspberrypi/firmware/tree/master/boot) only
lists "brcm,bcm2708-usb" as a compatible property, and some Linux kernels, such
as the one used by Debian, require "bcm,bcm2835-usb" to also be listed in order
to handle USB devices.

For instance, if you don't have "bcm,bcm2835-usb", you may find that the USB
keyboards are unresponsive with the Debian installer.

Also, once this patch has been applied, we should be able to replace the Device
Tree blobs we currently have in edk2-non-osi for the RPi3 platform (that have
been manually modified to have "bcm,bcm2835-usb") with the untouched ones from
the Raspberry Pi Foundation. I will therefore send a patch to that effect once
these changes have been merged.

Pete Batard (1):
  Platform/Rpi3: Add compatible property to the "usb" Device Tree node

 Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c | 75 
 1 file changed, 75 insertions(+)

-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#46299): https://edk2.groups.io/g/devel/message/46299
Mute This Topic: https://groups.io/mt/33000473/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 1/1] Platform/Rpi3: Add compatible property to the "usb" Device Tree node

2019-08-23 Thread Pete Batard
Some Linux kernels (e.g. Debian) require "bcm,bcm2835-usb" to be present in
the list of compatible properties for the "usb" node, else they are unable
to handle some USB devices.

This patch ensures that the compatible property is added if not present.

Signed-off-by: Pete Batard 
---
 Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c | 75 
 1 file changed, 75 insertions(+)

diff --git a/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c 
b/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c
index 45ffe2e394a2..eb8048930c30 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c
+++ b/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c
@@ -135,6 +135,76 @@ UpdateMacAddress (
   return EFI_SUCCESS;
 }
 
+//
+// Add "bcm2835-usb" to the USB compatible property list, if not present.
+// Required because some Linux kernels can't handle USB devices otherwise.
+//
+STATIC
+EFI_STATUS
+AddUsbCompatibleProperty (
+  VOID
+  )
+{
+  CONST CHAR8   Prop[]= "brcm,bcm2708-usb";
+  CONST CHAR8   NewProp[] = "brcm,bcm2835-usb";
+  CONST CHAR8   *List;
+  CHAR8 *NewList;
+  INT32 ListSize;
+  INTN  Node;
+  INTN  Retval;
+
+  // Locate the node that the 'usb' alias refers to
+  Node = fdt_path_offset (mFdtImage, "usb");
+  if (Node < 0) {
+DEBUG ((DEBUG_ERROR, "%a: failed to locate 'usb' alias\n", __FUNCTION__));
+return EFI_NOT_FOUND;
+  }
+
+  // Get the property list. This is a list of NUL terminated strings.
+  List = fdt_getprop (mFdtImage, Node, "compatible", );
+  if (List == NULL) {
+DEBUG ((DEBUG_ERROR, "%a: failed to locate properties\n", __FUNCTION__));
+return EFI_NOT_FOUND;
+  }
+
+  // Check if the compatible value we plan to add is already present
+  if (fdt_stringlist_contains (List, ListSize, NewProp)) {
+DEBUG ((DEBUG_INFO, "%a: property '%a' is already set.\n",
+  __FUNCTION__, NewProp));
+return EFI_SUCCESS;
+  }
+
+  // Make sure the compatible device is what we expect
+  if (!fdt_stringlist_contains (List, ListSize, Prop)) {
+DEBUG ((DEBUG_ERROR, "%a: property '%a' is missing!\n",
+  __FUNCTION__, Prop));
+return EFI_NOT_FOUND;
+  }
+
+  // Add the new NUL terminated entry to our list
+  DEBUG ((DEBUG_INFO, "%a: adding '%a' to the properties\n",
+__FUNCTION__, NewProp));
+
+  NewList = AllocatePool (ListSize + sizeof (NewProp));
+  if (NewList == NULL) {
+DEBUG ((DEBUG_ERROR, "%a: failed to allocate memory\n", __FUNCTION__));
+return EFI_OUT_OF_RESOURCES;;
+  }
+  CopyMem (NewList, List, ListSize);
+  CopyMem ([ListSize], NewProp, sizeof (NewProp));
+
+  Retval = fdt_setprop (mFdtImage, Node, "compatible", NewList,
+ ListSize + sizeof (NewProp));
+  FreePool (NewList);
+  if (Retval != 0) {
+DEBUG ((DEBUG_ERROR, "%a: failed to update properties (%d)\n",
+  __FUNCTION__, Retval));
+return EFI_NOT_FOUND;
+  }
+
+  return EFI_SUCCESS;
+}
+
 STATIC
 EFI_STATUS
 CleanMemoryNodes (
@@ -486,6 +556,11 @@ FdtDxeInitialize (
 Print (L"Failed to update MAC address: %r\n", Status);
   }
 
+  Status = AddUsbCompatibleProperty ();
+  if (EFI_ERROR (Status)) {
+Print (L"Failed to update USB compatible properties: %r\n", Status);
+  }
+
   if (Internal) {
 /*
  * A GPU-provided DTB already has the full command line.
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#46300): https://edk2.groups.io/g/devel/message/46300
Mute This Topic: https://groups.io/mt/33000474/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 1/1] Platform/Rpi3: Add compatible property to the "usb" Device Tree node

2019-08-23 Thread Pete Batard
Some Linux kernels (e.g. Debian) require "bcm,bcm2835-usb" to be present in
the list of compatible properties for the "usb" node, else they are unable
to handle some USB devices.

This patch ensures that the compatible property is added if not present.

Signed-off-by: Pete Batard 
---
 Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c | 74 
 1 file changed, 74 insertions(+)

diff --git a/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c 
b/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c
index 45ffe2e394a2..399a48430457 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c
+++ b/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c
@@ -135,6 +135,75 @@ UpdateMacAddress (
   return EFI_SUCCESS;
 }
 
+//
+// Add "bcm2835-usb" to the USB compatible property list, if not present.
+// Required because some Linux kernels can't handle USB devices otherwise.
+//
+STATIC
+EFI_STATUS
+AddUsbCompatibleProperty (
+  VOID
+  )
+{
+  CONST CHAR8   Prop[]= "brcm,bcm2708-usb";
+  CONST CHAR8   NewProp[] = "brcm,bcm2835-usb";
+  CONST CHAR8   *List;
+  CHAR8 *NewList;
+  INT32 ListSize;
+  INTN  Node;
+  INTN  Retval;
+
+  // Locate the node that the 'usb' alias refers to
+  Node = fdt_path_offset (mFdtImage, "usb");
+  if (Node < 0) {
+DEBUG ((DEBUG_ERROR, "%a: failed to locate 'usb' alias\n", __FUNCTION__));
+return EFI_NOT_FOUND;
+  }
+
+  // Get the property list. This is a list of NUL terminated strings.
+  List = fdt_getprop (mFdtImage, Node, "compatible", );
+  if (List == NULL) {
+DEBUG ((DEBUG_ERROR, "%a: failed to locate properties\n", __FUNCTION__));
+return EFI_NOT_FOUND;
+  }
+
+  // Check if the compatible value we plan to add is already present
+  if (fdt_stringlist_contains (List, ListSize, NewProp)) {
+DEBUG ((DEBUG_INFO, "%a: property '%a' is already set.\n",
+  __FUNCTION__, NewProp));
+return EFI_SUCCESS;
+  }
+
+  // Make sure the compatible device is what we expect
+  if (!fdt_stringlist_contains (List, ListSize, Prop)) {
+DEBUG ((DEBUG_ERROR, "%a: property '%a' is missing!\n",
+  __FUNCTION__, Prop));
+return EFI_NOT_FOUND;
+  }
+
+  // Add the new NUL terminated entry to our list
+  DEBUG ((DEBUG_INFO, "%a: adding '%a' to the properties\n",
+__FUNCTION__, NewProp));
+
+  NewList = AllocatePool (ListSize + sizeof (NewProp));
+  if (NewList == NULL) {
+DEBUG ((DEBUG_ERROR, "%a: failed to allocate memory\n", __FUNCTION__));
+return EFI_OUT_OF_RESOURCES;;
+  }
+  CopyMem (NewList, List, ListSize);
+  CopyMem ([ListSize], NewProp, sizeof (NewProp));
+
+  Retval = fdt_setprop (mFdtImage, Node, "compatible", NewList,
+ ListSize + sizeof (NewProp));
+  if (Retval != 0) {
+DEBUG ((DEBUG_ERROR, "%a: failed to update properties (%d)\n",
+  __FUNCTION__, Retval));
+return EFI_NOT_FOUND;
+  }
+
+  return EFI_SUCCESS;
+}
+
 STATIC
 EFI_STATUS
 CleanMemoryNodes (
@@ -486,6 +555,11 @@ FdtDxeInitialize (
 Print (L"Failed to update MAC address: %r\n", Status);
   }
 
+  Status = AddUsbCompatibleProperty ();
+  if (EFI_ERROR (Status)) {
+Print (L"Failed to update USB compatible properties: %r\n", Status);
+  }
+
   if (Internal) {
 /*
  * A GPU-provided DTB already has the full command line.
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#46298): https://edk2.groups.io/g/devel/message/46298
Mute This Topic: https://groups.io/mt/33000395/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 0/1] Platform/Rpi3: Add compatible property to the "usb" Device Tree node

2019-08-23 Thread Pete Batard
The following patch adds automatic the insertion of "bcm,bcm2835-usb" into the
"usb" Device Tree node for the Raspberry Pi 3, if not already present.

In terms of DTS structure, this patch basically alters:
  compatible = "brcm,bcm2708-usb";
to:
  compatible = "brcm,bcm2708-usb", "brcm,bcm2835-usb";

The reason we require this is because the official DT published by the Raspberry
Pi Foundation (https://github.com/raspberrypi/firmware/tree/master/boot) only
lists "brcm,bcm2708-usb" as a compatible property, and some Linux kernels, such
as the one used by Debian, require "bcm,bcm2835-usb" to also be listed in order
to handle USB devices.

For instance, if you don't have "bcm,bcm2835-usb", you may find that the USB
keyboards are unresponsive with the Debian installer.

Also, once this patch has been applied, we should be able to replace the Device
Tree blobs we currently have in edk2-non-osi for the RPi3 platform (that have
been manually modified to have "bcm,bcm2835-usb") with the untouched ones from
the Raspberry Pi Foundation. I will therefore send a patch to that effect once
these changes have been merged.

Pete Batard (1):
  Platform/Rpi3: Add compatible property to the "usb" Device Tree node

 Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c | 74 
 1 file changed, 74 insertions(+)

-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#46297): https://edk2.groups.io/g/devel/message/46297
Mute This Topic: https://groups.io/mt/33000394/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 0/2] Platforms/RPi3: Device Tree driver improvements

2019-08-16 Thread Pete Batard
Changes from v1:
- Break down DEBUB output embellishments from the other code changes.
- Use GUIDs that are explicitly named after each platform/model rather than
  generic ones.
- Drop the use of a GUID table/index and use a single GUID variable instead.
- Add additional fallback in case the required internal Device Tree cannot
  be located (e.g. missing from the FDF).
- Ensures that all of the Device Tree selection and fallback can be set up
  in the .dec (FdtDxe reusability).
- Add premilinary Raspberry Pi 4 support (FdtDxe reusability).

Note: Since the changes required to support the Raspberry Pi 4 are a direct
byproduct of the changes required for multiple Device Tree support, I did
not feel the need to break them down into a separate patch.

Pete Batard (2):
  Platforms/RPi3: Improve debug output in FdtDxe
  Platforms/RPi3: Add multiple embedded Device Tree selection

 Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c   | 78 +++-
 Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.inf |  5 +-
 Platform/RaspberryPi/RPi3/RPi3.dec  |  8 +-
 Platform/RaspberryPi/RPi3/RPi3.fdf  |  6 +-
 4 files changed, 77 insertions(+), 20 deletions(-)

-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#45813): https://edk2.groups.io/g/devel/message/45813
Mute This Topic: https://groups.io/mt/32896985/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 2/2] Platforms/RPi3: Add multiple embedded Device Tree selection

2019-08-16 Thread Pete Batard
The Raspberry Pi 3 platform currently has 2 different models, each with a
different Device Tree. Rather than embedding a single one, and requiring
users to manually provide the other, this patch ensures that we now embed
both and and serve the relevant one at runtime.

This patch also adds support for the Raspberry Pi 4 in FdtDxe.

Signed-off-by: Pete Batard 
---
 Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c   | 56 +---
 Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.inf |  5 +-
 Platform/RaspberryPi/RPi3/RPi3.dec  |  8 ++-
 Platform/RaspberryPi/RPi3/RPi3.fdf  |  6 ++-
 4 files changed, 66 insertions(+), 9 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c 
b/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c
index da99ef9535c8..45ffe2e394a2 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c
+++ b/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c
@@ -366,9 +366,11 @@ FdtDxeInitialize (
   )
 {
   EFI_STATUS Status;
+  EFI_GUID   *FdtGuid;
   VOID   *FdtImage;
   UINTN  FdtSize;
   INT32  Retval;
+  UINT32 BoardRevision;
   BOOLEANInternal;
 
   Status = gBS->LocateProtocol (, NULL,
@@ -386,16 +388,58 @@ FdtDxeInitialize (
 DEBUG ((DEBUG_INFO, "Device Tree passed via config.txt (0x%lx bytes)\n", 
FdtSize));
 Status = EFI_SUCCESS;
   } else {
+/*
+ * Use one of the embedded FDT's.
+ */
 Internal = TRUE;
 DEBUG ((DEBUG_INFO, "No/Bad Device Tree found at address 0x%p (%a), "
-  "trying internal one...\n", FdtImage, fdt_strerror (Retval)));
-Status = GetSectionFromAnyFv (, EFI_SECTION_RAW, 0,
-   , );
-if (Status == EFI_SUCCESS) {
-  if (fdt_check_header (FdtImage) != 0) {
-Status = EFI_INCOMPATIBLE_VERSION;
+  "looking up internal one...\n", FdtImage, fdt_strerror (Retval)));
+/*
+ * Query the board revision to differentiate between models.
+ */
+Status = mFwProtocol->GetModelRevision ();
+if (EFI_ERROR (Status)) {
+  DEBUG ((DEBUG_ERROR, "Failed to get board type: %r\n", Status));
+  DEBUG ((DEBUG_INFO, "Using default internal Device Tree\n"));
+  FdtGuid = 
+} else {
+  // 
www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md
+  switch ((BoardRevision >> 4) & 0xFF) {
+  case 0x08:
+DEBUG ((DEBUG_INFO, "Using Raspberry Pi 3 Model B internal Device 
Tree\n"));
+FdtGuid = 
+break;
+  case 0x0D:
+DEBUG ((DEBUG_INFO, "Using Raspberry Pi 3 Model B+ internal Device 
Tree\n"));
+FdtGuid = 
+break;
+  case 0x11:
+DEBUG ((DEBUG_INFO, "Using Raspberry Pi 4 Model B internal Device 
Tree\n"));
+FdtGuid = 
+break;
+  default:
+DEBUG ((DEBUG_INFO, "Using default internal Device Tree\n"));
+FdtGuid = 
+break;
   }
 }
+do {
+  Status = GetSectionFromAnyFv (FdtGuid, EFI_SECTION_RAW, 0, , 
);
+  if (Status == EFI_SUCCESS) {
+if (fdt_check_header (FdtImage) != 0) {
+  Status = EFI_INCOMPATIBLE_VERSION;
+}
+  }
+  // No retry needed if we are successful or are dealing with the default 
Fdt.
+  if ( (Status == EFI_SUCCESS) ||
+   (CompareGuid (FdtGuid, )) )
+break;
+  // Otherwise, try one more time with the default Fdt. An example of this
+  // is if we detected a non-default Fdt, that isn't included in the FDF.
+  DEBUG ((DEBUG_INFO, "Internal Device Tree was not found for this 
platform, "
+"falling back to default...\n"));
+  FdtGuid = 
+} while (1);
   }
 
   if (EFI_ERROR (Status)) {
diff --git a/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.inf 
b/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.inf
index 5b0b1a09f374..570b05b62564 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.inf
+++ b/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.inf
@@ -35,7 +35,10 @@ [LibraryClasses]
 
 [Guids]
   gFdtTableGuid
-  gRaspberryPiFdtFileGuid
+  gRaspberryPi3ModelBFdtGuid
+  gRaspberryPi3ModelBPlusFdtGuid
+  gRaspberryPi4ModelBFdtGuid
+  gRaspberryPiDefaultFdtGuid
 
 [Protocols]
   gRaspberryPiFirmwareProtocolGuid  ## CONSUMES
diff --git a/Platform/RaspberryPi/RPi3/RPi3.dec 
b/Platform/RaspberryPi/RPi3/RPi3.dec
index 22de439fde8f..d2a813417648 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.dec
+++ b/Platform/RaspberryPi/RPi3/RPi3.dec
@@ -24,9 +24,15 @@ [Protocols]
 
 [Guids]
   gRaspberryPiTokenSpaceGuid = {0xCD7CC258, 0x31DB, 0x11E6, {0x9F, 0xD3, 0x63, 
0xB0, 0xB8, 0xEE, 0xD6, 0xB5}}
-  gRaspberryPiFdtFileGuid = {0xDF5DA223, 0x1D27, 0x47C3, { 0x8D, 0x1B, 0x9A, 
0x41, 0xB5, 0x5A, 0x18, 0xBC}}
   gRaspberryPiEventResetGuid = {0xCD7CC258, 0x31DB, 0x11E6, {0x9F, 0xD3, 0x63, 
0xB4, 0xB4, 0xE4, 0xD4, 0xB4}}
   gConfigDxeFormSe

[edk2-devel] [edk2-platforms: PATCH v2 1/2] Platforms/RPi3: Improve debug output in FdtDxe

2019-08-16 Thread Pete Batard
Harmonize messages, avoid acronyms and provide human readable status codes.

Signed-off-by: Pete Batard 
---
 Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c | 24 ++--
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c 
b/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c
index c84e5b2767e2..da99ef9535c8 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c
+++ b/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c
@@ -383,12 +383,12 @@ FdtDxeInitialize (
  * Have FDT passed via config.txt.
  */
 FdtSize = fdt_totalsize (FdtImage);
-DEBUG ((DEBUG_INFO, "DTB passed via config.txt of 0x%lx bytes\n", 
FdtSize));
+DEBUG ((DEBUG_INFO, "Device Tree passed via config.txt (0x%lx bytes)\n", 
FdtSize));
 Status = EFI_SUCCESS;
   } else {
 Internal = TRUE;
-DEBUG ((DEBUG_INFO, "No/bad FDT at %p (%a), trying internal DTB...\n",
-  FdtImage, fdt_strerror (Retval)));
+DEBUG ((DEBUG_INFO, "No/Bad Device Tree found at address 0x%p (%a), "
+  "trying internal one...\n", FdtImage, fdt_strerror (Retval)));
 Status = GetSectionFromAnyFv (, EFI_SECTION_RAW, 0,
, );
 if (Status == EFI_SUCCESS) {
@@ -399,7 +399,7 @@ FdtDxeInitialize (
   }
 
   if (EFI_ERROR (Status)) {
-DEBUG ((DEBUG_ERROR, "Failed to locate device tree: %r\n", Status));
+DEBUG ((DEBUG_ERROR, "Failed to locate Device Tree: %r\n", Status));
 return Status;
   }
 
@@ -410,7 +410,7 @@ FdtDxeInitialize (
   Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesData,
   EFI_SIZE_TO_PAGES (FdtSize), 
(EFI_PHYSICAL_ADDRESS*));
   if (EFI_ERROR (Status)) {
-DEBUG ((DEBUG_ERROR, "Failed to allocate new device tree: %r\n", Status));
+DEBUG ((DEBUG_ERROR, "Failed to allocate Device Tree: %r\n", Status));
 return Status;
   }
 
@@ -419,27 +419,27 @@ FdtDxeInitialize (
 
   Status = SanitizePSCI ();
   if (EFI_ERROR (Status)) {
-Print (L"Failed to sanitize PSCI (error %d)\n", Status);
+Print (L"Failed to sanitize PSCI: %r\n", Status);
   }
 
   Status = CleanMemoryNodes ();
   if (EFI_ERROR (Status)) {
-Print (L"Failed to clean memory nodes (error %d)\n", Status);
+Print (L"Failed to clean memory nodes: %r\n", Status);
   }
 
   Status = CleanSimpleFramebuffer ();
   if (EFI_ERROR (Status)) {
-Print (L"Failed to clean frame buffer (error %d)\n", Status);
+Print (L"Failed to clean frame buffer: %r\n", Status);
   }
 
   Status = FixEthernetAliases ();
   if (EFI_ERROR (Status)) {
-Print (L"Failed to fix ethernet aliases (error %d)\n", Status);
+Print (L"Failed to fix ethernet aliases: %r\n", Status);
   }
 
   Status = UpdateMacAddress ();
   if (EFI_ERROR (Status)) {
-Print (L"Failed to update MAC address (error %d)\n", Status);
+Print (L"Failed to update MAC address: %r\n", Status);
   }
 
   if (Internal) {
@@ -448,11 +448,11 @@ FdtDxeInitialize (
  */
 Status = UpdateBootArgs ();
 if (EFI_ERROR (Status)) {
-  Print (L"Failed to update boot arguments (error %d)\n", Status);
+  Print (L"Failed to update boot arguments: %r\n", Status);
 }
   }
 
-  DEBUG ((DEBUG_INFO, "Installed FDT is at %p\n", mFdtImage));
+  DEBUG ((DEBUG_INFO, "Installed Device Tree at address 0x%p\n", mFdtImage));
   Status = gBS->InstallConfigurationTable (, mFdtImage);
   ASSERT_EFI_ERROR (Status);
 
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#45814): https://edk2.groups.io/g/devel/message/45814
Mute This Topic: https://groups.io/mt/32896986/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [edk2-platforms: PATCH 1/1] Platforms/RPi3: Add multiple embedded Device Tree selection

2019-08-15 Thread Pete Batard

Hi Leif,

On 2019.08.15 13:13, Leif Lindholm wrote:

On Mon, Aug 12, 2019 at 02:06:34PM +0100, Pete Batard wrote:

The Raspberry Pi 3 platform currently has 2 different models, each with a
different Device Tree. Rather than embedding a single one, and requiring
users to manually provide the other, this patch ensures that we now embed
both and and serve the relevant one at runtime.

Signed-off-by: Pete Batard 


Changeset looks very useful. Some style issues. And one question.

First the question: is there no practical size restriction on the
firmware image? This is a 24k increase in image size.


I thought about that too, but we still have plenty of unused payload to 
go by, which is why I've been adding stuff like the EBC driver, and now 
this, without worrying too much about the extra space taken.


For one, in the current 2 MB firmware image, we're still barely 
scratching 1.2 MB of effective data (for RELEASE. For DEBUG that's ~1.5 
MB), so we have plenty of space to add additional Device Trees, logos, 
and similar non critical data. As a matter of fact, I was almost tempted 
to have this patchset also include the Raspberry Pi 4 Device Tree, so 
that we would just have all of the DT's we might ever be interested in 
available at runtime, regardless of whether they are applicable or not 
(as this would simplify FdtDxe reuse a well GUID handling).


Also, I would expect the build process to complain loudly if we go over 
capacity.


Finally, I'm pretty sure we could relatively easily switch to a 4 MB or 
8 MB firmware image, if we start to run out of space with the current 2 
MB, since, from what I am aware of, the SoC is designed to be able to 
boot large Linux kernels directly and doesn't enforce a hardcoded limit 
on our FV size.


In other words, even if we start to regularly add a tens of KB here and 
there, it's going to take some time before we have to start to worry 
about going over capacity...



---
  Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c   | 57 
  Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.inf |  3 +-
  Platform/RaspberryPi/RPi3/RPi3.dec  |  3 +-
  Platform/RaspberryPi/RPi3/RPi3.fdf  |  6 ++-
  4 files changed, 55 insertions(+), 14 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c 
b/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c
index c84e5b2767e2..7c0ab75e7cb1 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c
+++ b/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c
@@ -20,6 +20,11 @@
  
  #include 
  
+CONST  EFI_GUID *mFdtGuid[] = {

+   ,
+   ,
+};
+
  STATIC VOID *mFdtImage;
  
  STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL   *mFwProtocol;

@@ -368,7 +373,9 @@ FdtDxeInitialize (
EFI_STATUS Status;
VOID   *FdtImage;
UINTN  FdtSize;
+  UINTN  FdtIndex;
INT32  Retval;
+  UINT32 BoardRevision;
BOOLEANInternal;
  
Status = gBS->LocateProtocol (, NULL,

@@ -383,13 +390,41 @@ FdtDxeInitialize (
   * Have FDT passed via config.txt.
   */
  FdtSize = fdt_totalsize (FdtImage);


This

-DEBUG ((DEBUG_INFO, "DTB passed via config.txt of 0x%lx bytes\n", 
FdtSize));
+DEBUG ((DEBUG_INFO, "Device Tree passed via config.txt (0x%lx bytes)\n", 
FdtSize));

looks unrelated to the changeset.


  Status = EFI_SUCCESS;
} else {
+/*
+ * Use one of the embedded FDT's.
+ */
  Internal = TRUE;


This DEBUG changes bit

-DEBUG ((DEBUG_INFO, "No/bad FDT at %p (%a), trying internal DTB...\n",
-  FdtImage, fdt_strerror (Retval)));
-Status = GetSectionFromAnyFv (, EFI_SECTION_RAW, 0,
+DEBUG ((DEBUG_INFO, "No/Bad Device Tree found at address 0x%p (%a), "
+  "looking up internal one...\n", FdtImage, fdt_strerror (Retval)));

to here looks completely unrelated to the changeset.
Which garbles the diff somewhat with regards to the functional line in
the middle..


I mentioned in the cover letter that changes were also added to 
harmonize the debug output to avoid acronyms and provide human readable 
error codes. But you're right, at the very least, these changes should 
have been mentioned in the commit message for actual patch itself, and 
are probably better off on their own.


I'll break them out as a separate patch as requested.

Regards,

/Pete




+/*
+ * Query the board revision to differentiate between models.
+ */
+Status = mFwProtocol->GetModelRevision ();
+if (EFI_ERROR (Status)) {
+  FdtIndex = 0;
+  DEBUG ((DEBUG_ERROR, "Failed to get board type: %r\n", Status));
+} else {
+  // 
www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md
+  switch ((BoardRevision >> 4) & 0xFF) {
+  case 0x

[edk2-devel] [edk2-platforms: PATCH 0/1] Platforms/RPi3: Add multiple embedded Device Tree selection

2019-08-12 Thread Pete Batard
The purpose of this patch is to enable the automatic provision of a relevant
Raspberry Pi 3 Device Tree at runtime, as there currently exists 2 models of
Raspberry Pi 3 (model B and model B+) but we only embed the Device Tree for a
single one (model B).

Obviously, the provision of only a single Device Tree is inconvenient, as it
currently forces users of the model B+ to locate and provide their own Device
Tree in config.txt, which might not be a straightforward operation. It also
adds to the number of extra files that must be copied to the boot media.

With this patch, both Device Tree binaries are embedded in the firmware, with
the relevant being served at runtime according to the detected hardware.

Note that we tried to future-proof the modified code with regards to expected
introduction of new Raspberry Pi platforms (such as the Pi 4). Therefore,
while the switch in FdtDxe.c may seem like overkill for now (with cases that
could be merged), it should make the reuse of that driver easier.

We also tried to harmonize debug output if FtdDxe (avoid acronyms and provide
human readable error codes).

Pete Batard (1):
  Platforms/RPi3: Add multiple embedded Device Tree selection

 Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c   | 54 
 Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.inf |  3 +-
 Platform/RaspberryPi/RPi3/RPi3.dec  |  3 +-
 Platform/RaspberryPi/RPi3/RPi3.fdf  |  6 ++-
 4 files changed, 52 insertions(+), 14 deletions(-)

-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#45434): https://edk2.groups.io/g/devel/message/45434
Mute This Topic: https://groups.io/mt/32840410/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 1/1] Platforms/RPi3: Add multiple embedded Device Tree selection

2019-08-12 Thread Pete Batard
The Raspberry Pi 3 platform currently has 2 different models, each with a
different Device Tree. Rather than embedding a single one, and requiring
users to manually provide the other, this patch ensures that we now embed
both and and serve the relevant one at runtime.

Signed-off-by: Pete Batard 
---
 Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c   | 57 
 Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.inf |  3 +-
 Platform/RaspberryPi/RPi3/RPi3.dec  |  3 +-
 Platform/RaspberryPi/RPi3/RPi3.fdf  |  6 ++-
 4 files changed, 55 insertions(+), 14 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c 
b/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c
index c84e5b2767e2..7c0ab75e7cb1 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c
+++ b/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c
@@ -20,6 +20,11 @@
 
 #include 
 
+CONST  EFI_GUID *mFdtGuid[] = {
+   ,
+   ,
+};
+
 STATIC VOID *mFdtImage;
 
 STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL   *mFwProtocol;
@@ -368,7 +373,9 @@ FdtDxeInitialize (
   EFI_STATUS Status;
   VOID   *FdtImage;
   UINTN  FdtSize;
+  UINTN  FdtIndex;
   INT32  Retval;
+  UINT32 BoardRevision;
   BOOLEANInternal;
 
   Status = gBS->LocateProtocol (, NULL,
@@ -383,13 +390,41 @@ FdtDxeInitialize (
  * Have FDT passed via config.txt.
  */
 FdtSize = fdt_totalsize (FdtImage);
-DEBUG ((DEBUG_INFO, "DTB passed via config.txt of 0x%lx bytes\n", 
FdtSize));
+DEBUG ((DEBUG_INFO, "Device Tree passed via config.txt (0x%lx bytes)\n", 
FdtSize));
 Status = EFI_SUCCESS;
   } else {
+/*
+ * Use one of the embedded FDT's.
+ */
 Internal = TRUE;
-DEBUG ((DEBUG_INFO, "No/bad FDT at %p (%a), trying internal DTB...\n",
-  FdtImage, fdt_strerror (Retval)));
-Status = GetSectionFromAnyFv (, EFI_SECTION_RAW, 0,
+DEBUG ((DEBUG_INFO, "No/Bad Device Tree found at address 0x%p (%a), "
+  "looking up internal one...\n", FdtImage, fdt_strerror (Retval)));
+/*
+ * Query the board revision to differentiate between models.
+ */
+Status = mFwProtocol->GetModelRevision ();
+if (EFI_ERROR (Status)) {
+  FdtIndex = 0;
+  DEBUG ((DEBUG_ERROR, "Failed to get board type: %r\n", Status));
+} else {
+  // 
www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md
+  switch ((BoardRevision >> 4) & 0xFF) {
+  case 0x08:  // Raspberry 3 Model B
+DEBUG ((DEBUG_INFO, "Using RPi3 Model B internal Device Tree\n"));
+FdtIndex = 0;
+break;
+  case 0x0D:  // Raspberry 3 Model B+
+DEBUG ((DEBUG_INFO, "Using RPi3 Model B+ internal Device Tree\n"));
+FdtIndex = 1;
+break;
+  default:
+DEBUG ((DEBUG_INFO, "Using default internal Device Tree\n"));
+FdtIndex = 0;
+break;
+  }
+}
+ASSERT (FdtIndex < ARRAY_SIZE (mFdtGuid));
+Status = GetSectionFromAnyFv (mFdtGuid[FdtIndex], EFI_SECTION_RAW, 0,
, );
 if (Status == EFI_SUCCESS) {
   if (fdt_check_header (FdtImage) != 0) {
@@ -419,27 +454,27 @@ FdtDxeInitialize (
 
   Status = SanitizePSCI ();
   if (EFI_ERROR (Status)) {
-Print (L"Failed to sanitize PSCI (error %d)\n", Status);
+Print (L"Failed to sanitize PSCI: %r\n", Status);
   }
 
   Status = CleanMemoryNodes ();
   if (EFI_ERROR (Status)) {
-Print (L"Failed to clean memory nodes (error %d)\n", Status);
+Print (L"Failed to clean memory nodes: %r\n", Status);
   }
 
   Status = CleanSimpleFramebuffer ();
   if (EFI_ERROR (Status)) {
-Print (L"Failed to clean frame buffer (error %d)\n", Status);
+Print (L"Failed to clean frame buffer: %r\n", Status);
   }
 
   Status = FixEthernetAliases ();
   if (EFI_ERROR (Status)) {
-Print (L"Failed to fix ethernet aliases (error %d)\n", Status);
+Print (L"Failed to fix ethernet aliases: %r\n", Status);
   }
 
   Status = UpdateMacAddress ();
   if (EFI_ERROR (Status)) {
-Print (L"Failed to update MAC address (error %d)\n", Status);
+Print (L"Failed to update MAC address: %r\n", Status);
   }
 
   if (Internal) {
@@ -448,11 +483,11 @@ FdtDxeInitialize (
  */
 Status = UpdateBootArgs ();
 if (EFI_ERROR (Status)) {
-  Print (L"Failed to update boot arguments (error %d)\n", Status);
+  Print (L"Failed to update boot arguments: %r\n", Status);
 }
   }
 
-  DEBUG ((DEBUG_INFO, "Installed FDT is at %p\n", mFdtImage));
+  DEBUG ((DEBUG_INFO, "Installed Device Tree at address 0x%p\n

[edk2-devel] [edk2-platforms: PATCH v3 0/1] Platform/RPi3: Add Debian 10 installation in Systems.md

2019-08-08 Thread Pete Batard
Changes from v2:
- Use "on-CPU" rather than "ondie".
- Make sure the options to force FAT16 are provided for both Windows and Linux.
- Provide a maximum size for FAT16 and add a forward references to the 
additional
  notes and the `fdisk` fixup, for people who might still choose FAT32.

Pete Batard (1):
  Platform/RPi3: Add Debian 10 installation in Systems.md

 Platform/RaspberryPi/RPi3/RPi3.fdf   |   2 +-
 Platform/RaspberryPi/RPi3/Readme.md  |   4 +-
 Platform/RaspberryPi/RPi3/Systems.md | 127 +++-
 3 files changed, 126 insertions(+), 7 deletions(-)

-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#45175): https://edk2.groups.io/g/devel/message/45175
Mute This Topic: https://groups.io/mt/32797835/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 v3 1/1] Platform/RPi3: Add Debian 10 installation in Systems.md

2019-08-08 Thread Pete Batard
This documents the installation of vanilla Debian 10.0 ARM64 (netinst),
which we validated for both Model B and Model B+.
Also fix an erroneous reference in an RPi3.fdf comment.

Signed-off-by: Pete Batard 
---
 Platform/RaspberryPi/RPi3/RPi3.fdf   |   2 +-
 Platform/RaspberryPi/RPi3/Readme.md  |   4 +-
 Platform/RaspberryPi/RPi3/Systems.md | 127 +++-
 3 files changed, 126 insertions(+), 7 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/RPi3.fdf 
b/Platform/RaspberryPi/RPi3/RPi3.fdf
index c7c3f7a2ab8c..c62d649834c7 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.fdf
+++ b/Platform/RaspberryPi/RPi3/RPi3.fdf
@@ -300,7 +300,7 @@ [FV.FvMain]
   INF Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/LogoDxe/LogoDxe.inf
 
   #
-  # FDT (GUID matches mRaspberryPiFfsFileGuid in RaspberryPiPlatformDxe)
+  # FDT (GUID matches gRaspberryPiFdtFileGuid in FdtDxe)
   #
   FILE FREEFORM = DF5DA223-1D27-47C3-8D1B-9A41B55A18BC {
 SECTION RAW = 
Platform/RaspberryPi/$(PLATFORM_NAME)/DeviceTree/bcm2710-rpi-3-b.dtb
diff --git a/Platform/RaspberryPi/RPi3/Readme.md 
b/Platform/RaspberryPi/RPi3/Readme.md
index 624f3a8d287a..797da1bab4a9 100644
--- a/Platform/RaspberryPi/RPi3/Readme.md
+++ b/Platform/RaspberryPi/RPi3/Readme.md
@@ -18,8 +18,8 @@ Raspberry Pi is a trademark of the [Raspberry Pi 
Foundation](http://www.raspberr
 
 This firmware, that has been validated to compile against the current
 
[edk2](https://github.com/tianocore/edk2)/[edk2-platforms](https://github.com/tianocore/edk2-platforms),
-should be able to boot Linux (SUSE, Ubuntu), NetBSD, FreeBSD as well as 
Windows 10 ARM64
-(full GUI version).
+should be able to boot Linux (Debian, Ubuntu, SUSE), NetBSD, FreeBSD as well 
as Windows
+10 ARM64 (full GUI version).
 
 It also provides support for ATF ([Arm Trusted 
Platform](https://github.com/ARM-software/arm-trusted-firmware)).
 
diff --git a/Platform/RaspberryPi/RPi3/Systems.md 
b/Platform/RaspberryPi/RPi3/Systems.md
index f6410eb25f0d..3a313c29cbdc 100644
--- a/Platform/RaspberryPi/RPi3/Systems.md
+++ b/Platform/RaspberryPi/RPi3/Systems.md
@@ -1,5 +1,128 @@
 # Tested Operating Systems
 
+## Debian
+
+[Debian 10](https://cdimage.debian.org/debian-cd/current/arm64/iso-cd/) 
netinst has been
+tested and confirmed to work, both on the Model B and Model B+, including 
installation in
+either wired or wireless mode.
+
+Below are steps you can follow to install Debian 10 onto an SD card:
+* Partition the media as MBR and create a ~300 MB partition on it with MBR 
type `0x0e`.
+  __Note:__ Make sure that the partition scheme is MBR (not GPT) and the type 
`0x0e` (not
+  `0xef` for instance), as the on-CPU Broadcom bootloader supports neither the 
GPT scheme
+  nor the ESP MBR type.
+* Set the partition as active/bootable. This is needed as the Debian partition 
manager can
+  not detect it as ESP otherwise, which we need for GRUB installation. If 
using `fdisk` on
+  Linux, you can use the `a` command to set a partition as active. On Windows, 
you can use
+  `diskpart` and then type `active` after selecting the relevant disk and 
partition.
+* Format the partition as FAT. Here you should make sure that you use FAT16 
over FAT32 else
+  the Debian partition manager may not automatically detect the partition as 
ESP. If you
+  are using Windows `diskpart` then `format fs=fat quick` will format a drive 
to FAT16. On
+  Linux, the equivalent command would be `mkfs.vfat -F 16 /dev/`. 
As long as
+  the partition is smaller than 2 GB, the use of FAT16 over FAT32 should not 
be a problem.
+  Note that it is also possible to use FAT32, but you will probably have to 
invoke `fdisk`
+  before rebooting, as shown in the _Additional Notes_ below, to reset the 
partition type.
+* Copy the UEFI firmware files (`RPI_EFI.fd`, `bootcode.bin`, `fixup.dat` and 
`start.elf`)
+  as well as an appropriate `config.txt` onto the FAT partition. If needed you 
can download
+  the non UEFI binary files from 
https://github.com/raspberrypi/firmware/tree/master/boot.
+* (Optional) If you plan to install through WiFi, you will need to download 
relevant
+  non-free  WLAN firmware binaries from your WLAN interface 
(`brcmfmac43430-sdio.txt` and
+  `brcmfmac43430-sdio.bin` for a Raspberry Pi 3 Model B, 
`brcmfmac43455-sdio.txt` and
+  `brcmfmac43455-sdio.bin` for a Raspberry Pi 3 Model B+). You may also want 
to obtain the
+  relevant `.clm_blob` (`brcmfmac43430-sdio.clm_blob` or 
`brcmfmac43455-sdio.clm_blob`),
+  though wireless networking should work even if you do not provide these 
files. Copy these
+  files either at the root of your FAT partition or into a `firmware/` 
directory there.
+* Download the latest `debian-##.#.#-arm64-netinst.iso` from
+  https://cdimage.debian.org/debian-cd/current/arm64/iso-cd/
+* Extract the full content of the ISO onto the FAT partition you created.
+* Insert the media and power up the Raspberry Pi device.
+* On the GRUB menu select `Install` and let the Debian Installer process start.
+  __Note

Re: [edk2-devel] [edk2-platforms: PATCH v2 1/1] Platform/RPi3: Add Debian 10 installation in Systems.md

2019-08-07 Thread Pete Batard

Hi Leif,

On 2019.08.06 18:25, Leif Lindholm wrote:

Minor suggestions inline:

On Thu, Jul 25, 2019 at 04:22:48PM +0100, Pete Batard wrote:

This documents the installation of vanilla Debian 10.0 ARM64 (netinst),
which we validated for both Model B and Model B+.
Also fix an erroneous reference in an RPi3.fdf comment.

Signed-off-by: Pete Batard 
---
  Platform/RaspberryPi/RPi3/RPi3.fdf   |   2 +-
  Platform/RaspberryPi/RPi3/Readme.md  |   4 +-
  Platform/RaspberryPi/RPi3/Systems.md | 124 +++-
  3 files changed, 123 insertions(+), 7 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/RPi3.fdf 
b/Platform/RaspberryPi/RPi3/RPi3.fdf
index c7c3f7a2ab8c..c62d649834c7 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.fdf
+++ b/Platform/RaspberryPi/RPi3/RPi3.fdf
@@ -300,7 +300,7 @@ [FV.FvMain]
INF Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/LogoDxe/LogoDxe.inf
  
#

-  # FDT (GUID matches mRaspberryPiFfsFileGuid in RaspberryPiPlatformDxe)
+  # FDT (GUID matches gRaspberryPiFdtFileGuid in FdtDxe)
#
FILE FREEFORM = DF5DA223-1D27-47C3-8D1B-9A41B55A18BC {
  SECTION RAW = 
Platform/RaspberryPi/$(PLATFORM_NAME)/DeviceTree/bcm2710-rpi-3-b.dtb
diff --git a/Platform/RaspberryPi/RPi3/Readme.md 
b/Platform/RaspberryPi/RPi3/Readme.md
index 624f3a8d287a..797da1bab4a9 100644
--- a/Platform/RaspberryPi/RPi3/Readme.md
+++ b/Platform/RaspberryPi/RPi3/Readme.md
@@ -18,8 +18,8 @@ Raspberry Pi is a trademark of the [Raspberry Pi 
Foundation](http://www.raspberr
  
  This firmware, that has been validated to compile against the current

  
[edk2](https://github.com/tianocore/edk2)/[edk2-platforms](https://github.com/tianocore/edk2-platforms),
-should be able to boot Linux (SUSE, Ubuntu), NetBSD, FreeBSD as well as 
Windows 10 ARM64
-(full GUI version).
+should be able to boot Linux (Debian, Ubuntu, SUSE), NetBSD, FreeBSD as well 
as Windows
+10 ARM64 (full GUI version).
  
  It also provides support for ATF ([Arm Trusted Platform](https://github.com/ARM-software/arm-trusted-firmware)).
  
diff --git a/Platform/RaspberryPi/RPi3/Systems.md b/Platform/RaspberryPi/RPi3/Systems.md

index f6410eb25f0d..4a0c6f3e4de3 100644
--- a/Platform/RaspberryPi/RPi3/Systems.md
+++ b/Platform/RaspberryPi/RPi3/Systems.md
@@ -1,5 +1,125 @@
  # Tested Operating Systems
  
+## Debian

+
+[Debian 10](https://cdimage.debian.org/debian-cd/current/arm64/iso-cd/) 
netinst has been
+tested and confirmed to work, both on the Model B and Model B+, including 
installation in
+either wired or wireless mode.
+
+Below are steps you can follow to install Debian 10 onto an SD card:
+* Partition the media as MBR and create a ~300 MB partition on it with MBR 
type `0x0e`.
+  __Note:__ Make sure that the partition scheme is MBR (not GPT) and the type 
`0x0e` (not
+  `0xef` for instance), as the ondie Broadcom bootloader supports neither the 
GPT scheme nor


ondie -> on-die (or on-SoC may be even more clear to civilians).


I think I'll use "on-CPU" then, as this should be even more explicit.


+  the ESP MBR type.
+* Set the partition as active/bootable. This is needed as the Debian partition 
manager can
+  not detect it as ESP otherwise, which we need for GRUB installation. If 
using `fdisk` on
+  Linux, you can use the `a` command to set a partition as active. On Windows, 
you can use
+  `DISKPART` and then type `active` after selecting the relevant disk and 
partition.
+* Format the partition as FAT. Here again you should make sure that you use 
FAT rather than
+  FAT32 else the Debian partition manager will not detect the partition as 
ESP. If you
+  are using Windows `DISKPART` then `format fs=fat quick` should do it. On 
Linux, `mkfs.vfat`
+  with the default options should do the same as long as the partition isn't 
too large.


It would be preferable if we could have an actual number here - the
12-bit, 16-bit and 32-bit fat size switchover points are known. I
assume it is the 32-bit breakpoint (2 or 4Gb?) we want to avoid?


The switchover point actually depends of the utility, since there is 
overlap between 12, 16 and 32. But that's not actually a problem with 
diskpart on Windows as 'fs=fat' does force FAT16 so you'll get an error 
if the partition is too large and can only accommodate FAT32 (which 
should usually occur past the 2 GB point).


In other words, the only potential issue here is with Linux' mkfs.vfat. 
But there too we can add a switch (-F 16) to force FAT16, so I'll alter 
the documentation to have that, plus a note that mentions that the 
partition should be under 2 GB.


I'll also take this opportunity to stress out that the only reason we 
are trying to force FAT16 here is because the Debian installer's 
partition manager is very temperamental with regards to its detection of 
an ESP that doesn't have either the relevant GUID for GPT or type 0xef 
for MBR, none of which can be used on a Pi. There are actually cases 
where I have seen that utility also detect a FAT32 MBR partition without 
type 0

[edk2-devel] [edk2-platforms: PATCH v2 0/1] Platform/RPi3: Add Debian 10 installation in Systems.md

2019-07-25 Thread Pete Batard
Sending a v2 that fixes a few typos:
"In that is the case" -> "If that is the case"
"that you can safely ignore it by selecting" -> "that you can safely ignore by 
selecting"
"prevents the same partition to be remounted" -> "prevents the same partition 
from being remounted"

Pete Batard (1):
  Platform/RPi3: Add Debian 10 installation in Systems.md

 Platform/RaspberryPi/RPi3/RPi3.fdf   |   2 +-
 Platform/RaspberryPi/RPi3/Readme.md  |   4 +-
 Platform/RaspberryPi/RPi3/Systems.md | 124 +++-
 3 files changed, 123 insertions(+), 7 deletions(-)

-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44389): https://edk2.groups.io/g/devel/message/44389
Mute This Topic: https://groups.io/mt/32599163/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 1/1] Platform/RPi3: Add Debian 10 installation in Systems.md

2019-07-25 Thread Pete Batard
This documents the installation of vanilla Debian 10.0 ARM64 (netinst),
which we validated for both Model B and Model B+.
Also fix an erroneous reference in an RPi3.fdf comment.

Signed-off-by: Pete Batard 
---
 Platform/RaspberryPi/RPi3/RPi3.fdf   |   2 +-
 Platform/RaspberryPi/RPi3/Readme.md  |   4 +-
 Platform/RaspberryPi/RPi3/Systems.md | 124 +++-
 3 files changed, 123 insertions(+), 7 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/RPi3.fdf 
b/Platform/RaspberryPi/RPi3/RPi3.fdf
index c7c3f7a2ab8c..c62d649834c7 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.fdf
+++ b/Platform/RaspberryPi/RPi3/RPi3.fdf
@@ -300,7 +300,7 @@ [FV.FvMain]
   INF Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/LogoDxe/LogoDxe.inf
 
   #
-  # FDT (GUID matches mRaspberryPiFfsFileGuid in RaspberryPiPlatformDxe)
+  # FDT (GUID matches gRaspberryPiFdtFileGuid in FdtDxe)
   #
   FILE FREEFORM = DF5DA223-1D27-47C3-8D1B-9A41B55A18BC {
 SECTION RAW = 
Platform/RaspberryPi/$(PLATFORM_NAME)/DeviceTree/bcm2710-rpi-3-b.dtb
diff --git a/Platform/RaspberryPi/RPi3/Readme.md 
b/Platform/RaspberryPi/RPi3/Readme.md
index 624f3a8d287a..797da1bab4a9 100644
--- a/Platform/RaspberryPi/RPi3/Readme.md
+++ b/Platform/RaspberryPi/RPi3/Readme.md
@@ -18,8 +18,8 @@ Raspberry Pi is a trademark of the [Raspberry Pi 
Foundation](http://www.raspberr
 
 This firmware, that has been validated to compile against the current
 
[edk2](https://github.com/tianocore/edk2)/[edk2-platforms](https://github.com/tianocore/edk2-platforms),
-should be able to boot Linux (SUSE, Ubuntu), NetBSD, FreeBSD as well as 
Windows 10 ARM64
-(full GUI version).
+should be able to boot Linux (Debian, Ubuntu, SUSE), NetBSD, FreeBSD as well 
as Windows
+10 ARM64 (full GUI version).
 
 It also provides support for ATF ([Arm Trusted 
Platform](https://github.com/ARM-software/arm-trusted-firmware)).
 
diff --git a/Platform/RaspberryPi/RPi3/Systems.md 
b/Platform/RaspberryPi/RPi3/Systems.md
index f6410eb25f0d..4a0c6f3e4de3 100644
--- a/Platform/RaspberryPi/RPi3/Systems.md
+++ b/Platform/RaspberryPi/RPi3/Systems.md
@@ -1,5 +1,125 @@
 # Tested Operating Systems
 
+## Debian
+
+[Debian 10](https://cdimage.debian.org/debian-cd/current/arm64/iso-cd/) 
netinst has been
+tested and confirmed to work, both on the Model B and Model B+, including 
installation in
+either wired or wireless mode.
+
+Below are steps you can follow to install Debian 10 onto an SD card:
+* Partition the media as MBR and create a ~300 MB partition on it with MBR 
type `0x0e`.
+  __Note:__ Make sure that the partition scheme is MBR (not GPT) and the type 
`0x0e` (not
+  `0xef` for instance), as the ondie Broadcom bootloader supports neither the 
GPT scheme nor
+  the ESP MBR type.
+* Set the partition as active/bootable. This is needed as the Debian partition 
manager can
+  not detect it as ESP otherwise, which we need for GRUB installation. If 
using `fdisk` on
+  Linux, you can use the `a` command to set a partition as active. On Windows, 
you can use
+  `DISKPART` and then type `active` after selecting the relevant disk and 
partition.
+* Format the partition as FAT. Here again you should make sure that you use 
FAT rather than
+  FAT32 else the Debian partition manager will not detect the partition as 
ESP. If you
+  are using Windows `DISKPART` then `format fs=fat quick` should do it. On 
Linux, `mkfs.vfat`
+  with the default options should do the same as long as the partition isn't 
too large.
+* Copy the UEFI firmware files (`RPI_EFI.fd`, `bootcode.bin`, `fixup.dat` and 
`start.elf`)
+  as well as an appropriate `config.txt` onto the FAT partition. If needed you 
can download
+  the non UEFI binary files from 
https://github.com/raspberrypi/firmware/tree/master/boot.
+* (Optional) If you plan to install through WiFi, you will need to download 
relevant non-free
+   WLAN firmware binaries from your WLAN interface (`brcmfmac43430-sdio.txt` 
and
+  `brcmfmac43430-sdio.bin` for a Raspberry Pi 3 Model B, 
`brcmfmac43455-sdio.txt` and
+  `brcmfmac43455-sdio.bin` for a Raspberry Pi 3 Model B+). You may also want 
to obtain the
+  relevant `.clm_blob` (`brcmfmac43430-sdio.clm_blob` or 
`brcmfmac43455-sdio.clm_blob`),
+  though wireless networking should work even if you do not provide these 
files. Copy these
+  files either at the root of your FAT partition or into a `firmware/` 
directory there.
+* Download the latest `debian-##.#.#-arm64-netinst.iso` from
+  https://cdimage.debian.org/debian-cd/current/arm64/iso-cd/
+* Extract the full content of the ISO onto the FAT partition you created.
+* Insert the media and power up the Raspberry Pi device.
+* On the GRUB menu select `Install` and let the Debian Installer process start.
+  __Note:__ In case anything goes wrong during the install process, you can use
+  Alt-F4 to check the installation log.
+* Select your Language, Country and Keyboard and let the installer proceed 
until it reports
+  that `No Common CD-ROM drive was detected.`
+* On `Load CD

[edk2-devel] [edk2-platforms: PATCH 1/1] Platform/RPi3: Add Debian 10 installation in Systems.md

2019-07-25 Thread Pete Batard
This documents the installation of vanilla Debian 10.0 ARM64 (netinst),
which we validated for both Model B and Model B+.
Also fix an erroneous reference in an RPi3.fdf comment.

Signed-off-by: Pete Batard 
---
 Platform/RaspberryPi/RPi3/RPi3.fdf   |   2 +-
 Platform/RaspberryPi/RPi3/Readme.md  |   4 +-
 Platform/RaspberryPi/RPi3/Systems.md | 124 +++-
 3 files changed, 123 insertions(+), 7 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/RPi3.fdf 
b/Platform/RaspberryPi/RPi3/RPi3.fdf
index c7c3f7a2ab8c..c62d649834c7 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.fdf
+++ b/Platform/RaspberryPi/RPi3/RPi3.fdf
@@ -300,7 +300,7 @@ [FV.FvMain]
   INF Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/LogoDxe/LogoDxe.inf
 
   #
-  # FDT (GUID matches mRaspberryPiFfsFileGuid in RaspberryPiPlatformDxe)
+  # FDT (GUID matches gRaspberryPiFdtFileGuid in FdtDxe)
   #
   FILE FREEFORM = DF5DA223-1D27-47C3-8D1B-9A41B55A18BC {
 SECTION RAW = 
Platform/RaspberryPi/$(PLATFORM_NAME)/DeviceTree/bcm2710-rpi-3-b.dtb
diff --git a/Platform/RaspberryPi/RPi3/Readme.md 
b/Platform/RaspberryPi/RPi3/Readme.md
index 624f3a8d287a..797da1bab4a9 100644
--- a/Platform/RaspberryPi/RPi3/Readme.md
+++ b/Platform/RaspberryPi/RPi3/Readme.md
@@ -18,8 +18,8 @@ Raspberry Pi is a trademark of the [Raspberry Pi 
Foundation](http://www.raspberr
 
 This firmware, that has been validated to compile against the current
 
[edk2](https://github.com/tianocore/edk2)/[edk2-platforms](https://github.com/tianocore/edk2-platforms),
-should be able to boot Linux (SUSE, Ubuntu), NetBSD, FreeBSD as well as 
Windows 10 ARM64
-(full GUI version).
+should be able to boot Linux (Debian, Ubuntu, SUSE), NetBSD, FreeBSD as well 
as Windows
+10 ARM64 (full GUI version).
 
 It also provides support for ATF ([Arm Trusted 
Platform](https://github.com/ARM-software/arm-trusted-firmware)).
 
diff --git a/Platform/RaspberryPi/RPi3/Systems.md 
b/Platform/RaspberryPi/RPi3/Systems.md
index f6410eb25f0d..edce1aaabb29 100644
--- a/Platform/RaspberryPi/RPi3/Systems.md
+++ b/Platform/RaspberryPi/RPi3/Systems.md
@@ -1,5 +1,125 @@
 # Tested Operating Systems
 
+## Debian
+
+[Debian 10](https://cdimage.debian.org/debian-cd/current/arm64/iso-cd/) 
netinst has been
+tested and confirmed to work, both on the Model B and Model B+, including 
installation in
+either wired or wireless mode.
+
+Below are steps you can follow to install Debian 10 onto an SD card:
+* Partition the media as MBR and create a ~300 MB partition on it with MBR 
type `0x0e`.
+  __Note:__ Make sure that the partition scheme is MBR (not GPT) and the type 
`0x0e` (not
+  `0xef` for instance), as the ondie Broadcom bootloader supports neither the 
GPT scheme nor
+  the ESP MBR type.
+* Set the partition as active/bootable. This is needed as the Debian partition 
manager can
+  not detect it as ESP otherwise, which we need for GRUB installation. If 
using `fdisk` on
+  Linux, you can use the `a`  command to set a partition as active. On 
Windows, you can use
+  `DISKPART` and then type `active` after selecting the relevant disk and 
partition.
+* Format the partition as FAT. Here again you should make sure that you use 
FAT rather than
+  FAT32 else the Debian partition manager will not detect the partition as 
ESP. If you
+  are using Windows `DISKPART` then `format fs=fat quick` should do it. On 
Linux, `mkfs.vfat`
+  with the default options should do the same as long as the partition isn't 
too large.
+* Copy the UEFI firmware files (`RPI_EFI.fd`, `bootcode.bin`, `fixup.dat` and 
`start.elf`)
+  as well as an appropriate `config.txt` onto the FAT partition. If needed you 
can download
+  the non UEFI binary files from 
https://github.com/raspberrypi/firmware/tree/master/boot.
+* (Optional) If you plan to install through WiFi, you will need to download 
relevant non-free
+   WLAN firmware binaries from your WLAN interface (`brcmfmac43430-sdio.txt` 
and
+  `brcmfmac43430-sdio.bin` for a Raspberry Pi 3 Model B, 
`brcmfmac43455-sdio.txt` and
+  `brcmfmac43455-sdio.bin` for a Raspberry Pi 3 Model B+). You may also want 
to obtain the
+  relevant `.clm_blob` (`brcmfmac43430-sdio.clm_blob` or 
`brcmfmac43455-sdio.clm_blob`),
+  though wireless networking should work even if you do not provide these 
files. Copy these
+  files either at the root of your FAT partition or into a `firmware/` 
directory there.
+* Download the latest `debian-##.#.#-arm64-netinst.iso` from
+  https://cdimage.debian.org/debian-cd/current/arm64/iso-cd/
+* Extract the full content of the ISO onto the FAT partition you created.
+* Insert the media and power up the Raspberry Pi device.
+* On the GRUB menu select `Install` and let the Debian Installer process start.
+  __Note:__ In case anything goes wrong during the install process, you can use
+  Alt-F4 to check the installation log.
+* Select your Language, Country and Keyboard and let the installer proceed 
until it reports
+  that `No Common CD-ROM drive was detected.`
+* On `Load CD

Re: [edk2-devel] [edk2-platforms: PATCH 1/1] Platform/RPi3: Accept "ethernet" or "ethernet0" aliases in device tree

2019-07-23 Thread Pete Batard
Just adding a comment for one item, that isn't directly relevant to what 
direction we should take with this patch, but that clarifies where we 
got our .dtb's from.


On 2019.07.23 12:00, Michael Brown wrote:

On 23/07/2019 11:34, Leif Lindholm wrote:

On Fri, Jul 19, 2019 at 06:29:07PM +0100, Michael Brown wrote:

Older device trees tend to use the alias "ethernet".  Newer device
trees tend to use "ethernet0" since older versions of U-Boot would
skip aliases that do not include an index number.  See, for example,
Linux kernel commit 10b6c0c ("ARM: dts: bcm2835: add index to the
ethernet alias") and U-Boot commit f8e57c6 ("fdt_support: Fixup
'ethernet' aliases not ending in digits").

Accept either "ethernet" or "ethernet0" as being the alias to the node
for which the MAC address should be updated.


Why is this patch useful?
I understand the problem, but we include the .dtb from our own
edk2-non-osi tree. And it seems that device tree already provides an
alias to support both:
https://github.com/tianocore/edk2-non-osi/blob/master/Platform/RaspberryPi/RPi3/DeviceTree/bcm2710-rpi-3-b.dts 



Would it be more useful to warn loudly if "ethernet" isn't present?
(And just *replace* ethernet[0] with ethernet below.)


The device tree can also be provided by the VC4 firmware, e.g. with a 
config.txt containing e.g.


   device_tree_address=0x1
   device_tree_end=0x2
   device_tree=bcm2710-rpi-3-b-plus.dtb

It is also possible to omit the explicit "device_tree=..." and have just

   device_tree_address=0x1
   device_tree_end=0x2

This configuration will cause the VC4 firmware to automatically load the 
appropriate device tree file.  I have tested that this allows me to boot 
from a 3B or 3B+ using a single SD card image that contains all of the 
.dtb files from


   https://github.com/raspberrypi/firmware/tree/master/boot

These "official" raspberrypi-firmware .dtb files are built from the 
stock Linux kernel .dts files, and contain only "ethernet0".


Note that the .dtb's we use for this platform (in edk2-non-osi) were 
actually picked up from the URL above, then decompiled to produce a .dts 
which was then edited to fix a couple issues, as per:

https://github.com/tianocore/edk2-non-osi/blob/master/Platform/RaspberryPi/RPi3/DeviceTree/bcm2710-rpi-3-b-plus.dts#L6-L15

Most notably, unless you change
  compatible = "brcm,bcm2708-usb";
to
  compatible = "brcm,bcm2835-usb";
in the usb@7e98 section you will find your USB keyboard may not work 
during a Linux install (Tested with both the Ubuntu 18.04 and Debian 10 
installers).


Now, I am also aware that the Raspberry Pi Foundation has updated its 
official .dtb's for the Pi 3 with the release of the Pi 4, and I have 
some plans to send a patch to also update our Device Tree accordingly at 
some stage. For the record, I've been testing these updated official 
versions last week and confirmed that the keyboard issue was still present.


Regards,

/Pete


To address your specific questions:

 > Why is this patch useful?

It allows us to boot using the "official" .dtb files without any 
unexpected behaviour.


This in turn allows us to boot with the VC4 firmware automatically 
selecting the appropriate .dtb file for the hardware.  This is extremely 
useful when trying to provide a single SD card image that will work on a 
wide range of hardware.


 > Would it be more useful to warn loudly if "ethernet" isn't present?
 > (And just *replace* ethernet[0] with ethernet below.)

This would also solve the problem.  I would find it mildly surprising 
behaviour if I were debugging around it, since the "official" .dtb files 
have moved in the other direction (going from "ethernet" to 
"ethernet0"), but I would not expect it to break anything.


Another option would be to have UpdateMacAddress() ensure that both 
"ethernet" and "ethernet0" aliases exist.


I am happy to work up a new version of the patch: just let me know which 
option you prefer.


Many thanks,

Michael



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44245): https://edk2.groups.io/g/devel/message/44245
Mute This Topic: https://groups.io/mt/32529756/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [edk2-platforms: PATCH 0/3] Platform/RPi3: Improve timeout handling in DwUsbHostDxe

2019-07-19 Thread Pete Batard

Hi Leif,

On 2019.07.19 12:53, Leif Lindholm wrote:

Hi Pete,

On Wed, Jul 17, 2019 at 12:46:42PM +0100, Pete Batard wrote:

Networking applications (e.g. iPXE) might experience failures when submitting
a bulk IN for the NIC's RX endpoint, because the bulk IN (correctly) times out
when no received packet is waiting, but DwUsbHostDxe.c treats this as a fatal
error.

With these patches, iPXE is able to successfully download a 128MB test file
via HTTP.


The patches look good, and I don't mind you upstreaming Michael's
code, *but* I don't want patches submitted with anyone other than the
contributor's Signed-off-by:. (It's the equivalent of saying "Yeah,
Michael says he's OK with https://developercertificate.org/, and of no
actual use.)


I see. It does make sense, now that you explain it.


(If patches are modified after contribution, but before being pushed,
then then additional contributions can be reflected with additional
Signed-off-bys. Make sense?)

The From: tag ensures he still retains authorship.
Are you OK with me dropping Michael's Signed-off-by before pushing?


That's fine with me. I reviewed these patches and can therefore vouch 
for them.


Regards,

/Pete

PS: Thanks for pushing the previous series.



Best Regards,

Leif


Michael Brown (3):
   Platform/RPi3: Use Wait4Bit return value consistently
   Platform/RPi3: Gracefully disable USB channel after a timeout
   Platform/RPi3: Reduce debug noise when using a USB network device

  Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c | 44 
+++-
  1 file changed, 25 insertions(+), 19 deletions(-)

--
2.21.0.windows.1




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44049): https://edk2.groups.io/g/devel/message/44049
Mute This Topic: https://groups.io/mt/32502331/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 3/3] Platform/RPi3: Reduce debug noise when using a USB network device

2019-07-17 Thread Pete Batard
From: Michael Brown 

The design of the EFI_USB2_HC_PROTOCOL does not allow for long-lived
bulk IN transactions as used by network devices, but instead requires
the network driver to rely on repeatedly issuing bulk IN transactions
with a very short timeout and in the expectation that most bulk IN
transactions will time out since no packet will have been received.

Timeouts are therefore normal and expected events when using a USB
network device under UEFI.  This currently results in a constant
stream of spurious "Wait4Bit: set timeout" and "Channel %u did not
halt" debug messages whenever the network device is open.

All callers of Wait4Bit already report a meaningful error in the event
of a timeout, so the Wait4Bit message may safely be removed without
impacting the ability to debug the code.

The "Channel %u did not halt" message may be moved to its sole call
site and restricted to the situation in which the subsequent attempt
to gracefully disable the channel did actually fail.

Signed-off-by: Michael Brown 
Signed-off-by: Pete Batard 
---
 Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c 
b/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c
index 22d9bd822f96..37ebf503fd60 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c
+++ b/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c
@@ -74,9 +74,6 @@ Wait4Bit (
 }
   } while (EFI_ERROR (gBS->CheckEvent (Timeout)));
 
-  DEBUG ((DEBUG_ERROR, "Wait4Bit: %a timeout (reg:0x%x, value:0x%x, 
mask:0x%x)\n",
-Set ? "set" : "clear", Reg, Set ? Value : ~Value, Mask));
-
   return EFI_TIMEOUT;
 }
 
@@ -99,7 +96,6 @@ Wait4Chhltd (
   Status = Wait4Bit (Timeout, DwHc->DwUsbBase + HCINT (Channel),
  DWC2_HCINT_CHHLTD, 1);
   if (EFI_ERROR (Status)) {
-DEBUG ((DEBUG_ERROR, "Channel %u did not halt\n", Channel));
 return XFER_NOT_HALTED;
   }
 
@@ -331,6 +327,7 @@ DwHcTransfer (
   if (Status == EFI_SUCCESS) {
 Status = EFI_TIMEOUT;
   } else {
+DEBUG ((DEBUG_ERROR, "Channel %u did not halt\n", Channel));
 Status = EFI_DEVICE_ERROR;
   }
   break;
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#43880): https://edk2.groups.io/g/devel/message/43880
Mute This Topic: https://groups.io/mt/32502336/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 0/3] Platform/RPi3: Improve timeout handling in DwUsbHostDxe

2019-07-17 Thread Pete Batard
Networking applications (e.g. iPXE) might experience failures when submitting
a bulk IN for the NIC's RX endpoint, because the bulk IN (correctly) times out
when no received packet is waiting, but DwUsbHostDxe.c treats this as a fatal
error.

With these patches, iPXE is able to successfully download a 128MB test file
via HTTP.

Michael Brown (3):
  Platform/RPi3: Use Wait4Bit return value consistently
  Platform/RPi3: Gracefully disable USB channel after a timeout
  Platform/RPi3: Reduce debug noise when using a USB network device

 Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c | 44 
+++-
 1 file changed, 25 insertions(+), 19 deletions(-)

-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#43877): https://edk2.groups.io/g/devel/message/43877
Mute This Topic: https://groups.io/mt/32502331/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 1/3] Platform/RPi3: Use Wait4Bit return value consistently

2019-07-17 Thread Pete Batard
From: Michael Brown 

There are multiple points in the existing code that take the UINT32
value returned by Wait4Bit and return it directly as an EFI_STATUS
value.  If Wait4Bit fails, this will result in a spurious EFI_STATUS
value of 0x1 (EFI_WARN_UNKNOWN_GLYPH) being returned to the caller.  A
caller treating any non-zero value as an error will see this as a
failure, but a caller using the EFI_ERROR macro will incorrectly see
it as a success.

Fix by defining the return type of Wait4Bit as EFI_STATUS and ensuring
that a valid EFI_STATUS value is always returned.

Signed-off-by: Michael Brown 
Signed-off-by: Pete Batard 
---
 Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c | 19 
++-
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c 
b/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c
index 59120b9d8564..c1e1229f858e 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c
+++ b/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c
@@ -53,7 +53,7 @@ DwCoreInit (
   IN EFI_EVENTTimeout
   );
 
-UINT32
+EFI_STATUS
 Wait4Bit (
   IN  EFI_EVENT Timeout,
   IN  UINT32Reg,
@@ -70,14 +70,14 @@ Wait4Bit (
 }
 
 if ((Value & Mask) == Mask) {
-  return 0;
+  return EFI_SUCCESS;
 }
   } while (EFI_ERROR (gBS->CheckEvent (Timeout)));
 
   DEBUG ((DEBUG_ERROR, "Wait4Bit: %a timeout (reg:0x%x, value:0x%x, 
mask:0x%x)\n",
 Set ? "set" : "clear", Reg, Set ? Value : ~Value, Mask));
 
-  return 1;
+  return EFI_TIMEOUT;
 }
 
 CHANNEL_HALT_REASON
@@ -91,13 +91,14 @@ Wait4Chhltd (
   IN  SPLIT_CONTROL   *Split
   )
 {
-  INT32   Ret;
+  EFI_STATUS Status;
   UINT32  Hcint, Hctsiz;
   UINT32  HcintCompHltAck = DWC2_HCINT_XFERCOMP;
 
   MicroSecondDelay (100);
-  Ret = Wait4Bit (Timeout, DwHc->DwUsbBase + HCINT (Channel), 
DWC2_HCINT_CHHLTD, 1);
-  if (Ret) {
+  Status = Wait4Bit (Timeout, DwHc->DwUsbBase + HCINT (Channel),
+ DWC2_HCINT_CHHLTD, 1);
+  if (EFI_ERROR (Status)) {
 DEBUG ((DEBUG_ERROR, "Channel %u did not halt\n", Channel));
 return XFER_NOT_HALTED;
   }
@@ -204,7 +205,7 @@ DwCoreReset (
   IN  EFI_EVENT Timeout
   )
 {
-  UINT32  Status;
+  EFI_STATUS Status;
 
   Status = Wait4Bit (Timeout, DwHc->DwUsbBase + GRSTCTL, DWC2_GRSTCTL_AHBIDLE, 
1);
   if (Status) {
@@ -1261,7 +1262,7 @@ DwFlushTxFifo (
   IN INT32 Num
   )
 {
-  UINT32 Status;
+  EFI_STATUS Status;
 
   MmioWrite32 (DwHc->DwUsbBase + GRSTCTL, DWC2_GRSTCTL_TXFFLSH |
 (Num << DWC2_GRSTCTL_TXFNUM_OFFSET));
@@ -1279,7 +1280,7 @@ DwFlushRxFifo (
   IN  EFI_EVENT Timeout
   )
 {
-  UINT32 Status;
+  EFI_STATUS Status;
 
   MmioWrite32 (DwHc->DwUsbBase + GRSTCTL, DWC2_GRSTCTL_RXFFLSH);
 
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#43878): https://edk2.groups.io/g/devel/message/43878
Mute This Topic: https://groups.io/mt/32502332/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 2/3] Platform/RPi3: Gracefully disable USB channel after a timeout

2019-07-17 Thread Pete Batard
From: Michael Brown 

When a timeout occurs, attempt to gracefully disable the channel.
Report a final status of EFI_TIMEOUT if the channel was disabled
successfully, or EFI_DEVICE_ERROR if we were unable to disable the
channel.

Signed-off-by: Michael Brown 
Signed-off-by: Pete Batard 
---
 Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c | 20 
++--
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c 
b/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c
index c1e1229f858e..22d9bd822f96 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c
+++ b/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c
@@ -318,13 +318,21 @@ DwHcTransfer (
 Ret = Wait4Chhltd (DwHc, Timeout, Channel, , Pid, IgnoreAck, );
 
 if (Ret == XFER_NOT_HALTED) {
-  /*
-   * FIXME: do proper channel reset.
-   */
-  MmioWrite32 (DwHc->DwUsbBase + HCCHAR (Channel), DWC2_HCCHAR_CHDIS);
-
   *TransferResult = EFI_USB_ERR_TIMEOUT;
-  Status = EFI_DEVICE_ERROR;
+  MmioOr32 (DwHc->DwUsbBase + HCCHAR (Channel), DWC2_HCCHAR_CHDIS);
+  Status = gBS->SetTimer (Timeout, TimerRelative,
+  EFI_TIMER_PERIOD_MILLISECONDS (1));
+  ASSERT_EFI_ERROR (Status);
+  if (EFI_ERROR (Status)) {
+break;
+  }
+  Status = Wait4Bit (Timeout, DwHc->DwUsbBase + HCINT (Channel),
+ DWC2_HCINT_CHHLTD, 1);
+  if (Status == EFI_SUCCESS) {
+Status = EFI_TIMEOUT;
+  } else {
+Status = EFI_DEVICE_ERROR;
+  }
   break;
 } else if (Ret == XFER_STALL) {
   *TransferResult = EFI_USB_ERR_STALL;
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#43879): https://edk2.groups.io/g/devel/message/43879
Mute This Topic: https://groups.io/mt/32502335/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 2/2] Platform/Rpi3: Add custom CPU frequency support

2019-07-04 Thread Pete Batard
Allow users to set a custom CPU frequency [100 - 1600 MHz]
in 'Device Manager' -> 'Raspberry Pi Configuration'.

Signed-off-by: Pete Batard 
---
 Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c   | 13 
+++-
 Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf |  1 +
 Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni  |  4 
 Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr  | 22 

 Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c |  6 --
 Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h  |  3 ++-
 Platform/RaspberryPi/RPi3/RPi3.dec|  1 +
 Platform/RaspberryPi/RPi3/RPi3.dsc|  1 +
 8 files changed, 47 insertions(+), 4 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c 
b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c
index d64e70adce36..fcb4ce6935b6 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c
+++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c
@@ -108,6 +108,14 @@ SetupVariables (
 PcdSet32 (PcdCpuClock, PcdGet32 (PcdCpuClock));
   }
 
+  Size = sizeof (UINT32);
+  Status = gRT->GetVariable(L"CustomCpuClock",
+,
+NULL, , );
+  if (EFI_ERROR (Status)) {
+PcdSet32 (PcdCustomCpuClock, PcdGet32 (PcdCustomCpuClock));
+  }
+
   Size = sizeof (UINT32);
   Status = gRT->GetVariable (L"SdIsArasan",
   ,
@@ -201,6 +209,7 @@ ApplyVariables (
   UINTN Gpio48Group;
   EFI_STATUS Status;
   UINT32 CpuClock = PcdGet32 (PcdCpuClock);
+  UINT32 CustomCpuClock = PcdGet32 (PcdCustomCpuClock);
   UINT32 Rate = 0;
 
   if (CpuClock != 0) {
@@ -213,6 +222,8 @@ ApplyVariables (
   if (Status != EFI_SUCCESS) {
 DEBUG ((DEBUG_ERROR, "Couldn't get the max CPU speed, leaving as is: 
%r\n", Status));
   }
+} else if (CpuClock == 3) {
+  Rate = CustomCpuClock * 100;
 } else {
   Rate = 600 * 100;
 }
@@ -220,7 +231,7 @@ ApplyVariables (
 
   if (Rate != 0) {
 DEBUG ((DEBUG_INFO, "Setting CPU speed to %uHz\n", Rate));
-Status = mFwProtocol->SetClockRate (RPI_MBOX_CLOCK_RATE_ARM, Rate);
+Status = mFwProtocol->SetClockRate (RPI_MBOX_CLOCK_RATE_ARM, Rate, 1);
 if (Status != EFI_SUCCESS) {
   DEBUG ((DEBUG_ERROR, "Couldn't set the CPU speed: %r\n", Status));
 }
diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf 
b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
index 3fee190ac41b..6d6c90b78408 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
+++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
@@ -54,6 +54,7 @@ [Protocols]
 
 [Pcd]
   gRaspberryPiTokenSpaceGuid.PcdCpuClock
+  gRaspberryPiTokenSpaceGuid.PcdCustomCpuClock
   gRaspberryPiTokenSpaceGuid.PcdSdIsArasan
   gRaspberryPiTokenSpaceGuid.PcdMmcForce1Bit
   gRaspberryPiTokenSpaceGuid.PcdMmcForceDefaultSpeed
diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni 
b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni
index a9c101433008..65b45f3e6496 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni
+++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni
@@ -25,6 +25,10 @@
 #string STR_CHIPSET_CLOCK_CPU_NA #language en-US "Don't Override"
 #string STR_CHIPSET_CLOCK_CPU_600MHZ #language en-US "Min (600MHz)"
 #string STR_CHIPSET_CLOCK_CPU_MAX#language en-US "Max"
+#string STR_CHIPSET_CLOCK_CPU_CUSTOM #language en-US "Custom"
+
+#string STR_CHIPSET_CUSTOM_CPU_CLOCK_PROMPT #language en-US "CPU Clock Rate 
(MHz)"
+#string STR_CHIPSET_CUSTOM_CPU_CLOCK_HELP   #language en-US "Adjust the CPU 
speed.\nMin value: 100 MHz\nMax value: 1600 MHz\n\nWarning: Overclocking can 
make the system unbootable!"
 
 #string STR_CHIPSET_SD_PROMPT#language en-US "uSD Routing"
 #string STR_CHIPSET_SD_HELP  #language en-US "Choose host controller 
to drive uSD slot"
diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr 
b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr
index 7a1824525892..217a285b5a1f 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr
+++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr
@@ -47,10 +47,15 @@ typedef struct {
* 0 - don't change the clock rate.
* 1 - 600MHz.
* 2 - maximum.
+   * 3 - custom.
*/
   UINT32 Clock;
 } CHIPSET_CPU_CLOCK_VARSTORE_DATA;
 
+typedef struct {
+  UINT32 Clock;
+} CHIPSET_CUSTOM_CPU_CLOCK_VARSTORE_DATA;
+
 typedef struct {
   /*
* 0 - uSD slot routed to Broadcom SDHOST.
@@ -116,6 +121,11 @@ formset
   name  = CpuClock,
   guid  = CONFIGDXE_FORM_SET_G

[edk2-devel] [edk2-platforms: PATCH v2 0/2] Platform/RPi3: Improve boot order and add custom freqs

2019-07-04 Thread Pete Batard
v2 to:
- Break a long line PlatformBm.c.
- Use a BOOLEAN for the SkipTurbo parameter.
- Keep already defined gRaspberryPiTokenSpaceGuid.### values as they are.

Note that, as opposed to what was discussed, EFI_VARIABLE_RUNTIME_ACCESS was
not removed because doing so effectively prevents the custom value to be
applied in the firmware menu. Without EFI_VARIABLE_RUNTIME_ACCESS you will get
the following notice when trying to save your changes:

Submit Fail For Form: Chipset Configuration.   
 Press D(d) to discard changes for this form, Press G(g) to go to this form

So I guess EFI_VARIABLE_RUNTIME_ACCESS applies to more than OS access.

Regards,

/Pete

Pete Batard (2):
  Platform/RPi3: Set the boot option of UEFI Shell as non-active
  Platform/Rpi3: Add custom CPU frequency support

 Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c   | 13 
+++-
 Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf |  1 +
 Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni  |  4 
 Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr  | 22 

 Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c |  6 
--
 Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h  |  3 ++-
 Platform/RaspberryPi/RPi3/Library/PlatformBootManagerLib/PlatformBm.c |  3 ++-
 Platform/RaspberryPi/RPi3/RPi3.dec|  1 +
 Platform/RaspberryPi/RPi3/RPi3.dsc|  1 +
 Platform/RaspberryPi/RPi3/Readme.md   |  6 
+++---
 10 files changed, 52 insertions(+), 8 deletions(-)

-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#43316): https://edk2.groups.io/g/devel/message/43316
Mute This Topic: https://groups.io/mt/32309760/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [edk2-platforms: PATCH 2/2] Platform/Rpi3: Add custom CPU frequency support

2019-07-03 Thread Pete Batard

Hi Leif,

On 2019.07.03 12:42, Leif Lindholm wrote:

On Tue, Jul 02, 2019 at 05:13:41PM +0100, Pete Batard wrote:

Allow users to set a custom CPU frequency [100 - 1600 MHz]
in 'Device Manager' -> 'Raspberry Pi Configuration'.

Signed-off-by: Pete Batard 
---
  Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c   | 13 
+++-
  Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf |  1 +
  Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni  |  4 
  Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr  | 22 

  Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c |  4 +++-
  Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h  |  3 ++-
  Platform/RaspberryPi/RPi3/RPi3.dec| 17 
---
  Platform/RaspberryPi/RPi3/RPi3.dsc|  1 +
  8 files changed, 54 insertions(+), 11 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c 
b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c
index d64e70adce36..fcb4ce6935b6 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c
+++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c
@@ -108,6 +108,14 @@ SetupVariables (
  PcdSet32 (PcdCpuClock, PcdGet32 (PcdCpuClock));
}
  
+  Size = sizeof (UINT32);

+  Status = gRT->GetVariable(L"CustomCpuClock",
+,
+NULL, , );
+  if (EFI_ERROR (Status)) {
+PcdSet32 (PcdCustomCpuClock, PcdGet32 (PcdCustomCpuClock));
+  }
+
Size = sizeof (UINT32);
Status = gRT->GetVariable (L"SdIsArasan",
,
@@ -201,6 +209,7 @@ ApplyVariables (
UINTN Gpio48Group;
EFI_STATUS Status;
UINT32 CpuClock = PcdGet32 (PcdCpuClock);
+  UINT32 CustomCpuClock = PcdGet32 (PcdCustomCpuClock);
UINT32 Rate = 0;
  
if (CpuClock != 0) {

@@ -213,6 +222,8 @@ ApplyVariables (
if (Status != EFI_SUCCESS) {
  DEBUG ((DEBUG_ERROR, "Couldn't get the max CPU speed, leaving as is: 
%r\n", Status));
}
+} else if (CpuClock == 3) {
+  Rate = CustomCpuClock * 100;
  } else {
Rate = 600 * 100;
  }
@@ -220,7 +231,7 @@ ApplyVariables (
  
if (Rate != 0) {

  DEBUG ((DEBUG_INFO, "Setting CPU speed to %uHz\n", Rate));
-Status = mFwProtocol->SetClockRate (RPI_MBOX_CLOCK_RATE_ARM, Rate);
+Status = mFwProtocol->SetClockRate (RPI_MBOX_CLOCK_RATE_ARM, Rate, 1);
  if (Status != EFI_SUCCESS) {
DEBUG ((DEBUG_ERROR, "Couldn't set the CPU speed: %r\n", Status));
  }
diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf 
b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
index 3fee190ac41b..6d6c90b78408 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
+++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
@@ -54,6 +54,7 @@ [Protocols]
  
  [Pcd]

gRaspberryPiTokenSpaceGuid.PcdCpuClock
+  gRaspberryPiTokenSpaceGuid.PcdCustomCpuClock
gRaspberryPiTokenSpaceGuid.PcdSdIsArasan
gRaspberryPiTokenSpaceGuid.PcdMmcForce1Bit
gRaspberryPiTokenSpaceGuid.PcdMmcForceDefaultSpeed
diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni 
b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni
index a9c101433008..04f735949ba5 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni
+++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni
@@ -25,6 +25,10 @@
  #string STR_CHIPSET_CLOCK_CPU_NA #language en-US "Don't Override"
  #string STR_CHIPSET_CLOCK_CPU_600MHZ #language en-US "Min (600MHz)"
  #string STR_CHIPSET_CLOCK_CPU_MAX#language en-US "Max"
+#string STR_CHIPSET_CLOCK_CPU_CUSTOM #language en-US "Custom"
+
+#string STR_CHIPSET_CUSTOM_CPU_CLOCK_PROMPT #language en-US "CPU Clock Rate 
(MHz)"
+#string STR_CHIPSET_CUSTOM_CPU_CLOCK_HELP   #language en-US "Adjust the CPU 
speed.\nMin value: 100 MHz\nMax value: 1600 MHz\n\nWarning: Overclocking can make the 
system unbootable!"
  
  #string STR_CHIPSET_SD_PROMPT#language en-US "uSD Routing"

  #string STR_CHIPSET_SD_HELP  #language en-US "Choose host controller to 
drive uSD slot"
diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr 
b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr
index 7a1824525892..217a285b5a1f 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr
+++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr
@@ -47,10 +47,15 @@ typedef struct {
 * 0 - don't change the clock rate.
 * 1 - 600MHz.
 * 2 - maximum.
+   * 3 - custom.
 */
UINT32 Clock;
  } CHIPSET_CPU_CLOCK_VARSTORE_DATA;
  
+typedef struct {

+  UINT32 Clock;
+} CHIPSET_CUSTOM_CPU_CLOCK_VARSTORE_DAT

[edk2-devel] [edk2-platforms: PATCH 0/2] Platform/RPi3 improve boot order and add custom freqs

2019-07-02 Thread Pete Batard
The following 2 patches update the Raspberry Pi 3 platform to:
- Remove UEFI Shell as default boot target, to instead default to SD then USB,
  which is the what most users of the UEFI firmware are likely to expect.
- Add the ability to set a custom CPU frequency [100 - 1600 MHz] instead
  of only allowing to pick from a limited set of default values.

Regards,

/Pete

Pete Batard (2):
  Platform/RPi3: Set the boot option of UEFI Shell as non-active
  Platform/Rpi3: Add custom CPU frequency support

 Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c   | 13 
+++-
 Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf |  1 +
 Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni  |  4 
 Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr  | 22 

 Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c |  4 +++-
 Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h  |  3 ++-
 Platform/RaspberryPi/RPi3/Library/PlatformBootManagerLib/PlatformBm.c |  2 +-
 Platform/RaspberryPi/RPi3/RPi3.dec| 17 
---
 Platform/RaspberryPi/RPi3/RPi3.dsc|  1 +
 Platform/RaspberryPi/RPi3/Readme.md   |  6 
+++---
 10 files changed, 58 insertions(+), 15 deletions(-)

-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#43171): https://edk2.groups.io/g/devel/message/43171
Mute This Topic: https://groups.io/mt/32287841/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-non-osi: PATCH 0/1] Platform/RaspberryPi/RPi3: Update ATF

2019-06-10 Thread Pete Batard
Following up on a discussion that we had during the initial Raspberry Pi 3
platform integration, the following patch updates the ATF for the platform to
the official 2.1 release (which also avoids a notice about ATF not being
a release version that is currentlly being issued during early boot).

Now, as opposed to an idea that was floated at the time, that proposed that we
remove the RPI3 ATF from non-osi and instead simply provide a link to pre-built
binaries (which could still be done if there is a majority pushing for it), I
would still suggest, as per this patch, that we do keep the provisioning of the
ATF binaries as part of the EDK2.

The reason for that is that the binaries are small enough not to increase
cloning times even if we update them on a semi regular basis, and I believe the
inconvenience of having to hunt and go through a download to be able to compile
the RPi3 firmware outweighs the push for trying to remove as many non-osi
components as we can from the EDK2.

With regards to how these binaries were built, I will point out that this was
achieved through a process that is designed to provide confidence that the files
can not have been altered in any way from the ones one would expect to be built
from vanilla source. As such, the build was enacted on build servers that we
don't have the possibility to alter in a concealed manner (AppVeyor) and where
every single step can be publicly validated not to have added unwarranted
elements. For instance, the log for the build that produced the attached files
can be found at: https://ci.appveyor.com/project/pbatard/pitf/builds/24506898

Also, as part of this public build process, we made sure to issue the SHA-256
sums of the binary, so they can easily be compared to the ones from the files
provided here.

For more details on these builds, you can check https://github.com/pbatard/pitf
which also hosts the resulting AppVeyor binary artefacts. One thing that should
be pointed out however is that the ATF builds are currently not reproducible as
the current build date is inserted into the binary, which means that, if you
clone the script above and issue your own AppVeyor builds, you will end up with
a different SHA-256. However, binary comparison can easily demonstrate that the
only difference between the binaries has to do with the build date.

Regards,

/Pete

Pete Batard (1):
  Platform/RaspberryPi/RPi3: Update ATF binaries to v2.1

 Platform/RaspberryPi/RPi3/TrustedFirmware/License.txt |   2 +-
 Platform/RaspberryPi/RPi3/TrustedFirmware/Readme.md   |  18 +++---
 Platform/RaspberryPi/RPi3/TrustedFirmware/bl1.bin | Bin 18801 -> 18776 
bytes
 Platform/RaspberryPi/RPi3/TrustedFirmware/fip.bin | Bin 41714 -> 45792 
bytes
 4 files changed, 12 insertions(+), 8 deletions(-)

-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#42097): https://edk2.groups.io/g/devel/message/42097
Mute This Topic: https://groups.io/mt/32003675/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-non-osi: PATCH 1/1] Platform/RaspberryPi/RPi3: Update ATF binaries to v2.1

2019-06-10 Thread Pete Batard
This patch updates the ARM Trusted Firmware to the latest release
using AppVeyor built binaries that provide verifiable evidence that
the files have not been altered from a vanilla source compilation.

Signed-off-by: Pete Batard 
---
 Platform/RaspberryPi/RPi3/TrustedFirmware/License.txt |   2 +-
 Platform/RaspberryPi/RPi3/TrustedFirmware/Readme.md   |  18 +++---
 Platform/RaspberryPi/RPi3/TrustedFirmware/bl1.bin | Bin 18801 -> 18776 
bytes
 Platform/RaspberryPi/RPi3/TrustedFirmware/fip.bin | Bin 41714 -> 45792 
bytes
 4 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/TrustedFirmware/License.txt 
b/Platform/RaspberryPi/RPi3/TrustedFirmware/License.txt
index b98dc643227e..48429979fec2 100644
--- a/Platform/RaspberryPi/RPi3/TrustedFirmware/License.txt
+++ b/Platform/RaspberryPi/RPi3/TrustedFirmware/License.txt
@@ -1,4 +1,4 @@
-Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
+Copyright (c) 2013-2019, ARM Limited and Contributors. All rights reserved.
 
 Redistribution and use in source and binary forms, with or without 
modification,
 are permitted provided that the following conditions are met:
diff --git a/Platform/RaspberryPi/RPi3/TrustedFirmware/Readme.md 
b/Platform/RaspberryPi/RPi3/TrustedFirmware/Readme.md
index 74bcec7d1f12..f0c4fcf414be 100644
--- a/Platform/RaspberryPi/RPi3/TrustedFirmware/Readme.md
+++ b/Platform/RaspberryPi/RPi3/TrustedFirmware/Readme.md
@@ -1,17 +1,21 @@
 ARM Trusted Firmware for Raspberry Pi 3
 ===
 
-The `bl1` and `fip` ATF binaries, found in this directory, were built from
-the [official ATF source](https://github.com/ARM-software/arm-trusted-firmware)
-(commit c3859557) using Linaro's GCC 5.5 compiler with:
+The `bl1.bin` and `fip.bin` ATF binaries found in this directory were built 
from the
+[official ATF 2.1 
release](https://github.com/ARM-software/arm-trusted-firmware/releases/tag/v2.1)
+through an [AppVeyor build 
script](https://github.com/pbatard/pitf/blob/master/appveyor.yml)
+that is designed to provide evidence that these binaries match the vanilla ATF 
source.
 
+As per the [AppVeyor build 
log](https://ci.appveyor.com/project/pbatard/pitf/builds/24506898),
+the SHA-256 sums for the blobs can be validated to be as follows:
+- `bl1.bin`: `57e30ed8572e6a3a161c231e68138ee2c78e9dfc6dc51be8c0b4d9c3fe9bbfad`
+- `fip.bin`: `b7eadad3a11088e322c52ab5fd2247a7bc79dc086a21db12cc8079a2ab4789f6`
+
+For Raspberry Pi 3 usage, ATF was built using the command:
 ```
-export 
CROSS_COMPILE=/usr/src/gcc-linaro-5.5.0-2017.10-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
 make PLAT=rpi3 PRELOADED_BL33_BASE=0x3 RPI3_PRELOADED_DTB_BASE=0x1 
SUPPORT_VFP=1 RPI3_USE_UEFI_MAP=1 fip all
 ```
-
-This results in the following memory mapping:
-
+which results in the following memory mapping:
 ```
 0x +-+
|   ROM   | BL1
diff --git a/Platform/RaspberryPi/RPi3/TrustedFirmware/bl1.bin 
b/Platform/RaspberryPi/RPi3/TrustedFirmware/bl1.bin
index 
e25138828d0a4ddb24772abb1a60eefc334666b5..cc3e79cc245fc07bedefd296bd9122eae2c9cce1
 100644
GIT binary patch
delta 8168
zcmZ`;4|G)JmA~)LOok-rWG4Se0y7gp$%x9IghW*GG9cKht%O-?m7YujtO#s11l=gu
z_Y$JgM!UScbZMhoCIKp$(z8g2-RagPpxe5|ZDC?qx2I>F0E#tk3jrh#2(!QYW(K3j
z%{jyO?|$FC-~I0W-FqMBI)wK-gdDQB#KMI?8ztwop%1F1p*}sQK=`X(R{R~xnKneU
zJ?3?WN4@T8Ly094##&6_dAVwc-hFb=Bh$Hhq9A$0v2dVx=!FdG3=vg)AMFMQb?!i`
z70@vvS#Lq>3(wSjL`S>ymkSnjf*@oq5>IaT4fym1j00gw4}j<$tRGTnr~!wJiqv@t
zzeekh`J}nxlG}fNMNRMc=C}6_NOdP#UQo=Qt)z!q
z74sVcb;hqHD#C8X+_j5zQPg7HZ;}48@v=}{F9;M2S1M6H#Y5D1-fa{y<%`($VIon$
z^HuyI3*1MKXzm
zEKQ{7|E475_6($Y9ukEgtcl_+%0q(YVqI)4pnHym_9?qD_kpT{s3uCd>P#H)
zd`O7Skd@xmSE;u?o6N;{3qFh=@*3;^9l1odIv>lk;R|`TN@1??fbE;ksnEfDmRV@E
zPi2y6?6cjJBk9Ex*@i^plx^uZ+G?V84^JPn1aC_U+@56)Ftu*kd?1kxh-W?5wa~_kIKy;Q6&)yPkF%8$g6z3*-(%Nze7a@u4CFZ|7PS8sGH+_0
zG4?!k2FHjHDaQPaDM|?AzIByjtc5tvy#z;LK$z%U;9tuw9hY(=;Y4D`XXvkiZkgU_
z_*aMnvdCm6K7kH;srtl+uuFJtWV0bS+|&3tR-NVj;S4?b?uRUtm?Rl~
z$DQ|YW2d9-OMwyGE_o^0F4h#2E+qSbE#L(!oQd^4p_w|AaeU8gZW-s3HhmY)_d*)lZ`Z#L3BUtV9AR9Y3j@bOpIy;rM
zUY?=fg>@bqnI}F%LsMMjKKwrDY4y?smF&7|*eid^edyVl#X5O@m*OE{khd61w
zbW2*S9QW$%F?uq;>r=4ROW{$C21Z+4f*Ar{@T;qEEVYQDhmE_likJGJS?jWjOFs;_
z(OMn4Nc(FAS&3GYxPHKvT7NZHk7Au*)RsXawv2Cn%ZgIrabsPUUv1$BW4*rX(oaKY
zO5#!_Id{Y;{@N(aG3w1Gm$u18KUoZv7P;`3Zh)HUyRpTRH%2BU*ZW%{%9Kox_
zSnwXu{DH?#CE5y8f|xKIaeaz@%67`m(|->F%2lFaAS7h1eHUXRls!xRu8ndT0$E!h
zL6c43%0~HDOOtQ*T9O~jyYA)lag(M+`T9jSnU8~(C9q7Zne;Ui$3%KP#>-(|c$FQK
z(Ptw;YSB0>Q;;z{PoYvB2lyvpU_}MQwPCg-R@dr$eL3bQ8IvcMsIv<6doh4-`wv*H
z+kXWo^QQ2`O}h(p4wlvd8w?!=YzZB{mI8uPFry(J^e~Nxfa(|@i
zd=|g!k-amqk*}a2a>T*d15kuMJ1BQ&*8l=(T(UyKZ1z5*)snNN=u=BOZ(8=jZ(ach;3SEG^8zA8KLi5v
z*e4KNz#Ze^78lZ&%)fzhh-hA`ONlOVE*V?`5FpB**MbYxkaGc1-aKk9aanY-^X_>v
zvWdmnfk71^ss^S`R5;JKW$oZjWNkirtV5!fm{jz$(di^bY#A-FJ%!;>AK4;4=hiM`
z-;IDsSn^`{k~#|(#;QMiV`0S$Ko!hQXUP!T@JY~fo94u>o>nL&a

[edk2-devel] [edk2-platforms: PATCH v2 2/2] RaspberryPi/RPi3: Update DSC/FDF to use NetworkPkg DSC/FDF

2019-06-07 Thread Pete Batard
This patch updates the platform DSC/FDF files to use the include fragment
files provided by NetworkPkg.

Signed-off-by: Pete Batard 
---
 Platform/RaspberryPi/RPi3/RPi3.dsc | 31 
 Platform/RaspberryPi/RPi3/RPi3.fdf | 11 +--
 2 files changed, 13 insertions(+), 29 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc 
b/Platform/RaspberryPi/RPi3/RPi3.dsc
index 85b954b060f1..fe883eac96ba 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.dsc
+++ b/Platform/RaspberryPi/RPi3/RPi3.dsc
@@ -25,6 +25,12 @@ [Defines]
   SKUID_IDENTIFIER   = DEFAULT
   FLASH_DEFINITION   = 
Platform/RaspberryPi/$(PLATFORM_NAME)/$(PLATFORM_NAME).fdf
 
+  #
+  # Network definition
+  #
+  DEFINE NETWORK_TLS_ENABLE   = FALSE
+  DEFINE NETWORK_HTTP_BOOT_ENABLE = FALSE
+
   #
   # Defines for default states.  These can be changed on the command line.
   # -D FLAG=VALUE
@@ -85,12 +91,6 @@ [LibraryClasses.common]
   # use the accelerated BaseMemoryLibOptDxe by default, overrides for SEC/PEI 
below
   BaseMemoryLib|MdePkg/Library/BaseMemoryLibOptDxe/BaseMemoryLibOptDxe.inf
 
-  # Networking Requirements
-  NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf
-  DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf
-  UdpIoLib|MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf
-  IpIoLib|MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf
-
   #
   # It is not possible to prevent the ARM compiler from inserting calls to 
intrinsic functions.
   # This library provides the instrinsic functions such a compiler may 
generate calls to.
@@ -117,6 +117,11 @@ [LibraryClasses.common]
   
PlatformHookLib|MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull.inf
   
SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf
 
+  # Cryptographic libraries
+  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
+  BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
+  OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
+
   #
   # Uncomment (and comment out the next line) For RealView Debugger. The 
Standard IO window
   # in the debugger will show load and unload commands for symbols. You can 
cut and paste this
@@ -140,11 +145,8 @@ [LibraryClasses.common]
   # Secure Boot dependencies
   #
 !if $(SECURE_BOOT_ENABLE) == TRUE
-  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
-  OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
   
TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
   AuthVariableLib|SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf
-  BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
 
   # re-use the UserPhysicalPresent() dummy implementation from the ovmf tree
   PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf
@@ -588,16 +590,7 @@ [Components.common]
   #
   # Networking stack
   #
-  MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
-  MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
-  MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf
-  MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf
-  MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf
-  MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf
-  MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf
-  MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf
-  NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf
-  NetworkPkg/TcpDxe/TcpDxe.inf
+!include NetworkPkg/Network.dsc.inc
 
   #
   # RNG
diff --git a/Platform/RaspberryPi/RPi3/RPi3.fdf 
b/Platform/RaspberryPi/RPi3/RPi3.fdf
index 6be7c23af467..c7c3f7a2ab8c 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.fdf
+++ b/Platform/RaspberryPi/RPi3/RPi3.fdf
@@ -265,16 +265,7 @@ [FV.FvMain]
   #
   # Networking stack
   #
-  INF MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
-  INF MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
-  INF MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf
-  INF MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf
-  INF MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf
-  INF MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf
-  INF MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf
-  INF MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf
-  INF NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf
-  INF NetworkPkg/TcpDxe/TcpDxe.inf
+!include NetworkPkg/Network.fdf.inc
 
   #
   # RNG
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#42034): https://edk2.groups.io/g/devel/message/42034
Mute This Topic: https://groups.io/mt/31975707/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 1/2] RaspberryPi/RPi3: Enable RAM Disk

2019-06-07 Thread Pete Batard
Also update UsbNetworking/Ax88772b/Ax88772b.inf references.

Signed-off-by: Pete Batard 
---
 Platform/RaspberryPi/RPi3/RPi3.dsc | 7 ++-
 Platform/RaspberryPi/RPi3/RPi3.fdf | 7 ++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc 
b/Platform/RaspberryPi/RPi3/RPi3.dsc
index 53b87ba4e5e0..85b954b060f1 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.dsc
+++ b/Platform/RaspberryPi/RPi3/RPi3.dsc
@@ -541,6 +541,11 @@ [Components.common]
   
Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf
   MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
 
+  #
+  # RAM Disk Support
+  #
+  MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf
+
   #
   # Bds
   #
@@ -571,7 +576,7 @@ [Components.common]
   MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
   MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf
   MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
-  OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772b.inf
+  Drivers/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772b.inf
 
   #
   # SD/MMC support
diff --git a/Platform/RaspberryPi/RPi3/RPi3.fdf 
b/Platform/RaspberryPi/RPi3/RPi3.fdf
index cf4b99a5e9b7..6be7c23af467 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.fdf
+++ b/Platform/RaspberryPi/RPi3/RPi3.fdf
@@ -247,6 +247,11 @@ [FV.FvMain]
   INF 
Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf
   INF MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
 
+  #
+  # RAM Disk Support
+  #
+  INF MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf
+
   #
   # Bds
   #
@@ -289,7 +294,7 @@ [FV.FvMain]
   INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
   INF MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf
   INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
-  INF OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772b.inf
+  INF Drivers/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772b.inf
 
   #
   # SD/MMC support
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#42033): https://edk2.groups.io/g/devel/message/42033
Mute This Topic: https://groups.io/mt/31975706/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 0/2] Minor updates to platform

2019-06-07 Thread Pete Batard
* v2 to update UsbNetworking/Ax88772b/Ax88772b.inf reference instead
  of removing it.

The following 2 patches provide minor updates for the Raspberry Pi 3
platform, by enabling the use of the RAM Disk feature as well as the
new network stack fragment file.

Pete Batard (2):
  RaspberryPi/RPi3: Enable RAM Disk
  RaspberryPi/RPi3: Update DSC/FDF to use NetworkPkg DSC/FDF

 Platform/RaspberryPi/RPi3/RPi3.dsc | 38 ++--
 Platform/RaspberryPi/RPi3/RPi3.fdf | 18 --
 2 files changed, 25 insertions(+), 31 deletions(-)

-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#42032): https://edk2.groups.io/g/devel/message/42032
Mute This Topic: https://groups.io/mt/31975705/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH 2/2] RaspberryPi/RPi3: Update DSC/FDF to use NetworkPkg DSC/FDF

2019-06-07 Thread Pete Batard
This patch updates the platform DSC/FDF files to use the include fragment
files provided by NetworkPkg.

Signed-off-by: Pete Batard 
---
 Platform/RaspberryPi/RPi3/RPi3.dsc | 31 
 Platform/RaspberryPi/RPi3/RPi3.fdf | 11 +--
 2 files changed, 13 insertions(+), 29 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc 
b/Platform/RaspberryPi/RPi3/RPi3.dsc
index f87d06f9b080..7c9ee5ef4802 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.dsc
+++ b/Platform/RaspberryPi/RPi3/RPi3.dsc
@@ -25,6 +25,12 @@ [Defines]
   SKUID_IDENTIFIER   = DEFAULT
   FLASH_DEFINITION   = 
Platform/RaspberryPi/$(PLATFORM_NAME)/$(PLATFORM_NAME).fdf
 
+  #
+  # Network definition
+  #
+  DEFINE NETWORK_TLS_ENABLE   = FALSE
+  DEFINE NETWORK_HTTP_BOOT_ENABLE = FALSE
+
   #
   # Defines for default states.  These can be changed on the command line.
   # -D FLAG=VALUE
@@ -85,12 +91,6 @@ [LibraryClasses.common]
   # use the accelerated BaseMemoryLibOptDxe by default, overrides for SEC/PEI 
below
   BaseMemoryLib|MdePkg/Library/BaseMemoryLibOptDxe/BaseMemoryLibOptDxe.inf
 
-  # Networking Requirements
-  NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf
-  DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf
-  UdpIoLib|MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf
-  IpIoLib|MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf
-
   #
   # It is not possible to prevent the ARM compiler from inserting calls to 
intrinsic functions.
   # This library provides the instrinsic functions such a compiler may 
generate calls to.
@@ -117,6 +117,11 @@ [LibraryClasses.common]
   
PlatformHookLib|MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull.inf
   
SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf
 
+  # Cryptographic libraries
+  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
+  BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
+  OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
+
   #
   # Uncomment (and comment out the next line) For RealView Debugger. The 
Standard IO window
   # in the debugger will show load and unload commands for symbols. You can 
cut and paste this
@@ -140,11 +145,8 @@ [LibraryClasses.common]
   # Secure Boot dependencies
   #
 !if $(SECURE_BOOT_ENABLE) == TRUE
-  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
-  OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
   
TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
   AuthVariableLib|SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf
-  BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
 
   # re-use the UserPhysicalPresent() dummy implementation from the ovmf tree
   PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf
@@ -587,16 +589,7 @@ [Components.common]
   #
   # Networking stack
   #
-  MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
-  MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
-  MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf
-  MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf
-  MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf
-  MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf
-  MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf
-  MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf
-  NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf
-  NetworkPkg/TcpDxe/TcpDxe.inf
+!include NetworkPkg/Network.dsc.inc
 
   #
   # RNG
diff --git a/Platform/RaspberryPi/RPi3/RPi3.fdf 
b/Platform/RaspberryPi/RPi3/RPi3.fdf
index 3bd2be314401..f2c0ee09af1e 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.fdf
+++ b/Platform/RaspberryPi/RPi3/RPi3.fdf
@@ -265,16 +265,7 @@ [FV.FvMain]
   #
   # Networking stack
   #
-  INF MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
-  INF MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
-  INF MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf
-  INF MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf
-  INF MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf
-  INF MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf
-  INF MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf
-  INF MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf
-  INF NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf
-  INF NetworkPkg/TcpDxe/TcpDxe.inf
+!include NetworkPkg/Network.fdf.inc
 
   #
   # RNG
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#42029): https://edk2.groups.io/g/devel/message/42029
Mute This Topic: https://groups.io/mt/31974935/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH 1/2] RaspberryPi/RPi3: Enable RAM Disk

2019-06-07 Thread Pete Batard
Also remove UsbNetworking/Ax88772b/Ax88772b.inf references since
this module is no longer present.

Signed-off-by: Pete Batard 
---
 Platform/RaspberryPi/RPi3/RPi3.dsc | 6 +-
 Platform/RaspberryPi/RPi3/RPi3.fdf | 6 +-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc 
b/Platform/RaspberryPi/RPi3/RPi3.dsc
index 53b87ba4e5e0..f87d06f9b080 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.dsc
+++ b/Platform/RaspberryPi/RPi3/RPi3.dsc
@@ -541,6 +541,11 @@ [Components.common]
   
Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf
   MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
 
+  #
+  # RAM Disk Support
+  #
+  MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf
+
   #
   # Bds
   #
@@ -571,7 +576,6 @@ [Components.common]
   MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
   MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf
   MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
-  OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772b.inf
 
   #
   # SD/MMC support
diff --git a/Platform/RaspberryPi/RPi3/RPi3.fdf 
b/Platform/RaspberryPi/RPi3/RPi3.fdf
index cf4b99a5e9b7..3bd2be314401 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.fdf
+++ b/Platform/RaspberryPi/RPi3/RPi3.fdf
@@ -247,6 +247,11 @@ [FV.FvMain]
   INF 
Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf
   INF MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
 
+  #
+  # RAM Disk Support
+  #
+  INF MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf
+
   #
   # Bds
   #
@@ -289,7 +294,6 @@ [FV.FvMain]
   INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
   INF MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf
   INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
-  INF OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772b.inf
 
   #
   # SD/MMC support
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#42028): https://edk2.groups.io/g/devel/message/42028
Mute This Topic: https://groups.io/mt/31974934/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH 0/2] RaspberryPi/RPi3: Minor updates to platform

2019-06-07 Thread Pete Batard
The following 2 patches provide minor updates for the Raspberry Pi 3
platform, by enabling the use of the RAM Disk feature as well as the
new network stack fragment file.

Pete Batard (2):
  RaspberryPi/RPi3: Enable RAM Disk
  RaspberryPi/RPi3: Update DSC/FDF to use NetworkPkg DSC/FDF

 Platform/RaspberryPi/RPi3/RPi3.dsc | 37 +---
 Platform/RaspberryPi/RPi3/RPi3.fdf | 17 -
 2 files changed, 23 insertions(+), 31 deletions(-)

-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#42027): https://edk2.groups.io/g/devel/message/42027
Mute This Topic: https://groups.io/mt/31974933/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v2 0/4] ArmPkg/CompilerIntrinsicsLib: Update MSFT, GCC intrinsics

2019-05-13 Thread Pete Batard

Hi Leif,

On 2019.05.13 16:56, Leif Lindholm wrote:

Hi Pete,

On Mon, May 13, 2019 at 09:54:12AM +0100, Pete Batard wrote:

This patch series cleans up and updates the CompilerIntrinsicsLib for ArmPkg.

The first patch removes sources that are no longer used and cleans up the .inf.
The second patch adds memcmp and memmove for MSFT, as I ran into missing symbols
for those while compiling a project with VS2017. Note that we are not reusing
the memmove.asm from ARM and instead adding a separate C source, as we need an
implemention that applies for both ARM and ARM64.
The third patch adds a lasr implementation, which I found was needed to fix
missing symbols when compiling with GCC/ARM on Debian 9.8.
The last patch premtpively adds references for uread/uwrite for completion.


Many thanks for this cleanup.
For the series - Reviewed-by: Leif Lindholm 
Pushed as 4ff689d982..96ef5a8e30.


Thanks.


But. One question:

When building with Visual Studio 2017, I get the following warning:
"cl : Command line warning D9025 : overriding '/GL' with '/GL-'"
(This is not caused by anything in this set.)

Should we also /wd9025 in the .inf (I think so, since we're explicitly
mucking with the toolchain here), and if so could you send an
additional patch to do that since Ard is still away and I can't sign
off my own patches? :)


Unfortunately, this is a "command line" warnings (D) and not a 
compiler warning (C) and MSVC doesn't seem to let you silence 
command line warnings.


Or at least, if they can be silenced, it's not through any option I have 
been able to figure out, as I can definitely report that /wd does not 
accept any of the D numbers.


Still, if anybody on this list knows how to silence MSVC command line 
warnings, I'd be very happy to hear from them and produce the patch you 
request, as I too have been wanting to squash these little annoyances 
for a while...


Regards,

/Pete

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#40524): https://edk2.groups.io/g/devel/message/40524
Mute This Topic: https://groups.io/mt/31605109/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v2 2/4] ArmPkg/CompilerIntrinsicsLib: Add memcmp, memmove intrinsics for MSFT

2019-05-13 Thread Pete Batard
We could have reused memmove.asm for ARM, but we would still need to add
an implemention for ARM64, so we use the same source for both archs.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Signed-off-by: Pete Batard 
---
 ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf |  2 ++
 ArmPkg/Library/CompilerIntrinsicsLib/memcmp_ms.c   | 31 
++
 ArmPkg/Library/CompilerIntrinsicsLib/memmove_ms.c  | 34 

 3 files changed, 67 insertions(+)

diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf 
b/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
index 0203ecb4870f..d6cc63db75c7 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
@@ -26,6 +26,8 @@ [Sources]
 
   memcpy_ms.c  | MSFT
   memset_ms.c  | MSFT
+  memcmp_ms.c  | MSFT
+  memmove_ms.c | MSFT
 
 [Sources.ARM]
   Arm/mullu.asm| RVCT
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memcmp_ms.c 
b/ArmPkg/Library/CompilerIntrinsicsLib/memcmp_ms.c
new file mode 100644
index ..551f8e77c12f
--- /dev/null
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/memcmp_ms.c
@@ -0,0 +1,31 @@
+//--
+//
+// Copyright (c) 2019, Pete Batard. All rights reserved.
+//
+// SPDX-License-Identifier: BSD-2-Clause-Patent
+//
+//--
+
+#if defined(_M_ARM64)
+typedef unsigned __int64  size_t;
+#else
+typedef unsigned __int32  size_t;
+#endif
+
+int memcmp(void *, void *, size_t);
+#pragma intrinsic(memcmp)
+#pragma function(memcmp)
+int memcmp(const void *s1, const void *s2, size_t n)
+{
+  unsigned char const *t1 = s1;
+  unsigned char const *t2 = s2;
+
+  while (n--) {
+if (*t1 != *t2)
+  return (int)*t1 - (int)*t2;
+t1++;
+t2++;
+  }
+
+  return 0;
+}
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memmove_ms.c 
b/ArmPkg/Library/CompilerIntrinsicsLib/memmove_ms.c
new file mode 100644
index ..5b261ef8b948
--- /dev/null
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/memmove_ms.c
@@ -0,0 +1,34 @@
+//--
+//
+// Copyright (c) 2019, Pete Batard. All rights reserved.
+//
+// SPDX-License-Identifier: BSD-2-Clause-Patent
+//
+//--
+
+#if defined(_M_ARM64)
+typedef unsigned __int64  size_t;
+#else
+typedef unsigned __int32  size_t;
+#endif
+
+void* memmove(void *, const void *, size_t);
+#pragma intrinsic(memmove)
+#pragma function(memmove)
+void* memmove(void *dest, const void *src, size_t n)
+{
+  unsigned char *d = dest;
+  unsigned char const *s = src;
+
+  if (d < s) {
+while (n--)
+  *d++ = *s++;
+  } else {
+d += n;
+s += n;
+while (n--)
+  *--d = *--s;
+  }
+
+  return dest;
+}
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#40489): https://edk2.groups.io/g/devel/message/40489
Mute This Topic: https://groups.io/mt/31605110/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v2 3/4] ArmPkg/CompilerIntrinsicsLib: Add lasr ARM assembly source for GCC

2019-05-13 Thread Pete Batard
The new source is a port of the RVCT version.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Signed-off-by: Pete Batard 
---
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/lasr.S| 30 

 ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf |  1 +
 2 files changed, 31 insertions(+)

diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/lasr.S 
b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/lasr.S
new file mode 100644
index ..feeea9edd12a
--- /dev/null
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/lasr.S
@@ -0,0 +1,30 @@
+#--
+#
+# Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#--
+
+#include 
+
+#
+#UINT64
+#EFIAPI
+#__aeabi_lasr (
+#  IN UINT64  Value
+#  IN UINT32  Shift
+#  );
+#
+ASM_FUNC(__aeabi_lasr)
+  subs r3,r2,#0x20
+  bpl  L_Test
+  rsb  r3,r2,#0x20
+  lsr  r0,r0,r2
+  orr  r0,r0,r1,LSL r3
+  asr  r1,r1,r2
+  bx   lr
+L_Test:
+  asr  r0,r1,r3
+  asr  r1,r1,#31
+  bx   lr
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf 
b/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
index d6cc63db75c7..aaf3de02a952 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
@@ -68,6 +68,7 @@ [Sources.ARM]
   Arm/sourcery.S   | GCC
   Arm/uldiv.S  | GCC
   Arm/ldivmod.S| GCC
+  Arm/lasr.S   | GCC
   Arm/llsr.S   | GCC
   Arm/llsl.S   | GCC
 
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#40491): https://edk2.groups.io/g/devel/message/40491
Mute This Topic: https://groups.io/mt/31605112/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v2 1/4] ArmPkg/CompilerIntrinsicsLib: Remove unused sources and clean up .inf

2019-05-13 Thread Pete Batard
None of the .c/.h in Arm/ are used any more => remove them.
Also merge the CC flags for MSFT ARM and ARM64, since these are the
only archs we support for this package.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Signed-off-by: Pete Batard 
---
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/Llvm_int_lib.h|  93 ---
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/ashldi3.c |  77 --
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/ashrdi3.c |  78 --
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/clzsi2.c  |  90 ---
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/ctzsi2.c  |  92 ---
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/divdi3.c  |  71 -
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/divsi3.c  |  72 -
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/lshrdi3.c |  77 --
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/moddi3.c  |  71 -
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/modsi3.c  |  64 -
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/muldi3.c  |  92 ---
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/ucmpdi2.c |  76 --
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/udivdi3.c |  65 -
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/udivmoddi4.c  | 281 

 ArmPkg/Library/CompilerIntrinsicsLib/Arm/udivsi3.c | 105 
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldivmod.c|  37 ---
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/umoddi3.c |  66 -
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/umodsi3.c |  62 -
 ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf | 103 +++
 19 files changed, 38 insertions(+), 1634 deletions(-)

diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/Llvm_int_lib.h 
b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/Llvm_int_lib.h
deleted file mode 100644
index 38bcad6b90cc..
--- a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/Llvm_int_lib.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/** @file
-
-  Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
-
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-/**
-  University of Illinois/NCSA
-  Open Source License
-
-  Copyright (c) 2003-2008 University of Illinois at Urbana-Champaign.
-  All rights reserved.
-
-  Developed by:
-
-  LLVM Team
-
-  University of Illinois at Urbana-Champaign
-
-  http://llvm.org
-
-  Permission is hereby granted, free of charge, to any person obtaining a copy 
of
-  this software and associated documentation files (the "Software"), to deal 
with
-  the Software without restriction, including without limitation the rights to
-  use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-  of the Software, and to permit persons to whom the Software is furnished to 
do
-  so, subject to the following conditions:
-
-  * Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimers.
-
-  * Redistributions in binary form must reproduce the above copyright 
notice,
-this list of conditions and the following disclaimers in the
-documentation and/or other materials provided with the distribution.
-
-  * Neither the names of the LLVM Team, University of Illinois at
-Urbana-Champaign, nor the names of its contributors may be used to
-endorse or promote products derived from this Software without specific
-prior written permission.
-
-  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
FITNESS
-  FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-  CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH 
THE
-  SOFTWARE.
-**/
-
-#include 
-#include 
-
-#define CHAR_BIT  8
-
-typedef union {
-INT64   all;
-struct {
-UINT32 low;
-INT32  high;
-};
-} dwords;
-
-typedef union {
-UINT64  all;
-struct {
-UINT32 low;
-UINT32 high;
-};
-} udwords;
-
-// __aeabi_ return values
-typedef struct {
-  UINT64  Quotent;
-  UINT64  Remainder;
-} ulldiv_t;
-
-typedef struct {
-  INT64   Quotent;
-  INT64   Remainder;
-} lldiv_t;
-
-typedef struct {
-  UINT32  Quotent;
-  UINT32  Remainder;
-} uidiv_return;
-
-#if __GNUC__
-  #define COUNT_LEADING_ZEROS(_a)   __builtin_clz((_a))
-  #define COUNT_TRAILING_ZEROS(_a)  __builtin_ctz((_a))
-#else
-#error COUNT_LEADING_ZEROS() and COUNT_TRAILING_ZEROS() macros not ported to 
your compiler
-#endif
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ashldi3.c 
b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ashldi3.c
deleted file mode 100644
index 0a1

[edk2-devel] [PATCH v2 4/4] ArmPkg/CompilerIntrinsicsLib: Add uread, uwrite GCC assembly sources

2019-05-13 Thread Pete Batard
The new sources are a copy of the RVCT version.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Signed-off-by: Pete Batard 
---
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/uread.S   | 54 

 ArmPkg/Library/CompilerIntrinsicsLib/Arm/uwrite.S  | 53 
+++
 ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf |  2 +
 3 files changed, 109 insertions(+)

diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uread.S 
b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uread.S
new file mode 100644
index ..e8a1dbad8692
--- /dev/null
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uread.S
@@ -0,0 +1,54 @@
+#--
+#
+# Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#--
+
+#include 
+
+#
+#UINT32
+#EFIAPI
+#__aeabi_uread4 (
+#  IN VOID   *Pointer
+#  );
+#
+ASM_FUNC(__aeabi_uread4)
+ldrbr1, [r0]
+ldrbr2, [r0, #1]
+ldrbr3, [r0, #2]
+ldrbr0, [r0, #3]
+orr r1, r1, r2, lsl #8
+orr r1, r1, r3, lsl #16
+orr r0, r1, r0, lsl #24
+bx  lr
+
+#
+#UINT64
+#EFIAPI
+#__aeabi_uread8 (
+#  IN VOID   *Pointer
+#  );
+#
+ASM_FUNC(__aeabi_uread8)
+mov r3, r0
+
+ldrbr1, [r3]
+ldrbr2, [r3, #1]
+orr r1, r1, r2, lsl #8
+ldrbr2, [r3, #2]
+orr r1, r1, r2, lsl #16
+ldrbr0, [r3, #3]
+orr r0, r1, r0, lsl #24
+
+ldrbr1, [r3, #4]
+ldrbr2, [r3, #5]
+orr r1, r1, r2, lsl #8
+ldrbr2, [r3, #6]
+orr r1, r1, r2, lsl #16
+ldrbr2, [r3, #7]
+orr r1, r1, r2, lsl #24
+
+bx  lr
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uwrite.S 
b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uwrite.S
new file mode 100644
index ..9432ac431799
--- /dev/null
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uwrite.S
@@ -0,0 +1,53 @@
+#--
+#
+# Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#--
+
+#include 
+
+#
+#UINT32
+#EFIAPI
+#__aeabi_uwrite4 (
+#  IN UINT32 Data,
+#  IN VOID   *Pointer
+#  );
+#
+ASM_FUNC(__aeabi_uwrite4)
+mov r2, r0, lsr #8
+strbr0, [r1]
+strbr2, [r1, #1]
+mov r2, r0, lsr #16
+strbr2, [r1, #2]
+mov r2, r0, lsr #24
+strbr2, [r1, #3]
+bx  lr
+
+#
+#UINT64
+#EFIAPI
+#__aeabi_uwrite8 (
+#  IN UINT64 Data,
+#  IN VOID   *Pointer
+#  );
+#
+ASM_FUNC(__aeabi_uwrite8)
+mov r3, r0, lsr #8
+strbr0, [r2]
+strbr3, [r2, #1]
+mov r3, r0, lsr #16
+strbr3, [r2, #2]
+mov r3, r0, lsr #24
+strbr3, [r2, #3]
+
+mov r3, r1, lsr #8
+strbr1, [r2, #4]
+strbr3, [r2, #5]
+mov r3, r1, lsr #16
+strbr3, [r2, #6]
+mov r3, r1, lsr #24
+strbr3, [r2, #7]
+bx  lr
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf 
b/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
index aaf3de02a952..d5bad9467758 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
@@ -71,6 +71,8 @@ [Sources.ARM]
   Arm/lasr.S   | GCC
   Arm/llsr.S   | GCC
   Arm/llsl.S   | GCC
+  Arm/uread.S  | GCC
+  Arm/uwrite.S | GCC
 
   Arm/div.asm  | MSFT
   Arm/uldiv.asm| MSFT
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#40492): https://edk2.groups.io/g/devel/message/40492
Mute This Topic: https://groups.io/mt/31605113/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] tool chain tag setting for vs2017

2019-05-08 Thread Pete Batard

Hi Flynn,

On 2019.05.08 09:00, " wrote:

Hey guys,

I may found a problem here..

I'm trying to build tianocore with visual studio 2017, the tianocore 
commit id is

df7c81b5b219c9aee776baa466dd64c9d318dd80(Tue Apr 30 10:16:01 2019),
after seting up the build environment and change TOOL_CHAIN_TAG to VS2017x86
according from 
https://github.com/tianocore/tianocore.github.io/wiki/Windows-systems-ToolChain-Matrix


The first thing that needs to be pointed out is that the 
ToolChain-Matrix has not been updated for VS2017, so you need to be 
careful about extrapolating what applies for VS2015 or VS2013 to VS2017.



, then build, the process will terminate with error message:
*[VS2017x86] not defined. No toolchain available for build! *


Indeed. That's because we are now using a separate VS2017_HOST 
(currently set to 'x86' by default) to identify the architecture of the 
host platform tools, so we're not using VS2017x86 any more.


After several tries, i change TOOL_CHAIN_TAG to *VS2017 *instead of 
VS2017x86,
then the problem solved, i'm not sure if vs2017 setting is inconsistent 
with vs2015 or vs2010..

or i have wrong setting somewhere else?


You should just use VS2017. And of course, we'll need to update the 
Matrix to make that information public as well.


If you are seeing issues after setting TOOL_CHAIN_TAG to VS2017, please 
let us know.


Regards,

/Pete

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#40196): https://edk2.groups.io/g/devel/message/40196
Mute This Topic: https://groups.io/mt/31541648/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH 1/1] ArmPkg/CompilerIntrinsicsLib: Add lasr assembly source for gcc/arm

2019-05-07 Thread Pete Batard
While compiling drivers or applications on Debian 9.8, using the native
gcc 6.3.0 ARM compiler, one may run into the following build failure:

  "undefined reference to `__aeabi_lasr'"

This patch adds the missing definition, through a port of the existing
RVCT lasr.asm source.

CC: Ard Biesheuvel 
CC: Leif Lindholm 
Signed-off-by: Pete Batard 
---
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/lasr.S| 22 

 ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf |  1 +
 2 files changed, 23 insertions(+)

diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/lasr.S 
b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/lasr.S
new file mode 100644
index ..9ded045b8bc4
--- /dev/null
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/lasr.S
@@ -0,0 +1,22 @@
+#--
+#
+# Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#--
+
+#include 
+
+ASM_FUNC(__aeabi_lasr)
+  subs r3,r2,#0x20
+  bpl  L_Test
+  rsb  r3,r2,#0x20
+  lsr  r0,r0,r2
+  orr  r0,r0,r1,LSL r3
+  asr  r1,r1,r2
+  bx   lr
+L_Test:
+  asr  r0,r1,r3
+  asr  r1,r1,#31
+  bx   lr
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf 
b/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
index 0d5634959993..7cb8f194f210 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
@@ -90,6 +90,7 @@ [Sources.ARM]
   Arm/uldiv.S  | GCC
   Arm/ldivmod.S| GCC
 
+  Arm/lasr.S   | GCC
   Arm/llsr.S   | GCC
   Arm/llsl.S   | GCC
 
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#40123): https://edk2.groups.io/g/devel/message/40123
Mute This Topic: https://groups.io/mt/31533433/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



<    1   2   3   4   5