merge flat kernel

git-svn-id: svn://kolibrios.org@465 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2007-04-18 06:37:14 +00:00
parent 4c272bed81
commit fef69aab20
59 changed files with 4558 additions and 3025 deletions

View File

@ -12,10 +12,10 @@ $Revision$
; Àâòîð èñõîäíîãî òåêñòà Êóëàêîâ Âëàäèìèð Ãåííàäüåâè÷.
; Àäàïòàöèÿ è äîðàáîòêà Mario79
give_back_application_data: ; ïåğåñëàòü ïğèëîæåíèş
mov edi,[TASK_BASE]
mov edi,[edi+TASKDATA.mem_start]
add edi,ecx
;give_back_application_data: ; ïåğåñëàòü ïğèëîæåíèş
; mov edi,[TASK_BASE]
; mov edi,[edi+TASKDATA.mem_start]
; add edi,ecx
give_back_application_data_1:
mov esi,FDD_BUFF ;FDD_DataBuffer ;0x40000
xor ecx,ecx
@ -24,10 +24,10 @@ give_back_application_data_1:
rep movsd
ret
take_data_from_application: ; âçÿòü èç ïğèëîæåíè
mov esi,[TASK_BASE]
mov esi,[esi+TASKDATA.mem_start]
add esi,ecx
;take_data_from_application: ; âçÿòü èç ïğèëîæåíè
; mov esi,[TASK_BASE]
; mov esi,[esi+TASKDATA.mem_start]
; add esi,ecx
take_data_from_application_1:
mov edi,FDD_BUFF ;FDD_DataBuffer ;0x40000
xor ecx,ecx

View File

@ -400,7 +400,7 @@ clear_hd_cache:
save_hd_wait_timeout:
push eax
mov eax,[timer_ticks];[0xfdf0]
mov eax,[timer_ticks]
add eax,300 ; 3 sec timeout
mov [hd_wait_timeout],eax
pop eax
@ -411,7 +411,7 @@ check_hd_wait_timeout:
push eax
mov eax,[hd_wait_timeout]
cmp [timer_ticks], eax ;[0xfdf0],eax
cmp [timer_ticks], eax
jg hd_timeout_error
pop eax
mov [hd_error],0
@ -430,8 +430,8 @@ hd_timeout_error:
; call clear_application_table_status
; mov esi,hd_timeout_str
; call sys_msg_board_str
DEBUGF 1,"K : FS - HD timeout\n"
; jmp $
DEBUGF 1,"K : FS - HD timeout\n"
mov [hd_error],1
pop eax
ret
@ -442,7 +442,7 @@ hd_read_error:
; call clear_application_table_status
; mov esi,hd_read_str
; call sys_msg_board_str
DEBUGF 1,"K : FS - HD read error\n"
DEBUGF 1,"K : FS - HD read error\n"
pop edx eax
ret
@ -450,17 +450,17 @@ hd_write_error:
; call clear_hd_cache
; call clear_application_table_status
; mov esi,hd_write_str
; call sys_msg_board_str
DEBUGF 1,"K : FS - HD write error\n"
ret
; mov esi,hd_write_str
; call sys_msg_board_str
DEBUGF 1,"K : FS - HD write error\n"
ret
hd_write_error_dma:
; call clear_hd_cache
; call clear_application_table_status
; mov esi, hd_write_str
; call sys_msg_board_str
DEBUGF 1,"K : FS - HD read error\n"
DEBUGF 1,"K : FS - HD read error\n"
pop esi
ret
@ -469,8 +469,8 @@ hd_lba_error:
; call clear_application_table_status
; mov esi,hd_lba_str
; call sys_msg_board_str
DEBUGF 1,"K : FS - HD LBA error\n"
jmp LBA_read_ret
DEBUGF 1,"K : FS - HD LBA error\n"
jmp LBA_read_ret
align 4
@ -582,9 +582,9 @@ iglobal
align 4
; note that IDE descriptor table must be 4-byte aligned and do not cross 4K boundary
IDE_descriptor_table:
dd OS_BASE+284000h
dw 2000h
dw 8000h
dd 0x284000
dw 0x2000
dw 0x8000
dma_cur_sector dd not 40h
irq14_func dd hdd_irq_null
@ -613,20 +613,20 @@ hdd_irq14:
mov dx, [IDEContrRegsBaseAddr]
mov al, 0
out dx, al
call update_counters
mov ebx, [dma_process]
cmp [CURRENT_TASK], ebx
jz .noswitch
mov [dma_task_switched], 1
mov edi, [dma_slot_ptr]
mov eax, [CURRENT_TASK]
mov [dma_process], eax
mov eax, [TASK_BASE]
mov [dma_slot_ptr], eax
mov [CURRENT_TASK], ebx
mov [TASK_BASE], edi
mov byte [0xFFFF], 1
call do_change_task
; call update_counters
; mov ebx, [dma_process]
; cmp [CURRENT_TASK], ebx
; jz .noswitch
; mov [dma_task_switched], 1
; mov edi, [dma_slot_ptr]
; mov eax, [CURRENT_TASK]
; mov [dma_process], eax
; mov eax, [TASK_BASE]
; mov [dma_slot_ptr], eax
; mov [CURRENT_TASK], ebx
; mov [TASK_BASE], edi
; mov byte [DONT_SWITCH], 1
; call do_change_task
.noswitch:
popad
popfd
@ -644,20 +644,20 @@ hdd_irq15:
add dx, 8
mov al, 0
out dx, al
call update_counters
mov ebx, [dma_process]
cmp [CURRENT_TASK], ebx
jz .noswitch
mov [dma_task_switched], 1
mov edi, [dma_slot_ptr]
mov eax, [CURRENT_TASK]
mov [dma_process], eax
mov eax, [TASK_BASE]
mov [dma_slot_ptr], eax
mov [CURRENT_TASK], ebx
mov [TASK_BASE], edi
mov byte [0xFFFF], 1
call do_change_task
; call update_counters
; mov ebx, [dma_process]
; cmp [CURRENT_TASK], ebx
; jz .noswitch
; mov [dma_task_switched], 1
; mov edi, [dma_slot_ptr]
; mov eax, [CURRENT_TASK]
; mov [dma_process], eax
; mov eax, [TASK_BASE]
; mov [dma_slot_ptr], eax
; mov [CURRENT_TASK], ebx
; mov [TASK_BASE], edi
; mov byte [DONT_SWITCH], 1
; call do_change_task
.noswitch:
popad
popfd
@ -689,9 +689,10 @@ hd_read_dma:
pop eax
ret
.notread:
mov eax, IDE_descriptor_table-OS_BASE
mov dword [eax+OS_BASE], 0x284000
mov word [eax+4+OS_BASE], 0x2000
mov eax, IDE_descriptor_table
mov dword [eax], 0x284000
mov word [eax+4], 0x2000
sub eax, OS_BASE
mov dx, [IDEContrRegsBaseAddr]
cmp [hdbase], 0x1F0
jz @f
@ -774,7 +775,7 @@ write_cache_chain:
mov eax, IDE_descriptor_table
mov edx, [cache_chain_pos]
shl edx, 9
add edx, OS_BASE+0x610000
add edx, 0x610000
mov [eax], edx
movzx edx, [cache_chain_size]
shl edx, 9
@ -785,10 +786,11 @@ write_cache_sector:
mov eax, IDE_descriptor_table
mov edx, edi
shl edx, 9
add edx, OS_BASE+0x610000
add edx, 0x610000
mov [eax], edx
mov word [eax+4], 0x200
do_write_dma:
sub eax, OS_BASE
mov dx, [IDEContrRegsBaseAddr]
cmp [hdbase], 0x1F0
jz @f

View File

@ -1,13 +1,13 @@
$Revision$
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; RAMDISK functions ;;
;; (C) 2004 Ville Turjanmaa, License: GPL ;;
;; Addings by M.Lisovin ;;
;; LFN support by diamond ;;
;; RAMDISK functions ;;
;; (C) 2004 Ville Turjanmaa, License: GPL ;;
;; Addings by M.Lisovin ;;
;; LFN support by diamond ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; calculate fat chain
@ -1802,7 +1802,12 @@ fs_RamdiskRewrite:
jnz .disk_full2
dec edi
dec edi
lea eax, [edi-(RAMDISK_FAT)]
; lea eax, [edi-(RAMDISK_FAT)]
mov eax, edi
sub eax, RAMDISK_FAT
shr eax, 1 ; eax = cluster
mov word [edi], 0xFFF ; mark as last cluster
xchg edi, [esp]
@ -2294,7 +2299,7 @@ fs_RamdiskExecute:
mov ebx, [ebx+4]
test ebx, ebx
jz @f
add ebx, std_application_base_address
; add ebx, std_application_base_address
@@:
;----------------------------------------------------------------

View File

@ -20,119 +20,6 @@ $Revision$
;
;==========================================================================
; 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
@ -160,72 +47,6 @@ printplain:
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
@ -258,17 +79,6 @@ macro _setcursor row,column
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
@ -281,7 +91,7 @@ boot_read_floppy:
inc si
cmp si, 10
jb @b
mov si, badsect-0x10000
mov si, badsect
sayerr_plain:
call printplain
jmp $
@ -301,15 +111,11 @@ start_of_code:
; \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]
mov word [cs:bx_from_load - 0x10000], bx ; {SPraid}[13.03.2007]
; set up stack
mov ax, 3000h
mov ss, ax
@ -326,14 +132,14 @@ start_of_code:
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
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
@ -341,7 +147,7 @@ if lang eq ru
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
@ -353,23 +159,17 @@ end if
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
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
@ -383,14 +183,14 @@ dfl1:
pop cx
loop dfl1
; draw bottom
mov si, d80x25_bottom - 0x10000
mov si, d80x25_bottom
mov cx, d80x25_bottom_num * 80
@@:
lodsb
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
@ -410,58 +210,19 @@ dfl1:
and dx,bx
cmp ax,dx
jnz cpugood
mov si,not386-0x10000
mov si,not386
sayerr:
call print
jmp $
cpugood:
push 0
popf
sti
; 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
@ -531,7 +292,7 @@ wait_loop: ; variant 2
; 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
@ -544,26 +305,17 @@ wait_loop: ; variant 2
mov ax, 0x5303 ; Connect 32 bit mode interface
xor bx, bx
int 0x15
; 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
push 0
pop es
mov [es:0x9040], ebx
mov [es:0x9050], ax
mov [es:0x9052], cx
mov [es:0x9054], dx
apm_end:
_setcursor d80x25_top_num, 0
; -----------------------------------------
; DISPLAY VESA INFORMATION
@ -573,14 +325,14 @@ apm_end:
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
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
@ -593,13 +345,13 @@ cfgmanager:
; 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
@ -610,11 +362,11 @@ cfgmanager:
@@:
.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'
@ -637,66 +389,66 @@ cfgmanager:
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:
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
@ -705,8 +457,8 @@ cfgmanager:
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
@ -716,11 +468,11 @@ cfgmanager:
; 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
@ -736,15 +488,15 @@ cfgmanager:
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
@ -754,46 +506,46 @@ cfgmanager:
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
@ -803,9 +555,7 @@ virtual at novesa
.bSettingsChanged db ?
.timer dd ?
end virtual
org $+0x10000
.loader_block dd -1
org $-0x10000
.gettime:
mov ah, 0
int 1Ah
@ -818,10 +568,10 @@ end virtual
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
@ -838,12 +588,12 @@ if lang eq ru
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
@ -851,11 +601,11 @@ else
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
@ -865,31 +615,31 @@ end if
.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
test eax, eax
jz .load
push eax
mov si, save_quest-0x10000
mov si, save_quest
call print
.waityn:
mov ah, 0
@ -900,7 +650,7 @@ end if
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
@ -911,7 +661,7 @@ end if
.cont:
push cs
pop ds
mov si, space_msg-0x10000
mov si, space_msg
mov byte [si+80], 0
_setcursor 15,0
call printplain
@ -921,12 +671,12 @@ end if
; 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]
@ -945,14 +695,14 @@ end if
; 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
newprobe:
inc bx
cmp bx,0x17f
mov si,prnotfnd-0x10000
mov si,prnotfnd
jz sayerr
probemore:
@ -999,12 +749,12 @@ end if
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
@ -1033,26 +783,26 @@ end if
; 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
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
@ -1065,7 +815,7 @@ end if
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
@ -1079,7 +829,7 @@ sayerr_floppy:
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
@ -1168,7 +918,7 @@ sayerr_floppy:
aam
xchg al, ah
add ax, '00'
mov si, pros-0x10000
mov si, pros
cmp [si], ax
jz @f
mov [si], ax
@ -1246,9 +996,10 @@ sayerr_floppy:
; 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
@ -1274,7 +1025,7 @@ sayerr_floppy:
setgr:
int 0x10
test ah,ah
mov si, fatalsel-0x10000
mov si, fatalsel
jnz sayerr
; set mode 0x12 graphics registers:
cmp bx,0x12
@ -1302,4 +1053,3 @@ setgr:
gmok2:
push ds
pop es

View File

@ -73,7 +73,7 @@ mode1 db "640x480",0
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 " with LFB",0
modevesa12 db ", VESA 1.2 Bnk",0
mode9 db "320x200, EGA/CGA 256 colors",0
@ -85,7 +85,7 @@ on_msg db " on",13,10,0
off_msg db " off",13,10,0
vrrm_msg db " [c] Use VRR:",0
preboot_device_msg db " [d] Floppy image: ",0
preboot_device_msgs dw 0,pdm1-0x10000,pdm2-0x10000,pdm3-0x10000
preboot_device_msgs dw 0,pdm1,pdm2,pdm3
pdm1 db "real floppy",13,10,0
pdm2 db "C:\kolibri.img (FAT32)",13,10,0
pdm3 db "use already loaded image",13,10,0

View File

@ -73,7 +73,7 @@ mode1 db "640x480",0
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 " koos LFB",0
modevesa12 db ", VESA 1.2 Bnk",0
mode9 db "320x200, EGA/CGA 256 värvi",0
@ -85,7 +85,7 @@ on_msg db " sees",13,10,0
off_msg db " väljas",13,10,0
vrrm_msg db " [c] Kasuta VRR:",0
preboot_device_msg db " [d] Disketi kujutis: ",0
preboot_device_msgs dw 0,pdm1-0x10000,pdm2-0x10000,pdm3-0x10000
preboot_device_msgs dw 0,pdm1,pdm2,pdm3
pdm1 db "reaalne diskett",13,10,0
pdm2 db "C:\kolibri.img (FAT32)",13,10,0
pdm3 db "kasuta juba laaditud kujutist",13,10,0

View File

@ -78,7 +78,7 @@ mode1 db "640x480",0
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 " mit LFB",0
modevesa12 db ", VESA 1.2 Bnk",0
mode9 db "320x200, EGA/CGA 256 colors",0
@ -90,7 +90,7 @@ on_msg db " an",13,10,0
off_msg db " aus",13,10,0
vrrm_msg db " [c] Nutze VRR:",0
preboot_device_msg db " [d] Diskettenimage: ",0
preboot_device_msgs dw 0,pdm1-0x10000,pdm2-0x10000,pdm3-0x10000
preboot_device_msgs dw 0,pdm1,pdm2,pdm3
pdm1 db "Echte Diskette",13,10,0
pdm2 db "C:\kolibri.img (FAT32)",13,10,0
pdm3 db "Nutze bereits geladenes Image",13,10,0

View File

@ -17,7 +17,6 @@ novesa db "
vervesa db "‚¥àá¨ï VESA: Vesa x.x",13,10,0
vervesa_off=19
msg_apm db " APM x.x ", 0
gr_mode db 186," Vesa 2.0+ 16 M LFB: [1] 640x480, [2] 800x600, "
db "[3] 1024x768, [4] 1280x1024",13,10
db 186," Vesa 1.2 16 M Bnk: [5] 640x480, [6] 800x600, "
@ -74,7 +73,7 @@ mode1 db "640x480",0
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
@ -86,7 +85,7 @@ on_msg db "
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

View File

@ -24,7 +24,7 @@ preboot_device db 0 ; boot device
;!!!! 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

View File

@ -8,7 +8,7 @@ $Revision$
; READ RAMDISK IMAGE FROM HD
cmp [boot_dev],1
cmp [boot_dev+OS_BASE+0x10000],1
jne no_sys_on_hd
test [DRIVE_DATA+1],byte 0x40
@ -88,7 +88,7 @@ $Revision$
ret
read_image:
mov eax, hdsysimage
mov eax, hdsysimage+OS_BASE+0x10000
mov ebx, 1474560/512
mov ecx, RAMDISK
mov esi, 0

View File

@ -90,4 +90,4 @@ RU_FNT2:
db 0x00, 0x00, 0xCF, 0xCD, 0xEF, 0xEC, 0xFF, 0xDC, 0xDC, 0xCC, 0xCC, 0xCC, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0xC6, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0xC6, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00

View File

@ -12,370 +12,249 @@ $Revision$
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
system_shutdown: ; shut down the system
call stop_all_services
push 3 ; stop playing cd
pop eax
call sys_cd_audio
cld
mov al,[0x2f0000+0x9030]
cmp al,1
jl no_shutdown_parameter
cmp al,4
jle yes_shutdown_param
no_shutdown_parameter:
; movzx ecx,word [0x2f0000+0x900A]
; movzx esi,word [0x2f0000+0x900C]
; imul ecx,esi ;[0xfe04]
;; mov ecx,0x500000/4 ;3fff00/4 ; darken screen
; push ecx
; mov esi,[0xfe80]
; cmp esi,32*0x100000
; jbe no_darken_screen
; mov edi,16*0x100000
; push esi edi
; sdnewpix:
; lodsd
; shr eax,1
; and eax,0x7f7f7f7f
; stosd
; loop sdnewpix
; pop ecx
; pop esi edi
; rep movsd
; no_darken_screen:
; read shutdown code:
; 1) display shutdown "window"
mov eax,[0xfe00]
shr eax,1
lea esi,[eax+220] ; x end
sub eax,220 ; x start
mov ebx,[ScreenHeight]
shr ebx,1
mov [shutdownpos],ebx
lea ebp,[ebx+105] ; y end
sub ebx,120 ; y start
xor edi,edi
inc edi ; force putpixel & dtext
mov ecx,0x0000ff
; vertical loop begin
sdnewpix1:
push eax ; save x start
; horizontal loop begin
sdnewpix2:
call [putpixel]
inc eax
cmp eax,esi
jnz sdnewpix2
; horizontal loop end
dec ecx ; color
pop eax ; restore x start
inc ebx ; advance y pos
cmp ebx,ebp
jnz sdnewpix1
; vertical loop end
; 2) display text strings
; a) version
mov eax,[0xfe00]
shr eax,1
shl eax,16
mov ax,word [shutdownpos]
push eax
sub eax,(220-27)*10000h + 105
mov ebx,0xffff00
mov ecx,version
push 34
pop edx
call dtext
; b) variants
add eax,105+33
push 6
pop esi
; mov ebx,0xffffff
mov bl,0xFF
mov ecx,shutdowntext
mov dl,40
newsdt:
call dtext
add eax,10
add ecx,edx
dec esi
jnz newsdt
; 3) load & display rose.txt
mov eax,rosef-std_application_base_address ; load rose.txt
xor ebx,ebx
push 2
pop ecx
mov edx,0x90000
push edx
push 12
pop esi
push edi ; may be destroyed
pushad
push eax
call file_system_lfn ; by SPraid fileread
pop eax
popad
pop edi
pop ecx
inc ecx ; do not display stars from rose.txt
pop eax
add eax,20*10000h - 110
mov ebx,0x00ff00
push 27
pop edx
nrl:
call dtext
; sub ebx,0x050000
ror ebx, 16
sub bl, 0x05
ror ebx, 16
add eax,8
add ecx,31
cmp cx,word 0x0001+25*31
jnz nrl
call checkVga_N13
yes_shutdown_param:
cli
mov eax,kernel ; load kernel.mnt to 0x8000:0
push 12
pop esi
xor ebx,ebx
or ecx,-1
mov edx,0x80000
call fileread
mov esi,restart_kernel_4000+0x10000 ; move kernel re-starter to 0x4000:0
mov edi,0x40000
mov ecx,1000
rep movsb
mov eax,0x2F0000 ; restore 0x0 - 0xffff
xor ebx,ebx
mov ecx,0x10000
call memmove
call restorefatchain
mov al, 0xFF
out 0x21, al
out 0xA1, al
mov word [0x467+0],pr_mode_exit-0x10000
mov word [0x467+2],0x1000
mov al,0x0F
out 0x70,al
mov al,0x05
out 0x71,al
mov al,0xFE
out 0x64,al
hlt
use16
align 4
pr_mode_exit:
org $-0x10000
; setup stack
mov ax, 3000h
mov ss, ax
mov esp, 0EC00h
mov ax, 0x3000
mov ss, ax
mov esp, 0x0EC00
; setup ds
push cs
pop ds
push cs
pop ds
lidt [old_ints_h-0x10000]
lidt [old_ints_h]
;remap IRQs
mov al,0x11
out 0x20,al
call rdelay
out 0xA0,al
call rdelay
mov al,0x11
out 0x20,al
call rdelay
out 0xA0,al
call rdelay
mov al,0x08
out 0x21,al
call rdelay
mov al,0x70
out 0xA1,al
call rdelay
mov al,0x08
out 0x21,al
call rdelay
mov al,0x70
out 0xA1,al
call rdelay
mov al,0x04
out 0x21,al
call rdelay
mov al,0x02
out 0xA1,al
call rdelay
mov al,0x04
out 0x21,al
call rdelay
mov al,0x02
out 0xA1,al
call rdelay
mov al,0x01
out 0x21,al
call rdelay
out 0xA1,al
call rdelay
mov al,0x01
out 0x21,al
call rdelay
out 0xA1,al
call rdelay
mov al,0xB8
out 0x21,al
call rdelay
mov al,0xBD
out 0xA1,al
sti
mov al,0xB8
out 0x21,al
call rdelay
mov al,0xBD
out 0xA1,al
sti
temp_3456:
xor ax,ax
mov es,ax
mov al,byte [es:0x9030]
cmp al,1
jl nbw
cmp al,4
jle nbw32
temp_3456:
xor ax,ax
mov es,ax
mov al,byte [es:0x9030]
cmp al,1
jl nbw
cmp al,4
jle nbw32
nbw:
in al,0x60
call pause_key
cmp al,6
jae nbw
mov bl,al
nbw2:
in al,0x60
call pause_key
cmp al,bl
je nbw2
cmp al,240 ;ax,240
jne nbw31
mov al,bl
dec ax
jmp nbw32
nbw31:
add bl,128
cmp al,bl
jne nbw
sub al,129
nbw:
in al,0x60
call pause_key
cmp al,6
jae nbw
mov bl,al
nbw2:
in al,0x60
call pause_key
cmp al,bl
je nbw2
cmp al,240 ;ax,240
jne nbw31
mov al,bl
dec ax
jmp nbw32
nbw31:
add bl,128
cmp al,bl
jne nbw
sub al,129
nbw32:
nbw32:
dec ax ; 1 = write floppy
js nbw
jnz no_floppy_write
call floppy_write
jmp temp_3456 ;nbw
no_floppy_write:
dec ax ; 1 = write floppy
js nbw
jnz no_floppy_write
call floppy_write
jmp temp_3456 ;nbw
no_floppy_write:
dec ax ; 2 = power off
jnz no_apm_off
call APM_PowerOff
jmp $
no_apm_off:
dec ax ; 2 = power off
jnz no_apm_off
call APM_PowerOff
jmp $
no_apm_off:
dec ax ; 3 = reboot
jnz restart_kernel ; 4 = restart kernel
push 0x40
pop ds
mov word[0x0072],0x1234
jmp 0xF000:0xFFF0
dec ax ; 3 = reboot
jnz restart_kernel ; 4 = restart kernel
push 0x40
pop ds
mov word[0x0072],0x1234
jmp 0xF000:0xFFF0
pause_key:
mov cx,100
pause_key_1:
loop pause_key_1
ret
pause_key:
mov cx,100
pause_key_1:
loop pause_key_1
ret
rdelay:
ret
ret
iglobal
kernel db 'KERNEL MNT'
; shutdown_parameter db 0
endg
floppy_write: ; write diskette image to physical floppy
cmp [flm],byte 1
je fwwritedone
mov [flm],byte 1
xor ax, ax ; reset drive
xor dx, dx
int 0x13
mov cx,0x0001 ; startcyl,startsector
xor dx, dx ; starthead,drive
mov ax, 80*2 ; read no of sect
fwwrites:
push ax
; move 1mb+ -> 0:a000
pusha
mov si, fwmovedesc
mov cx,256*18
mov ah,0x87
push ds
pop es
int 0x15
add dword [fwmovedesc+0x12], 512*18
popa
xor si,si
mov es,si
fwnewwrite:
mov bx,0xa000 ; es:bx -> data area
mov ax,0x0300+18 ; read, no of sectors to read
int 0x13
test ah, ah
jz fwgoodwrite
inc si
cmp si,10
jnz fwnewwrite
; can't access diskette - return
pop ax
ret
fwgoodwrite:
inc dh
cmp dh,2
jnz fwbb2
mov dh,0
inc ch
fwbb2:
pop ax
dec ax
jnz fwwrites
ret
APM_PowerOff:
mov ax, 5304h
xor bx, bx
int 15h
;!!!!!!!!!!!!!!!!!!!!!!!!
mov ax,0x5300
xor bx,bx
int 0x15
push ax
mov ax,0x5301
xor bx,bx
int 0x15
mov ax,0x5308
mov bx,1
mov cx,bx
int 0x15
mov ax,0x530E
xor bx,bx
pop cx
int 0x15
mov ax,0x530D
mov bx,1
mov cx,bx
int 0x15
mov ax,0x530F
mov bx,1
mov cx,bx
int 0x15
mov ax,0x5307
mov bx,1
mov cx,3
int 0x15
;!!!!!!!!!!!!!!!!!!!!!!!!
fwwritedone:
ret
restart_kernel:
mov ax,0x0003 ; set text mode for screen
int 0x10
jmp 0x4000:0000
restart_kernel_4000:
cli
; mov di,0x1000 ; load kernel image from 0x8000:0 -> 0x1000:0
;
; new_kernel_block_move:
;
; mov ebx,0
;
; new_kernel_byte_move:
;
; mov ax,di
; add ax,0x7000
; mov es,ax
; mov dl,[es:bx]
; mov es,di
; mov [es:bx],dl
;
; inc ebx
; cmp ebx,65536
; jbe new_kernel_byte_move
;
; add di,0x1000
; cmp di,0x2000
; jbe new_kernel_block_move
push ds
pop es
mov cx, 0x8000
push cx
mov ds, cx
xor si, si
xor di, di
rep movsw
push 0x9000
pop ds
push 0x2000
pop es
pop cx
rep movsw
push ds
pop es
mov cx, 0x8000
push cx
mov ds, cx
xor si, si
xor di, di
rep movsw
push 0x9000
pop ds
push 0x2000
pop es
pop cx
rep movsw
wbinvd ; write and invalidate cache
; mov ax,0x1000
; mov es,ax
; mov ax,0x3000
; mov ss,ax
; mov sp,0xec00
; restore timer
mov al, 00110100b
out 43h, al
jcxz $+2
mov al, 0xFF
out 40h, al
jcxz $+2
out 40h, al
jcxz $+2
mov al, 00110100b
out 43h, al
jcxz $+2
mov al, 0xFF
out 40h, al
jcxz $+2
out 40h, al
jcxz $+2
sti
; (hint by Black_mirror)
@ -386,160 +265,10 @@ restart_kernel_4000:
in al, 0x60
; bootloader interface
push 0x1000
pop ds
mov si, kernel_restart_bootblock-0x10000
mov ax, 'KL'
push 0x1000
pop ds
mov si, kernel_restart_bootblock
mov ax, 'KL'
jmp 0x1000:0000
APM_PowerOff:
mov ax, 5304h
xor bx, bx
int 15h
;!!!!!!!!!!!!!!!!!!!!!!!!
mov ax,0x5300
xor bx,bx
int 0x15
push ax
mov ax,0x5301
xor bx,bx
int 0x15
mov ax,0x5308
mov bx,1
mov cx,bx
int 0x15
mov ax,0x530E
xor bx,bx
pop cx
int 0x15
mov ax,0x530D
mov bx,1
mov cx,bx
int 0x15
mov ax,0x530F
mov bx,1
mov cx,bx
int 0x15
mov ax,0x5307
mov bx,1
mov cx,3
int 0x15
;!!!!!!!!!!!!!!!!!!!!!!!!
fwwritedone:
ret
org $+0x10000
flm db 0
org $-0x10000
floppy_write: ; write diskette image to physical floppy
cmp [flm-0x10000],byte 1
je fwwritedone
mov [flm-0x10000],byte 1
xor ax, ax ; reset drive
xor dx, dx
int 0x13
mov cx,0x0001 ; startcyl,startsector
; mov dx,0x0000 ; starthead,drive
xor dx, dx
mov ax, 80*2 ; read no of sect
fwwrites:
push ax
; move 1mb+ -> 0:a000
pusha
mov si,fwmovedesc -0x10000
mov cx,256*18
mov ah,0x87
push ds
pop es
int 0x15
add dword [fwmovedesc-0x10000+0x12], 512*18
popa
xor si,si
mov es,si
fwnewwrite:
mov bx,0xa000 ; es:bx -> data area
mov ax,0x0300+18 ; read, no of sectors to read
int 0x13
test ah, ah
jz fwgoodwrite
inc si
cmp si,10
jnz fwnewwrite
; can't access diskette - return
pop ax
ret
fwgoodwrite:
inc dh
cmp dh,2
jnz fwbb2
mov dh,0
inc ch
fwbb2:
pop ax
dec ax
jnz fwwrites
ret
org $+0x10000
fwmovedesc:
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0xff,0xff,0x0,0x00,0x10,0x93,0x0,0x0
db 0xff,0xff,0x0,0xa0,0x00,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
use32
org $+0x10000
uglobal
shutdownpos dd 0x0
endg
iglobal
if lang eq en
shutdowntext:
db "IT'S SAFE TO POWER OFF COMPUTER OR "
db ' '
db '1) SAVE RAMDISK TO FLOPPY '
db '2) APM - POWEROFF '
db '3) REBOOT '
db '4) RESTART KERNEL '
else if lang eq ru
shutdowntext:
db "<EFBFBD>¥§®¯ á­®¥ ¢ëª«î祭¨¥ ª®¬¯ìîâ¥à  ¨«¨ "
db ' '
db '1) ‘®åà ­¨âì à ¬¤¨áª ­  ¤¨áª¥âã '
db '2) APM - ¢ëª«î祭¨¥ ¯¨â ­¨ï '
db '3) <20>¥à¥§ £à㧪  á¨á⥬ë '
db '4) <20>¥áâ àâ ï¤à  ¨§ Ž‡“ '
else
shutdowntext:
db "SIE KOENNEN DEN COMPUTER NUN AUSSCHALTEN"
db ' '
db '1) RAMDISK AUF DISK SPEICHERN '
db '2) APM - AUSSCHALTEN '
db '3) NEUSTARTEN '
db '4) KERNEL NEU STARTEN '
end if
rosef:
dd 0,0,0,1024,0x90000-std_application_base_address
db '/rd/1/ROSE.TXT',0
endg

