Subversion Repositories Kolibri OS

Rev

Rev 551 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
31 halyavin 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;                                          ;
3
;   Stack Configuration Tool               ;
4
;                                          ;
5
;   Compile with FASM for Menuet           ;
6
;                                          ;
7
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8
 
199 heavyiron 9
 
10
memsize = 100000h
11
               org 0
12
PARAMS  = memsize - 1024
13
 
31 halyavin 14
use32
15
 
16
               db     'MENUET01'              ; 8 byte id
17
               dd     0x01                    ; header version
18
               dd     START                   ; start of code
19
               dd     I_END                   ; size of image
199 heavyiron 20
               dd     memsize                 ; memory for app
21
               dd     memsize - 1024          ; esp
22
               dd     PARAMS , 0x0            ; I_Param , I_Icon
31 halyavin 23
 
24
include 'lang.inc'
485 heavyiron 25
include '..\..\..\macros.inc'
26
 
31 halyavin 27
START:                          ; start of execution
28
 
625 diamond 29
    cmp     [PARAMS], dword 'BOOT'
30
    jz      boot_set_settings
199 heavyiron 31
 
32
no_params:
33
 
485 heavyiron 34
  red:
31 halyavin 35
    call draw_window            ; at first, draw the window
36
 
37
still:
38
 
39
    mov  eax,10                 ; wait here for event
485 heavyiron 40
    mcall
31 halyavin 41
 
42
    cmp  eax,1                  ; redraw request ?
485 heavyiron 43
    jz   red
31 halyavin 44
    cmp  eax,2                  ; key in buffer ?
485 heavyiron 45
    jnz  button
31 halyavin 46
 
47
  key:                          ; key
625 diamond 48
;    mov  al,2                  ; just read it and ignore
485 heavyiron 49
    mcall
31 halyavin 50
    jmp  still
51
 
52
  button:                       ; button
485 heavyiron 53
    mov  al,17                 ; get id
54
    mcall
31 halyavin 55
 
56
    shr  eax,8
57
 
625 diamond 58
    dec  eax                     ; button id=1 ?
31 halyavin 59
    jne  noclose
485 heavyiron 60
    or   eax,-1                 ; close this program
61
    mcall
31 halyavin 62
  noclose:
63
 
625 diamond 64
    dec  eax
31 halyavin 65
    je   read_stack_setup
66
 
625 diamond 67
    dec  eax
199 heavyiron 68
    jne  no_apply_stack_setup
69
    call apply_stack_setup
70
    jmp  still
31 halyavin 71
 
199 heavyiron 72
no_apply_stack_setup:
625 diamond 73
    dec  eax                  ; GET COM PORT
74
    dec  eax
31 halyavin 75
    jne  no_read_comport
76
    mov  [string_x],272
77
    mov  [string_y],40
78
    mov  [string_length],3
79
    call read_string
80
    movzx eax,byte [string]
81
    cmp  eax,'A'
82
    jb   gcp1
83
    sub  eax,'A'-'9'-1
84
   gcp1:
85
    sub  eax,48
86
    shl  eax,8
87
    mov  ebx,eax
88
    movzx eax,byte [string+1]
89
    cmp  eax,'A'
90
    jb   gcp2
91
    sub  eax,'A'-'9'-1
92
   gcp2:
93
    sub  eax,48
94
    shl  eax,4
95
    add  ebx,eax
96
    movzx eax,byte [string+2]
97
    cmp  eax,'A'
98
    jb   gcp3
99
    sub  eax,'A'-'9'-1
100
   gcp3:
101
    sub  eax,48
102
    add  ebx,eax
103
    mov  [com_add],ebx
625 diamond 104
    jmp  red
31 halyavin 105
   no_read_comport:
106
 
625 diamond 107
    dec  eax                  ; GET COM IRQ
31 halyavin 108
    jne  no_read_comirq
109
    mov  [string_x],284
110
    mov  [string_y],50
111
    mov  [string_length],1
112
    call read_string
113
    movzx eax,byte [string]
114
    cmp  eax,'A'
115
    jb   gci1
