Esempio n. 1
0
/* Disconnect ISR from its PCI interrupt vector. */
static
int vxworksDevPCIDisconnectInterrupt(
  const epicsPCIDevice *dev,
  void (*pFunction)(void *),
  void  *parameter
)
{
    int status;
    struct osdPCIDevice *osd=pcidev2osd(dev);

   /* Get the IRQ number from the PCI device structure
    * and use it to get the interrupt number from the translation table
    * (if there is one). If there is no translation table, or the table
    * is too small, jut use the irq as the interrupt number.
    */
    unsigned char irq = osd->dev.irq;
    if (inumTableSize && (irq < inumTableSize))
        irq = inumTable[(int)irq];

    /* prefer the newer API when it is available */
    if(CallPciIntDisconnect2) {
        status=CallPciIntDisconnect2((void*)INUM_TO_IVEC(VXPCIINTOFFSET + irq),
                                     pFunction, (int)parameter);
    } else {
        status=CallPciIntDisconnect((void*)INUM_TO_IVEC(VXPCIINTOFFSET + irq),
                                    pFunction);
    }

    if(status)
        return S_dev_intDisconnect;

    return 0;
}
Esempio n. 2
0
File: vmeio.c Progetto: cjpl/midas
INLINE void vmeio_int_attach(const DWORD base_adr, DWORD base_vect, int intnum,
                             void (*isr) (void))