View File

@ -1,19 +1,19 @@
$Revision$
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; PCI16.INC ;;
;; ;;
;; 16 bit PCI driver code ;;
;; ;;
;; Version 0.2 December 21st, 2002 ;;
;; ;;
;; Author: Victor Prodan, victorprodan@yahoo.com ;;
;; ;;
;; See file COPYING for details ;;
;; ;;
;; PCI16.INC ;;
;; ;;
;; 16 bit PCI driver code ;;
;; ;;
;; Version 0.2 December 21st, 2002 ;;
;; ;;
;; Author: Victor Prodan, victorprodan@yahoo.com ;;
;; ;;
;; See file COPYING for details ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View File

@ -1,23 +1,23 @@
$Revision$
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; ;;
;; PCI32.INC ;;
;; ;;
;; 32 bit PCI driver code ;;
;; ;;
;; Version 0.2 December 21st, 2002 ;;
;; ;;
;; Author: Victor Prodan, victorprodan@yahoo.com ;;
;; Credits: ;;
;; Ralf Brown ;;
;; Mike Hibbett, mikeh@oceanfree.net ;;
;; ;;
;; See file COPYING for details ;;
;; ;;
;; PCI32.INC ;;
;; ;;
;; 32 bit PCI driver code ;;
;; ;;
;; Version 0.2 December 21st, 2002 ;;
;; ;;
;; Author: Victor Prodan, victorprodan@yahoo.com ;;
;; Credits: ;;
;; Ralf Brown ;;
;; Mike Hibbett, mikeh@oceanfree.net ;;
;; ;;
;; See file COPYING for details ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -39,7 +39,7 @@ pci_api:
or al,al
jnz pci_fn_1
; PCI function 0: get pci version (AH.AL)
movzx eax,word [0x2F0000+0x9022]
movzx eax,word [BOOT_VAR+0x9022]
ret
pci_fn_1:
@ -47,14 +47,14 @@ pci_fn_1:
jnz pci_fn_2
; PCI function 1: get last bus in AL
mov al,[0x2F0000+0x9021]
mov al,[BOOT_VAR+0x9021]
ret
pci_fn_2:
cmp al,2
jne pci_fn_3
; PCI function 2: get pci access mechanism
mov al,[0x2F0000+0x9020]
mov al,[BOOT_VAR+0x9020]
ret
pci_fn_3:
@ -113,7 +113,7 @@ pci_make_config_cmd:
align 4
pci_read_reg:
cmp byte [0x2F0000+0x9020],2 ;what mechanism will we use?
cmp byte [BOOT_VAR+0x9020],2 ;what mechanism will we use?
je pci_read_reg_2
; mechanism 1
@ -243,7 +243,7 @@ pci_read_reg_err:
align 4
pci_write_reg:
cmp byte [0x2F0000+0x9020],2 ;what mechanism will we use?
cmp byte [BOOT_VAR+0x9020],2 ;what mechanism will we use?
je pci_write_reg_2
; mechanism 1

View File

