/kernel/branches/kolibri_pe/const.inc |
---|
195,6 → 195,7 |
OS_TEMP equ 0xDFC00000 |
heap_tabs equ (page_tabs+ (HEAP_BASE shr 10)) |
kernel_tabs equ (page_tabs+ (OS_BASE shr 10)) ;0xFDE00000 |
master_tab equ (page_tabs+ (page_tabs shr 10)) ;0xFDFF70000 |
280,7 → 281,7 |
DONT_DRAW_MOUSE equ (OS_BASE+0x000FFF5) |
DONT_SWITCH equ (OS_BASE+0x000FFFF) |
TMP_STACK_TOP equ 0x006CC00 |
;TMP_STACK_TOP equ 0x006CC00 |
FONT_II equ (OS_BASE+0x006DC00) |
FONT_I equ (OS_BASE+0x006E600) |
296,8 → 297,6 |
VGABasePtr equ (OS_BASE+0x00A0000) |
;RAMDISK equ (OS_BASE+0x0100000) |
RAMDISK_FAT equ (OS_BASE+0x0180000) |
FLOPPY_FAT equ (OS_BASE+0x0182000) |
/kernel/branches/kolibri_pe/core/heap.c |
---|
110,7 → 110,7 |
md_t *new_md = (md_t*)slab_alloc(md_slab,0); |
link_initialize(&new_md->link); |
list_insert(&md->adj, &new_md->adj); |
list_insert(&new_md->adj, &md->adj); |
new_md->base = md->base; |
new_md->size = size; |
144,19 → 144,34 |
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); |
if(mask) |
{ |
md_t *tmp; |
idx0 = _bsf(mask); |
ASSERT( !list_empty(&sheap.list[idx0])) |
md = (md_t*)sheap.list[idx0].next; |
tmp = (md_t*)sheap.list[idx0].next; |
list_remove((link_t*)md); |
while((link_t*)tmp != &sheap.list[idx0]) |
{ |
if(tmp->size >= size) |
{ |
//printf("remove tmp %x\n", tmp); |
list_remove((link_t*)tmp); |
if(list_empty(&sheap.list[idx0])) |
_reset_smask(idx0); |
} |
else |
md = tmp; |
break; |
}; |
tmp = (md_t*)tmp->link.next; |
}; |
}; |
if( !md) |
{ |
md_t *lmd; |
lmd = find_large_md((size+0x3FFFFF)&~0x3FFFFF); |
181,7 → 196,7 |
md_t *new_md = (md_t*)slab_alloc(md_slab,0); |
link_initialize(&new_md->link); |
list_insert(&md->adj, &new_md->adj); |
list_insert(&new_md->adj, &md->adj); |
new_md->base = md->base; |
new_md->size = size; |
191,9 → 206,30 |
md->base+= size; |
md->size-= size; |
idx1 = (md->size>>22) - 1 < 32 ? (md->size>>22) - 1 : 31; |
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); |
if( idx1 < 31) |
list_prepend(&md->link, &sheap.list[idx1]); |
else |
{ |
if( list_empty(&sheap.list[31])) |
list_prepend(&md->link, &sheap.list[31]); |
else |
{ |
md_t *tmp = (md_t*)sheap.list[31].next; |
while((link_t*)tmp != &sheap.list[31]) |
{ |
if(md->base < tmp->base) |
break; |
tmp = (md_t*)tmp->link.next; |
} |
list_insert(&md->link, &tmp->link); |
}; |
}; |
_set_smask(idx1); |
safe_sti(efl); |
282,6 → 318,8 |
size = (size+4095)&~4095; |
md = find_small_md(size); |
// printf("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 |
---|
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); |
// printf ("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); |
// 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); |
}; |
mod--; |
rd_base = mod->mod_start+OS_BASE; |
51,7 → 51,7 |
rd_fat_end = rd_base + 512 + 4278; |
rd_root = rd_base + 512*19; |
rd_root_end = rd_base + 512*33; |
printf(" rd_base = %x\n", rd_base); |
// printf(" rd_base = %x\n", rd_base); |
} |
if (CHECK_FLAG (boot_mbi->flags, 6)) |
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); |
// printf ("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,7 → 68,7 |
+ mmap->size + sizeof (mmap->size))) |
{ |
u32_t page; |
/* |
printf (" size = 0x%x, base_addr = 0x%x%x," |
" length = 0x%x%x, type = 0x%x\n", |
(unsigned) mmap->size, |
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/malloc.inc |
---|
986,8 → 986,8 |
stdcall kernel_alloc, 0x40000 |
mov [mst.top], eax |
mov [mst.topsize], 128*1024 |
mov dword [eax+4], (128*1024) or 1 |
mov [mst.topsize], 256*1024 |
mov dword [eax+4], (256*1024) or 1 |
mov eax, mst.smallbins |
@@: |
mov [eax+8], eax |
/kernel/branches/kolibri_pe/core/memory.inc |
---|
31,27 → 31,9 |
align 4 |
proc free_page |
free_page: |
;arg: eax page address |
; pushfd |
; cli |
; shr eax, 12 ;page index |
; bts dword [sys_pgmap], eax ;that's all! |
; cmc |
; adc [pg_data.pages_free], 0 |
; shr eax, 3 |
; and eax, not 3 ;dword offset from page_map |
; add eax, sys_pgmap |
; cmp [page_start], eax |
; ja @f |
; popfd |
; ret |
;@@: |
; mov [page_start], eax |
; popfd |
ret |
endp |
proc map_io_mem stdcall, base:dword, size:dword, flags:dword |
145,9 → 127,6 |
shr esi, 10 |
add esi, page_tabs |
; mov ebp, [pg_data.pages_free] |
; mov ebx, [page_start] |
; mov edx, sys_pgmap |
@@: |
xor eax, eax |
xchg eax, [esi] |
154,27 → 133,11 |
push eax |
invlpg [edi] |
pop eax |
; test eax, 1 |
; jz .next |
; shr eax, 12 |
; bts [edx], eax |
; cmc |
; adc ebp, 0 |
; shr eax, 3 |
; and eax, -4 |
; add eax, edx |
; cmp eax, ebx |
; jae .next |
; mov ebx, eax |
.next: |
add edi, 0x1000 |
add esi, 4 |
dec ecx |
jnz @B |
; mov [pg_data.pages_free], ebp |
and [pg_data.pg_mutex],0 |
popad |
ret |
440,8 → 403,6 |
mov ebx, [.err_addr] |
mov eax, [.err_code] |
; xchg bx, bx |
cmp ebx, HEAP_BASE |
jb .user_space ;ñòðàíèöà â ïàìÿòè ïðèëîæåíèÿ ; |
451,15 → 412,19 |
cmp ebx, page_tabs |
jb .lfb |
cmp ebx, heap_tabs |
jb .user_tabs |
cmp ebx, OS_BASE |
jb .core_tabs |
jb .heap_tab |
jmp .core_tabs |
; cmp ebx, kernel_tabs |
; jb .alloc;.app_tabs ;òàáëèöû ñòðàíèö ïðèëîæåíèÿ ; |
;ïðîñòî ñîçäàäèì îäíó |
.lfb: |
shr ebx, 22 |
mov edx, [_sys_pdbr + ebx*4] |
466,8 → 431,28 |
mov [master_tab + ebx*4], edx |
jmp .exit |
.core_tabs: |
.user_tabs: |
shr ebx, 12 |
and ebx, 0x3FF |
mov edx, [master_tab + ebx*4] |
test edx, PG_MAP |
jnz .fail |
call _alloc_page |
test eax, eax |
jz .fail |
lea edx, [eax + PG_UW] |
lea edi, [eax + OS_BASE] |
mov ecx, 1024 |
xor eax, eax |
cld |
rep stosd |
mov [master_tab + ebx*4], edx |
jmp .exit |
.heap_tab: |
shr ebx, 12 |
and ebx, 0x3FF |
mov edx, [master_tab + ebx*4] |
474,18 → 459,20 |
test edx, PG_MAP |
jz .check_ptab ;òàáëèöà ñòðàíèö íå ñîçäàíà |
jmp .fail |
align 4 |
.kernel_heap: |
mov ecx, ebx |
shr ebx, 22 |
mov edx, [master_tab + ebx*4] |
test edx, PG_MAP |
jz .check_ptab ;òàáëèöà ñòðàíèö íå ñîçäàíà |
shr ecx, 12 |
mov eax, [page_tabs+ecx*4] |
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); |
// printf("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); |
// printf("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); |
// printf("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); |
// printf("zone release base %x top %x\n", base, top); |
for (i = base; i < top; i++) { |
z->frames[i-z->base].refcount = 0; |
586,6 → 586,9 |
v = zone_frame_alloc(&z_core, 0); |
spinlock_unlock(&z_core.lock); |
safe_sti(efl); |
//printf("alloc_page: %x\n", v << FRAME_WIDTH); |
restore_edx(edx); |
return (v << FRAME_WIDTH); |
}; |
604,6 → 607,9 |
v = zone_frame_alloc(&z_core, to_order(count)); |
spinlock_unlock(&z_core.lock); |
safe_sti(efl); |
//printf("alloc_pages: %x count %x\n", v << FRAME_WIDTH, count); |
restore_edx(edx); |
return (v << FRAME_WIDTH); |
/kernel/branches/kolibri_pe/core/taskman.inc |
---|
356,7 → 356,7 |
mov eax, [app_size] |
add eax, 4095 |
and eax, NOT(4095) |
and eax, not 4095 |
mov [app_size], eax |
mov ebx, eax |
shr eax, 12 |
363,39 → 363,49 |
mov [app_pages], eax |
add ebx, 0x3FFFFF |
and ebx, NOT(0x3FFFFF) |
and ebx, not 0x3FFFFF |
shr ebx, 22 |
mov [app_tabs], ebx |
mov ecx, [img_size] |
add ecx, 4095 |
and ecx, NOT(4095) |
and ecx, not 4095 |
mov [img_size], ecx |
shr ecx, 12 |
mov [img_pages], ecx |
if GREEDY_KERNEL |
lea eax, [ecx+ebx+2] ;only image size |
else |
lea eax, [eax+ebx+2] ;all requested memory |
end if |
; if GREEDY_KERNEL |
; lea eax, [ecx+ebx+2] ;only image size |
; else |
; lea eax, [eax+ebx+2] ;all requested memory |
; end if |
; cmp eax, [pg_data.pages_free] |
; ja .fail |
call _alloc_page |
test eax, eax |
mov [dir_addr], eax |
jz .fail |
mov [dir_addr], eax |
;lea edi, [eax + OS_BASE] |
;mov ecx, (OS_BASE shr 20)/4 |
;xor eax, eax |
;cld |
;rep stosd |
;mov ecx, 1024-(OS_BASE shr 20)/4 |
;mov esi, _sys_pdbr+(OS_BASE shr 20) |
;rep movsd |
lea edi, [eax + OS_BASE] |
mov ecx, (OS_BASE shr 20)/4 |
mov ecx, 512 |
xor eax, eax |
cld |
rep stosd |
mov ecx, 1024-(OS_BASE shr 20)/4 |
mov esi, _sys_pdbr+(OS_BASE shr 20) |
mov ecx, 512 |
mov esi, _sys_pdbr+(HEAP_BASE shr 20) |
rep movsd |
mov edi, [dir_addr] |
402,18 → 412,19 |
lea eax, [edi+PG_SW] |
mov [edi+OS_BASE+(page_tabs shr 20)], eax |
and eax, -4096 |
mov eax, edi |
call set_cr3 |
mov edx, [app_tabs] |
xor edi, edi |
mov edi, master_tab |
@@: |
call _alloc_page |
test eax, eax |
jz .fail |
stdcall map_page_table, edi, eax |
add edi, 0x00400000 |
or eax, PG_UW |
stosd |
dec edx |
jnz @B |
/kernel/branches/kolibri_pe/include/link.h |
---|
51,7 → 51,7 |
head->next = link; |
} |
static inline list_insert(link_t *old, link_t *new) |
static inline list_insert(link_t *new, link_t *old) |
{ |
new->prev = old->prev; |
new->next = old; |
/kernel/branches/kolibri_pe/kernel.asm |
---|
399,13 → 399,14 |
mov edi,BOOT_VAR |
mov ecx,0x10000 / 4 |
rep movsd |
xor edi, edi |
xor eax, eax |
mov ecx,0x10000 / 4 |
rep stosd |
mov edi, SLOT_BASE |
mov ecx,0x10000 / 4 |
mov edi, 0x40000 |
mov ecx, (0x90000-0x40000)/4 |
rep stosd |
mov dword [_sys_pdbr], eax |
849,9 → 850,9 |
;protect io permission map |
mov esi, [default_io_map] |
stdcall map_page,esi,(tss._io_map_0-OS_BASE), PG_MAP |
add esi, 0x1000 |
stdcall map_page,esi,(tss._io_map_1-OS_BASE), PG_MAP |
; stdcall map_page,esi,(tss._io_map_0-OS_BASE), PG_MAP |
; add esi, 0x1000 |
; stdcall map_page,esi,(tss._io_map_1-OS_BASE), PG_MAP |
; stdcall map_page,tss._io_map_0,\ |
; (tss._io_map_0-OS_BASE), PG_MAP |
2320,8 → 2321,13 |
cmp ebx,2 ; SET PIXEL |
jnz nosb2 |
cmp ecx,[mem_BACKGROUND] |
jae nosb2 |
mov ebx, [mem_BACKGROUND] |
add ebx, 4095 |
and ebx, -4096 |
sub ebx, 4 |
cmp ecx, ebx |
ja @F |
mov eax,[img_background] |
mov ebx,[eax+ecx] |
and ebx,0xFF000000 ;255*256*256*256 |
2328,8 → 2334,9 |
and edx,0x00FFFFFF ;255*256*256+255*256+255 |
add edx,ebx |
mov [eax+ecx],edx |
; mov [bgrchanged],1 |
@@: |
ret |
nosb2: |
cmp ebx,3 ; DRAW BACKGROUND |
2474,19 → 2481,24 |
mov ax,[BgrDataHeight] |
mov [esp+36],eax |
ret |
nogb1: |
cmp eax,2 ; PIXEL |
jnz nogb2 |
; mov edx,0x160000-16 |
; cmp edx,ebx |
; jbe nogb2 |
; mov eax, [ebx+IMG_BACKGROUND] |
mov ecx, [mem_BACKGROUND] |
add ecx, 4095 |
and ecx, -4096 |
sub ecx, 4 |
cmp ebx, ecx |
ja @F |
mov eax,[img_background] |
mov eax,[ebx+eax] |
and eax, 0xFFFFFF |
mov [esp+36],eax |
@@: |
ret |
nogb2: |
/kernel/branches/kolibri_pe/makefile |
---|
15,7 → 15,8 |
core/heap.inc \ |
core/taskman.inc \ |
core/sys32.inc \ |
core/dll.inc |
core/dll.inc \ |
data32.inc |
PE_SRC:= \ |
init.c \ |