import Unicorn2

This commit is contained in:
Nguyen Anh Quynh
2021-10-03 22:14:44 +08:00
parent 772558119a
commit aaaea14214
837 changed files with 368717 additions and 200912 deletions

View File

@@ -1,62 +0,0 @@
/* QEMU accelerator interfaces
*
* Copyright (c) 2014 Red Hat Inc
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef HW_ACCEL_H
#define HW_ACCEL_H
#include "qemu/typedefs.h"
#include "qom/object.h"
typedef struct AccelState {
/*< private >*/
Object parent_obj;
} AccelState;
typedef struct AccelClass {
/*< private >*/
ObjectClass parent_class;
/*< public >*/
const char *opt_name;
const char *name;
int (*available)(void);
int (*init_machine)(MachineState *ms);
bool *allowed;
} AccelClass;
#define TYPE_ACCEL "accel"
#define ACCEL_CLASS_SUFFIX "-" TYPE_ACCEL
#define ACCEL_CLASS_NAME(a) (a ACCEL_CLASS_SUFFIX)
#define ACCEL_CLASS(uc, klass) \
OBJECT_CLASS_CHECK(uc, AccelClass, (klass), TYPE_ACCEL)
#define ACCEL(uc, obj) \
OBJECT_CHECK(uc, AccelState, (obj), TYPE_ACCEL)
#define ACCEL_GET_CLASS(uc, obj) \
OBJECT_GET_CLASS(uc, AccelClass, (obj), TYPE_ACCEL)
int configure_accelerator(MachineState *ms);
void register_accel_types(struct uc_struct *uc);
#endif

View File

@@ -1,20 +1,25 @@
#ifndef QEMU_CPUS_H
#define QEMU_CPUS_H
struct uc_struct;
#include "qemu/timer.h"
/* cpus.c */
int resume_all_vcpus(struct uc_struct*);
void cpu_stop_current(struct uc_struct*);
bool qemu_in_vcpu_thread(void);
void qemu_init_cpu_loop(void);
void resume_all_vcpus(struct uc_struct* uc);
void cpu_stop_current(struct uc_struct* uc);
void cpu_ticks_init(void);
#ifndef CONFIG_USER_ONLY
/* vl.c */
extern int smp_cores;
extern int smp_threads;
#else
/* *-user doesn't have configurable SMP topology */
#define smp_cores 1
#define smp_threads 1
#endif
/* Unblock cpu */
void qemu_cpu_kick_self(void);
void cpu_synchronize_all_states(void);
void cpu_synchronize_all_post_reset(void);
void cpu_synchronize_all_post_init(void);
void cpu_synchronize_all_pre_loadvm(void);
void qtest_clock_warp(int64_t dest);
void list_cpus(const char *optarg);
#endif

View File

@@ -15,28 +15,10 @@
#define MEMORY_MAPPING_H
#include "qemu/queue.h"
#include "qemu/typedefs.h"
#include "exec/cpu-defs.h"
#include "exec/memory.h"
typedef struct GuestPhysBlock {
/* visible to guest, reflects PCI hole, etc */
hwaddr target_start;
/* implies size */
hwaddr target_end;
/* points into host memory */
uint8_t *host_addr;
QTAILQ_ENTRY(GuestPhysBlock) next;
} GuestPhysBlock;
/* point-in-time snapshot of guest-visible physical mappings */
typedef struct GuestPhysBlockList {
unsigned num;
QTAILQ_HEAD(GuestPhysBlockHead, GuestPhysBlock) head;
} GuestPhysBlockList;
/* The physical and virtual address in the memory mapping are contiguous. */
/* The physical and virtual address in the memory mapping are contiguous. */
typedef struct MemoryMapping {
hwaddr phys_addr;
target_ulong virt_addr;
@@ -60,24 +42,4 @@ void memory_mapping_list_add_merge_sorted(MemoryMappingList *list,
hwaddr virt_addr,
ram_addr_t length);
void memory_mapping_list_free(MemoryMappingList *list);
void memory_mapping_list_init(MemoryMappingList *list);
void guest_phys_blocks_free(GuestPhysBlockList *list);
void guest_phys_blocks_init(GuestPhysBlockList *list);
//void guest_phys_blocks_append(GuestPhysBlockList *list);
void qemu_get_guest_memory_mapping(struct uc_struct *uc,
MemoryMappingList *list,
const GuestPhysBlockList *guest_phys_blocks,
Error **errp);
/* get guest's memory mapping without do paging(virtual address is 0). */
void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list,
const GuestPhysBlockList *guest_phys_blocks);
void memory_mapping_filter(MemoryMappingList *list, int64_t begin,
int64_t length);
#endif

