mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-08-05 10:14:04 +00:00
[client/common] restructure project in prep for full SDL removal
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Looking Glass - KVM FrameRelay (KVMFR)
|
||||
Copyright (C) 2017-2019 Geoffrey McRae <geoff@hostfission.com>
|
||||
Copyright (C) 2017-2021 Geoffrey McRae <geoff@hostfission.com>
|
||||
https://looking-glass.hostfission.com
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -16,9 +16,17 @@ You should have received a copy of the GNU General Public License along with
|
||||
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _H_LG_COMMON_KVMFR_
|
||||
#define _H_LG_COMMON_KVMFR_
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "types.h"
|
||||
|
||||
#define KVMFR_MAGIC "KVMFR---"
|
||||
#define KVMFR_VERSION 8
|
||||
|
||||
#define LGMP_Q_POINTER 1
|
||||
#define LGMP_Q_FRAME 2
|
||||
@@ -26,47 +34,15 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#define LGMP_Q_FRAME_LEN 2
|
||||
#define LGMP_Q_POINTER_LEN 20
|
||||
|
||||
typedef enum FrameType
|
||||
{
|
||||
FRAME_TYPE_INVALID ,
|
||||
FRAME_TYPE_BGRA , // BGRA interleaved: B,G,R,A 32bpp
|
||||
FRAME_TYPE_RGBA , // RGBA interleaved: R,G,B,A 32bpp
|
||||
FRAME_TYPE_RGBA10 , // RGBA interleaved: R,G,B,A 10,10,10,2 bpp
|
||||
FRAME_TYPE_RGBA16F , // RGBA interleaved: R,G,B,A 16,16,16,16 bpp float
|
||||
FRAME_TYPE_MAX , // sentinel value
|
||||
}
|
||||
FrameType;
|
||||
|
||||
typedef enum FrameRotation
|
||||
{
|
||||
FRAME_ROT_0,
|
||||
FRAME_ROT_90,
|
||||
FRAME_ROT_180,
|
||||
FRAME_ROT_270
|
||||
}
|
||||
FrameRotation;
|
||||
|
||||
extern const char * FrameTypeStr[FRAME_TYPE_MAX];
|
||||
|
||||
enum
|
||||
{
|
||||
CURSOR_FLAG_POSITION = 0x1,
|
||||
CURSOR_FLAG_VISIBLE = 0x2,
|
||||
CURSOR_FLAG_SHAPE = 0x4
|
||||
};
|
||||
|
||||
typedef uint32_t KVMFRCursorFlags;
|
||||
|
||||
typedef enum CursorType
|
||||
{
|
||||
CURSOR_TYPE_COLOR ,
|
||||
CURSOR_TYPE_MONOCHROME ,
|
||||
CURSOR_TYPE_MASKED_COLOR
|
||||
}
|
||||
CursorType;
|
||||
|
||||
#define KVMFR_MAGIC "KVMFR---"
|
||||
#define KVMFR_VERSION 8
|
||||
|
||||
typedef struct KVMFR
|
||||
{
|
||||
char magic[8];
|
||||
@@ -99,3 +75,5 @@ typedef struct KVMFRFrame
|
||||
uint32_t mouseScalePercent; // movement scale factor of the mouse (relates to DPI of display, 100 = no scale)
|
||||
}
|
||||
KVMFRFrame;
|
||||
|
||||
#endif
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
KVMGFX Client - A KVM Client for VGA Passthrough
|
||||
Copyright (C) 2017-2019 Geoffrey McRae <geoff@hostfission.com>
|
||||
Copyright (C) 2017-2021 Geoffrey McRae <geoff@hostfission.com>
|
||||
https://looking-glass.hostfission.com
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -17,7 +17,12 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _H_LG_COMMON_CRASH_
|
||||
#define _H_LG_COMMON_CRASH_
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool installCrashHandler(const char * exe);
|
||||
void cleanupCrashHandler(void);
|
||||
|
||||
#endif
|
||||
|
@@ -17,6 +17,9 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _H_LG_COMMON_DEBUG_
|
||||
#define _H_LG_COMMON_DEBUG_
|
||||
|
||||
#ifndef __STDC_FORMAT_MACROS
|
||||
#define __STDC_FORMAT_MACROS
|
||||
#endif
|
||||
@@ -82,3 +85,5 @@ void printBacktrace(void);
|
||||
#else
|
||||
#define DEBUG_PROTO(fmt, ...) do {} while(0)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@@ -17,9 +17,14 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _H_LG_COMMON_DPI_
|
||||
#define _H_LG_COMMON_DPI_
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
// At 100% scaling, Windows reports 96 DPI.
|
||||
#define DPI_100_PERCENT 96
|
||||
|
||||
UINT monitor_dpi(HMONITOR hMonitor);
|
||||
|
||||
#endif
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Looking Glass - KVM FrameRelay (KVMFR) Client
|
||||
Copyright (C) 2017-2020 Geoffrey McRae <geoff@hostfission.com>
|
||||
Copyright (C) 2017-2021 Geoffrey McRae <geoff@hostfission.com>
|
||||
https://looking-glass.hostfission.com
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -17,7 +17,8 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef _H_LG_COMMON_EVENT_
|
||||
#define _H_LG_COMMON_EVENT_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <time.h>
|
||||
@@ -40,3 +41,5 @@ LGEvent * lgWrapEvent(void * handle);
|
||||
// Posix specific, not implmented/possible in windows
|
||||
bool lgWaitEventAbs(LGEvent * handle, struct timespec * ts);
|
||||
bool lgWaitEventNS (LGEvent * handle, unsigned int timeout);
|
||||
|
||||
#endif
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
KVMGFX Client - A KVM Client for VGA Passthrough
|
||||
Copyright (C) 2017-2019 Geoffrey McRae <geoff@hostfission.com>
|
||||
Copyright (C) 2017-2021 Geoffrey McRae <geoff@hostfission.com>
|
||||
https://looking-glass.hostfission.com
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -17,7 +17,8 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef _H_LG_COMMON_FRAMEBUFFER_
|
||||
#define _H_LG_COMMON_FRAMEBUFFER_
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
@@ -58,3 +59,5 @@ void framebuffer_prepare(FrameBuffer * frame);
|
||||
* Write data from the src buffer into the KVMFRFrame
|
||||
*/
|
||||
bool framebuffer_write(FrameBuffer * frame, const void * src, size_t size);
|
||||
|
||||
#endif
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Looking Glass - KVM FrameRelay (KVMFR) Client
|
||||
Copyright (C) 2017-2020 Geoffrey McRae <geoff@hostfission.com>
|
||||
Copyright (C) 2017-2021 Geoffrey McRae <geoff@hostfission.com>
|
||||
https://looking-glass.hostfission.com
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -17,7 +17,8 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef _H_LG_COMMON_IVSHMEM_
|
||||
#define _H_LG_COMMON_IVSHMEM_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
@@ -41,3 +42,5 @@ void ivshmemFree(struct IVSHMEM * dev);
|
||||
/* Linux KVMFR support only for now (VM->VM) */
|
||||
bool ivshmemHasDMA (struct IVSHMEM * dev);
|
||||
int ivshmemGetDMABuf(struct IVSHMEM * dev, uint64_t offset, uint64_t size);
|
||||
|
||||
#endif
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Looking Glass - KVM FrameRelay (KVMFR) Client
|
||||
Copyright (C) 2017-2019 Geoffrey McRae <geoff@hostfission.com>
|
||||
Copyright (C) 2017-2021 Geoffrey McRae <geoff@hostfission.com>
|
||||
https://looking-glass.hostfission.com
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -16,7 +16,9 @@ You should have received a copy of the GNU General Public License along with
|
||||
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#ifndef _H_LG_COMMON_LOCKING_
|
||||
#define _H_LG_COMMON_LOCKING_
|
||||
|
||||
#include "time.h"
|
||||
|
||||
@@ -38,3 +40,5 @@ typedef atomic_flag LG_Lock;
|
||||
LG_LOCK(lock) \
|
||||
x \
|
||||
LG_UNLOCK(lock)
|
||||
|
||||
#endif
|
||||
|
@@ -1,135 +0,0 @@
|
||||
/*
|
||||
KVMGFX Client - A KVM Client for VGA Passthrough
|
||||
Copyright (C) 2017-2019 Geoffrey McRae <geoff@hostfission.com>
|
||||
https://looking-glass.hostfission.com
|
||||
|
||||
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, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <tmmintrin.h>
|
||||
#include <immintrin.h>
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
#if defined(NATIVE_MEMCPY)
|
||||
#define memcpySSE memcpy
|
||||
#elif defined(_MSC_VER)
|
||||
extern "C" void * memcpySSE(void *dst, const void * src, size_t length);
|
||||
#elif (defined(__GNUC__) || defined(__GNUG__)) && defined(__i386__)
|
||||
inline static void * memcpySSE(void *dst, const void * src, size_t length)
|
||||
{
|
||||
if (length == 0 || dst == src)
|
||||
return;
|
||||
|
||||
// copies under 1MB are faster with the inlined memcpy
|
||||
// tell the dev to use that instead
|
||||
if (length < 1048576)
|
||||
{
|
||||
static bool smallBufferWarn = false;
|
||||
if (!smallBufferWarn)
|
||||
{
|
||||
DEBUG_WARN("Do not use memcpySSE for copies under 1MB in size!");
|
||||
smallBufferWarn = true;
|
||||
}
|
||||
memcpy(dst, src, length);
|
||||
return;
|
||||
}
|
||||
|
||||
const void * end = dst + (length & ~0x7F);
|
||||
const size_t off = (7 - ((length & 0x7F) >> 4)) * 9;
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"cmp %[dst],%[end] \n\t"
|
||||
"je Remain_%= \n\t"
|
||||
|
||||
// perform SIMD block copy
|
||||
"loop_%=: \n\t"
|
||||
"movaps 0x00(%[src]),%%xmm0 \n\t"
|
||||
"movaps 0x10(%[src]),%%xmm1 \n\t"
|
||||
"movaps 0x20(%[src]),%%xmm2 \n\t"
|
||||
"movaps 0x30(%[src]),%%xmm3 \n\t"
|
||||
"movaps 0x40(%[src]),%%xmm4 \n\t"
|
||||
"movaps 0x50(%[src]),%%xmm5 \n\t"
|
||||
"movaps 0x60(%[src]),%%xmm6 \n\t"
|
||||
"movaps 0x70(%[src]),%%xmm7 \n\t"
|
||||
"movntdq %%xmm0 ,0x00(%[dst]) \n\t"
|
||||
"movntdq %%xmm1 ,0x10(%[dst]) \n\t"
|
||||
"movntdq %%xmm2 ,0x20(%[dst]) \n\t"
|
||||
"movntdq %%xmm3 ,0x30(%[dst]) \n\t"
|
||||
"movntdq %%xmm4 ,0x40(%[dst]) \n\t"
|
||||
"movntdq %%xmm5 ,0x50(%[dst]) \n\t"
|
||||
"movntdq %%xmm6 ,0x60(%[dst]) \n\t"
|
||||
"movntdq %%xmm7 ,0x70(%[dst]) \n\t"
|
||||
"add $0x80,%[dst] \n\t"
|
||||
"add $0x80,%[src] \n\t"
|
||||
"cmp %[dst],%[end] \n\t"
|
||||
"jne loop_%= \n\t"
|
||||
|
||||
"Remain_%=: \n\t"
|
||||
|
||||
// copy any remaining 16 byte blocks
|
||||
"call GetPC_%=\n\t"
|
||||
"Offset_%=:\n\t"
|
||||
"add $(BlockTable_%= - Offset_%=), %%eax \n\t"
|
||||
"add %[off],%%eax \n\t"
|
||||
"jmp *%%eax \n\t"
|
||||
|
||||
"GetPC_%=:\n\t"
|
||||
"mov (%%esp), %%eax \n\t"
|
||||
"ret \n\t"
|
||||
|
||||
"BlockTable_%=:\n\t"
|
||||
"movaps 0x60(%[src]),%%xmm6 \n\t"
|
||||
"movntdq %%xmm6 ,0x60(%[dst]) \n\t"
|
||||
"movaps 0x50(%[src]),%%xmm5 \n\t"
|
||||
"movntdq %%xmm5 ,0x50(%[dst]) \n\t"
|
||||
"movaps 0x40(%[src]),%%xmm4 \n\t"
|
||||
"movntdq %%xmm4 ,0x40(%[dst]) \n\t"
|
||||
"movaps 0x30(%[src]),%%xmm3 \n\t"
|
||||
"movntdq %%xmm3 ,0x30(%[dst]) \n\t"
|
||||
"movaps 0x20(%[src]),%%xmm2 \n\t"
|
||||
"movntdq %%xmm2 ,0x20(%[dst]) \n\t"
|
||||
"movaps 0x10(%[src]),%%xmm1 \n\t"
|
||||
"movntdq %%xmm1 ,0x10(%[dst]) \n\t"
|
||||
"movaps 0x00(%[src]),%%xmm0 \n\t"
|
||||
"movntdq %%xmm0 ,0x00(%[dst]) \n\t"
|
||||
"nop\n\t"
|
||||
"nop\n\t"
|
||||
|
||||
: [dst]"+r" (dst),
|
||||
[src]"+r" (src)
|
||||
: [off]"r" (off),
|
||||
[end]"r" (end)
|
||||
: "eax",
|
||||
"xmm0",
|
||||
"xmm1",
|
||||
"xmm2",
|
||||
"xmm3",
|
||||
"xmm4",
|
||||
"xmm5",
|
||||
"xmm6",
|
||||
"xmm7",
|
||||
"memory"
|
||||
);
|
||||
|
||||
//copy any remaining bytes
|
||||
memcpy(dst, src, length & 0xF);
|
||||
}
|
||||
#else
|
||||
#define memcpySSE memcpy
|
||||
#endif
|
@@ -17,6 +17,9 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _H_COMMON_OPTION_
|
||||
#define _H_COMMON_OPTION_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "common/stringlist.h"
|
||||
|
||||
@@ -53,7 +56,7 @@ struct Option
|
||||
char * (*toString )(struct Option * opt);
|
||||
StringList (*getValues)(struct Option * opt);
|
||||
|
||||
void (*printHelp)();
|
||||
void (*printHelp)(void);
|
||||
|
||||
// internal use only
|
||||
bool failed_set;
|
||||
@@ -75,10 +78,12 @@ bool option_parse(int argc, char * argv[]);
|
||||
bool option_load(const char * filename);
|
||||
|
||||
// called by the main application to validate the option values
|
||||
bool option_validate();
|
||||
bool option_validate(void);
|
||||
|
||||
// print out the options, help, and their current values
|
||||
void option_print();
|
||||
void option_print(void);
|
||||
|
||||
// final cleanup
|
||||
void option_free();
|
||||
void option_free(void);
|
||||
|
||||
#endif
|
||||
|
@@ -17,6 +17,9 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _H_LG_COMMON_STRINGLIST_
|
||||
#define _H_LG_COMMON_STRINGLIST_
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct StringList * StringList;
|
||||
@@ -25,4 +28,6 @@ StringList stringlist_new (bool owns_strings);
|
||||
void stringlist_free (StringList * sl);
|
||||
int stringlist_push (StringList sl, char * str);
|
||||
unsigned int stringlist_count(StringList sl);
|
||||
char * stringlist_at (StringList sl, unsigned int index);
|
||||
char * stringlist_at (StringList sl, unsigned int index);
|
||||
|
||||
#endif
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
KVMGFX Client - A KVM Client for VGA Passthrough
|
||||
Copyright (C) 2017-2019 Geoffrey McRae <geoff@hostfission.com>
|
||||
Copyright (C) 2017-2021 Geoffrey McRae <geoff@hostfission.com>
|
||||
https://looking-glass.hostfission.com
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -17,6 +17,11 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _H_LG_COMMON_STRINGUTILS
|
||||
#define _H_LG_COMMON_STRINGUTILS
|
||||
|
||||
// sprintf but with buffer allocation
|
||||
int alloc_sprintf(char ** str, const char * format, ...)
|
||||
__attribute__ ((format (printf, 2, 3)));
|
||||
__attribute__ ((format (printf, 2, 3)));
|
||||
|
||||
#endif
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
KVMGFX Client - A KVM Client for VGA Passthrough
|
||||
Copyright (C) 2017-2019 Geoffrey McRae <geoff@hostfission.com>
|
||||
Copyright (C) 2017-2021 Geoffrey McRae <geoff@hostfission.com>
|
||||
https://looking-glass.hostfission.com
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -17,5 +17,10 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _H_LG_COMMON_SYSUTILS
|
||||
#define _H_LG_COMMON_SYSUTILS
|
||||
|
||||
// returns the page size
|
||||
long sysinfo_getPageSize();
|
||||
|
||||
#endif
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Looking Glass - KVM FrameRelay (KVMFR) Client
|
||||
Copyright (C) 2017-2020 Geoffrey McRae <geoff@hostfission.com>
|
||||
Copyright (C) 2017-2021 Geoffrey McRae <geoff@hostfission.com>
|
||||
https://looking-glass.hostfission.com
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -17,12 +17,16 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef _H_LG_COMMON_THREAD_
|
||||
#define _H_LG_COMMON_THREAD_
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct LGThread LGThread;
|
||||
typedef int (*LGThreadFunction)(void * opaque);
|
||||
|
||||
bool lgCreateThread(const char * name, LGThreadFunction function, void * opaque, LGThread ** handle);
|
||||
bool lgCreateThread(const char * name, LGThreadFunction function, void * opaque,
|
||||
LGThread ** handle);
|
||||
bool lgJoinThread (LGThread * handle, int * resultCode);
|
||||
|
||||
#endif
|
||||
|
58
common/include/common/types.h
Normal file
58
common/include/common/types.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
Looking Glass - KVM FrameRelay (KVMFR) Client
|
||||
Copyright (C) 2017-2021 Geoffrey McRae <geoff@hostfission.com>
|
||||
https://looking-glass.hostfission.com
|
||||
|
||||
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, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _LG_TYPES_H_
|
||||
#define _LG_TYPES_H_
|
||||
|
||||
struct DoublePoint
|
||||
{
|
||||
double x, y;
|
||||
};
|
||||
|
||||
typedef enum FrameType
|
||||
{
|
||||
FRAME_TYPE_INVALID ,
|
||||
FRAME_TYPE_BGRA , // BGRA interleaved: B,G,R,A 32bpp
|
||||
FRAME_TYPE_RGBA , // RGBA interleaved: R,G,B,A 32bpp
|
||||
FRAME_TYPE_RGBA10 , // RGBA interleaved: R,G,B,A 10,10,10,2 bpp
|
||||
FRAME_TYPE_RGBA16F , // RGBA interleaved: R,G,B,A 16,16,16,16 bpp float
|
||||
FRAME_TYPE_MAX , // sentinel value
|
||||
}
|
||||
FrameType;
|
||||
|
||||
typedef enum FrameRotation
|
||||
{
|
||||
FRAME_ROT_0,
|
||||
FRAME_ROT_90,
|
||||
FRAME_ROT_180,
|
||||
FRAME_ROT_270
|
||||
}
|
||||
FrameRotation;
|
||||
|
||||
extern const char * FrameTypeStr[FRAME_TYPE_MAX];
|
||||
|
||||
typedef enum CursorType
|
||||
{
|
||||
CURSOR_TYPE_COLOR ,
|
||||
CURSOR_TYPE_MONOCHROME ,
|
||||
CURSOR_TYPE_MASKED_COLOR
|
||||
}
|
||||
CursorType;
|
||||
|
||||
#endif
|
@@ -1 +1,25 @@
|
||||
/*
|
||||
KVMGFX Client - A KVM Client for VGA Passthrough
|
||||
Copyright (C) 2017-2021 Geoffrey McRae <geoff@hostfission.com>
|
||||
https://looking-glass.hostfission.com
|
||||
|
||||
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, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _H_LG_COMMON_VERSION_
|
||||
#define _H_LG_COMMON_VERSION_
|
||||
|
||||
extern char * BUILD_VERSION;
|
||||
|
||||
#endif
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Looking Glass - KVM FrameRelay (KVMFR) Client
|
||||
Copyright (C) 2017-2020 Geoffrey McRae <geoff@hostfission.com>
|
||||
Copyright (C) 2017-2021 Geoffrey McRae <geoff@hostfission.com>
|
||||
https://looking-glass.hostfission.com
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -17,7 +17,8 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef _H_LG_COMMON_WINDEBUG_
|
||||
#define _H_LG_COMMON_WINDEBUG_
|
||||
|
||||
#include "debug.h"
|
||||
#include <windows.h>
|
||||
@@ -35,4 +36,6 @@ bool IsWindows8();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@@ -1,237 +0,0 @@
|
||||
.code
|
||||
memcpySSE proc
|
||||
; dst = rcx
|
||||
; src = rdx
|
||||
; len = r8
|
||||
|
||||
mov rax, rcx
|
||||
|
||||
test r8, r8
|
||||
jz @Exit
|
||||
|
||||
cmp rcx, rdx
|
||||
je @Exit
|
||||
|
||||
sub rsp, 8 + 2*16 + 4*8
|
||||
movdqa oword ptr [rsp + 4*8 + 00 ], xmm6
|
||||
movdqa oword ptr [rsp + 4*8 + 16 ], xmm7
|
||||
|
||||
; void * end = dst + (length & ~0x7F);
|
||||
; end = r10
|
||||
mov r9 , r8
|
||||
and r9 , 0FFFFFFFFFFFFFF80h
|
||||
jz @RemainingBlocks
|
||||
mov r10, rcx
|
||||
add r10, r9
|
||||
|
||||
@FullLoop:
|
||||
movaps xmm0 , xmmword ptr [rdx + 000h]
|
||||
movaps xmm1 , xmmword ptr [rdx + 010h]
|
||||
movaps xmm2 , xmmword ptr [rdx + 020h]
|
||||
movaps xmm3 , xmmword ptr [rdx + 030h]
|
||||
movaps xmm4 , xmmword ptr [rdx + 040h]
|
||||
movaps xmm5 , xmmword ptr [rdx + 050h]
|
||||
movaps xmm6 , xmmword ptr [rdx + 060h]
|
||||
movaps xmm7 , xmmword ptr [rdx + 070h]
|
||||
movntdq xmmword ptr [rcx + 000h], xmm0
|
||||
movntdq xmmword ptr [rcx + 010h], xmm1
|
||||
movntdq xmmword ptr [rcx + 020h], xmm2
|
||||
movntdq xmmword ptr [rcx + 030h], xmm3
|
||||
movntdq xmmword ptr [rcx + 040h], xmm4
|
||||
movntdq xmmword ptr [rcx + 050h], xmm5
|
||||
movntdq xmmword ptr [rcx + 060h], xmm6
|
||||
movntdq xmmword ptr [rcx + 070h], xmm7
|
||||
add rdx, 080h
|
||||
add rcx, 080h
|
||||
cmp rcx, r10
|
||||
jne @FullLoop
|
||||
|
||||
@RemainingBlocks:
|
||||
; size_t rem = (length & 0x7F) >> 4);
|
||||
; rem = r11
|
||||
mov r11, r8
|
||||
and r11, 07Fh
|
||||
jz @RestoreExit
|
||||
shr r11, 4
|
||||
jz @FinalBytes
|
||||
|
||||
mov r10, 7
|
||||
sub r10, r11
|
||||
imul r10, 9
|
||||
lea r9 , @FinalBlocks
|
||||
add r9 , r10
|
||||
jmp r9
|
||||
|
||||
@RestoreExit:
|
||||
movdqa xmm6 , oword ptr [rsp + 4*8 + 00]
|
||||
movdqa xmm7 , oword ptr [rsp + 4*8 + 16]
|
||||
add rsp, 8 + 2*16 + 4*8
|
||||
|
||||
@Exit:
|
||||
ret
|
||||
|
||||
@FinalBlocks:
|
||||
movaps xmm6 , xmmword ptr [rdx + 060h]
|
||||
movntdq xmmword ptr [rcx + 060h], xmm6
|
||||
movaps xmm5 , xmmword ptr [rdx + 050h]
|
||||
movntdq xmmword ptr [rcx + 050h], xmm5
|
||||
movaps xmm4 , xmmword ptr [rdx + 040h]
|
||||
movntdq xmmword ptr [rcx + 040h], xmm4
|
||||
movaps xmm3 , xmmword ptr [rdx + 030h]
|
||||
movntdq xmmword ptr [rcx + 030h], xmm3
|
||||
movaps xmm2 , xmmword ptr [rdx + 020h]
|
||||
movntdq xmmword ptr [rcx + 020h], xmm2
|
||||
movaps xmm1 , xmmword ptr [rdx + 010h]
|
||||
movntdq xmmword ptr [rcx + 010h], xmm1
|
||||
movaps xmm0 , xmmword ptr [rdx + 000h]
|
||||
movntdq xmmword ptr [rcx + 000h], xmm0
|
||||
|
||||
movdqa xmm6 , oword ptr [rsp + 4*8 + 00]
|
||||
movdqa xmm7 , oword ptr [rsp + 4*8 + 16]
|
||||
add rsp, 8 + 2*16 + 4*8
|
||||
sfence
|
||||
|
||||
shl r11, 4
|
||||
add rdx, r11
|
||||
add rcx, r11
|
||||
|
||||
@FinalBytes:
|
||||
and r8, 0Fh
|
||||
jz @Exit
|
||||
imul r8, 5
|
||||
lea r9, @FinalBytesTable
|
||||
add r9, r8
|
||||
jmp r9
|
||||
|
||||
@FinalBytesTable:
|
||||
jmp @Copy1
|
||||
jmp @Copy2
|
||||
jmp @Copy3
|
||||
jmp @Copy4
|
||||
jmp @Copy5
|
||||
jmp @Copy6
|
||||
jmp @Copy7
|
||||
jmp @Copy8
|
||||
jmp @Copy9
|
||||
jmp @Copy10
|
||||
jmp @Copy11
|
||||
jmp @Copy12
|
||||
jmp @Copy13
|
||||
jmp @Copy14
|
||||
jmp @Copy15
|
||||
|
||||
db 128 DUP(0CCh)
|
||||
|
||||
; fall through - 1 byte
|
||||
@Copy1:
|
||||
mov al, byte ptr [rdx]
|
||||
mov byte ptr [rcx], al
|
||||
ret
|
||||
|
||||
@Copy2:
|
||||
mov r10w, word ptr [rdx]
|
||||
mov word ptr [rcx], r10w
|
||||
ret
|
||||
|
||||
@Copy3:
|
||||
mov r10w, word ptr [rdx]
|
||||
mov word ptr [rcx], r10w
|
||||
mov r11b, byte ptr [rdx + 02h]
|
||||
mov byte ptr [rcx + 02h], r11b
|
||||
ret
|
||||
|
||||
@Copy4:
|
||||
mov r9d, dword ptr [rdx]
|
||||
mov dword ptr [rcx], r9d
|
||||
ret
|
||||
|
||||
@Copy5:
|
||||
mov r9d, dword ptr [rdx ]
|
||||
mov r11b , byte ptr [rdx + 04h]
|
||||
mov dword ptr [rcx ], r9d
|
||||
mov byte ptr [rcx + 04h], r11b
|
||||
ret
|
||||
|
||||
@Copy6:
|
||||
mov r9d , dword ptr [rdx ]
|
||||
mov r10w, word ptr [rdx + 04h]
|
||||
mov dword ptr [rcx ], r9d
|
||||
mov word ptr [rcx + 04h], r10w
|
||||
ret
|
||||
|
||||
@Copy7:
|
||||
mov r9d , dword ptr [rdx ]
|
||||
mov r10w, word ptr [rdx + 04h]
|
||||
mov r11b, byte ptr [rdx + 06h]
|
||||
mov dword ptr [rcx ], r9d
|
||||
mov word ptr [rcx + 04h], r10w
|
||||
mov byte ptr [rcx + 06h], r11b
|
||||
ret
|
||||
|
||||
@Copy8:
|
||||
mov r8, qword ptr [rdx]
|
||||
mov qword ptr [rcx], r8
|
||||
ret
|
||||
|
||||
@Copy9:
|
||||
mov r8 , qword ptr [rdx ]
|
||||
mov r11b, byte ptr [rdx + 08h]
|
||||
mov qword ptr [rcx ], r8
|
||||
mov byte ptr [rcx + 08h], r11b
|
||||
ret
|
||||
|
||||
@Copy10:
|
||||
mov r8 , qword ptr [rdx ]
|
||||
mov r10w, word ptr [rdx + 08h]
|
||||
mov qword ptr [rcx ], r8
|
||||
mov word ptr [rcx + 08h], r10w
|
||||
ret
|
||||
|
||||
@Copy11:
|
||||
mov r8 , qword ptr [rdx ]
|
||||
mov r10w, word ptr [rdx + 08h]
|
||||
mov r11b, byte ptr [rdx + 0Ah]
|
||||
mov qword ptr [rcx ], r8
|
||||
mov word ptr [rcx + 08h], r10w
|
||||
mov byte ptr [rcx + 0Ah], r11b
|
||||
ret
|
||||
|
||||
@Copy12:
|
||||
mov r8 , qword ptr [rdx ]
|
||||
mov r9d, dword ptr [rdx + 08h]
|
||||
mov qword ptr [rcx ], r8
|
||||
mov dword ptr [rcx + 08h], r9d
|
||||
ret
|
||||
|
||||
@Copy13:
|
||||
mov r8 , qword ptr [rdx ]
|
||||
mov r9d , dword ptr [rdx + 08h]
|
||||
mov r11b, byte ptr [rdx + 0Ch]
|
||||
mov qword ptr [rcx ], r8
|
||||
mov dword ptr [rcx + 08h], r9d
|
||||
mov byte ptr [rcx + 0Ch], r11b
|
||||
ret
|
||||
|
||||
@Copy14:
|
||||
mov r8 , qword ptr [rdx ]
|
||||
mov r9d , dword ptr [rdx + 08h]
|
||||
mov r10w, word ptr [rdx + 0Ch]
|
||||
mov qword ptr [rcx ], r8
|
||||
mov dword ptr [rcx + 08h], r9d
|
||||
mov word ptr [rcx + 0Ch], r10w
|
||||
ret
|
||||
|
||||
; copy 15
|
||||
@Copy15:
|
||||
mov r8 , qword ptr [rdx + 00h]
|
||||
mov r9d , dword ptr [rdx + 08h]
|
||||
mov r10w, word ptr [rdx + 0Ch]
|
||||
mov r11b, byte ptr [rdx + 0Eh]
|
||||
mov qword ptr [rcx + 00h], r8
|
||||
mov dword ptr [rcx + 08h], r9d
|
||||
mov word ptr [rcx + 0Ch], r10w
|
||||
mov byte ptr [rcx + 0Eh], r11b
|
||||
ret
|
||||
|
||||
memcpySSE endp
|
||||
end
|
Reference in New Issue
Block a user