Subversion Repositories Kolibri OS

Rev

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

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