Fixing up doxygen comments
[tpg/acess2.git] / Kernel / arch / x86_64 / mm_phys.c
index 55fc68a..0130773 100644 (file)
@@ -31,7 +31,7 @@ void  MM_DerefPhys(tPAddr PAddr);
  int   MM_int_GetRangeID( tPAddr Addr );
 
 // === GLOBALS ===
-tSpinlock      glPhysicalPages;
+tMutex glPhysicalPages;
 Uint64 *gaSuperBitmap = (void*)MM_PAGE_SUPBMP; // 1 bit = 64 Pages, 16 MiB Per Word
 Uint64 *gaMainBitmap = (void*)MM_PAGE_BITMAP;  // 1 bit = 1 Page, 256 KiB per Word
 Uint64 *gaMultiBitmap = (void*)MM_PAGE_DBLBMP; // Each bit means that the page is being used multiple times
@@ -307,28 +307,28 @@ void MM_InitPhys_Multiboot(tMBoot_Info *MBoot)
 
 /**
  * \brief Allocate a contiguous range of physical pages with a maximum
- *        bit size of \a Bits
- * \param Num  Number of pages to allocate
- * \param Bits Maximum size of the physical address
- * \note If \a Bits is <= 0, any sized address is used (with preference
+ *        bit size of \a MaxBits
+ * \param Pages        Number of pages to allocate
+ * \param MaxBits      Maximum size of the physical address
+ * \note If \a MaxBits is <= 0, any sized address is used (with preference
  *       to higher addresses)
  */
-tPAddr MM_AllocPhysRange(int Num, int Bits)
+tPAddr MM_AllocPhysRange(int Pages, int MaxBits)
 {
        tPAddr  addr, ret;
         int    rangeID;
         int    nFree = 0, i;
        
-       ENTER("iNum iBits", Num, Bits);
+       ENTER("iPages iBits", Pages, MaxBits);
        
-       if( Bits <= 0 || Bits >= 64 )   // Speedup for the common case
+       if( MaxBits <= 0 || MaxBits >= 64 )     // Speedup for the common case
                rangeID = MM_PHYS_MAX;
        else
-               rangeID = MM_int_GetRangeID( (1LL << Bits) - 1 );
+               rangeID = MM_int_GetRangeID( (1LL << MaxBits) - 1 );
        
        LOG("rangeID = %i", rangeID);
        
-       LOCK(&glPhysicalPages);
+       Mutex_Acquire(&glPhysicalPages);
        
        // Check if the range actually has any free pages
        while(giPhysRangeFree[rangeID] == 0 && rangeID)
@@ -338,20 +338,20 @@ tPAddr MM_AllocPhysRange(int Num, int Bits)
        
        // What the? Oh, man. No free pages
        if(giPhysRangeFree[rangeID] == 0) {
-               RELEASE(&glPhysicalPages);
+               Mutex_Release(&glPhysicalPages);
                // TODO: Page out
                // ATM. Just Warning
                Warning(" MM_AllocPhysRange: Out of free pages");
                Log_Warning("Arch",
                        "Out of memory (unable to fulfil request for %i pages), zero remaining",
-                       Num
+                       Pages
                        );
                LEAVE('i', 0);
                return 0;
        }
        
        // Check if there is enough in the range
-       if(giPhysRangeFree[rangeID] >= Num)
+       if(giPhysRangeFree[rangeID] >= Pages)
        {
                LOG("{%i,0x%x -> 0x%x}",
                        giPhysRangeFree[rangeID],
@@ -389,14 +389,14 @@ tPAddr MM_AllocPhysRange(int Num, int Bits)
                        }
                        nFree ++;
                        addr ++;
-                       LOG("nFree(%i) == %i (0x%x)", nFree, Num, addr);
+                       LOG("nFree(%i) == %i (0x%x)", nFree, Pages, addr);
                        if(nFree == Num)
                                break;
                }
                LOG("nFree = %i", nFree);
                // If we don't find a contiguous block, nFree will not be equal
                // to Num, so we set it to zero and do the expensive lookup.
-               if(nFree != Num)        nFree = 0;
+               if(nFree != Pages)      nFree = 0;
        }
        
        if( !nFree )
@@ -406,7 +406,7 @@ tPAddr MM_AllocPhysRange(int Num, int Bits)
                nFree = 1;
                addr = giPhysRangeLast[ rangeID ];
                // TODO
-               RELEASE(&glPhysicalPages);
+               Mutex_Release(&glPhysicalPages);
                // TODO: Page out
                // ATM. Just Warning
                Warning(" MM_AllocPhysRange: Out of memory (unable to fulfil request for %i pages)", Num);
@@ -420,8 +420,8 @@ tPAddr MM_AllocPhysRange(int Num, int Bits)
        LOG("nFree = %i, addr = 0x%08x", nFree, addr);
        
        // Mark pages as allocated
-       addr -= Num;
-       for( i = 0; i < Num; i++, addr++ )
+       addr -= Pages;
+       for( i = 0; i < Pages; i++, addr++ )
        {
                gaMainBitmap[addr >> 6] |= 1LL << (addr & 63);
                rangeID = MM_int_GetRangeID(addr << 12);
@@ -433,16 +433,16 @@ tPAddr MM_AllocPhysRange(int Num, int Bits)
        ret = addr;     // Save the return address
        
        // Update super bitmap
-       Num += addr & (64-1);
+       Pages += addr & (64-1);
        addr &= ~(64-1);
-       Num = (Num + (64-1)) & ~(64-1);
-       for( i = 0; i < Num/64; i++ )
+       Pages = (Pages + (64-1)) & ~(64-1);
+       for( i = 0; i < Pages/64; i++ )
        {
                if( gaMainBitmap[ addr >> 6 ] + 1 == 0 )
                        gaSuperBitmap[addr>>12] |= 1LL << ((addr >> 6) & 63);
        }
        
-       RELEASE(&glPhysicalPages);
+       Mutex_Release(&glPhysicalPages);
        LEAVE('x', ret << 12);
        return ret << 12;
 }

UCC git Repository :: git.ucc.asn.au