1111init_net:
1212 ; Check Bus Table for a Ethernet device
1313 mov rsi , bus_table ; Load Bus Table address to RSI
14- sub rsi , 16
15- add rsi , 8 ; Add offset to Class Code
14+ sub rsi , 8 ; Subtract offset for Class Code
1615init_net_check_bus:
1716 add rsi , 16 ; Increment to next record in memory
1817 mov ax , [ rsi ] ; Load Class Code / Subclass Code
@@ -29,6 +28,8 @@ init_net_probe_find_driver:
2928 mov edx , [ rsi ] ; Load value for os_bus_read/write
3029 mov r8d , [ rsi + 4 ] ; Save the Device ID / Vendor ID in R8D
3130 rol r8d , 16 ; Swap the Device ID / Vendor ID
31+ add rsi , 8 ; Move RSI back to Class Code
32+ push rsi
3233 mov rsi , NIC_DeviceVendor_ID
3334init_net_probe_find_next_driver:
3435 lodsw ; Load a driver ID
@@ -44,8 +45,8 @@ init_net_probe_find_next_device:
4445 cmp eax , r8d
4546 je init_net_probe_found ; If Carry is clear then we found a supported NIC
4647 jmp init_net_probe_find_next_device ; Check the next device
47-
4848init_net_probe_found:
49+ pop rsi
4950 cmp bx , 0x1AF4
5051 je init_net_probe_found_virtio
5152 cmp bx , 0x8254
@@ -79,12 +80,17 @@ init_net_probe_found_r8169:
7980 jmp init_net_probe_found_finish
8081
8182init_net_probe_found_finish:
82- add byte [ os_net_icount ], 1
8383 mov byte [ os_NetEnabled ], 1 ; A supported NIC was found. Signal to the OS that networking is enabled
8484 add r9 , 15 ; Add offset to driver enabled byte
8585 mov byte [ r9 ], 1 ; Mark device as having a driver
86+ add byte [ os_net_icount ], 1
87+ cmp byte [ os_net_icount ], 2 ; Have 2 NIC's been activated?
88+ je init_net_end ; If so, bail out as 2 is the max at the moment
89+ jmp init_net_check_bus ; Check for another network device
8690
8791init_net_probe_not_found:
92+
93+ init_net_end:
8894 ; Output block to screen (4/4)
8995 mov ebx , 6
9096 call os_debug_block
0 commit comments