STATUS sysRtl81x9IntEnable ( int level /* level number */ ) { return (sysIntEnablePIC(level)); }
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); }
void sysHwInit( void ) { #ifdef INCLUDE_MMU int i; PHYS_MEM_DESC *pVm; /* Initialize number of virtual memory descriptos */ pVm = &sysPhysMemDesc[0]; /* For all virtual memory descriptos */ for (i = 0; i < NELEMENTS(sysPhysMemDesc); i++) { if ((int) pVm->vAddr != (int) VM_INVALID_ADDR) { pVm++; } else { break; } } /* Store number of descriptors */ sysPhysMemDescNumEntries = i; #endif /* INCLUDE_MMU */ sysIntInitPIC(); sysIntEnablePIC(PIT0_INT_LVL); }
void sysSerialHwInit2 ( void ) { int i; for (i = 0; i < N_UART_CHANNELS; i++) { if (i8250Chan[i].int_vec != 0) { intConnectDefault(i8250Chan[i].int_vec, i8250Int, &i8250Chan[i]); sysIntEnablePIC(devParams[i].intLevel); } } }
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 */
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); }
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; } } }
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; }
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; }
int i8042MseDevCreate( char *name ) { int result; int drvNum; I8042_MSE_DEVICE *pDev; drvNum = iosDrvInstall( (FUNCPTR) i8042MseOpen, (FUNCPTR) i8042MseDelete, (FUNCPTR) i8042MseOpen, (FUNCPTR) i8042MseClose, (FUNCPTR) i8042MseRead, (FUNCPTR) i8042MseWrite, (FUNCPTR) i8042MseIoctl ); if (drvNum == ERROR) { result = ERROR; } else { pDev = (I8042_MSE_DEVICE *) malloc(sizeof(I8042_MSE_DEVICE)); if (pDev == NULL) { result = ERROR; } else { if (tyDevInit( &pDev->tyDev, 512, 512, (FUNCPTR) i8042MseTxStart) != OK) { free(pDev); result = ERROR; } else { /* Initialize device registers */ pDev->dataReg = I8042_KBD_DATA_REG; pDev->statReg = I8042_KBD_STAT_REG; pDev->cmdReg = I8042_KBD_CMD_REG; /* Connect interrupt handler */ intConnectDefault(I8042_MSE_INT, (VOIDFUNCPTR) i8042Intr, pDev); i8042MseHwInit(pDev); /* Enable interrupt level */ sysIntEnablePIC(I8042_MSE_INT_LVL); if (iosDevAdd(&pDev->tyDev.devHeader, name, drvNum) != OK) { free(pDev); result = ERROR; } else { result = drvNum; } } } } return result; }