void keyboard_xt_write(uint16_t port, uint8_t val, void *priv) { switch (port) { case 0x61: if (!(keyboard_xt.pb & 0x40) && (val & 0x40)) /*Reset keyboard*/ { pclog("keyboard_xt : reset keyboard\n"); key_queue_end = key_queue_start; keyboard_xt_adddata(0xaa); } if ((keyboard_xt.pb & 0x80)==0 && (val & 0x80)!=0) { keyboard_xt.pa = 0; keyboard_xt.blocked = 0; picintc(2); } keyboard_xt.pb = val; ppi.pb = val; timer_process(); timer_update_outstanding(); speaker_update(); speaker_gated = val & 1; speaker_enable = val & 2; if (speaker_enable) was_speaker_enable = 1; pit_set_gate(&pit, 2, val & 1); break; } }
static void pit_load(int t) { int l = pit.l[t] ? pit.l[t] : 0x10000; timer_process(); pit.newcount[t] = 0; pit.disabled[t] = 0; // pclog("pit_load: t=%i l=%x\n", t, l); switch (pit.m[t]) { case 0: /*Interrupt on terminal count*/ pit.count[t] = l; pit.c[t] = (int)((l << TIMER_SHIFT) * PITCONST); pit_set_out(t, 0); pit.thit[t] = 0; pit.enabled[t] = pit.gate[t]; break; case 1: /*Hardware retriggerable one-shot*/ pit.enabled[t] = 1; break; case 2: /*Rate generator*/ if (pit.initial[t]) { pit.count[t] = l - 1; pit.c[t] = (int)(((l - 1) << TIMER_SHIFT) * PITCONST); pit_set_out(t, 1); pit.thit[t] = 0; } pit.enabled[t] = pit.gate[t]; break; case 3: /*Square wave mode*/ if (pit.initial[t]) { pit.count[t] = l; pit.c[t] = (int)((((l + 1) >> 1) << TIMER_SHIFT) * PITCONST); pit_set_out(t, 1); pit.thit[t] = 0; } pit.enabled[t] = pit.gate[t]; // pclog("pit_load: square wave mode c=%x\n", pit.c[t]); break; case 4: /*Software triggered stobe*/ if (!pit.thit[t] && !pit.initial[t]) pit.newcount[t] = 1; else { pit.count[t] = l; pit.c[t] = (int)((l << TIMER_SHIFT) * PITCONST); pit_set_out(t, 0); pit.thit[t] = 0; } pit.enabled[t] = pit.gate[t]; break; case 5: /*Hardware triggered stobe*/ pit.enabled[t] = 1; break; }
void keyboard_pcjr_write(uint16_t port, uint8_t val, void *priv) { // pclog("keyboard_pcjr : write %04X %02X %02X\n", port, val, keyboard_pcjr.pb); /* if (ram[8] == 0xc3) { output = 3; }*/ switch (port) { case 0x60: keyboard_pcjr.pa = val; break; case 0x61: keyboard_pcjr.pb = val; timer_process(); timer_update_outstanding(); speaker_update(); speaker_gated = val & 1; speaker_enable = val & 2; if (speaker_enable) was_speaker_enable = 1; pit_set_gate(2, val & 1); sn76489_mute = speaker_mute = 1; switch (val & 0x60) { case 0x00: speaker_mute = 0; break; case 0x60: sn76489_mute = 0; break; } break; case 0xa0: nmi_mask = val & 0x80; pit_set_using_timer(1, !(val & 0x20)); break; } }
int access_loop() { //int rel; int ok_cam_flag; int ok_send_flag; u32 time, tick; char record_buf[64]; if( check_card_action() > 0 ){ g_deal_card_no = g_card_no; g_card_no = 0; ok_cam_flag = do_cam(); if( ok_cam_flag <= -2 ){ // invailed card set_illegal_card_page(); set_page_keep_second( 5 ); } else if( ok_cam_flag == -1 ){ // disable enter set_forbid_enter_page(); set_page_keep_second( 5 ); } else if( ok_cam_flag == 1 ){ set_allow_enter_page(); set_page_keep_second( 5 ); } time = RTC_Get(); tick = get_sys_tick(); // make send record buf gen_record_string( record_buf, time, tick, g_record_id, g_deal_card_no, ok_cam_flag ); ok_send_flag = system_send_buf_to_host( record_buf, strlen( record_buf ) ); // make save file record buf sprintf( &record_buf[ strlen( record_buf ) ], "%d", ok_send_flag ); save_card_info( g_record_id, record_buf, ok_send_flag ); show_main_page(); g_record_id ++; } timer_process(); access_command_deal(); return 0; }
void keyboard_pcjr_write(uint16_t port, uint8_t val, void *priv) { switch (port) { case 0x60: keyboard_pcjr.pa = val; break; case 0x61: keyboard_pcjr.pb = val; timer_process(); timer_update_outstanding(); speaker_update(); speaker_gated = val & 1; speaker_enable = val & 2; if (speaker_enable) was_speaker_enable = 1; pit_set_gate(&pit, 2, val & 1); sn76489_mute = speaker_mute = 1; switch (val & 0x60) { case 0x00: speaker_mute = 0; break; case 0x60: sn76489_mute = 0; break; } break; case 0xa0: nmi_mask = val & 0x80; pit_set_using_timer(&pit, 1, !(val & 0x20)); break; } }
/** * Start the CDiameterPeer operations. * It forks all the processes required. * @param blocking - if this is set, use the calling processes for the timer and never * return; else fork a new one for the timer and return * @returns 1 on success, 0 on error, never if blocking */ int diameter_peer_start(int blocking) { int pid; int k=0; peer *p; /* fork workers */ for(k=0;k<config->workers;k++){ pid = fork_process(1001+k,"cdp_worker",1); if (pid==-1){ LM_CRIT("init_diameter_peer(): Error on fork() for worker!\n"); return 0; } if (pid==0) { srandom(time(0)*k); snprintf(pt[process_no].desc, MAX_PT_DESC,"cdp worker child=%d", k ); if (cfg_child_init()) return 0; worker_process(k); LM_CRIT("init_diameter_peer(): worker_process finished without exit!\n"); exit(-1); }else{ dp_add_pid(pid); } } /* init the fd_exchange pipes */ receiver_init(NULL); for(p = peer_list->head,k=0;p;p=p->next,k++) receiver_init(p); /* fork receiver for unknown peers */ pid = fork_process(1001+k,"cdp_receiver_peer_unkown",1); if (pid==-1){ LM_CRIT("init_diameter_peer(): Error on fork() for unknown peer receiver!\n"); return 0; } if (pid==0) { srandom(time(0)*k); snprintf(pt[process_no].desc, MAX_PT_DESC, "cdp receiver peer unknown"); if (cfg_child_init()) return 0; receiver_process(NULL); LM_CRIT("init_diameter_peer(): receiver_process finished without exit!\n"); exit(-1); }else{ dp_add_pid(pid); } /* fork receivers for each pre-configured peers */ lock_get(peer_list_lock); for(p = peer_list->head,k=-1;p;p = p->next,k--){ pid = fork_process(1001+k,"cdp_receiver_peer",1); if (pid==-1){ LM_CRIT("init_diameter_peer(): Error on fork() for peer receiver!\n"); return 0; } if (pid==0) { srandom(time(0)*k); snprintf(pt[process_no].desc, MAX_PT_DESC, "cdp_receiver_peer=%.*s", p->fqdn.len,p->fqdn.s ); if (cfg_child_init()) return 0; receiver_process(p); LM_CRIT("init_diameter_peer(): receiver_process finished without exit!\n"); exit(-1); }else{ dp_add_pid(pid); } } lock_release(peer_list_lock); /* Fork the acceptor process (after receivers, so it inherits all the right sockets) */ pid = fork_process(1000,"cdp_acceptor",1); if (pid==-1){ LM_CRIT("init_diameter_peer(): Error on fork() for acceptor!\n"); return 0; } if (pid==0) { if (cfg_child_init()) return 0; acceptor_process(config); LM_CRIT("init_diameter_peer(): acceptor_process finished without exit!\n"); exit(-1); }else{ dp_add_pid(pid); } /* fork/become timer */ if (blocking) { dp_add_pid(getpid()); if (cfg_child_init()) return 0; timer_process(1); } else{ pid = fork_process(1001,"cdp_timer",1); if (pid==-1){ LM_CRIT("init_diameter_peer(): Error on fork() for timer!\n"); return 0; } if (pid==0) { if (cfg_child_init()) return 0; timer_process(0); LM_CRIT("init_diameter_peer(): timer_process finished without exit!\n"); exit(-1); }else{ dp_add_pid(pid); } } return 1; }
/** * Start the CDiameterPeer operations. * It forks all the processes required. * @param blocking - if this is set, use the calling processes for the timer and never * return; else fork a new one for the timer and return * @returns 1 on success, 0 on error, never if blocking */ int diameter_peer_start(int blocking) { int pid; int k=0; /* Fork the acceptor process */ #ifdef CDP_FOR_SER pid = fork_process(1000,"cdp_acceptor",1); #else pid = fork(); #endif if (pid==-1){ LOG(L_CRIT,"ERROR:init_diameter_peer(): Error on fork() for acceptor!\n"); return 0; } if (pid==0) { acceptor_process(config); LOG(L_CRIT,"ERROR:init_diameter_peer(): acceptor_process finished without exit!\n"); exit(-1); }else{ dp_add_pid(pid); } /* fork workers */ for(k=0;k<config->workers;k++){ #ifdef CDP_FOR_SER pid = fork_process(1001+k,"cdp_worker",1); #else pid = fork(); #endif if (pid==-1){ LOG(L_CRIT,"ERROR:init_diameter_peer(): Error on fork() for worker!\n"); return 0; } if (pid==0) { srandom(time(0)*k); #ifdef CDP_FOR_SER snprintf(pt[process_no].desc, MAX_PT_DESC, "cdp worker child=%d", k ); #endif worker_process(k); LOG(L_CRIT,"ERROR:init_diameter_peer(): worker_process finished without exit!\n"); exit(-1); }else{ dp_add_pid(pid); } } /* fork/become timer */ if (blocking) { dp_add_pid(getpid()); timer_process(1); } else{ #ifdef CDP_FOR_SER pid = fork_process(1001,"cdp_timer",1); #else pid = fork(); #endif if (pid==-1){ LOG(L_CRIT,"ERROR:init_diameter_peer(): Error on fork() for timer!\n"); return 0; } if (pid==0) { timer_process(0); LOG(L_CRIT,"ERROR:init_diameter_peer(): timer_process finished without exit!\n"); exit(-1); }else{ dp_add_pid(pid); } } return 1; }
void fdc_write(uint16_t addr, uint8_t val, void *priv) { // pclog("Write FDC %04X %02X %04X:%04X %i %02X %i rate=%i %i\n",addr,val,cs>>4,pc,ins,fdc.st0,ins,fdc.rate, fdc.data_ready); int drive; switch (addr&7) { case 1: return; case 2: /*DOR*/ // if (val == 0xD && (cs >> 4) == 0xFC81600 && ins > 769619936) output = 3; // printf("DOR was %02X\n",fdc.dor); if (fdc.pcjr) { if ((fdc.dor & 0x40) && !(val & 0x40)) { fdc.watchdog_timer = 1000 * TIMER_USEC; fdc.watchdog_count = 1000; picintc(1 << 6); // pclog("watchdog set %i %i\n", fdc.watchdog_timer, TIMER_USEC); } if ((val & 0x80) && !(fdc.dor & 0x80)) { timer_process(); disctime = 128 * (1 << TIMER_SHIFT); timer_update_outstanding(); discint=-1; fdc_reset(); } motoron = val & 0x01; fdc.drive = 0; /* if (motoron) output = 3; else output = 0;*/ } else { if (val&4) { fdc.stat=0x80; fdc.pnum=fdc.ptot=0; } if ((val&4) && !(fdc.dor&4)) { timer_process(); disctime = 128 * (1 << TIMER_SHIFT); timer_update_outstanding(); discint=-1; fdc_reset(); } timer_process(); motoron = (val & 0xf0) ? 1 : 0; timer_update_outstanding(); fdc.drive = val & 3; } fdc.dor=val; // printf("DOR now %02X\n",val); return; case 3: /* TDR */ if (fdc.enh_mode) { drive = (fdc.dor & 1) ^ fdd_swap; fdc.rwc[drive] = (val & 0x30) >> 4; } return; case 4: if (val & 0x80) { timer_process(); disctime = 128 * (1 << TIMER_SHIFT); timer_update_outstanding(); discint=-1; fdc_reset(); } return; case 5: /*Command register*/ if ((fdc.stat & 0xf0) == 0xb0) { if (fdc.pcjr || !fdc.fifo) { fdc.dat = val; fdc.stat &= ~0x80; } else { fdc_fifo_buf_write(val); if (fdc.fifobufpos == 0) fdc.stat &= ~0x80; } break; } // if (fdc.inread) // rpclog("c82c711_fdc_write : writing while inread! %02X\n", val); // rpclog("Write command reg %i %i\n",fdc.pnum, fdc.ptot); if (fdc.pnum==fdc.ptot) { fdc.tc = 0; fdc.data_ready = 0; fdc.command=val; // pclog("Starting FDC command %02X\n",fdc.command); switch (fdc.command&0x1F) { case 1: /*Mode*/ if (!fdc.is_nsc) goto bad_command; fdc.pnum=0; fdc.ptot=4; fdc.stat=0x90; fdc.pos=0; fdc.format_state = 0; break; case 2: /*Read track*/ fdc.pnum=0; fdc.ptot=8; fdc.stat=0x90; fdc.pos=0; break; case 3: /*Specify*/ fdc.pnum=0; fdc.ptot=2; fdc.stat=0x90; break; case 4: /*Sense drive status*/ fdc.pnum=0; fdc.ptot=1; fdc.stat=0x90; break; case 5: /*Write data*/ // printf("Write data!\n"); fdc.pnum=0; fdc.ptot=8; fdc.stat=0x90; fdc.pos=0; // readflash=1; break; case 6: /*Read data*/ fdc.pnum=0; fdc.ptot=8; fdc.stat=0x90; fdc.pos=0; break; case 7: /*Recalibrate*/ fdc.pnum=0; fdc.ptot=1; fdc.stat=0x90; break; case 8: /*Sense interrupt status*/ // printf("Sense interrupt status %i\n",curdrive); fdc.lastdrive = fdc.drive; // fdc.stat = 0x10 | (fdc.stat & 0xf); // fdc_time=1024; discint = 8; fdc.pos = 0; fdc_callback(); break; case 10: /*Read sector ID*/ fdc.pnum=0; fdc.ptot=1; fdc.stat=0x90; fdc.pos=0; break; case 0x0d: /*Format track*/ fdc.pnum=0; fdc.ptot=5; fdc.stat=0x90; fdc.pos=0; fdc.format_state = 0; break; case 15: /*Seek*/ fdc.pnum=0; fdc.ptot=2; fdc.stat=0x90; break; case 0x0e: /*Dump registers*/ fdc.lastdrive = fdc.drive; discint = 0x0e; fdc.pos = 0; fdc_callback(); break; case 0x10: /*Get version*/ fdc.lastdrive = fdc.drive; discint = 0x10; fdc.pos = 0; fdc_callback(); break; case 0x12: /*Set perpendicular mode*/ fdc.pnum=0; fdc.ptot=1; fdc.stat=0x90; fdc.pos=0; break; case 0x13: /*Configure*/ fdc.pnum=0; fdc.ptot=3; fdc.stat=0x90; fdc.pos=0; break; case 0x14: /*Unlock*/ case 0x94: /*Lock*/ fdc.lastdrive = fdc.drive; discint = fdc.command; fdc.pos = 0; fdc_callback(); break; case 0x18: if (!fdc.is_nsc) goto bad_command; fdc.lastdrive = fdc.drive; discint = 0x10; fdc.pos = 0; fdc_callback(); /* fdc.stat = 0x10; discint = 0xfc; fdc_callback(); */ break; default: bad_command: // fatal("Bad FDC command %02X\n",val); // dumpregs(); // exit(-1); fdc.stat=0x10; discint=0xfc; timer_process(); disctime = 200 * (1 << TIMER_SHIFT); timer_update_outstanding(); break; } } else { fdc.params[fdc.pnum++]=val; if (fdc.pnum==fdc.ptot) { // pclog("Got all params %02X\n", fdc.command); fdc.stat=0x30; discint=fdc.command&0x1F; timer_process(); disctime = 1024 * (1 << TIMER_SHIFT); timer_update_outstanding(); // fdc.drive = fdc.params[0] & 3; disc_drivesel = fdc.drive & 1; fdc_reset_stat = 0; disc_set_drivesel(fdc.drive & 1); switch (discint) { case 2: /*Read a track*/ fdc_rate(fdc.drive); fdc.head=fdc.params[2]; fdc.sector=fdc.params[3]; fdc.eot[fdc.drive] = fdc.params[5]; if (fdc.config & 0x40) fdd_seek(fdc.drive, fdc.params[1] - fdc.track[fdc.drive]); fdc.track[fdc.drive]=fdc.params[1]; // pclog("Read a track track=%i head=%i sector=%i eot=%i\n", fdc.track[fdc.drive], fdc.head, fdc.sector, fdc.eot[fdc.drive]); disc_readsector(fdc.drive, SECTOR_FIRST, fdc.track[fdc.drive], fdc.head, fdc.rate, fdc.params[4]); disctime = 0; readflash = 1; fdc.inread = 1; break; case 3: /*Specify*/ fdc.stat=0x80; fdc.specify[0] = fdc.params[0]; fdc.specify[1] = fdc.params[1]; fdc.dma = (fdc.specify[1] & 1) ^ 1; disctime = 0; break; case 5: /*Write data*/ fdc_rate(fdc.drive); fdc.head=fdc.params[2]; fdc.sector=fdc.params[3]; fdc.eot[fdc.drive] = fdc.params[5]; if (fdc.config & 0x40) fdd_seek(fdc.drive, fdc.params[1] - fdc.track[fdc.drive]); fdc.track[fdc.drive]=fdc.params[1]; fdc.rw_track = fdc.params[1]; disc_writesector(fdc.drive, fdc.sector, fdc.track[fdc.drive], fdc.head, fdc.rate, fdc.params[4]); disctime = 0; fdc.written = 0; readflash = 1; fdc.pos = 0; if (fdc.pcjr) fdc.stat = 0xb0; // ioc_fiq(IOC_FIQ_DISC_DATA); break; case 6: /*Read data*/ fdc_rate(fdc.drive); fdc.head=fdc.params[2]; fdc.sector=fdc.params[3]; fdc.eot[fdc.drive] = fdc.params[5]; if (fdc.config & 0x40) fdd_seek(fdc.drive, fdc.params[1] - fdc.track[fdc.drive]); fdc.track[fdc.drive]=fdc.params[1]; fdc.rw_track = fdc.params[1]; disc_readsector(fdc.drive, fdc.sector, fdc.track[fdc.drive], fdc.head, fdc.rate, fdc.params[4]); disctime = 0; readflash = 1; fdc.inread = 1; break; case 7: /*Recalibrate*/ fdc.stat = 1 << fdc.drive; disctime = 0; fdd_seek(fdc.drive, SEEK_RECALIBRATE); break; case 0x0d: /*Format*/ fdc_rate(fdc.drive); fdc.head = (fdc.params[0] & 4) ? 1 : 0; fdc.format_state = 1; fdc.pos = 0; fdc.stat = 0x30; break; case 0xf: /*Seek*/ fdc.stat = 1 << fdc.drive; fdc.head = (fdc.params[0] & 4) ? 1 : 0; disctime = 0; fdd_seek(fdc.drive, fdc.params[1] - fdc.track[fdc.drive]); // pclog("Seek to %i\n", fdc.params[1]); break; case 10: /*Read sector ID*/ fdc_rate(fdc.drive); disctime = 0; fdc.head = (fdc.params[0] & 4) ? 1 : 0; // pclog("Read sector ID %i %i\n", fdc.rate, fdc.drive); disc_readaddress(fdc.drive, fdc.track[fdc.drive], fdc.head, fdc.rate); break; } } } return; case 7: if (!AT) return; fdc.rate=val&3; disc_3f7=val; return; }