Subversion Repositories Kolibri OS

Rev

Rev 593 | Rev 802 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                              ;;
  3. ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
  4. ;; Distributed under terms of the GNU General Public License    ;;
  5. ;;                                                              ;;
  6. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7.  
  8. ;-------------------------------------------------------------------------
  9. ;Loading configuration from ini file
  10. ;    {SPraid.simba}
  11. ;-------------------------------------------------------------------------
  12.  
  13. $Revision: 750 $
  14.  
  15.  
  16. conf_path_sect: db 'path',0
  17.  
  18. conf_fname db '/sys/sys.conf',0
  19.  
  20. ; set soke kernel configuration
  21. proc set_kernel_conf
  22. locals
  23.   par db 30 dup(?)
  24. endl
  25.   pushad
  26.   ;[gui]
  27.   ;mouse_speed
  28.   lea eax,[par]
  29.   push eax
  30.   invoke ini.get_str,conf_fname, ugui, ugui_mouse_speed, eax,30, ugui_mouse_speed_def        
  31.   pop eax
  32.   stdcall strtoint,eax
  33.         mov     [mouse_speed_factor], ax
  34.  
  35.   ;mouse_delay
  36.   lea eax,[par]
  37.   push eax
  38.   invoke ini.get_str,conf_fname, ugui, ugui_mouse_delay, eax,30, ugui_mouse_delay_def
  39.   pop eax
  40.   stdcall strtoint,eax
  41.         mov     [mouse_delay], eax
  42.  
  43.   ;[dev]
  44.   ;sb16
  45.   lea eax,[par]
  46.   push eax
  47.   invoke ini.get_str,conf_fname, udev, udev_sb16, eax,30, udev_sb16_def
  48.   pop eax
  49.   stdcall strtoint,eax
  50.         cmp     eax, 0x100
  51.         jb      @f
  52.         cmp     eax, 0x10000
  53.         jae     @f
  54.         mov     [sb16], eax
  55. @@:
  56.  
  57.   ;sound_dma
  58.   lea eax,[par]
  59.   push eax
  60.   invoke ini.get_str,conf_fname, udev, udev_sound_dma, eax,30, udev_sound_dma_def
  61.   pop eax
  62.   stdcall strtoint,eax
  63.         cmp     eax, 3
  64.         ja      @f
  65.         mov     [sound_dma], eax
  66. @@:
  67.  
  68.   ;midibase
  69.   lea eax,[par]
  70.   push eax
  71.   invoke ini.get_str,conf_fname, udev, udev_midibase, eax,30, udev_midibase_def
  72.   pop eax
  73.   stdcall strtoint,eax
  74.         cmp     eax, 0x100
  75.         jb      @f
  76.         cmp     eax, 0x10000
  77.         jae     @f
  78.         mov     [midi_base], ax
  79.         mov     [mididp], eax
  80.         inc     eax
  81.         mov     [midisp], eax
  82. @@:
  83.  
  84.   popad
  85.   ret
  86. endp
  87.  
  88. ugui db 'gui',0
  89. ugui_mouse_speed db 'mouse_speed',0
  90. ugui_mouse_speed_def db '2',0
  91. ugui_mouse_delay db 'mouse_delay',0
  92. ugui_mouse_delay_def db '0x00A',0
  93.  
  94. udev db 'dev',0
  95. udev_sb16 db 'sb16',0
  96. udev_sb16_def db '0x220',0
  97. udev_sound_dma db 'sound_dma',0
  98. udev_sound_dma_def db '1',0
  99. udev_midibase db 'midibase',0
  100. udev_midibase_def db '0x320',0
  101.  
  102. ;set up netvork configuration
  103. proc set_network_conf
  104. locals
  105.   par db 30 dup(?)
  106. endl
  107.   pushad
  108.  
  109.   ;[net]
  110.   ;active
  111.   lea eax,[par]
  112.   invoke ini.get_int,conf_fname, unet, unet_active, 0
  113.   or eax,eax
  114.   jz .do_not_set_net
  115.         mov     eax, [stack_config]
  116.         and     eax, 0xFFFFFF80
  117.         add     eax, 3
  118.         mov     [stack_config], eax
  119.         call    ash_eth_enable
  120.  
  121.   ;addr
  122.   lea eax,[par]
  123.   push eax
  124.   invoke ini.get_str,conf_fname, unet, unet_addr, eax,30, unet_def
  125.   pop eax
  126.   stdcall do_inet_adr,eax
  127.         mov     [stack_ip], eax
  128.  
  129.   ;mask
  130.   lea eax,[par]
  131.   push eax
  132.   invoke ini.get_str,conf_fname, unet, unet_mask, eax,30, unet_def
  133.   pop eax
  134.   stdcall do_inet_adr,eax
  135.         mov     [subnet_mask], eax
  136.  
  137.   ;gate
  138.   lea eax,[par]
  139.   push eax
  140.   invoke ini.get_str,conf_fname, unet, unet_gate, eax,30, unet_def
  141.   pop eax
  142.   stdcall do_inet_adr,eax
  143.         mov     [gateway_ip], eax
  144. .do_not_set_net:
  145.   popad
  146.   ret
  147.  
  148.  
  149. endp
  150.  
  151. unet db 'net',0
  152. unet_active db 'active',0
  153. unet_addr db 'addr',0
  154. unet_mask db 'mask',0
  155. unet_gate db 'gate',0
  156. unet_def db 0
  157.  
  158. ; convert string to DWord
  159. proc strtoint stdcall,strs
  160.   pushad
  161.  
  162.   mov eax,[strs]
  163.   inc eax
  164.   mov bl,[eax]
  165.   cmp bl,'x'
  166.   je .hex
  167.   cmp bl,'X'
  168.   je .hex
  169.   jmp .dec
  170. .hex:
  171.   inc eax
  172.   stdcall strtoint_hex,eax
  173.   jmp .exit
  174. .dec:
  175.   dec eax
  176.   stdcall strtoint_dec,eax
  177. .exit:
  178.   mov [esp+28],eax
  179.   popad
  180.   ret  
  181. endp
  182.  
  183. ; convert string to DWord for decimal value
  184. proc strtoint_dec stdcall,strs
  185.   pushad
  186.   xor edx,edx
  187.   ; ¯®¨áª ª®­æ 
  188.   mov esi,[strs]
  189. @@:
  190.   lodsb
  191.   or al,al
  192.   jnz @b
  193.   mov ebx,esi
  194.   mov esi,[strs]
  195.   dec ebx
  196.   sub ebx,esi
  197.   mov ecx,1
  198.  
  199. @@:
  200.   dec ebx
  201.   or ebx,ebx
  202.   jz @f
  203.   imul ecx,ecx,10  ; ¯®à冷ª
  204.   jmp @b
  205. @@:
  206.  
  207.  xchg ebx,ecx
  208.  
  209.  
  210.   xor ecx,ecx
  211.  
  212.  
  213. @@:  
  214.   xor eax,eax
  215.   lodsb
  216.   cmp al,0
  217.   je .eend
  218.  
  219.   sub al,30h
  220.   imul ebx
  221.   add ecx,eax
  222.   push ecx
  223.   xchg eax,ebx
  224.   mov ecx,10
  225.   div ecx
  226.   xchg eax,ebx
  227.   pop ecx
  228.   jmp @b
  229.  
  230. .eend:
  231.   mov [esp+28],ecx
  232.   popad
  233.   ret
  234. endp
  235.  
  236. ;convert string to DWord for hex value
  237. proc strtoint_hex stdcall,strs
  238.   pushad
  239.   xor edx,edx
  240.  
  241.   mov esi,[strs]
  242.   mov ebx,1
  243.   add esi,1
  244.  
  245. @@:
  246.   lodsb
  247.   or al,al
  248.   jz @f
  249.   shl ebx,4
  250.   jmp @b
  251. @@:
  252.   xor ecx,ecx
  253.   mov esi,[strs]
  254.  
  255. @@:  
  256.   xor eax,eax
  257.   lodsb
  258.   cmp al,0
  259.   je .eend
  260.  
  261.   cmp al,'a'
  262.   jae .bm
  263.   cmp al,'A'
  264.   jae .bb
  265.   jmp .cc
  266. .bm:    ; 57h
  267.   sub al,57h
  268.   jmp .do
  269.  
  270. .bb:    ; 37h
  271.   sub al,37h
  272.   jmp .do
  273.  
  274. .cc:    ; 30h
  275.   sub al,30h
  276.  
  277. .do:  
  278.   imul ebx
  279.   add ecx,eax
  280.   shr ebx,4
  281.  
  282.   jmp @b
  283.  
  284. .eend:
  285.   mov [esp+28],ecx
  286.   popad
  287.   ret
  288. endp    
  289.  
  290.  
  291. ; convert string to DWord for IP addres
  292. proc do_inet_adr stdcall,strs
  293.   pushad
  294.  
  295.   mov esi,[strs]
  296.   mov ebx,0
  297. .next:
  298.   push esi
  299. @@:
  300.   lodsb
  301.   or al,al
  302.   jz @f
  303.   cmp al,'.'
  304.   jz @f
  305.   jmp @b
  306. @@:
  307.   mov cl, al
  308.   mov [esi-1],byte 0
  309.   ;pop eax
  310.   call strtoint_dec
  311.   rol eax,24
  312.   ror ebx,8
  313.   add ebx,eax
  314.   or cl,cl
  315.   jz @f
  316.   jmp .next
  317. @@:
  318.   mov [esp+28],ebx
  319.   popad
  320.   ret
  321. endp
  322.