Subversion Repositories shark

Rev

Rev 3 | Go to most recent revision | Details | Compare with Previous | 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
 */
80 pj 57
#include "ll/sys/cdefs.h"
2 pj 58
 
80 pj 59
__BEGIN_DECLS
60
 
2 pj 61
extern int verifyuserread(const void * addr, unsigned long size);
62
extern int verifyuserwrite(const void * addr, unsigned long size);
63
extern int verifyuserreadnolen(const void *addr);
64
 
65
#ifdef DUMMY_MACCESS
66
 
67
#define __verify_write(x,y) (-1)
68
#define __verify_read(x,y) (-1)
69
#define __verify_read_nolen(x) (1)
70
 
71
#else
72
 
73
#define __verify_write(x,y) verifyuserwrite(x,y)
74
#define __verify_read(x,y) verifyuserread(x,y)
75
#define __verify_read_nolen(x) verifyuserreadnolen(x)
76
 
77
#endif
78
 
79
/*
80
 *
81
 * copy data to/from user space
82
 *
83
 */
84
 
85
#ifdef DUMMY_MACCESS
86
 
87
extern __inline__ void memcpytouser(void *to, void *from, int size)
88
{ memcpy(to,from,size); }
89
extern __inline__ void memcpyfromuser(void *to, void *from, int size)
90
{ memcpy(to,from,size); }
91
 
92
#define declare_buffer(type,name,maxlen) type *name
93
#define init_buffer(name) name=NULL
94
#define __copy_from_user(to,from,size) ((to)=(from))
95
#define __copy_to_user(to,from,size) memcpy(to,from,size)
96
 
97
#else
98
 
99
extern void memcpytouser(void *to, void *from, int size);
100
extern void memcpyfromuser(void *to, void *from, int size);
101
 
102
#define declare_buffer(type,name,maxlen) type name[maxlen]
103
#define init_buffer(name) 
104
#define __copy_from_user(to,from,size) memcpyfromuser(to,from,size)
105
#define __copy_to_user(to,from,size) memcpytouser(to,from,size)
106
 
107
#endif    
108
 
109
/*
110
 *
111
 * physical resource allocator
112
 *
113
 */
114
 
115
extern int requestiospace(void *startaddr, int size);
116
extern int releaseiospace(void *startaddr, int size);
117
 
118
#ifdef DUMMY_MACCESS
119
 
120
#define __request_io_space(x,y) (-1)
121
#define __release_io_space(x,y) 
122
 
123
#else
124
 
125
#define __request_io_space(x,y) requestiospace(x,y)
126
#define __release_io_space(x,y) releaseiospace(x,y)
127
 
128
#endif
80 pj 129
__END_DECLS
2 pj 130
#endif