@ -12,7 +12,7 @@ cpl0 equ 10011010b ; code read dpl0
cpl3 equ 11111010b ; code read dpl3
D32 equ 01000000b ; 32bit segment
G32 equ 10000000b ; page gran
G32 equ 10000000b ; page gran
;;;;;;;;;;;;cpu_caps flags;;;;;;;;;;;;;;;;
@ -140,13 +140,53 @@ SSE_FZ equ 0x8000
SSE_INIT equ (SSE_IM+SSE_DM+SSE_ZM+SSE_OM+SSE_UM+SSE_PM)
OS_BASE equ 0
window_data equ (OS_BASE+0x0000000)
struc TSS
{
._back rw 2
._esp0 rd 1
._ss0 rw 2
._esp1 rd 1
._ss1 rw 2
._esp2 rd 1
._ss2 rw 2
._cr3 rd 1
._eip rd 1
._eflags rd 1
._eax rd 1
._ecx rd 1
._edx rd 1
._ebx rd 1
._esp rd 1
._ebp rd 1
._esi rd 1
._edi rd 1
._es rw 2
._cs rw 2
._ss rw 2
._ds rw 2
._fs rw 2
._gs rw 2
._ldt rw 2
._trap rw 1
._io rw 1
rb 24
._io_map_0 rb 4096
._io_map_1 rb 4096
}
virtual at 0
TSS TSS
end virtual
TSS_SIZE equ (128+8192)
OS_BASE equ 0x80000000
window_data equ OS_BASE
CURRENT_TASK equ (OS_BASE+0x0003000)
TASK_COUNT equ (OS_BASE+0x0003004)
CURRENT_RING0_ESP equ (OS_BASE+0x0003008)
TASK_BASE equ (OS_BASE+0x0003010)
TASK_DATA equ (OS_BASE+0x0003020)
TASK_EVENT equ (OS_BASE+0x0003020)
@ -203,7 +243,6 @@ MOUSE_BUFF_COUNT equ (OS_BASE+0x000FCFF)
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)
@ -247,7 +286,6 @@ IMG_BACKGROUND equ (OS_BASE+0x0300000)
WinMapAddress equ (OS_BASE+0x0460000)
display_data equ (OS_BASE+0x0460000)
;unused ?
HD_CACHE equ (OS_BASE+0x0600000)
stack_data_start equ (OS_BASE+0x0700000)
@ -259,32 +297,68 @@ resendQ equ (OS_BASE+0x0770000)
skin_data equ (OS_BASE+0x0778000)
draw_data equ (OS_BASE+0x0780000);
tss_data equ (OS_BASE+0x780000)
draw_data equ (OS_BASE+0x988000)
virtual at (OS_BASE+0x0783F80)
tss TSS
end virtual
HEAP_BASE equ (OS_BASE+0x98B000)
tmp_page_tab equ 0x0786000;
LFB_BASE equ 0x7DC00000
HEAP_BASE equ (OS_BASE+tmp_page_tab)
HEAP_MIN_SIZE equ 0x01000000
page_tabs equ 0x7FC00000
master_tab equ 0x7FDFF000
app_page_tabs equ 0x7FE00000
page_tabs equ 0xFDC00000
app_page_tabs equ 0xFDC00000
kernel_tabs equ (page_tabs+ (OS_BASE shr 10)) ;0xFDE00000
master_tab equ (page_tabs+ (page_tabs shr 10)) ;0xFDFF70000
sys_pgdir equ OS_BASE+0x00050000
sys_master_tab equ OS_BASE+0x00051000
sys_pgmap equ OS_BASE+0x00052000
LFB_BASE equ 0xFE000000
sys_pgdir equ (OS_BASE+0x00050000)
sys_pgmap equ (OS_BASE+0x00052000)
new_app_base equ 0;
new_app_base equ 0x80000000
twdw equ (CURRENT_TASK-window_data)
twdw equ 0x3000 ;(CURRENT_TASK-window_data)
std_application_base_address equ new_app_base
RING0_STACK_SIZE equ (0x2000-512) ;512 áàéò äëÿ êîíòåêñòà FPU
RING0_STACK_SIZE equ (0x2000 - 512) ;512 áàéò äëÿ êîíòåêñòà FPU
if 0
REG_SS equ (RING0_STACK_SIZE-4)
REG_APP_ESP equ (RING0_STACK_SIZE-8)
REG_EFLAGS equ (RING0_STACK_SIZE-12)
REG_CS equ (RING0_STACK_SIZE-16)
REG_EIP equ (RING0_STACK_SIZE-20)
REG_EFL_2 equ (RING0_STACK_SIZE-24)
REG_EAX equ (RING0_STACK_SIZE-28)
REG_ECX equ (RING0_STACK_SIZE-32)
REG_EDX equ (RING0_STACK_SIZE-36)
REG_EBX equ (RING0_STACK_SIZE-40)
REG_ESP equ (RING0_STACK_SIZE-44) ;RING0_STACK_SIZE-20
REG_EBP equ (RING0_STACK_SIZE-48)
REG_ESI equ (RING0_STACK_SIZE-52)
REG_EDI equ (RING0_STACK_SIZE-56)
REG_RET equ (RING0_STACK_SIZE-60) ;irq0.return
end if
REG_SS equ (RING0_STACK_SIZE-4)
REG_APP_ESP equ (RING0_STACK_SIZE-8)
REG_EFLAGS equ (RING0_STACK_SIZE-12)
REG_CS equ (RING0_STACK_SIZE-16)
REG_EIP equ (RING0_STACK_SIZE-20)
REG_EAX equ (RING0_STACK_SIZE-24)
REG_ECX equ (RING0_STACK_SIZE-28)
REG_EDX equ (RING0_STACK_SIZE-32)
REG_EBX equ (RING0_STACK_SIZE-36)
REG_ESP equ (RING0_STACK_SIZE-40) ;RING0_STACK_SIZE-20
REG_EBP equ (RING0_STACK_SIZE-44)
REG_ESI equ (RING0_STACK_SIZE-48)
REG_EDI equ (RING0_STACK_SIZE-52)
REG_RET equ (RING0_STACK_SIZE-56) ;irq0.return
;PAGES_USED equ 4
PG_UNMAP equ 0x000
PG_MAP equ 0x001
@ -331,16 +405,27 @@ EVENT_EXTENDED equ 0x00000200
EV_INTR equ 1
struc THR_DATA
{
rb (8192-512)
.pl0_stack:
.fpu_state rb 512
.tls_page rb 4096
.pdbr rb 4096
}
THR_DATA_SIZE equ 4096*4
virtual at (OS_BASE-THR_DATA_SIZE)
thr_data THR_DATA
end virtual
struc SYS_VARS
{ .bpp dd ?
.scanline dd ?
.vesa_mode dd ?
.x_res dd ?
.y_res dd ?
.cpu_caps dd ?
dd ?
dd ?
dd ?
}
struc APPOBJ ;common object header
@ -467,7 +552,6 @@ struc PG_DATA
.pages_free dd ?
.pages_faults dd ?
.pagemap_size dd ?
.kernel_max dd ?
.kernel_pages dd ?
.kernel_tables dd ?
.sys_page_dir dd ?
@ -496,6 +580,9 @@ struc SRV
SRV_FD_OFFSET equ 0x18
SRV_SIZE equ 44
DRV_ENTRY equ 1
DRV_EXIT equ -1
struc COFF_HEADER
{ .machine dw ?
.nSections dw ?

View File

@ -27,9 +27,8 @@ sys_debug_services_table:
debug_set_event_data:
; in: ebx = pointer
; destroys eax
mov eax, [CURRENT_TASK]
shl eax, 8
mov [eax+SLOT_BASE+APPDATA.dbg_event_mem], ebx
mov eax, [current_slot]
mov [eax+APPDATA.dbg_event_mem], ebx
ret
get_debuggee_slot:
@ -123,7 +122,6 @@ debug_getcontext:
; destroys eax,ecx,edx,esi,edi
cmp ecx, 28h
jnz .ret
add edx, std_application_base_address
push ebx
mov ebx, edx
call check_region
@ -132,43 +130,35 @@ debug_getcontext:
jnz .ret
call get_debuggee_slot
jc .ret
imul eax, tss_step/32
add eax, tss_data
mov edi, edx
cmp [eax+TSS._cs], app_code
jnz .ring0
lea esi, [eax+TSS._eip]
shr ecx, 2
rep movsd
jmp .ret
mov eax, [eax*8+SLOT_BASE+APPDATA.pl0_stack]
lea esi, [eax+RING0_STACK_SIZE]
mov edi, edx
.ring0:
; note that following code assumes that all interrupt/exception handlers
; saves ring-3 context by push ds es, pushad in this order
mov esi, [eax+TSS._esp0]
; top of ring0 stack: ring3 stack ptr (ss+esp), iret data (cs+eip+eflags), ds, es, pushad
sub esi, 8+12+8+20h
lodsd
; saves ring-3 context by pushad in this order
; top of ring0 stack: ring3 stack ptr (ss+esp), iret data (cs+eip+eflags), pushad
sub esi, 8+12+20h
lodsd ;edi
mov [edi+24h], eax
lodsd
lodsd ;esi
mov [edi+20h], eax
lodsd
lodsd ; ebp
mov [edi+1Ch], eax
lodsd
lodsd
lodsd ;esp
lodsd ;ebx
mov [edi+14h], eax
lodsd
lodsd ;edx
mov [edi+10h], eax
lodsd
lodsd ;ecx
mov [edi+0Ch], eax
lodsd
lodsd ;eax
mov [edi+8], eax
add esi, 8
lodsd
lodsd ;eip
mov [edi], eax
lodsd
lodsd
lodsd ;cs
lodsd ;eflags
mov [edi+4], eax
lodsd
lodsd ;esp
mov [edi+18h], eax
.ret:
sti
@ -182,7 +172,6 @@ debug_setcontext:
; destroys eax,ecx,edx,esi,edi
cmp ecx, 28h
jnz .ret
add edx, std_application_base_address
push ebx
mov ebx, edx
call check_region
@ -191,40 +180,32 @@ debug_setcontext:
jnz .ret
call get_debuggee_slot
jc .stiret
imul eax, tss_step/32
add eax, tss_data
mov esi, edx
cmp [eax+TSS._cs], app_code
jnz .ring0
lea edi, [eax+TSS._eip]
shr ecx, 2
rep movsd
jmp .stiret
mov eax, [eax*8+SLOT_BASE+APPDATA.pl0_stack]
lea edi, [eax+RING0_STACK_SIZE]
mov esi, edx
.ring0:
mov edi, [eax+TSS._esp0]
sub edi, 8+12+8+20h
mov eax, [esi+24h]
sub edi, 8+12+20h
mov eax, [esi+24h] ;edi
stosd
mov eax, [esi+20h]
mov eax, [esi+20h] ;esi
stosd
mov eax, [esi+1Ch]
mov eax, [esi+1Ch] ;ebp
stosd
scasd
mov eax, [esi+14h] ;ebx
stosd
mov eax, [esi+10h] ;edx
stosd
mov eax, [esi+0Ch] ;ecx
stosd
mov eax, [esi+8] ;eax
stosd
mov eax, [esi] ;eip
stosd
scasd
mov eax, [esi+14h]
mov eax, [esi+4] ;eflags
stosd
mov eax, [esi+10h]
stosd
mov eax, [esi+0Ch]
stosd
mov eax, [esi+8]
stosd
add edi, 8
mov eax, [esi]
stosd
scasd
mov eax, [esi+4]
stosd
mov eax, [esi+18h]
mov eax, [esi+18h] ;esp
stosd
.stiret:
sti
@ -238,8 +219,8 @@ debug_set_drx:
lea eax, [eax*8+SLOT_BASE+APPDATA.dbg_regs]
; [eax]=dr0, [eax+4]=dr1, [eax+8]=dr2, [eax+C]=dr3
; [eax+10]=dr7
add edx, std_application_base_address
jc .errret
cmp edx, OS_BASE
jae .errret
cmp cl, 3
ja .errret
mov ebx, dr7
@ -256,8 +237,9 @@ debug_set_drx:
btr dword [eax+10h], ecx ; clear L<i> bit
test byte [eax+10h], 55h
jnz .okret
imul eax, ebp, tss_step/32
and byte [eax + tss_data + TSS._trap], not 1
; imul eax, ebp, tss_step/32
; and byte [eax + tss_data + TSS._trap], not 1
and [ebp*8 + SLOT_BASE+APPDATA.dbg_state], not 1
.okret:
and dword [esp+36], 0
sti
@ -298,8 +280,9 @@ debug_set_drx:
not edx
and [eax+10h+2], dx
or [eax+10h+2], bx ; set R/W and LEN fields
imul eax, ebp, tss_step/32
or byte [eax + tss_data + TSS._trap], 1
; imul eax, ebp, tss_step/32
; or byte [eax + tss_data + TSS._trap], 1
or [ebp*8 + SLOT_BASE+APPDATA.dbg_state], 1
jmp .okret
debug_read_process_memory:
@ -310,7 +293,6 @@ debug_read_process_memory:
; edx=address in debuggee
; out: [esp+36]=sizeof(read)
; destroys all
add esi, std_application_base_address
push ebx
mov ebx, esi
call check_region
@ -337,7 +319,6 @@ debug_write_process_memory:
; edx=address in debuggee
; out: [esp+36]=sizeof(write)
; destroys all
add esi, std_application_base_address
push ebx
mov ebx, esi
call check_region
@ -430,45 +411,22 @@ debug_exc:
; int 1 = #DB
save_ring3_context
cld
mov ax, os_data
mov ax, app_data ;os_data
mov ds, ax
mov es, ax
mov eax, dr6
test ax, ax
jns @f
; this is exception from task switch
; set DRx registers for task and continue
mov eax, [CURRENT_TASK]
shl eax, 8
add eax, SLOT_BASE+APPDATA.dbg_regs
mov ecx, [eax+0]
mov dr0, ecx
mov ecx, [eax+4]
mov dr1, ecx
mov ecx, [eax+8]
mov dr2, ecx
mov ecx, [eax+0Ch]
mov dr3, ecx
xor ecx, ecx
mov dr6, ecx
mov ecx, [eax+10h]
mov dr7, ecx
restore_ring3_context
iretd
@@:
push eax
xor eax, eax
mov dr6, eax
; test if debugging
cli
mov eax, [CURRENT_TASK]
shl eax, 8
mov eax, [SLOT_BASE+eax+APPDATA.debugger_slot]
mov eax, [current_slot]
mov eax, [eax+APPDATA.debugger_slot]
test eax, eax
jnz .debug
sti
; not debuggee => say error and terminate
add esp, 28h+4
add esp, 0x20+4
mov [error_interrupt], 1
call show_error_parameters
mov edx, [TASK_BASE]

View File

@ -6,10 +6,8 @@ $Revision$
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
DRV_ENTRY equ 1
DRV_EXIT equ -1
DRV_COMPAT equ 4 ;minimal required drivers version
DRV_CURRENT equ 4 ;current drivers model version
DRV_COMPAT equ 5 ;minimal required drivers version
DRV_CURRENT equ 5 ;current drivers model version
DRV_VERSION equ (DRV_COMPAT shl 16) or DRV_CURRENT
@ -134,7 +132,7 @@ align 4
align 16
.main:
save_ring3_context
mov bx, os_data
mov bx, app_data ;os_data
mov ds, bx
mov es, bx
@ -161,14 +159,13 @@ align 4
proc get_notify stdcall, p_ev:dword
.wait:
mov ebx,[CURRENT_TASK]
shl ebx,8
test dword [ebx+SLOT_BASE+0xA8],EVENT_NOTIFY
mov ebx,[current_slot]
test dword [ebx+APPDATA.event_mask],EVENT_NOTIFY
jz @f
and dword [ebx+SLOT_BASE+0xA8], not EVENT_NOTIFY
and dword [ebx+APPDATA.event_mask], not EVENT_NOTIFY
mov edi, [p_ev]
mov dword [edi], EV_INTR
mov eax, [ebx+SLOT_BASE+APPDATA.event]
mov eax, [ebx+APPDATA.event]
mov dword [edi+4], eax
ret
@@:
@ -256,9 +253,8 @@ endp
align 4
srv_handlerEx:
test ebx, ebx
jz .fail
add ebx, new_app_base
cmp ebx, OS_BASE
jae .fail
mov eax, [ebx+handle]
cmp [eax+SRV.magic], ' SRV'
@ -267,9 +263,6 @@ srv_handlerEx:
cmp [eax+SRV.size], SRV_SIZE
jne .fail
add [ebx+input], new_app_base
add [ebx+output], new_app_base
stdcall [eax+SRV.srv_proc], ebx
ret
.fail:
@ -410,9 +403,9 @@ proc get_fileinfo stdcall, file_name:dword, info:dword
xor eax, eax
mov ebx, [file_name]
sub ebx, new_app_base
; sub ebx, new_app_base
mov ecx, [info]
sub ecx, new_app_base
; sub ecx, new_app_base
mov [cmd], 5
mov [offset], eax
@ -424,7 +417,7 @@ proc get_fileinfo stdcall, file_name:dword, info:dword
mov eax, 70
lea ebx, [cmd]
sub ebx, new_app_base
; sub ebx, new_app_base
int 0x40
ret
endp
@ -447,8 +440,6 @@ proc read_file stdcall,file_name:dword, buffer:dword, off:dword,\
mov ecx, [off]
mov edx, [bytes]
mov esi, [buffer]
sub ebx, new_app_base
sub esi, new_app_base
mov [cmd], eax
mov [offset], ecx
@ -461,7 +452,6 @@ proc read_file stdcall,file_name:dword, buffer:dword, off:dword,\
pushad
push eax
lea eax, [cmd]
sub eax, new_app_base
call file_system_lfn
pop eax
popad
@ -708,23 +698,23 @@ proc load_driver stdcall, driver_name:dword
file_name rb 14+16+4+1 ; '/rd/1/drivers/<up-to-16-chars>.obj'
endl
lea edx, [file_name]
mov dword [edx], '/rd/'
mov dword [edx+4], '1/dr'
mov dword [edx+8], 'iver'
mov word [edx+12], 's/'
mov esi, [driver_name]
lea edi, [edx+14]
mov ecx, 16
lea edx, [file_name]
mov dword [edx], '/rd/'
mov dword [edx+4], '1/dr'
mov dword [edx+8], 'iver'
mov word [edx+12], 's/'
mov esi, [driver_name]
lea edi, [edx+14]
mov ecx, 16
@@:
lodsb
test al, al
jz @f
stosb
loop @b
lodsb
test al, al
jz @f
stosb
loop @b
@@:
mov dword [edi], '.obj'
mov byte [edi+4], 0
mov dword [edi], '.obj'
mov byte [edi+4], 0
stdcall load_file, edx
test eax, eax
@ -919,13 +909,13 @@ proc load_library stdcall, file_name:dword
jmp .next
.copy:
add esi, edx
add edi, new_app_base
; add edi, new_app_base
mov ecx, [eax+CFS.SizeOfRawData]
cld
rep movsb
.next:
add edi, 15-new_app_base
and edi, not 15
add edi, 15 ;-new_app_base
and edi, -16
add eax, COFF_SECTION_SIZE
dec ebx
jnz @B
@ -1006,9 +996,8 @@ create_kernel_object:
test eax, eax
jz .fail
mov ecx,[CURRENT_TASK]
shl ecx,8
add ecx, SLOT_BASE+APP_OBJ_OFFSET
mov ecx,[current_slot]
add ecx, APP_OBJ_OFFSET
pushfd
cli
@ -1048,21 +1037,68 @@ destroy_kernel_object:
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
if 0
irq:
.irq0:
pusfd
pushad
push IRQ_0
jmp .master
.irq_1:
pusfd
pushad
push IRQ_1
jmp .master
.master:
mov ax, app_data
mov ds, eax
mov es, eax
mov ebx, [esp+4] ;IRQ_xx
mov eax, [irq_handlers+ebx+4]
call intr_handler
mov ecx, [esp+4]
cmp [irq_actids+ecx*4], 0
je @F
in al, 0x21
bts eax, ecx
out 0x21, al
mov al, 0x20
out 0x20, al
jmp .restart
.slave:
mov ax, app_data
mov ds, eax
mov es, eax
mov ebx, [esp+4] ;IRQ_xx
mov eax, [irq_handlers+ebx+4]
call intr_handler
mov ecx, [esp+4]
sub ecx, 8
cmp [irq_actids+ecx*4], 0
je @F
in al, 0xA1
bts eax, ecx
out 0xA1, al
mov al, 0x20
out 0xA0, al
out 0x20, al
.restart:
mov ebx, [next_slot]
test ebx, ebx
jz @F
mov [next_task],0
mov esi, [prev_slot]
call do_change_task
add esp, 4
iretd
end if
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

View File

@ -141,40 +141,40 @@ fpu_restore:
align 4
e7: ;#NM exception handler
save_ring3_context
clts
mov ax, os_data
mov ds, ax
mov es, ax
save_ring3_context
clts
mov ax, app_data ;
mov ds, ax
mov es, ax
mov ebx, [fpu_owner]
cmp ebx, [CURRENT_TASK]
je .exit
mov ebx, [fpu_owner]
cmp ebx, [CURRENT_TASK]
je .exit
shl ebx, 8
mov eax, [ebx+SLOT_BASE+APPDATA.fpu_state]
bt [cpu_caps], CAPS_SSE
jnc .no_SSE
shl ebx, 8
mov eax, [ebx+SLOT_BASE+APPDATA.fpu_state]
bt [cpu_caps], CAPS_SSE
jnc .no_SSE
fxsave [eax]
mov ebx, [CURRENT_TASK]
mov [fpu_owner], ebx
shl ebx, 8
mov eax, [ebx+SLOT_BASE+APPDATA.fpu_state]
fxrstor [eax]
fxsave [eax]
mov ebx, [CURRENT_TASK]
mov [fpu_owner], ebx
shl ebx, 8
mov eax, [ebx+SLOT_BASE+APPDATA.fpu_state]
fxrstor [eax]
.exit:
restore_ring3_context
iret
restore_ring3_context
iret
.no_SSE:
fnsave [eax]
mov ebx, [CURRENT_TASK]
mov [fpu_owner], ebx
shl ebx, 8
mov eax, [ebx+SLOT_BASE+APPDATA.fpu_state]
frstor [eax]
restore_ring3_context
iret
fnsave [eax]
mov ebx, [CURRENT_TASK]
mov [fpu_owner], ebx
shl ebx, 8
mov eax, [ebx+SLOT_BASE+APPDATA.fpu_state]
frstor [eax]
restore_ring3_context
iret
iglobal
fpu_owner dd 1
@ -196,17 +196,17 @@ except_16: ;fpu native exceptions handler
push ecx
push edx
mov ebx, [ss:CURRENT_TASK]
mov ebx, [CURRENT_TASK]
shl ebx, 8
mov eax, [ss:ebx+SLOT_BASE+APPDATA.fpu_handler]
mov eax, [ebx+SLOT_BASE+APPDATA.fpu_handler]
test eax, eax
jz .default
mov ecx, [reg_eip]
mov edx, [reg_esp]
sub edx, 4
mov [ss:edx+new_app_base], ecx
mov [edx], ecx
mov [reg_esp], edx
mov dword [reg_eip], eax
@ -240,17 +240,16 @@ except_19: ;sse exceptions handler
push ecx
push edx
mov ebx, [ss:CURRENT_TASK]
shl ebx, 8
mov ebx, [current_slot]
mov eax, [ss:ebx+SLOT_BASE+APPDATA.sse_handler]
mov eax, [ebx+APPDATA.sse_handler]
test eax, eax
jz .default
mov ecx, [reg_eip]
mov edx, [reg_esp]
sub edx, 4
mov [ss:edx+new_app_base], ecx
mov [edx], ecx
mov [reg_esp], edx
mov dword [reg_eip], eax

View File

@ -621,25 +621,24 @@ HEAP_TOP equ 0x5FC00000
align 4
proc init_heap
mov ebx,[CURRENT_TASK]
shl ebx,8
mov eax, [SLOT_BASE+APPDATA.heap_top+ebx]
mov ebx,[current_slot]
mov eax, [ebx+APPDATA.heap_top]
test eax, eax
jz @F
sub eax,[SLOT_BASE+APPDATA.heap_base+ebx]
sub eax,[ebx+APPDATA.heap_base]
sub eax, 4096
ret
@@:
mov esi, [SLOT_BASE+APPDATA.mem_size+ebx]
mov esi, [ebx+APPDATA.mem_size]
add esi, 4095
and esi, not 4095
mov [SLOT_BASE+APPDATA.mem_size+ebx], esi
mov [ebx+APPDATA.mem_size], esi
mov eax, HEAP_TOP
mov [SLOT_BASE+APPDATA.heap_base+ebx], esi
mov [SLOT_BASE+APPDATA.heap_top+ebx], eax
mov [ebx+APPDATA.heap_base], esi
mov [ebx+APPDATA.heap_top], eax
sub eax, esi
add esi, new_app_base
; add esi, new_app_base
shr esi, 10
mov ecx, eax
sub eax, 4096
@ -658,12 +657,9 @@ proc user_alloc stdcall, alloc_size:dword
add ecx, (4095+4096)
and ecx, not 4095
mov ebx, [CURRENT_TASK]
shl ebx, 8
mov esi, dword [ebx+SLOT_BASE+APPDATA.heap_base]; heap_base
mov edi, dword [ebx+SLOT_BASE+APPDATA.heap_top]; heap_top
add esi, new_app_base
add edi, new_app_base
mov ebx, [current_slot]
mov esi, dword [ebx+APPDATA.heap_base] ; heap_base
mov edi, dword [ebx+APPDATA.heap_top] ; heap_top
l_0:
cmp esi, edi
jae m_exit
@ -684,7 +680,6 @@ l_0:
or eax, FREE_BLOCK
shr edx, 12
mov [page_tabs+edx*4], eax
@@:
or ecx, USED_BLOCK
mov [page_tabs+ebx*4], ecx
@ -697,17 +692,15 @@ l_0:
dec ecx
jnz @B
mov edx, [CURRENT_TASK]
shl edx, 8
mov ebx, [alloc_size]
add ebx, 0xFFF
and ebx, not 0xFFF
add ebx, [SLOT_BASE+APPDATA.mem_size+edx]
call update_mem_size
mov edx, [current_slot]
mov ebx, [alloc_size]
add ebx, 0xFFF
and ebx, not 0xFFF
add ebx, [edx+APPDATA.mem_size]
call update_mem_size
mov eax, esi
add eax, 4096
sub eax, new_app_base
ret
m_next:
add esi, eax
@ -760,11 +753,10 @@ proc user_free stdcall, base:dword
dec ecx
jnz .release
.not_used:
mov edx, [CURRENT_TASK]
shl edx, 8
mov esi, dword [edx+SLOT_BASE+APPDATA.heap_base]; heap_base
mov edi, dword [edx+SLOT_BASE+APPDATA.heap_top]; heap_top
sub ebx, [edx+SLOT_BASE+APPDATA.mem_size]
mov edx, [current_slot]
mov esi, dword [edx+APPDATA.heap_base]
mov edi, dword [edx+APPDATA.heap_top]
sub ebx, [edx+APPDATA.mem_size]
neg ebx
call update_mem_size
call user_normalize
@ -779,8 +771,6 @@ user_normalize:
; in: esi=heap_base, edi=heap_top
; out: eax=0 <=> OK
; destroys: ebx,edx,esi,edi
add esi, new_app_base
add edi, new_app_base
shr esi, 12
shr edi, 12
@@:
@ -835,7 +825,7 @@ user_realloc:
ret
@@:
push ecx edx
lea ecx, [eax + new_app_base - 0x1000]
lea ecx, [eax - 0x1000]
shr ecx, 12
mov edx, [page_tabs+ecx*4]
test edx, USED_BLOCK
@ -874,16 +864,15 @@ user_realloc:
jnz .nofreeall
mov eax, [page_tabs+ecx*4]
and eax, not 0xFFF
mov edx, [CURRENT_TASK]
shl edx, 8
mov ebx, [SLOT_BASE+APPDATA.mem_size+edx]
mov edx, [current_slot]
mov ebx, [APPDATA.mem_size+edx]
sub ebx, eax
add ebx, 0x1000
or al, FREE_BLOCK
mov [page_tabs+ecx*4], eax
push esi edi
mov esi, [SLOT_BASE+APPDATA.heap_base+edx]
mov edi, [SLOT_BASE+APPDATA.heap_top+edx]
mov esi, [APPDATA.heap_base+edx]
mov edi, [APPDATA.heap_top+edx]
call update_mem_size
call user_normalize
pop edi esi
@ -896,14 +885,13 @@ user_realloc:
shr ebx, 12
sub ebx, edx
push ebx ecx edx
mov edx, [CURRENT_TASK]
shl edx, 8
mov edx, [current_slot]
shl ebx, 12
sub ebx, [SLOT_BASE+APPDATA.mem_size+edx]
sub ebx, [APPDATA.mem_size+edx]
neg ebx
call update_mem_size
pop edx ecx ebx
lea eax, [ecx+1-(new_app_base shr 12)]
lea eax, [ecx+1]
shl eax, 12
push eax
add ecx, ebx
@ -911,9 +899,8 @@ user_realloc:
shl ebx, 12
jz .ret
push esi
mov esi, [CURRENT_TASK]
shl esi, 8
mov esi, [SLOT_BASE+APPDATA.heap_top+esi]
mov esi, [current_slot]
mov esi, [APPDATA.heap_top+esi]
shr esi, 12
@@:
cmp edx, esi
@ -935,10 +922,8 @@ user_realloc:
ret
.realloc_add:
; get some additional memory
mov eax, [CURRENT_TASK]
shl eax, 8
mov eax, [SLOT_BASE+APPDATA.heap_top+eax]
add eax, new_app_base
mov eax, [current_slot]
mov eax, [APPDATA.heap_top+eax]
shr eax, 12
cmp edx, eax
jae .cant_inplace
@ -958,7 +943,7 @@ user_realloc:
shl eax, 12
or al, USED_BLOCK
mov [page_tabs+ecx*4], eax
lea eax, [ecx+1-(new_app_base shr 12)]
lea eax, [ecx+1]
shl eax, 12
push eax
push edi
@ -969,21 +954,17 @@ user_realloc:
cld
rep stosd
pop edi
mov edx, [CURRENT_TASK]
shl edx, 8
mov edx, [current_slot]
shl ebx, 12
add ebx, [SLOT_BASE+APPDATA.mem_size+edx]
add ebx, [APPDATA.mem_size+edx]
call update_mem_size
pop eax edx ecx
ret
.cant_inplace:
push esi edi
mov eax, [CURRENT_TASK]
shl eax, 8
mov esi, [SLOT_BASE+APPDATA.heap_base+eax]
mov edi, [SLOT_BASE+APPDATA.heap_top+eax]
add esi, new_app_base
add edi, new_app_base
mov eax, [current_slot]
mov esi, [APPDATA.heap_base+eax]
mov edi, [APPDATA.heap_top+eax]
shr esi, 12
shr edi, 12
sub ebx, ecx
@ -1022,7 +1003,6 @@ user_realloc:
inc esi
mov eax, esi
shl eax, 12
sub eax, new_app_base
push eax
mov eax, [page_tabs+ecx*4]
and eax, not 0xFFF
@ -1043,10 +1023,9 @@ user_realloc:
dec edx
jnz @b
push ebx
mov edx, [CURRENT_TASK]
shl edx, 8
mov edx, [current_slot]
shl ebx, 12
add ebx, [SLOT_BASE+APPDATA.mem_size+edx]
add ebx, [APPDATA.mem_size+edx]
call update_mem_size
pop ebx
@@:

View File

@ -992,7 +992,7 @@ init_malloc:
mov [eax+12], eax
add eax, 16
cmp eax, mst.smallbins+512
jl @B
jb @B
ret

View File

@ -6,162 +6,6 @@ $Revision$
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
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
@ -400,7 +244,7 @@ proc init_LFB
@@:
mov edx, LFB_BASE
mov esi, [LFBAddress]
mov edi, [LFBSize]
mov edi, 0x00800000
mov dword [exp_lfb+4], edx
shr edi, 12
@ -410,10 +254,9 @@ proc init_LFB
bt [cpu_caps], CAPS_PSE
jnc .map_page_tables
or esi, PG_LARGE+PG_UW
shr edx, 20
mov ecx, edx
mov edx, sys_pgdir+(LFB_BASE shr 20)
@@:
mov [sys_pgdir+edx], esi
mov [edx], esi
add edx, 4
add esi, 0x00400000
dec edi
@ -421,7 +264,7 @@ proc init_LFB
bt [cpu_caps], CAPS_PGE
jnc @F
or dword [sys_pgdir+ecx], PG_GLOBAL
or dword [sys_pgdir+(LFB_BASE shr 20)], PG_GLOBAL
@@:
mov dword [LFBAddress], LFB_BASE
mov eax, cr3 ;flush TLB
@ -430,11 +273,12 @@ proc init_LFB
.map_page_tables:
@@:
call alloc_page
stdcall map_page_table, edx, eax
add edx, 0x00400000
dec edi
jnz .map_page_tables
jnz @B
mov eax, [LFBAddress]
mov edi, page_tabs + (LFB_BASE shr 10)
@ -465,12 +309,11 @@ proc new_mem_resize stdcall, new_size:dword
and edi,not 4095
mov [new_size], edi
mov edx,[CURRENT_TASK]
shl edx,8
cmp [SLOT_BASE+APPDATA.heap_base+edx],0
mov edx,[current_slot]
cmp [edx+APPDATA.heap_base],0
jne .exit
mov esi, [SLOT_BASE+APPDATA.mem_size+edx]
mov esi, [edx+APPDATA.mem_size]
add esi, 4095
and esi, not 4095
@ -494,16 +337,13 @@ proc new_mem_resize stdcall, new_size:dword
jb @B
.update_size:
mov ebx, [new_size]
call update_mem_size
mov ebx, [new_size]
call update_mem_size
xor eax, eax
dec [pg_data.pg_mutex]
ret
.expand:
add edi, new_app_base
add esi, new_app_base
push esi
push edi
@ -567,14 +407,14 @@ proc new_mem_resize stdcall, new_size:dword
endp
update_mem_size:
; in: edx = slot shl 8
; in: edx = slot base
; ebx = new memory size
; destroys eax,ecx,edx
mov [SLOT_BASE+APPDATA.mem_size+edx],ebx
mov [APPDATA.mem_size+edx],ebx
;search threads and update
;application memory size infomation
mov ecx,[SLOT_BASE+APPDATA.dir_table+edx]
mov ecx,[APPDATA.dir_table+edx]
mov eax,2
.search_threads:
@ -610,53 +450,75 @@ get_pg_addr:
and eax, 0xFFFFF000
ret
align 4
proc page_fault_handler
pushad
.err_code equ ebp+32
.err_addr equ ebp-4
pushad
mov ebp, esp
mov eax, cr2
push eax
push ds
push es
mov ax, 0x10
mov ax, app_data
mov ds, ax
mov es, ax
inc [pg_data.pages_faults]
mov ebx, [ebp-4]
; push eax
; push edx
; mov edx, 0x400 ;bochs
; mov al,0xff ;bochs
; out dx, al ;bochs
; pop edx
; pop eax
cmp ebx, 0x80000000
jae .user_space
mov ebx, [.err_addr]
mov eax, [.err_code]
cmp ebx, app_page_tabs
jae .alloc
cmp ebx, OS_BASE
jb .user_space ;ñòðàíèöà â ïàìÿòè ïðèëîæåíèÿ ;
cmp ebx, page_tabs
jae .tab_space
jb .kernel_space ;ñòðàíèöà â ïàìÿòè ÿäðà
cmp ebx, 0x7DC00000
jae .lfb_addr
cmp ebx, kernel_tabs
jb .alloc;.app_tabs ;òàáëèöû ñòðàíèö ïðèëîæåíèÿ ;
;ïðîñòî ñîçäàäèì îäíó
jmp .kernel_space
cmp ebx, LFB_BASE
jb .core_tabs ;òàáëèöû ñòðàíèö ÿäðà
;Îøèáêà
.lfb:
;îáëàñòü LFB
;Îøèáêà
jmp .fail
align 4
.user_space:
test eax, PG_MAP
jnz .err_access ;Ñòðàíèöà ïðèñóòñòâóåò
;Îøèáêà äîñòóïà ?
shr ebx, 12
mov ecx, ebx
shr ecx, 10
mov edx, [master_tab+ecx*4]
test edx, 1
jz .fail
test edx, PG_MAP
jz .fail ;òàáëèöà ñòðàíèö íå ñîçäàíà
;íåâåðíûé àäðåñ â ïðîãðàììå
mov eax, [page_tabs+ebx*4]
test eax, 2
jz .fail
jz .fail ;àäðåñ íå çàðåçåðâèðîâàí äëÿ ;
;èñïîëüçîâàíèÿ. Îøèáêà
.alloc:
call alloc_page
and eax, eax
jz .exit
jz .fail
stdcall map_page,[ebp-4],eax,dword PG_UW
@ -667,49 +529,76 @@ proc page_fault_handler
cld
rep stosd
.exit:
pop es
pop ds
mov esp, ebp
popad
add esp, 4
iretd
.err_access:
;íèêîãäà íå ïðîèñõîäèò
jmp .fail
.kernel_space:
test eax, PG_MAP
jz .fail ;ñòðàíèöà íå ïðèñóòñòâóåò
test eax, 4 ;U/S
jnz .fail ;ïðèëîæåíèå îáðàòèëîñü ê ïàìÿòè
;ÿäðà
test eax, 8
jnz .fail ;óñòàíîâëåí çàðåçåðâèðîâàííûé áèò
;â òàáëèöàõ ñòðàíèö. äîáàâëåíî â P4/Xeon
;ïîïûòêà çàïèñè â çàùèù¸ííóþ ñòðàíèöó ÿäðà
cmp ebx, tss._io_map_0
jb .fail
cmp ebx, tss._io_map_0+8192
jae .fail
; io permission map
; copy-on-write protection
call alloc_page
and eax, eax
jz .fail
push eax
stdcall map_page,[ebp-4],eax,dword PG_SW
pop eax
mov edi, [.err_addr]
and edi, -4096
lea esi, [edi+(not tss._io_map_0)+1]; -tss._io_map_0
mov ebx, esi
shr ebx, 12
mov edx, [current_slot]
or eax, PG_SW
mov [edx+APPDATA.io_map+ebx*4], eax
add esi, [default_io_map]
mov ecx, 4096/4
cld
rep movsd
jmp .exit
;íå îáðàáàòûâàåì. Îøèáêà
.core_tabs:
.fail:
pop es
pop ds
mov esp, ebp
popad
add esp, 4
; iretd
save_ring3_context ;debugger support
mov bl, 14
jmp exc_c
iretd
.kernel_space:
; shr ebx, 12
; mov eax, [page_tabs+ebx*4]
; shr ebx, 10
; mov eax, [master_tab+ebx*4]
jmp .exit
.old_addr:
; shr ebx, 12
; mov eax, [page_tabs+ebx*4]
; shr ebx, 10
; mov eax, [master_tab+ebx*4]
jmp .exit
.lfb_addr:
; shr ebx, 22
; ;mov ecx, [sys_page_dir]
; mov eax, [master_tab+ebx*4]
jmp .exit
.tab_space:
; shr ebx, 12
; mov eax, [page_tabs+ebx*4]
; shr ebx, 10
; ;mov ecx, [sys_page_dir]
; mov eax, [master_tab+ebx*4]
jmp .exit
endp
align 4
@ -845,15 +734,12 @@ sys_IPC:
align 4
proc set_ipc_buff
mov eax,[CURRENT_TASK]
shl eax,8
add eax, SLOT_BASE
mov eax,[current_slot]
pushf
cli
mov [eax+0xA0],ebx ;set fields in extended information area
mov [eax+0xA4],ecx
mov [eax+APPDATA.ipc_start],ebx ;set fields in extended information area
mov [eax+APPDATA.ipc_size],ecx
add ebx, new_app_base
add ecx, ebx
add ecx, 4095
and ecx, not 4095
@ -890,7 +776,7 @@ proc sys_ipc_send stdcall, PID:dword, msg_addr:dword, msg_size:dword
jz .no_ipc_area
mov ebx, edi
add edi, new_app_base
; add edi, new_app_base
and ebx, 0xFFF
mov [dst_offset], ebx
@ -924,7 +810,7 @@ proc sys_ipc_send stdcall, PID:dword, msg_addr:dword, msg_size:dword
mov [edi+4], ecx
add edi, 8
mov esi, [msg_addr]
add esi, new_app_base
; add esi, new_app_base
cld
rep movsb
@ -982,9 +868,9 @@ endp
align 4
sysfn_meminfo:
add ebx, new_app_base
cmp ebx, new_app_base
jb .fail
; add ebx, new_app_base
cmp ebx, OS_BASE
jae .fail
mov eax, [pg_data.pages_count]
mov [ebx], eax
@ -1030,26 +916,23 @@ new_services:
@@:
cmp eax, 13
ja @f
add ebx, new_app_base
stdcall user_free, ebx
mov [esp+36], eax
ret
@@:
cmp eax, 14
ja @f
add ebx, new_app_base
cmp ebx, new_app_base
jb .fail
cmp ebx, OS_BASE
jae .fail
stdcall get_event_ex, ebx, ecx
mov [esp+36], eax
ret
@@:
cmp eax, 15
ja @f
mov ecx, [CURRENT_TASK]
shl ecx, 8
mov eax, [ecx+SLOT_BASE+APPDATA.fpu_handler]
mov [ecx+SLOT_BASE+APPDATA.fpu_handler], ebx
mov ecx, [current_slot]
mov eax, [ecx+APPDATA.fpu_handler]
mov [ecx+APPDATA.fpu_handler], ebx
mov [esp+36], eax
ret
@@:
@ -1058,9 +941,8 @@ new_services:
test ebx, ebx
jz .fail
add ebx, new_app_base
cmp ebx, new_app_base
jb .fail
cmp ebx, OS_BASE
jae .fail
stdcall get_service, ebx
mov [esp+36], eax
ret
@ -1073,18 +955,16 @@ new_services:
@@:
cmp eax, 18
ja @f
mov ecx, [CURRENT_TASK]
shl ecx, 8
mov eax, [ecx+SLOT_BASE+APPDATA.sse_handler]
mov [ecx+SLOT_BASE+APPDATA.sse_handler], ebx
mov ecx, [current_slot]
mov eax, [ecx+APPDATA.sse_handler]
mov [ecx+APPDATA.sse_handler], ebx
mov [esp+36], eax
ret
@@:
cmp eax, 19
ja @f
add ebx, new_app_base
cmp ebx, new_app_base
jb .fail
cmp ebx, OS_BASE
jae .fail
stdcall load_library, ebx
mov [esp+36], eax
ret
@ -1102,144 +982,6 @@ new_services:
mov [esp+36], eax
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
@ -1314,6 +1056,43 @@ proc set_mtrr stdcall, reg:dword,base:dword,size:dword,mem_type:dword
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
@ -1341,106 +1120,6 @@ proc stall stdcall, delay:dword
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
@ -1660,3 +1339,15 @@ k_strlen:
ret
end if
if 0
push eax
push edx
mov edx, 0x400 ;bochs
mov al,0xff ;bochs
out dx, al ;bochs
pop edx
pop eax
end if

View File

@ -10,12 +10,14 @@ $Revision$
;; IRQ0 HANDLER (TIMER INTERRUPT) ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
align 32
irq0:
save_ring3_context
mov ax, os_data
mov ds, ax
mov es, ax
; pushfd
pushad
mov ax, app_data ;
mov ds, ax
mov es, ax
inc dword [timer_ticks]
@ -27,8 +29,7 @@ irq0:
add eax,100
mov [next_usage_update],eax
call updatecputimes
.nocounter:
.nocounter:
cmp [DONT_SWITCH], byte 1
jne .change_task
@ -38,10 +39,11 @@ irq0:
mov [DONT_SWITCH], byte 0
restore_ring3_context
iret
popad
; popfd
iretd
.change_task:
.change_task:
call update_counters
call find_next_task
@ -56,9 +58,10 @@ irq0:
call do_change_task
.return:
restore_ring3_context
iret
.return:
popad
; popfd
iretd
align 4
@ -69,6 +72,9 @@ change_task:
pushad
call update_counters
if 0
; \begin{Mario79}
cmp [dma_task_switched], 1
jne .find_next_task
@ -82,6 +88,9 @@ change_task:
jmp @f
.find_next_task:
; \end{Mario79}
end if
call find_next_task
test eax, eax ; the same task -> skip switch
jnz .return
@ -89,10 +98,9 @@ change_task:
mov [DONT_SWITCH],byte 1
call do_change_task
.return:
.return:
popad
popfd
ret
@ -112,7 +120,7 @@ endg
update_counters:
mov edi, [TASK_BASE]
mov ebx, [edi+TASKDATA.counter_add] ; time stamp counter add
call _rdtsc
rdtsc
sub eax, ebx
add eax, [edi+TASKDATA.counter_sum] ; counter sum
mov [edi+TASKDATA.counter_sum], eax
@ -130,15 +138,15 @@ find_next_task:
mov edi, [TASK_BASE]
mov [prev_slot], ebx
.waiting_for_termination:
.waiting_for_reuse:
.waiting_for_event:
.suspended:
.waiting_for_termination:
.waiting_for_reuse:
.waiting_for_event:
.suspended:
cmp ebx, [TASK_COUNT]
jb @f
mov edi, CURRENT_TASK
xor ebx, ebx
@@:
@@:
add edi,0x20
inc ebx
@ -159,12 +167,6 @@ find_next_task:
mov [CURRENT_TASK],ebx
mov [TASK_BASE],edi
push ebx
shl ebx, 8
mov ebx, [SLOT_BASE + ebx + APPDATA.pl0_stack]
add ebx, RING0_STACK_SIZE
mov [CURRENT_RING0_ESP], ebx
pop ebx
cmp al, 5
jne .noevents
@ -173,30 +175,69 @@ find_next_task:
jz .waiting_for_event
mov [event_sched], eax
mov [edi+TASKDATA.state], byte 0
.noevents:
.found:
.noevents:
.found:
mov [CURRENT_TASK],ebx
mov [TASK_BASE],edi
call _rdtsc
rdtsc ;call _rdtsc
mov [edi+TASKDATA.counter_add],eax
mov esi, [prev_slot]
xor eax, eax
cmp ebx, [prev_slot]
cmp ebx, esi
sete al
ret
; in: ebx = TSS selector index
; param
; ebx = incoming task
; esi = outcomig task
do_change_task:
shl ebx, 3
xor eax, eax
add ebx, tss0
mov [far_jump.sel], bx ; selector
mov [far_jump.offs], eax ; offset
jmp pword [far_jump]
shl ebx, 8
add ebx, SLOT_BASE
mov [current_slot], ebx
shl esi, 8
add esi, SLOT_BASE
mov [esi+APPDATA.saved_esp], esp
mov esp, [ebx+APPDATA.saved_esp]
; set thread io map
mov ecx, [ebx+APPDATA.io_map]
mov edx, [ebx+APPDATA.io_map+4]
mov dword [page_tabs+((tss._io_map_0 and -4096) shr 10)], ecx
mov dword [page_tabs+((tss._io_map_1 and -4096) shr 10)], edx
mov eax, [ebx+APPDATA.dir_table]
mov cr3, eax
mov ebx, [ebx+APPDATA.pl0_stack]
add ebx, RING0_STACK_SIZE
mov [tss._esp0], ebx
mov ecx, cr0
or ecx, CR0_TS ;set task switch flag
mov cr0, ecx
inc [context_counter] ;noname & halyavin
ret
test [ebx+APPDATA.dbg_state], 1
jnz @F
ret
@@:
mov eax, [ebx+APPDATA.dbg_regs.dr0]
mov dr0, eax
mov eax, [ebx+APPDATA.dbg_regs.dr1]
mov dr1, eax
mov eax, [ebx+APPDATA.dbg_regs.dr2]
mov dr2, eax
mov eax, [ebx+APPDATA.dbg_regs.dr3]
mov dr3, eax
xor eax, eax
mov dr6, eax
mov eax, [ebx+APPDATA.dbg_regs.dr7]
mov dr7, eax
ret
align 4
updatecputimes:
@ -206,7 +247,7 @@ updatecputimes:
mov [idleuse],dword 0
mov ecx, [TASK_COUNT]
mov edi, TASK_DATA
.newupdate:
.newupdate:
mov ebx,[edi+TASKDATA.counter_sum]
mov [edi+TASKDATA.cpu_usage],ebx
mov [edi+TASKDATA.counter_sum],dword 0
@ -215,3 +256,108 @@ updatecputimes:
jnz .newupdate
ret
if 0
struc TIMER
{
.next dd ?
.exp_time dd ?
.func dd ?
.arg dd ?
}
MAX_PROIRITY 0 ; highest, used for kernel tasks
MAX_USER_PRIORITY 0 ; highest priority for user processes
USER_PRIORITY 7 ; default (should correspond to nice 0)
MIN_USER_PRIORITY 14 ; minimum priority for user processes
IDLE_PRIORITY 15 ; lowest, only IDLE process goes here
NR_SCHED_QUEUES 16 ; MUST equal IDLE_PRIORYTY + 1
rdy_head rd 16
align 4
pick_task:
xor eax, eax
.pick:
mov ebx, [rdy_head+eax*4]
test ebx, ebx
jz .next
mov [next_task], ebx
test [ebx+flags.billable]
jz @F
mov [bill_task], ebx
@@:
ret
.next:
inc eax
jmp .pick
; param
; eax= task
;
; retval
; eax= task
; ebx= queue
; ecx= front if 1 or back if 0
align 4
shed:
cmp [eax+.tics_left], 0 ;signed compare
mov ebx, [eax+.priority]
setg ecx
jg @F
mov edx, [eax+.tics_quantum]
mov [eax+.ticks_left], edx
cmp ebx, (IDLE_PRIORITY-1)
je @F
inc ebx
@@:
ret
; param
; eax= task
align 4
enqueue:
call shed ;eax
cmp [rdy_head+ebx*4],0
jnz @F
mov [rdy_head+ebx*4], eax
mov [rdy_tail+ebx*4], eax
mov [eax+.next_ready], 0
jmp .pick
@@:
test ecx, ecx
jz .back
mov ecx, [rdy_head+ebx*4]
mov [eax+.next_ready], ecx
mov [rdy_head+ebx*4], eax
jmp .pick
.back:
mov ecx, [rdy_tail+ebx*4]
mov [ecx+.next_ready], eax
mov [rdy_tail+ebx*4], eax
mov [eax+.next_ready], 0
.pick:
call pick_proc ;select next task
ret
end if

View File

@ -17,25 +17,6 @@ idtreg:
dw 8*0x41-1
dd idts+8
build_process_gdt_tss_pointer:
mov ecx,tss_data
mov edi,0
setgdtl2:
mov [edi+gdts+ tss0 +0], word tss_step
mov [edi+gdts+ tss0 +2], cx
mov eax,ecx
shr eax,16
mov [edi+gdts+ tss0 +4], al
mov [edi+gdts+ tss0 +7], ah
mov [edi+gdts+ tss0 +5], word 01010000b *256 +11101001b
add ecx,tss_step
add edi,8
cmp edi,8*(max_processes+5)
jbe setgdtl2
ret
build_interrupt_table:
mov edi, idts+8
@ -43,11 +24,11 @@ build_interrupt_table:
mov ecx, 0x40
@@:
lodsd
mov [edi], ax ; lower part of offset
mov [edi+2], word os_code ; segment selector
mov [edi], ax ; lower part of offset
mov [edi+2], word os_code ; segment selector
mov ax, word 10001110b shl 8 ; type: interrupt gate
mov [edi+4], eax
add edi, 8
add edi, 8
loop @b
;mov edi,8*0x40+idts+8
@ -67,7 +48,7 @@ iglobal
times 12 dd unknown_interrupt
dd irq0 , irq_serv.irq_1, p_irq2 , p_irq3 ;irq_serv.irq_3
dd p_irq4 ,irq_serv.irq_5,p_irq6,irq_serv.irq_7
dd irq_serv.irq_4 ,irq_serv.irq_5,p_irq6,irq_serv.irq_7
dd irq_serv.irq_8, irq_serv.irq_9, irq_serv.irq_10
dd irq_serv.irq_11,p_irq12,irqD ,p_irq14,p_irq15
@ -78,13 +59,11 @@ endg
macro save_ring3_context
{
push ds es
pushad
}
macro restore_ring3_context
{
popad
pop es ds
}
; simply return control to interrupted process
@ -114,20 +93,19 @@ exc_wo_code 0, 1, 2, 3, 4, 5, 6, 9, 15, 18
exc_w_code 8, 10, 11, 12, 13, 14, 17
exc_c:
mov ax, os_data
mov ds, ax
mov es, ax
mov ax, app_data ;èñêëþ÷åíèå
mov ds, ax ;çàãðóçèì ïðàâèëüíûå çíà÷åíè
mov es, ax ;â ðåãèñòðû
; test if debugging
cli
mov eax, [CURRENT_TASK]
shl eax, 8
mov eax, [SLOT_BASE+eax+APPDATA.debugger_slot]
mov eax, [current_slot]
mov eax, [eax+APPDATA.debugger_slot]
test eax, eax
jnz .debug
sti
; not debuggee => say error and terminate
add esp, 28h
add esp, 0x20 ;28h
movzx eax, bl
mov [error_interrupt], eax
call show_error_parameters
@ -242,8 +220,8 @@ macro irqh [num]
irqh 2,5,7,8,9,10,11
irq_c:
mov ax, os_data
irq_c:
mov ax, app_data ;os_data
mov ds, ax
mov es, ax
call irqhandler
@ -252,7 +230,7 @@ irqh 2,5,7,8,9,10,11
p_irq6:
save_ring3_context
mov ax, os_data
mov ax, app_data ;os_data
mov ds, ax
mov es, ax
call fdc_irq
@ -262,7 +240,7 @@ p_irq6:
p_irq3:
save_ring3_context
mov ax, os_data
mov ax, app_data ;os_data
mov ds, ax
mov es, ax
cmp [com2_mouse_detected],0
@ -278,7 +256,7 @@ p_irq3:
p_irq4:
save_ring3_context
mov ax, os_data
mov ax, app_data ;os_data
mov ds, ax
mov es, ax
cmp [com1_mouse_detected],0
@ -294,7 +272,7 @@ p_irq4:
p_irq12:
save_ring3_context
mov ax, os_data
mov ax, app_data ;os_data
mov ds, ax
mov es, ax
call check_mouse_data_ps2
@ -303,7 +281,7 @@ p_irq12:
p_irq14:
save_ring3_context
mov ax, os_data
mov ax, app_data ;os_data
mov ds, ax
mov es, ax
call [irq14_func]
@ -312,7 +290,7 @@ p_irq14:
iret
p_irq15:
save_ring3_context
mov ax, os_data
mov ax, app_data ;os_data
mov ds, ax
mov es, ax
call [irq15_func]
@ -335,7 +313,7 @@ ready_for_next_irq_1:
irqD:
save_ring3_context
mov ax, os_data
mov ax, app_data ;os_data
mov ds, ax
mov es, ax
@ -674,6 +652,17 @@ term9:
mov edi, [.slot]
shl edi,8
add edi,SLOT_BASE
mov eax, [edi+APPDATA.io_map]
cmp eax, (tss._io_map_0-OS_BASE+PG_MAP)
je @F
call free_page
@@:
mov eax, [edi+APPDATA.io_map+4]
cmp eax, (tss._io_map_1-OS_BASE+PG_MAP)
je @F
call free_page
@@:
mov eax, 0x20202020
stosd
stosd
@ -837,13 +826,12 @@ endg
build_scheduler:
; mov esi,boot_sched_1
; call boot_log
call build_process_gdt_tss_pointer
mov esi,boot_sched_1
call boot_log
; call build_process_gdt_tss_pointer
; mov esi,boot_sched_2
; call boot_log
call build_interrupt_table
; mov esi,boot_sched_2
; call boot_log
ret

View File

@ -12,17 +12,16 @@ $Revision$
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
align 32
align 16
i40:
; diamond, 27.03.2007: handler does not require disabled interrupts
; so interrupts remain enabled when calling int 0x40
push ds es
pushad
cld
mov ax,word os_data
mov ds,ax
mov es,ax
; mov ax, word app_data
; mov ds, ax
; mov es, ax
; load all registers in crossed order
mov eax, ebx
@ -38,10 +37,8 @@ i40:
and edi,0xff
call dword [servetable+edi*4]
pop eax
; cli
popad
pop es ds
iretd
@ -67,18 +64,13 @@ sysenter_entry:
; mov eax, [ss:SLOT_BASE + eax + APPDATA.pl0_stack]
; lea esp, [eax + RING0_STACK_SIZE] ; configure ESP
; mov eax, [ss:sysenter_stack - 4] ; eax - original eax, from app
mov esp, [ss:CURRENT_RING0_ESP]
mov esp, [ss:tss._esp0]
sti
;------------------
push ds es
;------------------
pushad
cld
mov ax, word os_data
mov ds, ax
mov es, ax
mov eax, ebx
mov ebx, ecx
mov ecx, edx
@ -92,10 +84,9 @@ sysenter_entry:
pop eax
popad
pop es ds
;------------------
mov edx, [SYSENTER_VAR] ; eip
mov ecx, [SYSENTER_VAR + 4] ; esp
mov edx, [SYSENTER_VAR] ; eip
mov ecx, [SYSENTER_VAR + 4] ; esp
sysexit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -105,12 +96,11 @@ sysenter_entry:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
align 32
syscall_entry:
; cli syscall clear IF
xchg esp, [ss:CURRENT_RING0_ESP]
xchg esp, [ss:tss._esp0]
push ecx
lea ecx, [esp+4]
xchg ecx, [ss:CURRENT_RING0_ESP]
xchg ecx, [ss:tss._esp0]
sti
push ecx
mov ecx, [ecx]
@ -123,13 +113,12 @@ syscall_entry:
; mov eax, [ss:sysenter_stack - 4] ; eax - original eax, from app
;------------------
push ds es
pushad
cld
mov ax, word os_data
mov ds, ax
mov es, ax
; mov ax, word app_data
; mov ds, ax
; mov es, ax
mov eax, ebx
mov ebx, ecx
@ -144,13 +133,11 @@ syscall_entry:
pop eax
popad
pop es ds
;------------------
mov ecx, [ss:esp+4]
pop esp
sysret
sysret
iglobal
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; SYSTEM FUNCTIONS TABLE ;;

View File

@ -28,40 +28,6 @@ struc APP_HEADER_01
.i_icon dd ? ;+32
}
struc TSS
{
._back rw 2
._esp0 rd 1
._ss0 rw 2
._esp1 rd 1
._ss1 rw 2
._esp2 rd 1
._ss2 rw 2
._cr3 rd 1
._eip rd 1
._eflags rd 1
._eax rd 1
._ecx rd 1
._edx rd 1
._ebx rd 1
._esp rd 1
._ebp rd 1
._esi rd 1
._edi rd 1
._es rw 2
._cs rw 2
._ss rw 2
._ds rw 2
._fs rw 2
._gs rw 2
._ldt rw 2
._trap rw 1
._io rw 1
}
virtual at 0
TSS TSS
end virtual
struc APP_PARAMS
{ .app_cmdline ;0x00
@ -154,9 +120,6 @@ proc fs_execute
cmp eax, 0
jne .wait_lock
; pushfd
; cli
call set_application_table_status
call get_new_process_place
@ -216,7 +179,7 @@ else
jna @F
xor eax, eax
add edi, new_app_base
; add edi, new_app_base
cld
rep stosb
@@:
@ -395,21 +358,21 @@ proc create_app_space stdcall, app_size:dword,img_base:dword,img_size:dword
mov [dir_addr], eax
stdcall map_page,[tmp_task_pdir],eax,dword PG_SW
mov esi, sys_pgdir
mov edi, [tmp_task_pdir]
mov ecx, (page_tabs shr 20)/4
mov ecx, (OS_BASE shr 20)/4
xor eax, eax
cld
rep stosd
mov ecx, (OS_BASE shr 20)/4
mov esi, sys_pgdir+(OS_BASE shr 20)
rep movsd
mov eax, [dir_addr]
or eax, PG_SW
stosd ; [(page_tabs shr 20)]= eax
mov [edi-4096+(page_tabs shr 20)], eax
mov ecx, 0x800/4
xor eax, eax
rep stosd
mov eax, [dir_addr]
and eax, -4096
call set_cr3
mov edx, [app_tabs]
@ -494,13 +457,9 @@ endp
align 4
set_cr3:
mov esi, [CURRENT_TASK]
mov ebx, esi
shl esi,8
mov [SLOT_BASE+esi+0xB8],eax
imul ebx,tss_step
add ebx,tss_data
mov [ebx+28], eax
mov ebx, [current_slot]
mov [ebx+APPDATA.dir_table], eax
mov cr3, eax
ret
@ -558,8 +517,7 @@ proc destroy_app_space stdcall, pg_dir:dword
and eax, not 0xFFF
stdcall map_page,[tmp_task_pdir],eax,dword PG_SW
mov esi, [tmp_task_pdir]
add esi, 0x800
mov edi, 0x800/4
mov edi, (OS_BASE shr 20)/4
.destroy:
mov eax, [esi]
test eax, 1
@ -744,7 +702,7 @@ proc read_process_memory
mov eax, [slot]
shl eax,8
mov ebx, [offset]
add ebx, new_app_base
; add ebx, new_app_base
push ecx
stdcall map_memEx, [proc_mem_map],\
[SLOT_BASE+eax+0xB8],\
@ -810,7 +768,7 @@ proc write_process_memory
mov eax, [slot]
shl eax,8
mov ebx, [offset]
add ebx, new_app_base
; add ebx, new_app_base
push ecx
stdcall map_memEx, [proc_mem_map],\
[SLOT_BASE+eax+0xB8],\
@ -875,9 +833,7 @@ proc new_sys_threads
mov [slot], eax
mov esi,[CURRENT_TASK]
shl esi,8
add esi,SLOT_BASE
mov esi,[current_slot]
mov ebx,esi ;ebx=esi - pointer to extended information about current thread
mov edi, eax
@ -942,6 +898,12 @@ wait_mutex:
pop eax
ret
EFL_IF equ 0x0200
EFL_IOPL1 equ 0x1000
EFL_IOPL2 equ 0x2000
EFL_IOPL3 equ 0x3000
align 4
proc set_app_params stdcall,slot:dword, params:dword,\
cmd_line:dword, app_path:dword, flags:dword
@ -963,9 +925,14 @@ proc set_app_params stdcall,slot:dword, params:dword,\
mov [eax+SLOT_BASE+APPDATA.fpu_handler], 0
mov [eax+SLOT_BASE+APPDATA.sse_handler], 0
;set default io permission map
mov [eax+SLOT_BASE+APPDATA.io_map],\
(tss._io_map_0-OS_BASE+PG_MAP)
mov [eax+SLOT_BASE+APPDATA.io_map+4],\
(tss._io_map_1-OS_BASE+PG_MAP)
mov esi, fpu_data
mov ecx, 512/4
cld
rep movsd
cmp ebx,[TASK_COUNT]
@ -1003,24 +970,24 @@ proc set_app_params stdcall,slot:dword, params:dword,\
cmp eax, [SLOT_BASE+APPDATA.mem_size+ebx*8]
ja @f
add edx, new_app_base
stdcall k_strncpy, edx, [cmd_line], 256
@@:
mov edx,[params]
mov edx, [edx+4] ;app_path
test edx,edx
jz @F ;application don't need path of file
mov eax, edx
add eax, 1024
jc @f
cmp eax, [SLOT_BASE+APPDATA.mem_size+ebx*8]
ja @f
add edx, new_app_base
mov eax, edx
add eax, 1024
jc @f
cmp eax, [SLOT_BASE+APPDATA.mem_size+ebx*8]
ja @f
stdcall k_strncpy, edx, [app_path], 1024
@@:
mov ebx,[slot]
mov eax,ebx
shl ebx,5
lea ecx,[draw_data+ebx] ;ecx - pointer to draw data
; set window state to 'normal' (non-minimized/maximized/rolled-up) state
mov [ebx+window_data+WDATA.fl_wstate], WSTATE_NORMAL
mov [ebx+window_data+WDATA.fl_redraw], 1
@ -1033,8 +1000,6 @@ proc set_app_params stdcall,slot:dword, params:dword,\
mov eax,[process_number]
mov [ebx+4],eax ;set PID
mov ecx,ebx
add ecx,(draw_data-CURRENT_TASK) ;ecx - pointer to draw data
;set draw data to full screen
mov [ecx+0],dword 0
@ -1044,54 +1009,34 @@ proc set_app_params stdcall,slot:dword, params:dword,\
mov eax,[ScreenHeight]
mov [ecx+12],eax
mov edi,[slot]
imul edi,tss_step
add edi,tss_data
mov ecx,128/4
xor eax, eax
cld
rep stosd
;Add IO access table - bit array of permitted ports
not eax
mov ecx,2048
rep stosd ; access to 4096*8=65536 ports
sub edi, tss_step
;set cr3 register in TSS of application
mov ecx, [slot]
shl ecx, 8
mov eax,[SLOT_BASE+ecx+APPDATA.dir_table]
mov [edi+TSS._cr3],eax
mov esi,[params]
mov eax, [esi+0x08] ;app_eip
mov [edi+TSS._eip],eax ;set eip in TSS
mov eax, [esi+0x0C] ;app_esp
mov [edi+TSS._esp],eax ;set stack in TSS
mov [edi+TSS._eflags],dword 0x1202
mov [edi+TSS._cs],app_code ;selector of code segment
mov [edi+TSS._ss],app_data
mov [edi+TSS._ds],app_data
mov [edi+TSS._es],app_data
mov [edi+TSS._fs],app_data
mov [edi+TSS._gs],graph_data ;selector of graphic segment
mov [edi+TSS._io],word 128
mov [edi+TSS._ss0], os_data
mov ebx, [pl0_stack]
add ebx, RING0_STACK_SIZE
mov [edi+TSS._esp0],ebx
mov esi,[params]
lea ecx, [ebx+REG_EIP]
xor eax, eax
mov ecx, edi ;ecx - address of application TSS
mov ebx,[slot]
shl ebx,3
;set TSS descriptor
mov [ebx+gdts+tss0+0],word tss_step ;limit (size)
mov [ebx+gdts+tss0+2],cx ;part of offset
shr ecx,16
mov [ebx+gdts+tss0+4],cl ;part of offset
mov [ebx+gdts+tss0+7],ch ;part of offset
mov [ebx+gdts+tss0+5],word 01010000b*256+11101001b ;system flags
mov [ebx+REG_RET], dword irq0.return
mov [ebx+REG_EDI], eax
mov [ebx+REG_ESI], eax
mov [ebx+REG_EBP], eax
mov [ebx+REG_ESP], ecx ;ebx+REG_EIP
mov [ebx+REG_EBX], eax
mov [ebx+REG_EDX], eax
mov [ebx+REG_ECX], eax
mov [ebx+REG_EAX], eax
mov eax, [esi+0x08] ;app_eip
mov [ebx+REG_EIP], eax ;app_entry
mov [ebx+REG_CS], dword app_code
mov [ebx+REG_EFLAGS], dword EFL_IOPL1+EFL_IF
mov eax, [esi+0x0C] ;app_esp
mov [ebx+REG_APP_ESP], eax ;app_stack
mov [ebx+REG_SS], dword app_data
lea ecx, [ebx+REG_RET]
mov ebx, [slot]
shl ebx, 8
mov [ebx+SLOT_BASE+APPDATA.saved_esp], ecx
;flush keyboard and buttons queue
mov [KEY_COUNT],byte 0
@ -1121,13 +1066,5 @@ proc set_app_params stdcall,slot:dword, params:dword,\
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

58
kernel/trunk/data16.inc Normal file
View File

@ -0,0 +1,58 @@
$Revision$
flm db 0
preboot_lfb db 0
preboot_bootlog db 0
align 4
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
fwmovedesc:
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0xff,0xff,0x0,0x00,0x10,0x93,0x0,0x0
db 0xff,0xff,0x0,0xa0,0x00,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

338
kernel/trunk/data32.inc Normal file
View File

@ -0,0 +1,338 @@
$Revision$
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
kernel_file db 'KERNEL MNT'
; 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+(new_app_base shr 16)+0xF;
app_data_l:
dw 0xFFFF
dw 0
db 0
db drw3
dw G32+D32+(new_app_base shr 16)+0xF;
; --------------- 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:
dw TSS_SIZE-1
dw tss and 0xFFFF
db (tss shr 16) and 0xFF
db 10001001b
dw (tss shr 16) and 0xFF00
endofcode:
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_seg 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
default_io_map rd 1
LFBSize rd 1
stall_mcs rd 1
current_slot 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_active rd 1
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

View File

@ -25,7 +25,7 @@ Detect_COM_Mouse:
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]
@ -47,7 +47,7 @@ Detect_COM_Mouse:
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]

