[PATCH 1/4] rtemsbsd: Clear bus DMA memory a byte at a time

Kinsey Moore kinsey.moore at oarcorp.com
Wed Oct 20 13:42:17 UTC 2021


Looks good.

On 10/19/2021 22:16, chrisj at rtems.org wrote:
> From: Chris Johns <chrisj at rtems.org>
>
> - memset may be optimized for performance and might work
>    with device type memory. Clear a byte at a time.
> ---
>   rtemsbsd/rtems/rtems-kernel-bus-dma.c | 9 +++++++--
>   1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/rtemsbsd/rtems/rtems-kernel-bus-dma.c b/rtemsbsd/rtems/rtems-kernel-bus-dma.c
> index 45c4287d..1d28f62c 100644
> --- a/rtemsbsd/rtems/rtems-kernel-bus-dma.c
> +++ b/rtemsbsd/rtems/rtems-kernel-bus-dma.c
> @@ -9,7 +9,7 @@
>    */
>   
>   /*
> - * Copyright (c) 2009-2012 embedded brains GmbH.
> + * Copyright (c) 2009-2012 embedded brains GmbH.
>    * All rights reserved.
>    *
>    *  embedded brains GmbH
> @@ -258,7 +258,12 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
>   	(*mapp)->buffer_size = dmat->maxsize;
>   
>   	if ((flags & BUS_DMA_ZERO) != 0) {
> -		memset(*vaddr, 0, dmat->maxsize);
> +		unsigned char* mem = *vaddr;
> +		int len = dmat->maxsize;
> +		while (len-- > 0) {
> +			bsp_bus_space_write_1(mem, 0);
> +			mem++;
> +		}
>   	}
>   
>   	return (0);


More information about the devel mailing list