UbixOS  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 /* Signal semaphore */
88 void sys_sem_signal(struct sys_sem **s) {
89  struct sys_sem *sem;
90  LWIP_ASSERT("invalid sem", (s != NULL) && (*s != NULL));
91  sem = *s;
92 
93  ubthread_mutex_lock(&(sem->mutex));
94  sem->signaled++;
95 
96  if (sem->signaled > 1) {
97  sem->signaled = 1;
98  }
99 
100  ubthread_cond_broadcast(&(sem->cond));
101  ubthread_mutex_unlock(&(sem->mutex));
102 }
103 
105  uint32_t time_needed = 0;
106  struct sys_sem *sem;
107  LWIP_ASSERT("invalid sem", (s != NULL) && (*s != NULL));
108  sem = *s;
109 
110  ubthread_mutex_lock(&(sem->mutex));
111  while (sem->signaled <= 0) {
112  if (timeout > 0) {
113  time_needed = cond_wait(&(sem->cond), &(sem->mutex), timeout);
114 
115  if (time_needed == SYS_ARCH_TIMEOUT) {
116  ubthread_mutex_unlock(&(sem->mutex));
117  return SYS_ARCH_TIMEOUT;
118  }
119  /* ubthread_mutex_unlock(&(sem->mutex));
120  return time_needed; */
121  }
122  else {
123  cond_wait(&(sem->cond), &(sem->mutex), 0);
124  }
125  }
126  sem->signaled--;
127  ubthread_mutex_unlock(&(sem->mutex));
128  return time_needed;
129 }
130 
131 int sys_sem_valid(struct sys_sem **s) {
132  struct sys_sem *sem = *s;
133  if (sem == 0)
134  return 0;
135  else
136  return 1;
137 }
138 
139 void sys_sem_set_invalid(struct sys_sem **s) {
140  *s = 0x0;
141 }
142 
145  return ERR_OK;
146 }
147 
150 }
151 
154 }
155 
158 }
159 
160 err_t sys_mbox_new(struct sys_mbox **mb, int size) {
161  struct sys_mbox *mbox = 0x0;
162  LWIP_UNUSED_ARG(size);
163 
164  mbox = (struct sys_mbox*) kmalloc(sizeof(struct sys_mbox));
165 
166  if (mbox == NULL)
167  return (ERR_MEM);
168 
169  mbox->head = 0;
170  mbox->tail = 0;
171  mbox->wait_send = 0;
172  //mbox->size = size;
173 
174  //Pass By Reference It's a Pointer
175  //ubthread_mutex_init(&mbox->lock, NULL);
176 
177  //Pass By Reference It's a Pointer
178  sys_sem_new(&mbox->lock, 1);
179  sys_sem_new(&mbox->empty, 0);
180  sys_sem_new(&mbox->full, 0);
181 
182  //mbox->queue = kmalloc(sizeof(void *) * size);//calloc(size, sizeof(void *));
183 
184  //if (!mbox->queue) {
185  // return ERR_MEM;
186  //}
187 
188  *mb = mbox;
189 
190  return (ERR_OK);
191 }
192 
193 void sys_mbox_free(struct sys_mbox **mb) {
194  if ((mb != NULL) && (*mb != SYS_MBOX_NULL)) {
195  struct sys_mbox *mbox = *mb;
196  sys_arch_sem_wait(&mbox->lock, 0);
197  /*
198  sys_sem_free_internal(mbox->full);
199  sys_sem_free_internal(mbox->empty);
200  sys_sem_free_internal(mbox->lock);
201  */
202  sem_destroy(mbox->full);
203  sem_destroy(mbox->empty);
204  sem_destroy(mbox->lock);
205 
206  mbox->full = mbox->empty = mbox->lock = NULL;
207  kfree(mbox);
208  *mb = 0x0;
209  }
210  //kfree(mbox->queue);
211  //mbox->queue = NULL;
212 }
213 
214 void sys_mbox_post(struct sys_mbox **mb, void *msg) {
215  uint8_t head;
216  struct sys_mbox *mbox;
217  LWIP_ASSERT("invalid mbox", (mb != NULL) && (*mb != NULL));
218  mbox = *mb;
219 
220  sys_arch_sem_wait(&mbox->lock, 0);
221 
222  LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_post: mbox %p msg %p\n", (void *)mbox, (void *)msg));
223 
224  while ((mbox->tail + 1) >= (mbox->head + SYS_MBOX_SIZE)) {
225  mbox->wait_send++;
226  sys_sem_signal(&mbox->lock);
227  sys_arch_sem_wait(&mbox->empty, 0);
228  sys_arch_sem_wait(&mbox->lock, 0);
229  mbox->wait_send--;
230  }
231 
232  mbox->msgs[mbox->tail % SYS_MBOX_SIZE] = msg;
233 
234  if (mbox->tail == mbox->head) {
235  head = 1;
236  }
237  else {
238  head = 0;
239  }
240 
241  mbox->tail++;
242 
243  if (head) {
244  sys_sem_signal(&mbox->full);
245  }
246 
247  sys_sem_signal(&mbox->lock);
248 }
249 
250 err_t sys_mbox_trypost(struct sys_mbox **mb, void *msg) {
251  uint8_t head;
252  struct sys_mbox *mbox;
253  LWIP_ASSERT("invalid mbox", (mb != NULL) && (*mb != NULL));
254  mbox = *mb;
255 
256  sys_arch_sem_wait(&mbox->lock, 0);
257 
258  LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_trypost: mbox %p msg %p\n",
259  (void *)mbox, (void *)msg));
260 
261  if ((mbox->tail + 1) >= (mbox->head + SYS_MBOX_SIZE)) {
262  sys_sem_signal(&mbox->lock);
263  return ERR_MEM;
264  }
265 
266  mbox->msgs[mbox->tail % SYS_MBOX_SIZE] = msg;
267 
268  if (mbox->tail == mbox->head) {
269  head = 1;
270  }
271  else {
272  head = 0;
273  }
274 
275  mbox->tail++;
276 
277  if (head) {
278  sys_sem_signal(&mbox->full);
279  }
280 
281  sys_sem_signal(&mbox->lock);
282 
283  return ERR_OK;
284 }
285 
286 uint32_t sys_arch_mbox_fetch(struct sys_mbox **mb, void **msg, uint32_t timeout) {
287  uint32_t time_needed = 0x0;
288  struct sys_mbox *mbox = 0x0;
289 
290  LWIP_ASSERT("invalid mbox", (mb != NULL) && (*mb != NULL));
291  mbox = *mb;
292 
293  /* The mutex lock is quick so we don't bother with the timeout
294  stuff here. */
295  sys_arch_sem_wait(&mbox->lock, 0);
296 
297  while (mbox->head == mbox->tail) {
298  sys_sem_signal(&mbox->lock);
299 
300  /* We block while waiting for a mail to arrive in the mailbox. We
301  must be prepared to timeout. */
302  if (timeout != 0) {
303  time_needed = sys_arch_sem_wait(&mbox->full, timeout);
304 
305  if (time_needed == SYS_ARCH_TIMEOUT) {
306  return SYS_ARCH_TIMEOUT;
307  }
308  }
309  else {
310  sys_arch_sem_wait(&mbox->full, 0);
311  }
312 
313  sys_arch_sem_wait(&mbox->lock, 0);
314  }
315 
316  if (msg != NULL) {
317  LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_fetch: mbox %p msg %p\n", (void *)mbox, *msg));
318  *msg = mbox->msgs[mbox->head % SYS_MBOX_SIZE];
319  }
320  else {
321  LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_fetch: mbox %p, null msg\n", (void *)mbox));
322  }
323 
324  mbox->head++;
325 
326  if (mbox->wait_send) {
327  sys_sem_signal(&mbox->empty);
328  }
329 
330  sys_sem_signal(&mbox->lock);
331 
332  return time_needed;
333 }
334 
335 uint32_t sys_arch_mbox_tryfetch(struct sys_mbox **mb, void **msg) {
336  struct sys_mbox *mbox;
337  LWIP_ASSERT("invalid mbox", (mb != NULL) && (*mb != NULL));
338  mbox = *mb;
339 
340  sys_arch_sem_wait(&mbox->lock, 0);
341 
342  if (mbox->head == mbox->tail) {
343  sys_sem_signal(&mbox->lock);
344  return SYS_MBOX_EMPTY;
345  }
346 
347  if (msg != NULL) {
348  LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_tryfetch: mbox %p msg %p\n", (void *)mbox, *msg));
349  *msg = mbox->msgs[mbox->head % SYS_MBOX_SIZE];
350  }
351  else {
352  LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_tryfetch: mbox %p, null msg\n", (void *)mbox));
353  }
354 
355  mbox->head++;
356 
357  if (mbox->wait_send) {
358  sys_sem_signal(&mbox->empty);
359  }
360 
361  sys_sem_signal(&mbox->lock);
362 
363  return 0;
364 }
365 
366 int sys_mbox_valid(struct sys_mbox **mb) {
367  struct sys_mbox *mbox = *mb;
368  if (mbox == NULL)
369  return (0);
370  else
371  return (1);
372 }
373 
374 void sys_mbox_set_invalid(struct sys_mbox **mb) {
375  *mb = 0x0;
376 }
377 
378 sys_thread_t sys_thread_new(const char *name, void (*thread)(void *arg), void *arg, int stacksize, int prio) {
379  //void sys_thread_new(void (*function)(void), void *arg) {
380  struct sys_thread *new_thread = 0x0;
381  //struct thread_start_param *thread_param;
382  prio = 1;
383  LWIP_ASSERT("Non-positive prio", prio > 0);
384  LWIP_ASSERT("Prio is too big", prio < 20);
385 
386  new_thread = kmalloc(sizeof(struct sys_thread));
387  memset(new_thread, 0x0, sizeof(struct sys_thread));
388 
389  spinLock(&netThreadSpinlock);
390  new_thread->next = threads;
391  new_thread->timeouts.next = NULL;
392  new_thread->ubthread = 0x0;
393  threads = new_thread;
394  spinUnlock(&netThreadSpinlock);
395 
396  /*
397  thread_param = kmalloc(sizeof(struct thread_start_param));
398 
399  thread_param->function = function;
400  thread_param->arg = arg;
401  thread_param->thread = thread;
402  */
403  if (ubthread_create(&new_thread->ubthread, 0x0, (void*) (thread), arg) != 0x0) {
404  kpanic("sys_thread_new: ubthread_create");
405  }
406  return (new_thread);
407 }
408 
409 /* OLD */
410 
413  void (*function)(void*);
414  void *arg;
415 };
416 
417 static uint32_t cond_wait(ubthread_cond_t *cond, ubthread_mutex_t *mutex, uint32_t timeout) {
418  unsigned int tdiff;
419  unsigned long sec, usec;
420  struct timeval rtime1, rtime2;
421  struct timespec ts;
422  struct timezone tz;
423  int retval;
424 
425  if (timeout > 0) {
426  /* Get a timestamp and add the timeout value. */
427  gettimeofday(&rtime1, &tz);
428  sec = rtime1.tv_sec;
429  usec = rtime1.tv_usec;
430  usec += timeout % 1000 * 1000;
431  sec += (int) (timeout / 1000) + (int) (usec / 1000000);
432  usec = usec % 1000000;
433  ts.tv_nsec = usec * 1000;
434  ts.tv_sec = sec;
435 
436  retval = ubthread_cond_timedwait(cond, mutex, &ts);
437  if (retval == ETIMEDOUT) {
438  return 0;
439  }
440  else {
441  /* Calculate for how long we waited for the cond. */
442  gettimeofday(&rtime2, &tz);
443  tdiff = (rtime2.tv_sec - rtime1.tv_sec) * 1000 + (rtime2.tv_usec - rtime1.tv_usec) / 1000;
444  if (tdiff == 0) {
445  return 1;
446  }
447  return tdiff;
448  }
449  }
450  else {
451  ubthread_cond_wait(cond, mutex);
452  return 0;
453  }
454 }
455 
456 static struct sys_thread* current_thread(void) {
457  struct sys_thread *st;
458  kTask_t *pt;
459  pt = ubthread_self();
460  spinLock(&netThreadSpinlock);
461  for (st = threads; st != NULL; st = st->next) {
462  if (st->ubthread == pt) {
463  spinUnlock(&netThreadSpinlock);
464  return st;
465  }
466  }
467  spinUnlock(&netThreadSpinlock);
468  kprintf("sys: current_thread: could not find current thread!\n");
469  kprintf("This is due to a race condition in the LinuxThreads\n");
470  kprintf("ubthreads implementation. Start the program again.\n");
471 
472  kpanic("ABORT");
473  return (0x0);
474 }
475 
477  struct sys_thread *thread;
478  thread = current_thread();
479  return (&thread->timeouts);
480 }
481 
482 unsigned long sys_unix_now() {
483  struct timeval tv;
484  struct timezone tz;
485  long sec, usec;
486  unsigned long msec;
487 
488  gettimeofday(&tv, &tz);
489 
490  sec = tv.tv_sec - starttime.tv_sec;
491  usec = tv.tv_usec - starttime.tv_usec;
492  msec = sec * 1000 + usec / 1000;
493  return msec;
494 }
495 
497  return (sys_unix_now());
498 }
499 
500 int sys_socket(struct thread *td, struct sys_socket_args *args) {
501  int error = 0x0;
502  int fd = 0x0;
503  struct file *nfp = 0x0;
504 
505  error = falloc(td, &nfp, &fd);
506 
507  if (error)
508  return (error);
509 
510  nfp->socket = lwip_socket(args->domain, args->type, args->protocol);
511  nfp->fd_type = 2;
512  kprintf("socket(%i:%i): 0x%X:0x%X:0x%X", nfp->socket, fd, args->domain, args->type, args->protocol);
513 
514  if (nfp->fd == 0x0 && nfp->socket) {
515  if (fdestroy(td, nfp, fd) != 0x0)
516  kprintf("[%s:%i] fdestroy() failed.", __FILE__, __LINE__);
517 
518  td->td_retval[0] = -1;
519  error = -1;
520  }
521  else {
522  td->td_retval[0] = fd; //nfp->fd; //MrOlsen 2018index;
523  }
524 
525  return (error);
526 }
527 
528 int sys_setsockopt(struct thread *td, struct sys_setsockopt_args *args) {
529  struct file *fd = 0x0;
530  getfd(td, &fd, args->s);
531 
532  td->td_retval[0] = lwip_setsockopt(fd->socket, args->level, args->name, args->val, args->valsize);
533  kprintf("SSO: %i:%i:%i", args->s, fd->socket, td->td_retval[0]);
534  td->td_retval[0] = 0;
535 
536  return (0);
537 }
538 
539 int sys_sendto(struct thread *td, struct sys_sendto_args *args) {
540  struct file *fd = 0x0;
541  getfd(td, &fd, args->s);
542 
543  lwip_sendto(fd->socket, args->buf, args->len, args->flags, args->to, args->tolen);
544  td->td_retval[0] = 0x0;
545 
546  return (0);
547 }
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:528
spinlock.h
sys_sem_set_invalid
void sys_sem_set_invalid(struct sys_sem **s)
Definition: sys_arch.c:139
sys_mbox_free
void sys_mbox_free(struct sys_mbox **mb)
Definition: sys_arch.c:193
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:335
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:131
sys_arch_sem_wait
uint32_t sys_arch_sem_wait(struct sys_sem **s, uint32_t timeout)
Definition: sys_arch.c:104
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:412
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:378
sys_mbox_post
void sys_mbox_post(struct sys_mbox **mb, void *msg)
Definition: sys_arch.c:214
sys_sendto_args
Definition: sysproto_posix.h:698
fdestroy
int fdestroy(struct thread *td, struct file *fp, int fd)
This destroys a thread local file descriptor.
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:148
sys_sem::signaled
uint32_t signaled
Definition: sem.h:37
sched.h
falloc
int falloc(struct thread *, struct file **, int *)
Definition: descrip.c:97
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:152
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:411
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:496
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:88
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:539
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:213
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:366
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:143
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:476
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:286
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:374
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:156
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:414
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:482
sys_socket
int sys_socket(struct thread *td, struct sys_socket_args *args)
Definition: sys_arch.c:500
sys_mbox_new
err_t sys_mbox_new(struct sys_mbox **mb, int size)
Definition: sys_arch.c:160
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:250
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