strcpy(stackPath, Path);
- LOG("stackPath = '%s'\n", stackPath);
+ LOG("stackPath = '%s'", stackPath);
if(Proc_Clone(CLONE_VM) == 0)
{
// CHILD
const char *args[2] = {stackPath, NULL};
- LOG("stackPath = '%s'\n", stackPath);
+ LOG("stackPath = '%s'", stackPath);
Proc_Execve(stackPath, args, &args[1]);
for(;;);
}
{
tVAddr base;
int i, fd;
+
+ ENTER("pBinary sPath pLoadMin pLoadMax", Binary, Path, LoadMin, LoadMax);
+
// Reference Executable (Makes sure that it isn't unloaded)
Binary->ReferenceCount ++;
// Error Check
if(base < LoadMin) {
Log_Warning("Binary", "Executable '%s' cannot be loaded, no space", Path);
+ LEAVE('i', 0);
return 0;
}
//LOG("*0x%x = 0x%x\n", binary->Pages[0].Virtual, *(Uint*)binary->Pages[0].Virtual);
+ LEAVE('p', base);
return base;
}
Uint ident;
tBinaryType *bt = gRegBinTypes;
- ENTER("iMountID XInode sPath", Path);
+ ENTER("iMountID XInode sPath", MountID, Inode, Path);
// Open File
fp = VFS_OpenInode(MountID, Inode, VFS_OPENFLAG_READ);
Proc_CallFaultHandler(thread);
}
+extern void MM_DumpTables(tVAddr Start, tVAddr End);
+
/**
* \fn void Threads_SegFault(tVAddr Addr)
* \brief Called when a Segment Fault occurs
*/
void Threads_SegFault(tVAddr Addr)
{
- Warning("Thread #%i committed a segfault at address %p", Proc_GetCurThread()->TID, Addr);
+ Log_Warning("Threads", "Thread #%i committed a segfault at address %p", Proc_GetCurThread()->TID, Addr);
+ MM_DumpTables(0, 0xC0000000);
Threads_Fault( 1 );
//Threads_Exit( 0, -1 );
}
#include <vfs_int.h>
#define MMAP_PAGES_PER_BLOCK 16
-#define PAGE_SIZE 0x1000 // Should be in mm_virt.h
// === STRUCTURES ===
typedef struct sVFS_MMapPageBlock tVFS_MMapPageBlock;
tVAddr mapping_dest;
int npages, pagenum;
tVFS_MMapPageBlock *pb, *prev;
+
+ ENTER("pDestHint iLength xProtection xFlags xFD XOffset", DestHint, Length, Protection, Flags, FD, Offset);
- npages = ((Offset & (PAGE_SIZE-1)) + Length) / PAGE_SIZE;
+ npages = ((Offset & (PAGE_SIZE-1)) + Length + (PAGE_SIZE - 1)) / PAGE_SIZE;
pagenum = Offset / PAGE_SIZE;
mapping_dest = (tVAddr)DestHint;
-#if 0
// TODO: Locate space for the allocation
- if( Flags & MAP_ANONYMOUS )
+
+ // Handle anonymous mappings
+ if( Flags & MMAP_MAP_ANONYMOUS )
{
- MM_Allocate(mapping_dest);
- return (void*)mapping_dest;
+ int i;
+ for( i = 0; i < npages; i ++ ) {
+ tPAddr rv = MM_Allocate(mapping_dest + i * PAGE_SIZE);
+ if( !rv ) {
+ // TODO: Error
+ }
+ }
+ LEAVE_RET('p', (void*)mapping_dest);
}
-#endif
h = VFS_GetHandle(FD);
- if( !h || !h->Node ) return NULL;
+ if( !h || !h->Node ) LEAVE_RET('n', NULL);
+
+ LOG("h = %p", h);
// Search for existing mapping for each page
// - Sorted list of 16 page blocks
{
void *old_pb = pb;
pb = malloc( sizeof(tVFS_MMapPageBlock) );
- if(!pb) return NULL;
+ if(!pb) LEAVE_RET('n', NULL);
pb->Next = old_pb;
pb->BaseOffset = pagenum - pagenum % MMAP_PAGES_PER_BLOCK;
memset(pb->PhysAddrs, 0, sizeof(pb->PhysAddrs));
pagenum = 0;
}
}
-
+
+ LEAVE('n');
return NULL;
}
int VFS_int_CreateHandle( tVFS_Node *Node, tVFS_Mount *Mount, int Mode )
{
int i;
+
+ ENTER("pNode pMount iMode", Node, Mount, Mode);
+
i = 0;
i |= (Mode & VFS_OPENFLAG_EXEC) ? VFS_PERM_EXECUTE : 0;
i |= (Mode & VFS_OPENFLAG_READ) ? VFS_PERM_READ : 0;
tVFS_Mount *mnt;
tVFS_Node *node;
- ENTER("iMount iInode xMode", Mount, Inode, Mode);
+ ENTER("iMount XInode xMode", Mount, Inode, Mode);
// Get mount point
mnt = VFS_GetMountByIdent(Mount);
// Does the filesystem support this?
if( !mnt->Filesystem->GetNodeFromINode ) {
+ LOG("Filesystem does not support inode accesses");
errno = ENOENT;
LEAVE_RET('i', -1);
}
// Get node
node = mnt->Filesystem->GetNodeFromINode(mnt->RootNode, Inode);
if( !node ) {
+ LOG("Unable to find inode");
errno = ENOENT;
LEAVE_RET('i', -1);
}