Ejemplo n.º 1
0
void tx_application_define(void *first_unused_memory)
{

	CHAR *pool_pointer;


	/* Create a byte memory pool from which to allocate
	the thread stacks. */
	tx_byte_pool_create(&my_byte_pool, "my_byte_pool",
		first_unused_memory,
		DEMO_BYTE_POOL_SIZE);

	/* Put system definition stuff in here, e.g., thread
	creates and other assorted create information. */

	/* Allocate the stack for the Speedy_Thread. */
	tx_byte_allocate(&my_byte_pool, (VOID **) &pool_pointer,
		DEMO_STACK_SIZE, TX_NO_WAIT);

	/* Create the Speedy_Thread. */
	tx_thread_create(&Speedy_Thread, "Speedy_Thread",
		Speedy_Thread_entry, 0,
		pool_pointer, DEMO_STACK_SIZE, 5, 5,
		TX_NO_TIME_SLICE, TX_AUTO_START);

	/* Allocate the stack for the Slow_Thread. */
	tx_byte_allocate(&my_byte_pool, (VOID **) &pool_pointer,
		DEMO_STACK_SIZE, TX_NO_WAIT);

	/* Create the Slow_Thread. */
	tx_thread_create(&Slow_Thread, "Slow_Thread",
		Slow_Thread_entry, 1, pool_pointer,
		DEMO_STACK_SIZE, 15, 15,
		TX_NO_TIME_SLICE, TX_AUTO_START);

	/* Create the mutex used by both threads */
	tx_mutex_create(&my_mutex, "my_mutex", TX_NO_INHERIT);


}
Ejemplo n.º 2
0
Archivo: demo.c Proyecto: igou/tx
void    tx_application_define(void *first_unused_memory)
{

CHAR    *pointer;


    /* Create a byte memory pool from which to allocate the thread stacks.  */
    tx_byte_pool_create(&byte_pool_0, "byte pool 0", first_unused_memory, DEMO_BYTE_POOL_SIZE);

    /* Put system definition stuff in here, e.g. thread creates and other assorted
       create information.  */

    /* Allocate the stack for thread 0.  */
    tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);

    /* Create the main thread.  */
    tx_thread_create(&thread_0, "thread 0", thread_0_entry, 0,  
            pointer, DEMO_STACK_SIZE, 
            1, 1, TX_NO_TIME_SLICE, TX_AUTO_START);


    /* Allocate the stack for thread 1.  */
    tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);

    /* Create threads 1 and 2. These threads pass information through a ThreadX 
       message queue.  It is also interesting to note that these threads have a time
       slice.  */
    tx_thread_create(&thread_1, "thread 1", thread_1_entry, 1,  
            pointer, DEMO_STACK_SIZE, 
            16, 16, 4, TX_AUTO_START);

    /* Allocate the stack for thread 2.  */
    tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);

    tx_thread_create(&thread_2, "thread 2", thread_2_entry, 2,  
            pointer, DEMO_STACK_SIZE, 
            16, 16, 4, TX_AUTO_START);

    /* Allocate the stack for thread 3.  */
    tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);

    /* Create threads 3 and 4.  These threads compete for a ThreadX counting semaphore.  
       An interesting thing here is that both threads share the same instruction area.  */
    tx_thread_create(&thread_3, "thread 3", thread_3_and_4_entry, 3,  
            pointer, DEMO_STACK_SIZE, 
            8, 8, TX_NO_TIME_SLICE, TX_AUTO_START);

    /* Allocate the stack for thread 4.  */
    tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);

    tx_thread_create(&thread_4, "thread 4", thread_3_and_4_entry, 4,  
            pointer, DEMO_STACK_SIZE, 
            8, 8, TX_NO_TIME_SLICE, TX_AUTO_START);

    /* Allocate the stack for thread 5.  */
    tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);

    /* Create thread 5.  This thread simply pends on an event flag which will be set
       by thread_0.  */
    tx_thread_create(&thread_5, "thread 5", thread_5_entry, 5,  
            pointer, DEMO_STACK_SIZE, 
            4, 4, TX_NO_TIME_SLICE, TX_AUTO_START);

    /* Allocate the stack for thread 6.  */
    tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);

    /* Create threads 6 and 7.  These threads compete for a ThreadX mutex.  */
    tx_thread_create(&thread_6, "thread 6", thread_6_and_7_entry, 6,  
            pointer, DEMO_STACK_SIZE, 
            8, 8, TX_NO_TIME_SLICE, TX_AUTO_START);

    /* Allocate the stack for thread 7.  */
    tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);

    tx_thread_create(&thread_7, "thread 7", thread_6_and_7_entry, 7,  
            pointer, DEMO_STACK_SIZE, 
            8, 8, TX_NO_TIME_SLICE, TX_AUTO_START);

    /* Allocate the message queue.  */
    tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_QUEUE_SIZE*sizeof(ULONG), TX_NO_WAIT);

    /* Create the message queue shared by threads 1 and 2.  */
    tx_queue_create(&queue_0, "queue 0", TX_1_ULONG, pointer, DEMO_QUEUE_SIZE*sizeof(ULONG));

    /* Create the semaphore used by threads 3 and 4.  */
    tx_semaphore_create(&semaphore_0, "semaphore 0", 1);

    /* Create the event flags group used by threads 1 and 5.  */
    tx_event_flags_create(&event_flags_0, "event flags 0");

    /* Create the mutex used by thread 6 and 7 without priority inheritance.  */
    tx_mutex_create(&mutex_0, "mutex 0", TX_NO_INHERIT);

    /* Allocate the memory for a small block pool.  */
    tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_BLOCK_POOL_SIZE, TX_NO_WAIT);

    /* Create a block memory pool to allocate a message buffer from.  */
    tx_block_pool_create(&block_pool_0, "block pool 0", sizeof(ULONG), pointer, DEMO_BLOCK_POOL_SIZE);

    /* Allocate a block and release the block memory.  */
    tx_block_allocate(&block_pool_0, (VOID **) &pointer, TX_NO_WAIT);

    /* Release the block back to the pool.  */
    tx_block_release(pointer);
}
Ejemplo n.º 3
0
/* Make sure that this function is at 0x20000000, don't initialize any
   local variable while declaring in this function */
