From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by mx.groups.io with SMTP id smtpd.web10.8156.1570792084321694081 for ; Fri, 11 Oct 2019 04:08:04 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@akeo-ie.20150623.gappssmtp.com header.s=20150623 header.b=KSwLcX2x; spf=none, err=permanent DNS error (domain: akeo.ie, ip: 209.85.221.65, mailfrom: pete@akeo.ie) Received: by mail-wr1-f65.google.com with SMTP id p14so11437231wro.4 for ; Fri, 11 Oct 2019 04:08:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akeo-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Q6uuCbF6AnCzlPNmHQBt38z+gsJX1Nput4LQL/bHnVA=; b=KSwLcX2xHosXS4dzQViqGCuEnOM7qkonGojg+IW34hGX/l+vxHrR34LF+87u3t8jr/ fS77KjPf+/er+wrwIA4Uns+GWQOuY9FvS/5PjtLiBbCv3G1kWKgYzD9u31ZIxayKqqSE mjcN+1icGDuTAJbDrysXmt3CEAPSzcSnAP2DaY/bEK5MNgpwpK935pmJoZYfd94R/tV9 65FtbqIaf335dUlPgqdrmj0kicUVycTdIVNBySaPPDn2mXrtRa8LypvOGe8QlifXHn93 knXkIkiZED4pDzOftmW5fnOOme/ngdZtQ0t4KooOMkNqrGNsZc3CHKbNFAkxBi2uQ1uK rtyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Q6uuCbF6AnCzlPNmHQBt38z+gsJX1Nput4LQL/bHnVA=; b=SSkSPsOzkX3ZhkLvQJhBjHxjjfgETFNux7LRITeUZ83lST51cU2q3wox7BKAslunTF KQmBgrXsm4duum/uZAQdJmcLAHPZvVKVhrfzDKRXUj+7+V0XAhUhdoGq7Q3VxS171Hm0 tvj4jV8LuyCP2vLu5iDvz/wDVo34i+W+aKXRZ2se23BXfbiWnRL4+hudEaUYIx1WBytS QnLHqBPw23YZgw1qLRw0UqkGHtDSxg39qbP/66J9CYVitFbt9W+i5SRWGxS+hA4yNNbJ XSpRAM581WnGjmpUcBU8vYwa4Zz6U1qxfw6S3ZF+ndlilg4TMn0I+dEWHCVEQ4UBoEsy oOXw== X-Gm-Message-State: APjAAAWIWQ8qvHtnIuZ6/kCn113Am+UdeDtehk+oAuOlMjUjDVPDHaZ9 fCOrx3HR8m1dIw+nC1v49QvNwZzko88= X-Google-Smtp-Source: APXvYqzLbUTwBNY+NViZzYx2NUqhiBfpjCcAzhjO5/xZES2B0tTX1gn6IZnOcF7MfRPTLqS51bQJDg== X-Received: by 2002:adf:ea86:: with SMTP id s6mr12236180wrm.397.1570792082643; Fri, 11 Oct 2019 04:08:02 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([84.203.40.122]) by smtp.gmail.com with ESMTPSA id r18sm12806044wme.48.2019.10.11.04.08.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Oct 2019 04:08:02 -0700 (PDT) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org Subject: [edk2-platforms][PATCH v3 4/5] Platform/RPi3/PlatformSmbiosDxe: Populate BIOS major/minor from PCD Date: Fri, 11 Oct 2019 12:07:45 +0100 Message-Id: <20191011110746.1952-5-pete@akeo.ie> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20191011110746.1952-1-pete@akeo.ie> References: <20191011110746.1952-1-pete@akeo.ie> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 | 45 ++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c index 9150dcfd8c5b..b5dcff897a59 100644 --- a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c +++ b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c @@ -41,6 +41,8 @@ #include #include +#define SMB_IS_DIGIT(c) (((c) >= '0') && ((c) <= '9')) + STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL *mFwProtocol; /*********************************************************************** @@ -597,6 +599,9 @@ BIOSInfoUpdateSmbiosType0 ( { UINT32 FirmwareRevision = 0; EFI_STATUS Status = EFI_SUCCESS; + INTN i; + INTN State = 0; + INTN Value[2]; // Populate the Firmware major and minor. Status = mFwProtocol->GetFirmwareRevision (&FirmwareRevision); @@ -618,6 +623,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*)&mBIOSInfoType0, mBIOSInfoType0Strings, NULL); } -- 2.21.0.windows.1