git.ucc.asn.au
/
tpg
/
acess2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Usermode/Libs - x86_64 port in progress
[tpg/acess2.git]
/
AcessNative
/
ld-acess_src
/
syscalls.c
diff --git
a/AcessNative/ld-acess_src/syscalls.c
b/AcessNative/ld-acess_src/syscalls.c
index
50352f8
..
02a59b9
100644
(file)
--- a/
AcessNative/ld-acess_src/syscalls.c
+++ b/
AcessNative/ld-acess_src/syscalls.c
@@
-15,7
+15,7
@@
// === IMPORTS ===
// === CODE ===
// === IMPORTS ===
// === CODE ===
-const char *ReadEntry(tRequestValue *Dest, void *DataDest, void **PtrDest, const char *ArgTypes, va_list Args)
+const char *ReadEntry(tRequestValue *Dest, void *DataDest, void **PtrDest, const char *ArgTypes, va_list
*
Args)
{
uint64_t val64;
uint32_t val32;
{
uint64_t val64;
uint32_t val32;
@@
-52,7
+52,8
@@
const char *ReadEntry(tRequestValue *Dest, void *DataDest, void **PtrDest, const
return NULL;
}
return NULL;
}
- val32 = va_arg(Args, uint32_t);
+ val32 = va_arg(*Args, uint32_t);
+ printf("val32 = 0x%x\n", val32);
Dest->Type = ARG_TYPE_INT32;
Dest->Length = sizeof(uint32_t);
Dest->Type = ARG_TYPE_INT32;
Dest->Length = sizeof(uint32_t);
@@
-69,7
+70,8
@@
const char *ReadEntry(tRequestValue *Dest, void *DataDest, void **PtrDest, const
return NULL;
}
return NULL;
}
- val64 = va_arg(Args, uint64_t);
+ val64 = va_arg(*Args, uint64_t);
+ printf("val64 = 0x%llx\n", val64);
Dest->Type = ARG_TYPE_INT64;
Dest->Length = sizeof(uint64_t);
Dest->Type = ARG_TYPE_INT64;
Dest->Length = sizeof(uint64_t);
@@
-85,7
+87,8
@@
const char *ReadEntry(tRequestValue *Dest, void *DataDest, void **PtrDest, const
return NULL;
}
return NULL;
}
- str = va_arg(Args, char*);
+ str = va_arg(*Args, char*);
+ printf("str = %p '%s'\n", str, str);
Dest->Type = ARG_TYPE_STRING;
Dest->Length = strlen(str) + 1;
Dest->Type = ARG_TYPE_STRING;
Dest->Length = strlen(str) + 1;
@@
-98,15
+101,17
@@
const char *ReadEntry(tRequestValue *Dest, void *DataDest, void **PtrDest, const
break;
// Data (special handling)
case 'd':
break;
// Data (special handling)
case 'd':
- len = va_arg(Args, int);
- str = va_arg(Args, char*);
+ len = va_arg(*Args, int);
+ str = va_arg(*Args, char*);
+
+ printf("len = %i, str = %p\n", len, str);
// Save the pointer for later
if( PtrDest ) *PtrDest = str;
// Create parameter block
// Save the pointer for later
if( PtrDest ) *PtrDest = str;
// Create parameter block
- Dest->Type = ARG_TYPE_
INT64
;
- Dest->Length =
sizeof(uint64_t)
;
+ Dest->Type = ARG_TYPE_
DATA
;
+ Dest->Length =
len
;
Dest->Flags = 0;
if( direction & 2 )
Dest->Flags |= ARG_FLAG_RETURN;
Dest->Flags = 0;
if( direction & 2 )
Dest->Flags |= ARG_FLAG_RETURN;
@@
-163,7
+168,7
@@
uint64_t _Syscall(int SyscallID, const char *ArgTypes, ...)
{
tRequestValue tmpVal;
{
tRequestValue tmpVal;
- str = ReadEntry(&tmpVal, NULL, NULL, str, args);
+ str = ReadEntry(&tmpVal, NULL, NULL, str,
&
args);
if( !str ) {
fprintf(stderr, "syscalls.c: ReadEntry failed (SyscallID = %i)\n", SyscallID);
exit(127);
if( !str ) {
fprintf(stderr, "syscalls.c: ReadEntry failed (SyscallID = %i)\n", SyscallID);
exit(127);
@@
-201,7
+206,7
@@
uint64_t _Syscall(int SyscallID, const char *ArgTypes, ...)
retCount = 0;
while(*str)
{
retCount = 0;
while(*str)
{
- str = ReadEntry(&req->Params[paramCount], dataPtr, &retPtrs[retCount], str, args);
+ str = ReadEntry(&req->Params[paramCount], dataPtr, &retPtrs[retCount], str,
&
args);
if( !str ) break;
if( !(req->Params[paramCount].Flags & ARG_FLAG_ZEROED) )
if( !str ) break;
if( !(req->Params[paramCount].Flags & ARG_FLAG_ZEROED) )
@@
-214,7
+219,7
@@
uint64_t _Syscall(int SyscallID, const char *ArgTypes, ...)
va_end(args);
// Send syscall request
va_end(args);
// Send syscall request
- if( SendRequest(req, dataLength) ) {
+ if( SendRequest(req, dataLength)
< 0
) {
fprintf(stderr, "syscalls.c: SendRequest failed (SyscallID = %i)\n", SyscallID);
exit(127);
}
fprintf(stderr, "syscalls.c: SendRequest failed (SyscallID = %i)\n", SyscallID);
exit(127);
}
@@
-260,6
+265,10
@@
void close(int FD) {
_Syscall(SYS_CLOSE, ">i", FD);
}
_Syscall(SYS_CLOSE, ">i", FD);
}
+int reopen(int FD, const char *Path, int Flags) {
+ return _Syscall(SYS_REOPEN, ">i >s >i", FD, Path, Flags);
+}
+
size_t read(int FD, size_t Bytes, void *Dest) {
return _Syscall(SYS_READ, "<i >i >i <d", FD, Bytes, Bytes, Dest);
}
size_t read(int FD, size_t Bytes, void *Dest) {
return _Syscall(SYS_READ, "<i >i >i <d", FD, Bytes, Bytes, Dest);
}
@@
-277,42
+286,30
@@
uint64_t tell(int FD) {
}
int ioctl(int fd, int id, void *data) {
}
int ioctl(int fd, int id, void *data) {
- int ret = 0;
// NOTE: 1024 byte size is a hack
// NOTE: 1024 byte size is a hack
- _Syscall(SYS_IOCTL, "<i >i >i ?d", &ret, fd, id, 1024, data);
- return ret;
+ return _Syscall(SYS_IOCTL, ">i >i ?d", fd, id, 1024, data);
}
int finfo(int fd, t_sysFInfo *info, int maxacls) {
}
int finfo(int fd, t_sysFInfo *info, int maxacls) {
- int ret = 0;
- _Syscall(SYS_FINFO, "<i >i <d >i",
- &ret, fd,
+ return _Syscall(SYS_FINFO, ">i <d >i",
+ fd,
sizeof(t_sysFInfo)+maxacls*sizeof(t_sysACL), info,
maxacls);
sizeof(t_sysFInfo)+maxacls*sizeof(t_sysACL), info,
maxacls);
- return ret;
}
int readdir(int fd, char *dest) {
}
int readdir(int fd, char *dest) {
- int ret = 0;
- _Syscall(SYS_READDIR, "<i >i <d", &ret, fd, 256, dest);
- return ret;
+ return _Syscall(SYS_READDIR, ">i <d", fd, 256, dest);
}
int _SysOpenChild(int fd, char *name, int flags) {
}
int _SysOpenChild(int fd, char *name, int flags) {
- int ret = 0;
- _Syscall(SYS_OPENCHILD, "<i >i >s >i", &ret, fd, name, flags);
- return ret;
+ return _Syscall(SYS_OPENCHILD, ">i >s >i", fd, name, flags);
}
int _SysGetACL(int fd, t_sysACL *dest) {
}
int _SysGetACL(int fd, t_sysACL *dest) {
- int ret = 0;
- _Syscall(SYS_GETACL, "<i >i <d", &ret, fd, sizeof(t_sysACL), dest);
- return ret;
+ return _Syscall(SYS_GETACL, "<i >i <d", fd, sizeof(t_sysACL), dest);
}
int _SysMount(const char *Device, const char *Directory, const char *Type, const char *Options) {
}
int _SysMount(const char *Device, const char *Directory, const char *Type, const char *Options) {
- int ret = 0;
- _Syscall(SYS_MOUNT, "<i >s >s >s >s", &ret, Device, Directory, Type, Options);
- return ret;
+ return _Syscall(SYS_MOUNT, ">s >s >s >s", Device, Directory, Type, Options);
}
}
@@
-321,6
+318,14
@@
int _SysSetFaultHandler(int (*Handler)(int)) {
return 0;
}
return 0;
}
+// --- Memory Management ---
+uint64_t _SysAllocate(uint vaddr)
+{
+ if( AllocateMemory(vaddr, 0x1000) == -1 ) // Allocate a page
+ return 0;
+ return vaddr; // Just ignore the need for paddrs :)
+}
+
// === Symbol List ===
#define DEFSYM(name) {#name, name}
// === Symbol List ===
#define DEFSYM(name) {#name, name}
@@
-329,6
+334,7
@@
const tSym caBuiltinSymbols[] = {
DEFSYM(open),
DEFSYM(close),
DEFSYM(open),
DEFSYM(close),
+ DEFSYM(reopen),
DEFSYM(read),
DEFSYM(write),
DEFSYM(seek),
DEFSYM(read),
DEFSYM(write),
DEFSYM(seek),
@@
-340,6
+346,8
@@
const tSym caBuiltinSymbols[] = {
DEFSYM(_SysGetACL),
DEFSYM(_SysMount),
DEFSYM(_SysGetACL),
DEFSYM(_SysMount),
+ DEFSYM(_SysAllocate),
+
{"_SysSetFaultHandler", _SysSetFaultHandler}
};
{"_SysSetFaultHandler", _SysSetFaultHandler}
};
UCC
git Repository :: git.ucc.asn.au