Subversion Repositories Kolibri OS

Rev

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