Subversion Repositories Kolibri OS

Rev

Rev 7323 | Rev 7327 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2288 clevermous 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
5363 yogev_ezra 3
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
2288 clevermous 4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
8
$Revision: 7325 $
9
 
10
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11
;;                                                            ;;
12
;;                     SYSENTER ENTRY                         ;;
13
;;                                                            ;;
14
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15
 
16
align 32
17
sysenter_entry:
3539 clevermous 18
        ; Настраиваем стек
2288 clevermous 19
        mov     esp, [ss:tss._esp0]
20
        sti
21
        push    ebp                     ; save app esp + 4
22
        mov     ebp, [ebp]              ; ebp - original ebp
23
        ;------------------
24
        pushad
25
        cld
26
 
3303 clevermous 27
        call    protect_from_terminate
28
 
29
        movzx   eax, byte [esp+28]
3304 clevermous 30
        mov     edx, dword [esp+20]
2288 clevermous 31
        call    dword [servetable2 + eax * 4]
32
 
3303 clevermous 33
        call    unprotect_from_terminate
2288 clevermous 34
        popad
35
        ;------------------
3539 clevermous 36
        xchg    ecx, [ss:esp]           ; в вершин стека - app ecx, ecx - app esp + 4
2288 clevermous 37
        sub     ecx, 4
38
        xchg    edx, [ecx]              ; edx - return point, & save original edx
39
        push    edx
40
        mov     edx, [ss:esp + 4]
41
        mov     [ecx + 4], edx          ; save original ecx
42
        pop     edx
43
        sysexit
44
 
45
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
46
;;                                                            ;;
47
;;                   SYSTEM CALL ENTRY                        ;;
48
;;                                                            ;;
49
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
50
 
51
align 16
52
i40:
53
        pushad
54
        cld
3303 clevermous 55
        call    protect_from_terminate
56
        movzx   eax, byte [esp+28]
3304 clevermous 57
        mov     edx, dword [esp+20]
2288 clevermous 58
        call    dword [servetable2 + eax * 4]
3303 clevermous 59
        call    unprotect_from_terminate
2288 clevermous 60
        popad
61
        iretd
62
 
63
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
64
;;                                                            ;;
65
;;                     SYSCALL ENTRY                          ;;
66
;;                                                            ;;
67
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
68
align 32
69
syscall_entry:
70
  ;     cli                 syscall clear IF
71
        xchg    esp, [ss:tss._esp0]
72
        push    ecx
73
        lea     ecx, [esp+4]
74
        xchg    ecx, [ss:tss._esp0]
75
        sti
76
        push    ecx
77
        mov     ecx, [ecx]
78
        ;------------------
79
        pushad
80
        cld
3303 clevermous 81
        call    protect_from_terminate
2288 clevermous 82
 
3303 clevermous 83
        movzx   eax, byte [esp+28]
3304 clevermous 84
        mov     edx, dword [esp+20]
2288 clevermous 85
        call    dword [servetable2 + eax * 4]
86
 
3303 clevermous 87
        call    unprotect_from_terminate
2288 clevermous 88
        popad
89
        ;------------------
90
        mov     ecx, [ss:esp+4]
91
        pop     esp
92
        sysret
93
 
94
iglobal
95
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
96
  ;; SYSTEM FUNCTIONS TABLE ;;
97
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
98
  align 4
99
  servetable2:
100
 
101
      dd syscall_draw_window     ; 0-DrawWindow
102
      dd syscall_setpixel        ; 1-SetPixel
103
      dd sys_getkey              ; 2-GetKey
104
      dd sys_clock               ; 3-GetTime
105
      dd syscall_writetext       ; 4-WriteText
3303 clevermous 106
      dd delay_hs_unprotected    ; 5-DelayHs
4273 clevermous 107
      dd undefined_syscall       ; 6-deprecated OpenRamdiskFile
2288 clevermous 108
      dd syscall_putimage        ; 7-PutImage
109
      dd syscall_button          ; 8-DefineButton
110
      dd sys_cpuusage            ; 9-GetProcessInfo
111
      dd sys_waitforevent        ; 10-WaitForEvent
