Subversion Repositories Kolibri OS

Rev

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

Rev 485 Rev 551
1
;
1
;
2
;    Stack Status Monitor
2
;    Stack Status Monitor
3
;
3
;
4
;    Compile with FASM for Menuet
4
;    Compile with FASM for Menuet
5
;
5
;
6
   
6
   
7
use32
7
use32
8
 org	0x0
8
 org	0x0
9
 db	'MENUET01'    ; header
9
 db	'MENUET01'    ; header
10
 dd	0x01	      ; header version
10
 dd	0x01	      ; header version
11
 dd	START	      ; entry point
11
 dd	START	      ; entry point
12
 dd	I_END	      ; image size
12
 dd	I_END	      ; image size
13
 dd	I_END+0x10000 ; required memory
13
 dd	I_END+0x10000 ; required memory
14
 dd	I_END+0x10000 ; esp
14
 dd	I_END+0x10000 ; esp
15
 dd	0x0 , 0x0     ; I_Param , I_Path
15
 dd	0x0 , 0x0     ; I_Param , I_Path
16
   
16
   
17
include 'lang.inc'
17
include 'lang.inc'
18
include '..\..\..\macros.inc'
18
include '..\..\..\macros.inc'
19
   
19
   
20
START:                          ; start of execution
20
START:                          ; start of execution
21
 
21
 
22
    call draw_window            ; at first, draw the window
22
    call draw_window            ; at first, draw the window
23
   
23
   
24
still:
24
still:
25
    mov  eax,23                 ; wait here for event
25
    mov  eax,23                 ; wait here for event
26
    mov  ebx,200    ; Time out after 2s
26
    mov  ebx,200    ; Time out after 2s
27
    mcall
27
    mcall
28
   
28
   
29
    cmp  eax,1                  ; redraw request ?
29
    cmp  eax,1                  ; redraw request ?
30
    jz   red
30
    jz   red
31
    cmp  eax,2                  ; key in buffer ?
31
    cmp  eax,2                  ; key in buffer ?
32
    jz   key
32
    jz   key
33
    cmp  eax,3                  ; button in buffer ?
33
    cmp  eax,3                  ; button in buffer ?
34
    jz   button
34
    jz   button
35
   
35
   
36
 ; read the stack status data, and write it to the screen buffer
36
 ; read the stack status data, and write it to the screen buffer
37
   
37
   
38
 mov  eax, 53
38
 mov  eax, 53
39
 mov  ebx, 255
39
 mov  ebx, 255
40
 mov  ecx, 6
40
 mov  ecx, 6
41
 mcall
41
 mcall
42
   
42
   
43
 mov  ebx, text + 24
43
 mov  ebx, text + 24
44
 call printhex
44
 call printhex
45
   
45
   
46
 mov  eax, 53
46
 mov  eax, 53
47
 mov  ebx, 255
47
 mov  ebx, 255
48
 mov  ecx, 2
48
 mov  ecx, 2
49
 mcall
49
 mcall
50
   
50
   
51
 mov  ebx, text + 107
51
 mov  ebx, text + 107
52
 call printhex
52
 call printhex
53
   
53
   
54
 mov  eax, 53
54
 mov  eax, 53
55
 mov  ebx, 255
55
 mov  ebx, 255
56
 mov  ecx, 5
56
 mov  ecx, 5
57
 mcall
57
 mcall
58
   
58
   
59
 mov  ebx, text + 107 + 40
59
 mov  ebx, text + 107 + 40
60
 call printhex
60
 call printhex
61
   
61
   
62
 mov  eax, 53
62
 mov  eax, 53
63
 mov  ebx, 255
63
 mov  ebx, 255
64
 mov  ecx, 4
64
 mov  ecx, 4
65
 mcall
65
 mcall
66
   
66
   
67
 mov  ebx, text + 107 + 80
67
 mov  ebx, text + 107 + 80
68
 call printhex
68
 call printhex
69
   
69
   
70
 mov  eax, 53
70
 mov  eax, 53
71
 mov  ebx, 255
71
 mov  ebx, 255
72
 mov  ecx, 100
