Skip to content

Commit

Permalink
Merge pull request #34 from jimmylu890303/Implement-virtio-net
Browse files Browse the repository at this point in the history
Implement virtio-net device
  • Loading branch information
jserv authored Jul 21, 2024
2 parents 1922ccc + f727c6e commit e2e954c
Show file tree
Hide file tree
Showing 11 changed files with 388 additions and 45 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ OBJS := \
virtio-pci.o \
virtq.o \
virtio-blk.o \
virtio-net.o \
diskimg.o \
main.o

Expand Down
87 changes: 44 additions & 43 deletions configs/busybox.config
Original file line number Diff line number Diff line change
Expand Up @@ -849,14 +849,14 @@ CONFIG_TREE=y
#
# CONFIG_FEATURE_IPV6 is not set
# CONFIG_FEATURE_UNIX_LOCAL is not set
# CONFIG_FEATURE_PREFER_IPV4_ADDRESS is not set
CONFIG_FEATURE_PREFER_IPV4_ADDRESS=y
# CONFIG_VERBOSE_RESOLUTION_ERRORS is not set
# CONFIG_FEATURE_ETC_NETWORKS is not set
# CONFIG_FEATURE_ETC_SERVICES is not set
# CONFIG_FEATURE_HWIB is not set
# CONFIG_FEATURE_TLS_SHA1 is not set
# CONFIG_ARP is not set
# CONFIG_ARPING is not set
CONFIG_ARP=y
CONFIG_ARPING=y
# CONFIG_BRCTL is not set
# CONFIG_FEATURE_BRCTL_FANCY is not set
# CONFIG_FEATURE_BRCTL_SHOW is not set
Expand All @@ -869,7 +869,7 @@ CONFIG_TREE=y
# CONFIG_FTPGET is not set
# CONFIG_FTPPUT is not set
# CONFIG_FEATURE_FTPGETPUT_LONG_OPTIONS is not set
# CONFIG_HOSTNAME is not set
CONFIG_HOSTNAME=y
# CONFIG_DNSDOMAINNAME is not set
# CONFIG_HTTPD is not set
CONFIG_FEATURE_HTTPD_PORT_DEFAULT=0
Expand All @@ -888,21 +888,21 @@ CONFIG_FEATURE_HTTPD_PORT_DEFAULT=0
# CONFIG_FEATURE_HTTPD_LAST_MODIFIED is not set
# CONFIG_FEATURE_HTTPD_DATE is not set
# CONFIG_FEATURE_HTTPD_ACL_IP is not set
# CONFIG_IFCONFIG is not set
# CONFIG_FEATURE_IFCONFIG_STATUS is not set
# CONFIG_FEATURE_IFCONFIG_SLIP is not set
# CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ is not set
# CONFIG_FEATURE_IFCONFIG_HW is not set
CONFIG_IFCONFIG=y
CONFIG_FEATURE_IFCONFIG_STATUS=y
CONFIG_FEATURE_IFCONFIG_SLIP=y
CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ=y
CONFIG_FEATURE_IFCONFIG_HW=y
# CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS is not set
# CONFIG_IFENSLAVE is not set
# CONFIG_IFPLUGD is not set
# CONFIG_IFUP is not set
# CONFIG_IFDOWN is not set
CONFIG_IFUP=y
CONFIG_IFDOWN=y
CONFIG_IFUPDOWN_IFSTATE_PATH=""
# CONFIG_FEATURE_IFUPDOWN_IP is not set
# CONFIG_FEATURE_IFUPDOWN_IPV4 is not set
# CONFIG_FEATURE_IFUPDOWN_IPV6 is not set
# CONFIG_FEATURE_IFUPDOWN_MAPPING is not set
CONFIG_FEATURE_IFUPDOWN_IP=y
CONFIG_FEATURE_IFUPDOWN_IPV4=y
CONFIG_FEATURE_IFUPDOWN_IPV6=y
CONFIG_FEATURE_IFUPDOWN_MAPPING=y
# CONFIG_FEATURE_IFUPDOWN_EXTERNAL_DHCP is not set
# CONFIG_INETD is not set
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO is not set
Expand All @@ -911,20 +911,20 @@ CONFIG_IFUPDOWN_IFSTATE_PATH=""
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME is not set
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN is not set
# CONFIG_FEATURE_INETD_RPC is not set
# CONFIG_IP is not set
# CONFIG_IPADDR is not set
# CONFIG_IPLINK is not set
# CONFIG_IPROUTE is not set
# CONFIG_IPTUNNEL is not set
# CONFIG_IPRULE is not set
# CONFIG_IPNEIGH is not set
# CONFIG_FEATURE_IP_ADDRESS is not set
# CONFIG_FEATURE_IP_LINK is not set
# CONFIG_FEATURE_IP_ROUTE is not set
CONFIG_IP=y
CONFIG_IPADDR=y
CONFIG_IPLINK=y
CONFIG_IPROUTE=y
CONFIG_IPTUNNEL=y
CONFIG_IPRULE=y
CONFIG_IPNEIGH=y
CONFIG_FEATURE_IP_ADDRESS=y
CONFIG_FEATURE_IP_LINK=y
CONFIG_FEATURE_IP_ROUTE=y
CONFIG_FEATURE_IP_ROUTE_DIR=""
# CONFIG_FEATURE_IP_TUNNEL is not set
# CONFIG_FEATURE_IP_RULE is not set
# CONFIG_FEATURE_IP_NEIGH is not set
CONFIG_FEATURE_IP_TUNNEL=y
CONFIG_FEATURE_IP_RULE=y
CONFIG_FEATURE_IP_NEIGH=y
# CONFIG_FEATURE_IP_RARE_PROTOCOLS is not set
# CONFIG_IPCALC is not set
# CONFIG_FEATURE_IPCALC_LONG_OPTIONS is not set
Expand All @@ -938,31 +938,31 @@ CONFIG_FEATURE_IP_ROUTE_DIR=""
# CONFIG_NC_SERVER is not set
# CONFIG_NC_EXTRA is not set
# CONFIG_NC_110_COMPAT is not set
# CONFIG_NETSTAT is not set
CONFIG_NETSTAT=y
# CONFIG_FEATURE_NETSTAT_WIDE is not set
# CONFIG_FEATURE_NETSTAT_PRG is not set
# CONFIG_NSLOOKUP is not set
# CONFIG_FEATURE_NSLOOKUP_BIG is not set
# CONFIG_FEATURE_NSLOOKUP_LONG_OPTIONS is not set
CONFIG_NSLOOKUP=y
CONFIG_FEATURE_NSLOOKUP_BIG=y
CONFIG_FEATURE_NSLOOKUP_LONG_OPTIONS=y
# CONFIG_NTPD is not set
# CONFIG_FEATURE_NTPD_SERVER is not set
# CONFIG_FEATURE_NTPD_CONF is not set
# CONFIG_FEATURE_NTP_AUTH is not set
# CONFIG_PING is not set
CONFIG_PING=y
# CONFIG_PING6 is not set
# CONFIG_FEATURE_FANCY_PING is not set
CONFIG_FEATURE_FANCY_PING=y
# CONFIG_PSCAN is not set
# CONFIG_ROUTE is not set
CONFIG_ROUTE=y
# CONFIG_SLATTACH is not set
# CONFIG_SSL_CLIENT is not set
# CONFIG_TC is not set
# CONFIG_FEATURE_TC_INGRESS is not set
# CONFIG_TCPSVD is not set
# CONFIG_UDPSVD is not set
# CONFIG_TELNET is not set
# CONFIG_FEATURE_TELNET_TTYPE is not set
# CONFIG_FEATURE_TELNET_AUTOLOGIN is not set
# CONFIG_FEATURE_TELNET_WIDTH is not set
CONFIG_TELNET=y
CONFIG_FEATURE_TELNET_TTYPE=y
CONFIG_FEATURE_TELNET_AUTOLOGIN=y
CONFIG_FEATURE_TELNET_WIDTH=y
# CONFIG_TELNETD is not set
# CONFIG_FEATURE_TELNETD_STANDALONE is not set
CONFIG_FEATURE_TELNETD_PORT_DEFAULT=0
Expand All @@ -976,7 +976,7 @@ CONFIG_FEATURE_TELNETD_PORT_DEFAULT=0
# CONFIG_FEATURE_TFTP_BLOCKSIZE is not set
# CONFIG_TFTP_DEBUG is not set
# CONFIG_TLS is not set
# CONFIG_TRACEROUTE is not set
CONFIG_TRACEROUTE=y
# CONFIG_TRACEROUTE6 is not set
# CONFIG_FEATURE_TRACEROUTE_VERBOSE is not set
# CONFIG_FEATURE_TRACEROUTE_USE_ICMP is not set
Expand All @@ -999,16 +999,17 @@ CONFIG_FEATURE_TELNETD_PORT_DEFAULT=0
CONFIG_DHCPD_LEASES_FILE=""
# CONFIG_DUMPLEASES is not set
# CONFIG_DHCPRELAY is not set
# CONFIG_UDHCPC is not set
# CONFIG_FEATURE_UDHCPC_ARPING is not set
# CONFIG_FEATURE_UDHCPC_SANITIZEOPT is not set
CONFIG_UDHCPC=y
CONFIG_FEATURE_UDHCPC_ARPING=y
CONFIG_FEATURE_UDHCPC_SANITIZEOPT=y
CONFIG_UDHCPC_DEFAULT_SCRIPT=""
CONFIG_UDHCPC6_DEFAULT_SCRIPT=""
# CONFIG_UDHCPC6 is not set
# CONFIG_FEATURE_UDHCPC6_RFC3646 is not set
# CONFIG_FEATURE_UDHCPC6_RFC4704 is not set
# CONFIG_FEATURE_UDHCPC6_RFC4833 is not set
# CONFIG_FEATURE_UDHCPC6_RFC5970 is not set

CONFIG_UDHCPC_DEFAULT_INTERFACE=""
# CONFIG_FEATURE_UDHCP_PORT is not set
CONFIG_UDHCP_DEBUG=0
Expand Down
14 changes: 13 additions & 1 deletion configs/linux-x86.config
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ CONFIG_CC_OPTIMIZE_FOR_SIZE=y
# CONFIG_SGETMASK_SYSCALL is not set
# CONFIG_SYSFS_SYSCALL is not set
# CONFIG_FHANDLE is not set
# CONFIG_POSIX_TIMERS is not set
# CONFIG_POSIX_TIMERS=y
# CONFIG_BUG is not set
# CONFIG_PCSPKR_PLATFORM is not set
# CONFIG_BASE_FULL is not set
Expand Down Expand Up @@ -115,3 +115,15 @@ CONFIG_FRAME_WARN=1024
# CONFIG_X86_DEBUG_FPU is not set
CONFIG_UNWINDER_GUESS=y
# CONFIG_RUNTIME_TESTING_MENU is not set
CONFIG_NET=y
CONFIG_INET=y
CONFIG_IP_MULTICAST=y
CONFIG_IP_PNP=y
CONFIG_IP_PNP_DHCP=y
CONFIG_NETDEVICES=y
CONFIG_VIRTIO=y
CONFIG_VIRTIO_NET=y
CONFIG_VIRTIO_RING=y
CONFIG_UNIX=y
CONFIG_UNIX_SCM=y
CONFIG_AF_UNIX_OOB=y
1 change: 1 addition & 0 deletions src/arch/x86/desc.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

#define RAM_BASE 0
#define SERIAL_IRQ 4
#define VIRTIO_NET_IRQ 14
#define VIRTIO_BLK_IRQ 15
#define KERNEL_OPTS "console=ttyS0 pci=conf1"
2 changes: 2 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ int main(int argc, char *argv[])
return throw_err("Failed to load initrd");
if (diskimg_file && vm_load_diskimg(&vm, diskimg_file) < 0)
return throw_err("Failed to load disk image");
if (vm_enable_net(&vm) < 0)
fprintf(stderr, "Failed to enable virtio-net device\n");

if (vm_late_init(&vm) < 0)
return -1;
Expand Down
Loading

0 comments on commit e2e954c

Please sign in to comment.