Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *   Paolo Gai           <pj@gandalf.sssup.it>
10
 *   Massimiliano Giorgi <massy@gandalf.sssup.it>
11
 *   Luca Abeni          <luca@gandalf.sssup.it>
12
 *   (see the web pages for full authors list)
13
 *
14
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
15
 *
16
 * http://www.sssup.it
17
 * http://retis.sssup.it
18
 * http://shark.sssup.it
19
 */
20
 
21
 
22
#ifndef __FS_MACCESS_H
23
#define __FS_MACCESS_H
24
 
25
/*+ if defined: the following functions are 'dummy' function +*/
26
#define DUMMY_MACCESS
27
//#undef  DUMMY_MACCESS
28
 
29
#ifdef DUMMY_MACCESS
30
#include <fs/util.h>
31
#endif
32
 
33
/*
34
 * port in/out
35
 */
36
 
37
#include <ll/i386/hw-instr.h>
38
 
39
/*
40
 *
41
 * address translation
42
 *
43
 */
44
 
45
//#include <x86/xsys.h>
46
//#define __lin_to_phy(ptr) appl2linear(ptr)
47
//#define __phy_to_lin(addr) linear2appl(addr)
48
 
49
#define __lin_to_phy(ptr)  ((int)ptr)
50
#define __phy_to_lin(addr) ((void*)addr)
51
 
52
/*
53
 *
54
 * verify read/write access to user space
55
 *
56
 */
57
 
58
extern int verifyuserread(const void * addr, unsigned long size);
59
extern int verifyuserwrite(const void * addr, unsigned long size);
60
extern int verifyuserreadnolen(const void *addr);
61
 
62
#ifdef DUMMY_MACCESS
63
 
64
#define __verify_write(x,y) (-1)
65
#define __verify_read(x,y) (-1)
66
#define __verify_read_nolen(x) (1)
67
 
68
#else
69
 
70
#define __verify_write(x,y) verifyuserwrite(x,y)
71
#define __verify_read(x,y) verifyuserread(x,y)
72
#define __verify_read_nolen(x) verifyuserreadnolen(x)
73
 
74
#endif
75
 
76
/*
77
 *
78
 * copy data to/from user space
79
 *
80
 */
81
 
82
#ifdef DUMMY_MACCESS
83
 
84
extern __inline__ void memcpytouser(void *to, void *from, int size)
85
{ memcpy(to,from,size); }
86
extern __inline__ void memcpyfromuser(void *to, void *from, int size)
87
{ memcpy(to,from,size); }
88
 
89
#define declare_buffer(type,name,maxlen) type *name
90
#define init_buffer(name) name=NULL
91
#define __copy_from_user(to,from,size) ((to)=(from))
92
#define __copy_to_user(to,from,size) memcpy(to,from,size)
93
 
94
#else
95
 
96
extern void memcpytouser(void *to, void *from, int size);
97
extern void memcpyfromuser(void *to, void *from, int size);
98
 
99
#define declare_buffer(type,name,maxlen) type name[maxlen]
100
#define init_buffer(name) 
101
#define __copy_from_user(to,from,size) memcpyfromuser(to,from,size)
102
#define __copy_to_user(to,from,size) memcpytouser(to,from,size)
103
 
104
#endif    
105
 
106
/*
107
 *
108
 * physical resource allocator
109
 *
110
 */
111
 
112
extern int requestiospace(void *startaddr, int size);
113
extern int releaseiospace(void *startaddr, int size);
114
 
115
#ifdef DUMMY_MACCESS
116
 
117
#define __request_io_space(x,y) (-1)
118
#define __release_io_space(x,y) 
119
 
120
#else
121
 
122
#define __request_io_space(x,y) requestiospace(x,y)
123
#define __release_io_space(x,y) releaseiospace(x,y)
124
 
125
#endif
126
 
127
#endif