Commit 128ab2ff50a85969d08d2dec0fd88accdd153bcb
1 parent
72c7b06c
Preliminary OpenBSD host support (based on OpenBSD patches by Todd T. Fries)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5012 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
8 changed files
with
75 additions
and
4 deletions
block-raw-posix.c
@@ -58,6 +58,12 @@ | @@ -58,6 +58,12 @@ | ||
58 | #include <sys/disk.h> | 58 | #include <sys/disk.h> |
59 | #endif | 59 | #endif |
60 | 60 | ||
61 | +#ifdef __OpenBSD__ | ||
62 | +#include <sys/ioctl.h> | ||
63 | +#include <sys/disklabel.h> | ||
64 | +#include <sys/dkio.h> | ||
65 | +#endif | ||
66 | + | ||
61 | //#define DEBUG_FLOPPY | 67 | //#define DEBUG_FLOPPY |
62 | 68 | ||
63 | //#define DEBUG_BLOCK | 69 | //#define DEBUG_BLOCK |
@@ -745,6 +751,26 @@ static int raw_truncate(BlockDriverState *bs, int64_t offset) | @@ -745,6 +751,26 @@ static int raw_truncate(BlockDriverState *bs, int64_t offset) | ||
745 | return 0; | 751 | return 0; |
746 | } | 752 | } |
747 | 753 | ||
754 | +#ifdef __OpenBSD__ | ||
755 | +static int64_t raw_getlength(BlockDriverState *bs) | ||
756 | +{ | ||
757 | + BDRVRawState *s = bs->opaque; | ||
758 | + int fd = s->fd; | ||
759 | + struct stat st; | ||
760 | + | ||
761 | + if (fstat(fd, &st)) | ||
762 | + return -1; | ||
763 | + if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)) { | ||
764 | + struct disklabel dl; | ||
765 | + | ||
766 | + if (ioctl(fd, DIOCGDINFO, &dl)) | ||
767 | + return -1; | ||
768 | + return (uint64_t)dl.d_secsize * | ||
769 | + dl.d_partitions[DISKPART(st.st_rdev)].p_size; | ||
770 | + } else | ||
771 | + return st.st_size; | ||
772 | +} | ||
773 | +#else /* !__OpenBSD__ */ | ||
748 | static int64_t raw_getlength(BlockDriverState *bs) | 774 | static int64_t raw_getlength(BlockDriverState *bs) |
749 | { | 775 | { |
750 | BDRVRawState *s = bs->opaque; | 776 | BDRVRawState *s = bs->opaque; |
@@ -791,6 +817,7 @@ static int64_t raw_getlength(BlockDriverState *bs) | @@ -791,6 +817,7 @@ static int64_t raw_getlength(BlockDriverState *bs) | ||
791 | } | 817 | } |
792 | return size; | 818 | return size; |
793 | } | 819 | } |
820 | +#endif | ||
794 | 821 | ||
795 | static int raw_create(const char *filename, int64_t total_size, | 822 | static int raw_create(const char *filename, int64_t total_size, |
796 | const char *backing_file, int flags) | 823 | const char *backing_file, int flags) |
configure
@@ -150,6 +150,7 @@ audio_possible_drivers="oss sdl esd" | @@ -150,6 +150,7 @@ audio_possible_drivers="oss sdl esd" | ||
150 | ;; | 150 | ;; |
151 | OpenBSD) | 151 | OpenBSD) |
152 | bsd="yes" | 152 | bsd="yes" |
153 | +openbsd="yes" | ||
153 | audio_drv_list="oss" | 154 | audio_drv_list="oss" |
154 | audio_possible_drivers="oss sdl esd" | 155 | audio_possible_drivers="oss sdl esd" |
155 | ;; | 156 | ;; |
@@ -1086,6 +1087,11 @@ EOF | @@ -1086,6 +1087,11 @@ EOF | ||
1086 | echo "#define HAVE_BYTESWAP_H 1" >> $config_h | 1087 | echo "#define HAVE_BYTESWAP_H 1" >> $config_h |
1087 | fi | 1088 | fi |
1088 | fi | 1089 | fi |
1090 | + | ||
1091 | +if [ "$openbsd" = "yes" ] ; then | ||
1092 | + echo "#define ENOTSUP 4096" >> $config_h | ||
1093 | +fi | ||
1094 | + | ||
1089 | if test "$darwin" = "yes" ; then | 1095 | if test "$darwin" = "yes" ; then |
1090 | echo "CONFIG_DARWIN=yes" >> $config_mak | 1096 | echo "CONFIG_DARWIN=yes" >> $config_mak |
1091 | echo "#define CONFIG_DARWIN 1" >> $config_h | 1097 | echo "#define CONFIG_DARWIN 1" >> $config_h |
curses.c
dyngen-exec.h
@@ -32,6 +32,9 @@ | @@ -32,6 +32,9 @@ | ||
32 | host headers do not allow that. */ | 32 | host headers do not allow that. */ |
33 | #include <stddef.h> | 33 | #include <stddef.h> |
34 | 34 | ||
35 | +#ifdef __OpenBSD__ | ||
36 | +#include <sys/types.h> | ||
37 | +#else | ||
35 | typedef unsigned char uint8_t; | 38 | typedef unsigned char uint8_t; |
36 | typedef unsigned short uint16_t; | 39 | typedef unsigned short uint16_t; |
37 | typedef unsigned int uint32_t; | 40 | typedef unsigned int uint32_t; |
@@ -61,6 +64,7 @@ typedef signed long int64_t; | @@ -61,6 +64,7 @@ typedef signed long int64_t; | ||
61 | typedef signed long long int64_t; | 64 | typedef signed long long int64_t; |
62 | #endif | 65 | #endif |
63 | #endif | 66 | #endif |
67 | +#endif | ||
64 | 68 | ||
65 | /* XXX: This may be wrong for 64-bit ILP32 hosts. */ | 69 | /* XXX: This may be wrong for 64-bit ILP32 hosts. */ |
66 | typedef void * host_reg_t; | 70 | typedef void * host_reg_t; |
fpu/softfloat-native.h
@@ -15,7 +15,9 @@ | @@ -15,7 +15,9 @@ | ||
15 | * Solaris 10 with GCC4 does not need these macros as they | 15 | * Solaris 10 with GCC4 does not need these macros as they |
16 | * are defined in <iso/math_c99.h> with a compiler directive | 16 | * are defined in <iso/math_c99.h> with a compiler directive |
17 | */ | 17 | */ |
18 | -#if defined(HOST_SOLARIS) && (( HOST_SOLARIS <= 9 ) || ((HOST_SOLARIS >= 10) && (__GNUC__ <= 4))) | 18 | +#if defined(HOST_SOLARIS) && (( HOST_SOLARIS <= 9 ) || ((HOST_SOLARIS >= 10) \ |
19 | + && (__GNUC__ <= 4))) \ | ||
20 | + || defined(__OpenBSD__) | ||
19 | /* | 21 | /* |
20 | * C99 7.12.3 classification macros | 22 | * C99 7.12.3 classification macros |
21 | * and | 23 | * and |
@@ -24,6 +26,9 @@ | @@ -24,6 +26,9 @@ | ||
24 | * ... do not work on Solaris 10 using GNU CC 3.4.x. | 26 | * ... do not work on Solaris 10 using GNU CC 3.4.x. |
25 | * Try to workaround the missing / broken C99 math macros. | 27 | * Try to workaround the missing / broken C99 math macros. |
26 | */ | 28 | */ |
29 | +#if defined(__OpenBSD__) | ||
30 | +#define unordered(x, y) (isnan(x) || isnan(y)) | ||
31 | +#endif | ||
27 | 32 | ||
28 | #define isnormal(x) (fpclass(x) >= FP_NZERO) | 33 | #define isnormal(x) (fpclass(x) >= FP_NZERO) |
29 | #define isgreater(x, y) ((!unordered(x, y)) && ((x) > (y))) | 34 | #define isgreater(x, y) ((!unordered(x, y)) && ((x) > (y))) |
@@ -84,6 +89,11 @@ typedef union { | @@ -84,6 +89,11 @@ typedef union { | ||
84 | | Software IEC/IEEE floating-point rounding mode. | 89 | | Software IEC/IEEE floating-point rounding mode. |
85 | *----------------------------------------------------------------------------*/ | 90 | *----------------------------------------------------------------------------*/ |
86 | #if (defined(_BSD) && !defined(__APPLE__)) || defined(HOST_SOLARIS) | 91 | #if (defined(_BSD) && !defined(__APPLE__)) || defined(HOST_SOLARIS) |
92 | +#if defined(__OpenBSD__) | ||
93 | +#define FE_RM FP_RM | ||
94 | +#define FE_RP FP_RP | ||
95 | +#define FE_RZ FP_RZ | ||
96 | +#endif | ||
87 | enum { | 97 | enum { |
88 | float_round_nearest_even = FP_RN, | 98 | float_round_nearest_even = FP_RN, |
89 | float_round_down = FP_RM, | 99 | float_round_down = FP_RM, |
osdep.c
@@ -68,7 +68,14 @@ void qemu_vfree(void *ptr) | @@ -68,7 +68,14 @@ void qemu_vfree(void *ptr) | ||
68 | 68 | ||
69 | #if defined(USE_KQEMU) | 69 | #if defined(USE_KQEMU) |
70 | 70 | ||
71 | +#ifdef __OpenBSD__ | ||
72 | +#include <sys/param.h> | ||
73 | +#include <sys/types.h> | ||
74 | +#include <sys/mount.h> | ||
75 | +#else | ||
71 | #include <sys/vfs.h> | 76 | #include <sys/vfs.h> |
77 | +#endif | ||
78 | + | ||
72 | #include <sys/mman.h> | 79 | #include <sys/mman.h> |
73 | #include <fcntl.h> | 80 | #include <fcntl.h> |
74 | 81 | ||
@@ -76,9 +83,14 @@ static void *kqemu_vmalloc(size_t size) | @@ -76,9 +83,14 @@ static void *kqemu_vmalloc(size_t size) | ||
76 | { | 83 | { |
77 | static int phys_ram_fd = -1; | 84 | static int phys_ram_fd = -1; |
78 | static int phys_ram_size = 0; | 85 | static int phys_ram_size = 0; |
86 | + void *ptr; | ||
87 | + | ||
88 | +#ifdef __OpenBSD__ /* no need (?) for a dummy file on OpenBSD */ | ||
89 | + int map_anon = MAP_ANON; | ||
90 | +#else | ||
91 | + int map_anon = 0; | ||
79 | const char *tmpdir; | 92 | const char *tmpdir; |
80 | char phys_ram_file[1024]; | 93 | char phys_ram_file[1024]; |
81 | - void *ptr; | ||
82 | #ifdef HOST_SOLARIS | 94 | #ifdef HOST_SOLARIS |
83 | struct statvfs stfs; | 95 | struct statvfs stfs; |
84 | #else | 96 | #else |
@@ -140,9 +152,10 @@ static void *kqemu_vmalloc(size_t size) | @@ -140,9 +152,10 @@ static void *kqemu_vmalloc(size_t size) | ||
140 | } | 152 | } |
141 | size = (size + 4095) & ~4095; | 153 | size = (size + 4095) & ~4095; |
142 | ftruncate(phys_ram_fd, phys_ram_size + size); | 154 | ftruncate(phys_ram_fd, phys_ram_size + size); |
155 | +#endif /* !__OpenBSD__ */ | ||
143 | ptr = mmap(NULL, | 156 | ptr = mmap(NULL, |
144 | size, | 157 | size, |
145 | - PROT_WRITE | PROT_READ, MAP_SHARED, | 158 | + PROT_WRITE | PROT_READ, map_anon | MAP_SHARED, |
146 | phys_ram_fd, phys_ram_size); | 159 | phys_ram_fd, phys_ram_size); |
147 | if (ptr == MAP_FAILED) { | 160 | if (ptr == MAP_FAILED) { |
148 | fprintf(stderr, "Could not map physical memory\n"); | 161 | fprintf(stderr, "Could not map physical memory\n"); |
osdep.h
@@ -2,6 +2,10 @@ | @@ -2,6 +2,10 @@ | ||
2 | #define QEMU_OSDEP_H | 2 | #define QEMU_OSDEP_H |
3 | 3 | ||
4 | #include <stdarg.h> | 4 | #include <stdarg.h> |
5 | +#ifdef __OpenBSD__ | ||
6 | +#include <sys/types.h> | ||
7 | +#include <sys/signal.h> | ||
8 | +#endif | ||
5 | 9 | ||
6 | #ifndef glue | 10 | #ifndef glue |
7 | #define xglue(x, y) x ## y | 11 | #define xglue(x, y) x ## y |
vl.c
@@ -61,9 +61,12 @@ | @@ -61,9 +61,12 @@ | ||
61 | #include <arpa/inet.h> | 61 | #include <arpa/inet.h> |
62 | #ifdef _BSD | 62 | #ifdef _BSD |
63 | #include <sys/stat.h> | 63 | #include <sys/stat.h> |
64 | -#ifndef __APPLE__ | 64 | +#if !defined(__APPLE__) && !defined(__OpenBSD__) |
65 | #include <libutil.h> | 65 | #include <libutil.h> |
66 | #endif | 66 | #endif |
67 | +#ifdef __OpenBSD__ | ||
68 | +#include <net/if.h> | ||
69 | +#endif | ||
67 | #elif defined (__GLIBC__) && defined (__FreeBSD_kernel__) | 70 | #elif defined (__GLIBC__) && defined (__FreeBSD_kernel__) |
68 | #include <freebsd/stdlib.h> | 71 | #include <freebsd/stdlib.h> |
69 | #else | 72 | #else |