OpenCores
URL https://opencores.org/ocsvn/minsoc/minsoc/trunk

Subversion Repositories minsoc

[/] [minsoc/] [trunk/] [sw/] [support/] [int.c] - Diff between revs 53 and 55

Only display areas with differences | Details | Blame | View Log

Rev 53 Rev 55
/* This file is part of test microkernel for OpenRISC 1000. */
/* This file is part of test microkernel for OpenRISC 1000. */
/* (C) 2001 Simon Srot, srot@opencores.org */
/* (C) 2001 Simon Srot, srot@opencores.org */
 
 
#include "support.h"
#include "support.h"
#include "or1200.h"
#include "or1200.h"
#include "int.h"
#include "int.h"
 
 
#ifdef OR1K
 
 
 
/* Interrupt handlers table */
/* Interrupt handlers table */
struct ihnd int_handlers[MAX_INT_HANDLERS];
struct ihnd int_handlers[MAX_INT_HANDLERS];
 
 
/* Initialize routine */
/* Initialize routine */
int int_init()
int int_init()
{
{
        int i;
        int i;
 
 
        for(i = 0; i < MAX_INT_HANDLERS; i++) {
        for(i = 0; i < MAX_INT_HANDLERS; i++) {
                int_handlers[i].handler = 0;
                int_handlers[i].handler = 0;
                int_handlers[i].arg = 0;
                int_handlers[i].arg = 0;
        }
        }
        mtspr(SPR_PICMR, 0x00000000);
        mtspr(SPR_PICMR, 0x00000000);
 
 
        //set OR1200 to accept exceptions
        //set OR1200 to accept exceptions
        mtspr(SPR_SR, mfspr(SPR_SR) | SPR_SR_IEE);
        mtspr(SPR_SR, mfspr(SPR_SR) | SPR_SR_IEE);
 
 
        return 0;
        return 0;
}
}
 
 
/* Add interrupt handler */
/* Add interrupt handler */
int int_add(unsigned long vect, void (* handler)(void *), void *arg)
int int_add(unsigned long vect, void (* handler)(void *), void *arg)
{
{
        if(vect >= MAX_INT_HANDLERS)
        if(vect >= MAX_INT_HANDLERS)
                return -1;
                return -1;
 
 
        int_handlers[vect].handler = handler;
        int_handlers[vect].handler = handler;
        int_handlers[vect].arg = arg;
        int_handlers[vect].arg = arg;
 
 
        mtspr(SPR_PICMR, mfspr(SPR_PICMR) | (0x00000001L << vect));
        mtspr(SPR_PICMR, mfspr(SPR_PICMR) | (0x00000001L << vect));
 
 
        return 0;
        return 0;
}
}
 
 
/* Disable interrupt */
/* Disable interrupt */
int int_disable(unsigned long vect)
int int_disable(unsigned long vect)
{
{
        if(vect >= MAX_INT_HANDLERS)
        if(vect >= MAX_INT_HANDLERS)
                return -1;
                return -1;
 
 
        mtspr(SPR_PICMR, mfspr(SPR_PICMR) & ~(0x00000001L << vect));
        mtspr(SPR_PICMR, mfspr(SPR_PICMR) & ~(0x00000001L << vect));
 
 
        return 0;
        return 0;
}
}
 
 
/* Enable interrupt */
/* Enable interrupt */
int int_enable(unsigned long vect)
int int_enable(unsigned long vect)
{
{
        if(vect >= MAX_INT_HANDLERS)
        if(vect >= MAX_INT_HANDLERS)
                return -1;
                return -1;
 
 
        mtspr(SPR_PICMR, mfspr(SPR_PICMR) | (0x00000001L << vect));
        mtspr(SPR_PICMR, mfspr(SPR_PICMR) | (0x00000001L << vect));
 
 
        return 0;
        return 0;
}
}
 
 
/* Main interrupt handler */
/* Main interrupt handler */
void int_main()
void int_main()
{
{
        unsigned long picsr = mfspr(SPR_PICSR);   //process only the interrupts asserted at signal catch, ignore all during process
        unsigned long picsr = mfspr(SPR_PICSR);   //process only the interrupts asserted at signal catch, ignore all during process
        unsigned long i = 0;
        unsigned long i = 0;
 
 
        while(i < 32) {
        while(i < 32) {
                if((picsr & (0x01L << i)) && (int_handlers[i].handler != 0)) {
                if((picsr & (0x01L << i)) && (int_handlers[i].handler != 0)) {
                        (*int_handlers[i].handler)(int_handlers[i].arg);
                        (*int_handlers[i].handler)(int_handlers[i].arg);
                }
                }
                i++;
                i++;
        }
        }
 
 
        mtspr(SPR_PICSR, 0);      //clear interrupt status: all modules have level interrupts, which have to be cleared by software,
        mtspr(SPR_PICSR, 0);      //clear interrupt status: all modules have level interrupts, which have to be cleared by software,
}                           //thus this is safe, since non processed interrupts will get re-asserted soon enough
}                           //thus this is safe, since non processed interrupts will get re-asserted soon enough
 
 
 
 
#endif
 
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.