From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@akeo-ie.20150623.gappssmtp.com header.s=20150623 header.b=kSxSdUyr; spf=none, err=permanent DNS error (domain: akeo.ie, ip: 209.85.221.67, mailfrom: pete@akeo.ie) Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by groups.io with SMTP; Tue, 08 Oct 2019 05:38:57 -0700 Received: by mail-wr1-f67.google.com with SMTP id r5so19157640wrm.12 for ; Tue, 08 Oct 2019 05:38:57 -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=xtZVc9+wAU6hh2UcqylYRmy/TvP3mt+zK6ZR8ZhtxLM=; b=kSxSdUyrIB3uC5A0xVdd5oMhthvJiuoCpwKdHMa1gUiVY7J5HuVO99fiURX6Xxd+zT 0c5U1mw6zQ8ttHvO5jNEbURqY+ccIyPWeewj/cZOEozWyqIxzo8vVF89/VcOvPC9iN9F bRgtwxJoOkyx35s14sznLKpXNK5yNjibZuKXkgK3VJJVpq4pv06HPcu2IglW487pZqoY c2OgBn9eT41ZrU3jq6VbKqxJjIm6zfUZa2vcndQDquDi5Z/7lZlOVwSBKBbqpUrabZtp pdWFQgAaiBEZ9UxqRe9AD2KYfH4zhtKt8m/dPRP6aI4ev/nJteggdEs4KwYYDCkqr5TJ zQfg== 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=xtZVc9+wAU6hh2UcqylYRmy/TvP3mt+zK6ZR8ZhtxLM=; b=TpradDmABuwoUh9PbtaNmEdDVLvSD7YwB+7tAjEBKr3H4b6v0bTxWwwXdSXtC5RY2s QRc5Rq1+FrUDLzhrh2/Hx2Sh/ANu6cgOYHEJrsZqKQwVkHPRmFWypuvjrOw41qgSOE1r gQQf6mfSbYMIWTU+hjmvVs4Iv69LICY27Q6gqwrfKy5QZWVD5Xd8/ykeuX4i9NWaydgf Eq31xnJh7bM42YD/UyxF5EeO1i/2xqkBO1VFqJlRTCRdpih0DgN4rdsfuNDpvgkme35N c58H86geAIQWhW5lLc6JWPsUyf1dqxwGnUDgcNttRXKnhV8rdYwoNc7KBvapCBd9gh68 0v7A== X-Gm-Message-State: APjAAAXJl1ClFC2fJUOt2I+B5vgu5gbGlvTdabEN7vuy997YM124u98a ADM8hnEu6g+rgkmcx3a4Hbus+dPROJs= X-Google-Smtp-Source: APXvYqwN3nxf3u9Ea/aIt0DszKttxAhATXtyrKHKMb4Vn0OZ0RGW0fE861Zw6L5Z9mBYAlODvOiXSA== X-Received: by 2002:a5d:5145:: with SMTP id u5mr12654653wrt.125.1570538335598; Tue, 08 Oct 2019 05:38:55 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([84.203.40.122]) by smtp.gmail.com with ESMTPSA id r6sm3203087wmh.38.2019.10.08.05.38.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Oct 2019 05:38:55 -0700 (PDT) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org Subject: [edk2-platforms][PATCH v2 2/5] Platform/RPi3/RpiFirmwareDxe: Improve serial number population Date: Tue, 8 Oct 2019 13:38:38 +0100 Message-Id: <20191008123841.12952-3-pete@akeo.ie> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20191008123841.12952-1-pete@akeo.ie> References: <20191008123841.12952-1-pete@akeo.ie> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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