View File

@@ -28,56 +28,27 @@
#include <winsock2.h>
#include <windows.h>
#include <setjmp.h>
/* Workaround for older versions of MinGW. */
#ifndef ECONNREFUSED
# define ECONNREFUSED WSAECONNREFUSED
#endif
#ifndef EINPROGRESS
# define EINPROGRESS WSAEINPROGRESS
#endif
#ifndef EHOSTUNREACH
# define EHOSTUNREACH WSAEHOSTUNREACH
#endif
#ifndef EINTR
# define EINTR WSAEINTR
#endif
#ifndef EINPROGRESS
# define EINPROGRESS WSAEINPROGRESS
#endif
#ifndef ENETUNREACH
# define ENETUNREACH WSAENETUNREACH
#endif
#ifndef ENOTCONN
# define ENOTCONN WSAENOTCONN
#endif
#ifndef EWOULDBLOCK
# define EWOULDBLOCK WSAEWOULDBLOCK
#endif
#include <ws2tcpip.h>
#if defined(_WIN64)
/* On w64, setjmp is implemented by _setjmp which needs a second parameter.
* If this parameter is NULL, longjump does no stack unwinding.
* That is what we need for QEMU. Passing the value of register rsp (default)
* lets longjmp try a stack unwinding which will crash with generated code. */
#if defined(_MSC_VER) // MSVC
#if defined(_MSC_VER) // MSVC
// See qemu/include/utils/setjmp-wrapper-win32.asm for details.
extern int _setjmp_wrapper(jmp_buf);
#undef setjmp
#define setjmp(env) _setjmp_wrapper(env)
# undef setjmp
# define setjmp(env) _setjmp_wrapper(env)
#else // MingW
#else // MinGW
// Original QEMU patch.
# undef setjmp
# define setjmp(env) _setjmp(env, NULL)
#undef setjmp
#define setjmp(env) _setjmp(env, NULL)
#endif
#endif
/* QEMU uses sigsetjmp()/siglongjmp() as the portable way to specify
* "longjmp and don't touch the signal masks". Since we know that the
* savemask parameter will always be zero we can safely define these
@@ -87,10 +58,6 @@ extern int _setjmp_wrapper(jmp_buf);
#define sigsetjmp(env, savemask) setjmp(env)
#define siglongjmp(env, val) longjmp(env, val)
size_t getpagesize(void);
#if !defined(EPROTONOSUPPORT)
# define EPROTONOSUPPORT EINVAL
#endif
int getpagesize(void);
#endif

View File

@@ -1,27 +1,9 @@
#ifndef SYSEMU_H
#define SYSEMU_H
/* Misc. things related to the system emulator. */
#include "qemu/timer.h"
#include "qapi/error.h"
/* vl.c */
struct uc_struct;
int runstate_is_running(void);
typedef struct vm_change_state_entry VMChangeStateEntry;
#define VMRESET_SILENT false
#define VMRESET_REPORT true
int vm_start(struct uc_struct*);
void qemu_system_reset_request(struct uc_struct*);
void qemu_system_shutdown_request(void);
void qemu_system_powerdown_request(void);
void qemu_system_reset(bool report);
extern int smp_cpus;
void qemu_system_shutdown_request(struct uc_struct*);
#endif

19
qemu/include/sysemu/tcg.h Normal file
View File

@@ -0,0 +1,19 @@
/*
* QEMU TCG support
*
* This work is licensed under the terms of the GNU GPL, version 2 or later.
* See the COPYING file in the top-level directory.
*/
#ifndef SYSEMU_TCG_H
#define SYSEMU_TCG_H
#include <stdbool.h>
//#include "uc_priv.h"
struct uc_struct;
void tcg_exec_init(struct uc_struct *uc, unsigned long tb_size);
#endif