--- /dev/null
+
+all:
+ @$(MAKE) -C acesskernel_src
+ @$(MAKE) -C ld-acess_src
#!/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
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
//#define NUM_CFG_ENTRIES 10
+extern void Debug_PutCharDebug(char ch);
+extern void Debug_PutStringDebug(const char *str);
+
#endif
--- /dev/null
+#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
+
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",
);
}
-
+ // Get the response
+ retHeader = SyscallRecieve(Client->CurrentRequest, &retSize);
+
if( !retHeader ) {
// Return an error to the client
printf("ERROR: SyscallRecieve failed\n");
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);
*
* Syscall Distribution
*/
-#define DEBUG 1
+#define DEBUG 0
#include <acess.h>
#include <threads.h>
#include <events.h>
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,
}
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];
}
// 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);
#include <mutex.h>
#include <semaphore.h>
#include <events.h>
+#include <threads_int.h>
#undef CLONE_VM // Such a hack
#undef off_t
} 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);
.MaxFD = 100
};
tThread gThreadZero = {
- .State=1,
+ .Status=THREAD_STAT_ACTIVE,
.ThreadName="ThreadZero",
.Process = &gProcessZero
};
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;
}
if(!thread) return -1;
us->Next = NULL;
- us->State = 3;
+ us->Status = THREAD_STAT_WAITING;
// TODO: Locking
if(thread->WaitingThreadsEnd)
{
int Threads_Wake(tThread *Thread)
{
- Thread->State = 0;
+ Thread->Status = THREAD_STAT_ACTIVE;
Threads_PostEvent(Thread, THREAD_EVENT_WAKEUP);
return 0;
}
return thread->PID;
}
+// --------------------------------------------------------------------
+// Mutexes
+// --------------------------------------------------------------------
int Mutex_Acquire(tMutex *Mutex)
{
if(!Mutex->Protector.IsValid) {
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));
return AmmountToAdd;
}
+// --------------------------------------------------------------------
+// Event handling
+// --------------------------------------------------------------------
Uint32 Threads_WaitEvents(Uint32 Mask)
{
Uint32 rv;
}
}
+void Threads_ClearEvent(Uint32 EventMask)
+{
+ gpCurrentThread->Events &= ~EventMask;
+}
+
--- /dev/null
+/*
+ * 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)
+{
+}
/*
- * 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>
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);
}
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
#if DEBUG
printf("Calling '%s' entry point %p\n", Name, entry);
#endif
- entry(ret, 0, argv, NULL);
+ entry(ret, 0, argv, gEnvP);
}
return ret;
*\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
\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
* - 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>
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);
}
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
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;
va_start(args, Format);
- printf("[_SysDebug %i]", giSyscall_ClientID);
+ printf("[_SysDebug %i] ", giSyscall_ClientID);
vprintf(Format, args);
printf("\n");
// === 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)
{
int (*appMain)(int, char *[], char **);
void *base;
int rv;
+
+ gEnvP = envp;
Request_Preinit();
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 )
-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
include $(ACESSDIR)/BuildConf/armv7/default.mk
+ARM_CPUNAME = cortex-a8
MODULES += Input/PS2KbMouse
MODULES += Display/PL110
include $(ACESSDIR)/BuildConf/armv7/default.mk
+ARM_CPUNAME = cortex-a9
MODULES += Display/Tegra2Vid
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
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;
//#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[];
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
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 );
}
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
// 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; )
#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
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
#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
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
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);
#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 ;
}
else
KernelPanic_PutChar(ch);
+
+ if( gbSendNetworkDebug )
+ {
+ char str[2] = {ch, 0};
+ IPStack_SendDebugText(str);
+ }
}
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)
{
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);
--- /dev/null
+/*
+ * 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;
+}
+
const Uint8 *stream = Buffer;
int rem = Length;
int op;
+
+ Uint16 tmp[6];
+
while( rem )
{
rem --;
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"
}
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"
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;
*/
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
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;
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
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
*/
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
/**
* \}
*/
-
- /**
- * \brief Functions associated with the node
- */
- tVFS_NodeType *Type;
} tVFS_Node;
/**
*/
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],
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)
{
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 ) )
{
foreach($lines as $line)
{
$line = trim($line);
+ if($line[0] == "#") continue;
// Directory
if(preg_match('/^Dir\s+"([^"]+)"\s+{$/', $line, $matches))
{
}
}
}
+#$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"
+#}
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);
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);
+}
+
#include <Input/Keyboard/include/keyboard.h>
#include "keymap_int.h"
#include "layout_kbdus.h"
+#include <hal_proc.h>
#define USE_KERNEL_MAGIC 1
case 'p': Threads_Dump(); return;
// Heap Statistics
case 'h': Heap_Stats(); return;
+ // PMem Statistics
+ case 'm': MM_DumpStatistics(); return;
// Dump Structure
case 's': return;
}
return ;
}
- while( --timeout && gpPL050_KeyboardBase[1] & PL050_TXBUSY );
+ while( --timeout && (gpPL050_KeyboardBase[1] & PL050_TXBUSY) );
if(timeout)
gpPL050_KeyboardBase[2] = Data;
else
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) );
{
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
return NULL;
if( ID == 0 )
- return strdup(".volume");
+ return strdup("ROOT");
else
return strdup( vol->SubVolumes[ID-1]->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 ++ )
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
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"
;;
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
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
}
// 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
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,
(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,
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))
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;
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;
}
// === CONSTANTS ===
enum eConnectionType
{
+ CONNTYPE_NONE,
CONNTYPE_SENDMESSAGE,
CONNTYPE_UDP,
CONNTYPE_TCP
include $(BASE)header.mk
# Variables
-SRCS := main.c
+SRCS := main.c addr.c routes.c
BIN := $(OUTPUTDIR)Bin/ifconfig
LDFLAGS-$(DIR) += -lnet
# 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
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 ;
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`
* 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>
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;
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
# 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