Subversion Repositories Kolibri OS

Rev

Rev 6 | Rev 40 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6 Rev 15
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                            ;;
2
;;                                                            ;;
3
;;                   SYSTEM CALL ENTRY                        ;;
3
;;                   SYSTEM CALL ENTRY                        ;;
4
;;                                                            ;;
4
;;                                                            ;;
5
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
uglobal
-
 
7
  pushed_regs rd 1
-
 
8
endg
-
 
9
 
6
 
10
align 32
7
align 32
11
i40:
8
i40:
-
 
9
      push  ds es
12
      pushad
10
      pushad
13
 
-
 
14
      push  ds
11
 
15
      mov   ax,word os_data
12
      mov   ax,word os_data
16
      mov   ds,ax
13
      mov   ds,ax
17
      mov   es,ax
14
      mov   es,ax
18
      mov   [pushed_regs],esp
-
 
19
      add   dword [pushed_regs],4
-
 
20
      cli
-
 
21
 
-
 
22
      mov    eax, [0x3000]
-
 
23
      mov    edi, eax
-
 
24
      shl    edi, 8
-
 
25
      mov    [edi+0x80000+0xB0],eax  ; used i40 handler
-
 
26
 
15
 
27
      ; for syscall trace function
16
      ; for syscall trace function
28
      call  save_registers
17
      call  save_registers
29
 
-
 
30
      mov   esi,[pushed_regs]
-
 
31
 
18
 
32
      ; load first 3 registers
-
 
33
      mov   eax,[esi+28]
-
 
34
      mov   ebx,[esi+16]
-
 
35
      mov   ecx,[esi+24]
-
 
36
 
-
 
37
      ; save current registers
-
 
38
      ; stack may be modified by a system function to return some value to caller!
-
 
39
      pushad
-
 
40
 
-
 
41
      ; load all registers from TSS of the application, in crossed order (why?)
19
      ; load all registers in crossed order
42
      mov   edi,[esi+28]
20
      mov   edi,[esp+28] ; eax
43
      mov   eax,[esi+16]
21
      mov   eax,[esp+16] ; ebx
44
      mov   ebx,[esi+24]
22
      mov   ebx,[esp+24] ; ecx
45
      mov   ecx,[esi+20]
23
      mov   ecx,[esp+20] ; edx
46
      mov   edx,[esi+4]
24
      mov   edx,[esp+4]  ; esi
47
      mov   esi,[esi+0]
25
      mov   esi,[esp+0]  ; edi
48
 
26
 
49
      ; enable interupts  -  a task switch or an IRQ _CAN_ interrupt i40 handler
27
      ; enable interupts  -  a task switch or an IRQ _CAN_ interrupt i40 handler
50
      sti
28
      sti
51
      ; eax doesn't need to be saved, but...
-
 
52
      push   eax
29
      push  eax
53
      and    edi,0xff
30
      and   edi,0xff
54
      call   dword [servetable+edi*4]
31
      call  dword [servetable+edi*4]
55
      pop    eax
32
      pop   eax
56
      cli
33
      cli
57
       
-
 
58
      ; return saved and probably even changed regs
-
 
59
      popad
-
 
60
 
-
 
61
      ; modify 3 program's registers (in its TSS)
-
 
62
      mov   [esi+28],eax   
-
 
63
      mov   [esi+16],ebx
-
 
64
      mov   [esi+24],ecx
-
 
65
 
-
 
66
      xor    eax, eax
-
 
67
      mov    edi, [0x3000]          ; no syscall interrupt in use anymore
-
 
68
      shl    edi, 8
-
 
69
      mov    [edi+0x80000+0xB0],eax
-
 
70
 
-
 
71
      pop     eax
-
 
72
      mov     ds,ax
-
 
73
      mov     es,ax
-
 
74
      
34
      
-
 
35
      popad
75
      popad
36
      pop   es ds
76
      iretd
37
      iretd
77
 
38
 
78
align 4
39
align 4
79
save_registers:
40
save_registers:
80
      mov   esi, [0x3010]
41
      mov   esi, [0x3010]
81
      mov   eax, [esi+0x4] ; load PID
42
      mov   eax, [esi+0x4] ; load PID
82
      mov   esi, [pushed_regs]
43
      lea   esi, [esp+4]
83
      inc   [save_syscall_count]
44
      inc   [save_syscall_count]
84
      mov   edi,[save_syscall_count]
45
      mov   edi,[save_syscall_count]
85
      and   edi,0xF
46
      and   edi,0xF
86
      shl   edi,6
47
      shl   edi,6
87
      add   edi,save_syscall_data+32
48
      add   edi,save_syscall_data+32
88
      mov   [edi-32],eax
49
      mov   [edi-32],eax
89
      mov   ecx,32 / 4
50
      mov   ecx,32 / 4
90
      cld
51
      cld
91
      rep   movsd
52
      rep   movsd
92
      ret
53
      ret
93
 
54
 
94
uglobal
55
uglobal
95
  save_syscall_count  dd 0x0
56
  save_syscall_count  dd 0x0
96
endg
57
endg
97
 
58
 
98
label save_syscall_data dword at 0x5000
59
label save_syscall_data dword at 0x5000
99
 
60
 
100
 
61
 
101
iglobal
62
iglobal
102
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
63
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
103
  ;; SYSTEM FUNCTIONS TABLE ;;
64
  ;; SYSTEM FUNCTIONS TABLE ;;
104
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
65
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
105
 
66
 
106
  align 4
67
  align 4
107
  servetable:
68
  servetable:
108
 
69
 
109
      dd sys_drawwindow          ; 0-DrawWindow
70
      dd sys_drawwindow          ; 0-DrawWindow
110
      dd syscall_setpixel        ; 1-SetPixel
71
      dd syscall_setpixel        ; 1-SetPixel
111
      dd sys_getkey              ; 2-GetKey
72
      dd sys_getkey              ; 2-GetKey
112
      dd sys_clock               ; 3-GetTime
73
      dd sys_clock               ; 3-GetTime
113
      dd syscall_writetext       ; 4-WriteText
74
      dd syscall_writetext       ; 4-WriteText
114
      dd delay_hs                ; 5-DelayHs
75
      dd delay_hs                ; 5-DelayHs
115
      dd syscall_openramdiskfile ; 6-OpenRamdiskFile
76
      dd syscall_openramdiskfile ; 6-OpenRamdiskFile
116
      dd syscall_putimage        ; 7-PutImage
77
      dd syscall_putimage        ; 7-PutImage
117
      dd sys_button              ; 8-DefineButton
78
      dd sys_button              ; 8-DefineButton
118
      dd sys_cpuusage            ; 9-GetProcessInfo
79
      dd sys_cpuusage            ; 9-GetProcessInfo
119
      dd sys_waitforevent        ; 10-WaitForEvent
80
      dd sys_waitforevent        ; 10-WaitForEvent
120
      dd sys_getevent            ; 11-CheckForEvent
81
      dd sys_getevent            ; 11-CheckForEvent
121
      dd sys_redrawstat          ; 12-BeginDraw and EndDraw
82
      dd sys_redrawstat          ; 12-BeginDraw and EndDraw
122
      dd syscall_drawrect        ; 13-DrawRect
83
      dd syscall_drawrect        ; 13-DrawRect
123
      dd syscall_getscreensize   ; 14-GetScreenSize
84
      dd syscall_getscreensize   ; 14-GetScreenSize
124
      dd sys_background          ; 15-bgr
85
      dd sys_background          ; 15-bgr
125
      dd sys_cachetodiskette     ; 16-FlushFloppyCache
86
      dd sys_cachetodiskette     ; 16-FlushFloppyCache
126
      dd sys_getbutton           ; 17-GetButton
87
      dd sys_getbutton           ; 17-GetButton
127
      dd syscall_system          ; 18-Shutdown,KillApp,WindowActivate
88
      dd syscall_system          ; 18-Shutdown,KillApp,WindowActivate
128
      dd syscall_startapp        ; 19-StartApp
89
      dd syscall_startapp        ; 19-StartApp
129
      dd sys_midi                ; 20-ResetMidi and OutputMidi
90
      dd sys_midi                ; 20-ResetMidi and OutputMidi
130
      dd sys_setup               ; 21-SetMidiBase,SetKeymap,SetShiftKeymap,.
91
      dd sys_setup               ; 21-SetMidiBase,SetKeymap,SetShiftKeymap,.
131
      dd sys_settime             ; 22-setting date,time,clock and alarm-clock
92
      dd sys_settime             ; 22-setting date,time,clock and alarm-clock
132
      dd sys_wait_event_timeout  ; 23-TimeOutWaitForEvent
93
      dd sys_wait_event_timeout  ; 23-TimeOutWaitForEvent
133
      dd syscall_cdaudio         ; 24-PlayCdTrack,StopCd and GetCdPlaylist
94
      dd syscall_cdaudio         ; 24-PlayCdTrack,StopCd and GetCdPlaylist
134
      dd sys_sb16                ; 25-SetSb16
95
      dd sys_sb16                ; 25-SetSb16
135
      dd sys_getsetup            ; 26-GetMidiBase,GetKeymap,GetShiftKeymap,.
96
      dd sys_getsetup            ; 26-GetMidiBase,GetKeymap,GetShiftKeymap,.
136
      dd sys_wss                 ; 27-SetWssMainVol and SetWssCdVol
97
      dd sys_wss                 ; 27-SetWssMainVol and SetWssCdVol
137
      dd sys_sb16II              ; 28-SetSb16
98
      dd sys_sb16II              ; 28-SetSb16
138
      dd sys_date                ; 29-GetDate
99
      dd sys_date                ; 29-GetDate
139
      dd syscall_readhd          ; 30-ReadHd
100
      dd syscall_readhd          ; 30-ReadHd
140
      dd syscall_starthdapp      ; 31-StartHdApp
101
      dd syscall_starthdapp      ; 31-StartHdApp
141
      dd syscall_delramdiskfile  ; 32-DelRamdiskFile
