Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Regard whitespace Rev 854 → Rev 853

/kernel/branches/kolibri_pe/include/spinlock.h
File deleted
/kernel/branches/kolibri_pe/include/types.h
File deleted
/kernel/branches/kolibri_pe/include/core.h
File deleted
/kernel/branches/kolibri_pe/include/mm.h
File deleted
/kernel/branches/kolibri_pe/include/atomic.h
File deleted
/kernel/branches/kolibri_pe/include/link.h
File deleted
/kernel/branches/kolibri_pe/boot/start.asm
File deleted
/kernel/branches/kolibri_pe/boot/boot
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/kernel/branches/kolibri_pe/boot/boot.asm
12,11 → 12,6
include "../kglobals.inc"
include "../lang.inc"
 
CR0_PE equ 0x00000001 ;protected mode
CR0_WP equ 0x00010000 ;write protect
CR0_PG equ 0x80000000 ;paging
 
 
public _enter_bootscreen
public _leave_bootscreen
 
65,7 → 60,7
cli
 
mov eax, cr0
or eax, CR0_PG+CR0_WP+CR0_PE
or eax, 0x80000001
mov cr0, eax
 
jmp pword 0x08:__setvars
/kernel/branches/kolibri_pe/boot/init.asm
0,0 → 1,135
 
format MS COFF
 
include '../macros.inc'
 
$Revision: 849 $
 
include "../const.inc"
 
public __start
 
extrn _high_code
extrn __os_stack
extrn _boot_mbi
extrn _sys_pdbr
 
extrn _gdts
extrn __edata
 
section '.init' code readable align 16
 
use32
 
align 4
 
mboot:
dd 0x1BADB002
dd 0x00010003
dd -(0x1BADB002 + 0x00010003)
dd mboot
dd 0x100000
dd __edata; - OS_BASE
dd LAST_PAGE
dd __start
 
align 16
__start:
cld
 
mov esp, __os_stack +(0x100000000-OS_BASE)
push 0
popf
 
cmp eax, 0x2BADB002
mov ecx, sz_invboot
jne .fault
 
bt dword [ebx], 3
mov ecx, sz_nomods
jnc .fault
 
bt dword [ebx], 6
mov ecx, sz_nommap
jnc .fault
 
mov [_boot_mbi+(0x100000000-OS_BASE)], ebx
 
xor eax, eax
cpuid
cmp eax, 0
mov ecx, sz_nopse
jbe .fault
 
mov eax, 1
cpuid
bt edx, 3
mov ecx, sz_nopse
jnc .fault
 
; ENABLE PAGING
 
mov ecx, 32
mov edi, _sys_pdbr+(OS_BASE shr 20)+(0x100000000-OS_BASE)
mov eax, PG_LARGE+PG_SW
@@:
stosd
add eax, 4*1024*1024
loop @B
 
mov dword [_sys_pdbr+(0x100000000-OS_BASE)], PG_LARGE+PG_SW
mov dword [_sys_pdbr+(0x100000000-OS_BASE)+4], PG_LARGE+PG_SW+4*1024*1024
mov dword [_sys_pdbr+(0x100000000-OS_BASE)+(page_tabs shr 20)], _sys_pdbr+PG_SW+(0x100000000-OS_BASE)
 
mov ebx, cr4
or ebx, CR4_PSE
and ebx, not CR4_PAE
mov cr4, ebx
 
mov eax, _sys_pdbr+(0x100000000-OS_BASE)
mov ebx, cr0
or ebx,CR0_PG+CR0_WP
 
mov cr3, eax
mov cr0, ebx
 
mov ebx, [_boot_mbi+(0x100000000-OS_BASE)]
 
mov edx, [ebx+20]
mov esi, [ebx+24]
mov ecx, LAST_PAGE
test edx, edx
jz .no_mods
.scan_mod:
mov ecx, [esi+4]
add esi, 16
dec edx
jnz .scan_mod
 
.no_mods:
add ecx, 4095
and ecx, not 4095
 
lgdt [_gdts+(0x100000000-OS_BASE)]
jmp pword 0x08:_high_code
 
 
.fault:
; push ecx
; call _lcls
; call __bprintf
_hlt:
hlt
jmp _hlt
 
sz_invboot db 'Invalid multiboot loader magic value',0x0A
db 'Halted',0
 
sz_nomods db 'No modules loaded',0x0A
db 'Halted',0
 
sz_nommap db 'No memory table', 0x0A
db 'Halted',0
 
sz_nopse db 'Page size extensions not supported',0x0A
db 'Halted',0
/kernel/branches/kolibri_pe/const.inc
214,7 → 214,7
CDDataBuf equ (OS_BASE+0x0007000)
FLOPPY_BUFF equ (OS_BASE+0x0008000)
ACTIVE_PROC_STACK equ (OS_BASE+0x000A400) ;unused
 
