Commit c5e97233e8c8e53aab1b80b5e9891a71c4edea3e

Authored by blueswir1
1 parent 9399f095

Support for DragonFly BSD (Hasso Tepper)

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6746 c046a42c-6fe2-441c-8c8c-71466251a162
audio/sdlaudio.c
... ... @@ -29,7 +29,7 @@
29 29 #ifndef _WIN32
30 30 #ifdef __sun__
31 31 #define _POSIX_PTHREAD_SEMANTICS 1
32   -#elif defined(__OpenBSD__) || defined(__FreeBSD__)
  32 +#elif defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
33 33 #include <pthread.h>
34 34 #endif
35 35 #include <signal.h>
... ...
block-raw-posix.c
... ... @@ -63,6 +63,11 @@
63 63 #include <sys/dkio.h>
64 64 #endif
65 65  
  66 +#ifdef __DragonFly__
  67 +#include <sys/ioctl.h>
  68 +#include <sys/diskslice.h>
  69 +#endif
  70 +
66 71 //#define DEBUG_FLOPPY
67 72  
68 73 //#define DEBUG_BLOCK
... ... @@ -762,6 +767,15 @@ static int64_t raw_getlength(BlockDriverState *bs)
762 767 if (!fstat(fd, &sb) && (S_IFCHR & sb.st_mode)) {
763 768 #ifdef DIOCGMEDIASIZE
764 769 if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size))
  770 +#elif defined(DIOCGPART)
  771 + {
  772 + struct partinfo pi;
  773 + if (ioctl(fd, DIOCGPART, &pi) == 0)
  774 + size = pi.media_size;
  775 + else
  776 + size = 0;
  777 + }
  778 + if (size == 0)
765 779 #endif
766 780 #ifdef CONFIG_COCOA
767 781 size = LONG_LONG_MAX;
... ...
... ... @@ -35,8 +35,10 @@
35 35 #include <sys/types.h>
36 36 #include <sys/stat.h>
37 37 #include <sys/ioctl.h>
  38 +#ifndef __DragonFly__
38 39 #include <sys/disk.h>
39 40 #endif
  41 +#endif
40 42  
41 43 #define SECTOR_BITS 9
42 44 #define SECTOR_SIZE (1 << SECTOR_BITS)
... ...
configure
... ... @@ -229,6 +229,15 @@ if [ &quot;$cpu&quot; = &quot;i386&quot; -o &quot;$cpu&quot; = &quot;x86_64&quot; ] ; then
229 229 kqemu="yes"
230 230 fi
231 231 ;;
  232 +DragonFly)
  233 +bsd="yes"
  234 +audio_drv_list="oss"
  235 +audio_possible_drivers="oss sdl esd pa"
  236 +if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
  237 + kqemu="yes"
  238 +fi
  239 +aio="no"
  240 +;;
232 241 NetBSD)
233 242 bsd="yes"
234 243 audio_drv_list="oss"
... ...
... ... @@ -454,7 +454,7 @@ static void code_gen_alloc(unsigned long tb_size)
454 454 exit(1);
455 455 }
456 456 }
457   -#elif defined(__FreeBSD__)
  457 +#elif defined(__FreeBSD__) || defined(__DragonFly__)
458 458 {
459 459 int flags;
460 460 void *addr = NULL;
... ...
... ... @@ -54,7 +54,7 @@
54 54 #include <sys/select.h>
55 55 #ifdef _BSD
56 56 #include <sys/stat.h>
57   -#ifdef __FreeBSD__
  57 +#if defined(__FreeBSD__) || defined(__DragonFly__)
58 58 #include <libutil.h>
59 59 #else
60 60 #include <util.h>
... ...
... ... @@ -92,7 +92,7 @@ static void *kqemu_vmalloc(size_t size)
92 92 void *ptr;
93 93  
94 94 /* no need (?) for a dummy file on OpenBSD/FreeBSD */
95   -#if defined(__OpenBSD__) || defined(__FreeBSD__)
  95 +#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
96 96 int map_anon = MAP_ANON;
97 97 #else
98 98 int map_anon = 0;
... ... @@ -159,7 +159,7 @@ static void *kqemu_vmalloc(size_t size)
159 159 }
160 160 size = (size + 4095) & ~4095;
161 161 ftruncate(phys_ram_fd, phys_ram_size + size);
162   -#endif /* !(__OpenBSD__ || __FreeBSD__) */
  162 +#endif /* !(__OpenBSD__ || __FreeBSD__ || __DragonFly__) */
