⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dma_test_misc2.c

📁 MMI层OBJ不能完全编译
💻 C
📖 第 1 页 / 共 4 页
字号:
/**
 * @file	dma_test_misc2.c
 *
 * Gathers functions used for demonstration of DMA SWE.
 *
 * @author	 ()
 * @version 0.1
 */

/*
 * History:
 *
 *	Date       	Author					Modification
 *	-------------------------------------------------------------------
 *	7/1/2003	 ()		Create.
 *
 * (C) Copyright 2003 by Texas Instruments Incorporated, All Rights Reserved
 */


#include "rvm/rvm_api.h"
#include "rvm/rvm_use_id_list.h"
#include "rvm/rvm_ext_use_id_list.h"

#include "tests/rtest/rtest_api.h"

#include "dma/dma_api.h"
#include "dma/dma_message.h" 
#include "dma/dma_i.h"

#include "dma/tests/dma_test_misc.h"
#include "dma/tests/dma_test_misc2.h"

/** Macro used for tracing DMA messages. */
#define DMA_TEST_SEND_TRACE(string, trace_level) \
	rvf_send_trace (string, (sizeof(string) - 1), NULL_PARAM, trace_level, RTEST_USE_ID)

#define DMA_TEST_SEND_TRACE_PARAM(text,param,level) \
  rvf_send_trace(text, sizeof(text)-1, param, level, RTEST_USE_ID )

#define SW_PRIORITY_NORMAL  100
/**********************************************************************
/  SDRAM for DMA Test
/**********************************************************************/
#define DMA_TEST_SDRAM_BUF_SIZE   (64 * 4)

#define DMA_TEST_SDRAM_BASE_ADDR  (0x08040000)

#define DMA_TEST_SDRAM_SRC_BUFFER (DMA_TEST_SDRAM_BASE_ADDR)
#define DMA_TEST_SDRAM_DST_BUFFER (DMA_TEST_SDRAM_SRC_BUFFER + DMA_TEST_SDRAM_BUF_SIZE)

#ifdef _WINDOWS
extern UINT32 dma_source_buffer      [];
extern UINT32 dma_destination_buffer [];
#define DMA_TEST_SRC_MEM(offset) dma_source_buffer      [offset] 
#define DMA_TEST_DST_MEM(offset) dma_destination_buffer [offset] 
#else
#define DMA_TEST_SRC_MEM(offset)  * (volatile SYS_UWORD32 *) (DMA_TEST_SDRAM_SRC_BUFFER + offset)
#define DMA_TEST_DST_MEM(offset)  * (volatile SYS_UWORD32 *) (DMA_TEST_SDRAM_DST_BUFFER + offset)
#endif //_WINDOWS
/**********************************************************************/

/**
 * All ICT tests shall start at 200
 */
#define ICT_TEST_OFFSET 200

/**
 * Manages the messages that DMA can send during the MISC test number 1.
 * The messages are forwarded by RTEST.
 *
 * @param	msg_p	Pointer on the header of the message.
 * @return	RVM_OK
 */
T_RVM_RETURN dma_test_handle_message_1 (T_RV_HDR *msg_p)
{

	if (msg_p != NULL)
	{
		switch (((T_RV_HDR*)msg_p)->msg_id)
		{		  

		/*
		 * We use rtest_send_result to end the test and to
		 * send the result of the test back to the test task.
		 * It unblocks the test task.
		 * The parameter of rtest_send_result can take the values
		 * TEST_PASSED, TEST_FAILED or TEST_IRRECOVERABLY_FAILED
		 */
		/*rtest_send_result(TEST_IRRECOVERABLY_FAILED);*/

		default:
			RV_TEST_TRACE_WARNING("DMA Test: Unexpected message returned");
			break;
		}
		rvf_free_buf(msg_p);
	}
	return RVM_OK;
}


/**
 * Initializes some parameters so that a test can start with a reset situation
 *
 */
