Rev 1885 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1885 | Rev 2220 | ||
---|---|---|---|
Line 19... | Line 19... | ||
19 | ;; GNU GENERAL PUBLIC LICENSE ;; |
19 | ;; GNU GENERAL PUBLIC LICENSE ;; |
20 | ;; Version 2, June 1991 ;; |
20 | ;; Version 2, June 1991 ;; |
21 | ;; ;; |
21 | ;; ;; |
22 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
22 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 23... | Line 23... | ||
23 | 23 | ||
Line 24... | Line 24... | ||
24 | $Revision: 1885 $ |
24 | $Revision: 2220 $ |
25 | 25 | ||
Line 26... | Line 26... | ||
26 | __DEBUG_LEVEL_OLD__ equ __DEBUG_LEVEL__ ; use seperate debug level for network part of kernel |
26 | __DEBUG_LEVEL_OLD__ equ __DEBUG_LEVEL__ ; use seperate debug level for network part of kernel |
Line 174... | Line 174... | ||
174 | 174 | ||
175 | align 4 |
175 | align 4 |
Line 176... | Line 176... | ||
176 | uglobal |
176 | uglobal |
177 | 177 | ||
Line 178... | Line 178... | ||
178 | NET_RUNNING dd ? |
178 | NET_RUNNING dd ? |
Line 179... | Line 179... | ||
179 | NET_DRV_LIST rd MAX_NET_DEVICES |
179 | NET_DRV_LIST rd (MAX_NET_DEVICES + 1) ; device 0 is a link to the default device |
Line 195... | Line 195... | ||
195 | stack_init: |
195 | stack_init: |
Line 196... | Line 196... | ||
196 | 196 | ||
197 | ; Init the network drivers list |
197 | ; Init the network drivers list |
198 | xor eax, eax |
198 | xor eax, eax |
199 | mov edi, NET_RUNNING |
199 | mov edi, NET_RUNNING |
200 | mov ecx, MAX_NET_DEVICES + 1 |
200 | mov ecx, (MAX_NET_DEVICES + 2) |
Line 201... | Line -... | ||
201 | rep stosd |
- | |
202 | 201 | rep stosd |
|
203 | ETH_init |
202 | |
Line 204... | Line 203... | ||
204 | ; SLIP_init |
203 | ; SLIP_init |
205 | ; PPPOE_init |
204 | ; PPPOE_init |
Line 257... | Line 256... | ||
257 | 256 | ||
258 | 257 | ||
259 | 258 | ||
260 | ;----------------------------------------------------------------- |
259 | ;----------------------------------------------------------------- |
261 | ; |
260 | ; |
262 | ; NET_add_Device: |
261 | ; NET_add_device: |
263 | ; |
262 | ; |
264 | ; This function is called by the network drivers, |
263 | ; This function is called by the network drivers, |
Line 269... | Line 268... | ||
269 | ; |
268 | ; |
270 | ;----------------------------------------------------------------- |
269 | ;----------------------------------------------------------------- |
271 | align 4 |
270 | align 4 |
272 | NET_add_device: |
271 | NET_add_device: |
Line 273... | Line 272... | ||
273 | 272 | ||
Line 274... | Line 273... | ||
274 | DEBUGF 1,"NET_Add_Device: %x\n", ebx |
273 | DEBUGF 1,"NET_Add_Device: %x\n", ebx ;;; TODO: use mutex to lock net device list |
275 | 274 | ||
276 | mov eax, [NET_RUNNING] |
275 | mov eax, [NET_RUNNING] |
Line 277... | Line 276... | ||
277 | cmp eax, MAX_NET_DEVICES |
276 | cmp eax, MAX_NET_DEVICES |
278 | jge .error |
277 | jge .error |
279 | 278 | ||
280 | ;---------------------------------- |
279 | ;---------------------------------- |
281 | ; Check if device is already listed |
280 | ; Check if device is already listed |
Line 282... | Line 281... | ||
282 | mov eax, ebx |
281 | mov eax, ebx |
283 | mov ecx, MAX_NET_DEVICES ; We need to check whole list because a device may be removed without re-organizing list |
282 | mov ecx, MAX_NET_DEVICES ; We need to check whole list because a device may be removed without re-organizing list |
Line 284... | Line 283... | ||
284 | mov edi, NET_DRV_LIST |
283 | mov edi, NET_DRV_LIST+4 |
285 | 284 | ||
286 | repne scasd ; See if device is already in the list |
285 | repne scasd ; See if device is already in the list |
287 | jz .error |
286 | jz .error |
288 | 287 | ||
Line 289... | Line 288... | ||
289 | ;---------------------------- |
288 | ;---------------------------- |
290 | ; Find empty slot in the list |
289 | ; Find empty slot in the list |
Line 291... | Line 290... | ||
291 | xor eax, eax |
290 | xor eax, eax |
Line 292... | Line -... | ||
292 | mov ecx, MAX_NET_DEVICES |
- | |
293 | mov edi, NET_DRV_LIST |
- | |
294 | - | ||
295 | repne scasd |
- | |
296 | jnz .error |
- | |
297 | - | ||
298 | sub edi, 4 |
- | |
299 | - | ||
300 | cmp [ebx + NET_DEVICE.type], NET_TYPE_ETH |
- | |
301 | je .ethernet |
- | |
302 | - | ||
303 | cmp [ebx + NET_DEVICE.type], NET_TYPE_SLIP |
- | |
304 | je .slip |
- | |
305 | - | ||
306 | DEBUGF 1,"Unknown network device type: %u\n", [ebx + NET_DEVICE.type] |
- | |
307 | jmp .error |
- | |
308 | - | ||
309 | .ethernet: |
- | |
310 | DEBUGF 1,"Trying to add an ethernet device\n" |
- | |
311 | - | ||
312 | inc [ETH_RUNNING] ; Indicate that one more ethernet device is up and running |
- | |
313 | jmp .add_it |
- | |
314 | - | ||
315 | .slip: |
291 | mov ecx, MAX_NET_DEVICES |
316 | DEBUGF 1,"Trying to add a slip device\n" |
292 | mov edi, NET_DRV_LIST+4 |
317 | ;;;; |
293 | |
Line 318... | Line 294... | ||
318 | jmp .error |
294 | repne scasd |
319 | 295 | jnz .error |
|
320 | 296 | ||
Line 321... | Line 297... | ||
321 | .add_it: |
297 | sub edi, 4 |
Line -... | Line 298... | ||
- | 298 | ||
- | 299 | ;----------------------------- |
|
- | 300 | ; Add device to the found slot |
|
- | 301 | mov [edi], ebx ; add device to list |
|
- | 302 | ||
- | 303 | mov eax, edi ; Calculate device number in eax |
|
- | 304 | sub eax, NET_DRV_LIST |
|
322 | 305 | shr eax, 2 |
|
323 | ;----------------------------- |
306 | |
Line 324... | Line 307... | ||
324 | ; Add device to the found slot |
307 | inc [NET_RUNNING] ; Indicate that one more network device is up and running |
325 | mov [edi], ebx ; add device to list |
308 | |
Line 340... | Line 323... | ||
340 | 323 | ||
341 | 324 | ||
- | 325 | ||
- | 326 | ;----------------------------------------------------------------- |
|
- | 327 | ; |
|
- | 328 | ; NET_set_default |
|
- | 329 | ; |
|
- | 330 | ; API to set the default interface |
|
- | 331 | ; |
|
- | 332 | ; IN: Device num in eax |
|
- | 333 | ; OUT: Device num in eax, -1 on error |
|
- | 334 | ; |
|
- | 335 | ;----------------------------------------------------------------- |
|
- | 336 | align 4 |
|
- | 337 | NET_set_default: |
|
- | 338 | ||
- | 339 | DEBUGF 1,"NET_set_default %x\n", eax |
|
- | 340 | ||
- | 341 | cmp eax, MAX_NET_DEVICES |
|
- | 342 | jge .error |
|
- | 343 | ||
- | 344 | cmp [NET_DRV_LIST+eax*4], 0 |
|
- | 345 | je .error |
|
- | 346 | ||
- | 347 | push [NET_DRV_LIST+eax*4] |
|
- | 348 | pop [NET_DRV_LIST] |
|
- | 349 | ||
- | 350 | DEBUGF 1,"Device number %u is now default!\n", eax |
|
- | 351 | ret |
|
- | 352 | ||
- | 353 | .error: |
|
- | 354 | or eax, -1 |
|
- | 355 | DEBUGF 2,"Setting default network device failed\n" |
|
- | 356 | ret |
|
- | 357 | ||
342 | 358 | ||
343 | ;----------------------------------------------------------------- |
359 | ;----------------------------------------------------------------- |
344 | ; |
360 | ; |
345 | ; NET_Remove_Device: |
361 | ; NET_Remove_Device: |
346 | ; |
- | |
- | 362 | ; |
|
347 | ; This function is called by etwork drivers, |
363 | ; This function is called by etwork drivers, |
348 | ; to unregister network devices from the kernel |
364 | ; to unregister network devices from the kernel |
349 | ; |
365 | ; d |
350 | ; IN: Pointer to device structure in ebx |
366 | ; IN: Pointer to device structure in ebx |
351 | ; OUT: eax: -1 on error |
367 | ; OUT: eax: -1 on error |
352 | ; |
368 | ; |
Line 353... | Line 369... | ||
353 | ;----------------------------------------------------------------- |
369 | ;----------------------------------------------------------------- |
354 | align 4 |
370 | align 4 |
Line -... | Line 371... | ||
- | 371 | NET_remove_device: |
|
- | 372 | ||
- | 373 | cmp [NET_RUNNING], 0 |
|
- | 374 | je .error |
|
- | 375 | ||
- | 376 | cmp [NET_DRV_LIST], ebx |
|
- | 377 | jne @f |
|
- | 378 | mov [NET_DRV_LIST], 0 |
|
- | 379 | cmp [NET_RUNNING], 1 |
|
- | 380 | je @f |
|
- | 381 | ; there are still active devices, find one and make it default |
|
- | 382 | xor eax, eax |
|
- | 383 | mov ecx, MAX_NET_DEVICES |
|
- | 384 | mov edi, NET_DRV_LIST+4 |
|
- | 385 | repe scasd |
|
355 | NET_remove_device: |
386 | jz @f |
356 | 387 | push dword [edi-4] |
|
Line 357... | Line 388... | ||
357 | cmp [NET_RUNNING], 0 |
388 | pop [NET_DRV_LIST] |
358 | je .error |
389 | @@: |
359 | 390 | ||
Line 360... | Line 391... | ||
360 | ;---------------------------- |
391 | ;---------------------------- |
361 | ; Find the driver in the list |
392 | ; Find the driver in the list |
Line 362... | Line 393... | ||
362 | 393 | ||
Line 393... | Line 424... | ||
393 | align 4 |
424 | align 4 |
394 | NET_ptr_to_num: |
425 | NET_ptr_to_num: |
395 | push ecx |
426 | push ecx |
Line 396... | Line 427... | ||
396 | 427 | ||
397 | mov ecx, MAX_NET_DEVICES |
428 | mov ecx, MAX_NET_DEVICES |
Line 398... | Line 429... | ||
398 | mov edi, NET_DRV_LIST |
429 | mov edi, NET_DRV_LIST+4 |
399 | 430 | ||
400 | .loop: |
431 | .loop: |
401 | cmp ebx, [edi] |
432 | cmp ebx, [edi] |
Line 559... | Line 590... | ||
559 | shr esi, 6 |
590 | shr esi, 6 |
Line 560... | Line 591... | ||
560 | 591 | ||
561 | cmp dword [esi + NET_DRV_LIST], 0 ; check if driver is running |
592 | cmp dword [esi + NET_DRV_LIST], 0 ; check if driver is running |
Line -... | Line 593... | ||
- | 593 | je .doesnt_exist |
|
- | 594 | ||
562 | je .doesnt_exist |
595 | |
563 | 596 | ||
Line 564... | Line 597... | ||
564 | test bl, bl ; 0 = Get device type (ethernet/token ring/...) |
597 | test bl, bl ; 0 = Get device type (ethernet/token ring/...) |
565 | jnz @f |
598 | jnz @f |
Line 603... | Line 636... | ||
603 | @@: |
636 | @@: |
604 | dec bl ; 4 = Get driver pointer |
637 | dec bl ; 4 = Get driver pointer |
605 | jnz @f |
638 | jnz @f |
Line 606... | Line 639... | ||
606 | 639 | ||
- | 640 | ; ..; |
|
- | 641 | xor eax, eax |
|
- | 642 | jmp .return |
|
- | 643 | ||
- | 644 | ||
- | 645 | @@: |
|
- | 646 | dec bl ; 5 = Get driver name |
|
- | 647 | jnz @f |
|
- | 648 | ||
- | 649 | ; ..; |
|
- | 650 | xor eax, eax |
|
- | 651 | jmp .return |
|
- | 652 | ||
- | 653 | ||
- | 654 | @@: |
|
- | 655 | dec bl ; 6 = Set default device |
|
- | 656 | jnz @f |
|
- | 657 | ||
- | 658 | mov eax, esi |
|
- | 659 | call NET_set_default |
|
Line 607... | Line 660... | ||
607 | ; ..; |
660 | jmp .return |
608 | - | ||
Line 609... | Line 661... | ||
609 | 661 | ||
610 | @@: |
662 | |
611 | ; ... ; 5 Get driver name |
663 | @@: |