Merging with current msvc.

This commit is contained in:
xorstream 2017-01-23 01:07:06 +11:00
commit e46f86c80b
64 changed files with 279 additions and 801 deletions

View file

@ -22,6 +22,7 @@ environment:
CYG_SETUP: setup-x86.exe CYG_SETUP: setup-x86.exe
BASH: C:\cygwin\bin\bash BASH: C:\cygwin\bin\bash
CC: gcc CC: gcc
- CC: msvc
# Cache Cygwin/MSYS files to speed up build # Cache Cygwin/MSYS files to speed up build
cache: cache:
@ -44,6 +45,7 @@ install:
build_script: build_script:
- if defined BASH (%BASH% -lc "cd $(cygpath ${APPVEYOR_BUILD_FOLDER}) && make") - if defined BASH (%BASH% -lc "cd $(cygpath ${APPVEYOR_BUILD_FOLDER}) && make")
- if "%MSYSTEM%" == "MINGW64" (%BASH% -lc "cd $(cygpath ${APPVEYOR_BUILD_FOLDER}) && make -C bindings/go") - if "%MSYSTEM%" == "MINGW64" (%BASH% -lc "cd $(cygpath ${APPVEYOR_BUILD_FOLDER}) && make -C bindings/go")
- if "%CC%" == "msvc" (msbuild %APPVEYOR_BUILD_FOLDER%/msvc/msvc.sln)
# make test # make test
#- 'cd %APPVEYOR_BUILD_FOLDER% && cd bindings\dotnet && msbuild UnicornDotNet.sln' #- 'cd %APPVEYOR_BUILD_FOLDER% && cd bindings\dotnet && msbuild UnicornDotNet.sln'
# Allows RDP # Allows RDP

View file

@ -1,5 +1,5 @@
#ifndef _QEMU_ELF_H #ifndef QEMU_ELF_H
#define _QEMU_ELF_H #define QEMU_ELF_H
/* /*
* i386 ELF relocation types * i386 ELF relocation types
@ -537,4 +537,4 @@
#define R_IA64_DTPREL64LSB 0xb7 /* @dtprel(sym + add), data8 LSB */ #define R_IA64_DTPREL64LSB 0xb7 /* @dtprel(sym + add), data8 LSB */
#define R_IA64_LTOFF_DTPREL22 0xba /* @ltoff(@dtprel(s+a)), imm22 */ #define R_IA64_LTOFF_DTPREL22 0xba /* @ltoff(@dtprel(s+a)), imm22 */
#endif /* _QEMU_ELF_H */ #endif /* QEMU_ELF_H */

View file

@ -17,8 +17,6 @@
#define WEXITSTATUS(x) (x) #define WEXITSTATUS(x) (x)
#endif #endif
#include "unicorn/platform.h"
#if defined(CONFIG_SOLARIS) && CONFIG_SOLARIS_VERSION < 10 #if defined(CONFIG_SOLARIS) && CONFIG_SOLARIS_VERSION < 10
/* [u]int_fast*_t not in <sys/int_types.h> */ /* [u]int_fast*_t not in <sys/int_types.h> */
typedef unsigned char uint_fast8_t; typedef unsigned char uint_fast8_t;
@ -110,67 +108,6 @@ void *qemu_anon_ram_alloc(size_t size, uint64_t *align);
void qemu_vfree(void *ptr); void qemu_vfree(void *ptr);
void qemu_anon_ram_free(void *ptr, size_t size); void qemu_anon_ram_free(void *ptr, size_t size);
#define QEMU_MADV_INVALID -1
#if defined(CONFIG_MADVISE)
#define QEMU_MADV_WILLNEED MADV_WILLNEED
#define QEMU_MADV_DONTNEED MADV_DONTNEED
#ifdef MADV_DONTFORK
#define QEMU_MADV_DONTFORK MADV_DONTFORK
#else
#define QEMU_MADV_DONTFORK QEMU_MADV_INVALID
#endif
#ifdef MADV_MERGEABLE
#define QEMU_MADV_MERGEABLE MADV_MERGEABLE
#else
#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID
#endif
#ifdef MADV_UNMERGEABLE
#define QEMU_MADV_UNMERGEABLE MADV_UNMERGEABLE
#else
#define QEMU_MADV_UNMERGEABLE QEMU_MADV_INVALID
#endif
#ifdef MADV_DODUMP
#define QEMU_MADV_DODUMP MADV_DODUMP
#else
#define QEMU_MADV_DODUMP QEMU_MADV_INVALID
#endif
#ifdef MADV_DONTDUMP
#define QEMU_MADV_DONTDUMP MADV_DONTDUMP
#else
#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID
#endif
#ifdef MADV_HUGEPAGE
#define QEMU_MADV_HUGEPAGE MADV_HUGEPAGE
#else
#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID
#endif
#elif defined(CONFIG_POSIX_MADVISE)
#define QEMU_MADV_WILLNEED POSIX_MADV_WILLNEED
#define QEMU_MADV_DONTNEED POSIX_MADV_DONTNEED
#define QEMU_MADV_DONTFORK QEMU_MADV_INVALID
#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID
#define QEMU_MADV_UNMERGEABLE QEMU_MADV_INVALID
#define QEMU_MADV_DODUMP QEMU_MADV_INVALID
#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID
#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID
#else /* no-op */
#define QEMU_MADV_WILLNEED QEMU_MADV_INVALID
#define QEMU_MADV_DONTNEED QEMU_MADV_INVALID
#define QEMU_MADV_DONTFORK QEMU_MADV_INVALID
#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID
#define QEMU_MADV_UNMERGEABLE QEMU_MADV_INVALID
#define QEMU_MADV_DODUMP QEMU_MADV_INVALID
#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID
#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID
#endif
#if defined(__HAIKU__) && defined(__i386__) #if defined(__HAIKU__) && defined(__i386__)
#define FMT_pid "%ld" #define FMT_pid "%ld"
#elif defined(WIN64) #elif defined(WIN64)
@ -179,35 +116,6 @@ void qemu_anon_ram_free(void *ptr, size_t size);
#define FMT_pid "%d" #define FMT_pid "%d"
#endif #endif
#ifdef _WIN32
static inline void qemu_timersub(const struct timeval *val1,
const struct timeval *val2,
struct timeval *res)
{
res->tv_sec = val1->tv_sec - val2->tv_sec;
if (val1->tv_usec < val2->tv_usec) {
res->tv_sec--;
res->tv_usec = val1->tv_usec - val2->tv_usec + 1000 * 1000;
} else {
res->tv_usec = val1->tv_usec - val2->tv_usec;
}
}
#else
#define qemu_timersub timersub
#endif
void qemu_set_cloexec(int fd);
void qemu_set_version(const char *);
const char *qemu_get_version(void);
void fips_set_state(bool requested);
bool fips_get_state(void);
/* Get the saved exec dir.
* Caller needs to release the returned string by g_free() */
char *qemu_get_exec_dir(void);
/** /**
* qemu_getauxval: * qemu_getauxval:
* @type: the auxiliary vector key to lookup * @type: the auxiliary vector key to lookup
@ -217,6 +125,4 @@ char *qemu_get_exec_dir(void);
*/ */
unsigned long qemu_getauxval(unsigned long type); unsigned long qemu_getauxval(unsigned long type);
void qemu_set_tty_echo(int fd, bool echo);
#endif #endif

View file

@ -1,14 +1,26 @@
/* * Software MMU support * * Generate helpers used by TCG for qemu_ld/st ops /*
and code load * functions. * * Included from target op helpers and exec.c. * * * Software MMU support
Copyright (c) 2003 Fabrice Bellard * * This library is free software; you can *
redistribute it and/or * modify it under the terms of the GNU Lesser General * Generate helpers used by TCG for qemu_ld/st ops and code load
Public * License as published by the Free Software Foundation; either * version * functions.
2 of the License, or (at your option) any later version. * * This library is *
distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; * Included from target op helpers and exec.c.
without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A *
PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more * Copyright (c) 2003 Fabrice Bellard
details. * * You should have received a copy of the GNU Lesser General Public * *
License along with this library; if not, see <http://www.gnu.org/licenses/>. */ * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
/* Modified for Unicorn Engine by Nguyen Anh Quynh, 2015 */ /* Modified for Unicorn Engine by Nguyen Anh Quynh, 2015 */
#include "qemu/timer.h" #include "qemu/timer.h"

View file

@ -1,432 +0,0 @@
/*
* Arm "Angel" semihosting syscalls
*
* Copyright (c) 2005, 2007 CodeSourcery.
* Written by Paul Brook.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "unicorn/platform.h"
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include "cpu.h"
#ifdef CONFIG_USER_ONLY
#include "qemu.h"
#define ARM_ANGEL_HEAP_SIZE (128 * 1024 * 1024)
#else
#include "qemu-common.h"
#include "hw/arm/arm.h"
#endif
#define TARGET_SYS_OPEN 0x01
#define TARGET_SYS_CLOSE 0x02
#define TARGET_SYS_WRITEC 0x03
#define TARGET_SYS_WRITE0 0x04
#define TARGET_SYS_WRITE 0x05
#define TARGET_SYS_READ 0x06
#define TARGET_SYS_READC 0x07
#define TARGET_SYS_ISTTY 0x09
#define TARGET_SYS_SEEK 0x0a
#define TARGET_SYS_FLEN 0x0c
#define TARGET_SYS_TMPNAM 0x0d
#define TARGET_SYS_REMOVE 0x0e
#define TARGET_SYS_RENAME 0x0f
#define TARGET_SYS_CLOCK 0x10
#define TARGET_SYS_TIME 0x11
#define TARGET_SYS_SYSTEM 0x12
#define TARGET_SYS_ERRNO 0x13
#define TARGET_SYS_GET_CMDLINE 0x15
#define TARGET_SYS_HEAPINFO 0x16
#define TARGET_SYS_EXIT 0x18
#ifndef O_BINARY
#define O_BINARY 0
#endif
#define GDB_O_RDONLY 0x000
#define GDB_O_WRONLY 0x001
#define GDB_O_RDWR 0x002
#define GDB_O_APPEND 0x008
#define GDB_O_CREAT 0x200
#define GDB_O_TRUNC 0x400
#define GDB_O_BINARY 0
static int open_modeflags[12] = {
O_RDONLY,
O_RDONLY | O_BINARY,
O_RDWR,
O_RDWR | O_BINARY,
O_WRONLY | O_CREAT | O_TRUNC,
O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
O_RDWR | O_CREAT | O_TRUNC,
O_RDWR | O_CREAT | O_TRUNC | O_BINARY,
O_WRONLY | O_CREAT | O_APPEND,
O_WRONLY | O_CREAT | O_APPEND | O_BINARY,
O_RDWR | O_CREAT | O_APPEND,
O_RDWR | O_CREAT | O_APPEND | O_BINARY
};
#ifdef CONFIG_USER_ONLY
static inline uint32_t set_swi_errno(TaskState *ts, uint32_t code)
{
if (code == (uint32_t)-1)
ts->swi_errno = errno;
return code;
}
#else
static inline uint32_t set_swi_errno(CPUARMState *env, uint32_t code)
{
return code;
}
#include "exec/softmmu-semi.h"
#endif
#if !defined(CONFIG_USER_ONLY)
static target_ulong syscall_err;
#endif
/* Read the input value from the argument block; fail the semihosting
* call if the memory read fails.
*/
#define GET_ARG(n) do { \
if (get_user_ual(arg ## n, args + (n) * 4)) { \
return (uint32_t)-1; \
} \
} while (0)
ram_addr_t ram_size = 0x10000; // qq
#define SET_ARG(n, val) put_user_ual(val, args + (n) * 4)
uint32_t do_arm_semihosting(CPUARMState *env)
{
ARMCPU *cpu = arm_env_get_cpu(env);
CPUState *cs = CPU(cpu);
target_ulong args;
target_ulong arg0, arg1, arg2;
char * s;
int nr;
uint32_t ret;
uint32_t len;
#ifdef CONFIG_USER_ONLY
TaskState *ts = cs->opaque;
#else
CPUARMState *ts = env;
#endif
nr = env->regs[0];
args = env->regs[1];
switch (nr) {
case TARGET_SYS_OPEN:
GET_ARG(0);
GET_ARG(1);
GET_ARG(2);
s = lock_user_string(arg0);
if (!s) {
/* FIXME - should this error code be -TARGET_EFAULT ? */
return (uint32_t)-1;
}
if (arg1 >= 12) {
unlock_user(s, arg0, 0);
return (uint32_t)-1;
}
if (strcmp(s, ":tt") == 0) {
int result_fileno = arg1 < 4 ? STDIN_FILENO : STDOUT_FILENO;
unlock_user(s, arg0, 0);
return result_fileno;
}
ret = set_swi_errno(ts, open(s, open_modeflags[arg1], 0644));
unlock_user(s, arg0, 0);
return ret;
case TARGET_SYS_CLOSE:
GET_ARG(0);
return set_swi_errno(ts, close(arg0));
case TARGET_SYS_WRITEC:
{
char c;
if (get_user_u8(c, args))
/* FIXME - should this error code be -TARGET_EFAULT ? */
return (uint32_t)-1;
/* Write to debug console. stderr is near enough. */
return write(STDERR_FILENO, &c, 1);
}
case TARGET_SYS_WRITE0:
if (!(s = lock_user_string(args)))
/* FIXME - should this error code be -TARGET_EFAULT ? */
return (uint32_t)-1;
len = strlen(s);
ret = write(STDERR_FILENO, s, len);
unlock_user(s, args, 0);
return ret;
case TARGET_SYS_WRITE:
GET_ARG(0);
GET_ARG(1);
GET_ARG(2);
len = arg2;
s = lock_user(VERIFY_READ, arg1, len, 1);
if (!s) {
/* FIXME - should this error code be -TARGET_EFAULT ? */
return (uint32_t)-1;
}
ret = set_swi_errno(ts, write(arg0, s, len));
unlock_user(s, arg1, 0);
if (ret == (uint32_t)-1)
return -1;
return len - ret;
case TARGET_SYS_READ:
GET_ARG(0);
GET_ARG(1);
GET_ARG(2);
len = arg2;
s = lock_user(VERIFY_WRITE, arg1, len, 0);
if (!s) {
/* FIXME - should this error code be -TARGET_EFAULT ? */
return (uint32_t)-1;
}
do {
ret = set_swi_errno(ts, read(arg0, s, len));
} while (ret == -1 && errno == EINTR);
unlock_user(s, arg1, len);
if (ret == (uint32_t)-1)
return -1;
return len - ret;
case TARGET_SYS_READC:
/* XXX: Read from debug console. Not implemented. */
return 0;
case TARGET_SYS_ISTTY:
GET_ARG(0);
return isatty(arg0);
case TARGET_SYS_SEEK:
GET_ARG(0);
GET_ARG(1);
ret = set_swi_errno(ts, lseek(arg0, arg1, SEEK_SET));
if (ret == (uint32_t)-1)
return -1;
return 0;
case TARGET_SYS_FLEN:
GET_ARG(0);
struct stat buf;
ret = set_swi_errno(ts, fstat(arg0, &buf));
if (ret == (uint32_t)-1)
return -1;
return buf.st_size;
case TARGET_SYS_TMPNAM:
/* XXX: Not implemented. */
return -1;
case TARGET_SYS_REMOVE:
GET_ARG(0);
GET_ARG(1);
s = lock_user_string(arg0);
if (!s) {
/* FIXME - should this error code be -TARGET_EFAULT ? */
return (uint32_t)-1;
}
ret = set_swi_errno(ts, remove(s));
unlock_user(s, arg0, 0);
return ret;
case TARGET_SYS_RENAME:
GET_ARG(0);
GET_ARG(1);
GET_ARG(2);
//GET_ARG(3);
char *s2;
s = lock_user_string(arg0);
s2 = lock_user_string(arg2);
if (!s || !s2)
/* FIXME - should this error code be -TARGET_EFAULT ? */
ret = (uint32_t)-1;
else
ret = set_swi_errno(ts, rename(s, s2));
if (s2)
unlock_user(s2, arg2, 0);
if (s)
unlock_user(s, arg0, 0);
return ret;
case TARGET_SYS_CLOCK:
return clock() / (CLOCKS_PER_SEC / 100);
case TARGET_SYS_TIME:
return set_swi_errno(ts, time(NULL));
case TARGET_SYS_SYSTEM:
GET_ARG(0);
GET_ARG(1);
s = lock_user_string(arg0);
if (!s) {
/* FIXME - should this error code be -TARGET_EFAULT ? */
return (uint32_t)-1;
}
ret = set_swi_errno(ts, system(s));
unlock_user(s, arg0, 0);
return ret;
case TARGET_SYS_ERRNO:
#ifdef CONFIG_USER_ONLY
return ts->swi_errno;
#else
return syscall_err;
#endif
case TARGET_SYS_GET_CMDLINE:
{
/* Build a command-line from the original argv.
*
* The inputs are:
* * arg0, pointer to a buffer of at least the size
* specified in arg1.
* * arg1, size of the buffer pointed to by arg0 in
* bytes.
*
* The outputs are:
* * arg0, pointer to null-terminated string of the
* command line.
* * arg1, length of the string pointed to by arg0.
*/
char *output_buffer;
size_t input_size;
size_t output_size;
int status = 0;
GET_ARG(0);
GET_ARG(1);
input_size = arg1;
/* Compute the size of the output string. */
#if !defined(CONFIG_USER_ONLY)
output_size = strlen(ts->boot_info->kernel_filename)
+ 1 /* Separating space. */
+ strlen(ts->boot_info->kernel_cmdline)
+ 1; /* Terminating null byte. */
#else
unsigned int i;
output_size = ts->info->arg_end - ts->info->arg_start;
if (!output_size) {
/* We special-case the "empty command line" case (argc==0).
Just provide the terminating 0. */
output_size = 1;
}
#endif
if (output_size > input_size) {
/* Not enough space to store command-line arguments. */
return -1;
}
/* Adjust the command-line length. */
if (SET_ARG(1, output_size - 1)) {
/* Couldn't write back to argument block */
return -1;
}
/* Lock the buffer on the ARM side. */
output_buffer = lock_user(VERIFY_WRITE, arg0, output_size, 0);
if (!output_buffer) {
return -1;
}
/* Copy the command-line arguments. */
#if !defined(CONFIG_USER_ONLY)
pstrcpy(output_buffer, output_size, ts->boot_info->kernel_filename);
pstrcat(output_buffer, output_size, " ");
pstrcat(output_buffer, output_size, ts->boot_info->kernel_cmdline);
#else
if (output_size == 1) {
/* Empty command-line. */
output_buffer[0] = '\0';
goto out;
}
if (copy_from_user(output_buffer, ts->info->arg_start,
output_size)) {
status = -1;
goto out;
}
/* Separate arguments by white spaces. */
for (i = 0; i < output_size - 1; i++) {
if (output_buffer[i] == 0) {
output_buffer[i] = ' ';
}
}
out:
#endif
/* Unlock the buffer on the ARM side. */
unlock_user(output_buffer, arg0, output_size);
return status;
}
case TARGET_SYS_HEAPINFO:
{
uint32_t *ptr;
uint32_t limit;
GET_ARG(0);
#ifdef CONFIG_USER_ONLY
/* Some C libraries assume the heap immediately follows .bss, so
allocate it using sbrk. */
if (!ts->heap_limit) {
abi_ulong ret;
ts->heap_base = do_brk(0);
limit = ts->heap_base + ARM_ANGEL_HEAP_SIZE;
/* Try a big heap, and reduce the size if that fails. */
for (;;) {
ret = do_brk(limit);
if (ret >= limit) {
break;
}
limit = (ts->heap_base >> 1) + (limit >> 1);
}
ts->heap_limit = limit;
}
ptr = lock_user(VERIFY_WRITE, arg0, 16, 0);
if (!ptr) {
/* FIXME - should this error code be -TARGET_EFAULT ? */
return (uint32_t)-1;
}
ptr[0] = tswap32(ts->heap_base);
ptr[1] = tswap32(ts->heap_limit);
ptr[2] = tswap32(ts->stack_base);
ptr[3] = tswap32(0); /* Stack limit. */
unlock_user(ptr, arg0, 16);
#else
limit = ram_size;
ptr = lock_user(VERIFY_WRITE, arg0, 16, 0);
if (!ptr) {
/* FIXME - should this error code be -TARGET_EFAULT ? */
return (uint32_t)-1;
}
/* TODO: Make this use the limit of the loaded application. */
ptr[0] = tswap32(limit / 2);
ptr[1] = tswap32(limit);
ptr[2] = tswap32(limit); /* Stack base */
ptr[3] = tswap32(0); /* Stack limit. */
unlock_user(ptr, arg0, 16);
#endif
return 0;
}
case TARGET_SYS_EXIT:
//gdb_exit(env, 0);
exit(0);
default:
fprintf(stderr, "qemu: Unsupported SemiHosting SWI 0x%02x\n", nr);
cpu_dump_state(cs, stderr, fprintf, 0);
abort();
}
}

