Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 387 → Rev 388

/kernel/branches/flat_kernel/blkdev/fdc.inc
9,7 → 9,7
endg
 
fdc_init: ;start with clean tracks.
mov edi,0xD201
mov edi,OS_BASE+0xD201
mov al,0
mov ecx,160
rep stosb
22,7 → 22,7
mov bl,18
div bl
mov ah,0
add eax,0xD201
add eax,OS_BASE+0xD201
mov [eax],byte 1 ;This track is now dirty.
popa
ret
/kernel/branches/flat_kernel/blkdev/hd_drv.inc
25,7 → 25,7
push ecx esi edi ; scan cache
 
mov ecx,cache_max ; entries in cache
mov esi,0x600000+8
mov esi,OS_BASE+0x600000+8
mov edi,1
 
hdreadcache:
54,7 → 54,7
call hd_read_pio
@@:
 
lea esi,[edi*8+0x600000]
lea esi,[edi*8+OS_BASE+0x600000]
mov [esi],eax ; sector number
mov dword [esi+4],1 ; hd read - mark as same as in hd
 
62,7 → 62,7
 
mov esi,edi
shl esi,9
add esi,0x600000+65536
add esi,OS_BASE+0x600000+65536
mov edi,ebx
mov ecx,512/4
cld
115,7 → 115,7
cli
push edi
shl edi,9
add edi,0x600000+65536
add edi,OS_BASE+0x600000+65536
mov ecx,256
mov edx,[hdbase]
cld
153,7 → 153,7
; check if the cache already has the sector and overwrite it
 
mov ecx,cache_max
mov esi,0x600000+8
mov esi,OS_BASE+0x600000+8
mov edi,1
 
hdwritecache:
178,7 → 178,7
cmp [hd_error],0
jne hd_write_access_denied
 
lea esi,[edi*8+0x600000]
lea esi,[edi*8+OS_BASE+0x600000]
mov [esi],eax ; sector number
 
yes_in_cache_write:
186,7 → 186,7
mov dword [esi+4],2 ; write - differs from hd
 
shl edi,9
add edi,0x600000+65536
add edi,OS_BASE+0x600000+65536
mov esi,ebx
mov ecx,512/4
cld
205,7 → 205,7
; write difference ( 2 ) from cache to hd
 
mov ecx,cache_max
mov esi,0x600000+8
mov esi,OS_BASE+0x600000+8
mov edi,1
 
write_cache_more:
323,7 → 323,7
; cli
mov esi,edi
shl esi,9
add esi,0x600000+65536 ; esi = from memory position
add esi,OS_BASE+0x600000+65536 ; esi = from memory position
mov ecx,256
mov edx,[hdbase]
cld
357,7 → 357,7
 
inside_cache:
 
cmp dword [edi*8+0x600000+4],2 ; get cache slot info
cmp dword [edi*8+OS_BASE+0x600000+4],2 ; get cache slot info
jb found_slot ; it's empty or read
dec ecx
jnz search_for_empty
378,7 → 378,7
clear_hd_cache:
 
push eax ecx edi
mov edi,0x600000
mov edi,OS_BASE+0x600000
mov ecx,16384
xor eax,eax
cld
574,7 → 574,7
align 4
; note that IDE descriptor table must be 4-byte aligned and do not cross 4K boundary
IDE_descriptor_table:
dd 284000h
dd OS_BASE+284000h
dw 2000h
dw 8000h
 
607,16 → 607,16
out dx, al
call update_counters
mov ebx, [dma_process]
cmp [0x3000], ebx
cmp [CURRENT_TASK], ebx
jz .noswitch
mov [dma_task_switched], 1
mov edi, [dma_slot_ptr]
mov eax, [0x3000]
mov eax, [CURRENT_TASK]
mov [dma_process], eax
mov eax, [0x3010]
mov eax, [TASK_BASE]
mov [dma_slot_ptr], eax
mov [0x3000], ebx
mov [0x3010], edi
mov [CURRENT_TASK], ebx
mov [TASK_BASE], edi
mov byte [0xFFFF], 1
call do_change_task
.noswitch:
638,16 → 638,16
out dx, al
call update_counters
mov ebx, [dma_process]
cmp [0x3000], ebx
cmp [CURRENT_TASK], ebx
jz .noswitch
mov [dma_task_switched], 1
mov edi, [dma_slot_ptr]
mov eax, [0x3000]
mov eax, [CURRENT_TASK]
mov [dma_process], eax
mov eax, [0x3010]
mov eax, [TASK_BASE]
mov [dma_slot_ptr], eax
mov [0x3000], ebx
mov [0x3010], edi
mov [CURRENT_TASK], ebx
mov [TASK_BASE], edi
mov byte [0xFFFF], 1
call do_change_task
.noswitch:
668,11 → 668,11
mov eax, [esp+4]
sub eax, [dma_cur_sector]
shl eax, 9
add eax, 0x284000
add eax, OS_BASE+0x284000
push ecx esi edi
mov esi, eax
shl edi, 9
add edi, 0x610000
add edi, OS_BASE+0x610000
mov ecx, 512/4
cld
rep movsd
681,9 → 681,9
pop eax
ret
.notread:
mov eax, IDE_descriptor_table
mov dword [eax], 0x284000
mov word [eax+4], 0x2000
mov eax, IDE_descriptor_table-OS_BASE
mov dword [eax+OS_BASE], 0x284000
mov word [eax+4+OS_BASE], 0x2000
mov dx, [IDEContrRegsBaseAddr]
cmp [hdbase], 0x1F0
jz @f
734,9 → 734,9
@@:
mov al, 9
out dx, al
mov eax, [0x3000]
mov eax, [CURRENT_TASK]
mov [dma_process], eax
mov eax, [0x3010]
mov eax, [TASK_BASE]
mov [dma_slot_ptr], eax
cmp [hdbase], 0x1F0
jnz .ide1
766,7 → 766,7
mov eax, IDE_descriptor_table
mov edx, [cache_chain_pos]
shl edx, 9
add edx, 0x610000
add edx, OS_BASE+0x610000
mov [eax], edx
movzx edx, [cache_chain_size]
shl edx, 9
777,7 → 777,7
mov eax, IDE_descriptor_table
mov edx, edi
shl edx, 9
add edx, 0x610000
add edx, OS_BASE+0x610000
mov [eax], edx
mov word [eax+4], 0x200
do_write_dma:
832,9 → 832,9
@@:
mov al, 1
out dx, al
mov eax, [0x3000]
mov eax, [CURRENT_TASK]
mov [dma_process], eax
mov eax, [0x3010]
mov eax, [TASK_BASE]
mov [dma_slot_ptr], eax
cmp [hdbase], 0x1F0
jnz .ide1
/kernel/branches/flat_kernel/boot/bootcode.inc
7,8 → 7,6
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 
 
;==========================================================================
;
; 16 BIT FUNCTIONS
15,120 → 13,7
;
;==========================================================================
 
; 16-bit data
org $+0x10000
 
old_ints_h:
dw 0x400
dd 0
dw 0
 
kernel_restart_bootblock:
db 1 ; version
dw 1 ; floppy image is in memory
dd 0 ; cannot save parameters
 
 
align 32
 
; GDT TABLE
 
gdts:
 
dw gdte-$-1
dd gdts
dw 0
 
; Attention! The order first four selectors not to change, is used in Fast System Call
; must be : os_code, os_data, app_code, app_data, ....
 
int_code_l:
os_code_l:
dw 0xffff
dw 0x0000
db 0x00
dw 11011111b *256 +10011010b
db 0x00
 
int_data_l:
os_data_l:
dw 0xffff
dw 0x0000
db 0x00
dw 11011111b *256 +10010010b
db 0x00
 
app_code_l:
dw 0xFFFF
dw 0
db 0
db cpl3
dw G32+D32+0x8000+0x7;
 
app_data_l:
dw 0xFFFF
dw 0
db 0
db drw3
dw G32+D32+0x8000+0x7;
 
; --------------- APM ---------------------
apm_code_32:
dw 0x0f ; limit 64kb
db 0, 0, 0
dw 11010000b *256 +10011010b
db 0x00
apm_code_16:
dw 0x0f
db 0, 0, 0
dw 10010000b *256 +10011010b
db 0x00
apm_data_16:
dw 0x0f
db 0, 0, 0
dw 10010000b *256 +10010010b
db 0x00
; -----------------------------------------
 
graph_data_l:
 
dw 0x7ff
dw 0x0000
db 0x00
dw 11010000b *256 +11110010b
db 0x00
 
tss0_l:
; times (max_processes+10) dd 0,0
gdte = $ + (max_processes+10)*8
 
; videomodes table
gr_table:
dw 0x112+0100000000000000b , 640 , 480 ; 1
dw 0x115+0100000000000000b , 800 , 600 ; 2
dw 0x118+0100000000000000b , 1024 , 768 ; 3
dw 0x11B+0100000000000000b , 1280 , 1024 ; 4
dw 0x112 , 640 , 480 ; 5
dw 0x115 , 800 , 600 ; 6
dw 0x118 , 1024 , 768 ; 7
dw 0x11B , 1280 ,1024 ; 8
dw 0x13, 640, 480 ; 9
dw 0x12, 640, 480 ; 0
 
; table for move to extended memory (int 15h, ah=87h)
movedesc:
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
 
db 0xff,0xff,0x0,0xa0,0x00,0x93,0x0,0x0
db 0xff,0xff,0x0,0x00,0x10,0x93,0x0,0x0
 
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
org $-0x10000
 
putchar:
; in: al=character
mov ah, 0Eh
155,72 → 40,6
popa
ret
 
; Now int 16 is used for keyboard support.
; This is shorter, simpler and more reliable.
if 0
getkey: push ecx
push edx
add ebx,0x0101
xor eax,eax
 
gk1:
in al,0x60
mov cl,al
gk0:
in al,0x60
cmp al,cl
je gk0
cmp ax,11
jg gk0
gk0_1:
mov cl,al
 
; add al,47
; mov [ds:keyinbs-0x10000],al
; mov si,keyinbs-0x10000
; call printplain
 
gk12:
in al,0x60
cmp al,cl
je gk12
cmp ax,240
jne gk13
mov al,cl
jmp gk14
gk13:
add cl,128
cmp al,cl
jne gk1
sub al,128
gk14:
 
movzx edx,bl
cmp eax,edx
jb gk1
movzx edx,bh
cmp eax,edx
jg gk1
test ebx,0x010000
jnz gk3
mov cx,0x1000
mov dx,cx
add eax,47
mov cx,ax
cmp cx,58
jb gk_nozero
sub cx,10
gk_nozero:
mov [ds:keyin-0x10000],cl
mov si,keyin-0x10000
call printplain
gk3:
sub eax,48
pop edx
pop ecx
ret
end if
 
getkey:
; get number in range [bl,bh] (bl,bh in ['0'..'9'])
; in: bx=range
253,17 → 72,6
call setcursor
}
 
;pagetable_set:
;eax - physical address
;es:di - page table
;ecx - number of pages to map
; or al, 7
;@@:
; stosd
; add eax, 1000h
; loop @b
; ret
 
boot_read_floppy:
push si
xor si, si
276,7 → 84,7
inc si
cmp si, 10
jb @b
mov si, badsect-0x10000
mov si, badsect
sayerr_plain:
call printplain
jmp $
296,8 → 104,8
; \begin{diamond}[02.12.2005]
cmp ax, 'KL'
jnz @f
mov word [cs:cfgmanager.loader_block-0x10000], si
mov word [cs:cfgmanager.loader_block+2-0x10000], ds
mov word [cs:cfgmanager.loader_block], si
mov word [cs:cfgmanager.loader_block+2], ds
@@:
; \end{diamond}[02.12.2005]
 
317,7 → 125,7
 
if lang eq ru
; Load & set russian VGA font (RU.INC)
mov bp,RU_FNT1-10000h ; RU_FNT1 - First part
mov bp, RU_FNT1 ; RU_FNT1 - First part
mov bx,1000h ; 768 bytes
mov cx,30h ; 48 symbols
mov dx,80h ; 128 - position of first symbol
324,7 → 132,7
mov ax,1100h
int 10h
 
mov bp,RU_FNT2-10000h ; RU_FNT2 -Second part
mov bp,RU_FNT2 ; RU_FNT2 -Second part
mov bx,1000h ; 512 bytes
mov cx,20h ; 32 symbols
mov dx,0E0h ; 224 - position of first symbol
332,7 → 140,7
int 10h
; End set VGA russian font
else if lang eq et
mov bp,ET_FNT-10000h ; ET_FNT1
mov bp,ET_FNT ; ET_FNT1
mov bx,1000h ;
mov cx,255 ; 256 symbols
mov dx,0h ; 0 - position of first symbol
344,16 → 152,10
push 0xb800
pop es
xor di, di
; mov si,d80x25-0x10000
; mov cx,80*25
; mov ah,1*16+15
; dfl1:
; lodsb
; stosw
; loop dfl1
mov ah, 1*16+15
 
