Skip to content

Commit 8ddf82c

Browse files
committed
First commit
Signed-off-by: <[email protected]>
0 parents  commit 8ddf82c

File tree

1,063 files changed

+163901
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,063 files changed

+163901
-0
lines changed

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# used to remove files from deployment using `git archive`
2+
# git files
3+
.gitattributes export-ignore
4+
.gitignore export-ignore
5+
.mailmap export-ignore

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
*.o
2+
*.a
3+
*.d
4+
.dir
5+
6+
outdir
7+
samples/libc/minimal-*-O?
8+
linux2/
9+
host/x86-linux2/bin/gen*
10+
host/x86-linux2/bin/bin2hex
11+
host/x86-linux2/bin/dec2hex
12+
host/x86-linux2/bin/mkevents
13+
host/x86-linux2/bin/sysgen

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

arch/arc/bsp/fatal_error.c

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/* fatal_error.c - ARCv2 system fatal error handler */
2+
3+
/*
4+
* Copyright (c) 2014 Wind River Systems, Inc.
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions are met:
8+
*
9+
* 1) Redistributions of source code must retain the above copyright notice,
10+
* this list of conditions and the following disclaimer.
11+
*
12+
* 2) Redistributions in binary form must reproduce the above copyright notice,
13+
* this list of conditions and the following disclaimer in the documentation
14+
* and/or other materials provided with the distribution.
15+
*
16+
* 3) Neither the name of Wind River Systems nor the names of its contributors
17+
* may be used to endorse or promote products derived from this software without
18+
* specific prior written permission.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30+
* POSSIBILITY OF SUCH DAMAGE.
31+
*/
32+
33+
/*
34+
DESCRIPTION
35+
This module provides the _SysFatalErrorHandler() routine for ARCv2 BSPs.
36+
*/
37+
38+
/* includes */
39+
40+
#include <cputype.h>
41+
#include <nanokernel.h>
42+
#include <nanokernel/cpu.h>
43+
#include <toolchain.h>
44+
#include <sections.h>
45+
#include "board.h"
46+
47+
#ifdef CONFIG_PRINTK
48+
#include <misc/printk.h>
49+
#define PRINTK(...) printk(__VA_ARGS__)
50+
#else
51+
#define PRINTK(...)
52+
#endif
53+
54+
#ifdef CONFIG_MICROKERNEL
55+
extern void _TaskAbort(void);
56+
static inline void nonEssentialTaskAbort(void)
57+
{
58+
PRINTK("Fatal fault in task ! Aborting task.\n");
59+
_TaskAbort();
60+
}
61+
#define NON_ESSENTIAL_TASK_ABORT() nonEssentialTaskAbort()
62+
#else
63+
#define NON_ESSENTIAL_TASK_ABORT() \
64+
do {/* nothing */ \
65+
} while ((0))
66+
#endif
67+
68+
/*******************************************************************************
69+
*
70+
* _SysFatalErrorHandler - fatal error handler
71+
*
72+
* This routine implements the corrective action to be taken when the system
73+
* detects a fatal error.
74+
*
75+
* This sample implementation attempts to abort the current context and allow
76+
* the system to continue executing, which may permit the system to continue
77+
* functioning with degraded capabilities.
78+
*
79+
* System designers may wish to enhance or substitute this sample
80+
* implementation to take other actions, such as logging error (or debug)
81+
* information to a persistent repository and/or rebooting the system.
82+
*
83+
* RETURNS: N/A
84+
*
85+
* \NOMANUAL
86+
*/
87+
88+
void _SysFatalErrorHandler(
89+
unsigned int reason, /* fatal error reason */
90+
const NANO_ESF *pEsf /* pointer to exception stack frame */
91+
)
92+
{
93+
nano_context_type_t curCtx = context_type_get();
94+
95+
ARG_UNUSED(reason);
96+
ARG_UNUSED(pEsf);
97+
98+
if ((curCtx == NANO_CTX_ISR) || _context_essential_check(NULL)) {
99+
PRINTK("Fatal fault in %s ! Spinning...\n",
100+
NANO_CTX_ISR == curCtx
101+
? "ISR"
102+
: NANO_CTX_FIBER == curCtx ? "essential fiber"
103+
: "essential task");
104+
for (;;)
105+
; /* spin forever */
106+
}
107+
108+
if (NANO_CTX_FIBER == curCtx) {
109+
PRINTK("Fatal fault in fiber ! Aborting fiber.\n");
110+
fiber_abort();
111+
return;
112+
}
113+
114+
NON_ESSENTIAL_TASK_ABORT();
115+
}

