Support for DragonFly BSD (Hasso Tepper)

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6746 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
blueswir1 2009-03-07 20:06:23 +00:00
parent 9399f095bd
commit c5e97233e8
11 changed files with 52 additions and 17 deletions

View File

@ -29,7 +29,7 @@
#ifndef _WIN32 #ifndef _WIN32
#ifdef __sun__ #ifdef __sun__
#define _POSIX_PTHREAD_SEMANTICS 1 #define _POSIX_PTHREAD_SEMANTICS 1
#elif defined(__OpenBSD__) || defined(__FreeBSD__) #elif defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
#include <pthread.h> #include <pthread.h>
#endif #endif
#include <signal.h> #include <signal.h>

View File

@ -63,6 +63,11 @@
#include <sys/dkio.h> #include <sys/dkio.h>
#endif #endif
#ifdef __DragonFly__
#include <sys/ioctl.h>
#include <sys/diskslice.h>
#endif
//#define DEBUG_FLOPPY //#define DEBUG_FLOPPY
//#define DEBUG_BLOCK //#define DEBUG_BLOCK
@ -762,6 +767,15 @@ static int64_t raw_getlength(BlockDriverState *bs)
if (!fstat(fd, &sb) && (S_IFCHR & sb.st_mode)) { if (!fstat(fd, &sb) && (S_IFCHR & sb.st_mode)) {
#ifdef DIOCGMEDIASIZE #ifdef DIOCGMEDIASIZE
if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size)) if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size))
#elif defined(DIOCGPART)
{
struct partinfo pi;
if (ioctl(fd, DIOCGPART, &pi) == 0)
size = pi.media_size;
else
size = 0;
}
if (size == 0)
#endif #endif
#ifdef CONFIG_COCOA #ifdef CONFIG_COCOA
size = LONG_LONG_MAX; size = LONG_LONG_MAX;

View File

@ -35,8 +35,10 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#ifndef __DragonFly__
#include <sys/disk.h> #include <sys/disk.h>
#endif #endif
#endif
#define SECTOR_BITS 9 #define SECTOR_BITS 9
#define SECTOR_SIZE (1 << SECTOR_BITS) #define SECTOR_SIZE (1 << SECTOR_BITS)

9
configure vendored
View File

@ -229,6 +229,15 @@ if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
kqemu="yes" kqemu="yes"
fi fi
;; ;;
DragonFly)
bsd="yes"
audio_drv_list="oss"
audio_possible_drivers="oss sdl esd pa"
if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
kqemu="yes"
fi
aio="no"
;;
NetBSD) NetBSD)
bsd="yes" bsd="yes"
audio_drv_list="oss" audio_drv_list="oss"

2
exec.c
View File

