Subversion Repositories Kolibri OS

Rev

Rev 536 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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