Subversion Repositories Kolibri OS

Rev

Rev 551 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;                                          ;
  3. ;   Stack Configuration Tool               ;
  4. ;                                          ;
  5. ;   Compile with FASM for Menuet           ;
  6. ;                                          ;
  7. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  8.  
  9.  
  10. memsize = 100000h
  11.                org 0
  12. PARAMS  = memsize - 1024
  13.  
  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
  20.                dd     memsize                 ; memory for app
  21.                dd     memsize - 1024          ; esp
  22.                dd     PARAMS , 0x0            ; I_Param , I_Icon
  23.  
  24. include 'lang.inc'
  25. include '..\..\..\macros.inc'
  26.  
  27. START:                          ; start of execution
  28.  
  29.     cmp     [PARAMS], dword 'BOOT'
  30.     jz      boot_set_settings
  31.  
  32. no_params:
  33.  
  34.   red:
  35.     call draw_window            ; at first, draw the window
  36.  
  37. still:
  38.  
  39.     mov  eax,10                 ; wait here for event
  40.     mcall
  41.  
  42.     cmp  eax,1                  ; redraw request ?
  43.     jz   red
  44.     cmp  eax,2                  ; key in buffer ?
  45.     jnz  button
  46.  
  47.   key:                          ; key
  48. ;    mov  al,2                  ; just read it and ignore
  49.     mcall
  50.     jmp  still
  51.  
  52.   button:                       ; button
  53.     mov  al,17                 ; get id
  54.     mcall
  55.  
  56.     shr  eax,8
  57.  
  58.     dec  eax                     ; button id=1 ?
  59.     jne  noclose
  60.     or   eax,-1                 ; close this program
  61.     mcall
  62.   noclose:
  63.  
  64.     dec  eax  
  65.     je   read_stack_setup
  66.  
  67.     dec  eax  
  68.     jne  no_apply_stack_setup
  69.     call apply_stack_setup
  70.     jmp  still
  71.  
  72. no_apply_stack_setup:
  73.     dec  eax                  ; GET COM PORT
  74.     dec  eax
  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
  104.     jmp  red
  105.    no_read_comport:
  106.  
  107.     dec  eax                  ; GET COM IRQ
  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
  120.     jmp  red
  121.     no_read_comirq:
  122.  
  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
  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
  160.    gip0:
  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:
  174.     stosb
  175.     cmp   edi,gateway_ip+3
  176.     jbe   gip0
  177.     jmp   red
  178.  
  179.   no_set_gateway:
  180.  
  181.     dec     eax
  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
  190.    sip0:
  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:
  204.     stosb
  205.     cmp   edi,subnet_mask+3
  206.     jbe   sip0
  207.     jmp   red
  208.  
  209.   no_set_subnet:
  210.     dec     eax
  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
  219.    dip0:
  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:
  233.     stosb
  234.     cmp   edi,dns_ip+3
  235.     jbe   dip0
  236.     jmp   red
  237.  
  238.   no_set_dns:
  239.  
  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:
  247.  
  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
  257.  
  258. read_stack_setup:
  259.  
  260.     mov  eax,52
  261.     mov  ebx,0
  262.     mcall
  263.     mov  [config],eax
  264.  
  265.     mov  eax,52
  266.     mov  ebx,1
  267.     mcall
  268.     mov  dword [ip_address],eax
  269.  
  270.     mov  eax,52
  271.     mov  ebx,9
  272.     mcall
  273.     mov  dword [gateway_ip],eax
  274.  
  275.     mov  eax,52
  276.     mov  ebx,10
  277.     mcall
  278.     mov  dword [subnet_mask],eax
  279.  
  280.     mov  eax,52
  281.     mov  ebx,13
  282.     mcall
  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
  303.     jmp  red
  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]
  321.     mcall
  322.  
  323.     mov  eax,52
  324.     mov  ebx,11
  325.     mov  ecx,dword [gateway_ip]
  326.     mcall
  327.  
  328.     mov  eax,52
  329.     mov  ebx,12
  330.     mov  ecx,dword [subnet_mask]
  331.     mcall
  332.  
  333.     mov  eax,52
  334.     mov  ebx,14
  335.     mov  ecx,dword [dns_ip]
  336.     mcall
  337.  
  338.     mov  eax,52
  339.     mov  ebx,2
  340.     mov  ecx,[config]
  341.     mcall
  342.  
  343.     ret
  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
  365.     mcall
  366.     cmp  eax,2
  367.     jne  read_done
  368. ;    mov  eax,2
  369.     mcall
  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
  412.     mcall
  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]
  421.     mcall
  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
  441.     mcall
  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]
  447.     mov  edx,0x14ffffff            ; color of work area RRGGBB,8->color gl
  448.     mov  edi,title                ; WINDOW LABEL
  449.     mcall
  450.  
  451.                                    
  452.     mov  eax,8                     ; BUTTON : READ SETUP
  453.     mov  ebx,90*65536+65
  454.     mov  ecx,127*65536+12
  455.     mov  edx,2
  456.     mov  esi,[button_color]
  457.     mcall
  458.  
  459.     ;mov  eax,8                     ; BUTTON : APPLY SETUP
  460.     mov  ebx,163*65536+65
  461.     mov  ecx,127*65536+12
  462.     mov  edx,3
  463.     mcall
  464.  
  465.     ;mov  eax,8                     ; BUTTONS 11-14 : SELECT INTERFACE
  466.     mov  ebx,29*65536+8
  467.     mov  ecx,39*65536+8
  468.     mov  edx,11
  469.   interface_select:
  470.     mcall
  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
  483.     mcall
  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]
  490.     mcall
  491.     ;mov  eax,8
  492.     mov  ebx,143*65536+8
  493.     mov  ecx,79*65536+8
  494.     mov  edx,22
  495.     mcall
  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
  505.     mcall
  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
  512.     mcall
  513.  
  514.     ;mov  eax,47                   ; COM IRQ
  515.     mov  ebx,1*65536+1*256
  516.     mov  ecx,[com_irq]
  517.     mov  edx,(266+3*6)*65536+50
  518.     mov  esi,0x000000
  519.     mcall
  520.  
  521.     mov  edi,ip_address
  522.     mov  edx,205*65536+80
  523.     mov  esi,0x000000
  524.     mov  ebx,3*65536
  525.   ipdisplay:
  526.     ;mov  eax,47
  527.     movzx ecx,byte [edi]
  528.     mcall
  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:
  539.     ;mov  eax,47
  540.     movzx ecx,byte [edi]
  541.     mcall
  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:
  552.     ;mov  eax,47
  553.     movzx ecx,byte [edi]
  554.     mcall
  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:
  565.     ;mov  eax,47
  566.     movzx ecx,byte [edi]
  567.     mcall
  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]
  579.     mcall
  580.     ;mov  eax,8                     ; BUTTON 6 : SET IRQ
  581.     mov  ecx,49*65536+8
  582.     inc  edx
  583.     mcall
  584.     ;mov  eax,8                     ; BUTTON 7 : SET IP
  585.     mov  ecx,79*65536+8
  586.     inc  edx
  587.     mcall
  588.  
  589.     ;mov  eax,8                     ; BUTTON 8 : SET gateway IP
  590.     mov  ebx,299*65536+8
  591.     mov  ecx,89*65536+8
  592.     inc  edx
  593.     mcall
  594.  
  595.     ;mov  eax,8                     ; BUTTON 9 : SET subnet
  596.     mov  ecx,99*65536+8
  597.     inc  edx
  598.     mcall
  599.  
  600.     ;mov  eax,8                     ; BUTTON 10 : SET dns ip
  601.     mov  ecx,109*65536+8
  602.     inc  edx
  603.     mcall
  604.  
  605.     mov  ebx,31*65536+40           ; draw info text with function 4
  606.     mov  edx,text
  607.     mov  esi,49
  608.     mov  eax,4
  609.   newline:
  610.     mov  ecx,0x224466
  611.     cmp  [edx],byte 'w'
  612.     jne  nowhite
  613.     mov  ecx,0xeeeeee
  614.    nowhite:
  615.     inc  edx
  616.     mcall
  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
  624.     mcall
  625.  
  626.     ret
  627.  
  628. ;******************************************************************************
  629.  
  630. boot_set_settings:
  631.  
  632.     mov  eax,52
  633.     mov  ebx,0
  634.     mcall
  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
  649.     mcall
  650.  
  651. ;******************************************************************************
  652.  
  653.  
  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.  
  668. xx: db 'x' ;<- END MARKER, DONT DELETE
  669.  
  670. button_color dd  0x2254b9
  671.  
  672. title      db  'STACK CONFIGURATION',0
  673.  
  674.  
  675. ;ENTER YOUR SETTINGS HERE:
  676.  
  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
  681.  
  682.  
  683. com_irq     dd      0   ; irq for slip/ppp
  684. com_add     dd      0   ; com port address for slip/ppp
  685. interface   dd      3   ; not active,slip,ppp,packet driver
  686. assigned    dd      0   ; get ip from server
  687.  
  688. config      dd      0
  689.  
  690. I_END:
  691.