Subversion Repositories Kolibri OS

Rev

Rev 2 | Rev 4 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 3
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                            ;;
2
;;                                                            ;;
3
;;                   SYSTEM CALL ENTRY                        ;;
3
;;                   SYSTEM CALL ENTRY                        ;;
4
;;                                                            ;;
4
;;                                                            ;;
5
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
 
6
uglobal
-
 
7
  task_tss rd 1
6
 
8
endg
7
align 32
9
align 32
8
i40:
10
i40:
-
 
11
      pushad
-
 
12
 
-
 
13
      push  ds
-
 
14
      mov   ax,word os_data
-
 
15
      mov   ds,ax
-
 
16
      mov   es,ax
-
 
17
      mov   [task_tss],esp
-
 
18
      add   dword [task_tss],4
9
      cli
19
      cli
Line 10... Line 20...
10
 
20
 
11
      mov    edi,[0x3000]
21
      mov    edi,[0x3000]
12
      mov    eax,edi
22
      mov    eax,edi
13
      shl    edi, 3
23
      shl    edi, 3
14
;clear busy flag in application's TSS      
24
;clear busy flag in application's TSS      
Line 15... Line 25...
15
      mov    [edi+gdts+ tss0 +5], word 01010000b *256 +11101001b
25
      mov    [edi+gdts+ tss0 +5], word 01010000b *256 +11101001b
16
      
26
      
17
;save GDT TSS entry
27
;save GDT TSS entry
18
      mov    edx,[edi+tss0_l]
28
;      mov    edx,[edi+tss0_l]
19
      mov    [reg1+eax*4],edx
29
;      mov    [reg1+eax*4],edx
20
      mov    edx,[edi+tss0_l+4]
30
;      mov    edx,[edi+tss0_l+4]
21
      mov    [reg2+eax*4],edx
31
;      mov    [reg2+eax*4],edx
22
;and then write there i40's descriptor
32
;and then write there i40's descriptor
23
      mov    edx,[tss0sys_l+edi]
33
;      mov    edx,[tss0sys_l+edi]
24
      mov    [edi+tss0_l],edx
34
;      mov    [edi+tss0_l],edx
Line 25... Line 35...
25
      mov    edx,[tss0sys_l+edi+4]
35
;      mov    edx,[tss0sys_l+edi+4]
26
      mov    [edi+tss0_l+4],edx            
36
;      mov    [edi+tss0_l+4],edx            
Line 27... Line 37...
27
 
37
 
28
 
38
 
Line 29... Line 39...
29
      shl    edi,5
39
      shl    edi,5
30
      mov    [edi+0x80000+0xB0],eax  ; used i40 handler
40
      mov    [edi+0x80000+0xB0],eax  ; used i40 handler
31
 
41
 
-
 
42
      ; for syscall trace function
-
 
43
      call  save_registers
32
      ; for syscall trace function
44
 
33
      call  save_registers
45
;      mov   esi, [0x3000]
34
 
46
;      imul  esi, tss_step
35
      mov   esi, [0x3000]
47
;      add   esi, tss_data
36
      imul  esi, tss_step
48
      mov   esi,[task_tss]
Line 37... Line 49...
37
      add   esi, tss_data
49
;      sub   esi,0x28
38
      ; esi holds address of TSS of interupted program
50
      ; esi holds address of TSS of interupted program
39
      ; load first 3 registers
51
      ; load first 3 registers
Line 40... Line 52...
40
      mov   eax,[esi+l.eax-tss_sceleton]
52
      mov   eax,[esi+28];+l.eax-tss_sceleton]
41
      mov   ebx,[esi+l.ebx-tss_sceleton]
53
      mov   ebx,[esi+16];l.ebx-tss_sceleton]
42
      mov   ecx,[esi+l.ecx-tss_sceleton]
54
      mov   ecx,[esi+24];l.ecx-tss_sceleton]
43
 
55
 
44
      ; save current registers
56
      ; save current registers
45
      ; stack may be modified by a system function to return some value to caller!
57
      ; stack may be modified by a system function to return some value to caller!
46
      pushad
58
      pushad
Line 47... Line 59...
47
 
59
 
48
      ; load all registers from TSS of the application, in crossed order (why?)
60
      ; load all registers from TSS of the application, in crossed order (why?)
49
      mov   edi,[esi+l.eax-tss_sceleton]
61
      mov   edi,[esi+28];l.eax-tss_sceleton]
50
      mov   eax,[esi+l.ebx-tss_sceleton]
62
      mov   eax,[esi+16];l.ebx-tss_sceleton]
Line 70... Line 82...
70
      ;imul  esi,tss_step
82
      ;imul  esi,tss_step
71
      ;add   esi,tss_data
83
      ;add   esi,tss_data
72
 ; 
84
 ; 
Line 73... Line 85...
73
 
85
 
74
      ; modify 3 program's registers (in its TSS)
86
      ; modify 3 program's registers (in its TSS)
75
      mov   [esi+l.eax-tss_sceleton], eax    
87
      mov   [esi+28],eax;[esi+l.eax-tss_sceleton], eax    
76
      mov   [esi+l.ebx-tss_sceleton], ebx
88
      mov   [esi+16],ebx;[esi+l.ebx-tss_sceleton], ebx
Line 77... Line 89...
77
      mov   [esi+l.ecx-tss_sceleton], ecx
89
      mov   [esi+24],ecx;[esi+l.ecx-tss_sceleton], ecx
78
 
90
 
79
      ; calculate app's TSS address
91
      ; calculate app's TSS address
80
      mov   ebx, [0x3000]
92
;      mov   ebx, [0x3000]
Line 81... Line 93...
81
      shl   ebx, 3
93
;      shl   ebx, 3
Line 82... Line 94...
82
      add   ebx, tss0_l
94
;      add   ebx, tss0_l
83
 
95
 
84
      mov   ecx, [0x3000]
96
;      mov   ecx, [0x3000]
85
 
97
 
86
      ; restore saved TSS descriptor
98
      ; restore saved TSS descriptor
Line 87... Line 99...
87
      mov   eax,     [reg1+ecx*4]
99
;      mov   eax,     [reg1+ecx*4]
88
      mov   [ebx],   eax
100
;      mov   [ebx],   eax
89
      mov   eax,     [reg2+ecx*4]
101
;      mov   eax,     [reg2+ecx*4]
90
      mov   [ebx+4], eax
102
;      mov   [ebx+4], eax
Line 91... Line 103...
91
 
103
 
92
      xor    eax, eax
104
      xor    eax, eax
93
      mov    edi, [0x3000]          ; no syscall interrupt in use anymore
105
      mov    edi, [0x3000]          ; no syscall interrupt in use anymore
94
      shl    edi, 8
106
      shl    edi, 8
Line 95... Line 107...
95
      mov    [edi+0x80000+0xB0],eax
107
      mov    [edi+0x80000+0xB0],eax
96
 
108
 
Line 97... Line 109...
97
      ; clear busy flag in TSS of this handler
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
Line 98... Line 116...
98
      mov    edi, [0x3000]
116
 
Line 99... Line 117...
99
      shl    edi, 3
117
;      jmp   pword [0xB000]
100
      mov    [edi+tss0sys_l +5], word 01010000b *256 +11101001b
118
      pop     eax