Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 670 → Rev 671

/kernel/trunk/core/syscall.inc
7,7 → 7,21
 
$Revision$
 
; Old style system call converter
align 16
cross_order:
; load all registers in crossed order
mov eax, ebx
mov ebx, ecx
mov ecx, edx
mov edx, esi
mov esi, edi
mov edi, [esp+28 + 4]
and edi,0xff
call dword [servetable+edi*4]
ret
 
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; SYSTEM CALL ENTRY ;;
14,36 → 28,15
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 
align 16
i40:
; diamond, 27.03.2007: handler does not require disabled interrupts
; so interrupts remain enabled when calling int 0x40
pushad
cld
 
; mov ax, word app_data
; mov ds, ax
; mov es, ax
 
; load all registers in crossed order
mov eax, ebx
mov ebx, ecx
mov ecx, edx
mov edx, esi
mov esi, edi
mov edi, [esp+28]
 
; enable interupts - a task switch or an IRQ _CAN_ interrupt i40 handler
; sti
push eax
and edi,0xff
call dword [servetable+edi*4]
pop eax
 
and eax, 0xff
call dword [servetable2 + eax * 4]
popad
iretd
 
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; SYSENTER ENTRY ;;
61,18 → 54,9
pushad
cld
 
mov eax, ebx
mov ebx, ecx
mov ecx, edx
mov edx, esi
mov esi, edi
mov edi, [esp + 28]
and eax, 0xff
call dword [servetable2 + eax * 4]
 
push eax
and edi, 0xff
call dword [servetable + edi * 4]
pop eax
 
popad
;------------------
xchg ecx, [ss:esp] ; â âåðøèí ñòåêà - app ecx, ecx - app esp + 4
99,37 → 83,15
sti
push ecx
mov ecx, [ecx]
 
; mov [ss:sysenter_stack - 4], eax
; mov eax, [ss:CURRENT_TASK]
; shl eax, 8
; 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
 
;------------------
pushad
cld
 
; mov ax, word app_data
; mov ds, ax
; mov es, ax
and eax, 0xff
call dword [servetable2 + eax * 4]
 
mov eax, ebx
mov ebx, ecx
mov ecx, edx
mov edx, esi
mov esi, edi
mov edi, [esp + 28]
 
push eax
and edi, 0xff
call dword [servetable + edi * 4]
pop eax
 
popad
;------------------
 
mov ecx, [ss:esp+4]
pop esp
sysret
143,45 → 105,45
 
dd sys_drawwindow ; 0-DrawWindow
dd syscall_setpixel ; 1-SetPixel
dd sys_getkey ; 2-GetKey
dd sys_clock ; 3-GetTime
dd 0
dd 0
dd syscall_writetext ; 4-WriteText
dd delay_hs ; 5-DelayHs
dd syscall_openramdiskfile ; 6-OpenRamdiskFile
dd syscall_putimage ; 7-PutImage
dd 0
dd sys_button ; 8-DefineButton
dd sys_cpuusage ; 9-GetProcessInfo
dd sys_waitforevent ; 10-WaitForEvent
dd sys_getevent ; 11-CheckForEvent
dd sys_redrawstat ; 12-BeginDraw and EndDraw
dd syscall_drawrect ; 13-DrawRect
dd syscall_getscreensize ; 14-GetScreenSize
dd 0
dd 0
dd 0
dd 0
dd 0
dd sys_background ; 15-bgr
dd sys_cachetodiskette ; 16-FlushFloppyCache
dd sys_getbutton ; 17-GetButton
dd 0
dd 0
dd sys_system ; 18-System Services
dd paleholder;undefined_syscall ; 19-reserved
dd 0
dd sys_midi ; 20-ResetMidi and OutputMidi
dd sys_setup ; 21-SetMidiBase,SetKeymap,SetShiftKeymap,.
dd sys_settime ; 22-setting date,time,clock and alarm-clock
dd sys_wait_event_timeout ; 23-TimeOutWaitForEvent
dd 0
dd syscall_cdaudio ; 24-PlayCdTrack,StopCd and GetCdPlaylist
dd sys_sb16 ; 25-SetSb16
dd sys_getsetup ; 26-GetMidiBase,GetKeymap,GetShiftKeymap,.
dd undefined_syscall ; 27-reserved
dd 0
dd sys_sb16II ; 28-SetSb16
dd sys_date ; 29-GetDate
dd 0
dd sys_current_directory ; 30-Get/SetCurrentDirectory
dd undefined_syscall ; 31-reserved
dd 0
dd syscall_delramdiskfile ; 32-DelRamdiskFile
dd syscall_writeramdiskfile; 33-WriteRamdiskFile
dd undefined_syscall ; 34-reserved
dd syscall_getpixel ; 35-GetPixel
dd syscall_readstring ; 36-ReadString (not yet ready)
dd 0
dd 0
dd 0
dd readmousepos ; 37-GetMousePosition_ScreenRelative,.
dd syscall_drawline ; 38-DrawLine
dd sys_getbackground ; 39-GetBackgroundSize,ReadBgrData,.
dd set_app_param ; 40-WantEvents
dd 0
dd syscall_getirqowner ; 41-GetIrqOwner
dd get_irq_data ; 42-ReadIrqData
dd sys_outport ; 43-SendDeviceData
195,12 → 157,12
dd syscall_threads ; 51-Threads
dd stack_driver_stat ; 52-Stack driver status
dd socket ; 53-Socket interface
dd user_events ; 54-User events
dd 0
dd sound_interface ; 55-Sound interface
dd undefined_syscall ; 56-reserved
dd sys_pcibios ; 57-reserved
dd 0
dd sys_pcibios ; 57-PCI BIOS32
dd file_system ; 58-Common file system interface
dd undefined_syscall ; 59-reserved
dd 0
dd sys_IPC ; 60-Inter Process Communication
dd sys_gs ; 61-Direct graphics access
dd sys_pci ; 62-PCI functions
215,7 → 177,86
dd syscall_windowsettings ; 71-Window settings
dd sys_sendwindowmsg ; 72-Send window message
 
times 255 - ( ($-servetable) /4 ) dd undefined_syscall
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; NEW SYSTEM FUNCTIONS TABLE ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
align 4
servetable2:
 
dd cross_order ; 0-DrawWindow
dd cross_order ; 1-SetPixel
dd sys_getkey ; 2-GetKey
dd sys_clock ; 3-GetTime
dd cross_order ; 4-WriteText
dd cross_order ; 5-DelayHs
dd cross_order ; 6-OpenRamdiskFile
dd syscall_putimage ; 7-PutImage
dd cross_order ; 8-DefineButton
dd cross_order ; 9-GetProcessInfo
dd sys_waitforevent ; 10-WaitForEvent
dd sys_getevent ; 11-CheckForEvent
dd sys_redrawstat ; 12-BeginDraw and EndDraw
dd syscall_drawrect ; 13-DrawRect
dd syscall_getscreensize ; 14-GetScreenSize
dd cross_order ; 15-bgr
dd sys_cachetodiskette ; 16-FlushFloppyCache
dd sys_getbutton ; 17-GetButton
dd cross_order ; 18-System Services
dd paleholder ; 19-reserved
dd cross_order ; 20-ResetMidi and OutputMidi
dd cross_order ; 21-SetMidiBase,SetKeymap,SetShiftKeymap,.
dd cross_order ; 22-setting date,time,clock and alarm-clock
dd sys_wait_event_timeout ; 23-TimeOutWaitForEvent
dd cross_order ; 24-PlayCdTrack,StopCd and GetCdPlaylist
dd cross_order ; 25-SetSb16
dd cross_order ; 26-GetMidiBase,GetKeymap,GetShiftKeymap,.
dd undefined_syscall ; 27-reserved
dd cross_order ; 28-SetSb16
dd sys_date ; 29-GetDate
dd cross_order ; 30-Get/SetCurrentDirectory
dd undefined_syscall ; 31-reserved
dd cross_order ; 32-DelRamdiskFile
dd cross_order ; 33-WriteRamdiskFile
dd undefined_syscall ; 34-reserved
dd syscall_getpixel ; 35-GetPixel
dd undefined_syscall ; 36-reserved
dd cross_order ; 37-GetMousePosition_ScreenRelative,.
dd cross_order ; 38-DrawLine
dd cross_order ; 39-GetBackgroundSize,ReadBgrData,.
dd set_app_param ; 40-WantEvents
dd cross_order ; 41-GetIrqOwner
dd cross_order ; 42-ReadIrqData
dd cross_order ; 43-SendDeviceData
dd cross_order ; 44-ProgramIrqs
dd cross_order ; 45-ReserveIrq and FreeIrq
dd cross_order ; 46-ReservePortArea and FreePortArea
dd cross_order ; 47-WriteNum
dd cross_order ; 48-SetRedrawType and SetButtonType
dd cross_order ; 49-Advanced Power Management (APM)
dd cross_order ; 50-Window shape & scale
dd cross_order ; 51-Threads
dd cross_order ; 52-Stack driver status
dd cross_order ; 53-Socket interface
dd undefined_syscall ; 54-reserved
dd cross_order ; 55-Sound interface
dd undefined_syscall ; 56-reserved
dd cross_order ; 57-PCI BIOS32
dd cross_order ; 58-Common file system interface
dd undefined_syscall ; 59-reserved
dd cross_order ; 60-Inter Process Communication
dd cross_order ; 61-Direct graphics access
dd cross_order ; 62-PCI functions
dd cross_order ; 63-System message board
dd cross_order ; 64-Resize application memory usage
dd cross_order ; 65-PutImagePalette
dd cross_order ; 66-Process definitions - keyboard
dd cross_order ; 67-Window move or resize
dd cross_order ; 68-Some internal services
dd cross_order ; 69-Debug
dd cross_order ; 70-Common file system interface, version 2
dd cross_order ; 71-Window settings
dd cross_order ; 72-Send window message
times 255 - ( ($-servetable2) /4 ) dd undefined_syscall
dd sys_end ; -1-end application
endg
/kernel/trunk/gui/event.inc
468,18 → 468,18
sys_getevent:
 
