/kernel/branches/kolibri_pe/core/heap.c |
---|
49,8 → 49,8 |
ASSERT(base != 0); |
ASSERT(size != 0) |
ASSERT(base & 0x3FFFFF == 0); |
ASSERT(size & 0x3FFFFF == 0); |
ASSERT((base & 0x3FFFFF) == 0); |
ASSERT((size & 0x3FFFFF) == 0); |
for (i = 0; i < 32; i++) |
{ |
84,7 → 84,7 |
count_t idx0; |
u32_t mask; |
ASSERT(size & 0x3FFFFF == 0); |
ASSERT((size & 0x3FFFFF) == 0); |
idx0 = (size>>22) - 1 < 32 ? (size>>22) - 1 : 31; |
mask = lheap.availmask & ( -1<<idx0 ); |
91,11 → 91,29 |
if(mask) |
{ |
if(idx0 == 31) |
{ |
md_t *tmp = (md_t*)lheap.list[31].next; |
while((link_t*)tmp != &lheap.list[31]) |
{ |
if(tmp->size >= size) |
{ |
DBG("remove large tmp %x\n", tmp); |
md = tmp; |
break; |
}; |
}; |
tmp = (md_t*)tmp->link.next; |
} |
else |
{ |
idx0 = _bsf(mask); |
ASSERT( !list_empty(&lheap.list[idx0])) |
md = (md_t*)lheap.list[idx0].next; |
}; |
} |
else |
return NULL; |
137,7 → 155,7 |
count_t idx0; |
u32_t mask; |
ASSERT(size & 0xFFF == 0); |
ASSERT((size & 0xFFF) == 0); |
efl = safe_cli(); |
144,37 → 162,46 |
idx0 = (size>>12) - 1 < 32 ? (size>>12) - 1 : 31; |
mask = sheap.availmask & ( -1<<idx0 ); |
//printf("smask %x size %x idx0 %x mask %x\n",sheap.availmask, size, idx0, mask); |
DBG("smask %x size %x idx0 %x mask %x\n",sheap.availmask, size, idx0, mask); |
if(mask) |
{ |
md_t *tmp; |
idx0 = _bsf(mask); |
ASSERT( !list_empty(&sheap.list[idx0])) |
tmp = (md_t*)sheap.list[idx0].next; |
while((link_t*)tmp != &sheap.list[idx0]) |
if(idx0 == 31) |
{ |
md_t *tmp = (md_t*)sheap.list[31].next; |
while((link_t*)tmp != &sheap.list[31]) |
{ |
if(tmp->size >= size) |
{ |
//printf("remove tmp %x\n", tmp); |
list_remove((link_t*)tmp); |
if(list_empty(&sheap.list[idx0])) |
_reset_smask(idx0); |
md = tmp; |
break; |
}; |
tmp = (md_t*)tmp->link.next; |
}; |
} |
else |
{ |
idx0 = _bsf(mask); |
ASSERT( !list_empty(&sheap.list[idx0])) |
md = (md_t*)sheap.list[idx0].next; |
} |
}; |
if( !md) |
if(md) |
{ |
DBG("remove md %x\n", md); |
list_remove((link_t*)md); |
if(list_empty(&sheap.list[idx0])) |
_reset_smask(idx0); |
} |
else |
{ |
md_t *lmd; |
lmd = find_large_md((size+0x3FFFFF)&~0x3FFFFF); |
DBG("get large md %x\n", lmd); |
if( !lmd) |
{ |
safe_sti(efl); |
208,7 → 235,7 |
idx1 = (md->size>>12) - 1 < 32 ? (md->size>>12) - 1 : 31; |
//printf("insert md %x, base %x size %x idx %x\n", md,md->base, md->size,idx1); |
DBG("insert md %x, base %x size %x idx %x\n", md,md->base, md->size,idx1); |
if( idx1 < 31) |
list_prepend(&md->link, &sheap.list[idx1]); |
319,7 → 346,8 |
md = find_small_md(size); |
// printf("alloc_kernel_space: %x size %x\n\n",md->base, size); |
DBG("alloc_kernel_space: %x size %x\n\n",md->base, size); |
if( md ) |
return (void*)md->base; |
return NULL; |
/kernel/branches/kolibri_pe/core/init.c |
---|
24,11 → 24,11 |
u32_t last_page = 0; |
if (CHECK_FLAG (boot_mbi->flags, 1)) |
printf ("boot_device = 0x%x\n", (unsigned) boot_mbi->boot_device); |
DBG ("boot_device = 0x%x\n", (unsigned) boot_mbi->boot_device); |
/* Is the command line passed? */ |
if (CHECK_FLAG (boot_mbi->flags, 2)) |
printf ("cmdline = %s\n", (char *) boot_mbi->cmdline); |
DBG ("cmdline = %s\n", (char *) boot_mbi->cmdline); |
/* Are mods_* valid? */ |
if (CHECK_FLAG (boot_mbi->flags, 3)) |
36,14 → 36,14 |
module_t *mod; |
int i; |
// printf ("mods_count = %d, mods_addr = 0x%x\n", |
// (u32_t) boot_mbi->mods_count, (u32_t) boot_mbi->mods_addr); |
DBG ("mods_count = %d, mods_addr = 0x%x\n", |
(u32_t) boot_mbi->mods_count, (u32_t) boot_mbi->mods_addr); |
for (i = 0, mod = (module_t *) boot_mbi->mods_addr; |
i < boot_mbi->mods_count;i++, mod++) |
{ |
pg_balloc = mod->mod_end; |
// printf (" mod_start = 0x%x, mod_end = 0x%x, string = %s\n", |
// (u32_t) mod->mod_start,(u32_t) mod->mod_end, (char *) mod->string); |
DBG (" mod_start = 0x%x, mod_end = 0x%x, string = %s\n", |
(u32_t) mod->mod_start,(u32_t) mod->mod_end, (char *) mod->string); |
}; |
mod--; |
rd_base = mod->mod_start+OS_BASE; |
59,8 → 59,8 |
memory_map_t *mmap; |
u32_t page; |
// printf ("mmap_addr = 0x%x, mmap_length = 0x%x\n", |
// (unsigned) boot_mbi->mmap_addr, (unsigned) boot_mbi->mmap_length); |
DBG("mmap_addr = 0x%x, mmap_length = 0x%x\n", |
(unsigned) boot_mbi->mmap_addr, (unsigned) boot_mbi->mmap_length); |
for (mmap = (memory_map_t *) boot_mbi->mmap_addr; |
(u32_t) mmap < boot_mbi->mmap_addr + boot_mbi->mmap_length; |
68,8 → 68,8 |
+ mmap->size + sizeof (mmap->size))) |
{ |
u32_t page; |
/* |
printf (" size = 0x%x, base_addr = 0x%x%x," |
DBG (" size = 0x%x, base_addr = 0x%x%x," |
" length = 0x%x%x, type = 0x%x\n", |
(unsigned) mmap->size, |
(unsigned) mmap->base_addr_high, |
77,7 → 77,7 |
(unsigned) mmap->length_high, |
(unsigned) mmap->length_low, |
(unsigned) mmap->type); |
*/ |
if( mmap->type != 1) |
continue; |
page = (mmap->base_addr_low+mmap->length_low)&(~4095); |
/kernel/branches/kolibri_pe/core/memory.inc |
---|
461,18 → 461,17 |
jmp .fail |
align 4 |
.kernel_heap: |
shr ebx, 22 |
mov edx, [master_tab + ebx*4] |
test edx, PG_MAP |
jz .check_ptab ;òàáëèöà ñòðàíèö íå ñîçäàíà |
jmp .exit |
jmp .fail |
.check_ptab: |
mov edx, [_sys_pdbr + ebx*4] |
test edx, PG_MAP |
/kernel/branches/kolibri_pe/core/mm.c |
---|
55,10 → 55,10 |
size_t core_size; |
pages = mem_amount >> FRAME_WIDTH; |
// printf("last page = %x total pages = %x\n",mem_amount, pages); |
DBG("last page = %x total pages = %x\n",mem_amount, pages); |
conf_size = pages*sizeof(frame_t); |
// printf("conf_size = %x free mem start =%x\n",conf_size, pg_balloc); |
DBG("conf_size = %x free mem start =%x\n",conf_size, pg_balloc); |
zone_create(&z_core, 0, pages); |
153,7 → 153,7 |
if(top > z->base+z->count) |
top = z->base+z->count; |
// printf("zone reserve base %x top %x\n", base, top); |
DBG("zone reserve base %x top %x\n", base, top); |
for (i = base; i < top; i++) |
zone_mark_unavailable(z, i - z->base); |
174,7 → 174,7 |
if(top > z->base+z->count) |
top = z->base+z->count; |
// printf("zone release base %x top %x\n", base, top); |
DBG("zone release base %x top %x\n", base, top); |
for (i = base; i < top; i++) { |
z->frames[i-z->base].refcount = 0; |
587,7 → 587,7 |
spinlock_unlock(&z_core.lock); |
safe_sti(efl); |
//printf("alloc_page: %x\n", v << FRAME_WIDTH); |
DBG("alloc_page: %x\n", v << FRAME_WIDTH); |
restore_edx(edx); |
return (v << FRAME_WIDTH); |
608,7 → 608,7 |
spinlock_unlock(&z_core.lock); |
safe_sti(efl); |
//printf("alloc_pages: %x count %x\n", v << FRAME_WIDTH, count); |
DBG("alloc_pages: %x count %x\n", v << FRAME_WIDTH, count); |
restore_edx(edx); |