View File

@ -10,16 +10,18 @@ format MS COFF
include 'proc32.inc'
include 'imports.inc'
DEBUG equ 1
API_VERSION equ 0x01000100
VID_ATI equ 0x1002
DEBUG equ 1
VID_ATI equ 0x1002
LOAD_FROM_FILE equ 0
LOAD_FROM_MEM equ 1
LOAD_INDIRECT equ 2
LOAD_SYSTEM equ 3
VIDEO_FREE equ 2
SRV_GETVERSION equ 0
struc BITMAPINFOHEADER {
.biSize dd ? ; DWORD
@ -71,9 +73,8 @@ R9800 equ 0x4E49 ;R350
R9800P equ 0x4E48 ;R350
R9800XT equ 0x4E4A ;R360
OS_BASE equ 0
new_app_base equ 0x80000000
SLOT_BASE equ 0x0080000
OS_BASE equ 0x80000000
SLOT_BASE equ (OS_BASE+0x0080000)
PG_SW equ 0x003
PG_NOCACHE equ 0x018
@ -230,13 +231,16 @@ out_size equ IOCTL.out_size
align 4
proc service_proc stdcall, ioctl:dword
mov edi, [ioctl]
mov ebx, [edi+io_code]
cmp ebx, VIDEO_FREE
mov ebx, [ioctl]
cmp [ebx+io_code], SRV_GETVERSION
jne .fail
mov eax, [edi+input]
call video_free
mov eax, [ebx+output]
cmp [ebx+out_size], 4
jne .fail
mov [eax], dword API_VERSION
xor eax, eax
ret
.fail:
or eax, -1
ret
@ -987,7 +991,7 @@ devices dd (R8500 shl 16)+VID_ATI
dd (R9800XT shl 16)+VID_ATI
dd 0 ;terminator
version dd 0x00040004
version dd (5 shl 16) or (API_VERSION and 0xFFFF)
sz_ati_srv db 'HWCURSOR',0

View File

@ -257,9 +257,9 @@ end virtual
EVENT_NOTIFY equ 0x00000200
OS_BASE equ 0;
OS_BASE equ 0x80000000
SLOT_BASE equ OS_BASE+0x0080000
new_app_base equ 0x80000000
new_app_base equ 0
public START
public service_proc
@ -391,7 +391,6 @@ proc service_proc stdcall, ioctl:dword
cmp eax, DEV_GET_MASTERVOL
jne @F
mov ebx, [edi+output]
add ebx, new_app_base
stdcall get_master_vol, ebx
ret
;@@:

View File

@ -10,6 +10,10 @@
format MS COFF
API_VERSION equ 0x01000100
SOUND_VERSION equ API_VERSION
include 'proc32.inc'
include 'main.inc'
include 'imports.inc'
@ -22,9 +26,10 @@ FORCE_MMX_128 equ 0 ;integer sse2 extensions
DEBUG equ 1
OS_BASE equ 0
new_app_base equ 0x80000000
SLOT_BASE equ OS_BASE+0x0080000
OS_BASE equ 0x80000000
SLOT_BASE equ (OS_BASE+0x0080000)
TASK_COUNT equ (OS_BASE+0x0003004)
CURRENT_TASK equ (OS_BASE+0x0003000)
CAPS_SSE2 equ 26
PG_SW equ 0x003
@ -159,8 +164,10 @@ proc service_proc stdcall, ioctl:dword
cmp eax, SRV_GETVERSION
jne @F
mov eax, [edi+output]
cmp [edi+out_size], 4
jne .fail
mov eax, [eax]
mov [eax+new_app_base], dword SOUND_VERSION
mov [eax], dword SOUND_VERSION
xor eax, eax
ret
@@:
@ -172,7 +179,7 @@ proc service_proc stdcall, ioctl:dword
pop edi
mov ecx, [edi+output]
mov ecx, [ecx]
mov [ecx+new_app_base], ebx
mov [ecx], ebx
ret
@@:
mov ebx, [edi+input]
@ -201,7 +208,7 @@ proc service_proc stdcall, ioctl:dword
movzx eax, word [edx+STREAM.format]
mov ecx, [edi+output]
mov ecx, [ecx]
mov [ecx+new_app_base], eax
mov [ecx], eax
xor eax, eax
ret
@@:
@ -222,13 +229,12 @@ proc service_proc stdcall, ioctl:dword
pop edi
mov ecx, [edi+output]
mov ecx, [ecx]
mov [ecx+new_app_base], ebx
mov [ecx], ebx
ret
@@:
cmp eax, SND_SETBUFF
jne @F
mov eax, [ebx+4]
add eax, new_app_base
stdcall set_buffer, [ebx],eax,[ebx+8],[ebx+12]
ret
@@:
@ -243,8 +249,6 @@ proc service_proc stdcall, ioctl:dword
mov eax, [edi+output]
mov ecx, [eax]
mov eax, [eax+4]
add ecx, new_app_base
add eax, new_app_base
stdcall GetBufferVol,[ebx],ecx,eax
ret
@@:
@ -258,7 +262,7 @@ proc service_proc stdcall, ioctl:dword
mov eax, [edx+STREAM.pan]
mov ebx, [edi+output]
mov ebx, [ebx]
mov [ebx+new_app_base], eax
mov [ebx], eax
xor eax, eax
ret
@@:
@ -266,7 +270,6 @@ proc service_proc stdcall, ioctl:dword
jne @F
mov eax, [ebx+4]
add eax, new_app_base
stdcall wave_out, [ebx],eax,[ebx+8]
ret
@@:
@ -287,7 +290,7 @@ proc service_proc stdcall, ioctl:dword
mov eax, [edx+STREAM.in_size]
mov ecx, [edi+output]
mov ecx, [ecx]
mov [ecx+new_app_base], eax
mov [ecx], eax
xor eax, eax
ret
@@:
@ -303,10 +306,6 @@ restore inp_size
restore output
restore out_size
TASK_COUNT equ 0x0003004
CURRENT_TASK equ 0x0003000
align 4
proc CreateBuffer stdcall, format:dword, size:dword
locals
@ -377,17 +376,17 @@ proc CreateBuffer stdcall, format:dword, size:dword
; ring and waveout
mov eax, 0x10000
mov ebx, 0x10000
test [format], PCM_RING
jz .waveout
mov eax, [eax+STREAM.r_size]
add eax, 4095
and eax, -4096
add eax, eax
mov ebx, [eax+STREAM.r_size]
add ebx, 4095
and ebx, -4096
add ebx, ebx
.waveout:
mov [ring_size], eax
mov ebx, eax
mov [ring_size], ebx
mov eax, ebx
shr ebx, 12
mov [ring_pages], ebx
@ -648,8 +647,8 @@ proc wave_out stdcall, str:dword,src:dword,size:dword
test esi, esi
jz .fail
cmp esi, new_app_base
jb .fail
cmp esi, OS_BASE
ja .fail
mov [state_saved], 0
@ -1252,7 +1251,7 @@ vol_min dd 0x0000D8F0,0x0000D8F0
pan_max dd 0x00002710,0x00002710
;stream_map dd 0xFFFF ; 16
version dd (4 shl 16) or (SOUND_VERSION and 0xFFFF)
version dd (5 shl 16) or (SOUND_VERSION and 0xFFFF)
szInfinity db 'INFINITY',0
szSound db 'SOUND',0
@ -1284,3 +1283,8 @@ mix_2_core rd 1
mix_3_core rd 1
mix_4_core rd 1

View File

@ -8,11 +8,9 @@
; (C) copyright Serge 2006-2007
; email: infinity_sound@mail.ru
SOUND_VERSION equ 0x01000100
PLAY_SYNC equ 0x80000000
PCM_ALL equ 0
PCM_OUT equ 0x08000000

View File

@ -9,6 +9,8 @@
format MS COFF
API_VERSION equ 0 ;debug
include 'proc32.inc'
include 'imports.inc'
@ -33,11 +35,13 @@ public START
public service_proc
public version
DEBUG equ 1
DEBUG equ 1
DRV_ENTRY equ 1
DRV_EXIT equ -1
STRIDE equ 4 ;size of row in devices table
DRV_ENTRY equ 1
DRV_EXIT equ -1
STRIDE equ 4 ;size of row in devices table
SRV_GETVERSION equ 0
section '.flat' code readable align 16
@ -53,7 +57,7 @@ proc START stdcall, state:dword
end if
stdcall RegService, my_service, service_proc
ret
ret
.fail:
.exit:
xor eax, eax
@ -70,11 +74,21 @@ out_size equ IOCTL.out_size
align 4
proc service_proc stdcall, ioctl:dword
; mov edi, [ioctl]
; mov eax, [edi+io_code]
mov ebx, [ioctl]
mov eax, [ebx+io_code]
cmp eax, SRV_GETVERSION
jne @F
xor eax, eax
ret
mov eax, [ebx+output]
cmp [ebx+out_size], 4
jne .fail
mov [eax], dword API_VERSION
xor eax, eax
ret
@@:
.fail:
or eax, -1
ret
endp
restore handle
@ -86,70 +100,70 @@ restore out_size
align 4
proc detect
locals
last_bus dd ?
endl
locals
last_bus dd ?
endl
xor eax, eax
mov [bus], eax
inc eax
xor eax, eax
mov [bus], eax
inc eax
call PciApi
cmp eax, -1
cmp eax, -1
je .err
mov [last_bus], eax
mov [last_bus], eax
.next_bus:
and [devfn], 0
and [devfn], 0
.next_dev:
stdcall PciRead32, [bus], [devfn], dword 0
test eax, eax
jz .next
cmp eax, -1
je .next
test eax, eax
jz .next
cmp eax, -1
je .next
mov edi, devices
mov edi, devices
@@:
mov ebx, [edi]
test ebx, ebx
jz .next
mov ebx, [edi]
test ebx, ebx
jz .next
cmp eax, ebx
je .found
cmp eax, ebx
je .found
add edi, STRIDE
jmp @B
.next: inc [devfn]
cmp [devfn], 256
jb .next_dev
mov eax, [bus]
inc eax
mov [bus], eax
cmp eax, [last_bus]
jna .next_bus
xor eax, eax
ret
.found:
xor eax, eax
.next:
inc [devfn]
cmp [devfn], 256
jb .next_dev
mov eax, [bus]
inc eax
ret
mov [bus], eax
cmp eax, [last_bus]
jna .next_bus
xor eax, eax
ret
.found:
xor eax, eax
inc eax
ret
.err:
xor eax, eax
ret
endp
;DEVICE_ID equ ; pci device id
;VENDOR_ID equ ; device vendor id
DEVICE_ID equ 1234; pci device id
VENDOR_ID equ 5678; device vendor id
;all initialized data place here
align 4
devices dd (DEVICE_ID shl 16)+VENDOR_ID
dd 0 ;terminator
devices dd (DEVICE_ID shl 16)+VENDOR_ID
dd 0 ;terminator
version dd 0x00030003
version dd (5 shl 16) or (API_VERSION and 0xFFFF)
my_service db 'MY_SERVICE',0 ;max 16 chars include zero

View File

@ -10,6 +10,8 @@ format MS COFF
include 'proc32.inc'
include 'imports.inc'
API_VERSION equ 0x01000100
DEBUG equ 1
CPU_FREQ equ 2000d ;cpu freq in MHz
@ -90,7 +92,7 @@ CTRL_CNT_GIE equ 0x00000001 ; GPI Interrupt Enable
CODEC_REG_POWERDOWN equ 0x26
CODEC_REG_ST equ 0x26
SRV_GETVERSION equ 0
DEV_PLAY equ 1
DEV_STOP equ 2
DEV_CALLBACK equ 3
@ -249,9 +251,8 @@ end virtual
EVENT_NOTIFY equ 0x00000200
OS_BASE equ 0; 0x80400000
OS_BASE equ 0x80000000
SLOT_BASE equ OS_BASE+0x0080000
new_app_base equ 0x80000000
public START
public service_proc
@ -341,6 +342,18 @@ proc service_proc stdcall, ioctl:dword
mov edi, [ioctl]
mov eax, [edi+io_code]
cmp eax, SRV_GETVERSION
jne @F
mov eax, [edi+output]
cmp [edi+out_size], 4
jne .fail
mov [eax], dword API_VERSION
xor eax, eax
ret
@@:
cmp eax, DEV_PLAY
jne @F
if DEBUG
@ -375,15 +388,14 @@ proc service_proc stdcall, ioctl:dword
cmp eax, DEV_GET_MASTERVOL
jne @F
mov ebx, [edi+output]
add ebx, new_app_base
stdcall get_master_vol, ebx
ret
@@:
cmp eax, DEV_GET_INFO
jne @F
mov ebx, [edi+output]
stdcall get_dev_info, ebx
ret
;@@:
; cmp eax, DEV_GET_INFO
; jne @F
; mov ebx, [edi+output]
; stdcall get_dev_info, ebx
; ret
@@:
.fail:
or eax, -1
@ -1138,7 +1150,7 @@ align 4
devices dd (CTRL_SIS shl 16)+VID_SIS,msg_AC, set_SIS
dd 0
version dd 0x00040004
version dd (5 shl 16) or (API_VERSION and 0xFFFF)
msg_AC db '7012 AC97 controller',13,10, 0
msg_SIS db 'Silicon Integrated Systems',13,10, 0

View File

@ -11,6 +11,8 @@ format MS COFF
include 'proc32.inc'
include 'imports.inc'
API_VERSION equ 0x01000100
DEBUG equ 1
REMAP_IRQ equ 0
@ -57,6 +59,9 @@ BIT29 EQU 0x20000000
BIT30 EQU 0x40000000
BIT31 EQU 0x80000000
PCM_4 equ BIT20
PCM_6 equ BIT21
VID_INTEL equ 0x8086
VID_NVIDIA equ 0x10DE
@ -90,16 +95,16 @@ PCM_IN_CR_REG equ 0x0b ; PCM in Control Register
MC_IN_CR_REG equ 0x2b ; MIC in Control Register
RR equ BIT1 ; reset registers. Nukes all regs
CODEC_MASTER_VOL_REG equ 0x02
CODEC_AUX_VOL equ 0x04 ;
CODEC_PCM_OUT_REG equ 18h ; PCM output volume
CODEC_EXT_AUDIO_REG equ 28h ; extended audio
CODEC_EXT_AUDIO_CTRL_REG equ 2ah ; extended audio control
CODEC_PCM_FRONT_DACRATE_REG equ 2ch ; PCM out sample rate
CODEC_PCM_SURND_DACRATE_REG equ 2eh ; surround sound sample rate
CODEC_PCM_LFE_DACRATE_REG equ 30h ; LFE sample rate
CODEC_MASTER_VOL_REG equ 0x02
CODEC_AUX_VOL equ 0x04 ;
CODEC_PCM_OUT_REG equ 0x18 ; PCM output volume
CODEC_EXT_AUDIO_REG equ 0x28 ; extended audio
CODEC_EXT_AUDIO_CTRL_REG equ 0x2a ; extended audio control
CODEC_PCM_FRONT_DACRATE_REG equ 0x2c ; PCM out sample rate
CODEC_PCM_SURND_DACRATE_REG equ 0x2e ; surround sound sample rate
CODEC_PCM_LFE_DACRATE_REG equ 0x30 ; LFE sample rate
GLOB_CTRL equ 0x2C ; Global Control
GLOB_CTRL equ 0x2C ; Global Control
CTRL_STAT equ 0x30 ; Global Status
CTRL_CAS equ 0x34 ; Codec Access Semiphore
@ -118,6 +123,7 @@ CTRL_CNT_GIE equ 0x00000001 ; GPI Interrupt Enable
CODEC_REG_POWERDOWN equ 0x26
CODEC_REG_ST equ 0x26
SRV_GETVERSION equ 0
DEV_PLAY equ 1
DEV_STOP equ 2
DEV_CALLBACK equ 3
@ -250,24 +256,24 @@ struc CODEC ;Audio Chip base class
}
struc CTRL_INFO
{ .pci_cmd dd ?
.irq dd ?
.glob_cntrl dd ?
.glob_sta dd ?
.codec_io_base dd ?
.ctrl_io_base dd ?
.codec_mem_base dd ?
.ctrl_mem_base dd ?
.codec_id dd ?
{ .pci_cmd dd ?
.irq dd ?
.glob_cntrl dd ?
.glob_sta dd ?
.codec_io_base dd ?
.ctrl_io_base dd ?
.codec_mem_base dd ?
.ctrl_mem_base dd ?
.codec_id dd ?
}
struc IOCTL
{ .handle dd ?
.io_code dd ?
.input dd ?
.inp_size dd ?
.output dd ?
.out_size dd ?
{ .handle dd ?
.io_code dd ?
.input dd ?
.inp_size dd ?
.output dd ?
.out_size dd ?
}
virtual at 0
@ -276,9 +282,8 @@ end virtual
EVENT_NOTIFY equ 0x00000200
OS_BASE equ 0;
OS_BASE equ 0x80000000
SLOT_BASE equ OS_BASE+0x0080000
new_app_base equ 0x80000000
public START
public service_proc
@ -358,6 +363,7 @@ proc START stdcall, state:dword
jnc .fail
stdcall AttachIntHandler, ebx, ac97_irq
.reg:
stdcall RegService, sz_sound_srv, service_proc
ret
.fail:
@ -385,6 +391,18 @@ proc service_proc stdcall, ioctl:dword
mov edi, [ioctl]
mov eax, [edi+io_code]
cmp eax, SRV_GETVERSION
jne @F
mov eax, [edi+output]
cmp [edi+out_size], 4
jne .fail
mov [eax], dword API_VERSION
xor eax, eax
ret
@@:
cmp eax, DEV_PLAY
jne @F
if DEBUG
@ -419,7 +437,6 @@ proc service_proc stdcall, ioctl:dword
cmp eax, DEV_GET_MASTERVOL
jne @F
mov ebx, [edi+output]
add ebx, new_app_base
stdcall get_master_vol, ebx
ret
;@@:
@ -872,6 +889,12 @@ proc init_codec
xor eax, eax ; timeout error
ret
.ready:
mov eax, 2 ;force set 16-bit 2-channel PCM
mov edx, GLOB_CTRL
call [ctrl.ctrl_write32]
mov eax, 5000 ; wait 5 ms
call StallExec
call detect_codec
xor eax, eax
@ -1357,7 +1380,8 @@ devices dd (CTRL_ICH shl 16)+VID_INTEL,msg_ICH, set_ICH
dd 0 ;terminator
version dd 0x00040004
version dd (5 shl 16) or (API_VERSION and 0xFFFF)
msg_ICH db 'Intel ICH', 13,10, 0
msg_ICH0 db 'Intel ICH0', 13,10, 0
@ -1415,5 +1439,3 @@ ctrl AC_CNTRL
lpc_bus rd 1
civ_val rd 1

View File

@ -0,0 +1,972 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
format MS COFF
include 'proc32.inc'
include 'imports.inc'
API_VERSION equ 0
UART_VERSION equ API_VERSION
PG_SW equ 0x003
page_tabs equ 0xFDC00000 ;hack
OS_BASE equ 0x80000000
SLOT_BASE equ (OS_BASE+0x0080000)
TASK_COUNT equ (OS_BASE+0x0003004)
CURRENT_TASK equ (OS_BASE+0x0003000)
struc APPOBJ ;common object header
{
.magic dd ? ;
.destroy dd ? ;internal destructor
.fd dd ? ;next object in list
.bk dd ? ;prev object in list
.pid dd ? ;owner id
};
virtual at 0
APPOBJ APPOBJ
end virtual
struc IOCTL
{ .handle dd ?
.io_code dd ?
.input dd ?
.inp_size dd ?
.output dd ?
.out_size dd ?
}
virtual at 0
IOCTL IOCTL
end virtual
DEBUG equ 1
DRV_ENTRY equ 1
DRV_EXIT equ -1
THR_REG equ 0; x3f8 ;transtitter/reciever
IER_REG equ 1; x3f9 ;interrupt enable
IIR_REG equ 2; x3fA ;interrupt info
LCR_REG equ 3; x3FB ;line control
MCR_REG equ 4; x3FC ;modem control
LSR_REG equ 5; x3FD ;line status
MSR_REG equ 6; x3FE ;modem status
LCR_5BIT equ 0x00
LCR_6BIT equ 0x01
LCR_7BIT equ 0x02
LCR_8BIT equ 0x03
LCR_STOP_1 equ 0x00
LCR_STOP_2 equ 0x04
LCR_PARITY equ 0x08
LCR_EVEN equ 0x10
LCR_STICK equ 0x20
LCR_BREAK equ 0x40
LCR_DLAB equ 0x80
LSR_DR equ 0x01 ;data ready
LSR_OE equ 0x02 ;overrun error
LSR_PE equ 0x04 ;parity error
LSR_FE equ 0x08 ;framing error
LSR_BI equ 0x10 ;break interrupt
LSR_THRE equ 0x20 ;transmitter holding empty
LSR_TEMT equ 0x40 ;transmitter empty
LSR_FER equ 0x80 ;FIFO error
FCR_EFIFO equ 0x01 ;enable FIFO
FCR_CRB equ 0x02 ;clear reciever FIFO
FCR_CXMIT equ 0x04 ;clear transmitter FIFO
FCR_RDY equ 0x08 ;set RXRDY and TXRDY pins
FCR_FIFO_1 equ 0x00 ;1 byte trigger
FCR_FIFO_4 equ 0x40 ;4 bytes trigger
FCR_FIFO_8 equ 0x80 ;8 bytes trigger
FCR_FIFO_14 equ 0xC0 ;14 bytes trigger
IIR_INTR equ 0x01 ;1= no interrupts
IER_RDAI equ 0x01 ;reciever data interrupt
IER_THRI equ 0x02 ;transmitter empty interrupt
IER_LSI equ 0x04 ;line status interrupt
IER_MSI equ 0x08 ;modem status interrupt
MCR_DTR equ 0x01 ;0-> DTR=1, 1-> DTR=0
MCR_RTS equ 0x02 ;0-> RTS=1, 1-> RTS=0
MCR_OUT_1 equ 0x04 ;0-> OUT1=1, 1-> OUT1=0
MCR_OUT_2 equ 0x08 ;0-> OUT2=1, 1-> OUT2=0; enable intr
MCR_LOOP equ 0x10 ;lopback mode
MSR_DCTS equ 0x01 ;delta clear to send
MSR_DDSR equ 0x02 ;delta data set redy
MSR_TERI equ 0x04 ;trailinh edge of ring
MSR_DDCD equ 0x08 ;delta carrier detect
RATE_50 equ 0
RATE_75 equ 1
RATE_110 equ 2
RATE_134 equ 3
RATE_150 equ 4
RATE_300 equ 5
RATE_600 equ 6
RATE_1200 equ 7
RATE_1800 equ 8
RATE_2000 equ 9
RATE_2400 equ 10
RATE_3600 equ 11
RATE_4800 equ 12
RATE_7200 equ 13
RATE_9600 equ 14
RATE_19200 equ 15
RATE_38400 equ 16
RATE_57600 equ 17
RATE_115200 equ 18
COM_1 equ 1
COM_2 equ 2
COM_3 equ 3
COM_4 equ 4
COM_MAX equ 2 ;only two port supported
COM_1_BASE equ 0x3F8
COM_2_BASE equ 0x2F8
COM_1_IRQ equ 4
COM_2_IRQ equ 3
UART_CLOSED equ 0
UART_TRANSMIT equ 1
UART_STOP equ 2
struc UART
{
.lock dd ?
.base dd ?
.lcr_reg dd ?
.mcr_reg dd ?
.rate dd ?
.mode dd ?
.state dd ?
.rcvr_buff dd ?
.rcvr_rp dd ?
.rcvr_wp dd ?
.rcvr_count dd ?
.rcvr_top dd ?
.xmit_buff dd ?
.xmit_rp dd ?
.xmit_wp dd ?
.xmit_count dd ?
.xmit_free dd ?
.xmit_top dd ?
}
virtual at 0
UART UART
end virtual
UART_SIZE equ 18*4
struc CONNECTION
{
.magic dd ? ;'CNCT'
.destroy dd ? ;internal destructor
.fd dd ? ;next object in list
.bk dd ? ;prev object in list
.pid dd ? ;owner id
.id dd ? ;reserved
.uart dd ? ;uart pointer
}
virtual at 0
CONNECTION CONNECTION
end virtual
CONNECTION_SIZE equ 7*4
public START
public service_proc
public version
section '.flat' code readable align 16
proc START stdcall, state:dword
cmp [state], 1
jne .stop
mov eax, UART_SIZE
call Kmalloc
test eax, eax
jz .fail
mov [com1], eax
mov edi, eax
mov ecx, UART_SIZE/4
xor eax, eax
cld
rep stosd
mov eax, [com1]
mov [eax+UART.base], COM_1_BASE
stdcall AllocKernelSpace, 32768
mov edi, [com1]
mov edx, eax
mov [edi+UART.rcvr_buff], eax
add eax, 8192
mov [edi+UART.rcvr_top], eax
add eax, 8192
mov [edi+UART.xmit_buff], eax
add eax, 8192
mov [edi+UART.xmit_top], eax
call AllocPage
test eax, eax
jz .fail
shr edx, 12
or eax, PG_SW
mov [page_tabs+edx*4], eax
mov [page_tabs+edx*4+8], eax
call AllocPage
test eax, eax
jz .fail
or eax, PG_SW
mov [page_tabs+edx*4+4], eax
mov [page_tabs+edx*4+12], eax
call AllocPage
test eax, eax
jz .fail
or eax, PG_SW
mov [page_tabs+edx*4+16], eax
mov [page_tabs+edx*4+24], eax
call AllocPage
test eax, eax
jz .fail
or eax, PG_SW
mov [page_tabs+edx*4+20], eax
mov [page_tabs+edx*4+28], eax
mov eax, [edi+UART.rcvr_buff]
invlpg [eax]
invlpg [eax+0x1000]
invlpg [eax+0x2000]
invlpg [eax+0x3000]
invlpg [eax+0x4000]
invlpg [eax+0x5000]
invlpg [eax+0x6000]
invlpg [eax+0x7000]
mov eax, edi
call uart_reset.internal ;eax= uart
stdcall AttachIntHandler, COM_1_IRQ, com_1_isr
stdcall RegService, sz_uart_srv, service_proc
ret
.fail:
.stop:
xor eax, eax
ret
endp
handle equ IOCTL.handle
io_code equ IOCTL.io_code
input equ IOCTL.input
inp_size equ IOCTL.inp_size
output equ IOCTL.output
out_size equ IOCTL.out_size
SRV_GETVERSION equ 0
PORT_OPEN equ 1
PORT_CLOSE equ 2
PORT_RESET equ 3
PORT_SETMODE equ 4
PORT_GETMODE equ 5
PORT_SETMCR equ 6
PORT_GETMCR equ 7
PORT_READ equ 8
PORT_WRITE equ 9
align 4
proc service_proc stdcall, ioctl:dword
mov ebx, [ioctl]
mov eax, [ebx+io_code]
cmp eax, PORT_WRITE
ja .fail
cmp eax, SRV_GETVERSION
jne @F
mov eax, [ebx+output]
cmp [ebx+out_size], 4
jne .fail
mov [eax], dword UART_VERSION
xor eax, eax
ret
@@:
cmp eax, PORT_OPEN
jne @F
cmp [ebx+out_size], 4
jne .fail
mov ebx, [ebx+input]
mov eax, [ebx]
call uart_open
mov ebx, [ioctl]
mov ebx, [ebx+output]
mov [ebx], ecx
ret
@@:
mov esi, [ebx+input] ;input buffer
mov edi, [ebx+output]
call [uart_func+eax*4]
ret
.fail:
or eax, -1
ret
endp
restore handle
restore io_code
restore input
restore inp_size
restore output
restore out_size
; param
; esi= input buffer
; +0 connection
;
; retval
; eax= error code
align 4
uart_reset:
mov eax, [esi]
cmp [eax+APPOBJ.magic], 'CNCT'
jne .fail
cmp [eax+APPOBJ.destroy], uart_close.destroy
jne .fail
mov eax, [eax+CONNECTION.uart]
test eax, eax
jz .fail
; set mode 2400 bod 8-bit
; disable DTR & RTS
; clear FIFO
; clear pending interrupts
;
; param
; eax= uart
align 4
.internal:
mov esi, eax
mov [eax+UART.state], UART_CLOSED
mov edx, [eax+UART.base]
add edx, MCR_REG
xor eax, eax
out dx, al ;clear DTR & RTS
mov eax, esi
mov ebx, RATE_2400
mov ecx, LCR_8BIT+LCR_STOP_1
call uart_set_mode.internal
mov edx, [esi+UART.base]
add edx, IIR_REG
mov eax,FCR_EFIFO+FCR_CRB+FCR_CXMIT+FCR_FIFO_14
out dx, al
.clear_RB:
mov edx, [esi+UART.base]
add edx, LSR_REG
in al, dx
test eax, LSR_DR
jz @F
mov edx, [esi+UART.base]
in al, dx
jmp .clear_RB
@@:
mov edx, [esi+UART.base]
add edx, IER_REG
mov eax,IER_RDAI+IER_THRI+IER_LSI
out dx, al
.clear_IIR:
mov edx, [esi+UART.base]
add edx, IIR_REG
in al, dx
test al, IIR_INTR
jnz .done
shr eax, 1
and eax, 3
jnz @F
mov edx, [esi+UART.base]
add edx, MSR_REG
in al, dx
jmp .clear_IIR
@@:
cmp eax, 1
je .clear_IIR
cmp eax, 2
jne @F
mov edx, [esi+UART.base]
in al, dx
jmp .clear_IIR
@@:
mov edx, [esi+UART.base]
add edx, LSR_REG
in al, dx
jmp .clear_IIR
.done:
mov edi, [esi+UART.rcvr_buff]
mov ecx, 8192/4
xor eax, eax
mov [esi+UART.rcvr_rp], edi
mov [esi+UART.rcvr_wp], edi
mov [esi+UART.rcvr_count], eax
cld
rep stosd
mov edi, [esi+UART.xmit_buff]
mov ecx, 8192/4
mov [esi+UART.xmit_rp], edi
mov [esi+UART.xmit_wp], edi
mov [esi+UART.xmit_count], eax
mov [esi+UART.xmit_free], 8192
rep stosd
ret ;eax= 0
.fail:
or eax, -1
ret
; param
; esi= input buffer
; +0 connection
; +4 rate
; +8 mode
;
; retval
; eax= error code
align 4
uart_set_mode:
mov eax, [esi]
cmp [eax+APPOBJ.magic], 'CNCT'
jne .fail
cmp [eax+APPOBJ.destroy], uart_close.destroy
jne .fail
mov eax, [eax+CONNECTION.uart]
test eax, eax
jz .fail
mov ebx, [esi+4]
mov ecx, [esi+8]
; param
; eax= uart
; ebx= baud rate
; ecx= mode
align 4
.internal:
cmp ebx, RATE_115200
ja .fail
cmp ecx, LCR_BREAK
jae .fail
mov [eax+UART.rate], ebx
mov [eax+UART.mode], ecx
mov esi, eax
mov bx, [divisor+ebx*2]
mov edx, [esi+UART.base]
push edx
add edx, LCR_REG
in al, dx
or al, 0x80
out dx, al
pop edx
mov al, bl
out dx, al
inc dx
mov al, bh
out dx, al
add edx, LCR_REG-1
mov eax, ecx
out dx, al
xor eax, eax
ret
.fail:
or eax, -1
ret
; param
; esi= input buffer
; +0 connection
; +4 modem control reg valie
;
; retval
; eax= error code
align 4
uart_set_mcr:
mov eax, [esi]
cmp [eax+APPOBJ.magic], 'CNCT'
jne .fail
cmp [eax+APPOBJ.destroy], uart_close.destroy
jne .fail
mov eax, [eax+CONNECTION.uart]
test eax, eax
jz .fail
mov ebx, [esi+4]
mov [eax+UART.mcr_reg], ebx
mov edx, [eax+UART.base]
add edx, MCR_REG
mov al, bl
out dx, al
xor eax, eax
ret
.fail:
or eax, -1
ret
; param
; eax= port
;
; retval
; ecx= connection
; eax= error code
align 4
uart_open:
dec eax
cmp eax, COM_MAX
jae .fail
mov esi, [com1+eax*4] ;uart
push esi
.do_wait:
cmp dword [esi+UART.lock],0
je .get_lock
; call change_task
jmp .do_wait
.get_lock:
mov eax, 1
xchg eax, [esi+UART.lock]
test eax, eax
jnz .do_wait
mov eax, esi ;uart
call uart_reset.internal
mov ebx, [CURRENT_TASK]
shl ebx, 5
mov ebx, [CURRENT_TASK+ebx+4]
mov eax, CONNECTION_SIZE
call CreateObject
pop esi ;uart
test eax, eax
jz .fail
mov [eax+APPOBJ.magic], 'CNCT'
mov [eax+APPOBJ.destroy], uart_close.destroy
mov [eax+CONNECTION.uart], esi
mov ecx, eax
xor eax, eax
ret
.fail:
or eax, -1
ret
restore .uart
; param
; esi= input buffer
align 4
uart_close:
mov eax, [esi]
cmp [eax+APPOBJ.magic], 'CNCT'
jne .fail
cmp [eax+APPOBJ.destroy], uart_close.destroy
jne .fail
.destroy:
push [eax+CONNECTION.uart]
call DestroyObject ;eax= object
pop eax ;eax= uart
test eax, eax
jz .fail
mov [eax+UART.state], UART_CLOSED
mov [eax+UART.lock], 0 ;release port
xor eax, eax
ret
.fail:
or eax, -1
ret
; param
; eax= uart
; ebx= baud rate
align 4
set_rate:
cmp ebx, RATE_115200
ja .fail
mov [eax+UART.rate], ebx
mov bx, [divisor+ebx*2]
mov edx, [eax+UART.base]
add edx, LCR_REG
in al, dx
push eax
or al, 0x80
out dx, al
sub edx, LCR_REG
mov al, bl
out dx, al
inc edx
mov al, bh
out dx, al
pop eax
add edx, LCR_REG-1
out dx, al
.fail:
ret
; param
; ebx= uart
align 4
transmit:
push esi
push edi
mov edx, [ebx+UART.base]
pushfd
cli
mov esi, [ebx+UART.xmit_rp]
mov ecx, [ebx+UART.xmit_count]
test ecx, ecx
je .stop
cmp ecx, 16
jbe @F
mov ecx, 16
@@:
sub [ebx+UART.xmit_count], ecx
add [ebx+UART.xmit_free], ecx
cld
@@:
lodsb
out dx, al
dec ecx
jnz @B
cmp esi,[ebx+UART.xmit_top]
jb @F
sub esi, 8192
@@:
mov [ebx+UART.xmit_rp], esi
cmp [ebx+UART.xmit_count], 0
je .stop
mov [ebx+UART.state], UART_TRANSMIT
jmp @F
.stop:
mov [ebx+UART.state], UART_STOP
@@:
popfd
pop edi
pop esi
ret
; param
; esi= input buffer
; +0 connection
; +4 dst buffer
; +8 dst size
; edi= output buffer
; +0 bytes read
; retval
; eax= error code
align 4
uart_read:
mov eax, [esi]
cmp [eax+APPOBJ.magic], 'CNCT'
jne .fail
cmp [eax+APPOBJ.destroy], uart_close.destroy
jne .fail
mov eax, [eax+CONNECTION.uart]
test eax, eax
jz .fail
mov ebx, [esi+8] ;dst size
mov ecx, [eax+UART.rcvr_count]
cmp ecx, ebx
jbe @F
mov ecx, ebx
@@:
mov [edi], ecx ;bytes read
test ecx, ecx
jz .done
push ecx
mov edi, [esi+4] ;dst
mov esi, [eax+UART.rcvr_rp]
cld
rep movsb
pop ecx
cmp esi, [eax+UART.rcvr_top]
jb @F
sub esi, 8192
@@:
mov [eax+UART.rcvr_rp], esi
sub [eax+UART.rcvr_count], ecx
.done:
xor eax, eax
ret
.fail:
or eax, -1
ret
; param
; esi= input buffer
; +0 connection
; +4 src buffer
; +8 src size
;
; retval
; eax= error code
align 4
uart_write:
mov eax, [esi]
cmp [eax+APPOBJ.magic], 'CNCT'
jne .fail
cmp [eax+APPOBJ.destroy], uart_close.destroy
jne .fail
mov eax, [eax+CONNECTION.uart]
test eax, eax
jz .fail
mov ebx, [esi+4]
mov edx, [esi+8]
; param
; eax= uart
; ebx= src
; edx= count
align 4
.internal:
mov esi, ebx
mov edi, [eax+UART.xmit_wp]
.write:
test edx, edx
jz .fail
.wait:
cmp [eax+UART.xmit_free], 0
jne .fill
cmp [eax+UART.state], UART_TRANSMIT
je .wait
mov ebx, eax
push edx
call transmit
pop edx
mov eax, ebx
jmp .write
.fill:
mov ecx, [eax+UART.xmit_free]
cmp ecx, edx
jbe @F
mov ecx, edx
@@:
push ecx
cld
rep movsb
pop ecx
sub [eax+UART.xmit_free], ecx
add [eax+UART.xmit_count], ecx
sub edx, ecx
jnz .wait
.done:
cmp edi, [eax+UART.xmit_top]
jb @F
sub edi, 8192
@@:
mov [eax+UART.xmit_wp], edi
cmp [eax+UART.state], UART_TRANSMIT
je @F
mov ebx, eax
call transmit
@@:
xor eax, eax
ret
.fail:
or eax, -1
ret
align 4
com_2_isr:
mov ebx, [com2]
jmp com_1_isr.get_info
align 4
com_1_isr:
mov ebx, [com1]
.get_info:
mov edx, [ebx+UART.base]
add edx, IIR_REG
in al, dx
test al, IIR_INTR
jnz .done
shr eax, 1
and eax, 3
call [isr_action+eax*4]
jmp .get_info
.done:
ret
align 4
isr_line:
mov edx, [ebx+UART.base]
add edx, LSR_REG
in al, dx
ret
align 4
isr_recieve:
mov esi, [ebx+UART.base]
add esi, LSR_REG
mov edi, [ebx+UART.rcvr_wp]
xor ecx, ecx
cld
.read:
mov edx, esi
in al, dx
test eax, LSR_DR
jz .done
mov edx, [ebx+UART.base]
in al, dx
stosb
inc ecx
jmp .read
.done:
cmp edi, [ebx+UART.rcvr_top]
jb @F
sub edi, 8192
@@:
mov [ebx+UART.rcvr_wp], edi
add [ebx+UART.rcvr_count], ecx
ret
align 4
isr_modem:
mov edx, [ebx+UART.base]
add edx, MSR_REG
in al, dx
ret
align 4
divisor dw 2304, 1536, 1047, 857, 768, 384
dw 192, 96, 64, 58, 48, 32
dw 24, 16, 12, 6, 3, 2, 1
align 4
uart_func dd 0 ;SRV_GETVERSION
dd 0 ;PORT_OPEN
dd uart_close ;PORT_CLOSE
dd uart_reset ;PORT_RESET
dd uart_set_mode ;PORT_SETMODE
dd 0 ;PORT_GETMODE
dd uart_set_mcr ;PORT_SETMODEM
dd 0 ;PORT_GETMODEM
dd uart_read ;PORT_READ
dd uart_write ;PORT_WRITE
isr_action dd isr_modem
dd transmit
dd isr_recieve
dd isr_line
version dd (5 shl 16) or (UART_VERSION and 0xFFFF)
sz_uart_srv db 'UART',0
align 4
com1 rd 1
com2 rd 1

View File

@ -0,0 +1,736 @@
;
; MenuetOS Driver (vmode.mdr)
; Target: Vertical Refresh Rate programming and videomode changing
;
; Author: Trans <<<<<13>>>>>
; Date: 20.07.2003
;
; Version: 1.0
; OS: MenuetOS
; Compiler: FASM
;
OS_BASE equ 0x80000000
use32
macro align value { rb (value-1) - ($ + value-1) mod value }
org 0x80760000
headerstart=$
mdid db 'MDAZ' ; 4 byte id
mdhver dd 0x00 ; header version
mdcode dd MDSTART ; start of code
mdver dd 0x00000001 ; driver version (subversion*65536+version)
mdname db 'Trans VideoDriver' ; 32 bytes of full driver name
times (32-($-mdname)) db ' ' ;
headerlen=$-headerstart
times (256-headerlen) db 0 ; reserved area for future
MDSTART: ; start of driver code ( base_adr+256 bytes)
; ebx(=ecx in program):
; 1 - Get DriverInfo and Driver Initial Set
; 2 - Get Current Video Mode With Vertical Refresh Rate
; 3 - Change Video Mode
; 4 - Return at Start System Video Mode
; 5 - Change vertical and horizontal size of visible screen area
; 6 - Change Vert/Hor position visible area on screen (not complete yet)
;
; MAXF - ...
MAXF=5
;-------Main Manager-------------
pushad
cmp ebx,1
jb mdvm_00
cmp ebx,MAXF
ja mdvm_00
shl ebx,2
add ebx,mdvm_func_table
call dword [ebx]
mov [esp+28],eax
mov [esp+24],ecx
mov [esp+20],edx
mov [esp+16],ebx
popad
retn
mdvm_00:
popad
xor eax,eax
dec eax
retn
; ------Drivers Functions----------
align 4
; EBX=1 (in applications ECX=1)- Get DriverInfo and Driver Initial Set
;
; IN: ecx (in app. edx) - pointer to 512-bytes info area in application
; OUT:
;
vm_info_init:
push ecx
cmp [mdrvm],dword 0
jnz .vmii_00
call vm_safe_reg
call vm_get_initial_videomode
mov eax,[initvm]
mov [currvm],eax
call vm_search_sys_func_table
call vm_get_cur_vert_rate
mov [initrr],eax
call vm_calc_pixelclock
call vm_calc_refrate
inc [mdrvm]
.vmii_00:
pop ecx
call vm_transfer_drv_info
mov ebx,dword [refrate]
mov eax,dword [mdid] ;dword [systlb]
retn
align 4
; EBX=2 (in applications ECX=2)- Get Current Video Mode
;
; OUT: eax = X_screen*65536+Y_screen
; ebx = current vertical rate
; ecx = current video mode (number)
vm_get_cur_mode:
cmp [mdrvm],dword 0
jz .vmgcm_00
call vm_get_cur_vert_rate
mov eax,[OS_BASE+0FE00h]
mov ebx,[OS_BASE+0FE04h]
shl eax,16
add eax,ebx
add eax,00010001h
mov ebx,[refrate]
mov ecx,[currvm]
retn
.vmgcm_00:
xor eax,eax
dec eax
retn
align 4
; EBX=3 (in applications ECX=3)- Change Video Mode
;
; IN: ecx = VertRate*65536+VideoMode
; OUT: eax = 0 if no error
;
vm_set_video_mode:
cmp [mdrvm],dword 0
jz .vmsvm_00
call vm_set_selected_mode
; xor eax,eax
retn
.vmsvm_00:
xor eax,eax
dec eax
retn
align 4
; EBX=4 (in applications ECX=4)- Return at Start System Video Mode
;
; IN:
; OUT: eax = = 0 if no error
;
vm_restore_init_video_mode:
cmp [mdrvm],dword 0
jz .vmrivm_00
call vm_restore_reg
xor eax,eax
retn
.vmrivm_00:
xor eax,eax
dec eax
retn
align 4
; EBX=5 (in applications ECX=5)- Change vertical and horizontal size
; of visible screen area
; IN: ecx (in app. edx) = 0/1 - -/+ horizontal size on 1 position
; = 2/3 - -/+ vertical size on 1 position (8 pixels)
; ^-^----- not complete yet
; OUT: eax = = 0 if no error
;
vm_change_screen_size:
cmp [mdrvm],dword 0
jz .vmcss_00
cmp cl,1
ja .vmcss_01
mov eax,ecx
call vm_inc_dec_width
xor eax,eax
retn
.vmcss_01:
and ecx,01h
mov eax,ecx
; call vm_inc_dec_high ; not complete yet
xor eax,eax
retn
.vmcss_00:
xor eax,eax
dec eax
retn
align 4
; EBX=6 (in applications ECX=6)- Change Vert/Hor position visible area on screen
;
; IN: ecx (in app. edx) = 0/1 - -/+ horizontal position on 1 point
; = 2/3 - -/+ vertical position on 1 pixel
; ^-^----- not complete yet
; OUT: eax = 0 if no error
;
vm_change_position_screen:
cmp [mdrvm],dword 0
jz .vmcps_00
; ...
xor eax,eax
retn
.vmcps_00:
xor eax,eax
dec eax
retn
;-----Drivers Subfunctions---------
;
; Searching i40 system functions pointer table in kernel area location
;
vm_search_sys_func_table:
push eax ; eax - current value
push ecx ; ecx - will be counter of equevalent value
push edx ; edx - last value
push esi ; esi - current address
xor ecx,ecx
mov esi,OS_BASE+010000h ; Start address of kernel location
lodsd
mov edx,eax
cld
.vmssft_00:
cmp esi,OS_BASE+30000h
ja .vmssft_03
inc ecx
lodsd
cmp edx,eax
mov edx,eax
je .vmssft_00
cmp ecx,128
ja .vmssft_02
.vmssft_01:
xor ecx,ecx
jmp .vmssft_00
.vmssft_02:
cmp edx,0
je .vmssft_01
sub esi,256*4-1
mov [systlb],esi
xor ecx,ecx
.vmssft_03_0:
inc ecx
lodsd
cmp edx,eax
mov edx,eax
jne .vmssft_03_0
mov esi,dword [systlb]
cmp cx,60
jae .vmssft_03
add esi,256*4-4
lodsb
mov edx,eax
jmp .vmssft_01
.vmssft_03:
mov [systlb],esi
pop esi
pop edx
pop ecx
pop eax
retn
; IN:
; OUT: eax= vertical rate in Hz
vm_get_cur_vert_rate:
push edx
push ebx
xor eax,eax
mov edx,eax
mov ebx,eax
mov dx,03DAh
.vmgcvt_00:
in al,dx
test al,8
jz .vmgcvt_00
.vmgcvt_01:
in al,dx
test al,8
jnz .vmgcvt_01
mov ebx,edx
rdtsc
mov edx,ebx
mov ebx,eax
.vmgcvt_02:
in al,dx
test al,8
jz .vmgcvt_02
.vmgcvt_03:
in al,dx
test al,8
jnz .vmgcvt_03
rdtsc
sub eax,ebx
mov ebx,eax
mov eax,[OS_BASE+0F600h]
xor edx,edx
div ebx
inc eax
mov [refrate],eax
pop ebx
pop edx
retn
vm_calc_pixelclock:
push ebx
push edx
xor eax,eax
mov al,[_00]
add ax,5
shl eax,3
xor ebx,ebx
mov bl,[_06]
mov bh,[_07]
and bh,00100001b
btr bx,13
jnc .vmcpc_00
or bh,2
.vmcpc_00:
xor edx,edx
mul ebx
xor edx,edx
mul [initrr]
mov [pclock],eax
pop edx
pop ebx
retn
;
; Safe of initial CRTC state
;
vm_safe_reg:
push edx
push ebx
push ecx
push edi
cli
mov dx,3d4h ; CRTC
mov al,11h
out dx,al
inc dx
in al,dx
and al,7fh
out dx,al ; Clear protection bit
dec dx
xor ecx,ecx
mov cl,19h
xor bl,bl
mov edi,CRTCreg
.vmsr_00:
mov al,bl
out dx,al
inc dx
in al,dx
dec dx
stosb
inc bl
loop .vmsr_00
sti
pop edi
pop ecx
pop ebx
pop edx
retn
;
; Restore of initial CRTC state
;
vm_restore_reg:
push eax
push ebx
push edx
push esi
mov eax,[oldX]
mov [OS_BASE+0FE00h],eax
mov eax,[oldY]
mov [OS_BASE+0FE04h],eax
mov dx,03dah
.vmrr_00:
in al,dx
test al,8
jnz .vmrr_00
.vmrr_01:
in al,dx
test al,8
jnz .vmrr_01
cli
mov dx,03c4h
mov ax,0101h
out dx,ax
mov dx,3d4h ; CRTC
mov al,11h
out dx,al
inc dx
in al,dx
and al,7fh ; Clear Protection bit
out dx,al
dec dx
xor ecx,ecx
mov cl,19h
mov esi,CRTCreg
xor bl,bl
.vmrr_02:
lodsb
mov ah,al
mov al,bl
out dx,ax
inc bl
loop .vmrr_02
sti
; call ref_screen
pop esi
pop edx
pop ecx
pop eax
retn
; Calculate of possible vertical refrash rate
; (light version of function)
vm_calc_refrate:
push ebx
push ecx
push edx
push edi
push esi
mov eax,[pclock]
xor edx,edx
mov edi,_m1
mov ebx,eax
mov ecx,(1696*1065)
div ecx
xor edx,edx
stosw
add edi,8
mov eax,ebx
mov ecx,(1344*804)
div ecx
xor edx,edx
stosw
add edi,8
mov eax,ebx
mov ecx,(1056*636)
div ecx
xor edx,edx
stosw
add edi,8
mov eax,ebx
mov ecx,(800*524)
div ecx
xor edx,edx
stosw
mov edi,_m1
mov esi,edi
mov ecx,5*4
.vmcrr_00:
lodsw
cmp ax,55
jb .vmcrr_01
stosw
loop .vmcrr_00
pop esi
pop edi
pop edx
pop ecx
pop ebx
retn
.vmcrr_01:
xor ax,ax
stosw
loop .vmcrr_00
pop esi
pop edi
pop edx
pop ecx
pop ebx
retn
vm_get_initial_videomode:
push eax
mov eax,dword [OS_BASE+0FE00h]
mov [oldX],eax
mov eax,dword [OS_BASE+0FE04h]
mov [oldY],eax
mov eax,dword [OS_BASE+0FE0Ch] ; initial video mode
and ax,01FFh
mov dword [initvm],eax
pop eax
retn
; IN: eax = 0/1 - -/+ 1 position of width
vm_inc_dec_width:
push ebx
push edx
mov ebx,eax
mov dx,3d4h ; CRTC
mov al,11h
out dx,al
inc dx
in al,dx
and al,7fh ; Clear Protection bit
out dx,al
dec dx
xor al,al
out dx,al
inc dx
in al,dx
dec al
cmp bl,0
jnz .vmidr_00
inc al
inc al
.vmidr_00:
out dx,al
pop edx
pop ebx
retn
;
; Copy driver info to application area
;
; IN: ecx (in app. edx) - pointer to 512-bytes info area in application
; OUT:
vm_transfer_drv_info:
push ecx
push edi
push esi
mov eax,ecx
xor ecx,ecx
mov cl,32/4
mov esi,mdname
mov edi,drvname
rep movsd
mov ecx,eax
mov eax,[mdver]
mov [drvver],eax
mov edi,[OS_BASE+3010h]
mov edi,[edi+10h]
add edi,ecx
mov esi,drvinfo
xor ecx,ecx
mov cx,512
rep movsb
pop esi
pop edi
pop ecx
retn
;
; Set selected video mode
; (light version)
;
; IN: ecx = VertRate*65536+VideoMode
;
vm_set_selected_mode:
push edx
push ecx
push esi
ror ecx,16
cmp cx,00h
je .vmssm_03
rol ecx,16
mov eax,ecx
shl eax,16
shr eax,16
mov [currvm],eax
cmp cx,112h
jne .vmssm_00
mov esi,mode0
mov ecx,639
mov edx,479
jmp .vmssm_st00
.vmssm_00:
cmp cx,115h
jne .vmssm_01
mov esi,mode1
mov ecx,799
mov edx,599
jmp .vmssm_st00
.vmssm_01:
cmp cx,118h
jne .vmssm_02
mov esi,mode2
mov ecx,1023
mov edx,767
jmp .vmssm_st00
.vmssm_02:
cmp cx,11Bh
jne .vmssm_03
mov esi,mode2
mov ecx,1279
mov edx,1023
jmp .vmssm_st00
.vmssm_03:
xor eax,eax
dec eax
pop esi
pop ecx
pop edx
retn
.vmssm_st00:
mov [OS_BASE+0FE00h],ecx
mov [OS_BASE+0FE04h],edx
cli
mov dx,03c4h
lodsw
out dx,ax
mov dx,03d4h
mov al,11h
out dx,al
inc dx
in al,dx
and al,7fh
out dx,al
dec dx
mov ecx,13
.vmssm_st01:
lodsw
out dx,ax
loop .vmssm_st01
sti
xor eax,eax
pop esi
pop ecx
pop edx
retn
;------------DATA AREA---------------
align 4
mdvm_func_table:
dd MDSTART
dd vm_info_init, vm_get_cur_mode
dd vm_set_video_mode, vm_restore_init_video_mode
dd vm_change_screen_size, vm_change_position_screen
CRTCreg:
_00 db ?
_01 db ?
_02 db ?
_03 db ?
_04 db ?
_05 db ?
_06 db ?
_07 db ?
_08 db ?
_09 db ?
_0a db ?
_0b db ?
_0c db ?
_0d db ?
_0e db ?
_0f db ?
_10 db ?
_11 db ?
_12 db ?
_13 db ?
_14 db ?
_15 db ?
_16 db ?
_17 db ?
_18 db ?
_19 db ?
align 4
oldX dd ?
oldY dd ?
initvm dd ?
currvm dd 0
refrate dd 0
initrr dd 0
systlb dd 0
pclock dd ?
mdrvm dd 0 ; 0 - not drv init yet, 1 - already drv init
drvinfo:
drvname: times 32 db ' '
drvver dd 0
times (32-($-drvver))/4 dd 0
drvmode dw 011Bh,0118h,0115h,0112h
times (64-($-drvmode))/2 dw 00h
_m1 dw 0,0,0,0,0
_m2 dw 0,0,0,0,0
_m3 dw 0,0,0,0,0
_m4 dw 0,0,0,0,0
_m5 dw 0,0,0,0,0
times (512-($-drvinfo)) db 0
drvinfoend:
;1280x1024 - 11Bh
mode3:
dw 0101h
dw 0d000h,9f01h,9f02h,9303h,0a904h,1905h,2806h,5a07h
dw 0110h,8411h,0ff12h,0ff15h,2916h
;1024x768 - 118h
mode2:
dw 0101h
dw 0a400h,7f01h,7f02h,8703h,8404h,9505h,2406h,0f507h
dw 0310h,8911h,0ff12h,0ff15h,2516h
;800x600 - 115h
mode1:
dw 0101h
dw 8000h,6301h,6302h,8303h,6a04h,1a05h,7206h,0f007h
dw 5910h,8d11h,5712h,5715h,7316h
;640x480 - 112h, 12h
mode0:
dw 0101h
dw 6000h,4f01h,4f02h,8303h,5304h,9f05h,00b06h,3e07h
dw 0ea10h,8c11h,0df12h,0df15h,0c16h
; 640x400
;mymode0:
; dw 0101h
;_0_7 dw 5f00h,4f01h,4f02h,8303h,5304h,9f05h,0BF06h,1f07h
; dw 9c10h,8e11h,8f12h,9615h,0B916h ;,4013h
; 640x800
;mymode1:
; dw 0101h
; dw 5f00h,4f01h,4f02h,8003h,5004h,9f05h,06006h,0FF07h
; dw 2d10h,8f11h,2012h,2615h,05716h ;,4013h
DRVM_END:

View File

@ -236,7 +236,7 @@ debug_beginf
pushad
movzx ebx,al
mov eax,1
call sys_msg_board
; call sys_msg_board
popad
ret
debug_endf
@ -249,7 +249,7 @@ debug_beginf
movzx ebx,byte[edx]
or bl,bl
jz .l2
call sys_msg_board
; call sys_msg_board
inc edx
jmp .l1
.l2: ret

View File

@ -1,12 +1,12 @@
$Revision$
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; FAT12.INC ;;
;; (C) 2005 Mario79, License: GPL ;;
;; ;;
;; FAT12.INC ;;
;; (C) 2005 Mario79, License: GPL ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
n_sector dd 0 ; temporary save for sector value
@ -1125,7 +1125,7 @@ fd_prev_prev_sector dd ?
endg
flp_root_next:
cmp edi, 0xD200-0x20
cmp edi, OS_BASE+0xD200-0x20
jae @f
add edi, 0x20
ret ; CF=0
@ -1172,7 +1172,7 @@ flp_rootmem_extend_dir:
ret
flp_notroot_next:
cmp edi, 0xD200-0x20
cmp edi, OS_BASE+0xD200-0x20
jae flp_notroot_next_sector
add edi, 0x20
ret ; CF=0
@ -1223,7 +1223,7 @@ flp_notroot_end_write:
popa
ret
flp_notroot_next_write:
cmp edi, 0xD200
cmp edi, OS_BASE+0xD200
jae @f
ret
@@:
@ -1464,7 +1464,7 @@ fs_FloppyReadFolder:
cmp byte [edi+11], 0xF
jnz .do_bdfe
add edi, 0x20
cmp edi, 0xD200
cmp edi, OS_BASE+0xD200
jb .do_bdfe
pop eax
inc eax
@ -1496,7 +1496,7 @@ fs_FloppyReadFolder:
call fat_entry_to_bdfe
.l2:
add edi, 0x20
cmp edi, 0xD200
cmp edi, OS_BASE+0xD200
jb .l1
pop eax
inc eax
@ -1895,7 +1895,10 @@ fs_FloppyRewrite:
jnz .ret
dec edi
dec edi
lea eax, [edi-(FLOPPY_FAT)]
mov eax, edi
sub eax, FLOPPY_FAT
shr eax, 1 ; eax = cluster
mov word [edi], 0xFFF ; mark as last cluster
xchg edi, [esp+4]
@ -2576,7 +2579,7 @@ fs_FloppyExecute:
mov ebx, [ebx+4]
test ebx, ebx
jz @f
add ebx, std_application_base_address
; add ebx, std_application_base_address
@@:
;----------------------------------------------------------------

View File

@ -1,48 +1,48 @@
$Revision$
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; FAT32.INC ;;
;; ;;
;; FAT16/32 functions for KolibriOS ;;
;; ;;
;; Copyright 2002 Paolo Minazzi, paolo.minazzi@inwind.it ;;
;; ;;
;; See file COPYING for details ;;
;; 04.02.2007 LFN create folder - diamond ;;
;; 08.10.2006 LFN delete file/folder - diamond ;;
;; 20.08.2006 LFN set file size (truncate/extend) - diamond ;;
;; 17.08.2006 LFN write/append to file - diamond ;;
;; 23.06.2006 LFN start application - diamond ;;
;; 15.06.2006 LFN get/set file/folder info - diamond ;;
;; 27.05.2006 LFN create/rewrite file - diamond ;;
;; 04.05.2006 LFN read folder - diamond ;;
;; 29.04.2006 Elimination of hangup after the ;;
;; expiration hd_wait_timeout - Mario79 ;;
;; 23.04.2006 LFN read file - diamond ;;
;; 28.01.2006 find all Fat16/32 partition in all input point ;;
;; to MBR, see file part_set.inc - Mario79 ;;
;; 15.01.2005 get file size/attr/date, file_append - ATV ;;
;; 04.12.2004 skip volume label, file delete bug fixed - ATV ;;
;; 29.11.2004 get_free_FAT changed, append dir bug fixed - ATV ;;
;; 23.11.2004 don't allow overwrite dir with file - ATV ;;
;; 18.11.2004 get_disk_info and more error codes - ATV ;;
;; 17.11.2004 set_FAT/get_FAT and disk cache rewritten - ATV ;;
;; 10.11.2004 removedir clear whole directory structure - ATV ;;
;; 08.11.2004 rename - ATV ;;
;; 30.10.2004 file_read return also dirsize in bytes - ATV ;;
;; 20.10.2004 Makedir/Removedir - ATV ;;
;; 14.10.2004 Partition chain/Fat16 - ATV (thanks drh3xx) ;;
;; 06.9.2004 Fix free space by Mario79 added - MH ;;
;; 24.5.2004 Write back buffer for File_write -VT ;;
;; 20.5.2004 File_read function to work with syscall 58 - VT ;;
;; 30.3.2004 Error parameters at function return - VT ;;
;; 01.5.2002 Bugfix in device write - VT ;;
;; 20.5.2002 Hd status check - VT ;;
;; 29.6.2002 Improved fat32 verification - VT ;;
;; ;;
;; FAT32.INC ;;
;; ;;
;; FAT16/32 functions for KolibriOS ;;
;; ;;
;; Copyright 2002 Paolo Minazzi, paolo.minazzi@inwind.it ;;
;; ;;
;; See file COPYING for details ;;
;; 04.02.2007 LFN create folder - diamond ;;
;; 08.10.2006 LFN delete file/folder - diamond ;;
;; 20.08.2006 LFN set file size (truncate/extend) - diamond ;;
;; 17.08.2006 LFN write/append to file - diamond ;;
;; 23.06.2006 LFN start application - diamond ;;
;; 15.06.2006 LFN get/set file/folder info - diamond ;;
;; 27.05.2006 LFN create/rewrite file - diamond ;;
;; 04.05.2006 LFN read folder - diamond ;;
;; 29.04.2006 Elimination of hangup after the ;;
;; expiration hd_wait_timeout - Mario79 ;;
;; 23.04.2006 LFN read file - diamond ;;
;; 28.01.2006 find all Fat16/32 partition in all input point ;;
;; to MBR, see file part_set.inc - Mario79 ;;
;; 15.01.2005 get file size/attr/date, file_append - ATV ;;
;; 04.12.2004 skip volume label, file delete bug fixed - ATV ;;
;; 29.11.2004 get_free_FAT changed, append dir bug fixed - ATV ;;
;; 23.11.2004 don't allow overwrite dir with file - ATV ;;
;; 18.11.2004 get_disk_info and more error codes - ATV ;;
;; 17.11.2004 set_FAT/get_FAT and disk cache rewritten - ATV ;;
;; 10.11.2004 removedir clear whole directory structure - ATV ;;
;; 08.11.2004 rename - ATV ;;
;; 30.10.2004 file_read return also dirsize in bytes - ATV ;;
;; 20.10.2004 Makedir/Removedir - ATV ;;
;; 14.10.2004 Partition chain/Fat16 - ATV (thanks drh3xx) ;;
;; 06.9.2004 Fix free space by Mario79 added - MH ;;
;; 24.5.2004 Write back buffer for File_write -VT ;;
;; 20.5.2004 File_read function to work with syscall 58 - VT ;;
;; 30.3.2004 Error parameters at function return - VT ;;
;; 01.5.2002 Bugfix in device write - VT ;;
;; 20.5.2002 Hd status check - VT ;;
;; 29.6.2002 Improved fat32 verification - VT ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
cache_max equ 1919 ; max. is 1919*512+0x610000=0x6ffe00
@ -3267,7 +3267,7 @@ fs_HdExecute:
mov ebx, [ebx+4]
test ebx, ebx
jz @f
add ebx, std_application_base_address
; add ebx, std_application_base_address
@@:
;----------------------------------------------------------------

View File

@ -1,21 +1,21 @@
$Revision$
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; ;;
;; System service for filesystem call ;;
;; (C) 2004 Ville Turjanmaa, License: GPL ;;
;; 29.04.2006 Elimination of hangup after the ;;
;; expiration hd_wait_timeout (for LBA) - Mario79 ;;
;; System service for filesystem call ;;
;; (C) 2004 Ville Turjanmaa, License: GPL ;;
;; 29.04.2006 Elimination of hangup after the ;;
;; expiration hd_wait_timeout (for LBA) - Mario79 ;;
;; 15.01.2005 get file size/attr/date, ;;
;; file_append (only for hd) - ATV ;;
;; 23.11.2004 test if hd/partition is set - ATV ;;
;; 18.11.2004 get_disk_info and more error codes - ATV ;;
;; 08.11.2004 expand_pathz and rename (only for hd) - ATV ;;
;; 20.10.2004 Makedir/Removedir (only for hd) - ATV ;;
;; ;;
;; 23.11.2004 test if hd/partition is set - ATV ;;
;; 18.11.2004 get_disk_info and more error codes - ATV ;;
;; 08.11.2004 expand_pathz and rename (only for hd) - ATV ;;
;; 20.10.2004 Makedir/Removedir (only for hd) - ATV ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
iglobal
@ -86,7 +86,7 @@ file_system:
; \end{diamond}[18.03.2006]
; Extract parameters
add eax, std_application_base_address ; abs start of info block
; add eax, std_application_base_address ; abs start of info block
cmp dword [eax+0],15 ; GET_DISK_INFO
je fs_info
@ -97,7 +97,7 @@ file_system:
cmp dword [eax+0],1
jnz .usual_check
mov ebx,[eax+12]
add ebx,std_application_base_address
; add ebx,std_application_base_address
mov ecx,[eax+8]
call check_region
test eax,eax
@ -120,7 +120,7 @@ endg
shl ecx,9
.small_size:
mov ebx,[eax+12]
add ebx,std_application_base_address
; add ebx,std_application_base_address
call check_region
test eax,eax
jz .error_output
@ -148,7 +148,7 @@ endg
; \end{diamond}[18.03.2006]
mov esi,dir0
mov edi,[eax+12]
add edi,std_application_base_address
; add edi,std_application_base_address
mov ecx,11
push ecx
; cld ; already is
@ -202,12 +202,12 @@ endg
push dword [eax+4] ; 512 block number to read
push dword [eax+8] ; bytes to write/append or 512 blocks to read
mov ebx,[eax+12]
add ebx,std_application_base_address
; add ebx,std_application_base_address
push ebx ; abs start of return/save area
lea esi,[eax+20] ; abs start of dir + filename
mov edi,[eax+16]
add edi,std_application_base_address ; abs start of work area
; add edi,std_application_base_address ; abs start of work area
call expand_pathz

View File

@ -93,7 +93,7 @@ file_system_lfn:
; 8 : delete file
; 9 : create directory
add eax, std_application_base_address
; add eax, std_application_base_address
; parse file name
xchg ebx, eax
lea esi, [ebx+20]
@ -102,7 +102,7 @@ file_system_lfn:
test al, al
jnz @f
mov esi, [esi]
add esi, std_application_base_address
; add esi, std_application_base_address
mov ebp, esi
lodsb
@@:
@ -112,7 +112,7 @@ file_system_lfn:
mov ebx, [ebx+8]
test ebx, ebx
jz .l1
add ebx, new_app_base
; add ebx, new_app_base
.l1:
call fs_execute ; ebp, ebx, edx
mov [esp+36], eax
@ -157,7 +157,7 @@ file_system_lfn:
xor eax, eax
mov ebp, [ebx+12]
mov edx, [ebx+16]
add edx, std_application_base_address
; add edx, std_application_base_address
push dword [ebx+4] ; first block
mov ebx, [ebx+8] ; flags
mov esi, [edi+4]
@ -239,7 +239,7 @@ file_system_lfn:
mov esi, virtual_root_query
mov ebp, [ebx+12]
mov edx, [ebx+16]
add edx, std_application_base_address
; add edx, std_application_base_address
push dword [ebx+4] ; first block
mov ebx, [ebx+8] ; flags
xor eax, eax
@ -348,7 +348,7 @@ fs_OnRamdisk:
jae .not_impl
mov ecx, [ebx+12]
mov edx, [ebx+16]
add edx, std_application_base_address
; add edx, std_application_base_address
add ebx, 4
call dword [fs_RamdiskServices + eax*4]
mov [esp+36], eax
@ -385,7 +385,7 @@ fs_OnFloppy:
mov [flp_number], cl
mov ecx, [ebx+12]
mov edx, [ebx+16]
add edx, std_application_base_address
; add edx, std_application_base_address
add ebx, 4
call dword [fs_FloppyServices + eax*4]
and [flp_status], 0
@ -449,7 +449,7 @@ fs_OnHd:
pop esi ebx
mov ecx, [ebx+12]
mov edx, [ebx+16]
add edx, std_application_base_address
; add edx, std_application_base_address
mov eax, [ebx]
cmp eax, fs_NumHdServices
jae .not_impl
@ -525,7 +525,7 @@ fs_OnCd:
@@:
mov ecx, [ebx+12]
mov edx, [ebx+16]
add edx, std_application_base_address
; add edx, std_application_base_address
mov eax, [ebx]
cmp eax,fs_NumCdServices
jae .not_impl

View File

@ -506,7 +506,7 @@ fs_CdExecute:
mov ebx, [ebx+4]
test ebx, ebx
jz @f
add ebx, std_application_base_address
; add ebx, std_application_base_address
@@:
;----------------------------------------------------------------

View File

@ -172,16 +172,15 @@ button_dececx:
sys_button:
push edi
mov edi,[CURRENT_TASK]
shl edi,8
mov edi,[current_slot]
rol eax,16
add ax,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left]
add ax,word[edi+APPDATA.wnd_clientbox.left]
rol eax,16
rol ebx,16
add bx,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top]
add bx,word[edi+APPDATA.wnd_clientbox.top]
rol ebx,16
pop edi
.forced:
.forced:
test ecx,0x80000000
jnz remove_button
@ -228,7 +227,7 @@ sys_button:
pop edx
and edx, 0xFFFF
.newline:
.newline:
call button_dececx
push edi
xor edi, edi
@ -241,7 +240,7 @@ sys_button:
call drawbuttonframes
button_no_draw:
button_no_draw:
and ecx,0xffff
@ -276,7 +275,7 @@ sys_button:
mov bx,[esp+8+0]
mov [eax],bx
noaddbutt:
noaddbutt:
pop edx
pop ecx
@ -292,14 +291,14 @@ remove_button:
and ecx,0x7fffffff
rnewba2:
rnewba2:
mov edi,[BTN_ADDR]
mov eax,edi
movzx ebx,word [edi]
inc bx
rnewba:
rnewba:
dec bx
jz rnmba
@ -325,7 +324,7 @@ remove_button:
jmp rnewba2
rnmba:
rnmba:
ret
@ -336,17 +335,17 @@ find_pressed_button_frames:
movzx ebx,word [eax+0]
shl ebx,5
add ebx,window_data
mov ecx, [ebx+ WDATA.box.left] ; window x start
mov ecx, [ebx+ WDATA.box.left] ; window x start
movzx edx,word [eax+4] ; button x start
add ecx,edx
push ecx
mov dx,[eax+6] ; button x size
mov dx,[eax+6] ; button x size
add cx,dx
mov esi,ecx
inc esi
mov ecx, [ebx+WDATA.box.top] ; window y start
mov dx,[eax+8] ; button y start
mov ecx, [ebx+WDATA.box.top] ; window y start
mov dx,[eax+8] ; button y start
add ecx,edx
mov ebx,ecx
mov dx,[eax+10] ; button y size

