forked from Imagelibrary/rtems
2000-10-18 Sergei Organov <osv@javad.ru>
* Added full support for MPC505. * mpc505/ictrl: New directory. * configure.in, mpc505/Makefile.am: Modified to reflect ictrl addition. * mpc505/ictrl/.cvsignore, mpc505/ictrl/Makefile.am, mpc505/ictrl/ictrl.c, mpc505/ictrl/ictrl.h: New files. * mpc505/timer/timer.c: Use <rtems.h>, not "rtems.h". * mpc505/vectors/Makefile.am: alignment exception handler now included. * mpc505/vectors/vectors.S: Now use constants for exception numbers. * old_exception_processing/ppc_offs.h: New file. * old_exception_processing/Makefile.am: Account for ppc_offs.h. * old_exception_processing/cpu.h: Make Nest and Disable levels volatile. * old_exception_processing/cpu_asm.S: Offsets moved to ppc_offs.h.
This commit is contained in:
2
c/src/lib/libcpu/powerpc/mpc505/ictrl/.cvsignore
Normal file
2
c/src/lib/libcpu/powerpc/mpc505/ictrl/.cvsignore
Normal file
@@ -0,0 +1,2 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
39
c/src/lib/libcpu/powerpc/mpc505/ictrl/Makefile.am
Normal file
39
c/src/lib/libcpu/powerpc/mpc505/ictrl/Makefile.am
Normal file
@@ -0,0 +1,39 @@
|
||||
##
|
||||
## $Id$
|
||||
##
|
||||
|
||||
AUTOMAKE_OPTIONS = foreign 1.4
|
||||
|
||||
PGM = $(ARCH)/ictrl.rel
|
||||
|
||||
C_FILES = ictrl.c
|
||||
|
||||
H_FILES = ictrl.h
|
||||
|
||||
ictrl_rel_OBJECTS = $(C_FILES:%.c=$(ARCH)/%.o)
|
||||
|
||||
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
|
||||
include $(top_srcdir)/../../../../../automake/compile.am
|
||||
include $(top_srcdir)/../../../../../automake/lib.am
|
||||
|
||||
$(PROJECT_INCLUDE):
|
||||
$(mkinstalldirs) $@
|
||||
$(PROJECT_INCLUDE)/%.h: %.h
|
||||
$(INSTALL_DATA) $< $@
|
||||
|
||||
#
|
||||
# (OPTIONAL) Add local stuff here using +=
|
||||
#
|
||||
|
||||
$(PGM): $(ictrl_rel_OBJECTS)
|
||||
$(make-rel)
|
||||
|
||||
TMPINSTALL_FILES += $(PROJECT_INCLUDE) $(PROJECT_INCLUDE)/ictrl.h
|
||||
|
||||
all-local: $(ARCH) $(ictrl_rel_OBJECTS) $(PGM) $(TMPINSTALL_FILES)
|
||||
|
||||
.PRECIOUS: $(PGM)
|
||||
|
||||
EXTRA_DIST = ictrl.c ictrl.h
|
||||
|
||||
include $(top_srcdir)/../../../../../automake/local.am
|
||||
68
c/src/lib/libcpu/powerpc/mpc505/ictrl/ictrl.c
Normal file
68
c/src/lib/libcpu/powerpc/mpc505/ictrl/ictrl.c
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* mpc505/509 external interrupt controller management.
|
||||
*/
|
||||
|
||||
#include "ictrl.h"
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/score/ppc.h>
|
||||
|
||||
/*
|
||||
* Internal routines.
|
||||
*/
|
||||
|
||||
static unsigned long volatile *const IRQAND =
|
||||
(unsigned long volatile *const)0x8007EFA4;
|
||||
|
||||
static void nullHandler()
|
||||
{
|
||||
}
|
||||
|
||||
/* Interrupt dispatch table. */
|
||||
static ExtIsrHandler extIrqHandlers[NUM_IRQS] =
|
||||
{
|
||||
nullHandler,
|
||||
nullHandler,
|
||||
nullHandler,
|
||||
nullHandler,
|
||||
nullHandler,
|
||||
nullHandler,
|
||||
nullHandler
|
||||
};
|
||||
|
||||
|
||||
/* RTEMS external interrupt handler. Calls installed external interrupt
|
||||
handlers for every pending external interrupt in turn. */
|
||||
static rtems_isr extIsr_( rtems_vector_number i )
|
||||
{
|
||||
#define BIT_NUMBER(val, bit) \
|
||||
asm volatile ( "cntlzw %0, %1; srawi %0, %0, 1": "=r" (bit) : "r" (val) );
|
||||
|
||||
int bit;
|
||||
(void)i;
|
||||
|
||||
BIT_NUMBER(*IRQAND & IMASK_ALL, bit);
|
||||
while ( bit < NUM_IRQS ) {
|
||||
extIrqHandlers[bit]();
|
||||
BIT_NUMBER(*IRQAND & IMASK_ALL, bit);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Public routines
|
||||
*/
|
||||
|
||||
void extIrqSetHandler(ExtInt interrupt,ExtIsrHandler handler)
|
||||
{
|
||||
extIrqHandlers[interrupt] = handler;
|
||||
}
|
||||
|
||||
void extIsrInit( void )
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
extIrqDisable(IMASK_ALL);
|
||||
for( i = 0; i < NUM_IRQS; i++)
|
||||
extIrqHandlers[i] = nullHandler;
|
||||
set_vector(extIsr_,PPC_IRQ_EXTERNAL,1);
|
||||
}
|
||||
75
c/src/lib/libcpu/powerpc/mpc505/ictrl/ictrl.h
Normal file
75
c/src/lib/libcpu/powerpc/mpc505/ictrl/ictrl.h
Normal file
@@ -0,0 +1,75 @@
|
||||
#ifndef _ICTRL_H
|
||||
#define _ICTRL_H
|
||||
|
||||
/*
|
||||
* mpc505/509 external interrupt controller management.
|
||||
*
|
||||
* FIXME: should be somehow merged into general RTEMS interrupt
|
||||
* management code.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define _SIU_IRQENABLE ((unsigned long volatile *const)0x8007EFA8)
|
||||
#define _SIU_IRQPEND ((unsigned long volatile *const)0x8007EFA0)
|
||||
|
||||
/* Interrupt masks. */
|
||||
enum {
|
||||
IMASK_EXT0 = 0x80000000,
|
||||
IMASK_EXT1 = 0x20000000,
|
||||
IMASK_EXT2 = 0x08000000,
|
||||
IMASK_EXT3 = 0x02000000,
|
||||
IMASK_EXT4 = 0x00800000,
|
||||
IMASK_EXT5 = 0x00200000,
|
||||
IMASK_EXT6 = 0x00080000,
|
||||
IMASK_ALL = IMASK_EXT0 | IMASK_EXT1 | IMASK_EXT2 | IMASK_EXT3 |
|
||||
IMASK_EXT4 | IMASK_EXT5 | IMASK_EXT6
|
||||
};
|
||||
|
||||
/* Interrupt numbers. */
|
||||
typedef enum {
|
||||
IRQ_EXT0,
|
||||
IRQ_EXT1,
|
||||
IRQ_EXT2,
|
||||
IRQ_EXT3,
|
||||
IRQ_EXT4,
|
||||
IRQ_EXT5,
|
||||
IRQ_EXT6,
|
||||
NUM_IRQS
|
||||
} ExtInt;
|
||||
|
||||
/* Type of external interrupt handlers */
|
||||
typedef void (*ExtIsrHandler) (void);
|
||||
|
||||
/* Initialization. Must be called once after RTEMS interrupts sybsystem
|
||||
is initiailized. 'predriver_hook' is one of such places. */
|
||||
extern void extIsrInit( void );
|
||||
|
||||
/* Set interrupt handler 'handler' for external interrupt number
|
||||
'interrupt'. */
|
||||
extern void extIrqSetHandler(ExtInt interrupt, ExtIsrHandler handler);
|
||||
|
||||
/* Check is external interrupt 'irq' (IMASK_XXXX) is pended. */
|
||||
#define extIrqIsSet(irq) \
|
||||
(*_SIU_IRQPEND & (irq))
|
||||
|
||||
/* Enable external interrupt 'irq' (IMASK_XXXX) processing. */
|
||||
#define extIrqEnable(irq) \
|
||||
(*_SIU_IRQENABLE |= (irq))
|
||||
|
||||
/* Disable external interrupt 'irq' (IMASK_XXXX) processing. */
|
||||
#define extIrqDisable(irq) \
|
||||
(*_SIU_IRQENABLE &= ~(irq))
|
||||
|
||||
/* Check if external interrupt 'irq' (IMASK_XXXX) processing is
|
||||
enabled. */
|
||||
#define extIrqGetEnable \
|
||||
(*_SIU_IRQENABLE)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ICTRL_H */
|
||||
Reference in New Issue
Block a user