annotate gsm-fw/sysglue/flashboot.S @ 631:7cf154cd3891

gsm-fw/sysglue: prep for building flashable images
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Mon, 01 Sep 2014 17:04:19 +0000
parents
children 1f54d2ba42c2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
631
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * This assembly module contains those bits which are specific to flashable
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 * image builds only. It puts bits of code into several different sections.
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 */
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include "../include/config.h"
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 .section flashboot.text,"ax",%progbits
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 .code 32
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 .org 0
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #if FLASH_BOOT_VIA_BOOTROM
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 /* sane targets with Calypso boot ROM enabled by the PCB wiring */
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 /* provide the necessary magic words for the boot ROM */
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 .word 0
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 .word _Flash_boot_entry
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 #elif CONFIG_TARGET_C139
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 /*
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 * On this target we are going to put a special flash boot stage at 0x2000,
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 * and then the actual gsm-fw image at the flash erase block boundary
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 * at 0x10000. The following bits will be read by our intermediate
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 * flash boot stage.
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 */
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 .asciz "FreeCalypso"
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 .word _Flash_boot_entry
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 #elif CONFIG_TARGET_C155
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 /*
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 * On this target the hand-off point between the bootloader and the main
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 * fw image coincides with a flash erase block boundary, thus no need
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 * for an intermediate flash boot stage. The following bits will appear
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 * at 0x20000.
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 */
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 .asciz "FreeCalypso firmware for C155/156 target"
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 .org 0xE0
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 /* C155/156 bootloader jumps here */
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 b _Flash_boot_entry
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 #include "vectors.S"
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 #else
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 #error "Unsupported flash boot configuration"
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 #endif
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41 .globl _Flash_boot_entry
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 _Flash_boot_entry:
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 /* first order of business: configure flash and XRAM access */
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 ldr r2, =0xFFFFFB00
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 #if CONFIG_TARGET_PIRELLI
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 mov r0, #0x00A4
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 strh r0, [r2, #0]
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 strh r0, [r2, #2]
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 strh r0, [r2, #6]
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 #else
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 mov r0, #0x00A3
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52 strh r0, [r2, #0]
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 strh r0, [r2, #2]
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 #endif
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 /*
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 * Switch the CS4/ADD22 pin to the ADD22 function. We only need this
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57 * setting on targets with 8 MiB flash (or XRAM) banks, but it doesn't
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58 * hurt to do it on all targets (like TI's original code does),
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 * until and unless we encounter a target that uses the CS4 function.
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 */
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 ldr r1, =0xFFFEF006
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62 mov r2, #0x0008
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63 strh r2, [r1]
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
64 /* we now have full access to all flash and RAM on the device */
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65 /* copy iram.text to where it's supposed to be */
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
66 ldr r8, =__iramtext_flash_addr
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
67 ldr r9, =__iramtext_ram_addr
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
68 ldr r10, =__iramtext_size
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
69 1: ldmia r8!, {r0-r7}
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
70 stmia r9!, {r0-r7}
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
71 subs r10, r10, #0x20
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
72 bhi 1b
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
73 /* likewise copy .data from flash to XRAM */
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
74 ldr r8, =__initdata_flash_addr
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
75 ldr r9, =__initdata_ram_addr
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
76 ldr r10, =__initdata_size
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
77 1: ldmia r8!, {r0-r7}
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
78 stmia r9!, {r0-r7}
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
79 subs r10, r10, #0x20
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
80 bhi 1b
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
81 /* boot path joins with fc-xram loadable builds */
7cf154cd3891 gsm-fw/sysglue: prep for building flashable images
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
82 b _FlashorXram_entry