changeset 21:dfc7b0bc468a

L1/dyn_dwl_cfile/*.c: initial import from tcs211-l1-reconst
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 10 Jun 2016 08:59:53 +0000
parents 5fd4e7669c93
children fc33e796507a
files L1/dyn_dwl_cfile/l1_dyn_dwl_afunc.c L1/dyn_dwl_cfile/l1_dyn_dwl_apihisr.c L1/dyn_dwl_cfile/l1_dyn_dwl_async.c L1/dyn_dwl_cfile/l1_dyn_dwl_func.c L1/dyn_dwl_cfile/l1_dyn_dwl_init.c L1/dyn_dwl_cfile/l1_dyn_dwl_sync.c
diffstat 6 files changed, 192 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- a/L1/dyn_dwl_cfile/l1_dyn_dwl_afunc.c	Fri Jun 10 08:56:53 2016 +0000
+++ b/L1/dyn_dwl_cfile/l1_dyn_dwl_afunc.c	Fri Jun 10 08:59:53 2016 +0000
@@ -7,11 +7,10 @@
  *
  ************* Revision Controle System Header *************/
 
-#include "config.h"
 #include "l1_confg.h"
 #include "l1_types.h"
 #include "sys_types.h"
-#include "../../gpf/inc/cust_os.h"
+#include "cust_os.h"
 #include "l1_macro.h"
 #include "l1_const.h"
 #if TESTMODE
@@ -188,7 +187,7 @@
 {
   UWORD16 j;
   UWORD16 counter=0;
-  UWORD16 msg_code_id=0 ;//omaps00090550
+  UWORD16 msg_code_id;
 
   // Check if one of the messages belongs to the set of primitves which triggers a dynamic download and saves its index
 
@@ -411,6 +410,50 @@
   }
 }
 
+/*
+ * TCS211 had l1_disable_DSP_trace() and l1_enable_DSP_trace() functions
+ * implemented here in the l1_dyn_dwl code.  The LoCosto version of L1
+ * has l1_{dis,en}able_dsp_trace() instead (note the case difference)
+ * implemented in the l1_trace.c module.  The LoCosto versions of these
+ * functions implement more complex logic with nesting, and use more
+ * state variables than are provided in TCS211 L1 data structures which
+ * we cannot change at this early phase of deblobbing.  Therefore,
+ * we are going to recreate the simpler logic of the older
+ * l1_{dis,en}able_DSP_trace() functions from disassembly.
+ */
+
+void l1_disable_DSP_trace()
+{
+#if (CODE_VERSION != SIMULATION)
+  T_NDB_MCU_DSP* dsp_ndb_ptr = (T_NDB_MCU_DSP *) NDB_ADR;
+#else
+  T_NDB_MCU_DSP* dsp_ndb_ptr = l1s_dsp_com.dsp_ndb_ptr;
+#endif
+
+  if (dsp_ndb_ptr->d_debug_trace_type != 0x0000)
+  {
+    l1a.dyn_dwnld.dsp_trace_level_copy = dsp_ndb_ptr->d_debug_trace_type;
+    dsp_ndb_ptr->d_debug_trace_type = (API)0x8000;	/* 0x9000 in LoCosto */
+    l1a.dyn_dwnld.trace_flag_blocked = TRUE;
+  }
+}
+
+void l1_enable_DSP_trace()
+{
+#if (CODE_VERSION != SIMULATION)
+  T_NDB_MCU_DSP* dsp_ndb_ptr = (T_NDB_MCU_DSP *) NDB_ADR;
+#else
+  T_NDB_MCU_DSP* dsp_ndb_ptr = l1s_dsp_com.dsp_ndb_ptr;
+#endif
+
+  if ((l1a.dyn_dwnld.trace_flag_blocked == TRUE) && (dsp_ndb_ptr->d_debug_trace_type == 0x0000))
+  {
+    l1a.dyn_dwnld.trace_flag_blocked = FALSE;
+
+    dsp_ndb_ptr->d_debug_trace_type = (API)l1a.dyn_dwnld.dsp_trace_level_copy | 0x8000;
+    l1a.dyn_dwnld.dsp_trace_level_copy = 0x0000;
+  }
+}
 
 /*---------------------------------------------------------- */
 /* l1_push_Primitive                                         */
