Пример #1
0
void test_byte(void * pParam)
{
	RAW_U16 ret;

	RAW_U32 i = 0;

	raw_byte_pool_create(&byte_mem_pool_test, (RAW_U8 *)"byte", byte_mem_pool, 1024 * 1024);

	while (1) {
		
		i++;
		ret = raw_byte_allocate(&byte_mem_pool_test, (RAW_VOID **)&aa, 2022);

		if (ret == RAW_NO_MEMORY) {
			vc_port_printf("RAW_NO_MEMORY\n");
			RAW_ASSERT(0);
		}

		ret = raw_byte_allocate(&byte_mem_pool_test, (RAW_VOID **)&bb, 2000);

		if (ret == RAW_NO_MEMORY) {
			vc_port_printf("RAW_NO_MEMORY\n");
			RAW_ASSERT(0);
		}


		raw_byte_release(&byte_mem_pool_test, bb);
		vc_port_printf("allocate byte %d\n", i);

	}

  

}
Пример #2
0
void fatfs_init(unsigned char prio)
{
	FRESULT fret;
	
	raw_printf("FatFs init...\r\t\t\t\t");
	disk_initialize(0);
	fret = f_mount(&_FS, _T("0"), 0);
	if(FR_OK != fret)
	{
		RAW_ASSERT(0);
	}
	raw_printf("[OK]\n");
	
//	if( need_format(0) )
	if(1)
	{
		raw_printf("mkfs ...\r\t\t\t\t");
		fret = f_mkfs(_T("0:"), 0, 512);
		if(FR_OK != fret)
		{
			RAW_ASSERT(0);
		}
		raw_printf("[OK]\n");
	}
}
Пример #3
0
/*
************************************************************************************************************************
*                                  Fire to active_object with the specified sig
*
* Description: This function is to fire to active_object with the specified sig
*
* Arguments  :me is the TIME_EVENT_STRUCT object
*                   --------------
*                   active_object is the timer want fire to
*                    --------------
*                    ticks is how long need to fire.
*                    -----------------------
*                    once is just fire once if once is set to 1.
* Returns			
*						
* Note(s)   If fire a once timer, just reuse this function every time, but you have to deactivate the timer if timer is not once before use it.
*
*             
************************************************************************************************************************
*/
void active_time_event_fire(TIME_EVENT_STRUCT *me, ACTIVE_OBJECT_STRUCT *active_object, RAW_TICK_TYPE ticks, RAW_U8 once)
{
	RAW_OS_ERROR ret;

	me->active_object = active_object;


	if (once) {

		ret = raw_timer_change(&me->timer, ticks, 0);
	}

	else {

		ret = raw_timer_change(&me->timer, ticks, ticks);

	}

	if (ret != RAW_SUCCESS) {

		RAW_ASSERT(0);
	}

	ret = raw_timer_activate(&me->timer, me);

	if (ret != RAW_SUCCESS) {

		RAW_ASSERT(0);
	}
	
}
Пример #4
0
/*
************************************************************************************************************************
*                                   Init the finit state machine
*
* Description: This function is used to init the finit state machine.
*
* Arguments  :me is the state machine
*                    ---------
*                    e is the trig event   
*				         
* Returns			
*						
* Note(s)    	
*
*             
************************************************************************************************************************
*/
RAW_U16 fsm_init1(STM_STRUCT *me, STATE_EVENT *e) 
{
    RAW_U16 ret;
	
    if (me->temp == 0) {

		RAW_ASSERT(0);

    }

	/*do the fsm constructor init function*/
	ret = (*me->temp)(me, e);

	/*transition must happen here*/
	if (ret != STM_RET_TRAN) {
		
		RAW_ASSERT(0);
	}

	/*trig the STM_ENTRY_SIG to the new transioned state*/
    STM_TRIG(me->temp, STM_ENTRY_SIG);

	/*change to new state*/
    me->state = me->temp; 

	return STM_SUCCESS;

   
}
Пример #5
0
RAW_VOID rsh_register_command(const xCommandLineInput * const pxCommandToRegister, xCommandLineInputListItem *pxNewListItem)
{

	/* Check the parameter is not NULL. */
	if (pxCommandToRegister == 0) {

		RAW_ASSERT(0);
	}

	
	if (pxNewListItem == 0) {
		
		RAW_ASSERT(0);
	}

	
	/* Reference the command being registered from the newly created 
	list item. */
	pxNewListItem->pxCommandLineDefinition = pxCommandToRegister;

	/* The new list item will get added to the end of the list, so 
	pxNext has nowhere to point. */
	pxNewListItem->pxNext = 0;

	/* Add the newly created list item to the end of the already existing
	list. */
	current_command_list_point->pxNext = pxNewListItem;

	/* Set the end of list marker to the new list item. */
	current_command_list_point = pxNewListItem;
	
}
Пример #6
0
/*
************************************************************************************************************************
*                                    Create an active object  
*
* Description: This function is called to post an event to active object
*
* Arguments  :me is the address of this active object
*                    ---------
*                    prio is the priority of this active object            
*			 ---------
*                    msg_start is the start address of active queue which is belonged to this active object
*			 ---------
*			 qLen is the active queue length
*			 ---------
*			 stkSto is the start stack address of this active object
*			 ---------
*			 stkSize is the stack size of this active object
*			 ---------
*			 event is the init event.
* Returns			
*						
* Note(s)    	
*
*             
************************************************************************************************************************
*/
void active_object_create(ACTIVE_OBJECT_STRUCT *me, RAW_U8 prio,
                   void **msg_start, RAW_U32 qLen,
                   void *stkSto, RAW_U32 stkSize,
                   STATE_EVENT *event)
{
	RAW_OS_ERROR err;

	err = raw_queue_create(&me->active_queue, (RAW_U8 *)"queue", msg_start, qLen);

	if (err != RAW_SUCCESS) {

		RAW_ASSERT(0);
	}


	me->prio = prio;                                

	hsm_init(&me->father, event);

	me->user_data = 1;

	err = raw_task_create(&me->thread, (RAW_U8  *)"task5", me,
	                 me->prio, 0,   stkSto, 
	                 stkSize, active_task_function, 1); 

	if (err != RAW_SUCCESS) {

		RAW_ASSERT(0);
	}
	
}
Пример #7
0
void test_block(void * pParam)
{
	RAW_U16 ret;
	RAW_U32 i = 0;

	
	raw_block_pool_create(&mem_pool_test, (RAW_U8  *)"blockqewq", 12, mem_pool, 1024 * 4);

	while (1) {
		
		i++;

		ret = raw_block_allocate(&mem_pool_test, (RAW_VOID **)&aa);

		if (ret == RAW_NO_MEMORY) {
			vc_port_printf("RAW_NO_MEMORY1\n");
			RAW_ASSERT(0);
		}

		vc_port_printf("****************\n");
		ret = raw_block_allocate(&mem_pool_test, (RAW_VOID **)&bb);

		if (ret == RAW_NO_MEMORY) {
			vc_port_printf("RAW_NO_MEMORY2\n");
			RAW_ASSERT(0);
		}

		raw_block_release(&mem_pool_test, bb);

		vc_port_printf("allocate block %d\n", i);
	 
	}


}
Пример #8
0
void app_receive_task2_mqueue(void * pParam) 
{	
	int *data1;
		int *data2;
			int *data3;
				int *data4;
					int *data5;
					
	RAW_U32 msg_length1;
	RAW_U32 msg_length2;
	RAW_U32 msg_length3;
	RAW_U32 msg_length4;
	RAW_U32 msg_length5;


	RAW_U32 pri1;
	RAW_U32 pri2;
	RAW_U32 pri3;
	RAW_U32 pri4;
	RAW_U32 pri5;
	
	while(1) {
		
	
		raw_mq_receive (&app_queue2_mqueue,  &data1, &msg_length1, &pri1,  RAW_WAIT_FOREVER);
		
		if (*data1 != 0x188)
			RAW_ASSERT(0);
		
		raw_mq_receive (&app_queue2_mqueue,  &data2, &msg_length2, &pri2,  RAW_WAIT_FOREVER);
		
		if (*data2 != 0x188)
			RAW_ASSERT(0);
		
		raw_mq_receive (&app_queue2_mqueue,  &data3, &msg_length3, &pri3,  RAW_WAIT_FOREVER);

		if (*data3 != 0x188)
			RAW_ASSERT(0);
		
		raw_mq_receive (&app_queue2_mqueue,  &data4, &msg_length4, &pri4,  RAW_WAIT_FOREVER);

		if (*data4 != 0x188)
			RAW_ASSERT(0);
		
		raw_mq_receive (&app_queue2_mqueue,  &data5, &msg_length5, &pri5,  RAW_WAIT_FOREVER);

		if (*data5 != 0x188)
			RAW_ASSERT(0);
		
	
	}
}
Пример #9
0
void idle_event_init(void) 
{

	ACTIVE_EVENT_STRUCT *temp;
	RAW_U8 i;

	/*Init idle task queue information, MAX_IDLE_EVENT_TASK max 64 is allowed*/
	for (i = 0; i <= MAX_IDLE_EVENT_TASK - 1; i++) {
		temp = active_idle_task[i].act;

		RAW_ASSERT(temp != 0); 
		
		temp->prio = i;
		temp->head    = 0;
		temp->tail    = 0;
		temp->nUsed   = 0;

		temp->priority_x = i & 0x7;
		temp->priority_y = i >> 3;
		
		temp->priority_bit_y = (RAW_U8 )(1 << temp->priority_y);
		temp->priority_bit_x = (RAW_U8 )(1 << temp->priority_x);

	}

	/*Init the list*/
	list_init(&raw_idle_tick_head);

}
Пример #10
0
/*
 * Initialization of device registration information table
 */
