Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 2220 → Rev 2219

/kernel/branches/net/drivers/i8255x.asm
File deleted
/kernel/branches/net/drivers/sis900.asm
436,7 → 436,7
 
; Get Card Revision
stdcall PciRead8, dword [device.pci_bus], dword [device.pci_dev], 0x08
mov [device.pci_revision], al ; save the revision for later use
mov [pci_revision], al ; save the revision for later use
 
; Look up through the specific_table
mov esi, specific_table
1255,8 → 1255,7
jl transmit_finish
 
movzx ecx, [device.cur_tx]
shl ecx, 4
mov ecx, [device.txd+ecx]
mov ecx, [device.txd+ecx*16]
 
;; TODO: check if desc is empty (for example: check for eax, 0x6200000 at [ecx+4]
;;; or: count number of available descriptors
/kernel/branches/net/network/stack.inc
176,7 → 176,7
uglobal
 
NET_RUNNING dd ?
NET_DRV_LIST rd (MAX_NET_DEVICES + 1) ; device 0 is a link to the default device
NET_DRV_LIST rd MAX_NET_DEVICES
 
endg
 
197,9 → 197,10
; Init the network drivers list
xor eax, eax
mov edi, NET_RUNNING
mov ecx, (MAX_NET_DEVICES + 2)
mov ecx, MAX_NET_DEVICES + 1
rep stosd
 
ETH_init
; SLIP_init
; PPPOE_init
 
258,7 → 259,7
 
;-----------------------------------------------------------------
;
; NET_add_device:
; NET_add_Device:
;
; This function is called by the network drivers,
; to register each running NIC to the kernel
270,7 → 271,7
align 4
NET_add_device:
 
DEBUGF 1,"NET_Add_Device: %x\n", ebx ;;; TODO: use mutex to lock net device list
DEBUGF 1,"NET_Add_Device: %x\n", ebx
 
mov eax, [NET_RUNNING]
cmp eax, MAX_NET_DEVICES
280,7 → 281,7
; Check if device is already listed
mov eax, ebx
mov ecx, MAX_NET_DEVICES ; We need to check whole list because a device may be removed without re-organizing list
mov edi, NET_DRV_LIST+4
mov edi, NET_DRV_LIST
 
repne scasd ; See if device is already in the list
jz .error
289,7 → 290,7
; Find empty slot in the list
xor eax, eax
mov ecx, MAX_NET_DEVICES
mov edi, NET_DRV_LIST+4
mov edi, NET_DRV_LIST
 
repne scasd
jnz .error
296,23 → 297,39
 
sub edi, 4
 
cmp [ebx + NET_DEVICE.type], NET_TYPE_ETH
je .ethernet
 
cmp [ebx + NET_DEVICE.type], NET_TYPE_SLIP
je .slip
 
DEBUGF 1,"Unknown network device type: %u\n", [ebx + NET_DEVICE.type]
jmp .error
 
.ethernet:
DEBUGF 1,"Trying to add an ethernet device\n"
 
inc [ETH_RUNNING] ; Indicate that one more ethernet device is up and running
jmp .add_it
 
.slip:
DEBUGF 1,"Trying to add a slip device\n"
;;;;
jmp .error
 
 
.add_it:
 
;-----------------------------
; Add device to the found slot
mov [edi], ebx ; add device to list
 
mov eax, edi ; Calculate device number in eax
sub eax, NET_DRV_LIST
sub edi, NET_DRV_LIST ; Calculate device number in eax
mov eax, edi ;
shr eax, 2
 
inc [NET_RUNNING] ; Indicate that one more network device is up and running
 
cmp eax, 1 ; If it's the first network device, try to set it as default
jne @f
push eax
call NET_set_default
pop eax
@@:
 
DEBUGF 1,"Device number: %u\n", eax
ret
 
325,44 → 342,11
 
;-----------------------------------------------------------------
;
; NET_set_default
;
; API to set the default interface
;
; IN: Device num in eax
; OUT: Device num in eax, -1 on error
;
;-----------------------------------------------------------------
align 4
NET_set_default:
 
DEBUGF 1,"NET_set_default %x\n", eax
 
cmp eax, MAX_NET_DEVICES
jge .error
 
cmp [NET_DRV_LIST+eax*4], 0
je .error
 
push [NET_DRV_LIST+eax*4]
pop [NET_DRV_LIST]
 
DEBUGF 1,"Device number %u is now default!\n", eax
ret
 
.error:
or eax, -1
DEBUGF 2,"Setting default network device failed\n"
ret
 
 
;-----------------------------------------------------------------
;
; NET_Remove_Device:
;
; This function is called by etwork drivers,
; to unregister network devices from the kernel
; d
;
; IN: Pointer to device structure in ebx
; OUT: eax: -1 on error
;
373,27 → 357,12
cmp [NET_RUNNING], 0
je .error
 
cmp [NET_DRV_LIST], ebx
jne @f
mov [NET_DRV_LIST], 0
cmp [NET_RUNNING], 1
je @f
; there are still active devices, find one and make it default
xor eax, eax
mov ecx, MAX_NET_DEVICES
mov edi, NET_DRV_LIST+4
repe scasd
jz @f
push dword [edi-4]
pop [NET_DRV_LIST]
@@:
 
;----------------------------
; Find the driver in the list
 
mov eax, ebx
mov ecx, MAX_NET_DEVICES
mov edi, NET_DRV_LIST+4
mov edi, NET_DRV_LIST
 
repne scasd
jnz .error
426,7 → 395,7
push ecx
 
mov ecx, MAX_NET_DEVICES
mov edi, NET_DRV_LIST+4
mov edi, NET_DRV_LIST
 
.loop:
cmp ebx, [edi]
592,8 → 561,6
cmp dword [esi + NET_DRV_LIST], 0 ; check if driver is running
je .doesnt_exist
 
 
 
test bl, bl ; 0 = Get device type (ethernet/token ring/...)
jnz @f
 
638,30 → 605,11
jnz @f
 
; ..;
xor eax, eax
jmp .return
 
 
@@:
dec bl ; 5 = Get driver name
jnz @f
; ... ; 5 Get driver name
 
; ..;
xor eax, eax
jmp .return
 
 
@@:
dec bl ; 6 = Set default device
jnz @f
 
mov eax, esi
call NET_set_default
jmp .return
 
 
@@:
 
.doesnt_exist:
DEBUGF 1,"sys_network: invalid device/function specified!\n"
mov eax, -1
/kernel/branches/net/network/ethernet.inc
44,8 → 44,28
ETH_BROADCAST dp 0xffffffffffff
endg
 
align 4
uglobal
ETH_RUNNING dd ?
endg
 
 
;-----------------------------------------------------------------
;
; ETH_init
;
; This function resets all ethernet variables
;
;-----------------------------------------------------------------
macro ETH_init {
 
mov [ETH_RUNNING], 0
 
}
 
 
;-----------------------------------------------------------------
;
; ETH_input
;
; This function is called by ethernet drivers,