forked from Imagelibrary/rtems
Merged of mcp750 and mvme2307 BSP by Eric Valette <valette@crf.canon.fr>.
As part of this effort, the mpc750 libcpu code is now shared with the ppc6xx.
This commit is contained in:
79
c/src/lib/libcpu/powerpc/mpc6xx/exceptions/Makefile.in
Normal file
79
c/src/lib/libcpu/powerpc/mpc6xx/exceptions/Makefile.in
Normal file
@@ -0,0 +1,79 @@
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
@SET_MAKE@
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = ../../..
|
||||
subdir = powerpc/mpc6xx/exceptions
|
||||
|
||||
RTEMS_ROOT = @RTEMS_ROOT@
|
||||
PROJECT_ROOT = @PROJECT_ROOT@
|
||||
|
||||
VPATH = @srcdir@
|
||||
|
||||
PGM = ${ARCH}/exceptions.rel
|
||||
|
||||
# C source names, if any, go here -- minus the .c
|
||||
C_PIECES = raw_exception
|
||||
C_FILES = $(C_PIECES:%=%.c)
|
||||
C_O_FILES = $(C_PIECES:%=${ARCH}/%.o)
|
||||
|
||||
H_FILES = $(srcdir)/raw_exception.h
|
||||
|
||||
# Assembly source names, if any, go here -- minus the .S
|
||||
S_PIECES = asm_utils
|
||||
S_FILES = $(S_PIECES:%=%.S)
|
||||
S_O_FILES = $(S_FILES:%.S=${ARCH}/%.o)
|
||||
|
||||
SRCS = $(C_FILES) $(CC_FILES) $(H_FILES) $(S_FILES)
|
||||
OBJS = $(C_O_FILES) $(CC_O_FILES) $(S_O_FILES)
|
||||
|
||||
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
|
||||
include $(RTEMS_ROOT)/make/leaf.cfg
|
||||
|
||||
INSTALL_CHANGE = @INSTALL_CHANGE@
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/@RTEMS_TOPdir@/mkinstalldirs
|
||||
|
||||
INSTALLDIRS = $(PROJECT_INCLUDE)/libcpu
|
||||
|
||||
$(INSTALLDIRS):
|
||||
@$(mkinstalldirs) $(INSTALLDIRS)
|
||||
|
||||
#
|
||||
# (OPTIONAL) Add local stuff here using +=
|
||||
#
|
||||
|
||||
DEFINES +=
|
||||
CPPFLAGS +=
|
||||
CFLAGS +=
|
||||
|
||||
LD_PATHS +=
|
||||
LD_LIBS +=
|
||||
LDFLAGS +=
|
||||
|
||||
#
|
||||
# Add your list of files to delete here. The config files
|
||||
# already know how to delete some stuff, so you may want
|
||||
# to just run 'make clean' first to see what gets missed.
|
||||
# 'make clobber' already includes 'make clean'
|
||||
#
|
||||
|
||||
CLEAN_ADDITIONS +=
|
||||
CLOBBER_ADDITIONS +=
|
||||
|
||||
${PGM}: ${OBJS}
|
||||
$(make-rel)
|
||||
|
||||
preinstall: $(INSTALLDIRS) $(H_FILES)
|
||||
@$(INSTALL_CHANGE) -m 644 $(H_FILES) $(PROJECT_INCLUDE)/libcpu
|
||||
|
||||
all: ${ARCH} $(SRCS) preinstall $(PGM)
|
||||
|
||||
# the .rel file built here will be put into libbsp.a by ../wrapup/Makefile
|
||||
install: all
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
65
c/src/lib/libcpu/powerpc/mpc6xx/exceptions/asm_utils.S
Normal file
65
c/src/lib/libcpu/powerpc/mpc6xx/exceptions/asm_utils.S
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* asm_utils.s
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 1999 Eric Valette (valette@crf.canon.fr)
|
||||
*
|
||||
* This file contains the low-level support for moving exception
|
||||
* exception code to appropriate location.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <libcpu/cpu.h>
|
||||
#include <libcpu/io.h>
|
||||
#include <rtems/score/targopts.h>
|
||||
#include "asm.h"
|
||||
|
||||
.globl codemove
|
||||
codemove:
|
||||
.type codemove,@function
|
||||
/* r3 dest, r4 src, r5 length in bytes, r6 cachelinesize */
|
||||
cmplw cr1,r3,r4
|
||||
addi r0,r5,3
|
||||
srwi. r0,r0,2
|
||||
beq cr1,4f /* In place copy is not necessary */
|
||||
beq 7f /* Protect against 0 count */
|
||||
mtctr r0
|
||||
bge cr1,2f
|
||||
|
||||
la r8,-4(r4)
|
||||
la r7,-4(r3)
|
||||
1: lwzu r0,4(r8)
|
||||
stwu r0,4(r7)
|
||||
bdnz 1b
|
||||
b 4f
|
||||
|
||||
2: slwi r0,r0,2
|
||||
add r8,r4,r0
|
||||
add r7,r3,r0
|
||||
3: lwzu r0,-4(r8)
|
||||
stwu r0,-4(r7)
|
||||
bdnz 3b
|
||||
|
||||
/* Now flush the cache: note that we must start from a cache aligned
|
||||
* address. Otherwise we might miss one cache line.
|
||||
*/
|
||||
4: cmpwi r6,0
|
||||
add r5,r3,r5
|
||||
beq 7f /* Always flush prefetch queue in any case */
|
||||
subi r0,r6,1
|
||||
andc r3,r3,r0
|
||||
mr r4,r3
|
||||
5: cmplw r4,r5
|
||||
dcbst 0,r4
|
||||
add r4,r4,r6
|
||||
blt 5b
|
||||
sync /* Wait for all dcbst to complete on bus */
|
||||
mr r4,r3
|
||||
6: cmplw r4,r5
|
||||
icbi 0,r4
|
||||
add r4,r4,r6
|
||||
blt 6b
|
||||
7: sync /* Wait for all icbi to complete on bus */
|
||||
isync
|
||||
blr
|
||||
195
c/src/lib/libcpu/powerpc/mpc6xx/exceptions/raw_exception.c
Normal file
195
c/src/lib/libcpu/powerpc/mpc6xx/exceptions/raw_exception.c
Normal file
@@ -0,0 +1,195 @@
|
||||
/*
|
||||
* raw_exception.c - This file contains implementation of C function to
|
||||
* Instanciate 60x ppc primary exception entries.
|
||||
* More detailled information can be found on motorola
|
||||
* site and more precisely in the following book :
|
||||
*
|
||||
* MPC750
|
||||
* Risc Microporcessor User's Manual
|
||||
* Motorola REF : MPC750UM/AD 8/97
|
||||
*
|
||||
* Copyright (C) 1999 Eric Valette (valette@crf.canon.fr)
|
||||
* Canon Centre Recherche France.
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in found in the file LICENSE in this distribution or at
|
||||
* http://www.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
#include <rtems/score/targopts.h>
|
||||
#include <rtems/score/ppc.h>
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/cpu.h>
|
||||
#include <libcpu/raw_exception.h>
|
||||
#include <libcpu/cpu.h>
|
||||
|
||||
static rtems_raw_except_connect_data* raw_except_table;
|
||||
static rtems_raw_except_connect_data default_raw_except_entry;
|
||||
static rtems_raw_except_global_settings* local_settings;
|
||||
|
||||
int mpc750_vector_is_valid(rtems_vector vector)
|
||||
{
|
||||
switch(vector) {
|
||||
case ASM_RESET_VECTOR: /* fall through */
|
||||
case ASM_MACH_VECTOR:
|
||||
case ASM_PROT_VECTOR:
|
||||
case ASM_ISI_VECTOR:
|
||||
case ASM_EXT_VECTOR:
|
||||
case ASM_ALIGN_VECTOR:
|
||||
case ASM_PROG_VECTOR:
|
||||
case ASM_FLOAT_VECTOR:
|
||||
case ASM_DEC_VECTOR:
|
||||
case ASM_SYS_VECTOR:
|
||||
case ASM_TRACE_VECTOR:
|
||||
case ASM_ADDR_VECTOR:
|
||||
case ASM_SYSMGMT_VECTOR:
|
||||
case ASM_ITM_VECTOR:
|
||||
return 1;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int mpc604_vector_is_valid(rtems_vector vector)
|
||||
{
|
||||
/*
|
||||
* Please fill this for MVME2307
|
||||
*/
|
||||
printk("Please complete libcpu/powerpc/XXX/raw_exception.c\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mpc60x_set_exception (const rtems_raw_except_connect_data* except)
|
||||
{
|
||||
unsigned int level;
|
||||
|
||||
if (current_ppc_cpu == PPC_750) {
|
||||
if (!mpc750_vector_is_valid(except->exceptIndex)){
|
||||
return 0;
|
||||
}
|
||||
goto exception_ok;
|
||||
}
|
||||
if (current_ppc_cpu == PPC_604) {
|
||||
if (!mpc604_vector_is_valid(except->exceptIndex)){
|
||||
return 0;
|
||||
}
|
||||
goto exception_ok;
|
||||
}
|
||||
printk("Please complete libcpu/powerpc/XXX/raw_exception.c\n");
|
||||
return 0;
|
||||
|
||||
exception_ok:
|
||||
/*
|
||||
* Check if default handler is actually connected. If not issue an error.
|
||||
* You must first get the current handler via mpc60x_get_current_exception
|
||||
* and then disconnect it using mpc60x_delete_exception.
|
||||
* RATIONALE : to always have the same transition by forcing the user
|
||||
* to get the previous handler before accepting to disconnect.
|
||||
*/
|
||||
if (memcmp(mpc60x_get_vector_addr(except->exceptIndex), (void*)default_raw_except_entry.hdl.raw_hdl,default_raw_except_entry.hdl.raw_hdl_size)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
_CPU_ISR_Disable(level);
|
||||
|
||||
raw_except_table [except->exceptIndex] = *except;
|
||||
codemove((void*)mpc60x_get_vector_addr(except->exceptIndex),
|
||||
except->hdl.raw_hdl,
|
||||
except->hdl.raw_hdl_size,
|
||||
PPC_CACHE_ALIGNMENT);
|
||||
except->on(except);
|
||||
|
||||
_CPU_ISR_Enable(level);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int mpc60x_get_current_exception (rtems_raw_except_connect_data* except)
|
||||
{
|
||||
if (!mpc750_vector_is_valid(except->exceptIndex)){
|
||||
return 0;
|
||||
}
|
||||
|
||||
*except = raw_except_table [except->exceptIndex];
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int mpc60x_delete_exception (const rtems_raw_except_connect_data* except)
|
||||
{
|
||||
unsigned int level;
|
||||
|
||||
if (!mpc750_vector_is_valid(except->exceptIndex)){
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* Check if handler passed is actually connected. If not issue an error.
|
||||
* You must first get the current handler via mpc60x_get_current_exception
|
||||
* and then disconnect it using mpc60x_delete_exception.
|
||||
* RATIONALE : to always have the same transition by forcing the user
|
||||
* to get the previous handler before accepting to disconnect.
|
||||
*/
|
||||
if (memcmp(mpc60x_get_vector_addr(except->exceptIndex),
|
||||
(void*)except->hdl.raw_hdl,
|
||||
except->hdl.raw_hdl_size)) {
|
||||
return 0;
|
||||
}
|
||||
_CPU_ISR_Disable(level);
|
||||
|
||||
except->off(except);
|
||||
codemove((void*)mpc60x_get_vector_addr(except->exceptIndex),
|
||||
default_raw_except_entry.hdl.raw_hdl,
|
||||
default_raw_except_entry.hdl.raw_hdl_size,
|
||||
PPC_CACHE_ALIGNMENT);
|
||||
|
||||
|
||||
raw_except_table[except->exceptIndex] = default_raw_except_entry;
|
||||
raw_except_table[except->exceptIndex].exceptIndex = except->exceptIndex;
|
||||
|
||||
_CPU_ISR_Enable(level);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Exception global init.
|
||||
*/
|
||||
int mpc60x_init_exceptions (rtems_raw_except_global_settings* config)
|
||||
{
|
||||
unsigned i;
|
||||
unsigned int level;
|
||||
|
||||
/*
|
||||
* store various accelerators
|
||||
*/
|
||||
raw_except_table = config->rawExceptHdlTbl;
|
||||
local_settings = config;
|
||||
default_raw_except_entry = config->defaultRawEntry;
|
||||
|
||||
_CPU_ISR_Disable(level);
|
||||
|
||||
for (i=0; i <= LAST_VALID_EXC; i++) {
|
||||
if (!mpc750_vector_is_valid(i)){
|
||||
continue;
|
||||
}
|
||||
codemove((void*)mpc60x_get_vector_addr(i),
|
||||
raw_except_table[i].hdl.raw_hdl,
|
||||
raw_except_table[i].hdl.raw_hdl_size,
|
||||
PPC_CACHE_ALIGNMENT);
|
||||
if (raw_except_table[i].hdl.raw_hdl != default_raw_except_entry.hdl.raw_hdl) {
|
||||
raw_except_table[i].on(&raw_except_table[i]);
|
||||
}
|
||||
else {
|
||||
raw_except_table[i].off(&raw_except_table[i]);
|
||||
}
|
||||
}
|
||||
_CPU_ISR_Enable(level);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int mpc60x_get_exception_config (rtems_raw_except_global_settings** config)
|
||||
{
|
||||
*config = local_settings;
|
||||
return 1;
|
||||
}
|
||||
|
||||
168
c/src/lib/libcpu/powerpc/mpc6xx/exceptions/raw_exception.h
Normal file
168
c/src/lib/libcpu/powerpc/mpc6xx/exceptions/raw_exception.h
Normal file
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* raw_execption.h
|
||||
*
|
||||
* This file contains implementation of C function to
|
||||
* Instanciate 60x ppc primary exception entries.
|
||||
* More detailled information can be found on motorola
|
||||
* site and more precisely in the following book :
|
||||
*
|
||||
* MPC750
|
||||
* Risc Microporcessor User's Manual
|
||||
* Mtorola REF : MPC750UM/AD 8/97
|
||||
*
|
||||
* Copyright (C) 1999 Eric Valette (valette@crf.canon.fr)
|
||||
* Canon Centre Recherche France.
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in found in the file LICENSE in this distribution or at
|
||||
* http://www.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef _LIBCPU_MCP750_EXCEPTION_RAW_EXCEPTION_H
|
||||
#define _LIBCPU_MCP750_EXCEPTION_RAW_EXCEPTION_H
|
||||
|
||||
/*
|
||||
* Exception Vectors as defined in the MCP750 manual
|
||||
*/
|
||||
|
||||
#define ASM_RESET_VECTOR 0x01
|
||||
#define ASM_MACH_VECTOR 0x02
|
||||
#define ASM_PROT_VECTOR 0x03
|
||||
#define ASM_ISI_VECTOR 0x04
|
||||
#define ASM_EXT_VECTOR 0x05
|
||||
#define ASM_ALIGN_VECTOR 0x06
|
||||
#define ASM_PROG_VECTOR 0x07
|
||||
#define ASM_FLOAT_VECTOR 0x08
|
||||
#define ASM_DEC_VECTOR 0x09
|
||||
#define ASM_SYS_VECTOR 0x0C
|
||||
#define ASM_TRACE_VECTOR 0x0D
|
||||
#define ASM_ADDR_VECTOR 0x13
|
||||
#define ASM_SYSMGMT_VECTOR 0x14
|
||||
#define ASM_ITM_VECTOR 0x17
|
||||
#define LAST_VALID_EXC ASM_ITM_VECTOR
|
||||
|
||||
/*
|
||||
* Vector offsets as defined in the MCP750 manual
|
||||
*/
|
||||
|
||||
#define ASM_RESET_VECTOR_OFFSET (ASM_RESET_VECTOR << 8)
|
||||
#define ASM_MACH_VECTOR_OFFSET (ASM_MACH_VECTOR << 8)
|
||||
#define ASM_PROT_VECTOR_OFFSET (ASM_PROT_VECTOR << 8)
|
||||
#define ASM_ISI_VECTOR_OFFSET (ASM_ISI_VECTOR << 8)
|
||||
#define ASM_EXT_VECTOR_OFFSET (ASM_EXT_VECTOR << 8)
|
||||
#define ASM_ALIGN_VECTOR_OFFSET (ASM_ALIGN_VECTOR << 8)
|
||||
#define ASM_PROG_VECTOR_OFFSET (ASM_PROG_VECTOR << 8)
|
||||
#define ASM_FLOAT_VECTOR_OFFSET (ASM_FLOAT_VECTOR << 8)
|
||||
#define ASM_DEC_VECTOR_OFFSET (ASM_DEC_VECTOR << 8)
|
||||
#define ASM_SYS_VECTOR_OFFSET (ASM_SYS_VECTOR << 8)
|
||||
#define ASM_TRACE_VECTOR_OFFSET (ASM_TRACE_VECTOR << 8)
|
||||
#define ASM_ADDR_VECTOR_OFFSET (ASM_ADDR_VECTOR << 8)
|
||||
#define ASM_SYSMGMT_VECTOR_OFFSET (ASM_SYSMGMT_VECTOR << 8)
|
||||
#define ASM_ITM_VECTOR_OFFSET (ASM_ITM_VECTOR << 8)
|
||||
|
||||
|
||||
#ifndef ASM
|
||||
|
||||
/*
|
||||
* Type definition for raw exceptions.
|
||||
*/
|
||||
|
||||
typedef unsigned char rtems_vector;
|
||||
struct __rtems_raw_except_connect_data__;
|
||||
typedef void (*rtems_raw_except_func) (void);
|
||||
typedef unsigned char rtems_raw_except_hdl_size;
|
||||
|
||||
typedef struct {
|
||||
rtems_vector vector;
|
||||
rtems_raw_except_func raw_hdl;
|
||||
rtems_raw_except_hdl_size raw_hdl_size;
|
||||
}rtems_raw_except_hdl;
|
||||
|
||||
typedef void (*rtems_raw_except_enable) (const struct __rtems_raw_except_connect_data__*);
|
||||
typedef void (*rtems_raw_except_disable) (const struct __rtems_raw_except_connect_data__*);
|
||||
typedef int (*rtems_raw_except_is_enabled) (const struct __rtems_raw_except_connect_data__*);
|
||||
|
||||
typedef struct __rtems_raw_except_connect_data__{
|
||||
/*
|
||||
* Exception vector (As defined in the manual)
|
||||
*/
|
||||
rtems_vector exceptIndex;
|
||||
/*
|
||||
* Exception raw handler. See comment on handler properties below in function prototype.
|
||||
*/
|
||||
rtems_raw_except_hdl hdl;
|
||||
/*
|
||||
* function for enabling raw exceptions. In order to be consistent
|
||||
* with the fact that the raw connexion can defined in the
|
||||
* libcpu library, this library should have no knowledge of
|
||||
* board specific hardware to manage exceptions and thus the
|
||||
* "on" routine must enable the except at processor level only.
|
||||
*
|
||||
*/
|
||||
rtems_raw_except_enable on;
|
||||
/*
|
||||
* function for disabling raw exceptions. In order to be consistent
|
||||
* with the fact that the raw connexion can defined in the
|
||||
* libcpu library, this library should have no knowledge of
|
||||
* board specific hardware to manage exceptions and thus the
|
||||
* "on" routine must disable the except both at device and PIC level.
|
||||
*
|
||||
*/
|
||||
rtems_raw_except_disable off;
|
||||
/*
|
||||
* function enabling to know what exception may currently occur
|
||||
*/
|
||||
rtems_raw_except_is_enabled isOn;
|
||||
}rtems_raw_except_connect_data;
|
||||
|
||||
typedef struct {
|
||||
/*
|
||||
* size of all the table fields (*Tbl) described below.
|
||||
*/
|
||||
unsigned int exceptSize;
|
||||
/*
|
||||
* Default handler used when disconnecting exceptions.
|
||||
*/
|
||||
rtems_raw_except_connect_data defaultRawEntry;
|
||||
/*
|
||||
* Table containing initials/current value.
|
||||
*/
|
||||
rtems_raw_except_connect_data* rawExceptHdlTbl;
|
||||
}rtems_raw_except_global_settings;
|
||||
|
||||
/*
|
||||
* C callable function enabling to set up one raw idt entry
|
||||
*/
|
||||
extern int mpc60x_set_exception (const rtems_raw_except_connect_data*);
|
||||
|
||||
/*
|
||||
* C callable function enabling to get one current raw idt entry
|
||||
*/
|
||||
extern int mpc60x_get_current_exception (rtems_raw_except_connect_data*);
|
||||
|
||||
/*
|
||||
* C callable function enabling to remove one current raw idt entry
|
||||
*/
|
||||
extern int mpc60x_delete_exception (const rtems_raw_except_connect_data*);
|
||||
|
||||
/*
|
||||
* C callable function enabling to check if vector is valid
|
||||
*/
|
||||
extern int mpc750_vector_is_valid(rtems_vector vector);
|
||||
|
||||
inline static void* mpc60x_get_vector_addr(rtems_vector vector)
|
||||
{
|
||||
return ((void*) (((unsigned) vector) << 8));
|
||||
}
|
||||
/*
|
||||
* Exception global init.
|
||||
*/
|
||||
extern int mpc60x_init_exceptions (rtems_raw_except_global_settings* config);
|
||||
extern int mpc60x_get_exception_config (rtems_raw_except_global_settings** config);
|
||||
|
||||
# endif /* ASM */
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user