//main function int main (int argc, char* argv[]) { ENTER(); PROGRESS("Create the wpa_supplicant mgr"); wpaHandle mgrHandle = wpa_supplicant_mgr_Init(); if (!mgrHandle){ ALLOC_FAIL("mgrHandle"); EXIT_WITH_ERROR(); return -1; } PROGRESS("Start the Manager Operation"); wpa_supplicant_mgr_Start(mgrHandle); //This function will not return until operation is complete //Perform needed Cleanup //The program enters here before it exits PROGRESS("Cleanup: Stop and Destroy the Mgr"); wpa_supplicant_mgr_Stop(mgrHandle); wpa_supplicant_mgr_Destroy (mgrHandle); EXIT(); return 0; }
void VideoConsumer::HandleEvent(const media_timed_event* event, bigtime_t lateness, bool realTimeEvent) { LOOP("VideoConsumer::HandleEvent\n"); switch (event->type) { case BTimedEventQueue::B_START: PROGRESS("VideoConsumer::HandleEvent - START\n"); _SetPerformanceTimeBase(event->event_time); break; case BTimedEventQueue::B_WARP: case BTimedEventQueue::B_SEEK: PROGRESS("VideoConsumer::HandleEvent - WARP or SEEK\n"); _SetPerformanceTimeBase(event->bigdata); break; case BTimedEventQueue::B_STOP: PROGRESS("VideoConsumer::HandleEvent - STOP\n"); EventQueue()->FlushEvents(event->event_time, BTimedEventQueue::B_ALWAYS, true, BTimedEventQueue::B_HANDLE_BUFFER); // unset the target's bitmap _UnsetTargetBuffer(); break; case BTimedEventQueue::B_HANDLE_BUFFER: LOOP("VideoConsumer::HandleEvent - HANDLE BUFFER\n"); _HandleBuffer(static_cast<BBuffer*>(event->pointer)); break; default: ERROR("VideoConsumer::HandleEvent - BAD EVENT\n"); break; } }
void hd_scan_sysfs_pci(hd_data_t *hd_data) { if(!hd_probe_feature(hd_data, pr_pci)) return; hd_data->module = mod_pci; /* some clean-up */ remove_hd_entries(hd_data); hd_data->pci = NULL; PROGRESS(1, 0, "sysfs drivers"); hd_sysfs_driver_list(hd_data); PROGRESS(2, 0, "get sysfs pci data"); hd_pci_read_data(hd_data); if(hd_data->debug) dump_pci_data(hd_data); add_pci_data(hd_data); PROGRESS(3, 0, "macio"); hd_read_macio(hd_data); PROGRESS(3, 0, "vio"); hd_read_vio(hd_data); }
void hd_scan_mouse(hd_data_t *hd_data) { ser_device_t *sm, *sm_next; if(!hd_probe_feature(hd_data, pr_mouse)) return; hd_data->module = mod_mouse; /* some clean-up */ remove_hd_entries(hd_data); hd_data->ser_mouse = NULL; #if 0 PROGRESS(1, 0, "ps/2"); get_ps2_mouse(hd_data); #endif PROGRESS(2, 0, "serial"); hd_fork(hd_data, 20, 20); if(hd_data->flags.forked) { get_serial_mouse(hd_data); hd_move_to_shm(hd_data); if((hd_data->debug & HD_DEB_MOUSE)) dump_ser_mouse_data(hd_data); } else { /* take data from shm */ hd_data->ser_mouse = ((hd_data_t *) (hd_data->shm.data))->ser_mouse; if((hd_data->debug & HD_DEB_MOUSE)) dump_ser_mouse_data(hd_data); } hd_fork_done(hd_data); add_serial_mouse(hd_data); hd_shm_clean(hd_data); for(sm = hd_data->ser_mouse; sm; sm = sm_next) { sm_next = sm->next; free_mem(sm->dev_name); free_mem(sm); } hd_data->ser_mouse = NULL; #if 0 PROGRESS(3, 0, "sunmouse"); get_sunmouse(hd_data); #endif }
void at_cmd(hd_data_t *hd_data, char *at, int raw, int log_it) { static unsigned u = 1; char *s, *s0; ser_device_t *sm; str_list_t *sl; int modems = 0; for(sm = hd_data->ser_modem; sm; sm = sm->next) { if(sm->do_io) { sm->buf_len = 0; modems++; } } if(modems == 0) return; PROGRESS(9, u, "write at cmd"); write_modem(hd_data, at); PROGRESS(9, u, "read at resp"); usleep (200000); read_modem(hd_data); PROGRESS(9, u, "read ok"); u++; for(sm = hd_data->ser_modem; sm; sm = sm->next) { if(sm->do_io) { sm->at_resp = free_str_list(sm->at_resp); if(sm->buf_len == 0 || raw) continue; s0 = sm->buf; while((s = strsep(&s0, "\r\n"))) { if(*s) add_str_list(&sm->at_resp, s); } } } if(!(hd_data->debug & HD_DEB_MODEM) || !log_it) return; for(sm = hd_data->ser_modem; sm; sm = sm->next) { if(sm->do_io) { ADD2LOG("%s@%u: %s\n", sm->dev_name, sm->cur_baud, at); if(raw) { ADD2LOG(" "); hexdump(&hd_data->log, 1, sm->buf_len, sm->buf); ADD2LOG("\n"); } else { for(sl = sm->at_resp; sl; sl = sl->next) ADD2LOG(" %s\n", sl->str); } } } }
/* * Try to read block 0 for block devices. */ void int_media_check(hd_data_t *hd_data) { hd_t *hd; int i, j = 0; for(hd = hd_data->hd; hd; hd = hd->next) { if(!hd_report_this(hd_data, hd)) continue; if( hd->base_class.id == bc_storage_device && ( /* hd->sub_class.id == sc_sdev_cdrom || */ /* cf. cdrom.c */ hd->sub_class.id == sc_sdev_disk || hd->sub_class.id == sc_sdev_floppy ) && hd->unix_dev_name && !hd->block0 && !hd->is.notready && hd->status.available != status_no ) { i = 5; PROGRESS(4, ++j, hd->unix_dev_name); hd->block0 = read_block0(hd_data, hd->unix_dev_name, &i); hd->is.notready = hd->block0 ? 0 : 1; } } }
loadmix(char *fnames[], int nscores, double *weights) { if(nscores<2 || nscores>NSCORES) error("Bad number of files\n"); double xty[NSCORES+1]; if(weights) { int j; for(j=0;j<=nscores;j++) xty[j]=weights[j]; } else computemix(fnames, nscores, xty); lg("Mixing coeeficients\n"); int f; for(f=0;f<=nscores;f++) lg("-lew %f ",xty[f]); lg("\n"); FILE *fp[NSCORES]; openfiles(fp,fnames,nscores); int i; for(i=0; i<NENTRIES; i++) { PROGRESS(i,NENTRIES); int r=(userent[i]>>USER_LMOVIEMASK)&7; float s[NSCORES]; readfiles(fp,s,nscores); float stotal=0.; int j; for(j=0;j<nscores;j++) stotal+=xty[j]*(r-s[j]); stotal+=xty[nscores]; err[i]=r-stotal; } closefiles(fp,nscores); }
/*---------------------------------------------------------------------------*/ void write_to_serial(void *inbuf, int len) { u_int8_t *p = inbuf; int i; /*, ecode;*/ /* printf("Got packet of length %d - write SLIP\n", len);*/ /* print_packet(p, len);*/ /* It would be ``nice'' to send a SLIP_END here but it's not * really necessary. */ /* slip_send(outfd, SLIP_END); */ PRINTF("Writing to serial len: %d\n", len); for(i = 0; i < len; i++) { switch(p[i]) { case SLIP_END: slip_send(SLIP_ESC); slip_send(SLIP_ESC_END); break; case SLIP_ESC: slip_send(SLIP_ESC); slip_send(SLIP_ESC_ESC); break; default: slip_send(p[i]); break; } } slip_send(SLIP_END); PROGRESS("t"); }
/* * Try to read block 0 for block devices. */ void int_media_check(hd_data_t *hd_data) { hd_t *hd; int i, j = 0; for(hd = hd_data->hd; hd; hd = hd->next) { if(!hd_report_this(hd_data, hd)) continue; if( hd->base_class.id == bc_storage_device && ( /* hd->sub_class.id == sc_sdev_cdrom || */ /* cf. cdrom.c */ hd->sub_class.id == sc_sdev_disk || hd->sub_class.id == sc_sdev_floppy ) && hd->unix_dev_name && !hd->block0 && !hd->is.notready && hd->status.available != status_no ) { i = 5; PROGRESS(4, ++j, hd->unix_dev_name); hd->block0 = read_block0(hd_data, hd->unix_dev_name, &i); hd->is.notready = hd->block0 ? 0 : 1; #if defined(__i386__) || defined(__x86_64__) if(hd->block0) { ADD2LOG(" mbr sig: 0x%08x\n", edd_disk_signature(hd)); } #endif } } }
void move_default(control_t *control) { velocity_t velocity = MIDDLE * VELOCITY_MODY; angle_t vert_angle = control->vert_angle; //pthread_t tid; void *ret; velocity_t velocitys[2]; velocitys[0] = velocity * cos(vert_angle) * VXY_MODY;//xy velocitys[1] = velocity * sin(vert_angle) * VZ_MODY;//z START_MOVE(); #ifdef DEBUG printw("moving...\n"); #endif //pthread_create(&tid, NULL, move_thread, (void*)&velocitys[0]); //calcu time!!!!!!!!! time_t time = (time_t)(V_T_INDEX * (control->distance/velocity));//V_T_INDEX is used to modify time if (IF_STOP()) return; PROGRESS(DEFAULT_FLAG, DISABLE, FRONT velocitys[0], UP velocitys[1], DISABLE); Sleep(time); //END_MOVE(); //pthread_join(tid, &ret); SIMPLE_HOVERING(); #ifdef DEBUG printw("stop\n"); #endif }
void slip_flushbuf(int fd) { int n; if (slip_empty()) { return; } n = write(fd, slip_buf + slip_begin, (slip_end - slip_begin)); if (n == -1 && errno != EAGAIN) { err(1, "slip_flushbuf write failed"); } else if (n == -1) { PROGRESS("Q"); /* Outqueue is full! */ } else { slip_begin += n; if (slip_begin == slip_end) { slip_begin = slip_end = 0; } } }
void hd_scan_sysfs_pci(hd_data_t *hd_data) { if(!hd_probe_feature(hd_data, pr_pci)) return; hd_data->module = mod_pci; /* some clean-up */ remove_hd_entries(hd_data); hd_data->pci = NULL; PROGRESS(1, 0, "sysfs drivers"); hd_sysfs_driver_list(hd_data); PROGRESS(2, 0, "get sysfs pci data"); hd_pci_read_data(hd_data); if(hd_data->debug) dump_pci_data(hd_data); add_pci_data(hd_data); PROGRESS(3, 0, "macio"); hd_read_macio(hd_data); PROGRESS(4, 0, "vio"); hd_read_vio(hd_data); PROGRESS(5, 0, "xen"); hd_read_xen(hd_data); PROGRESS(6, 0, "ps3"); hd_read_ps3_system_bus(hd_data); PROGRESS(7, 0, "platform"); hd_read_platform(hd_data); PROGRESS(8, 0, "of_platform"); hd_read_of_platform(hd_data); PROGRESS(9, 0, "vm"); hd_read_vm(hd_data); PROGRESS(10, 0, "virtio"); hd_read_virtio(hd_data); }
void hd_scan_sysfs_usb(hd_data_t *hd_data) { if(!hd_probe_feature(hd_data, pr_usb)) return; hd_data->module = mod_usb; /* some clean-up */ remove_hd_entries(hd_data); hd_data->proc_usb = free_str_list(hd_data->proc_usb); hd_data->usb = NULL; PROGRESS(1, 0, "sysfs drivers"); hd_sysfs_driver_list(hd_data); PROGRESS(2, 0, "usb"); get_usb_devs(hd_data); PROGRESS(3, 1, "joydev mod"); load_module(hd_data, "joydev"); PROGRESS(3, 2, "evdev mod"); load_module(hd_data, "evdev"); PROGRESS(3, 3, "input"); get_input_devs(hd_data); PROGRESS(3, 4, "lp"); get_printer_devs(hd_data); PROGRESS(3, 5, "serial"); get_serial_devs(hd_data); }
void hd_scan_sysfs_block(hd_data_t *hd_data) { if(!hd_probe_feature(hd_data, pr_block)) return; hd_data->module = mod_block; /* some clean-up */ remove_hd_entries(hd_data); hd_data->disks = free_str_list(hd_data->disks); hd_data->partitions = free_str_list(hd_data->partitions); hd_data->cdroms = free_str_list(hd_data->cdroms); if(hd_probe_feature(hd_data, pr_block_mods)) { PROGRESS(1, 0, "block modules"); // load_module(hd_data, "ide-cd"); load_module(hd_data, "ide-cd_mod"); load_module(hd_data, "ide-disk"); load_module(hd_data, "sr_mod"); load_module(hd_data, "sd_mod"); #if !defined(__s390__) && !defined(__s390x__) load_module(hd_data, "st"); #endif } PROGRESS(2, 0, "sysfs drivers"); hd_sysfs_driver_list(hd_data); PROGRESS(3, 0, "cdrom"); read_cdroms(hd_data); PROGRESS(4, 0, "partition"); read_partitions(hd_data); PROGRESS(5, 0, "get sysfs block dev data"); get_block_devs(hd_data); if(hd_data->cdrom) { ADD2LOG("oops: cdrom list not empty\n"); } }
void hd_scan_input(hd_data_t *hd_data) { if(!hd_probe_feature(hd_data, pr_input)) return; hd_data->module = mod_input; /* some clean-up */ remove_hd_entries(hd_data); PROGRESS(1, 0, "joydev mod"); load_module(hd_data, "joydev"); PROGRESS(1, 1, "evdev mod"); load_module(hd_data, "evdev"); PROGRESS(2, 0, "input"); get_input_devices(hd_data); }
void *move_thread(void *paras) { velocity_t *velocity = (velocity_t*)paras; while ((!IF_STOP()) && move_tag) { PROGRESS(DEFAULT_FLAG, DISABLE, FRONT velocity[0], UP velocity[1], DISABLE); } SIMPLE_HOVER(); return NULL; }
/* function to write compressed file * @return: total number of written bytes to compressed file i.e. size of compressed file */ f_type write_outfile(char *filename,f_type *freq,struct huffcode *codeTable,struct node *root, f_type total_bytes){ f_type written_bytes=0,read_bytes=0; NODE_PTR(ptr); struct buffer buff={0,-1}; unsigned b; string outfilename=string(filename) + extension; FILE *infile=fopen(filename,"rb"); if(!infile){ fprintf(stderr,"Source file opening error: %s\n",strerror(errno)); return 0; } FILE *outfile=fopen(outfilename.c_str(),"wbx"); for(int i=1;i<=5 && !outfile;i++){ outfilename.insert(outfilename.begin()+outfilename.find_last_of('.'),'1'); outfile=fopen(outfilename.c_str(),"wbx"); } if(!outfile){ fclose(infile); fprintf(stderr,"Destination file opening error: %s\n",strerror(errno)); return 0; } written_bytes=fwrite(freq,sizeof(f_type),TABLE_SIZE,outfile); if(written_bytes==0){ fclose(outfile); fclose(infile); return 0; } while((b=fgetc(infile))!=EOF){ read_bytes++; for(int i=0;i<codeTable[b].length;i++){ buff.byte[++buff.top]=codeTable[b].code[i]; if(buff.top==7){//buffer is full, so write it to file fputc(buff.byte.to_ulong(),outfile); written_bytes++; buff.byte=0; buff.top=-1; } } PROGRESS(read_bytes,total_bytes); } printf("\n"); if(buff.top!=-1){ written_bytes+=2; fputc(buff.byte.to_ulong(),outfile); fputc(buff.top + 1,outfile);//this is length of code in last byte } else{ written_bytes++; fputc(8,outfile);//length of code in last byte is 8 } fclose(infile); fclose(outfile); return written_bytes; }
/*---------------------------------------------------------------------------*/ static void write_to_serial(int outfd, const uint8_t * inbuf, int len) { const uint8_t *p = inbuf; int i; if(slip_config_verbose > 2) { #ifdef __CYGWIN__ printf("Packet from WPCAP of length %d - write SLIP\n", len); #else printf("Packet from TUN of length %d - write SLIP\n", len); #endif if(slip_config_verbose > 4) { #if WIRESHARK_IMPORT_FORMAT printf("0000"); for(i = 0; i < len; i++) printf(" %02x", p[i]); #else printf(" "); for(i = 0; i < len; i++) { printf("%02x", p[i]); if((i & 3) == 3) printf(" "); if((i & 15) == 15) printf("\n "); } #endif printf("\n"); } } /* It would be ``nice'' to send a SLIP_END here but it's not * really necessary. */ /* slip_send(outfd, SLIP_END); */ for(i = 0; i < len; i++) { switch (p[i]) { case SLIP_END: slip_send(outfd, SLIP_ESC); slip_send(outfd, SLIP_ESC_END); break; case SLIP_ESC: slip_send(outfd, SLIP_ESC); slip_send(outfd, SLIP_ESC_ESC); break; default: slip_send(outfd, p[i]); break; } } slip_send(outfd, SLIP_END); PROGRESS("t"); }
void write_to_serial(int outfd, void *inbuf, int len) { u_int8_t *p = inbuf; int i, ecode; struct ip *iphdr = inbuf; /* * Sanity checks. */ ecode = check_ip(inbuf, len); if (ecode < 0) { fprintf(stderr, "tun_to_serial: drop packet %d\n", ecode); return; } if (iphdr->ip_id == 0 && iphdr->ip_off & IP_DF) { uint16_t nid = htons(ip_id++); iphdr->ip_id = nid; nid = ~nid; /* negate */ iphdr->ip_sum += nid; /* add */ if (iphdr->ip_sum < nid) { /* 1-complement overflow? */ iphdr->ip_sum++; } ecode = check_ip(inbuf, len); if (ecode < 0) { fprintf(stderr, "tun_to_serial: drop packet %d\n", ecode); return; } } /* It would be ``nice'' to send a SLIP_END here but it's not * really necessary. */ /* slip_send(outfd, SLIP_END); */ for (i = 0; i < len; i++) { switch (p[i]) { case SLIP_END: slip_send(outfd, SLIP_ESC); slip_send(outfd, SLIP_ESC_END); break; case SLIP_ESC: slip_send(outfd, SLIP_ESC); slip_send(outfd, SLIP_ESC_ESC); break; default: slip_send(outfd, p[i]); break; } } slip_send(outfd, SLIP_END); PROGRESS("t"); }
void hd_scan_modem(hd_data_t *hd_data) { ser_device_t *sm, *sm_next; if(!hd_probe_feature(hd_data, pr_modem)) return; hd_data->module = mod_modem; /* some clean-up */ remove_hd_entries(hd_data); hd_data->ser_modem = NULL; PROGRESS(1, 0, "serial"); hd_fork(hd_data, 15, 120); if(hd_data->flags.forked) { get_serial_modem(hd_data); hd_move_to_shm(hd_data); if((hd_data->debug & HD_DEB_MODEM)) dump_ser_modem_data(hd_data); } else { /* take data from shm */ hd_data->ser_modem = ((hd_data_t *) (hd_data->shm.data))->ser_modem; if((hd_data->debug & HD_DEB_MODEM)) dump_ser_modem_data(hd_data); } hd_fork_done(hd_data); add_serial_modem(hd_data); hd_shm_clean(hd_data); for(sm = hd_data->ser_modem; sm; sm = sm_next) { sm_next = sm->next; free_str_list(sm->at_resp); free_mem(sm->dev_name); free_mem(sm->serial); free_mem(sm->class_name); free_mem(sm->dev_id); free_mem(sm->user_name); free_mem(sm->vend); free_mem(sm->init_string1); free_mem(sm->init_string2); free_mem(sm); } hd_data->ser_modem = NULL; }
void hd_scan_pcmcia(hd_data_t *hd_data) { if(!hd_probe_feature(hd_data, pr_pcmcia)) return; hd_data->module = mod_pcmcia; /* some clean-up */ remove_hd_entries(hd_data); PROGRESS(1, 0, "sysfs drivers"); hd_sysfs_driver_list(hd_data); PROGRESS(2, 0, "pcmcia"); pcmcia_read_data(hd_data); PROGRESS(3, 0, "pcmcia ctrl"); pcmcia_ctrl_read_data(hd_data); }
void write_to_serial(int outfd, void *inbuf, int len) { u_int8_t *p = inbuf; int i; if(verbose>2) { if (timestamp) stamptime(); printf("Packet from TUN of length %d - write SLIP\n", len); if (verbose>4) { printf(" "); for(i = 0; i < len; i++) { printf("%02x", p[i]); if((i & 3) == 3) { printf(" "); } if((i & 15) == 15) printf("\n "); } printf("\n"); } } /* It would be ``nice'' to send a SLIP_END here but it's not * really necessary. */ /* slip_send(outfd, SLIP_END); */ for(i = 0; i < len; i++) { switch(p[i]) { case SLIP_END: slip_send(outfd, SLIP_ESC); slip_send(outfd, SLIP_ESC_END); break; case SLIP_ESC: slip_send(outfd, SLIP_ESC); slip_send(outfd, SLIP_ESC_ESC); break; default: slip_send(outfd, p[i]); break; } } slip_send(outfd, SLIP_END); PROGRESS("t"); }
/*---------------------------------------------------------------------------*/ static void write_to_serial(int outfd, const uint8_t * inbuf, int len) { const uint8_t *p = inbuf; int i; slip_message_sent++; LOG6LBR_PRINTF(PACKET, SLIP_OUT, "write: %d\n", len); if (LOG6LBR_COND(DUMP, SLIP_OUT)) { printf(" "); for(i = 0; i < len; i++) { printf("%02x", p[i]); if((i & 3) == 3) printf(" "); if((i & 15) == 15) printf("\n "); } printf("\n"); } /* It would be ``nice'' to send a SLIP_END here but it's not * really necessary. */ /* slip_send(outfd, SLIP_END); */ for(i = 0; i < len; i++) { switch (p[i]) { case SLIP_END: slip_send(outfd, SLIP_ESC); slip_send(outfd, SLIP_ESC_END); break; case SLIP_ESC: slip_send(outfd, SLIP_ESC); slip_send(outfd, SLIP_ESC_ESC); break; default: slip_send(outfd, p[i]); break; } } slip_send(outfd, SLIP_END); PROGRESS("t"); }
status_t TVideoPreviewView::Connected( const media_source & producer, const media_destination & where, const media_format & with_format, media_input* out_input) { FUNCTION("TVideoPreviewView::Connected()\n"); out_input->node = Node(); out_input->source = mProducer = producer; out_input->destination = mDestination; out_input->format = with_format; sprintf(out_input->name, "TVideoPreviewView"); mXSize = with_format.u.raw_video.display.line_width; mYSize = with_format.u.raw_video.display.line_count; mRowBytes = with_format.u.raw_video.display.bytes_per_row; mColorspace = with_format.u.raw_video.display.format; mBufferAvailable = create_sem (0, "Video buffer available"); if (mBufferAvailable < B_NO_ERROR) { ERROR("TVideoPreviewView: couldn't create semaphore\n"); return B_ERROR; } mBufferQueue = new BTimedBufferQueue(); // Create offscreen if (m_Bitmap == NULL) { m_Bitmap = new BBitmap(BRect(0, 0, (mXSize-1), (mYSize - 1)), mColorspace, false, false); } if (vThread == 0) { mDisplayQuit = false; int drawPrio = suggest_thread_priority(B_VIDEO_PLAYBACK, 30, 1000, 5000); PROGRESS("Suggested draw thread priority: %d\n", drawPrio); vThread = spawn_thread(vRun, "TVideoPreviewView:draw", drawPrio, this); resume_thread(vThread); } mConnected = true; return B_OK; }
/*---------------------------------------------------------------------------*/ void slip_flushbuf(int fd) { int n; if(slip_empty()) { return; } n = write(fd, slip_buf + slip_begin, slip_packet_end - slip_begin); if(n == -1 && errno != EAGAIN) { LOG6LBR_FATAL("slip_flushbuf::write() : %s\n", strerror(errno)); exit(1); } else if(n == -1) { PROGRESS("Q"); /* Outqueue is full! */ } else { slip_begin += n; if(slip_begin == slip_packet_end) { slip_packet_count--; if(slip_end > slip_packet_end) { memcpy(slip_buf, slip_buf + slip_packet_end, slip_end - slip_packet_end); } slip_end -= slip_packet_end; slip_begin = slip_packet_end = 0; if(slip_end > 0) { /* Find end of next slip packet */ for(n = 1; n < slip_end; n++) { if(slip_buf[n] == SLIP_END) { slip_packet_end = n + 1; break; } } /* a delay between slip packets to avoid losing data */ if(send_delay > 0) { timer_set(&send_delay_timer, send_delay); } } } } }
void hd_scan_veth(hd_data_t *hd_data) { unsigned u; hd_t *hd; DIR *dir; struct dirent *de; if(!hd_probe_feature(hd_data, pr_veth)) return; hd_data->module = mod_veth; /* some clean-up */ remove_hd_entries(hd_data); PROGRESS(1, 0, "read data"); if((dir = opendir(PROC_ISERIES_VETH))) { while((de = readdir(dir))) { if(sscanf(de->d_name, "veth%u", &u) == 1) { hd = add_hd_entry(hd_data, __LINE__, 0); hd->base_class.id = bc_network; hd->slot = u; hd->vendor.id = MAKE_ID(TAG_SPECIAL, 0x6001); // IBM hd->device.id = MAKE_ID(TAG_SPECIAL, 0x1000); str_printf(&hd->device.name, 0, "Virtual Ethernet card %d", hd->slot); } } closedir(dir); return; } if((dir = opendir(PROC_ISERIES))) { hd = add_hd_entry(hd_data, __LINE__, 0); hd->base_class.id = bc_network; hd->slot = 0; hd->vendor.id = MAKE_ID(TAG_SPECIAL, 0x6001); // IBM hd->device.id = MAKE_ID(TAG_SPECIAL, 0x1000); str_printf(&hd->device.name, 0, "Virtual Ethernet card %d", hd->slot); } }
static void kmallocthread(void *sm, unsigned long num) { struct semaphore *sem = sm; void *ptr; void *oldptr=NULL; void *oldptr2=NULL; int i; for (i=0; i<NTRIES; i++) { PROGRESS(i); ptr = kmalloc(ITEMSIZE); if (ptr==NULL) { if (sem) { kprintf("thread %lu: kmalloc returned NULL\n", num); goto done; } kprintf("kmalloc returned null; test failed.\n"); goto done; } if (oldptr2) { kfree(oldptr2); } oldptr2 = oldptr; oldptr = ptr; } done: if (oldptr2) { kfree(oldptr2); } if (oldptr) { kfree(oldptr); } if (sem) { V(sem); } }
static void get_sunmouse(hd_data_t *hd_data) { hd_t *hd; int fd; int found; found = 0; /* Only search for Sun mouse if we have a Sun keyboard */ for(hd = hd_data->hd; hd; hd = hd->next) { if(hd->base_class.id == bc_keyboard && hd->sub_class.id == sc_keyboard_kbd && ID_TAG(hd->vendor.id) == TAG_SPECIAL && ID_VALUE(hd->vendor.id) == 0x0202) found = 1; } if (found) { if ((fd = open(DEV_SUNMOUSE, O_RDONLY)) != -1) { /* FIXME: Should probably talk to the mouse to see if the connector is not empty. */ close (fd); PROGRESS(1, 1, "Sun Mouse"); hd = add_hd_entry (hd_data, __LINE__, 0); hd->base_class.id = bc_mouse; hd->sub_class.id = sc_mou_sun; hd->bus.id = bus_serial; hd->unix_dev_name = new_str(DEV_SUNMOUSE); hd->vendor.id = MAKE_ID(TAG_SPECIAL, 0x0202); hd->device.id = MAKE_ID(TAG_SPECIAL, 0x0000); } } }
/* Send * ---------------------------------------------------------------------------- */ ECommError CLogBlock::Send (BYTE byCommand, BYTE *pData, UINT uLen) { ASSERT(m_pPhys); // Build block frame if (m_pDataFrame == NULL) { m_pDataFrame = (XFrame *)new char [HD_FRAME + m_Para.uBlockLen]; } memset (m_pDataFrame, 0x00, HD_FRAME); m_pDataFrame->BLK.CMD.byCommand = byCommand; USHORT uBlock = 0; UINT uBlockLen = 0; UINT uDataLen = 0; BOOL bLast = FALSE; BYTE byType = BT_DATA; UINT uProgMax = uLen / m_Para.uBlockLen + ((uLen % m_Para.uBlockLen) > 0 ? 1 : 0); UINT uProgCur = 0; while (! bLast) { PROGRESS(uProgCur, uProgMax); // Block count starts with 1! uBlock++; m_pDataFrame->byType = byType; // Build data length uDataLen = (uLen - (uBlock - 1) * m_Para.uBlockLen) <= m_Para.uBlockLen ? (uLen - (uBlock - 1) * m_Para.uBlockLen) : m_Para.uBlockLen; // Build block length uBlockLen = uDataLen + HD_FRAME; bLast = (uBlock * m_Para.uBlockLen >= uLen); m_pDataFrame->BLK.byLast = (uBlock * m_Para.uBlockLen >= uLen); m_pDataFrame->BLK.uBlock = uBlock; m_pDataFrame->BLK.uLen = (USHORT)uDataLen; if (pData != NULL) { memcpy(m_pDataFrame->BLK.CMD.pData, pData + m_Para.uBlockLen * (uBlock - 1), uDataLen); } BuildCRC(m_pDataFrame); // Convert Little -> Big Endian HtoT(m_pDataFrame); ECommError eError = ceError; for (UINT i = 0; (i < m_uRepeatOnError && eError != ceAck) || i == 0; i++) { TRACE(_T(">>> %-8s %3d %3d "), byCommand <= LAST_CMD_VALUE ? szCommandText[byCommand] : _T("Invalid"), uBlock, uDataLen); TrcPrint(TRC_INTERFACE, _T(">>> %-8s %3d %3d "), byCommand <= LAST_CMD_VALUE ? szCommandText[byCommand] : _T("Invalid"), uBlock, uDataLen); // Send block eError = m_pPhys->Send((BYTE *)m_pDataFrame, HD_FRAME + uDataLen); if (eError != ceOK) { // Communication error sending data block. SleepEx (m_uWaitResend, FALSE); m_pPhys->Flush(); continue; } // Wait for acknowledge eError = RecvAck (uBlock); if (eError != ceAck && eError != ceNAck) { // Communication Error receiving ACK / NACK. SleepEx (m_uWaitResend, FALSE); m_pPhys->Flush(); continue; } } // end for if (eError != ceAck) { // A block could not be transmitted correctly. PROGRESS_LAST(uProgMax); return eError; } uProgCur++; } // end while PROGRESS(uProgCur, uProgMax); return ceOK; }
/* Receive * ---------------------------------------------------------------------------- */ ECommError CLogBlock::Receive (BYTE *bypCommand, BYTE **ppData, UINT *upLen) { HEAP_FREE(*ppData, *upLen); // Build block frame if (m_pDataFrame == NULL) { m_pDataFrame = (XFrame *)new char [HD_FRAME + m_Para.uBlockLen]; } memset (m_pDataFrame, 0x00, HD_FRAME); *upLen = 0; USHORT uBlock = 0; UINT uBlockLen = 0; UINT uDataLen = 0; BOOL bLast = FALSE; ECommError eError; UINT uProgMax = m_uMaxRecvProg; UINT uProgCur = 0; while (! bLast) { PROGRESS(uProgCur,uProgMax); // Block count starts with 1! uBlock++; eError = ceError; for (UINT i = 0; (i < m_uRepeatOnError && eError != ceOK) || i == 0; i++) { bLast = FALSE; // Send request for response block eError = SendInfoBlock (uBlock, BT_REQ); if (eError != ceOK) { // Communication error sending block SleepEx (m_uWaitResend, FALSE); m_pPhys->Flush(); continue; } uBlockLen = m_Para.uBlockLen + HD_FRAME; // Receive block eError = m_pPhys->Receive((BYTE *)m_pDataFrame, &uBlockLen); if (eError != ceOK) { // Communication error or time out; try again SleepEx (m_uWaitResend, FALSE); m_pPhys->Flush(); continue; } // Check block size if (uBlockLen < HD_FRAME) { // Received block could not be a valid block; try again SleepEx (m_uWaitResend, FALSE); m_pPhys->Flush(); TrcPrint(TRC_ERROR, _T("[CLogBlock][Receive] Invalid block length.\n")); eError = ceError; continue; } // Convert Big -> Little Endian TtoH(m_pDataFrame); if (HD_FRAME + m_pDataFrame->BLK.uLen != uBlockLen) { TrcPrint(TRC_ERROR, _T("[CLogBlock][Receive] CRC frame data length check failed.\n")); PROGRESS_LAST(uProgMax); return ceCRC; } // Check CRC if (CheckCRC (m_pDataFrame) != ceOK) { TRACE (_T("CRC_CRC_CRC_CRC_CRC_CRC_CRC_CRC_CRC_CRC_CRC_CRC_CRC_CRC_CRC_\n")); TrcPrint(TRC_ERROR, _T("[CLogBlock][Receive] CRC check failed.\n")); // Wrong checksum; send NACK and try again SleepEx (m_uWaitResend, FALSE); m_pPhys->Flush(); eError = ceCRC; continue; } // Check block type if (m_pDataFrame->byType != BT_DATA) { // Received block could not be a valid block; try again SleepEx (m_uWaitResend, FALSE); m_pPhys->Flush(); TrcPrint(TRC_ERROR, _T("[CLogBlock][Receive] Invalid block type (data expected).\n")); eError = ceError; continue; } bLast = m_pDataFrame->BLK.byLast; // Check block number if (m_pDataFrame->BLK.uBlock != uBlock) { // Received block number does not match SleepEx (m_uWaitResend, FALSE); m_pPhys->Flush(); TrcPrint(TRC_ERROR, _T("[CLogBlock][Receive] Invalid block number.\n")); eError = ceError; continue; } *bypCommand = m_pDataFrame->BLK.CMD.byCommand; uDataLen = m_pDataFrame->BLK.uLen; // Create Command Buffer if (uBlock == 1) { HEAP_ALLOC(*ppData, uDataLen); } else { HEAP_RE_ALLOC(*ppData, *upLen + uDataLen); } if (*ppData == NULL) { TrcPrint(TRC_ERROR, _T("[CLogBlock][Receive] Alloc Memory.\n")); eError = ceError; continue; } // Copy data memcpy(*ppData + *upLen, m_pDataFrame->BLK.CMD.pData, uDataLen); *upLen += uDataLen; if (m_pDataFrame->BLK.CMD.byCommand > 0x80u) { // Error Message from VMM TRACE(_T("<<< %-8s %3d %4d \n"), _T("FAILED"), uBlock, m_pDataFrame->BLK.uLen); TrcPrint(TRC_INTERFACE, _T("<<< %-8s %3d %4d \n"), _T("FAILED"), uBlock, m_pDataFrame->BLK.uLen); PROGRESS_LAST(uProgMax); return ceOK; } else { TRACE(_T("<<< %-8s %3d %3d \n"), m_pDataFrame->BLK.CMD.byCommand <= LAST_CMD_VALUE ? szCommandText[m_pDataFrame->BLK.CMD.byCommand] : _T("Invalid"), uBlock, m_pDataFrame->BLK.uLen); TrcPrint(TRC_INTERFACE, _T("<<< %-8s %3d %4d \n"), m_pDataFrame->BLK.CMD.byCommand <= LAST_CMD_VALUE ? szCommandText[m_pDataFrame->BLK.CMD.byCommand] : _T("Invalid"), uBlock, m_pDataFrame->BLK.uLen); } } // end for if (eError != ceOK) { HEAP_FREE(*ppData, *upLen); PROGRESS_LAST(uProgMax); return eError; } if (++uProgCur == uProgMax) { uProgMax += uProgMax; } } // end while PROGRESS_LAST(uProgMax); return ceOK; }