; draw top
mov si, d80x25_top - 0x10000
mov si, d80x25_top
mov cx, d80x25_top_num * 80
@@:
lodsb
360,7 → 162,7
stosw
loop @b
; draw spaces
mov si, space_msg - 0x10000
mov si, space_msg
mov cx, 25 - d80x25_top_num - d80x25_bottom_num
dfl1:
push cx
374,7 → 176,7
pop cx
loop dfl1
; draw bottom
mov si, d80x25_bottom - 0x10000
mov si, d80x25_bottom
mov cx, d80x25_bottom_num * 80
@@:
lodsb
381,7 → 183,7
stosw
loop @b
 
mov byte [space_msg-0x10000+80], 0 ; now space_msg is null terminated
mov byte [space_msg+80], 0 ; now space_msg is null terminated
 
_setcursor d80x25_top_num,0
 
401,73 → 203,24
and dx,bx
cmp ax,dx
jnz cpugood
mov si,not386-0x10000
mov si,not386
sayerr:
call print
jmp $
cpugood:
 
 
; set up esp
movzx esp, sp
 
; FLUSH 8042 KEYBOARD CONTROLLER
 
;// mike.dld [
; mov al,0xED
; out 0x60,al
; or cx,-1
; @@:
; in al,0x64
; test al,2
; jz @f
; loop @b
; @@:
; mov al,0
; out 0x60,al
; or cx,-1
; @@:
; in al,0x64
; test al,2
; jz @f
; loop @b
; @@:
;// mike.dld ]
 
; mov ecx,10000
; fl1:
; in al,0x64
; loop fl1
; test al,1
; jz fl2
; in al,0x60
; jmp fl1
; fl2:
 
;****************************************************************
; The function is modified Mario79
;*****************************************************************
; wait_kbd: ; variant 1
; mov cx,2500h ;çàäåðæêà ïîðÿäêà 10 ìñåê
; test_kbd:
; in al,64h ;÷èòàåì ñîñòîÿíèå êëàâèàòóðû
; test al,2 ;ïðîâåðêà áèòà ãîòîâíîñòè
; loopnz test_kbd
 
push 0
pop es
and word [es:0x9031], 0
; \begin{Mario79}
; find HDD IDE DMA PCI device
; check for PCI BIOS
mov ax, 0xB101
int 0x1A
jc .nopci
cmp edx, 'PCI '
jnz .nopci
; find PCI class code
; class 1 = mass storage
; subclass 1 = IDE controller
; a) class 1, subclass 1, programming interface 0x80
mov ax, 0xB103
mov ecx, 1*10000h + 1*100h + 0x80
mov si, 0 ; device index = 0
522,10 → 275,11
; Write APM ver ----
and ax, 0xf0f
add ax, '00'
mov si, msg_apm - 0x10000
mov si, msg_apm
mov [si + 5], ah
mov [si + 7], al
_setcursor 0, 3
 
call printplain
_setcursor d80x25_top_num,0
; ------------------
536,26 → 290,36
mov ax, 0x5303 ; Connect 32 bit mode interface
xor bx, bx
int 0x15
 
push 0
pop es
 
mov [es:0x9050], ax
mov [es:0x9052], cx
mov [es:0x9040], dx
 
 
; init selectors
movzx eax, ax ; real-mode segment base address of protected-mode 32-bit code segment
shl eax, 4
mov [apm_code_32 - 0x10000 + 2], ax
shr eax, 16
mov [apm_code_32 - 0x10000 + 4], al
movzx ecx, cx ; real-mode segment base address of protected-mode 16-bit code segment
shl ecx, 4
mov [apm_code_16 - 0x10000 + 2], cx
shr ecx, 16
mov [apm_code_16 - 0x10000 + 4], cl
movzx edx, dx ; real-mode segment base address of protected-mode 16-bit data segment
shl edx, 4
mov [apm_data_16 - 0x10000 + 2], dx
shr edx, 16
mov [apm_data_16 - 0x10000 + 4], dl
mov [es : 0x9040], ebx ; offset of APM entry point
; movzx eax, ax ; real-mode segment base address of protected-mode 32-bit code segment
; shl eax, 4
; mov [dword apm_code_32 + 2], ax
; shr eax, 16
; mov [dword apm_code_32 + 4], al
; movzx ecx, cx ; real-mode segment base address of protected-mode 16-bit code segment
; shl ecx, 4
; mov [dword apm_code_16 + 2], cx
; shr ecx, 16
; mov [dword apm_code_16 + 4], cl
; movzx edx, dx ; real-mode segment base address of protected-mode 16-bit data segment
; shl edx, 4
; mov [dword apm_data_16 + 2], dx
; shr edx, 16
; mov [dword apm_data_16 + 4], dl
; mov [es : 0x9040], ebx ; offset of APM entry point
apm_end:
; -----------------------------------------
 
 
; DISPLAY VESA INFORMATION
 
push 0
564,7 → 328,7
mov di,0xa000
int 0x10
cmp ax,0x004f
mov si, novesa-0x10000
mov si, novesa
jnz @f
mov bx, word [es:di+0x12]
shl ebx,16
571,7 → 335,7
mov [es:0x9050], ebx
mov ax,[es:di+4]
add ax,'0'*256+'0'
mov si,vervesa-0x10000
mov si,vervesa
mov [si+vervesa_off], ah
mov [si+vervesa_off+2], al
@@: call print
584,13 → 348,13
; b) preboot_dma_write = use DMA write?
; c) preboot_vrrm = use VRR?
; d) preboot_device = from what boot?
mov di, preboot_graph-0x10000
mov di, preboot_graph
; check bootloader block
cmp [.loader_block-0x10000], -1
cmp [.loader_block], -1
jz .noloaderblock
les bx, [.loader_block-0x10000]
les bx, [.loader_block]
cmp byte [es:bx], 1
mov si, loader_block_error-0x10000
mov si, loader_block_error
jnz sayerr
test byte [es:bx+1], 1
jz @f
601,11 → 365,11
@@:
.noloaderblock:
; determine default settings
mov [.bSettingsChanged-0x10000], 0
mov [.bSettingsChanged], 0
cmp byte [di], 0
jnz .preboot_gr_end
mov [di+preboot_gprobe-preboot_graph], 0
mov al, [vervesa+vervesa_off-0x10000]
mov al, [vervesa+vervesa_off]
cmp al, 'x'
jz .novesa
cmp al, '1'
628,42 → 392,42
cmp [di+preboot_device-preboot_graph], 1
adc [di+preboot_device-preboot_graph], 0
; notify user
mov si, linef-0x10000
mov si, linef
call print
mov si, start_msg-0x10000
mov si, start_msg
call print
mov si, time_msg-0x10000
mov si, time_msg
call print
; get start time
call .gettime
mov [.starttime-0x10000], eax
mov word [.timer-0x10000], .newtimer
mov word [.timer-0x10000+2], cs
mov [.starttime], eax
mov word [.timer], .newtimer
mov word [.timer+2], cs
.printcfg:
_setcursor 9,0
mov si, current_cfg_msg-0x10000
mov si, current_cfg_msg
call print
mov si, curvideo_msg-0x10000
mov si, curvideo_msg
call print
mov al, [preboot_graph-0x10000]
mov al, [preboot_graph]
cmp al, 8
ja .pnovesa
mov dl, al
and eax, 3
mov si, [modes_msg-0x10000+eax*2]
mov si, [modes_msg+eax*2]
call printplain
mov si, modevesa20-0x10000
mov si, modevesa20
cmp dl, 4
jbe @f
mov si, modevesa12-0x10000
mov si, modevesa12
@@:
call printplain
cmp dl, 4
ja .x
mov si, probeno_msg-0x10000
cmp [preboot_gprobe-0x10000], 2
mov si, probeno_msg
cmp [preboot_gprobe], 2
jnz @f
mov si, probeok_msg-0x10000
mov si, probeok_msg
@@:
call printplain
.x:
670,24 → 434,24
jmp .c
.pnovesa:
cmp al, 9
mov si, mode9-0x10000
mov si, mode9
jz @b
mov si, mode10-0x10000
mov si, mode10
jmp @b
.c:
mov si, linef-0x10000
mov si, linef
call printplain
mov si, dma_msg-0x10000
cmp [preboot_dma_write-0x10000], 1
mov si, dma_msg
cmp [preboot_dma_write], 1
call .say_on_off
mov si, vrrm_msg-0x10000
cmp [preboot_vrrm-0x10000], 1
mov si, vrrm_msg
cmp [preboot_vrrm], 1
call .say_on_off
mov si, preboot_device_msg-0x10000
mov si, preboot_device_msg
call print
mov al, [preboot_device-0x10000]
mov al, [preboot_device]
and eax, 3
mov si, [preboot_device_msgs-0x10000+eax*2]
mov si, [preboot_device_msgs+eax*2]
call printplain
.wait:
_setcursor 25,0 ; out of screen
696,8 → 460,8
push 0
pop es
mov eax, [es:8*4]
mov [.oldtimer-0x10000], eax
mov eax, [.timer-0x10000]
mov [.oldtimer], eax
mov eax, [.timer]
mov [es:8*4], eax
sti
; wait for keypressed
707,11 → 471,11
; restore timer interrupt
push 0
pop es
mov eax, [.oldtimer-0x10000]
mov eax, [.oldtimer]
mov [es:8*4], eax
mov [.timer-0x10000], eax
mov [.timer], eax
_setcursor 7,0
mov si, space_msg-0x10000
mov si, space_msg
call printplain
pop ax
; switch on key
727,15 → 491,15
cmp al, 'd'
jnz .wait
_setcursor 15,0
mov si,bdev-0x10000
mov si,bdev
call print
mov bx,'13'
call getkey
mov [preboot_device-0x10000], al
mov [preboot_device], al
_setcursor 13,0
.d:
mov [.bSettingsChanged-0x10000], 1
mov si, space_msg-0x10000
mov [.bSettingsChanged], 1
mov si, space_msg
call printplain
_setcursor 15,0
mov cx, 6
745,46 → 509,46
jmp .printcfg
.change_a:
_setcursor 15,0
mov si, gr_mode-0x10000
mov si, gr_mode
call printplain
mov bx, '09'
call getkey
mov [preboot_graph-0x10000], al
mov [preboot_graph], al
cmp al, 4
ja @f
mov si, probetext-0x10000
mov si, probetext
call printplain
mov bx, '12'
call getkey
mov [preboot_gprobe-0x10000], al
mov [preboot_gprobe], al
@@:
_setcursor 10,0
jmp .d
.change_b:
_setcursor 15,0
mov si, ask_dma-0x10000
mov si, ask_dma
call print
mov bx, '12'
call getkey
mov [preboot_dma_write-0x10000], al
mov [preboot_dma_write], al
_setcursor 11,0
jmp .d
.change_c:
_setcursor 15,0
mov si, vrrmprint-0x10000
mov si, vrrmprint
call print
mov bx, '12'
call getkey
mov [preboot_vrrm-0x10000], al
mov [preboot_vrrm], al
_setcursor 12,0
jmp .d
.say_on_off:
pushf
call print
mov si, on_msg-0x10000
mov si, on_msg
popf
jz @f
mov si, off_msg-0x10000
mov si, off_msg
@@: call printplain
ret
; novesa and vervesa strings are not used at the moment of executing this code
794,10 → 558,9
.bSettingsChanged db ?
.timer dd ?
end virtual
org $+0x10000
.loader_block dd -1
org $-0x10000
.gettime:
 
mov ah, 0
int 1Ah
xchg ax, cx
809,10 → 572,10
push cs
pop ds
pushf
call [.oldtimer-0x10000]
call [.oldtimer]
pushad
call .gettime
sub eax, [.starttime-0x10000]
sub eax, [.starttime]
sub ax, 18*5
jae .timergo
neg ax
829,12 → 592,12
mov cl, 'ã'
jz @f
mov cl, 'ë'
@@: mov [time_str+9-0x10000], cl
@@: mov [time_str+9], cl
else if lang eq et
cmp al, 1
ja @f
mov [time_str+9-0x10000], ' '
mov [time_str+10-0x10000],' '
mov [time_str+9], ' '
mov [time_str+10],' '
@@:
else
; wait 5/4/3/2 seconds, 1 second
842,11 → 605,11
mov cl, 's'
ja @f
mov cl, ' '
@@: mov [time_str+9-0x10000], cl
@@: mov [time_str+9], cl
end if
add al, '0'
mov [time_str+1-0x10000], al
mov si, time_msg-0x10000
mov [time_str+1], al
mov si, time_msg
_setcursor 7,0
call print
_setcursor 25,0
856,24 → 619,24
.timergo:
push 0
pop es
mov eax, [.oldtimer-0x10000]
mov eax, [.oldtimer]
mov [es:8*4], eax
mov sp, 0EC00h
.continue:
sti
_setcursor 6,0
mov si, space_msg-0x10000
mov si, space_msg
call printplain
call printplain
_setcursor 6,0
mov si, loading_msg-0x10000
mov si, loading_msg
call print
_setcursor 15,0
cmp [.bSettingsChanged-0x10000], 0
cmp [.bSettingsChanged], 0
jz .load
cmp [.loader_block-0x10000], -1
cmp [.loader_block], -1
jz .load
les bx, [.loader_block-0x10000]
les bx, [.loader_block]
mov eax, [es:bx+3]
push ds
pop es
880,7 → 643,7
test eax, eax
jz .load
push eax
mov si, save_quest-0x10000
mov si, save_quest
call print
.waityn:
mov ah, 0
891,7 → 654,7
cmp al, 'y'
jnz .waityn
call putchar
mov byte [space_msg-0x10000+80], 186
mov byte [space_msg+80], 186
pop eax
push cs
push .cont
902,7 → 665,7
.cont:
push cs
pop ds
mov si, space_msg-0x10000
mov si, space_msg
mov byte [si+80], 0
_setcursor 15,0
call printplain
912,12 → 675,12
 
