UbixOS V2  2.0
sys_arch.c
Go to the documentation of this file.
1 #include <sys/types.h>
2 #include <ubixos/sched.h>
3 #include <ubixos/ubthread.h>
4 #include <ubixos/kpanic.h>
5 #include <lib/kprintf.h>
6 #include <lib/kmalloc.h>
7 #include <sys/sysproto_posix.h>
8 #include <sys/descrip.h>
9 
10 #include "net/debug.h"
11 #include "net/sys.h"
12 #include "net/opt.h"
13 #include "net/stats.h"
14 #include <net/arch/sys_arch.h>
15 
16 #include <ubixos/spinlock.h>
17 #include <ubixos/sem.h>
18 
19 /* Get Definitions For These */
20 #define ERR_NOT_READY 0
21 #define ERR_TIMED_OUT 1
22 #define INFINITE_TIME 0
23 
24 static struct timeval starttime;
25 static struct spinLock netThreadSpinlock = SPIN_LOCK_INITIALIZER;
26 static struct sys_thread *threads = 0x0;
27 
28 static uint32_t cond_wait(ubthread_cond_t *cond, ubthread_mutex_t *mutex, uint32_t timeout);
29 static void sys_sem_free_internal(struct sys_sem *sem);
30 
31 /* sys_arch layer initializer */
32 void sys_init() {
33  struct timezone tz;
34  gettimeofday(&starttime, &tz);
35 }
36 
37 #ifdef _IGNORE
38 static struct sys_sem *sys_sem_new_internal(uint8_t count) {
39  struct sys_sem *sem;
40 
41  sem = (struct sys_sem *) kmalloc(sizeof(struct sys_sem));
42  if (sem != NULL) {
43  sem->signaled = count;
44  ubthread_cond_init(&(sem->cond), NULL);
45  ubthread_mutex_init(&(sem->mutex), NULL);
46  }
47  return sem;
48 }
49 #endif
50 
51 /* Create a new semaphore */
53  return (sem_init(sem, count));
54 
55 #ifdef __IGNORE
56  sys_sem_t *newSem = 0x0;
57 
58  if (*sem != 0) {
59  kprintf("UH OH!");
60  }
61 
62  newSem = kmalloc(sizeof(struct sys_sem));
63  newSem->signaled = count;
64 
65  ubthread_cond_init(&(newSem->cond), NULL);
66  ubthread_mutex_init(&(newSem->mutex), NULL);
67 
68  *sem = newSem;
69 
70  return (ERR_OK);
71 #endif
72 }
73 
74 /* Deallocate semaphore */
75 void sys_sem_free(struct sys_sem **sem) {
76  sem_destroy(sem);
77 
78 #ifdef _IGNORE
79  if ((sem != NULL) && (*sem != SYS_SEM_NULL)) {
80  sys_sem_free_internal(*sem);
81  *sem = 0x0;
82  }
83 #endif
84 
85 
86 }
87 
88 /* Signal semaphore */
89 void sys_sem_signal(struct sys_sem **s) {
90  struct sys_sem *sem;
91  LWIP_ASSERT("invalid sem", (s != NULL) && (*s != NULL));
92  sem = *s;
93 
94  ubthread_mutex_lock(&(sem->mutex));
95  sem->signaled++;
96 
97  if (sem->signaled > 1) {
98  sem->signaled = 1;
99  }
100 
101  ubthread_cond_broadcast(&(sem->cond));
102  ubthread_mutex_unlock(&(sem->mutex));
103 }
104 
106  uint32_t time_needed = 0;
107  struct sys_sem *sem;
108  LWIP_ASSERT("invalid sem", (s != NULL) && (*s != NULL));
109  sem = *s;
110 
111  ubthread_mutex_lock(&(sem->mutex));
112  while (sem->signaled <= 0) {
113  if (timeout > 0) {
114  time_needed = cond_wait(&(sem->cond), &(sem->mutex), timeout);
115 
116  if (time_needed == SYS_ARCH_TIMEOUT) {
117  ubthread_mutex_unlock(&(sem->mutex));
118  return SYS_ARCH_TIMEOUT;
119  }
120  /* ubthread_mutex_unlock(&(sem->mutex));
121  return time_needed; */
122  }
123  else {
124  cond_wait(&(sem->cond), &(sem->mutex), 0);
125  }
126  }
127  sem->signaled--;
128  ubthread_mutex_unlock(&(sem->mutex));
129  return time_needed;
130 }
131 
132 int sys_sem_valid(struct sys_sem **s) {
133  struct sys_sem *sem = *s;
134  if (sem == 0)
135  return 0;
136  else
137  return 1;
138 }
139 
140 void sys_sem_set_invalid(struct sys_sem **s) {
141  *s = 0x0;
142 }
143 
146  return ERR_OK;
147 }
148 
151 }
152 
155 }
156 
159 }
160 
161 err_t sys_mbox_new(struct sys_mbox **mb, int size) {
162  struct sys_mbox *mbox = 0x0;
163  LWIP_UNUSED_ARG(size);
164 
165  mbox = (struct sys_mbox *) kmalloc(sizeof(struct sys_mbox));
166 
167  if (mbox == NULL)
168  return (ERR_MEM);
169 
170  mbox->head = 0;
171  mbox->tail = 0;
172  mbox->wait_send = 0;
173  //mbox->size = size;
174 
175  //Pass By Reference It's a Pointer
176  //ubthread_mutex_init(&mbox->lock, NULL);
177 
178  //Pass By Reference It's a Pointer
179  sys_sem_new(&mbox->lock, 1);
180  sys_sem_new(&mbox->empty, 0);
181  sys_sem_new(&mbox->full, 0);
182 
183  //mbox->queue = kmalloc(sizeof(void *) * size);//calloc(size, sizeof(void *));
184 
185  //if (!mbox->queue) {
186  // return ERR_MEM;
187  //}
188 
189  *mb = mbox;
190 
191  return (ERR_OK);
192 }
193 
194 void sys_mbox_free(struct sys_mbox **mb) {
195  if ((mb != NULL) && (*mb != SYS_MBOX_NULL)) {
196  struct sys_mbox *mbox = *mb;
197  sys_arch_sem_wait(&mbox->lock, 0);
198 /*
199  sys_sem_free_internal(mbox->full);
200  sys_sem_free_internal(mbox->empty);
201  sys_sem_free_internal(mbox->lock);
202 */
203  sem_destroy(mbox->full);
204  sem_destroy(mbox->empty);
205  sem_destroy(mbox->lock);
206 
207  mbox->full = mbox->empty = mbox->lock = NULL;
208  kfree(mbox);
209  *mb = 0x0;
210  }
211  //kfree(mbox->queue);
212  //mbox->queue = NULL;
213 }
214 
215 void sys_mbox_post(struct sys_mbox **mb, void *msg) {
216  uint8_t head;
217  struct sys_mbox *mbox;
218  LWIP_ASSERT("invalid mbox", (mb != NULL) && (*mb != NULL));
219  mbox = *mb;
220 
221  sys_arch_sem_wait(&mbox->lock, 0);
222 
223  LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_post: mbox %p msg %p\n", (void *)mbox, (void *)msg));
224 
225  while ((mbox->tail + 1) >= (mbox->head + SYS_MBOX_SIZE)) {
226  mbox->wait_send++;
227  sys_sem_signal(&mbox->lock);
228  sys_arch_sem_wait(&mbox->empty, 0);
229  sys_arch_sem_wait(&mbox->lock, 0);
230  mbox->wait_send--;
231  }
232 
233  mbox->msgs[mbox->tail % SYS_MBOX_SIZE] = msg;
234 
235  if (mbox->tail == mbox->head) {
236  head = 1;
237  }
238  else {
239  head = 0;
240  }
241 
242  mbox->tail++;
243 
244  if (head) {
245  sys_sem_signal(&mbox->full);
246  }
247 
248  sys_sem_signal(&mbox->lock);
249 }
250 
251 err_t sys_mbox_trypost(struct sys_mbox **mb, void *msg) {
252  uint8_t head;
253  struct sys_mbox *mbox;
254  LWIP_ASSERT("invalid mbox", (mb != NULL) && (*mb != NULL));
255  mbox = *mb;
256 
257  sys_arch_sem_wait(&mbox->lock, 0);
258 
259  LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_trypost: mbox %p msg %p\n",
260  (void *)mbox, (void *)msg));
261 
262  if ((mbox->tail + 1) >= (mbox->head + SYS_MBOX_SIZE)) {
263  sys_sem_signal(&mbox->lock);
264  return ERR_MEM;
265  }
266 
267  mbox->msgs[mbox->tail % SYS_MBOX_SIZE] = msg;
268 
269  if (mbox->tail == mbox->head) {
270  head = 1;
271  }
272  else {
273  head = 0;
274  }
275 
276  mbox->tail++;
277 
278  if (head) {
279  sys_sem_signal(&mbox->full);
280  }
281 
282  sys_sem_signal(&mbox->lock);
283 
284  return ERR_OK;
285 }
286 
287 uint32_t sys_arch_mbox_fetch(struct sys_mbox **mb, void **msg, uint32_t timeout) {
288  uint32_t time_needed = 0x0;
289  struct sys_mbox *mbox = 0x0;
290 
291  LWIP_ASSERT("invalid mbox", (mb != NULL) && (*mb != NULL));
292  mbox = *mb;
293 
294  /* The mutex lock is quick so we don't bother with the timeout
295  stuff here. */
296  sys_arch_sem_wait(&mbox->lock, 0);
297 
298  while (mbox->head == mbox->tail) {
299  sys_sem_signal(&mbox->lock);
300 
301  /* We block while waiting for a mail to arrive in the mailbox. We
302  must be prepared to timeout. */
303  if (timeout != 0) {
304  time_needed = sys_arch_sem_wait(&mbox->full, timeout);
305 
306  if (time_needed == SYS_ARCH_TIMEOUT) {
307  return SYS_ARCH_TIMEOUT;
308  }
309  }
310  else {
311  sys_arch_sem_wait(&mbox->full, 0);
312  }
313 
314  sys_arch_sem_wait(&mbox->lock, 0);
315  }
316 
317  if (msg != NULL) {
318  LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_fetch: mbox %p msg %p\n", (void *)mbox, *msg));
319  *msg = mbox->msgs[mbox->head % SYS_MBOX_SIZE];
320  }
321  else {
322  LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_fetch: mbox %p, null msg\n", (void *)mbox));
323  }
324 
325  mbox->head++;
326 
327  if (mbox->wait_send) {
328  sys_sem_signal(&mbox->empty);
329  }
330 
331  sys_sem_signal(&mbox->lock);
332 
333  return time_needed;
334 }
335 
336 uint32_t sys_arch_mbox_tryfetch(struct sys_mbox **mb, void **msg) {
337  struct sys_mbox *mbox;
338  LWIP_ASSERT("invalid mbox", (mb != NULL) && (*mb != NULL));
339  mbox = *mb;
340 
341  sys_arch_sem_wait(&mbox->lock, 0);
342 
343  if (mbox->head == mbox->tail) {
344  sys_sem_signal(&mbox->lock);
345  return SYS_MBOX_EMPTY;
346  }
347 
348  if (msg != NULL) {
349  LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_tryfetch: mbox %p msg %p\n", (void *)mbox, *msg));
350  *msg = mbox->msgs[mbox->head % SYS_MBOX_SIZE];
351  }
352  else {
353  LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_tryfetch: mbox %p, null msg\n", (void *)mbox));
354  }
355 
356  mbox->head++;
357 
358  if (mbox->wait_send) {
359  sys_sem_signal(&mbox->empty);
360  }
361 
362  sys_sem_signal(&mbox->lock);
363 
364  return 0;
365 }
366 
367 int sys_mbox_valid(struct sys_mbox **mb) {
368  struct sys_mbox *mbox = *mb;
369  if (mbox == NULL)
370  return(0);
371  else
372  return(1);
373 }
374 
375 void sys_mbox_set_invalid(struct sys_mbox **mb) {
376  *mb = 0x0;
377 }
378 
379 sys_thread_t sys_thread_new(const char *name, void (*thread)(void *arg), void *arg, int stacksize, int prio) {
380  //void sys_thread_new(void (*function)(void), void *arg) {
381  struct sys_thread *new_thread = 0x0;
382  //struct thread_start_param *thread_param;
383  prio = 1;
384  LWIP_ASSERT("Non-positive prio", prio > 0);
385  LWIP_ASSERT("Prio is too big", prio < 20);
386 
387  new_thread = kmalloc(sizeof(struct sys_thread));
388  memset(new_thread, 0x0, sizeof(struct sys_thread));
389 
390  spinLock(&netThreadSpinlock);
391  new_thread->next = threads;
392  new_thread->timeouts.next = NULL;
393  new_thread->ubthread = 0x0;
394  threads = new_thread;
395  spinUnlock(&netThreadSpinlock);
396 
397  /*
398  thread_param = kmalloc(sizeof(struct thread_start_param));
399 
400  thread_param->function = function;
401  thread_param->arg = arg;
402  thread_param->thread = thread;
403  */
404  if (ubthread_create(&new_thread->ubthread, 0x0, (void *) (thread), arg) != 0x0) {
405  kpanic("sys_thread_new: ubthread_create");
406  }
407  return (new_thread);
408 }
409 
410 /* OLD */
411 
414  void (*function)(void *);
415  void *arg;
416 };
417 
418 static uint32_t cond_wait(ubthread_cond_t *cond, ubthread_mutex_t *mutex, uint32_t timeout) {
419  unsigned int tdiff;
420  unsigned long sec, usec;
421  struct timeval rtime1, rtime2;
422  struct timespec ts;
423  struct timezone tz;
424  int retval;
425 
426  if (timeout > 0) {
427  /* Get a timestamp and add the timeout value. */
428  gettimeofday(&rtime1, &tz);
429  sec = rtime1.tv_sec;
430  usec = rtime1.tv_usec;
431  usec += timeout % 1000 * 1000;
432  sec += (int) (timeout / 1000) + (int) (usec / 1000000);
433  usec = usec % 1000000;
434  ts.tv_nsec = usec * 1000;
435  ts.tv_sec = sec;
436 
437  retval = ubthread_cond_timedwait(cond, mutex, &ts);
438  if (retval == ETIMEDOUT) {
439  return 0;
440  }
441  else {
442  /* Calculate for how long we waited for the cond. */
443  gettimeofday(&rtime2, &tz);
444  tdiff = (rtime2.tv_sec - rtime1.tv_sec) * 1000 + (rtime2.tv_usec - rtime1.tv_usec) / 1000;
445  if (tdiff == 0) {
446  return 1;
447  }
448  return tdiff;
449  }
450  }
451  else {
452  ubthread_cond_wait(cond, mutex);
453  return 0;
454  }
455 }
456 
457 static struct sys_thread *current_thread(void) {
458  struct sys_thread *st;
459  kTask_t *pt;
460  pt = ubthread_self();
461  spinLock(&netThreadSpinlock);
462  for (st = threads; st != NULL; st = st->next) {
463  if (st->ubthread == pt) {
464  spinUnlock(&netThreadSpinlock);
465  return st;
466  }
467  }
468  spinUnlock(&netThreadSpinlock);
469  kprintf("sys: current_thread: could not find current thread!\n");
470  kprintf("This is due to a race condition in the LinuxThreads\n");
471  kprintf("ubthreads implementation. Start the program again.\n");
472 
473  kpanic("ABORT");
474  return (0x0);
475 }
476 
478  struct sys_thread *thread;
479  thread = current_thread();
480  return (&thread->timeouts);
481 }
482 
483 unsigned long sys_unix_now() {
484  struct timeval tv;
485  struct timezone tz;
486  long sec, usec;
487  unsigned long msec;
488 
489  gettimeofday(&tv, &tz);
490 
491  sec = tv.tv_sec - starttime.tv_sec;
492  usec = tv.tv_usec - starttime.tv_usec;
493  msec = sec * 1000 + usec / 1000;
494  return msec;
495 }
496 
498  return (sys_unix_now());
499 }
500 
501 
502 int sys_socket(struct thread *td, struct sys_socket_args *args) {
503  int error = 0x0;
504  int fd = 0x0;
505  struct file *nfp = 0x0;
506 
507  error = falloc(td, &nfp, &fd);
508 
509  if (error)
510  return (error);
511 
512  nfp->socket = lwip_socket(args->domain, args->type, args->protocol);
513  nfp->fd_type = 2;
514  kprintf("socket(%i:%i): 0x%X:0x%X:0x%X", nfp->socket, fd, args->domain, args->type, args->protocol);
515 
516  if (nfp->fd == 0x0 && nfp->socket) {
517  fdestroy(td, nfp, fd);
518 
519  td->td_retval[0] = -1;
520  error = -1;
521  }
522  else {
523  td->td_retval[0] = fd;//nfp->fd; //MrOlsen 2018index;
524  }
525 
526  return (error);
527 }
528 
529 int sys_setsockopt(struct thread *td, struct sys_setsockopt_args *args) {
530  struct file *fd = 0x0;
531  getfd(td, &fd, args->s);
532 
533  td->td_retval[0] = lwip_setsockopt(fd->socket, args->level, args->name, args->val, args->valsize);
534  kprintf("SSO: %i:%i:%i", args->s, fd->socket, td->td_retval[0]);
535  td->td_retval[0] = 0;
536 
537  return(0);
538 }
539 
540 int sys_sendto(struct thread *td, struct sys_sendto_args *args) {
541  struct file *fd = 0x0;
542  getfd(td, &fd, args->s);
543 
544  lwip_sendto(fd->socket, args->buf, args->len, args->flags, args->to, args->tolen);
545  td->td_retval[0] = 0x0;
546 
547  return (0);
548 }
taskStruct
Definition: sched.h:62
sys.h
sys_mbox::wait_send
int wait_send
Definition: sys_arch.h:35
opt.h
timezone
Definition: time.h:55
sys_setsockopt
int sys_setsockopt(struct thread *td, struct sys_setsockopt_args *args)
Definition: sys_arch.c:529
spinlock.h
sys_sem_set_invalid
void sys_sem_set_invalid(struct sys_sem **s)
Definition: sys_arch.c:140
sys_mbox_free
void sys_mbox_free(struct sys_mbox **mb)
Definition: sys_arch.c:194
sys_socket_args::type
int type
Definition: sysproto_posix.h:646
ubthread_mutex
Definition: ubthread.h:52
LWIP_ASSERT
#define LWIP_ASSERT(message, assertion)
Definition: debug.h:116
sys_timeouts::next
struct sys_timeout * next
Definition: sys_arch.h:13
sys_sem_new
err_t sys_sem_new(sys_sem_t **sem, uint8_t count)
Definition: sys_arch.c:52
sys_sendto_args::to
caddr_t to
Definition: sysproto_posix.h:712
sys_arch_mbox_tryfetch
uint32_t sys_arch_mbox_tryfetch(struct sys_mbox **mb, void **msg)
Definition: sys_arch.c:336
ubthread_cond_wait
int ubthread_cond_wait(ubthread_cond_t *cond, ubthread_mutex_t *mutex)
Definition: ubthread.c:148
sys_sem_free
void sys_sem_free(struct sys_sem **sem)
Definition: sys_arch.c:75
timeval::tv_usec
suseconds_t tv_usec
Definition: _timeval.h:19
sys_setsockopt_args::val
caddr_t val
Definition: sysproto_posix.h:664
ubthread_self
struct taskStruct * ubthread_self()
Definition: ubthread.c:45
sys_sem::mutex
ubthread_mutex_t mutex
Definition: sem.h:39
sys_sendto_args::s
int s
Definition: sysproto_posix.h:700
sem.h
sys_sem_valid
int sys_sem_valid(struct sys_sem **s)
Definition: sys_arch.c:132
sys_arch_sem_wait
uint32_t sys_arch_sem_wait(struct sys_sem **s, uint32_t timeout)
Definition: sys_arch.c:105
sysproto_posix.h
file
Definition: descrip.h:67
kfree
void kfree(void *baseAddr)
Definition: kmalloc.c:342
sys_mbox::lock
struct sys_sem * lock
Definition: sys_arch.h:33
sem_destroy
int sem_destroy(sys_sem_t **)
Definition: sem.c:87
thread
Definition: thread.h:40
thread_start_param::thread
struct sys_thread * thread
Definition: sys_arch.c:413
spinUnlock
void spinUnlock(spinLock_t *lock)
Definition: spinlock.c:36
sys_thread
Definition: sys_arch.h:43
sys_socket_args::protocol
int protocol
Definition: sysproto_posix.h:649
sys_arch.h
sys_thread_new
sys_thread_t sys_thread_new(const char *name, void(*thread)(void *arg), void *arg, int stacksize, int prio)
Definition: sys_arch.c:379
sys_mbox_post
void sys_mbox_post(struct sys_mbox **mb, void *msg)
Definition: sys_arch.c:215
sys_sendto_args
Definition: sysproto_posix.h:698
fdestroy
int fdestroy(struct thread *td, struct file *fp, int fd)
The function bar.
Definition: descrip.c:147
ETIMEDOUT
#define ETIMEDOUT
Definition: errno.h:105
SPIN_LOCK_INITIALIZER
#define SPIN_LOCK_INITIALIZER
Definition: spinlock.h:36
sys_setsockopt_args
Definition: sysproto_posix.h:653
sys_timeouts
Definition: sys_arch.h:12
sys_mutex_free
void sys_mutex_free(sys_mutex_t *mutex)
Definition: sys_arch.c:149
sys_sem::signaled
uint32_t signaled
Definition: sem.h:37
sched.h
falloc
int falloc(struct thread *, struct file **, int *)
Definition: descrip.c:96
kpanic
void kpanic(const char *fmt,...)
print panic message and halt system
Definition: kpanic.c:41
types.h
sys_mutex_lock
void sys_mutex_lock(sys_mutex_t *mutex)
Definition: sys_arch.c:153
file::fd_type
int fd_type
Definition: descrip.h:72
ubthread_mutex_init
int ubthread_mutex_init(ubthread_mutex_t *mutex, const uInt32 attr)
sys_setsockopt_args::s
int s
Definition: sysproto_posix.h:655
sys_sem
Definition: sem.h:36
SYS_MBOX_SIZE
#define SYS_MBOX_SIZE
Definition: sys_arch.h:9
sys_sendto_args::flags
int flags
Definition: sysproto_posix.h:709
timespec::tv_nsec
long tv_nsec
Definition: _timespec.h:13
sem_init
int sem_init(sys_sem_t **, uint8_t)
Definition: sem.c:56
spinLock
void spinLock(spinLock_t *lock)
Definition: spinlock.c:55
kpanic.h
stats.h
ERR_MEM
Definition: err.h:65
thread_start_param
Definition: sys_arch.c:412
timespec::tv_sec
time_t tv_sec
Definition: _timespec.h:12
file::fd
fileDescriptor_t * fd
Definition: descrip.h:71
sys_now
uint32_t sys_now()
Definition: sys_arch.c:497
gettimeofday
int gettimeofday(struct timeval *tp, struct timezone *tzp)
Definition: time.c:110
thread::td_retval
int td_retval[2]
Definition: thread.h:41
sys_sem_signal
void sys_sem_signal(struct sys_sem **s)
Definition: sys_arch.c:89
ubthread_mutex_unlock
int ubthread_mutex_unlock(ubthread_mutex_t *mutex)
Definition: ubthread.c:109
sys_mbox::empty
struct sys_sem * empty
Definition: sys_arch.h:31
kprintf.h
ubthread_mutex_lock
int ubthread_mutex_lock(ubthread_mutex_t *mutex)
Definition: ubthread.c:88
sys_setsockopt_args::level
int level
Definition: sysproto_posix.h:658
sys_sendto
int sys_sendto(struct thread *td, struct sys_sendto_args *args)
Definition: sys_arch.c:540
mutex
struct ubthread_mutex_list * mutex
Definition: ubthread.c:43
sys_thread::timeouts
struct sys_timeouts timeouts
Definition: sys_arch.h:45
ubthread_cond_timedwait
int ubthread_cond_timedwait(ubthread_cond_t *cond, ubthread_mutex_t *mutex, const struct timespec *abstime)
Definition: ubthread.c:129
ubthread.h
getfd
int getfd(struct thread *td, struct file **fp, int fd)
get pointer to file fd in specified thread
Definition: descrip.c:214
sys_mbox::full
struct sys_sem * full
Definition: sys_arch.h:32
sys_sendto_args::len
size_t len
Definition: sysproto_posix.h:706
ubthread_mutex_list::mutex
ubthread_mutex_t * mutex
Definition: ubthread.h:70
LWIP_UNUSED_ARG
#define LWIP_UNUSED_ARG(x)
Definition: arch.h:315
uint32_t
__uint32_t uint32_t
Definition: types.h:46
sys_mbox_valid
int sys_mbox_valid(struct sys_mbox **mb)
Definition: sys_arch.c:367
sys_sem::cond
ubthread_cond_t cond
Definition: sem.h:38
sys_mutex_new
err_t sys_mutex_new(sys_mutex_t *mutex)
Definition: sys_arch.c:144
SYS_DEBUG
#define SYS_DEBUG
Definition: lwipopts.h:459
sys_socket_args
Definition: sysproto_posix.h:641
sys_setsockopt_args::name
int name
Definition: sysproto_posix.h:661
sys_arch_timeouts
struct sys_timeouts * sys_arch_timeouts(void)
Definition: sys_arch.c:477
sys_thread::ubthread
kTask_t * ubthread
Definition: sys_arch.h:46
sys_arch_mbox_fetch
uint32_t sys_arch_mbox_fetch(struct sys_mbox **mb, void **msg, uint32_t timeout)
Definition: sys_arch.c:287
timeval::tv_sec
time_t tv_sec
Definition: _timeval.h:18
sys_mbox::head
uint32_t head
Definition: sys_arch.h:23
sys_mbox_set_invalid
void sys_mbox_set_invalid(struct sys_mbox **mb)
Definition: sys_arch.c:375
sys_sendto_args::tolen
int tolen
Definition: sysproto_posix.h:715
ERR_OK
Definition: err.h:63
sys_mutex_unlock
void sys_mutex_unlock(sys_mutex_t *mutex)
Definition: sys_arch.c:157
err_t
s8_t err_t
Definition: err.h:57
sys_setsockopt_args::valsize
int valsize
Definition: sysproto_posix.h:667
name
const char * name
Definition: pci.c:37
sys_sendto_args::buf
caddr_t buf
Definition: sysproto_posix.h:703
ubthread_cond_broadcast
int ubthread_cond_broadcast(ubthread_cond_t *cond)
Definition: ubthread.c:164
sys_thread::next
struct sys_thread * next
Definition: sys_arch.h:44
timeval
Definition: _timeval.h:17
thread_start_param::arg
void * arg
Definition: sys_arch.c:415
sys_socket_args::domain
int domain
Definition: sysproto_posix.h:643
ubthread_mutex_destroy
int ubthread_mutex_destroy(ubthread_mutex_t *mutex)
Definition: ubthread.c:77
kmalloc
void * kmalloc(uInt32 len)
Definition: kmalloc.c:241
ubthread_cond_init
int ubthread_cond_init(ubthread_cond_t *cond, const uInt32 attr)
spinLock
Definition: spinlock.h:41
descrip.h
memset
void * memset(void *dst, int c, size_t length)
SYS_MBOX_EMPTY
#define SYS_MBOX_EMPTY
Definition: sys.h:52
sys_init
void sys_init()
Definition: sys_arch.c:32
SYS_ARCH_TIMEOUT
#define SYS_ARCH_TIMEOUT
Definition: sys.h:47
ubthread_cond
Definition: ubthread.h:47
sys_unix_now
unsigned long sys_unix_now()
Definition: sys_arch.c:483
sys_socket
int sys_socket(struct thread *td, struct sys_socket_args *args)
Definition: sys_arch.c:502
sys_mbox_new
err_t sys_mbox_new(struct sys_mbox **mb, int size)
Definition: sys_arch.c:161
sys_mbox::tail
uint32_t tail
Definition: sys_arch.h:24
SYS_SEM_NULL
#define SYS_SEM_NULL
Definition: sys_arch.h:8
uint8_t
__uint8_t uint8_t
Definition: types.h:44
timespec
Definition: _timespec.h:11
file::socket
int socket
Definition: descrip.h:73
kprintf
int kprintf(const char *,...)
Definition: kprintf.c:259
sys_mbox_trypost
err_t sys_mbox_trypost(struct sys_mbox **mb, void *msg)
Definition: sys_arch.c:251
SYS_MBOX_NULL
#define SYS_MBOX_NULL
Definition: sys_arch.h:7
sys_mutex
Definition: sys_arch.h:16
LWIP_DEBUGF
#define LWIP_DEBUGF(debug, message)
Definition: debug.h:164
kmalloc.h
debug.h
sys_mbox
Definition: sys_arch.h:22
ubthread_create
int ubthread_create(struct taskStruct **thread, const uInt32 *attr, void(*tproc)(void), void *arg)
Definition: ubthread.c:83
NULL
#define NULL
Definition: fat_string.h:17