1*5d5fbe79SDavid van Moolenbroeksys_arch interface for lwIP 2*5d5fbe79SDavid van Moolenbroek 3*5d5fbe79SDavid van MoolenbroekAuthor: Adam Dunkels 4*5d5fbe79SDavid van Moolenbroek Simon Goldschmidt 5*5d5fbe79SDavid van Moolenbroek 6*5d5fbe79SDavid van MoolenbroekThe operating system emulation layer provides a common interface 7*5d5fbe79SDavid van Moolenbroekbetween the lwIP code and the underlying operating system kernel. The 8*5d5fbe79SDavid van Moolenbroekgeneral idea is that porting lwIP to new architectures requires only 9*5d5fbe79SDavid van Moolenbroeksmall changes to a few header files and a new sys_arch 10*5d5fbe79SDavid van Moolenbroekimplementation. It is also possible to do a sys_arch implementation 11*5d5fbe79SDavid van Moolenbroekthat does not rely on any underlying operating system. 12*5d5fbe79SDavid van Moolenbroek 13*5d5fbe79SDavid van MoolenbroekThe sys_arch provides semaphores, mailboxes and mutexes to lwIP. For the full 14*5d5fbe79SDavid van MoolenbroeklwIP functionality, multiple threads support can be implemented in the 15*5d5fbe79SDavid van Moolenbroeksys_arch, but this is not required for the basic lwIP 16*5d5fbe79SDavid van Moolenbroekfunctionality. Timer scheduling is implemented in lwIP, but can be implemented 17*5d5fbe79SDavid van Moolenbroekby the sys_arch port (LWIP_TIMERS_CUSTOM==1). 18*5d5fbe79SDavid van Moolenbroek 19*5d5fbe79SDavid van MoolenbroekIn addition to the source file providing the functionality of sys_arch, 20*5d5fbe79SDavid van Moolenbroekthe OS emulation layer must provide several header files defining 21*5d5fbe79SDavid van Moolenbroekmacros used throughout lwip. The files required and the macros they 22*5d5fbe79SDavid van Moolenbroekmust define are listed below the sys_arch description. 23*5d5fbe79SDavid van Moolenbroek 24*5d5fbe79SDavid van MoolenbroekSemaphores can be either counting or binary - lwIP works with both 25*5d5fbe79SDavid van Moolenbroekkinds. Mailboxes should be implemented as a queue which allows multiple messages 26*5d5fbe79SDavid van Moolenbroekto be posted (implementing as a rendez-vous point where only one message can be 27*5d5fbe79SDavid van Moolenbroekposted at a time can have a highly negative impact on performance). A message 28*5d5fbe79SDavid van Moolenbroekin a mailbox is just a pointer, nothing more. 29*5d5fbe79SDavid van Moolenbroek 30*5d5fbe79SDavid van MoolenbroekSemaphores are represented by the type "sys_sem_t" which is typedef'd 31*5d5fbe79SDavid van Moolenbroekin the sys_arch.h file. Mailboxes are equivalently represented by the 32*5d5fbe79SDavid van Moolenbroektype "sys_mbox_t". Mutexes are represented by the type "sys_mutex_t". 33*5d5fbe79SDavid van MoolenbroeklwIP does not place any restrictions on how these types are represented 34*5d5fbe79SDavid van Moolenbroekinternally. 35*5d5fbe79SDavid van Moolenbroek 36*5d5fbe79SDavid van MoolenbroekSince lwIP 1.4.0, semaphore, mutexes and mailbox functions are prototyped in a way that 37*5d5fbe79SDavid van Moolenbroekallows both using pointers or actual OS structures to be used. This way, memory 38*5d5fbe79SDavid van Moolenbroekrequired for such types can be either allocated in place (globally or on the 39*5d5fbe79SDavid van Moolenbroekstack) or on the heap (allocated internally in the "*_new()" functions). 40*5d5fbe79SDavid van Moolenbroek 41*5d5fbe79SDavid van MoolenbroekThe following functions must be implemented by the sys_arch: 42*5d5fbe79SDavid van Moolenbroek 43*5d5fbe79SDavid van Moolenbroek- void sys_init(void) 44*5d5fbe79SDavid van Moolenbroek 45*5d5fbe79SDavid van Moolenbroek Is called to initialize the sys_arch layer. 46*5d5fbe79SDavid van Moolenbroek 47*5d5fbe79SDavid van Moolenbroek- err_t sys_sem_new(sys_sem_t *sem, u8_t count) 48*5d5fbe79SDavid van Moolenbroek 49*5d5fbe79SDavid van Moolenbroek Creates a new semaphore. The semaphore is allocated to the memory that 'sem' 50*5d5fbe79SDavid van Moolenbroek points to (which can be both a pointer or the actual OS structure). 51*5d5fbe79SDavid van Moolenbroek The "count" argument specifies the initial state of the semaphore (which is 52*5d5fbe79SDavid van Moolenbroek either 0 or 1). 53*5d5fbe79SDavid van Moolenbroek If the semaphore has been created, ERR_OK should be returned. Returning any 54*5d5fbe79SDavid van Moolenbroek other error will provide a hint what went wrong, but except for assertions, 55*5d5fbe79SDavid van Moolenbroek no real error handling is implemented. 56*5d5fbe79SDavid van Moolenbroek 57*5d5fbe79SDavid van Moolenbroek- void sys_sem_free(sys_sem_t *sem) 58*5d5fbe79SDavid van Moolenbroek 59*5d5fbe79SDavid van Moolenbroek Deallocates a semaphore. 60*5d5fbe79SDavid van Moolenbroek 61*5d5fbe79SDavid van Moolenbroek- void sys_sem_signal(sys_sem_t *sem) 62*5d5fbe79SDavid van Moolenbroek 63*5d5fbe79SDavid van Moolenbroek Signals a semaphore. 64*5d5fbe79SDavid van Moolenbroek 65*5d5fbe79SDavid van Moolenbroek- u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout) 66*5d5fbe79SDavid van Moolenbroek 67*5d5fbe79SDavid van Moolenbroek Blocks the thread while waiting for the semaphore to be 68*5d5fbe79SDavid van Moolenbroek signaled. If the "timeout" argument is non-zero, the thread should 69*5d5fbe79SDavid van Moolenbroek only be blocked for the specified time (measured in 70*5d5fbe79SDavid van Moolenbroek milliseconds). If the "timeout" argument is zero, the thread should be 71*5d5fbe79SDavid van Moolenbroek blocked until the semaphore is signalled. 72*5d5fbe79SDavid van Moolenbroek 73*5d5fbe79SDavid van Moolenbroek If the timeout argument is non-zero, the return value is the number of 74*5d5fbe79SDavid van Moolenbroek milliseconds spent waiting for the semaphore to be signaled. If the 75*5d5fbe79SDavid van Moolenbroek semaphore wasn't signaled within the specified time, the return value is 76*5d5fbe79SDavid van Moolenbroek SYS_ARCH_TIMEOUT. If the thread didn't have to wait for the semaphore 77*5d5fbe79SDavid van Moolenbroek (i.e., it was already signaled), the function may return zero. 78*5d5fbe79SDavid van Moolenbroek 79*5d5fbe79SDavid van Moolenbroek Notice that lwIP implements a function with a similar name, 80*5d5fbe79SDavid van Moolenbroek sys_sem_wait(), that uses the sys_arch_sem_wait() function. 81*5d5fbe79SDavid van Moolenbroek 82*5d5fbe79SDavid van Moolenbroek- int sys_sem_valid(sys_sem_t *sem) 83*5d5fbe79SDavid van Moolenbroek 84*5d5fbe79SDavid van Moolenbroek Returns 1 if the semaphore is valid, 0 if it is not valid. 85*5d5fbe79SDavid van Moolenbroek When using pointers, a simple way is to check the pointer for != NULL. 86*5d5fbe79SDavid van Moolenbroek When directly using OS structures, implementing this may be more complex. 87*5d5fbe79SDavid van Moolenbroek This may also be a define, in which case the function is not prototyped. 88*5d5fbe79SDavid van Moolenbroek 89*5d5fbe79SDavid van Moolenbroek- void sys_sem_set_invalid(sys_sem_t *sem) 90*5d5fbe79SDavid van Moolenbroek 91*5d5fbe79SDavid van Moolenbroek Invalidate a semaphore so that sys_sem_valid() returns 0. 92*5d5fbe79SDavid van Moolenbroek ATTENTION: This does NOT mean that the semaphore shall be deallocated: 93*5d5fbe79SDavid van Moolenbroek sys_sem_free() is always called before calling this function! 94*5d5fbe79SDavid van Moolenbroek This may also be a define, in which case the function is not prototyped. 95*5d5fbe79SDavid van Moolenbroek 96*5d5fbe79SDavid van Moolenbroek- void sys_mutex_new(sys_mutex_t *mutex) 97*5d5fbe79SDavid van Moolenbroek 98*5d5fbe79SDavid van Moolenbroek Creates a new mutex. The mutex is allocated to the memory that 'mutex' 99*5d5fbe79SDavid van Moolenbroek points to (which can be both a pointer or the actual OS structure). 100*5d5fbe79SDavid van Moolenbroek If the mutex has been created, ERR_OK should be returned. Returning any 101*5d5fbe79SDavid van Moolenbroek other error will provide a hint what went wrong, but except for assertions, 102*5d5fbe79SDavid van Moolenbroek no real error handling is implemented. 103*5d5fbe79SDavid van Moolenbroek 104*5d5fbe79SDavid van Moolenbroek- void sys_mutex_free(sys_mutex_t *mutex) 105*5d5fbe79SDavid van Moolenbroek 106*5d5fbe79SDavid van Moolenbroek Deallocates a mutex. 107*5d5fbe79SDavid van Moolenbroek 108*5d5fbe79SDavid van Moolenbroek- void sys_mutex_lock(sys_mutex_t *mutex) 109*5d5fbe79SDavid van Moolenbroek 110*5d5fbe79SDavid van Moolenbroek Blocks the thread until the mutex can be grabbed. 111*5d5fbe79SDavid van Moolenbroek 112*5d5fbe79SDavid van Moolenbroek- void sys_mutex_unlock(sys_mutex_t *mutex) 113*5d5fbe79SDavid van Moolenbroek 114*5d5fbe79SDavid van Moolenbroek Releases the mutex previously locked through 'sys_mutex_lock()'. 115*5d5fbe79SDavid van Moolenbroek 116*5d5fbe79SDavid van Moolenbroek- void sys_mutex_valid(sys_mutex_t *mutex) 117*5d5fbe79SDavid van Moolenbroek 118*5d5fbe79SDavid van Moolenbroek Returns 1 if the mutes is valid, 0 if it is not valid. 119*5d5fbe79SDavid van Moolenbroek When using pointers, a simple way is to check the pointer for != NULL. 120*5d5fbe79SDavid van Moolenbroek When directly using OS structures, implementing this may be more complex. 121*5d5fbe79SDavid van Moolenbroek This may also be a define, in which case the function is not prototyped. 122*5d5fbe79SDavid van Moolenbroek 123*5d5fbe79SDavid van Moolenbroek- void sys_mutex_set_invalid(sys_mutex_t *mutex) 124*5d5fbe79SDavid van Moolenbroek 125*5d5fbe79SDavid van Moolenbroek Invalidate a mutex so that sys_mutex_valid() returns 0. 126*5d5fbe79SDavid van Moolenbroek ATTENTION: This does NOT mean that the mutex shall be deallocated: 127*5d5fbe79SDavid van Moolenbroek sys_mutex_free() is always called before calling this function! 128*5d5fbe79SDavid van Moolenbroek This may also be a define, in which case the function is not prototyped. 129*5d5fbe79SDavid van Moolenbroek 130*5d5fbe79SDavid van Moolenbroek- err_t sys_mbox_new(sys_mbox_t *mbox, int size) 131*5d5fbe79SDavid van Moolenbroek 132*5d5fbe79SDavid van Moolenbroek Creates an empty mailbox for maximum "size" elements. Elements stored 133*5d5fbe79SDavid van Moolenbroek in mailboxes are pointers. You have to define macros "_MBOX_SIZE" 134*5d5fbe79SDavid van Moolenbroek in your lwipopts.h, or ignore this parameter in your implementation 135*5d5fbe79SDavid van Moolenbroek and use a default size. 136*5d5fbe79SDavid van Moolenbroek If the mailbox has been created, ERR_OK should be returned. Returning any 137*5d5fbe79SDavid van Moolenbroek other error will provide a hint what went wrong, but except for assertions, 138*5d5fbe79SDavid van Moolenbroek no real error handling is implemented. 139*5d5fbe79SDavid van Moolenbroek 140*5d5fbe79SDavid van Moolenbroek- void sys_mbox_free(sys_mbox_t *mbox) 141*5d5fbe79SDavid van Moolenbroek 142*5d5fbe79SDavid van Moolenbroek Deallocates a mailbox. If there are messages still present in the 143*5d5fbe79SDavid van Moolenbroek mailbox when the mailbox is deallocated, it is an indication of a 144*5d5fbe79SDavid van Moolenbroek programming error in lwIP and the developer should be notified. 145*5d5fbe79SDavid van Moolenbroek 146*5d5fbe79SDavid van Moolenbroek- void sys_mbox_post(sys_mbox_t *mbox, void *msg) 147*5d5fbe79SDavid van Moolenbroek 148*5d5fbe79SDavid van Moolenbroek Posts the "msg" to the mailbox. This function have to block until 149*5d5fbe79SDavid van Moolenbroek the "msg" is really posted. 150*5d5fbe79SDavid van Moolenbroek 151*5d5fbe79SDavid van Moolenbroek- err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg) 152*5d5fbe79SDavid van Moolenbroek 153*5d5fbe79SDavid van Moolenbroek Try to post the "msg" to the mailbox. Returns ERR_MEM if this one 154*5d5fbe79SDavid van Moolenbroek is full, else, ERR_OK if the "msg" is posted. 155*5d5fbe79SDavid van Moolenbroek 156*5d5fbe79SDavid van Moolenbroek- u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout) 157*5d5fbe79SDavid van Moolenbroek 158*5d5fbe79SDavid van Moolenbroek Blocks the thread until a message arrives in the mailbox, but does 159*5d5fbe79SDavid van Moolenbroek not block the thread longer than "timeout" milliseconds (similar to 160*5d5fbe79SDavid van Moolenbroek the sys_arch_sem_wait() function). If "timeout" is 0, the thread should 161*5d5fbe79SDavid van Moolenbroek be blocked until a message arrives. The "msg" argument is a result 162*5d5fbe79SDavid van Moolenbroek parameter that is set by the function (i.e., by doing "*msg = 163*5d5fbe79SDavid van Moolenbroek ptr"). The "msg" parameter maybe NULL to indicate that the message 164*5d5fbe79SDavid van Moolenbroek should be dropped. 165*5d5fbe79SDavid van Moolenbroek 166*5d5fbe79SDavid van Moolenbroek The return values are the same as for the sys_arch_sem_wait() function: 167*5d5fbe79SDavid van Moolenbroek Number of milliseconds spent waiting or SYS_ARCH_TIMEOUT if there was a 168*5d5fbe79SDavid van Moolenbroek timeout. 169*5d5fbe79SDavid van Moolenbroek 170*5d5fbe79SDavid van Moolenbroek Note that a function with a similar name, sys_mbox_fetch(), is 171*5d5fbe79SDavid van Moolenbroek implemented by lwIP. 172*5d5fbe79SDavid van Moolenbroek 173*5d5fbe79SDavid van Moolenbroek- u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg) 174*5d5fbe79SDavid van Moolenbroek 175*5d5fbe79SDavid van Moolenbroek This is similar to sys_arch_mbox_fetch, however if a message is not 176*5d5fbe79SDavid van Moolenbroek present in the mailbox, it immediately returns with the code 177*5d5fbe79SDavid van Moolenbroek SYS_MBOX_EMPTY. On success 0 is returned. 178*5d5fbe79SDavid van Moolenbroek 179*5d5fbe79SDavid van Moolenbroek To allow for efficient implementations, this can be defined as a 180*5d5fbe79SDavid van Moolenbroek function-like macro in sys_arch.h instead of a normal function. For 181*5d5fbe79SDavid van Moolenbroek example, a naive implementation could be: 182*5d5fbe79SDavid van Moolenbroek #define sys_arch_mbox_tryfetch(mbox,msg) \ 183*5d5fbe79SDavid van Moolenbroek sys_arch_mbox_fetch(mbox,msg,1) 184*5d5fbe79SDavid van Moolenbroek although this would introduce unnecessary delays. 185*5d5fbe79SDavid van Moolenbroek 186*5d5fbe79SDavid van Moolenbroek- int sys_mbox_valid(sys_mbox_t *mbox) 187*5d5fbe79SDavid van Moolenbroek 188*5d5fbe79SDavid van Moolenbroek Returns 1 if the mailbox is valid, 0 if it is not valid. 189*5d5fbe79SDavid van Moolenbroek When using pointers, a simple way is to check the pointer for != NULL. 190*5d5fbe79SDavid van Moolenbroek When directly using OS structures, implementing this may be more complex. 191*5d5fbe79SDavid van Moolenbroek This may also be a define, in which case the function is not prototyped. 192*5d5fbe79SDavid van Moolenbroek 193*5d5fbe79SDavid van Moolenbroek- void sys_mbox_set_invalid(sys_mbox_t *mbox) 194*5d5fbe79SDavid van Moolenbroek 195*5d5fbe79SDavid van Moolenbroek Invalidate a mailbox so that sys_mbox_valid() returns 0. 196*5d5fbe79SDavid van Moolenbroek ATTENTION: This does NOT mean that the mailbox shall be deallocated: 197*5d5fbe79SDavid van Moolenbroek sys_mbox_free() is always called before calling this function! 198*5d5fbe79SDavid van Moolenbroek This may also be a define, in which case the function is not prototyped. 199*5d5fbe79SDavid van Moolenbroek 200*5d5fbe79SDavid van MoolenbroekIf threads are supported by the underlying operating system and if 201*5d5fbe79SDavid van Moolenbroeksuch functionality is needed in lwIP, the following function will have 202*5d5fbe79SDavid van Moolenbroekto be implemented as well: 203*5d5fbe79SDavid van Moolenbroek 204*5d5fbe79SDavid van Moolenbroek- sys_thread_t sys_thread_new(char *name, void (* thread)(void *arg), void *arg, int stacksize, int prio) 205*5d5fbe79SDavid van Moolenbroek 206*5d5fbe79SDavid van Moolenbroek Starts a new thread named "name" with priority "prio" that will begin its 207*5d5fbe79SDavid van Moolenbroek execution in the function "thread()". The "arg" argument will be passed as an 208*5d5fbe79SDavid van Moolenbroek argument to the thread() function. The stack size to used for this thread is 209*5d5fbe79SDavid van Moolenbroek the "stacksize" parameter. The id of the new thread is returned. Both the id 210*5d5fbe79SDavid van Moolenbroek and the priority are system dependent. 211*5d5fbe79SDavid van Moolenbroek 212*5d5fbe79SDavid van MoolenbroekWhen lwIP is used from more than one context (e.g. from multiple threads OR from 213*5d5fbe79SDavid van Moolenbroekmain-loop and from interrupts), the SYS_LIGHTWEIGHT_PROT protection SHOULD be enabled! 214*5d5fbe79SDavid van Moolenbroek 215*5d5fbe79SDavid van Moolenbroek- sys_prot_t sys_arch_protect(void) 216*5d5fbe79SDavid van Moolenbroek 217*5d5fbe79SDavid van Moolenbroek This optional function does a "fast" critical region protection and returns 218*5d5fbe79SDavid van Moolenbroek the previous protection level. This function is only called during very short 219*5d5fbe79SDavid van Moolenbroek critical regions. An embedded system which supports ISR-based drivers might 220*5d5fbe79SDavid van Moolenbroek want to implement this function by disabling interrupts. Task-based systems 221*5d5fbe79SDavid van Moolenbroek might want to implement this by using a mutex or disabling tasking. This 222*5d5fbe79SDavid van Moolenbroek function should support recursive calls from the same task or interrupt. In 223*5d5fbe79SDavid van Moolenbroek other words, sys_arch_protect() could be called while already protected. In 224*5d5fbe79SDavid van Moolenbroek that case the return value indicates that it is already protected. 225*5d5fbe79SDavid van Moolenbroek 226*5d5fbe79SDavid van Moolenbroek sys_arch_protect() is only required if your port is supporting an operating 227*5d5fbe79SDavid van Moolenbroek system. 228*5d5fbe79SDavid van Moolenbroek 229*5d5fbe79SDavid van Moolenbroek- void sys_arch_unprotect(sys_prot_t pval) 230*5d5fbe79SDavid van Moolenbroek 231*5d5fbe79SDavid van Moolenbroek This optional function does a "fast" set of critical region protection to the 232*5d5fbe79SDavid van Moolenbroek value specified by pval. See the documentation for sys_arch_protect() for 233*5d5fbe79SDavid van Moolenbroek more information. This function is only required if your port is supporting 234*5d5fbe79SDavid van Moolenbroek an operating system. 235*5d5fbe79SDavid van Moolenbroek 236*5d5fbe79SDavid van MoolenbroekFor some configurations, you also need: 237*5d5fbe79SDavid van Moolenbroek 238*5d5fbe79SDavid van Moolenbroek- u32_t sys_now(void) 239*5d5fbe79SDavid van Moolenbroek 240*5d5fbe79SDavid van Moolenbroek This optional function returns the current time in milliseconds (don't care 241*5d5fbe79SDavid van Moolenbroek for wraparound, this is only used for time diffs). 242*5d5fbe79SDavid van Moolenbroek Not implementing this function means you cannot use some modules (e.g. TCP 243*5d5fbe79SDavid van Moolenbroek timestamps, internal timeouts for NO_SYS==1). 244*5d5fbe79SDavid van Moolenbroek 245*5d5fbe79SDavid van Moolenbroek 246*5d5fbe79SDavid van MoolenbroekNote: 247*5d5fbe79SDavid van Moolenbroek 248*5d5fbe79SDavid van MoolenbroekBe careful with using mem_malloc() in sys_arch. When malloc() refers to 249*5d5fbe79SDavid van Moolenbroekmem_malloc() you can run into a circular function call problem. In mem.c 250*5d5fbe79SDavid van Moolenbroekmem_init() tries to allcate a semaphore using mem_malloc, which of course 251*5d5fbe79SDavid van Moolenbroekcan't be performed when sys_arch uses mem_malloc. 252*5d5fbe79SDavid van Moolenbroek 253*5d5fbe79SDavid van Moolenbroek------------------------------------------------------------------------------- 254*5d5fbe79SDavid van MoolenbroekAdditional files required for the "OS support" emulation layer: 255*5d5fbe79SDavid van Moolenbroek------------------------------------------------------------------------------- 256*5d5fbe79SDavid van Moolenbroek 257*5d5fbe79SDavid van Moolenbroekcc.h - Architecture environment, some compiler specific, some 258*5d5fbe79SDavid van Moolenbroek environment specific (probably should move env stuff 259*5d5fbe79SDavid van Moolenbroek to sys_arch.h.) 260*5d5fbe79SDavid van Moolenbroek 261*5d5fbe79SDavid van Moolenbroek Typedefs for the types used by lwip - 262*5d5fbe79SDavid van Moolenbroek u8_t, s8_t, u16_t, s16_t, u32_t, s32_t, mem_ptr_t 263*5d5fbe79SDavid van Moolenbroek 264*5d5fbe79SDavid van Moolenbroek Compiler hints for packing lwip's structures - 265*5d5fbe79SDavid van Moolenbroek PACK_STRUCT_FIELD(x) 266*5d5fbe79SDavid van Moolenbroek PACK_STRUCT_STRUCT 267*5d5fbe79SDavid van Moolenbroek PACK_STRUCT_BEGIN 268*5d5fbe79SDavid van Moolenbroek PACK_STRUCT_END 269*5d5fbe79SDavid van Moolenbroek 270*5d5fbe79SDavid van Moolenbroek Platform specific diagnostic output - 271*5d5fbe79SDavid van Moolenbroek LWIP_PLATFORM_DIAG(x) - non-fatal, print a message. 272*5d5fbe79SDavid van Moolenbroek LWIP_PLATFORM_ASSERT(x) - fatal, print message and abandon execution. 273*5d5fbe79SDavid van Moolenbroek Portability defines for printf formatters: 274*5d5fbe79SDavid van Moolenbroek U16_F, S16_F, X16_F, U32_F, S32_F, X32_F, SZT_F 275*5d5fbe79SDavid van Moolenbroek 276*5d5fbe79SDavid van Moolenbroek "lightweight" synchronization mechanisms - 277*5d5fbe79SDavid van Moolenbroek SYS_ARCH_DECL_PROTECT(x) - declare a protection state variable. 278*5d5fbe79SDavid van Moolenbroek SYS_ARCH_PROTECT(x) - enter protection mode. 279*5d5fbe79SDavid van Moolenbroek SYS_ARCH_UNPROTECT(x) - leave protection mode. 280*5d5fbe79SDavid van Moolenbroek 281*5d5fbe79SDavid van Moolenbroek If the compiler does not provide memset() this file must include a 282*5d5fbe79SDavid van Moolenbroek definition of it, or include a file which defines it. 283*5d5fbe79SDavid van Moolenbroek 284*5d5fbe79SDavid van Moolenbroek This file must either include a system-local <errno.h> which defines 285*5d5fbe79SDavid van Moolenbroek the standard *nix error codes (or define LWIP_ERRNO_INCLUDE to that file name), 286*5d5fbe79SDavid van Moolenbroek or it should #define LWIP_PROVIDE_ERRNO to make lwip/arch.h define the codes 287*5d5fbe79SDavid van Moolenbroek which are used throughout. 288*5d5fbe79SDavid van Moolenbroek 289*5d5fbe79SDavid van Moolenbroek 290*5d5fbe79SDavid van Moolenbroekperf.h - Architecture specific performance measurement. 291*5d5fbe79SDavid van Moolenbroek Measurement calls made throughout lwip, these can be defined to nothing. 292*5d5fbe79SDavid van Moolenbroek PERF_START - start measuring something. 293*5d5fbe79SDavid van Moolenbroek PERF_STOP(x) - stop measuring something, and record the result. 294*5d5fbe79SDavid van Moolenbroek 295*5d5fbe79SDavid van Moolenbroeksys_arch.h - Tied to sys_arch.c 296*5d5fbe79SDavid van Moolenbroek 297*5d5fbe79SDavid van Moolenbroek Arch dependent types for the following objects: 298*5d5fbe79SDavid van Moolenbroek sys_sem_t, sys_mbox_t, sys_thread_t, 299*5d5fbe79SDavid van Moolenbroek And, optionally: 300*5d5fbe79SDavid van Moolenbroek sys_prot_t 301*5d5fbe79SDavid van Moolenbroek 302*5d5fbe79SDavid van Moolenbroek Defines to set vars of sys_mbox_t and sys_sem_t to NULL. 303*5d5fbe79SDavid van Moolenbroek SYS_MBOX_NULL NULL 304*5d5fbe79SDavid van Moolenbroek SYS_SEM_NULL NULL 305