Subversion Repositories Kolibri OS

Rev

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

Rev 3 Rev 4
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                            ;;
2
;;                                                            ;;
3
;;                   SYSTEM CALL ENTRY                        ;;
3
;;                   SYSTEM CALL ENTRY                        ;;
4
;;                                                            ;;
4
;;                                                            ;;
5
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
uglobal
6
uglobal
7
  task_tss rd 1
7
  task_tss rd 1
8
endg
8
endg
9
align 32
9
align 32
10
i40:
10
i40:
11
      pushad
11
      pushad
12
 
12
 
13
      push  ds
13
      push  ds
14
      mov   ax,word os_data
14
      mov   ax,word os_data
15
      mov   ds,ax
15
      mov   ds,ax
16
      mov   es,ax
16
      mov   es,ax
17
      mov   [task_tss],esp
17
      mov   [task_tss],esp
18
      add   dword [task_tss],4
18
      add   dword [task_tss],4
19
      cli
19
      cli
20
 
20
 
21
      mov    edi,[0x3000]
21
      mov    edi,[0x3000]
22
      mov    eax,edi
22
      mov    eax,edi
23
      shl    edi, 3
23
      shl    edi, 3
24
;clear busy flag in application's TSS      
24
;clear busy flag in application's TSS      
25
      mov    [edi+gdts+ tss0 +5], word 01010000b *256 +11101001b
25
      mov    [edi+gdts+ tss0 +5], word 01010000b *256 +11101001b
26
      
-
 
27
;save GDT TSS entry
-
 
28
;      mov    edx,[edi+tss0_l]
-
 
29
;      mov    [reg1+eax*4],edx
-
 
30
;      mov    edx,[edi+tss0_l+4]
-
 
31
;      mov    [reg2+eax*4],edx
-
 
32
;and then write there i40's descriptor
-
 
33
;      mov    edx,[tss0sys_l+edi]
-
 
34
;      mov    [edi+tss0_l],edx
-
 
35
;      mov    edx,[tss0sys_l+edi+4]
-
 
36
;      mov    [edi+tss0_l+4],edx            
-
 
37
 
26
 
38
 
27
 
39
      shl    edi,5
28
      shl    edi,5
40
      mov    [edi+0x80000+0xB0],eax  ; used i40 handler
29
      mov    [edi+0x80000+0xB0],eax  ; used i40 handler
41
 
30
 
42
      ; for syscall trace function
31
      ; for syscall trace function
43
      call  save_registers
32
      call  save_registers
44
 
33
 
45
;      mov   esi, [0x3000]
34
;      mov   esi, [0x3000]
46
;      imul  esi, tss_step
35
;      imul  esi, tss_step
47
;      add   esi, tss_data
36
;      add   esi, tss_data
48
      mov   esi,[task_tss]
37
      mov   esi,[task_tss]
49
;      sub   esi,0x28
38
;      sub   esi,0x28
50
      ; esi holds address of TSS of interupted program
39
      ; esi holds address of TSS of interupted program
51
      ; load first 3 registers
40
      ; load first 3 registers
52
      mov   eax,[esi+28];+l.eax-tss_sceleton]
41
      mov   eax,[esi+28];+l.eax-tss_sceleton]
53
      mov   ebx,[esi+16];l.ebx-tss_sceleton]
42
      mov   ebx,[esi+16];l.ebx-tss_sceleton]
54
      mov   ecx,[esi+24];l.ecx-tss_sceleton]
43
      mov   ecx,[esi+24];l.ecx-tss_sceleton]
55
 
44
 
56
      ; save current registers
45
      ; save current registers
57
      ; stack may be modified by a system function to return some value to caller!
46
      ; stack may be modified by a system function to return some value to caller!
58
      pushad
47
      pushad
59
 
48
 
60
      ; load all registers from TSS of the application, in crossed order (why?)
49
      ; load all registers from TSS of the application, in crossed order (why?)
61
      mov   edi,[esi+28];l.eax-tss_sceleton]
50
      mov   edi,[esi+28];l.eax-tss_sceleton]
62
      mov   eax,[esi+16];l.ebx-tss_sceleton]
51
      mov   eax,[esi+16];l.ebx-tss_sceleton]
63
      mov   ebx,[esi+24];l.ecx-tss_sceleton]
52
      mov   ebx,[esi+24];l.ecx-tss_sceleton]