72
 mov  ecx, 100
73
 mcall
73
 mcall
74
   
74
   
75
 mov  ebx, text + 258
75
 mov  ebx, text + 258
76
 call printhex
76
 call printhex
77
   
77
   
78
 mov  eax, 53
78
 mov  eax, 53
79
 mov  ebx, 255
79
 mov  ebx, 255
80
 mov  ecx, 101
80
 mov  ecx, 101
81
 mcall
81
 mcall
82
   
82
   
83
 mov  ebx, text + 258 + 40
83
 mov  ebx, text + 258 + 40
84
 call printhex
84
 call printhex
85
   
85
   
86
 mov  eax, 53
86
 mov  eax, 53
87
 mov  ebx, 255
87
 mov  ebx, 255
88
 mov  ecx, 102
88
 mov  ecx, 102
89
 mcall
89
 mcall
90
   
90
   
91
 mov  ebx, text + 258 + 80
91
 mov  ebx, text + 258 + 80
92
 call printhex
92
 call printhex
93
   
93
   
94
 mov  eax, 53
94
 mov  eax, 53
95
 mov  ebx, 255
95
 mov  ebx, 255
96
 mov  ecx, 103
96
 mov  ecx, 103
97
 mcall
97
 mcall
98
   
98
   
99
 mov  ebx, text + 258 + 120
99
 mov  ebx, text + 258 + 120
100
 call printhex
100
 call printhex
101
   
101
   
102
red:                           ; redraw
102
red:                           ; redraw
103
    call draw_window
103
    call draw_window
104
    jmp  still
104
    jmp  still
105
   
105
   
106
key:                           ; Keys are not valid at this part of the
106
key:                           ; Keys are not valid at this part of the
107
    mov  eax,2                  ; loop. Just read it and ignore
107
    mov  eax,2                  ; loop. Just read it and ignore
108
    mcall
108
    mcall
109
    jmp  still
109
    jmp  still
110
   
110
   
111
button:                        ; button
111
button:                        ; button
112
    mov  eax,17                 ; get id
112
    mov  eax,17                 ; get id
113
    mcall
113
    mcall
114
   
114
   
115
    cmp  ah,1                   ; button id=1 ?
115
    cmp  ah,1                   ; button id=1 ?
116
    jnz  still
116
    jnz  still
117
   
117
   
118
    or  eax,-1                 ; close this program
118
    or  eax,-1                 ; close this program
119
    mcall
119
    mcall
120
   
120
   
121
    jmp  still
121
    jmp  still
122
   
122
   
123
   
123
   
124
   
124
   
125
   
125
   
126
;   *********************************************
126
;   *********************************************
127
;   *******  WINDOW DEFINITIONS AND DRAW ********
127
;   *******  WINDOW DEFINITIONS AND DRAW ********
128
;   *********************************************
128
;   *********************************************
129
   
129
   
130
   
130
   
131
draw_window:
131
draw_window:
132
   
132
   
133
    mov  eax,12                    ; function 12:tell os about windowdraw
133
    mov  eax,12                    ; function 12:tell os about windowdraw
134
    mov  ebx,1                     ; 1, start of draw
134
    mov  ebx,1                     ; 1, start of draw
135
    mcall
135
    mcall
136
   
136
   
137
                                   ; DRAW WINDOW
137
                                   ; DRAW WINDOW
138
    xor  eax,eax                   ; function 0 : define and draw window
138
    xor  eax,eax                   ; function 0 : define and draw window
139
    mov  ebx,100*65536+260         ; [x start] *65536 + [x size]
139
    mov  ebx,100*65536+260         ; [x start] *65536 + [x size]
140
    mov  ecx,100*65536+205         ; [y start] *65536 + [y size]
140
    mov  ecx,100*65536+205         ; [y start] *65536 + [y size]
141
    mov  edx,0x13224466            ; color of work area RRGGBB
141
    mov  edx,0x14224466            ; color of work area RRGGBB
142
    mov  edi,title                 ; WINDOW LABEL
142
    mov  edi,title                 ; WINDOW LABEL