void GsnStartup_Main( void )
{
    unsigned int* bssEnd = __section_end("BSS_SECTION");
    unsigned int* bssStart = __section_begin("BSS_SECTION");
    unsigned int* dataEnd = __section_end("DATA_SECTION");
    unsigned int* dataStart = __section_begin("DATA_SECTION");
    unsigned int* dataInitStart = __section_begin("DATA_INIT_SECTION");
    unsigned int* romPatchFptEnd = __section_end("ROM_PATCH_FPT_SECTION");
    unsigned int* romPatchFptStart = __section_begin("ROM_PATCH_FPT_SECTION");
    unsigned int* appCodeEnd = __section_end("APP_CODE_SECTION");
    unsigned int* appCodeStart = (unsigned int*)APP_CODE_START;
    unsigned int length, src, dst,  heap1Start, heap2Start;

    int heap1Length, heap2Length;


	/* 2. Copy from flash to initialize the "initialised data" in data	segment.
    The Data init secion can be used as heap once the below copy is done. For
    now we are not doing this  */
	length = (unsigned int)( dataEnd )- (unsigned int)(dataStart);
	src = (unsigned int)dataInitStart; /* Location in Flash */
	dst = (unsigned int)dataStart; /* RAM location to copy, i.e. the DATA section */
    APP_STARTUP_COPY_PROG(src, length, dst);
	
	/*
     * Copy patch function pointers from the flash to the SRAM.
       The ROM PATCH secion can be used as heap once the below copy is done. For
       now we are not doing this. ROM PATCH and DATA INIT section seems to be
       contiguous. So both the section can be clubed to one and can be made as
       one single  heap  */
    length = (unsigned int)( romPatchFptEnd )- (unsigned int)(romPatchFptStart);
    src = (unsigned int)romPatchFptStart;/* Location in Flash for ROM PATCH FPT */
    dst = GSN_ROM_PATCH_FPT_LOCATION;/* RAM location to copy */
    APP_STARTUP_COPY_PROG(src, length,  dst );


	/* Won't be copying the APP code. Calculate the heap at the end*/
	heap1Start = (((unsigned int)&GsnSramFreeMem) & ~0x3) + 0x8;
	heap1Length = (unsigned int)(appCodeStart)  - heap1Start;
	if( heap1Length < 0 )
	{
		/* ERROR APP CODE Section is more than what it can fit in the SRAM. */
		while(1);
	}
	heap2Start = (((unsigned int)appCodeEnd) & ~0x3) + 0x8;
	heap2Length = SRAM_END_ADDR - heap2Start;

	
	/*
	* Initialize BSS segment.
	*/
    /* 1. memset uninitailize data.*/
    src = (unsigned int)bssStart;
    length = (unsigned int)( bssEnd )- (unsigned int)( bssStart );
    memset((void*) src, 0, length );


    /* Initialize the free memory section to use tx byte pool for dynamic memory
       allocation */
	/*Note : bytePool[0] is already created in rom_main.c */
    tx_byte_pool_create(&bytePool[0].bPool, NULL, (void*)heap1Start,
                               (UINT32)heap1Length );

    tx_byte_pool_create(&bytePool[1].bPool, NULL, (void*)heap2Start,
                               (UINT32)heap2Length );
   


	pGsnBytePoolHead =  ( heap2Length > heap1Length ) ?
					&bytePool[1] : &bytePool[0];
	pGsnBytePoolHead->pNext = ( heap2Length > heap1Length ) ?
					&bytePool[0] : &bytePool[1];
	pGsnBytePoolHead->pNext->pNext = NULL;


    /* Assign 3 SRAM blocks to wlan*/
    *((volatile UINT32 *)(0x40080008)) = (UINT32)0x1c;
	//*((volatile UINT32 *)(0x40080008)) = (UINT32)0x78;

	/* Call APP MAIN */
    App_Main();
    //while(1);
    App_IdleHandlerLoop();
}