static void init_device( void )
{
	DevCB	*devcb;
	INT	num;
	ER	ercd;

	num = MaxRegDev;

	/* Generate device registration information table */
	DevCBtbl = raw_malloc(num * sizeof(DevCB));
	
	if (DevCBtbl == NULL) {
		
		RAW_ASSERT(0);
	}

	list_init(&UsedDevCB);
	list_init(&FreeDevCB);

	devcb = DevCBtbl;
	while ( num-- > 0 ) {
		list_insert(&FreeDevCB, &devcb->q);
		devcb->devnm[0] = '\0';
		devcb++;
	}

	return RAW_SUCCESS;
	
}
Пример #11
0
static void work_queue_task(void *pa)
{
	RAW_OS_ERROR  ret;
	OBJECT_WORK_QUEUE_MSG *msg_recv;
	WORK_QUEUE_STRUCT *wq;

	RAW_SR_ALLOC();
	
	wq = pa;

	while (1) {

		ret = raw_queue_receive (&wq->queue, RAW_WAIT_FOREVER, (void **)(&msg_recv));

		if (ret != RAW_SUCCESS) {
			
			RAW_ASSERT(0);

		}

		msg_recv->handler(msg_recv->arg, msg_recv->msg);

		RAW_CPU_DISABLE();

		msg_recv->next = free_work_queue_msg;
		free_work_queue_msg = msg_recv;

		RAW_CPU_ENABLE();


	}

}
Пример #12
0
/*
************************************************************************************************************************
*                                    Post an event to active object  
*
* Description: This function is called to post an event to active object (Implemented as FIFO way)
*
* Arguments  :me is the address of this active object
*                    ---------
*                    event is the address of sending event               
*				         
* Returns			
*						
* Note(s)    	
*
*             
************************************************************************************************************************
*/
void active_event_post_end(ACTIVE_OBJECT_STRUCT *me, STATE_EVENT *event)
{
	RAW_OS_ERROR err;

	RAW_SR_ALLOC();
	

	RAW_CPU_DISABLE();

	if (event->which_pool) {          
		event->ref_count++;          
	}

	RAW_CPU_ENABLE();

	err = raw_queue_end_post(&me->active_queue, (void *)event);

	if (err != RAW_SUCCESS) {

		RAW_ASSERT(0);

	}

	

	
	
}
Пример #13
0
/*
************************************************************************************************************************
*                                    Post an event to active object  
*
* Description: This function is called to post an event to active object (Implemented as LIFO way)
*
* Arguments  :me is the address of this active object
*                    ---------
*                    event is the address of sending event               
*				         
* Returns			
*						
* Note(s)    	
*
*             
************************************************************************************************************************
*/
void active_event_post_front(ACTIVE_OBJECT_STRUCT *me, STATE_EVENT *event)
{

	RAW_U16 ret;

	RAW_SR_ALLOC();

	RAW_CPU_DISABLE();

	if (event->which_pool) {          
		event->ref_count++;          
	}

	RAW_CPU_ENABLE();

	ret = raw_queue_front_post(&me->active_queue, (void *)event);

	if (ret != RAW_SUCCESS) {

		RAW_ASSERT(0);

	}

	
	
}
Пример #14
0
/*
************************************************************************************************************************
*                                   exceute the finit state machine
*
* Description: This function is used to exceute the finit state machine.
*
* Arguments  :me is the state machine
*                    ---------
*                    e is the trig event 
*				         
* Returns			
*						
* Note(s)    	
*
*             
************************************************************************************************************************
*/
void fsm_exceute(STM_STRUCT *me, STATE_EVENT *e) 
{
	RAW_U16 ret;

	/*State must be stable here*/
	if (me->state != me->temp) {

		RAW_ASSERT(0);

	}

	/*exceute the state function with new event*/
    ret = (*me->state)(me, e); 
	
    if (ret == STM_RET_TRAN) {                            

		/*exit the original state */
		STM_EXIT(me->state); 
		/*enter the new state*/
		STM_ENTER(me->temp); 
		/*change to new state*/
		me->state = me->temp; 
    }
   
}
Пример #15
0
/*this function can be used in interrupt*/
int
process_post(struct process *p, process_event_t ev, process_data_t data)
{
  static process_num_events_t snum;
  RAW_SR_ALLOC();
  
  if(nevents == PROCESS_CONF_NUMEVENTS) {

    RAW_ASSERT(0);
  }

  RAW_CRITICAL_ENTER();
  
  snum = (process_num_events_t)(fevent + nevents) & (PROCESS_CONF_NUMEVENTS - 1);
  ++nevents;
  
  RAW_CRITICAL_EXIT();
  
  events[snum].ev = ev;
  events[snum].data = data;
  events[snum].p = p;
  
  if(nevents > process_maxevents) {
    process_maxevents = nevents;
  }

  
  return PROCESS_ERR_OK;
}
Пример #16
0
static void prvHeapInit( void )
{
	xBlockLink *pxFirstFreeBlock;
	unsigned char *pucHeapEnd, *pucAlignedHeap;

	/* Ensure the heap starts on a correctly aligned boundary. */
	pucAlignedHeap = ( unsigned char * ) ( ( ( portPOINTER_SIZE_TYPE ) &ucHeap[ portBYTE_ALIGNMENT ] ) & ( ( portPOINTER_SIZE_TYPE ) ~portBYTE_ALIGNMENT_MASK ) );

	/* xStart is used to hold a pointer to the first item in the list of free
	blocks.  The void cast is used to prevent compiler warnings. */
	xStart.pxNextFreeBlock = ( void * ) pucAlignedHeap;
	xStart.xBlockSize = ( size_t ) 0;

	/* pxEnd is used to mark the end of the list of free blocks and is inserted
	at the end of the heap space. */
	pucHeapEnd = pucAlignedHeap + xTotalHeapSize;
	pucHeapEnd -= heapSTRUCT_SIZE;
	pxEnd = ( void * ) pucHeapEnd;
	RAW_ASSERT( ( ( ( unsigned long ) pxEnd ) & ( ( unsigned long ) portBYTE_ALIGNMENT_MASK ) ) == 0UL );
	pxEnd->xBlockSize = 0;
	pxEnd->pxNextFreeBlock = NULL;

	/* To start with there is a single free block that is sized to take up the
	entire heap space, minus the space taken by pxEnd. */
	pxFirstFreeBlock = ( void * ) pucAlignedHeap;
	pxFirstFreeBlock->xBlockSize = xTotalHeapSize - heapSTRUCT_SIZE;
	pxFirstFreeBlock->pxNextFreeBlock = pxEnd;

	/* The heap now contains pxEnd. */
	xFreeBytesRemaining -= heapSTRUCT_SIZE;

	/* Work out the position of the top bit in a size_t variable. */
	xBlockAllocatedBit = ( ( size_t ) 1 ) << ( ( sizeof( size_t ) * heapBITS_PER_BYTE ) - 1 );
}
Пример #17
0
static void active_task_function(void *pdata) 
{       
	STATE_EVENT *e;
	RAW_OS_ERROR err;

	ACTIVE_OBJECT_STRUCT *object = pdata;


	while (object->user_data == 1) {

		e = active_event_get(object);

		hsm_exceute(&object->father, e);

		active_memory_collect(e);

	}


	err = raw_task_delete(raw_task_identify());

	if (err != RAW_SUCCESS) {

		RAW_ASSERT(0);

	}
	
}
Пример #18
0
void raw_stack_check(void)
{
	PORT_STACK *task_stack_start;

	task_stack_start = raw_task_active->task_stack_base;

	/*statck check method 1*/
	if (*task_stack_start) {

		RAW_ASSERT(0);
	}

	/*statck check method 2*/
	if ((PORT_STACK *)(raw_task_active->task_stack) < task_stack_start) {

		RAW_ASSERT(0);
	}

}
Пример #19
0
/*
************************************************************************************************************************
*                                    Delete an event  object  
*
* Description: This function is called to delete an event to active object.
*
* Arguments  :me is the address of this active object
*                   
*                              
*				         
* Returns			
*						
* Note(s)    	
*
*             
************************************************************************************************************************
*/
void active_object_delete(ACTIVE_OBJECT_STRUCT *me)
{
	RAW_OS_ERROR err;
	me->user_data = 0;                        
	err = raw_queue_delete(&me->active_queue);

	if (err != RAW_SUCCESS) {

		RAW_ASSERT(0);
	}
}
Пример #20
0
/*
************************************************************************************************************************
*                                       Activate  the specified timer
*
* Description: This function is called to activate  the specified timer
*
* Arguments  :timer_ptr is the address of this timer object
*                    -----
*                
*				         
*				         
* Returns   RAW_TIMER_STATE_INVALID:  means timer is already active or timer is deleted..
*				   RAW_SUCCESS: means timer activate success
* Note(s)    :RAW_STATE_UNKNOWN wrong task state, probally sysytem error.
*
*             
************************************************************************************************************************
*/
RAW_U16 raw_timer_activate(RAW_TIMER *timer_ptr, RAW_VOID *expiration_input)
{
	RAW_U16 position;
	RAW_U16 mutex_ret;
	
	#if (RAW_TIMER_FUNCTION_CHECK > 0)
	
	if (timer_ptr == 0) {
		return RAW_NULL_OBJECT;
	}

	if (raw_int_nesting) {

		return RAW_NOT_CALLED_BY_ISR;
		
	}

	
	#endif

	if (timer_ptr->object_type != RAW_TIMER_OBJ_TYPE) {

		return RAW_ERROR_OBJECT_TYPE;
	}
	
	/*Timer state TIMER_ACTIVE TIMER_DELETED is not allowed to delete*/
	if (timer_ptr->timer_state == TIMER_ACTIVE) {
		
		return RAW_TIMER_STATE_INVALID;	
	}

	if (timer_ptr->timer_state == TIMER_DELETED) {
		
		return RAW_TIMER_STATE_INVALID;
	}

	timer_ptr->raw_timeout_param = expiration_input;
	
	mutex_ret = raw_mutex_get(&timer_mutex, RAW_WAIT_FOREVER);
	RAW_ASSERT(mutex_ret == RAW_SUCCESS);
		
	timer_ptr->match  = raw_timer_count + timer_ptr->init_count;
	position   = (RAW_U16)(timer_ptr->match & (TIMER_HEAD_NUMBERS - 1) );
	/*Sort by remain time*/
	timer_ptr->remain = timer_ptr->init_count;
	/*Used by timer delete*/
	timer_ptr->to_head = &timer_head[position];
	
	timer_list_priority_insert(&timer_head[position], timer_ptr);
	timer_ptr->timer_state = TIMER_ACTIVE;
	raw_mutex_put(&timer_mutex);

	return RAW_SUCCESS;
}
Пример #21
0
void raw_stack_check(void)
{
	PORT_STACK *task_stack_start;
	PORT_STACK *task_stack_end;

	task_stack_start = raw_task_active->task_stack_base;
	
	task_stack_end = task_stack_start + raw_task_active->stack_size;

	if (*(task_stack_end - 1)) {

		RAW_ASSERT(0);
	}

	if ((PORT_STACK *)(raw_task_active->task_stack) > task_stack_end) {

		RAW_ASSERT(0);
	}

}
Пример #22
0
/*
************************************************************************************************************************
*                                   Post an event  to a defered queue
*
* Description: This function is called to post an event  to a defered queue.
*
* Arguments  :q is the address of the defered queue
*                    ---------
*                    event is the defered event           
*				         
* Returns			
*						
* Note(s)    	
*
*             
************************************************************************************************************************
*/
void active_event_defer_post(RAW_QUEUE *q, STATE_EVENT *event)
{
	RAW_OS_ERROR err;

	err = raw_queue_end_post(q, (void *)event);

	if (err != RAW_SUCCESS) {

		RAW_ASSERT(0);

	}
}
Пример #23
0
/*
************************************************************************************************************************
*                                   Post an event  to a defered queue
*
* Description: This function is called to post an event  to a defered queue.
*
* Arguments  :q is the address of the defered queue
*                    ---------
*                    event is the defered event           
*				         
* Returns			
*						
* Note(s)    	
*
*             
************************************************************************************************************************
*/
void active_event_defer_post(RAW_QUEUE *q, STATE_EVENT *event)
{
	RAW_U16 ret;

	ret = raw_queue_end_post(q, (void *)event);

	if (ret != RAW_SUCCESS) {

		RAW_ASSERT(0);

	}
}
Пример #24
0
/*
 * Device registration
 */
