From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by mx.groups.io with SMTP id smtpd.web11.3797.1570698123559950215 for ; Thu, 10 Oct 2019 02:02:03 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=RI6FLXqV; spf=pass (domain: linaro.org, ip: 209.85.128.66, mailfrom: leif.lindholm@linaro.org) Received: by mail-wm1-f66.google.com with SMTP id f22so5880099wmc.2 for ; Thu, 10 Oct 2019 02:02:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=qA/ZNwrb85QUAqn2EiIprWOcQ/64aSp5rgzvgYhCiFE=; b=RI6FLXqVDjcGRqFXVOvVO+FhLK3srhqTYNkV3tLvGaimb/9pEdYflH7EDqXgelhvt6 3q/pE75Ps6ZnevdGZ9SBCVDPw72HDBXsPWNu7nKdZUUgQ+Fmanbx3MZoX/eDlsgVjKTt MojYZKZkw/8PXj9+/LCENgcHp1WFoIa5eM4bTF+cVDh704BIpK1uqkEDsecuvj7mnuZo qymADGLjuXTGCmPKNQ2UkfeucdPOJf4rV4kmJ9Fen8LD8LZ3d12YXu4QIHpmeI69I8s6 PvhIPghVKOstKzctSPzX8oUia2gyfVr/D8/WqVOVMM1gVh0WmrRd4hbQwRZdpvojG6ey IrHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=qA/ZNwrb85QUAqn2EiIprWOcQ/64aSp5rgzvgYhCiFE=; b=mkuKXG3eE/s4OFnpMw3+qM8Tl8WhCoz8zo41Ds4R3st7gYZSNU3SiQL0feMdVKMtqS n8OmvKbG1TjRUV2T2CV9F3PmOXpWxHOulgl4aZPBWXu87RtA5cQskPnSISddsA1/hQXo BHKikLoaZPBt44VhNRnCOb9gCG+P7K1f83V9T2uO+AB3Z/rDcOrE+Y6Qoj3Wt6hl/7Uv G7EcT0xuTjFj03LhZHW3s0P7GQ4yXBAL5LUlDmVrfCfsPVuwZXYM+dekDfzS63PFEHTO GoAiqWEJB0n2WwL8zCnUE6R5RN+oIdbzkij0SMshOSLYteoMUJxQNIh+T8IgF+sQDWyb K8tw== X-Gm-Message-State: APjAAAURBnIXAWyyR7DO8kj1BBcLzvBTLtngQcfvu/y7UKJEQv1kcrB5 1voFnBHyUWQHfAqoktyzZhGCTA== X-Google-Smtp-Source: APXvYqxmrpUijdWMbpj0gRvibflHOC0vjqonERfP+u6gIua8yEo6XirIVD77ntnvWmmYUMeJU+Q6Zw== X-Received: by 2002:a1c:7e44:: with SMTP id z65mr6636127wmc.21.1570698121936; Thu, 10 Oct 2019 02:02:01 -0700 (PDT) Return-Path: Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id f9sm7668530wre.74.2019.10.10.02.02.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2019 02:02:00 -0700 (PDT) Date: Thu, 10 Oct 2019 10:01:59 +0100 From: "Leif Lindholm" To: Pete Batard Cc: devel@edk2.groups.io, ard.biesheuvel@linaro.org Subject: Re: [edk2-platforms][PATCH v2 4/5] Platform/RPi3/PlatformSmbiosDxe: Populate BIOS major/minor from PCD Message-ID: <20191010090159.GV25504@bivouac.eciton.net> References: <20191008123841.12952-1-pete@akeo.ie> <20191008123841.12952-5-pete@akeo.ie> MIME-Version: 1.0 In-Reply-To: <20191008123841.12952-5-pete@akeo.ie> User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Oct 08, 2019 at 01:38:40PM +0100, Pete Batard wrote: > 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; Style fix only. / Leif > > /*********************************************************************** > 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*)&mBIOSInfoType0, mBIOSInfoType0Strings, NULL); > } > > -- > 2.21.0.windows.1 >