changeset 27:8abeb95e9766

l1_memcpy_16bit() moved from l1_func.c into l1_dyn_dwl_func.c
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Thu, 22 Oct 2015 22:35:35 +0000
parents 428835f700ef
children d465d2510d28
files chipsetsw/layer1/dyn_dwl_cfile/l1_dyn_dwl_func.c
diffstat 1 files changed, 56 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/chipsetsw/layer1/dyn_dwl_cfile/l1_dyn_dwl_func.c	Thu Oct 22 17:21:37 2015 +0000
+++ b/chipsetsw/layer1/dyn_dwl_cfile/l1_dyn_dwl_func.c	Thu Oct 22 22:35:35 2015 +0000
@@ -130,6 +130,62 @@
   *pp_src_mcu  = (UWORD16 *) l1_apihisr.dyn_dwnld.running_source_pointer;   
 }
 
+/*--------------------------------------------------------*/
+/* l1_memcpy_16bit()                                      */
+/*--------------------------------------------------------*/
+/*                                                        */
+/* Description:                                           */
+/* ------------                                           */
+/* This function is equivalemt of memcopy. Thid function  */
+/* does only 8/16 bit accessed to both source and         */
+/* destination                                            */
+/*                                                        */
+/* Input parameter:                                       */
+/* ---------------                                        */
+/* "src" - input pointer                                  */
+/* "len" - number of bytes to copy                        */
+/*                                                        */
+/* Output parameter:                                      */
+/* ----------------                                       */
+/*  "dst" - output pointer                                */
+/*                                                        */
+/*--------------------------------------------------------*/
+void l1_memcpy_16bit(void *dst,void* src,unsigned int len)
+{
+	unsigned int i;
+	unsigned int tempLen;
+	unsigned char *cdst,*csrc;
+	unsigned short *ssrc,*sdst;
+
+	cdst=dst;
+	csrc=src;
+	sdst=dst;
+	ssrc=src;
+
+  if(((unsigned int)src&0x01) || ((unsigned int)dst&0x01)){
+  // if either source or destination is not 16-bit aligned do the entire memcopy
+  // in 8-bit
+    for(i=0;i<len;i++){
+      *cdst++=*csrc++;
+    }
+  }
+  else{
+    // if both the source and destination are 16-bit aligned do the memcopy
+    // in 16-bits
+    tempLen = len>>1;
+    for(i=0;i<tempLen;i++){
+      *sdst++ = *ssrc++;
+    }
+    if(len & 0x1){
+      // if the caller wanted to copy odd number of bytes do a last 8-bit copy
+      cdst=(unsigned char*)sdst;
+      csrc=(unsigned char*)ssrc;
+      *cdst++ = *csrc++;
+    }
+  }
+  return;
+}
+
 /*---------------------------------------------------------------------------- */
 /* l1_copy_till_the_end_of_the_patch_and_update_write_pointer                  */
 /*---------------------------------------------------------------------------- */