void dma_test_init (void)
{
  UINT8 n;
  extern T_DMA_ENV_CTRL_BLK* dma_env_ctrl_blk_p;

  extern T_DMA_CHANNEL_ARRAY dma_channel_array [DMA_MAX_NUMBER_OF_CHANNEL]; 
  extern T_DMA_QUEUE_ARRAY   dma_queue_array   [DMA_MAX_QUEUED_REQUESTS];
  extern UINT8 dma_function_status [DMA_MAX_NUMBER_OF_CHANNEL];

  /* At start up all the channels are free */
  for (n=0; n<DMA_MAX_QUEUED_REQUESTS; n++)
  {
    dma_queue_array[n].specific    = DMA_QUEUE_POS_FREE;
    dma_queue_array[n].queue_index = DMA_QUEUE_INDEX_MIN;
    dma_queue_array[n].sw_priority = DMA_QUEUE_POS_FREE;
    dma_function_status[n]         = DMA_FUNCTION_NONE;
    dma_channel_array[n].specific = DMA_QUEUE_POS_FREE;
  }

  dma_env_ctrl_blk_p->dma_queue_index = DMA_QUEUE_INDEX_MIN;
}


/**
 * Initializes all the parameters required for a transfer to a default value
 *
 */
void dma_test_set_default_parameters (T_DMA_CHANNEL_PARAMETERS *dma_channel_parameters)
{
  dma_channel_parameters->data_width   = DMA_DATA_S32;
  dma_channel_parameters->sync         = DMA_SYNC_DEVICE_NONE;
  dma_channel_parameters->hw_priority  = DMA_HW_PRIORITY_LOW;
  dma_channel_parameters->dma_mode     = DMA_SINGLE;
  dma_channel_parameters->flush        = DMA_FLUSH_DISABLED;
  dma_channel_parameters->nmb_frames   = 1;
  dma_channel_parameters->nmb_elements = 64;
  dma_channel_parameters->dma_end_notification = DMA_NO_NOTIFICATION;
  dma_channel_parameters->secure       = DMA_NOT_SECURED;
  dma_channel_parameters->transfer     = DMA_MODE_TRANSFER_DISABLE;

  dma_channel_parameters->source_address      = DMA_TEST_SDRAM_SRC_BUFFER;
  dma_channel_parameters->source_address_mode = DMA_ADDR_MODE_POST_INC; 
  dma_channel_parameters->source_packet       = DMA_NOT_PACKED;
  dma_channel_parameters->source_burst        = DMA_NO_BURST;

  dma_channel_parameters->destination_address = DMA_TEST_SDRAM_DST_BUFFER;
  dma_channel_parameters->destination_address_mode = DMA_ADDR_MODE_POST_INC; 
  dma_channel_parameters->destination_packet       = DMA_NOT_PACKED;
  dma_channel_parameters->destination_burst        = DMA_NO_BURST;

}


/**
 * This test will reservate channel number 3 (specific) 
 */
void dma_test_misc_201 (void) 
{

  UINT8 n=0;
  T_RV_RETURN_PATH dma_test_path;
  T_DMA_STATUS_RSP_MSG *msg_p;


	/* Sets message forwarding */
  dma_test_path.addr_id = rtest_get_addr_id();
  dma_test_path.callback_func = NULL;

  if (dma_reserve_channel (DMA_CHAN_SPECIFIC,3, DMA_QUEUE_ENABLE, 
      SW_PRIORITY_NORMAL, dma_test_path) != RV_OK)
  {
      DMA_TEST_SEND_TRACE("DMA TEST immediate return NOT OK ",\
                           DMA_TRACE_LEVEL);
      rtest_send_result (TEST_FAILED);
      return;
  }

  msg_p = (T_DMA_STATUS_RSP_MSG *) rtest_wait_for_message (DMA_STATUS_RSP_MSG);
  switch (msg_p->result.status)
  {
    case DMA_RESERVE_OK:
    case DMA_QUEUED:

    {
      DMA_TEST_SEND_TRACE_PARAM("DMA TEST result OK, return value: ",\
                                 msg_p->result.status,\
                                 DMA_TRACE_LEVEL);
      DMA_TEST_SEND_TRACE_PARAM("DMA TEST channel returned: ",\
                                 msg_p->result.channel,\
                                 DMA_TRACE_LEVEL);
      rtest_send_result (TEST_PASSED);
    }
    break;
    
    default:
      DMA_TEST_SEND_TRACE_PARAM("DMA TEST result NOT OK, return value: ",\
                                 msg_p->result.status,\
                                 DMA_TRACE_LEVEL);
      rtest_send_result (TEST_FAILED);
      break;
  }

  rvf_free_buf (msg_p);
  return;
}