idts equ (OS_BASE+0x000B100)
WIN_STACK equ (OS_BASE+0x000C000)
WIN_POS equ (OS_BASE+0x000C400)
FDD_BUFF equ (OS_BASE+0x000D000)
/kernel/branches/kolibri_pe/data32.inc
269,9 → 269,12
 
endofcode:
gdte:
edata: ;equ $-OS_BASE
 
section '.bss' data writeable align 4096
section '.bss' code readable align 4096
 
org edata
 
align 4096
 
_sys_pdbr rd 1024
283,9 → 286,6
cur_saved_data rb 4096
fpu_data: rb 512
 
 
idts rq 0x41
 
; device irq owners
irq_owner rd 16 ; process id
 
/kernel/branches/kolibri_pe/kernel.asm
114,50 → 114,78
public _gdts
public _high_code
 
public __hlt
public _panic_printf
public _printf
public _pg_balloc
public _mem_amount
public @balloc@4
 
public __setvars
 
extrn _enter_bootscreen
extrn _leave_bootscreen
 
extrn _init
extrn _init_mm
extrn _bx_from_load
 
public _rd_base
public _rd_fat
public _rd_fat_end
public _rd_root
public _rd_root_end
section '.flat' code readable align 16
 
extrn _alloc_pages
extrn _alloc_page
use32
 
extrn _bx_from_load
org 0xE0102000
 
section '.flat' code readable align 4096
 
use32
 
align 4
 
use32
 
 
; CLEAR 0x280000 - HEAP_BASE
 
; xor eax,eax
; mov edi,0x280000
; mov ecx,(0x800000-0x280000) / 4
; cld
; rep stosd
 
; mov edi,0x40000
; mov ecx,(0x90000-0x40000)/4
; rep stosd
 
; CLEAR KERNEL UNDEFINED GLOBALS
; mov edi, endofcode-OS_BASE
; mov ecx, (uglobals_size/4)+4
; rep stosd
 
 
; call test_cpu
; bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc
bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc
 
; call init_BIOS32
 
; mov dword [sys_pgdir-OS_BASE], PG_LARGE+PG_SW
; mov dword [sys_pgdir-OS_BASE+4], PG_LARGE+PG_SW+4*1024*1024
 
; mov ecx, 32
; lea edi, [sys_pgdir-OS_BASE+0xE00]
; mov eax, PG_LARGE+PG_SW
;@@:
; stosd
; add eax, 4*1024*1024
; loop @B
 
; mov ebx, cr4
; or ebx, CR4_PSE
; and ebx, not CR4_PAE
; mov cr4, ebx
 
 
; mov eax, sys_pgdir-OS_BASE
; mov ebx, cr0
; or ebx,CR0_PG+CR0_WP
 
; mov cr3, eax
; mov cr0, ebx
 
; lgdt [gdts]
; jmp pword os_code:high_code
 
align 4
;bios32_entry dd ?
;tmp_page_tabs dd ?
bios32_entry dd ?
tmp_page_tabs dd ?
 
 
__DEBUG__ fix 1
169,22 → 197,12
MEM_UC equ 0 ;uncached memory
 
 
__hlt:
cli
@@:
hlt
jmp @B
include 'printf.inc'
include 'core/mm.asm'
 
align 4
_panic_printf:
include 'core/init.asm'
 
mov dword [esp], __hlt
jmp _printf
 
align 4
include 'printf.inc'
 
align 4
proc test_cpu
locals
cpu_type dd ?
285,7 → 303,6
 
align 4
_high_code:
 
mov ax,os_stack
mov dx,app_data
mov ss,ax
296,7 → 313,10
mov fs, dx
mov gs, dx
 
; push ecx
; push ebx
 
 
; bt [cpu_caps], CAPS_PGE
; jnc @F
 
529,9 → 549,11
wrmsr
.noSYSCALL:
; -----------------------------------------
 
; LOAD IDT
 
call _init_idt
call build_interrupt_table
lidt [idtreg]
 
mov [LFBSize], 0x800000
call init_LFB
598,7 → 620,7
stdcall kernel_alloc, [mem_BACKGROUND]
mov [img_background], eax
 
mov [SLOT_BASE + 256 + APPDATA.dir_table], _sys_pdbr + (0x100000000-OS_BASE)
mov [SLOT_BASE + 256 + APPDATA.dir_table], _sys_pdbr - OS_BASE
 
; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f
 
627,6 → 649,8
include 'detect/disks.inc'
;!!!!!!!!!!!!!!!!!!!!!!!!!!
 
xchg bx, bx
 
call Parser_params
 
; READ RAMDISK IMAGE FROM HD
/kernel/branches/kolibri_pe/ld.x
12,15 → 12,15
.boot . + __image_base__ :
{
*(.boot)
*(.start)
*(.init)
. = ALIGN(4096);
}
 
.flat . + 0xE0000000:
.flat :
{
*(.flat) *(.text) *(.rdata) *(.data)
*(.flat)
}
__edata = . - 0xE0000000;
__edata = .;
 