; ASK GRAPHICS MODE
 
movzx ax, [preboot_graph-0x10000]
movzx ax, [preboot_graph]
push 0
pop es
; address is gr_table+6*(ax-1)-0x10000
; address is gr_table+6*(ax-1)
add ax, ax
lea si, [gr_table-0x10000 + eax + eax*2 - 6]
lea si, [gr_table + eax + eax*2 - 6]
mov bx,[si+0]
mov cx,[si+2]
mov dx,[si+4]
936,7 → 699,7
; USE DEFAULTS OR PROBE
 
; bx - mode : cx - x size : dx - y size
cmp [preboot_gprobe-0x10000], 1
cmp [preboot_gprobe], 1
jz noprobe
 
mov bx,0x100
943,7 → 706,7
newprobe:
inc bx
cmp bx,0x17f
mov si,prnotfnd-0x10000
mov si,prnotfnd
jz sayerr
 
probemore:
990,12 → 753,12
mov [es:0x9000],al
nov:
cmp al,24
mov si,bt24-0x10000
mov si,bt24
jz bppl
cmp al,32
mov si,bt32-0x10000
mov si,bt32
jz bppl
mov si,btns-0x10000
mov si,btns
jmp sayerr
bppl:
call print
1024,108 → 787,26
 
; DMA WRITE
 
mov al, [preboot_dma_write-0x10000]
mov al, [preboot_dma_write]
mov [es:0x901F],al
 
; VRR_M USE
 
mov al,[preboot_vrrm-0x10000]
mov al,[preboot_vrrm]
mov [es:0x9030],al
 
 
; MEMORY MODEL
 
; movzx eax,byte [es:preboot_memory-0x10000]
; cmp eax,0
; jne pre_mem
;;;;;;;;;;;;;;;;;;;;;;;;;
; mario79 - memory size ;
;;;;;;;;;;;;;;;;;;;;;;;;;
; mov ax,0E801h
;;; xor bx,bx ; thanks to Alexei for bugfix [18.07.2004]
; xor cx, cx
; xor dx, dx
; int 0x15
; movzx ebx, dx ;bx
; movzx eax, cx ;ax
; shl ebx,6 ; ïåðåâîä â êèëîáàéòû (x64)
; add eax,ebx
; add eax, 1000h ;440h
; cmp eax,40000h ; 256?
; jge mem_256_z
; cmp eax,20000h ; 128?
; jge mem_128_z
; cmp eax,10000h ; 64?
; jge mem_64_z
; cmp eax,8000h ; 32?
; jge mem_32_z
; jmp mem_16_z
;
;mem_256_z: mov si,memokz256-0x10000
; call printplain
; mov eax,5
; jmp pre_mem
;mem_128_z: mov si,memokz128-0x10000
; call printplain
; mov eax,4
; jmp pre_mem
;mem_64_z: mov si,memokz64-0x10000
; call printplain
; mov eax,3
; jmp pre_mem
;mem_32_z: mov si,memokz32-0x10000
; call printplain
; mov eax,2
; jmp pre_mem
;mem_16_z: mov si,memokz16-0x10000
; call printplain
; mov eax,1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; pre_mem:
; push word 0x0000
; pop es
; mov [es:0x9030],al
; push word 0x1000
; pop es
; mov si,linef-0x10000
; call printplain
 
 
 
 
; DIRECT WRITE TO LFB, PAGING DISABLED
 
; movzx eax,byte [es:preboot_lfb-0x10000]
; mov eax,1 ; paging disabled
; cmp eax,0
; jne pre_lfb
; mov si,gr_direct-0x10000
; call printplain
; mov ebx,'12'
; call getkey
; pre_lfb:
; push word 0x0000
; pop es
; mov [es:0x901E],al
; mov ax,0x1000
; mov es,ax
; mov si,linef-0x10000
; call printplain
mov [es:0x901E],byte 1
 
 
 
; BOOT DEVICE
 
mov al, [preboot_device-0x10000]
mov al, [preboot_device]
dec al
mov [boot_dev-0x10000],al
mov [boot_dev],al
 
; READ DISKETTE TO MEMORY
 
; cmp [boot_dev-0x10000],0
; cmp [boot_dev],0
jne no_sys_on_floppy
mov si,diskload-0x10000
mov si,diskload
call print
xor ax, ax ; reset drive
xor dx, dx
1138,7 → 819,7
mov bx, 0xB000 ; es:bx -> data area
call boot_read_floppy
; and copy them to extended memory
mov si, movedesc-0x10000
mov si, movedesc
mov [si+8*2+3], bh
push es
push ds
1152,7 → 833,7
mov dx, 0x3f2
mov al, 0
out dx, al
mov si, memmovefailed-0x10000
mov si, memmovefailed
jmp sayerr_plain
@@:
add dword [si+8*3+2], 512*10
1241,7 → 922,7
aam
xchg al, ah
add ax, '00'
mov si, pros-0x10000
mov si, pros
cmp [si], ax
jz @f
mov [si], ax
1319,10 → 1000,12
; jnz reads
; readdone:
; pop ax
mov si,backspace2-0x10000
 
mov si,backspace2
call printplain
mov si,okt-0x10000
mov si,okt
call printplain
 
no_sys_on_floppy:
xor ax, ax ; reset drive
xor dx, dx
1331,42 → 1014,9
mov al,0
out dx,al
 
push es
; PAGE TABLE
 
push dword [es:0x9018]
;
; mmap_mem equ 64 ; amount of memory to map
;
push 0x6000
pop es ; es:di = 6000:0
; xor di,di
; mov cx,256*mmap_mem ; Map (mapmem) M
;; initialize as identity mapping
; xor eax, eax
; call pagetable_set
;
;
; 4 KB PAGE DIRECTORY
;
push 0x7F00
pop es ; es:di = 7F00:0
; xor di, di
; mov cx, 64 / 4
; mov eax, 0x60007 ; for 0 M
; call pagetable_set
; xor si,si
; mov di,second_base_address shr 20
; mov cx,64/2
; rep movs word [es:di], [es:si]
 
; mov eax, 0x7F000 +8+16 ; Page directory and enable caches
; mov cr3, eax
 
; SET GRAPHICS
 
pop es
 
xor ax, ax
mov es, ax
 
1380,8 → 1030,9
setgr:
int 0x10
test ah,ah
mov si, fatalsel-0x10000
mov si, fatalsel
jnz sayerr
 
; set mode 0x12 graphics registers:
cmp bx,0x12
jne gmok2
1405,7 → 1056,6
pop dx
out dx,al ; select GDC bit mask register
; for writes to 0x03cf
 
gmok2:
push ds
pop es
/kernel/branches/flat_kernel/boot/bootru.inc
112,7 → 112,7
mode2 db "800x600",0
mode3 db "1024x768",0
mode4 db "1280x1024",0
modes_msg dw mode4-0x10000,mode1-0x10000,mode2-0x10000,mode3-0x10000
modes_msg dw mode4,mode1,mode2,mode3
modevesa20 db " á LFB",0
modevesa12 db ", VESA 1.2 Bnk",0
mode9 db "320x200, EGA/CGA 256 梥⮢",0
124,7 → 124,7
off_msg db " ¢ëª«",13,10,0
vrrm_msg db " [c] ˆá¯®«ì§®¢ ­¨¥ VRR:",0
preboot_device_msg db " [d] Ž¡à § ¤¨áª¥âë: ",0
preboot_device_msgs dw 0,pdm1-0x10000,pdm2-0x10000,pdm3-0x10000
preboot_device_msgs dw 0,pdm1,pdm2,pdm3
pdm1 db "­ áâ®ïé ï ¤¨áª¥â ",13,10,0
pdm2 db "C:\kolibri.img (FAT32)",13,10,0
pdm3 db "¨á¯®«ì§®¢ âì 㦥 § £à㦥­­ë© ®¡à §",13,10,0
/kernel/branches/flat_kernel/boot/preboot.inc
16,7 → 16,7
;!!!! 0 - autodetect !!!!
preboot_blogesc db 1 ; start immediately after bootlog
 
if $>10200h
if $>0x200
ERROR: prebooting parameters must fit in first sector!!!
end if
hdsysimage db 'KOLIBRI IMG' ; load from
/kernel/branches/flat_kernel/boot/rdload.inc
1,9 → 1,9
; READ RAMDISK IMAGE FROM HD
 
cmp [boot_dev],1
cmp [boot_dev+OS_BASE+0x10000],1
jne no_sys_on_hd
 
test [0x40001],byte 0x40
test [DRIVE_DATA+1],byte 0x40
jz position_2
mov [hdbase],0x1f0
mov [hdid],0x0
14,11 → 14,11
call search_and_read_image
cmp [image_retrieved],1
je yes_sys_on_hd
movzx eax,byte [0x40002]
movzx eax,byte [DRIVE_DATA+2]
cmp [fat32part],eax
jle position_1_1
position_2:
test [0x40001],byte 0x10
test [DRIVE_DATA+1],byte 0x10
jz position_3
mov [hdbase],0x1f0
mov [hdid],0x10
29,11 → 29,11
call search_and_read_image
cmp [image_retrieved],1
je yes_sys_on_hd
movzx eax,byte [0x40003]
movzx eax,byte [DRIVE_DATA+3]
cmp eax,[fat32part]
jle position_2_1
position_3:
test [0x40001],byte 0x4
test [DRIVE_DATA+1],byte 0x4
jz position_4
mov [hdbase],0x170
mov [hdid],0x0
44,11 → 44,11
call search_and_read_image
cmp [image_retrieved],1
je yes_sys_on_hd
movzx eax,byte [0x40004]
movzx eax,byte [DRIVE_DATA+4]
cmp eax,[fat32part]
jle position_3_1
position_4:
test [0x40001],byte 0x1
test [DRIVE_DATA+1],byte 0x1
jz no_sys_on_hd
mov [hdbase],0x170
mov [hdid],0x10
59,7 → 59,7
call search_and_read_image
cmp [image_retrieved],1
je yes_sys_on_hd
movzx eax,byte [0x40005]
movzx eax,byte [DRIVE_DATA+5]
cmp eax,[fat32part]
jle position_4_1
jmp yes_sys_on_hd
80,7 → 80,7
ret
 
read_image:
mov eax, hdsysimage
mov eax, hdsysimage+OS_BASE+0x10000
mov ebx, 1474560/512
mov ecx, RAMDISK
mov esi, 0
/kernel/branches/flat_kernel/boot/shutdown.inc
16,7 → 16,7
call sys_cd_audio
cld
 
mov al,[0x2f0000+0x9030]
mov al,[BOOT_VAR+0x9030]
cmp al,1
jl no_shutdown_parameter
cmp al,4
23,8 → 23,8
jle yes_shutdown_param
no_shutdown_parameter:
 
; movzx ecx,word [0x2f0000+0x900A]
; movzx esi,word [0x2f0000+0x900C]
; movzx ecx,word [BOOT_VAR+0x900A]
; movzx esi,word [BOOT_VAR+0x900C]
; imul ecx,esi ;[0xfe04]
;; mov ecx,0x500000/4 ;3fff00/4 ; darken screen
; push ecx
378,7 → 378,7
; bootloader interface
push 0x1000
pop ds
mov si, kernel_restart_bootblock-0x10000
mov si, kernel_restart_bootblock
mov ax, 'KL'
jmp 0x1000:0000
 
/kernel/branches/flat_kernel/const.inc
134,9 → 134,9
 
SSE_INIT equ (SSE_IM+SSE_DM+SSE_ZM+SSE_OM+SSE_UM+SSE_PM)
 
OS_BASE equ 0
OS_BASE equ 0x01000000
 
window_data equ (OS_BASE+0x0000000)
window_data equ OS_BASE
 
CURRENT_TASK equ (OS_BASE+0x0003000)
TASK_COUNT equ (OS_BASE+0x0003004)
196,7 → 196,6
 
LFBAddress equ (OS_BASE+0x000FE80)
MEM_AMOUNT equ (OS_BASE+0x000FE8C)
;LFBSize equ (OS_BASE+0x02f9050)
 
ScreenWidth equ (OS_BASE+0x000FE00)
ScreenHeight equ (OS_BASE+0x000FE04)
235,7 → 234,7
BUTTON_INFO equ (OS_BASE+0x02C0000)
RESERVED_PORTS equ (OS_BASE+0x02D0000)
IRQ_SAVE equ (OS_BASE+0x02E0000)
SYS_VAR equ (OS_BASE+0x02f0000)
BOOT_VAR equ (OS_BASE+0x02f0000)
IMG_BACKGROUND equ (OS_BASE+0x0300000)
WinMapAddress equ (OS_BASE+0x0460000)
display_data equ (OS_BASE+0x0460000)
256,7 → 255,7
tss_data equ (OS_BASE+0x780000)
draw_data equ (OS_BASE+0x988000)
 
HEAP_BASE equ (OS_BASE+0x98B000)
HEAP_BASE equ (OS_BASE+0x01000000)
 
LFB_BASE equ 0x7DC00000
 
264,12 → 263,10
master_tab equ 0x7FDFF000
app_page_tabs equ 0x7FE00000
 
sys_pgdir equ OS_BASE+0x00050000
sys_master_tab equ OS_BASE+0x00051000
sys_pgmap equ OS_BASE+0x00052000
sys_pgdir equ (OS_BASE+0x00050000)
sys_pgmap equ (OS_BASE+0x00052000)
 
 
 
new_app_base equ 0x80000000
 
twdw equ (CURRENT_TASK-window_data)
330,10 → 327,6
.vesa_mode dd ?
.x_res dd ?
.y_res dd ?
.cpu_caps dd ?
dd ?
dd ?
dd ?
}
 
struc APPOBJ ;common object header
/kernel/branches/flat_kernel/core/dll.inc
1038,21 → 1038,3
ret
 
 
;szSound db 'SOUND',0
;szInfinity db 'INFINITY',0
szHwMouse db 'ATI2D',0
 
szSTART db 'START',0
szEXPORTS db 'EXPORTS',0
szIMPORTS db 'IMPORTS',0
 
msg_unresolved db 'unresolved ',0
msg_module db 'in module ',0
msg_version db 'incompatible driver version',13,10,0
msg_www db 'please visit www.kolibrios.org',13,10,0
msg_CR db 13,10,0
 
align 4
create_cursor dd 0
set_hw_cursor dd 0
hw_restore dd 0
/kernel/branches/flat_kernel/core/memory.inc
1,161 → 1,5
 
tmp_page_tab equ HEAP_BASE
 
align 4
proc mem_test
 
mov eax, cr0
and eax, not (CR0_CD+CR0_NW)
or eax, CR0_CD ;disable caching
mov cr0, eax
wbinvd ;invalidate cache
 
xor edi, edi
mov ebx, 'TEST'
@@:
add edi, 0x400000
xchg ebx, dword [edi]
cmp dword [edi], 'TEST'
xchg ebx, dword [edi]
je @b
mov [MEM_AMOUNT], edi
 
and eax, not (CR0_CD+CR0_NW) ;enable caching
mov cr0, eax
mov eax, edi
mov [LFBSize], 0x00800000
ret
endp
 
align 4
proc init_mem
 
mov eax, [MEM_AMOUNT]
 
mov [pg_data.mem_amount], eax
mov [pg_data.kernel_max], eax
 
shr eax, 12
mov edx, eax
mov [pg_data.pages_count], eax
mov [pg_data.kernel_pages], eax
 
shr eax, 3
mov [pg_data.pagemap_size], eax
 
shr edx, 10
cmp edx, 3
ja @f
inc edx ;at least 4Mb for kernel heap
@@:
mov [pg_data.kernel_tables], edx
 
xor eax, eax
mov edi, sys_pgdir
mov ecx, 2048
cld
rep stosd
 
mov edx, sys_pgdir
bt [cpu_caps], CAPS_PSE
jnc .no_PSE
 
mov ebx, cr4
or ebx, CR4_PSE
mov eax, PG_LARGE+PG_SW
bt [cpu_caps], CAPS_PGE
jnc @F
or eax, PG_GLOBAL
or ebx, CR4_PGE
@@:
mov cr4, ebx
sub [pg_data.kernel_tables], 2
 
mov [edx], eax
add eax, 0x00400000
mov [edx+4], eax
add edx, 8
 
mov eax, 0x800000+PG_SW
mov ecx, (HEAP_BASE-0x800000)/4096
jmp .map_low
.no_PSE:
mov eax, PG_SW
mov ecx, HEAP_BASE/4096
.map_low:
mov edi, tmp_page_tab
@@: ;
stosd
add eax, 0x1000
dec ecx
jnz @B
 
mov ecx, [pg_data.kernel_tables]
shl ecx, 10
xor eax, eax
rep stosd
 
mov ecx, [pg_data.kernel_tables]
mov eax, tmp_page_tab+PG_SW
mov edi, edx
 
.map_kernel_tabs:
 
stosd
add eax, 0x1000
dec ecx
jnz .map_kernel_tabs
 
mov dword [sys_pgdir+(page_tabs shr 20)], sys_pgdir+PG_SW
ret
endp
 
align 4
proc init_page_map
 
mov edi, sys_pgmap
mov ecx, (HEAP_BASE/4096)/32 ;384/4
mov ebx, ecx
xor eax,eax
cld
rep stosd
 
not eax
mov ecx, [pg_data.pagemap_size]
sub ecx, ebx
shr ecx, 2
rep stosd
 
lea edi, [sys_pgmap+ebx*4] ;+384
mov edx, [pg_data.pages_count]
mov ecx, [pg_data.kernel_tables]
add ecx, (HEAP_BASE/4096) and 31
sub edx, HEAP_BASE/4096
sub edx, ecx
mov [pg_data.pages_free], edx
 
xor eax, eax
mov ebx, ecx
shr ecx, 5
rep stosd
 
not eax
mov ecx, ebx
and ecx, 31
shl eax, cl
mov [page_start], edi; sys_pgmap+384
stosd
 
mov ebx, sys_pgmap
add ebx, [pg_data.pagemap_size]
mov [page_end], ebx
 
mov [pg_data.pg_mutex], 0
 
ret
endp
 
align 4
proc alloc_page
 
pushfd
382,7 → 226,7
 
cmp dword [LFBAddress], -1
jne @f
mov [0x2f0000+0x901c],byte 2
mov [BOOT_VAR+0x901c],byte 2
stdcall kernel_alloc, 0x280000
mov [LFBAddress], eax
ret
389,14 → 233,22
@@:
test [SCR_MODE],word 0100000000000000b
jnz @f
mov [0x2f0000+0x901c],byte 2
mov [BOOT_VAR+0x901c],byte 2
ret
@@:
mov edx, LFB_BASE
mov esi, [LFBAddress]
mov edi, [LFBSize]
mov edi, 0x00800000
mov dword [exp_lfb+4], edx
 
push eax
push edx
mov edx, 0x400 ;bocsh
mov al,0xff ;bocsh
out dx, al ;bocsh
pop edx
pop eax
 
shr edi, 12
mov [pg_count], edi
shr edi, 10
427,7 → 279,7
@@:
call alloc_page
stdcall map_page_table, edx, eax
add esi, 0x00400000
add edx, 0x00400000
dec edi
jnz @B
 
436,7 → 288,11
or eax, PG_UW
mov ecx, [pg_count]
cld
rep stosd
@@:
stosd
add eax, 0x1000
dec ecx
jnz @B
 
mov dword [LFBAddress], LFB_BASE
mov eax, cr3 ;flush TLB
605,6 → 461,14
proc page_fault_handler
pushad
 
push eax
push edx
mov edx, 0x400 ;bocsh
mov al,0xff ;bocsh
out dx, al ;bocsh
pop edx
pop eax
 
mov ebp, esp
mov eax, cr2
push eax
670,6 → 534,7
mov esp, ebp
popad
add esp, 4
iretd
 
save_ring3_context ;debugger support
 
1086,147 → 951,9
ret
 
align 4
proc strncmp stdcall, str1:dword, str2:dword, count:dword
 
mov ecx,[count]
jecxz .end
 
mov ebx,ecx
 
mov edi,[str1]
mov esi,edi
xor eax,eax
repne scasb
neg ecx ; cx = count - strlen
add ecx,ebx ; strlen + count - strlen
 
.okay:
mov edi,esi
mov esi,[str2]
repe cmpsb
mov al,[esi-1]
xor ecx,ecx
 
cmp al,[edi-1]
ja .str2_big
je .end
 
.str1_big:
sub ecx,2
 
.str2_big:
not ecx
.end:
mov eax,ecx
ret
endp
 
align 4
proc test_cpu
locals
cpu_type dd ?
cpu_id dd ?
cpu_Intel dd ?
cpu_AMD dd ?
endl
 
mov [cpu_type], 0
xor eax, eax
mov [cpu_caps], eax
mov [cpu_caps+4], eax
 
pushfd
pop eax
mov ecx, eax
xor eax, 0x40000
push eax
popfd
pushfd
pop eax
xor eax, ecx
mov [cpu_type], CPU_386
jz .end_cpuid
push ecx
popfd
 
mov [cpu_type], CPU_486
mov eax, ecx
xor eax, 0x200000
push eax
popfd
pushfd
pop eax
xor eax, ecx
je .end_cpuid
mov [cpu_id], 1
 
xor eax, eax
cpuid
mov [cpu_vendor], ebx
mov [cpu_vendor+4], edx
mov [cpu_vendor+8], ecx
cmp ebx, dword [intel_str]
jne .check_AMD
cmp edx, dword [intel_str+4]
jne .check_AMD
cmp ecx, dword [intel_str+8]
jne .check_AMD
mov [cpu_Intel], 1
cmp eax, 1
jl .end_cpuid
mov eax, 1
cpuid
mov [cpu_sign], eax
mov [cpu_info], ebx
mov [cpu_caps], edx
mov [cpu_caps+4],ecx
 
shr eax, 8
and eax, 0x0f
ret
.end_cpuid:
mov eax, [cpu_type]
ret
 
.check_AMD:
cmp ebx, dword [AMD_str]
jne .unknown
cmp edx, dword [AMD_str+4]
jne .unknown
cmp ecx, dword [AMD_str+8]
jne .unknown
mov [cpu_AMD], 1
cmp eax, 1
jl .unknown
mov eax, 1
cpuid
mov [cpu_sign], eax
mov [cpu_info], ebx
mov [cpu_caps], edx
mov [cpu_caps+4],ecx
shr eax, 8
and eax, 0x0f
ret
.unknown:
mov eax, 1
cpuid
mov [cpu_sign], eax
mov [cpu_info], ebx
mov [cpu_caps], edx
mov [cpu_caps+4],ecx
shr eax, 8
and eax, 0x0f
ret
endp
 
MEM_WB equ 6 ;write-back memory
MEM_WC equ 1 ;write combined memory
MEM_UC equ 0 ;uncached memory
 
align 4
proc init_mtrr
 
cmp [0x2f0000+0x901c],byte 2
cmp [BOOT_VAR+0x901c],byte 2
je .exit
 
bt [cpu_caps], CAPS_MTRR
1297,7 → 1024,44
ret
endp
 
 
align 4
proc strncmp stdcall, str1:dword, str2:dword, count:dword
 
mov ecx,[count]
jecxz .end
 
mov ebx,ecx
 
mov edi,[str1]
mov esi,edi
xor eax,eax
repne scasb
neg ecx ; cx = count - strlen
add ecx,ebx ; strlen + count - strlen
 
.okay:
mov edi,esi
mov esi,[str2]
repe cmpsb
mov al,[esi-1]
xor ecx,ecx
 
cmp al,[edi-1]
ja .str2_big
je .end
 
.str1_big:
sub ecx,2
 
.str2_big:
not ecx
.end:
mov eax,ecx
ret
endp
 
align 4
proc stall stdcall, delay:dword
push ecx
push edx
1324,107 → 1088,7
ret
endp
 
iglobal
align 4
intel_str db "GenuineIntel",0
AMD_str db "AuthenticAMD",0
endg
 
uglobal
align 16
irq_tab rd 16
 
MEM_FreeSpace rd 1
 
ipc_tmp rd 1
ipc_pdir rd 1
ipc_ptab rd 1
 
proc_mem_map rd 1
proc_mem_pdir rd 1
proc_mem_tab rd 1
 
tmp_task_pdir rd 1
tmp_task_ptab rd 1
 
fdd_buff rd 1
LFBSize rd 1
 
stall_mcs rd 1
;;CPUID information
 
cpu_vendor rd 3
cpu_sign rd 1
cpu_info rd 1
 
;;;;; cursors data
 
align 16
cur_saved_data rb 4096
 
def_cursor rd 1
hw_cursor rd 1
 
scr_width rd 1
scr_height rd 1
 
cur_def_interl rd 1
cur_saved_base rd 1
cur_saved_interl rd 1
cur_saved_w rd 1
cur_saved_h rd 1
 
endg
 
uglobal
align 16
fpu_data:
rb 512
 
mst MEM_STATE
 
mem_block_map rb 512
event_map rb 64
mem_block_list rd 64
mem_block_mask rd 2
 
srv.fd rd 1
srv.bk rd 1
 
mem_used.fd rd 1
mem_used.bk rd 1
 
mem_block_arr rd 1
mem_block_start rd 1
mem_block_end rd 1
 
heap_mutex rd 1
heap_size rd 1
heap_free rd 1
heap_blocks rd 1
free_blocks rd 1
 
page_start rd 1
page_end rd 1
events rd 1
event_start rd 1
event_end rd 1
event_uid rd 1
sys_page_map rd 1
os_stack rd 1
endg
 
if 0
push eax
push edx
mov edx, 0x400 ;bocsh
mov al,0xff ;bocsh
out dx, al ;bocsh
pop edx
pop eax
end if
 
align 4
k_strrchr:
push eax
xor eax,eax
1643,3 → 1307,15
ret
 
end if
 