RAW_U32 _tk_def_dev( CONST UB *devnm, CONST T_DDEV *ddev, void *caller_gp )
{
	DevCB	*devcb;
	INT	len, evttyp;
	ER	ercd;


	len = ChkSpaceBstrR(devnm, 0);
	
	if ( len <= 0 || len > MaxRegDev ) {
		
		RAW_ASSERT(0);
	}


	/* Search whether 'devnm' device is registered */
	devcb = searchDevCB(devnm);
	if ( devcb == 0 ) {
		if ( ddev == 0 ) {
			ercd = E_NOEXS;
			goto err_ret2;
		}

		/* Get 'devcb' for new registration because it is not
		   registered */
		devcb = newDevCB(devnm);
		if ( devcb == NULL ) {
			ercd = E_LIMIT;
			goto err_ret2;
		}
	}

	if ( ddev != NULL ) {
		/* Set/update device registration information */
		devcb->ddev = *ddev;

		evttyp = TSEVT_DEVICE_REGIST;
	} else {
		if ( !isQueEmpty(&devcb->openq) ) {
			/* In use (open) */
			ercd = E_BUSY;
			goto err_ret2;
		}

		/* Device unregistration */
		delDevCB(devcb);
		evttyp = TSEVT_DEVICE_DELETE;
	}

	return DID(devcb);
}
Пример #25
0
/*
************************************************************************************************************************
*                                   Init the time event for post specified sig
*
* Description: This function is to init the time event for post specified sig
*
* Arguments  :me is the TIME_EVENT_STRUCT object
*                   --------------
*                   sig is the timer want to fire
* Returns			
*						
* Note(s)   
*
*             
************************************************************************************************************************
*/
void active_time_event_create(TIME_EVENT_STRUCT *me, RAW_U16 sig) 
{
	RAW_OS_ERROR ret;

	if (sig < STM_USER_SIG) {

		RAW_ASSERT(0);
	}


	me->active_object= 0;
	me->father.sig = sig;
	me->father.which_pool = 0;
	
	ret = raw_timer_create(&me->timer, (RAW_U8  *)"timer", active_time_event_post, 0,1,0,0);

	if (ret != RAW_SUCCESS) {

		RAW_ASSERT(0);

	}
	
}
Пример #26
0
void mem_4_free(void *pv)
{
	unsigned char *puc = ( unsigned char * ) pv;
	xBlockLink *pxLink;

	if( pv != NULL )
	{
		/* The memory being freed will have an xBlockLink structure immediately
		before it. */
		puc -= heapSTRUCT_SIZE;

		/* This casting is to keep the compiler from issuing warnings. */
		pxLink = ( void * ) puc;

		/* Check the block is actually allocated. */
		RAW_ASSERT( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 );
		RAW_ASSERT( pxLink->pxNextFreeBlock == NULL );
		
		if( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 )
		{
			if( pxLink->pxNextFreeBlock == NULL )
			{
				/* The block is being returned to the heap - it is no longer
				allocated. */
				pxLink->xBlockSize &= ~xBlockAllocatedBit;

				raw_disable_sche();
				{
					/* Add this block to the list of free blocks. */
					xFreeBytesRemaining += pxLink->xBlockSize;
					prvInsertBlockIntoFreeList( ( ( xBlockLink * ) pxLink ) );
				}
				raw_enable_sche();
			}
		}
	}
}
Пример #27
0
void test_heap(void * pParam)
{
	RAW_U32 free_size;
	void *mem;
	void *mem2;
	
	while (1) {

		mem = mem_4_malloc(13);
		
		if (mem == NULL) {

			RAW_ASSERT(0);
			
		}
		
		mem2 = mem_4_malloc(17);

		if (mem2 == NULL) {

			RAW_ASSERT(0);
			
		}
		
		free_size = mem_4_free_get();
		vc_port_printf("free_size %d\n", free_size);
		mem_4_free(mem);
		mem_4_free(mem2);
		raw_sleep(RAW_TICKS_PER_SECOND);


	}

	

}
Пример #28
0
STATE_EVENT *active_event_get(ACTIVE_OBJECT_STRUCT *me) 
{
	RAW_OS_ERROR err;
	STATE_EVENT *e;

	err = raw_queue_receive (&me->active_queue, RAW_WAIT_FOREVER, (void  **)&e);

	if (err != RAW_SUCCESS) {


		RAW_ASSERT(0);
	}

	return e;
	
}
Пример #29
0
/*
************************************************************************************************************************
*                                    Finish interrupt
*
* Description: This function is called to when exit interrupt.
*
* Arguments  :NONE
*                
*               
*                
*                 
*				         
* Returns		
*					
* Note(s)    
*             
************************************************************************************************************************
*/
void raw_finish_int(void)
{

	RAW_SR_ALLOC();

	#if (CONFIG_RAW_ISR_STACK_CHECK > 0)
	
	/*if you have no idea how to implement this function just write a blank port function*/
	port_isr_stack_check();
	
	#endif

	/*It should not be zero here*/
	RAW_ASSERT(raw_int_nesting != 0);
	
	USER_CPU_INT_DISABLE();

	raw_int_nesting--;
	/*if still interrupt nested just return */
	if (raw_int_nesting) {              
		USER_CPU_INT_ENABLE();                                  
		return;
	}
	/*if system is locked then just return*/
	if (raw_sched_lock) { 

		USER_CPU_INT_ENABLE(); 
		return;
	}

	/*get the highest task*/
	get_ready_task(&raw_ready_queue);

	/*if the current task is still the highest task then we do not need to have interrupt switch*/ 
	if (high_ready_obj == raw_task_active) {                 
		USER_CPU_INT_ENABLE();                                     
		return;
	}

	TRACE_INT_TASK_SWITCH(raw_task_active, high_ready_obj);
	
	/*switch to the highest task, this function is cpu related, thus need to be ported*/
	raw_int_switch();  

	USER_CPU_INT_ENABLE();  

}
Пример #30
0
void test_slab(void * pParam)
{
	void *test_mem1;
	int count = 0;
	int i = 0;
	int ret = 0;
	
	frame_init((RAW_U32)test_page_mem, 48*1024);
	slab_cache_init();
	/*Decide whether the magazine work.*/
	slab_enable_cpucache();
	/*0--on, for user program debugging purpose; 
	  1--off, normally, it should be off.*/
	free_check_switch = 0;


	for(i = 0; i < 20; i++){	
		test_mem1 = raw_slab_malloc(1024);
		test_mem1 = raw_slab_malloc(1024);
		
		if (test_mem1) {
			vc_port_printf("test_mem1 is %p\n", test_mem1);
			ret = raw_slab_free(test_mem1);
			if(ret != 0)
				vc_port_printf("****raw_slab_free failed!\n");
			count++;
		}
		else {
			RAW_ASSERT(0);
		}
	}

	/*free a freed address*/
	if(free_check_switch == 0){
		ret = raw_slab_free(test_mem1);
		if(ret != 0)
			vc_port_printf("****Error: Free a freed obj!\n");
	}

	/*Some debug information*/
	slab_print_list();
	vc_port_printf("\n");
	zone_print_one(0);
	while (1);
}