1 ; =============================================================================
2 ; BareMetal -- a 64-bit OS written in Assembly for x86-64 systems
3 ; Copyright (C) 2008-2011 Return Infinity -- see LICENSE.TXT
6 ; =============================================================================
14 ; Search for a supported NIC
15 mov rsi
, NIC_DeviceVendor_ID
18 lodsd ; Load a device and vendor ID from our list of supported NICs
19 cmp eax, 0x00000000 ; 0x00000000 means we have reached the end of the list
20 je init_net_probe_not_found
; No suported NIC found
21 call os_pci_find_device
; Returns BL = Bus number (8-bit value) and CL = Device/Slot number (5-bit value) if NIC was found
22 jnc init_net_probe_found
; If Carry is clear then we found a supported NIC
23 add rsi
, 4 ; Skip the device type
24 jmp init_net_probe_next
27 lodsd ; Load the device type
29 je init_net_probe_found_rtl8169
31 je init_net_probe_found_i8254x
32 jmp init_net_probe_not_found
34 init_net_probe_found_rtl8169:
35 call os_net_rtl8169_init
36 mov rdi
, os_net_transmit
37 mov rax
, os_net_rtl8169_transmit
39 mov rax
, os_net_rtl8169_poll
41 mov rax
, os_net_rtl8169_ack_int
43 jmp init_net_probe_found_finish
45 init_net_probe_found_i8254x:
46 call os_net_i8254x_init
47 mov rdi
, os_net_transmit
48 mov rax
, os_net_i8254x_transmit
50 mov rax
, os_net_i8254x_poll
52 mov rax
, os_net_i8254x_ack_int
54 jmp init_net_probe_found_finish
56 init_net_probe_found_finish:
63 mov byte [os_NetEnabled
], 1 ; A supported NIC was found. Signal to the OS that networking is enabled
65 init_net_probe_not_found:
70 ; =============================================================================