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

📄 lh7a400_evbmmuinit.c

📁 sharp的arm920t 7A400的评估板附带光盘Sharp KEVLH7A400 v0.3b Welcome to the SHARP KEV7A400 Evaluation board
💻 C
字号:
/***********************************************************************
 *
 * $Workfile:   LH7A400_evbmmuinit.c  $
 * $Revision:   1.0  $
 * $Author:   WellsK  $
 * $Date:   Sep 23 2002 13:52:02  $
 *
 * Project: LH7A400
 *
 * Description: LH7A400 MMU initialization routines
 *
 * Revision History:
 * $Log:   //smaicnt2/pvcs/VM/CDROM/archives/KEV7A400/Software/Startup_lite/LH7A400_evbmmuinit.c-arc  $
 * 
 *    Rev 1.0   Sep 23 2002 13:52:02   WellsK
 * Initial revision.
 * 
 *    Rev 1.0   Sep 14 2002 11:38:06   WellsK
 * Initial revision.
 * 
 *    Rev 1.3   Aug 12 2002 15:08:28   BarnettH
 * Cleaned up banners.
 * Cleaned up bracing.
 * 
 *    Rev 1.2   Jun 05 2002 11:04:38   BarnettH
 * Changed to SMA_get_mmu_control_reg
 * 
 *    Rev 1.1   Apr 11 2002 17:08:00   BarnettH
 * Changed function names to standard
 * Removed tabs
 * Changed formatting to standard
 * 
 *    Rev 1.0   Sep 18 2001 18:05:40   BarnettH
 * Initial revision.
 * 
 ***********************************************************************
 * 
 *  Copyright (c) 2002 Sharp Microelectronics of the Americas
 *
 *  All rights reserved
 *
 *  SHARP MICROELECTRONICS OF THE AMERICAS MAKES NO REPRESENTATION
 *  OR WARRANTIES WITH RESPECT TO THE PERFORMANCE OF THIS SOFTWARE,
 *  AND SPECIFICALLY DISCLAIMS ANY RESPONSIBILITY FOR ANY DAMAGES,
 *  SPECIAL OR CONSEQUENTIAL, CONNECTED WITH THE USE OF THIS SOFTWARE.
 *
 *  SHARP MICROELECTRONICS OF THE AMERICAS PROVIDES THIS SOFTWARE SOLELY
 *  FOR THE PURPOSE OF SOFTWARE DEVELOPMENT INCORPORATING THE USE OF A
 *  SHARP MICROCONTROLLER OR SYSTEM-ON-CHIP PRODUCT.  USE OF THIS SOURCE
 *  FILE IMPLIES ACCEPTANCE OF THESE CONDITIONS.
 *
 **********************************************************************/

#include "LH7A400_evb.h"
#include "LH7A400_evbmmuinit.h"

UNS_32 SMA_get_mmu_control_reg (void);

/***********************************************************************
 *
 * Function: INT_32 LH7A400_init_mmu_page_table (PAGETABLE * pt)
 *
 * Purpose:
 *   Page Table Initialization
 *
 * Processing:
 *   [Placeholder]
 *
 * Parameters:  pt - address of page table
 *
 * Outputs:  None
 *
 * Returns:  
 *
 * Notes: 
 *    (1) This initialization is custom for the LH7A400 and the
 *        LH7A400 EVB.  The present implementation is a non-functional
 *        placeholder until the function is written.
 *
 **********************************************************************/

INT_32 LH7A400_init_mmu_page_table (PAGETABLE * pt)
{
    INT_32 ret = _NO_ERROR;

    return (ret);
}

