Subversion Repositories Kolibri OS

Rev

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

Rev 1997 Rev 1998
1
;
1
;
2
;   DEBUG BOARD for APPLICATIONS and KERNEL DEVELOPMENT
2
;   DEBUG BOARD for APPLICATIONS and KERNEL DEVELOPMENT
3
;
3
;
4
;   See f63
4
;   See f63
5
;
5
;
6
;   Compile with FASM for Menuet
6
;   Compile with FASM for Menuet
7
;
7
;
8
WRITE_LOG  equ 1
8
WRITE_LOG  equ 1
9
 
9
 
10
include 'lang.inc'
10
include 'lang.inc'
11
 
11
 
12
   use32
12
   use32
13
   org	  0x0
13
   org	  0x0
14
   db	  'MENUET01'		  ; 8 byte id
14
   db	  'MENUET01'		  ; 8 byte id
15
   dd	  0x01			  ; header version
15
   dd	  0x01			  ; header version
16
   dd	  START 		  ; start of code
16
   dd	  START 		  ; start of code
17
   dd	  I_END 		  ; size of image
17
   dd	  I_END 		  ; size of image
18
   dd	  mem			; memory for app
18
   dd	  mem			; memory for app
19
   dd	  mem			; esp
19
   dd	  mem			; esp
20
   dd	  filename , 0x0	  ; I_Param , I_Icon
20
   dd	  filename , 0x0	  ; I_Param , I_Icon
21
include '../../../macros.inc'
21
include '../../../macros.inc'
22
include 'debug.inc'
22
include 'debug.inc'
23
purge newline
23
purge newline
24
MAXSTRINGS = 16
24
MAXSTRINGS = 16
25
TMP = 80*(MAXSTRINGS+1)
25
TMP = 80*(MAXSTRINGS+1)
26
 
26
 
27
START:				; start of execution
27
START:				; start of execution
28
	mov	edi, filename
28
	mov	edi, filename
29
	cmp	byte [edi], 0
29
	cmp	byte [edi], 0
30
	jnz	param
30
	jnz	param
31
	mov	esi, default_filename
31
	mov	esi, default_filename
32
@@:
32
@@:
33
	lodsb
33
	lodsb
34
	stosb
34
	stosb
35
	test	al, al
35
	test	al, al
36
	jnz	@b
36
	jnz	@b
37
param:
37
param:
38
 
38
 
39
; allow user to see messages written before start
39
; allow user to see messages written before start
40
;     mov  ecx,4096
40
;     mov  ecx,4096
41
;    flush:
41
;    flush:
42
;     mov  eax,63
42
;     mov  eax,63
43
;     mov  ebx,2
43
;     mov  ebx,2
44
;     mcall
44
;     mcall
45
;     loop flush
45
;     loop flush
46
 
46
 
47
     mov  ecx, TMP
47
     mov  ecx, TMP
48
     xor  eax, eax
48
     xor  eax, eax
49
     mov  edi, [targ]
49
     mov  edi, [targ]
50
     rep  stosb
50
     rep  stosb
51
 
51
 
52
     mov  [tmp1],'x'
52
     mov  [tmp1],'x'
53
     mov  [tmp2],'x'
53
     mov  [tmp2],'x'
54
 
54
 
55
     mov  eax,14
55
     mov  eax,14
56
     mcall
56
     mcall
57
     and  eax,0xffff0000
57
     and  eax,0xffff0000
58
     sub  eax,399 shl 16
58
     sub  eax,399 shl 16
59
     add  eax,399
59
     add  eax,399
60
     mov  [xstart],eax
60
     mov  [xstart],eax
61
 
61
 
62
     mov  eax,48
62
     mov  eax,48
63
     mov  ebx,3
63
     mov  ebx,3
64
     mov  ecx,sc
64
     mov  ecx,sc
65
     mov  edx,sizeof.system_colors
65
     mov  edx,sizeof.system_colors
66
     mcall
66
     mcall
67
  if WRITE_LOG
67
  if WRITE_LOG
68
     mov  esi, filename
68
     mov  esi, filename
69
     call CreateFile
69
     call CreateFile
70
  end if
70
  end if
71
 
71
 
72
  red:
72
  red:
73
     call draw_window
73
     call draw_window
74
 
74
 
75
still:
75
still:
76
 
76
 
77
    mov  eax,23 		; wait here for event
77
    mov  eax,23 		; wait here for event
78
    mov  ebx,1
78
    mov  ebx,1
79
    mcall
79
    mcall
80
 
80
 
81
    cmp  eax,1			; redraw request ?
81
    cmp  eax,1			; redraw request ?
82
    je	 red
