Subversion Repositories Kolibri OS

Rev

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