.bss ALIGN(4096) :
{
/kernel/branches/kolibri_pe/makefile
2,21 → 2,16
CC = gcc
FASM = fasm.exe
 
INCLUDE = include/
INCLUDE = include
 
DEFS = -DUSE_SMP
 
CFLAGS = -c -O2 -DCONFIG_DEBUG -I $(INCLUDE) -fomit-frame-pointer -fno-builtin-printf -masm=intel
CFLAGS = -c -O2 -I $(INCLUDE) -fomit-frame-pointer -fno-builtin-printf -masm=intel
LDFLAGS = -shared -s -Map kernel.map --image-base 0x100000 --file-alignment 32
 
 
KERNEL_SRC:= \
kernel.asm \
init.c \
mm.c \
spinlock.c \
boot/boot.asm \
boot/start.asm
boot/init.asm
 
KERNEL_OBJS = $(patsubst %.s, bin/%.obj, $(patsubst %.asm, bin/%.obj,\
31,12 → 26,12
kernel.mnt: $(KERNEL_OBJS) Makefile ld.x
ld $(LDFLAGS) -T ld.x -o $@ $(KERNEL_OBJS)
 
bin/%.obj : core/%.c Makefile
$(CC) $(CFLAGS) -o $@ $<
bin/%.obj: %.asm
$(FASM) $< $@
 
bin/%.obj : core/%.c
$(CC) $(CFLAGS) -o $@ -c $<
 
all: $(SUBDIRS)
 
.PHONY: all
/kernel/branches/kolibri_pe/core/mm.c
File deleted
/kernel/branches/kolibri_pe/core/multiboot.h
File deleted
/kernel/branches/kolibri_pe/core/init.c
File deleted
/kernel/branches/kolibri_pe/core/spinlock.c
File deleted
/kernel/branches/kolibri_pe/core/memory.inc
231,7 → 231,7
cmp dword [LFBAddress], -1
jne @f
mov [BOOT_VAR+0x901c],byte 2
stdcall _alloc_pages, 0x280000 shr 12
stdcall alloc_pages, 0x280000 shr 12
add eax, OS_BASE
mov [LFBAddress], eax
ret
325,7 → 325,7
xchg esi, edi
 
@@:
call _alloc_page
call alloc_page
test eax, eax
jz .exit
 
347,7 → 347,7
pop edi
pop esi
@@:
call _alloc_page
call alloc_page
test eax, eax
jz .exit
stdcall map_page,esi,eax,dword PG_UW
477,21 → 477,17
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]
 
.check_ptab:
mov edx, [_sys_pdbr + ebx*4]
test edx, PG_MAP
jnz @F
 
call _alloc_page
call alloc_page
test eax, eax
jz .fail
 
526,7 → 522,7
jz .fail ;àäðåñ íå çàðåçåðâèðîâàí äëÿ ;
;èñïîëüçîâàíèÿ. Îøèáêà
.alloc:
call _alloc_page
call alloc_page
test eax, eax
jz .fail
 
570,7 → 566,7
; io permission map
; copy-on-write protection
 
call _alloc_page
call alloc_page
test eax, eax
jz .fail
 
1184,7 → 1180,7
shr ebx, 12
push ebx
 
stdcall _alloc_pages, ebx
stdcall alloc_pages, ebx
pop ecx
 
test eax, eax
/kernel/branches/kolibri_pe/core/taskman.inc
383,7 → 383,7
; cmp eax, [pg_data.pages_free]
; ja .fail
 
call _alloc_page
call alloc_page
test eax, eax
jz .fail
mov [dir_addr], eax
408,7 → 408,7
mov edx, [app_tabs]
xor edi, edi
@@:
call _alloc_page
call alloc_page
test eax, eax
jz .fail
 
450,7 → 450,7
else
 
.alloc:
call _alloc_page
call alloc_page
test eax, eax
jz .fail
 
944,7 → 944,7
pl0_stack dd ?
endl
 
stdcall _alloc_pages, (RING0_STACK_SIZE+512) shr 12
stdcall alloc_pages, (RING0_STACK_SIZE+512) shr 12
add eax, OS_BASE
mov [pl0_stack], eax
 
988,7 → 988,7
add eax, RING0_STACK_SIZE
mov [SLOT_BASE+APPDATA.saved_esp0+ebx], eax
 
call _alloc_page
call alloc_page
add eax, OS_BASE
mov esi,[current_slot]
mov esi,[esi+APPDATA.cur_dir]
/kernel/branches/kolibri_pe/core/init.asm
0,0 → 1,151
DWORD equ dword
WORD equ word
BYTE equ byte
 
PTR equ
 
_init:
push esi
push ebx
sub esp, 4
mov eax, DWORD PTR [_boot_mbi]
test BYTE PTR [eax], 2
je .L2
push ecx
push ecx
push DWORD PTR [eax+12]
push .LC0
call _printf
add esp, 16
.L2:
mov eax, DWORD PTR [_boot_mbi]
test BYTE PTR [eax], 4
je L4
push edx
push edx
push DWORD PTR [eax+16]
push .LC1
call _printf
add esp, 16
.L4:
mov eax, DWORD PTR [_boot_mbi]
test BYTE PTR [eax], 8
je .L6
push esi
xor esi, esi
push DWORD PTR [eax+24]
push DWORD PTR [eax+20]
push .LC2
call _printf
mov eax, DWORD PTR [_boot_mbi]
mov ebx, DWORD PTR [eax+24]
jmp .L22
.L9:
mov eax, DWORD PTR [ebx-12]
inc esi
push DWORD PTR [ebx-8]
mov DWORD PTR [_pg_balloc], eax
push eax
push DWORD PTR [ebx-16]
push .LC3
call _printf
.L22:
mov eax, DWORD PTR [_boot_mbi]
add esp, 16
mov edx, ebx
add ebx, 16
cmp esi, DWORD PTR [eax+20]
jb .L9
mov edx, DWORD PTR [edx-16]
push ebx
push ebx
sub edx, 536870912
lea eax, [edx+512]
mov DWORD PTR [_rd_fat], eax
lea eax, [edx+4790]
push edx
push .LC4
mov DWORD PTR [_rd_fat_end], eax
lea eax, [edx+9728]
mov DWORD PTR [_rd_root], eax
lea eax, [edx+16896]
mov DWORD PTR [_rd_base], edx
mov DWORD PTR [_rd_root_end], eax
call _printf
add esp, 16
.L6:
mov eax, DWORD PTR [_boot_mbi]
xor esi, esi
test BYTE PTR [eax], 64
je .L13
push ecx
push DWORD PTR [eax+44]
push DWORD PTR [eax+48]
push .LC5
call _printf
mov eax, DWORD PTR [_boot_mbi]
add esp, 16
mov ebx, DWORD PTR [eax+48]
jmp .L14
.L15:
push edx
push DWORD PTR [ebx+20]
push DWORD PTR [ebx+12]
push DWORD PTR [ebx+16]
push DWORD PTR [ebx+4]
push DWORD PTR [ebx+8]
push DWORD PTR [ebx]
push .LC6
call _printf
add esp, 32
cmp DWORD PTR [ebx+20], 1
jne .L16
mov eax, DWORD PTR [ebx+4]
add eax, DWORD PTR [ebx+12]
and eax, -4096
cmp esi, eax
jae .L16
mov esi, eax
.L16:
mov eax, DWORD PTR [ebx]
add eax, 4
lea ebx, [eax+ebx]
.L14:
mov edx, DWORD PTR [_boot_mbi]
mov eax, DWORD PTR [edx+48]
add eax, DWORD PTR [edx+44]
cmp ebx, eax
jb .L15
cmp esi, 268435456
jbe .L13
mov esi, 268435456
.L13:
mov DWORD PTR [_mem_amount], esi
pop eax
pop ebx
pop esi
ret
 
 
.LC0:
db "boot_device = 0x%x",10,0
.LC1:
db "cmdline = %s",10,0
.LC2:
db "mods_count = %d, mods_addr = 0x%x",10,0
.LC3:
db " mod_start = 0x%x, mod_end = 0x%x, string = %s",10,0
.LC4:
db " rd_base = %x",10,0
.LC5:
db "mmap_addr = 0x%x, mmap_length = 0x%x",10,0
.LC6:
db " size = 0x%x, base_addr = 0x%x%x, length = 0x%x%x, type = 0x%x",10,0
 
 
restore DWORD
restore WORD
restore BYTE
 
restore PTR
 
/kernel/branches/kolibri_pe/core/mm.asm
0,0 → 1,687
DWORD equ dword
WORD equ word
BYTE equ byte
 
PTR equ
 
_mem_counter equ (BOOT_VAR + 0x9100)
_mem_table equ (BOOT_VAR + 0x9104)
 
_spinlock_initialize:
mov eax, DWORD PTR [esp+4]
mov DWORD PTR [eax], 0
ret
 
_buddy_find_block:
push ebx
mov eax, DWORD PTR [eax+12]
mov ebx, ecx
sub edx, eax
sar edx, 2
imul ecx, edx, -858993459
lea eax, [eax+edx*4]
.L4:
cmp DWORD PTR [eax+12], ebx
jne .L7
sub ecx, 1
sub eax, 20
cmp ecx, -1
jne .L4
xor eax, eax
.L7:
pop ebx
ret
 
@buddy_system_free@8:
push ebp
mov ebp, edx
push edi
push esi
mov esi, edx
push ebx
sub esp, 8
mov ebx, DWORD PTR [edx+12]
mov DWORD PTR [esp+4], ecx
cmp BYTE PTR [ecx+24], bl
mov edi, ebx
je .L17
mov edx, DWORD PTR [ecx+12]
mov DWORD PTR [esp], edx
jmp .L15
.L30:
mov eax, 1
sal eax, cl
add edx, eax
mov eax, DWORD PTR [esp+4]
cmp edx, DWORD PTR [eax+8]
jae .L17
.L31:
lea eax, [edx+edx*4]
mov edx, DWORD PTR [esp]
lea ecx, [edx+eax*4]
cmp ebx, DWORD PTR [ecx+12]
jne .L17
mov eax, DWORD PTR [ecx+8]
test eax, eax
jne .L17
mov eax, DWORD PTR [ecx+4]
cmp esi, ecx
mov edx, DWORD PTR [ecx]
mov DWORD PTR [esi+12], 255
mov DWORD PTR [ecx+12], 255
mov DWORD PTR [eax], edx
mov edx, DWORD PTR [ecx]
mov DWORD PTR [ecx], 0
mov DWORD PTR [edx+4], eax
mov edx, ebp
mov DWORD PTR [ecx+4], 0
jb .L26
mov edx, ecx
.L26:
mov ecx, edi
mov esi, edx
movzx eax, cl
mov ebp, edx
lea ebx, [eax+1]
mov eax, DWORD PTR [esp+4]
mov DWORD PTR [edx+12], ebx
movzx edi, BYTE PTR [eax+24]
mov edx, edi
cmp dl, bl
je .L17
mov edi, ebx
.L15:
mov eax, esi
mov ecx, ebx
sub eax, DWORD PTR [esp]
sar eax, 2
imul edx, eax, -858993459
mov eax, edx
shr eax, cl
test al, 1
je .L30
mov eax, 1
mov ecx, ebx
sal eax, cl
sub edx, eax
mov eax, DWORD PTR [esp+4]
cmp edx, DWORD PTR [eax+8]
jb .L31
.L17:
mov ecx, edi
movzx edx, cl
mov ecx, DWORD PTR [esp+4]
mov eax, DWORD PTR [ecx+28+edx*8]
mov DWORD PTR [ebp], eax
lea eax, [ecx+28+edx*8]
mov DWORD PTR [ebp+4], eax
mov eax, DWORD PTR [ecx+28+edx*8]
mov DWORD PTR [ecx+28+edx*8], ebp
mov DWORD PTR [eax+4], ebp
add esp, 8
pop ebx
pop esi
pop edi
pop ebp
ret
 
@buddy_system_alloc_block@8:
push ebp
mov ebp, ecx
push edi
mov ecx, 255
push esi
mov eax, ebp
push ebx
sub esp, 4
mov DWORD PTR [esp], edx
call _buddy_find_block
mov ebx, eax
mov eax, DWORD PTR [eax+4]
mov edx, DWORD PTR [ebx]
mov DWORD PTR [eax], edx
mov edx, DWORD PTR [ebx]
mov DWORD PTR [ebx], 0
mov DWORD PTR [edx+4], eax
mov eax, DWORD PTR [ebx+12]
mov DWORD PTR [ebx+4], 0
test eax, eax
jne .L38
jmp .L34
.L35:
mov DWORD PTR [ebx+8], 1
mov edx, esi
mov ecx, ebp
call @buddy_system_free@8
mov eax, DWORD PTR [ebx+12]
mov DWORD PTR [ebx+8], 0
test eax, eax
je .L34
.L38:
lea ecx, [eax-1]
mov edx, DWORD PTR [esp]
mov eax, 20
sal eax, cl
lea edi, [ebx+eax]
mov eax, ebp
mov DWORD PTR [ebx+12], ecx
mov esi, edi
mov DWORD PTR [edi+12], ecx
mov ecx, 255
call _buddy_find_block
cmp edi, eax
jne .L35
mov esi, ebx
mov ebx, edi
jmp .L35
.L34:
mov DWORD PTR [ebx+8], 1
mov eax, ebx
add esp, 4
pop ebx
pop esi
pop edi
pop ebp
ret
 
_zone_release:
push edi
push esi
push ebx
mov esi, DWORD PTR [esp+16]
mov eax, DWORD PTR [esp+20]
mov edi, DWORD PTR [esp+24]
mov edx, DWORD PTR [esi+4]
add edi, eax
cmp edi, edx
jb .L48
mov ebx, edx
add ebx, DWORD PTR [esi+8]
cmp eax, ebx
ja .L48
cmp eax, edx
mov ecx, eax
jae .L44
mov ecx, edx
.L44:
cmp edi, ebx
jbe .L45
mov edi, ebx
.L45:
cmp ecx, edi
jae .L48
mov ebx, ecx
.L47:
mov edx, DWORD PTR [esi+12]
mov eax, ecx
add ebx, 1
sub eax, DWORD PTR [esi+4]
lea eax, [eax+eax*4]
mov DWORD PTR [edx+8+eax*4], 0
sub ecx, DWORD PTR [esi+4]
lea edx, [ecx+ecx*4]
mov ecx, esi
sal edx, 2
add edx, DWORD PTR [esi+12]
call @buddy_system_free@8
cmp edi, ebx
mov ecx, ebx
ja .L47
.L48:
pop ebx
pop esi
pop edi
ret
 
_zone_reserve:
push edi
push esi
push ebx
mov esi, DWORD PTR [esp+16]
mov eax, DWORD PTR [esp+20]
mov ebx, DWORD PTR [esp+24]
mov edx, DWORD PTR [esi+4]
add ebx, eax
cmp ebx, edx
jb .L61
mov ecx, edx
add ecx, DWORD PTR [esi+8]
cmp eax, ecx
ja .L61
cmp eax, edx
jae .L54
mov eax, edx
.L54:
cmp ebx, ecx
mov edi, ebx
jbe .L55
mov edi, ecx
.L55:
cmp eax, edi
jae .L61
mov ebx, eax
jmp .L57
.L58:
add ebx, 1
cmp edi, ebx
mov eax, ebx
jbe .L61
.L62:
mov edx, DWORD PTR [esi+4]
.L57:
sub eax, edx
lea eax, [eax+eax*4]
lea edx, [0+eax*4]
add edx, DWORD PTR [esi+12]
mov ecx, DWORD PTR [edx+8]
test ecx, ecx
jne .L58
add ebx, 1
mov ecx, esi
call @buddy_system_alloc_block@8
mov eax, ebx
sub DWORD PTR [esi+16], 1
cmp edi, ebx
ja .L62
.L61:
pop ebx
pop esi
pop edi
ret
 
@buddy_system_alloc@8:
sub esp, 12
mov DWORD PTR [esp], ebx
lea eax, [ecx+28+edx*8]
mov ebx, edx
mov DWORD PTR [esp+4], esi
mov esi, ecx
mov DWORD PTR [esp+8], edi
cmp DWORD PTR [ecx+32+edx*8], eax
je .L64
mov ecx, DWORD PTR [ecx+32+edx*8]
mov eax, DWORD PTR [ecx+4]
mov edx, DWORD PTR [ecx]
mov DWORD PTR [ecx+8], 1
mov DWORD PTR [eax], edx
mov edx, DWORD PTR [ecx]
mov DWORD PTR [ecx], 0
mov DWORD PTR [edx+4], eax
mov DWORD PTR [ecx+4], 0
.L66:
mov ebx, DWORD PTR [esp]
mov eax, ecx
mov esi, DWORD PTR [esp+4]
mov edi, DWORD PTR [esp+8]
add esp, 12
ret
.L64:
movzx eax, BYTE PTR [ecx+24]
cmp eax, edx
jne .L71
.L67:
xor ecx, ecx
jmp .L66
.L71:
lea edx, [edx+1]
call @buddy_system_alloc@8
test eax, eax
mov edi, eax
je .L67
mov ecx, DWORD PTR [eax+12]
mov edx, 20
mov DWORD PTR [eax+12], ebx
mov DWORD PTR [eax+8], 1
sub ecx, 1
sal edx, cl
mov ecx, esi
add edx, eax
mov DWORD PTR [edx+12], ebx
call @buddy_system_free@8
mov ecx, edi
jmp .L66
 
_zone_frame_alloc:
sub esp, 8
mov ecx, eax
mov DWORD PTR [esp], ebx
mov ebx, eax
mov DWORD PTR [esp+4], esi
mov esi, edx
call @buddy_system_alloc@8
mov ecx, esi
mov edx, 1
sal edx, cl
mov esi, DWORD PTR [esp+4]
sub DWORD PTR [ebx+16], edx
sub eax, DWORD PTR [ebx+12]
add DWORD PTR [ebx+20], edx
mov ebx, DWORD PTR [esp]
add esp, 8
sar eax, 2
imul eax, eax, -858993459
ret
 
_frame_set_parent:
mov eax, DWORD PTR [esp+4]
sub eax, DWORD PTR [_z_core+4]
mov ecx, DWORD PTR [esp+8]
mov edx, DWORD PTR [_z_core+12]
lea eax, [eax+eax*4]
mov DWORD PTR [edx+16+eax*4], ecx
ret
 
@zone_free@8:
sub esp, 8
lea edx, [edx+edx*4]
mov DWORD PTR [esp], ebx
sal edx, 2
mov ebx, ecx
mov DWORD PTR [esp+4], esi
add edx, DWORD PTR [ecx+12]
mov eax, DWORD PTR [edx+8]
mov esi, DWORD PTR [edx+12]
sub eax, 1
test eax, eax
mov DWORD PTR [edx+8], eax
jne .L79
call @buddy_system_free@8
mov eax, 1
mov ecx, esi
sal eax, cl
add DWORD PTR [ebx+16], eax
sub DWORD PTR [ebx+20], eax
.L79:
mov ebx, DWORD PTR [esp]
mov esi, DWORD PTR [esp+4]
add esp, 8
ret
 
 
@zone_alloc@8:
sub esp, 8
mov DWORD PTR [esp], ebx
mov ebx, ecx
mov DWORD PTR [esp+4], esi
 
pushf
pop esi
cli
 
@@:
pause
mov eax, [_z_core]
test eax, eax
jnz @b
inc eax
xchg [_z_core], eax
test eax, eax
jnz @b
 
mov eax, ecx
call _zone_frame_alloc
mov edx, DWORD PTR [ebx+4]
mov DWORD PTR [ebx], 0
 
push esi
popf
 
mov ebx, DWORD PTR [esp]
add eax, edx
mov esi, DWORD PTR [esp+4]
sal eax, 12
add esp, 8
ret
 
alloc_page:
_alloc_page:
push ebx
 
pushf
pop ebx
cli
@@:
pause
mov eax, [_z_core]
test eax, eax
jnz @b
inc eax
xchg [_z_core], eax
test eax, eax
jnz @b
 
push edx
xor edx, edx
mov eax, _z_core
call _zone_frame_alloc
pop edx
mov [_z_core], 0
 
push ebx
popf
 
pop ebx
sal eax, 12
ret
 
alloc_pages:
_alloc_pages@4:
push ebx
 
pushf
pop ebx
cli
@@:
pause
mov eax, [_z_core]
test eax, eax
jnz @b
inc eax
xchg [_z_core], eax
test eax, eax
jnz @b
 
mov eax, DWORD PTR [esp+8]
add eax, 7
and eax, -8
 
xor ecx, ecx
bsr ecx, eax
inc ecx
 
push edx
 
mov edx, ecx
mov eax, _z_core
call _zone_frame_alloc
pop edx
 
mov [_z_core], 0
push ebx
popf
 
pop ebx
sal eax, 12
ret 4
 
_zone_create:
push esi
push ebx
sub esp, 4
mov ebx, DWORD PTR [esp+16]
mov esi, DWORD PTR [esp+24]
mov DWORD PTR [esp], ebx
call _spinlock_initialize
mov eax, DWORD PTR [esp+20]
mov DWORD PTR [ebx+8], esi
mov DWORD PTR [ebx+16], esi
mov DWORD PTR [ebx+20], 0
mov DWORD PTR [ebx+4], eax
 
xor eax, eax
bsr eax, esi
 
xor edx, edx
mov BYTE PTR [ebx+24], al
.L81:
lea eax, [ebx+28+edx*8]
mov DWORD PTR [ebx+28+edx*8], eax
mov DWORD PTR [ebx+32+edx*8], eax
movzx eax, BYTE PTR [ebx+24]
add edx, 1
cmp eax, edx
jae .L81
lea ecx, [esi+esi*4]
sal ecx, 2
call @balloc@4
test esi, esi
mov DWORD PTR [ebx+12], eax
je .L83
xor ecx, ecx
xor edx, edx
.L85:
mov eax, edx
add ecx, 1
add eax, DWORD PTR [ebx+12]
add edx, 20
cmp ecx, esi
mov DWORD PTR [eax+8], 1
mov DWORD PTR [eax+12], 0
jne .L85
.L83:
add esp, 4
mov eax, 1
pop ebx
pop esi
ret
 
_init_mm:
push ebx
sub esp, 24
mov eax, DWORD PTR [_mem_amount]
mov DWORD PTR [esp], .LC3
mov ebx, eax
shr ebx, 12
mov DWORD PTR [esp+8], ebx
mov DWORD PTR [esp+4], eax
call _printf
mov eax, DWORD PTR [_pg_balloc]
mov DWORD PTR [esp], .LC4
mov DWORD PTR [esp+8], eax
lea eax, [ebx+ebx*4]
sal eax, 2
mov DWORD PTR [esp+4], eax
call _printf
mov DWORD PTR [esp+8], ebx
mov DWORD PTR [esp+4], 0
mov DWORD PTR [esp], _z_core
call _zone_create
mov DWORD PTR [esp+8], ebx
mov DWORD PTR [esp+4], 0
mov DWORD PTR [esp], _z_core
call _zone_release
mov eax, DWORD PTR [_pg_balloc]
mov DWORD PTR [esp+4], 0
mov DWORD PTR [esp], _z_core
shr eax, 12
mov DWORD PTR [esp+8], eax
call _zone_reserve
add esp, 24
pop ebx
ret
.LC3:
db "last page = %x total pages = %x",10,0
.LC4:
db "conf_size = %x free mem start =%x",10,0
 
 
_frame_free:
push ebx
mov edx, DWORD PTR [esp+8]
 
pushf
pop ebx
cli
@@:
pause
mov eax, [_z_core]
test eax, eax
jnz @b
inc eax
xchg [_z_core], eax
test eax, eax
jnz @b
 
mov ecx, _z_core
shr edx, 12
call @zone_free@8
mov [_z_core], 0
 
push ebx
popf
 
pop ebx
ret
 
_core_free:
push ebx
mov edx, DWORD PTR [esp+8]
 
pushf
pop ebx
cli
@@:
pause
mov eax, [_z_core]
test eax, eax
jnz @b
inc eax
xchg [_z_core], eax
test eax, eax
jnz @b
 
mov ecx, _z_core
shr edx, 12
call @zone_free@8
mov [_z_core], 0
 
push ebx
popf
 
pop ebx
ret
 
_core_alloc:
push ebx
pushf
pop ebx
cli
@@:
pause
mov eax, [_z_core]
test eax, eax
jnz @b
inc eax
xchg [_z_core], eax
test eax, eax
jnz @b
 
mov edx, DWORD PTR [esp+8]
mov eax, _z_core
call _zone_frame_alloc
mov [_z_core], 0
 
push ebx
popf
 
pop ebx
sal eax, 12
ret
 
 
restore DWORD
restore WORD
restore BYTE
 
restore PTR
 
/kernel/branches/kolibri_pe/core/heap.inc
575,7 → 575,7
 
and ebx, not 7
push ebx
stdcall _alloc_pages, ebx
stdcall alloc_pages, ebx
pop ecx ; yes ecx!!!
test eax, eax
jz .err
594,7 → 594,7
jz .end
@@:
push ecx
call _alloc_page
call alloc_page
pop ecx
test eax, eax
jz .err
/kernel/branches/kolibri_pe/core/sys32.inc
13,13 → 13,15
 
$Revision$
 
 
align 4
_init_idt:
push edi
push esi
mov edi, idts
mov dword [idtreg+2], edi
idtreg:
dw 8*0x41-1
dd idts+8
 
build_interrupt_table:
 
mov edi, idts+8
mov esi, sys_int
mov ecx, 0x40
@@:
31,29 → 33,17
add edi, 8
loop @b
 
mov eax, i40
mov ecx, i40
and eax, 0x0000FFFF
and ecx, 0xFFFF0000
or eax, os_code shl 16
or ecx, (11101111b shl 8)
mov [edi], eax
mov [edi+4], ecx
 
lidt [idtreg]
pop esi
pop edi
;mov edi,8*0x40+idts+8
mov dword [edi], (i40 and 0xFFFF) or (os_code shl 16)
mov dword [edi+4], (11101111b shl 8) or (i40 and 0xFFFF0000)
; type: trap gate
ret
 
 
 
iglobal
 
msg_sel_ker db "kernel", 0
msg_sel_app db "application", 0
 
align 4
 
sys_int:
dd e0,debug_exc,e2,e3
dd e4,e5,e6,e7
76,11 → 66,6
times 16 dd unknown_interrupt
 
dd i40
 
idtreg:
dw 8*0x41-1
dd idts
 
endg
 
macro save_ring3_context
/kernel/branches/kolibri_pe/core/exports.inc
103,8 → 103,8
dd szPciWrite16 , pci_write16
dd szPciWrite32 , pci_write32
 
dd szAllocPage , _alloc_page ;stdcall
dd szAllocPages , _alloc_pages ;stdcall
dd szAllocPage , alloc_page ;stdcall
dd szAllocPages , alloc_pages ;stdcall
dd szFreePage , free_page
dd szMapPage , map_page ;stdcall
dd szMapSpace , map_space
/kernel/branches/kolibri_pe/core/export.inc
17,16 → 17,16
forward
count = count+1
common
dd 0,0,0, (module+(0x100000000-OS_BASE)) , 1
dd count,count,(addresses+(0x100000000-OS_BASE)),(names+(0x100000000-OS_BASE)),(ordinal+(0x100000000-OS_BASE))
dd 0,0,0, (module-OS_BASE) , 1
dd count,count,(addresses-OS_BASE),(names-OS_BASE),(ordinal-OS_BASE)
addresses:
forward
dd (label+(0x100000000-OS_BASE))
dd (label-OS_BASE)
common
names:
forward
local name
dd (name+(0x100000000-OS_BASE))
dd (name-OS_BASE)
common
ordinal: count = 0
forward
/kernel/branches/kolibri_pe/network/eth_drv/drivers/sis900.inc
458,7 → 458,7
;*************** load Transmit Descriptor Register ***************
mov dx, [io_addr] ; base address
add dx, SIS900_txdp ; TX Descriptor Pointer
mov eax, txd + (0x100000000-OS_BASE) ; First Descriptor
mov eax, txd - OS_BASE ; First Descriptor
out dx, eax ; move the pointer
ret
 
486,7 → 486,7
xor ebx, ebx ;
SIS900_init_rxd_Loop_0: ;
imul ebx, 12 ;
add ebx, rxd + (0x100000000-OS_BASE);
add ebx, rxd - OS_BASE ;
mov [rxd+eax], ebx ;save link to next descriptor
mov [rxd+eax+4],dword RX_BUFF_SZ ;status bits init to buf size
mov ebx, ecx ;find where the buf is located
500,7 → 500,7
; descriptor*********
mov dx, [io_addr]
add dx, SIS900_rxdp
mov eax, rxd + (0x100000000-OS_BASE)
mov eax, rxd - OS_BASE
out dx, eax
ret
 
998,7 → 998,7
out dx, eax
;*******load Transmit Descriptor Register *******
lea edx,[ebp+SIS900_txdp]
mov eax, txd + (0x100000000-OS_BASE)
mov eax, txd - OS_BASE
out dx, eax
;******* copy packet to descriptor*******
push esi