143
    mcall
143
    mcall
144
   
144
   
145
                                  
145
                                  
146
    ; Re-draw the screen text
146
    ; Re-draw the screen text
147
    cld
147
    cld
148
    mov  eax,4
148
    mov  eax,4
149
    mov  ebx,25*65536+35           ; draw info text with function 4
149
    mov  ebx,25*65536+35           ; draw info text with function 4
150
    mov  ecx,0xffffff
150
    mov  ecx,0xffffff
151
    mov  edx,text
151
    mov  edx,text
152
    mov  esi,40
152
    mov  esi,40
153
  newline:
153
  newline:
154
    mcall
154
    mcall
155
    add  ebx,16
155
    add  ebx,16
156
    add  edx,40
156
    add  edx,40
157
    cmp  [edx],byte 'x'
157
    cmp  [edx],byte 'x'
158
    jnz  newline
158
    jnz  newline
159
   
159
   
160
   
160
   
161
    mov  eax,12                    ; function 12:tell os about windowdraw
161
    mov  eax,12                    ; function 12:tell os about windowdraw
162
    mov  ebx,2                     ; 2, end of draw
162
    mov  ebx,2                     ; 2, end of draw
163
    mcall
163
    mcall
164
   
164
   
165
    ret
165
    ret
166
   
166
   
167
; Taken from PS.ASM
167
; Taken from PS.ASM
168
printhex:
168
printhex:
169
; number in eax
169
; number in eax
170
; print to ebx
170
; print to ebx
171
; xlat from hextable
171
; xlat from hextable
172
 pusha
172
 pusha
173
 mov esi, ebx
173
 mov esi, ebx
174
 add esi, 8
174
 add esi, 8
175
 mov ebx, hextable
175
 mov ebx, hextable
176
 mov ecx, 8
176
 mov ecx, 8
177
phex_loop:
177
phex_loop:
178
 mov edx, eax
178
 mov edx, eax
179
 and eax, 15
179
 and eax, 15
180
 xlatb
180
 xlatb
181
 mov [esi], al
181
 mov [esi], al
182
 mov eax, edx
182
 mov eax, edx
183
 shr eax, 4
183
 shr eax, 4
184
 dec esi
184
 dec esi
185
 loop phex_loop
185
 loop phex_loop
186
 popa
186
 popa
187
 ret
187
 ret
188
   
188
   
189
   
189
   
190
; DATA AREA
190
; DATA AREA
191
   
191
   
192
text:
192
text:
193
    db ' Ethernet card status : xxxxxxxx        '
193
    db ' Ethernet card status : xxxxxxxx        '
194
    db '                                        '
194
    db '                                        '
195
    db ' IP packets received :     xxxxxxxx     '
195
    db ' IP packets received :     xxxxxxxx     '
196
    db ' ARP packets received :    xxxxxxxx     '
196
    db ' ARP packets received :    xxxxxxxx     '
197
    db ' Dumped received packets : xxxxxxxx     '
197
    db ' Dumped received packets : xxxxxxxx     '
198
    db '                                        '
198
    db '                                        '
199
    db ' EMPTY QUEUE    : xxxxxxxx              '
199
    db ' EMPTY QUEUE    : xxxxxxxx              '
200
    db ' IPOUT QUEUE    : xxxxxxxx              '
200
    db ' IPOUT QUEUE    : xxxxxxxx              '
201
    db ' IPIN  QUEUE    : xxxxxxxx              '
201
    db ' IPIN  QUEUE    : xxxxxxxx              '
202
    db ' NET1OUT QUEUE  : xxxxxxxx              '
202
    db ' NET1OUT QUEUE  : xxxxxxxx              '
203
    db 'x <- END MARKER, DONT DELETE            '
203
    db 'x <- END MARKER, DONT DELETE            '
204
   
204
   
205
   
205
   
206
title    db   'Stack Status',0
206
title    db   'Stack Status',0
207
   
207
   
208
hextable db '0123456789ABCDEF'
208
hextable db '0123456789ABCDEF'
209
   
209
   
210
   
210
   
211
I_END:
211
I_END: