e:/hudson/workspace/MityDSP MDK Release/trunk/sw/src/lwip_port/arch/sys_arch.c File Reference
MityDSP architecture-specific routines for lwIP.  
More...
#include <stdio.h>
#include <std.h>
#include <c62.h>
#include <clk.h>
#include "lwip/def.h"
#include "lwip/sys.h"
#include "lwip/mem.h"
#include "arch/sys_arch.h"
| Defines | 
| #define | LOG_DEBUG   0 | 
| Functions | 
| void | sys_set_max_lwip_threads (int anMaxTasks) | 
| int | sys_get_max_lwip_threads (void) | 
| void | sys_set_mbx_queue_entries (int anMbxEntries) | 
| int | sys_get_mbx_queue_entries (void) | 
| void | sys_init (void) | 
| sys_sem_t | sys_sem_new (u8_t anInitCount) | 
| void | sys_sem_free (sys_sem_t ahSem) | 
| void | sys_sem_signal (sys_sem_t ahSem) | 
| u32_t | sys_arch_sem_wait (sys_sem_t ahSem, u32_t anTimeout) | 
| sys_mbox_t | sys_mbox_new (int anSize) | 
| void | sys_mbox_free (sys_mbox_t ahMbox) | 
| void | sys_mbox_post (sys_mbox_t ahMbox, void *apMsg) | 
| err_t | sys_mbox_trypost (sys_mbox_t ahMbox, void *apMsg) | 
| u32_t | sys_arch_mbox_fetch (sys_mbox_t ahMbox, void **apMsg, u32_t anTimeout) | 
| u32_t | sys_arch_mbox_tryfetch (sys_mbox_t ahMbox, void **apMsg) | 
| struct sys_timeouts * | sys_arch_timeouts (void) | 
| int | sys_thread_register (sys_thread_t ahThread) | 
| int | sys_thread_unregister (sys_thread_t ahThread) | 
| int | sys_thread_priority (sys_thread_t ahThread, int anPrio) | 
| sys_thread_t | sys_thread_new (char *apName, void(*ahThread)(void *), void *apArg, int anStacksize, int anPrio) | 
| void | sys_arch_assert (const char *apMsg, int anLine, const char *apFile) | 
| Variables | 
| NetAssertCB | DSPNet_nacb_func | 
| int | DSPNet_tcpip_priority | 
| static int | fnLwipTaskMax = 5 | 
|  | Set default for the number of concurrent lwIP threads. 
 | 
| static int | fnMbxQueueEntries = PBUF_POOL_SIZE / 2 | 
|  | Set default lwIP mailbox depths. 
 | 
| static struct sys_timeouts * | fpLwipTimeouts = NULL | 
|  | This structure contains a linked list of timeouts managed on a per thread basis. 
 | 
| static TSK_Handle * | fpLwipTasks = NULL | 
|  | Task handles associated with the fpLwipTimeouts structure. 
 | 
| static LCK_Handle | fhMutex = NULL | 
|  | Local lock for thread creation/modification functions. 
 | 
| static unsigned int | fnTicksPerMsec = 1 | 
|  | MityDSP clock ticks per millisecond. 
 | 
| tsSysArchStats | fsSysArchStats | 
|  | Statistic storage. 
 | 
| LCK_Handle | ghLwipLock = NULL | 
|  | Define the lwIP Critical Section lock. 
 | 
| void(* | lwip_printf )(const char *fmt,...) = NULL | 
|  | Define default lwip_printf function. 
 | 
Detailed Description
MityDSP architecture-specific routines for lwIP. 
o 0 | / Copyright (c) 2005-2007 (CL)---o Critical Link, LLC \ O 
Define Documentation
Function Documentation
      
        
          | void sys_set_max_lwip_threads | ( | int | anMaxTasks | ) |  | 
      
 
Set number of threads allowed to use lwIP concurrently.
- Note:
- Must be called prior to stack initialization.
- Parameters:
- 
  
    | [in] | anMaxTasks | Maximum lwIP threads allowed. |  
 
- Returns:
- None. 
 
 
      
        
          | int sys_get_max_lwip_threads | ( | void |  | ) |  | 
      
 
Get number of threads allowed to use lwIP concurrently.
- Returns:
- Concurrent threads allowed. 
 
 
      
        
          | void sys_set_mbx_queue_entries | ( | int | anMbxEntries | ) |  | 
      
 
Set number of queue entries created in lwIP mailboxes.
- Note:
- Must be called prior to stack initialization.
- Parameters:
- 
  
    | [in] | anMbxEntries | Number of entries to create. |  
 
- Returns:
- None. 
 
 
      
        
          | int sys_get_mbx_queue_entries | ( | void |  | ) |  | 
      
 
Get number of queue entries used in lwIP mailboxes.
- Returns:
- Queue entries configured. 
 
 
Initialize internal lwIP data structures.
- Returns:
- None. 
 
 
Create and initialize a semaphore.
- Parameters:
- 
  
    | [in] | anInitCount | Initial semaphore count. |  
 
- Returns:
- Semaphore handle. 
 
 
Delete a previously created semaphore.
- Parameters:
- 
  
    | [in] | ahSem | Semaphore handle. |  
 
- Returns:
- None. 
 
 
Signal a previously created semaphore.
- Parameters:
- 
  
    | [in] | ahSem | Semaphore handle. |  
 
