;/*****************************************************************************/
;/* S3C44B0X.S: Startup file for Samsung S3C44B0X */
;/*****************************************************************************/
;/* <<< Use Configuration Wizard in Context Menu >>> */
;/*****************************************************************************/
;/* This file is part of the uVision/ARM development tools. */
;/* Copyright (c) 2005-2006 Keil Software. All rights reserved. */
;/* This software may only be used under the terms of a valid, current, */
;/* end user licence from KEIL for a compatible version of KEIL software */
;/* development tools. Nothing else gives you the right to use this software. */
;/*****************************************************************************/
; *** Startup Code (executed after Reset) ***
; Standard definitions of Mode bits and Interrupt (I & F) flags in PSRs
Mode_USR EQU 0x10
Mode_FIQ EQU 0x11
Mode_IRQ EQU 0x12
Mode_SVC EQU 0x13
Mode_ABT EQU 0x17
Mode_UND EQU 0x1B
Mode_SYS EQU 0x1F
I_Bit EQU 0x80 ; when I bit is set, IRQ is disabled
F_Bit EQU 0x40 ; when F bit is set, FIQ is disabled
;// Stack Configuration (Stack Sizes in Bytes)
;// Undefined Mode <0x0-0xFFFFFFFF:8>
;// Supervisor Mode <0x0-0xFFFFFFFF:8>
;// Abort Mode <0x0-0xFFFFFFFF:8>
;// Fast Interrupt Mode <0x0-0xFFFFFFFF:8>
;// Interrupt Mode <0x0-0xFFFFFFFF:8>
;// User/System Mode <0x0-0xFFFFFFFF:8>
;//
UND_Stack_Size EQU 0x00000000
SVC_Stack_Size EQU 0x00000100
ABT_Stack_Size EQU 0x00000000
FIQ_Stack_Size EQU 0x00000000
IRQ_Stack_Size EQU 0x00000100
USR_Stack_Size EQU 0x00000100
ISR_Stack_Size EQU (UND_Stack_Size + SVC_Stack_Size + ABT_Stack_Size + \
FIQ_Stack_Size + IRQ_Stack_Size)
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE USR_Stack_Size
__initial_sp SPACE ISR_Stack_Size
Stack_Top
;// Heap Configuration
;// Heap Size (in Bytes) <0x0-0xFFFFFFFF>
;//
Heap_Size EQU 0x00000000
AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem SPACE Heap_Size
__heap_limit
; CPU Wrapper and Bus Priorities definitions
CPUW_BASE EQU 0x01C00000 ; CPU Wrapper Base Address
SYSCFG_OFS EQU 0x00 ; SYSCFG Offset
NCACHBE0_OFS EQU 0x04 ; NCACHBE0 Offset
NCACHBE1_OFS EQU 0x08 ; NCACHBE0 Offset
BUSP_BASE EQU 0x01C40000 ; Bus Priority Base Address
SBUSCON_OFS EQU 0x00 ; SBUSCON Offset
;// CPU Wrapper and Bus Priorities
;// CPU Wrapper
;// SE: Stall Enable
;// CM: Cache Mode
;// <0=> Disable Cache (8kB SRAM)
;// <1=> Half Cache Enable (4kB Cache, 4kB SRAM)
;// <2=> Reserved
;// <3=> Full Cache Enable (8kB Cache)
;// WE: Write Buffer Enable
;// RSE: Read Stall Enable
;// DA: Data Abort <0=> Enable <1=> Disable
;// Non-cacheable Area 0
;// Start Address <0x0-0x0FFFF000:0x1000><#/0x1000>
;// SA = (Start Address) / 4k
;// End Address + 1 <0x0-0x10000000:0x1000><#/0x1000>
;// SE = (End Address + 1) / 4k
;//
;// Non-cacheable Area 1
;// Start Address <0x0-0x0FFFF000:0x1000><#/0x1000>
;// SA = (Start Address) / 4k
;// End Address + 1 <0x0-0x10000000:0x1000><#/0x1000>
;// SE = (End Address + 1) / 4k
;//
;//
;// Bus Priorities
;// FIX: Fixed Priorities
;// LCD_DMA <0=> 1st <1=> 2nd <2=> 3rd <3=> 4th
;// ZDMA <0=> 1st <1=> 2nd <2=> 3rd <3=> 4th
;// BDMA <0=> 1st <1=> 2nd <2=> 3rd <3=> 4th
;// nBREQ <0=> 1st <1=> 2nd <2=> 3rd <3=> 4th
;//
;//
SYS_SETUP EQU 0
SYSCFG_Val EQU 0x00000001
NCACHBE0_Val EQU 0x00000000
NCACHBE1_Val EQU 0x00000000
SBUSCON_Val EQU 0x80001B1B
;// Vectored Interrupt Mode (for IRQ)
;// EINT0 External Interrupt 0
;// EINT1 External Interrupt 1
;// EINT2 External Interrupt 2
;// EINT3 External Interrupt 3
;// EINT4567 External Interrupt 4/5/6/7
;// TICK RTC Time Tick Interrupt
;// ZDMA0 General DMA0 Interrupt
;// ZDMA1 General DMA1 Interrupt
;// BDMA0 Bridge DMA0 Interrupt
;// BDMA1 Bridge DMA1 Interrupt
;// WDT Watchdog Timer Interrupt
;// UERR01 UART0/1 Error Interrupt
;// TIMER0 Timer0 Interrupt
;// TIMER1 Timer1 Interrupt
;// TIMER2 Timer2 Interrupt
;// TIMER3 Timer3 Interrupt
;// TIMER4 Timer4 Interrupt
;// TIMER5 Timer5 Interrupt
;// URXD0 UART0 Rx Interrupt
;// URXD1 UART1 Rx Interrupt
;// IIC IIC Interrupt
;// SIO SIO Interrupt
;// UTXD0 UART0 Tx Interrupt
;// UTXD1 UART1 Tx Interrupt
;// RTC RTC Alarm Interrupt
;// ADC ADC EOC Interrupt
;//
VIM_SETUP EQU 0
VIM_CFG EQU 0x00000000
; Clock Management definitions
CLK_BASE EQU 0x01D80000 ; Clock Base Address
PLLCON_OFS EQU 0x00 ; PLLCON Offset
CLKCON_OFS EQU 0x04 ; CLKCON Offset
CLKSLOW_OFS EQU 0x08 ; CLKSLOW Offset
LOCKTIME_OFS EQU 0x0C ; LOCKTIME Offset
;// Clock Management
;// PLL Settings
;// Fpllo = (m * Fin) / (p * 2^s), 20MHz < Fpllo < 66MHz
;// MDIV: Main divider <0x0-0xFF>
;// m = MDIV + 8
;// PDIV: Pre-divider <0x0-0x3F>
;// p = PDIV + 2, 1MHz <= Fin/p < 2MHz
;// SDIV: Post Divider <0x0-0x03>
;// s = SDIV, Fpllo * 2^s < 170MHz
;// LTIME CNT: PLL Lock Time Count <0x0-0x0FFF>
;//
;// Master Clock
;// PLL Clock: Fout = Fpllo
;// Slow Clock: Fout = Fin / (2 * SLOW_VAL), SLOW_VAL > 0
;// Slow Clock: Fout = Fin, SLOW_VAL = 0
;// PLL_OFF: PLL Off
;// PLL is turned Off only when SLOW_BIT = 1
;// SLOW_BIT: Slow Clock
;// SLOW_VAL: Slow Clock divider <0x0-0x0F>
;//
;// Clock Generation
;// IIS <0=> Disable <1=> Enable
;// IIC <0=> Disable <1=> Enable
;// ADC <0=> Disable <1=> Enable
;// RTC <0=> Disable <1=> Enable
;// GPIO <0=> Disable <1=> Enable
;// UART1 <0=> Disable <1=> Enable
;// UART0 <0=> Disable <1=> Enable
;// BDMA0,1 <0=> Disable <1=> Enable
;// LCDC <0=> Disable <1=> Enable
;// SIO <0=> Disable <1=> Enable
;// ZDMA0,1 <0=> Disable <1=> Enable
;// PWMTIMER <0=> Disable <1=> Enable
;//
;//
CLK_SETUP EQU 1
PLLCON_Val EQU 0x00038080
CLKCON_Val EQU 0x00007FF8
CLKSLOW_Val EQU 0x00000009
LOCKTIME_Val EQU 0x00000FFF
; Watchdog Timer definitions
WT_BASE EQU 0x01D30000 ; WT Base Address
WTCON_OFS EQU 0x00 ; WTCON Offset
WTDAT_OFS EQU 0x04 ; WTDAT Offset
WTCNT_OFS EQU 0x08 ; WTCNT Offset
;// Watchdog Timer
;// Watchdog Timer Enable/Disable
;// Reset Enable/Disable
;// Interrupt Enable/Disable
;// Clock Select
;// <0=> 1/16 <1=> 1/32 <2=> 1/64 <3=> 1/128
;// Clock Division Factor
;// Prescaler Value <0x0-0xFF>
;// Time-out Value <0x0-0xFFFF>
;//
WT_SETUP EQU 1
WTCON_Val EQU 0x00008000
WTDAT_Val EQU 0x00008000
; Memory Controller definitions
MC_BASE EQU 0x01C80000 ; Memory Controller Base Address
;// Memory Controller
MC_SETUP EQU 1
;// Bank 0
;// PMC: Page Mode Configuration
;// <0=> 1 Data <1=> 4 Data <2=> 8 Data <3=> 16 Data
;// Tpac: Page Mode Access Cycle
;// <0=> 2 clks <1=> 3 clks <2=> 4 clks <3=> 6 clks
;// Tcah: Address Holding Time after nGCSn
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;// Toch: Chip Select Hold on nOE
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;// Tacc: Access Cycle
;// <0=> 1 clk <1=> 2 clks <2=> 3 clks <3=> 4 clks
;// <4=> 6 clk <5=> 8 clks <6=> 10 clks <7=> 14 clks
;// Tcos: Chip Select Set-up nOE
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;// Tacs: Address Set-up before nGCSn
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;//
;//
;// Bank 1
;// DW: Data Bus Width
;// <0=> 8-bit <1=> 16-bit <2=> 32-bit <3=> Rsrvd
;// WS: WAIT Status
;// <0=> WAIT Disable
;// <1=> WAIT Enable
;// ST: SRAM Type
;// <0=> Not using UB/LB
;// <1=> Using UB/LB
;// PMC: Page Mode Configuration
;// <0=> 1 Data <1=> 4 Data <2=> 8 Data <3=> 16 Data
;// Tpac: Page Mode Access Cycle
;// <0=> 2 clks <1=> 3 clks <2=> 4 clks <3=> 6 clks
;// Tcah: Address Holding Time after nGCSn
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;// Toch: Chip Select Hold on nOE
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;// Tacc: Access Cycle
;// <0=> 1 clk <1=> 2 clks <2=> 3 clks <3=> 4 clks
;// <4=> 6 clk <5=> 8 clks <6=> 10 clks <7=> 14 clks
;// Tcos: Chip Select Set-up nOE
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;// Tacs: Address Set-up before nGCSn
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;//
;//
;// Bank 2
;// DW: Data Bus Width
;// <0=> 8-bit <1=> 16-bit <2=> 32-bit <3=> Rsrvd
;// WS: WAIT Status
;// <0=> WAIT Disable
;// <1=> WAIT Enable
;// ST: SRAM Type
;// <0=> Not using UB/LB
;// <1=> Using UB/LB
;// PMC: Page Mode Configuration
;// <0=> 1 Data <1=> 4 Data <2=> 8 Data <3=> 16 Data
;// Tpac: Page Mode Access Cycle
;// <0=> 2 clks <1=> 3 clks <2=> 4 clks <3=> 6 clks
;// Tcah: Address Holding Time after nGCSn
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;// Toch: Chip Select Hold on nOE
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;// Tacc: Access Cycle
;// <0=> 1 clk <1=> 2 clks <2=> 3 clks <3=> 4 clks
;// <4=> 6 clk <5=> 8 clks <6=> 10 clks <7=> 14 clks
;// Tcos: Chip Select Set-up nOE
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;// Tacs: Address Set-up before nGCSn
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;//
;//
;// Bank 3
;// DW: Data Bus Width
;// <0=> 8-bit <1=> 16-bit <2=> 32-bit <3=> Rsrvd
;// WS: WAIT Status
;// <0=> WAIT Disable
;// <1=> WAIT Enable
;// ST: SRAM Type
;// <0=> Not using UB/LB
;// <1=> Using UB/LB
;// PMC: Page Mode Configuration
;// <0=> 1 Data <1=> 4 Data <2=> 8 Data <3=> 16 Data
;// Tpac: Page Mode Access Cycle
;// <0=> 2 clks <1=> 3 clks <2=> 4 clks <3=> 6 clks
;// Tcah: Address Holding Time after nGCSn
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;// Toch: Chip Select Hold on nOE
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;// Tacc: Access Cycle
;// <0=> 1 clk <1=> 2 clks <2=> 3 clks <3=> 4 clks
;// <4=> 6 clk <5=> 8 clks <6=> 10 clks <7=> 14 clks
;// Tcos: Chip Select Set-up nOE
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;// Tacs: Address Set-up before nGCSn
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;//
;//
;// Bank 4
;// DW: Data Bus Width
;// <0=> 8-bit <1=> 16-bit <2=> 32-bit <3=> Rsrvd
;// WS: WAIT Status
;// <0=> WAIT Disable
;// <1=> WAIT Enable
;// ST: SRAM Type
;// <0=> Not using UB/LB
;// <1=> Using UB/LB
;// PMC: Page Mode Configuration
;// <0=> 1 Data <1=> 4 Data <2=> 8 Data <3=> 16 Data
;// Tpac: Page Mode Access Cycle
;// <0=> 2 clks <1=> 3 clks <2=> 4 clks <3=> 6 clks
;// Tcah: Address Holding Time after nGCSn
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;// Toch: Chip Select Hold on nOE
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;// Tacc: Access Cycle
;// <0=> 1 clk <1=> 2 clks <2=> 3 clks <3=> 4 clks
;// <4=> 6 clk <5=> 8 clks <6=> 10 clks <7=> 14 clks
;// Tcos: Chip Select Set-up nOE
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;// Tacs: Address Set-up before nGCSn
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;//
;//
;// Bank 5
;// DW: Data Bus Width
;// <0=> 8-bit <1=> 16-bit <2=> 32-bit <3=> Rsrvd
;// WS: WAIT Status
;// <0=> WAIT Disable
;// <1=> WAIT Enable
;// ST: SRAM Type
;// <0=> Not using UB/LB
;// <1=> Using UB/LB
;// PMC: Page Mode Configuration
;// <0=> 1 Data <1=> 4 Data <2=> 8 Data <3=> 16 Data
;// Tpac: Page Mode Access Cycle
;// <0=> 2 clks <1=> 3 clks <2=> 4 clks <3=> 6 clks
;// Tcah: Address Holding Time after nGCSn
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;// Toch: Chip Select Hold on nOE
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;// Tacc: Access Cycle
;// <0=> 1 clk <1=> 2 clks <2=> 3 clks <3=> 4 clks
;// <4=> 6 clk <5=> 8 clks <6=> 10 clks <7=> 14 clks
;// Tcos: Chip Select Set-up nOE
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;// Tacs: Address Set-up before nGCSn
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;//
;//
;// Bank 6
;// BK76MAP: Bank 6/7 Memory Map
;// <0=> 32M <4=> 2M <5=> 4M <6=> 8M <7=> 16M
;// DW: Data Bus Width
;// <0=> 8-bit <1=> 16-bit <2=> 32-bit <3=> Rsrvd
;// WS: WAIT Status
;// <0=> WAIT Disable
;// <1=> WAIT Enable
;// ST: SRAM Type
;// <0=> Not using UB/LB
;// <1=> Using UB/LB
;// MT: Memory Type
;// <0=> ROM or SRAM
;// <1=> FP DRAMP
;// <2=> EDO DRAM
;// <3=> SDRAM
;// ROM or SRAM
;// PMC: Page Mode Configuration
;// <0=> 1 Data <1=> 4 Data <2=> 8 Data <3=> 16 Data
;// Tpac: Page Mode Access Cycle
;// <0=> 2 clks <1=> 3 clks <2=> 4 clks <3=> 6 clks
;// Tcah: Address Holding Time after nGCSn
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;// Toch: Chip Select Hold on nOE
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;// Tacc: Access Cycle
;// <0=> 1 clk <1=> 2 clks <2=> 3 clks <3=> 4 clks
;// <4=> 6 clk <5=> 8 clks <6=> 10 clks <7=> 14 clks
;// Tcos: Chip Select Set-up nOE
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;// Tacs: Address Set-up before nGCSn
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;//
;// FP DRAM or EDO DRAM
;// CAN: Columnn Address Number
;// <0=> 8-bit <1=> 9-bit <2=> 10-bit <3=> 11-bit
;// Tcp: CAS Pre-charge
;// <0=> 1 clk <1=> 2 clks
;// Tcas: CAS Pulse Width
;// <0=> 1 clk <1=> 2 clks
;// Trcd: RAS to CAS Delay
;// <0=> 1 clk <1=> 2 clks <2=> 3 clks <3=> 4 clks
;//
;// SDRAM
;// SCAN: Columnn Address Number
;// <0=> 8-bit <1=> 9-bit <2=> 10-bit <3=> Rsrvd
;// Trcd: RAS to CAS Delay
;// <0=> 2 clks <1=> 3 clks <2=> 4 clks <3=> Rsrvd
;// SCLKEN: SCLK Selection (Bank 6/7)
;// <0=> Normal
;// <1=> Reduced Power
;// BL: Burst Length
;// <0=> 1
;// BT: Burst Type
;// <0=> Sequential
;// CL: CAS Latency
;// <0=> 1 clk <1=> 2 clks <2=> 3 clks
;// TM: Test Mode
;// <0=> Mode Register Set
;// WBL: Write Burst Length
;// <0=> 0
;//
;//
;//
;// Bank 7
;// BK76MAP: Bank 6/7 Memory Map
;// <0=> 32M <4=> 2M <5=> 4M <6=> 8M <7=> 16M
;// DW: Data Bus Width
;// <0=> 8-bit <1=> 16-bit <2=> 32-bit <3=> Rsrvd
;// WS: WAIT Status
;// <0=> WAIT Disable
;// <1=> WAIT Enable
;// ST: SRAM Type
;// <0=> Not using UB/LB
;// <1=> Using UB/LB
;// MT: Memory Type
;// <0=> ROM or SRAM
;// <1=> FP DRAMP
;// <2=> EDO DRAM
;// <3=> SDRAM
;// ROM or SRAM
;// PMC: Page Mode Configuration
;// <0=> 1 Data <1=> 4 Data <2=> 8 Data <3=> 16 Data
;// Tpac: Page Mode Access Cycle
;// <0=> 2 clks <1=> 3 clks <2=> 4 clks <3=> 6 clks
;// Tcah: Address Holding Time after nGCSn
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;// Toch: Chip Select Hold on nOE
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;// Tacc: Access Cycle
;// <0=> 1 clk <1=> 2 clks <2=> 3 clks <3=> 4 clks
;// <4=> 6 clk <5=> 8 clks <6=> 10 clks <7=> 14 clks
;// Tcos: Chip Select Set-up nOE
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;// Tacs: Address Set-up before nGCSn
;// <0=> 0 clk <1=> 1 clk <2=> 2 clks <3=> 4 clks
;//
;// FP DRAM or EDO DRAM
;// CAN: Columnn Address Number
;// <0=> 8-bit <1=> 9-bit <2=> 10-bit <3=> 11-bit
;// Tcp: CAS Pre-charge
;// <0=> 1 clk <1=> 2 clks
;// Tcas: CAS Pulse Width
;// <0=> 1 clk <1=> 2 clks
;// Trcd: RAS to CAS Delay
;// <0=> 1 clk <1=> 2 clks <2=> 3 clks <3=> 4 clks
;//
;// SDRAM
;// SCAN: Columnn Address Number
;// <0=> 8-bit <1=> 9-bit <2=> 10-bit <3=> Rsrvd
;// Trcd: RAS to CAS Delay
;// <0=> 2 clks <1=> 3 clks <2=> 4 clks <3=> Rsrvd
;// SCLKEN: SCLK Selection (Bank 6/7)
;// <0=> Normal
;// <1=> Reduced Power
;// BL: Burst Length
;// <0=> 1
;// BT: Burst Type
;// <0=> Sequential
;// CL: CAS Latency
;// <0=> 1 clk <1=> 2 clks <2=> 3 clks
;// TM: Test Mode
;// <0=> Mode Register Set
;// WBL: Write Burst Length
;// <0=> 0
;//
;//
;//
;// Refresh
;// REFEN: DRAM/SDRAM Refresh
;// <0=> Disable <1=> Enable
;// TREFMD: DRAM/SDRAM Refresh Mode
;// <0=> CBR/Auto Refresh
;// <1=> Self Refresh
;// Trp: DRAM/SDRAM RAS Pre-charge Time
;// <0=> 1.5 clks (DRAM) / 2 clks (SDRAM)
;// <1=> 2.5 clks (DRAM) / 3 clks (SDRAM)
;// <2=> 3.5 clks (DRAM) / 4 clks (SDRAM)
;// <3=> 4.5 clks (DRAM) / Rsrvd (SDRAM)
;// Trc: SDRAM RC Min Time
;// <0=> 4 clks <1=> 5 clks <2=> 6 clks <3=> 7 clks
;// Tchr: DRAM CAS Hold Time
;// <0=> 1 clks <1=> 2 clks <2=> 3 clks <3=> 4 clks
;// Refresh Counter <0x0-0x07FF>
;// Refresh Period = (2^11 - Refresh Count + 1) / MCLK
;//
BANKCON0_Val EQU 0x00000700
BANKCON1_Val EQU 0x00000700
BANKCON2_Val EQU 0x00000700
BANKCON3_Val EQU 0x00000700
BANKCON4_Val EQU 0x00000700
BANKCON5_Val EQU 0x00000700
BANKCON6_Val EQU 0x00018008
BANKCON7_Val EQU 0x00018008
BWSCON_Val EQU 0x00000000
REFRESH_Val EQU 0x00AC0000
BANKSIZE_Val EQU 0x00000000
MRSRB6_Val EQU 0x00000000
MRSRB7_Val EQU 0x00000000
;// End of MC
; I/O Ports definitions
PIO_BASE EQU 0x01D20000 ; PIO Base Address
PCONA_OFS EQU 0x00 ; PCONA Offset
PCONB_OFS EQU 0x08 ; PCONB Offset
PCONC_OFS EQU 0x10 ; PCONC Offset
PCOND_OFS EQU 0x1C ; PCOND Offset
PCONE_OFS EQU 0x28 ; PCONE Offset
PCONF_OFS EQU 0x34 ; PCONF Offset
PCONG_OFS EQU 0x40 ; PCONG Offset
PUPC_OFS EQU 0x18 ; PUPC Offset
PUPD_OFS EQU 0x24 ; PUPD Offset
PUPE_OFS EQU 0x30 ; PUPE Offset
PUPF_OFS EQU 0x3C ; PUPF Offset
PUPG_OFS EQU 0x48 ; PUPG Offset
SPUCR_OFS EQU 0x4C ; SPUCR Offset
;// I/O Configuration
PIO_SETUP EQU 0
;// Port A
;// PA0 <0=> Output <1=> ADDR0
;// PA1 <0=> Output <1=> ADDR16
;// PA2 <0=> Output <1=> ADDR17
;// PA3 <0=> Output <1=> ADDR18
;// PA4 <0=> Output <1=> ADDR19
;// PA5 <0=> Output <1=> ADDR20
;// PA6 <0=> Output <1=> ADDR21
;// PA7 <0=> Output <1=> ADDR22
;// PA8 <0=> Output <1=> ADDR23
;// PA9 <0=> Output <1=> ADDR24
;//
PIOA_SETUP EQU 1
PCONA_Val EQU 0x000003FF
;// Port B
;// PB0 <0=> Output <1=> SCKE
;// PB1 <0=> Output <1=> CKLK
;// PB2 <0=> Output <1=> nSCAS/nCAS2
;// PB3 <0=> Output <1=> nSRAS/nCAS3
;// PB4 <0=> Output <1=> nWBE2/nBE2/DQM2
;// PB5 <0=> Output <1=> nWBE3/nBE3/DQM3
;// PB6 <0=> Output <1=> nGCS1
;// PB7 <0=> Output <1=> nGCS2
;// PB8 <0=> Output <1=> nGCS3
;// PB9 <0=> Output <1=> nGCS4
;// PB10 <0=> Output <1=> nGCS5
;//
PIOB_SETUP EQU 1
PCONB_Val EQU 0x000007FF
;// Port C
;// PC0 <0=> Input <1=> Output <2=> DATA16 <3=> IISLRCK
;// PC1 <0=> Input <1=> Output <2=> DATA17 <3=> IISDO
;// PC2 <0=> Input <1=> Output <2=> DATA18 <3=> IISDI
;// PC3 <0=> Input <1=> Output <2=> DATA19 <3=> IISCLK
;// PC4 <0=> Input <1=> Output <2=> DATA20 <3=> VD7
;// PC5 <0=> Input <1=> Output <2=> DATA21 <3=> VD6
;// PC6 <0=> Input <1=> Output <2=> DATA22 <3=> VD5
;// PC7 <0=> Input <1=> Output <2=> DATA23 <3=> VD4
;// PC8 <0=> Input <1=> Output <2=> DATA24 <3=> nXDACK1
;// PC9 <0=> Input <1=> Output <2=> DATA25 <3=> nXDREQ1
;// PC10 <0=> Input <1=> Output <2=> DATA26 <3=> nRTS1
;// PC11 <0=> Input <1=> Output <2=> DATA27 <3=> nCTS1
;// PC12 <0=> Input <1=> Output <2=> DATA28 <3=> TxD1
;// PC13 <0=> Input <1=> Output <2=> DATA29 <3=> RxD1
;// PC14 <0=> Input <1=> Output <2=> DATA30 <3=> nRTS0
;// PC15 <0=> Input <1=> Output <2=> DATA31 <3=> nCTS0
;// Pull-up Resistors
;// PC0 Pull-up <0=> Enabled <1=> Disabled
;// PC1 Pull-up <0=> Enabled <1=> Disabled
;// PC2 Pull-up <0=> Enabled <1=> Disabled
;// PC3 Pull-up <0=> Enabled <1=> Disabled
;// PC4 Pull-up <0=> Enabled <1=> Disabled
;// PC5 Pull-up <0=> Enabled <1=> Disabled
;// PC6 Pull-up <0=> Enabled <1=> Disabled
;// PC7 Pull-up <0=> Enabled <1=> Disabled
;// PC8 Pull-up <0=> Enabled <1=> Disabled
;// PC9 Pull-up <0=> Enabled <1=> Disabled
;// PC10 Pull-up <0=> Enabled <1=> Disabled
;// PC11 Pull-up <0=> Enabled <1=> Disabled
;// PC12 Pull-up <0=> Enabled <1=> Disabled
;// PC13 Pull-up <0=> Enabled <1=> Disabled
;// PC14 Pull-up <0=> Enabled <1=> Disabled
;// PC15 Pull-up <0=> Enabled <1=> Disabled
;//
;//
PIOC_SETUP EQU 1
PCONC_Val EQU 0xAAAAAAAA
PUPC_Val EQU 0x00000000
;// Port D
;// PD0 <0=> Input <1=> Output <2=> VD0 <3=> Reserved
;// PD1 <0=> Input <1=> Output <2=> VD1 <3=> Reserved
;// PD2 <0=> Input <1=> Output <2=> VD2 <3=> Reserved
;// PD3 <0=> Input <1=> Output <2=> VD3 <3=> Reserved
;// PD4 <0=> Input <1=> Output <2=> VCLK <3=> Reserved
;// PD5 <0=> Input <1=> Output <2=> VLINE <3=> Reserved
;// PD6 <0=> Input <1=> Output <2=> VM <3=> Reserved
;// PD7 <0=> Input <1=> Output <2=> VFRAME <3=> Reserved
;// Pull-up Resistors
;// PD0 Pull-up <0=> Enabled <1=> Disabled
;// PD1 Pull-up <0=> Enabled <1=> Disabled
;// PD2 Pull-up <0=> Enabled <1=> Disabled
;// PD3 Pull-up <0=> Enabled <1=> Disabled
;// PD4 Pull-up <0=> Enabled <1=> Disabled
;// PD5 Pull-up <0=> Enabled <1=> Disabled
;// PD6 Pull-up <0=> Enabled <1=> Disabled
;// PD7 Pull-up <0=> Enabled <1=> Disabled
;//
;//
PIOD_SETUP EQU 1
PCOND_Val EQU 0x00000000
PUPD_Val EQU 0x00000000
;// Port E
;// PE0 <0=> Input <1=> Output <2=> Fpllo <3=> Fout
;// PE1 <0=> Input <1=> Output <2=> TxD0 <3=> Reserved
;// PE2 <0=> Input <1=> Output <2=> RxD0 <3=> Reserved
;// PE3 <0=> Input <1=> Output <2=> TOUT0 <3=> Reserved
;// PE4 <0=> Input <1=> Output <2=> TOUT1 <3=> TCLK
;// PE5 <0=> Input <1=> Output <2=> TOUT2 <3=> TCLK
;// PE6 <0=> Input <1=> Output <2=> TOUT3 <3=> VD6
;// PE7 <0=> Input <1=> Output <2=> TOUT4 <3=> VD7
;// PE8 <0=> Input <1=> Output <2=> CODECLK <3=> Reserved
;// Pull-up Resistors
;// PE0 Pull-up <0=> Enabled <1=> Disabled
;// PE1 Pull-up <0=> Enabled <1=> Disabled
;// PE2 Pull-up <0=> Enabled <1=> Disabled
;// PE3 Pull-up <0=> Enabled <1=> Disabled
;// PE4 Pull-up <0=> Enabled <1=> Disabled
;// PE5 Pull-up <0=> Enabled <1=> Disabled
;// PE6 Pull-up <0=> Enabled <1=> Disabled
;// PE7 Pull-up <0=> Enabled <1=> Disabled
;// PE8 Pull-up <0=> Enabled <1=> Disabled
;//
;//
PIOE_SETUP EQU 1
PCONE_Val EQU 0x00000000
PUPE_Val EQU 0x00000000
;// Port F
;// PF0 <0=> Input <1=> Output <2=> IICSCL <3=> Reserved
;// PF1 <0=> Input <1=> Output <2=> IICSDA <3=> Reserved
;// PF2 <0=> Input <1=> Output <2=> nWAIT <3=> Reserved
;// PF3 <0=> Input <1=> Output <2=> nXBACK <3=> nXDACK0
;// PF4 <0=> Input <1=> Output <2=> nXBREQ <3=> nXDREQ0
;// PF5 <0=> Input <1=> Output <2=> nRTS1 <3=> SIOTxD
;// <4=> IISLRCK <5=> Reserved <6=> Reserved <7=> Reserved
;// PF6 <0=> Input <1=> Output <2=> TxD1 <3=> SIORDY
;// <4=> IISDO <5=> Reserved <6=> Reserved <7=> Reserved
;// PF7 <0=> Input <1=> Output <2=> RxD1 <3=> SIORxD
;// <4=> IISDI <5=> Reserved <6=> Reserved <7=> Reserved
;// PF8 <0=> Input <1=> Output <2=> nCTS1 <3=> SIOCLK
;// <4=> IISCLK <5=> Reserved <6=> Reserved <7=> Reserved
;// Pull-up Resistors
;// PF0 Pull-up <0=> Enabled <1=> Disabled
;// PF1 Pull-up <0=> Enabled <1=> Disabled
;// PF2 Pull-up <0=> Enabled <1=> Disabled
;// PF3 Pull-up <0=> Enabled <1=> Disabled
;// PF4 Pull-up <0=> Enabled <1=> Disabled
;// PF5 Pull-up <0=> Enabled <1=> Disabled
;// PF6 Pull-up <0=> Enabled <1=> Disabled
;// PF7 Pull-up <0=> Enabled <1=> Disabled
;// PF8 Pull-up <0=> Enabled <1=> Disabled
;//
;//
PIOF_SETUP EQU 1
PCONF_Val EQU 0x00000000
PUPF_Val EQU 0x00000000
;// Port G
;// PG0 <0=> Input <1=> Output <2=> VD4 <3=> EINT0
;// PG1 <0=> Input <1=> Output <2=> VD5 <3=> EINT1
;// PG2 <0=> Input <1=> Output <2=> nCTS0 <3=> EINT2
;// PG3 <0=> Input <1=> Output <2=> nRTS0 <3=> EINT3
;// PG4 <0=> Input <1=> Output <2=> IISCLK <3=> EINT4
;// PG5 <0=> Input <1=> Output <2=> IISDI <3=> EINT5
;// PG6 <0=> Input <1=> Output <2=> IISDO <3=> EINT6
;// PG7 <0=> Input <1=> Output <2=> IISLRCK <3=> EINT7
;// Pull-up Resistors
;// PG0 Pull-up <0=> Enabled <1=> Disabled
;// PG1 Pull-up <0=> Enabled <1=> Disabled
;// PG2 Pull-up <0=> Enabled <1=> Disabled
;// PG3 Pull-up <0=> Enabled <1=> Disabled
;// PG4 Pull-up <0=> Enabled <1=> Disabled
;// PG5 Pull-up <0=> Enabled <1=> Disabled
;// PG6 Pull-up <0=> Enabled <1=> Disabled
;// PG7 Pull-up <0=> Enabled <1=> Disabled
;//
;//
PIOG_SETUP EQU 1
PCONG_Val EQU 0x00000000
PUPG_Val EQU 0x00000000
;// Special Pull-up
;// SPUCR0: DATA[7:0] Pull-up Resistor
;// <0=> Enabled <1=> Disabled
;// SPUCR1: DATA[15:8] Pull-up Resistor
;// <0=> Enabled <1=> Disabled
;// HZ@STOP
;// <0=> Prevoius state of PAD
;// <1=> HZ @ Stop
;//
PSPU_SETUP EQU 1
SPUCR_Val EQU 0x00000004
;//
PRESERVE8
; Area Definition and Entry Point
; Startup Code must be linked first at Address at which it expects to run.
AREA RESET, CODE, READONLY
ARM
; Exception Vectors
; Mapped to Address 0.
; Absolute addressing mode must be used.
; Dummy Handlers are implemented as infinite loops which can be modified.
Vectors LDR PC, Reset_Addr
LDR PC, Undef_Addr
LDR PC, SWI_Addr
LDR PC, PAbt_Addr
LDR PC, DAbt_Addr
NOP ; Reserved Vector
LDR PC, IRQ_Addr
LDR PC, FIQ_Addr
Reset_Addr DCD Reset_Handler
Undef_Addr DCD Undef_Handler
SWI_Addr DCD SWI_Handler
PAbt_Addr DCD PAbt_Handler
DAbt_Addr DCD DAbt_Handler
DCD 0 ; Reserved Address
IRQ_Addr DCD IRQ_Handler
FIQ_Addr DCD FIQ_Handler
Undef_Handler B Undef_Handler
SWI_Handler B SWI_Handler
PAbt_Handler B PAbt_Handler
DAbt_Handler B DAbt_Handler
FIQ_Handler B FIQ_Handler
; CPU Wrapper and Bus Priorities Configuration
IF SYS_SETUP <> 0
SYS_CFG
DCD CPUW_BASE
DCD BUSP_BASE
DCD SYSCFG_Val
DCD NCACHBE0_Val
DCD NCACHBE1_Val
DCD SBUSCON_Val
ENDIF
; Memory Controller Configuration
IF MC_SETUP <> 0
MC_CFG
DCD BWSCON_Val
DCD BANKCON0_Val
DCD BANKCON1_Val
DCD BANKCON2_Val
DCD BANKCON3_Val
DCD BANKCON4_Val
DCD BANKCON5_Val
DCD BANKCON6_Val
DCD BANKCON7_Val
DCD REFRESH_Val
DCD BANKSIZE_Val
DCD MRSRB6_Val
DCD MRSRB7_Val
ENDIF
; Clock Management Configuration
IF CLK_SETUP <> 0
CLK_CFG
DCD CLK_BASE
DCD PLLCON_Val
DCD CLKCON_Val
DCD CLKSLOW_Val
DCD LOCKTIME_Val
ENDIF
; I/O Configuration
IF PIO_SETUP <> 0
PIO_CFG
DCD PCONA_Val
DCD PCONB_Val
DCD PCONC_Val
DCD PCOND_Val
DCD PCONE_Val
DCD PCONF_Val
DCD PCONG_Val
DCD PUPC_Val
DCD PUPD_Val
DCD PUPE_Val
DCD PUPF_Val
DCD PUPG_Val
DCD SPUCR_Val
ENDIF
; Reset Handler
EXPORT Reset_Handler
Reset_Handler
IF SYS_SETUP <> 0
ADR R8, SYS_CFG
LDMIA R8, {R0-R5}
STMIA R0, {R2-R4}
STR R5, [R1]
ENDIF
IF MC_SETUP <> 0
ADR R14, MC_CFG
LDMIA R14, {R0-R12}
LDR R14, =MC_BASE
STMIA R14, {R0-R12}
ENDIF
IF CLK_SETUP <> 0
ADR R8, CLK_CFG
LDMIA R8, {R0-R4}
STR R4, [R0, #LOCKTIME_OFS]
STR R1, [R0, #PLLCON_OFS]
STR R3, [R0, #CLKSLOW_OFS]
STR R2, [R0, #CLKCON_OFS]
ENDIF
IF WT_SETUP <> 0
LDR R0, =WT_BASE
LDR R1, =WTCON_Val
LDR R2, =WTDAT_Val
STR R2, [R0, #WTCNT_OFS]
STR R2, [R0, #WTDAT_OFS]
STR R1, [R0, #WTCON_OFS]
ENDIF
IF PIO_SETUP <> 0
ADR R14, PIO_CFG
LDMIA R14, {R0-R12}
LDR R14, =PIO_BASE
IF PIOA_SETUP <> 0
STR R0, [R14, #PCONA_OFS]
ENDIF
IF PIOB_SETUP <> 0
STR R1, [R14, #PCONB_OFS]
ENDIF
IF PIOC_SETUP <> 0
STR R2, [R14, #PCONC_OFS]
STR R7, [R14, #PUPC_OFS]
ENDIF
IF PIOD_SETUP <> 0
STR R3, [R14, #PCOND_OFS]
STR R8, [R14, #PUPD_OFS]
ENDIF
IF PIOE_SETUP <> 0
STR R4, [R14, #PCONE_OFS]
STR R9, [R14, #PUPE_OFS]
ENDIF
IF PIOF_SETUP <> 0
STR R5, [R14, #PCONF_OFS]
STR R10,[R14, #PUPF_OFS]
ENDIF
IF PIOG_SETUP <> 0
STR R6, [R14, #PCONG_OFS]
STR R11,[R14, #PUPG_OFS]
ENDIF
IF PSPU_SETUP <> 0
STR R12,[R14, #SPUCR_OFS]
ENDIF
ENDIF
; Setup Stack for each mode
LDR R0, =Stack_Top
; Enter Undefined Instruction Mode and set its Stack Pointer
MSR CPSR_c, #Mode_UND:OR:I_Bit:OR:F_Bit
MOV SP, R0
SUB R0, R0, #UND_Stack_Size
; Enter Abort Mode and set its Stack Pointer
MSR CPSR_c, #Mode_ABT:OR:I_Bit:OR:F_Bit
MOV SP, R0
SUB R0, R0, #ABT_Stack_Size
; Enter FIQ Mode and set its Stack Pointer
MSR CPSR_c, #Mode_FIQ:OR:I_Bit:OR:F_Bit
MOV SP, R0
SUB R0, R0, #FIQ_Stack_Size
; Enter IRQ Mode and set its Stack Pointer
MSR CPSR_c, #Mode_IRQ:OR:I_Bit:OR:F_Bit
MOV SP, R0
SUB R0, R0, #IRQ_Stack_Size
; Enter Supervisor Mode and set its Stack Pointer
MSR CPSR_c, #Mode_SVC:OR:I_Bit:OR:F_Bit
MOV SP, R0
SUB R0, R0, #SVC_Stack_Size
; Enter User Mode and set its Stack Pointer
; MSR CPSR_c, #Mode_USR
IF :DEF:__MICROLIB
EXPORT __initial_sp
ELSE
; MOV SP, R0
; SUB SL, SP, #USR_Stack_Size
ENDIF
; Enter the C code
IMPORT __main
LDR R0, =__main
BX R0
IMPORT rt_interrupt_enter
IMPORT rt_interrupt_leave
IMPORT rt_thread_switch_interrupt_flag
IMPORT rt_interrupt_from_thread
IMPORT rt_interrupt_to_thread
IMPORT rt_hw_trap_irq
IRQ_Handler PROC
EXPORT IRQ_Handler
STMFD sp!, {r0-r12,lr}
BL rt_interrupt_enter
BL rt_hw_trap_irq
BL rt_interrupt_leave
; if rt_thread_switch_interrupt_flag set, jump to
; rt_hw_context_switch_interrupt_do and don't return
LDR r0, =rt_thread_switch_interrupt_flag
LDR r1, [r0]
CMP r1, #1
BEQ rt_hw_context_switch_interrupt_do
LDMFD sp!, {r0-r12,lr}
SUBS pc, lr, #4
ENDP
; /*
; * void rt_hw_context_switch_interrupt_do(rt_base_t flag)
; */
rt_hw_context_switch_interrupt_do PROC
EXPORT rt_hw_context_switch_interrupt_do
MOV r1, #0 ; clear flag
STR r1, [r0]
LDMFD sp!, {r0-r12,lr}; reload saved registers
STMFD sp!, {r0-r3} ; save r0-r3
MOV r1, sp
ADD sp, sp, #16 ; restore sp
SUB r2, lr, #4 ; save old task's pc to r2
MRS r3, spsr ; get cpsr of interrupt thread
; switch to SVC mode and no interrupt
MSR cpsr_c, #I_Bit|F_Bit|Mode_SVC
STMFD sp!, {r2} ; push old task's pc
STMFD sp!, {r4-r12,lr}; push old task's lr,r12-r4
MOV r4, r1 ; Special optimised code below
MOV r5, r3
LDMFD r4!, {r0-r3}
STMFD sp!, {r0-r3} ; push old task's r3-r0
STMFD sp!, {r5} ; push old task's cpsr
MRS r4, spsr
STMFD sp!, {r4} ; push old task's spsr
LDR r4, =rt_interrupt_from_thread
LDR r5, [r4]
STR sp, [r5] ; store sp in preempted tasks's TCB
LDR r6, =rt_interrupt_to_thread
LDR r6, [r6]
LDR sp, [r6] ; get new task's stack pointer
LDMFD sp!, {r4} ; pop new task's spsr
MSR spsr_cxsf, r4
LDMFD sp!, {r4} ; pop new task's psr
MSR cpsr_cxsf, r4
LDMFD sp!, {r0-r12,lr,pc} ; pop new task's r0-r12,lr & pc
ENDP
IF :DEF:__MICROLIB
EXPORT __heap_base
EXPORT __heap_limit
ELSE
; User Initial Stack & Heap
AREA |.text|, CODE, READONLY
IMPORT __use_two_region_memory
EXPORT __user_initial_stackheap
__user_initial_stackheap
LDR R0, = Heap_Mem
LDR R1, =(Stack_Mem + USR_Stack_Size)
LDR R2, = (Heap_Mem + Heap_Size)
LDR R3, = Stack_Mem
BX LR
ENDIF
END