From bd5e8623e509a443d7d6e1b959b79f85b0c285b7 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Wed, 18 Jul 2012 21:37:19 +0800 Subject: [PATCH] Kernel - Changed MM_GetPhysAddr to take a pointer --- KernelLand/Kernel/arch/x86/errors.c | 4 ++-- KernelLand/Kernel/arch/x86/mm_phys.c | 19 ++++++++---------- KernelLand/Kernel/arch/x86/mm_virt.c | 16 +++++++-------- KernelLand/Kernel/arch/x86/proc.c | 11 ++++------ KernelLand/Kernel/binary.c | 4 ++-- KernelLand/Kernel/heap.c | 10 +++++----- KernelLand/Kernel/include/acess.h | 2 +- KernelLand/Kernel/libc.c | 4 ++-- KernelLand/Kernel/syscalls.c | 2 +- KernelLand/Kernel/vfs/handle.c | 12 +++++------ KernelLand/Kernel/vfs/mmap.c | 13 ++++++------ .../Modules/Network/VIARhineII/rhine2.c | 2 +- KernelLand/Modules/Storage/ATA/io.c | 8 ++++---- KernelLand/Modules/USB/UHCI/uhci.c | 20 +++++++++---------- 14 files changed, 60 insertions(+), 67 deletions(-) diff --git a/KernelLand/Kernel/arch/x86/errors.c b/KernelLand/Kernel/arch/x86/errors.c index 9562c413..8dc90b01 100644 --- a/KernelLand/Kernel/arch/x86/errors.c +++ b/KernelLand/Kernel/arch/x86/errors.c @@ -228,14 +228,14 @@ void Error_Backtrace(Uint eip, Uint ebp) LogF("Backtrace: 0x%x", eip); // else // LogF("Backtrace: %s+0x%x", str, delta); - if(!MM_GetPhysAddr(ebp)) + if(!MM_GetPhysAddr((void*)ebp)) { LogF("\nBacktrace: Invalid EBP %p, stopping\n", ebp); return; } - while( MM_GetPhysAddr(ebp) && i < MAX_BACKTRACE ) + while( MM_GetPhysAddr((void*)ebp) && i < MAX_BACKTRACE ) { if( ebp >= MM_KERNEL_STACKS_END ) break; //str = Debug_GetSymbol(*(Uint*)(ebp+4), &delta); diff --git a/KernelLand/Kernel/arch/x86/mm_phys.c b/KernelLand/Kernel/arch/x86/mm_phys.c index a3318176..b0f1c616 100644 --- a/KernelLand/Kernel/arch/x86/mm_phys.c +++ b/KernelLand/Kernel/arch/x86/mm_phys.c @@ -270,7 +270,7 @@ tPAddr MM_AllocPhys(void) } // Mark page used - if( MM_GetPhysAddr( (tVAddr)&gaPageReferences[indx] ) ) + if( MM_GetPhysAddr( &gaPageReferences[indx] ) ) gaPageReferences[indx] = 1; gaPageBitmap[ indx>>5 ] |= 1 << (indx&31); @@ -305,7 +305,6 @@ tPAddr MM_AllocPhys(void) */ tPAddr MM_AllocPhysRange(int Pages, int MaxBits) { - int a, b; int i, idx, sidx; tPAddr ret; @@ -330,8 +329,6 @@ tPAddr MM_AllocPhysRange(int Pages, int MaxBits) } idx = sidx / 32; sidx %= 32; - b = idx % 32; - a = idx / 32; #if 0 LOG("a=%i, b=%i, idx=%i, sidx=%i", a, b, idx, sidx); @@ -406,7 +403,7 @@ tPAddr MM_AllocPhysRange(int Pages, int MaxBits) // Mark pages used for( i = 0; i < Pages; i++ ) { - if( MM_GetPhysAddr( (tVAddr)&gaPageReferences[idx*32+sidx] ) ) + if( MM_GetPhysAddr( &gaPageReferences[idx*32+sidx] ) ) gaPageReferences[idx*32+sidx] = 1; gaPageBitmap[ idx ] |= 1 << sidx; sidx ++; @@ -448,7 +445,7 @@ void MM_RefPhys(tPAddr PAddr) // Reference the page if( gaPageReferences ) { - if( MM_GetPhysAddr( (tVAddr)&gaPageReferences[PAddr] ) == 0 ) + if( MM_GetPhysAddr( &gaPageReferences[PAddr] ) == 0 ) { int i, base; tVAddr addr = ((tVAddr)&gaPageReferences[PAddr]) & ~0xFFF; @@ -510,7 +507,7 @@ void MM_DerefPhys(tPAddr PAddr) giLastPossibleFree = PAddr; // Dereference - if( !MM_GetPhysAddr( (tVAddr)&gaPageReferences[PAddr] ) || (-- gaPageReferences[PAddr]) == 0 ) + if( !MM_GetPhysAddr( &gaPageReferences[PAddr] ) || (-- gaPageReferences[PAddr]) == 0 ) { #if TRACE_ALLOCS Log_Debug("PMem", "MM_DerefPhys: Free'd %P (%i free)", PAddr<<12, giPageCount-giPhysAlloc); @@ -522,7 +519,7 @@ void MM_DerefPhys(tPAddr PAddr) if(gaPageBitmap[ PAddr / 32 ] == 0) gaSuperBitmap[ PAddr >> 10 ] &= ~(1 << ((PAddr >> 5)&31)); - if( MM_GetPhysAddr( (tVAddr) &gaPageNodes[PAddr] ) ) + if( MM_GetPhysAddr( &gaPageNodes[PAddr] ) ) { gaPageNodes[PAddr] = NULL; // TODO: Free Node Page when fully unused @@ -544,7 +541,7 @@ int MM_GetRefCount(tPAddr PAddr) // We don't care about non-ram pages if(PAddr >= giPageCount) return -1; - if( MM_GetPhysAddr( (tVAddr)&gaPageReferences[PAddr] ) == 0 ) + if( MM_GetPhysAddr( &gaPageReferences[PAddr] ) == 0 ) return (gaPageBitmap[PAddr / 32] & (1 << PAddr%32)) ? 1 : 0; // Check if it is freed @@ -562,7 +559,7 @@ int MM_SetPageNode(tPAddr PAddr, void *Node) block_addr = (tVAddr) &gaPageNodes[PAddr]; block_addr &= ~(PAGE_SIZE-1); - if( !MM_GetPhysAddr( block_addr ) ) + if( !MM_GetPhysAddr( (void*)block_addr ) ) { if( !MM_Allocate( block_addr ) ) { Log_Warning("PMem", "Unable to allocate Node page"); @@ -581,7 +578,7 @@ int MM_GetPageNode(tPAddr PAddr, void **Node) if( MM_GetRefCount(PAddr) == 0 ) return 1; PAddr /= PAGE_SIZE; - if( !MM_GetPhysAddr( (tVAddr) &gaPageNodes[PAddr] ) ) { + if( !MM_GetPhysAddr( &gaPageNodes[PAddr] ) ) { *Node = NULL; return 0; } diff --git a/KernelLand/Kernel/arch/x86/mm_virt.c b/KernelLand/Kernel/arch/x86/mm_virt.c index d15c3d72..868fe86a 100644 --- a/KernelLand/Kernel/arch/x86/mm_virt.c +++ b/KernelLand/Kernel/arch/x86/mm_virt.c @@ -414,13 +414,14 @@ void MM_Deallocate(tVAddr VAddr) * \fn tPAddr MM_GetPhysAddr(tVAddr Addr) * \brief Checks if the passed address is accesable */ -tPAddr MM_GetPhysAddr(tVAddr Addr) +tPAddr MM_GetPhysAddr(const void *Addr) { - if( !(gaPageDir[Addr >> 22] & 1) ) + tVAddr addr = (tVAddr)Addr; + if( !(gaPageDir[addr >> 22] & 1) ) return 0; - if( !(gaPageTable[Addr >> 12] & 1) ) + if( !(gaPageTable[addr >> 12] & 1) ) return 0; - return (gaPageTable[Addr >> 12] & ~0xFFF) | (Addr & 0xFFF); + return (gaPageTable[addr >> 12] & ~0xFFF) | (addr & 0xFFF); } /** @@ -717,7 +718,8 @@ tVAddr MM_NewKStack(void) for(base = MM_KERNEL_STACKS; base < MM_KERNEL_STACKS_END; base += MM_KERNEL_STACK_SIZE) { // Check if space is free - if(MM_GetPhysAddr(base) != 0) continue; + if(MM_GetPhysAddr( (void*) base) != 0) + continue; // Allocate //for(i = MM_KERNEL_STACK_SIZE; i -= 0x1000 ; ) for(i = 0; i < MM_KERNEL_STACK_SIZE; i += 0x1000 ) @@ -1069,7 +1071,6 @@ tVAddr MM_MapHWPages(tPAddr PAddr, Uint Number) */ tVAddr MM_AllocDMA(int Pages, int MaxBits, tPAddr *PhysAddr) { - tPAddr maxCheck = (1 << MaxBits); tPAddr phys; tVAddr ret; @@ -1084,9 +1085,6 @@ tVAddr MM_AllocDMA(int Pages, int MaxBits, tPAddr *PhysAddr) return 0; } - // Bound - if(MaxBits >= PHYS_BITS) maxCheck = -1; - // Fast Allocate if(Pages == 1 && MaxBits >= PHYS_BITS) { diff --git a/KernelLand/Kernel/arch/x86/proc.c b/KernelLand/Kernel/arch/x86/proc.c index cd5316e5..de0d5c3c 100644 --- a/KernelLand/Kernel/arch/x86/proc.c +++ b/KernelLand/Kernel/arch/x86/proc.c @@ -467,7 +467,6 @@ void Proc_IdleThread(void *Ptr) */ void Proc_Start(void) { - int tid; #if USE_MP int i; #endif @@ -479,7 +478,7 @@ void Proc_Start(void) if(i) gaCPUs[i].Current = NULL; // Create Idle Task - tid = Proc_NewKThread(Proc_IdleThread, &gaCPUs[i]); + Proc_NewKThread(Proc_IdleThread, &gaCPUs[i]); // Start the AP if( i != giProc_BootProcessorID ) { @@ -496,8 +495,7 @@ void Proc_Start(void) while( giNumInitingCPUs ) __asm__ __volatile__ ("hlt"); #else // Create Idle Task - tid = Proc_NewKThread(Proc_IdleThread, &gaCPUs[0]); -// gaCPUs[0].IdleThread = Threads_GetThread(tid); + Proc_NewKThread(Proc_IdleThread, &gaCPUs[0]); // Set current task gaCPUs[0].Current = &gThreadZero; @@ -588,9 +586,8 @@ void Proc_ClearThread(tThread *Thread) tTID Proc_NewKThread(void (*Fcn)(void*), void *Data) { Uint esp; - tThread *newThread, *cur; + tThread *newThread; - cur = Proc_GetCurThread(); newThread = Threads_CloneTCB(0); if(!newThread) return -1; @@ -711,7 +708,7 @@ Uint Proc_MakeUserStack(void) // Check Prospective Space for( i = USER_STACK_SZ >> 12; i--; ) - if( MM_GetPhysAddr( base + (i<<12) ) != 0 ) + if( MM_GetPhysAddr( (void*)(base + (i<<12)) ) != 0 ) break; if(i != -1) return 0; diff --git a/KernelLand/Kernel/binary.c b/KernelLand/Kernel/binary.c index 8a8bc3eb..de94c6f6 100644 --- a/KernelLand/Kernel/binary.c +++ b/KernelLand/Kernel/binary.c @@ -881,12 +881,12 @@ int Binary_int_CheckMemFree( tVAddr _start, size_t _len ) _start &= ~(PAGE_SIZE-1); LOG("_start = %p, _len = 0x%x", _start, _len); for( ; _len > PAGE_SIZE; _len -= PAGE_SIZE, _start += PAGE_SIZE ) { - if( MM_GetPhysAddr(_start) != 0 ) { + if( MM_GetPhysAddr( (void*)_start ) != 0 ) { LEAVE('i', 1); return 1; } } - if( _len == PAGE_SIZE && MM_GetPhysAddr(_start) != 0 ) { + if( _len == PAGE_SIZE && MM_GetPhysAddr( (void*)_start ) != 0 ) { LEAVE('i', 1); return 1; } diff --git a/KernelLand/Kernel/heap.c b/KernelLand/Kernel/heap.c index 9e291450..4c7ffd95 100644 --- a/KernelLand/Kernel/heap.c +++ b/KernelLand/Kernel/heap.c @@ -519,7 +519,7 @@ void Heap_Dump(void) foot = (void*)( (Uint)head + head->Size - sizeof(tHeapFoot) ); #if VERBOSE_DUMP Log_Log("Heap", "%p (0x%P): 0x%08x (%i) %4C", - head, MM_GetPhysAddr((tVAddr)head), head->Size, head->ValidSize, &head->Magic); + head, MM_GetPhysAddr(head), head->Size, head->ValidSize, &head->Magic); Log_Log("Heap", "%p %4C", foot->Head, &foot->Magic); if(head->File) { Log_Log("Heap", "%sowned by %s:%i", @@ -569,7 +569,7 @@ void Heap_Dump(void) #if !VERBOSE_DUMP Log_Log("Heap", "%p (%P): 0x%08lx %i %4C", - head, MM_GetPhysAddr((Uint)head), head->Size, head->ValidSize, &head->Magic); + head, MM_GetPhysAddr(head), head->Size, head->ValidSize, &head->Magic); if(foot) Log_Log("Heap", "Foot %p = {Head:%p,Magic:%4C}", foot, foot->Head, &foot->Magic); if(head->File) { @@ -589,7 +589,7 @@ void Heap_Dump(void) while( (tVAddr)head >= (tVAddr)badHead ) { Log_Log("Heap", "%p (%P): 0x%08lx %i %4C", - head, MM_GetPhysAddr((Uint)head), head->Size, head->ValidSize, &head->Magic); + head, MM_GetPhysAddr(head), head->Size, head->ValidSize, &head->Magic); Log_Log("Heap", "%p %4C", foot->Head, &foot->Magic); if(head->File) Log_Log("Heap", "%sowned by %s:%i", @@ -669,10 +669,10 @@ void Heap_Stats(void) #if 1 if( head->Magic == MAGIC_FREE ) Log_Debug("Heap", "%p (%P) - 0x%x free", - head->Data, MM_GetPhysAddr((tVAddr)&head->Data), head->Size); + head->Data, MM_GetPhysAddr(&head->Data), head->Size); else Log_Debug("Heap", "%p (%P) - 0x%x (%i) Owned by %s:%i (%lli ms old)", - head->Data, MM_GetPhysAddr((tVAddr)&head->Data), head->Size, head->ValidSize, head->File, head->Line, + head->Data, MM_GetPhysAddr(&head->Data), head->Size, head->ValidSize, head->File, head->Line, now() - head->AllocateTime ); #endif diff --git a/KernelLand/Kernel/include/acess.h b/KernelLand/Kernel/include/acess.h index 1a982fe5..87aef6ec 100644 --- a/KernelLand/Kernel/include/acess.h +++ b/KernelLand/Kernel/include/acess.h @@ -252,7 +252,7 @@ extern int MM_Map(tVAddr VAddr, tPAddr PAddr); * \param Addr Address of the page to get the physical address of * \return Physical page mapped at \a Addr */ -extern tPAddr MM_GetPhysAddr(tVAddr Addr); +extern tPAddr MM_GetPhysAddr(const void *Addr); /** * \brief Set the access flags on a page * \param VAddr Virtual address of the page diff --git a/KernelLand/Kernel/libc.c b/KernelLand/Kernel/libc.c index c6ada1e9..7a7cc056 100644 --- a/KernelLand/Kernel/libc.c +++ b/KernelLand/Kernel/libc.c @@ -739,7 +739,7 @@ int CheckString(const char *String) addr = (tVAddr)String; - if( !MM_GetPhysAddr( addr ) ) + if( !MM_GetPhysAddr( (void*)addr ) ) return 0; // Check 1st page @@ -751,7 +751,7 @@ int CheckString(const char *String) { if(bUser && !MM_IsUser(addr) ) return 0; - if(!bUser && !MM_GetPhysAddr(addr) ) + if(!bUser && !MM_GetPhysAddr((void*)addr) ) return 0; } addr ++; diff --git a/KernelLand/Kernel/syscalls.c b/KernelLand/Kernel/syscalls.c index 5580187d..d629ae4e 100644 --- a/KernelLand/Kernel/syscalls.c +++ b/KernelLand/Kernel/syscalls.c @@ -102,7 +102,7 @@ void SyscallHandler(tSyscallRegs *Regs) // -- Get the physical address of a page case SYS_GETPHYS: - ret = MM_GetPhysAddr(Regs->Arg1); + ret = MM_GetPhysAddr( (void*)Regs->Arg1 ); break; // -- Map an address diff --git a/KernelLand/Kernel/vfs/handle.c b/KernelLand/Kernel/vfs/handle.c index 6d2b83fb..8cae8040 100644 --- a/KernelLand/Kernel/vfs/handle.c +++ b/KernelLand/Kernel/vfs/handle.c @@ -60,7 +60,7 @@ int VFS_AllocHandle(int bIsUser, tVFS_Node *Node, int Mode) { int max_handles = *Threads_GetMaxFD(); // Allocate Buffer - if( MM_GetPhysAddr( (tVAddr)gaUserHandles ) == 0 ) + if( MM_GetPhysAddr( gaUserHandles ) == 0 ) { Uint addr, size; size = max_handles * sizeof(tVFS_Handle); @@ -87,7 +87,7 @@ int VFS_AllocHandle(int bIsUser, tVFS_Node *Node, int Mode) else { // Allocate space if not already - if( MM_GetPhysAddr( (tVAddr)gaKernelHandles ) == 0 ) + if( MM_GetPhysAddr( gaKernelHandles ) == 0 ) { Uint addr, size; size = MAX_KERNEL_FILES * sizeof(tVFS_Handle); @@ -121,7 +121,7 @@ void VFS_ReferenceUserHandles(void) int max_handles = *Threads_GetMaxFD(); // Check if this process has any handles - if( MM_GetPhysAddr( (tVAddr)gaUserHandles ) == 0 ) + if( MM_GetPhysAddr( gaUserHandles ) == 0 ) return ; for( i = 0; i < max_handles; i ++ ) @@ -141,7 +141,7 @@ void VFS_CloseAllUserHandles(void) int max_handles = *Threads_GetMaxFD(); // Check if this process has any handles - if( MM_GetPhysAddr( (tVAddr)gaUserHandles ) == 0 ) + if( MM_GetPhysAddr( gaUserHandles ) == 0 ) return ; for( i = 0; i < max_handles; i ++ ) @@ -165,7 +165,7 @@ void *VFS_SaveHandles(int NumFDs, int *FDs) int max_handles = *Threads_GetMaxFD(); // Check if this process has any handles - if( MM_GetPhysAddr( (tVAddr)gaUserHandles ) == 0 ) + if( MM_GetPhysAddr( gaUserHandles ) == 0 ) return NULL; // Allocate @@ -214,7 +214,7 @@ void VFS_RestoreHandles(int NumFDs, void *Handles) return ; // Check if there is already a set of handles - if( MM_GetPhysAddr( (tVAddr)gaUserHandles ) != 0 ) + if( MM_GetPhysAddr( gaUserHandles ) != 0 ) return ; diff --git a/KernelLand/Kernel/vfs/mmap.c b/KernelLand/Kernel/vfs/mmap.c index 61288695..c5015e67 100644 --- a/KernelLand/Kernel/vfs/mmap.c +++ b/KernelLand/Kernel/vfs/mmap.c @@ -50,7 +50,7 @@ void *VFS_MMap(void *DestHint, size_t Length, int Protection, int Flags, int FD, LOG("%i pages anonymous to %p", npages, mapping_dest); for( ; npages --; mapping_dest += PAGE_SIZE, ofs += PAGE_SIZE ) { - if( MM_GetPhysAddr(mapping_dest) ) { + if( MM_GetPhysAddr((void*)mapping_dest) ) { // TODO: Set flags to COW if needed (well, if shared) MM_SetFlags(mapping_dest, MM_PFLAG_COW, MM_PFLAG_COW); LOG("clear from %p, %i bytes", (void*)(mapping_base + ofs), @@ -109,7 +109,7 @@ void *VFS_MMap(void *DestHint, size_t Length, int Protection, int Flags, int FD, // - Map (and allocate) pages while( npages -- ) { - if( MM_GetPhysAddr(mapping_dest) == 0 ) + if( MM_GetPhysAddr( (void*)mapping_dest ) == 0 ) { if( pb->PhysAddrs[pagenum - pb->BaseOffset] == 0 ) { @@ -132,11 +132,12 @@ void *VFS_MMap(void *DestHint, size_t Length, int Protection, int Flags, int FD, } // TODO: Clip read length read_len = nt->Read(h->Node, pagenum*PAGE_SIZE, PAGE_SIZE, (void*)mapping_dest); -// if( read_len != PAGE_SIZE ) { -// memset( (void*)(mapping_dest+read_len), 0, PAGE_SIZE-read_len ); -// } + // TODO: This was commented out, why? + if( read_len != PAGE_SIZE ) { + memset( (void*)(mapping_dest+read_len), 0, PAGE_SIZE-read_len ); + } } - pb->PhysAddrs[pagenum - pb->BaseOffset] = MM_GetPhysAddr( mapping_dest ); + pb->PhysAddrs[pagenum - pb->BaseOffset] = MM_GetPhysAddr( (void*)mapping_dest ); MM_SetPageNode( pb->PhysAddrs[pagenum - pb->BaseOffset], h->Node ); MM_RefPhys( pb->PhysAddrs[pagenum - pb->BaseOffset] ); LOG("Read and map %X to %p (%P)", pagenum*PAGE_SIZE, mapping_dest, diff --git a/KernelLand/Modules/Network/VIARhineII/rhine2.c b/KernelLand/Modules/Network/VIARhineII/rhine2.c index a1686f7e..f9f4d254 100644 --- a/KernelLand/Modules/Network/VIARhineII/rhine2.c +++ b/KernelLand/Modules/Network/VIARhineII/rhine2.c @@ -330,7 +330,7 @@ int Rhine2_SendPacket(void *Ptr, tIPStackBuffer *Buffer) card->NextTX = (card->NextTX + nDescs) % N_TX_DESCS; desc = card->TXDescs + first_desc_id; - desc->TXBufferStart = MM_GetPhysAddr( (tVAddr)data ); + desc->TXBufferStart = MM_GetPhysAddr( data ); desc->BufferSize = len | (1 << 15); desc->TSR = 0; desc->TCR = 0; diff --git a/KernelLand/Modules/Storage/ATA/io.c b/KernelLand/Modules/Storage/ATA/io.c index 89f1a464..0ed5e374 100644 --- a/KernelLand/Modules/Storage/ATA/io.c +++ b/KernelLand/Modules/Storage/ATA/io.c @@ -148,16 +148,16 @@ int ATA_SetupIO(void) IRQ_AddHandler( gATA_IRQPri, ATA_IRQHandlerPri, NULL ); IRQ_AddHandler( gATA_IRQSec, ATA_IRQHandlerSec, NULL ); - gATA_PRDTs[0].PBufAddr = MM_GetPhysAddr( (tVAddr)&gATA_Buffers[0] ); - gATA_PRDTs[1].PBufAddr = MM_GetPhysAddr( (tVAddr)&gATA_Buffers[1] ); + gATA_PRDTs[0].PBufAddr = MM_GetPhysAddr( &gATA_Buffers[0] ); + gATA_PRDTs[1].PBufAddr = MM_GetPhysAddr( &gATA_Buffers[1] ); LOG("gATA_PRDTs = {PBufAddr: 0x%x, PBufAddr: 0x%x}", gATA_PRDTs[0].PBufAddr, gATA_PRDTs[1].PBufAddr); - gaATA_PRDT_PAddrs[0] = MM_GetPhysAddr( (tVAddr)&gATA_PRDTs[0] ); + gaATA_PRDT_PAddrs[0] = MM_GetPhysAddr( &gATA_PRDTs[0] ); LOG("gaATA_PRDT_PAddrs[0] = 0x%x", gaATA_PRDT_PAddrs[0]); ATA_int_BusMasterWriteDWord(4, gaATA_PRDT_PAddrs[0]); - gaATA_PRDT_PAddrs[1] = MM_GetPhysAddr( (tVAddr)&gATA_PRDTs[1] ); + gaATA_PRDT_PAddrs[1] = MM_GetPhysAddr( &gATA_PRDTs[1] ); LOG("gaATA_PRDT_PAddrs[1] = 0x%x", gaATA_PRDT_PAddrs[1]); ATA_int_BusMasterWriteDWord(12, gaATA_PRDT_PAddrs[1]); diff --git a/KernelLand/Modules/USB/UHCI/uhci.c b/KernelLand/Modules/USB/UHCI/uhci.c index e57a1c30..257171a8 100644 --- a/KernelLand/Modules/USB/UHCI/uhci.c +++ b/KernelLand/Modules/USB/UHCI/uhci.c @@ -191,7 +191,7 @@ int UHCI_int_InitHost(tUHCI_Controller *Host) 1,17,9,25,5,21,13,29,3,19,11,27,7,23,15,31 }; for( int i = 0; i < 1024; i ++ ) { - Uint32 addr = MM_GetPhysAddr( (tVAddr)&Host->TDQHPage->ControlQH ); + Uint32 addr = MM_GetPhysAddr( &Host->TDQHPage->ControlQH ); Host->FrameList[i] = addr | 2; } for( int i = 0; i < 64; i ++ ) { @@ -220,12 +220,12 @@ int UHCI_int_InitHost(tUHCI_Controller *Host) dest += _count; destphys += _count * sizeof(tUHCI_QH); } // Skip padding, and move to control QH - dest->Next = MM_GetPhysAddr( (tVAddr)&Host->TDQHPage->BulkQH ) | 2; + dest->Next = MM_GetPhysAddr( &Host->TDQHPage->BulkQH ) | 2; dest->Child = 1; } // Set up control and bulk queues - Host->TDQHPage->ControlQH.Next = MM_GetPhysAddr( (tVAddr)&Host->TDQHPage->BulkQH ) | 2; + Host->TDQHPage->ControlQH.Next = MM_GetPhysAddr( &Host->TDQHPage->BulkQH ) | 2; Host->TDQHPage->ControlQH.Child = 1; Host->TDQHPage->BulkQH.Next = 1; Host->TDQHPage->BulkQH.Child = 1; @@ -297,11 +297,11 @@ void UHCI_int_AppendTD(tUHCI_Controller *Cont, tUHCI_QH *QH, tUHCI_TD *TD) // Add TD->Link = 1; if( QH->Child & 1 ) { - QH->Child = MM_GetPhysAddr( (tVAddr)TD ); + QH->Child = MM_GetPhysAddr( TD ); } else { // Depth first - QH->_LastItem->Link = MM_GetPhysAddr( (tVAddr)TD ) | 4; + QH->_LastItem->Link = MM_GetPhysAddr( TD ) | 4; } QH->_LastItem = TD; @@ -360,7 +360,7 @@ tUHCI_TD *UHCI_int_CreateTD( if( ((tVAddr)Data & (PAGE_SIZE-1)) + Length > PAGE_SIZE #if PHYS_BITS > 32 - || MM_GetPhysAddr( (tVAddr)Data ) >> 32 + || MM_GetPhysAddr( Data ) >> 32 #endif ) { @@ -373,8 +373,8 @@ tUHCI_TD *UHCI_int_CreateTD( LOG("Relocated IN"); info = calloc( sizeof(tUHCI_ExtraTDInfo), 1 ); info->Offset = ((tVAddr)Data & (PAGE_SIZE-1)); - info->FirstPage = MM_GetPhysAddr( (tVAddr)Data ); - info->SecondPage = MM_GetPhysAddr( (tVAddr)Data + Length - 1 ); + info->FirstPage = MM_GetPhysAddr( Data ); + info->SecondPage = MM_GetPhysAddr( (const char *)Data + Length - 1 ); } else { @@ -388,7 +388,7 @@ tUHCI_TD *UHCI_int_CreateTD( } else { - td->BufferPointer = MM_GetPhysAddr( (tVAddr)Data ); + td->BufferPointer = MM_GetPhysAddr( Data ); td->_info.bFreePointer = 0; } @@ -661,7 +661,7 @@ tUHCI_TD *UHCI_int_GetTDFromPhys(tUHCI_Controller *Controller, Uint32 PAddr) } - tPAddr global_pool = MM_GetPhysAddr( (tVAddr)gaUHCI_TDPool ); + tPAddr global_pool = MM_GetPhysAddr( gaUHCI_TDPool ); if( PAddr < global_pool || PAddr >= global_pool + PAGE_SIZE ) return NULL; -- 2.20.1