CMSIS2000  0.0.7
 Указатель Структуры данных Файлы Функции Переменные Определения типов Перечисления Элементы перечислений Макросы Группы Страницы
iboot_main_PC.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 test find and load uboot file in memory
35 \author Cherepanov Dmitiy
36 */
37 /*----------------------------------------------------------------------------*/
38 #include "./GCC_CMAKE/test_file_bin.h"
39 #include "common/uboot_file.h"
40 /*----------------------------------------------------------------------------*/
41 #include <stdlib.h>
42 #include <string.h>
43 #define IMAGE_STEP 0x100
44 /*----------------------------------------------------------------------------*/
45 int main (void)
46 {
47 flash_addr_t uboot_file_addr;
48 
49 
50  uboot_file_addr = find_uboot_file((flash_addr_t)test_file_file_content,
51  (flash_addr_t)test_file_file_content+ sizeof(test_file_file_content));
52  if (uboot_file_addr != ((flash_addr_t)test_file_file_content)) {
53  puts("Error for searching from known address");
54  } else {
55  puts("Searching from known address succsesful");
56  }
57 /*--------------------------*/
58  char * memallocated = malloc(sizeof(test_file_file_content)+IMAGE_STEP+IMAGE_STEP/2-1 +IMAGE_STEP * 3);
59  char * memallocated_end = memallocated + sizeof(test_file_file_content)+IMAGE_STEP+IMAGE_STEP/2-1 +IMAGE_STEP * 3;
60 
61  char * alligned_ptr = (char * )
62  (((unsigned) memallocated + IMAGE_STEP * 3 +(IMAGE_STEP - 1))&(~(IMAGE_STEP - 1)));
63 
64  memcpy(alligned_ptr,test_file_file_content,sizeof(test_file_file_content) );
65 
66  uboot_file_addr = find_uboot_file(memallocated, memallocated_end);
67  if (uboot_file_addr != ((flash_addr_t)alligned_ptr)) {
68  puts("Error for searching from unknown address aligned by 256");
69  } else {
70  puts("Searching from unknown address succsesful aligned by 256");
71  }
72 /*--------------------------*/
73  char * notalligned_ptr = alligned_ptr + IMAGE_STEP/2-1;
74  memcpy(notalligned_ptr,test_file_file_content,sizeof(test_file_file_content) );
75 
76  uboot_file_addr = find_uboot_file(memallocated, memallocated_end);
77  if (uboot_file_addr != ((flash_addr_t)notalligned_ptr)) {
78  puts("Error for searching from unknown address");
79  } else {
80  puts("Searching from unknown address succsesful");
81  }
82 
83  uboot_file_addr = find_uboot_file((flash_addr_t)test_file_file_content,
84  sizeof(test_file_file_content));
85 }
86