⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cpc700intr.c

📁 VxWorks下 Spruce的BSP源代码
💻 C
字号:
/* CPC700Intr.c - IBM CPC700-specific interrupt handling library *//*******************************************************************************   This source and object code has been made available to you by IBM on an   AS-IS basis.   IT IS PROVIDED WITHOUT WARRANTY OF ANY KIND, INCLUDING THE WARRANTIES OF   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE OR OF   NONINFRINGEMENT OF THIRD PARTY RIGHTS.  IN NO EVENT SHALL IBM OR ITS   LICENSORS BE LIABLE FOR INCIDENTAL, CONSEQUENTIAL OR PUNITIVE DAMAGES.   IBM'S OR ITS LICENSOR'S DAMAGES FOR ANY CAUSE OF ACTION, WHETHER IN   CONTRACT OR IN TORT, AT LAW OR AT EQUITY, SHALL BE LIMITED TO A MAXIMUM   OF $1,000 PER LICENSE.  Anyone receiving this source or object code is   licensed under IBM copyrights to use it in any way he or she deems fit,   including copying it, modifying it, compiling it, and redistributing it   either with or without modifications.  No license under IBM patents or   patent applications is to be implied by the copyright license.   Any user of this software should understand that neither IBM nor its   licensors will be responsible for any consequences resulting from the   use of this software.   Any person who transfers this object code or any derivative work must   include the IBM copyright notice in the transferred software.   COPYRIGHT   I B M   CORPORATION 1999   LICENSED MATERIAL  -  PROGRAM PROPERTY OF  I B M"*******************************************************************************//* Copyright 1984-1997 Wind River Systems, Inc. */#include "copyright_wrs.h"/* modification history-----------------------01c,27mar01,kab  Removed IBM support info per request01b,14sep99,mcg  updated for Tornado 201a,05mar99,mcg  created from PPC403Intr.c version 01m.*//*This library provides various interface routines to manipulate and connectto external hardware interrupts of the Universal Interrupt Controller (UIC)on the IBM CPC700 Embedded companion chipset for PowerPC 6xx/7xx processors.*/#include "vxWorks.h"#include "logLib.h"#include "stdio.h"#include "private/eventP.h"/* defines */#define INT_LEVEL_MAX   31             /* the UIC has 32 interrupt sources */#define INT_LEVEL_MIN   0/* externals */IMPORT STATUS   (*_func_intConnectRtn) (VOIDFUNCPTR *, VOIDFUNCPTR, int);IMPORT int      (*_func_intEnableRtn) (int);IMPORT int      (*_func_intDisableRtn) (int);/* globals */void sysCPC700IntHandler (void);/* locals */LOCAL VOIDFUNCPTR       sysIntBlTbl [32] = {(VOIDFUNCPTR) NULL};LOCAL int               sysIntArg [32]   = {0};/* forward LOCAL functions declarations */STATUS    sysCPC700IntConnect (VOIDFUNCPTR * vector, VOIDFUNCPTR routine,                               int parameter);STATUS    sysCPC700IntEnable  (int intLevel);STATUS    sysCPC700IntDisable (int intLevel);/********************************************************************************* sysCPC700IntrInit - initialize the CPC700 interrupt facility** This routine initializes the interrupt facility for the CPC700 Embedded* companion chipset.** RETURNS: OK, always.*/STATUS sysCPC700IntrInit    (    void    )    {    /* set the BSP driver specific Interrupt Handler and intConnect routines */    _func_intConnectRtn = sysCPC700IntConnect;    _func_intEnableRtn = sysCPC700IntEnable;    _func_intDisableRtn = sysCPC700IntDisable;    /*     * Initial Interrupt controller setup for Spruce     */    sysOutLong(UICSR,0xFFFFFFFF);     /* clear all ints */    sysOutLong(UICER,0x00000000);     /* disable all ints */    sysOutLong(UICCR,0xFFFFFFFF);     /* set all ints to be critical */    sysOutLong(UICPR,0xFFFFFE00);     /* set int polarities to '1' active */    sysOutLong(UICTR,0xC0000600);     /* set int trigger levels */                                      /* UARTs and keyboard/mouse (if used) */                                      /* are edge triggered.                */    sysOutLong(UICVCR,0x00000001);    /* set vect base=0,INT0 highest priority*/    sysOutLong(UICSR,0xFFFFFFFF);     /* clear all ints again */    return (OK);    }/********************************************************************************* sysCPC700IntConnect - connect a C routine to a hardware interrupt** This routine connects a specified C routine to a specified* interrupt vector.  It is called by intConnect().** The CPC700 Embedded companion chipset does not provide vectors for external* interrupts.  Instead, vectors are assigned according to the bits in the* Universal Interrupt Controller Enable Register (UICER).** RETURNS: OK, or ERROR if <vector> is out of range.** SEE ALSO: intConnect(), sysCPC700IntHandler()*/STATUS sysCPC700IntConnect    (    VOIDFUNCPTR * vector,       /* interrupt vector to attach to     */    VOIDFUNCPTR   routine,      /* routine to be called              */    int           parameter     /* parameter to be passed to routine */    )    {    if (((int)vector > INT_LEVEL_MAX) || ((int)vector < INT_LEVEL_MIN))        return (ERROR);    else        {        sysIntBlTbl[(int)vector] = routine;        sysIntArg[(int)vector]   = parameter;        return (OK);        }    }/********************************************************************************* sysCPC700IntHandler - CPC700 external interrupt handler** This is the external interrupt handler for the CPC700* Embedded Companion Chipset.** RETURNS: N/A*/void sysCPC700IntHandler    (    void    )    {    int vector;    INT32 uicmsr;               /* contents of Masked Status Register */    INT32 uicer;                /* contents of interrupt enable reg */    INT32 mask;    /*     * Get contents of UICMSR.  This register is read-only     * and relects the value of UICSR ANDed with UICER.     */    uicmsr = sysInLong (UICMSR);    uicer  = sysInLong (UICER);    /*     * get interrupt number     */    vector = vxFirstBit (uicmsr);#ifdef INCLUDE_WINDVIEW    WV_EVT_INT_ENT(vector)#endif    if (vector <= INT_LEVEL_MAX)        {        /*         * clear the interrupt status bit in UICSR         */        sysOutLong (UICSR, 1 << (INT_LEVEL_MAX - vector));        /*         * Mask this and lower priority interrupt levels:         */        mask = (0xFFFFFFFF << (INT_LEVEL_MAX+1 - vector)) & sysInLong (UICER);        sysOutLong (UICER, mask);        /*         * Enable interrupt nesting         */        intUnlock (_PPC_MSR_EE);        /*         * Call the appropriate handler with the appropriate argument         */        if (sysIntBlTbl [vector] != (VOIDFUNCPTR) NULL)            (*sysIntBlTbl [vector]) (sysIntArg[vector]);        else            logMsg ("uninitialized interrupt vector %d\n", vector, 0,0,0,0,0);        /*         * re-enable interrupt mask         */        sysOutLong (UICER, uicer);        }    }/********************************************************************************* sysCPC700IntDisable - disable an external interrupt level** This routine disables a specified external interrupt for the CPC700* Embedded Companion Chipset.** RETURNS: OK, or ERROR if <intLevel> is not in the range 0 - 31.** SEE ALSO: sysCPC700IntEnable()*/STATUS sysCPC700IntDisable    (    int intLevel        /* interrupt level to disable */    )    {    UINT32 intMask;    if (intLevel > INT_LEVEL_MAX || intLevel < INT_LEVEL_MIN)        return (ERROR);    intMask = 1 << (INT_LEVEL_MAX - intLevel);    /*     * disable the interrupt level     */    sysOutLong(UICER, intMask ^ sysInLong (UICER));    sysOutLong(UICSR, intMask);             /* clear pending interrupts */    return (OK);    }/********************************************************************************* sysCPC700IntEnable - enable an external interrupt level** This routine enables a specified external interrupt for the CPC700* Embedded Companion Chipset.** RETURNS: OK, or ERROR if <intLevel> is not in the range 0 - 31.** SEE ALSO: sysCPC700IntDisable()*/STATUS sysCPC700IntEnable    (    int intLevel        /* interrupt level to enable */    )    {    UINT32 intMask;    if (intLevel > INT_LEVEL_MAX || intLevel < INT_LEVEL_MIN)        return (ERROR);    intMask = 1 << (INT_LEVEL_MAX - intLevel);    sysOutLong (UICSR, intMask);             /* clear pending interrupts */    /*     * enable the interrupt level     */    sysOutLong (UICER, intMask | sysInLong (UICER));    return (OK);    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -