git.ucc.asn.au
/
tpg
/
acess2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added current time syscall, commented some others
[tpg/acess2.git]
/
Kernel
/
arch
/
x86_64
/
mm_phys.c
diff --git
a/Kernel/arch/x86_64/mm_phys.c
b/Kernel/arch/x86_64/mm_phys.c
index
1e7c4c2
..
a5f6f27
100644
(file)
--- a/
Kernel/arch/x86_64/mm_phys.c
+++ b/
Kernel/arch/x86_64/mm_phys.c
@@
-228,14
+228,14
@@
void MM_InitPhys_Multiboot(tMBoot_Info *MBoot)
size = ent->Size >> 12;
if(base & 63) {
size = ent->Size >> 12;
if(base & 63) {
- Uint64 val = -1 << (base & 63);
+ Uint64 val = -1
L
<< (base & 63);
gaMainBitmap[base / 64] &= ~val;
size -= (base & 63);
base += 64 - (base & 63);
}
memset( &gaMainBitmap[base / 64], 0, size/8 );
if( size & 7 ) {
gaMainBitmap[base / 64] &= ~val;
size -= (base & 63);
base += 64 - (base & 63);
}
memset( &gaMainBitmap[base / 64], 0, size/8 );
if( size & 7 ) {
- Uint64 val = -1 << (size & 7);
+ Uint64 val = -1
L
<< (size & 7);
val <<= (size/8)&7;
gaMainBitmap[base / 64] &= ~val;
}
val <<= (size/8)&7;
gaMainBitmap[base / 64] &= ~val;
}
@@
-246,7
+246,7
@@
void MM_InitPhys_Multiboot(tMBoot_Info *MBoot)
size = (size + (base & 63) + 63) >> 6;
base = base >> 6;
if(base & 63) {
size = (size + (base & 63) + 63) >> 6;
base = base >> 6;
if(base & 63) {
- Uint64 val = -1 << (base & 63);
+ Uint64 val = -1
L
<< (base & 63);
gaSuperBitmap[base / 64] &= ~val;
size -= (base & 63);
base += 64 - (base & 63);
gaSuperBitmap[base / 64] &= ~val;
size -= (base & 63);
base += 64 - (base & 63);
@@
-258,7
+258,7
@@
void MM_InitPhys_Multiboot(tMBoot_Info *MBoot)
size = firstFreePage >> 12;
memset( &gaMainBitmap[base / 64], -1, size/8 );
if( size & 7 ) {
size = firstFreePage >> 12;
memset( &gaMainBitmap[base / 64], -1, size/8 );
if( size & 7 ) {
- Uint64 val = -1 << (size & 7);
+ Uint64 val = -1
L
<< (size & 7);
val <<= (size/8)&7;
gaMainBitmap[base / 64] |= val;
}
val <<= (size/8)&7;
gaMainBitmap[base / 64] |= val;
}
@@
-268,7
+268,7
@@
void MM_InitPhys_Multiboot(tMBoot_Info *MBoot)
if(gaiStaticAllocPages[i] != 0)
continue;
gaMainBitmap[ gaiStaticAllocPages[i] >> (12+6) ]
if(gaiStaticAllocPages[i] != 0)
continue;
gaMainBitmap[ gaiStaticAllocPages[i] >> (12+6) ]
- &= ~(1 << ((gaiStaticAllocPages[i]>>12)&63));
+ &= ~(1
L
<< ((gaiStaticAllocPages[i]>>12)&63));
}
// Fill the super bitmap
}
// Fill the super bitmap
@@
-276,8
+276,8
@@
void MM_InitPhys_Multiboot(tMBoot_Info *MBoot)
memset(gaSuperBitmap, 0, superPages<<12);
for( base = 0; base < (size+63)/64; base ++)
{
memset(gaSuperBitmap, 0, superPages<<12);
for( base = 0; base < (size+63)/64; base ++)
{
- if( gaMainBitmap[ base ]
== -1
)
- gaSuperBitmap[ base/64 ] |= 1 << (base&63);
+ if( gaMainBitmap[ base ]
+ 1 == 0
)
+ gaSuperBitmap[ base/64 ] |= 1
L
<< (base&63);
}
// Set free page counts
}
// Set free page counts
@@
-285,7
+285,7
@@
void MM_InitPhys_Multiboot(tMBoot_Info *MBoot)
{
int rangeID;
// Skip allocated
{
int rangeID;
// Skip allocated
- if( gaMainBitmap[ base >> 6 ] & (1
<< (base&63)) )
continue;
+ if( gaMainBitmap[ base >> 6 ] & (1
L << (base&63)) )
continue;
// Get range ID
rangeID = MM_int_GetRangeID( base << 12 );
// Get range ID
rangeID = MM_int_GetRangeID( base << 12 );
@@
-314,7
+314,7
@@
void MM_InitPhys_Multiboot(tMBoot_Info *MBoot)
*/
tPAddr MM_AllocPhysRange(int Num, int Bits)
{
*/
tPAddr MM_AllocPhysRange(int Num, int Bits)
{
- tPAddr addr;
+ tPAddr addr
, ret
;
int rangeID;
int nFree = 0, i;
int rangeID;
int nFree = 0, i;
@@
-323,7
+323,7
@@
tPAddr MM_AllocPhysRange(int Num, int Bits)
if( Bits <= 0 || Bits >= 64 ) // Speedup for the common case
rangeID = MM_PHYS_MAX;
else
if( Bits <= 0 || Bits >= 64 ) // Speedup for the common case
rangeID = MM_PHYS_MAX;
else
- rangeID = MM_int_GetRangeID( (1
<< Bits) -
1 );
+ rangeID = MM_int_GetRangeID( (1
L << Bits) -
1 );
LOG("rangeID = %i", rangeID);
LOG("rangeID = %i", rangeID);
@@
-364,23
+364,23
@@
tPAddr MM_AllocPhysRange(int Num, int Bits)
{
//Log(" MM_AllocPhysRange: addr = 0x%x", addr);
// Check the super bitmap
{
//Log(" MM_AllocPhysRange: addr = 0x%x", addr);
// Check the super bitmap
- if( gaSuperBitmap[addr >> (6+6)]
== -1
) {
+ if( gaSuperBitmap[addr >> (6+6)]
+ 1 == 0
) {
LOG("nFree = %i = 0 (super) (0x%x)", nFree, addr);
nFree = 0;
LOG("nFree = %i = 0 (super) (0x%x)", nFree, addr);
nFree = 0;
- addr += 1 << (6+6);
- addr &=
(1 << (6+6)) - 1;
+ addr += 1
L
<< (6+6);
+ addr &=
~0xFFF; // (1L << 6+6) - 1
continue;
}
// Check page block (64 pages)
continue;
}
// Check page block (64 pages)
- if( ga
SuperBitmap[addr >> (6+6)] & (1 << (addr>>6)&63)
) {
+ if( ga
MainBitmap[addr >> 6] + 1 == 0
) {
LOG("nFree = %i = 0 (main) (0x%x)", nFree, addr);
nFree = 0;
LOG("nFree = %i = 0 (main) (0x%x)", nFree, addr);
nFree = 0;
- addr += 1
<< (12+
6);
- addr &=
(1 << (12+6)) - 1
;
+ addr += 1
L << (
6);
+ addr &=
~0x3F
;
continue;
}
// Check individual page
continue;
}
// Check individual page
- if( gaMainBitmap[addr >> 6] & (1 << (addr & 63)) ) {
+ if( gaMainBitmap[addr >> 6] & (1
L
<< (addr & 63)) ) {
LOG("nFree = %i = 0 (page) (0x%x)", nFree, addr);
nFree = 0;
addr ++;
LOG("nFree = %i = 0 (page) (0x%x)", nFree, addr);
nFree = 0;
addr ++;
@@
-420,12
+420,16
@@
tPAddr MM_AllocPhysRange(int Num, int Bits)
// Mark pages as allocated
addr -= Num;
// Mark pages as allocated
addr -= Num;
- for( i = 0; i < Num; i++ )
+ for( i = 0; i < Num; i++
, addr++
)
{
{
- gaMainBitmap[addr >> 6] |= 1 << (addr & 63);
- rangeID = MM_int_GetRangeID(addr);
+ gaMainBitmap[addr >> 6] |= 1
L
<< (addr & 63);
+ rangeID = MM_int_GetRangeID(addr
<< 12
);
giPhysRangeFree[ rangeID ] --;
giPhysRangeFree[ rangeID ] --;
+ LOG("%x == %x", addr, giPhysRangeFirst[ rangeID ]);
+ if(addr == giPhysRangeFirst[ rangeID ])
+ giPhysRangeFirst[ rangeID ] += 1;
}
}
+ ret = addr; // Save the return address
// Update super bitmap
Num += addr & (64-1);
// Update super bitmap
Num += addr & (64-1);
@@
-433,13
+437,13
@@
tPAddr MM_AllocPhysRange(int Num, int Bits)
Num = (Num + (64-1)) & ~(64-1);
for( i = 0; i < Num/64; i++ )
{
Num = (Num + (64-1)) & ~(64-1);
for( i = 0; i < Num/64; i++ )
{
- if( gaMainBitmap[ addr >> 6 ]
== -1
)
- gaSuperBitmap[addr>>12] |= 1
<< ((addr >> 6) & 64
);
+ if( gaMainBitmap[ addr >> 6 ]
+ 1 == 0
)
+ gaSuperBitmap[addr>>12] |= 1
L << ((addr >> 6) & 63
);
}
RELEASE(&glPhysicalPages);
}
RELEASE(&glPhysicalPages);
- LEAVE('x',
addr
<< 12);
- return
addr
<< 12;
+ LEAVE('x',
ret
<< 12);
+ return
ret
<< 12;
}
/**
}
/**
@@
-472,18
+476,18
@@
void MM_RefPhys(tPAddr PAddr)
if( PAddr >> 12 > giMaxPhysPage ) return ;
if( PAddr >> 12 > giMaxPhysPage ) return ;
- if( gaMainBitmap[ page >> 6 ] & (1 << (page&63)) )
+ if( gaMainBitmap[ page >> 6 ] & (1
L
<< (page&63)) )
{
// Reference again
{
// Reference again
- gaMultiBitmap[ page >> 6 ] |= 1 << (page&63);
+ gaMultiBitmap[ page >> 6 ] |= 1
L
<< (page&63);
gaiPageReferences[ page ] ++;
}
else
{
// Allocate
gaiPageReferences[ page ] ++;
}
else
{
// Allocate
- gaMainBitmap[page >> 6] |= 1 << (page&63);
- if( gaMainBitmap[page >> 6 ]
== -1
)
- gaSuperBitmap[page>> 12] |= 1 << ((page >> 6) & 63);
+ gaMainBitmap[page >> 6] |= 1
L
<< (page&63);
+ if( gaMainBitmap[page >> 6 ]
+ 1 == 0
)
+ gaSuperBitmap[page>> 12] |= 1
L
<< ((page >> 6) & 63);
}
}
}
}
@@
-496,26
+500,31
@@
void MM_DerefPhys(tPAddr PAddr)
if( PAddr >> 12 > giMaxPhysPage ) return ;
if( PAddr >> 12 > giMaxPhysPage ) return ;
- if( gaMultiBitmap[ page >> 6 ] & (1 << (page&63)) ) {
+ if( gaMultiBitmap[ page >> 6 ] & (1
L
<< (page&63)) ) {
gaiPageReferences[ page ] --;
if( gaiPageReferences[ page ] == 1 )
gaiPageReferences[ page ] --;
if( gaiPageReferences[ page ] == 1 )
- gaMultiBitmap[ page >> 6 ] &= ~(1 << (page&63));
+ gaMultiBitmap[ page >> 6 ] &= ~(1
L
<< (page&63));
if( gaiPageReferences[ page ] == 0 )
if( gaiPageReferences[ page ] == 0 )
- gaMainBitmap[ page >> 6 ] &= ~(1 << (page&63));
+ gaMainBitmap[ page >> 6 ] &= ~(1
L
<< (page&63));
}
else
}
else
- gaMainBitmap[ page >> 6 ] &= ~(1 << (page&63));
+ gaMainBitmap[ page >> 6 ] &= ~(1
L
<< (page&63));
- //
TODO: Update free counts
- if( !(gaMainBitmap[ page >> 6 ] & (1 << (page&63))) )
+ //
Update the free counts if the page was freed
+ if( !(gaMainBitmap[ page >> 6 ] & (1
L
<< (page&63))) )
{
int rangeID;
rangeID = MM_int_GetRangeID( PAddr );
giPhysRangeFree[ rangeID ] ++;
{
int rangeID;
rangeID = MM_int_GetRangeID( PAddr );
giPhysRangeFree[ rangeID ] ++;
+ if( giPhysRangeFirst[rangeID] > page )
+ giPhysRangeFirst[rangeID] = page;
+ if( giPhysRangeLast[rangeID] < page )
+ giPhysRangeLast[rangeID] = page;
}
}
- if(gaMainBitmap[ page >> 6 ] == 0) {
- gaSuperBitmap[page >> 12] &= ~(1 << ((page >> 6) & 63));
+ // If the bitmap entry is not -1, unset the bit in the super bitmap
+ if(gaMainBitmap[ page >> 6 ] + 1 != 0 ) {
+ gaSuperBitmap[page >> 12] &= ~(1L << ((page >> 6) & 63));
}
}
}
}
UCC
git Repository :: git.ucc.asn.au