Subversion Repositories Kolibri OS

Rev

Rev 813 | Go to most recent revision | Details | Compare with Previous | 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
60
 
808 serge 61
62
 
63
64
 
65
66
 
67
//void *DestroyObject(void *obj);
68
69
 
70
71
 
817 serge 72
{
808 serge 73
  u32_t retval;
817 serge 74
808 serge 75
 
76
    "call *__imp__GetPgAddr \n\t"
77
    :"=eax" (retval)
78
    :"a" (mem)
79
	);
80
  return retval;
81
}
82
83
 
817 serge 84
{
85
  size = (size+4095) & ~4095;
86
	asm volatile (
87
    "call *__imp__CommitPages"
88
    :
89
    :"a" (page), "b"(mem),"c"(size>>12)
90
    :"edx"
91
	);
92
93
 
94
 
95
static inline void UnmapPages(void *mem, size_t size)
96
{
97
  size = (size+4095) & ~4095;
98
	asm volatile (
99
    "call *__imp__UnmapPages"
100
    :
101
    :"a" (mem), "c"(size>>12)
102
    :"eax","ecx", "edx"
103
	);
104
}
105
///////////////////////////////////////////////////////////////////////////////
808 serge 106
107
 
108
109
 
110
u16 STDCALL PciRead16(u32 bus, u32 devfn, u32 reg)__asm__("PciRead16");
111
u32 STDCALL PciRead32(u32 bus, u32 devfn, u32 reg)__asm__("PciRead32");
112
113
 
114
u32 STDCALL PciWrite16(u32 bus, u32 devfn, u32 reg,u16 val)__asm__("PciWrite16");
115
u32 STDCALL PciWrite32(u32 bus, u32 devfn, u32 reg,u32 val)__asm__("PciWrite32");
116
117
 
118
119
 
120
#define PciApi          __PciApi
121
//#define RegService      __RegService
122
#define CreateObject    __CreateObject
123
#define DestroyObject   __DestroyObject
124
125
 
126
127
 
128
void *calloc( size_t num, size_t size );
129
void *realloc(void*, size_t);
130
void free(void*);
131
132
 
133
#define kfree   free
134
135
 
136
137
 
138
void * memcpy(void * _dest, const void *_src, size_t _n);
139
char * strcpy(char *to, const char *from);
140
char * strcat(char *s, const char *append);
141
int strcmp(const char *s1, const char *s2);
142
size_t strlen(const char *str);
143
char * strdup(const char *_s);
144
char * strchr(const char *s, int c);
145
146
 
147
148
 
149
int printf(const char* format, ...);
150
int dbg_open(char *path);
151
int dbgprintf(const char* format, ...);
152
153
 
154
155
 
156
 
157
158
 
159
abs (int i)
160
{
161
  return i < 0 ? -i : i;
162
};
163
164
 
165
__clear (void * dst, unsigned len)
166
{ u32 tmp;
167
  asm __volatile__
168
  (
169
    "xorl %%eax, %%eax \n\t"
170
    "cld \n\t"
171
    "rep stosb \n"
172
    :"=c"(tmp),"=D"(tmp)
173
    :"c"(len),"D"(dst)
174
    :"memory","eax","cc"
175
  );
176
};
177
178
 
179
 
180
{
181
  u32 tmp;
182
	asm volatile (
183
		"pushf\n\t"
184
		"popl %0\n\t"
185
		"cli\n"
186
    : "=r" (tmp)
187
	);
188
  return tmp;
189
}
190
191
 
192
{
193
	asm volatile (
194
		"pushl %0\n\t"
195
		"popf\n"
196
		: : "r" (ipl)
197
	);
198
}
199
200
 
201
202
 
203
int _stdcall srv_2d(ioctl_t *io);
204