/**********************************************************************
 *
 * Function:
 *   INT_32 LH7A400_init_mmu_trans_table (TRANSTABLE * tt,
 *                                        TT_SECTION_BLOCK * ttsbp)
 * Purpose:
 *  To initialize the MMU page table.
 *
 * Processing:
 *  Return error if MMU is enabled.
 *  Return error if target Translation Table address
 *      is not 16K aligned.
 *  Clear the Translation Table area.
 *  Build the Translation Table from the initialization data in the
 *      Section Block array.
 *  Return no error.
 *
 * Parameters:  
 *  tt - address of Translation Table in RAM.
 *  ttsbp - address of the beginning of the initialization array.
 *
 * Outputs: 
 *
 * Returns:  
 *  This function returns _ERROR when the MMU is enabled, or the
 *  target address is not 16K aligned.
 *  Otherwise, it returns _NO_ERROR.
 *
 * Notes: 
 *  (1) This function is not intended to be used when the MMU is
 *      enabled.
 *
 **********************************************************************/

INT_32 LH7A400_init_mmu_trans_table (TRANSTABLE * tt,
                                     TT_SECTION_BLOCK * ttsbp)
{
    UNS_32 idx;
    UNS_32 va_idx;
    UNS_32 pa_addr;
    UNS_32 * uiptr;
    UNS_32 ret = _NO_ERROR;

    /* The following check returns an error if the MMU is enabled.
     * This condition is not necessarily an error, but an existing
     * Translation Table for an enabled MMU should not be overwritten
     * while the MMU is enabled. */ 
    if (SMA_get_mmu_control_reg () & MMU_ENABLE)
        return (_ERROR);  /* MMU is enabled */ 

    if ((INT_32) tt & 0x3FFF)
        return (_ERROR);    /* Address not on 16K boundary */ 

    /* Clear the entire Translation Table.
     * This results in L1D_TYPE_FAULT being the default for any
     * uninitialized entries.
     */
    uiptr = (UNS_32 *) tt;
    for (idx = 0; idx < TT_ENTRIES; idx++)
        *uiptr++ = 0;

    /* Build the TT from user provided TT_SECTION_BLOCK array */ 
    while (ttsbp->num_sections != 0)
    {
        switch ((ttsbp->entry) & 0x13)
        {
            case (L1D_TYPE_SECTION):
                va_idx = ttsbp->virt_addr >> 20;
                pa_addr = ttsbp->phys_addr & 0xFFF00000;
                for (idx = 0; idx < ttsbp->num_sections; idx++)
                {
                    tt->vidx[va_idx] = pa_addr | ttsbp->entry;
                    va_idx++;
                    pa_addr += 0x100000;
                }
                break;

            case (L1D_TYPE_PAGE):
                va_idx = ttsbp->virt_addr >> 20;
                pa_addr = ttsbp->phys_addr & 0xFFFFFC00;
                for (idx = 0; idx < ttsbp->num_sections; idx++)
                {
                    tt->vidx[va_idx] = pa_addr | ttsbp->entry;
                    va_idx++;
                    pa_addr += 0x100000;
                }
                break;

            case (L1D_TYPE_FAULT):
            default:
                break;
        }

        ttsbp++;
    }
    return (ret);
}

/***********************************************************************
 *
 * Function: INT_32 LH7A400_init_mmu_tables_wrapper (TRANSTABLE * tt)
 *
 * Purpose:
 *   Translation Table Initialization wrapper.
 *
 * Processing:
 *   Return error if argument not aligned on 16K boundary.
 *   else call init MMU Translation Table function with argument and a
 *   pointer to the array of 
 *
 * Parameters:  
 *   tt - pointer to translation table
 *
 * Outputs: None
 *
 * Returns: _ERROR or _NO_ERROR
 *
 * Notes: 
 *    (1) This wrapper enables initialization of the TT from assembly 
 *        language.  Set a1 to the desired address of the Translation
 *        Table and branch with link to this function.
 *
 **********************************************************************/

INT_32 LH7A400_init_mmu_tables_wrapper (TRANSTABLE * tt)
{
    INT_32 ret = _NO_ERROR;

    if ((INT_32) tt & 0x3FFF)
        return (_ERROR);    /* Address not on 16K boundary */ 

    ret = LH7A400_init_mmu_trans_table (tt, MMU_LEVEL1_DESCRIPTORS);

    return (ret);
}

⌨️ 快捷键说明

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