/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 |
/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 |
165,6 → 167,8 |
.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 |
_WaitEvent: |
_WaitEventTimeout: |
_FS_Service: |
ret |
.section .drectve |
326,4 → 332,4 |
.ascii " -export:WaitEvent" # stdcall |
.ascii " -export:WaitEventTimeout" # stdcall |
.ascii " -export:FS_Service" # watch system call 70 |
/drivers/ddk/io/create.c |
---|
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); |
}; |
/drivers/ddk/io/finfo.c |
---|
1,3 → 1,4 |
#include <syscall.h> |
#pragma pack(push, 1) |
typedef struct |
52,31 → 53,16 |
unsigned size; |
unsigned size_high; |
} FILEINFO; |
#pragma pack(pop) |
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; |
}; |
/drivers/ddk/io/ssize.c |
---|
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); |
} |
/drivers/ddk/io/write.c |
---|
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; |
} |
/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,8 → 26,31 |
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) |
/////////////////////////////////////////////////////////////////////////////// |
#define STDCALL __attribute__ ((stdcall)) __attribute__ ((dllimport)) |
507,7 → 532,17 |
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 |