116
    sub  eax,'A'-'9'-1
117
   gci1:
118
    sub  eax,48
119
    mov  [com_irq],eax
625 diamond 120
    jmp  red
31 halyavin 121
    no_read_comirq:
122
 
625 diamond 123
    dec  eax                  ; GET IP
124
    jne  no_read_ip
125
    mov  [string_x],205
126
    mov  [string_y],80
127
    mov  [string_length],15
128
    call read_string
129
    mov   esi,string-1
130
    mov   edi,ip_address
131
   ip0:
132
    xor   eax,eax
133
   ip1:
134
    inc   esi
135
    cmp   [esi],byte '0'
136
    jb    ip2
137
    cmp   [esi],byte '9'
138
    jg    ip2
139
    imul  eax,10
140
    movzx ebx,byte [esi]
141
    sub   ebx,48
142
    add   eax,ebx
143
    jmp   ip1
144
   ip2:
145
    stosb
146
    cmp   edi,ip_address+3
147
    jbe   ip0
148
    jmp   red
149
   no_read_ip:
150
 
151
    dec     eax                 ; set gateway ip
31 halyavin 152
    jne     no_set_gateway
153
 
154
    mov  [string_x],205
155
    mov  [string_y],90
156
    mov  [string_length],15
157
    call read_string
158
    mov   esi,string-1
159
    mov   edi,gateway_ip
625 diamond 160
   gip0:
31 halyavin 161
    xor   eax,eax
162
   gip1:
163
    inc   esi
164
    cmp   [esi],byte '0'
165
    jb    gip2
166
    cmp   [esi],byte '9'
167
    jg    gip2
168
    imul  eax,10
169
    movzx ebx,byte [esi]
170
    sub   ebx,48
171
    add   eax,ebx
172
    jmp   gip1
173
   gip2:
625 diamond 174
    stosb
31 halyavin 175
    cmp   edi,gateway_ip+3
625 diamond 176
    jbe   gip0
177
    jmp   red
31 halyavin 178
 
625 diamond 179
  no_set_gateway:
31 halyavin 180
 
625 diamond 181
    dec     eax
31 halyavin 182
    jne     no_set_subnet
183
 
184
    mov  [string_x],205
185
    mov  [string_y],100
186
    mov  [string_length],15
187
    call read_string
188
    mov   esi,string-1
189
    mov   edi,subnet_mask
625 diamond 190
   sip0:
31 halyavin 191
    xor   eax,eax
192
   sip1:
193
    inc   esi
194
    cmp   [esi],byte '0'
195
    jb    sip2
196
    cmp   [esi],byte '9'
197
    jg    sip2
198
    imul  eax,10
199
    movzx ebx,byte [esi]
200
    sub   ebx,48
201
    add   eax,ebx
202
    jmp   sip1
203
   sip2:
625 diamond 204
    stosb
31 halyavin 205
    cmp   edi,subnet_mask+3
625 diamond 206
    jbe   sip0
207
    jmp   red
31 halyavin 208
 
209
  no_set_subnet:
625 diamond 210
    dec     eax
31 halyavin 211
    jne     no_set_dns
212
 
213
    mov  [string_x],205
214
    mov  [string_y],110
215
    mov  [string_length],15
216
    call read_string
217
    mov   esi,string-1
218
    mov   edi,dns_ip
625 diamond 219
   dip0:
31 halyavin 220
    xor   eax,eax
221
   dip1:
222
    inc   esi
223
    cmp   [esi],byte '0'
224
    jb    dip2
225
    cmp   [esi],byte '9'
226
    jg    dip2
227
    imul  eax,10
228
    movzx ebx,byte [esi]
229
    sub   ebx,48
230
    add   eax,ebx
231
    jmp   dip1
232
   dip2:
625 diamond 233
    stosb
31 halyavin 234
    cmp   edi,dns_ip+3
625 diamond 235
    jbe   dip0
236
    jmp   red
31 halyavin 237
 
238
  no_set_dns:
239
 
625 diamond 240
    dec  eax
241
    jb   no_set_interface
