2005-12-27 02:56:14 -05:00
|
|
|
$OpenBSD: patch-vl_c,v 1.5 2005/12/27 07:56:15 todd Exp $
|
|
|
|
--- vl.c.orig Mon Dec 19 16:51:53 2005
|
|
|
|
+++ vl.c Tue Dec 20 10:53:26 2005
|
|
|
|
@@ -43,7 +43,7 @@
|
|
|
|
#include <netdb.h>
|
2005-03-07 11:41:28 -05:00
|
|
|
#ifdef _BSD
|
|
|
|
#include <sys/stat.h>
|
|
|
|
-#ifndef __APPLE__
|
|
|
|
+#if !defined(__APPLE__) && !defined(__OpenBSD__)
|
|
|
|
#include <libutil.h>
|
|
|
|
#endif
|
|
|
|
#else
|
2005-12-27 02:56:14 -05:00
|
|
|
@@ -126,6 +126,7 @@ QEMUTimer *gui_timer;
|
2005-08-10 21:15:17 -04:00
|
|
|
int vm_running;
|
2005-12-27 02:56:14 -05:00
|
|
|
int rtc_utc = 1;
|
|
|
|
int cirrus_vga_enabled = 1;
|
2005-08-10 21:15:17 -04:00
|
|
|
+int nic_pcnet = 0;
|
2005-12-27 02:56:14 -05:00
|
|
|
#ifdef TARGET_SPARC
|
|
|
|
int graphic_width = 1024;
|
|
|
|
int graphic_height = 768;
|
|
|
|
@@ -549,7 +550,23 @@ int64_t cpu_get_real_ticks(void)
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
-#error unsupported CPU
|
|
|
|
+# warning non-optimized CPU
|
|
|
|
+#include <sys/time.h>
|
|
|
|
+#include <time.h>
|
|
|
|
+
|
|
|
|
+int64_t cpu_get_real_ticks(void)
|
|
|
|
+{
|
|
|
|
+ struct timeval tv;
|
|
|
|
+ static int64_t i = 0;
|
|
|
|
+ int64_t j;
|
|
|
|
+
|
|
|
|
+ gettimeofday(&tv, NULL);
|
|
|
|
+ do {
|
|
|
|
+ j = (tv.tv_sec * (uint64_t) 1000000) + tv.tv_usec;
|
|
|
|
+ } while (i == j);
|
|
|
|
+ i = j;
|
|
|
|
+ return j;
|
|
|
|
+}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static int64_t cpu_ticks_offset;
|
|
|
|
@@ -2037,11 +2054,35 @@ static int tap_open(char *ifname, int if
|
2005-03-07 11:41:28 -05:00
|
|
|
char *dev;
|
|
|
|
struct stat s;
|
|
|
|
|
|
|
|
+#ifdef __OpenBSD__
|
|
|
|
+ int i = 0, enoentcount = 0, err = 0;
|
|
|
|
+ char dname[100];
|
|
|
|
+
|
|
|
|
+ for (; i < 10; i++) {
|
2005-08-10 21:15:17 -04:00
|
|
|
+ snprintf(dname, sizeof dname, "/dev/tun%d", i);
|
2005-03-07 11:41:28 -05:00
|
|
|
+ fd = open(dname, O_RDWR);
|
|
|
|
+ if (fd >= 0)
|
|
|
|
+ break;
|
|
|
|
+ else if (errno != ENOENT || ++enoentcount > 3) {
|
|
|
|
+ if (errno != EBUSY) {
|
2005-08-10 21:15:17 -04:00
|
|
|
+ err = errno;
|
|
|
|
+ break;
|
2005-03-07 11:41:28 -05:00
|
|
|
+ }
|
|
|
|
+ } else
|
|
|
|
+ err = errno;
|
|
|
|
+ }
|
|
|
|
+ if (fd < 0) {
|
2005-08-10 21:15:17 -04:00
|
|
|
+ fprintf(stderr, "warning: could not open %s (%s): no virtual "
|
|
|
|
+ "network emulation\n", dname, strerror(err));
|
|
|
|
+ return -1;
|
2005-03-07 11:41:28 -05:00
|
|
|
+ }
|
|
|
|
+#else
|
|
|
|
fd = open("/dev/tap", O_RDWR);
|
|
|
|
if (fd < 0) {
|
|
|
|
fprintf(stderr, "warning: could not open /dev/tap: no virtual network emulation\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
fstat(fd, &s);
|
|
|
|
dev = devname(s.st_rdev, S_IFCHR);
|
2005-12-27 02:56:14 -05:00
|
|
|
@@ -3986,6 +4027,7 @@ void help(void)
|
2005-08-10 21:15:17 -04:00
|
|
|
#if defined(TARGET_PPC) || defined(TARGET_SPARC)
|
|
|
|
"-g WxH[xDEPTH] Set the initial graphical resolution and depth\n"
|
|
|
|
#endif
|
|
|
|
+ "-nic-pcnet simulate an AMD PC-Net PCI ethernet adaptor\n"
|
|
|
|
"\n"
|
|
|
|
"Network options:\n"
|
2005-12-27 02:56:14 -05:00
|
|
|
"-net nic[,vlan=n][,macaddr=addr]\n"
|
|
|
|
@@ -4093,6 +4135,7 @@ enum {
|
|
|
|
QEMU_OPTION_audio_help,
|
|
|
|
QEMU_OPTION_soundhw,
|
|
|
|
#endif
|
2005-08-10 21:15:17 -04:00
|
|
|
+ QEMU_OPTION_nic_pcnet,
|
2005-12-27 02:56:14 -05:00
|
|
|
|
|
|
|
QEMU_OPTION_net,
|
|
|
|
QEMU_OPTION_tftp,
|
|
|
|
@@ -4195,6 +4238,7 @@ const QEMUOption qemu_options[] = {
|
2005-08-10 21:15:17 -04:00
|
|
|
|
|
|
|
/* temporary options */
|
2005-12-27 02:56:14 -05:00
|
|
|
{ "usb", 0, QEMU_OPTION_usb },
|
2005-08-10 21:15:17 -04:00
|
|
|
+ { "nic-pcnet", 0, QEMU_OPTION_nic_pcnet },
|
|
|
|
{ "cirrusvga", 0, QEMU_OPTION_cirrusvga },
|
|
|
|
{ NULL },
|
|
|
|
};
|
2005-12-27 02:56:14 -05:00
|
|
|
@@ -4441,7 +4485,7 @@ int main(int argc, char **argv)
|
2005-11-05 07:11:05 -05:00
|
|
|
serial_devices[i][0] = '\0';
|
|
|
|
serial_device_index = 0;
|
|
|
|
|
|
|
|
- pstrcpy(parallel_devices[0], sizeof(parallel_devices[0]), "vc");
|
|
|
|
+ pstrcpy(parallel_devices[0], sizeof(parallel_devices[0]), "null");
|
|
|
|
for(i = 1; i < MAX_PARALLEL_PORTS; i++)
|
|
|
|
parallel_devices[i][0] = '\0';
|
|
|
|
parallel_device_index = 0;
|
2005-12-27 02:56:14 -05:00
|
|
|
@@ -4601,6 +4645,9 @@ int main(int argc, char **argv)
|
|
|
|
optarg);
|
|
|
|
nb_net_clients++;
|
2005-08-10 21:15:17 -04:00
|
|
|
break;
|
|
|
|
+ case QEMU_OPTION_nic_pcnet:
|
2005-12-27 02:56:14 -05:00
|
|
|
+ nic_pcnet = 1;
|
|
|
|
+ break;
|
|
|
|
#ifdef CONFIG_SLIRP
|
|
|
|
case QEMU_OPTION_tftp:
|
|
|
|
tftp_prefix = optarg;
|