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

📄 dspmmu_table.c

📁 Omap5910的Dsp和arm内存共享程序。实现双核的内存共享通信机制。
💻 C
字号:
/* ***********************************************************
* THIS PROGRAM IS PROVIDED "AS IS". TI MAKES NO WARRANTIES OR
* REPRESENTATIONS, EITHER EXPRESS, IMPLIED OR STATUTORY, 
* INCLUDING ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 
* FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR 
* COMPLETENESS OF RESPONSES, RESULTS AND LACK OF NEGLIGENCE. 
* TI DISCLAIMS ANY WARRANTY OF TITLE, QUIET ENJOYMENT, QUIET 
* POSSESSION, AND NON-INFRINGEMENT OF ANY THIRD PARTY 
* INTELLECTUAL PROPERTY RIGHTS WITH REGARD TO THE PROGRAM OR 
* YOUR USE OF THE PROGRAM.
*
* IN NO EVENT SHALL TI BE LIABLE FOR ANY SPECIAL, INCIDENTAL, 
* CONSEQUENTIAL OR INDIRECT DAMAGES, HOWEVER CAUSED, ON ANY 
* THEORY OF LIABILITY AND WHETHER OR NOT TI HAS BEEN ADVISED 
* OF THE POSSIBILITY OF SUCH DAMAGES, ARISING IN ANY WAY OUT 
* OF THIS AGREEMENT, THE PROGRAM, OR YOUR USE OF THE PROGRAM. 
* EXCLUDED DAMAGES INCLUDE, BUT ARE NOT LIMITED TO, COST OF 
* REMOVAL OR REINSTALLATION, COMPUTER TIME, LABOR COSTS, LOSS 
* OF GOODWILL, LOSS OF PROFITS, LOSS OF SAVINGS, OR LOSS OF 
* USE OR INTERRUPTION OF BUSINESS. IN NO EVENT WILL TI'S 
* AGGREGATE LIABILITY UNDER THIS AGREEMENT OR ARISING OUT OF 
* YOUR USE OF THE PROGRAM EXCEED FIVE HUNDRED DOLLARS 
* (U.S.$500).
*
* Unless otherwise stated, the Program written and copyrighted 
* by Texas Instruments is distributed as "freeware".  You may, 
* only under TI's copyright in the Program, use and modify the 
* Program without any charge or restriction.  You may 
* distribute to third parties, provided that you transfer a 
* copy of this license to the third party and the third party 
* agrees to these terms by its first use of the Program. You 
* must reproduce the copyright notice and any other legend of 
* ownership on each copy or partial copy, of the Program.
*
* You acknowledge and agree that the Program contains 
* copyrighted material, trade secrets and other TI proprietary 
* information and is protected by copyright laws, 
* international copyright treaties, and trade secret laws, as 
* well as other intellectual property laws.  To protect TI's 
* rights in the Program, you agree not to decompile, reverse 
* engineer, disassemble or otherwise translate any object code 
* versions of the Program to a human-readable form.  You agree 
* that in no event will you alter, remove or destroy any 
* copyright notice included in the Program.  TI reserves all 
* rights not specifically granted under this license. Except 
* as specifically provided herein, nothing in this agreement 
* shall be construed as conferring by implication, estoppel, 
* or otherwise, upon you, any license or other right under any 
* TI patents, copyrights or trade secrets.
*
* You may not use the Program in non-TI devices.
* ********************************************************* */


#include "DSPMMU_Table.h"
#include <stdio.h>


void MMU_Reset();
void MMU_ReleaseReset();
void MMU_Enable();
void MMU_Disable();
short MMU_ReadFaultType();
int MMU_ReadFaultAddress();
short MMU_CheckError();

#pragma DATA_ALIGN(Level1Table, 256)
int Level1Table[16];

void Init_DSPMMU_Table( void )
{ 

      unsigned int PhysicalAddress;         
      unsigned int TableEntry;
      int i;
      
      // Build Translation Table
      // Map 16MB DSP External Address Space to Physical Address Space starting at 0x1000:0000
      for(i=0;i<16;i++)
      {
	       // We map theDSP memory space contiguously into SDRAM starting at 0x1000:0000
		   // We map 16 sections, each 1MB (0x0010:0000) in size 
	       PhysicalAddress = 0x10000000+i*0x00100000;
	       
	       
	       // Bits 31..20 are the 12 upper Bits of the Section Start Address
	       TableEntry =  PhysicalAddress & 0xFFF00000;
	       
	       // Bits 11 and 10 are Access Permission Bits	   
	       // No access = 0, Read only = 2, Read and write = 3
		   // For test purposes, even virtual addresses will be read / write, odd ones read only
	       if((i%2)==1)
	        TableEntry += SECTION_READ_ONLY;
           else
            TableEntry += SECTION_READ_WRITE;

		   // Bits 1 and 0 define the first-level table entry type
	       // Coarse page table pointer = 1, Section translation = 2, Fine page table pointer = 3	       
	       TableEntry += SECTION;
	       Level1Table[i] = TableEntry;
      }       
      
      // Position Tanslation Table via TTB Registers
	  // The upper 16 Bit go into TTB_H_REG
	  TTB_H_REG = ((int) &Level1Table) >> 16;
	  // Bits 15..7 go into TTB_L_REG (Bits 6...0 should always be zero)
	  TTB_L_REG = ((int) &Level1Table) & 0xFF80;
	  
	  // Configure MMU for Translation Table usage 
      CNTL_REG |= USE_TABLE;       	 
}

short MMU_CheckError()
{
 short i;
 int addr;

 i = MMU_ReadFaultType();
 if (i!=0)
 {
	if (i & 0x1)
 	 printf("Translation Fault! \n");
	if (i & 0x2)
	 printf("TLB Miss! \n");
	if (i & 0x4)
	 printf("Permission Fault! \n");
	if (i & 0x8)
	 printf("Error during prefetch! \n");	
    addr = MMU_ReadFaultAddress();
	 printf("Fault address : 0x%x (Byte) / 0x%x (Word) \n", addr, addr>>1);
 }	
 return i;
}

void MMU_Reset()
{
   	// Reset DSP MMU to default parameters
	CNTL_REG = RESET;
}

void MMU_ReleaseReset()
{
   	// Release MMU from Reset
 	CNTL_REG = REL_RESET;
}

void MMU_Enable()
{
 // Enable MMU
 CNTL_REG |= ENABLE;
}

void MMU_Disable()
{
 CNTL_REG &= DISABLE;
}

short MMU_ReadFaultType()
{
 return F_ST_REG;
}

int MMU_ReadFaultAddress()
{
 int i;
 i = FAULT_AD_H_REG << 16;
 i += FAULT_AD_L_REG;
 return i;
}

⌨️ 快捷键说明

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