/* romInit.s - Motorola 860DAB ROM initialization module */
#define _ASMLANGUAGE #include "vxWorks.h" #include "asm.h" #include "cacheLib.h" #include "config.h" #include "regs.h" #include "sysLib.h" #include "drv/multi/ppc860Siu.h" /* internals */
.globl _romInit /* start of system code */ .globl romInit /* start of system code */ /* externals */
.extern romStart /* system initialization routine */
.text .align 2
_romInit: romInit: bl cold /* jump to the cold boot initialization */ bl start /* jump to the warm boot initialization */
/* copyright notice appears at beginning of ROM (in TEXT segment) */
.ascii "Copyright 1984-1996 Wind River Systems, Inc." .align 2
cold: li r3, BOOT_COLD /* set cold boot as start type */
lis r4, HIADJ(start) /* load r4 with the address */ addi r4, r4, LO(start) /* of start */
lis r5, HIADJ(romInit) /* load r5 with the address */ addi r5, r5, LO(romInit) /* of romInit() */
lis r6, HIADJ(ROM_TEXT_ADRS) /* load r6 with the address */ addi r6, r6, LO(ROM_TEXT_ADRS) /* of ROM_TEXT_ADRS */
sub r4, r4, r5 /* */ add r4, r4, r6
mtspr LR, r4 /* save destination address*/ /* into LR register */ blr /* jump to flash mem address */ start: /* set the MSR register to a known state */ xor r4, r4, r4 /* clear register R4 */ mtmsr r4 /* cleat the MSR register */ /* DER - clear the Debug Enable Register */ mtspr DER, r4 /* ICR - clear the Interrupt Cause Register */ mtspr ICR, r4 /*ICTRL - initialize the Intstruction Support Control register*/ lis r5, HIADJ(0x00000007) addi r5, r5, LO(0x00000007) mtspr ICTRL, r5 /* disable the instruction/data cache */ lis r4, HIADJ ( CACHE_CMD_DISABLE) /* load disable cmd */ addi r4, r4, LO (CACHE_CMD_DISABLE) mtspr IC_CST, r4 /* disable I cache */ mtspr DC_CST, r4 /* disable D cache */ /* unlock the instruction/data cache */ lis r4, HIADJ ( CACHE_CMD_UNLOCK_ALL) /* load unlock cmd */ addi r4, r4, LO (CACHE_CMD_UNLOCK_ALL) mtspr IC_CST, r4 /* unlock all I cache lines */ mtspr DC_CST, r4 /* unlock all D cache lines */ /* invalidate the instruction/data cache */ lis r4, HIADJ ( CACHE_CMD_INVALIDATE) /* load invalidate cmd*/ addi r4, r4, LO (CACHE_CMD_INVALIDATE) mtspr IC_CST, r4 /* invalidate all I cache lines */ mtspr DC_CST, r4 /* invalidate all D cache lines */ /* * initialize the IMMR register before any non-core registers * modification. */
lis r4, HIADJ( INTERNAL_MEM_MAP_ADDR) addi r4, r4, LO(INTERNAL_MEM_MAP_ADDR) mtspr IMMR, r4 /* initialize the IMMR register */
mfspr r4, IMMR /* read it back, to be sure */ rlwinm r4, r4, 0, 0, 15 /* only high 16 bits count */
/* SYPCR - turn off the system protection stuff */
lis r5, HIADJ( 0xFFFFFF08) addi r5, r5, LO(0xFFFFFF08) stw r5, SYPCR(0)(r4)
/* set the SIUMCR register for important debug port, etc... stuff */
lis r5, HIADJ( 0x00600400) addi r5, r5, LO(0x00600400) stw r5, SIUMCR(0)(r4)
/* TBSCR - initialize the Time Base Status and Control register */ lis r5, HIADJ( TBSCR_REFA | TBSCR_REFB) addi r5, r5, LO(TBSCR_REFA | TBSCR_REFB) sth r5, TBSCR(0)(r4) /* set PIT status and control init value */ li r5, PISCR_PS | PISCR_PITF sth r5, PISCR(0)(r4) /* set the SPLL frequency to 40 Mhz : Mo */ /* lis r5, HIADJ( 0x00800000) addi r5, r5, LO(0x00800000) stw r5, SCCR(0)(r4) */ lis r5, HIADJ( (SPLL_MUL_FACTOR << PLPRCR_MF_SHIFT) | PLPRCR_TEXPS) addi r5, r5, LO((SPLL_MUL_FACTOR << PLPRCR_MF_SHIFT) | PLPRCR_TEXPS) stw r5, PLPRCR(0)(r4)
/* Select the UPM table for SDRAM */
lis r6, HIADJ( UpmTable) addi r6, r6, LO(UpmTable)
lis r7, HIADJ( UpmTableEnd) addi r7, r7, LO(UpmTableEnd) b upmInit
upmInit: /* init UPMA for memory access */
sub r5, r7, r6 /* compute table size */ srawi r5, r5, 2 /* in integer size */
/* convert UpmTable to ROM based addressing */
lis r7, HIADJ(romInit) addi r7, r7, LO(romInit)
lis r8, HIADJ(ROM_TEXT_ADRS) addi r8, r8, LO(ROM_TEXT_ADRS)
sub r6, r6, r7 /* subtract romInit base address */ add r6, r6, r8 /* add in ROM_TEXT_ADRS address */
lis r9, HIADJ ( 0x0 ) addi r9, r9, LO( 0x0 )
UpmWriteLoop: /* write the UPM table in the UPM */
lwz r10, 0(r6) /* get data from table */ stw r10, MDR(0)(r4) /* store the data to MD register */
stw r9, MCR(0)(r4) /* issue command to MCR register */
addi r6, r6, 4 /* next entry in the table */ addi r9, r9, 1 /* next MAD address */ cmpw r9, r5 /* done yet ? */ blt UpmWriteLoop /**/ lis r5, HIADJ( 0xFF800E00) addi r5, r5, LO(0xFF800E00) stw r5, OR2(0)(r4)
lis r5, HIADJ( 0x00000081) addi r5, r5, LO( 0x00000081) stw r5, BR2(0)(r4)
lis r5, HIADJ( 0x4E802114 ) addi r5, r5, LO(0x4E802114 ) stw r5, MAMR(0)(r4)
li r5, 0x0800 sth r5, MPTPR(0)(r4)
li r5, 0x0000 sth r5, MSTAT(0)(r4) /**/ lis r5, HIADJ( 0xffffffff) addi r5, r5, LO(0xffffffff ) stw r5, MDR(0)(r4)
lis r5, HIADJ( 0x00000088) addi r5, r5, LO(0x00000088 ) stw r5, MAR(0)(r4)
lis r5, HIADJ( 0x80004110) addi r5, r5, LO(0x80004110 ) stw r5, MCR(0)(r4) lis r5, HIADJ( 0x80004811) addi r5, r5, LO(0x80004811 ) stw r5, MCR(0)(r4) lis r5, HIADJ( 0x80004116) addi r5, r5, LO(0x80004116 ) stw r5, MCR(0)(r4) /**/ sdramInit: /* Map the bank 2 to the SDram area */
lis r5, HIADJ( 0xFF800E00 ) addi r5, r5, LO( 0xFF800E00 ) stw r5, OR2(0)(r4)
lis r5, HIADJ( 0x00000081 ) addi r5, r5, LO(0x00000081 ) stw r5, BR2(0)(r4)
lis r5, HIADJ( 0x4E802114 ) addi r5, r5, LO( 0x4E802114 ) stw r5, MAMR(0)(r4)
/* * Map the bank 0 to the flash area - On the 860pc board at reset time * the bank 0 is already used to map the flash. */ lis r5, HIADJ(0x00000000) addi r5, r5, LO(0x00000000) stw r5, BR1(0)(r4)
lis r5, HIADJ(0x00000000) addi r5, r5, LO(0x00000000) stw r5, OR1(0)(r4)
lis r5, HIADJ( 0x00000000) addi r5, r5, LO(0x00000000) stw r5, BR5(0)(r4)
lis r5, HIADJ(0x00000000) addi r5, r5, LO(0x00000000) stw r5, OR5(0)(r4)
lis r5, HIADJ( 0x00000000) addi r5, r5, LO(0x00000000) stw r5, BR3(0)(r4)
lis r5, HIADJ(0x00000000) addi r5, r5, LO(0x00000000) stw r5, OR3(0)(r4)
lis r5, HIADJ( 0x00000000) addi r5, r5, LO(0x00000000) stw r5, BR4(0)(r4)
lis r5, HIADJ(0x00000000) addi r5, r5, LO(0x00000000) stw r5, OR4(0)(r4)
lis r5, HIADJ( 0x00000000) addi r5, r5, LO(0x00000000) stw r5, BR6(0)(r4)
lis r5, HIADJ(0x00000000) addi r5, r5, LO(0x00000000) stw r5, OR6(0)(r4)
lis r5, HIADJ( 0x00000000) addi r5, r5, LO(0x00000000) stw r5, BR7(0)(r4)
lis r5, HIADJ(0x00000000) addi r5, r5, LO(0x00000000) stw r5, OR7(0)(r4)
lis r5, HIADJ( 0x00800001) addi r5, r5, LO(0x00800001) stw r5, BR0(0)(r4)
lis r5, HIADJ( 0xFFC00920 ) addi r5, r5, LO(0xFFC00920 ) stw r5, OR0(0)(r4)
/* initialize the stack pointer */
lis sp, HIADJ(STACK_ADRS) addi sp, sp, LO(STACK_ADRS) /* go to C entry point */
addi sp, sp, -FRAMEBASESZ /* get frame stack */
/* * calculate C entry point: routine - entry point + ROM base * routine = romStart * entry point = romInit = R7 * ROM base = ROM_TEXT_ADRS = R8 * C entry point: romStart - R7 + R8 */
lis r6, HIADJ(romStart) addi r6, r6, LO(romStart) /* load R6 with C entry point */
sub r6, r6, r7 /* routine - entry point */ add r6, r6, r8 /* + ROM base */
mtlr r6 /* move C entry point to LR */ blr /* jump to the C entry point */
UpmTable: /* single read. (offset 0 in upm RAM) */ .long 0x0f0dfc24, 0x0ffffc04, 0x00bf7c04, 0x0ffdf400 .long 0x1ffffc05, 0x0ffffc04, 0x0FFFFC04, 0x1ffffc05
/* burst read. (offset 8 in upm RAM) */ .long 0x0f0dfc24, 0x0ffffc04, 0x00bf7c04, 0x00fffc00 .long 0x00fffc00, 0x00fffc00, 0x0ffdf400, 0x1ffdfc05 .long 0x0ffdf405, 0x0ffd7c84, 0xfffffc04, 0xfffffc04 .long 0xfffffc84, 0xfffffc05, 0x0f0d7434, 0xfffffc05
/* single write. (offset 18 in upm RAM) */ .long 0x0f0dfc24, 0x0ffffc00, 0x00bf7404, 0x0ffffc04 .long 0x0ffdf404, 0x1ffffc05, 0xfffffc44, 0xfffffd47
/* burst write. (offset 20 in upm RAM) */ .long 0x0f0dfc24, 0x0ffffc00, 0x00bf7400, 0x00fffc00 .long 0x00fffc00, 0x00fffc04, 0x00fffc04, 0x0ffdf404 .long 0x1ffffc05, 0xfffffc47, 0xfffffc04, 0xfffffc04 .long 0xfffffc04, 0xfffffc04, 0xfffffc04, 0xfffffc04
/* refresh. (offset 30 in upm RAM) */ .long 0x0ffd7c84, 0x0ffffc04, 0x0ffffc04, 0x0ffffc84 .long 0x1ffffc05, 0xfffffc04, 0xfffffc04, 0xfffffc04 .long 0xfffffc04, 0xfffffc04, 0xfffffc04, 0xfffffc04
/* exception. (offset 3c in upm RAM) */ .long 0x7ffffc07, 0xffffffff, 0xffffffff, 0xffffffff
UpmTableEnd: |