Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
 
2
#ifndef __GLUE_H
3
#define __GLUE_H
4
 
5
#include <fs/glue.h>
6
 
7
#include <fs/const.h>
8
#include <fs/util.h>
9
#include <fs/assert.h>
10
#include <fs/maccess.h>
11
#include <fs/irq.h>
12
 
13
#include <kernel/model.h>
14
#include <kernel/func.h>
15
#include <kernel/assert.h>
16
#include <kernel/int_sem.h>
17
 
18
/*
19
 * mutex
20
 */
21
 
22
#include <kernel/int_sem.h>
23
 
24
/*+ a semaphore object +*/
25
typedef internal_sem_t __b_mutex_t;
26
 
27
/*
28
  The following macros can be used to synchronize events; all
29
  require a pointer to a semaphore object and return nothing;
30
  a semaphore can have "val" resource free.
31
 */
32
 
33
/*+ Initialize a semaphore (to integer val) +*/
34
#define __b_mutex_init(ptr)     internal_sem_init((ptr),1)
35
 
36
/*+ Wait for a semaphore +*/
37
#define __b_mutex_lock(ptr)     (internal_sem_wait(ptr))
38
 
39
/*+ Try to wait for a semaphore (return 0 on success) +*/
40
#define __b_mutex_trylock(ptr)  (internal_sem_wait(ptr))
41
 
42
/*+ Signal a semaphore +*/
43
#define __b_mutex_unlock(ptr)   (internal_sem_post(ptr))
44
 
45
#if 0
46
 
47
/*+ a mutex object +*/
48
typedef mutex_t  __b_mutex_t;
49
 
50
/*
51
  The following macros require a pointer to a mutex object and
52
  return nothing.
53
*/
54
 
55
extern void *bmutexattr;
56
 
57
/* Initialize a mutex object */
58
#define __b_mutex_init(ptr)    assertk(mutex_init(ptr,bmutexattr)==0)
59
 
60
/*+ Lock a mutex object +*/
61
#define __b_mutex_lock(ptr)    assertk(mutex_lock((ptr))==0)
62
 
63
/*+ Try to lock a mutex (return 0 on success locking) +*/
64
#define __b_mutex_trylock(ptr) mutex_trylock((ptr))
65
 
66
/*+ Unlock a mutex +*/
67
#define __b_mutex_unlock(ptr)  assertk(mutex_unlock(ptr)==0)
68
 
69
#endif
70
 
71
/*
72
 * fast mutex
73
 */
74
 
75
typedef SYS_FLAGS  __b_fastmutex_t;
76
 
77
/*+ Mutex initialization +*/
78
#define __b_fastmutex_init(ptr) 
79
 
80
/*+ Lock a mutex object +*/
81
#define __b_fastmutex_lock(ptr)    *(ptr)=kern_fsave()
82
 
83
/*+ Unlock a mutex +*/
84
#define __b_fastmutex_unlock(ptr)  kern_frestore(*(ptr))
85
 
86
/*
87
 *semaphores
88
 */
89
 
90
/*+ a semaphore object +*/
91
typedef internal_sem_t __b_sem_t;
92
 
93
/*
94
  The following macros can be used to synchronize events; all
95
  require a pointer to a semaphore object and return nothing;
96
  a semaphore can have "val" resource free.
97
 */
98
 
99
/*+ Initialize a semaphore (to integer val) +*/
100
#define __b_sem_init(ptr,val) internal_sem_init((ptr),(val))
101
 
102
/*+ Wait for a semaphore +*/
103
#define __b_sem_wait(ptr)     internal_sem_wait(ptr)
104
 
105
/*+ Try to wait for a semaphore (return 0 on success) +*/
106
#define __b_sem_trywait(ptr)  internal_sem_trywait(ptr)
107
 
108
/*+ Signal a semaphore +*/
109
#define __b_sem_signal(ptr)   internal_sem_post(ptr)
110
 
111
/*
112
 *
113
 */
114
 
115
#define panic(x) sys_panic(x)
116
 
117
/* timer functions */
118
 
119
#include <ll/time.h>
120
 
121
/* all in usec */
122
 
123
#define __gettimer() sys_gettime(NULL)
124
 
125
/* I need an active delay! */
126
#define __delayk(delta) {       \
127
  TIME t=__gettimer()+delta;    \
128
  while (__gettimer()<t);       \
129
}
130
 
131
#endif
132