CMSIS2000  0.0.7
 Указатель Структуры данных Файлы Функции Переменные Определения типов Перечисления Элементы перечислений Макросы Группы Страницы
iboot_main.c
См. документацию.
1 /*
2  * CMSIS2000
3  * CMSIS-like sources for LPC2xxx series MCUs
4  *
5  * (C) Copyright 2011-2012, Dmitriy Cherepanov, All Rights Reserved
6  *
7  * Version: 0.0.7
8  * Date of the Last Update: 2013-03-04
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining a copy
11  * of this software and associated documentation files (the "Software"), to
12  * deal in the Software without restriction, including without limitation the
13  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
14  * sell copies of the Software, and to permit persons to whom the Software is
15  * furnished to do so, subject to the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be included in
18  * all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
26  * IN THE SOFTWARE.
27  *
28  * Do not be lasy! For the latest version see http://irtos.sourceforge.net .
29  *
30  *
31 #*/
32 /*----------------------------------------------------------------------------*/
33 /**
34 \file uboot file load applic
35 \author Cherepanov Dmitiy
36 */
37 /*----------------------------------------------------------------------------*/
38 extern const unsigned char _etext ;// the end of const data in image - start of image
39 extern const unsigned char __data_end ;
40 extern const unsigned char __data_start ;
41 extern const unsigned char __isr_vector ;// the start of image
42 
43 #include "../uboot/uboot_file.h"
44 #define END_OF_SEARCH_REGION (32 * 1024)
45 /*----------------------------------------------------------------------------*/
46 extern unsigned int load_file_from_external_source_to(flash_addr_t free_space_start);
47 /*----------------------------------------------------------------------------*/
48 static void uboot_file_run(flash_addr_t start_addr);//NON_RETURN
49 /*----------------------------------------------------------------------------*/
50 int main ()
51 {
52 flash_addr_t uboot_file_addr;
53 const flash_addr_t end_of_iboot_applic = (flash_addr_t ) ( &__isr_vector + (unsigned int)&_etext + (&__data_end - &__data_start));
54 
55 uboot_file_addr = end_of_iboot_applic;
56 do {
57  uboot_file_addr = find_uboot_file(uboot_file_addr, END_OF_SEARCH_REGION);
58  if (uboot_file_addr != ((flash_addr_t)(-1))) {
59  flash_addr_t uboot_applic_addr;
60  uboot_applic_addr = uboot_file_get_load_addr(uboot_file_addr);
61  if (mcu_addr_is_in_SDRAM(uboot_applic_addr )) {
62  EMC_Init();
63  if (SDRAM_Test() != 0) {
64  while(1==1); // oops SDRAM NOT WORKING
65  }
66  }
67  uboot_applic_addr = uboot_file_load (uboot_file_addr);
68  if (uboot_applic_addr != -1) {
69  uboot_file_run(uboot_applic_addr );
70  }
71  }
72 #ifdef HAS_FILE_SOURCE
73  do {
74  uboot_file_addr = load_file_from_external_source_to(uboot_file_addr);
75  } while (uboot_file_addr == 0);
76  /* now uboot_applic_addr points to flash */
77 #endif
78 } while(1==1); // oops NO UBOOT FILE
79 }
80 
81 static void uboot_file_run(flash_addr_t start_addr)
82 {
83 void (*startApplication) (void) = (void (* ) (void)) start_addr;
84  startApplication();
85 }