📄 flashentry.s
字号:
/* flashentry.s * * This file contains the entry code for RTEMS programs starting * directly from Flash. * * Author: Thomas Doerfler <td@imd.m.isar.de> * IMD Ingenieurbuero fuer Microcomputertechnik * * COPYRIGHT (c) 1998 by IMD * * Changes from IMD are covered by the original distributions terms. * This file has been derived from the papyrus BSP: * * This file contains the entry veneer for RTEMS programs * stored in Papyrus' flash ROM. * * Author: Andrew Bray <andy@i-cubed.co.uk> * * COPYRIGHT (c) 1995 by i-cubed ltd. * * To anyone who acknowledges that this file is provided "AS IS" * without any express or implied warranty: * permission to use, copy, modify, and distribute this file * for any purpose is hereby granted without fee, provided that * the above copyright notice and this notice appears in all * copies, and that the name of i-cubed limited not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * i-cubed limited makes no representations about the suitability * of this software for any purpose. * * $Id: flashentry.S,v 1.2.6.1 2004/11/02 02:43:35 ralf Exp $ */#include "asm.h"#include <rtems/score/ppc.h> /*---------------------------------------------------------------------------- * Reset_entry. *---------------------------------------------------------------------------*/#if PPC_ASM == PPC_ASM_ELF .section .reset,"ax",@progbits /* this section MUST be located at absolute address 0xFFFFFFFC or last word of EPROM */#else .csect .text[PR]#endif ba flash_entry /* this is the first instruction after reset */ .previous /*---------------------------------------------------------------------------- * ROM Vector area. *---------------------------------------------------------------------------*/#if PPC_ASM == PPC_ASM_ELF .section .entry,"ax",@progbits#else .csect .text[PR]#endif PUBLIC_VAR (flash_entry)SYM (flash_entry): bl .startup /* call startup, link reg points to base_addr */base_addr:/*---------------------------------------------------------------------------- * Parameters from linker *---------------------------------------------------------------------------*/toc_pointer:#if PPC_ASM == PPC_ASM_ELF .long s.got#else .long TOC[tc0]#endiftext_length: .long text.sizetext_addr: .long text.startcopy_src: .long copy.srccopy_length: .long copy.sizecopy_dest: .long copy.destbss_length: .long bss.sizebss_addr: .long bss.startstack_top: .long stack.end /*---------------------------------------------------------------------------- * from Reset_entry. *---------------------------------------------------------------------------*/.startup: /* Get start address, r1 points to label base_addr */ mflr r1 /* Set up Bank regs, cache etc. */ /* set up bank register BR0 for Flash-EPROM: * NOTE: bank size should stay 1MByte, this is standard size * after RESET * base addr = Fffxxxxx -> 0b11111111........................ * bank size = 1 MByte -> 0b........000..................... (std) * bank use = readonly -> 0b...........01................... * seq. fill = targ frst-> 0b.............0.................. * burst mode= enable -> 0b..............1................. * bus width = 8 bit -> 0b...............00............... * ready pin = disable -> 0b.................0.............. * first wait= 2 clocks -> 0b..................0010.......... * burst wait= 2 clocks -> 0b......................10........ * CSon time = 0 clocks -> 0b........................0....... * OEon time = 0 clocks -> 0b.........................0...... * WBon time = 1 clocks -> 0b..........................1..... * WBoff time= 0 clocks -> 0b...........................0.... * Hold time = 1 clocks -> 0b............................001. * ram type = SRAM(ign)-> 0b...............................1 * value 0b11111111000010100000101000100011 * 0x F F 0 A 0 A 2 3 */ lis r2,0xFF0A ori r2,r2,0x0A23 mtdcr br0,r2 /* write to DCR BR0 */ /*-------------------------------------------------------------------- * test various RAM configurations (from big to small per bank) *------------------------------------------------------------------*/ /*-------------------------------------------------------------------- * test RAM config 16 MByte (1x4Mx32Bit) *------------------------------------------------------------------*/ /* set up bank register BR7 for DRAM: * base addr = 000xxxxx -> 0b00000000........................ * bank size = 16MByte -> 0b........100..................... * bank use = readwrite-> 0b...........11................... * seq. fill = targ.frst-> 0b.............0.................. * early RAS = disabled -> 0b..............0................. * bus width = 32bit -> 0b...............10............... * adr mux = internal -> 0b.................0.............. * RAS to CAS= 2 clocks -> 0b..................1............. * Alt. Rfrsh= normal -> 0b...................0............ * page mode = enabled -> 0b....................1........... * first wait= 1 clocks -> 0b.....................01......... * burst wait= 1 clocks -> 0b.......................01....... * precharge = 1 clocks -> 0b.........................0...... * RAS Rfrsh = 2 clocks -> 0b..........................1..... * Rfrsh Itvl= 512 clks -> 0b...........................1000. * ram type = DRAM -> 0b...............................0 * value 0b00000000100110010010101010110000 * 0x 0 0 9 9 2 A B 0 */ lis r2,0x0099 ori r2,r2,0x2AB0 mtdcr br7,r2 /* write to DCR BR7*/ lis r2,0x0000 /* start address = 0x00000000 */ lis r3,0x0100 /* size 16 MB = 0x01000000 */ bl ramacc /* test memory accessibility */ cmpi 0,0,r4,0 /* memory ok? else test smaller size */ bne ramcfgt18 /*-------------------------------------------------------------------- * test RAM config 32 MByte (2x4Mx32Bit) *------------------------------------------------------------------*/ /* set up bank register BR7 like above * set up bank register BR6 for DRAM: * base addr = 010xxxxx -> 0b00010000........................ * bank size = 16MByte -> 0b........100..................... (for now) * bank use = readwrite-> 0b...........11................... * seq. fill = targ.frst-> 0b.............0.................. * early RAS = disabled -> 0b..............0................. * bus width = 32bit -> 0b...............10............... * adr mux = internal -> 0b.................0.............. * RAS to CAS= 2 clocks -> 0b..................1............. * Alt. Rfrsh= normal -> 0b...................0............ * page mode = enabled -> 0b....................1........... * first wait= 1 clocks -> 0b.....................01......... * burst wait= 1 clocks -> 0b.......................01....... * precharge = 1 clocks -> 0b.........................0...... * RAS Rfrsh = 2 clocks -> 0b..........................1..... * Rfrsh Itvl= 512 clks -> 0b...........................1000. * ram type = DRAM -> 0b...............................0 * value 0b00010000100110010010101010110000 * 0x 1 0 9 9 2 A B 0 */ lis r2,0x1099 ori r2,r2,0x2AB0 mtdcr br6,r2 /* write to DCR BR6*/ lis r2,0x0100 /* start address = 0x01000000 */ lis r3,0x0100 /* size 16 MB = 0x01000000 */ bl ramacc /* test memory accessibility */ cmpi 0,0,r4,0 /* memory ok? else test smaller size */ beq ramcfgok /* ok, we found configuration... */ lis r2,0x0000 /* disable BR6, config not ok */ mtdcr br6,r2 /* write to DCR BR6*/ b ramcfgok /* and finish configuration */ ramcfgt18: /*-------------------------------------------------------------------- * test RAM config 8 MByte (1x2Mx32Bit) *------------------------------------------------------------------*/ /* set up bank register BR7 for DRAM: * base addr = 000xxxxx -> 0b00000000........................ * bank size = 8MByte -> 0b........011..................... * bank use = readwrite-> 0b...........11................... * seq. fill = targ.frst-> 0b.............0.................. * early RAS = disabled -> 0b..............0................. * bus width = 32bit -> 0b...............10............... * adr mux = internal -> 0b.................0.............. * RAS to CAS= 2 clocks -> 0b..................1............. * Alt. Rfrsh= normal -> 0b...................0............ * page mode = enabled -> 0b....................1........... * first wait= 1 clocks -> 0b.....................01......... * burst wait= 1 clocks -> 0b.......................01....... * precharge = 1 clocks -> 0b.........................0...... * RAS Rfrsh = 2 clocks -> 0b..........................1..... * Rfrsh Itvl= 512 clks -> 0b...........................1000. * ram type = DRAM -> 0b...............................0 * value 0b00000000011110010010101010110000 * 0x 0 0 7 9 2 A B 0 */ lis r2,0x0079 ori r2,r2,0x2AB0 mtdcr br7,r2 /* write to DCR BR7 */ lis r2,0x0000 /* start address = 0x00000000 */ lis r3,0x0080 /* size 8 MB = 0x00800000 */ bl ramacc /* test memory accessibility */ cmpi 0,0,r4,0 /* memory ok? else test smaller size */ bne ramcfgt14 /*-------------------------------------------------------------------- * test RAM config 16 MByte (2x2Mx32Bit) *------------------------------------------------------------------*/ /* set up bank register BR7 like above * set up bank register BR6 for DRAM:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -