Subversion Repositories Kolibri OS

Compare Revisions

Ignore whitespace Rev 834 → Rev 837

/kernel/branches/kolibri_pe/boot/bootcode.inc
144,7 → 144,7
;
;=========================================================================
 
include 'bootvesa.inc' ;Include source for boot vesa
include 'bootvesa.inc' ;Include source for boot vesa
 
start_of_code:
cld
499,7 → 499,7
push dword [es:8*4]
pop dword [.oldtimer]
push dword [.timer]
pop dword [es:8*4]
pop dword [es:8*4]
; mov eax, [es:8*4]
; mov [.oldtimer], eax
; mov eax, [.timer]
577,7 → 577,7
.down: cmp ah,0x50;x,0x50E0 ; down
jne .pgup
cmp word[es:si+10],-1
je .loops
je .loops
add word [cursor_pos],size_of_step
jmp .loops
 
629,7 → 629,7
push word [es:bp+6]
pop word [number_vm]
mov word [preboot_graph],bp ;save choose
 
jmp .d
 
.change_b:
846,7 → 846,7
; TODO: !!!! read only first sector and set variables !!!!!
; ...
; TODO: !!! then read flippy image track by track
 
mov cx, 0x0001 ; startcyl,startsector
.a1:
push cx dx
935,7 → 935,7
; and copy them to extended memory
mov si, movedesc
mov [si+8*2+3], bh ; from
 
mov ax, word [BPB_BytsPerSec]
shr ax, 1 ; words per sector
mov cx, word [BPB_RsvdSecCnt]
943,7 → 943,7
mul cx
push ax ; save to stack count of words in boot+FAT
xchg ax, cx
 
push es
push ds
pop es
968,7 → 968,7
; TODO: BPB_NumFATs !!!!!
add bx, word [BPB_BytsPerSec] ; !!! TODO: may be need multiply by BPB_RsvdSecCnt !!!
mov byte [si+8*2+3], bh ; bx - begin of FAT
 
mov ax, word [BPB_BytsPerSec]
shr ax, 1 ; words per sector
mov cx, word [BPB_FATSz16]
983,12 → 983,12
pop es
test ah, ah
jnz sayerr_floppy
 
mov ax, cx
shl ax, 1
and eax, 0ffffh ; ax - count of bytes in FAT
add dword [si+8*3+2], eax
 
; reading RootDir
; TODO: BPB_NumFATs
add bx, ax
1013,7 → 1013,7
pop bx
push bx
add word [FirstDataSector], bx ; Begin of data region of floppy
 
; read RootDir
call conv_abs_to_THS
pop ax
1135,6 → 1135,31
out dx, al
 
 
; GET SMAP
 
xor ebx, ebx
mov es, bx
 
mov edi, 0x9104
mov ecx, 20
mov edx, 0x534D4150
@@:
mov [es:0x9100], ebx
mov eax, 0xe820
int 0x15
 
jc .nosmap
cmp eax, 0x534D4150
jne .nosmap
 
test ebx, ebx
jz .nosmap
 
add edi, ecx
jmp @B
 
.nosmap:
 
; SET GRAPHICS
 
xor ax, ax
/kernel/branches/kolibri_pe/boot/preboot.inc
23,13 → 23,13
number_vm dw 0 ;
;pixel_save dw 0 ; per to pixel
preboot_gprobe db 0 ; probe vesa3 videomodes (1-no, 2-yes)
preboot_vrrm db 0 ; use VRR_M (1-yes, 2- no)
preboot_vrrm db 2 ; use VRR_M (1-yes, 2- no)
preboot_dma db 0 ; use DMA for access to HDD (1-always, 2-only for read, 3-never)
preboot_device db 0 ; boot device
; (1-floppy 2-harddisk 3-kernel restart 4-format ram disk)
;!!!! 0 - autodetect !!!!
preboot_blogesc = 0 ; start immediately after bootlog
preboot_biosdisk db 0 ; use V86 to access disks through BIOS (1-yes, 2-no)
preboot_biosdisk db 2 ; use V86 to access disks through BIOS (1-yes, 2-no)
 
if $>0x200
ERROR: prebooting parameters must fit in first sector!!!
/kernel/branches/kolibri_pe/const.inc
184,7 → 184,7
 
TSS_SIZE equ (128+8192)
 
OS_BASE equ 0x80000000
OS_BASE equ 0xE0000000
 
window_data equ OS_BASE
 
/kernel/branches/kolibri_pe/core/heap.inc
209,6 → 209,39
.err:
xor edi, edi
ret
; param
; eax= required size
;
; retval
; edi= memory block descriptor
; ebx= descriptor index
align 4
get_large_block:
mov edx, -1
mov ecx, eax
shr ecx, 22
dec ecx
cmp ecx, 31
jle .get_index
mov ecx, 31
.get_index:
shl edx, cl
and edx, [large_block_mask]
.find:
bsf edi, edx
mov ebx, edi
mov edi, [large_block_list+edi*4]
.check_size:
cmp eax, [edi+block_size]
ja .next
ret
.next:
mov edi, [edi+list_fd]
test edi, edi
jnz .check_size
.fail:
xor edi, edi
ret
 
align 4
alloc_mem_block:
639,6 → 672,138
ret
endp
 
 
align 4
proc alloc_large stdcall, size:dword
local block_ind:DWORD
 
push ebx
push esi
push edi
 
mov eax, [size]
add eax, 0x3FFFFF
and eax, not 0x3FFFFF
mov [size], eax
 
; mov ebx, heap_mutex
; call wait_mutex ;ebx
 
; cmp eax, [heap_free]
; ja .error
 
call get_large_block ; eax
test edi, edi
jz .error
 
cmp [edi+block_flags], FREE_BLOCK
jne .error
 
mov [block_ind], ebx ;index of allocated block
 
mov eax, [edi+block_size]
cmp eax, [size]
je .m_eq_size
 
call alloc_mem_block
and eax, eax
jz .error
 
mov esi, eax ;esi - splitted block
 
mov [esi+block_next], edi
mov eax, [edi+block_prev]
mov [esi+block_prev], eax
mov [edi+block_prev], esi
mov [esi+list_fd], 0
mov [esi+list_bk], 0
test eax, eax
jz @f
mov [eax+block_next], esi
@@:
mov ebx, [edi+block_base]
mov [esi+block_base], ebx
mov edx, [size]
mov [esi+block_size], edx
add [edi+block_base], edx
sub [edi+block_size], edx
 
mov eax, [edi+block_size]
shr eax, 22
dec eax
cmp eax, 31
jna @f
mov eax, 31
@@:
cmp eax, [block_ind]
je .m_eq_ind
 
remove_from_list edi
 
mov ecx, [block_ind]
mov [large_block_list+ecx*4], edx
 
test edx, edx
jnz @f
btr [large_block_mask], ecx
@@:
mov edx, [large_block_list+eax*4]
mov [edi+list_fd], edx
test edx, edx
jz @f
mov [edx+list_bk], edi
@@:
mov [large_block_list+eax*4], edi
bts [large_block_mask], eax
.m_eq_ind:
mov ecx, mem_used.fd-MEM_LIST_OFFSET
mov edx, [ecx+list_fd]
mov [esi+list_fd], edx
mov [esi+list_bk], ecx
mov [ecx+list_fd], esi
mov [edx+list_bk], esi
 
mov [esi+block_flags], USED_BLOCK
mov eax, [esi+block_base]
mov ebx, [size]
sub [heap_free], ebx
and [heap_mutex], 0
pop edi
pop esi
pop ebx
ret
.m_eq_size:
remove_from_list edi
mov [large_block_list+ebx*4], edx
and edx, edx
jnz @f
btr [large_block_mask], ebx
@@:
mov ecx, mem_used.fd-MEM_LIST_OFFSET
mov edx, [ecx+list_fd]
mov [edi+list_fd], edx
mov [edi+list_bk], ecx
mov [ecx+list_fd], edi
mov [edx+list_bk], edi
 
mov [edi+block_flags], USED_BLOCK
mov eax, [edi+block_base]
mov ebx, [size]
sub [heap_free], ebx
and [heap_mutex], 0
pop edi
pop esi
pop ebx
ret
.error:
xor eax, eax
mov [heap_mutex], eax
pop edi
pop esi
pop ebx
ret
endp
 
restore block_next
restore block_prev
restore block_list
/kernel/branches/kolibri_pe/core/memory.inc
241,7 → 241,9
@@:
xor eax, eax
xchg eax, [esi]
push eax
invlpg [edi]
pop eax
 
test eax, 1
jz .next
417,7 → 419,9
mov dword [app_page_tabs+edi*4], 2
mov ebx, edi
shl ebx, 12
push eax
invlpg [ebx]
pop eax
call free_page
 
.next: add edi, 1
559,13 → 563,8
 