64
      mov   ecx,[esi+20];l.edx-tss_sceleton]
53
      mov   ecx,[esi+20];l.edx-tss_sceleton]
65
      mov   edx,[esi+4];l.esi-tss_sceleton]
54
      mov   edx,[esi+4];l.esi-tss_sceleton]
66
      mov   esi,[esi+0];l.edi-tss_sceleton]
55
      mov   esi,[esi+0];l.edi-tss_sceleton]
67
 
56
 
68
      ; enable interupts  -  a task switch or an IRQ _CAN_ interrupt i40 handler
57
      ; enable interupts  -  a task switch or an IRQ _CAN_ interrupt i40 handler
69
      sti
58
      sti
70
      ; eax doesn't need to be saved, but...
59
      ; eax doesn't need to be saved, but...
71
      push   eax
60
      push   eax
72
      and    edi,0xff
61
      and    edi,0xff
73
      call   dword [servetable+edi*4]
62
      call   dword [servetable+edi*4]
74
      pop    eax
63
      pop    eax
75
      cli
64
      cli
76
       
65
       
77
      ; return saved and probably even changed regs
66
      ; return saved and probably even changed regs
78
      popad
67
      popad
79
 
68
 
80
 ;  esi already loaded  -  look above "pusha"
69
 ;  esi already loaded  -  look above "pusha"
81
      ;mov   esi,[0x3000]
70
      ;mov   esi,[0x3000]
82
      ;imul  esi,tss_step
71
      ;imul  esi,tss_step
83
      ;add   esi,tss_data
72
      ;add   esi,tss_data
84
 ; 
73
 ; 
85
 
74
 
86
      ; modify 3 program's registers (in its TSS)
75
      ; modify 3 program's registers (in its TSS)
87
      mov   [esi+28],eax;[esi+l.eax-tss_sceleton], eax    
76
      mov   [esi+28],eax;[esi+l.eax-tss_sceleton], eax    
88
      mov   [esi+16],ebx;[esi+l.ebx-tss_sceleton], ebx
77
      mov   [esi+16],ebx;[esi+l.ebx-tss_sceleton], ebx
89
      mov   [esi+24],ecx;[esi+l.ecx-tss_sceleton], ecx
78
      mov   [esi+24],ecx;[esi+l.ecx-tss_sceleton], ecx
90
 
-
 
91
      ; calculate app's TSS address
-
 
92
;      mov   ebx, [0x3000]
-
 
93
;      shl   ebx, 3
-
 
94
;      add   ebx, tss0_l
-
 
95
 
-
 
96
;      mov   ecx, [0x3000]
-
 
97
 
-
 
98
      ; restore saved TSS descriptor
-
 
99
;      mov   eax,     [reg1+ecx*4]
-
 
100
;      mov   [ebx],   eax
-
 
101
;      mov   eax,     [reg2+ecx*4]
-
 
102
;      mov   [ebx+4], eax
-
 
103
 
79
 
104
      xor    eax, eax
80
      xor    eax, eax
105
      mov    edi, [0x3000]          ; no syscall interrupt in use anymore
81
      mov    edi, [0x3000]          ; no syscall interrupt in use anymore
106
      shl    edi, 8
82
      shl    edi, 8
107
      mov    [edi+0x80000+0xB0],eax
83
      mov    [edi+0x80000+0xB0],eax
108
 
-
 
109
      ; clear busy flag in TSS of this handler
-
 
110
;      mov    edi, [0x3000]
-
 
111
;      shl    edi, 3
-
 
112
;      mov    [edi+tss0sys_l +5], word 01010000b *256 +11101001b
-
 
113
 
-
 
114
;      add   edi,tss0
-
 
115
;      mov   [0xB004], di
-
 
116
 
-
 
117
;      jmp   pword [0xB000]
84
 
118
      pop     eax
85
      pop     eax
119
      mov     ds,ax
86
      mov     ds,ax
120
      mov     es,ax
87
      mov     es,ax
121
      
88
      
122
      popad
89
      popad
123
      iretd
90
      iretd
124
 
91
 
125
      jmp    i40
92
      jmp    i40
126
 
93
 
127
label reg1    dword at 0x6000
94
label reg1    dword at 0x6000
128
label reg2    dword at 0x6400
95
label reg2    dword at 0x6400
129
label usedi40 byte  at 0x6800
96
label usedi40 byte  at 0x6800
130
 
97
 
131
uglobal
98
uglobal
132
  schd dd 0x0
99
  schd dd 0x0
133
endg
100
endg
134
 
101
 
135
align 4
102
align 4
136
save_registers:
103
save_registers:
137
 
104
 
138
      mov   esi,[0x3000]
105
      mov   esi,[0x3000]
139
      imul  esi,tss_step
106
      imul  esi,tss_step
140
      add   esi,tss_data
107
      add   esi,tss_data
141
 
108
 
142
      mov   eax,[esi+l.eax-tss_sceleton]
109
      mov   eax,[esi+l.eax-tss_sceleton]
143
      mov   ebx,[esi+l.ebx-tss_sceleton]
110
      mov   ebx,[esi+l.ebx-tss_sceleton]
144
      mov   ecx,[esi+l.ecx-tss_sceleton]
111
      mov   ecx,[esi+l.ecx-tss_sceleton]
145
      mov   edx,[esi+l.edx-tss_sceleton]
112
      mov   edx,[esi+l.edx-tss_sceleton]
146
      mov   edi,[esi+l.edi-tss_sceleton]
113
      mov   edi,[esi+l.edi-tss_sceleton]
147
      mov   ebp,[esi+l.ebp-tss_sceleton]
114
      mov   ebp,[esi+l.ebp-tss_sceleton]
148
 
115
 
149
      mov   esi,[esi+l.esi-tss_sceleton]
116
      mov   esi,[esi+l.esi-tss_sceleton]
150
 
117
 
151
      push  eax ecx esi edi
118
      push  eax ecx esi edi
152
      mov   esi,[0x3010]
119
      mov   esi,[0x3010]
153
      mov   eax,[esi+0x4]
120
      mov   eax,[esi+0x4]
154
      mov   esi,esp
121
      mov   esi,esp
155
      inc   [save_syscall_count]
122
      inc   [save_syscall_count]
156
      mov   edi,[save_syscall_count]
123
      mov   edi,[save_syscall_count]
157
      and   edi,0xF
124
      and   edi,0xF
158
      shl   edi,6
125
      shl   edi,6
159
      add   edi,save_syscall_data+32
126
      add   edi,save_syscall_data+32
160
      mov   [edi-32],eax
127
      mov   [edi-32],eax
161
      mov   ecx,32 / 4
128
      mov   ecx,32 / 4
162
      cld
129
      cld
163
      rep   movsd
130
      rep   movsd
164
      pop   edi esi ecx eax
131
      pop   edi esi ecx eax
165
      ret
132
      ret
166
 
133
 
167
uglobal
134
uglobal
168
  save_syscall_count  dd 0x0
135
  save_syscall_count  dd 0x0
169
endg
136
endg
170
 
137
 
171
label save_syscall_data dword at 0x5000
138
label save_syscall_data dword at 0x5000
172
 
139
 
173
 
140
 
174
iglobal
141
iglobal
175
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
142
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
176
  ;; SYSTEM FUNCTIONS TABLE ;;
143
  ;; SYSTEM FUNCTIONS TABLE ;;
177
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
144
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
178
 
145
 
179
  align 4
146
  align 4
180
  servetable:
147
  servetable:
181
 
148
 
182
      dd sys_drawwindow          ; 0-DrawWindow
149
      dd sys_drawwindow          ; 0-DrawWindow
183
      dd syscall_setpixel        ; 1-SetPixel
150
      dd syscall_setpixel        ; 1-SetPixel
184
      dd sys_getkey              ; 2-GetKey
151
      dd sys_getkey              ; 2-GetKey
185
      dd sys_clock               ; 3-GetTime
152
      dd sys_clock               ; 3-GetTime
186
      dd syscall_writetext       ; 4-WriteText
153
      dd syscall_writetext       ; 4-WriteText
187
      dd delay_hs                ; 5-DelayHs
154
      dd delay_hs                ; 5-DelayHs
188
      dd syscall_openramdiskfile ; 6-OpenRamdiskFile
155
      dd syscall_openramdiskfile ; 6-OpenRamdiskFile
189
      dd syscall_putimage        ; 7-PutImage
156
      dd syscall_putimage        ; 7-PutImage
190
      dd sys_button              ; 8-DefineButton
