Subversion Repositories Kolibri OS

Rev

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

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