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 | 58 | #include <sys/disk.h> |
59 | 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 | 67 | //#define DEBUG_FLOPPY |
62 | 68 | |
63 | 69 | //#define DEBUG_BLOCK |
... | ... | @@ -745,6 +751,26 @@ static int raw_truncate(BlockDriverState *bs, int64_t offset) |
745 | 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 | 774 | static int64_t raw_getlength(BlockDriverState *bs) |
749 | 775 | { |
750 | 776 | BDRVRawState *s = bs->opaque; |
... | ... | @@ -791,6 +817,7 @@ static int64_t raw_getlength(BlockDriverState *bs) |
791 | 817 | } |
792 | 818 | return size; |
793 | 819 | } |
820 | +#endif | |
794 | 821 | |
795 | 822 | static int raw_create(const char *filename, int64_t total_size, |
796 | 823 | const char *backing_file, int flags) | ... | ... |
configure
... | ... | @@ -150,6 +150,7 @@ audio_possible_drivers="oss sdl esd" |
150 | 150 | ;; |
151 | 151 | OpenBSD) |
152 | 152 | bsd="yes" |
153 | +openbsd="yes" | |
153 | 154 | audio_drv_list="oss" |
154 | 155 | audio_possible_drivers="oss sdl esd" |
155 | 156 | ;; |
... | ... | @@ -1086,6 +1087,11 @@ EOF |
1086 | 1087 | echo "#define HAVE_BYTESWAP_H 1" >> $config_h |
1087 | 1088 | fi |
1088 | 1089 | fi |
1090 | + | |
1091 | +if [ "$openbsd" = "yes" ] ; then | |
1092 | + echo "#define ENOTSUP 4096" >> $config_h | |
1093 | +fi | |
1094 | + | |
1089 | 1095 | if test "$darwin" = "yes" ; then |
1090 | 1096 | echo "CONFIG_DARWIN=yes" >> $config_mak |
1091 | 1097 | echo "#define CONFIG_DARWIN 1" >> $config_h | ... | ... |
curses.c
dyngen-exec.h
... | ... | @@ -32,6 +32,9 @@ |
32 | 32 | host headers do not allow that. */ |
33 | 33 | #include <stddef.h> |
34 | 34 | |
35 | +#ifdef __OpenBSD__ | |
36 | +#include <sys/types.h> | |
37 | +#else | |
35 | 38 | typedef unsigned char uint8_t; |
36 | 39 | typedef unsigned short uint16_t; |
37 | 40 | typedef unsigned int uint32_t; |
... | ... | @@ -61,6 +64,7 @@ typedef signed long int64_t; |
61 | 64 | typedef signed long long int64_t; |
62 | 65 | #endif |
63 | 66 | #endif |
67 | +#endif | |
64 | 68 | |
65 | 69 | /* XXX: This may be wrong for 64-bit ILP32 hosts. */ |
66 | 70 | typedef void * host_reg_t; | ... | ... |
fpu/softfloat-native.h
... | ... | @@ -15,7 +15,9 @@ |
15 | 15 | * Solaris 10 with GCC4 does not need these macros as they |
16 | 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 | 22 | * C99 7.12.3 classification macros |
21 | 23 | * and |
... | ... | @@ -24,6 +26,9 @@ |
24 | 26 | * ... do not work on Solaris 10 using GNU CC 3.4.x. |
25 | 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 | 33 | #define isnormal(x) (fpclass(x) >= FP_NZERO) |
29 | 34 | #define isgreater(x, y) ((!unordered(x, y)) && ((x) > (y))) |
... | ... | @@ -84,6 +89,11 @@ typedef union { |
84 | 89 | | Software IEC/IEEE floating-point rounding mode. |
85 | 90 | *----------------------------------------------------------------------------*/ |
86 | 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 | 97 | enum { |
88 | 98 | float_round_nearest_even = FP_RN, |
89 | 99 | float_round_down = FP_RM, | ... | ... |
osdep.c
... | ... | @@ -68,7 +68,14 @@ void qemu_vfree(void *ptr) |
68 | 68 | |
69 | 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 | 76 | #include <sys/vfs.h> |
77 | +#endif | |
78 | + | |
72 | 79 | #include <sys/mman.h> |
73 | 80 | #include <fcntl.h> |
74 | 81 | |
... | ... | @@ -76,9 +83,14 @@ static void *kqemu_vmalloc(size_t size) |
76 | 83 | { |
77 | 84 | static int phys_ram_fd = -1; |
78 | 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 | 92 | const char *tmpdir; |
80 | 93 | char phys_ram_file[1024]; |
81 | - void *ptr; | |
82 | 94 | #ifdef HOST_SOLARIS |
83 | 95 | struct statvfs stfs; |
84 | 96 | #else |
... | ... | @@ -140,9 +152,10 @@ static void *kqemu_vmalloc(size_t size) |
140 | 152 | } |
141 | 153 | size = (size + 4095) & ~4095; |
142 | 154 | ftruncate(phys_ram_fd, phys_ram_size + size); |
155 | +#endif /* !__OpenBSD__ */ | |
143 | 156 | ptr = mmap(NULL, |
144 | 157 | size, |
145 | - PROT_WRITE | PROT_READ, MAP_SHARED, | |
158 | + PROT_WRITE | PROT_READ, map_anon | MAP_SHARED, | |
146 | 159 | phys_ram_fd, phys_ram_size); |
147 | 160 | if (ptr == MAP_FAILED) { |
148 | 161 | fprintf(stderr, "Could not map physical memory\n"); | ... | ... |
osdep.h
vl.c
... | ... | @@ -61,9 +61,12 @@ |
61 | 61 | #include <arpa/inet.h> |
62 | 62 | #ifdef _BSD |
63 | 63 | #include <sys/stat.h> |
64 | -#ifndef __APPLE__ | |
64 | +#if !defined(__APPLE__) && !defined(__OpenBSD__) | |
65 | 65 | #include <libutil.h> |
66 | 66 | #endif |
67 | +#ifdef __OpenBSD__ | |
68 | +#include <net/if.h> | |
69 | +#endif | |
67 | 70 | #elif defined (__GLIBC__) && defined (__FreeBSD_kernel__) |
68 | 71 | #include <freebsd/stdlib.h> |
69 | 72 | #else | ... | ... |