--- a/L1/dyn_dwl_cfile/l1_dyn_dwl_apihisr.c	Fri Jun 10 08:56:53 2016 +0000
+++ b/L1/dyn_dwl_cfile/l1_dyn_dwl_apihisr.c	Fri Jun 10 08:59:53 2016 +0000
@@ -9,11 +9,9 @@
 
 #include <stdio.h>
 #include <string.h>
-#include "config.h"
+#include "nucleus.h"
 #include "l1_confg.h"
 #include "sys_types.h"
-#include "../../riviera/rv/rv_general.h"
-#include "../../nucleus/nucleus.h"
 #include "l1_types.h"
 #include "l1audio_cust.h"
 #include "l1audio_defty.h"
@@ -43,7 +41,7 @@
 #endif
 
 #include "l1_defty.h"
-#include "../../gpf/inc/cust_os.h"
+#include "cust_os.h"
 /* #include "nu_main.h" */
 #include "l1audio_signa.h"
 #include "l1audio_cust.h"
--- a/L1/dyn_dwl_cfile/l1_dyn_dwl_async.c	Fri Jun 10 08:56:53 2016 +0000
+++ b/L1/dyn_dwl_cfile/l1_dyn_dwl_async.c	Fri Jun 10 08:59:53 2016 +0000
@@ -8,13 +8,11 @@
  ************* Revision Controle System Header *************/
 #include <stdio.h>
 #include <string.h>
-#include "config.h"
+#include "nucleus.h"
 #include "l1_confg.h"
+#include "l1_types.h"
 #include "sys_types.h"
-#include "../../riviera/rv/rv_general.h"
-#include "../../nucleus/nucleus.h"
-#include "l1_types.h"
-#include "../../gpf/inc/cust_os.h"
+#include "cust_os.h"
 #include "l1audio_signa.h"
 #include "l1audio_const.h"
 #include "l1audio_cust.h"
@@ -46,7 +44,11 @@
 #include "l1_defty.h"
 #include "l1_varex.h"
 #include "l1_trace.h"
-/* #include "sys_dma.h" */
+#include "sys_dma.h"
+
+#if (OP_RIV_AUDIO == 1)
+  #include "rv/rv_general.h"
+#endif
 
 
 #if (L1_DYN_DSP_DWNLD == 1)
@@ -177,7 +179,7 @@
   UWORD16 i;
   UWORD16 patch_id_uninstall_vect[MAX_NUM_OF_PATCH_IDS];
   UWORD16 patch_id;
-  UWORD16 temp_patch_id[MAX_NUM_OF_PATCH_IDS]= {0}; //omaps00090550
+  UWORD16 temp_patch_id[MAX_NUM_OF_PATCH_IDS];
   BOOL return_flag = FALSE;
 
   // Primitive is processed only if it triggers a dynamic download or there is a delay