82
    je	 red
83
    cmp  eax,2			; key in buffer ?
83
    cmp  eax,2			; key in buffer ?
84
    je	 key
84
    je	 key
85
    cmp  eax,3			; button in buffer ?
85
    cmp  eax,3			; button in buffer ?
86
    je	 button
86
    je	 button
87
 
87
 
88
    mov  eax,63
88
    mov  eax,63
89
    mov  ebx,2
89
    mov  ebx,2
90
    mcall
90
    mcall
91
 
91
 
92
    cmp  ebx,1
92
    cmp  ebx,1
93
    jne  still
93
    jne  still
94
 
94
 
95
  new_data:
95
  new_data:
96
  if WRITE_LOG
96
  if WRITE_LOG
97
     pusha
97
     pusha
98
     mov  [tmp], al
98
     mov  [tmp], al
99
     mov  edx, tmp
99
     mov  edx, tmp
100
     mov  ecx, 1
100
     mov  ecx, 1
101
     mov  esi, filename
101
     mov  esi, filename
102
  .write_to_logfile:
102
  .write_to_logfile:
103
     call WriteToFile
103
     call WriteToFile
104
     cmp  eax, 5
104
     cmp  eax, 5
105
     jne  @f
105
     jne  @f
106
     mov  esi, filename
106
     mov  esi, filename
107
     mov  [filepos], 0
107
     mov  [filepos], 0
108
     call CreateFile
108
     call CreateFile
109
     jmp  .write_to_logfile
109
     jnc  .write_to_logfile
110
  @@:
110
  @@:
111
     inc  [filepos]
111
     inc  [filepos]
112
     popa
112
     popa
113
  end if
113
  end if
114
 
114
 
115
    mov  ebp,[targ]
115
    mov  ebp,[targ]
116
  .no4:
116
  .no4:
117
    cmp  al,13
117
    cmp  al,13
118
    jne  no13
118
    jne  no13
119
    and  dword[ebp-8],0
119
    and  dword[ebp-8],0
120
    jmp  new_check
120
    jmp  new_check
121
   no13:
121
   no13:
122
    cmp  al,10
122
    cmp  al,10
123
    jne  no10
123
    jne  no10
124
    and  dword[ebp-8],0
124
    and  dword[ebp-8],0
125
    inc  dword[ebp-4]
125
    inc  dword[ebp-4]
126
    cmp  dword[ebp-4],MAXSTRINGS
126
    cmp  dword[ebp-4],MAXSTRINGS
127
    jbe  .noypos
127
    jbe  .noypos
128
    mov  dword[ebp-4],MAXSTRINGS
128
    mov  dword[ebp-4],MAXSTRINGS
129
    lea  esi,[ebp+80]
129
    lea  esi,[ebp+80]
130
    mov  edi,ebp
130
    mov  edi,ebp
131
    mov  ecx,80*(MAXSTRINGS)
131
    mov  ecx,80*(MAXSTRINGS)
132
    cld
132
    cld
133
    rep  movsb
133
    rep  movsb
134
 
134
 
135
    mov  esi,[ebp-4]
135
    mov  esi,[ebp-4]
136
    imul esi,80
136
    imul esi,80
137
    add  esi,[ebp-8]
137
    add  esi,[ebp-8]
138
    add  esi,ebp
138
    add  esi,ebp
139
    mov  ecx,80
139
    mov  ecx,80
140
    xor  al,al
140
    xor  al,al
141
    rep  stosb
141
    rep  stosb
142
  .noypos:
142
  .noypos:
143
    mov  [targ],text2
143
    mov  [targ],text2
144
    and  [krnl_cnt],0
144
    and  [krnl_cnt],0
145
    jmp  new_check
145
    jmp  new_check
146
  no10:
146
  no10:
147
    cmp  ebp,text1
147
    cmp  ebp,text1
148
    je	 add2
148
    je	 add2
149
		mov  ecx,[krnl_cnt]
149
		mov  ecx,[krnl_cnt]
150
		  cmp  al,[krnl_msg+ecx]
150
		  cmp  al,[krnl_msg+ecx]
151
		jne  .noknl
151
		jne  .noknl
152
		  inc  [krnl_cnt]
152
		  inc  [krnl_cnt]
153
		cmp  [krnl_cnt],4
153
		cmp  [krnl_cnt],4
154
		jne  new_check
154
		jne  new_check
155
    mov  [targ],text1
155
    mov  [targ],text1
156
	.noknl:
156
	.noknl:
157
    mov  ebp,[targ]
157
    mov  ebp,[targ]
158
	   jecxz .add
158
	   jecxz .add
159
    push eax
159
    push eax
160
    mov  esi,krnl_msg
160
    mov  esi,krnl_msg
161
   .l1:
161
   .l1:
162
    lodsb
162
    lodsb
163
    call add_char
163
    call add_char
164
    loop .l1
164
    loop .l1
165
    pop  eax
165
    pop  eax
166
   .add:
166
   .add:
167
    and  [krnl_cnt],0
167
    and  [krnl_cnt],0
168
  add2:
168
  add2:
169
    call add_char
169
    call add_char
170
 
170
 
171
  new_check:
171
  new_check:
172
 
172
 
173
    mov  eax,63
173
    mov  eax,63
174
    mov  ebx,2
174
    mov  ebx,2
175
    mcall
175
    mcall
176
 
176
 
177
    cmp  ebx,1
177
    cmp  ebx,1
178
    je	 new_data
178
    je	 new_data
179
 
179
 
180
    call draw_window
180
    call draw_window
181
 
181
 
182
    jmp  still
182
    jmp  still
183
 
183
 
184
  key:				; key
184
  key:				; key
185
    mov  al,2		       ; just read it and ignore
185
    mov  al,2		       ; just read it and ignore
186
    mcall
186
    mcall
187
    cmp  ah,' '
187
    cmp  ah,' '
188
    je	 button.noclose
188
    je	 button.noclose
189
    jmp  still
189
    jmp  still
190
 
190
 
191
  button:			; button
191
  button:			; button
192
    mov  al,17		       ; get id
192
    mov  al,17		       ; get id
193
    mcall
193
    mcall
194
 
194
 
195
    cmp  ah,1			; button id=1 ?
195
    cmp  ah,1			; button id=1 ?
196
    jne  .noclose
196
    jne  .noclose
197
 
197
 
198
    or	 eax,-1 		; close this program
198
    or	 eax,-1 		; close this program
199
    mcall
199
    mcall
200
  .noclose:
200
  .noclose:
201
    xor  [vmode],1
201
    xor  [vmode],1
202
    jmp  red
202
    jmp  red
203
 
203
 
204
add_char:
204
add_char:
205
    push esi
205
    push esi
206
    mov  esi,[ebp-4]
206
    mov  esi,[ebp-4]
207
    imul esi,80
207
    imul esi,80
208
    add  esi,[ebp-8]
208
    add  esi,[ebp-8]
209
    mov  [ebp+esi],al
209
    mov  [ebp+esi],al
210
    inc  dword[ebp-8]
210
    inc  dword[ebp-8]
211
    cmp  dword[ebp-8],80
211
    cmp  dword[ebp-8],80
212
    jb	 .ok
212
    jb	 .ok
213
    mov  dword[ebp-8],79
213
    mov  dword[ebp-8],79
214
  .ok:
214
  .ok:
215
    pop  esi
215
    pop  esi
216
    ret
216
    ret
217
 
217
 
218
;   *********************************************
218
;   *********************************************
219
;   *******  WINDOW DEFINITIONS AND DRAW ********
219
;   *******  WINDOW DEFINITIONS AND DRAW ********
220
;   *********************************************
220
;   *********************************************
221
 
221
 
222
 
222
 
223
draw_window:
223
draw_window:
224
 
224
 
225
    mov  eax,12 		   ; function 12:tell os about windowdraw
225
    mov  eax,12 		   ; function 12:tell os about windowdraw
226
    mov  ebx,1			   ; 1, start of draw
226
    mov  ebx,1			   ; 1, start of draw
227
    mcall
227
    mcall
228
 
228
 
229
				   ; DRAW WINDOW
229
				   ; DRAW WINDOW
230
    xor  eax,eax		     ; function 0 : define and draw window
230
    xor  eax,eax		     ; function 0 : define and draw window
231
;   mov  ebx,50*65536+400          ; [x start] *65536 + [x size]
231
;   mov  ebx,50*65536+400          ; [x start] *65536 + [x size]
232
    mov  ebx,[xstart]
232
    mov  ebx,[xstart]
233
    mov  ecx,MAXSTRINGS*10+45	   ; [y start] *65536 + [y size]
233
    mov  ecx,MAXSTRINGS*10+45	   ; [y start] *65536 + [y size]
234
    mov  edx,[sc.work]		   ; color of work area RRGGBB,8->color gl
234
    mov  edx,[sc.work]		   ; color of work area RRGGBB,8->color gl
235
    or	 edx,0x13000000
235
    or	 edx,0x13000000
236
    mov  edi,title		  ; WINDOW LABEL
236
    mov  edi,title		  ; WINDOW LABEL
237
    mcall
237
    mcall
238
 
238
 