@ -454,7 +454,7 @@ static void code_gen_alloc(unsigned long tb_size)
exit(1); exit(1);
} }
} }
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__) || defined(__DragonFly__)
{ {
int flags; int flags;
void *addr = NULL; void *addr = NULL;

2
net.c
View File

@ -54,7 +54,7 @@
#include <sys/select.h> #include <sys/select.h>
#ifdef _BSD #ifdef _BSD
#include <sys/stat.h> #include <sys/stat.h>
#ifdef __FreeBSD__ #if defined(__FreeBSD__) || defined(__DragonFly__)
#include <libutil.h> #include <libutil.h>
#else #else
#include <util.h> #include <util.h>

View File

@ -92,7 +92,7 @@ static void *kqemu_vmalloc(size_t size)
void *ptr; void *ptr;
/* no need (?) for a dummy file on OpenBSD/FreeBSD */ /* no need (?) for a dummy file on OpenBSD/FreeBSD */
#if defined(__OpenBSD__) || defined(__FreeBSD__) #if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
int map_anon = MAP_ANON; int map_anon = MAP_ANON;
#else #else
int map_anon = 0; int map_anon = 0;
@ -159,7 +159,7 @@ static void *kqemu_vmalloc(size_t size)
} }
size = (size + 4095) & ~4095; size = (size + 4095) & ~4095;
ftruncate(phys_ram_fd, phys_ram_size + size); ftruncate(phys_ram_fd, phys_ram_size + size);
#endif /* !(__OpenBSD__ || __FreeBSD__) */ #endif /* !(__OpenBSD__ || __FreeBSD__ || __DragonFly__) */
ptr = mmap(NULL, ptr = mmap(NULL,
size, size,
PROT_WRITE | PROT_READ, map_anon | MAP_SHARED, PROT_WRITE | PROT_READ, map_anon | MAP_SHARED,

View File

@ -67,6 +67,10 @@
#include <libutil.h> #include <libutil.h>
#include <dev/ppbus/ppi.h> #include <dev/ppbus/ppi.h>
#include <dev/ppbus/ppbconf.h> #include <dev/ppbus/ppbconf.h>
#elif defined(__DragonFly__)
#include <libutil.h>
#include <dev/misc/ppi/ppi.h>
#include <bus/ppbus/ppbconf.h>
#else #else
#include <util.h> #include <util.h>
#endif #endif
@ -806,7 +810,7 @@ void cfmakeraw (struct termios *termios_p)
#endif #endif
#if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \ #if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \
|| defined(__NetBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
typedef struct { typedef struct {
int fd; int fd;
@ -934,7 +938,7 @@ static CharDriverState *qemu_chr_open_pty(void)
PtyCharDriver *s; PtyCharDriver *s;
struct termios tty; struct termios tty;
int slave_fd, len; int slave_fd, len;
#if defined(__OpenBSD__) #if defined(__OpenBSD__) || defined(__DragonFly__)
char pty_name[PATH_MAX]; char pty_name[PATH_MAX];
#define q_ptsname(x) pty_name #define q_ptsname(x) pty_name
#else #else
@ -1280,7 +1284,7 @@ static CharDriverState *qemu_chr_open_pp(const char *filename)
} }
#endif /* __linux__ */ #endif /* __linux__ */
#if defined(__FreeBSD__) #if defined(__FreeBSD__) || defined(__DragonFly__)
static int pp_ioctl(CharDriverState *chr, int cmd, void *arg) static int pp_ioctl(CharDriverState *chr, int cmd, void *arg)
{ {
int fd = (int)chr->opaque; int fd = (int)chr->opaque;
@ -2153,13 +2157,13 @@ CharDriverState *qemu_chr_open(const char *label, const char *filename, void (*i
if (strstart(filename, "/dev/parport", NULL)) { if (strstart(filename, "/dev/parport", NULL)) {
chr = qemu_chr_open_pp(filename); chr = qemu_chr_open_pp(filename);
} else } else
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__) || defined(__DragonFly__)
if (strstart(filename, "/dev/ppi", NULL)) { if (strstart(filename, "/dev/ppi", NULL)) {
chr = qemu_chr_open_pp(filename); chr = qemu_chr_open_pp(filename);
} else } else
#endif #endif
#if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \ #if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \
|| defined(__NetBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
if (strstart(filename, "/dev/", NULL)) { if (strstart(filename, "/dev/", NULL)) {
chr = qemu_chr_open_tty(filename); chr = qemu_chr_open_tty(filename);
} else } else

View File

@ -54,7 +54,7 @@
#include <sys/select.h> #include <sys/select.h>
#ifdef _BSD #ifdef _BSD
#include <sys/stat.h> #include <sys/stat.h>
#ifdef __FreeBSD__ #if defined(__FreeBSD__) || defined(__DragonFly__)
#include <libutil.h> #include <libutil.h>
#else #else
#include <util.h> #include <util.h>

View File

@ -34,7 +34,11 @@
#undef USB_SPEED_LOW #undef USB_SPEED_LOW
#include <sys/ioctl.h> #include <sys/ioctl.h>
#ifndef __DragonFly__
#include <dev/usb/usb.h> #include <dev/usb/usb.h>
#else
#include <bus/usb/usb.h>
#endif
#include <signal.h> #include <signal.h>
/* This value has maximum potential at 16. /* This value has maximum potential at 16.
@ -68,7 +72,7 @@ static int ensure_ep_open(USBHostDevice *dev, int ep, int mode)
ep = UE_GET_ADDR(ep); ep = UE_GET_ADDR(ep);
if (dev->ep_fd[ep] < 0) { if (dev->ep_fd[ep] < 0) {
#ifdef __FreeBSD__ #if defined(__FreeBSD__) || defined(__DragonFly__)
snprintf(buf, sizeof(buf) - 1, "%s.%d", dev->devpath, ep); snprintf(buf, sizeof(buf) - 1, "%s.%d", dev->devpath, ep);
#else #else
snprintf(buf, sizeof(buf) - 1, "%s.%02d", dev->devpath, ep); snprintf(buf, sizeof(buf) - 1, "%s.%02d", dev->devpath, ep);
@ -321,7 +325,7 @@ USBDevice *usb_host_device_open(const char *devname)
return NULL; return NULL;
} }
#ifdef __FreeBSD__ #if defined(__FreeBSD__) || defined(__DragonFly__)
snprintf(ctlpath, PATH_MAX, "/dev/%s", bus_info.udi_devnames[0]); snprintf(ctlpath, PATH_MAX, "/dev/%s", bus_info.udi_devnames[0]);
#else #else
snprintf(ctlpath, PATH_MAX, "/dev/%s.00", bus_info.udi_devnames[0]); 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)
if (strncmp(bus_info.udi_devnames[0], "ugen", 4) != 0) if (strncmp(bus_info.udi_devnames[0], "ugen", 4) != 0)
continue; continue;
#ifdef __FreeBSD__ #if defined(__FreeBSD__) || defined(__DragonFly__)
snprintf(devbuf, sizeof(devbuf) - 1, "/dev/%s", bus_info.udi_devnames[0]); snprintf(devbuf, sizeof(devbuf) - 1, "/dev/%s", bus_info.udi_devnames[0]);
#else #else
snprintf(devbuf, sizeof(devbuf) - 1, "/dev/%s.00", bus_info.udi_devnames[0]); snprintf(devbuf, sizeof(devbuf) - 1, "/dev/%s.00", bus_info.udi_devnames[0]);

8
vl.c
View File

@ -55,7 +55,7 @@
#include <sys/select.h> #include <sys/select.h>
#ifdef _BSD #ifdef _BSD
#include <sys/stat.h> #include <sys/stat.h>
#ifdef __FreeBSD__ #if defined(__FreeBSD__) || defined(__DragonFly__)
#include <libutil.h> #include <libutil.h>
#else #else
#include <util.h> #include <util.h>
@ -759,7 +759,8 @@ static int use_rt_clock;
static void init_get_clock(void) static void init_get_clock(void)
{ {
use_rt_clock = 0; use_rt_clock = 0;
#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) #if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \
|| defined(__DragonFly__)
{ {
struct timespec ts; struct timespec ts;
if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) { if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
@ -771,7 +772,8 @@ static void init_get_clock(void)
static int64_t get_clock(void) static int64_t get_clock(void)
{ {
#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) #if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \
|| defined(__DragonFly__)
if (use_rt_clock) { if (use_rt_clock) {
struct timespec ts; struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts); clock_gettime(CLOCK_MONOTONIC, &ts);