Changeset 778

Show
Ignore:
Timestamp:
08/04/08 20:51:26 (4 months ago)
Author:
liamstask
Message:

- incorporate changes from freertos lwip 1.3 port - mostly changes to sys_arch.c, adding in more stats info

Location:
firmware/trunk/core
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • firmware/trunk/core/lwip/contrib/port/FreeRTOS/AT91SAM7X/arch/sys_arch.h

    r688 r778  
    4040#define SYS_MBOX_NULL (xQueueHandle)0 
    4141#define SYS_SEM_NULL  (xSemaphoreHandle)0 
    42 // MakingThings - addition for lwip 1.3.0 
    43 // FIXME - more robust implementation... 
    44 #define sys_arch_mbox_tryfetch(mbox,msg) sys_arch_mbox_fetch(mbox,msg,1) 
    4542 
    4643typedef xSemaphoreHandle sys_sem_t; 
     
    4845typedef xTaskHandle sys_thread_t; 
    4946 
     47/* Message queue constants. */ 
     48#define archMESG_QUEUE_LENGTH ( 6 ) 
     49#define archPOST_BLOCK_TIME_MS  ( ( unsigned portLONG ) 10000 ) 
     50 
    5051#endif /* __SYS_RTXC_H__ */ 
    5152 
  • firmware/trunk/core/lwip/contrib/port/FreeRTOS/AT91SAM7X/sys_arch.c

    r688 r778  
    3939#include "lwip/sys.h" 
    4040#include "lwip/mem.h" 
    41  
    42 /* Message queue constants. */ 
    43 #define archMESG_QUEUE_LENGTH ( 6 ) 
    44 #define archPOST_BLOCK_TIME_MS  ( ( unsigned portLONG ) 10000 ) 
     41#include "lwip/stats.h" 
     42#include "lwipopts.h" 
    4543 
    4644struct timeoutlist  
     
    5149 
    5250/* This is the number of threads that can be started with sys_thread_new() */ 
    53 // #define SYS_THREAD_MAX 6 
    54  
    55 #define lwipTCP_STACK_SIZE      200 
    56 #define lwipBASIC_SERVER_STACK_SIZE 150 
     51//#define SYS_THREAD_MAX 4 
    5752 
    5853// static struct timeoutlist timeoutlist[SYS_THREAD_MAX]; 
     
    7671  mbox = xQueueCreate( archMESG_QUEUE_LENGTH, sizeof( void * ) ); 
    7772 
     73#if SYS_STATS 
     74      ++lwip_stats.sys.mbox.used; 
     75      if (lwip_stats.sys.mbox.max < lwip_stats.sys.mbox.used) { 
     76         lwip_stats.sys.mbox.max = lwip_stats.sys.mbox.used; 
     77    } 
     78#endif /* SYS_STATS */ 
     79 
    7880  return mbox; 
    7981} 
     
    9193  { 
    9294    /* Line for breakpoint.  Should never break here! */ 
    93     __asm volatile ( "NOP" ); 
     95    portNOP(); 
     96#if SYS_STATS 
     97      lwip_stats.sys.mbox.err++; 
     98#endif /* SYS_STATS */ 
    9499  } 
    95100 
    96101  vQueueDelete( mbox );  
     102 
     103#if SYS_STATS 
     104     --lwip_stats.sys.mbox.used; 
     105#endif /* SYS_STATS */ 
    97106} 
    98107 
     
    107116/*-----------------------------------------------------------------------------------*/ 
    108117// MakingThings - added for lwip 1.3.0 
    109 //  Posts the "msg" to the mailbox. This function have to block until 
    110 //  the "msg" is really posted. 
     118//  Posts the "msg" to the mailbox. 
    111119err_t  
    112120sys_mbox_trypost(sys_mbox_t mbox, void *msg) 
    113 {    
    114   portBASE_TYPE result = xQueueSend( mbox, &msg, ( portTickType ) ( archPOST_BLOCK_TIME_MS / portTICK_RATE_MS ) ); 
    115   while( result == errQUEUE_FULL) 
    116   { 
    117     vTaskDelay(1); 
    118     result = xQueueSend( mbox, &msg, ( portTickType ) ( archPOST_BLOCK_TIME_MS / portTICK_RATE_MS ) ); 
    119   } 
    120   return ERR_OK; 
     121{ 
     122err_t result; 
     123 
     124   if ( xQueueSend( mbox, &msg, 0 ) == pdPASS )  
     125   { 
     126      result = ERR_OK; 
     127   } 
     128   else { 
     129      // could not post, queue must be full 
     130      result = ERR_MEM; 
     131#if SYS_STATS 
     132      lwip_stats.sys.mbox.err++; 
     133#endif /* SYS_STATS */ 
     134   } 
     135 
     136   return result; 
    121137} 
    122138 
     
    185201 
    186202/*-----------------------------------------------------------------------------------*/ 
     203/* 
     204  Similar to sys_arch_mbox_fetch, but if message is not ready immediately, we'll 
     205  return with SYS_MBOX_EMPTY.  On success, 0 is returned. 
     206*/ 
     207u32_t sys_arch_mbox_tryfetch(sys_mbox_t mbox, void **msg) 
     208{ 
     209void *dummyptr; 
     210 
     211  if ( msg == NULL ) 
     212  { 
     213    msg = &dummyptr; 
     214  } 
     215    
     216   if ( pdTRUE == xQueueReceive( mbox, &(*msg), 0 ) )  
     217   { 
     218      return ERR_OK; 
     219   } 
     220   else  
     221   { 
     222      return SYS_MBOX_EMPTY;    
     223   } 
     224} 
     225 
     226/*-----------------------------------------------------------------------------------*/ 
    187227//  Creates and returns a new semaphore. The "count" argument specifies 
    188228//  the initial state of the semaphore. TBD finish and test 
     
    202242  if( xSemaphore == NULL ) 
    203243  { 
     244#if SYS_STATS 
     245      ++lwip_stats.sys.sem.err; 
     246#endif /* SYS_STATS */ 
    204247    return NULL;  // TBD need assert 
    205248  } 
    206249  else 
    207250  { 
     251#if SYS_STATS 
     252      ++lwip_stats.sys.sem.used; 
     253      if (lwip_stats.sys.sem.max < lwip_stats.sys.sem.used) { 
     254         lwip_stats.sys.sem.max = lwip_stats.sys.sem.used; 
     255    } 
     256#endif /* SYS_STATS */ 
    208257    return xSemaphore; 
    209258  } 
     
    281330sys_sem_free(sys_sem_t sem) 
    282331{ 
     332#if SYS_STATS 
     333      --lwip_stats.sys.sem.used; 
     334#endif /* SYS_STATS */ 
    283335  vQueueDelete( sem );  
    284336} 
  • firmware/trunk/core/makingthings/SAM7_EMAC.c

    r769 r778  
    522522  while( !( AT91C_BASE_RSTC->RSTC_RSR & AT91C_RSTC_NRSTL ) ) 
    523523  { 
    524     __asm volatile ( "NOP" ); 
    525   } 
    526     __asm volatile ( "NOP" ); 
     524    portNOP(); 
     525  } 
     526 
     527  portNOP(); 
    527528 
    528529  /* Setup the pins. */ 
     
    783784  while( !( AT91C_BASE_EMAC->EMAC_NSR & AT91C_EMAC_IDLE ) ) 
    784785  { 
    785     __asm( "NOP" ); 
     786    portNOP(); 
    786787  } 
    787788 
     
    806807  while( !( AT91C_BASE_EMAC->EMAC_NSR & AT91C_EMAC_IDLE ) ) 
    807808  { 
    808     __asm( "NOP" ); 
     809    portNOP(); 
    809810  }; 
    810811 
  • firmware/trunk/core/makingthings/lwipopts.h

    r760 r778  
    4141#define SYS_LIGHTWEIGHT_PROT            1 
    4242 
     43#define lwipTCP_STACK_SIZE          600 
    4344#define TCPIP_THREAD_PRIO 5 
    4445 
     
    9697/* ---------- Pbuf options ---------- */ 
    9798/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */ 
    98 #define PBUF_POOL_SIZE          6 
     99#define PBUF_POOL_SIZE          8 
    99100 
    100101/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */