Merge branch 'master' of ted.mutabah.net:acess2
authorJohn Hodge <[email protected]>
Sat, 14 Jul 2012 09:23:32 +0000 (17:23 +0800)
committerJohn Hodge <[email protected]>
Sat, 14 Jul 2012 09:23:32 +0000 (17:23 +0800)
Conflicts:
KernelLand/Kernel/Makefile

54 files changed:
AcessNative/Makefile [new file with mode: 0644]
AcessNative/RunTest
AcessNative/acesskernel_src/Makefile
AcessNative/acesskernel_src/include/arch.h
AcessNative/acesskernel_src/include/threads_int.h [new file with mode: 0644]
AcessNative/acesskernel_src/server.c
AcessNative/acesskernel_src/syscalls.c
AcessNative/acesskernel_src/threads.c
AcessNative/acesskernel_src/time.c [new file with mode: 0644]
AcessNative/ld-acess_src/binary.c
AcessNative/ld-acess_src/elf_load.c
AcessNative/ld-acess_src/exports.c
AcessNative/ld-acess_src/main.c
AcessNative/ld-acess_src/memory.c
BuildConf/armv7/Makefile.cfg
BuildConf/armv7/realview_pb.mk
BuildConf/armv7/tegra2.mk
KernelLand/Kernel/Makefile
KernelLand/Kernel/arch/x86/irq.c
KernelLand/Kernel/arch/x86/mm_phys.c
KernelLand/Kernel/arch/x86_64/include/arch.h
KernelLand/Kernel/arch/x86_64/mm_phys.c
KernelLand/Kernel/bin/elf.c
KernelLand/Kernel/debug.c
KernelLand/Kernel/drv/zero-one.c [new file with mode: 0644]
KernelLand/Kernel/drvutil_video.c
KernelLand/Kernel/include/hal_proc.h
KernelLand/Kernel/include/tpl_mm_phys_bitmap.h
KernelLand/Kernel/include/tpl_mm_phys_stack.h
KernelLand/Kernel/include/vfs.h
KernelLand/Kernel/logging.c
KernelLand/Kernel/modules.c
KernelLand/Modules/Filesystems/InitRD/GenerateInitRD.php
KernelLand/Modules/Filesystems/InitRD/files.lst
KernelLand/Modules/IPStack/adapters.c
KernelLand/Modules/Input/Keyboard/main.c
KernelLand/Modules/Input/PS2KbMouse/pl050.c
KernelLand/Modules/Network/VIARhineII/rhine2.c
KernelLand/Modules/Storage/ATA/io.c
KernelLand/Modules/Storage/LVM/main.c
KernelLand/Modules/Storage/LVM/volumes.c
RunQemuArm
Usermode/Applications/Makefile.cfg
Usermode/Applications/axwin3_src/WM/decorator.c
Usermode/Applications/axwin3_src/WM/ipc.c
Usermode/Applications/axwin3_src/WM/video.c
Usermode/Applications/axwin3_src/libaxwin3.so_src/msg.c
Usermode/Applications/ip_src/rules.mk
Usermode/Applications/rules.mk
Usermode/Applications/wget_src/main.c
Usermode/Libraries/Makefile.cfg
Usermode/Libraries/ld-acess.so_src/elf.c
Usermode/Libraries/libc.so_src/stdlib.c
Usermode/Libraries/rules.mk

diff --git a/AcessNative/Makefile b/AcessNative/Makefile
new file mode 100644 (file)
index 0000000..c9cd481
--- /dev/null
@@ -0,0 +1,4 @@
+
+all:
+       @$(MAKE) -C acesskernel_src
+       @$(MAKE) -C ld-acess_src
index 9137ff9..6ea88b6 100755 (executable)
@@ -1,5 +1,6 @@
 #!/bin/sh
 trap '' 2
-./AcessKernel --rootapp /Acess/SBin/login
+#$1 ./AcessKernel --rootapp /Acess/SBin/login
+$1 ./AcessKernel --rootapp /Acess/Apps/AxWin/3.0/AxWinWM
 trap 2
 killall ld-acess
index 4cc939e..0d63d5f 100644 (file)
@@ -25,7 +25,7 @@ N_OBJ := main.o
 BUILDINFO_OBJ := obj-$(PLATFORM)/buildinfo.o\r
 BUILDINFO_SRC := $(BUILDINFO_OBJ:%.o=%.c)\r
 \r
-OBJ := helpers.o threads.o server.o syscalls.o\r
+OBJ := helpers.o threads.o server.o syscalls.o time.o\r
 OBJ += video.o keyboard.o mouse.o nativefs.o vfs_handle.o ui_sdl.o\r
 OBJ := $(addprefix obj-$(PLATFORM)/,$(OBJ))\r
 N_OBJ := $(addprefix obj-$(PLATFORM)/,$(N_OBJ))\r
index f513530..b63d1bb 100644 (file)
@@ -40,5 +40,8 @@ struct sShortSpinlock
 
 //#define      NUM_CFG_ENTRIES 10
 
+extern void    Debug_PutCharDebug(char ch);
+extern void    Debug_PutStringDebug(const char *str);
+
 #endif
 
diff --git a/AcessNative/acesskernel_src/include/threads_int.h b/AcessNative/acesskernel_src/include/threads_int.h
new file mode 100644 (file)
index 0000000..f070a50
--- /dev/null
@@ -0,0 +1,78 @@
+#ifndef _THREADS_INT_H_
+#define _THREADS_INT_H_
+
+/**
+ * \brief IPC Message
+ */
+typedef struct sMessage
+{
+       struct sMessage *Next;  //!< Next message in thread's inbox
+       tTID    Source; //!< Source thread ID
+       Uint    Length; //!< Length of message data in bytes
+       Uint8   Data[]; //!< Message data
+} tMsg;
+
+typedef struct sProcess
+{
+        int    nThreads;
+        int    NativePID;
+       char    *CWD;
+       char    *Chroot;
+        int    MaxFD;
+} tProcess;
+
+struct sThread
+{
+       struct sThread  *GlobalNext;
+       struct sThread  *Next;
+
+        int    KernelTID;
+
+       tTID    TID, PID;
+       tUID    UID, GID;
+
+       struct sThread  *Parent;
+
+       char    *ThreadName;
+
+        int    Status; // 0: Dead, 1: Active, 2: Paused, 3: Asleep
+        int    ExitStatus;
+        int    _errno;
+
+       // Threads waiting for this thread to exit.
+       // Quit logic:
+       // - Wait for `WaitingThreads` to be non-null (maybe?)
+       // - Wake first in the queue, wait for it to be removed
+       // - Repeat
+       // - Free thread and quit kernel thread
+       struct sThread  *WaitingThreads;
+       struct sThread  *WaitingThreadsEnd;
+
+       tProcess        *Process;       
+
+       Uint32  Events, WaitMask;
+       void    *EventSem;      // Should be SDL_sem, but I don't want SDL in this header
+
+       // Message queue
+       tMsg * volatile Messages;       //!< Message Queue
+       tMsg    *LastMessage;   //!< Last Message (speeds up insertion)
+};
+
+enum {
+       THREAD_STAT_NULL,       // Invalid process
+       THREAD_STAT_ACTIVE,     // Running and schedulable process
+       THREAD_STAT_SLEEPING,   // Message Sleep
+       THREAD_STAT_MUTEXSLEEP, // Mutex Sleep
+       THREAD_STAT_SEMAPHORESLEEP,     // Semaphore Sleep
+       THREAD_STAT_QUEUESLEEP, // Queue
+       THREAD_STAT_EVENTSLEEP, // Event sleep
+       THREAD_STAT_WAITING,    // ??? (Waiting for a thread)
+       THREAD_STAT_PREINIT,    // Being created
+       THREAD_STAT_ZOMBIE,     // Died/Killed, but parent not informed
+       THREAD_STAT_DEAD,       // Awaiting burial (free)
+       THREAD_STAT_BURIED      // If it's still on the list here, something's wrong
+};
+extern tThread *Threads_GetThread(Uint TID);
+
+#endif
+
index 7bb5033..78f7fa1 100644 (file)
@@ -131,14 +131,16 @@ int Server_WorkerThread(void *ClientPtr)
                while( Client->CurrentRequest == NULL )
                        SDL_CondWait(Client->WaitFlag, Client->Mutex);
                
+//             Log_Debug("AcessSrv", "Worker got message %p", Client->CurrentRequest);
+               
                if(Client->ClientID != cur_client_id) {
+//                     Log_Debug("AcessSrv", "Client thread ID changed from %i to %i",
+//                             cur_client_id, Client->ClientID);
                        Threads_SetThread( Client->ClientID );
                        cur_client_id = Client->ClientID;
                }
                
-               // Get the response
-               retHeader = SyscallRecieve(Client->CurrentRequest, &retSize);
-
+               // Debug
                {
                        int     callid = Client->CurrentRequest->CallID;
                        Log_Debug("AcessSrv", "Client %i request %i %s",
@@ -147,7 +149,9 @@ int Server_WorkerThread(void *ClientPtr)
                                );
                }
                
-               
+               // Get the response
+               retHeader = SyscallRecieve(Client->CurrentRequest, &retSize);
+
                if( !retHeader ) {
                        // Return an error to the client
                        printf("ERROR: SyscallRecieve failed\n");
@@ -302,8 +306,8 @@ int Server_ListenThread(void *Unused)
                        continue;
                }
                
-               Log_Debug("AcessSrv", "Message from Client %i (%p)",
-                       client->ClientID, client);
+//             Log_Debug("AcessSrv", "Message from Client %i (%p)",
+//                     client->ClientID, client);
 
                // Make a copy of the request data      
                req = malloc(length);
index 58dc801..9b9fda4 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Syscall Distribution
  */
-#define DEBUG  1
+#define DEBUG  0
 #include <acess.h>
 #include <threads.h>
 #include <events.h>
@@ -194,10 +194,21 @@ SYSCALL2(Syscall_SendMessage, "id", int, void *,
        return Proc_SendMessage(a0, Sizes[1], a1);
 );
 
-SYSCALL2(Syscall_GetMessage, "dd", Uint *, void *,
-       if( Sizes[0] < sizeof(*a0) )
+SYSCALL2(Syscall_GetMessage, "dd", uint32_t *, void *,
+       if( a0 && Sizes[0] < sizeof(*a0) ) {
+               Log_Notice("Syscalls", "Syscall_GetMessage - Arg 1 Undersize (%i < %i)",
+                       Sizes[0], sizeof(*a0));
                return -1;
-       return Proc_GetMessage(a0, a1);
+       }
+       Uint    tmp;
+        int    rv;
+       if( a0 ) {
+               rv = Proc_GetMessage(&tmp, a1);
+               *a0 = tmp;
+       }
+       else
+               rv = Proc_GetMessage(NULL, a1);
+       return rv;
 );
 
 SYSCALL1(Syscall_WaitEvent, "i", int,
@@ -298,7 +309,7 @@ tRequestHeader *SyscallRecieve(tRequestHeader *Request, int *ReturnLength)
        }
        formatString[i] = '\0';
        
-       //LOG("Request %i(%s) '%s'", Request->CallID, casSYSCALL_NAMES[Request->CallID], formatString);
+       LOG("Request %i(%s) '%s'", Request->CallID, casSYSCALL_NAMES[Request->CallID], formatString);
        
        {
                char    argListData[argListLen];
@@ -341,7 +352,13 @@ tRequestHeader *SyscallRecieve(tRequestHeader *Request, int *ReturnLength)
                                }
                                
                                // Check for non-resident data
-                               if( Request->Params[i].Flags & ARG_FLAG_ZEROED )
+                               if( Request->Params[i].Length == 0 )
+                               {
+                                       returnData[i] = NULL;
+                                       *(void**)&argListData[argListLen] = NULL;
+                                       argListLen += sizeof(void*);
+                               }
+                               else if( Request->Params[i].Flags & ARG_FLAG_ZEROED )
                                {
                                        // Allocate and zero the buffer
                                        returnData[i] = calloc(1, Request->Params[i].Length);
index 71fa294..c390a03 100644 (file)
@@ -16,6 +16,7 @@
 #include <mutex.h>
 #include <semaphore.h>
 #include <events.h>
+#include <threads_int.h>
 
 #undef CLONE_VM        // Such a hack
 #undef off_t   
@@ -41,49 +42,6 @@ typedef struct sState
 }      tState;
 #endif
 
-typedef struct sProcess
-{
-        int    nThreads;
-        int    NativePID;
-       char    *CWD;
-       char    *Chroot;
-        int    MaxFD;
-} tProcess;
-
-struct sThread
-{
-       struct sThread  *GlobalNext;
-       struct sThread  *Next;
-
-        int    KernelTID;
-
-       tTID    TID, PID;
-       tUID    UID, GID;
-
-       struct sThread  *Parent;
-
-       char    *ThreadName;
-
-        int    State;  // 0: Dead, 1: Active, 2: Paused, 3: Asleep
-        int    ExitStatus;
-        int    _errno;
-
-       // Threads waiting for this thread to exit.
-       // Quit logic:
-       // - Wait for `WaitingThreads` to be non-null (maybe?)
-       // - Wake first in the queue, wait for it to be removed
-       // - Repeat
-       // - Free thread and quit kernel thread
-       struct sThread  *WaitingThreads;
-       struct sThread  *WaitingThreadsEnd;
-
-       tProcess        *Process;       
-
-       Uint32  Events, WaitMask;
-       SDL_sem *EventSem;
-
-};
-
 // === PROTOTYPES ===
  int   Threads_Wake(tThread *Thread);
 
@@ -95,7 +53,7 @@ tProcess gProcessZero = {
        .MaxFD = 100
 };
 tThread        gThreadZero = {
-       .State=1,
+       .Status=THREAD_STAT_ACTIVE,
        .ThreadName="ThreadZero",
        .Process = &gProcessZero
 };
@@ -136,13 +94,14 @@ void Threads_SetThread(int TID)
        Log_Error("Threads", "_SetThread - Thread %i is not on global list", TID);
 }
 
-tThread        *Threads_GetThread(int TID)
+tThread        *Threads_GetThread(Uint TID)
 {
        tThread *thread;
        for( thread = gpThreads; thread; thread = thread->GlobalNext )
        {
-               if( thread->TID == TID )
+               if( thread->TID == TID ) {
                        return thread;
+               }
        }
        return NULL;
 }
@@ -232,7 +191,7 @@ tTID Threads_WaitTID(int TID, int *Status)
                if(!thread)     return -1;
                
                us->Next = NULL;
-               us->State = 3;
+               us->Status = THREAD_STAT_WAITING;
                // TODO: Locking
                if(thread->WaitingThreadsEnd)
                {
@@ -298,7 +257,7 @@ void Threads_Exit(int TID, int Status)
 
 int Threads_Wake(tThread *Thread)
 {
-       Thread->State = 0;
+       Thread->Status = THREAD_STAT_ACTIVE;
        Threads_PostEvent(Thread, THREAD_EVENT_WAKEUP);
        return 0;
 }
@@ -332,6 +291,9 @@ int Threads_Fork(void)
        return thread->PID;
 }
 
+// --------------------------------------------------------------------
+// Mutexes 
+// --------------------------------------------------------------------
 int Mutex_Acquire(tMutex *Mutex)
 {
        if(!Mutex->Protector.IsValid) {
@@ -347,6 +309,9 @@ void Mutex_Release(tMutex *Mutex)
        pthread_mutex_unlock( &Mutex->Protector.Mutex );
 }
 
+// --------------------------------------------------------------------
+// Semaphores
+// --------------------------------------------------------------------
 void Semaphore_Init(tSemaphore *Sem, int InitValue, int MaxValue, const char *Module, const char *Name)
 {
        memset(Sem, 0, sizeof(tSemaphore));
@@ -368,6 +333,9 @@ int Semaphore_Signal(tSemaphore *Sem, int AmmountToAdd)
        return AmmountToAdd;
 }
 
+// --------------------------------------------------------------------
+// Event handling
+// --------------------------------------------------------------------
 Uint32 Threads_WaitEvents(Uint32 Mask)
 {
        Uint32  rv;
@@ -397,3 +365,8 @@ void Threads_PostEvent(tThread *Thread, Uint32 Events)
        }
 }
 
+void Threads_ClearEvent(Uint32 EventMask)
+{
+       gpCurrentThread->Events &= ~EventMask;
+}
+
diff --git a/AcessNative/acesskernel_src/time.c b/AcessNative/acesskernel_src/time.c
new file mode 100644 (file)
index 0000000..89669cf
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Acess2 Native Kernel
+ * - Acess kernel emulation on another OS using SDL and UDP
+ *
+ * time.c
+ * - Timer code
+ */
+#include <acess.h>
+#include <timers.h>
+
+struct sTimer {
+       tTimer  *Next;
+       Sint64  FiresAfter;
+       void    (*Callback)(void*);
+       void    *Argument;
+       BOOL    bActive;
+};
+
+// === CODE ===
+tTimer *Time_CreateTimer(int Delta, tTimerCallback *Callback, void *Argument)
+{
+       return NULL;
+}
+
+tTimer *Time_AllocateTimer(tTimerCallback *Callback, void *Argument)
+{
+       return NULL;
+}
+
+void Time_FreeTimer(tTimer *Timer)
+{
+}
+
+void Time_ScheduleTimer(tTimer *Timer, int Delta)
+{
+}
+
+void Time_RemoveTimer(tTimer *Timer)
+{
+}
index 6235431..d04ac6d 100644 (file)
@@ -1,7 +1,11 @@
 /*
- * AcessNative
+ * AcessNative Dynamic Linker
+ * - By John Hodge (thePowersGang)
+ * 
+ * binary.c
+ * - Provides binary loading and type abstraction
  */