242
    cmp  eax,14-11
243
    ja   no_set_interface
244
    mov  [interface],eax
245
    jmp  red
246
   no_set_interface:
31 halyavin 247
 
625 diamond 248
    sub  eax,21-11
249
    jb   no_ip_sf
250
    cmp  eax,22-21
251
    ja   no_ip_sf
252
    xor  eax,1
253
    mov  [assigned],eax
254
    jmp  red
255
    no_ip_sf:
256
    jmp  still
31 halyavin 257
 
258
read_stack_setup:
259
 
260
    mov  eax,52
261
    mov  ebx,0
485 heavyiron 262
    mcall
31 halyavin 263
    mov  [config],eax
264
 
265
    mov  eax,52
266
    mov  ebx,1
485 heavyiron 267
    mcall
31 halyavin 268
    mov  dword [ip_address],eax
269
 
270
    mov  eax,52
271
    mov  ebx,9
485 heavyiron 272
    mcall
31 halyavin 273
    mov  dword [gateway_ip],eax
274
 
275
    mov  eax,52
276
    mov  ebx,10
485 heavyiron 277
    mcall
31 halyavin 278
    mov  dword [subnet_mask],eax
279
 
280
    mov  eax,52
281
    mov  ebx,13
485 heavyiron 282
    mcall
31 halyavin 283
    mov  dword [dns_ip],eax
284
 
285
    mov  eax,[config]   ; unwrap com IRQ
286
    shr  eax,8
287
    and  eax,0xf
288
    mov  [com_irq],eax
289
 
290
    mov  eax,[config]   ; unwrap com PORT
291
    shr  eax,16
292
    and  eax,0xfff
293
    mov  [com_add],eax
294
 
295
    mov  eax,[config]   ; unwrap IRQ
296
    and  eax,0xf
297
    mov  [interface],eax
298
 
299
    mov  eax,[config]   ; unwrap com PORT
300
    shr  eax,7
301
    and  eax,1
302
    mov  [assigned],eax
625 diamond 303
    jmp  red
31 halyavin 304
 
305
apply_stack_setup:
306
 
307
    mov  eax,[com_irq]
308
    shl  eax,8
309
    mov  ebx,[com_add]
310
    shl  ebx,16
311
    add  eax,ebx
312
    add  eax,[interface]
313
    mov  ebx,[assigned]
314
    shl  ebx,7
315
    add  eax,ebx
316
    mov  [config],eax
317
 
318
    mov  eax,52
319
    mov  ebx,3
320
    mov  ecx,dword [ip_address]
485 heavyiron 321
    mcall
31 halyavin 322
 
323
    mov  eax,52
324
    mov  ebx,11
325
    mov  ecx,dword [gateway_ip]
485 heavyiron 326
    mcall
31 halyavin 327
 
328
    mov  eax,52
329
    mov  ebx,12
330
    mov  ecx,dword [subnet_mask]
485 heavyiron 331
    mcall
31 halyavin 332
 
333
    mov  eax,52
334
    mov  ebx,14
335
    mov  ecx,dword [dns_ip]
485 heavyiron 336
    mcall
31 halyavin 337
 
338
    mov  eax,52
339
    mov  ebx,2
340
    mov  ecx,[config]
485 heavyiron 341
    mcall
31 halyavin 342
 
199 heavyiron 343
    ret
31 halyavin 344
 
345
 
346
string_length  dd    16
347
string_x       dd    200
348
string_y       dd    60
349
 
350
string         db    '________________'
351
 
352
 
353
read_string:
354
 
355
    mov  edi,string
356
    mov  eax,'_'
357
    mov  ecx,[string_length]
358
    cld
359
    rep  stosb
360
    call print_text
361
 
362
    mov  edi,string
363
  f11:
364
    mov  eax,10
485 heavyiron 365
    mcall
31 halyavin 366
    cmp  eax,2
367
    jne  read_done
625 diamond 368
;    mov  eax,2
485 heavyiron 369
    mcall
31 halyavin 370
    shr  eax,8
371
    cmp  eax,13
372
    je   read_done
373
    cmp  eax,8
374
    jnz  nobsl
375
    cmp  edi,string
376
    jz   f11
377
    sub  edi,1
378
    mov  [edi],byte '_'
379
    call print_text
380
    jmp  f11
381
  nobsl:
382
    cmp  eax,dword 31
383
    jbe  f11
384
    cmp  eax,dword 95
385
    jb   keyok
386
    sub  eax,32
387
  keyok:
388
    mov  [edi],al
389
    call print_text
390
 
391
    inc  edi
392
    mov  esi,string
393
    add  esi,[string_length]
394
    cmp  esi,edi
395
    jnz  f11
396
 
397
  read_done:
398
 
399
print_text:
400
 
401
    pusha
402
 
403
    mov  eax,13
404
    mov  ebx,[string_x]
405
    shl  ebx,16
406
    add  ebx,[string_length]
407
    imul bx,6
408
    mov  ecx,[string_y]
409
    shl  ecx,16
410
    mov  cx,8
411
    mov  edx,0xffffff
485 heavyiron 412
    mcall
31 halyavin 413
 
414
    mov  eax,4
415
    mov  ebx,[string_x]
416
    shl  ebx,16
417
    add  ebx,[string_y]
418
    mov  ecx,0x000000
419
    mov  edx,string
420
    mov  esi,[string_length]
485 heavyiron 421
    mcall
31 halyavin 422
 
423
    popa
424
    ret
425
 
426
 
427
 
428
 
429
 
430
 
431
 
432
;   *********************************************
433
;   *******  WINDOW DEFINITIONS AND DRAW ********
434
;   *********************************************
435
 
436
 
437
draw_window:
438
 
439
    mov  eax,12                    ; function 12:tell os about windowdraw
440
    mov  ebx,1                     ; 1, start of draw
485 heavyiron 441
    mcall
31 halyavin 442
 
443
                                   ; DRAW WINDOW
444
    mov  eax,0                     ; function 0 : define and draw window
445
    mov  ebx,100*65536+330         ; [x start] *65536 + [x size]
446
    mov  ecx,100*65536+157         ; [y start] *65536 + [y size]
551 spraid 447
    mov  edx,0x14ffffff            ; color of work area RRGGBB,8->color gl
485 heavyiron 448
    mov  edi,title                ; WINDOW LABEL
449
    mcall
31 halyavin 450
 
199 heavyiron 451
 
31 halyavin 452
    mov  eax,8                     ; BUTTON : READ SETUP
453
    mov  ebx,90*65536+65
454
    mov  ecx,127*65536+12
455
    mov  edx,2
199 heavyiron 456
    mov  esi,[button_color]
485 heavyiron 457
    mcall
31 halyavin 458
 
199 heavyiron 459
    ;mov  eax,8                     ; BUTTON : APPLY SETUP
31 halyavin 460
    mov  ebx,163*65536+65
461
    mov  ecx,127*65536+12
462
    mov  edx,3
485 heavyiron 463
    mcall
31 halyavin 464
 
199 heavyiron 465
    ;mov  eax,8                     ; BUTTONS 11-14 : SELECT INTERFACE
31 halyavin 466
    mov  ebx,29*65536+8
467
    mov  ecx,39*65536+8
468
    mov  edx,11
469
  interface_select:
485 heavyiron 470
    mcall
31 halyavin 471
    add  ecx,10*65536
472
    inc  edx
473
    cmp  edx,11+4
474
    jb   interface_select
475
 
476
    mov  ebx,[interface]           ; PRINT SELECTED INTERFACE 'X'
477
    imul ebx,10
478
    add  ebx,31*65536+39
479
    mov  eax,4
480
    mov  ecx,0xffffff
481
    mov  edx,xx
482
    mov  esi,1
485 heavyiron 483
    mcall
31 halyavin 484
 
485
    mov  eax,8                    ; BUTTONS 21-22 : SERVER / MANUAL IP
486
    mov  ebx,143*65536+8
487
    mov  ecx,69*65536+8
488
    mov  edx,21
489
    mov  esi,[button_color]
