static bool interrupt_init(void) { if(used_irq != 0xff) return true; if(irq_InstallISR(GetMCIRQ(), user_int, (void*)name) == false) { printf("irq_install fail\n"); return false; } used_irq = GetMCIRQ(); return true; }
static bool interrupt_init(int mc) { if(used_irq != 0xff) return true; if(irq_InstallISR(GetMCIRQ(), user_int, (void*)name) == false) { printf("irq_install fail\n"); return false; } // enable mcm general interrupt function mc_outp(MC_GENERAL, 0x38, mc_inp(MC_GENERAL, 0x38) & ~(1L << mc)); used_irq = GetMCIRQ(); return true; }
DMPAPI(int) interrupt_init(void) { #if defined (DMP_LINUX) OSSPININIT(idc.spinlock); for(int i = 0; i < INTERRUPTS; i++) idc.intr[i].used = false; int err = pthread_create(&idc.thread, NULL, intrMain, NULL); if(err != 0) printf("failed to create the thread\n"); return 0; #elif defined (DMP_DOS_DJGPP) if(used_irq != 0xff) return 0; if(irq_InstallISR(GetMCIRQ(), user_int, (void*)name) == false) { printf("irq_install fail\n"); return -1; } used_irq = GetMCIRQ(); return 0; #endif }
static bool interrupt_init(void) { if(used_irq != 0xff) return true; if(irq_Init() == false) { printf("irq_init fail\n"); return false; } if(irq_Setting(GetMCIRQ(), IRQ_LEVEL_TRIGGER + IRQ_DISABLE_INTR) == false) { printf("%s\n", __FUNCTION__); return false; } if(irq_InstallISR(GetMCIRQ(), user_int, (void*)name) == false) { printf("irq_install fail\n"); return false; } //printf("BaseAddr = %08lxh irq = %d\n\n", mc_setbaseaddr(), GetMCIRQ()); //Master_DX2(); used_irq = GetMCIRQ(); Set_MCIRQ(used_irq); return true; }
void RTCZero::enableAlarm(uint8_t match) { unsigned char tmp; if(RTCZeroInit == false) return; if(RTCZeroEnable == false) { if(irq_Setting(RTCIRQ, IRQ_EDGE_TRIGGER) == false) { printf("MCM IRQ Setting fail\n"); return; } if(irq_InstallISR(RTCIRQ, rtczero_isr_handler, isrname_rtc) == false) { printf("irq_install fail\n"); return; } } io_DisableINT(); alarmType = match; if(alarmType == ALARMSEC) { outpb_cmos(0x03, inpb_cmos(0x02)); outpb_cmos(0x05, inpb_cmos(0x04)); } else if(alarmType == ALARMMINSEC) { outpb_cmos(0x05, inpb_cmos(0x04)); } tmp = inpb_cmos(0x0B); outpb_cmos(0x0B, tmp | 0x20); // Alarm interrupt io_RestoreINT(); RTCZeroEnable = true; }
DMPAPI(bool) usb_Init(void *vusb) { #if defined DMP_DOS_DJGPP static bool locked = false; int size_temp; #endif USB_Device *usb = (USB_Device *)vusb; if (usb->InUse == 1) return true; // if (USB_IsAttached() == false) return false; USB_Connect(); if (irq_Init() == false) { err_print((char*)"%s: IRQ init fail.\n", __FUNCTION__); io_Close(); return false; } #if defined DMP_DOS_DJGPP if (locked == false) { int i, str_size; DPMI_LOCK_FUNC(SetEPnDLR); DPMI_LOCK_FUNC(Set_Address); DPMI_LOCK_FUNC(Get_Descriptor); DPMI_LOCK_FUNC(Set_Descriptor); DPMI_LOCK_FUNC(Get_Configuration); DPMI_LOCK_FUNC(Set_Configuration); DPMI_LOCK_FUNC(Get_Interface); DPMI_LOCK_FUNC(Set_Interface); DPMI_LOCK_FUNC(Synch_Frame); DPMI_LOCK_FUNC(USB_Standard_Request); DPMI_LOCK_FUNC(Set_Line_Coding); DPMI_LOCK_FUNC(Get_Line_Coding); DPMI_LOCK_FUNC(Set_Control_Line_State); DPMI_LOCK_FUNC(Send_Break); DPMI_LOCK_FUNC(USB_CDC_Request); DPMI_LOCK_FUNC(EP0_SetupHandler); DPMI_LOCK_FUNC(EP0_InHandler); DPMI_LOCK_FUNC(EP0_OutHandler); DPMI_LOCK_FUNC(EP1_InHandler); DPMI_LOCK_FUNC(EP2_InHandler); DPMI_LOCK_FUNC(EP2_OutHandler); DPMI_LOCK_FUNC(usb_Reset); DPMI_LOCK_FUNC(USB_ISR); DPMI_LOCK_VAR(desc_Device); DPMI_LOCK_VAR(desc_Config_Set); DPMI_LOCK_VAR(StringDescTable[0]); DPMI_LOCK_VAR(StringDescTable[1]); DPMI_LOCK_VAR(StringDescTable[2]); DPMI_LOCK_VAR(StringDescTable[3]); DPMI_LOCK_VAR(StringDescTable[4]); DPMI_LOCK_VAR(StringDescTable[5]); DPMI_LOCK_VAR(StringDescTable[6]); locked = true; } #endif io_outpb(usb->CFR, 0x02); // Soft reset while (io_inpb(usb->CFR) & 0x02); if ((usb->EP[0].SetupBuf = (BYTE *)ker_Malloc(sizeof(BYTE)*EP0_MAX_PACKET_SIZE)) == NULL) goto EP0_SETUP_FAIL; if ((usb->EP[0].InBuf = (BYTE *)ker_Malloc(sizeof(BYTE)*EP0_MAX_PACKET_SIZE)) == NULL) goto EP0_IN_FAIL; if ((usb->EP[0].OutBuf = (BYTE *)ker_Malloc(sizeof(BYTE)*EP0_MAX_PACKET_SIZE)) == NULL) goto EP0_OUT_FAIL; if ((usb->EP[1].InBuf = (BYTE *)ker_Malloc(sizeof(BYTE)*EP1_MAX_PACKET_SIZE_IN)) == NULL) goto EP1_IN_FAIL; if ((usb->EP[2].InBuf = (BYTE *)ker_Malloc(sizeof(BYTE)*EP2_MAX_PACKET_SIZE_IN)) == NULL) goto EP2_IN_FAIL; if ((usb->EP[2].OutBuf = (BYTE *)ker_Malloc(sizeof(BYTE)*EP2_MAX_PACKET_SIZE_OUT)) == NULL) goto EP2_OUT_FAIL; #if defined DMP_DOS_DJGPP if ((dma_handle = dma_Alloc(EP0_MAX_PACKET_SIZE + EP0_MAX_PACKET_SIZE + EP0_MAX_PACKET_SIZE + EP1_MAX_PACKET_SIZE_IN + EP2_MAX_PACKET_SIZE_IN + EP2_MAX_PACKET_SIZE_OUT, &dma_addr)) == DMA_FAIL) goto EP2_OUT_FAIL; size_temp = 0; usb->EP[0].SetupPhysical = dma_addr; usb->EP[0].InPhysical = dma_addr + (size_temp += EP0_MAX_PACKET_SIZE); usb->EP[0].OutPhysical = dma_addr + (size_temp += EP0_MAX_PACKET_SIZE); usb->EP[1].InPhysical = dma_addr + (size_temp += EP0_MAX_PACKET_SIZE); usb->EP[2].InPhysical = dma_addr + (size_temp += EP1_MAX_PACKET_SIZE_IN); usb->EP[2].OutPhysical = dma_addr + (size_temp += EP2_MAX_PACKET_SIZE_IN); #else usb->EP[0].SetupPhysical = GrabPhysicalMEM((void *)usb->EP[0].SetupBuf); usb->EP[0].InPhysical = GrabPhysicalMEM((void *)usb->EP[0].InBuf); usb->EP[0].OutPhysical = GrabPhysicalMEM((void *)usb->EP[0].OutBuf); usb->EP[1].InPhysical = GrabPhysicalMEM((void *)usb->EP[1].InBuf); usb->EP[2].InPhysical = GrabPhysicalMEM((void *)usb->EP[2].InBuf); usb->EP[2].OutPhysical = GrabPhysicalMEM((void *)usb->EP[2].OutBuf); #endif // usb->DevAddr = 0x00; // usb->ReadySetAddr = false; // io_outpb(usb->DAR, 0x00); // enable USB device io_outpdw(usb->EP[0].SetupDSR, usb->EP[0].SetupPhysical); io_outpdw(usb->EP[0].InDSR , usb->EP[0].InPhysical); io_outpdw(usb->EP[0].OutDSR , usb->EP[0].OutPhysical); io_outpdw(usb->EP[1].InDSR , usb->EP[1].InPhysical); io_outpdw(usb->EP[2].InDSR , usb->EP[2].InPhysical); io_outpdw(usb->EP[2].OutDSR , usb->EP[2].OutPhysical); io_outpw(usb->EP[0].CtrlTR , 0x2000 | EP0_MAX_PACKET_SIZE); io_outpw(usb->EP[1].InTR , 0x3800 | EP1_MAX_PACKET_SIZE_IN); io_outpw(usb->EP[2].InTR , 0x3000 | EP2_MAX_PACKET_SIZE_IN); io_outpw(usb->EP[2].OutTR , 0x3000 | EP2_MAX_PACKET_SIZE_OUT); SetEPnDLR(usb, EP0, SETUP, ENABLE); // io_outpb(usb->DAR, 0x80); // enable USB device // while (!(io_inpb(usb->DAR) & 0x80)); // ClearQueue(usb->rcvd); // ClearQueue(usb->xmit); // io_DisableINT(); // { // io_outpb(usb->CFR, io_inpb(usb->CFR) & 0xFE); // io_outpdw(usb->IER, ISOF + IBRST + ISUSP + IRESM + SYSERR + // IEP0SETUP + IEP0RX + IEP0TX + IEP1TX + IEP2RX + IEP2TX); // io_outpb(usb->CFR, io_inpb(usb->CFR) | 0x01); // } // io_RestoreINT(); // usb->state = USB_DEV_DEFAULT; io_outpb(usb->DAR, 0x80); // enable USB device while (!(io_inpb(usb->DAR) & 0x80)); io_outpdw(usb->ISR, 0xFFFFFFFFL); io_DisableINT(); { io_outpb(usb->CFR, io_inpb(usb->CFR) & 0xFE); irq_Setting(usb->nIRQ, IRQ_LEVEL_TRIGGER); irq_InstallISR(usb->nIRQ, USB_ISR, (void *)usb); io_outpdw(usb->IER, ISOF + IBRST + ISUSP + IRESM + SYSERR + IEP0SETUP + IEP0RX + IEP0TX + IEP1TX + IEP2RX + IEP2TX); io_outpb(usb->CFR, io_inpb(usb->CFR) | 0x01); } io_RestoreINT(); usb->state = USB_DEV_POWERED; usb->InUse = 1; return true; EP2_OUT_FAIL: ker_Mfree(usb->EP[2].InBuf); EP2_IN_FAIL: ker_Mfree(usb->EP[1].InBuf); EP1_IN_FAIL: ker_Mfree(usb->EP[0].OutBuf); EP0_OUT_FAIL: ker_Mfree(usb->EP[0].InBuf); EP0_IN_FAIL: ker_Mfree(usb->EP[0].SetupBuf); EP0_SETUP_FAIL: err_print((char*)"%s: Alloc endpoint buffers error!!\n", __FUNCTION__); irq_Close(); io_Close(); return false; }