X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Fvfs%2Fmmap.c;h=7c3fdf4bc5c16f88936adac4d29023daf8765e7a;hb=9dc3cf2a69c5c4563091f37a06eece1723f51d0d;hp=dbdd4b2a9b7234ac6b8e2d05fafbd66f23a4d96c;hpb=e9391ef54c88fb5180d6330a7a1b43c3115befb8;p=tpg%2Facess2.git diff --git a/Kernel/vfs/mmap.c b/Kernel/vfs/mmap.c index dbdd4b2a..7c3fdf4b 100644 --- a/Kernel/vfs/mmap.c +++ b/Kernel/vfs/mmap.c @@ -21,7 +21,7 @@ struct sVFS_MMapPageBlock }; // === CODE === -void *VFS_MMap(int *ErrNo, void *DestHint, size_t Length, int Protection, int Flags, int FD, Uint64 Offset) +void *VFS_MMap(void *DestHint, size_t Length, int Protection, int Flags, int FD, Uint64 Offset) { tVFS_Handle *h; tVAddr mapping_dest; @@ -31,14 +31,16 @@ void *VFS_MMap(int *ErrNo, void *DestHint, size_t Length, int Protection, int Fl npages = ((Offset & (PAGE_SIZE-1)) + Length) / PAGE_SIZE; pagenum = Offset / PAGE_SIZE; - mapping_dest = DestHint; + mapping_dest = (tVAddr)DestHint; +#if 0 // TODO: Locate space for the allocation if( Flags & MAP_ANONYMOUS ) { MM_Allocate(mapping_dest); return (void*)mapping_dest; } +#endif h = VFS_GetHandle(FD); if( !h || !h->Node ) return NULL; @@ -51,10 +53,10 @@ void *VFS_MMap(int *ErrNo, void *DestHint, size_t Length, int Protection, int Fl prev = pb, pb = pb->Next ); + // - Allocate a block if needed if( !pb || pb->BaseOffset > pagenum ) { void *old_pb = pb; - // Allocate if needed pb = malloc( sizeof(tVFS_MMapPageBlock) ); if(!pb) return NULL; pb->Next = old_pb; @@ -66,6 +68,7 @@ void *VFS_MMap(int *ErrNo, void *DestHint, size_t Length, int Protection, int Fl h->Node->MMapInfo = pb; } + // - Map (and allocate) pages while( npages -- ) { if( pb->PhysAddrs[pagenum - pb->BaseOffset] == 0 ) @@ -75,10 +78,14 @@ void *VFS_MMap(int *ErrNo, void *DestHint, size_t Length, int Protection, int Fl else { // Allocate pages and read data - MM_Allocate(mapping_dest); + if( MM_Allocate(mapping_dest) == 0 ) { + // TODO: Unwrap + return NULL; + } h->Node->Read(h->Node, pagenum*PAGE_SIZE, PAGE_SIZE, (void*)mapping_dest); } pb->PhysAddrs[pagenum - pb->BaseOffset] = MM_GetPhysAddr( mapping_dest ); +// MM_SetPageInfo( pb->PhysAddrs[pagenum - pb->BaseOffset], h->Node, pagenum*PAGE_SIZE ); } else { @@ -108,7 +115,7 @@ void *VFS_MMap(int *ErrNo, void *DestHint, size_t Length, int Protection, int Fl return NULL; } -int VFS_MUnmap(int *ErrNo, void *Addr, size_t Length) +int VFS_MUnmap(void *Addr, size_t Length) { return 0; }