major restructuring, prepare for smp
This commit is contained in:
1 parent
b3569a2b90
commit
6bff37746d
229 files changed
+1617
-1489
No files matched your search
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
// posix_fd.h - file descriptor table (internal to posix.dll)
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef enum {
|
||||
FD_FREE,
|
||||
FD_FILE,
|
||||
FD_CONSOLE_R, // fd 0 - reads from keyboard via SysKbReadChar
|
||||
FD_CONSOLE_W, // fd 1, 2 - writes via SysWriteConsole
|
||||
FD_DEVNULL, // /dev/null
|
||||
FD_DEVZERO, // /dev/zero
|
||||
FD_SOCKET, // kernel socket handle
|
||||
} FD_TYPE;
|
||||
|
||||
typedef struct {
|
||||
FD_TYPE Type;
|
||||
uint32_t KHandle; // kernel handle; 0 for console/devnull/devzero
|
||||
bool Used;
|
||||
} FD_ENTRY;
|
||||
|
||||
#define FD_MAX 64
|
||||
#define FD_TABLE_PIDS 32 // circular, indexed by pid % FD_TABLE_PIDS
|
||||
|
||||
// Called from _start before main(); sets up fds 0/1/2 for this process.
|
||||
__declspec(dllexport) void PosixFdInit(void);
|
||||
|
||||
// Allocate the lowest free fd >= 3. Returns -1 and sets errno=EMFILE on failure.
|
||||
__declspec(dllexport) int FdAlloc(uint32_t pid, FD_TYPE type, uint32_t khandle);
|
||||
|
||||
// Look up an fd. Returns NULL and sets errno=EBADF if invalid.
|
||||
__declspec(dllexport) FD_ENTRY* FdGet(uint32_t pid, int fd);
|
||||
|
||||
// Release an fd slot (does NOT close the kernel handle).
|
||||
__declspec(dllexport) void FdFree(uint32_t pid, int fd);
|
||||
|
||||
int PosixStatusToErrno(uint32_t s);
|
||||
Reference in new issue
Block a user