aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGene Cumm <gene.cumm@gmail.com>2012-04-27 22:36:16 -0400
committerGene Cumm <gene.cumm@gmail.com>2012-04-27 22:36:16 -0400
commit930e929b202ed292077fb14981e5c6bd4c55651e (patch)
tree54c493d9b92aec7f6969a8d0d5de6a3b3f1d3b7c /core
parentb2d6e6e37706f7894d876927cd786362d6162368 (diff)
downloadsyslinux-930e929b202ed292077fb14981e5c6bd4c55651e.tar.gz
syslinux-930e929b202ed292077fb14981e5c6bd4c55651e.tar.xz
syslinux-930e929b202ed292077fb14981e5c6bd4c55651e.zip
core/pxe: lwip semaphore changes
Upstream changed how it called back to the system implementing semaphores/mutexes Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
Diffstat (limited to 'core')
-rw-r--r--core/lwip/src/arch/sys_arch.c98
-rw-r--r--core/lwip/src/include/arch/sys_arch.h7
-rw-r--r--core/lwip/src/include/lwipopts.h4
3 files changed, 80 insertions, 29 deletions
diff --git a/core/lwip/src/arch/sys_arch.c b/core/lwip/src/arch/sys_arch.c
index 65be3874..5f8437e8 100644
--- a/core/lwip/src/arch/sys_arch.c
+++ b/core/lwip/src/arch/sys_arch.c
@@ -8,77 +8,119 @@ void sys_init(void)
{
}
-sys_sem_t sys_sem_new(u8_t count)
+err_t sys_sem_new(sys_sem_t *sem, u8_t count)
{
- sys_sem_t sem = malloc(sizeof(struct semaphore));
if (!sem)
- return NULL;
+ return EINVAL;
+ *sem = malloc(sizeof(struct semaphore));
+ if (!*sem)
+ return ENOMEM;
- sem_init(sem, count);
- return sem;
+ sem_init(*sem, count);
+ return 0;
}
-void sys_sem_free(sys_sem_t sem)
+void sys_sem_free(sys_sem_t *sem)
{
- free(sem);
+ if (!!sem && !!*sem) {
+ sys_sem_set_invalid(sem);
+ free(*sem);
+ }
}
-u32_t sys_arch_sem_wait(sys_sem_t sem, u32_t timeout)
+void sys_sem_set_invalid(sys_sem_t *sem)
+{
+ if (!sem || !*sem)
+ return;
+ sem_set_invalid(*sem);
+}
+
+
+int sys_sem_valid(sys_sem_t *sem)
+{
+ if (!sem || !*sem)
+ return 0;
+ return sem_is_valid(*sem);
+}
+
+u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)
{
mstime_t rv;
- rv = sem_down(sem, timeout);
+ if (!!sem)
+ return SYS_ARCH_TIMEOUT;
+ rv = sem_down(*sem, timeout);
if (rv == (mstime_t)-1)
return SYS_ARCH_TIMEOUT;
else
return rv;
}
-sys_mbox_t sys_mbox_new(int size)
+err_t sys_mbox_new(sys_mbox_t *mbox, int size)
{
- struct mailbox *mbox;
-
- mbox = malloc(MBOX_BYTES(size));
if (!mbox)
- return NULL;
+ return EINVAL;
+ *mbox = malloc(MBOX_BYTES(size));
+ if (!(*mbox))
+ return ENOMEM;
- mbox_init(mbox, size);
- return mbox;
+ mbox_init(*mbox, size);
+ return 0;
}
-void sys_mbox_free(sys_mbox_t mbox)
+void sys_mbox_free(sys_mbox_t *mbox)
{
- free(mbox);
+ if (!!mbox && !!*mbox)
+ free(*mbox);
}
-void sys_mbox_post(sys_mbox_t mbox, void *msg)
+void sys_mbox_post(sys_mbox_t *mbox, void *msg)
{
- mbox_post(mbox, msg, 0);
+ if (!!mbox)
+ mbox_post(*mbox, msg, 0);
}
-err_t sys_mbox_trypost(sys_mbox_t mbox, void *msg)
+err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg)
{
- return mbox_post(mbox, msg, -1);
+ if (!mbox)
+ return EINVAL;
+ return mbox_post(*mbox, msg, -1);
}
-u32_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u32_t timeout)
+u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout)
{
mstime_t rv;
- rv = mbox_fetch(mbox, msg, timeout);
+ if (!mbox)
+ return SYS_MBOX_EMPTY;
+ rv = mbox_fetch(*mbox, msg, timeout);
if (rv == (mstime_t)-1)
return SYS_ARCH_TIMEOUT;
else
return rv;
}
-u32_t sys_arch_mbox_tryfetch(sys_mbox_t mbox, void **msg)
+u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg)
+{
+ if (!mbox)
+ return SYS_MBOX_EMPTY;
+ return mbox_fetch(*mbox, msg, -1);
+}
+
+void sys_mbox_set_invalid(sys_mbox_t *mbox)
{
- return mbox_fetch(mbox, msg, -1);
+ if (!!mbox)
+ mbox_set_invalid(*mbox);
}
-sys_thread_t sys_thread_new(char *name, void (*thread)(void *),
- void *arg, int stacksize, int prio)
+int sys_mbox_valid(sys_mbox_t *mbox)
+{
+ return ((!!mbox) && mbox_is_valid(*mbox));
+}
+
+
+sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread,
+ void *arg, int stacksize, int prio)
{
return start_thread(name, stacksize, prio, thread, arg);
}
diff --git a/core/lwip/src/include/arch/sys_arch.h b/core/lwip/src/include/arch/sys_arch.h
index 89126208..732a19c4 100644
--- a/core/lwip/src/include/arch/sys_arch.h
+++ b/core/lwip/src/include/arch/sys_arch.h
@@ -10,7 +10,12 @@ typedef struct semaphore *sys_sem_t;
typedef struct mailbox *sys_mbox_t;
typedef struct thread *sys_thread_t;
-#define sys_sem_signal(x) sem_up(x)
+static inline void sys_sem_signal(sys_sem_t *sem)
+{
+ if (!!sem)
+ sem_up(*sem);
+}
+
#define sys_now ms_timer
#define SYS_MBOX_NULL NULL
diff --git a/core/lwip/src/include/lwipopts.h b/core/lwip/src/include/lwipopts.h
index 5778fe5e..5f2ea204 100644
--- a/core/lwip/src/include/lwipopts.h
+++ b/core/lwip/src/include/lwipopts.h
@@ -2,6 +2,7 @@
#define __LWIPOPTS_H__
#include <byteswap.h>
+#include <netinet/in.h>
#define SYS_LIGHTWEIGHT_PROT 1
#define LWIP_NETIF_API 1
@@ -64,5 +65,8 @@
#define LWIP_PLATFORM_HTONS(x) bswap_16(x)
#define LWIP_PLATFORM_HTONL(x) bswap_32(x)
+#define LWIP_PREFIX_BYTEORDER_FUNCS 0
+#define LWIP_COMPAT_MUTEX 1
+
void undiarp_tmr(void);
#endif /* __LWIPOPTS_H__ */