openbsd-ports/emulators/qemu/patches/patch-vl_c

125 lines
3.2 KiB
Plaintext
Raw Normal View History

$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>
#ifdef _BSD
#include <sys/stat.h>
-#ifndef __APPLE__
+#if !defined(__APPLE__) && !defined(__OpenBSD__)
#include <libutil.h>
#endif
#else
@@ -126,6 +126,7 @@ QEMUTimer *gui_timer;
int vm_running;
int rtc_utc = 1;
int cirrus_vga_enabled = 1;
+int nic_pcnet = 0;
#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
char *dev;
struct stat s;
+#ifdef __OpenBSD__
+ int i = 0, enoentcount = 0, err = 0;
+ char dname[100];
+
+ for (; i < 10; i++) {
+ snprintf(dname, sizeof dname, "/dev/tun%d", i);
+ fd = open(dname, O_RDWR);
+ if (fd >= 0)
+ break;
+ else if (errno != ENOENT || ++enoentcount > 3) {
+ if (errno != EBUSY) {
+ err = errno;
+ break;
+ }
+ } else
+ err = errno;
+ }
+ if (fd < 0) {
+ fprintf(stderr, "warning: could not open %s (%s): no virtual "
+ "network emulation\n", dname, strerror(err));
+ return -1;
+ }
+#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);
@@ -3986,6 +4027,7 @@ void help(void)
#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"
"-net nic[,vlan=n][,macaddr=addr]\n"
@@ -4093,6 +4135,7 @@ enum {
QEMU_OPTION_audio_help,
QEMU_OPTION_soundhw,
#endif
+ QEMU_OPTION_nic_pcnet,
QEMU_OPTION_net,
QEMU_OPTION_tftp,
@@ -4195,6 +4238,7 @@ const QEMUOption qemu_options[] = {
/* temporary options */
{ "usb", 0, QEMU_OPTION_usb },
+ { "nic-pcnet", 0, QEMU_OPTION_nic_pcnet },
{ "cirrusvga", 0, QEMU_OPTION_cirrusvga },
{ NULL },
};
@@ -4441,7 +4485,7 @@ int main(int argc, char **argv)
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;
@@ -4601,6 +4645,9 @@ int main(int argc, char **argv)
optarg);
nb_net_clients++;
break;
+ case QEMU_OPTION_nic_pcnet:
+ nic_pcnet = 1;
+ break;
#ifdef CONFIG_SLIRP
case QEMU_OPTION_tftp:
tftp_prefix = optarg;