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

📄 srio.c

📁 RapidIO boot code CPU配置交换芯片代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*********************************************************************
 *
 *  Copyright (C) 2005  Freescale Semiconductors, Inc.
 *
 ********************************************************************/
/*********************************************************************
 *  FILE: main.c
 *
 *  DESCRIPTION :
 *    Contains the entry point to the application to bring up the
 *    RapidIO system. Also contains other functions related to the
 *    user interface.
 *    main : sets up and discovers the basic system, and presents
 *     the user with a number of options
 *    print_menu : Prints a list of possible options to the user
 *     interface
 *    print_switch_info : prints information about the state of the
 *     tsi500 to the user interface
 *    print_rioport_info : prints information about the state of the
 *     RapidIO ports on each of the endpoints
 *
 * NOTES :
 *
 *
 * HISTORY
 * Version    Date     Auth.,Loc.     Comments
 *   0.1    27-Jul-04  LM, EKB       First released version
 *   0.2    14-Apr-05  LM, EKB	     Adapted to SRIO on MPC8548
 ********************************************************************/
/*************************************************
*01 add vxWorks header  by lyh 2007-1-25 16:27 ,must be always at the first
*02 change data types u32 ----> UINT32 ,2007-1-25 16:32
*03 set
*
*/

#include "vxHeader.h"

#include "immap_85xx.h"
#include "mmu.h"
#include	"srio.h"

/*
#include <common.h>
#include <syscall.h>
#include <asm-ppc/immap_85xx.h>
#include <asm-ppc/mmu.h>


#include "rio_regs.h"
*/
#include "rio_bringup.h"
#include "srio_msgs.h"




/********************************************************************
Globally defined variables
*********************************************************************/
volatile srio_device_t *srio_device;
volatile immap_t *local_imm;
volatile ccsr_srio_t *local_srio;
volatile ccsr_local_ecm_t *local_ecm;
UINT32 system_type;
UINT32 hostdeviceid;
UINT32 nextdevid ;
int ipportstops,opportstops,testbs,testas;
/* volatile data_msg_cntrllr *message_unit1, *message_unit2;  */



/*define the size of the larget message inbound queue can accept */ 
#define MAX_IB_MSG 4096
#define IBMSG_FRM_SIZE 0x0B

/*define the number of messages which can be held in the inbound queue */ 
#define MESSAGES_IN_IBQ 4
#define IBMSG_CIRQ_SIZE 1

#define MESSAGES_IN_OBQ 4



/********************************************************************
Locally defined functions
********************************************************************/
void print_menu (void);
void print_switch_info (void);
void print_rioport_info (int device_id);
void print_perport_info (int port);