/**************************************************************\
 Purpose: Book an ISR for a bitwise set of interrupt input (0xff).
          The interrupt vector is then the VECTOR_BASE+intnum
 Input:
  DWORD * base_addr      : base address of the VMEIO
  DWORD base_vect        : base vector of the module
  DWORD intnum           : interrupt number (0:7)
  DWORD isr_routine      : interrupt routine pointer
 Output:
    none
 Function value:
    none
\**************************************************************/
{
   vmeio_int_clear(base_adr);   /* clear any pending front panel interrupts */
   vmeio_int_disable(base_adr, intnum); /* bitwise input */
#ifdef OS_VXWORKS
   if (intnum < 8)
      intConnect(INUM_TO_IVEC(base_vect + intnum), (VOIDFUNCPTR) isr, intnum);
#else
   printf("vector : 0x%x\n", base_vect + intnum);
#endif
   vmeio_int_enable(base_adr, intnum);  /* bitwise input */
}
Esempio n. 3
0
STATUS pcmciaInit (void)

    {
    PCMCIA_CTRL *pCtrl		= &pcmciaCtrl;
    PCMCIA_CHIP *pChip		= &pCtrl->chip;
    PCMCIA_CARD *pCard;
    PCMCIA_ADAPTER *pAdapter 	= NULL;
    int sock;
    int ix;


    pcmciaMsgQId = msgQCreate (PCMCIA_MAX_MSGS, sizeof(PCMCIA_MSG), MSG_Q_FIFO);

    if (pcmciaMsgQId == NULL)
	return (ERROR);

    pcmciadId = taskSpawn ("tPcmciad", pcmciadPriority,
			   pcmciadOptions, pcmciadStackSize,
			   (FUNCPTR) pcmciad, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

    if (pcmciadId == ERROR)
	return (ERROR);

    for (ix = 0; ix < pcmciaAdapterNumEnt; ix++)
	{
        pAdapter = &pcmciaAdapter[ix];
        if ((* pAdapter->initRtn) (pAdapter->ioBase,
				   pAdapter->intVec,
				   pAdapter->intLevel,
				   pAdapter->showRtn) == OK)
	    break;
	}

    if (ix >= pcmciaAdapterNumEnt)
	return (ERROR);

    semMInit (&cisMuteSem, SEM_Q_PRIORITY | SEM_DELETE_SAFE |
	      SEM_INVERSION_SAFE);

    (void) intConnect ((VOIDFUNCPTR *)INUM_TO_IVEC(pAdapter->intVec),
		       (VOIDFUNCPTR)pcmciaCscIntr, 0);

    if (pCtrl->socks != 0)		/* if explicitely defined, use it */
        pChip->socks = pCtrl->socks;

    for (sock = 0; sock < pChip->socks; sock++)
	{
	pCard = &pCtrl->card[sock];

	if ((pCard->cardStatus = (* pChip->status) (sock)) & PC_IS_CARD)
	    (void) cisGet (sock);

        (void) (* pChip->cscPoll) (sock);
        (void) (* pChip->cscOn) (sock, pChip->intLevel);
	}

    sysIntEnablePIC (pAdapter->intLevel);

    return (OK);
    }
/*
 *      isrFetch()
 */
static myISR *isrFetch(unsigned vectorNumber)
{
    myISR   *psub;
    myISR   *pCISR;
    void    *pParam;
    int s;

    /*
     * fetch the handler or C stub attached at this vector
     */
    psub = (myISR *) intVecGet((FUNCPTR *)INUM_TO_IVEC(vectorNumber));

    if ( psub ) {
        /*
         * from libvxWorks/veclist.c
         *
         * checks to see if it is a C ISR
         * and if so finds the function pointer and
         * the parameter passed
         */
        s = cISRTest(psub, &pCISR, &pParam);
        if(!s){
            psub = pCISR;
        }
    }

    return psub;
}
/*
 *
 *  vxDevDisconnectInterruptVME()
 *
 *  wrapper to minimize driver dependency on vxWorks
 *
 *  The parameter pFunction should be set to the C function pointer that 
 *  was connected. It is used as a key to prevent a driver from removing 
 *  an interrupt handler that was installed by another driver
 *
 */
static long vxDevDisconnectInterruptVME (
    unsigned vectorNumber,
    void (*pFunction)() 
)
{
    void (*psub)();
    int status;

#   if CPU_FAMILY == PPC
        return S_dev_vecInstlFail;
#   endif

    /*
     * If pFunction not connected to this vector
     * then they are probably disconnecting from the wrong vector
     */
    psub = isrFetch(vectorNumber);
    if(psub != pFunction){
        return S_dev_vectorNotInUse;
    }

    status = intConnect(
            (void *)INUM_TO_IVEC(vectorNumber),
            unsolicitedHandlerEPICS,
            (int) vectorNumber);        
    if(status<0){
        return S_dev_vecInstlFail;
    }

    return 0;
}
Esempio n. 6
0
/* Connect ISR to its PCI interrupt vector. */
static
int vxworksDevPCIConnectInterrupt(
  const epicsPCIDevice *dev,
  void (*pFunction)(void *),
  void  *parameter,
  unsigned int opt
)
{
    struct osdPCIDevice *osd=pcidev2osd(dev);
    int status;

   /* Get the IRQ number from the PCI device structure
    * and use it to get the interrupt number from the translation table
    * (if there is one). If there is no translation table, or the table
    * is too small, just use the irq as the interrupt number.
    */
    unsigned char irq = osd->dev.irq;
    if (inumTableSize && (irq < inumTableSize))
        irq = inumTable[(int)irq];

   /* Attempt to connect the interrupt vector.  Abort on failure.
    */
    status = CallPciIntConnect ((VOIDFUNCPTR *)INUM_TO_IVEC(VXPCIINTOFFSET+irq),
                                pFunction, (int)parameter);
    if(status)
        return S_dev_vecInstlFail;

    return 0;
}
Esempio n. 7
0
File: sis3803.c Progetto: cjpl/midas
/************ INLINE function for General command ***********/
INLINE void sis3803_int_detach(const DWORD base_adr, DWORD base_vect, int level)
/**************************************************************\
 Purpose: Unbook an ISR for a bitwise set of interrupt input (0xff).
          The interrupt vector is then the VECTOR_BASE+intnum
 Input:
  DWORD * base_addr       : base address of the sis3803
  DWORD base_vect        : base vector of the module
  int   level            : IRQ level (1..7)
 Output:
    none
 Function value:
    none
\**************************************************************/
{

   /* disable all IRQ sources */
/*  Should be done but not in detach 
  sis3803_int_source(base_adr   , DISABLE_IRQ_DI_BS0
		    | DISABLE_IRQ_DI_BS1
		    | DISABLE_IRQ_DI_BS2);
*/

#ifdef OS_VXWORKS
/* Suppose to save the default isr before attach but would
 * required isr table in case of multiple IRQ
 * for now restore with myStub()
 */
   intConnect(INUM_TO_IVEC(base_vect), (VOIDFUNCPTR) myStub_sis3803, 0);
   sysIntDisable(level);        /* interrupt level */
#else
   printf("vector : 0x%x\n", base_vect + intnum);
#endif
}
void sysSerialHwInit2 (void)
{
    int i;
	for (i = 0; i < AMBA_UART_CHANNELS_NUM; i++)
	{
		(void)intConnect (INUM_TO_IVEC(dev_paras[i].vector),
				   balongv7r2_uart_irq_handler, (int) &amba_chan[i] );
		(void)intEnable ((int)dev_paras[i].int_level);
    }
}
void main (void)
{
	unsigned char tempOut;
	/* Connect interrupt service routine to vector and all stuff */
	intConnect (INUM_TO_IVEC(aioIntNum), my_ISR, aioIntNum);
	sysIntEnablePIC (aioIRQNum);
	/* Enable interrupts on the aio:
	* All interrupts and interrupt from counter 1 too */
	tempOut = 0x24;
	sysOutByte (aioBase + intEnAddress, tempOut);
	
	/* Start counter 1 as timer with 50 ms period 
	* It has a clock input of 1 MHz = 1 µs 
	* Therefore the load value is 0xC350 = 50000 */
	tempOut = 0x74;
	sysOutByte (aioBase + cntCntrlReg, tempOut);
	tempOut = 0x50;
	sysOutByte (aioBase + cnt1Address, tempOut);
	tempOut = 0xC3;
	sysOutByte (aioBase + cnt1Address, tempOut);

	/* Add your code here: create tasks, semaphores, ... */
	//printf("Hello World!");
	
	/*The second task shall do the following:
	 *	- It starts counter a as an auto-reload timer with a period of 50 ms.
	 *	- The interrupt generated by this counter activates the task.
	 *		This shall be done with a semaphore.
	 *	- The task reads the analog inputs of both the potentiometer and the temperature.
	 *	- If the values have changed compared to the previous ones, these shall be written into global
	 *		variables (AIn).
	 *	- A hysteresis of e.g. 10 – 20 bit is necessary due to the noise of the analog inputs.
	 * 
	 * */
	initHardware(0);
	
	int readTask;
	readTask = taskSpawn("tRead", 101, 0, 0x1000, (FUNCPTR) tRead,0,0,0,0,0,0,0,0,0,0);
	
	timIntSem = semBCreate(SEM_Q_PRIORITY, SEM_EMPTY);
	
	/* The third task shall do the following:
	 *	- It writes the values of the global variables (AIn) onto the display.
	 *	- This shall happen approx. each 100 ms
	 */
	int writeTask;
	writeTask = taskSpawn("tWrite",102,0,0x1000, (FUNCPTR) tWrite,0,0,0,0,0,0,0,0,0,0);
	
	/* Suspend own task */
	taskSuspend (0);	//suspended sich selber
} /* main */
Esempio n. 10
0
/******************************************************************************
**  Function:  CFE_PSP_Init1HzTone()
**
**  Purpose:
**    Initializes the 1Hz Tone interrupt
**
**  Arguments:
**
**  Return:
**
*/
void CFE_PSP_Init1HzTone()
{
    uint32 val;
    uint32 tone1HzPin = (1 << 7); /* GPIO0_7 */

    val = am335xInLong (AM335X_GPIO0_BASE + AM335X_GPIO_IRQSTATUS_SET1);
    am335xOutLong (AM335X_GPIO0_BASE + AM335X_GPIO_IRQSTATUS_SET1, val | tone1HzPin);

    val = am335xInLong (AM335X_GPIO0_BASE + AM335X_GPIO_RISINGDETECT);
    am335xOutLong (AM335X_GPIO0_BASE + AM335X_GPIO_RISINGDETECT, val | tone1HzPin);

    intConnect((VOIDFUNCPTR *)INUM_TO_IVEC (AM335X_GPIOINT0B), CFE_PSP_ToneISR, 0);
    intEnable(AM335X_GPIOINT0B);
}
Esempio n. 11
0
STATUS sysScsiInit (VOID)
    {
#ifdef INCLUDE_AIC_7880

    AIC7880_INFO *aicResource;

    aicResource = &aic7880InfoTable;

    /* Create the SCSI controller */

    if ((pSysScsiCtrl = (SCSI_CTRL *) aic7880CtrlCreate 
        (aicResource->pciBus, aicResource->pciDevice, 
        SCSI_DEF_CTRL_BUS_ID)) == NULL)
        {
	logMsg ("Could not create SCSI controller\n", 
	         0, 0, 0, 0, 0, 0);
	return (ERROR);
	}
	
    /* connect the SCSI controller's interrupt service routine */
	
    if ((pciIntConnect (INUM_TO_IVEC (INT_NUM_GET (aicResource->irq)),
                        aic7880Intr, (int) pSysScsiCtrl)) == ERROR)
        {
        logMsg ("Failed to connect interrupt\n",
                 0, 0, 0, 0, 0, 0);
	return (ERROR);
        }

    sysIntEnablePIC((int) aicResource->irq) ;

#endif /* INCLUDE_AIC_7880 */

#ifdef  INCLUDE_TAPEFS
    tapeFsInit ();      /* initialize tape file system */
#endif /* INCLUDE_TAPEFS */

#ifdef INCLUDE_CDROMFS
    cdromFsInit ();     /* include CD-ROM file system */
#endif /* INCLUDE_CDROMFS */

    return (OK);
    }
Esempio n. 12
0
/*
 * devConnectInterruptVME
 *
 * wrapper to minimize driver dependency on vxWorks
 */
static long vxDevConnectInterruptVME (
    unsigned vectorNumber,
    void (*pFunction)(),
    void  *parameter)
{
    int status;


    if (vxDevInterruptInUseVME(vectorNumber)) {
        return S_dev_vectorInUse; 
    }
    status = intConnect(
            (void *)INUM_TO_IVEC(vectorNumber),
            pFunction,
            (int) parameter);       
    if (status<0) {
        return S_dev_vecInstlFail;
    }

    return 0;
}
Esempio n. 13
0
PUBLIC IX_STATUS
ixOsalIrqUnbind (UINT32 irqLevel)
{
    /*
     * disable interrupts for this vector 
     */
    if (intDisable (IVEC_TO_INUM (irqLevel)) != OK)
    {
        return IX_FAIL;
    }

    /*
     * register a dummy ISR 
     */
    if (intConnect (INUM_TO_IVEC(irqLevel), 
	           (IxOsalVoidFnVoidPtr) ixOsalDummyIsr, 0) != OK)
    {
        return IX_FAIL;
    }
    return IX_SUCCESS;
}
void sysSerialHwInit2 (void)
{
    int i;

	AT91DBGUDevInit2( &at91DBGUChan );

    for (i = 0; i < N_SIO_CHANNELS; i++)
	{
		/*
		 * Connect and enable the interrupt.
		 * We would like to check the return value from this and log a message
		 * if it failed. However, logLib has not been initialised yet, so we
		 * cannot log a message, so there's little point in checking it.
		 * URAT still in quiet state
		 */
		(void) intConnect ( INUM_TO_IVEC(devParas[i].vector),
				   AT91UartInt, (UINT32) &at91UartChan[i] );
		
		intEnable (devParas[i].intLevel);
		AT91UartDevInit2( &at91UartChan[i] );
	}
}
Esempio n. 15
0
int readInputs (void)
{
	unsigned char tempOut;
	/* Connect interrupt service routine to vector and all stuff */
	intConnect (INUM_TO_IVEC(aioIntNum), my_ISR, aioIntNum);
	sysIntEnablePIC (aioIRQNum);
	/* Enable interrupts on the aio:
	* All interrupts and interrupt from counter 1 too */
	tempOut = 0x24;
	sysOutByte (aioBase + intEnAddress, tempOut);
	/* Start counter 1 as timer with 50 ms period 
	* It has a clock input of 1 MHz = 1 µs 
	* Therefore the load value is 0xC350 = 50000 */
	tempOut = 0x74;
	sysOutByte (aioBase + cntCntrlReg, tempOut);
	tempOut = 0x50;
	sysOutByte (aioBase + cnt1Address, tempOut);
	tempOut = 0xC3;
	sysOutByte (aioBase + cnt1Address, tempOut);
	
	int poti;
	int temp;
	int hyst = 15;
	
	while(1){
		semTake (analogInputs, WAIT_FOREVER);
		poti =  readAnalog (2, 0);
		temp =  readAnalog (5, 2);
		//printf ("Werte %d %d \n", poti, temp);
		if  ((poti > globalPoti+hyst) | (poti < globalPoti-hyst))
		{
			globalPoti = poti;
		}
		if  ((temp > globalTemp+hyst) | (temp < globalTemp-hyst))
		{
			globalTemp = temp;
		}
	}
}
Esempio n. 16
0
PUBLIC IX_STATUS
ixOsalIrqBind (UINT32 irqLevel, IxOsalVoidFnVoidPtr routine, void *parameter)
{

#if((CPU==SIMSPARCSOLARIS) || (CPU==SIMLINUX))
    /*
     * No Irq support in simulation env 
     */
    return IX_FAIL;
#else
    if (intConnect
        (INUM_TO_IVEC(irqLevel),
	(IxOsalVoidFnVoidPtr) routine, 
	(int) parameter) != OK)
    {
        return IX_FAIL;
    }
    intEnable (irqLevel);
    return IX_SUCCESS;

#endif

}
Esempio n. 17
0
File: vmeio.c Progetto: cjpl/midas
INLINE void vmeio_int_detach(const DWORD base_adr, DWORD base_vect, int intnum)
/**************************************************************\
 Purpose: Unbook an ISR for a bitwise set of interrupt input (0xff).
          The interrupt vector is then the VECTOR_BASE+intnum
 Input:
  DWORD * base_addr       : base address of the VMEIO
  DWORD base_vect        : base vector of the module
  DWORD intnum           : interrupt number (0:7)
 Output:
    none
 Function value:
    none
\**************************************************************/
{
   vmeio_int_clear(base_adr);   /* clear any pending front panel interrupts */
   vmeio_int_disable(base_adr, intnum); /* mask off external interrupt x */
#ifdef OS_VXWORKS
   if (intnum < 8)
      intConnect(INUM_TO_IVEC(base_vect + intnum), (VOIDFUNCPTR) myStub, intnum);
#else
   printf("vector : 0x%x\n", base_vect + intnum);
#endif
}
Esempio n. 18
0
File: sis3803.c Progetto: cjpl/midas
/************ INLINE function for General command ***********/
INLINE void sis3803_int_attach(const DWORD base_adr, DWORD base_vect, int level,
                               void (*isr) (void))
/**************************************************************\
 Purpose: Book an ISR for a bitwise set of interrupt input (0xff).
          The interrupt vector is then the VECTOR_BASE+intnum
 Input:
  DWORD * base_addr      : base address of the sis3803
  DWORD base_vect        : base vector of the module
  int   level            : IRQ level (1..7)
  DWORD isr_routine      : interrupt routine pointer
 Output:
    none
 Function value:
    none
\**************************************************************/
{
   volatile DWORD *spec_adr;

   /* disable all IRQ sources */
/*  Should be done but not in attach 
  sis3803_int_source(base_adr
			     , DISABLE_IRQ_DI_BS0
			     | DISABLE_IRQ_DI_BS1
			     | DISABLE_IRQ_DI_BS2);
*/

#ifdef OS_VXWORKS
   if ((level < 8) && (level > 0) && (base_vect < 0x100)) {
      spec_adr = (DWORD *) (A32D24 + base_adr + IRQ_REG);
      *spec_adr = (level << 8) | VME_IRQ_ENABLE | base_vect;
      sysIntEnable(level);      /* interrupt level */
   }
   intConnect(INUM_TO_IVEC(base_vect), (VOIDFUNCPTR) isr, 0);
#else
   printf("Not implemented for this OS\n");
#endif
}
Esempio n. 19
0
void sysPciPirqShow (void)
    {

#   if defined (INCLUDE_ICH2) || defined (INCLUDE_ICH3)

    {
    INT32 ix;

    /* show the PIRQ[A-H] - IRQ[0-15] routing table */

    for (ix = 0; ix < N_IOAPIC_PIRQS; ix++)
	{
        printf ("PIRQ%c: offset=0x%04x, PIRQ=0x%02x, IRQ=0x%02x\n",
	    'A' + ix,
            sysPciPirqTbl[ix].offset,
            sysPciPirqTbl[ix].pirq,
            sysPciPirqTbl[ix].irq);
	}
    }

#   endif /* defined (INCLUDE_ICH2) || defined (INCLUDE_ICH3) */

#   ifdef INCLUDE_UNKNOWN_MOTHER

    {
    INT32 ix;

    /* show the network device table */

    for (ix = 0; ix < sysPciNnets; ix++)
	{
        printf ("bus=0x%04x dev=0x%04x venId=0x%04x "
            "devId=0x%04x intPin=0x%02x intLine=0x%02x\n",
            sysPciNetTbl[ix].pciBus,
            sysPciNetTbl[ix].pciDev,
            sysPciNetTbl[ix].vendorId,
            sysPciNetTbl[ix].deviceId,
            sysPciNetTbl[ix].intPin,
            sysPciNetTbl[ix].intLine);
	}
    }

#   elif defined (INCLUDE_D815EEA) || defined (INCLUDE_D850GB)

    {
    INT32 pciBusSlot	= MOTHER_PCI_BUSNO_SLOT;
    INT32 pciFuncSlot	= MOTHER_PCI_FUNCNO_SLOT;
    FUNCPTR defIsr;	/* ISR of the default IRQ */
    FUNCPTR curIsr;	/* ISR of the current IRQ */
    INT32 idtType;	/* IDT type */
    INT32 selector;	/* CS selector */
    INT32 vendorId;	/* PCI vendor Id */
    UINT8 intPin;	/* PCI INT[A-D] from PCI Int Pin Reg */
    UINT8 defIrq;	/* default IRQ */
    UINT8 curIrq;	/* current IRQ */
    UINT8 pirq;		/* PIRQ[n] */
    INT32 ix;

    for (ix = 0; ix < N_PCI_SLOTS; ix++)
	{
	/* skip if the slot is empty */

        pciConfigInLong (pciBusSlot, sysPciSlotTbl[ix], pciFuncSlot, 
			 PCI_CFG_VENDOR_ID, &vendorId);

	if ((vendorId & 0x0000ffff) == 0x0000ffff)
	    {
	    printf ("slot %d: empty \n", ix);
	    continue;
	    }

	/* get the PCI INT[A-D] and IRQ[0-15] of the device */

        pciConfigInByte (pciBusSlot, sysPciSlotTbl[ix], pciFuncSlot, 
	    PCI_CFG_DEV_INT_PIN, &intPin);
        pciConfigInByte (pciBusSlot, sysPciSlotTbl[ix], pciFuncSlot, 
	    PCI_CFG_DEV_INT_LINE, &curIrq);

	/* get the PIRQ[A-H] of the device */

	pirq = sysPciIntTbl[ix][intPin - 1];

	/* if sysPciPirqTbl[] table is not initialized, use the curIrq */

	defIrq = sysPciPirqTbl[pirq - IOAPIC_PIRQA_INT_LVL].irq; 

	/* get the default Isr and current Isr */

	intVecGet2 ((FUNCPTR *)INUM_TO_IVEC (INT_NUM_GET (defIrq)), 
	    &defIsr, &idtType, &selector);
	intVecGet2 ((FUNCPTR *)INUM_TO_IVEC (INT_NUM_GET (curIrq)), 
	    &curIsr, &idtType, &selector);

	/* show the default IRQ and the current IRQ setting */

	printf ("slot %d: def-IRQ(ISR) = 0x%04x(0x%08x)  "
		"cur-IRQ(ISR) = 0x%04x(0x%08x)\n",
		ix, defIrq, (int)defIsr, curIrq, (int)curIsr);
	}
    }

#   endif /* INCLUDE_UNKNOWN_MOTHER */

    }
Esempio n. 20
0
/* This is needed by the GNAT run time to handle Vxworks interrupts.  */
void *
__gnat_inum_to_ivec (int num)
{
  return INUM_TO_IVEC (num);
}
int probe1()
{
    unsigned int pciBusNo, pciDevNo, pciFuncNo;
    unsigned char byte;
   /* int           i,j;*/
    UINT32 s_pBA0, s_pBA1;

    /* To ensure that taskDelay(1) is 1ms delay */
    sysClkRateSet(1000);
    if (pciConfigLibInit (PCI_MECHANISM_1, 0xCF8, 0xCFC, 0) != OK) {
	printf("PCI lib config error\n");
	return 1;
    }

    /****************************
     * Find SoundCard
     * Set  BaseAddr0, BaseAddr1
     ****************************/
    if(!(pciFindDevice(PCI_VENDOR_ID_CIRRUS,PCI_DEVICE_ID_CRYSTAL_CS4281,
		       0, &pciBusNo, &pciDevNo, &pciFuncNo)==OK)) {
	printf("\n CS4281 sound card NOT FOUND!!! \n");
	return 1;
    }

    printf("\n FOUND CS4281 sound card, configuring BA0,BA1... \n");    
    pciConfigOutLong( pciBusNo, pciDevNo, pciFuncNo,
		      PCI_CFG_BASE_ADDRESS_0, CS4281_pBA0);
    /*
    pciConfigOutLong( pciBusNo, pciDevNo, pciFuncNo,
		      PCI_CFG_BASE_ADDRESS_1, CS4281_pBA1);
    */
    pciConfigInLong( pciBusNo, pciDevNo, pciFuncNo,
		     PCI_CFG_BASE_ADDRESS_0, &s_pBA0);
    pciConfigInLong( pciBusNo, pciDevNo, pciFuncNo,
		     PCI_CFG_BASE_ADDRESS_1, &s_pBA1 );
    printf ("\npBusNo    pDeviceNo  pFuncNo  pBA0      pBA1\n\n");
    printf ("%.8x  %.8x  %.8x  %.8x  %.8x \n",
	    pciBusNo, pciDevNo, pciFuncNo, s_pBA0,s_pBA1); 


    

    /********************************
     * Config PCI Device Capability
     *     DMA Master
     *     MEM mapped
     ********************************/

    /* Set the INTA vector */
    pciConfigInByte(pciBusNo, pciDevNo, pciFuncNo,
		    PCI_CFG_DEV_INT_LINE, &cs4281_irq);
    printf("\nFound CS4281 configured for IRQ %d\n", cs4281_irq);
    
    pciConfigInByte(pciBusNo, pciDevNo, pciFuncNo,
		    PCI_CFG_DEV_INT_PIN, &byte);
    printf("\tINT_PIN=%.8x\n", byte);

    /* Enable the device's capabilities as specified
     * Bus Master Enable/ Mem Space Enable */
    pciConfigOutWord(pciBusNo, pciDevNo, pciFuncNo, PCI_CFG_COMMAND,
		     (unsigned short)0x0006);

    
    /***************************
     * BringUp Hardware 
     ***************************/
    /*Include Init Function Here*/
    cs4281_hw_init();

    /****************************
     * Allocate ADC_BUFFER
     * Allocate DAC_BUFFER
     *
     * Hook cs4281_interrupt
     *
     * Program CoDec
     ****************************/
    if((DAC_BUFFER=valloc(DAC_BUFFER_SIZE))==NULL) {
       printf("\n DAC_BUFFER valloc failed!\n");
       return 1;
       
    }
    memset( DAC_BUFFER, 0, DAC_BUFFER_SIZE );
    printf("\ndac=%x",DAC_BUFFER);
    /*for( i=0 ; i < DAC_BUFFER_SIZE  ; i++ )
        ((char *)DAC_BUFFER)[i]=0x7f;*/

    writel((UINT32)DAC_BUFFER+8,CS4281_pBA0 + BA0_DBA0);
    writel(DAC_BUFFER_SIZE-16, CS4281_pBA0 + BA0_DBC0);
    printf("\nbao=%x",readl(CS4281_pBA0 + BA0_DBA0));
    printf("\nbco=%x",readl(CS4281_pBA0 + BA0_DBC0));
    printf("\ncco=%x",readl(CS4281_pBA0 + BA0_DCC0));
    if((ADC_BUFFER=valloc(ADC_BUFFER_SIZE))==NULL) {
       printf("\n ADC_BUFFER valloc failed!\n");
       return 1;
    }
    printf("\nadc=%x",ADC_BUFFER);
    /*for( i=0 ; i < ADC_BUFFER_SIZE  ; i++ )
        ((char *)ADC_BUFFER)[i]=0x7f;*/

    writel((UINT32)ADC_BUFFER+8,CS4281_pBA0 + BA0_DBA1);
    writel(ADC_BUFFER_SIZE-16, CS4281_pBA0 + BA0_DBC1);
    
    /* connect interrupt */
    printf("\n Hook cs4281_interrupt to vector %d\n",
	   (INUM_TO_IVEC (cs4281_irq+INT_NUM_IRQ0)));
    pciIntConnect((INUM_TO_IVEC (cs4281_irq+INT_NUM_IRQ0)),
		(VOIDFUNCPTR)cs4281_interrupt, 0);
    sysIntEnablePIC(cs4281_irq);
    
    SEM_DMA_Playback = semBCreate(SEM_Q_FIFO,SEM_EMPTY);
    SEM_MY_Playback = semBCreate(SEM_Q_FIFO,SEM_EMPTY);
    SEM_DMA_Record = semBCreate(SEM_Q_FIFO,SEM_EMPTY);
    SEM_Sample = semBCreate(SEM_Q_FIFO,SEM_EMPTY);

    CNT_DMA_Playback = CNT_DMA_Record = 0;
    
    /* program coDec */
    printf("\n Program CoDec (sample rate, DMA...)\n");
    prog_codec();


    /*********************************************
     *  start dac/adc, interrupt is comming...
     *********************************************/
    start_dac();
  	return 0;
}
Esempio n. 22
0
int rapiInit(pwr_tUInt8* pRapiDPMBase, int irq)
{
#if 0
   RAPI_HEADER*   pRapiHeader;
   RAPI_DEV*      pRapiDevtab;
   RAPI_IMREG*    pRapiImReg;
#endif
   if(cRapi >= NUM_RAPI - 1)	                          /* No free rapi module block's */
   {

#ifdef DEBUG
      printf("rapiInit: no free rapi module block\n");
#endif
      return(RAPI_ERR);
   }

   pRapiHeader = (RAPI_HEADER *) pRapiDPMBase;          /* Setup RAPI header pointer */

#ifdef DEBUG
   printf("rapiInit: pRapiDPMBase = 0x%x\n", (unsigned int) pRapiDPMBase);
   printf("Id 0 : %d\n", pRapiHeader->rapiId[0]);     /* Printout of RAPI ID */
   printf("Id 0 : %d\n", pRapiHeader->rapiId[1]);
   printf("Id 0 : %d\n", pRapiHeader->rapiId[2]);
   printf("Id 0 : %d\n", pRapiHeader->rapiId[3]);
#endif

   if((pRapiHeader->rapiId[0] != 'R') ||   	         /* Test for valid RAPI ID structure */
      (pRapiHeader->rapiId[1] != 'A') ||
      (pRapiHeader->rapiId[2] != 'P') ||
      (pRapiHeader->rapiId[3] != 'I') )
   {

#ifdef DEBUG
      printf("rapiInit: ""RAPI"" string missing in header\n");
#endif
      return(RAPI_ERR);
   }

   if(pRapiHeader->crc != rapiCrcCalc(pRapiDPMBase))  /* Check CRC */
   {

#ifdef DEBUG
      printf("rapiInit: crc error\n");
#endif
      return(RAPI_ERR);
   }

#ifdef DEBUG
   printf("RAPI rev %d\n", pRapiHeader->rapiRev);
   printf("Module ID %d, Nr %d, Rev %d\n", pRapiHeader->modId,
           pRapiHeader->modNr, pRapiHeader->modRev);
#endif

   pRapiDevtab = (RAPI_DEV *)&pRapiDPMBase[wordSwapChk(pRapiHeader->devtab)];   /* Get pointer to device table */
   pRapiImReg = (RAPI_IMREG *)&pRapiDPMBase[wordSwapChk(pRapiHeader->vectab)];  /* Get pointer to interrupt vector table */

#ifdef DEBUG
   printf("rapiInit: pRapiDevtab = 0x%x\n", (unsigned int) pRapiDevtab);
   printf("rapiInit: pRapiImReg = 0x%x\n", (unsigned int) pRapiImReg);
#endif

   rapiModule[cRapi].pRapiDPM    = pRapiDPMBase;      /* Store pointer to Dual Ported Memory */
   rapiModule[cRapi].pRapiHeader = pRapiHeader;       /* Store pointer to RAPI_HEADER */
   rapiModule[cRapi].pRapiDevtab = pRapiDevtab;       /* Store pointer to RAPI_DEV */
   rapiModule[cRapi].pRapiImReg  = pRapiImReg;        /* Store pointer to RAPI_IMREG */

#if 0    /* Obsolete in Lynx/SSPA case !?!? */

   pRapiImReg->irqVec1 = irq;
   pRapiImReg->irqVec2 = irq;

   intConnect(INUM_TO_IVEC(irq), rapiInt, (unsigned int) cRapi);

#endif   /* Obsolete in Lynx/SSPA case !?!? */

   rapiModeSet(cRapi, RAPI_RESET);                    /* Initialize to RESET mode */

   cRapi++;                                           /* Increment initialized module count */

   return(cRapi - 1);                                 /* Return index for the module we just initialized */
}
Esempio n. 23
0
int pci_int_connect(int intLine,
		    pci_isr_t isr,
		    void *isr_data)
{
#if !defined(NEGEV)
    extern int sysVectorIRQ0;
#endif

#if defined(NSX) || defined(GTO) || defined(METROCORE)
    int i;
#endif
  
    debugk(DK_PCI,
	   "pci_int_connect: intLine=%d, isr=%p, isr_data=%p\n",
	   intLine, (void *)isr, (void *)isr_data);

#if defined(NSX) || defined(METROCORE)
    /* all int lines */
    for (i = 0; i < 4; i++) {
        /* printk("pciIntConnect int line = %d\n", intLine + i); */
        if (pciIntConnect ((VOIDFUNCPTR *)
                     INUM_TO_IVEC(sysVectorIRQ0 + intLine + i),
                     (VOIDFUNCPTR) isr,
                     PTR_TO_INT(isr_data)) != OK) {
            return -1;
        }
    }
    return 0;
#endif

#if defined(GTO)
    for (i = 0; i < 4; i++) {
        /* PCI interrupts are connected at external interrupt
         * 0, 1, 2, and 3.
         */ 
        if (pciIntConnect ((VOIDFUNCPTR *)
                     INUM_TO_IVEC(sysVectorIRQ0 + i),
                     (VOIDFUNCPTR) isr,
                     PTR_TO_INT(isr_data)) != OK) {
            return -1;
        }

        if (intEnable(sysVectorIRQ0 + i) == ERROR) {
	    return -1;
        }
    }
    return 0;
#endif

#if !defined (NEGEV)
    if (pciIntConnect ((VOIDFUNCPTR *)
		       INUM_TO_IVEC(sysVectorIRQ0 + intLine),
		       (VOIDFUNCPTR) isr,
		       PTR_TO_INT(isr_data)) != OK) {
      return -1;
    }
#endif

#if (CPU_FAMILY != PPC) && !defined(IDTRP334) && \
    !defined(MBZ) && !defined(IDT438) && !defined(NSX) && !defined(ROBO_4704) \
    && !defined(ROBO_4702) && !defined(RAPTOR) && !defined(METROCORE) \
    && !defined(KEYSTONE)
    if (sysIntEnablePIC(intLine) == ERROR) {
	return -1;
    }
#endif
    
#if (CPU_FAMILY == PPC)
    if (intEnable(intLine) != OK) {
	return -1;
    }
#endif /* (CPU_FAMILY == PPC) */

    return 0;
}
Esempio n. 24
0
//STATUS dac3550DevCreate (char *devName, int port, int irq)
DEV_HDR* dac3550DevCreate (char *devName, int port, int irq)
{
  SND_DEV *pDev;

  if (DrvNum < 1)
  {
    errno = S_ioLib_NO_DRIVER;
    return ERROR;
  }
  if(dac3550Dev) 
  	return &(dac3550Dev->devHdr);
  pDev = (SND_DEV *)malloc (sizeof(SND_DEV));
  if (!pDev) return 0;

  bzero ((char *)pDev, sizeof(SND_DEV));
  if(port==0) port = (int)AT91C_BASE_SSC1;
  if(irq==0) irq = AT91C_ID_SSC1;
  pDev->port   = port;
  pDev->irq    = irq;
/*  pDev->dma8   = dma8;
  pDev->dma16  = dma16;
*/
  pDev->devSem = semBCreate (SEM_Q_FIFO, SEM_FULL);
  pDev->intSem = semCCreate (SEM_Q_FIFO, 0);
  pDev->bufSem = semCCreate (SEM_Q_FIFO, MAX_DMA_MSGS);
  pDev->dmaQ   = msgQCreate (MAX_DMA_MSGS, sizeof (DMA_MSG), MSG_Q_FIFO);

  pDev->dmaIndex = 0;

  if (createDmaBuffer () < 0)
  {
    free (pDev);
    return 0;
  }

  if (dsp_init (pDev) < 0)
  {
    free (pDev);
    return 0;
  }



  if (iosDevAdd (&pDev->devHdr, devName, DrvNum) == ERROR)
  {
    free ((char *)pDev);
    return 0;
  }
/*
  pDev->tid = taskSpawn ("tSndTask", TASK_PRIORITY, TASK_OPTIONS,
			 TASK_STACK_SIZE, dspHelperTask, (int)pDev,
			 0, 0, 0, 0, 0, 0, 0, 0, 0);

  if (pDev->tid == ERROR)
  {
    free (pDev);
    return ERROR;
  }
*/
  intConnect (INUM_TO_IVEC (	(irq)), dspInterrupt, (int)pDev);
  dac3550Dev = pDev;
  return &(pDev->devHdr);
}
Esempio n. 25
0
/*
 *
 * veclist()
 *
 */
int veclist(int all)
{
  	int		vec;
	int		value;
	SYM_TYPE	type;
	char		name[MAX_SYS_SYM_LEN];
	char		function_type[10];
	FUNCPTR		proutine;
	FUNCPTR		pCISR;
	int		cRoutine;
	void		*pparam;
	int		status;
	unsigned	i;

  	for(vec=0; vec<NVEC; vec++){
    		proutine = intVecGet((FUNCPTR *)INUM_TO_IVEC(vec));

		status = cISRTest(proutine, &pCISR, &pparam);
		if(status == OK){
			cRoutine = TRUE;
			proutine = pCISR;
			strcpy(function_type, "C");
		}
		else{
			cRoutine = FALSE;
			strcpy(function_type, "MACRO");
			pCISR = NULL;
		}
 
		status = symFindByValue(
				sysSymTbl, 
				(int)proutine, 
				name,
				&value,
				&type);
		if(status<0 || value != (int)proutine){
			sprintf(name, "0x%X", (unsigned int) proutine);
		}
		else if(!all){
			int	match = FALSE;

			for(i=0; i<NELEMENTS(ignore_list); i++){
				if(!strcmp(ignore_list[i],name)){
					match = TRUE;
					break;
				}
			}
			if(match){
				continue;
			}
		}
       		printf(	"vec 0x%02X %5s ISR %s", 
			vec, 
			function_type,
			name);
		if(cRoutine){
			printf("(0x%X)", (unsigned int) pparam);
		}
		printf("\n");
	}

	return OK;
}