@@ -263,7 +265,7 @@
 #if ((TRACE_TYPE == 1) || (TRACE_TYPE == 4) || (TRACE_TYPE == 5))
         if((trace_info.current_config->l1_dyn_trace) & (1<<L1_DYN_TRACE_DYN_DWNLD))
         {
-          char str[16];
+          char str[18];
           sprintf(str,"UNINST_ID: %d \r\n", element);
 #if(CODE_VERSION == SIMULATION)
           trace_fct_simu_dyn_dwnld(str);
@@ -328,7 +330,7 @@
 #if ((TRACE_TYPE == 1) || (TRACE_TYPE == 4) || (TRACE_TYPE == 5))
       if((trace_info.current_config->l1_dyn_trace) & (1<<L1_DYN_TRACE_DYN_DWNLD))
       {
-        char str[22];
+        char str[18];
         sprintf(str,"DWNLD_ID: %d \r\n", patch_id);
 
 #if(CODE_VERSION == SIMULATION)
@@ -386,7 +388,7 @@
 
 #if ((TRACE_TYPE == 1) || (TRACE_TYPE == 4))
   // Disable trace DSP upon Dynamic Download activation
-  l1_disable_dsp_trace();
+  l1_disable_DSP_trace();
 #endif
           
   // Reset API variables
@@ -638,6 +640,7 @@
             
             //  Check if there is any pending primitive waiting to be de-queued
             {
+#if 0	/* LoCosto code */
               UWORD32 remaining_primitive_flag=0;
               UWORD32 process_continue_flag=1;
               UWORD32 delay_primitive_processed_flag=0;
@@ -655,15 +658,15 @@
                   l1a_apihisr_com.dyn_dwnld.command.restart = TRUE;
 
                   /********** WORKAROUND *************/
-#if 1 //(OP_RIV_AUDIO == 1)
+                #if (OP_RIV_AUDIO == 1)
                   {
                     // WARNING: temporary until os_activate_hisr() is declared in L3 functions
                     extern NU_HISR apiHISR;
                     NU_Activate_HISR(&apiHISR);
                   }
-#else
+                #else
                   os_activate_hisr(API_HISR);
-#endif // OP_RIV_AUDIO == 1         
+                #endif // OP_RIV_AUDIO == 1         
                   /********** WORKAROUND *************/
                   *state = WAIT_RESULT;
                 }
@@ -673,14 +676,50 @@
               // else stop the DSP background task as no other patch must be downloaded
               if(delay_primitive_processed_flag == 0)
               {
-#if ((TRACE_TYPE == 1) || (TRACE_TYPE == 4))
+              #if ((TRACE_TYPE == 1) || (TRACE_TYPE == 4))
                 // Enable trace DSP upon Dynamic Download deactivation
-                l1_enable_dsp_trace();
+                l1_enable_DSP_trace();
                 //Trace_dsp_dump();
-#endif  // omaps00090550 #14-D removal
+              #endif  // omaps00090550 #14-D removal
                 l1a_l1s_com.dyn_dwnld_task.stop=TRUE;
                 *state = WAIT_STOP;
               }
+
+#else	/* TCS211 reconstruction from disassembly */
+
+              if (l1_check_Fifo_Primitive() != 0)
+              {
+                l1_pop_Primitive(&(delay_primitive));
+                if (l1_dynamic_download_manager(delay_primitive, TRUE) == TRUE)
+                {
+                  // If yes set the restart command at apihisr level
+                  l1a_apihisr_com.dyn_dwnld.command.restart = TRUE;
+
+                  /********** WORKAROUND *************/
+                #if (OP_RIV_AUDIO == 1)
+                  {
+                    // WARNING: temporary until os_activate_hisr() is declared in L3 functions
+                    extern NU_HISR apiHISR;
+                    NU_Activate_HISR(&apiHISR);
+                  }
+                #else
+                  os_activate_hisr(API_HISR);
+                #endif // OP_RIV_AUDIO == 1         
+                  /********** WORKAROUND *************/
+                  *state = WAIT_RESULT;
+                }
+              }
+              else
+              {
+              #if ((TRACE_TYPE == 1) || (TRACE_TYPE == 4))
+                // Enable trace DSP upon Dynamic Download deactivation
+                l1_enable_DSP_trace();
+                //Trace_dsp_dump();
+              #endif  // omaps00090550 #14-D removal
+                l1a_l1s_com.dyn_dwnld_task.stop=TRUE;
+                *state = WAIT_STOP;
+              }
+#endif
             }
           }
           break;
--- a/L1/dyn_dwl_cfile/l1_dyn_dwl_func.c	Fri Jun 10 08:56:53 2016 +0000
+++ b/L1/dyn_dwl_cfile/l1_dyn_dwl_func.c	Fri Jun 10 08:59:53 2016 +0000
@@ -9,7 +9,6 @@
 
 #include <stdio.h>
 #include <string.h>
-#include "config.h"
 #include "l1_confg.h"
 #include "l1_types.h"
 #include "l1_const.h"        
@@ -131,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                  */
 /*---------------------------------------------------------------------------- */
--- a/L1/dyn_dwl_cfile/l1_dyn_dwl_init.c	Fri Jun 10 08:56:53 2016 +0000
+++ b/L1/dyn_dwl_cfile/l1_dyn_dwl_init.c	Fri Jun 10 08:59:53 2016 +0000
@@ -6,11 +6,9 @@
  *  Copyright 2004 (C) Texas Instruments
  *
  ************* Revision Controle System Header *************/
-#include "config.h"
+#include "nucleus.h"
 #include "l1_confg.h"
 #include "sys_types.h"
-#include "../../riviera/rv/rv_general.h"
-#include "../../nucleus/nucleus.h"
 #include "l1_types.h"
 #include "l1audio_const.h"
 #include "l1audio_cust.h"
@@ -39,7 +37,7 @@
 #endif //L1_AAC
 
 #include "l1_defty.h"
-#include "../../gpf/inc/cust_os.h"
+#include "cust_os.h"
 /* #include "nu_main.h" */
 #include "l1audio_signa.h"
 #include "l1_varex.h"