arch/arc/bsp/prep_c.c

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/* prep_c.c - full C support initialization */
2+
3+
/*
4+
* Copyright (c) 2014 Wind River Systems, Inc.
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions are met:
8+
*
9+
* 1) Redistributions of source code must retain the above copyright notice,
10+
* this list of conditions and the following disclaimer.
11+
*
12+
* 2) Redistributions in binary form must reproduce the above copyright notice,
13+
* this list of conditions and the following disclaimer in the documentation
14+
* and/or other materials provided with the distribution.
15+
*
16+
* 3) Neither the name of Wind River Systems nor the names of its contributors
17+
* may be used to endorse or promote products derived from this software without
18+
* specific prior written permission.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30+
* POSSIBILITY OF SUCH DAMAGE.
31+
*/
32+
33+
/*
34+
DESCRIPTION
35+
36+
Initialization of full C support: zero the .bss, copy the .data if XIP,
37+
call _Cstart().
38+
39+
Stack is available in this module, but not the global data/bss until their
40+
initialization is performed.
41+
*/
42+
43+
#include <stdint.h>
44+
#include <toolchain.h>
45+
#include <linker-defs.h>
46+
47+
/*******************************************************************************
48+
*
49+
* bssZero - clear BSS
50+
*
51+
* This routine clears the BSS region, so all bytes are 0.
52+
*
53+
* RETURNS: N/A
54+
*/
55+
56+
static void bssZero(void)
57+
{
58+
volatile uint32_t *pBSS = (uint32_t *)&__bss_start;
59+
unsigned int n;
60+
61+
for (n = 0; n < (unsigned int)&__bss_num_words; n++) {
62+
pBSS[n] = 0;
63+
}
64+
}
65+
66+
/*******************************************************************************
67+
*
68+
* dataCopy - copy the data section from ROM to RAM
69+
*
70+
* This routine copies the data section from ROM to RAM.
71+
*
72+
* RETURNS: N/A
73+
*/
74+
75+
#ifdef CONFIG_XIP
76+
static void dataCopy(void)
77+
{
78+
volatile uint32_t *pROM = (uint32_t *)&__data_rom_start;
79+
volatile uint32_t *pRAM = (uint32_t *)&__data_ram_start;
80+
unsigned int n;
81+
82+
for (n = 0; n < (unsigned int)&__data_num_words; n++) {
83+
pRAM[n] = pROM[n];
84+
}
85+
}
86+
#else
87+
static void dataCopy(void)
88+
{
89+
}
90+
#endif
91+
92+
extern FUNC_NORETURN void _Cstart(void);
93+
/*******************************************************************************
94+
*
95+
* _PrepC - prepare to and run C code
96+
*
97+
* This routine prepares for the execution of and runs C code.
98+
*
99+
* RETURNS: N/A
100+
*/
101+
102+
void _PrepC(void)
103+
{
104+
bssZero();
105+
dataCopy();
106+
_Cstart();
107+
CODE_UNREACHABLE;
108+
}

arch/arc/bsp/reset.s

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/* reset.s - reset handler */
2+
3+
/*
4+
* Copyright (c) 2014 Wind River Systems, Inc.
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions are met:
8+
*
9+
* 1) Redistributions of source code must retain the above copyright notice,
10+
* this list of conditions and the following disclaimer.
11+
*
12+
* 2) Redistributions in binary form must reproduce the above copyright notice,
13+
* this list of conditions and the following disclaimer in the documentation
14+
* and/or other materials provided with the distribution.
15+
*
16+
* 3) Neither the name of Wind River Systems nor the names of its contributors
17+
* may be used to endorse or promote products derived from this software without
18+
* specific prior written permission.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30+
* POSSIBILITY OF SUCH DAMAGE.
31+
*/
32+
33+
/*
34+
DESCRIPTION
35+
Reset handler that prepares the system for running C code.
36+
*/
37+
38+
#define _ASMLANGUAGE
39+
40+
#include <board.h>
41+
#include <toolchain.h>
42+
#include <sections.h>
43+
#include <nanokernel/cpu.h>
44+
45+
#define _RAM_END (CONFIG_RAM_START + CONFIG_RAM_SIZE)
46+
47+
GTEXT(__reset)
48+
49+
/*******************************************************************************
50+
*
51+
* __reset - reset vector
52+
*
53+
* Ran when the system comes out of reset. The processor is at supervisor level.
54+
*
55+
* Locking interrupts prevents anything from interrupting the CPU.
56+
*
57+
* When these steps are completed, jump to _PrepC(), which will finish setting
58+
* up the system for running C code.
59+
*
60+
* RETURNS: N/A
61+
*/
62+
63+
SECTION_FUNC(TEXT,__reset)
64+
65+
/* lock interrupts: will get unlocked when switch to main task */
66+
clri
67+
68+
/* setup a stack at the end of the RAM */
69+
mov sp, _RAM_END
70+
71+
j @_PrepC

0 commit comments

Comments
 (0)