- 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
AS = as
CC = kos32-gcc
AS = kos32-as
LD = kos32-ld
DRV_TOPDIR = $(CURDIR)/..
DRV_INCLUDES = $(DRV_TOPDIR)/include

View File

@ -83,6 +83,8 @@
.global _WaitEvent
.global _WaitEventTimeout
.global _FS_Service
.def _AcpiGetRootPtr; .scl 2; .type 32; .endef
.def _AllocKernelSpace; .scl 2; .type 32; .endef
@ -164,7 +166,9 @@
.def _WaitEvent; .scl 2; .type 32; .endef
.def _WaitEventTimeout; .scl 2; .type 32; .endef
.def _FS_Service; .scl 2; .type 32; .endef
_AcpiGetRootPtr:
_AllocKernelSpace:
@ -244,6 +248,8 @@ _UserFree:
_WaitEvent:
_WaitEventTimeout:
_FS_Service:
ret
.section .drectve
@ -326,4 +332,4 @@ _WaitEventTimeout:
.ascii " -export:WaitEvent" # 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 retval;
int count;
__asm__ __volatile__ (
"pushl $0 \n\t"
"pushl $0 \n\t"
"movl %2, 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), "=b"(count)
:"r" (path)
);
return retval;
int err=0;
ksys70_t k;
k.p00 = 2;
k.p12 = 0;
k.p20 = 0;
k.p21 = path;
return FS_Service(&k, &err);
};

View File

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

View File

@ -1,25 +1,20 @@
#include <syscall.h>
int write_file(const char *path,const void *buff,
unsigned offset,unsigned count,unsigned *writes)
{
int retval;
unsigned cnt;
__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"
"addl $28, %%esp \n\t"
:"=a" (retval), "=b"(cnt)
:"a"(path),"b"(buff),"c"(offset),"d"(count));
if(writes)
*writes = cnt;
return retval;
};
ksys70_t k;
k.p00 = 3;
k.p04 = offset;
k.p12 = count;
k.cbuf16 = buff;
k.p20 = 0;
k.p21 = path;
int status;
unsigned bytes_written_v;
FS_Service(&k, &bytes_written_v);
if (!status){
*writes = bytes_written_v;
}
return status;
}

View File

@ -6,6 +6,8 @@
typedef u32 addr_t;
typedef u32 count_t;
#pragma pack(push, 1)
typedef struct
{
int width;
@ -24,7 +26,30 @@ struct kos32_pdev
u8 bus;
u8 reserved[2];
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;
};
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