102
      dd syscall_delramdiskfile  ; 32-DelRamdiskFile
142
      dd syscall_writeramdiskfile; 33-WriteRamdiskFile
103
      dd syscall_writeramdiskfile; 33-WriteRamdiskFile
143
      dd read_floppy_file        ; 34-ReadFloppyDrive
104
      dd read_floppy_file        ; 34-ReadFloppyDrive
144
      dd syscall_getpixel        ; 35-GetPixel
105
      dd syscall_getpixel        ; 35-GetPixel
145
      dd syscall_readstring      ; 36-ReadString (not yet ready)
106
      dd syscall_readstring      ; 36-ReadString (not yet ready)
146
      dd readmousepos            ; 37-GetMousePosition_ScreenRelative,.
107
      dd readmousepos            ; 37-GetMousePosition_ScreenRelative,.
147
      dd syscall_drawline        ; 38-DrawLine
108
      dd syscall_drawline        ; 38-DrawLine
148
      dd sys_getbackground       ; 39-GetBackgroundSize,ReadBgrData,.
109
      dd sys_getbackground       ; 39-GetBackgroundSize,ReadBgrData,.
149
      dd set_app_param           ; 40-WantEvents
110
      dd set_app_param           ; 40-WantEvents
150
      dd syscall_getirqowner     ; 41-GetIrqOwner
111
      dd syscall_getirqowner     ; 41-GetIrqOwner
151
      dd get_irq_data            ; 42-ReadIrqData
112
      dd get_irq_data            ; 42-ReadIrqData
152
      dd sys_outport             ; 43-SendDeviceData
113
      dd sys_outport             ; 43-SendDeviceData
153
      dd sys_programirq          ; 44-ProgramIrqs
114
      dd sys_programirq          ; 44-ProgramIrqs
154
      dd reserve_free_irq        ; 45-ReserveIrq and FreeIrq
115
      dd reserve_free_irq        ; 45-ReserveIrq and FreeIrq
155
      dd syscall_reserveportarea ; 46-ReservePortArea and FreePortArea
116
      dd syscall_reserveportarea ; 46-ReservePortArea and FreePortArea
156
      dd display_number          ; 47-WriteNum
117
      dd display_number          ; 47-WriteNum
157
      dd display_settings        ; 48-SetRedrawType and SetButtonType
118
      dd display_settings        ; 48-SetRedrawType and SetButtonType
158
      dd syscall_appints         ; 49-AppInts
119
      dd syscall_appints         ; 49-AppInts
159
      dd random_shaped_window    ; 50-Window shape & scale
120
      dd random_shaped_window    ; 50-Window shape & scale
160
      dd syscall_threads         ; 51-Threads
121
      dd syscall_threads         ; 51-Threads
161
      dd stack_driver_stat       ; 52-Stack driver status
122
      dd stack_driver_stat       ; 52-Stack driver status
162
      dd socket                  ; 53-Socket interface
123
      dd socket                  ; 53-Socket interface
163
      dd user_events             ; 54-User events
124
      dd user_events             ; 54-User events
164
      dd sound_interface         ; 55-Sound interface
125
      dd sound_interface         ; 55-Sound interface
165
      dd write_to_hd             ; 56-Write a file to hd
126
      dd write_to_hd             ; 56-Write a file to hd
166
      dd delete_from_hd          ; 57-Delete a file from hd
127
      dd delete_from_hd          ; 57-Delete a file from hd
167
      dd file_system             ; 58-Common file system interface
128
      dd file_system             ; 58-Common file system interface
168
      dd sys_trace               ; 59-System call trace
129
      dd sys_trace               ; 59-System call trace
169
      dd new_sys_ipc             ; 60-Inter Process Communication
130
      dd new_sys_ipc             ; 60-Inter Process Communication
170
      dd sys_gs                  ; 61-Direct graphics access
131
      dd sys_gs                  ; 61-Direct graphics access
171
      dd sys_pci                 ; 62-PCI functions
132
      dd sys_pci                 ; 62-PCI functions
172
      dd sys_msg_board           ; 63-System message board
133
      dd sys_msg_board           ; 63-System message board
173
      dd sys_resize_app_memory   ; 64-Resize application memory usage
134
      dd sys_resize_app_memory   ; 64-Resize application memory usage
174
      dd undefined_syscall       ; 65-UTF
135
      dd undefined_syscall       ; 65-UTF
175
      dd sys_process_def         ; 66-Process definitions - keyboard
136
      dd sys_process_def         ; 66-Process definitions - keyboard
176
      dd sys_window_move         ; 67-Window move or resize
137
      dd sys_window_move         ; 67-Window move or resize
177
      dd sys_internal_services   ; 68-Some internal services
138
      dd sys_internal_services   ; 68-Some internal services
178
 
139
 
179
  times 255 - ( ($-servetable) /4 )  dd undefined_syscall
140
  times 255 - ( ($-servetable) /4 )  dd undefined_syscall
180
 
141
 
181
      dd sys_end                 ; -1-end application
142
      dd sys_end                 ; -1-end application
182
endg
143
endg