📄 cpu_config.c
字号:
/*
* The above copyright holder, limited to cases in which one satisfies
* conditions (1) ~ (4) below, or the conditions described in Version 2
* of of the GNU Public License officially announced by the Free Software
* Foundation, consents to the use, reproduction, alteration, and
* redistribution (hereafter called utilization) of this software (this
* software includes alterations, likewise below) without compensation.
*
* (1) When this software is utilized in the form of source code, the
* above copyright declaration, these conditions of utilization, and the
* following stipulation of no guarantee shall be included in unchanged
* form inside the source code.
* (2) When this software is redistributed in a form in which it can be
* used in the development of other software, library form, etc., the above
* copyright display, these terms of utilization, and the following
* stipulation of no guarantee shall be inserted in documentation accompanying
* redistribution (user's manual, etc.).
* (3) When this software is redistributed in a form in which it cannot be used
* in the development of other software, embedded in devices, etc., one of the
* following conditions shall be satisfied.
* (a) The above copyright display, these terms of utilization, and the
* following stipulation of no guarantee shall be inserted in documentation
* accompanying redistribution (user's manual, etc.).
* (b) The TOPPERS Project shall be notified owing to a method in which the
* form of distribution is decided otherwise.
* (4) The above copyright holder and the TOPPERS Project shall be exempt
* from responsibility for whatever damages occur either directly or indirectly
* through the utilization of this software.
*
* This software is something that is provided with no guarantee. The above copyright
* holder and the TOPPERS Project make no guarantee whatsoever in regard to this
* software, including the possibility of its application. In addition, the above
* copyright holder and the TOPPERS Project shall also not bear responsibility for
* whatever damages occur either directly or indirectly through the utilization of
* this software.
* @(#) $Id: cpu_config.c,v 1.2 2006/07/21 09:50:00 9564907 Exp $
*/
/*
* Module that dependent to the processor (for the use of ARM4vT)
*/
#include "jsp_kernel.h"
#include "check.h"
#include <armv4.h>
#include "task.h"
/*
* The reference address to the jump instruction that already had been written in exception vector
*
*/
UW *arm_vector_add[8];
/*
* Start address number of the handler that corresponding to exception
*/
UW arm_handler_add[8];
/*
* Count of nest times of interruptions
*/
UW interrupt_count;
/*
* Stack temporarily used by the CPU/interruption handler's gateway processing
*/
UW int_stack[INT_STACK_SIZE];
/*
* Set the handler of CPU exceptions
*/
void
define_exc(EXCNO excno, FP exchdr)
{
arm_install_handler(excno,exchdr);
}
/*
* Process when undefined exception occurs
*/
void
undef_exception(){
syslog(LOG_EMERG, "Unregistered Exception occurs. UNDEF");
while(1);
}
void
swi_exception(){
syslog(LOG_EMERG, "Unregistered Exception occurs. SWI");
while(1);
}
void
prefetch_exception(){
syslog(LOG_EMERG, "Unregistered Exception occurs. PREFETCH");
while(1);
}
void
data_abort_exception(){
syslog(LOG_EMERG, "Unregistered Exception occurs. DATA ABORT");
while(1);
}
void
irq_exception(){
syslog(LOG_EMERG, "Unregistered Exception occurs. IRQ");
while(1);
}
void
fiq_exception(){
syslog(LOG_EMERG, "Unregistered Exception occurs. FIQ");
while(1);
}
/*
* Initialization of processor dependence
*/
void
cpu_initialize()
{
UW i,vector_value;
interrupt_count = 1;
/*
* With the address get from the instruction registered in the exception vector, save the
* content of the address (the execution destination of the handler).
*/
for(i = 0; i <=7; i++){
vector_value = *(volatile UW *)(i*4);
vector_value &= 0x00000fff;
if(i==0){
arm_vector_add[i] = (UW *)(vector_value + 8) + i;
arm_handler_add[i] = *(arm_vector_add[i]);
}else{
arm_vector_add[i] = (UW *)0xFFFFFEF0 + (i-1);
arm_handler_add[i] = *(arm_vector_add[i]);
}
}
}
/*
* Termination of processor dependence
*/
void
cpu_terminate()
{
UW i;
/* Restore the vector table. */
for(i = 0; i <=7; i++)
*arm_vector_add[i] = arm_handler_add[i];
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -