-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathcfe_psp_support.c
199 lines (183 loc) · 4.76 KB
/
cfe_psp_support.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
/************************************************************************
* NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
*
* Copyright (c) 2020 United States Government as represented by the
* Administrator of the National Aeronautics and Space Administration.
* All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
************************************************************************/
/******************************************************************************
** File: cfe_psp_support.c
**
** Purpose:
** This file contains glue routines between the cFE and the OS Board Support Package ( BSP ).
** The functions here allow the cFE to interface functions that are board and OS specific
** and usually don't fit well in the OS abstraction layer.
**
** History:
** 2005/06/05 Alan Cudmore | Initial version,
**
******************************************************************************/
/*
** Include Files
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "vxWorks.h"
#include "sysLib.h"
#include "taskLib.h"
#include "ramDrv.h"
#include "dosFsLib.h"
#include "errnoLib.h"
#include "usrLib.h"
#include "cacheLib.h"
#include "drv/hdisk/ataDrv.h"
#include "cacheLib.h"
#include "rebootLib.h"
/*
** cFE includes
*/
#include "common_types.h"
#include "osapi.h"
/*
** Types and prototypes for this module
*/
#include "cfe_psp.h"
#include "cfe_psp_memory.h"
#include "target_config.h"
#define CFE_PSP_CPU_ID (GLOBAL_CONFIGDATA.Default_CpuId)
#define CFE_PSP_CPU_NAME (GLOBAL_CONFIGDATA.Default_CpuName)
#define CFE_PSP_SPACECRAFT_ID (GLOBAL_CONFIGDATA.Default_SpacecraftId)
/*
* Track the overall "reserved memory block" at the start of RAM.
* This single large block is then subdivided into separate areas for CFE use.
*/
extern CFE_PSP_MemoryBlock_t MCP750_ReservedMemBlock;
/******************************************************************************
**
** Purpose:
** Provides a common interface to the processor reset.
**
** Arguments:
** reset_type : Type of reset.
**
** Return:
** (none)
*/
void CFE_PSP_Restart(uint32 reset_type)
{
if (reset_type == CFE_PSP_RST_TYPE_POWERON)
{
CFE_PSP_ReservedMemoryMap.BootPtr->bsp_reset_type = CFE_PSP_RST_TYPE_POWERON;
CFE_PSP_FlushCaches(1, MCP750_ReservedMemBlock.BlockPtr, MCP750_ReservedMemBlock.BlockSize);
reboot(BOOT_CLEAR);
}
else
{
CFE_PSP_ReservedMemoryMap.BootPtr->bsp_reset_type = CFE_PSP_RST_TYPE_PROCESSOR;
CFE_PSP_FlushCaches(1, MCP750_ReservedMemBlock.BlockPtr, MCP750_ReservedMemBlock.BlockSize);
reboot(BOOT_NORMAL);
}
}
/******************************************************************************
**
** Purpose:
** Provides a common interface to abort the cFE startup process and return
** back to the OS.
**
** Arguments:
** ErrorCode : Reason for Exiting.
**
** Return:
** (none)
*/
void CFE_PSP_Panic(int32 ErrorCode)
{
printf("CFE_PSP_Panic Called with error code = 0x%08X. Exiting.\n", (unsigned int)ErrorCode);
exit(-1); /* Need to improve this */
}
/******************************************************************************
**
** Purpose:
** Provides a common interface to flush the processor caches. This routine
** is in the BSP because it is sometimes implemented in hardware and
** sometimes taken care of by the RTOS.
**
** Arguments:
**
** Return:
** (none)
*/
void CFE_PSP_FlushCaches(uint32 type, void *address, uint32 size)
{
if (type == 1)
{
cacheTextUpdate(address, size);
}
}
/*
**
** Purpose:
** return the processor ID.
**
**
** Parameters:
**
** Global Inputs: None
**
** Global Outputs: None
**
**
**
** Return Values: Processor ID
*/
uint32 CFE_PSP_GetProcessorId(void)
{
return CFE_PSP_CPU_ID;
}
/*
**
** Purpose:
** return the spacecraft ID.
**
** Parameters:
**
** Global Inputs: None
**
** Global Outputs: None
**
**
** Return Values: Spacecraft ID
*/
uint32 CFE_PSP_GetSpacecraftId(void)
{
return CFE_PSP_SPACECRAFT_ID;
}
/*
**
** Purpose:
** return the processor name.
**
** Parameters:
**
** Global Inputs: None
**
** Global Outputs: None
**
**
** Return Values: Processor name
*/
const char *CFE_PSP_GetProcessorName(void)
{
return CFE_PSP_CPU_NAME;
}