View file

@ -759,7 +759,6 @@ void helper_fprem1(CPUX86State *env)
st1 = floatx80_to_double(env, ST1); st1 = floatx80_to_double(env, ST1);
if (isinf(st0) || isnan(st0) || isnan(st1) || (st1 == 0.0)) { if (isinf(st0) || isnan(st0) || isnan(st1) || (st1 == 0.0)) {
ST0 = double_to_floatx80(env, NAN); /* NaN */ ST0 = double_to_floatx80(env, NAN); /* NaN */
env->fpus &= ~0x4700; /* (C3,C2,C1,C0) <-- 0000 */ env->fpus &= ~0x4700; /* (C3,C2,C1,C0) <-- 0000 */
return; return;

View file

@ -4848,16 +4848,14 @@ static void gen_sse(CPUX86State *env, DisasContext *s, int b,
if( (b >= 0x50 && b <= 0x5a) || if( (b >= 0x50 && b <= 0x5a) ||
(b >= 0x5c && b <= 0x5f) || (b >= 0x5c && b <= 0x5f) ||
b == 0xc2 ) b == 0xc2 ) {
{
/* Most sse scalar operations. */ /* Most sse scalar operations. */
if (b1 == 2) { if (b1 == 2) {
sz = 2; sz = 2;
} else if (b1 == 3) { } else if (b1 == 3) {
sz = 3; sz = 3;
} }
} } else if( b == 0x2e || /* ucomis[sd] */
else if( b == 0x2e || /* ucomis[sd] */
b == 0x2f ) /* comis[sd] */ b == 0x2f ) /* comis[sd] */
{ {
if (b1 == 0) { if (b1 == 0) {

View file

@ -1,114 +0,0 @@
/*
* m68k/ColdFire Semihosting syscall interface
*
* Copyright (c) 2005-2007 CodeSourcery.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include "unicorn/platform.h"
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include "cpu.h"
#if defined(CONFIG_USER_ONLY)
#include "qemu.h"
#define SEMIHOSTING_HEAP_SIZE (128 * 1024 * 1024)
#else
#include "qemu-common.h"
#include "exec/softmmu-semi.h"
#endif
#include "sysemu/sysemu.h"
#define HOSTED_EXIT 0
#define HOSTED_INIT_SIM 1
#define HOSTED_OPEN 2
#define HOSTED_CLOSE 3
#define HOSTED_READ 4
#define HOSTED_WRITE 5
#define HOSTED_LSEEK 6
#define HOSTED_RENAME 7
#define HOSTED_UNLINK 8
#define HOSTED_STAT 9
#define HOSTED_FSTAT 10
#define HOSTED_GETTIMEOFDAY 11
#define HOSTED_ISATTY 12
#define HOSTED_SYSTEM 13
static void translate_stat(CPUM68KState *env, target_ulong addr, struct stat *s)
{
}
static void m68k_semi_return_u32(CPUM68KState *env, uint32_t ret, uint32_t err)
{
target_ulong args = env->dregs[1];
if (put_user_u32(ret, args) ||
put_user_u32(err, args + 4)) {
/* The m68k semihosting ABI does not provide any way to report this
* error to the guest, so the best we can do is log it in qemu.
* It is always a guest error not to pass us a valid argument block.
*/
qemu_log_mask(LOG_GUEST_ERROR, "m68k-semihosting: return value "
"discarded because argument block not writable\n");
}
}
static void m68k_semi_return_u64(CPUM68KState *env, uint64_t ret, uint32_t err)
{
target_ulong args = env->dregs[1];
if (put_user_u32(ret >> 32, args) ||
put_user_u32(ret, args + 4) ||
put_user_u32(err, args + 8)) {
/* No way to report this via m68k semihosting ABI; just log it */
qemu_log_mask(LOG_GUEST_ERROR, "m68k-semihosting: return value "
"discarded because argument block not writable\n");
}
}
static int m68k_semi_is_fseek;
static void m68k_semi_cb(CPUState *cs, target_ulong ret, target_ulong err)
{
M68kCPU *cpu = M68K_CPU(cs->uc, cs);
CPUM68KState *env = &cpu->env;
if (m68k_semi_is_fseek) {
/* FIXME: We've already lost the high bits of the fseek
return value. */
m68k_semi_return_u64(env, ret, err);
m68k_semi_is_fseek = 0;
} else {
m68k_semi_return_u32(env, ret, err);
}
}
/* Read the input value from the argument block; fail the semihosting
* call if the memory read fails.
*/
#define GET_ARG(n) do { \
if (get_user_ual(arg ## n, args + (n) * 4)) { \
result = -1; \
errno = EFAULT; \
goto failed; \
} \
} while (0)
void do_m68k_semihosting(CPUM68KState *env, int nr)
{
}

View file

@ -20,6 +20,27 @@
#define __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS
<<<<<<< HEAD
=======
// windows specific includes
#ifdef _MSC_VER
#include <io.h>
#include <windows.h>
#define PRIx64 "llX"
#ifdef DYNLOAD
#include "unicorn_dynload.h"
#else // DYNLOAD
#include <unicorn/unicorn.h>
#ifdef _WIN64
#pragma comment(lib, "unicorn_staload64.lib")
#else // _WIN64
#pragma comment(lib, "unicorn_staload.lib")
#endif // _WIN64
#endif // DYNLOAD
// posix specific includes
#else // _MSC_VER
>>>>>>> unicorn-engine/msvc
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>

View file

@ -3,6 +3,27 @@
/* Sample code to demonstrate how to emulate ARM code */ /* Sample code to demonstrate how to emulate ARM code */
<<<<<<< HEAD
=======
// windows specific
#ifdef _MSC_VER
#include <io.h>
#include <windows.h>
#define PRIx64 "llX"
#ifdef DYNLOAD
#include "unicorn_dynload.h"
#else // DYNLOAD
#include <unicorn/unicorn.h>
#ifdef _WIN64
#pragma comment(lib, "unicorn_staload64.lib")
#else // _WIN64
#pragma comment(lib, "unicorn_staload.lib")
#endif // _WIN64
#endif // DYNLOAD
// posix specific
#else // _MSC_VER
>>>>>>> unicorn-engine/msvc
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>
#include <string.h> #include <string.h>

View file

@ -3,6 +3,27 @@
/* Sample code to demonstrate how to emulate ARM64 code */ /* Sample code to demonstrate how to emulate ARM64 code */
<<<<<<< HEAD
=======
// windows specific
#ifdef _MSC_VER
#include <io.h>
#include <windows.h>
#define PRIx64 "llX"
#ifdef DYNLOAD
#include "unicorn_dynload.h"
#else // DYNLOAD
#include <unicorn/unicorn.h>
#ifdef _WIN64
#pragma comment(lib, "unicorn_staload64.lib")
#else // _WIN64
#pragma comment(lib, "unicorn_staload.lib")
#endif // _WIN64
#endif // DYNLOAD
// posix specific
#else // _MSC_VER
>>>>>>> unicorn-engine/msvc
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>
#include <string.h> #include <string.h>

View file

@ -1,4 +1,9 @@
<<<<<<< HEAD
=======
#include <stdio.h>
#include <string.h>
>>>>>>> unicorn-engine/msvc
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>

View file

@ -3,6 +3,27 @@
/* Sample code to demonstrate how to emulate m68k code */ /* Sample code to demonstrate how to emulate m68k code */
<<<<<<< HEAD
=======
// windows specific
#ifdef _MSC_VER
#include <io.h>
#include <windows.h>
#define PRIx64 "llX"
#ifdef DYNLOAD
#include "unicorn_dynload.h"
#else // DYNLOAD
#include <unicorn/unicorn.h>
#ifdef _WIN64
#pragma comment(lib, "unicorn_staload64.lib")
#else // _WIN64
#pragma comment(lib, "unicorn_staload.lib")
#endif // _WIN64
#endif // DYNLOAD
// posix specific
#else // _MSC_VER
>>>>>>> unicorn-engine/msvc
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>
#include <string.h> #include <string.h>

View file

@ -3,6 +3,27 @@
/* Sample code to demonstrate how to emulate Mips code (big endian) */ /* Sample code to demonstrate how to emulate Mips code (big endian) */
<<<<<<< HEAD
=======
// windows specific
#ifdef _MSC_VER
#include <io.h>
#include <windows.h>
#define PRIx64 "llX"
#ifdef DYNLOAD
#include "unicorn_dynload.h"
#else // DYNLOAD
#include <unicorn/unicorn.h>
#ifdef _WIN64
#pragma comment(lib, "unicorn_staload64.lib")
#else // _WIN64
#pragma comment(lib, "unicorn_staload.lib")
#endif // _WIN64
#endif // DYNLOAD
// posix specific
#else // _MSC_VER
>>>>>>> unicorn-engine/msvc
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>
#include <string.h> #include <string.h>

View file

@ -3,6 +3,27 @@
/* Sample code to demonstrate how to emulate Sparc code */ /* Sample code to demonstrate how to emulate Sparc code */
<<<<<<< HEAD
=======
// windows specific
#ifdef _MSC_VER
#include <io.h>
#include <windows.h>
#define PRIx64 "llX"
#ifdef DYNLOAD
#include "unicorn_dynload.h"
#else // DYNLOAD
#include <unicorn/unicorn.h>
#ifdef _WIN64
#pragma comment(lib, "unicorn_staload64.lib")
#else // _WIN64
#pragma comment(lib, "unicorn_staload.lib")
#endif // _WIN64
#endif // DYNLOAD
// posix specific
#else // _MSC_VER
>>>>>>> unicorn-engine/msvc
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>
#include <string.h> #include <string.h>

View file

@ -20,10 +20,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>
<<<<<<< HEAD
=======
#include <assert.h>
>>>>>>> unicorn-engine/msvc
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
<<<<<<< HEAD
# #
=======
>>>>>>> unicorn-engine/msvc
#pragma pack(push, 1) #pragma pack(push, 1)
struct SegmentDescriptor { struct SegmentDescriptor {
union { union {

View file

@ -3,6 +3,27 @@
/* Sample code to trace code with Linux code with syscall */ /* Sample code to trace code with Linux code with syscall */
<<<<<<< HEAD
=======
// windows specific
#ifdef _MSC_VER
#include <io.h>
#include <windows.h>
#define PRIx64 "llX"
#ifdef DYNLOAD
#include "unicorn_dynload.h"
#else // DYNLOAD
#include <unicorn/unicorn.h>
#ifdef _WIN64
#pragma comment(lib, "unicorn_staload64.lib")
#else // _WIN64
#pragma comment(lib, "unicorn_staload.lib")
#endif // _WIN64
#endif // DYNLOAD
// posix specific
#else // _MSC_VER
>>>>>>> unicorn-engine/msvc
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>
#include <string.h> #include <string.h>

View file

@ -1,8 +1,6 @@
#include <sys/types.h> #include <sys/types.h>
#include "unicorn/platform.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "unicorn/platform.h"
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>

View file

@ -1,6 +1,5 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include "unicorn/platform.h"
#include <assert.h> #include <assert.h>
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>

View file

@ -1,4 +1,3 @@
#include "unicorn/platform.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>

View file

@ -1,8 +1,6 @@
#include <sys/types.h> #include <sys/types.h>
#include "unicorn/platform.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "unicorn/platform.h"
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>

View file

@ -22,8 +22,6 @@ Test for uc_emu_stop() in code hook not always stopping the emu at the current i
// posix specific // posix specific
#else // _MSC_VER #else // _MSC_VER
#include "unicorn/platform.h"
#include "unicorn/platform.h"
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>
#include "pthread.h" #include "pthread.h"
#endif // _MSC_VER #endif // _MSC_VER

View file

@ -1,6 +1,5 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include "unicorn/platform.h"
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>

View file

@ -1,4 +1,3 @@
#include "unicorn/platform.h"
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>
static void hook_block(uc_engine *uc, uint64_t address, uint32_t size, void *user_data) { static void hook_block(uc_engine *uc, uint64_t address, uint32_t size, void *user_data) {

View file

@ -1,5 +1,4 @@
#include <stdio.h> #include <stdio.h>
#include "unicorn/platform.h"
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>
uint64_t starts[] = {0x10000000, 0x110004000ll}; uint64_t starts[] = {0x10000000, 0x110004000ll};

View file

@ -1,7 +1,5 @@
#define __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS
#include "unicorn/platform.h"
#include <string.h> #include <string.h>
#include "unicorn/platform.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>

View file

@ -19,9 +19,7 @@
*/ */
#define __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS
#include "unicorn/platform.h"
#include <string.h> #include <string.h>
#include "unicorn/platform.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>

View file

@ -1,7 +1,5 @@
#define __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS
#include "unicorn/platform.h"
#include <string.h> #include <string.h>
#include "unicorn/platform.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>

View file

@ -1,6 +1,5 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include "unicorn/platform.h"
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>

View file

@ -19,9 +19,7 @@
*/ */
#define __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS
#include "unicorn/platform.h"
#include <string.h> #include <string.h>
#include "unicorn/platform.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>

View file

@ -20,9 +20,7 @@
*/ */
#define __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS
#include "unicorn/platform.h"
#include <string.h> #include <string.h>
#include "unicorn/platform.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>

View file

@ -21,8 +21,6 @@
// posix specific // posix specific
#else // _MSC_VER #else // _MSC_VER
#include "unicorn/platform.h"
#include "unicorn/platform.h"
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>
#endif // _MSC_VER #endif // _MSC_VER

View file

@ -21,8 +21,6 @@
// posix specific // posix specific
#else // _MSC_VER #else // _MSC_VER
#include "unicorn/platform.h"
#include "unicorn/platform.h"
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>
#endif // _MSC_VER #endif // _MSC_VER

View file

@ -21,8 +21,6 @@
// posix specific // posix specific
#else // _MSC_VER #else // _MSC_VER
#include "unicorn/platform.h"
#include "unicorn/platform.h"
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>
#endif // _MSC_VER #endif // _MSC_VER

View file

@ -21,8 +21,6 @@
// posix specific // posix specific
#else // _MSC_VER #else // _MSC_VER
#include "unicorn/platform.h"
#include "unicorn/platform.h"
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>
#endif // _MSC_VER #endif // _MSC_VER

View file

@ -21,8 +21,6 @@
// posix specific // posix specific
#else // _MSC_VER #else // _MSC_VER
#include "unicorn/platform.h"
#include "unicorn/platform.h"
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>
#endif // _MSC_VER #endif // _MSC_VER

View file

@ -21,8 +21,6 @@
// posix specific // posix specific
#else // _MSC_VER #else // _MSC_VER
#include "unicorn/platform.h"
#include "unicorn/platform.h"
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>
#endif // _MSC_VER #endif // _MSC_VER

View file

@ -22,8 +22,6 @@
// posix specific // posix specific
#else // _MSC_VER #else // _MSC_VER
#include "unicorn/platform.h"
#include "unicorn/platform.h"
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>
#include "pthread.h" #include "pthread.h"
#endif // _MSC_VER #endif // _MSC_VER

View file

@ -27,8 +27,6 @@ but that the code hook is just not occurring.
// posix specific // posix specific
#else // _MSC_VER #else // _MSC_VER
#include "unicorn/platform.h"
#include "unicorn/platform.h"
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>
#endif // _MSC_VER #endif // _MSC_VER

View file

@ -18,9 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
#include "unicorn/platform.h"
#include <string.h> #include <string.h>
#include "unicorn/platform.h"
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>

View file

@ -20,9 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
#define __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS
#include "unicorn/platform.h"
#include <string.h> #include <string.h>
#include "unicorn/platform.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>

View file

@ -18,9 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
#include "unicorn/platform.h"
#include <string.h> #include <string.h>
#include "unicorn/platform.h"
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>

View file

@ -1,6 +1,5 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include "unicorn/platform.h"
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>
#define ADDRESS 0x1000000 #define ADDRESS 0x1000000

View file

@ -33,8 +33,6 @@ background.
// posix specific // posix specific
#else // _MSC_VER #else // _MSC_VER
#include "unicorn/platform.h"
#include "unicorn/platform.h"
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>
#include "pthread.h" #include "pthread.h"
#endif // _MSC_VER #endif // _MSC_VER

View file

@ -9,8 +9,6 @@ call to uc_emu_start(). See issue #78 for more details:
https://github.com/unicorn-engine/unicorn/issues/78 https://github.com/unicorn-engine/unicorn/issues/78
*/ */
#include "unicorn/platform.h"
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>

View file

@ -1,9 +1,7 @@
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>
#include "unicorn/platform.h"
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include "unicorn/platform.h"
/** /**
* Assert that err matches expect * Assert that err matches expect

View file

@ -5,7 +5,7 @@
#include "unicorn_test.h" #include "unicorn_test.h"
#include <stdio.h> #include <stdio.h>
#include "unicorn/platform.h" #include "unicorn/unicorn.h"
uint64_t trunc_page(uint64_t addr) uint64_t trunc_page(uint64_t addr)
{ {

View file

@ -4,7 +4,7 @@
// emulation by counts of instruction code // emulation by counts of instruction code
// //
#include "unicorn_test.h" #include "unicorn_test.h"
#include "unicorn/platform.h" #include "unicorn/unicorn.h"
#define DEBUG 1 #define DEBUG 1

View file

@ -7,7 +7,7 @@
#include "unicorn_test.h" #include "unicorn_test.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "unicorn/platform.h" #include "unicorn/unicorn.h"
/* Called before every test to set up a new instance */ /* Called before every test to set up a new instance */
static int setup(void **state) static int setup(void **state)

View file

@ -1,5 +1,5 @@
#include "unicorn_test.h" #include "unicorn_test.h"
#include "unicorn/platform.h" #include "unicorn/unicorn.h"
#define OK(x) uc_assert_success(x) #define OK(x) uc_assert_success(x)

View file

@ -1,6 +1,6 @@
// Test PC change during the callback. by Nguyen Anh Quynh, 2016 // Test PC change during the callback. by Nguyen Anh Quynh, 2016
#include "unicorn_test.h" #include "unicorn_test.h"
#include "unicorn/platform.h" #include "unicorn/unicorn.h"
#define OK(x) uc_assert_success(x) #define OK(x) uc_assert_success(x)

View file

@ -8,7 +8,7 @@
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "unicorn/platform.h" #include "unicorn/unicorn.h"
#define RIP_NEXT_TO_THE_SELFMODIFY_OPCODE (1) #define RIP_NEXT_TO_THE_SELFMODIFY_OPCODE (1)

View file

@ -1,5 +1,5 @@
#include "unicorn_test.h" #include "unicorn_test.h"
#include "unicorn/platform.h" #include "unicorn/unicorn.h"
#define OK(x) uc_assert_success(x) #define OK(x) uc_assert_success(x)

View file

@ -1,5 +1,3 @@
#include "unicorn/platform.h"
#include "unicorn/platform.h"
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>
#include "unicorn_test.h" #include "unicorn_test.h"

View file

@ -1,4 +1,4 @@
#include "unicorn/platform.h" #include "unicorn/unicorn.h"
#include <string.h> #include <string.h>
#include "unicorn_test.h" #include "unicorn_test.h"

View file

@ -1,5 +1,5 @@
#include "unicorn_test.h" #include "unicorn_test.h"
#include "unicorn/platform.h" #include "unicorn/unicorn.h"
/* /*
Two tests here for software paging Two tests here for software paging