4 * This file is part of BeRTOS.
6 * Bertos is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * As a special exception, you may use this file as part of a free software
21 * library without restriction. Specifically, if other files instantiate
22 * templates or use macros or inline functions from this file, or you compile
23 * this file and link it with other files to produce an executable, this
24 * file does not by itself cause the resulting executable to be covered by
25 * the GNU General Public License. This exception does not however
26 * invalidate any other reasons why the executable file might be covered by
27 * the GNU General Public License.
29 * Copyright 2009 Develer S.r.l. (http://www.develer.com/)
33 * \author Luca Ottaviano <lottaviano@develer.com>
35 * \brief Emulation Layer for lwIP
38 #ifndef LWIP_SYS_ARCH_H
39 #define LWIP_SYS_ARCH_H
45 #include <kern/proc.h>
47 /****************************************************************************/
50 * Generic mutex (binary semaphore) prototypes
52 * TODO: move this to a different place (i.e., bertos/kern/sem.h).
54 #include <cpu/byteorder.h> // cpu_atomic_xchg()
55 #include <cpu/types.h>
57 #include <struct/list.h>
59 #define MUTEX_UNLOCKED 1
60 #define MUTEX_LOCKED (!MUTEX_UNLOCKED)
68 void mutex_init(struct Mutex *s);
69 bool mutex_attempt(struct Mutex *s);
70 void mutex_obtain(struct Mutex *s);
71 void mutex_release(struct Mutex *s);
73 /****************************************************************************/
75 typedef Mutex *sys_sem_t;
76 typedef MsgPort *sys_mbox_t;
77 typedef struct Process *sys_thread_t;
78 // TODO: what does it mean?
79 typedef int sys_prot_t;
81 #define SYS_MBOX_NULL (sys_mbox_t)0
82 #define SYS_SEM_NULL (sys_sem_t)0
89 sys_sem_t sys_sem_new(u8_t count);
90 void sys_sem_free(sys_sem_t sem);
91 void sys_sem_signal(sys_sem_t sem);
92 u32_t sys_arch_sem_wait(sys_sem_t sem, u32_t timeout);
94 sys_mbox_t sys_mbox_new(int);
95 void sys_mbox_free(sys_mbox_t mbox);
96 void sys_mbox_post(sys_mbox_t mbox, void *msg);
97 u32_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u32_t timeout);
99 struct sys_timeouts *sys_arch_timeouts(void);