;/*****************************************************************************/
;/* S3C2440A.S: Startup file for Samsung S3C440A */
;/*****************************************************************************/
;/* <<< 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. */
;/*****************************************************************************/
;Author: Wuhan R&D Center, embest
;History:
; *** 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 0x00000400
SVC_Stack_Size EQU 0x00001000
ABT_Stack_Size EQU 0x00000400
FIQ_Stack_Size EQU 0x00001000
IRQ_Stack_Size EQU 0x00001000
USR_Stack_Size EQU 0x00003800
Stack_Size EQU (UND_Stack_Size + SVC_Stack_Size + ABT_Stack_Size + \
FIQ_Stack_Size + IRQ_Stack_Size + USR_Stack_Size)
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE Stack_Size
Stack_Top EQU Stack_Mem + Stack_Size
;// Heap Configuration
;// Heap Size (in Bytes) <0x0-0xFFFFFFFF>
;//
Heap_Size EQU 0x00004800
AREA HEAP, NOINIT, READWRITE, ALIGN=3
Heap_Mem SPACE Heap_Size
;INT CONFIG
INT_BASE EQU 0x4A000000
SRCPND_OFS EQU 0x0
INTMSK_OFS EQU 0x8
INTPND_OFS EQU 0x10
INTSUBMASK_OFS EQU 0x1c
INT_SETUP EQU 1
INTMSK_VAL EQU 0xFFFFFFFF
INTSUBMASK_VAL EQU 0X7FF
; Clock Management definitions
CLK_BASE EQU 0x4C000000 ; Clock Base Address
LOCKTIME_OFS EQU 0x00 ; LOCKTIME Offset
MPLLCON_OFS EQU 0x04 ; MPLLCON Offset
UPLLCON_OFS EQU 0X08 ; UPLLCON Offset
CLKCON_OFS EQU 0x0C ; CLKCON Offset
CLKSLOW_OFS EQU 0x10 ; CLKSLOW Offset
CLKDIVN_OFS EQU 0X14 ; CLDKIVN Offset
CAMDIVN_OFS EQU 0X18 ; CAMDIVN Offset
;// Clock Management
;// MPLL Settings
;// Mpll = (m * Fin) / (p * 2^s)
;// MDIV: Main divider <0x0-0xFF>
;// m = MDIV + 8
;// PDIV: Pre-divider <0x0-0x3F>
;// p = PDIV + 2
;// SDIV: Post Divider <0x0-0x03>
;// s = SDIV
;//
;// UPLL Settings
;// Upll = ( m * Fin) / (p * 2^s),Uclk must be 48MHZ to USB device
;// MDIV: Main divider <0x1-0xF8>
;// m = MDIV + 8,if Fin=12MHZ MDIV could be 0x38
;// PDIV: Pre-divider <0x1-0x3E>
;// p = PDIV + 2,if Fin=12MHZ PDIV could be 0x2
;// SDIV: Post Divider <0x0-0x03>
;// s = SDIV ,if Fin=12MHZ SDIV could be 0x2
;//
;// LOCK TIME
;// LTIME CNT: MPLL Lock Time Count <0x0-0xFFF>
;// LTIME CNT: UPLL Lock Time Count <0x0-0xFFF>
;//
;// Master Clock
;// PLL Clock: FCLK = FMPLL
;// Slow Clock: FCLK = Fin / (2 * SLOW_VAL), SLOW_VAL > 0
;// Slow Clock: FCLK = Fin, SLOW_VAL = 0
;// UCLK_ON: UCLK ON
;// 0: UCLK ON(UPLL is also turned on) 1: UCLK OFF (UPLL is also turned off)
;// MPLL_OFF: Turn off PLL
;// 0: Turn on PLL.After PLL stabilization time (minimum 300us), SLOW_BIT can be cleared to 0. 1: Turn off PLL. PLL is turned off only when SLOW_BIT is 1.
;// SLOW_BIT: Slow Clock
;// SLOW_VAL: Slow Clock divider <0x0-0x7>
;//
;// CLOCK DIVIDER CONTROL
;// HDIVN
;// 0: HCLK = FCLK/1, 01 : HCLK = FCLK/2
;// PDIVN
;// 0: PCLK has the clock same as the HCLK/1,1: PCLK has the clock same as the HCLK/2
;//
;// Clock Generation
;// SPI <0=> Disable <1=> Enable
;// 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
;// UART2 <0=> Disable <1=> Enable
;// UART1 <0=> Disable <1=> Enable
;// UART0 <0=> Disable <1=> Enable
;// SDI <0=> Disable <1=> Enable
;// PWMTIMER <0=> Disable <1=> Enable
;// USB device <0=> Disable <1=> Enable
;// USB host <0=> Disable <1=> Enable
;// LCDC <0=> Disable <1=> Enable
;// NAND FLASH Controller <0=> Disable <1=> Enable
;// POWER-OFF <0=> Disable <1=> Enable
;// IDLE BIT <0=> Disable <1=> Enable
;// SM_BIT <0=> Disable <1=> Enable
;//
;//
CLK_SETUP EQU 1
MPLLCON_Val EQU 0x0005C042
UPLLCON_Val EQU 0x00028080
CLKCON_Val EQU 0x0007FFF0
CLKSLOW_Val EQU 0x00000004
LOCKTIME_Val EQU 0x00FFFFFF
CLKDIVN_Val EQU 0X00000003
;Interrupt definitions
INTOFFSET EQU 0X4A000014 ;Address of Interrupt offset Register
;// Interrupt Vector Table
;// Interrupt Vector address <0x20-0x3fffff78>
;// You could define Interuupt Vctor Table address.
;// The Interrupt Vector Table address must be word aligned adress.
;//
IntVT_SETUP EQU 1
IntVTAddress EQU 0x33FFFF20
; Watchdog Timer definitions
WT_BASE EQU 0x53000000 ; 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 0x0
WTDAT_Val EQU 0x8000
; Memory Controller definitions
MC_BASE EQU 0x48000000 ; 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 <1=> 64M <2=> 128M <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
;// <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
;//
;// 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
;// SCKEEN: SCLK Selection (Bank 6/7)
;// <0=> Normal
;// <1=> Reduced Power
;// SCLKEN: SDRAM power down mode (Bank 6/7)
;// <0=> DISABLE
;// <1=> ENABLE
;// BURST_EN: ARM core burst operation (Bank 6/7)
;// <0=> DISABLE
;// <1=> ENABLE
;// 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 <1=> 64M <2=> 128M <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
;// <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
;//
;// 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
;// SCLKEN: SDRAM power down mode (Bank 6/7)
;// <0=> DISABLE
;// <1=> ENABLE
;// BURST_EN: ARM core burst operation (Bank 6/7)
;// <0=> DISABLE
;// <1=> ENABLE
;// 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: SDRAM Refresh
;// <0=> Disable <1=> Enable
;// TREFMD: SDRAM Refresh Mode
;// <0=> CBR/Auto Refresh
;// <1=> Self Refresh
;// Trp: SDRAM RAS Pre-charge Time
;// <0=> 2 clks
;// <1=> 3 clks
;// <2=> 4 clks
;// <3=> Rsrvd
;// Tsrc: SDRAM Semi Row cycle time
;// SDRAM Row cycle time: Trc=Tsrc+Trp
;// <0=> 4 clks <1=> 5 clks <2=> 6 clks <3=> 7 clks
;// Refresh Counter <0x0-0x07FF>
;// Refresh Period = (2^11 - Refresh Count + 1) / HCLK
;//
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 0x00018005
BANKCON7_Val EQU 0x00018005
BWSCON_Val EQU 0X22119120;0x22111110
REFRESH_Val EQU 0x008e0459
BANKSIZE_Val EQU 0x00000032;0x000000b2
MRSRB6_Val EQU 0x00000030
MRSRB7_Val EQU 0x00000030
;// End of MC
; I/O Ports definitions
PIO_BASE EQU 0x56000000 ; PIO Base Address
PCONA_OFS EQU 0x00 ; PCONA Offset
PCONB_OFS EQU 0x10 ; PCONB Offset
PCONC_OFS EQU 0x20 ; PCONC Offset
PCOND_OFS EQU 0x30 ; PCOND Offset
PCONE_OFS EQU 0x40 ; PCONE Offset
PCONF_OFS EQU 0x50 ; PCONF Offset
PCONG_OFS EQU 0x60 ; PCONG Offset
PCONH_OFS EQU 0x70 ; PCONH Offset
PCONJ_OFS EQU 0xD0 ; PCONJ Offset
PUPB_OFS EQU 0x18 ; PUPB Offset
PUPC_OFS EQU 0x28 ; PUPC Offset
PUPD_OFS EQU 0x38 ; PUPD Offset
PUPE_OFS EQU 0x48 ; PUPE Offset
PUPF_OFS EQU 0x58 ; PUPF Offset
PUPG_OFS EQU 0x68 ; PUPG Offset
PUPH_OFS EQU 0x78 ; PUPH Offset
PUPJ_OFS EQU 0xD8 ; PUPJ Offset
;// I/O Configuration
PIO_SETUP EQU 1
;// 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
;// PA0 <0=> Output <1=> ADDR25
;// PA1 <0=> Output <1=> ADDR26
;// PA2 <0=> Output <1=> nGCS[1]
;// PA3 <0=> Output <1=> nGCS[2]
;// PA4 <0=> Output <1=> nGCS[3]
;// PA5 <0=> Output <1=> nGCS[4]
;// PA6 <0=> Output <1=> nGCS[5]
;// PA7 <0=> Output <1=> CLE
;// PA8 <0=> Output <1=> ALE
;// PA9 <0=> Output <1=> nFWE
;// PA0 <0=> Output <1=> nFRE
;// PA1 <0=> Output <1=> nRSTOUT
;// PA2 <0=> Output <1=> nFCE
;//
PIOA_SETUP EQU 0
PCONA_Val EQU 0x000003FF
;// Port B
;// PB0 <0=> Input <1=> Output <2=> TOUT0 <3=> Reserved
;// PB1 <0=> Input <1=> Output <2=> TOUT1 <3=> Reserved
;// PB2 <0=> Input <1=> Output <2=> TOUT2 <3=> Reserved
;// PB3 <0=> Input <1=> Output <2=> TOUT3 <3=> Reserved
;// PB4 <0=> Input <1=> Output <2=> TCLK[0] <3=> Reserved
;// PB5 <0=> Input <1=> Output <2=> nXBACK <3=> Reserved
;// PB6 <0=> Input <1=> Output <2=> nXBREQ <3=> Reserved
;// PB7 <0=> Input <1=> Output <2=> nXDACK1 <3=> Reserved
;// PB8 <0=> Input <1=> Output <2=> nXDREQ1 <3=> Reserved
;// PB9 <0=> Input <1=> Output <2=> nXDACK0 <3=> Reserved
;// PB10 <0=> Input <1=> Output <2=> nXDREQ0 <3=> Reserved
;// Pull-up Resistors
;// PB0 Pull-up <0=> Enabled <1=> Disabled
;// PB1 Pull-up <0=> Enabled <1=> Disabled
;// PB2 Pull-up <0=> Enabled <1=> Disabled
;// PB3 Pull-up <0=> Enabled <1=> Disabled
;// PB4 Pull-up <0=> Enabled <1=> Disabled
;// PB5 Pull-up <0=> Enabled <1=> Disabled
;// PB6 Pull-up <0=> Enabled <1=> Disabled
;// PB7 Pull-up <0=> Enabled <1=> Disabled
;// PB8 Pull-up <0=> Enabled <1=> Disabled
;// PB9 Pull-up <0=> Enabled <1=> Disabled
;// PB10 Pull-up <0=> Enabled <1=> Disabled
;//
;//
PIOB_SETUP EQU 1
PCONB_Val EQU 0x00000FFF
PUPB_Val EQU 0x00000000
;// Port C
;// PC0 <0=> Input <1=> Output <2=> LEND <3=> Reserved
;// PC1 <0=> Input <1=> Output <2=> VCLK <3=> Reserved
;// PC2 <0=> Input <1=> Output <2=> VLINE <3=> Reserved
;// PC3 <0=> Input <1=> Output <2=> VFRAME <3=> Reserved
;// PC4 <0=> Input <1=> Output <2=> VM <3=> Reserved
;// PC5 <0=> Input <1=> Output <2=> LCDVF2 <3=> Reserved
;// PC6 <0=> Input <1=> Output <2=> LCDVF1 <3=> Reserved
;// PC7 <0=> Input <1=> Output <2=> LCDVF0 <3=> Reserved
;// PC8 <0=> Input <1=> Output <2=> VD[0] <3=> Reserved
;// PC9 <0=> Input <1=> Output <2=> VD[1] <3=> Reserved
;// PC10 <0=> Input <1=> Output <2=> VD[2] <3=> Reserved
;// PC11 <0=> Input <1=> Output <2=> VD[3] <3=> Reserved
;// PC12 <0=> Input <1=> Output <2=> VD[4] <3=> Reserved
;// PC13 <0=> Input <1=> Output <2=> VD[5] <3=> Reserved
;// PC14 <0=> Input <1=> Output <2=> VD[6] <3=> Reserved
;// PC15 <0=> Input <1=> Output <2=> VD[7] <3=> Reserved
;// 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 0
PCONC_Val EQU 0xAAAAAAAA
PUPC_Val EQU 0x00000000
;// Port D
;// PD0 <0=> Input <1=> Output <2=> VD[8] <3=> Reserved
;// PD1 <0=> Input <1=> Output <2=> VD[9] <3=> Reserved
;// PD2 <0=> Input <1=> Output <2=> VD[10] <3=> Reserved
;// PD3 <0=> Input <1=> Output <2=> VD[11] <3=> Reserved
;// PD4 <0=> Input <1=> Output <2=> VD[12] <3=> Reserved
;// PD5 <0=> Input <1=> Output <2=> VD[13] <3=> Reserved
;// PD6 <0=> Input <1=> Output <2=> VD[14] <3=> Reserved
;// PD7 <0=> Input <1=> Output <2=> VD[15] <3=> Reserved
;// PD8 <0=> Input <1=> Output <2=> VD[16] <3=> Reserved
;// PD9 <0=> Input <1=> Output <2=> VD[17] <3=> Reserved
;// PD10 <0=> Input <1=> Output <2=> VD[18] <3=> Reserved
;// PD11 <0=> Input <1=> Output <2=> VD[19] <3=> Reserved
;// PD12 <0=> Input <1=> Output <2=> VD[20] <3=> Reserved
;// PD13 <0=> Input <1=> Output <2=> VD[21] <3=> Reserved
;// PD14 <0=> Input <1=> Output <2=> VD[22] <3=> nSS1
;// PD15 <0=> Input <1=> Output <2=> VD[23] <3=> nSS0
;// 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
;// PD8 Pull-up <0=> Enabled <1=> Disabled
;// PD9 Pull-up <0=> Enabled <1=> Disabled
;// PD10 Pull-up <0=> Enabled <1=> Disabled
;// PD11 Pull-up <0=> Enabled <1=> Disabled
;// PD12 Pull-up <0=> Enabled <1=> Disabled
;// PD13 Pull-up <0=> Enabled <1=> Disabled
;// PD14 Pull-up <0=> Enabled <1=> Disabled
;// PD15 Pull-up <0=> Enabled <1=> Disabled
;//
;//
PIOD_SETUP EQU 0
PCOND_Val EQU 0x00000000
PUPD_Val EQU 0x00000000
;// Port E
;// PE0 <0=> Input <1=> Output <2=> I2SLRCK <3=> Reserved
;// PE1 <0=> Input <1=> Output <2=> I2SSCLK <3=> Reserved
;// PE2 <0=> Input <1=> Output <2=> CDCLK <3=> Reserved
;// PE3 <0=> Input <1=> Output <2=> I2SDI <3=> nSS0
;// PE4 <0=> Input <1=> Output <2=> I2SDO <3=> I2SSDI
;// PE5 <0=> Input <1=> Output <2=> SDCLK <3=> Reserved
;// PE6 <0=> Input <1=> Output <2=> SDCMD <3=> Reserved
;// PE7 <0=> Input <1=> Output <2=> SDDAT0 <3=> Reserved
;// PE8 <0=> Input <1=> Output <2=> SDDAT1 <3=> Reserved
;// PE9 <0=> Input <1=> Output <2=> SDDAT2 <3=> Reserved
;// PE10 <0=> Input <1=> Output <2=> SDDAT3 <3=> Reserved
;// PE11 <0=> Input <1=> Output <2=> SPIMISO0 <3=> Reserved
;// PE12 <0=> Input <1=> Output <2=> SPIMOSI0 <3=> Reserved
;// PE13 <0=> Input <1=> Output <2=> SPICLK0 <3=> Reserved
;// PE14 <0=> Input <1=> Output <2=> IICSCL <3=> Reserved
;// PE15 <0=> Input <1=> Output <2=> IICSDA <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
;// PE9 Pull-up <0=> Enabled <1=> Disabled
;// PE10 Pull-up <0=> Enabled <1=> Disabled
;// PE11 Pull-up <0=> Enabled <1=> Disabled
;// PE12 Pull-up <0=> Enabled <1=> Disabled
;// PE13 Pull-up <0=> Enabled <1=> Disabled
;// PE14 Pull-up <0=> Enabled <1=> Disabled
;// PE15 Pull-up <0=> Enabled <1=> Disabled
;//
;//
PIOE_SETUP EQU 0
PCONE_Val EQU 0x00000000
PUPE_Val EQU 0x00000000
;// Port F
;// PF0 <0=> Input <1=> Output <2=> EINT[0] <3=> Reserved
;// PF1 <0=> Input <1=> Output <2=> EINT[1] <3=> Reserved
;// PF2 <0=> Input <1=> Output <2=> EINT[2] <3=> Reserved
;// PF3 <0=> Input <1=> Output <2=> EINT[3] <3=> Reserved
;// PF4 <0=> Input <1=> Output <2=> EINT[4] <3=> Reserved
;// PF5 <0=> Input <1=> Output <2=> EINT[5] <3=> Reserved
;// PF6 <0=> Input <1=> Output <2=> EINT[6] <3=> Reserved
;// PF7 <0=> Input <1=> Output <2=> EINT[7] <3=> 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
;//
;//
PIOF_SETUP EQU 1
PCONF_Val EQU 0x000055aa
PUPF_Val EQU 0x000000ff
;// Port G
;// PG0 <0=> Input <1=> Output <2=> EINT[8] <3=> Reserved
;// PG1 <0=> Input <1=> Output <2=> EINT[9] <3=> Reserved
;// PG2 <0=> Input <1=> Output <2=> EINT[10] <3=> nSS0
;// PG3 <0=> Input <1=> Output <2=> EINT[11] <3=> nSS1
;// PG4 <0=> Input <1=> Output <2=> EINT[12] <3=> LCD_PWRDN
;// PG5 <0=> Input <1=> Output <2=> EINT[13] <3=> SPIMISO1
;// PG6 <0=> Input <1=> Output <2=> EINT[14] <3=> SPIMOSI1
;// PG7 <0=> Input <1=> Output <2=> EINT[15] <3=> SPICLK1
;// PG8 <0=> Input <1=> Output <2=> EINT[16] <3=> Reserved
;// PG9 <0=> Input <1=> Output <2=> EINT[17] <3=> Reserved
;// PG10 <0=> Input <1=> Output <2=> EINT[18] <3=> Reserved
;// PG11 <0=> Input <1=> Output <2=> EINT[19] <3=> TCLK1
;// PG12 <0=> Input <1=> Output <2=> EINT[20] <3=> XMON
;// PG13 <0=> Input <1=> Output <2=> EINT[21] <3=> nXPON
;// PG14 <0=> Input <1=> Output <2=> EINT[22] <3=> YMON
;// PG15 <0=> Input <1=> Output <2=> EINT[23] <3=> nYPON
;// 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
;// PG8 Pull-up <0=> Enabled <1=> Disabled
;// PG9 Pull-up <0=> Enabled <1=> Disabled
;// PG10 Pull-up <0=> Enabled <1=> Disabled
;// PG11 Pull-up <0=> Enabled <1=> Disabled
;// PG12 Pull-up <0=> Enabled <1=> Disabled
;// PG13 Pull-up <0=> Enabled <1=> Disabled
;// PG14 Pull-up <0=> Enabled <1=> Disabled
;// PG15 Pull-up <0=> Enabled <1=> Disabled
;//
;//
PIOG_SETUP EQU 0
PCONG_Val EQU 0x00000000
PUPG_Val EQU 0x00000000
;// Port H
;// PH0 <0=> Input <1=> Output <2=> nCTS0 <3=> Reserved
;// PH1 <0=> Input <1=> Output <2=> nRTS0 <3=> Reserved
;// PH2 <0=> Input <1=> Output <2=> TXD[0] <3=> Reserved
;// PH3 <0=> Input <1=> Output <2=> RXD[0] <3=> Reserved
;// PH4 <0=> Input <1=> Output <2=> TXD[1] <3=> Reserved
;// PH5 <0=> Input <1=> Output <2=> RXD[1] <3=> Reserved
;// PH6 <0=> Input <1=> Output <2=> TXD[2] <3=> nRTS1
;// PH7 <0=> Input <1=> Output <2=> RXD[2] <3=> nCTS1
;// PH8 <0=> Input <1=> Output <2=> UCLK <3=> Reserved
;// PH9 <0=> Input <1=> Output <2=> CLKOUT0 <3=> Reserved
;// PH10 <0=> Input <1=> Output <2=> CLKOUT1 <3=> Reserved
;// Pull-up Resistors
;// PH0 Pull-up <0=> Enabled <1=> Disabled
;// PH1 Pull-up <0=> Enabled <1=> Disabled
;// PH2 Pull-up <0=> Enabled <1=> Disabled
;// PH3 Pull-up <0=> Enabled <1=> Disabled
;// PH4 Pull-up <0=> Enabled <1=> Disabled
;// PH5 Pull-up <0=> Enabled <1=> Disabled
;// PH6 Pull-up <0=> Enabled <1=> Disabled
;// PH7 Pull-up <0=> Enabled <1=> Disabled
;// PH8 Pull-up <0=> Enabled <1=> Disabled
;// PH9 Pull-up <0=> Enabled <1=> Disabled
;// PH10 Pull-up <0=> Enabled <1=> Disabled
;//
;//
PIOH_SETUP EQU 0
PCONH_Val EQU 0x000007FF
PUPH_Val EQU 0x00000000
;//
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
IF IntVT_SETUP <> 0
;Interrupt Vector Table Address
HandleEINT0 EQU IntVTAddress
HandleEINT1 EQU IntVTAddress +4
HandleEINT2 EQU IntVTAddress +4*2
HandleEINT3 EQU IntVTAddress +4*3
HandleEINT4_7 EQU IntVTAddress +4*4
HandleEINT8_23 EQU IntVTAddress +4*5
HandleReserved EQU IntVTAddress +4*6
HandleBATFLT EQU IntVTAddress +4*7
HandleTICK EQU IntVTAddress +4*8
HandleWDT EQU IntVTAddress +4*9
HandleTIMER0 EQU IntVTAddress +4*10
HandleTIMER1 EQU IntVTAddress +4*11
HandleTIMER2 EQU IntVTAddress +4*12
HandleTIMER3 EQU IntVTAddress +4*13
HandleTIMER4 EQU IntVTAddress +4*14
HandleUART2 EQU IntVTAddress +4*15
HandleLCD EQU IntVTAddress +4*16
HandleDMA0 EQU IntVTAddress +4*17
HandleDMA1 EQU IntVTAddress +4*18
HandleDMA2 EQU IntVTAddress +4*19
HandleDMA3 EQU IntVTAddress +4*20
HandleMMC EQU IntVTAddress +4*21
HandleSPI0 EQU IntVTAddress +4*22
HandleUART1 EQU IntVTAddress +4*23
;HandleReserved EQU IntVTAddress +4*24
HandleUSBD EQU IntVTAddress +4*25
HandleUSBH EQU IntVTAddress +4*26
HandleIIC EQU IntVTAddress +4*27
HandleUART0 EQU IntVTAddress +4*28
HandleSPI1 EQU IntVTAddress +4*39
HandleRTC EQU IntVTAddress +4*30
HandleADC EQU IntVTAddress +4*31
IRQ_Entry
sub sp,sp,#4 ;reserved for PC
stmfd sp!,{r8-r9}
ldr r9,=INTOFFSET
ldr r9,[r9]
ldr r8,=HandleEINT0
add r8,r8,r9,lsl #2
ldr r8,[r8]
str r8,[sp,#8]
ldmfd sp!,{r8-r9,pc}
ENDIF
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
IF IntVT_SETUP <> 1
IRQ_Handler B IRQ_Handler
ENDIF
IF IntVT_SETUP <> 0
IRQ_Handler B IRQ_Entry
ENDIF
FIQ_Handler B FIQ_Handler
; 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 LOCKTIME_Val
DCD CLKDIVN_Val
DCD MPLLCON_Val
DCD UPLLCON_Val
DCD CLKSLOW_Val
DCD CLKCON_Val
ENDIF
; I/O Configuration
IF PIO_SETUP <> 0
PIOA_CFG
DCD PCONA_Val
PIOB_CFG DCD PCONB_Val
DCD PUPB_Val
PIOC_CFG DCD PCONC_Val
DCD PUPC_Val
PIOD_CFG DCD PCOND_Val
DCD PUPD_Val
PIOE_CFG DCD PCONE_Val
DCD PUPE_Val
PIOF_CFG DCD PCONF_Val
DCD PUPF_Val
PIOG_CFG DCD PCONG_Val
DCD PUPG_Val
PIOH_CFG DCD PCONH_Val
DCD PUPH_Val
ENDIF
; Reset Handler
EXPORT Reset_Handler
Reset_Handler
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 INT_SETUP <> 0
LDR R0, =INT_BASE
LDR R1, =INTMSK_VAL
LDR R2, =INTSUBMASK_VAL
STR R1, [R0,#INTMSK_OFS]
STR R2, [R0,#INTSUBMASK_OFS]
ENDIF
IF CLK_SETUP <> 0
LDR R0, =CLK_BASE
ADR R8, CLK_CFG
LDMIA R8, {R1-R6}
STR R1, [R0, #LOCKTIME_OFS]
STR R2, [R0, #CLKDIVN_OFS]
STR R3, [R0, #MPLLCON_OFS]
STR R4, [R0, #UPLLCON_OFS]
STR R5, [R0, #CLKSLOW_OFS]
STR R6, [R0, #CLKCON_OFS]
ENDIF
IF MC_SETUP <> 0
ADR R13, MC_CFG
LDMIA R13, {R0-R12}
LDR R13, =MC_BASE
STMIA R13, {R0-R12}
ENDIF
IF PIO_SETUP <> 0
LDR R13, =PIO_BASE
IF PIOA_SETUP <> 0
ADR R0, PIOA_CFG
STR R0, [R13, #PCONA_OFS]
ENDIF
IF PIOB_SETUP <> 0
ADR R0, PIOB_CFG
LDR R1, [R0,#4]
STR R0, [R13, #PCONB_OFS]
STR R1, [R13, #PUPB_OFS]
ENDIF
IF PIOC_SETUP <> 0
ADR R0, PIOC_CFG
LDR R1, [R0,#4]
STR R0, [R13, #PCONC_OFS]
STR R1, [R13, #PUPC_OFS]
ENDIF
IF PIOD_SETUP <> 0
ADR R0, PIOD_CFG
LDR R1, [R0,#4]
STR R0, [R13, #PCOND_OFS]
STR R1, [R13, #PUPD_OFS]
ENDIF
IF PIOE_SETUP <> 0
ADR R0, PIOE_CFG
LDR R1, [R0,#4]
STR R0, [R13, #PCONE_OFS]
STR R1, [R13, #PUPE_OFS]
ENDIF
IF PIOF_SETUP <> 0
ADR R0, PIOF_CFG
LDR R1, [R0,#4]
STR R0, [R13, #PCONF_OFS]
STR R1, [R13, #PUPF_OFS]
ENDIF
IF PIOG_SETUP <> 0
ADR R0, PIOG_CFG
LDR R1, [R0,#4]
STR R0, [R13, #PCONG_OFS]
STR R1, [R13, #PUPG_OFS]
ENDIF
IF PIOH_SETUP <> 0
ADR R0, PIOH_CFG
LDR R1, [R0,#4]
STR R0, [R13, #PCONH_OFS]
STR R1, [R13, #PUPH_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
MOV SP, R0
SUB SL, SP, #USR_Stack_Size
; Enter the C code
IMPORT __main
LDR R0, =__main
BX R0
; 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
END