From: John Hodge Date: Sun, 30 Dec 2012 12:10:51 +0000 (+0800) Subject: All - Changes for AcessNative on windows X-Git-Tag: rel0.15~600^2~1 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=c18c6fea968e72403f9a7b75d6f7f8e3f9e8757f;p=tpg%2Facess2.git All - Changes for AcessNative on windows NOTE: Kernel build possibly broken --- diff --git a/AcessNative/acesskernel_src/Makefile b/AcessNative/acesskernel_src/Makefile index b4b7c11d..d17e3bb8 100644 --- a/AcessNative/acesskernel_src/Makefile +++ b/AcessNative/acesskernel_src/Makefile @@ -13,7 +13,8 @@ endif KERNEL_SRC = ../../KernelLand/Kernel/ -KERNEL_OBJ := logging.o adt.o lib.o libc.o debug.o messages.o drvutil_disk.o drvutil_video.o +KERNEL_OBJ := logging.o adt.o lib.o debug.o messages.o drvutil_disk.o drvutil_video.o +#KERNEL_OBJ += libc.o KERNEL_OBJ += vfs/main.o vfs/open.o vfs/acls.o vfs/io.o vfs/dir.o KERNEL_OBJ += vfs/nodecache.o vfs/mount.o vfs/memfile.o vfs/select.o KERNEL_OBJ += vfs/fs/root.o vfs/fs/devfs.o @@ -36,7 +37,8 @@ DEPFILES := $(DEPFILES:%=%.dep) KCPPFLAGS = -I include/ -I $(KERNEL_SRC)include/ CFLAGS += -Wall -g -std=gnu99 -LDFLAGS += -lSDL -lSDLmain -g -Wl,--defsym,__buildnum=$(BUILD_NUM) +CPPFLAGS += $(shell sdl-config --cflags) -I /usr/include/ +LDFLAGS += $(shell sdl-config --libs) -g -Wl,--defsym,__buildnum=$(BUILD_NUM) ifeq ($(PLATFORM),win) BIN := ../AcessKernel.exe @@ -69,7 +71,7 @@ $(OBJ): obj-$(PLATFORM)/%.o: %.c $(K_OBJ): $(KERNEL_SRC)obj-native-$(PLATFORM)/%.o: $(KERNEL_SRC)%.c @mkdir -p $(dir $@) @echo [CC] -o $@ - $(CC) -ffreestanding -c $< -o $@ $(CFLAGS) $(KCPPFLAGS) $(CPPFLAGS) + @$(CC) -ffreestanding -c $< -o $@ $(CFLAGS) $(KCPPFLAGS) $(CPPFLAGS) @$(CC) -ffreestanding -M $(KCPPFLAGS) $(CPPFLAGS) -MT $@ -o $@.dep $< @@ -81,12 +83,13 @@ $(N_OBJ): obj-$(PLATFORM)/%.o: %.c $(BUILDINFO_SRC): $(filter-out $(BUILDINFO_OBJ), $(OBJ)) Makefile @echo "" > $@ - $(eval _GITHASH=$(shell (git log -n 1 | head -n 1 | awk '{print $$2}') || echo UNK)) - $(eval _GITCHANGED=$(shell (git status --porcelain | grep -c '^ M ') || echo UNK)) + $(eval _GITHASH=$(shell (git log -n 1 | head -n 1 | awk '{print $$2}') 2>/dev/null || echo UNK)) + $(eval _GITCHANGED=$(shell (git status --porcelain | grep -c '^ M ') 2>/dev/null || echo UNK)) + $(eval _HOSTNAME=$(shell hostname --fqdn 2>/dev/null || hostname || echo UNK)) @echo "const char gsKernelVersion[] = \"$(ACESS_VERSION)\";" >> $@ @echo "const char gsGitHash[] = \"$(_GITHASH)\";" >> $@ - @echo "const char gsBuildInfo[] = \"Acess2 v$(KERNEL_VERSION) $(ARCH)-$(PLATFORM)\\\\r\\\\n\"" >> $@ - @echo " \"Build $(shell hostname --fqdn):$(BUILD_NUM) Git $(_GITHASH) - $(_GITCHANGED) modified\";" >> $@ + @echo "const char gsBuildInfo[] = \"AcessNative $(ACESS_VERSION) $(ARCH)-$(PLATFORM)\\\\r\\\\n\"" >> $@ + @echo " \"Build $(_HOSTNAME):$(BUILD_NUM) Git $(_GITHASH) - $(_GITCHANGED) modified\";" >> $@ @echo "const int giBuildNumber = $(BUILD_NUM);" >> $@ $(BUILDINFO_OBJ): $(BUILDINFO_SRC) @echo [CC] -o $@ diff --git a/AcessNative/acesskernel_src/helpers.c b/AcessNative/acesskernel_src/helpers.c index 3cf273e4..51b96533 100644 --- a/AcessNative/acesskernel_src/helpers.c +++ b/AcessNative/acesskernel_src/helpers.c @@ -9,6 +9,7 @@ #include #include #include +#include #if 0 void LogF(const char *Fmt, ...) @@ -67,10 +68,14 @@ void KernelPanic_PutChar(char ch) void Debug_PutCharDebug(char ch) { printf("%c", ch); + if( ch == '\n' ) + fflush(stdout); } void Debug_PutStringDebug(const char *String) { printf("%s", String); + if( strchr(String, '\n') ) + fflush(stdout); } void *Heap_Allocate(const char *File, int Line, int ByteCount) @@ -93,6 +98,11 @@ void Heap_Deallocate(void *Ptr) free(Ptr); } +char *Heap_StringDup(const char *File, int Line, const char *Str) +{ + return strdup(Str); +} + void Heap_Dump(void) { } @@ -130,3 +140,26 @@ void IPStack_SendDebugText(const char *str) // nop } +int strpos(const char *str, char ch) +{ + const char *retptr = strchr(str, ch); + int rv = retptr ? retptr - str : -1; + fprintf(stderr, "strpos: str = %p'%s', retptr = %p, rv = %i\n", str, str, retptr, rv); + return rv; +} + +int CheckString(const char *string) +{ + if( (intptr_t)string < 0x1000 ) + return 0; + strlen(string); + return 1; +} + +int CheckMem(const void *buf, size_t len) +{ + if( (intptr_t)buf < 0x1000 ) + return 0; + return 1; +} + diff --git a/AcessNative/acesskernel_src/include/arch.h b/AcessNative/acesskernel_src/include/arch.h index 1307e0c6..e99948c9 100644 --- a/AcessNative/acesskernel_src/include/arch.h +++ b/AcessNative/acesskernel_src/include/arch.h @@ -29,7 +29,6 @@ typedef intptr_t tPAddr; typedef int BOOL; #include -#undef NULL #undef offsetof struct sShortSpinlock diff --git a/AcessNative/acesskernel_src/include/heap.h b/AcessNative/acesskernel_src/include/heap.h index 287250ca..8bf7d8ec 100644 --- a/AcessNative/acesskernel_src/include/heap.h +++ b/AcessNative/acesskernel_src/include/heap.h @@ -11,6 +11,7 @@ extern void *Heap_Reallocate(const char *File, int Line, void *Ptr, size_t Bytes extern void Heap_Deallocate(void *Ptr); extern int Heap_IsHeapAddr(void *Ptr); extern void Heap_Validate(void); +extern char *Heap_StringDup(const char *File, int Line, const char *Str); #define malloc(size) Heap_Allocate(_MODULE_NAME_"/"__FILE__, __LINE__, (size)) #define calloc(num,size) Heap_AllocateZero(_MODULE_NAME_"/"__FILE__, __LINE__, (num)*(size)) @@ -18,6 +19,6 @@ extern void Heap_Validate(void); #define free(ptr) Heap_Deallocate((ptr)) #define IsHeap(ptr) Heap_IsHeapAddr((ptr)) -#define strdup(Str) _strdup(_MODULE_NAME_"/"__FILE__, __LINE__, (Str)) +#define strdup(Str) Heap_StringDup(_MODULE_NAME_"/"__FILE__, __LINE__, (Str)) #endif diff --git a/AcessNative/acesskernel_src/include/threads_int.h b/AcessNative/acesskernel_src/include/threads_int.h index 1294a5f4..8061f1e9 100644 --- a/AcessNative/acesskernel_src/include/threads_int.h +++ b/AcessNative/acesskernel_src/include/threads_int.h @@ -50,7 +50,7 @@ struct sThread tProcess *Process; - Uint32 Events, WaitMask; + Uint32 EventState, WaitMask; void *EventSem; // Should be SDL_sem, but I don't want SDL in this header // Message queue diff --git a/AcessNative/acesskernel_src/nativefs.c b/AcessNative/acesskernel_src/nativefs.c index 0e791b8f..af25e3c3 100644 --- a/AcessNative/acesskernel_src/nativefs.c +++ b/AcessNative/acesskernel_src/nativefs.c @@ -5,11 +5,13 @@ * nativefs.c * - Host filesystem access */ -#define DEBUG 0 +#define DEBUG 1 #define off_t _acess_off_t +#define sprintf _acess_sprintf #include // Acess #include // Acess #undef off_t +#undef sprintf #include // Posix #include // Posix #include // Posix diff --git a/AcessNative/acesskernel_src/syscalls.c b/AcessNative/acesskernel_src/syscalls.c index d14a1d9f..827d6110 100644 --- a/AcessNative/acesskernel_src/syscalls.c +++ b/AcessNative/acesskernel_src/syscalls.c @@ -4,7 +4,7 @@ * * Syscall Distribution */ -#define DEBUG 0 +#define DEBUG 1 #include #include #include @@ -89,7 +89,7 @@ typedef int (*tSyscallHandler)(Uint *Errno, const char *Format, void *Args, int } // === CODE === -int Syscall_Null(Uint*Errno, const char *Format, void *Args, int *Sizes) +int Syscall_Null(Uint *Errno, const char *Format, void *Args, int *Sizes) { return 0; } @@ -100,7 +100,9 @@ SYSCALL1(Syscall_Exit, "i", int, ); SYSCALL2(Syscall_Open, "si", const char *, int, - return VFS_Open(a0, a1|VFS_OPENFLAG_USER); + int rv = VFS_Open(a0, a1|VFS_OPENFLAG_USER); + if(rv == -1) *Errno = errno; + return rv; ); SYSCALL1(Syscall_Close, "i", int, VFS_Close(a0); @@ -111,12 +113,18 @@ SYSCALL3(Syscall_Read, "iid", int, int, void *, Log_Warning("Syscalls", "Read - %i < %i", Sizes[2], a1); return -1; } - return VFS_Read(a0, a1, a2); + size_t rv = VFS_Read(a0, a1, a2); + if(rv == -1) *Errno = errno; + return rv; ); SYSCALL3(Syscall_Write, "iid", int, int, const void *, - if( Sizes[2] < a1 ) + if( Sizes[2] < a1 ) { + *Errno = EINVAL; return -1; - return VFS_Write(a0, a1, a2); + } + size_t rv = VFS_Write(a0, a1, a2); + if(rv == -1) *Errno = errno; + return rv; ); SYSCALL3(Syscall_Seek, "iIi", int, int64_t, int, return VFS_Seek(a0, a1, a2); @@ -129,7 +137,7 @@ SYSCALL3(Syscall_IOCtl, "iid", int, int, void *, ); SYSCALL3(Syscall_FInfo, "idi", int, void *, int, if( Sizes[1] < sizeof(tFInfo)+a2*sizeof(tVFS_ACL)) { - LOG("offsetof(size) = %i", offsetof(tFInfo, size)); + //LOG("offsetof(size) = %i", offsetof(tFInfo, size)); LOG("Bad size %i < %i", Sizes[1], sizeof(tFInfo)+a2*sizeof(tVFS_ACL)); *Errno = -EINVAL; return -1; @@ -392,9 +400,17 @@ tRequestHeader *SyscallRecieve(tRequestHeader *Request, int *ReturnLength) } } + // --- Perform request retVal = caSyscalls[Request->CallID](&ret_errno, formatString, argListData, argSizes); } + // ---------- Return + + if( ret_errno == 0 ) { + perror("Syscall?"); + ret_errno = errno; + } + // Allocate the return size_t msglen = sizeof(tRequestHeader) + retValueCount * sizeof(tRequestValue) + retDataLen; ret = malloc(msglen); diff --git a/AcessNative/acesskernel_src/threads.c b/AcessNative/acesskernel_src/threads.c index 661d584b..7296a58e 100644 --- a/AcessNative/acesskernel_src/threads.c +++ b/AcessNative/acesskernel_src/threads.c @@ -339,7 +339,7 @@ Uint32 Threads_WaitEvents(Uint32 Mask) //Log_Debug("Threads", "Mask = %x, ->Events = %x", Mask, gpCurrentThread->Events); gpCurrentThread->WaitMask = Mask; - if( !(gpCurrentThread->Events & Mask) ) + if( !(gpCurrentThread->EventState & Mask) ) { if( Threads_Glue_SemWait(gpCurrentThread->EventSem, INT_MAX) == -1 ) { Log_Warning("Threads", "Wait on eventsem of %p, %p failed", @@ -347,8 +347,8 @@ Uint32 Threads_WaitEvents(Uint32 Mask) } //Log_Debug("Threads", "Woken from nap (%i here)", SDL_SemValue(gpCurrentThread->EventSem)); } - rv = gpCurrentThread->Events & Mask; - gpCurrentThread->Events &= ~Mask; + rv = gpCurrentThread->EventState & Mask; + gpCurrentThread->EventState &= ~Mask; gpCurrentThread->WaitMask = -1; //Log_Debug("Threads", "- rv = %x", rv); @@ -358,7 +358,7 @@ Uint32 Threads_WaitEvents(Uint32 Mask) void Threads_PostEvent(tThread *Thread, Uint32 Events) { - Thread->Events |= Events; + Thread->EventState |= Events; // Log_Debug("Threads", "Trigger event %x (->Events = %p) on %p", Events, Thread->Events, Thread); if( Events == 0 || Thread->WaitMask & Events ) { @@ -369,6 +369,6 @@ void Threads_PostEvent(tThread *Thread, Uint32 Events) void Threads_ClearEvent(Uint32 EventMask) { - gpCurrentThread->Events &= ~EventMask; + gpCurrentThread->EventState &= ~EventMask; } diff --git a/AcessNative/acesskernel_src/video.c b/AcessNative/acesskernel_src/video.c index da18f482..3cce4848 100644 --- a/AcessNative/acesskernel_src/video.c +++ b/AcessNative/acesskernel_src/video.c @@ -14,8 +14,8 @@ // === PROTOTYPES === int Video_Install(char **Arguments); -Uint64 Video_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer); -Uint64 Video_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer); +size_t Video_Read(tVFS_Node *Node, Uint64 Offset, size_t Length, void *Buffer); +size_t Video_Write(tVFS_Node *Node, Uint64 Offset, size_t Length, const void *Buffer); int Video_IOCtl(tVFS_Node *Node, int ID, void *Data); // --- 2D Acceleration Functions -- void Video_2D_Fill(void *Ent, Uint16 X, Uint16 Y, Uint16 W, Uint16 H, Uint32 Colour); @@ -55,7 +55,7 @@ int Video_Install(char **Arguments) /** * \brief Read from framebuffer (unimplemented) */ -Uint64 Video_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) +size_t Video_Read(tVFS_Node *Node, Uint64 Offset, size_t Length, void *Buffer) { return 0; } @@ -63,7 +63,7 @@ Uint64 Video_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) /** * \brief Write to the framebuffer */ -Uint64 Video_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer) +size_t Video_Write(tVFS_Node *Node, Uint64 Offset, size_t Length, const void *Buffer) { int i; ENTER("pNode XOffset XLength pBuffer", Node, Offset, Length, Buffer); diff --git a/AcessNative/ld-acess_src/Makefile b/AcessNative/ld-acess_src/Makefile index bbaef1de..78e07856 100644 --- a/AcessNative/ld-acess_src/Makefile +++ b/AcessNative/ld-acess_src/Makefile @@ -11,7 +11,8 @@ OBJ := $(addprefix obj-$(PLATFORM)/,$(OBJ)) ifeq ($(PLATFORM),win) BIN := ../ld-acess.exe - LDFLAGS += -lws2_32 + LINKADDR := 0x70000000 + LDFLAGS += -lws2_32 -Wl,--image-base,$(LINKADDR) endif ifeq ($(PLATFORM),lin) BIN := ../ld-acess diff --git a/AcessNative/ld-acess_src/common.h b/AcessNative/ld-acess_src/common.h index 63db8612..376faa58 100644 --- a/AcessNative/ld-acess_src/common.h +++ b/AcessNative/ld-acess_src/common.h @@ -31,7 +31,7 @@ static inline void AddLoaded(const char *Path, void *Base) Binary_SetReadyToUse(Base); } -static inline int SysSetMemFlags(uintptr_t Addr, unsigned int flags, unsigned int mask) +static inline int _SysSetMemFlags(uintptr_t Addr, unsigned int flags, unsigned int mask) { return 0; } diff --git a/AcessNative/ld-acess_src/exports.c b/AcessNative/ld-acess_src/exports.c index 07662a5b..d7e49227 100644 --- a/AcessNative/ld-acess_src/exports.c +++ b/AcessNative/ld-acess_src/exports.c @@ -11,7 +11,8 @@ #include #include -#define DEBUG(v...) do{}while(0)//Debug(v) +#define DEBUG(v...) Debug(v) +//#define DEBUG(v...) do{}while(0)//Debug(v) #define PAGE_SIZE 4096 typedef struct sFILE FILE; @@ -125,7 +126,7 @@ int acess_SysReadDir(int fd, char *dest) { return _Syscall(SYS_READDIR, ">i i ?d ?d ?d >d >i", nfds, @@ -137,7 +138,7 @@ int acess__SysSelect(int nfds, fd_set *read, fd_set *write, fd_set *error, time_ ); } -int acess_select(int nfds, fd_set *read, fd_set *write, fd_set *error, time_t *timeout) +int acess_select(int nfds, fd_set *read, fd_set *write, fd_set *error, int64_t *timeout) { return acess__SysSelect(nfds, read, write, error, timeout, 0); } @@ -166,7 +167,7 @@ int acess__SysSetFaultHandler(int (*Handler)(int)) { } // --- Memory Management --- -uint64_t acess__SysAllocate(uint vaddr) +uint64_t acess__SysAllocate(uintptr_t vaddr) { if( AllocateMemory(vaddr, 0x1000) == -1 ) // Allocate a page return 0; @@ -349,6 +350,12 @@ void acess__exit(int Status) exit(Status); } +uint32_t acess__SysSetMemFlags(uintptr_t vaddr, uint32_t flags, uint32_t mask) +{ + // TODO: Impliment acess__SysSetMemFlags? + return 0; +} + // === Symbol List === #define DEFSYM(name) {#name, &acess_##name} @@ -388,6 +395,7 @@ const tSym caBuiltinSymbols[] = { DEFSYM(SysGetMessage), DEFSYM(_SysAllocate), + DEFSYM(_SysSetMemFlags), DEFSYM(_SysDebug), DEFSYM(_SysSetFaultHandler), DEFSYM(_SysWaitEvent), diff --git a/AcessNative/ld-acess_src/main.c b/AcessNative/ld-acess_src/main.c index e4acbf06..3f1cb2bf 100644 --- a/AcessNative/ld-acess_src/main.c +++ b/AcessNative/ld-acess_src/main.c @@ -85,7 +85,10 @@ int main(int argc, char *argv[], char **envp) base = Binary_Load(appPath, (uintptr_t*)&appMain); printf("[DEBUG %i] base = %p\n", giSyscall_ClientID, base); - if( !base ) return 127; + if( !base ) { + *((char*)NULL) = 0; + return 127; + } printf("==============================\n"); printf("[DEBUG %i] %i ", giSyscall_ClientID, appArgc); diff --git a/AcessNative/ld-acess_src/memory.c b/AcessNative/ld-acess_src/memory.c index 3f0091d3..c8166af4 100644 --- a/AcessNative/ld-acess_src/memory.c +++ b/AcessNative/ld-acess_src/memory.c @@ -21,9 +21,26 @@ int AllocateMemory(uintptr_t VirtAddr, size_t ByteCount) size_t size = (VirtAddr & 0xFFF) + ByteCount; void *tmp; #if __WIN32__ - tmp = VirtualAlloc((void*)base, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE); + do + { + MEMORY_BASIC_INFORMATION info; + VirtualQuery( (void*)base, &info, sizeof(info) ); + if( info.State != MEM_FREE ) { + printf("ERROR: Unable to allocate memory %p+0x%x, already allocated\n", + (void*)base, size); + base += 0x1000; + if( size < 0x1000 ) + return 0; + size -= 0x1000; + } + else + break; + } while( size >= 0x1000 ); + tmp = VirtualAlloc((void*)base, size, MEM_RESERVE|MEM_COMMIT, PAGE_EXECUTE_READWRITE); if( tmp == NULL ) { - printf("ERROR: Unable to allocate memory (0x%x)\n", (int)GetLastError()); + printf("ERROR: Unable to allocate memory %p+%x (0x%x)\n", + (void*)base, size, + (int)GetLastError()); return -1; } #else diff --git a/AcessNative/ld-acess_src/request.c b/AcessNative/ld-acess_src/request.c index 5bcf8cd3..2fa481a7 100644 --- a/AcessNative/ld-acess_src/request.c +++ b/AcessNative/ld-acess_src/request.c @@ -1,6 +1,6 @@ /* */ -#define DEBUG 0 +#define DEBUG 1 #if DEBUG @@ -51,6 +51,7 @@ void Request_Preinit(void) memset((void *)&gSyscall_ServerAddr, '\0', sizeof(struct sockaddr_in)); gSyscall_ServerAddr.sin_family = AF_INET; gSyscall_ServerAddr.sin_port = htons(SERVER_PORT); + gSyscall_ServerAddr.sin_addr.s_addr = htonl(0x7F000001); } int _InitSyscalls(void) @@ -80,20 +81,13 @@ int _InitSyscalls(void) exit(0); } - #if 0 - // Set client address - memset((void *)&client, '\0', sizeof(struct sockaddr_in)); - client.sin_family = AF_INET; - client.sin_port = htons(0); - client.sin_addr.s_addr = htonl(0x7F000001); - #endif - #if USE_TCP if( connect(gSocket, (struct sockaddr *)&gSyscall_ServerAddr, sizeof(struct sockaddr_in)) < 0 ) { fprintf(stderr, "[ERROR -] Cannot connect to server (localhost:%i)\n", SERVER_PORT); perror("_InitSyscalls"); #if __WIN32__ + fprintf(stderr, "[ERROR -] - WSAGetLastError said %i", WSAGetLastError()); closesocket(gSocket); WSACleanup(); #else @@ -104,6 +98,11 @@ int _InitSyscalls(void) #endif #if 0 + // Set client address + memset((void *)&client, '\0', sizeof(struct sockaddr_in)); + client.sin_family = AF_INET; + client.sin_port = htons(0); + client.sin_addr.s_addr = htonl(0x7F000001); // Bind if( bind(gSocket, (struct sockaddr *)&client, sizeof(struct sockaddr_in)) == -1 ) { @@ -309,7 +308,11 @@ int ReadData(void *Dest, int MaxLength, int Timeout) } if( ret == 0 ) { fprintf(stderr, "[ERROR %i] Connection closed.\n", giSyscall_ClientID); + #if __WIN32__ + closesocket(gSocket); + #else close(gSocket); + #endif exit(0); } diff --git a/AcessNative/ld-acess_src/syscalls.c b/AcessNative/ld-acess_src/syscalls.c index 26f6c44c..d659fe55 100644 --- a/AcessNative/ld-acess_src/syscalls.c +++ b/AcessNative/ld-acess_src/syscalls.c @@ -9,7 +9,9 @@ #include #include #include -#include // posix_spawn +#ifndef __WIN32__ +# include // posix_spawn +#endif #include "request.h" #if SYSCALL_TRACE @@ -341,7 +343,11 @@ int native_spawn(const char *filename, const char *const argv[], const char *con { int rv; + #if __WIN32__ + rv = _spawnve(_P_NOWAIT, filename, argv, envp); + #else rv = posix_spawn(NULL, filename, NULL, NULL, (void*)argv, (void*)envp); + #endif return rv; } diff --git a/KernelLand/Kernel/arch/x86_64/pci.c b/KernelLand/Kernel/arch/x86_64/pci.c index cac29a8f..6ccf2665 120000 --- a/KernelLand/Kernel/arch/x86_64/pci.c +++ b/KernelLand/Kernel/arch/x86_64/pci.c @@ -1 +1 @@ -../x86/pci.c \ No newline at end of file +#include "../x86/pci.c" \ No newline at end of file diff --git a/KernelLand/Kernel/drv/proc.c b/KernelLand/Kernel/drv/proc.c index 9c7d909a..930616ae 100644 --- a/KernelLand/Kernel/drv/proc.c +++ b/KernelLand/Kernel/drv/proc.c @@ -150,6 +150,10 @@ int SysFS_RegisterFile(const char *Path, const char *Data, int Length) if( !child ) { child = calloc( 1, sizeof(tSysFS_Ent)+tmp+1 ); + if( !child ) { + Log_Error("SysFS", "calloc(%i) failure", sizeof(tSysFS_Ent)+tmp+1); + return -1; + } child->Next = NULL; memcpy(child->Name, &Path[start], tmp); child->Name[tmp] = '\0'; @@ -174,7 +178,8 @@ int SysFS_RegisterFile(const char *Path, const char *Data, int Length) ent->Node.Size ++; else gSysFS_DriverInfo.RootNode.Size ++; - Log_Log("SysFS", "Added directory '%s'", child->Name); + Log_Log("SysFS", "Added directory '%.*s'", tmp, &Path[start]); + Log_Log("SysFS", "Added directory '%.*s'", tmp, child->Name); } ent = child; diff --git a/KernelLand/Kernel/drv/vterm.c b/KernelLand/Kernel/drv/vterm.c index fc6dea26..5316ba55 100644 --- a/KernelLand/Kernel/drv/vterm.c +++ b/KernelLand/Kernel/drv/vterm.c @@ -114,11 +114,11 @@ int VT_Install(char **Arguments) if( strcmp(opt, "Video") == 0 ) { if( !gsVT_OutputDevice ) - gsVT_OutputDevice = strdup(val); + gsVT_OutputDevice = val; } else if( strcmp(opt, "Input") == 0 ) { if( !gsVT_InputDevice ) - gsVT_InputDevice = strdup(val); + gsVT_InputDevice = val; } else if( strcmp(opt, "Width") == 0 ) { giVT_RealWidth = atoi( val ); diff --git a/KernelLand/Kernel/include/vfs_ext.h b/KernelLand/Kernel/include/vfs_ext.h index 44c70f86..a130ac65 100644 --- a/KernelLand/Kernel/include/vfs_ext.h +++ b/KernelLand/Kernel/include/vfs_ext.h @@ -143,6 +143,10 @@ typedef struct sFInfo tVFS_ACL acls[]; //!< ACL buffer (size is passed in the \a MaxACLs argument to VFS_FInfo) } PACKED tFInfo; +// --- fd_set -- +#include "../../../Usermode/Libraries/ld-acess.so_src/include_exp/acess/fd_set.h" + +#if 0 /** * \brief fd_set for select() */ @@ -170,6 +174,7 @@ typedef struct * \param fdsetp Set to modify */ #define FD_ISSET(fd, fdsetp) ((fdsetp)->flags[(fd)/16]&(1<<((fd)%16))) +#endif // === FUNCTIONS === /** diff --git a/KernelLand/Kernel/logging.c b/KernelLand/Kernel/logging.c index aab25a10..5149e021 100644 --- a/KernelLand/Kernel/logging.c +++ b/KernelLand/Kernel/logging.c @@ -93,7 +93,7 @@ void Log_AddEvent(const char *Ident, int Level, const char *Format, va_list Args if( Level >= NUM_LOG_LEVELS ) return; va_copy(args_tmp, Args); - len = vsnprintf(NULL, 256, Format, args_tmp); + len = vsnprintf(NULL, 0, Format, args_tmp); #if USE_RING_BUFFER || !CACHE_MESSAGES { diff --git a/Usermode/Libraries/ld-acess.so_src/include_exp/acess/fd_set.h b/Usermode/Libraries/ld-acess.so_src/include_exp/acess/fd_set.h index 07939010..8972cbe4 100644 --- a/Usermode/Libraries/ld-acess.so_src/include_exp/acess/fd_set.h +++ b/Usermode/Libraries/ld-acess.so_src/include_exp/acess/fd_set.h @@ -21,9 +21,26 @@ typedef struct } fd_set; -extern void FD_ZERO(fd_set *fdsetp); -extern void FD_CLR(int fd, fd_set *fdsetp); -extern void FD_SET(int fd, fd_set *fdsetp); -extern int FD_ISSET(int fd, fd_set *fdsetp); +static inline void FD_ZERO(fd_set *fdsetp) +{ + int i = FD_SETSIZE/16; + while( i-- ) + fdsetp->flags[i] = 0; +} +static inline void FD_CLR(int fd, fd_set *fdsetp) +{ + if(fd < 0 || fd > FD_SETSIZE) return; + fdsetp->flags[fd/16] &= (fd_set_ent_t) ((~1 << (fd%16))) & 0xFFFF; +} +static inline void FD_SET(int fd, fd_set *fdsetp) +{ + if(fd < 0 || fd > FD_SETSIZE) return; + fdsetp->flags[fd/16] |= (fd_set_ent_t) (1 << (fd%16)); +} +static inline int FD_ISSET(int fd, fd_set *fdsetp) +{ + if(fd < 0 || fd > FD_SETSIZE) return 0; + return !!( fdsetp->flags[fd/16] & (1<<(fd%16)) ); +} #endif diff --git a/Usermode/Libraries/libaxwin3.so_src/include_exp/axwin3/keysyms.h b/Usermode/Libraries/libaxwin3.so_src/include_exp/axwin3/keysyms.h index 93c2064e..1d05cf90 120000 --- a/Usermode/Libraries/libaxwin3.so_src/include_exp/axwin3/keysyms.h +++ b/Usermode/Libraries/libaxwin3.so_src/include_exp/axwin3/keysyms.h @@ -1 +1 @@ -../../../../../KernelLand/Kernel/include/keysyms.h \ No newline at end of file +#include "../../../../../KernelLand/Kernel/include/keysyms.h" \ No newline at end of file diff --git a/Usermode/Libraries/libc.so_src/Makefile b/Usermode/Libraries/libc.so_src/Makefile index 31adb5c2..c29e0e5f 100644 --- a/Usermode/Libraries/libc.so_src/Makefile +++ b/Usermode/Libraries/libc.so_src/Makefile @@ -10,7 +10,7 @@ LDFLAGS += -soname libc.so -Map map.txt INCFILES := stdio.h stdlib.h -OBJ = stub.o heap.o stdlib.o env.o stdio.o string.o select.o rand.o +OBJ = stub.o heap.o stdlib.o env.o stdio.o string.o rand.o OBJ += perror.o scanf.o signals.o strtoi.o strtof.o OBJ += arch/$(ARCHDIR).ao # signals.o diff --git a/Usermode/Libraries/libc.so_src/select.c b/Usermode/Libraries/libc.so_src/select.c deleted file mode 100644 index c42848c4..00000000 --- a/Usermode/Libraries/libc.so_src/select.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Acess2 C Library - * - By John Hodge (thePowersGang) - * - * select.c - */ - -//#include -#include - -void FD_ZERO(fd_set *fdsetp) -{ - int i = FD_SETSIZE/16; - while( i-- ) - fdsetp->flags[i]=0; -} - -void FD_CLR(int fd, fd_set *fdsetp) -{ - if(fd < 0 || fd > FD_SETSIZE) return; - fdsetp->flags[fd/16] &= (fd_set_ent_t) ((~1 << (fd%16))) & 0xFFFF; -} - -void FD_SET(int fd, fd_set *fdsetp) -{ - if(fd < 0 || fd > FD_SETSIZE) return; - fdsetp->flags[fd/16] |= (fd_set_ent_t) (1 << (fd%16)); -} - -int FD_ISSET(int fd, fd_set *fdsetp) -{ - if(fd < 0 || fd > FD_SETSIZE) return 0; - return !!( fdsetp->flags[fd/16] & (1<<(fd%16)) ); -} -