From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt0-x229.google.com (mail-qt0-x229.google.com [IPv6:2607:f8b0:400d:c0d::229]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 89F3921A143DA for ; Thu, 8 Jun 2017 20:54:23 -0700 (PDT) Received: by mail-qt0-x229.google.com with SMTP id u19so63607376qta.3 for ; Thu, 08 Jun 2017 20:55:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=1CX9XIEjjcdw1csxLbt8BP2S8jw6FHTZIPM1YNyAAdQ=; b=T5xO5Jm2pyLCwD+lo4AjGkPuveYdGUqnBls5x92PzW+UMGns6TJf/I8Adv0xtq6sDh /+N9/3eSVQe18GY6imFQMgy1BtwkYGykpytr9yRFrVaMo4S5prAwIdyPUTBGRll22wB2 /uIZYckh51ifHGYpt4psdaLMVZtY3xzYATPLM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=1CX9XIEjjcdw1csxLbt8BP2S8jw6FHTZIPM1YNyAAdQ=; b=p8T4FXDDzGWn8CvMK8mKYnbMclTEYEluDk4C0hFv2oP3asPX9+KUu1g+rO2qZDErIb yCmhWw58VOeudeLBsjhLtdbtY/d2sqkIimI+uhfrsnNOavxlKk7abkQDChodVmL8poC6 kRlzKqgB47JknIjIhyWhvho6z29u+9cmGDoNKAqVQ9ImYVBT5ncLTNqlqkQZOlmZg/Eo FAQawJN2r4CQBx+5evRwr+BJz0LjEhLvjZNRRuKfBbXx6FOm9c38iJ5B8GA2RwXPH3jY X/XQJf9/4c26QlDw4dvjCEin54csLVkZWS2VKuhtwKXksIlXUt69gp+nYNnZaRnhTq1+ kahg== X-Gm-Message-State: AODbwcDazmdZdLIhx+t9p0bpzrzEX6K19WR+w8hwJTMtAoibxBNhRgOz oo1LlFVXXjednqe1n3l9RjAhAKhVdj4m X-Received: by 10.237.58.71 with SMTP id n65mr19841811qte.160.1496980532477; Thu, 08 Jun 2017 20:55:32 -0700 (PDT) MIME-Version: 1.0 Received: by 10.55.0.69 with HTTP; Thu, 8 Jun 2017 20:55:31 -0700 (PDT) In-Reply-To: <1235B084-B1C5-490B-89CC-BC88BF652FB5@apple.com> References: <1496909927-16812-1-git-send-email-jun.nie@linaro.org> <1235B084-B1C5-490B-89CC-BC88BF652FB5@apple.com> From: Jun Nie Date: Fri, 9 Jun 2017 11:55:31 +0800 Message-ID: To: Andrew Fish Cc: Olivier Martin , Haojian Zhuang , edk2-devel@lists.01.org, Jason Liu , Shawn Guo Subject: Re: [PATCH] EmbeddedPkg/MmcDxe: Add alignment for ECSD data X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Jun 2017 03:54:23 -0000 Content-Type: text/plain; charset="UTF-8" 2017-06-08 22:55 GMT+08:00 Andrew Fish : > > On Jun 8, 2017, at 1:18 AM, Jun Nie wrote: > > Add alignment for ECSD data for DMA access. Otherwise > the data is corrupted on Sanechips platform. > > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Jun Nie > --- > EmbeddedPkg/Universal/MmcDxe/Mmc.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/EmbeddedPkg/Universal/MmcDxe/Mmc.h > b/EmbeddedPkg/Universal/MmcDxe/Mmc.h > index 8a7d5a3..ca1a9d5 100644 > --- a/EmbeddedPkg/Universal/MmcDxe/Mmc.h > +++ b/EmbeddedPkg/Universal/MmcDxe/Mmc.h > @@ -319,7 +319,7 @@ typedef struct { > OCR OCRData; > CID CIDData; > CSD CSDData; > - ECSD ECSDData; // MMC V4 extended card > specific > + ECSD ECSDData __attribute__((aligned(8))); // MMC V4 extended card > specific > } CARD_INFO; > > > Jun, > > This structure does not look portable. > 1) CARD_TYPE is an ENUM and the size of an enum is not a standard thing in > C. Compiler is probably picking int and it seems to work. > 2) I don't think __attribute__((aligned(8))) is supported by all the edk2 > compilers (VC++ for example). It is an GNU extensions to C, not standard C, > so we normally don't use it in edk2 code. > > While the alignment of types is not defined by the C standard, it is defined > in the EFI ABI to be natural alignment. So you can add padding elements to a > structure. You can also union with a UINT64 for force 8 byte alignment. > > typedef struct { > UINT16 RCA; > UINT32 CardType; //CARD_TYPE > OCR OCRData; > CID CIDData; > CSD CSDData; > UINT32 Pad; > ECSD ECSDData; // MMC V4 extended card > specific > } CARD_INFO; > > Thanks, > > Andrew Fish Thanks for showing this robust method. Will change to this way. Jun > > typedef struct _MMC_HOST_INSTANCE { > -- > 1.9.1 > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel > >