static void process_msg_connect(IVShmemState *s, uint16_t posn, int fd, Error **errp) { Peer *peer = &s->peers[posn]; int vector; /* * The N-th connect message for this peer comes with the file * descriptor for vector N-1. Count messages to find the vector. */ if (peer->nb_eventfds >= s->vectors) { error_setg(errp, "Too many eventfd received, device has %d vectors", s->vectors); close(fd); return; } vector = peer->nb_eventfds++; IVSHMEM_DPRINTF("eventfds[%d][%d] = %d\n", posn, vector, fd); event_notifier_init_fd(&peer->eventfds[vector], fd); fcntl_setfl(fd, O_NONBLOCK); /* msix/irqfd poll non block */ if (posn == s->vm_id) { setup_interrupt(s, vector, errp); /* TODO do we need to handle the error? */ } if (ivshmem_has_feature(s, IVSHMEM_IOEVENTFD)) { ivshmem_add_eventfd(s, posn, vector); } }
int tmlib_init (void) { #ifdef SFS_WANTED clock_t init_ticks = times (NULL); init_scheduler (); create_parent_task (init_ticks); create_idle_task (); init_soft_irq (); init_io (); #endif mem_init (); msg_Q_init (); init_timer_mgr (); #ifdef SFS_WANTED setup_interrupt (); #endif return 0; }
void CAN::attach(void (*fptr)(void)) { if (fptr != NULL) { _rxirq.attach(fptr); setup_interrupt(); } else { remove_interrupt(); } }
int main() { //Game Init setup_interrupt(); initializeGame(); pSramAliens = sram_malloc(sizeof(struct Alien) * (ALIEN_COLS * ALIEN_ROWS)); int pSramBulletBuffer = sram_malloc((sizeof(struct Projectile) * (ALIEN_COLS * ALIEN_WIDTH * VOID_HEIGHT)) + sizeof(struct Projectile)); //New Game gameOver = 0; unsigned int gameStartTime = *game_time; unsigned int previousUpdateBoard = *game_time; unsigned int previousUpdateBullets = *game_time; initRandomAliens(pSramAliens); initProjectileBuffer(pSramBulletBuffer); pBuffer = calloc(TRANSMIT_BUFFER_SIZE, sizeof(char)); pBufferHead = pBuffer; pTransmit = pBuffer; *data_bus_output = 0xFF; //Game Event Loop while(1) { if(gameOver) { if(gameOver == 1) { printf("\nAliens Win!\n"); } else if(gameOver ==2) { printf("\nGunner Win!\n"); } return 0; } if(((*game_time) - previousUpdateBoard) > 10) { alienShift = ((*game_time) / 10) % 8; updateDisplay(pSramAliens, pSramBulletBuffer, gunnerX, (*game_time) % 2, alienShift); previousUpdateBoard = (*game_time); } if(((*game_time) - previousUpdateBullets) > 5) { updateProjectileNodes(); previousUpdateBullets = (*game_time); } /*moveGunnerLeft(&gunnerX); moveGunnerRight(&gunnerX); shootAliens();*/ } return 0; }
static int __init ptp_ixp_init(void) { if (!cpu_is_ixp46x()) return -ENODEV; ixp_clock.regs = (struct ixp46x_ts_regs __iomem *) IXP4XX_TIMESYNC_BASE_VIRT; ixp_clock.caps = ptp_ixp_caps; ixp_clock.ptp_clock = ptp_clock_register(&ixp_clock.caps, NULL); if (IS_ERR(ixp_clock.ptp_clock)) return PTR_ERR(ixp_clock.ptp_clock); ixp46x_phc_index = ptp_clock_index(ixp_clock.ptp_clock); __raw_writel(DEFAULT_ADDEND, &ixp_clock.regs->addend); __raw_writel(1, &ixp_clock.regs->trgt_lo); __raw_writel(0, &ixp_clock.regs->trgt_hi); __raw_writel(TTIPEND, &ixp_clock.regs->event); if (MASTER_IRQ != setup_interrupt(MASTER_GPIO)) { pr_err("failed to setup gpio %d as irq\n", MASTER_GPIO); goto no_master; } if (SLAVE_IRQ != setup_interrupt(SLAVE_GPIO)) { pr_err("failed to setup gpio %d as irq\n", SLAVE_GPIO); goto no_slave; } return 0; no_slave: free_irq(MASTER_IRQ, &ixp_clock); no_master: ptp_clock_unregister(ixp_clock.ptp_clock); return -ENODEV; }
int main(void) { int status; //Configure the IIC data structure IicConfig(XPAR_XIICPS_0_DEVICE_ID); //Configure the Audio Codec's PLL AudioPllConfig(); //Configure the Line in and Line out ports. //Call LineInLineOutConfig() for a configuration that //enables the HP jack too. AudioConfigureJacks(); xil_printf("ADAU1761 configured\n\r"); // Setup the FIR instances status=hls_voicerec_init(&HlsVoiceRec); if(status != XST_SUCCESS){ print("HLS peripheral setup failed\n\r"); return(-1); } //Setup the interrupt status = setup_interrupt(); if(status != XST_SUCCESS){ print("Interrupt setup failed\n\r"); return(-1); } // Enable Global and instance interrupts XVoicerec_InterruptEnable(&HlsVoiceRec,1); XVoicerec_InterruptGlobalEnable(&HlsVoiceRec); ResultAvailHlsVoiceRec = 0; run_voice_recognition(); // switch SW0 to record 2 second command return 0; }
int main() { //fcntl(STDIN_FILENO, F_SETFL, O_NONBLOCK); //FOR NIOS //fcntl(STDIN_FILENO, F_SETFL, O_NONBLOCK); //Tests //sram_malloc_test(); //sram_free_test(); //Game Init setup_interrupt(); initializeGame(); pSramAliens = sram_malloc(sizeof(struct Alien) * (ALIEN_COLS * ALIEN_ROWS)); int pSramBulletBuffer = sram_malloc((sizeof(struct Projectile) * (ALIEN_COLS * ALIEN_WIDTH * VOID_HEIGHT)) + sizeof(struct Projectile)); //printf("%i\n", sizeof(struct Projectile) * (ALIEN_COLS * ALIEN_WIDTH * VOID_HEIGHT)); //New Game gameOver = 0; unsigned int gameStartTime = *game_time; unsigned int previousUpdateBoard = *game_time; unsigned int previousUpdateBullets = *game_time; initRandomAliens(pSramAliens); initProjectileBuffer(pSramBulletBuffer); pBuffer = calloc(TRANSMIT_BUFFER_SIZE, sizeof(char)); pBufferHead = pBuffer; pTransmit = pBuffer; *data_bus_output = 0xAF; //while(1); char hello[20] = "Hello, world! abc123"; int i; for(i = 0; i < 20; i++) { writeBuffer(hello[i]); } transmitIfBufferNotEmpty(); //Game Event Loop while(1) { if(gameOver) { if(gameOver == 1) { printf("\nAliens Win!\n"); } else if(gameOver ==2) { printf("\nGunner Win!\n"); } return 0; } //gameOver =1; if(((*game_time) - previousUpdateBoard) > 10) { alienShift = ((*game_time) / 10) % 8; //alienShift = 2; updateDisplay(pSramAliens, pSramBulletBuffer, gunnerX, (*game_time) % 2, alienShift); previousUpdateBoard = (*game_time); //printf("GunnerX: %i\n", gunnerX); } if(((*game_time) - previousUpdateBullets) > 5) { updateProjectileNodes(); previousUpdateBullets = (*game_time); } moveGunnerLeft(&gunnerX); moveGunnerRight(&gunnerX); //shootGunner(&gunnerX); shootAliens(); } return 0; }
static void ivshmem_read(void *opaque, const uint8_t *buf, int size) { IVShmemState *s = opaque; int incoming_fd; int new_eventfd; int64_t incoming_posn; Error *err = NULL; Peer *peer; if (!fifo_update_and_get_i64(s, buf, size, &incoming_posn)) { return; } if (incoming_posn < -1) { IVSHMEM_DPRINTF("invalid incoming_posn %" PRId64 "\n", incoming_posn); return; } /* pick off s->server_chr->msgfd and store it, posn should accompany msg */ incoming_fd = qemu_chr_fe_get_msgfd(s->server_chr); IVSHMEM_DPRINTF("posn is %" PRId64 ", fd is %d\n", incoming_posn, incoming_fd); /* make sure we have enough space for this peer */ if (incoming_posn >= s->nb_peers) { if (resize_peers(s, incoming_posn + 1) < 0) { error_report("failed to resize peers array"); if (incoming_fd != -1) { close(incoming_fd); } return; } } peer = &s->peers[incoming_posn]; if (incoming_fd == -1) { /* if posn is positive and unseen before then this is our posn*/ if (incoming_posn >= 0 && s->vm_id == -1) { /* receive our posn */ s->vm_id = incoming_posn; } else { /* otherwise an fd == -1 means an existing peer has gone away */ IVSHMEM_DPRINTF("posn %" PRId64 " has gone away\n", incoming_posn); close_peer_eventfds(s, incoming_posn); } return; } /* if the position is -1, then it's shared memory region fd */ if (incoming_posn == -1) { void * map_ptr; if (memory_region_is_mapped(&s->ivshmem)) { error_report("shm already initialized"); close(incoming_fd); return; } if (check_shm_size(s, incoming_fd, &err) == -1) { error_report_err(err); close(incoming_fd); return; } /* mmap the region and map into the BAR2 */ map_ptr = mmap(0, s->ivshmem_size, PROT_READ|PROT_WRITE, MAP_SHARED, incoming_fd, 0); if (map_ptr == MAP_FAILED) { error_report("Failed to mmap shared memory %s", strerror(errno)); close(incoming_fd); return; } memory_region_init_ram_ptr(&s->ivshmem, OBJECT(s), "ivshmem.bar2", s->ivshmem_size, map_ptr); qemu_set_ram_fd(s->ivshmem.ram_addr, incoming_fd); vmstate_register_ram(&s->ivshmem, DEVICE(s)); IVSHMEM_DPRINTF("guest h/w addr = %p, size = %" PRIu64 "\n", map_ptr, s->ivshmem_size); memory_region_add_subregion(&s->bar, 0, &s->ivshmem); return; } /* each peer has an associated array of eventfds, and we keep * track of how many eventfds received so far */ /* get a new eventfd: */ if (peer->nb_eventfds >= s->vectors) { error_report("Too many eventfd received, device has %d vectors", s->vectors); close(incoming_fd); return; } new_eventfd = peer->nb_eventfds++; /* this is an eventfd for a particular peer VM */ IVSHMEM_DPRINTF("eventfds[%" PRId64 "][%d] = %d\n", incoming_posn, new_eventfd, incoming_fd); event_notifier_init_fd(&peer->eventfds[new_eventfd], incoming_fd); fcntl_setfl(incoming_fd, O_NONBLOCK); /* msix/irqfd poll non block */ if (incoming_posn == s->vm_id) { setup_interrupt(s, new_eventfd); } if (ivshmem_has_feature(s, IVSHMEM_IOEVENTFD)) { ivshmem_add_eventfd(s, incoming_posn, new_eventfd); } }