View File

@ -121,9 +121,8 @@ create_event:
cld
rep movsd
@@:
mov ecx, [CURRENT_TASK]
shl ecx,8
add ecx, SLOT_BASE+APP_OBJ_OFFSET
mov ecx, [current_slot]
add ecx, APP_OBJ_OFFSET
pushfd
cli
@ -224,12 +223,11 @@ align 4
proc get_event_ex stdcall, p_ev:dword, timeout:dword
.wait:
mov edx,[CURRENT_TASK]
shl edx,8
mov edx,[current_slot]
; cmp [SLOT_BASE+edx+APPDATA.ev_count], 0
; je .switch
add edx, SLOT_BASE+APP_EV_OFFSET
add edx, APP_EV_OFFSET
mov eax, [edx+APPOBJ.fd]
cmp eax, edx
@ -307,9 +305,7 @@ wait_event:
test [eax+EVENT.state], MANUAL_RESET
jnz .done
mov edx,[CURRENT_TASK]
shl edx,8
add edx, SLOT_BASE
mov edx,[current_slot]
pushfd
cli ;remove event from events
@ -576,22 +572,21 @@ get_event_for_app:
xor eax, eax
ret
no_eventoccur3:
no_eventoccur3:
;mov edi,[TASK_BASE] ; mouse event
test [edi+TASKDATA.event_mask],dword 00100000b
jz no_mouse_event
mov eax,[CURRENT_TASK]
shl eax,8
mov eax, [CURRENT_TASK]
shl eax, 8
test [eax+SLOT_BASE+APPDATA.event_mask],dword 00100000b
jz no_mouse_event
and [eax+SLOT_BASE+APPDATA.event_mask],dword 0xffffffff-00100000b
and [eax+SLOT_BASE+APPDATA.event_mask],dword (not 00100000b)
popad
mov eax,6
ret
no_mouse_event:
no_mouse_event:
;mov edi,[TASK_BASE] ; DESKTOP BACKGROUND REDRAW
test [edi+TASKDATA.event_mask],dword 16
@ -601,39 +596,38 @@ get_event_for_app:
popad
mov eax,5
ret
no_eventoccur5:
no_eventoccur5:
;mov edi,[TASK_BASE] ; IPC
test [edi+TASKDATA.event_mask],dword 01000000b
jz no_ipc
mov eax,[CURRENT_TASK]
shl eax,8
mov eax, [CURRENT_TASK]
shl eax, 8
test [eax+SLOT_BASE+APPDATA.event_mask],dword 01000000b
jz no_ipc
and [eax+SLOT_BASE+APPDATA.event_mask],dword 0xffffffff-01000000b
popad
mov eax,7
ret
no_ipc:
no_ipc:
;mov edi,[TASK_BASE] ; STACK
test [edi+TASKDATA.event_mask],dword 10000000b
jz no_stack_event
mov eax,[CURRENT_TASK]
shl eax,8
mov eax, [CURRENT_TASK]
shl eax, 8
test [eax+SLOT_BASE+APPDATA.event_mask],dword 10000000b
jz no_stack_event
and [eax+SLOT_BASE+APPDATA.event_mask],dword 0xffffffff-10000000b
popad
mov eax,8
ret
no_stack_event:
no_stack_event:
test byte [edi+TASKDATA.event_mask+1], 1 ; DEBUG
jz .test_IRQ
mov eax, [CURRENT_TASK]
shl eax, 8
mov eax, [CURRENT_TASK]
shl eax, 8
test byte [eax+SLOT_BASE+APPDATA.event_mask+1], byte 1
jz .test_IRQ
and byte [eax+SLOT_BASE+APPDATA.event_mask+1], not 1

View File

@ -16,35 +16,9 @@ load_skin_file:
mov ebx,1
or ecx,-1
mov esi,12
; call fileread
pushad
push eax
sub edx,std_application_base_address
mov [skin_to_load.adr],edx
;sub eax,std_application_base_address
;mov [skin_to_load.stradr],eax
mov [skin_to_load.stradr],_skin_file_default - std_application_base_address
mov eax,skin_to_load - std_application_base_address
call file_system_lfn
;call fileread
pop eax
popad
call fileread
ret
ret
skin_to_load:
dd 0,0,0
dd 64*1024
.adr dd 0
db 0
.stradr dd 0
struct SKIN_HEADER
.ident dd ?
.version dd ?

View File

@ -11,7 +11,7 @@ $Revision$
;
iglobal
_skin_file_default db '/rd/1/DEFAULT.SKN',0
_skin_file_default db 'DEFAULT SKN',0
endg
struct SKIN_DATA

View File

@ -1781,18 +1781,15 @@ random_shaped_window:
test eax, eax
jne rsw_no_address
mov eax,[CURRENT_TASK]
shl eax,8
mov [eax+SLOT_BASE+APPDATA.wnd_shape],ebx
rsw_no_address:
mov eax,[current_slot]
mov [eax+APPDATA.wnd_shape],ebx
rsw_no_address:
cmp eax,1
jne rsw_no_scale
mov eax,[CURRENT_TASK]
shl eax,8
mov byte [eax+SLOT_BASE+APPDATA.wnd_shape_scale], bl
rsw_no_scale:
mov eax,[current_slot]
mov byte [eax+APPDATA.wnd_shape_scale], bl
rsw_no_scale:
ret

274
kernel/trunk/init.inc Normal file
View File

@ -0,0 +1,274 @@
$Revision$
MEM_WB equ 6 ;write-back memory
MEM_WC equ 1 ;write combined memory
MEM_UC equ 0 ;uncached memory
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, 0x100000
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
shr eax, 12
mov edx, eax
mov [pg_data.pages_count-OS_BASE], eax
shr eax, 3
mov [pg_data.pagemap_size-OS_BASE], eax
cmp edx, (OS_BASE/4096)
jbe @F
mov edx, (OS_BASE/4096)
jmp .set
@@:
cmp edx, (HEAP_MIN_SIZE/4096)
jae .set
mov edx, (HEAP_MIN_SIZE/4096)
.set:
mov [pg_data.kernel_pages-OS_BASE], edx
shr edx, 10
mov [pg_data.kernel_tables-OS_BASE], edx
xor eax, eax
mov edi, sys_pgdir-OS_BASE
mov ecx, 4096/4
cld
rep stosd
mov edx, (sys_pgdir-OS_BASE)+ 0x800; (OS_BASE shr 20)
bt [cpu_caps-OS_BASE], 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], 1
mov [edx], eax
add eax, 0x00400000
; mov [edx+4], eax
add edx, 4
mov eax, 0x400000+PG_SW
mov ecx, (tmp_page_tab-0x400000)/4096
jmp .map_low
.no_PSE:
mov eax, PG_SW
mov ecx, tmp_page_tab/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
mov edi, (sys_pgdir-OS_BASE)
lea esi, [edi+(OS_BASE shr 20)]
lodsd
and eax, not PG_GLOBAL
stosd
lodsd
and eax, not PG_GLOBAL
stosd
lodsd
and eax, not PG_GLOBAL
stosd
ret
endp
align 4
proc init_page_map
mov edi, sys_pgmap-OS_BASE
mov ecx, ((HEAP_BASE-OS_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-OS_BASE)/4096) and 31
sub edx, (HEAP_BASE-OS_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
mov [edi], eax
add edi, OS_BASE
mov [page_start-OS_BASE], edi;
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

File diff suppressed because it is too large Load Diff

View File

@ -1,51 +0,0 @@
$Revision$
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; KERNEL16.INC ;;
;; ;;
;; Included 16 bit kernel files for MenuetOS ;;
;; ;;
;; This file is kept separate as it will be easier to ;;
;; maintain and compile with an automated SETUP program ;;
;; in the future. ;;
;; ;;
;; Copyright Ville Turjanmaa, see file COPYING for details. ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;% +include
;!!!
include "boot/bootstr.inc" ; language-independent boot messages
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
else if lang eq et
include "boot/bootet.inc" ; estonian system boot messages
else
include "boot/bootge.inc" ; german system boot messages
;!!!
end if
if lang eq et
include "boot/et.inc" ; Estonian font
else if lang eq ru
include "boot/ru.inc" ; Russian font
end if
; ñþäà äàííûå çàïèñûâàþòñÿ â 16 ðàçðÿäíîì ðåæèìå, ÷èòàþòñÿ â 32 ðàçðÿäíîì
bx_from_load: ; ñòðóêòóðà äëÿ õðàíåíèÿ ïàðàìåòðîâ- îòêóäà ãàøðóçèëèñü, áåðåòñÿ íèæå èç bx ; {SPraid}[13.03.2007]
.from_disc db 0 ; a,b,c,d - âèí÷åñòåðû, r - ðàì äèñê
.from_part db 0,0 ; # äèñêà... ñèìâîë, à íå áàéò. '1', à íå 1
org $-0x10000
include "boot/bootcode.inc" ; 16 bit system boot code
include "bus/pci/pci16.inc"
;% -include

View File

@ -1,17 +1,17 @@
$Revision$
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; KERNEL32.INC ;;
;; ;;
;; Included 32 bit kernel files for MenuetOS ;;
;; ;;
;; This file is kept separate as it will be easier to ;;
;; maintain and compile with an automated SETUP program ;;
;; in the future. ;;
;; ;;
;; KERNEL32.INC ;;
;; ;;
;; Included 32 bit kernel files for MenuetOS ;;
;; ;;
;; This file is kept separate as it will be easier to ;;
;; maintain and compile with an automated SETUP program ;;
;; in the future. ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;struc db [a] { common . db a
@ -41,7 +41,7 @@ $Revision$
struc RECT {
.left dd ?
.top dd ?
.top dd ?
.right dd ?
.bottom dd ?
}
@ -51,7 +51,7 @@ end virtual
struc BOX {
.left dd ?
.top dd ?
.top dd ?
.width dd ?
.height dd ?
}
@ -60,7 +60,7 @@ virtual at 0
end virtual
; constants definition
WSTATE_NORMAL = 00000000b
WSTATE_NORMAL = 00000000b
WSTATE_MAXIMIZED = 00000001b
WSTATE_MINIMIZED = 00000010b
WSTATE_ROLLEDUP = 00000100b
@ -77,7 +77,7 @@ struc TASKDATA
.pid dd ?
dw ?
.state db ?
db ?
db ?
dw ?
.wnd_number db ?
db ?
@ -111,25 +111,28 @@ struc APPDATA
.app_name db 11 dup(?)
db 5 dup(?)
.fpu_state dd ? ;+16
.ev_count dd ? ;+20
.fpu_handler dd ? ;+24
.sse_handler dd ? ;+28
.pl0_stack dd ? ;unused ;+32
.heap_base dd ? ;+36
.heap_top dd ? ;+40
.cursor dd ? ;+44
.fd_ev dd ? ;+48
.bk_ev dd ? ;+52
.fd_obj dd ? ;+56
.bk_obj dd ? ;+60
.fpu_state dd ? ;+16
.ev_count dd ? ;+20
.fpu_handler dd ? ;+24
.sse_handler dd ? ;+28
.pl0_stack dd ? ;unused ;+32
.heap_base dd ? ;+36
.heap_top dd ? ;+40
.cursor dd ? ;+44
.fd_ev dd ? ;+48
.bk_ev dd ? ;+52
.fd_obj dd ? ;+56
.bk_obj dd ? ;+60
.saved_esp dd ? ;+64
.io_map rd 2 ;+68
.dbg_state dd ? ;+76
db 64 dup(?) ;+64
db 48 dup(?) ;+80
.wnd_shape dd ? ;+128
.wnd_shape_scale dd ? ;+132
dd ? ;+136
.mem_size dd ? ;+140
.wnd_shape dd ? ;+128
.wnd_shape_scale dd ? ;+132
dd ? ;+136
.mem_size dd ? ;+140
.saved_box BOX
.ipc_start dd ?
.ipc_size dd ?
@ -161,7 +164,7 @@ include "core/sync.inc" ; macros for synhronization objects
include "core/sys32.inc" ; process management
include "core/sched.inc" ; process scheduling
include "core/syscall.inc" ; system call
include "core/fpu.inc" ; all fpu/sse support
include "core/fpu.inc" ; all fpu/sse support
include "core/memory.inc"
include "core/heap.inc" ; kernel and app heap
include "core/malloc.inc" ; small kernel heap
@ -177,14 +180,12 @@ include "gui/button.inc"
; shutdown
include "boot/shutdown.inc" ; shutdown or restart
; file system
include "fs/fs.inc" ; syscall
include "fs/fat32.inc" ; read / write for fat32 filesystem
include "fs/ntfs.inc" ; read / write for ntfs filesystem
include "fs/fat12.inc" ; read / write for fat12 filesystem
include "fs/fs.inc" ; syscall
include "fs/fat32.inc" ; read / write for fat32 filesystem
include "fs/ntfs.inc" ; read / write for ntfs filesystem
include "fs/fat12.inc" ; read / write for fat12 filesystem
include "blkdev/rd.inc" ; ramdisk read /write
include "fs/fs_lfn.inc" ; syscall, version 2
include "fs/iso9660.inc" ; read for iso9660 filesystem CD
@ -205,6 +206,9 @@ include "video/cursors.inc" ; cursors functions
include "network/stack.inc"
;include "drivers/uart.inc"
; Mouse pointer
include "gui/mouse.inc"

View File

@ -59,7 +59,7 @@ macro IncludeAllGlobals {
IncludeIGlobals
IncludeUGlobals
}
iglobal
endg

View File

@ -1,4 +1,3 @@
$Revision$
;
; MEMORY MAP
;
@ -25,7 +24,9 @@ $Revision$
;
; Runtime:
;
; 0000 -> 1FFF window_data - 256 entries
; 0x00000000 -> 0x7FFFFFFF application 2Gb
; 0x80000000 -> 1FFF window_data - 256 entries
;
; 0000 dword x start
; 0004 dword y start
@ -120,106 +121,119 @@ $Revision$
; FFF5 byte 1 do not draw pointer
; FFFF byte do not change task for 1/100 sec.
;
; 10000 -> 3DBFF kernel, 32-bit run-time code (up to 183 Kb)
; 3DC00 -> 3EBFF stack at boot time (4Kb)
; 3EC00 -> 3F5FF basic text font II
; 3F600 -> 3FFFF basic text font I
; 40000 -> 4FFFF data of retrieved disks and partitions (Mario79)
; 0x80010000 -> 3DBFF kernel, 32-bit run-time code (up to 183 Kb)
; 0x8003DC00 -> 3EBFF stack at boot time (4Kb)
; 0x8003EC00 -> 3F5FF basic text font II
; 0x8003F600 -> 3FFFF basic text font I
; 0x80040000 -> 4FFFF data of retrieved disks and partitions (Mario79)
; 50000 -> 50FFF main page directory
; 50200 -> 5FFFF pages bitmap
; 0x80050000 -> 50FFF main page directory
; 0x80050200 -> 5FFFF pages bitmap
; 60000 -> 7FFFF free (128 Kb)
; 80000 -> 8FFFF additional app info, in 256 byte steps - 256 entries
; 0x80060000 -> 7FFFF free (128 Kb)
; 0x80080000 -> 8FFFF additional app info, in 256 byte steps - 256 entries
;
; 00 11db name of app running
; 10 108db floating point unit save area
; 7f byte 0= no fpu saved , 1= fpu saved to 0x10 -> restore
; 80 dword address of random shaped window area
; 84 byte shape area scale
; 88 dword free
; 8C dword application memory size
; 90 dword window X position save
; 94 dword window Y position save
; 98 dword window X size save
; 9C dword window Y size save
; A0 dword IPC memory start
; A4 dword IPC memory size
; A8 dword event bits: mouse, stack,..
; AC dword 0 or debugger slot
; B0 dword free
; B4 byte keyboard mode: 0 = keymap, 1 = scancodes
; B8 dword physical address of directory table
; BC dword address of debug event memory
; C0 5 dd thread debug registers: DR0,DR1,DR2,DR3,DR7
; 00 11db name of app running
; 0x10 dword pointer to fpu save area
; 0x14 dword event count
; 0x18 dword user fpu exceptoins handler
; 0x1c dword user sse exceptions handler
; 20 dword PL0 stack base
; 24 dword user heap base
; 28 dword user heap top
; 2c dword window cursor handle
; 30 dword first event in list
; 34 dword last event in list
; 38 dword first kernel object in list
; 3c dword last kernel object in list
; 40 dword thread esp
; 44 dword io permission map page 0
; 48 dword io permission map page 1
4c dword debug state: 1= load debug registers
; 50-7F unused
;
; 90000 -> 9FFFF tmp
; A0000 -> AFFFF screen access area
; B0000 -> FFFFF bios rest in peace -area
; 100000 -> 27FFFF diskette image
; 280000 -> 281FFF ramdisk fat
; 282000 -> 283FFF floppy fat
; 80 dword address of random shaped window area
; 84 byte shape area scale
; 88 dword free
; 8C dword application memory size
; 90 dword window X position save
; 94 dword window Y position save
; 98 dword window X size save
; 9C dword window Y size save
; A0 dword IPC memory start
; A4 dword IPC memory size
; A8 dword event bits: mouse, stack,..
; AC dword 0 or debugger slot
; B0 dword free
; B4 byte keyboard mode: 0 = keymap, 1 = scancodes
; B8 dword physical address of directory table
; BC dword address of debug event memory
; C0 5 dd thread debug registers: DR0,DR1,DR2,DR3,DR7
;
; 284000 -> 29FFFF free (112 Kb)
; 0x80090000 -> 9FFFF tmp
; 0x800A0000 -> AFFFF screen access area
; 0x800B0000 -> FFFFF bios rest in peace -area
; 0x80100000 -> 27FFFF diskette image
; 0x80280000 -> 281FFF ramdisk fat
; 0x80282000 -> 283FFF floppy fat
;
; 2A0000 -> 2B00ff wav device data
; 2C0000 -> 2C3fff button info
; 0x80284000 -> 29FFFF free (112 Kb)
;
; 0000 word number of buttons
; 0x802A0000 -> 2B00ff wav device data
; 0x802C0000 -> 2C3fff button info
;
; 0000 word number of buttons
; first button entry at 0x10
; +0000 word process number
; +0002 word button id number : bits 00-15
; +0004 word x start
; +0006 word x size
; +0008 word y start
; +000A word y size
; +000C word button id number : bits 16-31
; +0000 word process number
; +0002 word button id number : bits 00-15
; +0004 word x start
; +0006 word x size
; +0008 word y start
; +000A word y size
; +000C word button id number : bits 16-31
;
; 2C4000 -> 2CFFFF free (48Kb)
; 0x802C4000 -> 2CFFFF free (48Kb)
;
; 2D0000 -> 2DFFFF reserved port area
; 0x802D0000 -> 2DFFFF reserved port area
;
; 0000 dword no of port areas reserved
; 0010 dword process id
; dword start port
; dword end port
; dword 0
; 0000 dword no of port areas reserved
; 0010 dword process id
; dword start port
; dword end port
; dword 0
;
; 2E0000 -> 2EFFFF irq data area
; 2F0000 -> 2FFFFF low memory save
; 0x802E0000 -> 2EFFFF irq data area
; 0x802F0000 -> 2FFFFF low memory save
;
; 300000 -> 45FFFF background image, max 1,375 M
; 0x80300000 -> 45FFFF background image, max 1,375 M
;
; 460000 -> 5FFFFF display info
; 0x80460000 -> 5FFFFF display info
;
; 600000 -> 6FFFFF hd cache
; 0x80600000 -> 6FFFFF hd cache
;
; 700000 -> 71ffff tcp memory (128 kb)
; 720000 -> 75ffff free (256 kb)
; 0x80700000 -> 71ffff tcp memory 128 Kb
; 0x80720000 -> 75ffff free (256 kb)
;
; 760000 -> 76ffff !vrr driver
; 770000 -> 777fff tcp memory ( 32 kb)
;
; 780000 -> 987FFF TSS and IO map for (8192*8)=65536 ports
; (128+8192)*256 = 2129920 = 0x208000
;
; 988000 -> 98AFFF draw_data - 256 entries
; 0x80760000 -> 76ffff !vrr driver
; 0x80770000 -> 777fff tcp memory 32 Kb
;
; 0x80780000 -> 0x80782FFF draw data - 256 entries
; 00 dword draw limit - x start
; 04 dword draw limit - y start
; 08 dword draw limit - x end
; 0C dword draw limit - y end
;
; 0x80783F80 -> 0x80783FFF TSS 128 bytes
;
; 0x0098B000 -> kernel heap
; 0x80784000 -> 0x80785FFF IO map for (8192*8)=65536 ports
;
; 0x01FFFFFF heap min limit
; 0x7DBFFFFF heap max limit
; 0x7DC00000 -> 0x7FBFFFFF LFB 32Mb
; 0x7DC00000 -> 0x7E3FFFFF application available LFB 8Mb
; 0x7E400000 -> 0x7FBFFFFF kernel LFB part 24 Mb
; 0x7FC00000 -> 0x7FFFFFFF page tables 4Mb
; 0x80000000 -> 0xFFFFFFFF application 2Gb
; 0x80786000 -> kernel heap
; 0x81FFFFFF heap min limit
; 0xFDBFFFFF heap max limit
; 0xFDC00000 -> 0xFDFFFFFF page tables 4Mb
; 0xFE000000 -> 0xFFFFFFFF LFB 32Mb
; 0xFE000000 -> 0xFE7FFFFF application available LFB 8Mb
; 0xFE800000 -> 0xFFFFFFFF kernel LFB part 24 Mb

View File

@ -596,7 +596,7 @@ socket_read_packet:
.startcopy:
mov edi, ecx ;
add edi, std_application_base_address ; get data pointer to buffer in application
; add edi, std_application_base_address ; get data pointer to buffer in application
mov esi, ebx ;
add esi, SOCKETHEADERSIZE ; we dont need to copy the header

View File

@ -1,4 +1,4 @@
$Revision$
; Macroinstructions for defining and calling procedures
macro stdcall proc,[arg] ; directly call STDCALL procedure

View File

@ -1,10 +1,15 @@
$Revision$
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
LOAD_FROM_FILE equ 0
LOAD_FROM_MEM equ 1
LOAD_INDIRECT equ 2
LOAD_SYSTEM equ 3
VIDEO_FREE equ 2
struc BITMAPINFOHEADER {
.biSize dd ? ; DWORD
@ -268,15 +273,13 @@ proc set_cursor stdcall, hcursor:dword
jne .fail
; cmp [eax+CURSOR.size], CURSOR_SIZE
; jne .fail
mov ebx, [CURRENT_TASK]
shl ebx, 8
xchg eax, [ebx+SLOT_BASE+APPDATA.cursor]
mov ebx, [current_slot]
xchg eax, [ebx+APPDATA.cursor]
ret
.fail:
mov eax, [def_cursor]
mov ebx, [CURRENT_TASK]
shl ebx, 8
xchg eax, [ebx+SLOT_BASE+APPDATA.cursor]
mov ebx, [current_slot]
xchg eax, [ebx+APPDATA.cursor]
ret
endp
@ -399,12 +402,11 @@ proc delete_cursor stdcall, hcursor:dword
cmp ebx, [esi+CURSOR.pid]
jne .fail
mov ebx, [CURRENT_TASK]
shl ebx, 8
cmp esi, [ebx+SLOT_BASE+APPDATA.cursor]
mov ebx, [current_slot]
cmp esi, [ebx+APPDATA.cursor]
jne @F
mov eax, [def_cursor]
mov [ebx+SLOT_BASE+APPDATA.cursor], eax
mov [ebx+APPDATA.cursor], eax
@@:
mov eax, [hcursor]
call [eax+APPOBJ.destroy]

View File

@ -27,7 +27,7 @@ endg
pushd [ScreenWidth] [ScreenHeight]
popd [old_screen_height] [old_screen_width]
or eax,-1 ; If driver is absent then eax does not change
call 0x760100 ; Entry point of video driver
call OS_BASE+0x760100 ; Entry point of video driver
mov [esp+36],eax
mov [esp+24],ebx
mov [esp+32],ecx

View File

@ -24,15 +24,8 @@ $Revision$
mov [OS_BASE+0x760000],eax ;
mov [OS_BASE+0x760100],byte 0xC3 ; Instruction RETN - driver loop
pushad
push eax
mov eax, vmode - std_application_base_address
call file_system_lfn
pop eax
popad
; mov esi, vmode
; xor ebx, ebx
; mov ecx, 0x8000 ; size of memory area for driver
; mov edx, OS_BASE+0x760000 ; Memory position of driver
; call fs_RamdiskRead
mov esi, vmode
xor ebx, ebx
mov ecx, 0x8000 ; size of memory area for driver
mov edx, OS_BASE+0x760000 ; Memory position of driver
call fs_RamdiskRead