/********************************************************************
int main (int argc, char *argv[])
Sets up the local coonfiguration, discovers other processors,
sets up access to the configuration space of the agents then presents
a user interface with options to boot, monitor, tests etc.
********************************************************************/
/*
int
main (int argc, char *argv[])
*/
int	srio()
{
  volatile srio_device_t srio_device_array[MAX_DEVICES_IN_SYSTEM];
  int result;
  UINT32 volatile *rio_maint_window, tempstore;
  char input, input2;
  int calibration, i;
  int device;
  volatile data_msg_cntrllr *message_unit1, *message_unit2;  
	/*lyh add 2007-2-1 14:41*/
	UINT32	tmp;
 
  	
   static UINT8 ib_message_q1[MAX_IB_MSG * MESSAGES_IN_IBQ] /*__attribute__   ((aligned (32)))*/;
   static UINT8 ib_message_q2[MAX_IB_MSG * MESSAGES_IN_IBQ]/* __attribute__ ((aligned (32)))*/;
   static UINT32 ob_message_q1[8 * MESSAGES_IN_OBQ] /*__attribute__((aligned(32)))*/;
   static UINT32 ob_message_q2[8 * MESSAGES_IN_OBQ] /*__attribute__((aligned(32)))*/;


   //temp stuff in here to check out port stop errors
   //seems to be fixed with imroved clocking 
   //ipportstops = opportstops = testbs = testas = 0;
       
  /*******************************************************************
  array will hold information about all devices in the system, init
  all these devices to default information
  *******************************************************************/
  srio_device = srio_device_array;
   for(i=0;i<MAX_DEVICES_IN_SYSTEM;i++)
  {
  	srio_device_array[i].imm = NULL;
	srio_device_array[i].srio = NULL;
	srio_device_array[i].ecm = NULL;
	srio_device_array[i].mem_block = NULL;
	srio_device_array[i].booted = 0;
  }

  
  /********************************************************************
  Pointers to the register structures within the local processor
  ********************************************************************/
  local_imm = (immap_t *) CCSR_BAR;
  local_srio = (ccsr_srio_t*)(((char*)(local_imm)) + 0xC0000);
  local_ecm = &(local_imm->im_local_ecm);
/*lyh 2007-2-2 15:03*/
  printf("addr of local_srio =0x%x\n",&(local_srio));
    printf("local_srio =0x%x\n",local_srio);
    printf("addr of local_ecm =0x%x\n",&(local_ecm));
    printf("local_ecm =0x%x\n",local_ecm);

  
  message_unit1 = (data_msg_cntrllr*) &(local_srio->om0mr);
  message_unit2 = (data_msg_cntrllr*)(((char*)(local_imm)) + 0xD3100);
  
  
  
 /* printf("local pescsr = 0x%08x \n", local_srio->p0escsr);
  if(local_srio->p0escsr & 0x00010000) 
  	opportstops++;
   if(local_srio->p0escsr & 0x00000100) 
 	ipportstops++;
	*/
	
   
  /*******************************************************************
  put this device into accept all mode 
  *******************************************************************/
  
  local_srio->pptaacr |= 0x00000001;
  /*lyh 2007-2-2 15:03*/
  printf("addr of local_srio->pptaacr =0x%x\n",&(local_srio->pptaacr));
    printf("local_srio->pptaacr =0x%x\n",local_srio->pptaacr);

  
/*add by lyh 2007-1-31 16:04*/
 /*as andy said ,Pls try to CCSR[PD] =1 ,
  the new field (PD) has been added to CCSR[8],
  input error state machine is forced to normal state.*/
  /*	UINT32	p0ccsr;		 0xc015c - Port Control Command and Status Register */
#if 	0
#define	CCSR_PD	0x00800000;
/* #define	CCSR_PD	0x00000100;*/
  local_srio->p0ccsr	|= CCSR_PD;/*set CCSR[PD] = 1,CCSR[8]*/
 printf("local_srio->p0ccsr =0x%x\n",local_srio->p0ccsr);
 printf("addr of local_srio->p0ccsr =0x%x\n",&(local_srio->p0ccsr));
 taskDelay(10);  /*wait uart display*/

#endif

  /*******************************************************************
  STEP 1: Local configuration
  Sets up the configuration on the local processor and ensures that
  RapidIO is trained.
  *******************************************************************/
  result = rio_local_config ();
  if (result != SUCCESS) {
    printf ("Completed rio_local_config() with error code %d\n", result);
    return result;
  }

  printf (" ---- rio_local_config() completed successfully ---- \n\n");
  /*add by lyh wait printf on UART 2007-2-1 10:20*/
/* 	UINT32	p0escsr;		0xc0158 - Port Error and Status Command and Status Register */
		printf("show  error local_srio->p0escsr = 0x%08x\n",local_srio->p0escsr);
		tmp		=		local_srio->p0escsr;
		local_srio->p0escsr					= tmp;
    taskDelay(200);
#if	  1

/* end */

  
   /*******************************************************************
  STEP 2 : Simplified Discovery
  'Discover' the other elements in the system.
  Limited to a single TSI500 system or 2 MPC8540/60 communicating point-to-point
  *******************************************************************/
  result = rio_discovery ();
  if (result != SUCCESS) {
    printf ("Completed rio discovery with error code %d \n", result);
    return result;
  }
  else {
  	printf("Discovered %d other devices \n", nextdevid-1); 
  }
  

  printf (" ---- rio_discovery() completed successfully ---- \n\n");

  /*take the local processor out of accept all mode */ 
  local_srio->pptaacr = 1; /*add by Andy*/
  /*add by lyh 2007-1-31 16:04*/


/*end*/
   
  /***********************************************************************
  STEP 3: Set up the lcsbacsr register which allows NREAD/NWRITE access into the
  agent devices internal memory space. Set up one single outbound (multi-segment)
  window on the host, then set up each of the agent devices in turn. 
  *********************************************************************/
  /*c1000000 = 1MByte window, lcs device 0 */
  printf("Set up ROWs of local processor for access through LCS window \n"); 
  if(system_type == FABRIC_SYSTEM)
  {
  	printf("Allow access back to host, through switch\n");
	  	local_srio->rowbar2 = 0x000c1000;
  	local_srio->rowar2 = 0x80045013;
  	local_srio->rowtar2 = 0x00001000;
  	printf("\nROW2 is for LCS access back to device 0\n");
	printf ("rowbar2 = 0x%08x, rowar2 = 0x%08x, rowtar2 = 0x%08x\n",
          local_srio->rowbar2, local_srio->rowar2, local_srio->rowtar2);
	  result = setup_remote_lcs_access (0); 

	        if (result != SUCCESS) 
	{
		printf("ERROR : Problem setting up LCS access \n"); 
	}
  
  }
  
  if(nextdevid > 1)
  {		
  /*c1100000 = 1MByte window, lcs device 1 */ 
  local_srio->rowbar3 = 0x000c1100;
  local_srio->rowar3 = 0x80045013;
  local_srio->rowtar3 = 0x00401000;
  printf("\nROW3 is for LCS access back to device 1\n");
  printf ("rowbar3 = 0x%08x, rowar3 = 0x%08x, rowtar3 = 0x%08x\n",
  local_srio->rowbar3, local_srio->rowar3, local_srio->rowtar3);
  	result = setup_remote_lcs_access (1);
        if (result != SUCCESS) 
	{
	printf("ERROR : Problem setting up LCS access \n"); 
	}

   }
  
  if(nextdevid > 2)
  {
  /*c1200000 = 1MByte window, lcs device 2 */ 
  local_srio->rowbar4 = 0x000c1200;
  local_srio->rowar4 = 0x80045013;
  local_srio->rowtar4 = 0x00801000;
  printf("\nROW4 is for LCS access back to device 2\n");
  printf ("rowbar4 = 0x%08x, rowar4 = 0x%08x, rowtar4 = 0x%08x\n",
  local_srio->rowbar4, local_srio->rowar4, local_srio->rowtar4);
  	result = setup_remote_lcs_access (2);
        if (result != SUCCESS) 
	{
	printf("ERROR : Problem setting up LCS access \n"); 
	}

  }
  
  if(nextdevid > 3)
  {
  	printf("Discovery found more devices in the system that this\n");
	printf("window setup was designed to handle \n"); 
	
  }

   printf
    (" ---- set up remote LCS access to all trained processors ---- \n\n");
    


  /* c6000000 = 4MByte window, i/o device 0 */ 
  local_srio->rowbar5 = 0x000c6000;
  local_srio->rowar5 = 0x80045015;
  local_srio->rowtar5 = 0x00000000;
   printf("\nROW5 is for memory access to device 0\n");
  printf ("rowbar5 = 0x%08x, rowar5 = 0x%08x, rowtar5 = 0x%08x\n",
  local_srio->rowbar5, local_srio->rowar5, local_srio->rowtar5);



  if(nextdevid > 1)
  {  
  /* c6400000 = 4MByte window, i/o device 1 */ 
  local_srio->rowbar6 = 0x000c6400;
  local_srio->rowar6 = 0x80045015;
  local_srio->rowtar6 = 0x00400000;
    printf("\nROW6 is for memory access to device 1\n");
  printf ("rowbar6 = 0x%08x, rowar6 = 0x%08x, rowtar6 = 0x%08x\n",
  local_srio->rowbar6, local_srio->rowar6, local_srio->rowtar6);

  }
  if(nextdevid > 2)
  {  
  /* c6800000 = 4MByte window, i/o device 2 */ 
  local_srio->rowbar7 = 0x000c6800;
  local_srio->rowar7 = 0x80045015;
  local_srio->rowtar7 = 0x00800000;
    printf("\nROW7 is for memroy access to device 2\n");
  printf ("rowbar7 = 0x%08x, rowar7 = 0x%08x, rowtar7 = 0x%08x\n",
  local_srio->rowbar7, local_srio->rowar7, local_srio->rowtar7);

  }


   
  for (i = (hostdeviceid+1); i < nextdevid; i++) 
    {
    	
	/* rather dodgy check to see if the device has been booted */
	printf("\n\n\nCheck boot status of device %d\n", i); 
	if(srio_device[i].ecm->ccsrbar == 0x000e0000)
	{
		srio_device[i].booted = 1; 
		printf("Looks like the device has already been booted \n"); 
	}
	else
	{
		printf("don't think this has been booted, ccsrbar = 0x%08x \n", srio_device[i].ecm->ccsrbar); 
		rio_boot(i);
	}
	printf("Set up access to device %d's memory space \n", i); 
	result = enable_rio_mem_access (i);
        if (result != SUCCESS)
              printf ("enable_rio_mem_access returned error code 0x%08x \n",
                      result);
	else
	{
		printf("setup memory access to device %d \n", i); 
	}
	


     }
  

     
  

⌨️ 快捷键说明

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