112
      dd sys_getevent            ; 11-CheckForEvent
113
      dd sys_redrawstat          ; 12-BeginDraw and EndDraw
114
      dd syscall_drawrect        ; 13-DrawRect
115
      dd syscall_getscreensize   ; 14-GetScreenSize
116
      dd sys_background          ; 15-bgr
117
      dd sys_cachetodiskette     ; 16-FlushFloppyCache
118
      dd sys_getbutton           ; 17-GetButton
119
      dd sys_system              ; 18-System Services
120
      dd paleholder              ; 19-reserved
121
      dd sys_midi                ; 20-ResetMidi and OutputMidi
122
      dd sys_setup               ; 21-SetMidiBase,SetKeymap,SetShiftKeymap,.
123
      dd sys_settime             ; 22-setting date,time,clock and alarm-clock
124
      dd sys_wait_event_timeout  ; 23-TimeOutWaitForEvent
125
      dd syscall_cdaudio         ; 24-PlayCdTrack,StopCd and GetCdPlaylist
2509 mario79 126
      dd syscall_putarea_backgr  ; 25-Put Area to background
2288 clevermous 127
      dd sys_getsetup            ; 26-GetMidiBase,GetKeymap,GetShiftKeymap,.
128
      dd undefined_syscall       ; 27-reserved
129
      dd undefined_syscall       ; 28-reserved
130
      dd sys_date                ; 29-GetDate
131
      dd sys_current_directory   ; 30-Get/SetCurrentDirectory
132
      dd undefined_syscall       ; 31-reserved
133
      dd undefined_syscall       ; 32-reserved
134
      dd undefined_syscall       ; 33-reserved
2511 mario79 135
      dd syscall_getpixel_WinMap ; 34-GetPixel WinMap
2288 clevermous 136
      dd syscall_getpixel        ; 35-GetPixel
137
      dd syscall_getarea         ; 36-GetArea
138
      dd readmousepos            ; 37-GetMousePosition_ScreenRelative,.
139
      dd syscall_drawline        ; 38-DrawLine
140
      dd sys_getbackground       ; 39-GetBackgroundSize,ReadBgrData,.
141
      dd set_app_param           ; 40-WantEvents
142
      dd undefined_syscall       ; 41- deprecated GetIrqOwner
143
      dd undefined_syscall       ; 42- deprecated ReadIrqData
144
      dd sys_outport             ; 43-SendDeviceData
145
      dd undefined_syscall       ; 44- deprecated ProgramIrqs
146
      dd undefined_syscall       ; 45- deprecated ReserveIrq and FreeIrq
147
      dd syscall_reserveportarea ; 46-ReservePortArea and FreePortArea
148
      dd display_number          ; 47-WriteNum
149
      dd syscall_display_settings ; 48-SetRedrawType and SetButtonType
150
      dd sys_apm                 ; 49-Advanced Power Management (APM)
151
      dd syscall_set_window_shape ; 50-Window shape & scale
152
      dd syscall_threads         ; 51-Threads
3837 mario79 153
      dd undefined_syscall       ; 52- deprecated Stack driver status
154
      dd undefined_syscall       ; 53- deprecated Socket interface
4199 mario79 155
      dd sys_clipboard           ; 54-Custom clipboard
2288 clevermous 156
      dd sound_interface         ; 55-Sound interface
157
      dd undefined_syscall       ; 56-reserved
158
      dd sys_pcibios             ; 57-PCI BIOS32
4273 clevermous 159
      dd undefined_syscall       ; 58-deprecated Common file system interface
2288 clevermous 160
      dd undefined_syscall       ; 59-reserved
161
      dd sys_IPC                 ; 60-Inter Process Communication
162
      dd sys_gs                  ; 61-Direct graphics access
3614 shikhin 163
      dd pci_api                 ; 62-PCI functions
164
      dd sys_msg_board           ; 63-System message board
2288 clevermous 165
      dd sys_resize_app_memory   ; 64-Resize application memory usage
166
      dd sys_putimage_palette    ; 65-PutImagePalette
