Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
808 serge 1
 
2
3
 
4
5
 
6
7
 
8
#define TRUE    1
9
10
 
11
12
 
13
14
 
15
typedef unsigned short u16;
16
typedef unsigned int   u32;
17
18
 
813 serge 19
typedef unsigned short u16_t;
20
typedef unsigned int   u32_t;
21
22
 
808 serge 23
typedef unsigned int size_t;
24
25
 
26
27
 
817 serge 28
 
808 serge 29
{
30
  unsigned      handle;
31
  unsigned      io_code;
32
  void          *input;
33
  int           inp_size;
34
  void          *output;
35
  int           out_size;
36
}ioctl_t;
37
38
 
39
40
 
817 serge 41
#define ERR_PARAM   -1
42
808 serge 43
 
817 serge 44
 
45
46
 
808 serge 47
48
 
49
#define IMPORT __attribute__ ((dllimport))
50
51
 
52
53
 
54
#define PG_NOCACHE  0x018
55
56
 
817 serge 57
void*  STDCALL KernelAlloc(size_t size)__asm__("KernelAlloc");
58
void*  STDCALL UserAlloc(size_t size)__asm__("UserAlloc");
59
int    STDCALL UserFree(void *mem)__asm__("UserFree");
818 serge 60
817 serge 61
 
818 serge 62
 
808 serge 63
64
 
65
66
 
67
68
 
69
//void *DestroyObject(void *obj);
70
71
 
72
73
 
817 serge 74
{
808 serge 75
  u32_t retval;
817 serge 76
808 serge 77
 
78
    "call *__imp__GetPgAddr \n\t"
79
    :"=eax" (retval)
80
    :"a" (mem)
81
	);
82
  return retval;
83
}
84
85
 
817 serge 86
{
87
  size = (size+4095) & ~4095;
88
	asm volatile (
89
    "call *__imp__CommitPages"
90
    :
91
    :"a" (page), "b"(mem),"c"(size>>12)
92
    :"edx"
93
  );
818 serge 94
  asm volatile (
95
    ""
96
    :
97
    :
98
    :"eax","ebx","ecx"
99
	);
817 serge 100
101
 
102
 
103
static inline void UnmapPages(void *mem, size_t size)
104
{
105
  size = (size+4095) & ~4095;
106
	asm volatile (
107
    "call *__imp__UnmapPages"
108
    :
109
    :"a" (mem), "c"(size>>12)
110
    :"edx"
818 serge 111
	);
817 serge 112
  asm volatile ("":::"eax","ecx");
829 serge 113
818 serge 114
 
817 serge 115
///////////////////////////////////////////////////////////////////////////////
808 serge 116
117
 
118
119
 
120
u16 STDCALL PciRead16(u32 bus, u32 devfn, u32 reg)__asm__("PciRead16");
121
u32 STDCALL PciRead32(u32 bus, u32 devfn, u32 reg)__asm__("PciRead32");
122
123
 
124
u32 STDCALL PciWrite16(u32 bus, u32 devfn, u32 reg,u16 val)__asm__("PciWrite16");
125
u32 STDCALL PciWrite32(u32 bus, u32 devfn, u32 reg,u32 val)__asm__("PciWrite32");
126
127
 
128
129
 
130
#define PciApi          __PciApi
131
//#define RegService      __RegService
132
#define CreateObject    __CreateObject
133
#define DestroyObject   __DestroyObject
134
135
 
136
137
 
138
void *calloc( size_t num, size_t size );
139
void *realloc(void*, size_t);
140
void free(void*);
141
142
 
143
#define kfree   free
144
145
 
868 serge 146
147
 
808 serge 148
149
 
150
void * memcpy(void * _dest, const void *_src, size_t _n);
151
char * strcpy(char *to, const char *from);
152
char * strcat(char *s, const char *append);
153
int strcmp(const char *s1, const char *s2);
154
size_t strlen(const char *str);
155
char * strdup(const char *_s);
156
char * strchr(const char *s, int c);
157
158
 
159
160
 
161
int printf(const char* format, ...);
162
int dbg_open(char *path);
163
int dbgprintf(const char* format, ...);
164
165
 
166
167
 
168
 
169
170
 
171
abs (int i)
172
{
173
  return i < 0 ? -i : i;
174
};
175
176
 
177
__clear (void * dst, unsigned len)
178
{ u32 tmp;
179
  asm __volatile__
180
  (
181
    "xorl %%eax, %%eax \n\t"
182
    "cld \n\t"
183
    "rep stosb \n"
184
    :"=c"(tmp),"=D"(tmp)
185
    :"c"(len),"D"(dst)
186
    :"eax"
829 serge 187
  );
808 serge 188
  asm volatile ("":::"ecx","edi");
829 serge 189
190
 
808 serge 191
192
 
193
 
194
{
195
  u32 tmp;
196
	asm volatile (
197
		"pushf\n\t"
198
		"popl %0\n\t"
199
		"cli\n"
200
    : "=r" (tmp)
201
	);
202
  return tmp;
203
}
204
205
 
206
{
207
	asm volatile (
208
		"pushl %0\n\t"
209
		"popf\n"
210
		: : "r" (ipl)
211
	);
212
}
213
214
 
215
216
 
217
int _stdcall srv_2d(ioctl_t *io);
218