inc [pg_data.pages_faults]
 
; push eax
; push edx
; mov edx, 0x400 ;bochs
; mov al,0xff ;bochs
; out dx, al ;bochs
; pop edx
; pop eax
; xchg bx,bx
; jmp .exit
 
mov ebx, [.err_addr]
mov eax, [.err_code]
/kernel/branches/kolibri_pe/core/peload.inc
172,8 → 172,8
mov esi, DWORD PTR [__exports+28]
mov eax, DWORD PTR [esp+56]
mov DWORD PTR [esp+20], edi
sub edi, -2147483648
sub esi, -2147483648
add edi, OS_BASE
add esi, OS_BASE
mov DWORD PTR [esp+44], esi
mov ecx, DWORD PTR [eax-4]
mov DWORD PTR [esp+48], edi
200,7 → 200,7
movzx eax, WORD PTR [edi]
mov edx, DWORD PTR [esp+56]
mov eax, DWORD PTR [edx+eax*4]
sub eax, -2147483648
add eax, OS_BASE
push eax
push esi
call strncmp
213,8 → 213,8
push ecx
push 32
mov ecx, DWORD PTR [esp+28]
mov eax, DWORD PTR [ecx-2147483648+ebx*4]
sub eax, -2147483648
mov eax, DWORD PTR [ecx+OS_BASE+ebx*4]
add eax, OS_BASE
push eax
push esi
call strncmp
225,7 → 225,7
mov edx, DWORD PTR [esp+52]
mov ecx, DWORD PTR [esp+28]
mov eax, DWORD PTR [esi+ebx*4]
sub eax, -2147483648
add eax, OS_BASE
mov DWORD PTR [ecx+edx*4], eax
jmp L36
L34:
252,7 → 252,7
mov edi, DWORD PTR [esp+52]
mov edx, DWORD PTR [esp+28]
mov eax, DWORD PTR [esi+eax*4]
sub eax, -2147483648
add eax, OS_BASE
mov DWORD PTR [edx+edi*4], eax
L37:
inc DWORD PTR [esp+52]
/kernel/branches/kolibri_pe/core/taskman.inc
396,7 → 396,7
cld
rep stosd
 
mov ecx, (OS_BASE shr 20)/4
mov ecx, 1024-(OS_BASE shr 20)/4
mov esi, sys_pgdir+(OS_BASE shr 20)
rep movsd
 
/kernel/branches/kolibri_pe/init.inc
39,7 → 39,32
 
align 4
proc init_mem
 
mov ecx, [0x2F0000 + 0x9100]
test ecx, ecx
jz .nosmap
 
xor eax, eax
mov esi, 0x2F0000 + 0x9104
@@:
cmp dword [esi+16], 1
jne .next
mov edx, [esi+8]
cmp eax, [esi+8]
ja .next
 
mov eax, [esi+8]
.next:
add esi, 20
loop @B
 
mov [MEM_AMOUNT-OS_BASE], eax
jmp @F
.nosmap:
call mem_test
 
mov eax, [MEM_AMOUNT-OS_BASE]
@@:
mov [pg_data.mem_amount-OS_BASE], eax
 
shr eax, 12
71,7 → 96,7
cld
rep stosd
 
mov edx, (sys_pgdir-OS_BASE)+ 0x800; (OS_BASE shr 20)
mov edx, (sys_pgdir-OS_BASE)+ (OS_BASE shr 20)
bt [cpu_caps-OS_BASE], CAPS_PSE
jnc .no_PSE
 
228,7 → 253,7
; çäåñü äîëæíà çàïîëíÿòñÿ pci_emu_dat
.BIOS32_not_found:
.end:
ret
ret
 
align 4
proc test_cpu
/kernel/branches/kolibri_pe/kernel.asm
243,10 → 243,11
 
call init_BIOS32
; MEMORY MODEL
call mem_test
 
call init_mem
call init_page_map
 
call init_page_map
 
; ENABLE PAGING
 
mov eax, sys_pgdir-OS_BASE
714,6 → 715,8
mov [SLOT_BASE+APPDATA.cursor],eax
mov [SLOT_BASE+APPDATA.cursor+256],eax
 
stdcall load_pe_driver, szAtiHW
 
; READ TSC / SECOND
 
mov esi,boot_tsc
804,9 → 807,12
 
no_load_vrr_m:
 
 
mov ebp, firstapp
call fs_execute_from_sysdir
 
 
 
cmp eax,2 ; continue if a process has been loaded
je first_app_found