void draw_char( void ) { static int first = 1; int i, j; if ( load_first ) { first = 1; load_first = 0; } if ( !first ) { putimage( 0 + align, 0, matrix_image, COPY_PUT ); } else { draw_grid( X, Y ); matrix_image = ( char * ) realloc( matrix_image, imagesize( 0 + align, 0, ( WIDTH_X + 2 )*X + align, ( WIDTH_Y + 2 )*Y ) ); getimage( 0 + align, 0, ( WIDTH_X + 2 )*X + align, ( WIDTH_Y + 2 )*Y, matrix_image ); } for ( j = 0; j < Y; j++ ) { for ( i = 0; i < X; i++ ) { if ( edit_font[i][j] ) { put_dot( i, j ); } else if ( first ) { square( i, j ); } } } first = 0; }
rtems_task Semaphore_task( rtems_task_argument argument ) { uint32_t count; rtems_status_code status; uint32_t yield_count; puts( "Getting SMID of semaphore" ); while ( FOREVER ) { status = rtems_semaphore_ident( Semaphore_name[ 1 ], RTEMS_SEARCH_ALL_NODES, &Semaphore_id[ 1 ] ); if ( status == RTEMS_SUCCESSFUL ) break; puts( "rtems_semaphore_ident FAILED!!" ); rtems_task_wake_after(2); } yield_count = 100; while ( Stop_Test == false ) { for ( count=SEMAPHORE_DOT_COUNT ; Stop_Test == false && count ; count-- ) { status = rtems_semaphore_obtain( Semaphore_id[ 1 ], RTEMS_DEFAULT_OPTIONS, RTEMS_NO_TIMEOUT ); directive_failed( status, "rtems_semaphore_obtain" ); status = rtems_semaphore_release( Semaphore_id[ 1 ] ); directive_failed( status, "rtems_semaphore_release" ); if ( Stop_Test == false ) if ( Multiprocessing_configuration.node == 1 && --yield_count == 0 ) { status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR ); directive_failed( status, "rtems_task_wake_after" ); yield_count = 100; } } put_dot( 's' ); } Exit_test(); }
rtems_task Partition_task( rtems_task_argument argument ) { uint32_t count; rtems_status_code status; uint32_t yield_count; void *buffer; puts( "Getting ID of partition" ); while ( FOREVER ) { status = rtems_partition_ident( Partition_name[ 1 ], RTEMS_SEARCH_ALL_NODES, &Partition_id[ 1 ] ); if ( status == RTEMS_SUCCESSFUL ) break; puts( "rtems_partition_ident FAILED!!" ); rtems_task_wake_after(2); } yield_count = 100; while ( Stop_Test == false ) { for ( count=PARTITION_DOT_COUNT ; Stop_Test == false && count ; count-- ) { status = rtems_partition_get_buffer( Partition_id[ 1 ], &buffer ); directive_failed( status, "rtems_partition_get_buffer" ); status = rtems_partition_return_buffer( Partition_id[ 1 ], buffer ); directive_failed( status, "rtems_partition_return_buffer" ); if (Stop_Test == false) if ( Multiprocessing_configuration.node == 1 && --yield_count == 0 ) { status = rtems_task_wake_after( 1 ); directive_failed( status, "rtems_task_wake_after" ); yield_count = 100; } } put_dot( 'p' ); } Exit_test(); }
rtems_task Delayed_events_task( rtems_task_argument argument ) { uint32_t count; uint32_t previous_mode; rtems_status_code status; rtems_event_set events; status = rtems_task_mode( RTEMS_PREEMPT | RTEMS_TIMESLICE, RTEMS_PREEMPT_MASK | RTEMS_TIMESLICE_MASK, &previous_mode ); directive_failed( status, "rtems_task_mode" ); status = rtems_timer_create( Timer_name[ 1 ], &Timer_id[ 1 ] ); directive_failed( status, "rtems_timer_create" ); while ( Stop_Test == FALSE ) { for ( count=DELAYED_EVENT_DOT_COUNT; Stop_Test == FALSE && count; count-- ){ status = rtems_timer_fire_after( Timer_id[ 1 ], 1, Delayed_send_event, NULL ); directive_failed( status, "rtems_timer_reset" ); status = rtems_event_receive( RTEMS_EVENT_16, RTEMS_DEFAULT_OPTIONS, RTEMS_NO_TIMEOUT, &events ); directive_failed( status, "rtems_event_receive" ); } put_dot('.'); } Exit_test(); }
void edit( int ch ) { struct viewporttype tmp; char key, *buff; take_char( ( char ) ch ); backup_char( ); getviewsettings( &tmp ); setviewport( 400, 30, getmaxx( ), getmaxy( ), 1 ); buff = ( char* ) malloc( imagesize( 0 + align, 0, X*( 2 + WIDTH_X ) + align, Y*( 2 + WIDTH_Y ) ) ); getimage( 0 + align, 0, X*( 2 + WIDTH_X ) + align, Y*( 2 + WIDTH_Y ), buff ); draw_char( ); start_clock( EDIT_FONT ); while ( ( key = get_pos( &pos_x, &pos_y, X - 1, Y - 1, 1, 1 ) ) != 3 ) { switch ( tolower( key ) ) { case 1: xor_dot( pos_x, pos_y ); continue; case '8': pan_up( ); draw_char( ); break; case '2': pan_down( ); draw_char( ); break; case '4': pan_left( ); draw_char( ); break; case '6': pan_right( ); draw_char( ); break; case 'r': insert_row( pos_y ); draw_char( ); break; case 'c': insert_col( pos_x ); draw_char( ); break; case 'e': del_row( pos_y ); draw_char( ); break; case 'd': del_col( pos_x ); draw_char( ); break; case 'i': invert( ); draw_char( ); break; case 'm': mirror( ); draw_char( ); break; case '.': ++draw_mode; switch ( draw_mode ) { case 0: break; case 1: put_dot( pos_x, pos_y ); edit_font[pos_x][pos_y] = ~0; break; case 2: square( pos_x, pos_y ); edit_font[pos_x][pos_y] = 0; break; case 3: draw_mode = 0; } continue; case 'u': undo( ); draw_char( ); goto exit; case '?': help( ); break; default: if ( draw_mode == 1 ) { put_dot( pos_x, pos_y ); edit_font[pos_x][pos_y] = ~0; } if ( draw_mode == 2 ) { square( pos_x, pos_y ); edit_font[pos_x][pos_y] = 0; } } } update_char( ( char ) ch ); exit: putimage( 0 + align, 0, buff, COPY_PUT ); free( buff ); stop_clock( ); dispblank( 50, 16, strlen( "Move mode" ), 0 ); setviewport( tmp.left, tmp.top, tmp.right, tmp.bottom, tmp.clip ); print_table( which_page( ch ) ); }
rtems_task Test_task( rtems_task_argument argument ) { rtems_status_code status; uint32_t count; uint32_t remote_node; rtems_id remote_tid; rtems_event_set event_out; rtems_event_set event_for_this_iteration; Stop_Test = FALSE; remote_node = (Multiprocessing_configuration.node == 1) ? 2 : 1; puts_nocr( "Remote task's name is : " ); put_name( Task_name[ remote_node ], TRUE ); puts( "Getting TID of remote task" ); do { status = rtems_task_ident( Task_name[ remote_node ], RTEMS_SEARCH_ALL_NODES, &remote_tid ); } while ( status != RTEMS_SUCCESSFUL ); directive_failed( status, "rtems_task_ident FAILED!!" ); if ( Multiprocessing_configuration.node == 1 ) puts( "Sending events to remote task" ); else puts( "Receiving events from remote task" ); status = rtems_timer_fire_after( Timer_id[ 1 ], 5 * TICKS_PER_SECOND, Stop_Test_TSR, NULL ); directive_failed( status, "rtems_timer_fire_after" ); count = 0; for ( ; ; ) { if ( Stop_Test == TRUE ) break; event_for_this_iteration = Event_set_table[ count % 32 ]; if ( Multiprocessing_configuration.node == 1 ) { status = rtems_event_send( remote_tid, event_for_this_iteration ); directive_failed( status, "rtems_event_send" ); status = rtems_task_wake_after( 1 ); directive_failed( status, "rtems_task_wake_after" ); } else { status = rtems_event_receive( event_for_this_iteration, RTEMS_DEFAULT_OPTIONS, 1 * TICKS_PER_SECOND, &event_out ); if ( rtems_are_statuses_equal( status, RTEMS_TIMEOUT ) ) { if ( Multiprocessing_configuration.node == 2 ) puts( "\nCorrect behavior if the other node exitted." ); else puts( "\nERROR... node 1 died" ); break; } else directive_failed( status, "rtems_event_receive" ); } if ( (count % DOT_COUNT) == 0 ) put_dot('.'); count++; } putchar( '\n' ); if ( Multiprocessing_configuration.node == 2 ) { status = rtems_event_receive( RTEMS_EVENT_16, RTEMS_DEFAULT_OPTIONS, 1 * TICKS_PER_SECOND, &event_out ); fatal_directive_status( status, RTEMS_TIMEOUT, "rtems_event_receive" ); puts( "rtems_event_receive - correctly returned RTEMS_TIMEOUT" ); } puts( "*** END OF TEST 6 ***" ); rtems_test_exit( 0 ); }
void Canvas:: fill_area() { const palette::index_t target_i = get_index(tool_point.x,tool_point.y); const palette::index_t source_i = get_color_index(); if(target_i == source_i) { return; } field.resize(module.get_width(),module.get_height()); field.fill(0); std::stack<Frame> stack; stack.emplace(tool_point.x,tool_point.y); START: if(stack.empty()) { return; } auto& top = stack.top(); switch(top.phase) { case(0): { auto& mark = field.get_element(top.x,top.y); if(mark) { stack.pop(); goto START; } mark = 1; auto& dst = get_index(top.x,top.y); if(dst == target_i) { put_dot(Dot(top.x,top.y,source_i)); } else { stack.pop(); goto START; } } case(1): if(top.x) { top.phase = 2; stack.emplace(top.x-1,top.y); goto START; } case(2): if(top.y) { top.phase = 3; stack.emplace(top.x,top.y-1); goto START; } case(3): if(top.x < (module.get_width()-1)) { top.phase = 4; stack.emplace(top.x+1,top.y); goto START; } case(4): if(top.y < (module.get_height()-1)) { top.phase = 5; stack.emplace(top.x,top.y+1); goto START; } case(5): default:; } stack.pop(); goto START; }
rtems_task Test_task( rtems_task_argument argument ) { uint32_t count; rtems_status_code status; puts( "Getting SMID of semaphore" ); do { status = rtems_semaphore_ident( Semaphore_name[ 1 ], RTEMS_SEARCH_ALL_NODES, &Semaphore_id[ 1 ] ); } while ( !rtems_is_status_successful( status ) ); if ( Multiprocessing_configuration.node == 2 ) { status = rtems_semaphore_delete( Semaphore_id[ 1 ] ); fatal_directive_status( status, RTEMS_ILLEGAL_ON_REMOTE_OBJECT, "rtems_semaphore_delete did not return RTEMS_ILLEGAL_ON_REMOTE_OBJECT" ); puts( "rtems_semaphore_delete correctly returned RTEMS_ILLEGAL_ON_REMOTE_OBJECT" ); } count = 0; /* number of times node 1 releases semaphore */ while ( FOREVER ) { put_dot( 'p' ); status = rtems_semaphore_obtain( Semaphore_id[ 1 ], RTEMS_DEFAULT_OPTIONS, RTEMS_NO_TIMEOUT ); if ( status != RTEMS_SUCCESSFUL ) { fatal_directive_status( status, RTEMS_OBJECT_WAS_DELETED, "rtems_semaphore_obtain" ); puts( "\nGlobal semaphore deleted" ); puts( "*** END OF TEST 8 ***" ); rtems_test_exit( 0 ); } if ( Multiprocessing_configuration.node == 1 && ++count == 1000 ) { status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() ); directive_failed( status, "rtems_task_wake_after" ); puts( "\nDeleting global semaphore" ); status = rtems_semaphore_delete( Semaphore_id[ 1 ] ); directive_failed( status, "rtems_semaphore_delete" ); puts( "*** END OF TEST 8 ***" ); rtems_test_exit( 0 ); } else { put_dot( 'v' ); status = rtems_semaphore_release( Semaphore_id[ 1 ] ); directive_failed( status, "rtems_semaphore_release FAILED!!" ); } } }
rtems_task Test_task( rtems_task_argument argument ) { rtems_status_code status; uint32_t count; uint32_t remote_node; rtems_id remote_tid; rtems_event_set event_out; remote_node = ((Multiprocessing_configuration.node == 1) ? 2 : 1); puts( "About to go to sleep!" ); status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() ); directive_failed( status, "rtems_task_wake_after" ); puts( "Waking up!" ); puts_nocr( "Remote task's name is : " ); put_name( Task_name[ remote_node ], TRUE ); puts( "Getting TID of remote task" ); while ( FOREVER ) { status = rtems_task_ident( Task_name[ remote_node ], RTEMS_SEARCH_ALL_NODES, &remote_tid ); if ( status == RTEMS_SUCCESSFUL ) break; puts( "rtems_task_ident FAILED!!" ); rtems_task_wake_after(2); } if ( Multiprocessing_configuration.node == 1 ) { puts( "Sending events to remote task" ); while ( Stop_Test == false ) { for ( count=EVENT_TASK_DOT_COUNT; Stop_Test == false && count; count-- ) { status = rtems_event_send( remote_tid, RTEMS_EVENT_16 ); directive_failed( status, "rtems_event_send" ); } put_dot( 'e' ); } } puts( "Receiving events from remote task" ); while ( Stop_Test == false ) { for ( count=EVENT_TASK_DOT_COUNT ; Stop_Test == false && count ; count-- ) { status = rtems_event_receive( RTEMS_EVENT_16, RTEMS_DEFAULT_OPTIONS, RTEMS_NO_TIMEOUT, &event_out ); directive_failed( status, "rtems_event_receive" ); } put_dot( 'e' ); } Exit_test(); }
void unss2_rect(VRaster *r,void *ucbuf, LONG pixsize, Coor xstart, Coor ystart, Ucoor width, Ucoor height) { /* Uncompress data into a rectangular area inside raster using word-run-length/delta compression scheme used in Autodesk Animator 386 for most frames except the first. (Unclipped.) */ static unsigned short x, y; static short lp_count; static short op_word; static short skip_size; static union {short *w; unsigned char *ub; char *b;} wpt; static short lastx; #define SBUF_SIZE 1024 static char sbuf[SBUF_SIZE]; static short *linebuf; static short *word, word_val; static int i; /* allocate the line buffer */ if(width > SBUF_SIZE) { if ((linebuf = (short *) malloc(width * sizeof(char))) == NULL) { return; } } else { linebuf = (short *) sbuf; } /* x-value of the last pixel in the line */ lastx = xstart + width - 1; /* wpt will walk the uncompress frame buffer */ wpt.w = (short *) ucbuf; /* get line count */ lp_count = *wpt.w++; /* get current line */ y = ystart; /* set current column */ lastx = xstart + width - 1; LINELOOP: /* if line counter is zero, then done */ if (lp_count == 0) { goto OUT; } /* get next op word */ op_word = *wpt.w++; /* if bits 15 and 14 are set, then skip to appropriate line */ if ((op_word & 0xc000) == 0xc000) { y -= op_word; goto LINELOOP; } /* if only bit 15 is set, then put the lower byte on the image */ if (op_word & 0x8000) { put_dot(r, op_word & 0xff, lastx, y); goto LINELOOP; } x = xstart; DELTALOOP: if (op_word == 0) { y++; lp_count--; goto LINELOOP; } x += *wpt.ub++; skip_size = *wpt.ub++; if (skip_size & 0x80) { skip_size = 256 - skip_size; word = linebuf; word_val = *wpt.w; for (i = 0; i < skip_size; i++) { *word++ = word_val; } skip_size <<= 1; put_rectpix(r, linebuf, x, y, skip_size, 1); x += skip_size; wpt.w++; } else { skip_size <<= 1; put_rectpix(r, wpt.ub, x, y, skip_size, 1); x += skip_size; wpt.ub += skip_size; } op_word--; goto DELTALOOP; OUT: /* if linebuf was allocated using 'malloc()', then free it */ if (linebuf != (short *) sbuf) { free(linebuf); } }
rtems_task Test_task( rtems_task_argument argument ) { rtems_status_code status; uint32_t count; uint32_t remote_node; rtems_id remote_tid; rtems_event_set event_out; Stop_Test = false; remote_node = (Multiprocessing_configuration.node == 1) ? 2 : 1; puts_nocr( "Remote task's name is : " ); put_name( Task_name[ remote_node ], TRUE ); puts( "Getting TID of remote task" ); do { status = rtems_task_ident( Task_name[ remote_node ], RTEMS_SEARCH_ALL_NODES, &remote_tid ); } while ( !rtems_is_status_successful( status ) ); if ( Multiprocessing_configuration.node == 1 ) { puts( "Sending first event to remote task" ); status = rtems_event_send( remote_tid, RTEMS_EVENT_16 ); directive_failed( status, "rtems_event_send" ); } status = rtems_timer_fire_after( Timer_id[ 1 ], 5 * rtems_clock_get_ticks_per_second(), Stop_Test_TSR, NULL ); directive_failed( status, "rtems_timer_fire_after" ); while ( true ) { for ( count=DOT_COUNT ; count && (Stop_Test == false) ; count-- ) { status = rtems_event_receive( RTEMS_EVENT_16, RTEMS_DEFAULT_OPTIONS, rtems_clock_get_ticks_per_second(), &event_out ); if ( status == RTEMS_TIMEOUT ) { printf("\nTA1 - RTEMS_TIMEOUT .. probably OK if the other node exits"); Stop_Test = true; break; } else directive_failed( status, "rtems_event_receive" ); status = rtems_event_send( remote_tid, RTEMS_EVENT_16 ); directive_failed( status, "rtems_event_send" ); } if ( Stop_Test ) break; put_dot('.'); } /* * Wait a bit before shutting down so we don't screw up the other node * when our MPCI shuts down */ rtems_task_wake_after(10); puts( "\n*** END OF TEST 7 ***" ); rtems_test_exit( 0 ); }
rtems_task Message_queue_task( rtems_task_argument index ) { rtems_status_code status; uint32_t count; uint32_t yield_count; uint32_t *buffer_count; uint32_t *overflow_count; size_t size; Msg_buffer[ index ][0] = 0; Msg_buffer[ index ][1] = 0; Msg_buffer[ index ][2] = 0; Msg_buffer[ index ][3] = 0; puts( "Getting ID of msg queue" ); while ( FOREVER ) { status = rtems_message_queue_ident( Queue_name[ 1 ], RTEMS_SEARCH_ALL_NODES, &Queue_id[ 1 ] ); if ( status == RTEMS_SUCCESSFUL ) break; puts( "rtems_message_queue_ident FAILED!!" ); rtems_task_wake_after(2); } if ( Multiprocessing_configuration.node == 1 ) { status = rtems_message_queue_send( Queue_id[ 1 ], (long (*)[4])Msg_buffer[ index ], 16 ); directive_failed( status, "rtems_message_queue_send" ); overflow_count = &Msg_buffer[ index ][0]; buffer_count = &Msg_buffer[ index ][1]; } else { overflow_count = &Msg_buffer[ index ][2]; buffer_count = &Msg_buffer[ index ][3]; } while ( Stop_Test == false ) { yield_count = 100; for ( count=MESSAGE_DOT_COUNT ; Stop_Test == false && count ; count-- ) { status = rtems_message_queue_receive( Queue_id[ 1 ], Msg_buffer[ index ], &size, RTEMS_DEFAULT_OPTIONS, RTEMS_NO_TIMEOUT ); directive_failed( status, "rtems_message_queue_receive" ); if ( *buffer_count == (uint32_t)0xffffffff ) { *buffer_count = 0; *overflow_count += 1; } else *buffer_count += 1; status = rtems_message_queue_send( Queue_id[ 1 ], Msg_buffer[ index ], 16 ); directive_failed( status, "rtems_message_queue_send" ); if (Stop_Test == false) if ( Multiprocessing_configuration.node == 1 && --yield_count == 0 ) { status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR ); directive_failed( status, "rtems_task_wake_after" ); yield_count = 100; } } put_dot( 'm' ); } Exit_test(); }