From be90c91c89715da08fae314e8867c732174cbe54 Mon Sep 17 00:00:00 2001 From: turbocat Date: Mon, 12 Jul 2021 22:49:51 +0000 Subject: [PATCH] ddk: - Fixed Makefile - Added FS_Service instead of calling system call 70 git-svn-id: svn://kolibrios.org@9057 a494cfbc-eb01-0410-851d-a64ba20cac60 --- drivers/ddk/Makefile | 5 +++-- drivers/ddk/core.S | 10 ++++++++-- drivers/ddk/io/create.c | 27 ++++++++------------------- drivers/ddk/io/finfo.c | 36 +++++++++++------------------------- drivers/ddk/io/ssize.c | 29 ++++++++++------------------- drivers/ddk/io/write.c | 37 ++++++++++++++++--------------------- drivers/include/syscall.h | 39 +++++++++++++++++++++++++++++++++++++-- 7 files changed, 93 insertions(+), 90 deletions(-) diff --git a/drivers/ddk/Makefile b/drivers/ddk/Makefile index 349533f044..236fd58619 100644 --- a/drivers/ddk/Makefile +++ b/drivers/ddk/Makefile @@ -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 diff --git a/drivers/ddk/core.S b/drivers/ddk/core.S index 97fe787c93..7f1b073f82 100644 --- a/drivers/ddk/core.S +++ b/drivers/ddk/core.S @@ -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 diff --git a/drivers/ddk/io/create.c b/drivers/ddk/io/create.c index 01a4bc121e..69c73fde2c 100644 --- a/drivers/ddk/io/create.c +++ b/drivers/ddk/io/create.c @@ -1,23 +1,12 @@ +#include 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); }; diff --git a/drivers/ddk/io/finfo.c b/drivers/ddk/io/finfo.c index d336461a6c..576dd10330 100644 --- a/drivers/ddk/io/finfo.c +++ b/drivers/ddk/io/finfo.c @@ -1,5 +1,6 @@ +#include -#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; -}; diff --git a/drivers/ddk/io/ssize.c b/drivers/ddk/io/ssize.c index 40349b4ed1..ac95a8334b 100644 --- a/drivers/ddk/io/ssize.c +++ b/drivers/ddk/io/ssize.c @@ -1,22 +1,13 @@ +#include 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); +} diff --git a/drivers/ddk/io/write.c b/drivers/ddk/io/write.c index ef0c8a4421..726acfc203 100644 --- a/drivers/ddk/io/write.c +++ b/drivers/ddk/io/write.c @@ -1,25 +1,20 @@ +#include 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; +} diff --git a/drivers/include/syscall.h b/drivers/include/syscall.h index f8cc3fa814..82d4918798 100644 --- a/drivers/include/syscall.h +++ b/drivers/include/syscall.h @@ -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