STATIC int pkt_preinit(void) { int rv; /* Start BCM RX and packet processing */ if ((rv = rx_start()) < 0) { return -1; } if (!cputrans_tx_setup_done()) { rv = cputrans_tx_pkt_setup(100, &bcm_trans_ptr); if (rv < 0) { cli_out("ERROR: cputrans TX setup failed: %s\n", bcm_errmsg(rv)); return -1; } } if (!cputrans_rx_setup_done()) { rv = cputrans_rx_pkt_setup(-1, NULL); /* Use defaults */ if (rv < 0) { cli_out("ERROR: cputrans RX setup failed: %s\n", bcm_errmsg(rv)); return -1; } } return 0; }
void h8_sci_device::rx_done() { if(!(ssr & SSR_FER)) { if((smr & SMR_PE) && rx_parity) { ssr |= SSR_PER; logerror("%s: Recieve parity error\n", tag()); } else if(ssr & SSR_RDRF) { ssr |= SSR_ORER; logerror("%s: Recieve overrun\n", tag()); } else { ssr |= SSR_RDRF; logerror("%s: Recieved %02x\n", tag(), rsr); rdr = rsr; } } if(scr & SCR_RIE) { if(has_recv_error()) intc->internal_interrupt(eri_int); else intc->internal_interrupt(rxi_int); } if((scr & SCR_RE) && !has_recv_error() && !is_sync_start()) rx_start(); else { clock_stop(CLK_RX); rx_state = ST_IDLE; } }
void h8_sci_device::rx_done() { if(!(ssr & SSR_FER)) { if((smr & SMR_PE) && rx_parity) { ssr |= SSR_PER; if(V>=1) logerror("Receive parity error\n"); } else if(ssr & SSR_RDRF) { ssr |= SSR_ORER; if(V>=1) logerror("Receive overrun\n"); } else { ssr |= SSR_RDRF; if(V>=1) logerror("Received %02x '%c'\n", rsr, rsr >= 32 && rsr < 127 ? rsr : '.'); rdr = rsr; } } if(scr & SCR_RIE) { if(has_recv_error()) intc->internal_interrupt(eri_int); else intc->internal_interrupt(rxi_int); } if((scr & SCR_RE) && !has_recv_error() && !is_sync_start()) rx_start(); else { clock_stop(CLK_RX); rx_state = ST_IDLE; } }
static void rs_start(struct tty_struct *tty) { struct s3c3410_serial *info = (struct s3c3410_serial *) tty->driver_data; unsigned long flags = 0; if (serial_paranoia_check(info, tty->device, "rs_start")) return; save_flags(flags); cli(); rx_start(info->use_ints); tx_start(info->use_ints); restore_flags(flags); }
void h8_sci_device::tx_start() { ssr |= SSR_TDRE; tsr = tdr; tx_parity = smr & SMR_OE ? 0 : 1; logerror("%s: start transmit %02x\n", tag(), tsr); if(scr & SCR_TIE) intc->internal_interrupt(txi_int); if(smr & SMR_CA) { tx_state = ST_BIT; tx_bit = 8; } else { tx_state = ST_START; tx_bit = 1; } clock_start(CLK_TX); if(rx_state == ST_IDLE && !has_recv_error() && is_sync_start()) rx_start(); }
/* create filesystem menu content */ struct animenucontext *animenu_createfilesystem(char *path, char *regex, char *command, int recurse) { struct animenucontext *menu; struct animenuitem *item; DIR *d = NULL; struct stat statbuf; struct dirent *dirent; char *title, *commandall; char pathbase[BUFSIZE + 1], pathcur[BUFSIZE + 1]; unsigned int size; struct files { char file[PATH_MAX + 1]; struct files *next; } *filecur, *fileroot = NULL, *fileprev = NULL; if (path) /* path already set, so use that */ _strncpy(pathbase, path, BUFSIZE + 1); else { if (regex == NULL) { fprintf(stderr, "cannot set base path"); return(FALSE); } else if (*regex != '/') { fprintf(stderr, "cannot set base path from '%s', ensure it is fully qualified", regex); return(FALSE); } /* set base path */ _strncpy(pathbase, regex, BUFSIZE + 1); char *rxs; if (rx_start(pathbase, &rxs)) *rxs = '\0'; /* return pointer to last occurence of char in array * and use this to terminate the string */ *strrchr(pathbase, '/') = '\0'; } if (!(d = opendir(pathbase))) { fprintf(stderr, "invalid base path '%s'", pathbase); return(FALSE); } /* fail if we can't allocate enough memory for the menu struct (known size) */ if (!(menu = malloc(sizeof(struct animenucontext)))) return(FALSE); memset(menu, 0, sizeof(struct animenucontext)); /* function pointers */ menu->dispose = animenu_disposemenu; menu->next = animenu_next; menu->prev = animenu_prev; menu->show = animenu_show; menu->showcurrent = animenu_showcurrent; menu->hide = animenu_hide; menu->additem = animenu_additem; menu->firstitem = NULL; menu->currentitem = NULL; menu->osd = NULL; for (*pathcur = '\0'; (dirent = readdir(d));) { /* use 'back' navigation to move up through the file hierarchy instead */ if (!strcmp(dirent->d_name, "..") || !strcmp(dirent->d_name, ".")) continue; /* set 'cur' as the current full path for consideration */ snprintf(pathcur, BUFSIZE + 1, "%s/%s", pathbase, dirent->d_name); if (stat(pathcur, &statbuf) != -1) { if (S_ISREG(statbuf.st_mode)) { if (!rx_compare(pathcur, regex)) { /* match the regex path */ if (!(filecur = malloc(sizeof(struct files)))) continue; if (fileroot == NULL) fileroot = filecur; else fileprev->next = filecur; /* copy the path into the file struct's file variable */ _strncpy(filecur->file, pathcur, BUFSIZE + 1); filecur->next = NULL; fileprev = filecur; } } else if (S_ISDIR(statbuf.st_mode) || S_ISLNK(statbuf.st_mode)) { if (recurse) ; /* no-op */ else { /* add the dir/link regardless of match */ if (!(filecur = malloc(sizeof(struct files)))) continue; if (fileroot == NULL) fileroot = filecur; else fileprev->next = filecur; /* copy the path into our struct's file variable */ _strncpy(filecur->file, pathcur, BUFSIZE + 1); filecur->next = NULL; fileprev = filecur; } } } } closedir(d); /* create the browse menu's items * either 'command' items or 'browse' (menu) items */ if (!*pathcur) { menu->dispose(menu); return(FALSE); } if (fileroot) { /* get the final size for the command + args string */ for (size = strlen(command) + 1, filecur = fileroot; filecur != NULL; filecur = filecur->next) size += strlen(filecur->file) + 3; if (!(commandall = malloc(size + 1))) { menu->dispose(menu); return(FALSE); } _strncpy(commandall, command, size); for (filecur = fileroot; filecur != NULL; filecur = filecur->next) { _strncat(commandall, " \"", size); _strncat(commandall, filecur->file, size); _strncat(commandall, "\"", size); } item = animenu_createitem(animenuitem_command, (char*)playall, NULL, NULL, commandall, 0); menu->additem(menu, item); for (filecur = fileroot; filecur != NULL; filecur = filecur->next) { title = strrchr(filecur->file, '/'); stat(filecur->file, &statbuf); if (S_ISREG(statbuf.st_mode)) { /* create command item */ snprintf(commandall, size, "%s \"%s\"", command, filecur->file); item = animenu_createitem(animenuitem_command, ++title, NULL, NULL, commandall, 0); menu->additem(menu, item); } else if (S_ISDIR(statbuf.st_mode) || S_ISLNK(statbuf.st_mode)) { /* create menu item */ item = animenu_createitem(animenuitem_filesystem, title, filecur->file, regex, command, recurse); menu->additem(menu, item); } } } else { /* create empty item for empty menu */ item = animenu_createitem(animenuitem_null, NULL, NULL, NULL, NULL, 0); menu->additem(menu, item); } return(menu); }