/*-----------------------------------------------------------------------------------
!
!                              COPYRIGHT 2015 BY
!                            MegaChips Corporation
!
!------------------------------------------------------------------------------------
! These coded instructions, statements, and computer programs include
! intellectual property and know-how belonging to MegaChips
! Corporaiton ("MCC") and its partner companies.
! Therefore, do not use these specifications for any purpose other than
! the purpose
! expressly agreed to by MCCs customer and MCC.  Also, do not duplicate,
! copy,
! or reproduce these specifications, nor reveal these specifications to
! any third party
! without MCCs prior written consent.
!
*/
/*-----------------------------------------------------------------------------------
  FILE        : copy.c
  DESCRIPTION : copy functions for driver
  Revision    : $Rev: 4 $
  Author      : $Author: shirait $
  Date        : $Date: 2015-09-09 15:19:58 +0900 (水, 09 9 2015) $
-----------------------------------------------------------------------------------*/
#include <stdint.h>
#include <assert.h>
#include "copy.h"

#define ALIGN4  (4)


/*---------------------------------------------------------------------------
  function  : Memory copy(Peripheral to Peripheral)
  arguments : pDst : I  : destination
              pSrc : I  : source
              size : I  : copy size
  return    : void
  detail    : Copy between the Peripheral register(4Byte-aligned memory)
--------------------------------------------------------------------------*/
void MemcpyP2P(volatile void* pDst, volatile const void* pSrc, size_t size)
{
	volatile const uint32_t* pSrc32;
	volatile uint32_t* pDst32;
	size_t cnt;


	assert(NULL != pDst);
	assert(NULL != pSrc);
	assert(0 != size);
	assert(0 == (((unsigned long)pSrc) & 0x03));
	assert(0 == (((unsigned long)pDst) & 0x03));
	assert(0 == (size & 0x03));

	pSrc32 = (volatile const uint32_t*)pSrc;
	pDst32 = (volatile uint32_t*)pDst;
	for (cnt = size / ALIGN4; 0 < cnt; cnt--) {
		*pDst32 = *pSrc32;
		pDst32++;
		pSrc32++;
	}
}


