* Acess2
* Common Binary Loader
*/
-#define DEBUG 0
+#define DEBUG 1
#include <acess.h>
#include <binary.h>
#include <mm_virt.h>
Uint Binary_FindSymbol(void *Base, char *Name, Uint *Val);
// === GLOBALS ===
- int glBinListLock = 0;
+tShortSpinlock glBinListLock;
tBinary *glLoadedBinaries = NULL;
char **gsaRegInterps = NULL;
int giRegInterps = 0;
- int glKBinListLock = 0;
+tShortSpinlock glKBinListLock;
tKernelBin *glLoadedKernelLibs;
tBinaryType *gRegBinTypes = &gELF_Info;
argenvBuf = malloc(argenvBytes);
if(argenvBuf == NULL) {
Log_Error("BIN", "Proc_Execve - What the hell? The kernel is out of heap space");
+ LEAVE('i', 0);
return 0;
}
strBuf = argenvBuf + (argc+1)*sizeof(void*) + (envc+1)*sizeof(void*);
if(bases[0] == 0)
{
Log_Warning("BIN", "Proc_Execve - Unable to load '%s'", Threads_GetName(-1));
+ LEAVE('-');
Threads_Exit(0, 0);
for(;;);
}
/**
* \fn Uint Binary_Load(char *file, Uint *entryPoint)
+ * \brief Load a binary into the current address space
+ * \param file Path to binary to load
+ * \param entryPoint Pointer for exectuable entry point
*/
Uint Binary_Load(char *file, Uint *entryPoint)
{
tBinary *pBinary;
Uint base = -1;
- ENTER("sfile", file);
+ ENTER("sfile pentryPoint", file, entryPoint);
// Sanity Check Argument
if(file == NULL) {
// Get True File Path
sTruePath = VFS_GetTruePath(file);
+ LOG("sTruePath = %p", sTruePath);
if(sTruePath == NULL) {
Log_Warning("BIN", "'%s' does not exist.", file);
}
LOG("sTruePath = '%s'", sTruePath);
+
+ // TODO: Also get modifcation time
// Check if the binary has already been loaded
if( !(pBinary = Binary_GetInfo(sTruePath)) )
VFS_Close(fp);
// Add to the list
- LOCK(&glBinListLock);
+ SHORTLOCK(&glBinListLock);
pBinary->Next = glLoadedBinaries;
glLoadedBinaries = pBinary;
- RELEASE(&glBinListLock);
+ SHORTREL(&glBinListLock);
// Return
LEAVE('p', pBinary);
pKBinary = malloc(sizeof(*pKBinary));
pKBinary->Base = (void*)base;
pKBinary->Info = pBinary;
- LOCK( &glKBinListLock );
+ SHORTLOCK( &glKBinListLock );
pKBinary->Next = glLoadedKernelLibs;
glLoadedKernelLibs = pKBinary;
- RELEASE( &glKBinListLock );
+ SHORTREL( &glKBinListLock );
LEAVE('p', base);
return (void*)base;