From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=34.238.86.106; helo=mail.paulo.ac; envelope-from=paulo@paulo.ac; receiver=edk2-devel@lists.01.org Received: from mail.paulo.ac (mail.paulo.ac [34.238.86.106]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 2A7A821D2BF05 for ; Thu, 25 Jan 2018 11:47:14 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by mail.paulo.ac (Postfix) with ESMTP id B07CCC0C972; Thu, 25 Jan 2018 19:52:43 +0000 (UTC) X-Virus-Scanned: amavisd-new at paulo.ac X-Spam-Flag: NO X-Spam-Score: -1.099 X-Spam-Level: X-Spam-Status: No, score=-1.099 tagged_above=-999 required=6.31 tests=[ALL_TRUSTED=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no Authentication-Results: mail.paulo.ac (amavisd-new); dkim=pass (1024-bit key) header.d=paulo.ac Received: from mail.paulo.ac ([127.0.0.1]) by localhost (mail.paulo.ac [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bAWHQ5SZ5gLY; Thu, 25 Jan 2018 19:52:42 +0000 (UTC) Received: from [100.125.200.179] (unknown [177.79.74.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.paulo.ac (Postfix) with ESMTPSA id 87118C83CF8; Thu, 25 Jan 2018 19:52:41 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.paulo.ac 87118C83CF8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=paulo.ac; s=default; t=1516909962; bh=G0x0wdpXFMClC5X31JB23XdrJaNwjPPcKIb0XOTkVgk=; h=Date:In-Reply-To:References:Subject:To:From:From; b=DL3IF1Pdk2IcOflsK3a+pBBO4jtgdvhOri3+ScxJTm8oAcshH8U90tkjZlgf0M4Il JcktJdiU3fk3JbUePWJjk3oZgRrM+ankf53Zvk47JWNOYJWTnDhhs5w4FlKzdjSRiy S42cUK3UvNoRoqZ+3QpRl5eOU68d6tnU8+/g2iVg= Date: Thu, 25 Jan 2018 17:52:36 -0200 User-Agent: K-9 Mail for Android In-Reply-To: References: MIME-Version: 1.0 To: edk2-devel@lists.01.org, Rafael Machado , "edk2-devel@lists.01.org" From: Paulo Alcantara Message-ID: Subject: Re: DMA Buffer write operation not persisted X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Jan 2018 19:47:15 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On January 25, 2018 4:53:06 PM GMT-02:00, Rafael Machado wrote: >Hi everyone=2E > >I'm currently work on a task, and I need to write some data at a DMA >buffer=2E >At the UEFI Driver Writer's guide, at page 359 there is a sample code >of >how to do that=2E > >Considering that code and adapting to my scenario I got the following >function (some debug prints are present for clarification): > >EFI_STATUS >EFIAPI >DoBusMasterWrite ( > IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciIo, > IN UINT8 *HostAddress, > IN UINTN *Length, > IN UINT32 Value >) >{ > EFI_STATUS Status; > UINTN NumberOfBytes; > EFI_PHYSICAL_ADDRESS DeviceAddress; > VOID *Mapping; > UINT64 ReadValue; > > // > // Call Map() to retrieve the DeviceAddress to use for the bus > // master write operation=2E The Map() function may not support > // performing a DMA operation for the entire length, so it may > // be broken up into smaller DMA operations=2E > // > NumberOfBytes =3D *Length; > Status =3D PciIo->Map (PciIo, // This > > EfiPciIoOperationBusMasterCommonBuffer, // Operation > (VOID *)HostAddress, // HostAddress > &NumberOfBytes, // NumberOfBytes > &DeviceAddress, //DeviceAddress > &Mapping //Mapping); > > if (EFI_ERROR (Status)) { > return Status; > } > > // > // Write the data to the desired address > // This write operation also starts the DMA transaction > // > Status =3D PciIo->Mem=2EWrite (PciIo, // This > EfiPciIoWidthUint32, // Width > *HostAddress, > 1, // Count > &Value // Buffer > ); I'm not sure, but I think you're passing the wrong value to the 3rd parame= ter (Address)=2E Shouldn't that be "(UINT64)(UINTN)HostAddress"? Paulo > > Print(L"NumberOfBytes: %d\r\n", NumberOfBytes); > Print(L"address: 0x%x\r\n", HostAddress); > Print(L"Value: 0x%x\r\n", Value); > Print(L"Status: %r\r\n", Status); > > if (EFI_ERROR (Status)) { >return Status; > } > > // > // The operations performed by PollMem() also flush all posted > // writes from the PCI bus master and through PCI-to-PCI bridges=2E > // > Status =3D PciIo->PollMem (PciIo, // This > EfiPciIoWidthUint32, // Width > *HostAddress, // Offset > 0xFFFFFFFF,// Mask > Value,// Value > EFI_TIMER_PERIOD_SECONDS >(1), // Timeout > &ReadValue // Result > ); > Print(L"Status2: %r\r\n", Status); > > if (EFI_ERROR (Status)) { >return Status; > } > > // > // Call Flush() to flush all write transactions to system memory > // > Status =3D PciIo->Flush (PciIo); > Print(L"Status3: %r\r\n", Status); > > if (EFI_ERROR (Status)) { >return Status; > } > > // > // Call Unmap() to complete the bus master write operation > // > Status =3D PciIo->Unmap (PciIo, Mapping); > Print(L"Status4: %r\r\n", Status); > > if (EFI_ERROR (Status)) { >return Status; > } > return Status; >} > >The output of this function is this: > NumberOfBytes: 4 > address: 0xCCCAC000 > Value: 0xAAAAA > Status: Success > Status2: Success > Status3: Success > Status4: Success > >The problem is that when I try to read this memory content using the >dmem >command at the efiShell the value 0xAAAAA cannot be found=2E Seems >something >is locking the DMA trasaction=2E >Can someone give me some light? > >Thanks and Regard >Rafael R=2E Machado >_______________________________________________ >edk2-devel mailing list >edk2-devel@lists=2E01=2Eorg >https://lists=2E01=2Eorg/mailman/listinfo/edk2-devel --=20 Sent from my Android device with K-9 Mail=2E Please excuse my brevity=2E