call get_event_for_app
mov [esp+36],eax
mov [esp + 32],eax
ret
 
sys_waitforevent:
or eax, 0xFFFFFFFF ; infinite timeout
or ebx, 0xFFFFFFFF ; infinite timeout
jmp @f
 
sys_wait_event_timeout:
add eax, [timer_ticks]
add ebx, [timer_ticks]
@@:
mov ebx, [current_slot]
mov [ebx + APPDATA.wait_timeout], eax
mov eax, [current_slot]
mov [eax + APPDATA.wait_timeout], ebx
call get_event_for_app
test eax, eax
jnz eventoccur
490,7 → 490,7
 
mov eax, [event_sched]
eventoccur:
mov [esp+36], eax
mov [esp+32], eax
ret
 
sys_sendwindowmsg:
/kernel/trunk/kernel.asm
1034,14 → 1034,6
mov [irq_owner+4*14], 1 ; ide I
mov [irq_owner+4*15], 1 ; ide II
 
; movzx eax,byte [0xf604] ; mouse irq
; dec eax
; add eax,mouseirqtable
; movzx eax,byte [eax]
; shl eax,2
; mov [irq_owner+eax],byte 1
 
 
; RESERVE PORTS
mov edi,1 ; 0x00-0x2d
mov [RESERVED_PORTS],edi
1071,26 → 1063,6
mov [RESERVED_PORTS+edi+4],dword 0xe5
mov [RESERVED_PORTS+edi+8],dword 0xff
 
 
; cmp [0xf604],byte 2 ; com1 mouse -> 0x3f0-0x3ff
; jne ripl1
; inc dword [0x2d0000]
; mov edi,[0x2d0000]
; shl edi,4
; mov [0x2d0000+edi+0],dword 1
; mov [0x2d0000+edi+4],dword 0x3f0
; mov [0x2d0000+edi+8],dword 0x3ff
; ripl1:
; cmp [0xf604],byte 3 ; com2 mouse -> 0x2f0-0x2ff
; jne ripl2
; inc dword [0x2d0000]
; mov edi,[0x2d0000]
; shl edi,4
; mov [0x2d0000+edi+0],dword 1
; mov [0x2d0000+edi+4],dword 0x2f0
; mov [0x2d0000+edi+8],dword 0x2ff
; ripl2:
 
popad
ret
 
1472,22 → 1444,6
ret
 
draw_num_text:
 
; dtext
;
; eax x & y
; ebx color
; ecx start of text
; edx length
; edi 1 force
 