157
      dd sys_button              ; 8-DefineButton
191
      dd sys_cpuusage            ; 9-GetProcessInfo
158
      dd sys_cpuusage            ; 9-GetProcessInfo
192
      dd sys_waitforevent        ; 10-WaitForEvent
159
      dd sys_waitforevent        ; 10-WaitForEvent
193
      dd sys_getevent            ; 11-CheckForEvent
160
      dd sys_getevent            ; 11-CheckForEvent
194
      dd sys_redrawstat          ; 12-BeginDraw and EndDraw
161
      dd sys_redrawstat          ; 12-BeginDraw and EndDraw
195
      dd syscall_drawrect        ; 13-DrawRect
162
      dd syscall_drawrect        ; 13-DrawRect
196
      dd syscall_getscreensize   ; 14-GetScreenSize
163
      dd syscall_getscreensize   ; 14-GetScreenSize
197
      dd sys_background          ; 15-bgr
164
      dd sys_background          ; 15-bgr
198
      dd sys_cachetodiskette     ; 16-FlushFloppyCache
165
      dd sys_cachetodiskette     ; 16-FlushFloppyCache
199
      dd sys_getbutton           ; 17-GetButton
166
      dd sys_getbutton           ; 17-GetButton
200
      dd syscall_system          ; 18-Shutdown,KillApp,WindowActivate
167
      dd syscall_system          ; 18-Shutdown,KillApp,WindowActivate
201
      dd syscall_startapp        ; 19-StartApp
168
      dd syscall_startapp        ; 19-StartApp
202
      dd sys_midi                ; 20-ResetMidi and OutputMidi
169
      dd sys_midi                ; 20-ResetMidi and OutputMidi
203
      dd sys_setup               ; 21-SetMidiBase,SetKeymap,SetShiftKeymap,.
170
      dd sys_setup               ; 21-SetMidiBase,SetKeymap,SetShiftKeymap,.
204
      dd sys_settime             ; 22-setting date,time,clock and alarm-clock
171
      dd sys_settime             ; 22-setting date,time,clock and alarm-clock
205
      dd sys_wait_event_timeout  ; 23-TimeOutWaitForEvent
172
      dd sys_wait_event_timeout  ; 23-TimeOutWaitForEvent
206
      dd syscall_cdaudio         ; 24-PlayCdTrack,StopCd and GetCdPlaylist
173
      dd syscall_cdaudio         ; 24-PlayCdTrack,StopCd and GetCdPlaylist
207
      dd sys_sb16                ; 25-SetSb16
174
      dd sys_sb16                ; 25-SetSb16
208
      dd sys_getsetup            ; 26-GetMidiBase,GetKeymap,GetShiftKeymap,.
175
      dd sys_getsetup            ; 26-GetMidiBase,GetKeymap,GetShiftKeymap,.
209
      dd sys_wss                 ; 27-SetWssMainVol and SetWssCdVol
176
      dd sys_wss                 ; 27-SetWssMainVol and SetWssCdVol
210
      dd sys_sb16II              ; 28-SetSb16
177
      dd sys_sb16II              ; 28-SetSb16
211
      dd sys_date                ; 29-GetDate
178
      dd sys_date                ; 29-GetDate
212
      dd syscall_readhd          ; 30-ReadHd
179
      dd syscall_readhd          ; 30-ReadHd
213
      dd syscall_starthdapp      ; 31-StartHdApp
180
      dd syscall_starthdapp      ; 31-StartHdApp
214
      dd syscall_delramdiskfile  ; 32-DelRamdiskFile
181
      dd syscall_delramdiskfile  ; 32-DelRamdiskFile
215
      dd syscall_writeramdiskfile; 33-WriteRamdiskFile
182
      dd syscall_writeramdiskfile; 33-WriteRamdiskFile
216
      dd read_floppy_file        ; 34-ReadFloppyDrive
183
      dd read_floppy_file        ; 34-ReadFloppyDrive
217
      dd syscall_getpixel        ; 35-GetPixel
184
      dd syscall_getpixel        ; 35-GetPixel
218
      dd syscall_readstring      ; 36-ReadString (not yet ready)
185
      dd syscall_readstring      ; 36-ReadString (not yet ready)
219
      dd readmousepos            ; 37-GetMousePosition_ScreenRelative,.
186
      dd readmousepos            ; 37-GetMousePosition_ScreenRelative,.
220
      dd syscall_drawline        ; 38-DrawLine
187
      dd syscall_drawline        ; 38-DrawLine
221
      dd sys_getbackground       ; 39-GetBackgroundSize,ReadBgrData,.
188
      dd sys_getbackground       ; 39-GetBackgroundSize,ReadBgrData,.
222
      dd set_app_param           ; 40-WantEvents
189
      dd set_app_param           ; 40-WantEvents
223
      dd syscall_getirqowner     ; 41-GetIrqOwner
190
      dd syscall_getirqowner     ; 41-GetIrqOwner
224
      dd get_irq_data            ; 42-ReadIrqData
191
      dd get_irq_data            ; 42-ReadIrqData
225
      dd sys_outport             ; 43-SendDeviceData
192
      dd sys_outport             ; 43-SendDeviceData
226
      dd sys_programirq          ; 44-ProgramIrqs
193
      dd sys_programirq          ; 44-ProgramIrqs
227
      dd reserve_free_irq        ; 45-ReserveIrq and FreeIrq
194
      dd reserve_free_irq        ; 45-ReserveIrq and FreeIrq
228
      dd syscall_reserveportarea ; 46-ReservePortArea and FreePortArea
195
      dd syscall_reserveportarea ; 46-ReservePortArea and FreePortArea
229
      dd display_number          ; 47-WriteNum
196
      dd display_number          ; 47-WriteNum
230
      dd display_settings        ; 48-SetRedrawType and SetButtonType
197
      dd display_settings        ; 48-SetRedrawType and SetButtonType
231
      dd syscall_appints         ; 49-AppInts
198
      dd syscall_appints         ; 49-AppInts
232
      dd random_shaped_window    ; 50-Window shape & scale
199
      dd random_shaped_window    ; 50-Window shape & scale
233
      dd syscall_threads         ; 51-Threads
200
      dd syscall_threads         ; 51-Threads
234
      dd stack_driver_stat       ; 52-Stack driver status
201
      dd stack_driver_stat       ; 52-Stack driver status
235
      dd socket                  ; 53-Socket interface
202
      dd socket                  ; 53-Socket interface
236
      dd user_events             ; 54-User events
203
      dd user_events             ; 54-User events
237
      dd sound_interface         ; 55-Sound interface
204
      dd sound_interface         ; 55-Sound interface
238
      dd write_to_hd             ; 56-Write a file to hd
205
      dd write_to_hd             ; 56-Write a file to hd
239
      dd delete_from_hd          ; 57-Delete a file from hd
206
      dd delete_from_hd          ; 57-Delete a file from hd
240
      dd file_system             ; 58-Common file system interface
207
      dd file_system             ; 58-Common file system interface
241
      dd sys_trace               ; 59-System call trace
208
      dd sys_trace               ; 59-System call trace
242
      dd new_sys_ipc             ; 60-Inter Process Communication
209
      dd new_sys_ipc             ; 60-Inter Process Communication
243
      dd sys_gs                  ; 61-Direct graphics access
210
      dd sys_gs                  ; 61-Direct graphics access
244
      dd sys_pci                 ; 62-PCI functions
211
      dd sys_pci                 ; 62-PCI functions
245
      dd sys_msg_board           ; 63-System message board
212
      dd sys_msg_board           ; 63-System message board
246
      dd sys_resize_app_memory   ; 64-Resize application memory usage
213
      dd sys_resize_app_memory   ; 64-Resize application memory usage
247
      dd undefined_syscall       ; 65-UTF
214
      dd undefined_syscall       ; 65-UTF
248
      dd sys_process_def         ; 66-Process definitions - keyboard
215
      dd sys_process_def         ; 66-Process definitions - keyboard
249
      dd sys_window_move         ; 67-Window move or resize
216
      dd sys_window_move         ; 67-Window move or resize
250
      dd sys_internal_services   ; 68-Some internal services
217
      dd sys_internal_services   ; 68-Some internal services
251
 
218
 
252
  times 255 - ( ($-servetable) /4 )  dd undefined_syscall
219
  times 255 - ( ($-servetable) /4 )  dd undefined_syscall
253
 
220
 
254
      dd sys_end                 ; -1-end application
221
      dd sys_end                 ; -1-end application
255
endg
222
endg