diff mbox

[U-Boot,RFC,v4,11/23] net: Access mapped physmem in net functions

Message ID 1424822552-4366-12-git-send-email-joe.hershberger@ni.com
State RFC
Delegated to: Simon Glass
Headers show

Commit Message

Joe Hershberger Feb. 25, 2015, 12:02 a.m. UTC
Previously the net functions would access memory assuming physmem did
not need to be mapped.  In sandbox, that's not the case.

Now we map the physmem specified by the user in loadaddr to the buffer
that represents that space.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>

---

Changes in v4:
-New to v4

Changes in v3: None
Changes in v2: None

 net/nfs.c  | 2 +-
 net/tftp.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Simon Glass March 1, 2015, 6:07 p.m. UTC | #1
Hi Joe,

On 24 February 2015 at 17:02, Joe Hershberger <joe.hershberger@ni.com> wrote:
> Previously the net functions would access memory assuming physmem did
> not need to be mapped.  In sandbox, that's not the case.
>
> Now we map the physmem specified by the user in loadaddr to the buffer
> that represents that space.
>
> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
>
> ---
>
> Changes in v4:
> -New to v4
>
> Changes in v3: None
> Changes in v2: None
>
>  net/nfs.c  | 2 +-
>  net/tftp.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/nfs.c b/net/nfs.c
> index 381b75f..c816acd 100644
> --- a/net/nfs.c
> +++ b/net/nfs.c
> @@ -93,7 +93,7 @@ store_block(uchar *src, unsigned offset, unsigned len)
>         } else
>  #endif /* CONFIG_SYS_DIRECT_FLASH_NFS */
>         {
> -               (void)memcpy((void *)(load_addr + offset), src, len);
> +               memcpy((void *)(map_sysmem(load_addr, 0) + offset), src, len);

I think this would be better as:

               memcpy(map_sysmem(load_addr + offset, src_len), src, len);

and for consistency we should call unmap_sysmem() too.

   void *ptr = map_sysmem(load_addr + offset, src_len);

   memcpy(ptr, src, len);
   unmap_sysmem(ptr);

>         }
>
>         if (NetBootFileXferSize < (offset+len))
> diff --git a/net/tftp.c b/net/tftp.c
> index 0a2c533..9290182 100644
> --- a/net/tftp.c
> +++ b/net/tftp.c
> @@ -184,7 +184,7 @@ store_block(int block, uchar *src, unsigned len)
>         } else
>  #endif /* CONFIG_SYS_DIRECT_FLASH_TFTP */
>         {
> -               (void)memcpy((void *)(load_addr + offset), src, len);
> +               memcpy((void *)(map_sysmem(load_addr, 0) + offset), src, len);

Similar here.

>         }
>  #ifdef CONFIG_MCAST_TFTP
>         if (Multicast)
> --
> 1.7.11.5
>

Regards,
Simon
diff mbox

Patch

diff --git a/net/nfs.c b/net/nfs.c
index 381b75f..c816acd 100644
--- a/net/nfs.c
+++ b/net/nfs.c
@@ -93,7 +93,7 @@  store_block(uchar *src, unsigned offset, unsigned len)
 	} else
 #endif /* CONFIG_SYS_DIRECT_FLASH_NFS */
 	{
-		(void)memcpy((void *)(load_addr + offset), src, len);
+		memcpy((void *)(map_sysmem(load_addr, 0) + offset), src, len);
 	}
 
 	if (NetBootFileXferSize < (offset+len))
diff --git a/net/tftp.c b/net/tftp.c
index 0a2c533..9290182 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -184,7 +184,7 @@  store_block(int block, uchar *src, unsigned len)
 	} else
 #endif /* CONFIG_SYS_DIRECT_FLASH_TFTP */
 	{
-		(void)memcpy((void *)(load_addr + offset), src, len);
+		memcpy((void *)(map_sysmem(load_addr, 0) + offset), src, len);
 	}
 #ifdef CONFIG_MCAST_TFTP
 	if (Multicast)