; mov edi,[CURRENT_TASK]
; shl edi,8
; add ax,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top]
; rol eax,16
; add ax,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left]
; rol eax,16
 
mov edx,eax
mov ecx,64+4
sub ecx,eax
1512,17 → 1468,6
mov edi, [esp+64+4]
jmp dtext
 
read_string:
 
; eax read_area
; ebx color of letter
; ecx color of background
; edx number of letters to read
; esi [x start]*65536 + [y_start]
 
ret
 
 
align 4
 
sys_setup:
2408,50 → 2353,22
UID_KOLIBRI=2 ;russian
 
sys_cachetodiskette:
; pushad
; cmp eax,1
; jne no_write_all_of_ramdisk
; call fdc_writeramdisk
; popad
; ret
; no_write_all_of_ramdisk:
; cmp eax,2
; jne no_write_part_of_ramdisk
; call fdc_commitflush
; popad
; ret
; no_write_part_of_ramdisk:
; cmp eax,3
; jne no_set_fdc
; call fdc_set
; popad
; ret
; no_set_fdc:
; cmp eax,4
; jne no_get_fdc
; popad
; call fdc_get
; mov [esp+36],ecx
; ret
; no_get_fdc:
; popad
; ret
cmp eax,1
jne no_floppy_a_save
cmp ebx, 1
jne .no_floppy_a_save
mov [flp_number],1
jmp save_image_on_floppy
no_floppy_a_save:
cmp eax,2
jne no_floppy_b_save
jmp .save_image_on_floppy
.no_floppy_a_save:
cmp ebx, 2
jne .no_floppy_b_save
mov [flp_number],2
save_image_on_floppy:
.save_image_on_floppy:
call save_image
mov [esp+36],dword 0
mov [esp + 32], dword 0
cmp [FDC_Status],0
je yes_floppy_save
no_floppy_b_save:
mov [esp+36],dword 1
yes_floppy_save:
je .yes_floppy_save
.no_floppy_b_save:
mov [esp + 32], dword 1
.yes_floppy_save:
ret
 
uglobal
2684,7 → 2601,7
align 4
 
sys_getkey:
mov [esp+36],dword 1
mov [esp + 32],dword 1
; test main buffer
mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK
movzx ecx,word [WIN_STACK + ebx * 2]
2700,16 → 2617,12
and byte [KEY_COUNT],127
movzx ecx,byte [KEY_COUNT]
add ecx,2
; mov esi,0xf402
; mov edi,0xf401
; cld
; rep movsb
mov eax, KEY_BUFF+1
mov ebx, KEY_BUFF
call memmove
pop eax
.ret_eax:
mov [esp+36],eax
mov [esp + 32], eax
ret
.finish:
; test hotkeys buffer
2735,7 → 2648,7
sys_getbutton:
 
mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK
mov [esp+36],dword 1
mov [esp + 32], dword 1
movzx ecx, word [WIN_STACK + ebx * 2]
mov edx, [TASK_COUNT] ; less than 256 processes
cmp ecx,edx
2746,7 → 2659,7
mov eax,[BTN_BUFF]
shl eax,8
mov [BTN_COUNT],byte 0
mov [esp+36],eax
mov [esp + 32], eax
.exit:
ret
 
2906,7 → 2819,7
movzx edx,al
add ecx,edx
sti
mov [esp+36],ecx
mov [esp + 32], ecx
ret
 
 
2915,7 → 2828,6
sys_date:
 
cli
 
@@: mov al, 10
out 0x70, al
in al, 0x71
2941,7 → 2853,7
in al,0x71
mov cl,al
sti
mov [esp+36],ecx
mov [esp+32], ecx
ret
 
 
2948,27 → 2860,18
; redraw status
 
sys_redrawstat:
 
cmp eax,1
cmp ebx, 1
jne no_widgets_away
 
; buttons away
 
mov ecx,[CURRENT_TASK]
 
sys_newba2:
 
mov edi,[BTN_ADDR]
cmp [edi],dword 0 ; empty button list ?
je end_of_buttons_away
 
movzx ebx,word [edi]
inc ebx
 
mov eax,edi
 
sys_newba:
 
dec ebx
jz end_of_buttons_away
 
2994,7 → 2897,7
 
no_widgets_away:
 
