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

📄 at91rm9200_misc.c

📁 ecos在9200上redboot实现
💻 C
📖 第 1 页 / 共 2 页
字号:
//==========================================================================////      at91rm9200_misc.c////      HAL misc board support code for ARM9/AT91RM9200////==========================================================================//####ECOSGPLCOPYRIGHTBEGIN####// -------------------------------------------// This file is part of eCos, the Embedded Configurable Operating System.// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.//// eCos is free software; you can redistribute it and/or modify it under// the terms of the GNU General Public License as published by the Free// Software Foundation; either version 2 or (at your option) any later version.//// eCos is distributed in the hope that it will be useful, but WITHOUT ANY// WARRANTY; without even the implied warranty of MERCHANTABILITY or// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License// for more details.//// You should have received a copy of the GNU General Public License along// with eCos; if not, write to the Free Software Foundation, Inc.,// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.//// As a special exception, if other files instantiate templates or use macros// or inline functions from this file, or you compile this file and link it// with other works to produce a work based on this file, this file does not// by itself cause the resulting work to be covered by the GNU General Public// License. However the source code for this file must still be made available// in accordance with section (3) of the GNU General Public License.//// This exception does not invalidate any other reasons why a work based on// this file might be covered by the GNU General Public License.//// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.// at http://sources.redhat.com/ecos/ecos-license/// -------------------------------------------//####ECOSGPLCOPYRIGHTEND####//==========================================================================//#####DESCRIPTIONBEGIN####//// Author(s):    Jiun-Shian H. <asky@syncom.com.tw>// Contributors: Jiun-Shian H. <asky@syncom.com.tw>// Date:         2005-08-10// Purpose:      HAL board support// Description:  Implementations of HAL board interfaces////####DESCRIPTIONEND####////==========================================================================#include <pkgconf/hal.h>#include <pkgconf/system.h>#include CYGBLD_HAL_PLATFORM_H#include <cyg/infra/cyg_type.h>         // base types#include <cyg/infra/cyg_trac.h>         // tracing macros#include <cyg/infra/cyg_ass.h>          // assertion macros#include <cyg/hal/hal_io.h>             // IO macros#include <cyg/hal/hal_arch.h>           // Register state info#include <cyg/hal/hal_diag.h>#include <cyg/hal/hal_intr.h>           // Interrupt names#include <cyg/hal/hal_cache.h>#include <cyg/hal/at91rm9200.h>         // Platform specifics#include <cyg/infra/diag.h>             // diag_printf#include <string.h>                     // memset// -------------------------------------------------------------------------// MMU initialization://// These structures are laid down in memory to define the translation// table.//// ARM Translation Table Base Bit Masks#define ARM_TRANSLATION_TABLE_MASK               0xFFFFC000// ARM Domain Access Control Bit Masks#define ARM_ACCESS_TYPE_NO_ACCESS(domain_num)    (0x0 << (domain_num)*2)#define ARM_ACCESS_TYPE_CLIENT(domain_num)       (0x1 << (domain_num)*2)#define ARM_ACCESS_TYPE_MANAGER(domain_num)      (0x3 << (domain_num)*2)struct ARM_MMU_FIRST_LEVEL_FAULT {    int id : 2;    int sbz : 30;};#define ARM_MMU_FIRST_LEVEL_FAULT_ID 0x0struct ARM_MMU_FIRST_LEVEL_PAGE_TABLE {    int id : 2;    int imp : 2;    int domain : 4;    int sbz : 1;    int base_address : 23;};#define ARM_MMU_FIRST_LEVEL_PAGE_TABLE_ID 0x1struct ARM_MMU_FIRST_LEVEL_SECTION {    int id : 2;    int b : 1;    int c : 1;    int imp : 1;    int domain : 4;    int sbz0 : 1;    int ap : 2;    int sbz1 : 8;    int base_address : 12;};#define ARM_MMU_FIRST_LEVEL_SECTION_ID 0x2struct ARM_MMU_FIRST_LEVEL_RESERVED {    int id : 2;    int sbz : 30;};#define ARM_MMU_FIRST_LEVEL_RESERVED_ID 0x3#define ARM_MMU_FIRST_LEVEL_DESCRIPTOR_ADDRESS(ttb_base, table_index) \   (unsigned long *)((unsigned long)(ttb_base) + ((table_index) << 2))#define ARM_FIRST_LEVEL_PAGE_TABLE_SIZE 0x4000#define ARM_MMU_SECTION(ttb_base, actual_base, virtual_base,              \                        cacheable, bufferable, perm)                      \    CYG_MACRO_START                                                       \        register union ARM_MMU_FIRST_LEVEL_DESCRIPTOR desc;               \                                                                          \        desc.word = 0;                                                    \        desc.section.id = ARM_MMU_FIRST_LEVEL_SECTION_ID;                 \        desc.section.imp = 1;                                             \        desc.section.domain = 0;                                          \        desc.section.c = (cacheable);                                     \        desc.section.b = (bufferable);                                    \        desc.section.ap = (perm);                                         \        desc.section.base_address = (actual_base);                        \        *ARM_MMU_FIRST_LEVEL_DESCRIPTOR_ADDRESS(ttb_base, (virtual_base)) \                            = desc.word;                                  \    CYG_MACRO_END#define X_ARM_MMU_SECTION(abase,vbase,size,cache,buff,access)      \    { int i; int j = abase; int k = vbase;                         \      for (i = size; i > 0 ; i--,j++,k++)                          \      {                                                            \        ARM_MMU_SECTION(ttb_base, j, k, cache, buff, access);      \      }                                                            \    }union ARM_MMU_FIRST_LEVEL_DESCRIPTOR {    unsigned long word;    struct ARM_MMU_FIRST_LEVEL_FAULT fault;    struct ARM_MMU_FIRST_LEVEL_PAGE_TABLE page_table;    struct ARM_MMU_FIRST_LEVEL_SECTION section;    struct ARM_MMU_FIRST_LEVEL_RESERVED reserved;};#define ARM_UNCACHEABLE                         0#define ARM_CACHEABLE                           1#define ARM_UNBUFFERABLE                        0#define ARM_BUFFERABLE                          1#define ARM_ACCESS_PERM_NONE_NONE               0#define ARM_ACCESS_PERM_RO_NONE                 0#define ARM_ACCESS_PERM_RO_RO                   0#define ARM_ACCESS_PERM_RW_NONE                 1#define ARM_ACCESS_PERM_RW_RO                   2#define ARM_ACCESS_PERM_RW_RW                   3voidhal_mmu_init(void){#if 0    unsigned long ttb_base = AT91RM9200_SDRAM_PHYS_BASE + 0x4000;    unsigned long i;    // Set the TTB register    asm volatile ("mcr  p15,0,%0,c2,c0,0" : : "r"(ttb_base) /*:*/);    // Set the Domain Access Control Register    i = ARM_ACCESS_TYPE_MANAGER(0)    |        ARM_ACCESS_TYPE_NO_ACCESS(1)  |        ARM_ACCESS_TYPE_NO_ACCESS(2)  |        ARM_ACCESS_TYPE_NO_ACCESS(3)  |        ARM_ACCESS_TYPE_NO_ACCESS(4)  |        ARM_ACCESS_TYPE_NO_ACCESS(5)  |        ARM_ACCESS_TYPE_NO_ACCESS(6)  |        ARM_ACCESS_TYPE_NO_ACCESS(7)  |        ARM_ACCESS_TYPE_NO_ACCESS(8)  |        ARM_ACCESS_TYPE_NO_ACCESS(9)  |        ARM_ACCESS_TYPE_NO_ACCESS(10) |        ARM_ACCESS_TYPE_NO_ACCESS(11) |        ARM_ACCESS_TYPE_NO_ACCESS(12) |        ARM_ACCESS_TYPE_NO_ACCESS(13) |        ARM_ACCESS_TYPE_NO_ACCESS(14) |        ARM_ACCESS_TYPE_NO_ACCESS(15);    asm volatile ("mcr  p15,0,%0,c3,c0,0" : : "r"(i) /*:*/);    // First clear all TT entries - ie Set them to Faulting    memset((void *)ttb_base, 0, ARM_FIRST_LEVEL_PAGE_TABLE_SIZE);    // Memory layout after MMU is turned on    //    //   SDRAM_BASE_ADDRESS:     0x00000000,  64M    //   SRAM_BASE_ADDRESS:      0x40000000,   4K    //   SFR_BASE_ADDRESS:       0x48000000, 512M    //   FLASH_BASE_ADDRESS:     0x80000000,   2M    //               Actual  Virtual  Size   Attributes                                                  Function    //               Base     Base     MB     cached?          buffered?         access permissions    //             xxx00000  xxx00000    X_ARM_MMU_SECTION(0x000,  0x800,    2,  ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); // Flash    X_ARM_MMU_SECTION(0x300,  0x000,   64,  ARM_CACHEABLE,   ARM_BUFFERABLE,   ARM_ACCESS_PERM_RW_RW); // SDRAM    X_ARM_MMU_SECTION(0x400,  0x400,    1,  ARM_CACHEABLE,   ARM_BUFFERABLE,   ARM_ACCESS_PERM_RW_RW); // SRAM    X_ARM_MMU_SECTION(0x480,  0x480,  512,  ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); // SFRs    X_ARM_MMU_SECTION(0x300,  0x300,   64,  ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); // Raw SDRAM#endif /* 0/1 */}//----------------------------------------------------------------------------// Platform specific initialization// This routine sets the default GPIO conditionstatic void port_init(void){#if 0    // Note: Follow the configuration order for setting the ports.    // 1) Set data register (GPnDAT)    // 2) Set control register (GPnCON)    // 3) Configure pull-up's (GPnUP)    //*** PORT A GROUP    //Ports  : GPA22 GPA21  GPA20 GPA19 GPA18 GPA17 GPA16 GPA15 GPA14 GPA13 GPA12    //Signal : nFCE nRSTOUT nFRE   nFWE  ALE   CLE  nGCS5 nGCS4 nGCS3 nGCS2 nGCS1    //Binary :  1      1      1      1    1     1     1     1     1     1     1    //-----------------------------------------------------------------------------------------    //Ports  : GPA11   GPA10  GPA9   GPA8   GPA7   GPA6   GPA5   GPA4   GPA3   GPA2   GPA1  GPA0    //Signal : ADDR26 ADDR25 ADDR24 ADDR23 ADDR22 ADDR21 ADDR20 ADDR19 ADDR18 ADDR17 ADDR16 ADDR0    //Binary :  1       1      1      1      1      1      1      1      1      1      1      1    HAL_WRITE_UINT32(GPACON, 0x7fffff);    //**** PORT B GROUP    //Ports  : GPB10    GPB9    GPB8    GPB7    GPB6     GPB5    GPB4   GPB3   GPB2     GPB1      GPB0    //Signal : nXDREQ0 nXDACK0 nXDREQ1 nXDACK1 nSS_KBD nDIS_OFF L3CLOCK L3DATA L3MODE nIrDATXDEN Keyboard    //Setting: INPUT  OUTPUT   INPUT  OUTPUT   INPUT   OUTPUT   OUTPUT OUTPUT OUTPUT   OUTPUT    OUTPUT    //Binary :   00     01       00     01       00      01       01     01     01       01        01    HAL_WRITE_UINT32(GPBCON, 0x044555);    HAL_WRITE_UINT32(GPBUP, 0x7ff);      // The pull up function is disabled GPB[10:0]    //*** PORT C GROUP    //Ports  : GPC15 GPC14 GPC13 GPC12 GPC11 GPC10 GPC9 GPC8 GPC7   GPC6   GPC5 GPC4 GPC3  GPC2  GPC1 GPC0    //Signal : VD7   VD6   VD5   VD4   VD3   VD2   VD1  VD0 LCDVF2 LCDVF1 LCDVF0 VM VFRAME VLINE VCLK LEND    //Binary : 10    10    10    10    10    10    10   10    10     10     10   10   10     10   10   10    HAL_WRITE_UINT32(GPCCON, 0xaaaaaaaa);    HAL_WRITE_UINT32(GPCUP, 0xffff);     // The pull up function is disabled GPC[15:0]    //*** PORT D GROUP    //Ports  : GPD15 GPD14 GPD13 GPD12 GPD11 GPD10 GPD9 GPD8 GPD7 GPD6 GPD5 GPD4 GPD3 GPD2 GPD1 GPD0    //Signal : VD23  VD22  VD21  VD20  VD19  VD18  VD17 VD16 VD15 VD14 VD13 VD12 VD11 VD10 VD9  VD8    //Binary :  10    10    10    10    10    10    10   10   10   10   10   10   10   10  10   10    HAL_WRITE_UINT32(GPDCON, 0xaaaaaaaa);    HAL_WRITE_UINT32(GPDUP, 0xffff);     // The pull up function is disabled GPD[15:0]    //*** PORT E GROUP    //Ports  : GPE15  GPE14 GPE13   GPE12   GPE11   GPE10   GPE9    GPE8     GPE7   GPE6  GPE5   GPE4    //Signal : IICSDA IICSCL SPICLK SPIMOSI SPIMISO SDDATA3 SDDATA2 SDDATA1 SDDATA0 SDCMD SDCLK I2SSDO    //Binary :  10     10     10      10      10      10      10      10      10     10    10     10    //------------------------------------------------------------------------------------------------    //Ports  :  GPE3   GPE2  GPE1    GPE0    //Signal : I2SSDI CDCLK I2SSCLK I2SLRCK

⌨️ 快捷键说明

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