485 heavyiron 490
    mcall
199 heavyiron 491
    ;mov  eax,8
31 halyavin 492
    mov  ebx,143*65536+8
493
    mov  ecx,79*65536+8
494
    mov  edx,22
485 heavyiron 495
    mcall
31 halyavin 496
    mov  ebx,[assigned]           ; PRINT SELECTED SERVER/MANUAL 'X'
497
    not  ebx
498
    and  ebx,1
499
    imul ebx,10
500
    add  ebx,145*65536+69
501
    mov  eax,4
502
    mov  ecx,0xffffff
503
    mov  edx,xx
504
    mov  esi,1
485 heavyiron 505
    mcall
31 halyavin 506
 
507
    mov  eax,47                   ; COM ADDRESS
508
    mov  ebx,3*65536+1*256
509
    mov  ecx,[com_add]
510
    mov  edx,272*65536+40
511
    mov  esi,0x000000
485 heavyiron 512
    mcall
31 halyavin 513
 
199 heavyiron 514
    ;mov  eax,47                   ; COM IRQ
31 halyavin 515
    mov  ebx,1*65536+1*256
516
    mov  ecx,[com_irq]
517
    mov  edx,(266+3*6)*65536+50
518
    mov  esi,0x000000
485 heavyiron 519
    mcall
31 halyavin 520
 
521
    mov  edi,ip_address
522
    mov  edx,205*65536+80
523
    mov  esi,0x000000
524
    mov  ebx,3*65536
525
  ipdisplay:
199 heavyiron 526
    ;mov  eax,47
31 halyavin 527
    movzx ecx,byte [edi]
485 heavyiron 528
    mcall
31 halyavin 529
    add  edx,6*4*65536
530
    inc  edi
531
    cmp  edi,ip_address+4
532
    jb   ipdisplay
533
 
534
    mov  edi,gateway_ip
535
    mov  edx,205*65536+90
536
    mov  esi,0x000000
537
    mov  ebx,3*65536
538
  gipdisplay:
199 heavyiron 539
    ;mov  eax,47
31 halyavin 540
    movzx ecx,byte [edi]
485 heavyiron 541
    mcall
31 halyavin 542
    add  edx,6*4*65536
543
    inc  edi
544
    cmp  edi,gateway_ip+4
545
    jb   gipdisplay
546
 
547
    mov  edi,subnet_mask
548
    mov  edx,205*65536+100
549
    mov  esi,0x000000
550
    mov  ebx,3*65536
551
  sipdisplay:
199 heavyiron 552
    ;mov  eax,47
31 halyavin 553
    movzx ecx,byte [edi]
485 heavyiron 554
    mcall
31 halyavin 555
    add  edx,6*4*65536
556
    inc  edi
557
    cmp  edi,subnet_mask+4
558
    jb   sipdisplay
559
 
560
    mov  edi,dns_ip
561
    mov  edx,205*65536+110
562
    mov  esi,0x000000
563
    mov  ebx,3*65536
564
  dipdisplay:
199 heavyiron 565
    ;mov  eax,47
31 halyavin 566
    movzx ecx,byte [edi]
485 heavyiron 567
    mcall
31 halyavin 568
    add  edx,6*4*65536
569
    inc  edi
570
    cmp  edi,dns_ip+4
571
    jb   dipdisplay
572
 
573
 
574
    mov  eax,8                     ; BUTTON 5 : SET PORT
575
    mov  ebx,299*65536+8
576
    mov  ecx,39*65536+8
577
    mov  edx,5
578
    mov  esi,[button_color]
485 heavyiron 579
    mcall
199 heavyiron 580
    ;mov  eax,8                     ; BUTTON 6 : SET IRQ
31 halyavin 581
    mov  ecx,49*65536+8
625 diamond 582
    inc  edx
485 heavyiron 583
    mcall
199 heavyiron 584
    ;mov  eax,8                     ; BUTTON 7 : SET IP
31 halyavin 585
    mov  ecx,79*65536+8
625 diamond 586
    inc  edx
485 heavyiron 587
    mcall
