- Fixed Makefile
- Added FS_Service instead of calling system call 70

git-svn-id: svn://kolibrios.org@9057 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
turbocat 2021-07-12 22:49:51 +00:00
parent 36c4b6f145
commit be90c91c89
7 changed files with 93 additions and 90 deletions

View File

@ -1,6 +1,7 @@
CC = gcc CC = kos32-gcc
AS = as AS = kos32-as
LD = kos32-ld
DRV_TOPDIR = $(CURDIR)/.. DRV_TOPDIR = $(CURDIR)/..
DRV_INCLUDES = $(DRV_TOPDIR)/include DRV_INCLUDES = $(DRV_TOPDIR)/include

View File

@ -83,6 +83,8 @@
.global _WaitEvent .global _WaitEvent
.global _WaitEventTimeout .global _WaitEventTimeout
.global _FS_Service
.def _AcpiGetRootPtr; .scl 2; .type 32; .endef .def _AcpiGetRootPtr; .scl 2; .type 32; .endef
.def _AllocKernelSpace; .scl 2; .type 32; .endef .def _AllocKernelSpace; .scl 2; .type 32; .endef
@ -165,6 +167,8 @@
.def _WaitEvent; .scl 2; .type 32; .endef .def _WaitEvent; .scl 2; .type 32; .endef
.def _WaitEventTimeout; .scl 2; .type 32; .endef .def _WaitEventTimeout; .scl 2; .type 32; .endef
.def _FS_Service; .scl 2; .type 32; .endef
_AcpiGetRootPtr: _AcpiGetRootPtr:
_AllocKernelSpace: _AllocKernelSpace:
@ -244,6 +248,8 @@ _UserFree:
_WaitEvent: _WaitEvent:
_WaitEventTimeout: _WaitEventTimeout:
_FS_Service:
ret ret
.section .drectve .section .drectve
@ -326,4 +332,4 @@ _WaitEventTimeout:
.ascii " -export:WaitEvent" # stdcall .ascii " -export:WaitEvent" # stdcall
.ascii " -export:WaitEventTimeout" # stdcall .ascii " -export:WaitEventTimeout" # stdcall
.ascii " -export:FS_Service" # watch system call 70

View File

@ -1,23 +1,12 @@
#include <syscall.h>
int create_file(const char *path) int create_file(const char *path)
{ {
int retval; int err=0;
int count; ksys70_t k;
__asm__ __volatile__ ( k.p00 = 2;
"pushl $0 \n\t" k.p12 = 0;
"pushl $0 \n\t" k.p20 = 0;
"movl %2, 1(%%esp) \n\t" k.p21 = path;
"pushl $0 \n\t" return FS_Service(&k, &err);
"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), "=b"(count)
:"r" (path)
);
return retval;
}; };

View File

@ -1,5 +1,6 @@
#include <syscall.h>
#pragma pack(push, 1) #pragma pack(push,1)
typedef struct typedef struct
{ {
char sec; char sec;
@ -52,31 +53,16 @@ typedef struct
unsigned size; unsigned size;
unsigned size_high; unsigned size_high;
} FILEINFO; } FILEINFO;
#pragma pack(pop) #pragma pack(pop)
int get_fileinfo(const char *path, FILEINFO *info)
int get_fileinfo(const char *path,FILEINFO *info)
{ {
int retval; ksys70_t k;
int tmp; int err;
k.p00 = 5;
k.bdfe = info;
k.p20 = 0;
k.p21 = path;
return FS_Service(&k, err);
}
asm __volatile__
(
"pushl $0 \n\t"
"pushl $0 \n\t"
"movl %2, 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),"=b"(tmp)
:"r" (path), "b" (info)
);
return retval;
};

View File

@ -1,22 +1,13 @@
#include <syscall.h>
int set_file_size(const char *path, unsigned size) int set_file_size(const char *path, unsigned size)
{ {
int retval; ksys70_t k;
int tmp; int err;
__asm__ __volatile__( k.p00 = 4;
"pushl $0 \n\t" k.p04dw = size;
"pushl $0 \n\t" k.p08dw = 0;
"movl %2, 1(%%esp) \n\t" k.p20 = 0;
"pushl $0 \n\t" k.p21 = path;
"pushl $0 \n\t" return FS_Service(&k, &err);
"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), "=b"(tmp)
:"r" (path), "b" (size));
return retval;
};

View File

@ -1,25 +1,20 @@
#include <syscall.h>
int write_file(const char *path,const void *buff, int write_file(const char *path,const void *buff,
unsigned offset,unsigned count,unsigned *writes) unsigned offset,unsigned count,unsigned *writes)
{ {
int retval; ksys70_t k;
unsigned cnt; k.p00 = 3;
__asm__ __volatile__( k.p04 = offset;
"pushl $0 \n\t" k.p12 = count;
"pushl $0 \n\t" k.cbuf16 = buff;
"movl %%eax, 1(%%esp) \n\t" k.p20 = 0;
"pushl %%ebx \n\t" k.p21 = path;
"pushl %%edx \n\t" int status;
"pushl $0 \n\t" unsigned bytes_written_v;
"pushl %%ecx \n\t" FS_Service(&k, &bytes_written_v);
"pushl $3 \n\t" if (!status){
"movl %%esp, %%ebx \n\t" *writes = bytes_written_v;
"mov $70, %%eax \n\t" }
"int $0x40 \n\t" return status;
"addl $28, %%esp \n\t" }
:"=a" (retval), "=b"(cnt)
:"a"(path),"b"(buff),"c"(offset),"d"(count));
if(writes)
*writes = cnt;
return retval;
};

View File

@ -6,6 +6,8 @@
typedef u32 addr_t; typedef u32 addr_t;
typedef u32 count_t; typedef u32 count_t;
#pragma pack(push, 1)
typedef struct typedef struct
{ {
int width; int width;
@ -24,7 +26,30 @@ struct kos32_pdev
u8 bus; u8 bus;
u8 reserved[2]; u8 reserved[2];
u32 owner; u32 owner;
} __attribute__((packed)); };
typedef struct {
unsigned p00;
union{
uint64_t p04;
struct {
unsigned p04dw;
unsigned p08dw;
};
};
unsigned p12;
union {
unsigned p16;
const char *new_name;
void *bdfe;
void *buf16;
const void *cbuf16;
};
char p20;
const char *p21;
}ksys70_t;
#pragma pack(pop)
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -507,7 +532,17 @@ static inline void *vzalloc(unsigned long size)
return mem; return mem;
}; };
static inline int power_supply_is_system_supplied(void) { return -1; }; static inline int power_supply_is_system_supplied(void) { return -1; };
static inline int FS_Service(ksys70_t *k, int* err){
int status;
__asm__ __volatile__(
"call *__imp__FS_Service"
:"=a" (status), "=b" (*err)
:"b" (k)
:"memory"
);
__asm__ __volatile__ ("":::"ebx","ecx","edx","esi","edi");
return status;
}
#endif #endif