sys_arch.c File Reference

#include <ubixos/types.h>
#include <ubixos/sched.h>
#include <ubixos/ubthread.h>
#include <ubixos/kpanic.h>
#include <lib/kprintf.h>
#include <lib/kmalloc.h>
#include "net/debug.h"
#include "net/sys.h"
#include "net/opt.h"
#include "net/stats.h"
#include <ubixos/spinlock.h>

Go to the source code of this file.

Data Structures

struct  sys_mbox
struct  sys_mbox_msg
struct  sys_sem
struct  sys_thread
struct  thread_start_param

Defines

#define SYS_MBOX_SIZE   100
#define UMAX(a, b)   ((a) > (b) ? (a) : (b))

Functions

static uInt16 cond_wait (ubthread_cond_t *cond, ubthread_mutex_t *mutex, uInt16 timeout)
static struct sys_threadcurrent_thread (void)
uInt16 sys_arch_mbox_fetch (struct sys_mbox *mbox, void **msg, uInt16 timeout)
uInt16 sys_arch_sem_wait (struct sys_sem *sem, uInt16 timeout)
sys_timeoutssys_arch_timeouts (void)
void sys_init ()
void sys_mbox_free (struct sys_mbox *mbox)
sys_mboxsys_mbox_new ()
void sys_mbox_post (struct sys_mbox *mbox, void *msg)
void sys_sem_free (struct sys_sem *sem)
static void sys_sem_free_ (struct sys_sem *sem)
sys_semsys_sem_new (uInt8 count)
static struct sys_semsys_sem_new_ (uInt8 count)
void sys_sem_signal (struct sys_sem *sem)
void sys_thread_new (void(*function)(void), void *arg)
unsigned long sys_unix_now ()

Variables

static spinLock_t netThreadSpinlock = SPIN_LOCK_INITIALIZER
static struct timeval starttime
static struct sys_threadthreads = 0x0


Define Documentation

#define SYS_MBOX_SIZE   100

Definition at line 106 of file sys_arch.c.

Referenced by sys_arch_mbox_fetch(), and sys_mbox_post().

#define UMAX ( a,
 )     ((a) > (b) ? (a) : (b))

Definition at line 96 of file sys_arch.c.


Function Documentation

static uInt16 cond_wait ( ubthread_cond_t cond,
ubthread_mutex_t mutex,
uInt16  timeout 
) [static]

Definition at line 311 of file sys_arch.c.

References ETIMEDOUT, gettimeofday(), mutex, timespec::tv_nsec, timespec::tv_sec, timeval::tv_sec, timeval::tv_usec, ubthread_cond_timedwait(), and ubthread_cond_wait().

Referenced by sys_arch_sem_wait().

static struct sys_thread* current_thread ( void   )  [static]

Definition at line 135 of file sys_arch.c.

References netThreadSpinlock, sys_thread::next, NULL, spinLock(), spinUnlock(), threads, sys_thread::ubthread, and ubthread_self().

Referenced by sys_arch_timeouts().

uInt16 sys_arch_mbox_fetch ( struct sys_mbox mbox,
void **  msg,
uInt16  timeout 
)

Definition at line 254 of file sys_arch.c.

References sys_mbox::first, sys_mbox::last, sys_mbox::mail, mbox, sys_mbox::msgs, sys_mbox::mutex, NULL, sys_arch_sem_wait(), SYS_MBOX_SIZE, and sys_sem_signal().

uInt16 sys_arch_sem_wait ( struct sys_sem sem,
uInt16  timeout 
)

Definition at line 351 of file sys_arch.c.

References sys_sem::c, sys_sem::cond, cond_wait(), sys_sem::mutex, ubthread_mutex_lock(), and ubthread_mutex_unlock().

struct sys_timeouts* sys_arch_timeouts ( void   ) 

Definition at line 409 of file sys_arch.c.

References current_thread(), and sys_thread::timeouts.

void sys_init ( void   ) 

Definition at line 404 of file sys_arch.c.

References gettimeofday(), and starttime.

Referenced by net_init().

void sys_mbox_free ( struct sys_mbox mbox  ) 

Definition at line 215 of file sys_arch.c.

References kfree(), sys_mbox::mail, mbox, sys_mbox::mutex, NULL, SYS_MBOX_NULL, sys_sem_free_(), and sys_sem_wait().

struct sys_mbox* sys_mbox_new ( void   ) 

Definition at line 204 of file sys_arch.c.

References sys_mbox::first, kmalloc(), sys_mbox::last, sys_mbox::mail, mbox, sys_mbox::mutex, and sys_sem_new_().

Referenced by accept_function(), do_listen(), netconn_bind(), netconn_connect(), netconn_listen(), netconn_new(), and tcpip_init().

void sys_mbox_post ( struct sys_mbox mbox,
void *  msg 
)

Definition at line 227 of file sys_arch.c.

References sys_mbox::first, sys_mbox::last, sys_mbox::mail, mbox, sys_mbox::msgs, sys_mbox::mutex, SYS_MBOX_SIZE, sys_sem_signal(), and sys_sem_wait().

void sys_sem_free ( struct sys_sem sem  ) 

Definition at line 379 of file sys_arch.c.

References sys_sem_free_(), and SYS_SEM_NULL.

static void sys_sem_free_ ( struct sys_sem sem  )  [static]

Definition at line 385 of file sys_arch.c.

References sys_sem::cond, kfree(), sys_sem::mutex, ubthread_cond_destroy(), and ubthread_mutex_destroy().

Referenced by sys_mbox_free(), and sys_sem_free().

struct sys_sem* sys_sem_new ( uInt8  count  ) 

Definition at line 295 of file sys_arch.c.

References sys_sem_new_().

Referenced by accept_function(), netconn_write(), and netMainThread().

static struct sys_sem * sys_sem_new_ ( uInt8  count  )  [static]

Definition at line 299 of file sys_arch.c.

References sys_sem::c, sys_sem::cond, kmalloc(), sys_sem::mutex, NULL, ubthread_cond_init(), and ubthread_mutex_init().

Referenced by sys_mbox_new(), and sys_sem_new().

void sys_sem_signal ( struct sys_sem sem  ) 

Definition at line 370 of file sys_arch.c.

References sys_sem::c, sys_sem::cond, sys_sem::mutex, ubthread_cond_signal(), ubthread_mutex_lock(), and ubthread_mutex_unlock().

void sys_thread_new ( void(*)(void)  function,
void *  arg 
)

Definition at line 172 of file sys_arch.c.

References kmalloc(), kpanic(), kprintf(), netThreadSpinlock, sys_timeouts::next, sys_thread::next, NULL, spinLock(), spinUnlock(), threads, sys_thread::timeouts, sys_thread::ubthread, and ubthread_create().

Referenced by bot_init(), low_level_init(), net_init(), shell_init(), tcpip_init(), and udpecho_init().

unsigned long sys_unix_now (  ) 

Definition at line 391 of file sys_arch.c.

References gettimeofday(), starttime, timeval::tv_sec, and timeval::tv_usec.


Variable Documentation

spinLock_t netThreadSpinlock = SPIN_LOCK_INITIALIZER [static]

Definition at line 99 of file sys_arch.c.

Referenced by current_thread(), and sys_thread_new().

struct timeval starttime [static]

Definition at line 128 of file sys_arch.c.

Referenced by sys_init(), and sys_unix_now().

struct sys_thread* threads = 0x0 [static]

Definition at line 98 of file sys_arch.c.

Referenced by current_thread(), and sys_thread_new().


Generated on Tue Dec 12 08:52:15 2006 for UbixOS V2 by  doxygen 1.4.7