Subversion Repositories shark

Rev

Rev 80 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
 
1063 tullio 2
/*
3
 * This program is free software; you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License as published by
5
 * the Free Software Foundation; either version 2 of the License, or
6
 * (at your option) any later version.
7
 *
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 * GNU General Public License for more details.
12
 *
13
 * You should have received a copy of the GNU General Public License
14
 * along with this program; if not, write to the Free Software
15
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
 *
17
 */
18
 
2 pj 19
#ifndef __GLUE_H
20
#define __GLUE_H
21
 
22
#include <fs/glue.h>
23
 
24
#include <fs/const.h>
25
#include <fs/util.h>
26
#include <fs/assert.h>
27
#include <fs/maccess.h>
28
#include <fs/irq.h>
29
 
30
#include <kernel/model.h>
31
#include <kernel/func.h>
32
#include <kernel/assert.h>
33
#include <kernel/int_sem.h>
34
 
35
/*
36
 * mutex
37
 */
38
 
39
#include <kernel/int_sem.h>
80 pj 40
#include "ll/sys/cdefs.h"
2 pj 41
 
80 pj 42
__BEGIN_DECLS
43
 
2 pj 44
/*+ a semaphore object +*/
45
typedef internal_sem_t __b_mutex_t;
46
 
47
/*
48
  The following macros can be used to synchronize events; all
49
  require a pointer to a semaphore object and return nothing;
50
  a semaphore can have "val" resource free.
51
 */
52
 
53
/*+ Initialize a semaphore (to integer val) +*/
54
#define __b_mutex_init(ptr)     internal_sem_init((ptr),1)
55
 
56
/*+ Wait for a semaphore +*/
57
#define __b_mutex_lock(ptr)     (internal_sem_wait(ptr))
58
 
59
/*+ Try to wait for a semaphore (return 0 on success) +*/
60
#define __b_mutex_trylock(ptr)  (internal_sem_wait(ptr))
61
 
62
/*+ Signal a semaphore +*/
63
#define __b_mutex_unlock(ptr)   (internal_sem_post(ptr))
64
 
65
#if 0
66
 
67
/*+ a mutex object +*/
68
typedef mutex_t  __b_mutex_t;
69
 
70
/*
71
  The following macros require a pointer to a mutex object and
72
  return nothing.
73
*/
74
 
75
extern void *bmutexattr;
76
 
77
/* Initialize a mutex object */
78
#define __b_mutex_init(ptr)    assertk(mutex_init(ptr,bmutexattr)==0)
79
 
80
/*+ Lock a mutex object +*/
81
#define __b_mutex_lock(ptr)    assertk(mutex_lock((ptr))==0)
82
 
83
/*+ Try to lock a mutex (return 0 on success locking) +*/
84
#define __b_mutex_trylock(ptr) mutex_trylock((ptr))
85
 
86
/*+ Unlock a mutex +*/
87
#define __b_mutex_unlock(ptr)  assertk(mutex_unlock(ptr)==0)
88
 
89
#endif
90
 
91
/*
92
 * fast mutex
93
 */
94
 
95
typedef SYS_FLAGS  __b_fastmutex_t;
96
 
97
/*+ Mutex initialization +*/
98
#define __b_fastmutex_init(ptr) 
99
 
100
/*+ Lock a mutex object +*/
101
#define __b_fastmutex_lock(ptr)    *(ptr)=kern_fsave()
102
 
103
/*+ Unlock a mutex +*/
104
#define __b_fastmutex_unlock(ptr)  kern_frestore(*(ptr))
105
 
106
/*
107
 *semaphores
108
 */
109
 
110
/*+ a semaphore object +*/
111
typedef internal_sem_t __b_sem_t;
112
 
113
/*
114
  The following macros can be used to synchronize events; all
115
  require a pointer to a semaphore object and return nothing;
116
  a semaphore can have "val" resource free.
117
 */
118
 
119
/*+ Initialize a semaphore (to integer val) +*/
120
#define __b_sem_init(ptr,val) internal_sem_init((ptr),(val))
121
 
122
/*+ Wait for a semaphore +*/
123
#define __b_sem_wait(ptr)     internal_sem_wait(ptr)
124
 
125
/*+ Try to wait for a semaphore (return 0 on success) +*/
126
#define __b_sem_trywait(ptr)  internal_sem_trywait(ptr)
127
 
128
/*+ Signal a semaphore +*/
129
#define __b_sem_signal(ptr)   internal_sem_post(ptr)
130
 
131
/*
132
 *
133
 */
134
 
135
#define panic(x) sys_panic(x)
136
 
137
/* timer functions */
138
 
139
#include <ll/time.h>
140
 
141
/* all in usec */
142
 
143
#define __gettimer() sys_gettime(NULL)
144
 
145
/* I need an active delay! */
146
#define __delayk(delta) {       \
147
  TIME t=__gettimer()+delta;    \
148
  while (__gettimer()<t);       \
149
}
150
 
80 pj 151
__END_DECLS
2 pj 152
#endif