int starttimer(struct timerobject *tobj, unsigned long msec, int (*timeouthandler)(void *), void *handlerparam) { struct timerobject * t1; // Initialize the timer object tobj->timer_count = msec; tobj->timer_handler = timeouthandler; tobj->timer_handlerparam = handlerparam; tobj->timer_ownerthread = (struct kthread *)current_thread; tobj->timer_next = tobj->timer_prev = NULL; _lock(&timerq_lock); #ifdef DEBUG // Check if timer is already in the list t1 = (struct timerobject *)timers; while (t1 != NULL && t1 != tobj) t1 = (struct timerobject *)t1->timer_next; if (t1 == tobj) { syscall_puts((char *)current_thread->kt_name); syscall_puts(" TIMER ALREADY IN THE QUEUE\n"); unlock(&timerq_lock); return -1; } #endif // Insert this timer object insert_timerobj(tobj); unlock(&timerq_lock); return 0; }
int display_putc(int chr) { struct msg_head msg; int r; if(display_queid==0) { r=display_init(); if(r<0) return r; } msg.size=sizeof(struct msg_head); msg.service=DISPLAY_SRV_DISPLAY; msg.command=DISPLAY_CMD_PUTC; msg.arg=chr; for(;;) { r=message_send(display_queid, &msg); if(r!=ERRNO_OVER) break; syscall_wait(10); } if(r<0) { syscall_puts("putc sndcmd="); long2hex(-r,s); syscall_puts(s); syscall_puts("\n"); return r; } 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; }
void do_syscall(TrapFrame *tf) { int id = tf->eax; switch(id) { case SYS_fork: syscall_fork(tf); break; case SYS_exec: syscall_exec(tf); break; case SYS_exit: syscall_exit(tf); break; case SYS_getpid: syscall_getpid(tf); break; case SYS_waitpid: syscall_waitpid(tf); break; case SYS_puts1: printk((char*)(tf->ebx)); printk(" %d\n", current->pid); break; case SYS_puts: syscall_puts(tf); break; case SYS_read_line: syscall_read_line(tf); break; case SYS_sleep: syscall_sleep(tf); break; case SYS_open: syscall_open(tf); break; case SYS_read: syscall_read(tf); break; case SYS_write: syscall_write(tf); break; case SYS_create: syscall_create(tf); break; case SYS_close: syscall_close(tf); break; case SYS_delete: syscall_delete(tf); break; case SYS_lseek: syscall_lseek(tf); break; case SYS_dup: syscall_dup(tf); break; case SYS_dup2: syscall_dup2(tf); break; case SYS_mkdir: syscall_mkdir(tf); break; case SYS_rmdir: syscall_rmdir(tf); break; case SYS_lsdir: syscall_lsdir(tf); break; case SYS_chdir: syscall_chdir(tf); break; //default: panic("Unknown system call type"); } }
int display_init(void) { int r; if(display_queid != 0) return 0; display_queid = environment_get_display((void*)CFG_MEM_USERARGUMENT); if(display_queid != 0) return 0; for(;;) { r = syscall_que_lookup(DISPLAY_QNM_DISPLAY); if(r==ERRNO_NOTEXIST) { syscall_wait(10); continue; } if(r<0) { syscall_puts("dsp_init srvq err="); long2hex(-r,s); syscall_puts(s); syscall_puts("\n"); return r; } display_queid = r; environment_make_display((void*)CFG_MEM_USERARGUMENT, display_queid); break; } /* syscall_puts("dspqids q="); int2dec(display_queid,s); syscall_puts(s); syscall_puts(","); int2dec(display_clientq,s); syscall_puts(s); syscall_puts("\n"); */ return 0; }
void syscall(struct _irq_regs *r) { int service = r->rax & 0xff; switch (service) { case printf: r->rax = syscall_printf((char *)(r->rsi), (void *)r->rdi); break; case getchar: r->rax = syscall_getchar(); break; case puts: r->rax = syscall_puts((char*)r->rsi); break; case getcwd: r->rax = syscall_getcwd((char *)r->rdi, (size_t)r->rcx); break; case opendir: r->rax = syscall_opendir((char *)r->rsi); break; case read_dirent_entry: r->rsi = syscall_read_dirent_entry(r->rsi, (char*)r->rdi, (unsigned long*)r->rcx); break; case get_file_info: r->rax = syscall_get_file_info((char*)r->rsi); break; case chdir: r->rax = syscall_chdir((char*)r->rsi); break; case exec: r->rax = syscall_exec((char*)r->rdi); break; default: kprintf("int 80, bad service, %d\r\n", service); break; } }
int test_engine() { MWCOORD x1,x2,y1,y2; unsigned long mask=0; int count=0; int y; psd = GdOpenScreen(); if(psd==NULL) { syscall_puts("GdOpenScreen error\n"); return 0; } GdSetForegroundPixelVal(psd, 7); GdSetBackgroundPixelVal(psd, 0); GdSetDash(&mask, &count); x1=100; x2=540; y1=100; y2= 380; GdLine(psd, x1, y1, x2, y1, 0); GdLine(psd, x2, y1, x2, y2, 0); GdLine(psd, x1, y2, x2, y2, 0); GdLine(psd, x1, y1, x1, y2, 0); for(y=0;y<8;y++) { GdSetForegroundPixelVal(psd, y); GdLine(psd, x1, y1+y, x2, y1+y, 0); } GdSetForegroundPixelVal(psd, 7); GdLine(psd, x1, y1, x2, y2, 0); syscall_wait(1000); GdCloseScreen(psd); return 0; }
int syscall_entry(int eax,int ebx,int ecx,int edx) { /* console_puts("[a="); int2str(eax,s); console_puts(s); console_puts(",b="); int2str(ebx,s); console_puts(s); console_puts(",c="); int2str(ecx,s); console_puts(s); console_puts(",d="); int2str(edx,s); console_puts(s); console_puts("]"); */ cpu_unlock(); task_set_lastfunc(eax); switch(eax) { case SYSCALL_FN_PUTC: eax = syscall_putc(ebx); break; case SYSCALL_FN_PUTS: eax = syscall_puts((char*)ebx); break; case SYSCALL_FN_GETCURSOR: eax = syscall_getcursor(); break; case SYSCALL_FN_SETCURSOR: eax = syscall_setcursor(ebx); break; case SYSCALL_FN_EXIT: eax = syscall_exit(ebx); break; case SYSCALL_FN_WAIT: eax = syscall_wait(ebx); break; case SYSCALL_FN_SHM_CREATE: eax = syscall_shm_create((unsigned int)ebx, (unsigned long)ecx, (unsigned int)edx); break; case SYSCALL_FN_SHM_SETNAME: eax = syscall_shm_setname(ebx, (unsigned int)ecx); break; case SYSCALL_FN_SHM_LOOKUP: eax = syscall_shm_lookup((unsigned int)ebx); break; case SYSCALL_FN_SHM_DELETE: eax = syscall_shm_delete(ebx); break; case SYSCALL_FN_SHM_GETSIZE: eax = syscall_shm_getsize(ebx, (unsigned long *)ecx); break; case SYSCALL_FN_SHM_MAP: eax = syscall_shm_map(ebx, (void *)ecx); break; case SYSCALL_FN_SHM_UNMAP: eax = syscall_shm_unmap(ebx, (void *)ecx); break; case SYSCALL_FN_SHM_GETPHYSICAL: eax = syscall_shm_getphysical(ebx, (unsigned int)ecx, (unsigned long *)edx); break; case SYSCALL_FN_SHM_PULL: eax = syscall_shm_pull(ebx, (unsigned int)ecx, (void *)edx); break; case SYSCALL_FN_QUE_CREATE: eax = syscall_que_create((unsigned int)ebx); break; case SYSCALL_FN_QUE_SETNAME: eax = syscall_que_setname(ebx, (unsigned int)ecx); break; case SYSCALL_FN_QUE_DELETE: eax = syscall_que_delete(ebx); break; case SYSCALL_FN_QUE_PUT: eax = syscall_que_put(ebx, (void *)ecx); break; case SYSCALL_FN_QUE_GET: eax = syscall_que_get(ebx, (void *)ecx); break; case SYSCALL_FN_QUE_TRYGET: eax = syscall_que_tryget(ebx, (void *)ecx); break; case SYSCALL_FN_QUE_PEEKSIZE: eax = syscall_que_peeksize(ebx); break; case SYSCALL_FN_QUE_TRYPEEKSIZE: eax = syscall_que_trypeeksize(ebx); break; case SYSCALL_FN_QUE_LOOKUP: eax = syscall_que_lookup((unsigned int)ebx); break; case SYSCALL_FN_QUE_LIST: eax = syscall_que_list(ebx, ecx, (void*)edx); break; case SYSCALL_FN_INTR_REGIST: eax = syscall_intr_regist(ebx, ecx); break; case SYSCALL_FN_DBG_LOCPUTS: eax = syscall_dbg_locputs(ebx, ecx, (char *)edx); break; case SYSCALL_FN_PGM_LOAD: eax = syscall_pgm_load((char *)ebx, ecx); break; case SYSCALL_FN_PGM_ALLOCATE: eax = syscall_pgm_allocate((char *)ebx, ecx, (unsigned long)edx); break; case SYSCALL_FN_PGM_LOADIMAGE: eax = syscall_pgm_loadimage(ebx, (void *)ecx, (unsigned long)edx); break; case SYSCALL_FN_PGM_SETARGS: eax = syscall_pgm_setargs(ebx, (char *)ecx, edx); break; case SYSCALL_FN_PGM_GETARGS: eax = syscall_pgm_getargs(ebx, (char *)ecx, edx); break; case SYSCALL_FN_PGM_START: eax = syscall_pgm_start(ebx, ecx); break; case SYSCALL_FN_PGM_DELETE: eax = syscall_pgm_delete(ebx); break; case SYSCALL_FN_PGM_SETTASKQ: eax = syscall_pgm_settaskq(ebx); break; case SYSCALL_FN_PGM_GETTASKQ: eax = syscall_pgm_gettaskq(ebx); break; case SYSCALL_FN_PGM_GETEXITCODE: eax = syscall_pgm_getexitcode(ebx); break; case SYSCALL_FN_PGM_LIST: eax = syscall_pgm_list(ebx, ecx, (void*)edx); break; case SYSCALL_FN_FILE_OPEN: eax = syscall_file_open((char *)ebx, ecx); break; case SYSCALL_FN_FILE_CLOSE: eax = syscall_file_close(ebx); break; case SYSCALL_FN_FILE_READ: eax = syscall_file_read(ebx, (void*)ecx, edx); break; case SYSCALL_FN_FILE_SIZE: eax = syscall_file_size(ebx, (unsigned int *)ecx); break; case SYSCALL_FN_FILE_DIROPEN: eax = syscall_file_opendir((unsigned long *)ebx, (char *)ecx); break; case SYSCALL_FN_FILE_DIRREAD: eax = syscall_file_readdir((unsigned long *)ebx, (char *)ecx); break; case SYSCALL_FN_FILE_DIRCLOSE: eax = syscall_file_closedir((unsigned long *)ebx); break; case SYSCALL_FN_KRN_GET_BIOS_INFO: eax = syscall_krn_get_bios_info((char *)ebx); break; case SYSCALL_FN_KRN_MEMORY_STATUS: eax = syscall_krn_memory_status((unsigned long *)ebx); break; case SYSCALL_FN_KRN_GET_SYSTIME: eax = syscall_krn_get_systime((void *)ebx); break; case SYSCALL_FN_ALARM_SET: eax = syscall_alarm_set((unsigned int)ebx, ecx, edx); break; case SYSCALL_FN_ALARM_UNSET: eax = syscall_alarm_unset(ebx, ecx); break; case SYSCALL_FN_MTX_LOCK: eax = syscall_mtx_lock((int *)ebx); break; case SYSCALL_FN_MTX_TRYLOCK: eax = syscall_mtx_trylock((int *)ebx); break; case SYSCALL_FN_MTX_UNLOCK: eax = syscall_mtx_unlock((int *)ebx); break; case SYSCALL_FN_DMA_SETMODE: eax = syscall_dma_setmode( (unsigned int)ebx, (unsigned int)ecx ); break; case SYSCALL_FN_DMA_ENABLE: eax = syscall_dma_enable( (unsigned int)ebx, (unsigned int)ecx ); break; case SYSCALL_FN_DMA_ALLOCBUFFER: eax = syscall_dma_allocbuffer( (unsigned int)ebx, (unsigned long)ecx ); break; case SYSCALL_FN_DMA_FREEBUFFER: eax = syscall_dma_freebuffer( (unsigned int)ebx ); break; case SYSCALL_FN_DMA_SETBUFFER: eax = syscall_dma_setbuffer( (unsigned int)ebx ); break; case SYSCALL_FN_DMA_PUSHBUFFER: eax = syscall_dma_pushbuffer( (unsigned int)ebx, (void*)ecx ); break; case SYSCALL_FN_DMA_PULLBUFFER: eax = syscall_dma_pullbuffer( (unsigned int)ebx, (void*)ecx ); break; default: eax = -1; } return eax; }
int systemcall(struct PAR_REGS *regs) { char *cpp1, *cpp2, **cppp1; //3, *cpp4, *cpp5, *cpp6, **cppp1, **cppp2; int i, ip1, ip2; //unsigned long old_cr0; switch (regs->eax) // Sys call number ? { case 0: return syscall_test(); case 1: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_open(CHARPPAR(regs->ebx), INTPAR(regs->ebx+4), INTPAR(regs+4+4)); case 2: return syscall_close(INTPAR(regs->ebx)); case 3: cpp1 = CHARPPAR(regs->ebx+4); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_read(INTPAR(regs->ebx), cpp1, INTPAR(regs->ebx+4+4)); case 4: cpp1 = CHARPPAR(regs->ebx+4); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_write(INTPAR(regs->ebx), cpp1, INTPAR(regs->ebx+4+4)); case 5: return syscall_lseek(INTPAR(regs->ebx), INTPAR(regs->ebx+4), INTPAR(regs->ebx+4+4)); case 6: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_mkdir(cpp1, INTPAR(regs->ebx+4)); case 7: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_rmdir(cpp1); case 8: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_chdir(cpp1); case 9: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_creat(cpp1, INTPAR(regs->ebx+4)); case 10: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; cpp1 = CHARPPAR(regs->ebx+4); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_rename(CHARPPAR(regs->ebx), CHARPPAR(regs->ebx+4)); case 11: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; cpp1 = CHARPPAR(regs->ebx+4); if (cpp1 < KERNELEND) return EINVALIDPTR; return (int) syscall_opendir(CHARPPAR(regs->ebx), (DIR *)CHARPPAR(regs->ebx+4)); case 12: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_closedir((DIR *) CHARPPAR(regs->ebx)); case 13: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; return (int) syscall_readdir((DIR *)CHARPPAR(regs->ebx)); case 14: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; cpp1 = CHARPPAR(regs->ebx+4); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_stat(CHARPPAR(regs->ebx),(struct stat *)CHARPPAR(regs->ebx+4)); case 15: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_unlink(CHARPPAR(regs->ebx)); case 16: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_chmod(CHARPPAR(regs->ebx),(mode_t)INTPAR(regs->ebx+4)); case 17: ip1 = INTPAR(regs->ebx); return syscall_dup(ip1); case 18: ip1 = INTPAR(regs->ebx); ip2 = INTPAR(regs->ebx + 4); return syscall_dup2(ip1, ip2); case 19: syscall_setcursor( INTPAR(regs->ebx),INTPAR(regs->ebx+4)); return 0; case 20: return syscall_getchar(); case 21: return syscall_getchare(); case 22: return syscall_getscanchar(); case 23: return syscall_putchar(CHARPAR(regs->ebx)); case 24: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_puts(CHARPPAR(regs->ebx)); case 25: cpp1 = CHARPPAR(regs->ebx); ip1 = INTPAR(regs->ebx + 4); syscall_seekdir((DIR *)cpp1, ip1); return 0; case 26: cpp1 = CHARPPAR(regs->ebx); return syscall_telldir((DIR *)cpp1); case 27: cpp1 = CHARPPAR(regs->ebx); syscall_rewinddir((DIR *)cpp1); return 0; case 32: cpp1 = CHARPPAR(regs->ebx+12); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_readblocks(INTPAR(regs->ebx), INTPAR(regs->ebx+4), INTPAR(regs->ebx+8), CHARPPAR(regs->ebx+12)); case 33: cpp1 = CHARPPAR(regs->ebx+12); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_writeblocks(INTPAR(regs->ebx), INTPAR(regs->ebx+4), INTPAR(regs->ebx+8), CHARPPAR(regs->ebx+12)); case 34: syscall_sync(0); return 0; case 50: syscall_tsleep(INTPAR(regs->ebx)); return 0; case 60: cpp1 = CHARPPAR(regs->ebx + 4); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_tsendto(SHORTPAR(regs->ebx), CHARPPAR(regs->ebx+4), INTPAR(regs->ebx+8), INTPAR(regs->ebx+12), INTPAR(regs->ebx+16), SHORTPAR(regs->ebx+20)); case 62: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; cpp1 = CHARPPAR(regs->ebx + 8); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_trecvfrom(CHARPPAR(regs->ebx), INTPAR(regs->ebx+4), SHORTPPAR(regs->ebx+8), INTPAR(regs->ebx+12)); case 65: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; cppp1 = (char **)CHARPPAR(regs->ebx+4); i = 0; while (cppp1[i] != NULL) { if (cppp1[i] < KERNELEND) return EINVALIDPTR; i++; } cppp1 = (char **)CHARPPAR(regs->ebx+8); i = 0; while (cppp1[i] != NULL) { if (cppp1[i] < KERNELEND) return EINVALIDPTR; i++; } return syscall_exectask(CHARPPAR(regs->ebx), (char **)CHARPPAR(regs->ebx+4), (char **)CHARPPAR(regs->ebx+8), INTPAR(regs->ebx+12)); case 66: syscall_exit(INTPAR(regs->ebx)); return 0; case 70: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; cpp1 = CHARPPAR(regs->ebx+4); if (cpp1 < KERNELEND && cpp1 != NULL) return EINVALIDPTR; cpp1 = CHARPPAR(regs->ebx+8); if (cpp1 < KERNELEND) return EINVALIDPTR; cpp1 = CHARPPAR(regs->ebx+12); if (cpp1 < KERNELEND && cpp1 != NULL) return EINVALIDPTR; return syscall_pthread_create((pthread_t *)INTPPAR(regs->ebx), (pthread_attr_t *)CHARPPAR(regs->ebx+4), (void *(*)(void *))INTPPAR(regs->ebx+8), (void *)CHARPPAR(regs->ebx+12)); case 71: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND && cpp1 != NULL) return EINVALIDPTR; syscall_pthread_exit((void *)CHARPPAR(regs->ebx)); return 0; case 72: cpp1 = CHARPPAR(regs->ebx+4); if (cpp1 < KERNELEND && cpp1 != NULL) return EINVALIDPTR; return syscall_pthread_join((pthread_t)INTPAR(regs->ebx), (void **)CHARPPAR(regs->ebx+4)); case 73: return syscall_pthread_detach((pthread_t)INTPAR(regs->ebx)); case 74: return syscall_pthread_yield(); case 75: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; cpp1 = CHARPPAR(regs->ebx+4); if (cpp1 < KERNELEND && cpp1 != NULL) return EINVALIDPTR; return syscall_pthread_mutex_init((pthread_mutex_t *)INTPAR(regs->ebx), (pthread_mutexattr_t *)CHARPPAR(regs->ebx+4)); case 76: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_pthread_mutex_trylock((pthread_mutex_t *)INTPAR(regs->ebx)); case 77: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_pthread_mutex_lock((pthread_mutex_t *)INTPAR(regs->ebx)); case 78: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_pthread_mutex_unlock((pthread_mutex_t *)INTPAR(regs->ebx)); case 79: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; cpp1 = CHARPPAR(regs->ebx+4); if (cpp1 < KERNELEND && cpp1 != NULL) return EINVALIDPTR; return syscall_pthread_cond_init((pthread_cond_t *)INTPAR(regs->ebx), (pthread_condattr_t *)CHARPPAR(regs->ebx+4)); case 80: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; cpp1 = CHARPPAR(regs->ebx+4); if (cpp1 < KERNELEND && cpp1 != NULL) return EINVALIDPTR; return syscall_pthread_cond_wait((pthread_cond_t *)INTPAR(regs->ebx), (pthread_mutex_t *)INTPPAR(regs->ebx+4)); case 81: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_pthread_cond_signal((pthread_cond_t *)INTPAR(regs->ebx)); case 82: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_pthread_cond_broadcast((pthread_cond_t *)INTPAR(regs->ebx)); case 83: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; cpp1 = CHARPPAR(regs->ebx+4); if (cpp1 < KERNELEND && cpp1 != NULL) return EINVALIDPTR; return syscall_pthread_barrier_init((pthread_barrier_t *)INTPAR(regs->ebx), (pthread_barrierattr_t *)INTPPAR(regs->ebx+4), INTPAR(regs->ebx+8)); case 84: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_pthread_barrier_wait((pthread_barrier_t *)INTPAR(regs->ebx)); case 90: return syscall_socket(INTPAR(regs->ebx), INTPAR(regs->ebx+4), INTPAR(regs->ebx+8)); case 91: cpp1 = CHARPPAR(regs->ebx+4); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_bind(INTPAR(regs->ebx), (struct sockaddr *)INTPPAR(regs->ebx+4), SHORTPAR(regs->ebx+8)); case 92: cpp1 = CHARPPAR(regs->ebx + 4); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_recv(INTPAR(regs->ebx), (void *)CHARPPAR(regs->ebx+4), (size_t)INTPAR(regs->ebx+8), INTPAR(regs->ebx+12)); case 93: cpp1 = CHARPPAR(regs->ebx + 4); if (cpp1 < KERNELEND) return EINVALIDPTR; cpp1 = CHARPPAR(regs->ebx+16); if (cpp1 < KERNELEND && cpp1 != NULL) return EINVALIDPTR; cpp1 = CHARPPAR(regs->ebx+20); if (cpp1 < KERNELEND && cpp1 != NULL) return EINVALIDPTR; return syscall_recvfrom(INTPAR(regs->ebx), (void *)CHARPPAR(regs->ebx+4), (size_t)INTPAR(regs->ebx+8), INTPAR(regs->ebx+12), (struct sockaddr *)CHARPPAR(regs->ebx+16), (socklen_t *)SHORTPPAR(regs->ebx+20)); case 94: cpp1 = CHARPPAR(regs->ebx + 4); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_send(INTPAR(regs->ebx), (void *)CHARPPAR(regs->ebx+4), (size_t)INTPAR(regs->ebx+8), INTPAR(regs->ebx+12)); case 95: cpp1 = CHARPPAR(regs->ebx + 4); if (cpp1 < KERNELEND) return EINVALIDPTR; cpp1 = CHARPPAR(regs->ebx + 16); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_sendto(INTPAR(regs->ebx), (void *)CHARPPAR(regs->ebx+4), (size_t)INTPAR(regs->ebx+8), INTPAR(regs->ebx+12), (struct sockaddr *)CHARPPAR(regs->ebx+16), (socklen_t)SHORTPAR(regs->ebx+20)); case 96: cpp1 = CHARPPAR(regs->ebx + 4); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_connect(INTPAR(regs->ebx), (struct sockaddr *)CHARPPAR(regs->ebx+4), (socklen_t)SHORTPAR(regs->ebx+8)); case 97: cpp1 = CHARPPAR(regs->ebx + 4); if (cpp1 < KERNELEND) return EINVALIDPTR; cpp1 = CHARPPAR(regs->ebx + 8); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_accept(INTPAR(regs->ebx), (struct sockaddr *)CHARPPAR(regs->ebx+4), (socklen_t *)CHARPPAR(regs->ebx+8)); case 98: return syscall_listen(INTPAR(regs->ebx), INTPAR(regs->ebx+4)); case 99: return syscall_kill(INTPAR(regs->ebx)); case 100: cpp1 = CHARPPAR(regs->ebx + 4); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_getprocinfo(INTPAR(regs->ebx), (struct uprocinfo *)INTPPAR(regs->ebx+4)); case 101: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_getpids(INTPPAR(regs->ebx), INTPAR(regs->ebx+4)); case 102: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_sem_init((sem_t *)(CHARPPAR(regs->ebx)), INTPAR(regs->ebx+4), (unsigned int)INTPAR(regs->ebx+8)); case 103: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_sem_destroy((sem_t *)(CHARPPAR(regs->ebx))); case 104: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; cpp1 = CHARPPAR(regs->ebx+16); if (cpp1 < KERNELEND) return EINVALIDPTR; return (int)syscall_sem_open(CHARPPAR(regs->ebx), INTPAR(regs->ebx+4), (mode_t)INTPAR(regs->ebx+8), INTPAR(regs->ebx+12), (sem_t *)CHARPPAR(regs->ebx+16)); case 105: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_sem_close((sem_t *)(CHARPPAR(regs->ebx))); case 106: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_sem_unlink(CHARPPAR(regs->ebx)); case 107: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_sem_wait((sem_t *)(CHARPPAR(regs->ebx))); case 108: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_sem_trywait((sem_t *)(CHARPPAR(regs->ebx))); case 109: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; cpp1 = CHARPPAR(regs->ebx+4); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_sem_timedwait((sem_t *)(CHARPPAR(regs->ebx)), (const struct timespec *)CHARPPAR(regs->ebx+4)); case 110: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_sem_post((sem_t *)(CHARPPAR(regs->ebx))); case 111: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; cpp1 = CHARPPAR(regs->ebx+4); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_sem_getvalue((sem_t *)(CHARPPAR(regs->ebx)), INTPPAR(regs->ebx+4)); case 112: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND && cpp1 != NULL) return EINVALIDPTR; return (int)syscall_time((time_t *)(CHARPPAR(regs->ebx))); case 113: return (int)syscall_pthread_self(); case 114: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND && cpp1 != NULL) return EINVALIDPTR; return syscall_brk((void *)CHARPPAR(regs->ebx)); case 115: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; cpp1 = CHARPPAR(regs->ebx+4); if (cpp1 < KERNELEND) return EINVALIDPTR; cpp1 = CHARPPAR(regs->ebx+8); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_gettsc((unsigned int *)INTPPAR(regs->ebx), (unsigned int *)INTPPAR(regs->ebx+4), (unsigned int *)INTPPAR(regs->ebx+8)); case 140: print_core_info(); print_minf_statistics(); return 0; case 147: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_wait(INTPPAR(regs->ebx)); case 148: return syscall_pageinfo(INTPAR(regs->ebx), INTPAR(regs->ebx+4)); case 153: syscall_machid(); return 0; case 154: return syscall_getcharf(INTPAR(regs->ebx)); case 155: return syscall_ungetcharf(INTPAR(regs->ebx), INTPAR(regs->ebx+4)); case 156: printk("broadcast called\n"); return syscall_broadcast(INTPAR(regs->ebx), CHARPPAR(regs->ebx+4), INTPAR(regs->ebx+8)); case 157: return syscall_primalloc((unsigned int)INTPAR(regs->ebx)); case 158: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_prifree((void *)CHARPPAR(regs->ebx), (unsigned int)INTPAR(regs->ebx+4)); case 202: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; cpp2 = CHARPPAR(regs->ebx + 4); if (cpp2 < KERNELEND) return EINVALIDPTR; mark_tsc((unsigned int *)cpp1, (unsigned int *)cpp2); return 0; case 203: return (secs * 1000 + millesecs); case 204: cpp1 = CHARPPAR(regs->ebx); if (cpp1 < KERNELEND) return EINVALIDPTR; return syscall_pthread_mutex_destroy((pthread_mutex_t *) cpp1); default: return syscall_notimplemented(regs->eax); } }
int display_puts(char *chr) { union display_msg msg; short len; int r; if(display_queid==0) { r=display_init(); if(r<0) return r; } /* if(display_queid<100) { syscall_puts(" qid="); int2dec(display_queid,s); syscall_puts(s); syscall_puts("\n"); } */ len=strlen(chr); if(len>=DISPLAY_STRLEN-1) len=DISPLAY_STRLEN-1; // msg.h.size=msg_size(sizeof(struct msg_head)+len+1); msg.h.size=sizeof(struct msg_head)+len+1; msg.h.service=DISPLAY_SRV_DISPLAY; msg.h.command=DISPLAY_CMD_PUTS; msg.h.arg=len; strncpy(msg.s.s, chr, DISPLAY_STRLEN); /* { char *ms=(char *)&msg; syscall_puts("sz="); int2dec(msg.h.size,s); syscall_puts(s); syscall_puts("arg="); int2dec(msg.h.arg,s); syscall_puts(s); syscall_puts("str="); byte2hex(ms[8],&s[0]); byte2hex(ms[9],&s[2]); syscall_puts(s); } */ for(;;) { r=message_send(display_queid, &msg); if(r!=ERRNO_OVER) break; syscall_wait(10); } if(r<0) { syscall_puts("puts sndcmd="); int2dec(-r,s); syscall_puts(s); syscall_puts(" qid="); int2dec(display_queid,s); syscall_puts(s); syscall_puts(" str="); syscall_puts(chr); syscall_puts("\n"); return r; } return 0; }