static uint32_t svga_draw_image(mp_image_t *mpi){ int i,x,y,w,h; int stride; uint8_t *rgbplane, *base; int bytesperline; int page; if(mpi->flags & MP_IMGFLAG_DIRECT){ if( mp_msg_test(MSGT_VO,MSGL_DBG3) ) mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: drawing direct rendered surface\n"); cpage=(uint32_t)mpi->priv; assert((cpage>=0)&&(cpage<max_pages)); return VO_TRUE; //it's already done } // if (mpi->flags&MP_IMGFLAGS_DRAWBACK) // return VO_TRUE;//direct render method 2 //find a free page to draw into //if there is no one then use the current one page = page_find_free(); if(page>=0) cpage=page; PageStore[cpage].locks=PAGE_BUSY; // these variables are used in loops x = mpi->x; y = mpi->y; w = mpi->w; h = mpi->h; stride = mpi->stride[0]; rgbplane = mpi->planes[0] + y*stride + (x*mpi->bpp)/8; x+=x_pos;//center y+=y_pos; if(mpi->bpp >= 8){//for modes<8 use only native if( (mode_capabilities&CAP_ACCEL_PUTIMAGE) && (x==0) && (w==mpi->width) && (stride == mode_stride) ){ //only monolite image can be accelerated w=(stride*8)/mpi->bpp;//we transfer pixels in the stride so the source //ACCELERATE if( mp_msg_test(MSGT_VO,MSGL_DBG3) ) mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: using HW PutImage (x=%d,y=%d,w=%d,h=%d)\n",x,y,w,h); if(mode_capabilities & CAP_ACCEL_BACKGR) vga_accel(ACCEL_SYNC); vga_accel(ACCEL_PUTIMAGE,x,y+PageStore[cpage].yoffset,w,h,rgbplane); return VO_TRUE; } if( mode_capabilities&CAP_LINEAR){ //DIRECT if( mp_msg_test(MSGT_VO,MSGL_DBG3) ) mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: using Direct memcpy (x=%d,y=%d,w=%d,h=%d)\n",x,y,w,h); bytesperline=(w*mpi->bpp)/8; base=PageStore[cpage].vbase + (y*mode_stride) + (x*mpi->bpp)/8; for(i=0;i<h;i++){ mem2agpcpy(base,rgbplane,bytesperline); base+=mode_stride; rgbplane+=stride; } return VO_TRUE; } }//(modebpp>=8 //NATIVE { int length; length=(w*mpi->bpp)/8; //one byte per pixel! svgalib innovation if(mpi->imgfmt==IMGFMT_RG4B || mpi->imgfmt==IMGFMT_BG4B) length=w; if( mp_msg_test(MSGT_VO,MSGL_DBG3) ) mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: using Native vga_draw(x=%d,y=%d,w=%d,h=%d)\n",x,y,w,h); y+=PageStore[cpage].yoffset;//y position of the page beggining for(i=0;i<h;i++){ vga_drawscansegment(rgbplane,x,y+i,length); rgbplane+=stride; } } return VO_TRUE; }
int new_thread( int type, struct process *proc, struct thread *parent, const char name[NAME_LENGTH], uint32_t entry, int priority, uint32_t data1, uint32_t data2, uint32_t data3, uint32_t data4 ) { struct thread *tr = (struct thread*)malloc( sizeof(struct thread) ); if ( tr == NULL ) return -1; strncpy( tr->name, name, NAME_LENGTH ); tr->tid = next_tid( proc ); tr->state = THREAD_SUSPENDED; tr->process = proc; tr->sched_state = -1; // architecture ... // tr->stack_user = page_find_free( proc->map, sK_BASE, sK_CEILING, sK_PAGES_THREAD + 1 ); tr->stack_user += (sK_PAGES_THREAD + 1) * PAGE_SIZE; // We're leaving a guard page at the bottom (and, // therefore, the top) of every thread stack. user_ensure( proc, tr->stack_user - (sK_PAGES_THREAD * PAGE_SIZE), sK_PAGES_THREAD ); tr->stack_kernel = (uint32_t) memory_alloc( sK_PAGES_KERNEL ); tr->stack_kernel += sK_PAGES_KERNEL * PAGE_SIZE; tr->cpu = -1; tr->cpu_affinity = -1; // No preference. tr->math_state = -1; tr->math = memory_alloc( 1 ); tr->stack = tr->stack_kernel; // ------------ if ( type == 1 ) { // kernel thread pushl( tr, GDT_SYSTEMDATA ); pushl( tr, tr->stack_user ); pushl( tr, EFLAG_BASE | EFLAG_INTERRUPT ); pushl( tr, GDT_SYSTEMCODE ); } else { // user thread pushl( tr, GDT_USERDATA | 3 ); pushl( tr, tr->stack_user ); pushl( tr, EFLAG_BASE | EFLAG_INTERRUPT ); pushl( tr, GDT_USERCODE | 3 ); } pushl( tr, entry ); pushl( tr, GDT_USERDATA | 3 ); // gs pushl( tr, GDT_USERDATA | 3 ); // fs pushl( tr, GDT_USERDATA | 3 ); // ds pushl( tr, GDT_USERDATA | 3 ); // es pushl( tr, data1 ); // eax pushl( tr, data3 ); // ecx pushl( tr, data4 ); // edx pushl( tr, data2 ); // ebx pushl( tr, 0 ); // temp esp pushl( tr, 0 ); // ebp pushl( tr, 0 ); // esi pushl( tr, 0 ); // edi FAMILY_INIT( tr ); LIST_INIT( tr ); // .... if ( proc->threads == NULL ) { proc->threads = tr; } else { if ( parent == NULL ) { family_add_sibling( &(parent->family_tree), &(tr->family_tree) ); list_insertAfter( &(proc->threads->list), &(tr->list) ); } else { family_add_child( &(parent->family_tree), &(tr->family_tree) ); list_insertAfter( &(proc->threads->list), &(tr->list) ); } } htable_insert( proc->threads_htable, tr ); proc->thread_count += 1; return tr->tid; }