-#define DEBUG  1
+#define DEBUG  0
 #include "common.h"
 #include <stdint.h>
 #include <stdio.h>
@@ -24,6 +28,7 @@ extern uintptr_t      ElfRelocate(void *Base);
 extern int     ElfGetSymbol(void *Base, char *Name, uintptr_t *ret, size_t *size);
 extern int     ciNumBuiltinSymbols;
 extern tSym    caBuiltinSymbols[];
+extern char    **gEnvP;
 
 // === PROTOTYPES ===
 void   Binary_AddToList(const char *Filename, void *Base, tBinFmt *Format);
@@ -109,7 +114,8 @@ void *Binary_LoadLibrary(const char *Name)
        }
 
        ret = Binary_Load(path, (uintptr_t*)&entry);
-       printf("LOADED '%s' to %p (Entry=%p)\n", path, ret, entry);
+       if( ret != (void*)-1 )
+               Debug("LOADED '%s' to %p (Entry=%p)", path, ret, entry);
        free(path);
        
        #if DEBUG
@@ -120,7 +126,7 @@ void *Binary_LoadLibrary(const char *Name)
                #if DEBUG
                printf("Calling '%s' entry point %p\n", Name, entry);
                #endif
-               entry(ret, 0, argv, NULL);
+               entry(ret, 0, argv, gEnvP);
        }
 
        return ret;
index 590da37..909c24a 100644 (file)
@@ -3,7 +3,7 @@
  *\r
  * ELF Executable Loader Code\r
  */\r
-#define DEBUG  1\r
+#define DEBUG  0\r
 #include <stdlib.h>\r
 #include <stdio.h>\r
 #include <string.h>\r
@@ -190,9 +190,9 @@ void *Elf64Load(int FD, Elf64_Ehdr *hdr)
        \r
        ENTER("iFD", FD);\r
        \r