if 0
push eax
push edx
mov edx, 0x400 ;bocsh
mov al,0xff ;bocsh
out dx, al ;bocsh
pop edx
pop eax
end if
 
 
/kernel/branches/flat_kernel/core/sys32.inc
7,6 → 7,7
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
align 4
idtreg:
dw 8*0x41-1
dd idts+8
/kernel/branches/flat_kernel/core/taskman.inc
1119,13 → 1119,5
ret
endp
 
 
 
include "debug.inc"
 
iglobal
new_process_loading db 'K : New Process - loading',13,10,0
new_process_running db 'K : New Process - done',13,10,0
start_not_enough_memory db 'K : New Process - not enough memory',13,10,0
endg
 
/kernel/branches/flat_kernel/data16.inc
0,0 → 1,41
 
preboot_lfb db 0
preboot_bootlog db 0
 
old_ints_h:
dw 0x400
dd 0
dw 0
 
kernel_restart_bootblock:
db 1 ; version
dw 1 ; floppy image is in memory
dd 0 ; cannot save parameters
 
align 4
; videomodes table
gr_table:
dw 0x112+0100000000000000b , 640 , 480 ; 1
dw 0x115+0100000000000000b , 800 , 600 ; 2
dw 0x118+0100000000000000b , 1024 , 768 ; 3
dw 0x11B+0100000000000000b , 1280 , 1024 ; 4
dw 0x112 , 640 , 480 ; 5
dw 0x115 , 800 , 600 ; 6
dw 0x118 , 1024 , 768 ; 7
dw 0x11B , 1280 ,1024 ; 8
dw 0x13, 640, 480 ; 9
dw 0x12, 640, 480 ; 0
 
; table for move to extended memory (int 15h, ah=87h)
align 8
movedesc:
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
 
db 0xff,0xff,0x0,0xa0,0x00,0x93,0x0,0x0
db 0xff,0xff,0x0,0x00,0x10,0x93,0x0,0x0
 
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
/kernel/branches/flat_kernel/data32.inc
0,0 → 1,329
 
keymap:
 
db '6',27
db '1234567890-=',8,9
db 'qwertyuiop[]',13
db '~asdfghjkl;',39,96,0,'\zxcvbnm,./',0,'45 '
db '@234567890123',180,178,184,'6',176,'7'
db 179,'8',181,177,183,185,182
db 'AB<D',255,'FGHIJKLMNOPQRSTUVWXYZ'
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
 
keymap_shift:
db '6',27
db '!@#$%^&*()_+',8,9
db 'QWERTYUIOP{}',13
db '~ASDFGHJKL:"~',0,'|ZXCVBNM<>?',0,'45 '
db '@234567890123',180,178,184,'6',176,'7'
db 179,'8',181,177,183,185,182
db 'AB>D',255,'FGHIJKLMNOPQRSTUVWXYZ'
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
 
 
keymap_alt:
db ' ',27
db ' @ $ {[]}\ ',8,9
db ' ',13
db ' ',0,' ',0,'4',0,' '
db ' ',180,178,184,'6',176,'7'
db 179,'8',181,177,183,185,182
db 'ABCD',255,'FGHIJKLMNOPQRSTUVWXYZ'
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
 
 
 
boot_memdetect db 'Determining amount of memory',0
boot_fonts db 'Fonts loaded',0
boot_tss db 'Setting TSSs',0
boot_cpuid db 'Reading CPUIDs',0
boot_devices db 'Detecting devices',0
boot_timer db 'Setting timer',0
boot_irqs db 'Reprogramming IRQs',0
boot_setmouse db 'Setting mouse',0
boot_windefs db 'Setting window defaults',0
boot_bgr db 'Calculating background',0
boot_resirqports db 'Reserving IRQs & ports',0
boot_setrports db 'Setting addresses for IRQs',0
boot_setostask db 'Setting OS task',0
boot_allirqs db 'Unmasking all IRQs',0
boot_tsc db 'Reading TSC',0
boot_pal_ega db 'Setting EGA/CGA 320x200 palette',0
boot_pal_vga db 'Setting VGA 640x480 palette',0
boot_mtrr db 'Setting MTRR',0
boot_tasking db 'All set - press ESC to start',0
 
new_process_loading db 'K : New Process - loading',13,10,0
new_process_running db 'K : New Process - done',13,10,0
start_not_enough_memory db 'K : New Process - not enough memory',13,10,0
 
msg_unresolved db 'unresolved ',0
msg_module db 'in module ',0
msg_version db 'incompatible driver version',13,10,0
msg_www db 'please visit www.kolibrios.org',13,10,0
msg_CR db 13,10,0
 
intel_str db "GenuineIntel",0
AMD_str db "AuthenticAMD",0
 
;szSound db 'SOUND',0
;szInfinity db 'INFINITY',0
szHwMouse db 'ATI2D',0
 
szSTART db 'START',0
szEXPORTS db 'EXPORTS',0
szIMPORTS db 'IMPORTS',0
 
firstapp db '/rd/1/LAUNCHER',0
char db 'FONTS/CHAR.MT',0
char2 db 'FONTS/CHAR2.MT',0
bootpath db '/KOLIBRI '
bootpath2 db 0
vmode db 'drivers/VMODE.MDR',0
vrr_m db '/rd/1/VRR_M',0
 
 
; mike.dld {
db 0
dd servetable-0x10000
draw_line dd __sys_draw_line
disable_mouse dd __sys_disable_mouse
draw_pointer dd __sys_draw_pointer
;//mike.dld, 2006-08-02 [
;drawbar dd __sys_drawbar
drawbar dd __sys_drawbar.forced
;//mike.dld, 2006-08-02 ]
putpixel dd __sys_putpixel
; } mike.dld
 
 
align 4
keyboard dd 1
sound_dma dd 1
syslang dd 1
 
boot_y dd 10
 
 
if __DEBUG__ eq 1
include_debug_strings
end if
 
IncludeIGlobals
 
align 16
gdts:
 
dw gdte-$-1
dd gdts
dw 0
 
; Attention! The order first four selectors not to change, is used in Fast System Call
; must be : os_code, os_data, app_code, app_data, ....
 
int_code_l:
os_code_l:
dw 0xffff
dw 0x0000
db 0x00
dw 11011111b *256 +10011010b
db 0x00
 
int_data_l:
os_data_l:
dw 0xffff
dw 0x0000
db 0x00
dw 11011111b *256 +10010010b
db 0x00
 
app_code_l:
dw 0xFFFF
dw 0
db 0
db cpl3
dw G32+D32+0x8000+0x7;
 
app_data_l:
dw 0xFFFF
dw 0
db 0
db drw3
dw G32+D32+0x8000+0x7;
 
; --------------- APM ---------------------
apm_code_32:
dw 0x0f ; limit 64kb
db 0, 0, 0
dw 11010000b *256 +10011010b
db 0x00
apm_code_16:
dw 0x0f
db 0, 0, 0
dw 10010000b *256 +10011010b
db 0x00
apm_data_16:
dw 0x0f
db 0, 0, 0
dw 10010000b *256 +10010010b
db 0x00
; -----------------------------------------
 
graph_data_l:
 
dw 0x7ff
dw 0x0000
db 0x00
dw 11010000b *256 +11110010b
db 0x00
 
endofcode:
tss0_l:
rq (max_processes+10)
 
gdte:
 
align 16
cur_saved_data rb 4096
fpu_data: rb 512
 
; device irq owners
irq_owner rd 16 ; process id
 
; on irq read ports
 
irq00read rd 16
irq01read rd 16
irq02read rd 16
irq03read rd 16
irq04read rd 16
irq05read rd 16
irq06read rd 16
irq07read rd 16
irq08read rd 16
irq09read rd 16
irq10read rd 16
irq11read rd 16
irq12read rd 16
irq13read rd 16
irq14read rd 16
irq15read rd 16
 
irq_tab rd 16
 
mem_block_map rb 512
event_map rb 64
mem_block_list rd 64
mem_block_mask rd 2
 
mem_used.fd rd 1
mem_used.bk rd 1
 
mem_block_arr rd 1
mem_block_start rd 1
mem_block_end rd 1
 
heap_mutex rd 1
heap_size rd 1
heap_free rd 1
heap_blocks rd 1
free_blocks rd 1
 
mst MEM_STATE
 
page_start rd 1
page_end rd 1
events rd 1
event_start rd 1
event_end rd 1
event_uid rd 1
sys_page_map rd 1
os_stack rd 1
 
srv.fd rd 1
srv.bk rd 1
 
scr_width rd 1
scr_height rd 1
 
create_cursor rd 1
set_hw_cursor rd 1
hw_restore rd 1
 
def_cursor rd 1
hw_cursor rd 1
cur_def_interl rd 1
cur_saved_base rd 1
cur_saved_interl rd 1
cur_saved_w rd 1
cur_saved_h rd 1
 
ipc_tmp rd 1
ipc_pdir rd 1
ipc_ptab rd 1
 
proc_mem_map rd 1
proc_mem_pdir rd 1
proc_mem_tab rd 1
 
tmp_task_pdir rd 1
tmp_task_ptab rd 1
 
LFBSize rd 1
 
stall_mcs rd 1
 
; status
hd1_status rd 1 ; 0 - free : other - pid
application_table_status rd 1 ; 0 - free : other - pid
 
; device addresses
mididp rd 1
midisp rd 1
 
cdbase rd 1
cdid rd 1
 
hdbase rd 1 ; for boot 0x1f0
hdid rd 1
hdpos rd 1 ; for boot 0x1
fat32part rd 1 ; for boot 0x1
 
sb16 rd 1
 
;CPUID information
cpu_vendor rd 3
cpu_sign rd 1
cpu_info rd 1
cpu_caps rd 4
 
 
pg_data PG_DATA
heap_test rd 1
 
buttontype rd 1
windowtypechanged rd 1
 
hd_entries rd 1 ;unused ? 0xfe10
 
;* start code - Mario79
mouse_pause rd 1
MouseTickCounter rd 1
ps2_mouse_detected rb 1
com1_mouse_detected rb 1
com2_mouse_detected rb 1
;* end code - Mario79
 
wraw_bacground_select rb 1
 
lba_read_enabled rd 1 ; 0 = disabled , 1 = enabled
pci_access_enabled rd 1 ; 0 = disabled , 1 = enabled
 
IncludeUGlobals
 
/kernel/branches/flat_kernel/detect/commouse.inc
17,7 → 17,7
 
mov eax,4
shl eax,2
mov [irq_owner+eax],byte 1
mov [irq_owner+eax], 1
 
inc dword [RESERVED_PORTS]
mov edi,[RESERVED_PORTS]
39,7 → 39,7
 
mov eax,3
shl eax,2
mov [irq_owner+eax],byte 1
mov [irq_owner+eax], 1
 
inc dword [RESERVED_PORTS]
mov edi,[RESERVED_PORTS]
/kernel/branches/flat_kernel/detect/dev_hdcd.inc
12,24 → 12,24
mov [DiskNumber],0
call FindHDD_3
; mov ax,[Sector512+176]
; mov [0x40006],ax
; mov [DRIVE_DATA+6],ax
; mov ax,[Sector512+126]
; mov [0x40008],ax
; mov [DRIVE_DATA+8],ax
; mov ax,[Sector512+128]
; mov [0x40008],ax
; mov [DRIVE_DATA+8],ax
mov [DiskNumber],1
call FindHDD_3
; mov al,[Sector512+176]
; mov [0x40007],al
; mov [DRIVE_DATA+7],al
inc [ChannelNumber]
mov [DiskNumber],0
call FindHDD_3
; mov al,[Sector512+176]
; mov [0x40008],al
; mov [DRIVE_DATA+8],al
mov [DiskNumber],1
call FindHDD_1
; mov al,[Sector512+176]
; mov [0x40009],al
; mov [DRIVE_DATA+9],al
jmp EndFindHDD
 
41,7 → 41,7
ja FindHDD_2
cmp [Sector512+12],word 255
ja FindHDD_2
inc byte [0x40001]
inc byte [DRIVE_DATA+1]
jmp FindHDD_2_2
FindHDD_2:
call DeviceReset
50,14 → 50,14
call ReadCD_ID
cmp [DevErrorCode],0
jne FindHDD_2_2
inc byte [0x40001]
inc byte [0x40001]
inc byte [DRIVE_DATA+1]
inc byte [DRIVE_DATA+1]
FindHDD_2_2:
ret
 
FindHDD_3:
call FindHDD_1
shl byte [0x40001],2
shl byte [DRIVE_DATA+1],2
ret
 
 
84,7 → 84,7
cmp [DevErrorCode],0 ;ïðîâåðèòü êîä îøèáêè
jne @@End ;çàêîí÷èòü, ñîõðàíèâ êîä îøèáêè
mov DX,[ATABasePortAddr]
add DX,7 ;àäðåñ ðåãèñòðà ñîñòîÿíèÿ
add DX,7 ;àäðåñ ðåãèñòðà ñîñòîÿíè
mov ecx,0xffff
@@WaitCompleet:
; Ïðîâåðèòü âðåìÿ âûïîëíåíèÿ êîìàíäû
191,7 → 191,7
; mov eax,[timer_ticks]
; mov [TickCounter_1],eax
@@WaitHDReady:
; Ïðîâåðèòü âðåìÿ îæèäàíèÿ
; Ïðîâåðèòü âðåìÿ îæèäàíè
dec ecx
cmp ecx,0
je @@Err1
199,7 → 199,7
; sub eax,[TickCounter_1]
; cmp eax,300 ;îæèäàòü 300 òèêîâ
; ja @@Err1 ;îøèáêà òàéì-àóòà
; Ïðî÷èòàòü ðåãèñòð ñîñòîÿíèÿ
; Ïðî÷èòàòü ðåãèñòð ñîñòîÿíè
in AL,DX
; Ïðîâåðèòü ñîñòîÿíèå ñèãíàëà BSY
test AL,80h
285,7 → 285,7
add DX,7 ;ïîðò 1õ7h
mov ecx,0xffff
@@WaitCompleet_1:
; Ïðîâåðèòü âðåìÿ
; Ïðîâåðèòü âðåì
dec ecx
cmp ecx,0
je @@Error1_1 ;îøèáêà òàéì-àóòà
348,11 → 348,11
out DX,AL
mov ecx,0x80000
@@WaitHDReady_1:
; Ïðîâåðèòü âðåìÿ îæèäàíèÿ
; Ïðîâåðèòü âðåìÿ îæèäàíè
dec ecx
cmp ecx,0
je @@Err1_2 ;îøèáêà òàéì-àóòà
; Ïðî÷èòàòü ðåãèñòð ñîñòîÿíèÿ
; Ïðî÷èòàòü ðåãèñòð ñîñòîÿíè
in AL,DX
; Ïðîâåðèòü ñîñòîÿíèå ñèãíàëà BSY
test AL,80h
/kernel/branches/flat_kernel/detect/sear_par.inc
3,9 → 3,9
; è çàíåñåíèå äàííûõ â îáëàñòü òàáëèöû
; àâòîð Mario79
;****************************************************
mov [transfer_adress],0x4000a
mov [transfer_adress],DRIVE_DATA+0xa
search_partitions_ide0:
test [0x40001],byte 0x40
test [DRIVE_DATA+1],byte 0x40
jz search_partitions_ide1
mov [hdbase],0x1f0
mov [hdid],0x0
15,7 → 15,7
call set_FAT32_variables
cmp [problem_partition],0
jne search_partitions_ide1
inc byte [0x40002]
inc byte [DRIVE_DATA+2]
call partition_data_transfer
add [transfer_adress],100
inc [fat32part]
22,7 → 22,7
jmp search_partitions_ide0_1
 
search_partitions_ide1:
test [0x40001],byte 0x10
test [DRIVE_DATA+1],byte 0x10
jz search_partitions_ide2
mov [hdbase],0x1f0
mov [hdid],0x10
32,7 → 32,7
call set_FAT32_variables
cmp [problem_partition],0
jne search_partitions_ide2
inc byte [0x40003]
inc byte [DRIVE_DATA+3]
call partition_data_transfer
add [transfer_adress],100
inc [fat32part]
39,7 → 39,7
jmp search_partitions_ide1_1
 
search_partitions_ide2:
test [0x40001],byte 0x4
test [DRIVE_DATA+1],byte 0x4
jz search_partitions_ide3
mov [hdbase],0x170
mov [hdid],0x0
49,7 → 49,7
call set_FAT32_variables
cmp [problem_partition],0
jne search_partitions_ide3
inc byte [0x40004]
inc byte [DRIVE_DATA+4]
call partition_data_transfer
add [transfer_adress],100
inc [fat32part]
56,7 → 56,7
jmp search_partitions_ide2_1
 
search_partitions_ide3:
test [0x40001],byte 0x1
test [DRIVE_DATA+1],byte 0x1
jz end_search_partitions_ide
mov [hdbase],0x170
mov [hdid],0x10
66,7 → 66,7
call set_FAT32_variables
cmp [problem_partition],0
jne end_search_partitions_ide
inc byte [0x40005]
inc byte [DRIVE_DATA+5]
call partition_data_transfer
add [transfer_adress],100
inc [fat32part]
/kernel/branches/flat_kernel/fs/fs.inc
389,8 → 389,8
choice_necessity_partition_1:
mov ecx,[hdpos]
xor eax,eax
mov [0xfe10], eax ; entries in hd cache
mov edx,0x40002
mov [hd_entries], eax ; entries in hd cache
mov edx,DRIVE_DATA+2
search_partition_array:
mov bl,[edx]
movzx ebx,bl
402,7 → 402,7
dec eax
xor edx,edx
imul eax,100
add eax,0x4000a
add eax,DRIVE_DATA+0xa
mov [transfer_adress],eax
call partition_data_transfer_1
ret
/kernel/branches/flat_kernel/fs/fs_lfn.inc
427,7 → 427,7
mov [hdpos], eax
cmp ecx, 0x100
jae .nf
cmp cl, [0x40001+eax]
cmp cl, [DRIVE_DATA+eax]
jbe @f
.nf:
call free_hd_channel
503,7 → 503,7
jae .nf
push ecx ebx
mov cl,al
mov bl,[0x40001]
mov bl,[DRIVE_DATA+1]
shr bl,cl
test bl,2
pop ebx ecx
/kernel/branches/flat_kernel/gui/font.inc
10,8 → 10,8
; edi 1 force
 
pushad
 
call [disable_mouse]
 
mov ebp, ecx ; ebp=pointer to text
mov ecx, ebx ; ecx=color
movsx ebx, ax ; ebx=y
/kernel/branches/flat_kernel/gui/window.inc
516,7 → 516,7
 
repos_windows:
mov ecx,[TASK_COUNT]
mov edi,0x20*2
mov edi, OS_BASE+0x20*2
mov byte[REDRAW_BACKGROUND],1
dec ecx
jge @f
537,6 → 537,7
neg eax
mov [edi+WDATA.box.height],eax
.lp1:
 
call set_window_clientbox
add edi,0x20
loop @b
/kernel/branches/flat_kernel/hid/mousedrv.inc
100,6 → 100,7
mov ecx, [ScreenWidth]
inc ecx
mul ecx
 
movzx edx, byte [display_data+ebx+eax]
shl edx, 8
mov ecx, [edx+SLOT_BASE+APPDATA.cursor]
320,9 → 321,10
disable_m:
cmp dword [MOUSE_VISIBLE],dword 0
jne no_mouse_disable
pushf
cli
call draw_mouse_under
sti
popf
mov [MOUSE_VISIBLE],dword 1
no_mouse_disable:
popad
350,9 → 352,10
mov [MOUSE_VISIBLE], dword 0
movzx ebx,word [MOUSE_Y]
movzx eax,word [MOUSE_X]
pushfd
cli
call save_draw_mouse
sti
popfd
nodmu2:
popad
ret
367,10 → 370,11
jne redrawmouse
jmp nodmp
redrawmouse:
pushfd
cli
call draw_mouse_under
call save_draw_mouse
sti
popfd
nodmp:
popad
ret
/kernel/branches/flat_kernel/init.inc
0,0 → 1,271
 
MEM_WB equ 6 ;write-back memory
MEM_WC equ 1 ;write combined memory
MEM_UC equ 0 ;uncached memory
 
tmp_page_tab equ 0x1000000 ; HEAP_BASE
 
align 4
proc mem_test
 
mov eax, cr0
and eax, not (CR0_CD+CR0_NW)
or eax, CR0_CD ;disable caching
mov cr0, eax
wbinvd ;invalidate cache
 
xor edi, edi
mov ebx, 'TEST'
@@:
add edi, 0x400000
xchg ebx, dword [edi]
cmp dword [edi], 'TEST'
xchg ebx, dword [edi]
je @b
mov [MEM_AMOUNT-OS_BASE], edi
 
and eax, not (CR0_CD+CR0_NW) ;enable caching
mov cr0, eax
mov eax, edi
ret
endp
 
align 4
proc init_mem
 
mov eax, [MEM_AMOUNT-OS_BASE]
mov [pg_data.mem_amount-OS_BASE], eax
mov [pg_data.kernel_max-OS_BASE], eax
 
shr eax, 12
mov edx, eax
mov [pg_data.pages_count-OS_BASE], eax
mov [pg_data.kernel_pages-OS_BASE], eax
 
shr eax, 3
mov [pg_data.pagemap_size-OS_BASE], eax
 
shr edx, 10
cmp edx, 3
ja @f
inc edx ;at least 4Mb for kernel heap
@@:
mov [pg_data.kernel_tables-OS_BASE], edx
 
xor eax, eax
mov edi, sys_pgdir-OS_BASE
mov ecx, 2048
cld
rep stosd
 
mov edx, sys_pgdir-OS_BASE
; bt [cpu_caps], CAPS_PSE
; jnc .no_PSE
 
mov ebx, cr4
or ebx, CR4_PSE
mov eax, PG_LARGE+PG_SW
bt [cpu_caps-OS_BASE], CAPS_PGE
jnc @F
or eax, PG_GLOBAL
or ebx, CR4_PGE
@@:
mov cr4, ebx
sub [pg_data.kernel_tables-OS_BASE], 2
 
mov [edx], eax
mov [edx+16], eax
add eax, 0x00400000
 
mov [edx+4], eax
mov [edx+20], eax
add eax, 0x00400000
 
mov [edx+8], eax
mov [edx+24], eax
add eax, 0x00400000
 
mov [edx+12], eax
mov [edx+28], eax
add edx, 32
add eax, 0x00400000
 
; mov eax, 0x800000+PG_SW
; mov ecx, (HEAP_BASE-0x800000)/4096
; jmp .map_low
;.no_PSE:
; mov eax, PG_SW
; mov ecx, HEAP_BASE/4096
;.map_low:
mov edi, tmp_page_tab
;@@: ;
; stosd
; add eax, 0x1000
; dec ecx
; jnz @B
 
mov ecx, [pg_data.kernel_tables-OS_BASE]
shl ecx, 10
xor eax, eax
rep stosd
 
mov ecx, [pg_data.kernel_tables-OS_BASE]
mov eax, tmp_page_tab+PG_SW
mov edi, edx
 
.map_kernel_tabs:
 
stosd
add eax, 0x1000
dec ecx
jnz .map_kernel_tabs
 
mov dword [sys_pgdir-OS_BASE+(page_tabs shr 20)], sys_pgdir+PG_SW-OS_BASE
ret
endp
 
align 4
proc init_page_map
 
mov edi, sys_pgmap-OS_BASE
mov ecx, (HEAP_BASE/4096)/32 ;384/4
mov ebx, ecx
xor eax,eax
cld
rep stosd
 
not eax
mov ecx, [pg_data.pagemap_size-OS_BASE]
sub ecx, ebx
shr ecx, 2
rep stosd
 
lea edi, [sys_pgmap-OS_BASE+ebx*4] ;+384
mov edx, [pg_data.pages_count-OS_BASE]
mov ecx, [pg_data.kernel_tables-OS_BASE]
add ecx, (HEAP_BASE/4096) and 31
sub edx, HEAP_BASE/4096
sub edx, ecx
mov [pg_data.pages_free-OS_BASE], edx
 
xor eax, eax
mov ebx, ecx
shr ecx, 5
rep stosd
 
not eax
mov ecx, ebx
and ecx, 31
shl eax, cl
add edi, OS_BASE
mov [page_start-OS_BASE], edi; sys_pgmap+384
stosd
 
mov ebx, sys_pgmap
add ebx, [pg_data.pagemap_size-OS_BASE]
mov [page_end-OS_BASE], ebx
 
mov [pg_data.pg_mutex-OS_BASE], 0
 
ret
endp
 
align 4
proc test_cpu
locals
cpu_type dd ?
cpu_id dd ?
cpu_Intel dd ?
cpu_AMD dd ?
endl
 
mov [cpu_type], 0
xor eax, eax
mov [cpu_caps-OS_BASE], eax
mov [cpu_caps+4-OS_BASE], eax
 
pushfd
pop eax
mov ecx, eax
xor eax, 0x40000
push eax
popfd
pushfd
pop eax
xor eax, ecx
mov [cpu_type], CPU_386
jz .end_cpuid
push ecx
popfd
 
mov [cpu_type], CPU_486
mov eax, ecx
xor eax, 0x200000
push eax
popfd
pushfd
pop eax
xor eax, ecx
je .end_cpuid
mov [cpu_id], 1
 
xor eax, eax
cpuid
 
mov [cpu_vendor-OS_BASE], ebx
mov [cpu_vendor+4-OS_BASE], edx
mov [cpu_vendor+8-OS_BASE], ecx
cmp ebx, dword [intel_str-OS_BASE]
jne .check_AMD
cmp edx, dword [intel_str+4-OS_BASE]
jne .check_AMD
cmp ecx, dword [intel_str+8-OS_BASE]
jne .check_AMD
mov [cpu_Intel], 1
cmp eax, 1
jl .end_cpuid
mov eax, 1
cpuid
mov [cpu_sign-OS_BASE], eax
mov [cpu_info-OS_BASE], ebx
mov [cpu_caps-OS_BASE], edx
mov [cpu_caps+4-OS_BASE],ecx
 
shr eax, 8
and eax, 0x0f
ret
.end_cpuid:
mov eax, [cpu_type]
ret
 