167
      dd sys_process_def         ; 66-Process definitions - keyboard
168
      dd syscall_move_window     ; 67-Window move or resize
169
      dd f68                     ; 68-Some internal services
170
      dd sys_debug_services      ; 69-Debug
3303 clevermous 171
      dd file_system_lfn         ; 70-Common file system interface, version 2
2288 clevermous 172
      dd syscall_window_settings ; 71-Window settings
173
      dd sys_sendwindowmsg       ; 72-Send window message
174
      dd blit_32                 ; 73-blitter;
3545 hidnplayr 175
      dd sys_network             ; 74-reserved for new stack
176
      dd sys_socket              ; 75-reserved for new stack
177
      dd sys_protocols           ; 76-reserved for new stack
6926 serge 178
      dd sys_posix               ; posix support
6798 pathoswith 179
      dd undefined_syscall       ; 78-free
180
      dd undefined_syscall       ; 79-free
181
      dd fileSystemUnicode       ; 80-File system interface for different encodings
7319 pavelyakov 182
      dd setInt0x40              ; 81-Implementation of the function in the system
6079 serge 183
 
2288 clevermous 184
        times 255 - ( ($-servetable2) /4 )  dd undefined_syscall
185
      dd sys_end                 ; -1-end application
186
 
187
endg
7319 pavelyakov 188
 
189
; Author Pavel Iakovlev
7320 pavelyakov 190
align 32
7325 pavelyakov 191
callSet0x40:
192
        shl     eax, 2
193
        push    dword [memNewFunctionTable + eax]
194
        pop     dword [tempPointerAlloc]
195
        mov     eax, dword [memOldFunctionTable + eax]
196
        call    dword [tempPointerAlloc]
197
        ret
198
align 4
7319 pavelyakov 199
setInt0x40:
7321 pavelyakov 200
 
7320 pavelyakov 201
        and     ebx, 0FFh
7325 pavelyakov 202
        shl     ebx, 2
203
        mov     eax, dword [servetable2 + ebx]
204
 
7319 pavelyakov 205
        pushad
7325 pavelyakov 206
        sub     esi, edx
207
        add     esi, 16
208
        stdcall kernel_alloc, esi
209
        mov     dword [tempPointerAlloc], eax
7319 pavelyakov 210
        popad
7321 pavelyakov 211
 
7319 pavelyakov 212
        push    ebx
7325 pavelyakov 213
        mov     eax, dword [tempPointerAlloc]
7319 pavelyakov 214
        mov     ebx, eax
7325 pavelyakov 215
        add     eax, esi
216
        sub     eax, edx
7321 pavelyakov 217
 
7325 pavelyakov 218
        push    edx
219
        push    ecx
7319 pavelyakov 220
        loopCopyMemory:
7321 pavelyakov 221
 
7325 pavelyakov 222
        mov     cl, byte[edx]
223
        mov     byte[ebx], cl
7319 pavelyakov 224
        inc     ebx
7325 pavelyakov 225
        inc     edx
7319 pavelyakov 226
        cmp     ebx, eax
227
        jne     loopCopyMemory
7325 pavelyakov 228
 
229
        pop     ecx
230
        pop     edx
7319 pavelyakov 231
        pop     ebx
7325 pavelyakov 232
 
233
        mov     eax, dword [tempPointerAlloc]
234
        mov     esi, dword [servetable2 + ebx]
235
        cmp     esi, undefined_syscall
236
        jne     .step1
237
        sub     ecx, edx
238
        add     eax, ecx
239
        mov     dword [servetable2 + ebx], eax
7319 pavelyakov 240
        ret
7325 pavelyakov 241
        .step1:
242
        mov     dword [memOldFunctionTable + ebx], esi
243
        sub     ecx, edx
244
        add     eax, ecx
245
        mov     dword [memNewFunctionTable + ebx], eax
246
        mov     dword [servetable2 + ebx], callSet0x40
247
        ret
248
 
249
align 4
250
tempPointerAlloc dd 0
251
memOldFunctionTable: times 255 dd 0
252
memNewFunctionTable: times 255 dd 0
7319 pavelyakov 253
;-------------------