Subversion Repositories Kolibri OS

Rev

Rev 1276 | Rev 2455 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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