/contrib/sdk/sources/newlib/sys/create.c |
---|
0,0 → 1,25 |
#include <sys/types.h> |
#include <sys/kos_io.h> |
int create_file(const char *path) |
{ |
int retval; |
__asm__ __volatile__ ( |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"movl %0, 1(%%esp) \n\t" |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"pushl $2 \n\t" |
"movl %%esp, %%ebx \n\t" |
"movl $70, %%eax \n\t" |
"int $0x40 \n\t" |
"addl $28, %%esp \n\t" |
:"=a" (retval) |
:"r" (path) |
:"ebx"); |
return retval; |
}; |
/contrib/sdk/sources/newlib/sys/delete.c |
---|
0,0 → 1,26 |
#include <sys/types.h> |
#include <sys/kos_io.h> |
int delete_file(const char *path) |
{ |
int retval; |
__asm__ __volatile__ ( |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"movl %0, 1(%%esp) \n\t" |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"pushl $8 \n\t" |
"movl %%esp, %%ebx \n\t" |
"movl $70, %%eax \n\t" |
"int $0x40 \n\t" |
"addl $28, %%esp \n\t" |
:"=a" (retval) |
:"r" (path) |
:"ebx"); |
return retval; |
}; |
/contrib/sdk/sources/newlib/sys/finfo.c |
---|
0,0 → 1,26 |
#include <sys/types.h> |
#include <sys/kos_io.h> |
int get_fileinfo(const char *path, fileinfo_t *info) |
{ |
int retval; |
__asm__ __volatile__ ( |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"movl %1, 1(%%esp) \n\t" |
"pushl %%ebx \n\t" |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"pushl $5 \n\t" |
"movl %%esp, %%ebx \n\t" |
"movl $70, %%eax \n\t" |
"int $0x40 \n\t" |
"addl $28, %%esp \n\t" |
:"=a" (retval) |
:"r" (path), "b" (info)); |
return retval; |
}; |
/contrib/sdk/sources/newlib/sys/fload.c |
---|
0,0 → 1,37 |
#include <sys/types.h> |
#include <stdint.h> |
#include <sys/kos_io.h> |
void *load_file(const char *path, size_t *len) |
{ |
fileinfo_t info; |
size_t bytes; |
void *file = NULL; |
if( len) *len = 0; |
if( !get_fileinfo(path, &info) ) |
{ |
file = (void*)user_alloc( info.size ); |
read_file(path, file, 0, info.size, &bytes ); |
if( bytes == info.size ) |
{ |
if ( *(uint32_t*)file == 0x4B43504B ) |
{ |
void *tmp = NULL; |
info.size = ((size_t*)file)[1]; |
tmp = (void*)user_alloc(info.size); |
unpack(file, tmp); |
user_free(file); |
file = tmp; |
} |
if(len) *len = info.size; |
}; |
}; |
return file; |
}; |
/contrib/sdk/sources/newlib/sys/fsize.c |
---|
0,0 → 1,26 |
#include <sys/types.h> |
#include <sys/kos_io.h> |
int set_file_size(const char *path, unsigned size) |
{ |
int retval; |
__asm__ __volatile__( |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"movl %%eax, 1(%%esp) \n\t" |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"pushl %%ebx \n\t" |
"push $4 \n\t" |
"movl %%esp, %%ebx \n\t" |
"movl $70, %%eax \n\t" |
"int $0x40 \n\t" |
"addl $28, %%esp \n\t" |
:"=a" (retval) |
:"a" (path), "b" (size)); |
return retval; |
}; |
/contrib/sdk/sources/newlib/sys/read.c |
---|
0,0 → 1,31 |
#include <sys/types.h> |
#include <sys/kos_io.h> |
int read_file(const char *path, void *buff, |
size_t offset, size_t count, size_t *reads) |
{ |
int retval; |
int d0; |
__asm__ __volatile__( |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"movl %%eax, 1(%%esp) \n\t" |
"pushl %%ebx \n\t" |
"pushl %%edx \n\t" |
"pushl $0 \n\t" |
"pushl %%ecx \n\t" |
"pushl $0 \n\t" |
"movl %%esp, %%ebx \n\t" |
"mov $70, %%eax \n\t" |
"int $0x40 \n\t" |
"testl %%esi, %%esi \n\t" |
"jz 1f \n\t" |
"movl %%ebx, (%%esi) \n\t" |
"1:" |
"addl $28, %%esp \n\t" |
:"=a" (retval) |
:"a"(path),"b"(buff),"c"(offset),"d"(count),"S"(reads)); |
return retval; |
}; |
/contrib/sdk/sources/newlib/sys/write.c |
---|
0,0 → 1,29 |
#include <sys/types.h> |
#include <sys/kos_io.h> |
int write_file(const char *path,const void *buff, |
size_t offset, size_t count, size_t *writes) |
{ |
int retval; |
__asm__ __volatile__( |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"movl %%eax, 1(%%esp) \n\t" |
"pushl %%ebx \n\t" |
"pushl %%edx \n\t" |
"pushl $0 \n\t" |
"pushl %%ecx \n\t" |
"pushl $3 \n\t" |
"movl %%esp, %%ebx \n\t" |
"mov $70, %%eax \n\t" |
"int $0x40 \n\t" |
"testl %%esi, %%esi \n\t" |
"jz 1f \n\t" |
"movl %%ebx, (%%esi) \n\t" |
"1:" |
"addl $28, %%esp \n\t" |
:"=a" (retval) |
:"a"(path),"b"(buff),"c"(offset),"d"(count),"S"(writes)); |
return retval; |
}; |