.check_AMD:
cmp ebx, dword [AMD_str-OS_BASE]
jne .unknown
cmp edx, dword [AMD_str+4-OS_BASE]
jne .unknown
cmp ecx, dword [AMD_str+8-OS_BASE]
jne .unknown
mov [cpu_AMD], 1
cmp eax, 1
jl .unknown
mov eax, 1
cpuid
mov [cpu_sign-OS_BASE], eax
mov [cpu_info-OS_BASE], ebx
mov [cpu_caps-OS_BASE], edx
mov [cpu_caps+4-OS_BASE],ecx
shr eax, 8
and eax, 0x0f
ret
.unknown:
mov eax, 1
cpuid
mov [cpu_sign-OS_BASE], eax
mov [cpu_info-OS_BASE], ebx
mov [cpu_caps-OS_BASE], edx
mov [cpu_caps+4-OS_BASE],ecx
shr eax, 8
and eax, 0x0f
ret
endp
 
/kernel/branches/flat_kernel/kernel.asm
15,20 → 15,18
include "lang.inc"
 
include "const.inc"
max_processes equ 255
tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4
 
;WinMapAddress equ 0x460000
;display_data = 0x460000
 
max_processes equ 255
os_data equ os_data_l-gdts ; GDTs
os_code equ os_code_l-gdts
graph_data equ 3+graph_data_l-gdts
tss0 equ tss0_l-gdts
app_code equ 3+app_code_l-gdts
app_data equ 3+app_data_l-gdts
 
;window_data equ 0x0000
;tss_data equ 0xD20000
tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4
;draw_data equ 0xC00000
;sysint_stack_data equ 0xC03000
 
;twdw equ (0x3000-window_data)
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Included files:
63,58 → 61,32
org 0x0
jmp start_of_code
 
; mike.dld {
org $+0x10000
db 0
dd servetable-0x10000
draw_line dd __sys_draw_line
disable_mouse dd __sys_disable_mouse
draw_pointer dd __sys_draw_pointer
;//mike.dld, 2006-08-02 [
;drawbar dd __sys_drawbar
drawbar dd __sys_drawbar.forced
;//mike.dld, 2006-08-02 ]
putpixel dd __sys_putpixel
; } mike.dld
 
version db 'Kolibri OS version 0.6.5.0 ',13,10,13,10,0
;dd endofcode-0x10000
 
;db 'Boot02'
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
include "boot/preboot.inc"
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
preboot_lfb db 0
preboot_bootlog db 0
if lang eq en
include "boot/booteng.inc" ; english system boot messages
else if lang eq ru
include "boot/bootru.inc" ; russian system boot messages
include "boot/ru.inc" ; Russian font
else if lang eq et
include "boot/bootet.inc" ; estonian system boot messages
include "boot/et.inc" ; Estonian font
else
include "boot/bootge.inc" ; german system boot messages
end if
 
include "boot/bootcode.inc" ; 16 bit system boot code
include "bus/pci/pci16.inc"
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; 16 BIT INCLUDED FILES ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
include "kernel16.inc"
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; SWITCH TO 32 BIT PROTECTED MODE ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
os_data = os_data_l-gdts ; GDTs
os_code = os_code_l-gdts
int_code equ int_code_l-gdts
int_data equ int_data_l-gdts
tss0sys equ tss0sys_l-gdts
graph_data equ 3+graph_data_l-gdts
tss0 equ tss0_l-gdts
app_code equ 3+app_code_l-gdts
app_data equ 3+app_data_l-gdts
 
 
 
; CR0 Flags - Protected mode and Paging
 
mov ecx, CR0_PE
121,7 → 93,7
 
; Enabling 32 bit protected mode
 
sidt [cs:old_ints_h-0x10000]
; sidt [cs:old_ints_h-0x10000]
 
cli ; disable all irqs
cld
143,173 → 115,148
jnz l.7
mov al, 0xFF
out 0x64, al
lgdt [cs:gdts-0x10000] ; Load GDT
mov eax, cr0 ; Turn on paging // protected mode
 
lgdt [cs:tmp_gdt] ; Load GDT
mov eax, cr0 ; protected mode
or eax, ecx
and eax, 10011111b *65536*256 + 0xffffff ; caching enabled
mov cr0, eax
jmp $+2
org $+0x10000
mov ax,os_data ; Selector for os
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov ss,ax
mov esp,0x3ec00 ; Set stack
jmp pword os_code:B32 ; jmp to enable 32 bit mode
 
if gdte >= $
error 'GDT overlaps with used code!'
end if
align 8
tmp_gdt:
 
use32
dw 23
dd tmp_gdt+0x10000
dw 0
 
include 'unpacker.inc'
dw 0xffff
dw 0x0000
db 0x00
dw 11011111b *256 +10011010b
db 0x00
 
__DEBUG__ fix 1
__DEBUG_LEVEL__ fix 1
include 'fdo.inc'
dw 0xffff
dw 0x0000
db 0x00
dw 11011111b *256 +10010010b
db 0x00
 
iglobal
boot_memdetect db 'Determining amount of memory',0
boot_fonts db 'Fonts loaded',0
boot_tss db 'Setting TSSs',0
boot_cpuid db 'Reading CPUIDs',0
boot_devices db 'Detecting devices',0
boot_timer db 'Setting timer',0
boot_irqs db 'Reprogramming IRQs',0
boot_setmouse db 'Setting mouse',0
boot_windefs db 'Setting window defaults',0
boot_bgr db 'Calculating background',0
boot_resirqports db 'Reserving IRQs & ports',0
boot_setrports db 'Setting addresses for IRQs',0
boot_setostask db 'Setting OS task',0
boot_allirqs db 'Unmasking all IRQs',0
boot_tsc db 'Reading TSC',0
boot_pal_ega db 'Setting EGA/CGA 320x200 palette',0
boot_pal_vga db 'Setting VGA 640x480 palette',0
boot_mtrr db 'Setting MTRR',0
boot_tasking db 'All set - press ESC to start',0
endg
include "data16.inc"
 
iglobal
boot_y dd 10
endg
use32
org $+0x10000
 
boot_log:
pushad
 
mov eax,10*65536
mov ax,word [boot_y]
add [boot_y],dword 10
mov ebx,0x80ffffff ; ASCIIZ string with white color
mov ecx,esi
mov edi,1
call dtext
 
mov [novesachecksum],1000
call checkVga_N13
 
cmp [preboot_blogesc],byte 1
je .bll2
 
cmp esi,boot_tasking
jne .bll2
; begin ealex 04.08.05
; in al,0x61
; and al,01111111b
; out 0x61,al
; end ealex 04.08.05
.bll1: in al,0x60 ; wait for ESC key press
cmp al,129
jne .bll1
 
.bll2: popad
 
ret
 
iglobal
firstapp db '/rd/1/LAUNCHER',0
char db 'FONTS/CHAR.MT',0
char2 db 'FONTS/CHAR2.MT',0
bootpath db '/KOLIBRI '
bootpath2 db 0
vmode db 'drivers/VMODE.MDR',0
vrr_m db '/rd/1/VRR_M',0
endg
 
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; 32 BIT ENTRY ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
align 4
 
B32:
; CLEAR 0x280000-0xF00000
mov ax,os_data ; Selector for os
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov ss,ax
mov esp,0x3ec00 ; Set stack
 
; CLEAR 0x280000 - HEAP_BASE
 
xor eax,eax
mov edi,0x280000
mov ecx,(0x100000*0xF-0x280000) / 4
mov ecx,(HEAP_BASE-0x280000) / 4
cld
rep stosd
; CLEAR 0x80000-0x90000
; xor eax,eax
 
mov edi,0x80000
mov ecx,(0x90000-0x80000)/4
; cld
mov edi,0x40000
mov ecx,(0x90000-0x40000)/4
rep stosd
 
; CLEAR KERNEL UNDEFINED GLOBALS
mov edi, endofcode
mov edi, endofcode-OS_BASE
mov ecx, (uglobals_size/4)+4
rep stosd
 
; SAVE & CLEAR 0-0xffff
 
mov esi,0x0000
xor esi, esi
mov edi,0x2F0000
mov ecx,0x10000 / 4
cld
rep movsd
xor eax,eax
mov edi,0
xor edi, edi
mov ecx,0x10000 / 4
cld
rep stosd
 
call test_cpu
bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc
 
; MEMORY MODEL
call mem_test
call init_mem
call init_page_map
 
; ENABLE PAGING
 
mov eax, sys_pgdir-OS_BASE
mov cr3, eax
 
mov eax,cr0
or eax,CR0_PG
mov cr0,eax
lgdt [gdts]
jmp pword os_code:high_code
 
__DEBUG__ fix 1
__DEBUG_LEVEL__ fix 1
include 'fdo.inc'
include 'init.inc'
include "boot/shutdown.inc" ; shutdown or restart
 
 
org OS_BASE+$
align 4
high_code:
mov ax,os_data
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov ss,ax
add esp, OS_BASE
 
mov dword [sys_pgdir], 0
mov dword [sys_pgdir+4], 0
mov dword [sys_pgdir+8], 0
mov dword [sys_pgdir+12], 0
 
mov eax, sys_pgdir-OS_BASE
mov cr3, eax
 
; SAVE REAL MODE VARIABLES
mov ax, [0x2f0000 + 0x9031]
mov ax, [BOOT_VAR + 0x9031]
mov [IDEContrRegsBaseAddr], ax
; --------------- APM ---------------------
mov eax, [0x2f0000 + 0x9040] ; entry point
mov dword[apm_entry], eax
mov word [apm_entry + 4], apm_code_32 - gdts
; mov eax, [BOOT_VAR + 0x9040] ; entry point
; mov dword[apm_entry], eax
; mov word [apm_entry + 4], apm_code_32 - gdts
 
mov eax, [0x2f0000 + 0x9044] ; version & flags
mov eax, [BOOT_VAR + 0x9044] ; version & flags
mov [apm_vf], eax
; -----------------------------------------
; movzx eax,byte [0x2f0000+0x9010] ; mouse port
; movzx eax,byte [BOOT_VAR+0x9010] ; mouse port
; mov [0xF604],byte 1 ;al
mov al, [0x2F0000+0x901F] ; DMA writing
mov al, [BOOT_VAR+0x901F] ; DMA writing
mov [allow_dma_write], al
mov al,[0x2f0000+0x9000] ; bpp
mov al,[BOOT_VAR+0x9000] ; bpp
mov [ScreenBPP],al
movzx eax,word [0x2f0000+0x900A] ; X max
movzx eax,word [BOOT_VAR+0x900A] ; X max
dec eax
mov [ScreenWidth],eax
mov [screen_workarea.right],eax
movzx eax,word [0x2f0000+0x900C] ; Y max
movzx eax,word [BOOT_VAR+0x900C] ; Y max
dec eax
mov [ScreenHeight],eax
mov [screen_workarea.bottom],eax
movzx eax,word [0x2f0000+0x9008] ; screen mode
movzx eax,word [BOOT_VAR+0x9008] ; screen mode
mov [SCR_MODE],eax
mov eax,[0x2f0000+0x9014] ; Vesa 1.2 bnk sw add
mov eax,[BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add
mov [BANK_SWITCH],eax
mov [BytesPerScanLine],word 640*4 ; Bytes PerScanLine
cmp [SCR_MODE],word 0x13 ; 320x200
316,22 → 263,14
je @f
cmp [SCR_MODE],word 0x12 ; VGA 640x480
je @f
mov ax,[0x2f0000+0x9001] ; for other modes
mov ax,[BOOT_VAR+0x9001] ; for other modes
mov [BytesPerScanLine],ax
@@:
 
; GRAPHICS ADDRESSES
 
;mov eax,0x100000*8 ; LFB address
;cmp [0xfe0c],word 0x13
;je no_d_lfb
;cmp [0xfe0c],word 0x12
;je no_d_lfb
;cmp [0x2f0000+0x901e],byte 1
;jne no_d_lfb
mov byte [0x2f0000+0x901e],0x0
mov eax,[0x2f0000+0x9018]
;no_d_lfb:
mov byte [BOOT_VAR+0x901e],0x0
mov eax,[BOOT_VAR+0x9018]
mov [LFBAddress],eax
 
cmp [SCR_MODE],word 0100000000000000b
339,39 → 278,28
cmp [SCR_MODE],word 0x13
je v20ga32
mov [PUTPIXEL],dword Vesa12_putpixel24 ; Vesa 1.2
mov [0xe024],dword Vesa12_getpixel24
mov [GETPIXEL],dword Vesa12_getpixel24
cmp [ScreenBPP],byte 24
jz ga24
mov [PUTPIXEL],dword Vesa12_putpixel32
mov [0xe024],dword Vesa12_getpixel32
mov [GETPIXEL],dword Vesa12_getpixel32
ga24:
jmp v20ga24
setvesa20:
mov [PUTPIXEL],dword Vesa20_putpixel24 ; Vesa 2.0
mov [0xe024],dword Vesa20_getpixel24
mov [GETPIXEL],dword Vesa20_getpixel24
cmp [ScreenBPP],byte 24
jz v20ga24
v20ga32:
mov [PUTPIXEL],dword Vesa20_putpixel32
mov [0xe024],dword Vesa20_getpixel32
mov [GETPIXEL],dword Vesa20_getpixel32
v20ga24:
cmp [SCR_MODE],word 0x12 ; 16 C VGA 640x480
jne no_mode_0x12
mov [PUTPIXEL],dword VGA_putpixel
mov [0xe024],dword Vesa20_getpixel32
mov [GETPIXEL],dword Vesa20_getpixel32
no_mode_0x12:
 
call test_cpu
; btr [cpu_caps], CAPS_SSE ;test: dont't use sse code
; btr [cpu_caps], CAPS_SSE2 ;test: don't use sse2
 
; btr [cpu_caps], CAPS_FXSR ;test: disable sse support
;all sse commands rise #UD exption
; btr [cpu_caps], CAPS_PSE ;test: don't use large pages
; btr [cpu_caps], CAPS_PGE ;test: don't use global pages
; btr [cpu_caps], CAPS_MTRR ;test: don't use MTRR
bts [cpu_caps], CAPS_TSC ;force use rdtsc
 
; -------- Fast System Call init ----------
; Intel SYSENTER/SYSEXIT (AMD CPU support it too)
bt [cpu_caps], CAPS_SEP
415,26 → 343,13
.noSYSCALL:
; -----------------------------------------
 
 
 
; MEMORY MODEL
call mem_test
call init_mtrr
call init_mem
call init_page_map
 
; ENABLE PAGING
mov eax, sys_pgdir
mov cr3, eax
 
mov eax,cr0
or eax,CR0_PG
mov cr0,eax
 
call init_kernel_heap
stdcall kernel_alloc, 0x2000
mov [os_stack], eax
 
mov [LFBSize], 0x800000
call init_mtrr
 
call init_LFB
call init_fpu
 
511,7 → 426,7
 
mov esi,char
xor ebx,ebx
mov ecx,2560;26000
mov ecx,2560
mov edx,FONT_I
call fs_RamdiskRead
 
552,8 → 467,7
call build_scheduler ; sys32.inc
 
; LOAD IDT
lidt [cs:idtreg]
cli
lidt [idtreg]
 
mov esi,boot_devices
call boot_log
628,8 → 542,6
 
mov dword [SLOT_BASE+256+APPDATA.fpu_handler], 0
mov dword [SLOT_BASE+256+APPDATA.sse_handler], 0
 
mov ebx, [def_cursor]
mov dword [SLOT_BASE+256+APPDATA.cursor], ebx
 
mov ebx, SLOT_BASE+256+APP_OBJ_OFFSET
637,6 → 549,8
mov dword [SLOT_BASE+256+APPDATA.bk_obj], ebx
 
; task list
mov [CURRENT_TASK],dword 1
mov [TASK_COUNT],dword 1
mov [TASK_DATA+TASKDATA.wnd_number], 1 ; on screen number
mov [TASK_DATA+TASKDATA.pid], 1 ; process id number
mov [TASK_DATA+TASKDATA.mem_start], 0 ; process base address
667,8 → 581,10
ltr ax
 
call init_cursors
mov eax, [def_cursor]
mov [SLOT_BASE+APPDATA.cursor],eax
mov [SLOT_BASE+APPDATA.cursor+256],eax
 
 
; READ TSC / SECOND
 
mov esi,boot_tsc
720,10 → 636,8
call load_skin
 
; LOAD FIRST APPLICATION
mov [CURRENT_TASK],dword 1
mov [TASK_COUNT],dword 1
cli
cmp byte [0x2f0000+0x9030],1
cmp byte [BOOT_VAR+0x9030],1
jne no_load_vrr_m
 
mov ebp, vrr_m
748,7 → 662,6
;mov [TASK_COUNT],dword 2
mov [CURRENT_TASK],dword 1 ; set OS task fisrt
 
 
; SET KEYBOARD PARAMETERS
mov al, 0xf6 ; reset keyboard, scan enabled
call kb_write
815,6 → 728,43
 
; Fly :)
 
 
include 'unpacker.inc'
 