239
    mov  ecx,4
239
    mov  ecx,4
240
    mov  esi,[sc.work]
240
    mov  esi,[sc.work]
241
    mov  ebx,296 shl 16+5*6
241
    mov  ebx,296 shl 16+5*6
242
    mov  edx,3;+1 shl 30
242
    mov  edx,3;+1 shl 30
243
    mcall 8,,<5,12>
243
    mcall 8,,<5,12>
244
    mov  edx,[vmode]
244
    mov  edx,[vmode]
245
    lea  edx,[edx*4+duk]
245
    lea  edx,[edx*4+duk]
246
    mcall 4,<300,8>,,,4
246
    mcall 4,<300,8>,,,4
247
 
247
 
248
    mov  ebx,15*65536+33	   ; draw info text with function 4
248
    mov  ebx,15*65536+33	   ; draw info text with function 4
249
    mov  ecx,[sc.work_text]
249
    mov  ecx,[sc.work_text]
250
    mov  edx,text1
250
    mov  edx,text1
251
    cmp  [vmode],0
251
    cmp  [vmode],0
252
    je	 .kern
252
    je	 .kern
253
    mov  edx,text2
253
    mov  edx,text2
254
  .kern:
254
  .kern:
255
    mov  esi,80
255
    mov  esi,80
256
    mov  eax,4
256
    mov  eax,4
257
  newline:
257
  newline:
258
    mcall
258
    mcall
259
    add  ebx,10
259
    add  ebx,10
260
    add  edx,80
260
    add  edx,80
261
    cmp  [edx],byte 'x'
261
    cmp  [edx],byte 'x'
262
    jne  newline
262
    jne  newline
263
    mov  eax,12 		   ; function 12:tell os about windowdraw
263
    mov  eax,12 		   ; function 12:tell os about windowdraw
264
    mov  ebx,2			   ; 2, end of draw
264
    mov  ebx,2			   ; 2, end of draw
265
    mcall
265
    mcall
266
 
266
 
267
    ret
267
    ret
268
 
268
 
269
 
269
 
270
if WRITE_LOG
270
if WRITE_LOG
271
;********************************************
271
;********************************************
272
;*  input:  esi = pointer to the file name  *
272
;*  input:  esi = pointer to the file name  *
273
;********************************************
273
;********************************************
274
 
274
 
275
CreateFile:
275
CreateFile:
276
    pusha
276
    pusha
277
    mov      dword [InfoStructure],    2   ; create file
277
    mov      dword [InfoStructure],    2   ; create file
278
    mov      dword [InfoStructure+4],  0   ; reserved
278
    mov      dword [InfoStructure+4],  0   ; reserved
279
    mov      dword [InfoStructure+8],  0   ; reserved
279
    mov      dword [InfoStructure+8],  0   ; reserved
280
    mov      dword [InfoStructure+12], 0   ; 0 bytes to write (just create)
280
    mov      dword [InfoStructure+12], 0   ; 0 bytes to write (just create)
281
    mov      dword [InfoStructure+16], 0   ; NULL data pointer (no data)
281
    mov      dword [InfoStructure+16], 0   ; NULL data pointer (no data)
282
    mov      dword [InfoStructure+20], 0   ; reserved
282
    mov      dword [InfoStructure+20], 0   ; reserved
283
    mov      dword [InfoStructure+21], esi ; pointer to the file name
283
    mov      dword [InfoStructure+21], esi ; pointer to the file name
284
    mcall    70, InfoStructure
284
    mcall    70, InfoStructure
285
    clc
-
 
286
    test     eax, eax
285
    test     eax, eax
287
    jz	     .out
286
    jz	     .out
288
    stc
287
    stc
289
  .out:
288
  .out:
290
    popa
289
    popa
291
    ret
290
    ret
292
 
291
 
293
;********************************************
292
;********************************************
294
;*  input:  esi = pointer to the file name  *
293
;*  input:  esi = pointer to the file name  *
295
;*          edx = pointer to data buffer    *
294
;*          edx = pointer to data buffer    *
296
;*          ecx = data length               *
295
;*          ecx = data length               *
297
;********************************************
296
;********************************************
298
 
297
 
299
WriteToFile:
298
WriteToFile:
300
    push     ebx
299
    push     ebx
301
    mov      dword [InfoStructure],    3   ; write to file
300
    mov      dword [InfoStructure],    3   ; write to file
302
    mov      eax,  [filepos]
301
    mov      eax,  [filepos]
303
    mov      dword [InfoStructure+4],  eax ; lower position addr
302
    mov      dword [InfoStructure+4],  eax ; lower position addr
304
    mov      dword [InfoStructure+8],  0   ; upper position addr (0 for FAT)
303
    mov      dword [InfoStructure+8],  0   ; upper position addr (0 for FAT)
305
    mov      dword [InfoStructure+12], ecx ; number of bytes to write
304
    mov      dword [InfoStructure+12], ecx ; number of bytes to write
306
    mov      dword [InfoStructure+16], edx ; pointer to data buffer
305
    mov      dword [InfoStructure+16], edx ; pointer to data buffer
307
    mov      dword [InfoStructure+20], 0   ; reserved
306
    mov      dword [InfoStructure+20], 0   ; reserved
308
    mov      dword [InfoStructure+21], esi ; pointer to the file name
307
    mov      dword [InfoStructure+21], esi ; pointer to the file name
309
    mcall    70, InfoStructure
308
    mcall    70, InfoStructure
310
    clc
309
    clc
311
    test     eax, eax
310
    test     eax, eax
312
    jz	     .out
311
    jz	     .out
313
    stc
312
    stc
314
  .out:
313
  .out:
315
    pop      ebx
314
    pop      ebx
316
    ret
315
    ret
317
 
316
 
318
 
317
 
319
InfoStructure:
318
InfoStructure:
320
		     dd      0x0     ; subfunction number
319
		     dd      0x0     ; subfunction number
321
		     dd      0x0     ; position in the file in bytes
320
		     dd      0x0     ; position in the file in bytes
322
		     dd      0x0     ; upper part of the position address
321
		     dd      0x0     ; upper part of the position address
323
		     dd      0x0     ; number of     bytes to read
322
		     dd      0x0     ; number of     bytes to read
324
		     dd      0x0     ; pointer to the buffer to write data
323
		     dd      0x0     ; pointer to the buffer to write data
325
		     db      0
324
		     db      0
326
		     dd      0	     ; pointer to the filename
325
		     dd      0	     ; pointer to the filename
327
 
326
 
328
filepos  dd 0
327
filepos  dd 0
329
default_filename db '/sys/boardlog.txt',0
328
default_filename db '/sys/boardlog.txt',0
330
tmp	 db 0
329
tmp	 db 0
331
end if
330
end if
332
 
331
 
333
 
332
 
334
 
333
 
335
 
334
 
336
krnl_msg db 'K : '
335
krnl_msg db 'K : '
337
duk db 'KernUser'
336
duk db 'KernUser'
338
 
337
 
339
; DATA AREA
338
; DATA AREA
340
 
339
 
341
; 11,11 > 0,-1
340
; 11,11 > 0,-1
342
; 5,11  > 0,-1
341
; 5,11  > 0,-1
343
if lang eq ru
342
if lang eq ru
344
   title    db	 '„®áª  ®â« ¤ª¨ ¨ á®®¡é¥­¨©',0
343
   title    db	 '„®áª  ®â« ¤ª¨ ¨ á®®¡é¥­¨©',0
345
else if lang eq en
344
else if lang eq en
346
   title    db	 'General debug & message board',0
345
   title    db	 'General debug & message board',0
347
else
346
else
348
   title    db	 'Allgemeines debug- & nachrichtenboard',0
347
   title    db	 'Allgemeines debug- & nachrichtenboard',0
349
end if
348
end if
350
   krnl_cnt dd 0
349
   krnl_cnt dd 0
351
   vmode dd 1
350
   vmode dd 1
352
   targ  dd text2
351
   targ  dd text2
353
I_END:
352
I_END:
354
     offs dd ?
353
     offs dd ?
355
     flag rb 1
354
     flag rb 1
356
     rd 2
355
     rd 2
357
;     x1pos  dd ?
356
;     x1pos  dd ?
358
;     y1pos  dd ?
357
;     y1pos  dd ?
359
     text1 rb 80*(MAXSTRINGS+1)
358
     text1 rb 80*(MAXSTRINGS+1)
360
     tmp1  db ?
359
     tmp1  db ?
361
     rd 2
360
     rd 2
362
;     x2pos  dd ?
361
;     x2pos  dd ?
363
;     y2pos  dd ?
362
;     y2pos  dd ?
364
     text2 rb 80*(MAXSTRINGS+1)
363
     text2 rb 80*(MAXSTRINGS+1)
365
     tmp2  db ?
364
     tmp2  db ?
366
     xstart dd ?
365
     xstart dd ?
367
     sc system_colors
366
     sc system_colors
368
i_end:
367
i_end:
369
 
368
 
370
filename	rb	256
369
filename	rb	256
371
align 4
370
align 4
372
stackbuf	rb	2000h
371
stackbuf	rb	2000h
373
mem:
372
mem: