Subversion Repositories Kolibri OS

Rev

Rev 1693 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1693 Rev 1906
Line 6... Line 6...
6
#include <_syslist.h>
6
#include <_syslist.h>
7
#include 
7
#include 
8
#include 
8
#include 
9
#include 
9
#include 
10
#include 
10
#include 
-
 
11
#include 
Line 11... Line 12...
11
 
12
 
12
/* Some targets provides their own versions of this functions.  Those
13
/* Some targets provides their own versions of this functions.  Those
Line 13... Line 14...
13
   targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS.  */
14
   targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS.  */
Line 47... Line 48...
47
	takes a pointer to the global data block, which holds
48
	takes a pointer to the global data block, which holds
48
	<>.
49
	<>.
49
*/
50
*/
Line 50... Line -...
50
 
-
 
51
 
-
 
52
#pragma pack(push, 1)
-
 
53
typedef struct
-
 
54
{
-
 
55
    char sec;
-
 
56
    char min;
-
 
57
    char hour;
-
 
58
    char rsv;
-
 
59
}detime_t;
-
 
60
 
-
 
61
typedef struct
-
 
62
{
-
 
63
    char  day;
-
 
64
    char  month;
-
 
65
    short year;
-
 
66
}dedate_t;
-
 
67
 
-
 
68
typedef struct
-
 
69
{
-
 
70
    unsigned    attr;
-
 
71
    unsigned    flags;
-
 
72
    union
-
 
73
    {
-
 
74
        detime_t  ctime;
-
 
75
        unsigned  cr_time;
-
 
76
    };
-
 
77
    union
-
 
78
    {
-
 
79
        dedate_t  cdate;
-
 
80
        unsigned  cr_date;
-
 
81
    };
-
 
82
    union
-
 
83
    {
-
 
84
        detime_t  atime;
-
 
85
        unsigned  acc_time;
-
 
86
    };
-
 
87
    union
-
 
88
    {
-
 
89
        dedate_t  adate;
-
 
90
        unsigned  acc_date;
-
 
91
    };
-
 
92
    union
-
 
93
    {
-
 
94
        detime_t  mtime;
-
 
95
        unsigned  mod_time;
-
 
96
    };
-
 
97
    union
-
 
98
    {
-
 
99
        dedate_t  mdate;
-
 
100
        unsigned  mod_date;
-
 
101
    };
-
 
102
    unsigned    size;
-
 
103
    unsigned    size_high;
-
 
104
} fileinfo_t;
-
 
105
 
-
 
Line 106... Line 51...
106
#pragma pack(pop)
51
 
107
 
52
 
Line 108... Line 53...
108
 
53
 
Line 124... Line 69...
124
#define _FILEEXT 0x8000 /* lseek with positive offset has been done */
69
#define _FILEEXT 0x8000 /* lseek with positive offset has been done */
125
#define _COMMIT 0x0001  /* extended flag: commit OS buffers on flush */
70
#define _COMMIT 0x0001  /* extended flag: commit OS buffers on flush */
Line 126... Line 71...
126
 
71
 
Line 127... Line -...
127
extern int       _fmode;
-
 
128
 
-
 
129
int create_file(const char *path)
-
 
130
{
-
 
131
     int retval;
-
 
132
     __asm__ __volatile__ (
-
 
133
     "pushl $0 \n\t"
-
 
134
     "pushl $0 \n\t"
-
 
135
     "movl %0, 1(%%esp) \n\t"
-
 
136
     "pushl $0 \n\t"
-
 
137
     "pushl $0 \n\t"
-
 
138
     "pushl $0 \n\t"
-
 
139
     "pushl $0 \n\t"
-
 
140
     "pushl $2 \n\t"
-
 
141
     "movl %%esp, %%ebx \n\t"
-
 
142
     "movl $70, %%eax \n\t"
-
 
143
     "int $0x40 \n\t"
-
 
144
     "addl $28, %%esp \n\t"
-
 
145
     :"=a" (retval)
-
 
146
     :"r" (path)
-
 
147
     :"ebx");
-
 
148
  return retval;
-
 
149
};
-
 
150
 
-
 
151
int set_file_size(const char *path, unsigned size)
-
 
152
{
-
 
153
     int retval;
-
 
154
     __asm__ __volatile__(
-
 
155
     "pushl $0 \n\t"
-
 
156
     "pushl $0 \n\t"
-
 
157
     "movl %%eax, 1(%%esp) \n\t"
-
 
158
     "pushl $0 \n\t"
-
 
159
     "pushl $0 \n\t"
-
 
160
     "pushl $0 \n\t"
-
 
161
     "pushl %%ebx \n\t"
-
 
162
     "push $4 \n\t"
-
 
163
     "movl %%esp, %%ebx \n\t"
-
 
164
     "movl $70, %%eax \n\t"
-
 
165
     "int $0x40 \n\t"
-
 
166
     "addl $28, %%esp \n\t"
-
 
167
     :"=a" (retval)
-
 
168
     :"a" (path), "b" (size));
-
 
169
     return retval;
-
 
170
};
-
 
171
 
-
 
172
int get_fileinfo(const char *path, fileinfo_t *info)
-
 
173
{
-
 
174
    int retval;
-
 
175
 
-
 
176
    __asm__ __volatile__ (
-
 
177
    "pushl $0 \n\t"
-
 
178
    "pushl $0 \n\t"
-
 
179
    "movl %1, 1(%%esp) \n\t"
-
 
180
    "pushl %%ebx \n\t"
-
 
181
    "pushl $0 \n\t"
-
 
182
    "pushl $0 \n\t"
-
 
183
    "pushl $0 \n\t"
-
 
184
    "pushl $5 \n\t"
-
 
185
    "movl %%esp, %%ebx \n\t"
-
 
186
    "movl $70, %%eax \n\t"
-
 
187
    "int $0x40 \n\t"
-
 
188
    "addl $28, %%esp \n\t"
-
 
189
    :"=a" (retval)
-
 
190
    :"r" (path), "b" (info));
-
 
191
   return retval;
-
 
192
};
-
 
193
 
-
 
194
 
-
 
195
int read_file(const char *path, void *buff,
-
 
196
               size_t offset, size_t count, size_t *reads)
-
 
197
{
-
 
198
    int  retval;
-
 
199
    int  d0;
-
 
200
    __asm__ __volatile__(
-
 
201
    "pushl $0 \n\t"
-
 
202
    "pushl $0 \n\t"
-
 
203
    "movl %%eax, 1(%%esp) \n\t"
-
 
204
    "pushl %%ebx \n\t"
-
 
205
    "pushl %%edx \n\t"
-
 
206
    "pushl $0 \n\t"
-
 
207
    "pushl %%ecx \n\t"
-
 
208
    "pushl $0 \n\t"
-
 
209
    "movl %%esp, %%ebx \n\t"
-
 
210
    "mov $70, %%eax \n\t"
-
 
211
    "int $0x40 \n\t"
-
 
212
    "testl %%esi, %%esi \n\t"
-
 
213
    "jz 1f \n\t"
-
 
214
    "movl %%ebx, (%%esi) \n\t"
-
 
215
"1:"
-
 
216
    "addl $28, %%esp \n\t"
-
 
217
    :"=a" (retval)
-
 
218
    :"a"(path),"b"(buff),"c"(offset),"d"(count),"S"(reads));
-
 
219
    return retval;
-
 
Line 220... Line 72...
220
};
72
extern int       _fmode;
221
 
73
 
222
 
74
 
223
static inline void debug_out(const char val)
75
static inline void debug_out(const char val)
Line 239... Line 91...
239
    };
91
    };
240
    *writes = ret;
92
    *writes = ret;
241
    return ret;
93
    return ret;
242
};
94
};
Line 243... Line -...
243
 
-
 
244
 
-
 
245
int write_file(const char *path,const void *buff,
-
 
246
               size_t offset, size_t count, size_t *writes)
-
 
247
{
-
 
248
     int retval;
-
 
249
     __asm__ __volatile__(
-
 
250
     "pushl $0 \n\t"
-
 
251
     "pushl $0 \n\t"
-
 
252
     "movl %%eax, 1(%%esp) \n\t"
-
 
253
     "pushl %%ebx \n\t"
-
 
254
     "pushl %%edx \n\t"
-
 
255
     "pushl $0 \n\t"
-
 
256
     "pushl %%ecx \n\t"
-
 
257
     "pushl $3 \n\t"
-
 
258
     "movl %%esp, %%ebx \n\t"
-
 
259
     "mov $70, %%eax \n\t"
-
 
260
     "int $0x40 \n\t"
-
 
261
     "testl %%esi, %%esi \n\t"
-
 
262
     "jz 1f \n\t"
-
 
263
     "movl %%ebx, (%%esi) \n\t"
-
 
264
"1:"
-
 
265
     "addl $28, %%esp \n\t"
-
 
266
     :"=a" (retval)
-
 
267
     :"a"(path),"b"(buff),"c"(offset),"d"(count),"S"(writes));
-
 
268
    return retval;
-
 
269
};
-
 
270
 
95
 
271
static int __openFileHandle(const char *path, int mode, int *err)
96
static int __openFileHandle(const char *path, int mode, int *err)
272
{
97
{
273
    fileinfo_t     info;
98
    fileinfo_t     info;