@@ -111,7 +109,6 @@
 void l1_dyn_dwnld_initialize_var()
 {
   UWORD16 i;
-  
 
   /* Init Dynamic Download NDB */
   dyn_dwl_ndb=(T_DYN_DWNLD_MCU_DSP *)API_address_dsp2mcu(C_DYN_DWNLD_API_BASE_ADDRESS);
@@ -130,32 +127,48 @@
     l1s_dsp_com.dsp_ndb_ptr->d_max_background=(API)(C_BGD_DSP_DYN_DWNLD+1);
 
   dyn_dwnld_copy_MCU_vect[0] = gprs_patch_array;
+  l1_set_dyn_dwnld_install_vect(size_vect,dyn_dwnld_address_vect,dyn_dwnld_crc_vect, gprs_patch_array, 0);
+
   dyn_dwnld_copy_MCU_vect[1] = amr_sch_patch_array;
+  l1_set_dyn_dwnld_install_vect(size_vect,dyn_dwnld_address_vect,dyn_dwnld_crc_vect, amr_sch_patch_array, 1);
+
   #if (L1_GTT == 1)
     dyn_dwnld_copy_MCU_vect[2] = tty_patch_array;
+    l1_set_dyn_dwnld_install_vect(size_vect,dyn_dwnld_address_vect,dyn_dwnld_crc_vect, tty_patch_array, 2);
   #endif
+
   #if (MELODY_E2 == 1)
     dyn_dwnld_copy_MCU_vect[3] = amr_mms_patch_array;
+    l1_set_dyn_dwnld_install_vect(size_vect,dyn_dwnld_address_vect,dyn_dwnld_crc_vect, amr_mms_patch_array, 3);
     dyn_dwnld_copy_MCU_vect[4] = e2_patch_array;
+    l1_set_dyn_dwnld_install_vect(size_vect,dyn_dwnld_address_vect,dyn_dwnld_crc_vect, e2_patch_array, 4);
   #endif
 
-  for(i=0;i<MAX_NUM_OF_PATCH_IDS;i++)
-  {
-    if (dyn_dwnld_copy_MCU_vect[i] != 0)
-    {
-      l1_set_dyn_dwnld_install_vect(size_vect,dyn_dwnld_address_vect,dyn_dwnld_crc_vect,dyn_dwnld_copy_MCU_vect[i],i);
-    }
-  }
-
   /*---------- Set L1A globals at phone init ----------------------------*/
   l1a.dyn_dwnld.melody0_E2_flag_activated = FALSE;
   l1a.dyn_dwnld.melody1_E2_flag_activated = FALSE;
+  l1a.dyn_dwnld.dedicated_stop_flag       = FALSE;
+
+  l1a.dyn_dwnld.num_patches_installed     = 2;
   l1a.dyn_dwnld.state                     = 0;
-  
+  l1a.dyn_dwnld.dsp_trace_level_copy      = 0;
+
+  l1a.dyn_dwnld.patch_id[0] = GPRS_PATCH;
+  l1a.dyn_dwnld.patch_id[1] = AMR_MMS_PATCH;
 
-  l1a.dyn_dwnld.num_patches_installed     = 0;  
+  for (i=l1a.dyn_dwnld.num_patches_installed;i<MAX_NUM_OF_PATCH_IDS;i++)
+  {  
+    l1a.dyn_dwnld.patch_id[i]      = 0xFFFF; //omaps00090550 ;
+    l1a.dyn_dwnld.next_patch_id[i] = 0xFFFF; //omaps00090550 ;
+  }
+  for (i=0;i<MAX_NUM_OF_SEMAPHORES;i++)
+     l1a.dyn_dwnld.semaphore_vect[i] = GREEN;
 
-  l1a.dyn_dwnld.patch_id[0] = 0xFFFF; //omaps00090550
+  l1a.dyn_dwnld.trace_flag_blocked = FALSE;
+
+  l1a.dyn_dwnld.waiting_patch_fifo.num_of_elem = 0;
+  for (i=0;i<MAX_NUM_OF_PATCH_IDS;i++)
+    l1a.dyn_dwnld.waiting_patch_fifo.signal_code_vect[i] = 0;
 
   /**************************************************/
 
@@ -170,19 +183,7 @@
     l1a.dyn_dwnld.num_of_primitives += 3;
   #endif // MELODY_E2
 
-  for (i=l1a.dyn_dwnld.num_patches_installed;i<MAX_NUM_OF_PATCH_IDS;i++)
-  {  
-    l1a.dyn_dwnld.patch_id[i]      = 0xFFFF; //omaps00090550 ;
-    l1a.dyn_dwnld.next_patch_id[i] = 0xFFFF; //omaps00090550 ;
-  }
-  for (i=0;i<MAX_NUM_OF_SEMAPHORES;i++)
-     l1a.dyn_dwnld.semaphore_vect[i] = GREEN;
 
-   
-    l1a.dyn_dwnld.waiting_patch_fifo.num_of_elem = 0;
-    for (i=0;i<MAX_NUM_OF_PATCH_IDS;i++)
-      l1a.dyn_dwnld.waiting_patch_fifo.signal_code_vect[i] = 0;
-  
   /*---------------------------------------------------------------------*/
 
   /*---------- Set L1S globals at phone init ----------------------------*/
--- a/L1/dyn_dwl_cfile/l1_dyn_dwl_sync.c	Fri Jun 10 08:56:53 2016 +0000
+++ b/L1/dyn_dwl_cfile/l1_dyn_dwl_sync.c	Fri Jun 10 08:59:53 2016 +0000
@@ -10,13 +10,11 @@
 #include <stdio.h>
 #include <string.h>
 
-#include "config.h"
+#include "nucleus.h"
 #include "l1_confg.h"
+#include "l1_types.h"
 #include "sys_types.h"
-#include "../../riviera/rv/rv_general.h"
-#include "../../nucleus/nucleus.h"
-#include "l1_types.h"
-#include "../../gpf/inc/cust_os.h"
+#include "cust_os.h"
 #include "l1audio_signa.h"
 #include "l1audio_const.h"
 #include "l1audio_cust.h"
@@ -48,7 +46,7 @@
 #include "l1_defty.h"
 #include "l1_varex.h"
 #include "l1_trace.h"
-/* #include "sys_dma.h" */
+#include "sys_dma.h"
 
 #if (L1_DYN_DSP_DWNLD == 1)