/**
 * This test will remove a request from the queue
 */
void dma_test_misc_202 (void)
{

  UINT8 queue_ind=0;
  T_RV_RETURN_PATH dma_test_path;
  T_DMA_STATUS_RSP_MSG *msg_p;

  UINT8 test_channel = DMA_MIN_CHANNEL +2;

  /* set all needed parameters to zero */ 
  dma_test_init ();

	/* Sets message forwarding */
  dma_test_path.addr_id = rtest_get_addr_id();
  dma_test_path.callback_func = NULL;

  /* Reserve a specific channel */
  if (dma_reserve_channel (DMA_CHAN_SPECIFIC,test_channel, DMA_QUEUE_ENABLE, 
      SW_PRIORITY_NORMAL, dma_test_path) != RV_OK)
  {
      DMA_TEST_SEND_TRACE("DMA TEST immediate return NOT OK ",\
                           DMA_TRACE_LEVEL);
      rtest_send_result (TEST_FAILED);
      return;
  }
  msg_p = (T_DMA_STATUS_RSP_MSG *) rtest_wait_for_message (DMA_STATUS_RSP_MSG);
  switch (msg_p->result.status)
  {
    case DMA_RESERVE_OK:
    {
      DMA_TEST_SEND_TRACE ("DMA TEST specific channel reservated ",\
                                 DMA_TRACE_LEVEL);
      DMA_TEST_SEND_TRACE_PARAM("DMA TEST channel returned: ",\
                                 msg_p->result.channel,\
                                 DMA_TRACE_LEVEL);
    }
    break;
  
    default:
      DMA_TEST_SEND_TRACE_PARAM("DMA TEST result NOT OK, return value: ",\
                                 msg_p->result.status,\
                                 DMA_TRACE_LEVEL);
      rtest_send_result (TEST_FAILED);
      break;
  }
  rvf_free_buf (msg_p);


  /* Reservate the channel again, so it is queued  */
  if (dma_reserve_channel (DMA_CHAN_SPECIFIC,test_channel, DMA_QUEUE_ENABLE,
      SW_PRIORITY_NORMAL, dma_test_path) != RV_OK)
  {
      DMA_TEST_SEND_TRACE("DMA TEST immediate return NOT OK ",\
                           DMA_TRACE_LEVEL);
      rtest_send_result (TEST_FAILED);
      return;
  }
  msg_p = (T_DMA_STATUS_RSP_MSG *) rtest_wait_for_message (DMA_STATUS_RSP_MSG);
  switch (msg_p->result.status)
  {
    case DMA_QUEUED:
    {
      /* store the index the function has returned */
      queue_ind = msg_p->result.channel;
      DMA_TEST_SEND_TRACE      ("DMA TEST specific channel has been queued",\
                                 DMA_TRACE_LEVEL);
      DMA_TEST_SEND_TRACE_PARAM("DMA TEST index value: ",\
                                 msg_p->result.channel,\
                                 DMA_TRACE_LEVEL);
    }
    break;
  
    default:
      DMA_TEST_SEND_TRACE_PARAM("DMA TEST result NOT OK, return value: ",\
                                 msg_p->result.status,\
                                 DMA_TRACE_LEVEL);
      rtest_send_result (TEST_FAILED);
      break;
  }
  rvf_free_buf (msg_p);


  /* remove the reservation from the queue */
  if (dma_remove_from_queue (queue_ind) != RV_OK)
  {
      DMA_TEST_SEND_TRACE("DMA TEST immediate return NOT OK ",\
                           DMA_TRACE_LEVEL);
      rtest_send_result (TEST_FAILED);
      return;
  }

  msg_p = (T_DMA_STATUS_RSP_MSG *) rtest_wait_for_message (DMA_STATUS_RSP_MSG);
  if (msg_p->result.status == DMA_REMOVED_FROM_QUEUE)
  {
    DMA_TEST_SEND_TRACE_PARAM("DMA TEST ok. Queued place freed. Index: ",\
                               queue_ind,\
                               DMA_TRACE_LEVEL);
  }
  else
  {
    rtest_send_result (TEST_FAILED);
  }

  rvf_free_buf (msg_p);
  
  /* release the channel */
  if (dma_release_channel (test_channel) != RV_OK)
  {
      DMA_TEST_SEND_TRACE("DMA TEST immediate return NOT OK ",\
                           DMA_TRACE_LEVEL);
      rtest_send_result (TEST_FAILED);
      return;
  }

  msg_p = (T_DMA_STATUS_RSP_MSG *) rtest_wait_for_message (DMA_STATUS_RSP_MSG);
  if ((msg_p->result.status == DMA_CHANNEL_RELEASED) && 
      (msg_p->result.channel == test_channel))
  {
    DMA_TEST_SEND_TRACE_PARAM("DMA released channel number:" ,\
                              msg_p->result.channel,\
                              DMA_TRACE_LEVEL);

  }
  else
  {
    DMA_TEST_SEND_TRACE_PARAM("DMA released WRONG channel number:" ,\
                              msg_p->result.channel,\
                              DMA_TRACE_LEVEL);
    rtest_send_result (TEST_FAILED);
  }
  rvf_free_buf (msg_p);

  /* reserve the channel again, it should not be queue or something like that */
  if (dma_reserve_channel (DMA_CHAN_SPECIFIC,test_channel, DMA_QUEUE_ENABLE, 
      SW_PRIORITY_NORMAL, dma_test_path) != RV_OK)
  {
      DMA_TEST_SEND_TRACE("DMA TEST immediate return NOT OK ",\
                           DMA_TRACE_LEVEL);
      rtest_send_result (TEST_FAILED);
      return;
  }

  msg_p = (T_DMA_STATUS_RSP_MSG *) rtest_wait_for_message (DMA_STATUS_RSP_MSG);
  if ((msg_p->result.status== DMA_RESERVE_OK) &&
      (msg_p->result.channel == test_channel))
  {
    DMA_TEST_SEND_TRACE ("DMA TEST OK: specific channel reservated ",\
                               DMA_TRACE_LEVEL);
    DMA_TEST_SEND_TRACE_PARAM("DMA TEST channel returned: ",\
                               msg_p->result.channel,\
                               DMA_TRACE_LEVEL);
      rtest_send_result (TEST_PASSED);
  }
  else
  {
      DMA_TEST_SEND_TRACE_PARAM("DMA TEST result NOT OK, return value: ",\
                                 msg_p->result.status,\
                                 DMA_TRACE_LEVEL);
      rtest_send_result (TEST_FAILED);
  }
  rvf_free_buf (msg_p);


  return;
}



/**
 * This test will set the parameters to setup a DMA transfer
 */
void dma_test_misc_203 (void)
{
  T_DMA_CHANNEL_PARAMETERS dma_channel_parameters;

  UINT8 n=0;
  T_RV_RETURN_PATH dma_test_path;
  T_DMA_STATUS_RSP_MSG *msg_p;

 
	/* Sets message forwarding */
  dma_test_path.addr_id = rtest_get_addr_id();
  dma_test_path.callback_func = NULL;

  dma_test_init ();

  if (dma_reserve_channel (DMA_CHAN_SPECIFIC,3, DMA_QUEUE_ENABLE, 
      SW_PRIORITY_NORMAL, dma_test_path) != RV_OK)
  {
      DMA_TEST_SEND_TRACE("DMA TEST immediate return NOT OK ",\
                           DMA_TRACE_LEVEL);
      rtest_send_result (TEST_FAILED);
      return;
  }

  msg_p = (T_DMA_STATUS_RSP_MSG *) rtest_wait_for_message (DMA_STATUS_RSP_MSG);
  switch (msg_p->result.status)
  {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -