add system time, clean up pci into pci.sys, clean up syscall names, fix USERAPC1 typo
This commit is contained in:
1 parent
c1a291c4c9
commit
e41bf6e2c0
64 files changed
+4514
-2220
No files matched your search
@@ -6,7 +6,7 @@
|
||||
typedef enum {
|
||||
FD_FREE,
|
||||
FD_FILE,
|
||||
FD_CONSOLE_R, // fd 0 - reads from keyboard via SysKbReadChar
|
||||
FD_CONSOLE_R, // fd 0 - reads from keyboard via SysReadKeyboardChar
|
||||
FD_CONSOLE_W, // fd 1, 2 - writes via SysWriteConsole
|
||||
FD_DEVNULL, // /dev/null
|
||||
FD_DEVZERO, // /dev/zero
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
#include "posix_path.h"
|
||||
|
||||
__declspec(dllexport) void clearscreen(void) {
|
||||
SysScreenClear(0x012456);
|
||||
SysClearScreen(0x012456);
|
||||
}
|
||||
|
||||
__declspec(dllexport) void clearkeyboard(void) {
|
||||
while (SysKbPoll()) (void)SysKbReadChar();
|
||||
while (SysPollKeyboard()) (void)SysReadKeyboardChar();
|
||||
}
|
||||
|
||||
__declspec(dllexport) int open(const char* path, int flags, ...) {
|
||||
@@ -64,7 +64,7 @@ __declspec(dllexport) ssize_t read(int fd, void* buf, size_t count) {
|
||||
// Read up to count chars from keyboard, blocking per char.
|
||||
char* dst = (char*)buf;
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
dst[i] = SysKbReadChar();
|
||||
dst[i] = SysReadKeyboardChar();
|
||||
if (dst[i] == '\n' || dst[i] == '\r') return (ssize_t)(i + 1);
|
||||
}
|
||||
return (ssize_t)count;
|
||||
@@ -82,7 +82,7 @@ __declspec(dllexport) ssize_t read(int fd, void* buf, size_t count) {
|
||||
}
|
||||
case FD_SOCKET: {
|
||||
size_t got = 0;
|
||||
uint32_t s = SysRecv(e->KHandle, buf, count, 0, &got);
|
||||
uint32_t s = SysRecvSocket(e->KHandle, buf, count, 0, &got);
|
||||
if (s != 0) { errno = PosixStatusToErrno(s); return -1; }
|
||||
return (ssize_t)got;
|
||||
}
|
||||
@@ -115,7 +115,7 @@ __declspec(dllexport) ssize_t write(int fd, const void* buf, size_t count) {
|
||||
}
|
||||
case FD_SOCKET: {
|
||||
size_t sent = 0;
|
||||
uint32_t s = SysSend(e->KHandle, buf, count, 0, &sent);
|
||||
uint32_t s = SysSendSocket(e->KHandle, buf, count, 0, &sent);
|
||||
if (s != 0) { errno = PosixStatusToErrno(s); return -1; }
|
||||
return (ssize_t)sent;
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ static FD_ENTRY* SocketFdGet(int fd) {
|
||||
|
||||
__declspec(dllexport) int socket(int domain, int type, int protocol) {
|
||||
uint32_t kh = 0;
|
||||
uint32_t s = SysSocket((uint32_t)domain, (uint32_t)type, (uint32_t)protocol, &kh);
|
||||
uint32_t s = SysCreateSocket((uint32_t)domain, (uint32_t)type, (uint32_t)protocol, &kh);
|
||||
if (s != 0) { errno = PosixStatusToErrno(s); return -1; }
|
||||
|
||||
int fd = FdAlloc(SysGetCurrentPid(), FD_SOCKET, kh);
|
||||
@@ -134,7 +134,7 @@ __declspec(dllexport) int bind(int fd, const struct sockaddr* addr, socklen_t ad
|
||||
if (!e) return -1;
|
||||
SYS_SOCKET_ADDRESS_IPV4 a;
|
||||
if (SockAddrToSys(addr, addrlen, &a) != 0) return -1;
|
||||
uint32_t s = SysBind(e->KHandle, &a, sizeof(a));
|
||||
uint32_t s = SysBindSocket(e->KHandle, &a, sizeof(a));
|
||||
if (s != 0) { errno = PosixStatusToErrno(s); return -1; }
|
||||
return 0;
|
||||
}
|
||||
@@ -142,7 +142,7 @@ __declspec(dllexport) int bind(int fd, const struct sockaddr* addr, socklen_t ad
|
||||
__declspec(dllexport) int listen(int fd, int backlog) {
|
||||
FD_ENTRY* e = SocketFdGet(fd);
|
||||
if (!e) return -1;
|
||||
uint32_t s = SysListen(e->KHandle, backlog < 0 ? 0u : (uint32_t)backlog);
|
||||
uint32_t s = SysListenSocket(e->KHandle, backlog < 0 ? 0u : (uint32_t)backlog);
|
||||
if (s != 0) { errno = PosixStatusToErrno(s); return -1; }
|
||||
return 0;
|
||||
}
|
||||
@@ -154,7 +154,7 @@ __declspec(dllexport) int accept(int fd, struct sockaddr* addr, socklen_t* addrl
|
||||
SYS_SOCKET_ADDRESS_IPV4 remote;
|
||||
size_t remoteSize = sizeof(remote);
|
||||
uint32_t kh = 0;
|
||||
uint32_t s = SysAccept(e->KHandle, addr ? &remote : (SYS_SOCKET_ADDRESS_IPV4*)0,
|
||||
uint32_t s = SysAcceptSocket(e->KHandle, addr ? &remote : (SYS_SOCKET_ADDRESS_IPV4*)0,
|
||||
addr ? &remoteSize : (size_t*)0, &kh);
|
||||
if (s != 0) { errno = PosixStatusToErrno(s); return -1; }
|
||||
|
||||
@@ -172,7 +172,7 @@ __declspec(dllexport) int connect(int fd, const struct sockaddr* addr, socklen_t
|
||||
if (!e) return -1;
|
||||
SYS_SOCKET_ADDRESS_IPV4 a;
|
||||
if (SockAddrToSys(addr, addrlen, &a) != 0) return -1;
|
||||
uint32_t s = SysConnect(e->KHandle, &a, sizeof(a));
|
||||
uint32_t s = SysConnectSocket(e->KHandle, &a, sizeof(a));
|
||||
if (s != 0) { errno = PosixStatusToErrno(s); return -1; }
|
||||
return 0;
|
||||
}
|
||||
@@ -181,7 +181,7 @@ __declspec(dllexport) ssize_t send(int fd, const void* buf, size_t len, int flag
|
||||
FD_ENTRY* e = SocketFdGet(fd);
|
||||
if (!e) return -1;
|
||||
size_t sent = 0;
|
||||
uint32_t s = SysSend(e->KHandle, buf, len, (uint32_t)flags, &sent);
|
||||
uint32_t s = SysSendSocket(e->KHandle, buf, len, (uint32_t)flags, &sent);
|
||||
if (s != 0) { errno = PosixStatusToErrno(s); return -1; }
|
||||
return (ssize_t)sent;
|
||||
}
|
||||
@@ -190,7 +190,7 @@ __declspec(dllexport) ssize_t recv(int fd, void* buf, size_t len, int flags) {
|
||||
FD_ENTRY* e = SocketFdGet(fd);
|
||||
if (!e) return -1;
|
||||
size_t got = 0;
|
||||
uint32_t s = SysRecv(e->KHandle, buf, len, (uint32_t)flags, &got);
|
||||
uint32_t s = SysRecvSocket(e->KHandle, buf, len, (uint32_t)flags, &got);
|
||||
if (s != 0) { errno = PosixStatusToErrno(s); return -1; }
|
||||
return (ssize_t)got;
|
||||
}
|
||||
@@ -212,7 +212,7 @@ __declspec(dllexport) ssize_t sendto(int fd, const void* buf, size_t len, int fl
|
||||
req.RemoteAddressSize = sizeof(remote);
|
||||
req.SentOut = &sent;
|
||||
|
||||
uint32_t s = SysSendTo(e->KHandle, &req);
|
||||
uint32_t s = SysSendToSocket(e->KHandle, &req);
|
||||
if (s != 0) { errno = PosixStatusToErrno(s); return -1; }
|
||||
return (ssize_t)sent;
|
||||
}
|
||||
@@ -234,7 +234,7 @@ __declspec(dllexport) ssize_t recvfrom(int fd, void* buf, size_t len, int flags,
|
||||
req.RemoteAddressSizeInOut = src ? &remoteSize : (size_t*)0;
|
||||
req.ReceivedOut = &got;
|
||||
|
||||
uint32_t s = SysRecvFrom(e->KHandle, &req);
|
||||
uint32_t s = SysRecvFromSocket(e->KHandle, &req);
|
||||
if (s != 0) { errno = PosixStatusToErrno(s); return -1; }
|
||||
if (src) SysToSockAddr(&remote, src, srclen);
|
||||
return (ssize_t)got;
|
||||
@@ -243,7 +243,7 @@ __declspec(dllexport) ssize_t recvfrom(int fd, void* buf, size_t len, int flags,
|
||||
__declspec(dllexport) int shutdown(int fd, int how) {
|
||||
FD_ENTRY* e = SocketFdGet(fd);
|
||||
if (!e) return -1;
|
||||
uint32_t s = SysShutdown(e->KHandle, (uint32_t)how);
|
||||
uint32_t s = SysShutdownSocket(e->KHandle, (uint32_t)how);
|
||||
if (s != 0) { errno = PosixStatusToErrno(s); return -1; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ __declspec(dllexport) void pthread_exit(void* retval) {
|
||||
__declspec(dllexport) int pthread_mutex_init(pthread_mutex_t* m, const pthread_mutexattr_t* attr) {
|
||||
(void)attr;
|
||||
uint32_t h;
|
||||
uint32_t s = SysMutexCreate(&h);
|
||||
uint32_t s = SysCreateMutex(&h);
|
||||
if (s != 0) return ENOMEM;
|
||||
m->Handle = h;
|
||||
return 0;
|
||||
@@ -133,16 +133,16 @@ __declspec(dllexport) int pthread_mutex_destroy(pthread_mutex_t* m) {
|
||||
}
|
||||
|
||||
__declspec(dllexport) int pthread_mutex_lock(pthread_mutex_t* m) {
|
||||
uint32_t s = SysMutexAcquire(m->Handle);
|
||||
uint32_t s = SysAcquireMutex(m->Handle);
|
||||
return s == 0 ? 0 : EINVAL;
|
||||
}
|
||||
|
||||
__declspec(dllexport) int pthread_mutex_trylock(pthread_mutex_t* m) {
|
||||
uint32_t s = SysMutexTryAcquire(m->Handle);
|
||||
uint32_t s = SysTryAcquireMutex(m->Handle);
|
||||
return s == 0 ? 0 : EAGAIN;
|
||||
}
|
||||
|
||||
__declspec(dllexport) int pthread_mutex_unlock(pthread_mutex_t* m) {
|
||||
uint32_t s = SysMutexRelease(m->Handle);
|
||||
uint32_t s = SysReleaseMutex(m->Handle);
|
||||
return s == 0 ? 0 : EINVAL;
|
||||
}
|
||||
Reference in new issue
Block a user