static int program_wait(int *exitcode, int tryflg) { int taskid; char *userargs; int usersize; usersize = environment_get_session_size(); userargs = malloc(usersize); if(userargs==0) return ERRNO_RESOURCE; taskid=environment_wait(exitcode, tryflg, userargs, usersize); if(taskid==ERRNO_OVER) { mfree(userargs); return taskid; } if(taskid<0) { display_puts("wait error="); int2dec(-taskid,s); display_puts(s); display_puts("\n"); mfree(userargs); return taskid; } if(*exitcode & 0x8000) { exception_dump((void*)userargs, display_puts); } mfree(userargs); return taskid; }
int cdfs_init(void) { int rc; if(cdfs_queid != 0) return 0; for(;;) { rc = syscall_que_lookup(CDFS_QNM_CDFS); if(rc==ERRNO_NOTEXIST) { syscall_wait(10); continue; } if(rc<0) { cdfs_queid = 0; display_puts("cdfs_init srvq="); long2hex(-rc,s); display_puts(s); display_puts("\n"); return rc; } cdfs_queid = rc; break; } //display_puts("cdfs_init done\n"); return 0; }
int tst_alarm(void) { int i; //int rc; //int alarm; struct msg_head selected_msg; for(i=0;i<10;i++) { display_puts("@"); syscall_wait(50); } display_puts("\n"); for(i=0;i<10;i++) { display_puts("@"); syscall_alarm_set(50,environment_getqueid(),0x00010000); selected_msg.size=sizeof(selected_msg); message_poll(MESSAGE_MODE_WAIT, 0, 0, &selected_msg); message_receive(MESSAGE_MODE_TRY, 0, 0, &selected_msg); } display_puts("\n"); return 0; }
int test_mouse_key() { unsigned long mask=0; int count=0; display_puts("key open\n"); if ((keyb_fd = GdOpenKeyboard()) < 0) { PRINT_ERROR("Cannot initialise keyboard"); return -1; } psd = GdOpenScreen(); if(psd==NULL) { syscall_puts("GdOpenScreen error\n"); GdCloseKeyboard(); return -1; } display_puts("mouse open\n"); if ((mouse_fd = GdOpenMouse()) < 0) { PRINT_ERROR("Cannot initialise mouse"); GdCloseScreen(psd); GdCloseKeyboard(); return -1; } GdSetForegroundPixelVal(psd, 7); GdSetBackgroundPixelVal(psd, 0); GdSetDash(&mask, &count); for(;;) { GsSelect(); } return 0; }
int cdfs_open_response(unsigned short *seq, int *handle) { union cdfs_msg msg; int rc; if(cdfs_queid==0) { rc=cdfs_init(); if(rc<0) return rc; } msg.h.size=sizeof(msg); rc=message_receive(MESSAGE_MODE_WAIT,CDFS_SRV_CDFS, CDFS_CMD_OPEN, &msg); if(rc<0) { display_puts("cdfs open="); int2dec(-rc,s); display_puts(s); display_puts("\n"); return rc; } *seq = msg.open.res.seq; *handle = msg.open.res.handle; return rc; }
int cdfs_getinfo_request(unsigned short seq,unsigned short devid) { int rc; union cdfs_msg msg; if(cdfs_queid==0) { rc=cdfs_init(); if(rc<0) return rc; } msg.h.size=sizeof(struct cdfs_req_getinfo); msg.h.service=CDFS_SRV_CDFS; msg.h.command=CDFS_CMD_GETINFO; msg.h.arg=environment_getqueid(); msg.getinfo.req.seq=seq; msg.getinfo.req.devid=devid; /* int2dec(msg.req.queid,s); display_puts(s); */ rc=message_send(cdfs_queid, &msg); if(rc<0) { display_puts("getcode sndcmd="); int2dec(-rc,s); display_puts(s); display_puts("\n"); return rc; } return 0; }
int cdfs_getinfo_response(unsigned short *seq, int *typecode) { union cdfs_msg msg; int rc; if(cdfs_queid==0) { rc=cdfs_init(); if(rc<0) return rc; } msg.h.size=sizeof(msg); rc=message_receive(MESSAGE_MODE_WAIT,CDFS_SRV_CDFS, CDFS_CMD_GETINFO, &msg); if(rc<0) { display_puts("getcode getresp="); int2dec(-rc,s); display_puts(s); display_puts("\n"); return rc; } *seq = msg.getinfo.res.seq; *typecode = msg.getinfo.res.type; return 0; }
int cdfs_stat_response(unsigned short *seq, struct file_info *info, unsigned long bufsize) { union cdfs_msg msg; int rc; if(cdfs_queid==0) { rc=cdfs_init(); if(rc<0) return rc; } msg.h.size=sizeof(msg); rc=message_receive(MESSAGE_MODE_WAIT,CDFS_SRV_CDFS, CDFS_CMD_STAT, &msg); if(rc<0) { display_puts("getcode getresp="); int2dec(-rc,s); display_puts(s); display_puts("\n"); return rc; } *seq = msg.stat.res.seq; unsigned long len = sizeof(struct file_info); if(len>bufsize) len = bufsize; memcpy(info, &msg.stat.res.info, len); if((int)(msg.stat.res.info.size) == -1) return 0; if(bufsize < sizeof(struct file_info)) return 0; return 0; }
int cdfs_stat_request(unsigned short seq,int handle) { int rc; union cdfs_msg msg; if(cdfs_queid==0) { rc=cdfs_init(); if(rc<0) return rc; } msg.h.size=sizeof(struct cdfs_req_readdir); msg.h.service=CDFS_SRV_CDFS; msg.h.command=CDFS_CMD_STAT; msg.h.arg=environment_getqueid(); msg.stat.req.seq=seq; msg.stat.req.handle=handle; /* int2dec(msg.req.queid,s); display_puts(s); */ rc=message_send(cdfs_queid, &msg); if(rc<0) { display_puts("cdfs_stat sndcmd="); int2dec(-rc,s); display_puts(s); display_puts("\n"); return rc; } return 0; }
int cdfs_read_response(unsigned short *seq, int *readbyte) { union cdfs_msg msg; int rc; if(cdfs_queid==0) { rc=cdfs_init(); if(rc<0) return rc; } msg.h.size=sizeof(msg); rc=message_receive(MESSAGE_MODE_WAIT,CDFS_SRV_CDFS, CDFS_CMD_READ, &msg); if(rc<0) { display_puts("getcode getresp="); int2dec(-rc,s); display_puts(s); display_puts("\n"); return rc; } *seq = msg.read.res.seq; *readbyte = msg.read.res.readbyte; return rc; }
void usage(void) { display_puts("usage: tstcdfs command fullpath\n"); display_puts("commands:\n"); display_puts("type - display file\n"); display_puts("dir - list directory\n"); }
// // Update mouse status and issue events on it if necessary. // This function doesn't block, but is normally only called when // there is known to be some data waiting to be read from the mouse. // BOOL GsCheckMouseEvent(void) { MWCOORD rootx; // latest mouse x position MWCOORD rooty; // latest mouse y position int newbuttons; // latest buttons int mousestatus; // latest mouse status // Read the latest mouse status: display_puts("mouse read\n"); mousestatus = GdReadMouse(&rootx, &rooty, &newbuttons); if(mousestatus < 0) { display_puts("Mouse error\n"); return FALSE; } else if(mousestatus) { // Deliver events as appropriate: /* display_puts("mouse "); sint2dec(rootx,s); display_puts(s); display_puts(","); sint2dec(rooty,s); display_puts(s); display_puts(","); long2hex(newbuttons,s); display_puts(s); display_puts("\n"); */ if(newbuttons&0x1) tstColorGd++; GdSetForegroundPixelVal(psd, tstColorGd); GdPoint(psd, rootx, rooty); return TRUE; } return FALSE; }
void placar (display *tela, int n_inimigos) { float elapsed = (float) clock() / CLOCKS_PER_SEC; elapsed -= g_start; display_puts(tela, 0, 1, "%d inimigos", n_inimigos); display_puts(tela, 0, 0, "%.2f segundos vivo", elapsed); }
void tst_shm2(void) { int r; int shmid; syscall_wait(10); shmid=shm_lookup(SHRMEMNAME); display_puts("shm2 lookup="); sint2dec(shmid,s); display_puts(s); r=shm_map(shmid,(void*)SHRMEMADDR); display_puts(" shm2 map="); sint2dec(r,s); display_puts(s); // display_puts("\n"); syscall_wait(50); syscall_mtx_lock((int*)SHRMEMADDR); memcpy(s,(void*)(SHRMEMADDR+sizeof(int)),4); syscall_mtx_unlock((int*)SHRMEMADDR); s[4]=0; display_puts(" shm2 shrstr="); display_puts(s); // display_puts("\n"); r=shm_unmap(shmid); display_puts(" shm2 unmap="); sint2dec(r,s); display_puts(s); display_puts("\n"); }
static void do_buttondown(GR_EVENT_BUTTON *ep) { mwin * mwp; static int app_no; char *userargs; int r,taskid,queid,n; char s[16]; char *argv[2]; if (ep->wid == w1) { app_no = ep->y / fheight; if (app_no >= num_apps) { app_no = num_apps - 1; } taskid=syscall_pgm_load( Apps[app_no].app_path, SYSCALL_PGM_TYPE_VGA|SYSCALL_PGM_TYPE_IO); if(taskid<0) { display_puts("load error="); int2dec(-taskid,s); display_puts(s); display_puts("\n"); return; } argv[0]=Apps[app_no].app_path; argv[1]=""; userargs=environment_copy_session(); n = environment_get_session_size(); environment_make_args(userargs, 2, argv); r = syscall_pgm_setargs(taskid, userargs, n); if(r<0) { display_puts("setargs error="); int2dec(-r,s); display_puts(s); display_puts("\n"); return; } mfree(userargs); queid = environment_getqueid(); r=syscall_pgm_start(taskid, queid); if(r<0) { display_puts("start error="); int2dec(-r,s); display_puts(s); display_puts("\n"); return; } } else if ((mwp = IsDecoration(ep->wid)) != NULL) { GrRaiseWindow(mwp->wid); GrRaiseWindow(mwp->fid); in_motion = mwp; move_xoff = ep->x; move_yoff = ep->y; } }
/*! * Display zum Setzen und Anfahren der Stackpunkte */ void drive_stack_display(void) { display_cursor(1, 1); display_printf("Stack %5d %5d", pos.x, pos.y); display_cursor(2, 1); display_puts("Save/Del : 3/8"); display_cursor(3, 1); display_puts("GoBack/Forward: 4/7"); display_cursor(4, 1); display_puts("Start WayPushPos: 5"); drivestack_disp_key_handler(); // Aufruf des Key-Handlers }
/** * Zeigt die aktuelle Speicherbelegung an. * Achtung, die Stackgroesse bezieht sich auf den Stack *dieser* Funktion! * Die Heapgroesse stimmt nur, wenn es dort keine Luecken gibt (z.b. durch free()) */ void ram_display(void) { unsigned char * sp = (unsigned char *) SP; extern unsigned char __data_start; extern unsigned char __bss_start; extern unsigned char __heap_start; extern unsigned char * __brkval; #ifdef RC5_AVAILABLE #ifdef LOG_AVAILABLE extern unsigned char __data_end; extern unsigned char __bss_end; if (RC5_Code == RC5_CODE_1) { LOG_DEBUG("__data_start = 0x%04x", &__data_start); LOG_DEBUG("__data_end = 0x%04x", &__data_end); LOG_DEBUG("__bss_start = 0x%04x", &__bss_start); LOG_DEBUG("__bss_end = 0x%04x", &__bss_end); LOG_DEBUG("__heap_start = 0x%04x", &__heap_start); LOG_DEBUG("__heap_end = 0x%04x", __brkval); LOG_DEBUG("SP = 0x%04x", sp); LOG_DEBUG("RAMEND = 0x%04x", RAMEND); RC5_Code = 0; } #endif // RC5_AVAILABLE #endif // LOG_AVAILABLE size_t data_size = (size_t) (&__bss_start - &__data_start); size_t bss_size = (size_t) (&__heap_start - &__bss_start); display_cursor(1, 1); display_puts("bss/data:"); display_cursor(1, 10); display_printf("%5u/%5u", bss_size, data_size); display_cursor(2, 1); display_puts("heap:"); display_cursor(2, 16); size_t heap_size = __brkval == NULL ? 0 : (size_t) (__brkval - &__heap_start); display_printf("%5u", heap_size); display_cursor(3, 1); size_t ram_size = (size_t) ((unsigned char *) (RAMEND + 1) - &__data_start); size_t stack_size = (size_t) ((unsigned char *) RAMEND - sp); display_puts("stack:"); #ifdef OS_DEBUG size_t stack_size_max = ram_size - (os_stack_unused(__brkval + __malloc_margin) + data_size + bss_size + heap_size); display_cursor(3, 10); display_printf("%5u/%5u", stack_size, stack_size_max); #else display_cursor(3, 16); display_printf("%5u", stack_size); #endif // OS_DEBUG display_cursor(4, 1); size_t frei = ram_size - (data_size + bss_size + heap_size + stack_size); display_puts("free/ram:"); display_cursor(4, 10); display_printf("%5u/%5u", frei, ram_size); }
int main(void) { WDTCTL = WDTPW | WDTHOLD; /* configure P2.6 and P2.7 as XIN/XOUT function pins */ P2DIR &= ~BIT6; P2DIR |= BIT7; P2SEL |= BIT7 | BIT6; /* 32kHz external crystal, XCAP = 12.5pF, clear LFXT1 osc fault */ BCSCTL3 |= XCAP0 | XCAP1; BCSCTL3 &= ~(LFXT1S0 | LFXT1S1); /* enable ACLK function of P1.0 (32KHz clock output) */ P1DIR |= BIT0; P1SEL |= BIT0; spi_init(); /* to save space, since we do it in the interrupt anyway */ P1DIR |= DISPLAY_SUPPLY; P1OUT |= DISPLAY_SUPPLY; #if 0 display_puts("MSP430", 0); display_puts("123456", 1); #endif display_init(1); delay_ms(100); display_update(1); /* enable falling edge interrupt for BUSY1 of the display, which * becomes low when the display content has been updated */ P1IE |= DISPLAY_BUSY1; P1IES |= DISPLAY_BUSY1; /* Timer A: input divider /8, ACLK clock source, UP mode */ TACTL = ID_3 | TASSEL_1 | MC_3; /* enable the TACCR0 compare interrupt */ TACCTL0 = CCIE; /* load TACCR0, starts timer. (32768Hz / 8) * 15 = 61440, so the * timer interrupt fires every 15 seconds */ TACCR0 = 61440 - 1; /* enable global interrupts and enter LPM3 */ _BIS_SR(LPM3_bits + GIE); while (1) { }; }
void dsp_open_error(int errno) { switch(errno) { case ERRNO_NOTEXIST: display_puts("Not found\n"); break; case ERRNO_SCSI_NotReady: display_puts("Drive is not ready\n"); break; default: print_format("Error(%d)\n",errno); } }
int pci_init(void) { pci_bios_entry.address=(unsigned long)pci_scan_bios(); if(pci_bios_entry.address==0) { return ERRNO_NOTEXIST; } unsigned long addr = pci_bios32_service_directory(PCI_SERVICE); if(addr) display_puts("In service"); else display_puts("Out of service"); return 0; }
/** * Handle keys when tea is not being brewed */ static void handle_key_idle(const char key) { //digit if (key >= 0x30 && key <= 0x39) { handle_temperature_digit(key - 0x30); } else if (key == '#') { if (tea_set_point == 0) display_puts("Err"); else tea_on(); } else if (key == '*') { display_puts("---"); del_timer(clear_temp_state); clear_temp_state(); } }
/** * Faehrt den Bot sauber herunter */ void ctbot_shutdown(void) { LOG_INFO("Shutting c't-Bot down..."); motor_set(BOT_SPEED_STOP, BOT_SPEED_STOP); #ifdef MAP_AVAILABLE map_flush_cache(); #endif #ifdef LOG_MMC_AVAILABLE log_flush(); #endif #ifdef BOT_FS_AVAILABLE botfs_close_volume(); #endif #ifdef DISPLAY_AVAILABLE display_clear(); display_cursor(1, 1); display_puts("SYSTEM HALTED."); #endif // DISPLAY_AVAILABLE ENA_off(0xff); ctbot_shutdown_low(); }
/** * Display fuer das uBasic-Verhalten */ void ubasic_display(void) { display_cursor(1, 1); display_puts("- uBasic -"); #ifdef RC5_CODE_PLAY display_cursor(2, 1); display_puts("PLAY:Run Prog"); #endif display_cursor(3, 1); display_puts("1-9:bas1..9.txt"); #ifdef RC5_CODE_STOP display_cursor(4, 1); display_puts("STOPP:Prog abbrechen"); #endif ubasic_disp_key_handler(); // Aufruf des Key-Handlers }
/** * Handle keys to set temperature digits */ static void handle_temperature_digit(const uint8_t digit) { char buf[4] = "---"; //this is the first digit if (temp_entry.state == TEMP_STATE_NONE) { temp_entry.state = TEMP_STATE_ENTER; temp_entry.digit = 0; } temp_entry.digits[temp_entry.digit] = digit; del_timer(clear_temp_state); for (uint8_t i = 0; i <= temp_entry.digit; ++i) buf[i] = temp_entry.digits[i]+0x30; display_puts(buf); if (temp_entry.digit == 2) { temp_entry.state = TEMP_STATE_NONE; uint16_t temp = temp_entry.digits[0]*100 + temp_entry.digits[1]*10 + temp_entry.digits[2]; tea_set_temperature(temp); } else { temp_entry.digit++; add_timer(clear_temp_state, 5*TIMER_HZ, 1); } }
static void dump(char *addr) { int i,j; for(j=0;j<2;j++) { long2hex((unsigned long)addr,s); display_puts(s); for(i=0;i<16;i++,addr++) { byte2hex(*addr,s); display_puts(" "); display_puts(s); } display_puts("\n"); syscall_wait(50); } }
int mouse_poll(void) { union mou_msg msg; int r; msg.req.h.size=sizeof(msg); r=message_poll(mou_quewait,MOU_SRV_MOUSE, MOU_CMD_GETCODE, &msg); if(r<0) { display_puts("mousepoll getresp="); int2dec(-r,s); display_puts(s); display_puts("\n"); return r; } return r; }
int cmd_stat(int ac, char **av) { int rc; int handle; char type; char buf[sizeof(struct file_info)+CDFS_FULLPATH_MAXLENGTH]; struct file_info *info=(void*)buf; //display_puts("cdfs_open\n"); handle = cdfs_open(av[0]); if(handle<0) { dsp_open_error(handle); goto EXITCMD; } //display_puts("cdfs_stat\n"); rc = cdfs_stat(handle,info,sizeof(buf)); if(rc<0) { display_puts("rc="); sint2dec(rc,s); display_puts(s); goto EXITCMD; } if(info->attr & CDFS_ATTR_DIRECTORY) type='D'; else type='F'; unsigned char *datestr=info->mtime; print_format("type=%c(%02x) date=%d-%02d-%02d %02d:%02d:%02d size=%d\n",type,info->attr,1900+datestr[0],datestr[1],datestr[2],datestr[3],datestr[4],datestr[5],info->size); EXITCMD: if(handle>0) { //display_puts("cdfs_close\n"); rc = cdfs_close(handle); if(rc<0) { display_puts("rc="); sint2dec(rc,s); display_puts(s); } } return 0; }
static void tea_off(void) { del_timer(tea_tick); //add_timer(display_test, TIMER_HZ/4, TIMER_RUN_UNLIMITED); device_state = DEV_STATE_IDLE; ssr_off(); servo_set_angle(0); display_puts("---"); }
static void *pci_scan_bios(void) { unsigned char *bios_addr; for(bios_addr = (void*)CFG_MEM_BIOSSTART; (unsigned long)bios_addr < CFG_MEM_BIOSMAX-sizeof(struct pci_bios) ; bios_addr++ ) { if(memcmp(bios_addr,"_32_",4)!=0) continue; struct pci_bios *info=(void*)bios_addr; if(info->revision!=0) continue; if(info->length!=(unsigned char)1) continue; unsigned char i,checksum=0; for(i=0;i<sizeof(struct pci_bios);i++) { checksum += bios_addr[i]; } if(checksum!=info->checksum) continue; display_puts("entry="); long2hex(info->entry,s); display_puts(s); display_puts(",rev="); int2dec(info->revision,s); display_puts(s); display_puts(",len="); int2dec(info->length,s); display_puts(s); display_puts(",chk="); byte2hex(info->checksum,s); display_puts(s); display_puts("\n"); return (void*)info->entry; //display_puts("."); //syscall_wait(100); } display_puts("PCI BIOS is not found\n"); dump((void*)CFG_MEM_BIOSSTART); return 0; }
/** * Zeigt ein paar Infos an, die man nicht naeher zuordnen kann */ void misc_display(void) { /* Anzeige der Bot-Adresse (aenderbar) */ display_cursor(1, 1); display_puts("bot_addr="); #ifdef KEYPAD_AVAILABLE if (RC5_Code == RC5_CODE_MUTE) { gui_keypad_request(change_bot_addr_callback, 1, 1, 10); #ifdef PC display_cursor(1, 10); #endif display_puts(" "); // clean new_address = 1; RC5_Code = 0; } if (new_address == 0) #endif // KEYPAD_AVAILABLE { #ifdef PC display_cursor(1, 10); #endif display_printf("0x%x", get_bot_address()); } #ifdef BEHAVIOUR_AVAILABLE display_cursor(2, 1); display_printf("TS=%+4d %+4d", target_speed_l, target_speed_r); #endif #ifdef SRF10_AVAILABLE display_cursor(2, 15); display_printf("US%4u", sensSRF10); #endif display_cursor(3, 1); display_printf("RC=%+4d %+4d", sensEncL, sensEncR); display_cursor(4, 1); display_printf("Speed=%+4d", v_center); display_cursor(4, 12); display_printf("%4u:%03u", timer_get_s(), timer_get_ms()); }