-       #if BITS <= 32\r
-       Warning("ELF64 being loaded in 32-bit env, this may not work");\r
-       #endif\r
+       if( sizeof(void*) == 4) {\r
+               Warning("ELF64 being loaded in 32-bit env, this may not work");\r
+       }\r
 \r
        // Check for a program header\r
        if(hdr->e_phoff == 0) {\r
index 406e55f..fc336c8 100644 (file)
@@ -5,7 +5,7 @@
  * - Exported functions
  */
 #define DONT_INCLUDE_SYSCALL_NAMES 1
-#include "../../Usermode/include/acess/sys.h"
+#include "../../Usermode/Libraries/ld-acess.so_src/include_exp/acess/sys.h"
 #include "../syscalls.h"
 #include "exports.h"
 #include <stdarg.h>
@@ -68,14 +68,16 @@ int acess_reopen(int FD, const char *Path, int Flags) {
 size_t acess_read(int FD, void *Dest, size_t Bytes) {
        if(FD & NATIVE_FILE_MASK)
                return native_read(FD & (NATIVE_FILE_MASK-1), Dest, Bytes);
-       DEBUG("read(0x%x, 0x%x, *%p)", FD, Bytes, Dest);
+//     if( FD > 2 )
+               DEBUG("read(0x%x, 0x%x, *%p)", FD, Bytes, Dest);
        return _Syscall(SYS_READ, ">i >i <d", FD, Bytes, Bytes, Dest);
 }
 
 size_t acess_write(int FD, const void *Src, size_t Bytes) {
        if(FD & NATIVE_FILE_MASK)
                return native_write(FD & (NATIVE_FILE_MASK-1), Src, Bytes);
-       DEBUG("write(0x%x, 0x%x, %p\"%.*s\")", FD, Bytes, Src, Bytes, (char*)Src);
+//     if( FD > 2 )
+               DEBUG("write(0x%x, 0x%x, %p\"%.*s\")", FD, Bytes, Src, Bytes, (char*)Src);
        return _Syscall(SYS_WRITE, ">i >i >d", FD, Bytes, Bytes, Src);
 }
 
@@ -95,8 +97,8 @@ uint64_t acess_tell(int FD) {
 
 int acess_ioctl(int fd, int id, void *data) {
         int    len;
-       // NOTE: 1024 byte size is a hack
        DEBUG("ioctl(%i, %i, %p)", fd, id, data);
+       // NOTE: The length here is hacky and could break
        if( data == NULL )
                len = 0;
        else
@@ -267,7 +269,7 @@ int acess_SysGetMessage(int *SourceTID, void *Data)
        int lastlen;
 
        lastlen = _Syscall(SYS_GETMSG, "<d <d",
-               SourceTID ? sizeof(int) : 0, SourceTID,
+               SourceTID ? sizeof(uint32_t) : 0, SourceTID,
                Data ? 1024 : 0, Data
                );
        return lastlen;
@@ -285,7 +287,7 @@ void acess__SysDebug(const char *Format, ...)
        
        va_start(args, Format);
        
-       printf("[_SysDebug %i]", giSyscall_ClientID);
+       printf("[_SysDebug %i] ", giSyscall_ClientID);
        vprintf(Format, args);
        printf("\n");
        
index 80c5b7a..0c9b743 100644 (file)
@@ -15,6 +15,9 @@ extern void   Request_Preinit(void);
 // === PROTOTYPES ===
 void   CallUser(void *Entry, int argc, char *argv[], char **envp) __attribute__((noreturn));
 
+// === GLOBALS ===
+char   **gEnvP;
+
 // === CODE ===
 int main(int argc, char *argv[], char **envp)
 {
@@ -25,6 +28,8 @@ int main(int argc, char *argv[], char **envp)
         int    (*appMain)(int, char *[], char **);
        void    *base;
         int    rv;
+
+       gEnvP = envp;
        
        Request_Preinit();
 
index f1147c2..2e9612c 100644 (file)
@@ -53,7 +53,7 @@ uintptr_t FindFreeRange(size_t ByteCount, int MaxBits)
 
        end <<= (sizeof(intptr_t)*8-MaxBits);
        end >>= (sizeof(intptr_t)*8-MaxBits);
-       printf("end = %p\n", (void*)end);
+//     printf("end = %p\n", (void*)end);
        
 //     for( base = 0; base < end - size; base -= PAGE_SIZE )
        for( base = end - size + 1; base > 0; base -= PAGE_SIZE )
index 9be93a7..4114eb0 100644 (file)
@@ -1,5 +1,6 @@
 
-CC = arm-elf-gcc
+ARM_CPUNAME = gerneric-armv7
+CC = arm-elf-gcc -mcpu=$(ARM_CPUNAME)
 AS = arm-elf-gcc -c
 LD = arm-elf-ld
 OBJDUMP = arm-elf-objdump
index 4b284ee..abb08e2 100644 (file)
@@ -1,5 +1,6 @@
 
 include $(ACESSDIR)/BuildConf/armv7/default.mk
 
+ARM_CPUNAME = cortex-a8
 MODULES += Input/PS2KbMouse
 MODULES += Display/PL110
index 4abc5c8..1bac800 100644 (file)
@@ -1,4 +1,5 @@
 
 include $(ACESSDIR)/BuildConf/armv7/default.mk
 
+ARM_CPUNAME = cortex-a9
 MODULES += Display/Tegra2Vid
index 2512f64..706ae3f 100644 (file)
@@ -55,7 +55,7 @@ OBJ += heap.o logging.o debug.o lib.o libc.o adt.o time.o
 OBJ += drvutil_video.o drvutil_disk.o
 OBJ += messages.o modules.o syscalls.o system.o
 OBJ += threads.o mutex.o semaphore.o workqueue.o events.o rwlock.o
-OBJ += drv/proc.o drv/fifo.o drv/iocache.o drv/pci.o
+OBJ += drv/zero-one.o drv/proc.o drv/fifo.o drv/iocache.o drv/pci.o
 OBJ += drv/vterm.o drv/vterm_font.o drv/vterm_vt100.o drv/vterm_output.o drv/vterm_input.o drv/vterm_termbuf.o
 OBJ += binary.o bin/elf.o bin/pe.o
 OBJ += vfs/main.o vfs/open.o vfs/acls.o vfs/dir.o vfs/io.o vfs/mount.o
index eb89139..0a19510 100644 (file)
@@ -61,8 +61,9 @@ int IRQ_AddHandler( int Num, void (*Callback)(int, void*), void *Ptr )
         int    i;
        for( i = 0; i < MAX_CALLBACKS_PER_IRQ; i++ )
        {
-               if( gIRQ_Handlers[Num][i] == NULL ) {
-//                     Log_Log("IRQ", "Added IRQ%i Cb#%i %p", Num, i, Callback);
+               if( gIRQ_Handlers[Num][i] == NULL )
+               {
+                       Log_Log("IRQ", "Added IRQ%i Cb#%i %p", Num, i, Callback);
                        gIRQ_Handlers[Num][i] = Callback;
                        gaIRQ_DataPointers[Num][i] = Ptr;
                        return 1;
index 5576811..49d7a1a 100644 (file)
@@ -10,6 +10,8 @@
 //#define USE_STACK    1
 #define TRACE_ALLOCS   0       // Print trace messages on AllocPhys/DerefPhys
 
+static const int addrClasses[] = {0,16,20,24,32,64};
+static const int numAddrClasses = sizeof(addrClasses)/sizeof(addrClasses[0]);
 
 // === IMPORTS ===
 extern char    gKernelEnd[];
@@ -28,6 +30,7 @@ tMutex        glPhysAlloc;
 Uint64 giPhysAlloc = 0;        // Number of allocated pages
 Uint64 giPageCount = 0;        // Total number of pages
 Uint64 giLastPossibleFree = 0; // Last possible free page (before all pages are used)
+Uint64 giTotalMemorySize = 0;  // Total number of allocatable pages
 
 Uint32 gaSuperBitmap[1024];    // Blocks of 1024 Pages
 Uint32 gaPageBitmap[1024*1024/32];     // Individual pages
@@ -53,8 +56,12 @@ void MM_Install(tMBoot_Info *MBoot)
                ent->Size += 4;
                
                // If entry is RAM and is above `maxAddr`, change `maxAddr`
-               if(ent->Type == 1 && ent->Base + ent->Length > maxAddr)
-                       maxAddr = ent->Base + ent->Length;
+               if(ent->Type == 1)
+               {
+                       if(ent->Base + ent->Length > maxAddr)
+                               maxAddr = ent->Base + ent->Length;
+                       giTotalMemorySize += ent->Length >> 12;
+               }
                // Go to next entry
                ent = (tMBoot_MMapEnt *)( (Uint)ent + ent->Size );
        }
@@ -111,10 +118,50 @@ void MM_Install(tMBoot_Info *MBoot)
        gaPageReferences = (void*)MM_REFCOUNT_BASE;
 
        Log_Log("PMem", "Physical memory set up (%lli pages of ~%lli MiB used)",
-               giPhysAlloc, (giPageCount*4)/1024
+               giPhysAlloc, (giTotalMemorySize*4)/1024
                );
 }
 
+void MM_DumpStatistics(void)
+{
+        int    i, pg;
+       for( i = 1; i < numAddrClasses; i ++ )
+       {
+                int    first = (i == 1 ? 0 : (1UL << (addrClasses[i-1] - 12)));
+                int    last  = (1UL << (addrClasses[i] - 12)) - 1;
+                int    nFree = 0;
+                int    nMultiRef = 0;
+                int    totalRefs = 0;
+
+               if( last > giPageCount )
+                       last = giPageCount;
+               
+                int    total = last - first + 1;
+       
+               for( pg = first; pg < last; pg ++ )
+               {
+                       if( !MM_GetPhysAddr(&gaPageReferences[pg]) || gaPageReferences[pg] == 0 ) {
+                               nFree ++;
+                               continue ;
+                       }
+                       totalRefs += gaPageReferences[pg];
+                       if(gaPageReferences[pg] > 1)
+                               nMultiRef ++;
+               }
+               
+                int    nUsed = (total - nFree);
+               Log_Log("MMPhys", "%ipbit - %i/%i used, %i reused, %i average reference count",
+                       addrClasses[i], nUsed, total, nMultiRef,
+                       nMultiRef ? (totalRefs-(nUsed - nMultiRef)) / nMultiRef : 0
+                       );
+               
+               if( last == giPageCount )
+                       break;
+       }
+       Log_Log("MMPhys", "%lli/%lli total pages used, 0 - %i possible free range",
+               giPhysAlloc, giTotalMemorySize, giLastPossibleFree);
+}
+
 /**
  * \fn tPAddr MM_AllocPhys(void)
  * \brief Allocates a physical page from the general pool
@@ -132,8 +179,6 @@ tPAddr MM_AllocPhys(void)
        // Classful scan
        #if 1
        {
-       const int addrClasses[] = {0,16,20,24,32,64};
-       const int numAddrClasses = sizeof(addrClasses)/sizeof(addrClasses[0]);
         int    i;
         int    first, last;
        for( i = numAddrClasses; i -- > 1; )
index bde7abd..633b167 100644 (file)
 #define BITS   64
 #define PAGE_SIZE      0x1000
 
+#ifndef MAX_CPUS
+# define MAX_CPUS      8
+#endif
+
 #define STACKED_LOCKS  2       // 0: No, 1: Per-CPU, 2: Per-Thread
 #define LOCK_DISABLE_INTS      0
 
index c2c215b..274b21c 100644 (file)
@@ -316,6 +316,11 @@ void MM_InitPhys_Multiboot(tMBoot_Info *MBoot)
        LEAVE('-');
 }
 
+void MM_DumpStatistics(void)
+{
+       // TODO: Statistics for x86_64 PMM
+}
+
 /**
  * \brief Allocate a contiguous range of physical pages with a maximum
  *        bit size of \a MaxBits
index 16da915..83dfa8a 100644 (file)
@@ -7,7 +7,7 @@
 #include <binary.h>\r
 \r
 #define _COMMON_H\r
-#define SysDebug(...)  LOG(v)\r
+#define SysDebug(v...) LOG(v)\r
 #define DISABLE_ELF64\r
 void   *GetSymbol(const char *Name, size_t *Size);\r
 void   *GetSymbol(const char *Name, size_t *Size) { Uint val; Binary_GetSymbol(Name, &val); if(Size)*Size=0; return (void*)val; };\r
@@ -50,7 +50,7 @@ tBinary *Elf_Load(int fp)
        switch(hdr.e_ident[4])  // EI_CLASS\r
        {\r
        case ELFCLASS32:\r
-               return Elf_Load32(fp, (Elf32_Ehdr*)&hdr);\r
+               return Elf_Load32(fp, (void*)&hdr);\r
        case ELFCLASS64:\r
                return Elf_Load64(fp, &hdr);\r
        default:\r
index 6a50ca2..dab20ad 100644 (file)
@@ -13,6 +13,7 @@
 extern void    Threads_Dump(void);
 extern void    KernelPanic_SetMode(void);
 extern void    KernelPanic_PutChar(char Ch);
+extern void    IPStack_SendDebugText(const char *Text);
 
 // === PROTOTYPES ===
 static void    Debug_Putchar(char ch);
@@ -30,11 +31,14 @@ volatile int        gbInPutChar = 0;
 #if LOCK_DEBUG_OUTPUT
 tShortSpinlock glDebug_Lock;
 #endif
+// - Disabled because it breaks shit
+ int   gbSendNetworkDebug = 0;
 
 // === CODE ===
 static void Debug_Putchar(char ch)
 {
        Debug_PutCharDebug(ch);
+       
        if( !gbDebug_IsKPanic )
        {
                if(gbInPutChar) return ;
@@ -45,6 +49,12 @@ static void Debug_Putchar(char ch)
        }
        else
                KernelPanic_PutChar(ch);
+       
+       if( gbSendNetworkDebug )
+       {
+               char str[2] = {ch, 0};
+               IPStack_SendDebugText(str);
+       }
 }
 
 static void Debug_Puts(int UseKTerm, const char *Str)
@@ -60,7 +70,10 @@ static void Debug_Puts(int UseKTerm, const char *Str)
        }
        else
                for( len = 0; Str[len]; len ++ );
-       
+
+       if( gbSendNetworkDebug )
+               IPStack_SendDebugText(Str);
+
        // Output to the kernel terminal
        if( UseKTerm && !gbDebug_IsKPanic && giDebug_KTerm != -1)
        {
@@ -79,9 +92,9 @@ void Debug_DbgOnlyFmt(const char *format, va_list args)
 void Debug_Fmt(int bUseKTerm, const char *format, va_list args)
 {
        char    buf[DEBUG_MAX_LINE_LEN];
-        int    len;
+//      int    len;
        buf[DEBUG_MAX_LINE_LEN-1] = 0;
-       len = vsnprintf(buf, DEBUG_MAX_LINE_LEN-1, format, args);
+       /*len = */vsnprintf(buf, DEBUG_MAX_LINE_LEN-1, format, args);
        //if( len < DEBUG_MAX_LINE )
                // do something
        Debug_Puts(bUseKTerm, buf);
diff --git a/KernelLand/Kernel/drv/zero-one.c b/KernelLand/Kernel/drv/zero-one.c
new file mode 100644 (file)
index 0000000..824f927
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * Acess2 Kernel
+ * - By John Hodge (thePowersGang)
+ *
+ * drv/zero-one.c
+ * - /Devices/{null,zero,one}
+ */
+#define DEBUG  0
+#include <acess.h>
+#include <modules.h>
+#include <fs_devfs.h>
+
+// === PROTOTYPES ===
+ int   CoreDevs_Install(char **Arguments);
+size_t CoreDevs_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer);
+size_t CoreDevs_Read_Zero(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer);
+size_t CoreDevs_Read_One (tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer);
+size_t CoreDevs_Read_Null(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer);
+
+// === GLOBALS ===
+MODULE_DEFINE(0, 0x0100, CoreDevs, CoreDevs_Install, NULL, NULL);
+tVFS_NodeType  gCoreDevs_NT_Null = {
+       .TypeName = "CoreDevs-null",
+       .Read  = CoreDevs_Read_Null,
+       .Write = CoreDevs_Write
+};
+tVFS_NodeType  gCoreDevs_NT_Zero = {
+       .TypeName = "CoreDevs-zero",
+       .Read  = CoreDevs_Read_Zero,
+       .Write = CoreDevs_Write
+};
+tVFS_NodeType  gCoreDevs_NT_One = {
+       .TypeName = "CoreDevs-one",
+       .Read  = CoreDevs_Read_One,
+       .Write = CoreDevs_Write
+};
+tDevFS_Driver  gCoreDevs_Null = {
+       NULL, "null",
+       {
+       .Size = 0,
+       .NumACLs = 1,
+       .ACLs = &gVFS_ACL_EveryoneRW,
+       .Type = &gCoreDevs_NT_Null
+       }
+};
+tDevFS_Driver  gCoreDevs_Zero = {
+       NULL, "zero",
+       {
+       .Size = 0,
+       .NumACLs = 1,
+       .ACLs = &gVFS_ACL_EveryoneRW,
+       .Type = &gCoreDevs_NT_Zero
+       }
+};
+tDevFS_Driver  gCoreDevs_One = {
+       NULL, "one",
+       {
+       .Size = 0,
+       .NumACLs = 1,
+       .ACLs = &gVFS_ACL_EveryoneRW,
+       .Type = &gCoreDevs_NT_One
+       }
+};
+
+// === CODE ===
+/**
+ * \brief Installs the CoreDevs driver
+ */
+int CoreDevs_Install(char **Options)
+{
+       DevFS_AddDevice( &gCoreDevs_Null );
+       DevFS_AddDevice( &gCoreDevs_Zero );
+       DevFS_AddDevice( &gCoreDevs_One  );
+       return MODULE_ERR_OK;
+}
+
+size_t CoreDevs_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer)
+{
+       return Length;  // Ignore
+}
+
+size_t CoreDevs_Read_Zero(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer)
+{
+       memset(Buffer, 0, Length);
+       return Length;
+}
+
+size_t CoreDevs_Read_One (tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer)
+{
+       Uint8   *ptr = Buffer;
+       size_t  rem;
+       for( rem = Length; rem --; ptr ++ )
+               *ptr = 0xFF;
+       return Length;
+}
+
+size_t CoreDevs_Read_Null(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer)
+{
+       return 0;
+}
+
index 6e63386..094f0b1 100644 (file)
@@ -58,6 +58,9 @@ int DrvUtil_Video_2DStream(void *Ent, const void *Buffer, int Length,
        const Uint8     *stream = Buffer;
         int    rem = Length;
         int    op;
+
+       Uint16  tmp[6];
+
        while( rem )
        {
                rem --;
@@ -83,7 +86,8 @@ int DrvUtil_Video_2DStream(void *Ent, const void *Buffer, int Length,
                case VIDEO_2DOP_NOP:    break;
                
                case VIDEO_2DOP_FILL:
-                       if(rem < 10)    return Length-rem;
+                       if(rem < 12)    return Length-rem;
+                       memcpy(tmp, stream, 6*2);
                        
                        if(!Handlers->Fill) {
                                Log_Warning("DrvUtil", "DrvUtil_Video_2DStream: Driver"
@@ -92,18 +96,18 @@ int DrvUtil_Video_2DStream(void *Ent, const void *Buffer, int Length,
                        }
                        
                        Handlers->Fill(
-                               Ent,
-                               ((const Uint16*)stream)[0], ((const Uint16*)stream)[1],
-                               ((const Uint16*)stream)[2], ((const Uint16*)stream)[3],
-                               ((const Uint32*)stream)[4]
+                               Ent, 
+                               tmp[0], tmp[1], tmp[2], tmp[3],
+                               tmp[4] | ((Uint32)tmp[5] << 16)
                                );
                        
-                       rem -= 10;
-                       stream += 10;
+                       rem -= 12;
+                       stream += 12;
                        break;
                
                case VIDEO_2DOP_BLIT:
                        if(rem < 12)    return Length-rem;
+                       memcpy(tmp, stream, 6*2);
                        
                        if(!Handlers->Blit) {
                                Log_Warning("DrvUtil", "DrvUtil_Video_2DStream: Driver"
@@ -113,9 +117,8 @@ int DrvUtil_Video_2DStream(void *Ent, const void *Buffer, int Length,
                        
                        Handlers->Blit(
                                Ent,
-                               ((const Uint16*)stream)[0], ((const Uint16*)stream)[1],
-                               ((const Uint16*)stream)[2], ((const Uint16*)stream)[3],
-                               ((const Uint16*)stream)[4], ((const Uint16*)stream)[5]
+                               tmp[0], tmp[1], tmp[2], tmp[3],
+                               tmp[4], tmp[5]
                                );
                        
                        rem -= 12;
index 0f21a1c..bb9dd4f 100644 (file)
@@ -84,6 +84,11 @@ extern void  MM_ClearUser(void);
  */
 extern void    MM_DumpTables(tVAddr Start, tVAddr End);
 
+/**
+ * \brief Dump physical memory usage statistics to the debug channel
+ */
+extern void    MM_DumpStatistics(void);
+
 /**
  * \brief Check if a buffer is valid (and all user if originally user)
  * \param Addr Base address
index 39444d9..cf3018f 100644 (file)
@@ -27,6 +27,7 @@
  int   MM_int_GetRangeID( tPAddr Addr );
  int   MM_int_GetMapEntry( void *Data, int Index, tPAddr *Start, tPAddr *Length );
 void   MM_Tpl_InitPhys(int MaxRAMPage, void *MemoryMap);
+void   MM_DumpStatistics(void);
 
 // === GLOBALS ===
 tMutex glPhysicalPages;
@@ -112,6 +113,11 @@ void MM_Tpl_InitPhys(int MaxRAMPage, void *MemoryMap)
        LEAVE('-');
 }
 
+void MM_DumpStatistics(void)
+{
+       // TODO: PM Statistics for tpl_mm_phys_bitmap
+}
+
 /**
  * \brief Allocate a contiguous range of physical pages with a maximum
  *        bit size of \a MaxBits
index 46ceb97..567cfaf 100644 (file)
@@ -78,6 +78,11 @@ void MM_Tpl_InitPhys(int MaxRAMPage)
        LEAVE('-');
 }
 
+void MM_DumpStatistics(void)
+{
+       // TODO: PM Statistics for tpl_mm_phys_bitmap
+}
+
 /**
  * \brief Allocate a contiguous range of physical pages with a maximum
  *        bit size of \a MaxBits
index 0977e28..91dcd69 100644 (file)
@@ -90,6 +90,11 @@ typedef struct sVFS_NodeType tVFS_NodeType;
  */
 typedef struct sVFS_Node
 {
+       /**
+        * \brief Functions associated with the node
+        */
+       tVFS_NodeType   *Type;
+       
        /**
         * \name Identifiers
         * \brief Fields used by the driver to identify what data this node
@@ -178,11 +183,6 @@ typedef struct sVFS_Node
        /**
         * \}
         */
-       
-       /**
-        * \brief Functions associated with the node
-        */
-       tVFS_NodeType   *Type;
 } tVFS_Node;
 
 /**
index b419be3..d067e49 100644 (file)
@@ -156,6 +156,8 @@ void Log_AddEvent(const char *Ident, int Level, const char *Format, va_list Args
  */
 void Log_Int_PrintMessage(tLogEntry *Entry)
 {
+       if( CPU_HAS_LOCK(&glLogOutput) )
+               return ;        // TODO: Error?
        SHORTLOCK( &glLogOutput );
        LogF("%s%014lli%s [%-8s] %i - %s",
                csaLevelColours[Entry->Level],
index e3e0ebe..8202b08 100644 (file)
@@ -351,9 +351,17 @@ int Module_LoadFile(const char *Path, const char *ArgString)
                Log_Warning("Module", "Module_LoadFile - Unable to load '%s'", Path);
                return 0;
        }
+
+       // TODO: I need a way of relocating the dependencies before everything else, so
+       // they can be resolved before any other link errors
+       if( !Binary_Relocate(base) ) {
+               Log_Warning("Relocation of module %s failed", Path);
+               Binary_Unload(base);
+               return 0;
+       }
        
        // Check for Acess Driver
-       if( Binary_FindSymbol(base, "DriverInfo", (Uint*)&info )  )
+       if( Binary_FindSymbol(base, "DriverInfo", (Uint*)&info ) == 0 )
        {
                for( loader = gModule_Loaders; loader; loader = loader->Next)
                {
@@ -375,12 +383,6 @@ int Module_LoadFile(const char *Path, const char *ArgString)
                return 0;
        }
 
-       if( !Binary_Relocate(base) ) {
-               Log_Warning("Relocation of module %s failed", Path);
-               Binary_Unload(base);
-               return 0;
-       }
-
        // Initialise (and register)
        if( loader ? loader->Loader(base) : Module_int_Initialise( info, ArgString ) )
        {
index e7cd4f7..ca7be3d 100644 (file)
@@ -28,6 +28,7 @@ $lStack = array( array("",array()) );
 foreach($lines as $line)
 {
        $line = trim($line);
+       if($line[0] == "#")     continue;
        // Directory
        if(preg_match('/^Dir\s+"([^"]+)"\s+{$/', $line, $matches))
        {
index 3ac0735..6751147 100644 (file)
@@ -36,3 +36,13 @@ Dir "Apps" {
                }
        }
 }
+#$Dir "Keen5" {
+#      File "keen5e" "/home/tpg/Projects/AcessPorts/omnispeak/bin/keen5e"
+#      File "EGADICT.CK5"  "/home/tpg/Projects/AcessPorts/omnispeak/bin/original/EGADICT.CK5"
+#      File "EGAGRAPH.CK5" "/home/tpg/Projects/AcessPorts/omnispeak/bin/original/EGAGRAPH.CK5"
+#      File "EGAHEAD.CK5"  "/home/tpg/Projects/AcessPorts/omnispeak/bin/original/EGAHEAD.CK5"
+#      File "GAMEMAPS.CK5" "/home/tpg/Projects/AcessPorts/omnispeak/bin/original/GAMEMAPS.CK5"
+#      File "GFXINFOE.CK5" "/home/tpg/Projects/AcessPorts/omnispeak/bin/original/GFXINFOE.CK5"
+#      File "MAPHEAD.CK5"  "/home/tpg/Projects/AcessPorts/omnispeak/bin/original/MAPHEAD.CK5"
+#      File "TILEINFO.CK5" "/home/tpg/Projects/AcessPorts/omnispeak/bin/original/TILEINFO.CK5"
+#}
index ab054ba..83741df 100644 (file)
@@ -79,9 +79,10 @@ void *IPStack_Adapter_Add(const tIPStack_AdapterType *Type, void *Ptr, const voi
        ret->Node.Type = &gIP_AdapterType;
        ret->Node.ImplPtr = ret;
 
-       // TODO: Locking
+       Mutex_Acquire( &glIP_Adapters );
        gpIP_AdapterList_Last->Next = ret;
        gpIP_AdapterList_Last = ret;
+       Mutex_Release( &glIP_Adapters );
        
        // Watch the adapter for incoming packets
        tTID tid = Proc_SpawnWorker(Adapter_int_WatchThread, ret);
@@ -314,3 +315,83 @@ int Adapter_int_LoopbackSendPacket(void *Unused, tIPStackBuffer *Buffer)
        return 0;
 }
 
+// --- Broadcast Debugging ---
+extern Uint16  IPv4_Checksum(const void *Buf, size_t Length);
+void IPStack_SendDebugText(const char *Text)
+{
+       const Uint8     pkt_hdr[] = {
+               0xFF,0xFF, 0xFF,0xFF, 0xFF,0xFF,
+               0x00,0x00, 0x00,0x00, 0x00,0x00,
+               0x08,0x00,
+               
+               0x45,0x00,      // Version/Length, DiffServices
+               0xFF,0xFF,      // Total Length
+               0x00,0x00,      // Identifcation
+               0x00,0x00, 0xFF,0x11,   // Flags,Fragment, TTL=255,proto=UDP
+               0x00,0x00,      // Header checksum
+               0x00,0x00,0x00,0x00,    // Source
+               0xFF,0xFF,0xFF,0xFF,    // Destination
+               
+               0x80,0x00, 0x80,0x00,
+               0xFF,0xFF, 0xFF,0xFF,
+       };
+       static tShortSpinlock   lLock;
+
+       // Fast return if there's no avaliable adapters
+       if( !gpIP_AdapterList )
+               return ;
+
+       if( CPU_HAS_LOCK(&lLock) )
+               return ;        // Nested!
+       SHORTLOCK(&lLock);
+       __asm__ __volatile__ ("sti");   // Start interrupts (x86 specific)
+
+       // Cache packets until a newline
+       static char     cache[1500 - (sizeof(pkt_hdr) + 4)];
+       static int      cache_len;
+       
+        int    len = strlen(Text);
+
+       // Append to cache
+       strncpy(cache + cache_len, Text, sizeof(cache) - cache_len);
+       cache_len += len;
+       // TODO: Detect overflows.
+       
+       // If there's no newline, only buffer
+       if( strpos(Text, '\n') == -1 ) {
+               SHORTREL(&lLock);
+               return ;
+       }
+
+       // Build packet
+        int    link_checksum_ofs = sizeof(pkt_hdr) + cache_len;
+       char    buffer[sizeof(pkt_hdr) + cache_len + 4];
+
+       memcpy(buffer, pkt_hdr, sizeof(pkt_hdr));
+       memcpy(buffer + sizeof(pkt_hdr), cache, cache_len);
+       
+       *(Uint16*)&buffer[14+2] = BigEndian16( sizeof(pkt_hdr)-14 + cache_len );        // IP Size
+       *(Uint16*)&buffer[14+10] = BigEndian16( 0 );    // IP Header
+       *(Uint16*)&buffer[14+20+4] = BigEndian16( 8+cache_len );        // UDP Size
+       *(Uint16*)&buffer[14+20+6] = BigEndian16( 0 );  // UDP Checksum
+       *(Uint32*)&buffer[link_checksum_ofs] = BigEndian32( 0 );        // 802.3 checksum?
+       // TODO: Calculate checksums
+       *(Uint16*)&buffer[14+10] = BigEndian16( IPv4_Checksum(buffer+14,20) );  // IP Header
+       
+       // Create buffer
+       tIPStackBuffer  *buf = IPStack_Buffer_CreateBuffer(1);
+       IPStack_Buffer_AppendSubBuffer(buf, link_checksum_ofs+4, 0, buffer, NULL, NULL);
+
+       // Send 'er off
+       for( tAdapter *a = gpIP_AdapterList; a; a = a->Next )
+       {
+               a->Type->SendPacket( a->CardHandle, buf );
+       }
+
+       IPStack_Buffer_DestroyBuffer(buf);
+
+       cache_len = 0;
+
+       SHORTREL(&lLock);
+}
+
index 8348106..f49d8ea 100644 (file)
@@ -16,6 +16,7 @@
 #include <Input/Keyboard/include/keyboard.h>
 #include "keymap_int.h"
 #include "layout_kbdus.h"
+#include <hal_proc.h>
 
 #define USE_KERNEL_MAGIC       1
 
@@ -280,6 +281,8 @@ void Keyboard_HandleKey(tKeyboard *Source, Uint32 HIDKeySym)
                case 'p':       Threads_Dump(); return;
                // Heap Statistics
                case 'h':       Heap_Stats();   return;
+               // PMem Statistics
+               case 'm':       MM_DumpStatistics();    return;
                // Dump Structure
                case 's':       return;
                }
index a8dd074..6e05bb4 100644 (file)
@@ -111,7 +111,7 @@ static inline void PL050_WriteKeyboardData(Uint8 Data)
                return ;
        }
 
-       while( --timeout && gpPL050_KeyboardBase[1] & PL050_TXBUSY );
+       while( --timeout && (gpPL050_KeyboardBase[1] & PL050_TXBUSY) );
        if(timeout)
                gpPL050_KeyboardBase[2] = Data;
        else
index d0fe6c9..a1686f7 100644 (file)
@@ -84,6 +84,7 @@ int Rhine2_Install(char **Options)
        tCard   *card;
        
        giRhine2_CardCount = PCI_CountDevices(VENDOR_ID, DEVICE_ID);
+       Log_Debug("Rhine2", "giRhine2_CardCount = %i", giRhine2_CardCount);
        if( giRhine2_CardCount == 0 )   return MODULE_ERR_NOTNEEDED;
        
        gaRhine2_Cards = calloc( giRhine2_CardCount, sizeof(tCard) );
index b8a15d0..89f1a46 100644 (file)
@@ -371,6 +371,10 @@ int ATA_ReadDMA(Uint8 Disk, Uint64 Address, Uint Count, void *Buffer)
        {
                HALT();
        }
+       
+       if( now() >= timeoutTime ) {
+               Log_Notice("ATA", "Timeout of %i ms exceeded", ATA_TIMEOUT);
+       }
 
        // Complete Transfer
        ATA_int_BusMasterWriteByte( cont * 8, 8 );      // Read and stop
index 44c2e57..b3b9c6c 100644 (file)
@@ -151,7 +151,7 @@ char *LVM_Vol_ReadDir(tVFS_Node *Node, int ID)
                return NULL;
 
        if( ID == 0 )
-               return strdup(".volume");
+               return strdup("ROOT");
        else
                return strdup( vol->SubVolumes[ID-1]->Name );
 }
@@ -159,7 +159,7 @@ tVFS_Node *LVM_Vol_FindDir(tVFS_Node *Node, const char *Name)
 {
        tLVM_Vol        *vol = Node->ImplPtr;
 
-       if( strcmp(".volume", Name) == 0 )
+       if( strcmp("ROOT", Name) == 0 )
                return &vol->VolNode;
        
        for( int i = 0; i < vol->nSubVolumes; i ++ )
index f15b1b0..c9ce9a8 100644 (file)
@@ -56,6 +56,7 @@ int LVM_AddVolume(const tLVM_VolType *Type, const char *Name, void *Ptr, size_t
        real_vol->BlockCount = BlockCount;
        real_vol->nSubVolumes = dummy_vol.nSubVolumes;
        real_vol->SubVolumes = (void*)( real_vol->Name + strlen(Name) + 1 );
+       real_vol->BlockSize = BlockSize;
        strcpy(real_vol->Name, Name);
        memset(real_vol->SubVolumes, 0, sizeof(tLVM_SubVolume*) * real_vol->nSubVolumes);
        // - VFS Nodes
index f506599..e952a3a 100755 (executable)
@@ -12,6 +12,11 @@ _NETTYPE="user"
 
 while [ $# -ne 0 ]; do
        case $1 in
+       -raspberrypi)
+               _SYSTEM="versatilepb"
+               QEMU_PARAMS=$QEMU_PARAMS" -cpu arm1176 -m 192 -localtime"
+               _KERNEL=Acess2.armv6-raspberrypi.bin
+               ;;
        -gdb)
                QEMU_PARAMS=$QEMU_PARAMS" -s -S"
                ;;
@@ -31,7 +36,7 @@ while [ $# -ne 0 ]; do
        esac
        shift
 done
-QEMU_PARAMS="-M $_SYSTEM -kernel $_KERNEL -net nic -net $_NETTYPE"$QEMU_PARAMS
+QEMU_PARAMS="-M $_SYSTEM -kernel KernelLand/$_KERNEL -net nic -net $_NETTYPE"$QEMU_PARAMS
 
 #      /home/tpg/apps/bin/qemu-system-x86_64 $QEMU_PARAMS -serial stdio -serial file:QemuLog.txt
 #      qemu-system-x86_64 $QEMU_PARAMS -serial stdio | tee QemuLog.txt
index cc72bf8..e5ef7ea 100644 (file)
@@ -8,7 +8,7 @@ ASFLAGS = -felf
 CPPFLAGS = -ffreestanding -I$(ACESSUSERDIR)/include/ -DARCHDIR_is_$(ARCHDIR)
 CPPFLAGS += $(addprefix -I,$(wildcard $(ACESSUSERDIR)Libraries/*/include_exp/))
 CFLAGS   = -fno-stack-protector $(CPPFLAGS)
-LDFLAGS  = -T $(OUTPUTDIR)Libs/acess.ld -rpath-link $(OUTPUTDIR)Libs -L $(OUTPUTDIR)Libs -I /Acess/Libs/ld-acess.so -lld-acess -lc $(OUTPUTDIR)Libs/crtbegin.o $(OUTPUTDIR)Libs/crtend.o
+LDFLAGS  = -T $(OUTPUTDIR)Libs/acess.ld -rpath-link $(OUTPUTDIR)Libs -L $(OUTPUTDIR)Libs -I /Acess/Libs/ld-acess.so -lld-acess -lc $(OUTPUTDIR)Libs/crtbegin.o $(OUTPUTDIR)Libs/crtend.o `$(CC) -print-libgcc-file-name`
 
 # Extra-verbose errors!
 #CFLAGS += -Wall -Wextra -Wwrite-strings -Wshadow -Wswitch-default -Wswitch-enum -Wstrict-overflow=5 -Wfloat-equal -Wundef -Wmissing-declarations -Wlogical-op
index 6239b76..14c0414 100644 (file)
@@ -64,14 +64,17 @@ void Decorator_Redraw(tWindow *Window)
        }
 
        // Draw title bar
+       // - Body
        WM_Render_FillRect(Window,
                0, -ciTitlebarHeight, Window->W, ciTitlebarHeight,
                (bActive ? cColourActive_Titlebar : cColourInactive_Titlebar)
                );
+       // - Top Border
        WM_Render_FillRect(Window,
                0, -ciTitlebarHeight, Window->W, 1,
                cColour_TitleTopBorder
                );
+       // - Sides
        WM_Render_FillRect(Window,
                0, -ciTitlebarHeight, 1, ciTitlebarHeight,
                cColour_SideBorder
@@ -81,11 +84,13 @@ void Decorator_Redraw(tWindow *Window)
                cColour_SideBorder
                );
 
+       // Get the font height
        WM_Render_GetTextDims(
                NULL,   // TODO: Select font
                Window->Title ? Window->Title : "jI", -1,
                &text_width, &text_height
                );
+       // - Use that to draw the window title on the left of the window
        WM_Render_DrawText(Window,
                ciTitlebarHeight + 4, -(ciTitlebarHeight - (ciTitlebarHeight/2 - text_height/2)),
                Window->W - ciTitlebarHeight - 4, text_height,
@@ -93,29 +98,32 @@ void Decorator_Redraw(tWindow *Window)
                (bActive ? cColourActive_TitleText : cColourInactive_TitleText),
                Window->Title ? Window->Title : "--", -1
                );
-       
+
+       // TODO: Minimise, Maximise and Close   
+
        // Maximized windows don't have any other borders
        if( Window->Flags & WINFLAG_MAXIMIZED )
                return ;
        
-       // Left
+       // Left Border
        WM_Render_FillRect(Window,
                -ciSideBorderWidth, -ciTitlebarHeight,
                ciSideBorderWidth, Window->H + ciTitlebarHeight + ciBottomBorderWidth,
                cColour_SideBorder
                );
-       // Right
+       // Right Border
        WM_Render_FillRect(Window,
                Window->W, -ciTitlebarHeight,
                ciSideBorderWidth, Window->H + ciTitlebarHeight + ciBottomBorderWidth,
                cColour_SideBorder
                );
-       // Bottom
+       // Bottom Border (hard line)
        WM_Render_FillRect(Window,
                -ciSideBorderWidth, Window->H,
                ciSideBorderWidth*2+Window->W, 1,
                0x000000
                );
+       // Bottom Border
        WM_Render_FillRect(Window,
                -ciSideBorderWidth, Window->H+1,
                ciSideBorderWidth*2+Window->W, ciBottomBorderWidth-1,
index 92f8984..b3648bb 100644 (file)
@@ -75,30 +75,40 @@ void IPC_Init(void)
         int    tmp;
        // TODO: Check this
        giNetworkFileHandle = open("/Devices/ip/loop/udp", OPENFLAG_READ);
-       tmp = AXWIN_PORT;       ioctl(giNetworkFileHandle, 4, &tmp);    // TODO: Don't hard-code IOCtl number
+       if( giNetworkFileHandle != -1 )
+       {
+               tmp = AXWIN_PORT;
+               ioctl(giNetworkFileHandle, 4, &tmp);    // TODO: Don't hard-code IOCtl number
+       }
 }
 
 void IPC_FillSelect(int *nfds, fd_set *set)
 {
-       if( giNetworkFileHandle > *nfds )       *nfds = giNetworkFileHandle;
-       FD_SET(giNetworkFileHandle, set);
+       if( giNetworkFileHandle != -1 )
+       {
+               if( giNetworkFileHandle > *nfds )       *nfds = giNetworkFileHandle;
+               FD_SET(giNetworkFileHandle, set);
+       }
 }
 
 void IPC_HandleSelect(fd_set *set)
 {
-       if( FD_ISSET(giNetworkFileHandle, set) )
+       if( giNetworkFileHandle != -1 )
        {
-               char    staticBuf[STATICBUF_SIZE];
-                int    readlen, identlen;
-               char    *msg;
-
-               readlen = read(giNetworkFileHandle, staticBuf, sizeof(staticBuf));
-               
-               identlen = 4 + Net_GetAddressSize( ((uint16_t*)staticBuf)[1] );
-               msg = staticBuf + identlen;
-
-               IPC_Handle(&gIPC_Type_Datagram, staticBuf, readlen - identlen, (void*)msg);
-//             _SysDebug("IPC_HandleSelect: UDP handled");
+               if( FD_ISSET(giNetworkFileHandle, set) )
+               {
+                       char    staticBuf[STATICBUF_SIZE];
+                        int    readlen, identlen;
+                       char    *msg;
+       
+                       readlen = read(giNetworkFileHandle, staticBuf, sizeof(staticBuf));
+                       
+                       identlen = 4 + Net_GetAddressSize( ((uint16_t*)staticBuf)[1] );
+                       msg = staticBuf + identlen;
+       
+                       IPC_Handle(&gIPC_Type_Datagram, staticBuf, readlen - identlen, (void*)msg);
+//                     _SysDebug("IPC_HandleSelect: UDP handled");
+               }
        }
 
        while(SysGetMessage(NULL, NULL))
index 3e6af58..5b513de 100644 (file)
@@ -34,13 +34,24 @@ void Video_Setup(void)
         int    tmpInt;
        
        // Open terminal
+       #if 0
        giTerminalFD = open(gsTerminalDevice, OPENFLAG_READ|OPENFLAG_WRITE);
        if( giTerminalFD == -1 )
        {
                fprintf(stderr, "ERROR: Unable to open '%s' (%i)\n", gsTerminalDevice, _errno);
                exit(-1);
        }
-       
+       #else
+       giTerminalFD = 1;
+       // Check that the console is a VT
+       // - ioctl(..., 0, NULL) returns the type, which should be 2
+       if( ioctl(1, 0, NULL) != 2 )
+       {
+               fprintf(stderr, "stdout is not an Acess VT, can't start");
+               _SysDebug("stdout is not an Acess VT, can't start");
+               exit(-1);
+       }
+       #endif
        
        // Set mode to video
        tmpInt = TERM_MODE_FB;
@@ -70,11 +81,12 @@ void Video_Update(void)
        
        if( giVideo_LastDirtyLine == 0 )        return; 
 
-//     _SysDebug("Video_Update - Updating lines %i to %i (0x%x+0x%x px)",
-//             giVideo_FirstDirtyLine, giVideo_LastDirtyLine, ofs, size);
+       _SysDebug("Video_Update - Updating lines %i to %i (0x%x+0x%x px)",
+               giVideo_FirstDirtyLine, giVideo_LastDirtyLine, ofs, size);
        seek(giTerminalFD, ofs*4, 1);
+       _SysDebug("Video_Update - Sending");
        write(giTerminalFD, gpScreenBuffer+ofs, size*4);
-//     _SysDebug("Video_Update - Done");
+       _SysDebug("Video_Update - Done");
        giVideo_FirstDirtyLine = 0;
        giVideo_LastDirtyLine = 0;
 }
index 4625db7..2b50167 100644 (file)
@@ -16,6 +16,7 @@
 // === CONSTANTS ===
 enum eConnectionType
 {
+       CONNTYPE_NONE,
        CONNTYPE_SENDMESSAGE,
        CONNTYPE_UDP,
        CONNTYPE_TCP
index f420eb8..4dff114 100644 (file)
@@ -3,7 +3,7 @@
 include $(BASE)header.mk
 
 # Variables
-SRCS := main.c
+SRCS := main.c addr.c routes.c
 BIN  := $(OUTPUTDIR)Bin/ifconfig
 
 LDFLAGS-$(DIR) += -lnet
index fb4d8eb..5779b3d 100644 (file)
@@ -2,7 +2,8 @@ include $(BASE)header.mk
 
 # Rules
 ASFLAGS-$(DIR)  := -felf -D ARCHDIR=$(ARCHDIR) -D __ASSEMBLER__=1
-CPPFLAGS-$(DIR) := -I$(ACESSDIR)/Usermode/include/ -DARCHDIR=$(ARCHDIR) -DARCHDIR_is_$(ARCHDIR)=1
+CPPFLAGS-$(DIR) := -ffreestanding -I$(ACESSDIR)/Usermode/include/ -DARCHDIR=$(ARCHDIR) -DARCHDIR_is_$(ARCHDIR)=1
+CPPFLAGS-$(DIR) += $(addprefix -I,$(wildcard $(ACESSUSERDIR)Libraries/*/include_exp/))
 CFLAGS-$(DIR)   := -g -Wall -fno-stack-protector -O3
 LDFLAGS-$(DIR)  := -T $(OUTPUTDIR)Libs/acess.ld -rpath-link $(OUTPUTDIR)Libs -L $(OUTPUTDIR)Libs -I /Acess/Libs/ld-acess.so -lld-acess -lc $(OUTPUTDIR)Libs/crtbegin.o $(OUTPUTDIR)Libs/crtend.o
 
index 5084374..69c9ab7 100644 (file)
@@ -84,7 +84,7 @@ int main(int argc, char *argv[])
                        continue ;
                }
 
-               rv = getaddrinfo(uri->Host, NULL, NULL, &addrinfo);
+               rv = getaddrinfo(uri->Host, "http", NULL, &addrinfo);
                if( rv != 0 ) {
                        fprintf(stderr, "Unable to resolve %s: %s\n", uri->Host, gai_strerror(rv));
                        continue ;
index c775d63..4aafe56 100644 (file)
@@ -9,4 +9,4 @@ ASFLAGS  += -D ARCHDIR=$(ARCHDIR) -D __ASSEMBLER__=1
 CPPFLAGS := -ffreestanding -I$(ACESSDIR)/Usermode/include/ -DARCHDIR=$(ARCHDIR) -DARCHDIR_is_$(ARCHDIR)=1
 CPPFLAGS += $(addprefix -I,$(wildcard $(ACESSUSERDIR)Libraries/*/include_exp/))
 CFLAGS   := -g -Wall -fPIC -fno-stack-protector -O3
-LDFLAGS  := -g -nostdlib -shared -I/Acess/Libs/ld-acess.so -lld-acess -e SoMain -x -L$(OUTPUTDIR)Libs/ --no-undefined
+LDFLAGS  := -g -nostdlib -shared -I/Acess/Libs/ld-acess.so -lld-acess -e SoMain -x -L$(OUTPUTDIR)Libs/ --no-undefined `$(CC) -print-libgcc-file-name`
index bbe45d6..92237ea 100644 (file)
@@ -5,7 +5,9 @@
  * elf.c
  * - ELF32/ELF64 relocation
  */
-#define DEBUG  0
+#ifndef DEBUG  // This code is #include'd from the kernel, so DEBUG may already be defined
+# define DEBUG 0
+#endif
 
 #include "common.h"
 #include <stdint.h>
@@ -481,11 +483,20 @@ int Elf32GetSymbol(void *Base, const char *Name, void **ret, size_t *Size)
                return 0;
        }
 
+       // ... ok... maybe they haven't been relocated
+       if( (uintptr_t)symtab < (uintptr_t)Base )
+       {
+               symtab    = (void*)( (uintptr_t)symtab    + iBaseDiff );
+               pBuckets  = (void*)( (uintptr_t)pBuckets  + iBaseDiff );
+               dynstrtab = (void*)( (uintptr_t)dynstrtab + iBaseDiff );
+               SysDebug("Executable not yet relocated");
+       }
+
        nbuckets = pBuckets[0];
 //     iSymCount = pBuckets[1];
        pBuckets = &pBuckets[2];
        pChains = &pBuckets[ nbuckets ];
-       
+
        // Get hash
        iNameHash = ElfHashString(Name);
        iNameHash %= nbuckets;
index 191f526..ddd1234 100644 (file)
@@ -134,3 +134,7 @@ EXPORT int atoi(const char *str)
        if(neg) ret = -ret;\r
        return ret;\r
 }\r
+\r
+int abs(int j) { return j < 0 ? -j : j; }\r
+long int labs(long int j) { return j < 0 ? -j : j; }\r
+\r
index 4786df9..5bac18f 100644 (file)
@@ -4,7 +4,8 @@ include $(BASE)header.mk
 
 # Rules
 ASFLAGS-$(DIR)  := -D ARCHDIR=$(ARCHDIR) -D __ASSEMBLER__=1
-CPPFLAGS-$(DIR) := -I$(ACESSDIR)/Usermode/include/ -DARCHDIR=$(ARCHDIR) -DARCHDIR_is_$(ARCHDIR)=1
+CPPFLAGS-$(DIR) := -ffreestanding -I$(ACESSDIR)/Usermode/include/ -DARCHDIR=$(ARCHDIR) -DARCHDIR_is_$(ARCHDIR)=1
+CPPFLAGS-$(DIR) += $(addprefix -I,$(wildcard $(ACESSUSERDIR)Libraries/*/include_exp/))
 CFLAGS-$(DIR)   := -g -Wall -fPIC -fno-stack-protector -O3
 LDFLAGS-$(DIR)  := -g -nostdlib -shared -I/Acess/Libs/ld-acess.so -lld-acess -e SoMain -x -L$(OUTPUTDIR)Libs/ --no-undefined
 

UCC git Repository :: git.ucc.asn.au