align 4
boot_log:
pushad
 
mov eax,10*65536
mov ax,word [boot_y]
add [boot_y],dword 10
mov ebx,0x80ffffff ; ASCIIZ string with white color
mov ecx,esi
mov edi,1
call dtext
 
mov [novesachecksum],1000
call checkVga_N13
 
cmp [preboot_blogesc+OS_BASE+0x10000],byte 1
je .bll2
 
cmp esi,boot_tasking
jne .bll2
; begin ealex 04.08.05
; in al,0x61
; and al,01111111b
; out 0x61,al
; end ealex 04.08.05
.bll1: in al,0x60 ; wait for ESC key press
cmp al,129
jne .bll1
 
.bll2: popad
 
ret
 
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
; MAIN OS LOOP START ;
918,13 → 868,14
 
pushad
 
mov [irq_owner+4*0],byte 1 ; timer
mov [irq_owner+4*1],byte 1 ; keyboard
mov [irq_owner+4*5],byte 1 ; sound blaster
mov [irq_owner+4*6],byte 1 ; floppy diskette
mov [irq_owner+4*13],byte 1 ; math co-pros
mov [irq_owner+4*14],byte 1 ; ide I
mov [irq_owner+4*15],byte 1 ; ide II
mov [irq_owner+4*0], 1 ; timer
mov [irq_owner+4*1], 1 ; keyboard
mov [irq_owner+4*5], 1 ; sound blaster
mov [irq_owner+4*6], 1 ; floppy diskette
mov [irq_owner+4*13], 1 ; math co-pros
mov [irq_owner+4*14], 1 ; ide I
mov [irq_owner+4*15], 1 ; ide II
 
; movzx eax,byte [0xf604] ; mouse irq
; dec eax
; add eax,mouseirqtable
1017,10 → 968,10
; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y
 
push eax
mov ax,[0x2f0000+0x900c]
mov ax,[BOOT_VAR+0x900c]
shr ax,1
shl eax,16
mov ax,[0x2f0000+0x900A]
mov ax,[BOOT_VAR+0x900A]
shr ax,1
mov [MOUSE_X],eax
pop eax
1031,7 → 982,7
 
;!! IP 04.02.2005:
mov [next_usage_update], 100
mov byte [0xFFFF], 0 ; change task if possible
mov byte [DONT_SWITCH], 0 ; change task if possible
 
ret
 
1929,7 → 1880,7
ret
 
sysfn_shutdown: ; 18.1 = BOOT
mov [0x2f0000+0x9030],byte 0
mov [BOOT_VAR+0x9030],byte 0
for_shutdown_parameter:
 
mov eax,[TASK_COUNT]
2053,7 → 2004,7
jl exit_for_anyone
cmp ebx,4
jg exit_for_anyone
mov [0x2f0000+0x9030],bl
mov [BOOT_VAR+0x9030],bl
jmp for_shutdown_parameter
 
sysfn_minimize: ; 18.10 = minimize window
2798,7 → 2749,7
mov ecx,[edi*8+SLOT_BASE+APPDATA.wnd_caption]
or ecx,ecx
jz @f
add ecx,[edi+twdw+TASKDATA.mem_start]
add ecx,[edi+CURRENT_TASK+TASKDATA.mem_start]
 
movzx eax,[edi+window_data+WDATA.fl_wstyle]
and al,0x0F
4755,7 → 4706,7
div ecx
mov ebx,edx
xchg eax,ebx
call dword [0xe024]
call dword [GETPIXEL]
mov [esp+36],ecx
ret
 
4920,162 → 4871,8
mov [esp+36],dword -1
ret
 
include "data32.inc"
 
;clear_busy_flag_at_caller:
 
; push edi
 
; mov edi,[CURRENT_TASK] ; restore processes tss pointer in gdt, busyfl?
; imul edi,8
; mov [edi+gdts+ tss0 +5], word 01010000b *256 +11101001b
 
; pop edi
 
; ret
 
 
keymap:
 
db '6',27
db '1234567890-=',8,9
db 'qwertyuiop[]',13
db '~asdfghjkl;',39,96,0,'\zxcvbnm,./',0,'45 '
db '@234567890123',180,178,184,'6',176,'7'
db 179,'8',181,177,183,185,182
db 'AB<D',255,'FGHIJKLMNOPQRSTUVWXYZ'
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
 
 
keymap_shift:
 
db '6',27
db '!@#$%^&*()_+',8,9
db 'QWERTYUIOP{}',13
db '~ASDFGHJKL:"~',0,'|ZXCVBNM<>?',0,'45 '
db '@234567890123',180,178,184,'6',176,'7'
db 179,'8',181,177,183,185,182
db 'AB>D',255,'FGHIJKLMNOPQRSTUVWXYZ'
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
 
 
keymap_alt:
 
db ' ',27
db ' @ $ {[]}\ ',8,9
db ' ',13
db ' ',0,' ',0,'4',0,' '
db ' ',180,178,184,'6',176,'7'
db 179,'8',181,177,183,185,182
db 'ABCD',255,'FGHIJKLMNOPQRSTUVWXYZ'
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
 
 
; device irq owners
uglobal
irq_owner: ; process id
 
dd 0x0
dd 0x0
dd 0x0
dd 0x0
dd 0x0
dd 0x0
dd 0x0
dd 0x0
dd 0x0
dd 0x0
dd 0x0
dd 0x0
dd 0x0
dd 0x0
dd 0x0
dd 0x0
endg
 
 
; on irq read ports
uglobal
irq00read dd 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
irq01read dd 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
irq02read dd 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
irq03read dd 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
irq04read dd 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
irq05read dd 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
irq06read dd 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
irq07read dd 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
irq08read dd 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
irq09read dd 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
irq10read dd 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
irq11read dd 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
irq12read dd 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
irq13read dd 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
irq14read dd 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
irq15read dd 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
endg
 
; status
uglobal
hd1_status dd 0x0 ; 0 - free : other - pid
application_table_status dd 0x0 ; 0 - free : other - pid
endg
 
; device addresses
uglobal
mididp dd 0x0
midisp dd 0x0
 
cdbase dd 0x0
cdid dd 0x0
 
hdbase dd 0x0 ; for boot 0x1f0
hdid dd 0x0
hdpos dd 0x0 ; for boot 0x1
fat32part dd 0x0 ; for boot 0x1
 
;part2_ld dd 0x0
 
;* start code - Mario79
mouse_pause dd 0
MouseTickCounter dd 0
ps2_mouse_detected db 0
com1_mouse_detected db 0
com2_mouse_detected db 0
;* end code - Mario79
 
wraw_bacground_select db 0
lba_read_enabled dd 0x0 ; 0 = disabled , 1 = enabled
pci_access_enabled dd 0x0 ; 0 = disabled , 1 = enabled
 
sb16 dd 0x0
 
buttontype dd 0x0
windowtypechanged dd 0x0
 
align 4
cpu_caps dd 4 dup(0)
pg_data PG_DATA
heap_test dd ?
endg
 
iglobal
keyboard dd 0x1
sound_dma dd 0x1
syslang dd 0x1
endg
 
if __DEBUG__ eq 1
include_debug_strings
end if
 
IncludeIGlobals
endofcode:
IncludeUGlobals
uglobals_size = $ - endofcode
diff16 "end of kernel code",0,$
 
/kernel/branches/flat_kernel/kernel32.inc
238,8 → 238,6
 
; shutdown
 
include "boot/shutdown.inc" ; shutdown or restart
 
; file system
 
include "fs/fs.inc" ; syscall
/kernel/branches/flat_kernel/network/stack.inc
72,10 → 72,10
 
; 128KB allocated for the stack and network driver buffers and other
; data requirements
stack_data_start equ 0x700000
eth_data_start equ 0x700000
stack_data equ 0x704000
stack_data_end equ 0x71ffff
;stack_data_start equ 0x700000
;eth_data_start equ 0x700000
;stack_data equ 0x704000
;stack_data_end equ 0x71ffff
 
; 32 bit word
stack_config equ stack_data
123,7 → 123,7
 
 
 
resendQ equ 0x770000
;resendQ equ 0x770000
resendBuffer equ resendQ + ( 4 * NUMRESENDENTRIES ) ; for TCP
 
 
/kernel/branches/flat_kernel/sound/sb16.inc
18,7 → 18,7
DMAPage equ 0x2A
Rate equ 44100
SB16Buffer equ 0x2A0000
SB16_Status equ SB16Buffer+65536
;SB16_Status equ SB16Buffer+65536
 
iglobal
sound_data_format dd 0x1
/kernel/branches/flat_kernel/video/cursors.inc
444,6 → 444,7
 
stdcall load_driver, szHwMouse
mov [hw_cursor], eax
 
test eax, eax
jz .sw_mouse
 
/kernel/branches/flat_kernel/video/vesa20.inc
38,7 → 38,7
 
getpixel:
push eax ebx edx edi
call dword [0xe024]
call dword [GETPIXEL]
pop edi edx ebx eax
ret
 
/kernel/branches/flat_kernel/vmodeld.inc
13,11 → 13,11
; LOAD VIDEOMODE DRIVER
; If vmode.mdr file not found
or eax,-1 ; Driver ID = -1 (not present in system)
mov [0x760000],eax ;
mov [0x760100],byte 0xC3 ; Instruction RETN - driver loop
mov [OS_BASE+0x760000],eax ;
mov [OS_BASE+0x760100],byte 0xC3 ; Instruction RETN - driver loop
 
mov esi, vmode
xor ebx, ebx
mov ecx, 0x8000 ; size of memory area for driver
mov edx, 0x760000 ; Memory position of driver
call fs_RamdiskRead
mov edx, OS_BASE+0x760000 ; Memory position of driver
call fs_RamdiskRead