- Returns:
- None. 
 
 
Pend on a previously created semaphore.
- Note:
- A timeout of zero causes the thread to pend indefinitely.
- Parameters:
- 
  
    | [in] | ahSem | Semaphore handle. |  | [in] | anTimeout | Timeout (msec). |  
 
- Returns:
- Time spent waiting (if successful), or SYS_ARCH_TIMEOUT. 
 
 
Create a mailbox to hold generic pointer values, with a queue length of fnMbxQueueEntries.
- Parameters:
- 
  
    | [in] | anSize | Mailbox depth (0=use default) |  
 
- Returns:
- Mailbox handle. 
 
 
Delete a previously created mailbox.
- Parameters:
- 
  
    | [in] | ahMbox | Mailbox handle. |  
 
- Returns:
- None. 
 
 
      
        
          | void sys_mbox_post | ( | sys_mbox_t | ahMbox, | 
        
          |  |  | void * | apMsg |  | 
        
          |  | ) |  |  |  | 
      
 
Post a message to a previously created mailbox, waiting indefinitely for space to become available.
- Parameters:
- 
  
    | [in] | ahMbox | Mailbox handle. |  | [in] | apMsg | Message to post. |  
 
- Returns:
- None. 
 
 
      
        
          | err_t sys_mbox_trypost | ( | sys_mbox_t | ahMbox, | 
        
          |  |  | void * | apMsg |  | 
        
          |  | ) |  |  |  | 
      
 
Attempt to post a message to a previously created mailbox, without blocking.
- Parameters:
- 
  
    | [in] | ahMbox | Mailbox handle. |  | [in] | apMsg | Message to post. |  
 
- Returns:
- ERR_OK upon success, ERR_MEM if mailbox full. 
 
 
Wait for a message from a previously created mailbox.
- Note:
- A timeout of zero causes the thread to wait indefinitely.
- Parameters:
- 
  
    | [in] | ahMbox | Mailbox handle. |  | [in] | apMsg | Storage for returned message. |  | [in] | anTimeout | Timeout (msec). |  
 
- Returns:
- Time spent waiting (if successful), or SYS_ARCH_TIMEOUT. 
 
 
Attempt to get a message IFF a mailbox is not empty.
- Parameters:
- 
  
    | [in] | ahMbox | Mailbox handle. |  | [in] | apMsg | Storage for returned message. |  
 
- Returns:
- SYS_MBOX_EMPTY if no message found, otherwise zero. 
 
 
      
        
          | struct sys_timeouts* sys_arch_timeouts | ( | void |  | ) |  [read] | 
      
 
Attempt to find the timeout structure for the current thread.
- Returns:
- Pointer to the timeout structure, or NULL if the current thread is not registered. 
 
 
Attempt to register a specified thread with lwIP.
- Parameters:
- 
  
    | [in] | ahThread | Handle of thread to register. |  
 
- Returns:
- Index into timeout structure (if successful), or -1 if failed. 
 
 
Attempt to un-register a specified thread with lwIP.
- Parameters:
- 
  
    | [in] | ahThread | Handle of thread to register. |  
 
- Returns:
- 0 (if successful), or -1 if failed. 
 
 
      
        
          | int sys_thread_priority | ( | sys_thread_t | ahThread, | 
        
          |  |  | int | anPrio |  | 
        
          |  | ) |  |  |  | 
      
 
Attempt to change the priority of a previously created thread.
- Parameters:
- 
  
    | [in] | ahThread | Handle of thread to register. |  | [in] | anPrio | New thread priority. |  
 
- Returns:
- Index into timeout structure (if successful), or -1 if failed. 
 
 
      
        
          | sys_thread_t sys_thread_new | ( | char * | apName, | 
        
          |  |  | void(*)(void *) | ahThread, | 
        
          |  |  | void * | apArg, | 
        
          |  |  | int | anStacksize, | 
        
          |  |  | int | anPrio |  | 
        
          |  | ) |  |  |  | 
      
 
Attempt to create a new thread and register it with lwIP.
- Parameters:
- 
  
    | [in] | apName | Pointer to static thread name string |  | [in] | ahThread | Function to start as a thread. |  | [in] | apArg | Argument to provided function. |  | [in] | anStacksize | Stack size to allocate (bytes). |  | [in] | anPrio | Thread priority. |  
 
- Note:
- All lwIP threads must be lower priority than the stack itself.
- Returns:
- Handle of created thread (if successful), or NULL if failed. 
 
 
      
        
          | void sys_arch_assert | ( | const char * | apMsg, | 
        
          |  |  | int | anLine, | 
        
          |  |  | const char * | apFile |  | 
        
          |  | ) |  |  |  | 
      
 
Upon failure of an assertion this routine creates an error string, passes it to any registered assertion handlers, and then aborts the current thread.
- Parameters:
- 
  
    | [in] | apMsg | Text message associate with assertion. |  | [in] | anLine | Line number assertion occurred on. |  | [in] | apFile | File that assertion occurred in. |  
 
- Returns:
- None (doesn't return). 
 
 
Variable Documentation
Set default for the number of concurrent lwIP threads. 
 
 
Set default lwIP mailbox depths. 
 
 
This structure contains a linked list of timeouts managed on a per thread basis. 
 
 
Task handles associated with the fpLwipTimeouts structure. 
 
 
Local lock for thread creation/modification functions. 
 
 
MityDSP clock ticks per millisecond. 
 
 
Define the lwIP Critical Section lock. 
 
 
Define default lwip_printf function.