cmp eax,2
cmp ebx, 2
jnz srl1
 
mov edx,[TASK_BASE] ; return whole screen draw area for this app
3008,13 → 2911,10
 
mov edi,[TASK_BASE]
or [edi-twdw+WDATA.fl_wdrawn], 1 ; no new position & buttons from app
 
call sys_window_mouse
 
ret
 
srl1:
 
ret
 
 
3888,12 → 3788,8
 
 
set_app_param:
push edi
 
mov edi,[TASK_BASE]
mov [edi+TASKDATA.event_mask],eax
 
pop edi
mov [edi + TASKDATA.event_mask], ebx
ret
 
 
4330,11 → 4226,6
align 4
 
syscall_putimage: ; PutImage
 
mov edx,ecx
mov ecx,ebx
mov ebx, eax
 
sys_putimage:
test ecx,0x80008000
jnz .exit
4773,7 → 4664,7
 
mov ecx,[msg_board_count]
cmp eax, 1
jne smbl1
jne .smbl1
 
 
mov [msg_board_data+ecx],bl
4782,35 → 4673,23
mov [msg_board_count], ecx
mov [check_idle_semaphore], 5
ret
smbl1:
 
.smbl1:
cmp eax, 2
jne smbl2
jne .smbl2
test ecx, ecx
jz smbl21
; mov edi, msg_board_data
; mov esi, msg_board_data+1
; movzx eax, byte [edi]
jz .smbl21
mov eax, msg_board_data+1
mov ebx, msg_board_data
movzx edx, byte [ebx]
call memmove
; push ecx
; shr ecx, 2
; cld
; rep movsd
; pop ecx
; and ecx, 3
; rep movsb
dec [msg_board_count]
mov [esp+36], edx ;eax
mov [esp+24], dword 1
ret
smbl21:
.smbl21:
mov [esp+36], ecx
mov [esp+24], ecx
 
smbl2:
.smbl2:
ret
 
 
5024,33 → 4903,36
 
syscall_drawrect: ; DrawRect
 
mov edi,ecx
mov edi, edx ; color + gradient
and edi,0x80FFFFFF
test ax,ax
je drectr
test bx,bx
je drectr
movzx ecx,ax
shr eax,16
movzx edx,bx
shr ebx,16
test bx, bx ; x.size
je .drectr
test cx, cx ; y.size
je .drectr
 
mov eax, ebx ; bad idea
mov ebx, ecx
 
movzx ecx, ax ; ecx - x.size
shr eax, 16 ; eax - x.coord
movzx edx, bx ; edx - y.size
shr ebx, 16 ; ebx - y.coord
mov esi,[current_slot]
 
add eax,[esi+APPDATA.wnd_clientbox.left]
add ebx,[esi+APPDATA.wnd_clientbox.top]
add ecx,eax
add edx,ebx
jmp [drawbar]
drectr:
.drectr:
ret
 
align 4
 
syscall_getscreensize: ; GetScreenSize
 
movzx eax,word[ScreenWidth]
mov ax, [ScreenWidth]
shl eax,16
mov ax,[ScreenHeight]
mov [esp+36],eax
mov [esp + 32], eax
ret
 
align 4
5140,24 → 5022,15
mov ecx,[ScreenWidth]
inc ecx
xor edx,edx
mov eax, ebx
div ecx
mov ebx,edx
xchg eax,ebx
call dword [GETPIXEL]
mov [esp+36],ecx
call dword [GETPIXEL] ; eax - x, ebx - y
mov [esp + 32], ecx
ret
 
align 4
 
syscall_readstring: ; ReadString
 
mov edi,[TASK_BASE]
add edi,TASKDATA.mem_start
add eax,[edi]
call read_string
mov [esp+36],eax
ret
 
align 4
 
syscall_drawline: ; DrawLine
5237,15 → 5110,6
 
align 4
 
user_events: ; User event times
 
mov eax,0x12345678
mov [esp+36],eax
 
ret
 
align 4
 
read_from_hd: ; Read from hd - fn not in use
 
mov edi,[TASK_BASE]
5321,8 → 5185,7
align 4
 
undefined_syscall: ; Undefined system call
 
mov [esp+36],dword -1
mov [esp + 32], dword -1
ret
 
align 4