2 * Copyright (c) 2013 Qualcomm Atheros, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted (subject to the limitations in the
7 * disclaimer below) provided that the following conditions are met:
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the
17 * * Neither the name of Qualcomm Atheros nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
22 * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
23 * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
24 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
32 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
33 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #ifndef __ATHOS_API_H__
36 #define __ATHOS_API_H__
39 * This file contains wrappers to OS operating system functions
40 * that are available in the Athos version of the operating system.
42 * Target software must always use these wrappers to access OS
43 * services -- it may not access any OS services directly.
45 * These wrappers are intended to provide OS-independence for applications.
46 * Using this header file, an application should be able to compile and
47 * fully link without any other OS header files, source files, or
53 #include "cmnos_api.h"
54 #include "Magpie_api.h"
58 /* save the ROM printf function point */
59 extern int (* save_cmnos_printf)(const char * fmt, ...);
61 extern unsigned int _data_start_in_rom;
62 extern unsigned int _data_start;
63 extern unsigned int _data_end;
64 extern unsigned int _bss_start;
65 extern unsigned int _bss_end;
66 extern unsigned int _stack_sentry;
67 extern unsigned int __stack;
68 extern unsigned int _fw_image_end;
70 #if defined(__XTENSA__)
71 #define START_DATA _data_start
72 #define END_DATA _data_end
73 #define START_BSS _bss_start
74 #define END_BSS _bss_end
76 #define STACK_START _stack_sentry
77 #define STACK_END __stack
80 struct _A_os_linkage_check {
86 * A_INIT() handles any initialization needed by the OS abstraction,
87 * and it clears the application's BSS, if necessary. (Application BSS
88 * is not cleared if the application is linked into a single image that
91 * A_INIT() must be called first thing in the application (from app_start)
92 * in order to guarantee that BSS has been cleared properly.
97 struct _A_os_linkage_check link_check;
100 if (&START_BSS != _A_MAGPIE_INDIRECTION_TABLE->cmnos.start_bss) {
102 for (clrptr = &START_BSS; clrptr < &END_BSS; clrptr++) {
107 /* Copy writable data from flash to RAM. */
108 unsigned int *srcptr, *destptr;
111 * The _data_start symbol points to the start of data IN FLASH.
112 * It is defined by flash.ld at application link time. If flash.ld
113 * is not used, it is defined (on the link line) as 0.
115 static int *data_start_addr = &_data_start;
117 if (data_start_addr != 0) {
118 for (srcptr = &_data_start, destptr = &START_DATA;
120 srcptr++, destptr++) {
125 #define OS_LINKAGE_VERSION 4
126 link_check.version = OS_LINKAGE_VERSION;
127 link_check.table = _A_MAGPIE_INDIRECTION_TABLE_SIZE;
129 return A_CMN(hal_linkage_check(sizeof(link_check), &link_check));
132 #endif /* __ATHOS_API_H__ */