163 163 ptr = mmap(NULL,
164 164 size,
165 165 PROT_WRITE | PROT_READ, map_anon | MAP_SHARED,
... ...
qemu-char.c
... ... @@ -67,6 +67,10 @@
67 67 #include <libutil.h>
68 68 #include <dev/ppbus/ppi.h>
69 69 #include <dev/ppbus/ppbconf.h>
  70 +#elif defined(__DragonFly__)
  71 +#include <libutil.h>
  72 +#include <dev/misc/ppi/ppi.h>
  73 +#include <bus/ppbus/ppbconf.h>
70 74 #else
71 75 #include <util.h>
72 76 #endif
... ... @@ -806,7 +810,7 @@ void cfmakeraw (struct termios *termios_p)
806 810 #endif
807 811  
808 812 #if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \
809   - || defined(__NetBSD__) || defined(__OpenBSD__)
  813 + || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
810 814  
811 815 typedef struct {
812 816 int fd;
... ... @@ -934,7 +938,7 @@ static CharDriverState *qemu_chr_open_pty(void)
934 938 PtyCharDriver *s;
935 939 struct termios tty;
936 940 int slave_fd, len;
937   -#if defined(__OpenBSD__)
  941 +#if defined(__OpenBSD__) || defined(__DragonFly__)
938 942 char pty_name[PATH_MAX];
939 943 #define q_ptsname(x) pty_name
940 944 #else
... ... @@ -1280,7 +1284,7 @@ static CharDriverState *qemu_chr_open_pp(const char *filename)
1280 1284 }
1281 1285 #endif /* __linux__ */
1282 1286  
1283   -#if defined(__FreeBSD__)
  1287 +#if defined(__FreeBSD__) || defined(__DragonFly__)
1284 1288 static int pp_ioctl(CharDriverState *chr, int cmd, void *arg)
1285 1289 {
1286 1290 int fd = (int)chr->opaque;
... ... @@ -2153,13 +2157,13 @@ CharDriverState *qemu_chr_open(const char *label, const char *filename, void (*i
2153 2157 if (strstart(filename, "/dev/parport", NULL)) {
2154 2158 chr = qemu_chr_open_pp(filename);
2155 2159 } else
2156   -#elif defined(__FreeBSD__)
  2160 +#elif defined(__FreeBSD__) || defined(__DragonFly__)
2157 2161 if (strstart(filename, "/dev/ppi", NULL)) {
2158 2162 chr = qemu_chr_open_pp(filename);
2159 2163 } else
2160 2164 #endif
2161 2165 #if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \
2162   - || defined(__NetBSD__) || defined(__OpenBSD__)
  2166 + || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
2163 2167 if (strstart(filename, "/dev/", NULL)) {
2164 2168 chr = qemu_chr_open_tty(filename);
2165 2169 } else
... ...
savevm.c
... ... @@ -54,7 +54,7 @@
54 54 #include <sys/select.h>
55 55 #ifdef _BSD
56 56 #include <sys/stat.h>
57   -#ifdef __FreeBSD__
  57 +#if defined(__FreeBSD__) || defined(__DragonFly__)
58 58 #include <libutil.h>
59 59 #else
60 60 #include <util.h>
... ...
usb-bsd.c
... ... @@ -34,7 +34,11 @@
34 34 #undef USB_SPEED_LOW
35 35  
36 36 #include <sys/ioctl.h>
  37 +#ifndef __DragonFly__
37 38 #include <dev/usb/usb.h>
  39 +#else
  40 +#include <bus/usb/usb.h>
  41 +#endif
38 42 #include <signal.h>
39 43  
40 44 /* This value has maximum potential at 16.
... ... @@ -68,7 +72,7 @@ static int ensure_ep_open(USBHostDevice *dev, int ep, int mode)
68 72 ep = UE_GET_ADDR(ep);
69 73  
70 74 if (dev->ep_fd[ep] < 0) {
71   -#ifdef __FreeBSD__
  75 +#if defined(__FreeBSD__) || defined(__DragonFly__)
72 76 snprintf(buf, sizeof(buf) - 1, "%s.%d", dev->devpath, ep);
73 77 #else
74 78 snprintf(buf, sizeof(buf) - 1, "%s.%02d", dev->devpath, ep);
... ... @@ -321,7 +325,7 @@ USBDevice *usb_host_device_open(const char *devname)
321 325 return NULL;
322 326 }
323 327  
324   -#ifdef __FreeBSD__
  328 +#if defined(__FreeBSD__) || defined(__DragonFly__)
325 329 snprintf(ctlpath, PATH_MAX, "/dev/%s", bus_info.udi_devnames[0]);
326 330 #else
327 331 snprintf(ctlpath, PATH_MAX, "/dev/%s.00", bus_info.udi_devnames[0]);
... ... @@ -411,7 +415,7 @@ static int usb_host_scan(void *opaque, USBScanFunc *func)
411 415 if (strncmp(bus_info.udi_devnames[0], "ugen", 4) != 0)
412 416 continue;
413 417  
414   -#ifdef __FreeBSD__
  418 +#if defined(__FreeBSD__) || defined(__DragonFly__)
415 419 snprintf(devbuf, sizeof(devbuf) - 1, "/dev/%s", bus_info.udi_devnames[0]);
416 420 #else
417 421 snprintf(devbuf, sizeof(devbuf) - 1, "/dev/%s.00", bus_info.udi_devnames[0]);
... ...
... ... @@ -55,7 +55,7 @@
55 55 #include <sys/select.h>
56 56 #ifdef _BSD
57 57 #include <sys/stat.h>
58   -#ifdef __FreeBSD__
  58 +#if defined(__FreeBSD__) || defined(__DragonFly__)
59 59 #include <libutil.h>
60 60 #else
61 61 #include <util.h>
... ... @@ -759,7 +759,8 @@ static int use_rt_clock;
759 759 static void init_get_clock(void)
760 760 {
761 761 use_rt_clock = 0;
762   -#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000)
  762 +#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \
  763 + || defined(__DragonFly__)
763 764 {
764 765 struct timespec ts;
765 766 if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
... ... @@ -771,7 +772,8 @@ static void init_get_clock(void)
771 772  
772 773 static int64_t get_clock(void)
773 774 {
774   -#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000)
  775 +#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \
  776 + || defined(__DragonFly__)
775 777 if (use_rt_clock) {
776 778 struct timespec ts;
777 779 clock_gettime(CLOCK_MONOTONIC, &ts);
... ...