31 halyavin 588
 
199 heavyiron 589
    ;mov  eax,8                     ; BUTTON 8 : SET gateway IP
31 halyavin 590
    mov  ebx,299*65536+8
591
    mov  ecx,89*65536+8
625 diamond 592
    inc  edx
485 heavyiron 593
    mcall
31 halyavin 594
 
199 heavyiron 595
    ;mov  eax,8                     ; BUTTON 9 : SET subnet
31 halyavin 596
    mov  ecx,99*65536+8
625 diamond 597
    inc  edx
485 heavyiron 598
    mcall
31 halyavin 599
 
199 heavyiron 600
    ;mov  eax,8                     ; BUTTON 10 : SET dns ip
31 halyavin 601
    mov  ecx,109*65536+8
625 diamond 602
    inc  edx
485 heavyiron 603
    mcall
31 halyavin 604
 
605
    mov  ebx,31*65536+40           ; draw info text with function 4
606
    mov  edx,text
607
    mov  esi,49
199 heavyiron 608
    mov  eax,4
31 halyavin 609
  newline:
610
    mov  ecx,0x224466
611
    cmp  [edx],byte 'w'
612
    jne  nowhite
613
    mov  ecx,0xeeeeee
614
   nowhite:
615
    inc  edx
485 heavyiron 616
    mcall
31 halyavin 617
    add  ebx,10
618
    add  edx,49
619
    cmp  [edx],byte 'x'
620
    jne  newline
621
 
622
    mov  eax,12                    ; function 12:tell os about windowdraw
623
    mov  ebx,2                     ; 2, end of draw
485 heavyiron 624
    mcall
31 halyavin 625
 
626
    ret
627
 
199 heavyiron 628
;******************************************************************************
31 halyavin 629
 
199 heavyiron 630
boot_set_settings:
631
 
632
    mov  eax,52
633
    mov  ebx,0
485 heavyiron 634
    mcall
199 heavyiron 635
    mov  [config],eax
636
 
637
    shr  eax,8          ; unwrap com IRQ
638
    and  eax,0xf
639
    mov  [com_irq],eax
640
 
641
    mov  eax,[config]   ; unwrap com PORT
642
    shr  eax,16
643
    and  eax,0xfff
644
    mov  [com_add],eax
645
 
646
    call apply_stack_setup
647
 
648
    mov  eax,-1                 ; close this program
485 heavyiron 649
    mcall
199 heavyiron 650
 
651
;******************************************************************************
652
 
653
 
31 halyavin 654
; DATA AREA
655
 
656
text:
657
    db '   Not active       Modem Com Port:    0x     <   '
658
    db '   Slip             Modem Com Irq:       0x   <   '
659
    db '   PPP                                            '
660
    db '   Packet Driver      IP server assigned          '
661
    db '                      Fixed:     .   .   .    <   '
662
    db '                      Gateway:   .   .   .    <   '
663
    db '                      Subnet:    .   .   .    <   '
664
    db '                      DNS IP:    .   .   .    <   '
665
    db '                                                  '
666
    db 'w             READ        APPLY                   '
667
 
199 heavyiron 668
xx: db 'x' ;<- END MARKER, DONT DELETE
31 halyavin 669
 
670
button_color dd  0x2254b9
671
 
485 heavyiron 672
title      db  'STACK CONFIGURATION',0
31 halyavin 673
 
205 heavyiron 674
 
675
;ENTER YOUR SETTINGS HERE:
676
 
199 heavyiron 677
ip_address  db  010,005,004,175
678
gateway_ip  db  010,005,000,001
679
subnet_mask db  255,255,000,000
680
dns_ip      db  213,184,238,006
31 halyavin 681
 
205 heavyiron 682
 
31 halyavin 683
com_irq     dd      0   ; irq for slip/ppp
684
com_add     dd      0   ; com port address for slip/ppp
199 heavyiron 685
interface   dd      3   ; not active,slip,ppp,packet driver
686
assigned    dd      0   ; get ip from server
31 halyavin 687
 
688
config      dd      0
689
 
690
I_END: