Commit Graph
76 Commits
Author SHA1 Message Date
Quantum ab033d84b1 [common] cpuinfo: handle more than 64 threads on Windows
The old code will not correctly report the number of threads on CPUs with
more than one processor group, i.e. when there are more than 64 logical
processors (threads).
2021-09-04 13:25:24 +10:00
Quantum ffabdd348c [common] cpuinfo: trim trailing whitespace from model name on Windows 2021-08-31 20:57:34 +10:00
Geoffrey McRae 5fc561fa63 [common] cpuinfo: trim any trailing whitespace from CPU model 2021-08-31 20:20:11 +10:00
Quantum 8514f35474 [common] windebug: handle FormatMessage failure 2021-08-31 20:14:29 +10:00
Quantum 0faafbff47 [common] cpuinfo: implement for Windows 2021-08-31 20:14:10 +10:00
Quantum a6112feddb [common] cpuinfo: implement for linux by parsing /proc/cpuinfo 2021-08-31 20:14:10 +10:00
Quantum e6df0acad9 [common] vector: eliminate double allocation when possible
This commit creates two constructor/destructor pairs for vector:
* vector_alloc/vector_free dynamically allocates the vector itself
* vector_create/vector_destroy uses existing Vector objects
2021-08-28 19:17:15 +10:00
Quantum e040b88bf0 [common] ivshmem: switch to using vectors 2021-08-24 22:10:36 +10:00
Quantum ccda264648 [common] windebug: pass FORMAT_MESSAGE_IGNORE_INSERTS to FormatMessage
This avoids problems when the error message we are told to format contains
inserts like %1.

See https://devblogs.microsoft.com/oldnewthing/20071128-00/?p=24353 for
details (or for fun).
2021-08-17 19:07:41 +10:00
Quantum 2de9e3e9be [common] remove all casts around malloc 2021-08-16 16:26:58 +10:00
Quantum 4d907cecab [common] use correct argument order for calloc
The signature for calloc is void *calloc(size_t num, size_t size), where num
is the number of elements to allocate, and size is the size. Therefore, to
allocate a single struct, we should pass 1 for num and the size of the struct
as size.

In some places, we use the opposite order, and we should flip it.
2021-08-16 16:25:59 +10:00
Tudor Brindus 1c5620ba25 [common] use variable-relative sizeof where possible 2021-08-16 16:22:55 +10:00
Quantum b2630024a7 [common] all: switch asserts to DEBUG_ASSERT 2021-08-14 12:19:07 +10:00
Quantum e5d252290d [common] array: add ALIGN_PAD macro for common logic
ALIGN_PAD(x, a) returns x rounded up to the nearest multiple of a.
2021-08-14 08:05:29 +10:00
Quantum 717b90366b [common] ivshmem: use correct page alignment logic
Before, if the size is exactly the multiple of the page size, an extra padding
page is added for no reason. This commit fixes the logic and also uses the
page size obtained dynamically.
2021-08-13 20:24:15 +10:00
Quantum 9f4afcd944 [common] crash: use DEBUG_WINERROR on windows 2021-08-11 02:41:33 +10:00
Quantum 87a21f5f5e [host] windows: use DEBUG_WINERROR for CallNtPowerInformation
We need to use the function RtlNtStatusToDosError to convert NTSTATUS to
Windows error codes.
2021-08-09 17:07:25 +10:00
Quantum 2f8ebc29e8 [common] open: implement opening URLs in browser
This is currently only implemented for Linux.

On Windows, ShellExecute should be used, but that should be done when it's
actually needed so it could be tested.
2021-08-05 22:43:46 +10:00
Quantum 51b9cd4e5a [all] copyright: use unicode copyright sign ©
This is done for consistency with the license strings in appstrings.c.
2021-08-04 21:16:35 +10:00
Geoffrey McRae 90b90e667a [common] event: lgResetEvent should return the last state of the event 2021-08-01 17:14:58 +10:00
Geoffrey McRae a094fb8104 [common] events/linux: fix failure to call pthread_cond_broadcast 2021-08-01 17:13:31 +10:00
Quantum 3369536cb8 [common] paths: add library to manage platform-specific paths
This abstracts away stuff like XDG base directory specification.
Currently, this is implemented for Linux only.
2021-07-31 21:11:09 +10:00
Quantum 2ea84cd07e [common] ivshmem: use consistent device numbering on Windows
We now enumerate all IVSHMEM devices, sort them based on PCI bus, slot,
and function numbers, then index from the resulting order. This should
be consistent across boots.

To help the user identify the correct IVSHMEM device, we also print the
list of IVSHMEM devices on startup.
2021-07-29 10:17:33 +10:00
Geoffrey McRae 5f5f497cbd [host/common] windows: provide delayExecution via nsleep
This change moves this platform specific sleep to `common` as the OS
agnostic `nsleep` function.

Ref PR #661
2021-07-26 16:36:56 +10:00
Quantum 3cf0257f34 [host] windows: do not complain about failed timer destruction at exit
When our window is destroyed, our timers are also destroyed. This causes our
attempt at destruction to fail. Instead, set MessageHWND to NULL in the
WM_DESTROY handler and don't try destroying the timers if the window is gone.
2021-07-23 15:52:45 +10:00
Quantum 26f16a3734 [common] windows: declare WINVER and _WIN32_WINNT
This is done for consistency with the Windows-specific portions of the host.
2021-07-20 12:45:29 +10:00
Quantum 2bb0602ebb [common] windebug: remove custom-rolled Windows 8 detector
Just use <versionhelpers.h> from Windows SDK.
2021-07-20 11:34:57 +10:00
Geoffrey McRae 2038517861 [common] linux: review and fix event logic, events should not be counted 2021-07-19 13:19:59 +10:00
Geoffrey McRae 2736e37e4a [common] timer: fix timespec parameters when interval >= 1000 2021-07-19 10:58:10 +10:00
Quantum ad974cfa0a [common] dpi: remove no longer used library 2021-07-18 10:50:57 +10:00
Geoffrey McRae 041b95507d [host] windows/nvfbc/common: strip out broken "enhanced" event logic
This so called "enhanced" event logic is completely flawed and can never
work correctly, better to strip it out and put our faith in windows to
handle the events for us.

And yes, I am fully aware I wrote the utter trash in the first place :)
2021-07-09 10:22:03 +10:00
Geoffrey McRae bfb47a0ae4 [common] windows: update event fast path to use atomics
Due to a failure to understand atomics when this code was originally
written it has a critical flaw with the fast path where an event could
be signalled when it should not be. This change set corrects this issue
by using atomic operations.
2021-07-09 04:50:14 +10:00
Geoffrey McRae 0acce0737f [common] debug: output to stdout and reset the the color at the end 2021-07-08 07:18:06 +10:00
Geoffrey McRae 1effd5fddc [common] debug: add color support to debug messages
People often miss the warnings about invalid arguments in their command
line, this last minute patch attempts to address this by making
warnings, errors, fixme's and fatal errors stand out if stdout is a TTY.
2021-07-07 23:05:46 +10:00
Quantum 24d0aa0c18 [all] normalize copyright on all source files 2021-06-06 11:53:05 +10:00
Quantum fc7dd7dbb7 [common] cmake: correctly link static libbfd.a
When linking against libbfd.so, just passing libbfd.so to the compiler is
sufficient. When linking against the static version libbfd.a, however,
we must additionally link against libiberty.a and libz.a.

This commit adds a CMake helper to find the correct libraries that need
to be passed to link against libbfd correctly.
2021-03-03 16:37:34 +11:00
Quantum 5ad70ccc41 [common] crash/linux: generate core dump when handling SIGSEGV
Calling abort() instead of exit() will generate a core dump, allowing gdb
to be used when the client crashes. This is desirable for the following
reasons:

1. gdb can be used to inspect the call stack with far more detail than the
   our quick stack trace code, and also allows the access to the heap.
2. Our SIGSEGV handler is unable to use debug symbols for shared libraries,
   making it impossible to debug bugs involving drivers and similar.
2021-02-27 13:34:03 +11:00
Quantum 62b27760ea [common] ivshmem: do not create dmabuf for simple mmap
It used to be the case that you need to create dmabuf for kvmfr devices
to be able to mmap them. But after #457, this is no longer needed.

Directly mmaping the kvmfr device has the advantage of avoiding the
creation of a dmabuf, which has cost (e.g. the list of pages, the
scatterlist, etc.).
2021-02-21 10:31:48 +11:00
Geoffrey McRae 6f1c19b3b0 [all] improve backtrace and debugging support 2021-02-21 10:30:57 +11:00
Quantum 7e15ec5e66 [common] windows: implement crash handler for stack traces
This commit uses the DbgHelp library which is shipped with Windows to
generate stack traces with function names and line number information.
It takes advantage of the pdb file generated by cv2pdb that is now
installed with looking-glass-host.exe.
2021-01-27 07:56:12 +11:00
Geoffrey McRae 27a38294ea [client] major restructure of platform specific code 2021-01-16 20:41:13 +11:00
Quantum afa277f8ee [common] ivshmem/linux: add stubs for ivshmemInit and ivshmemFree
These two functions were added in 9ff1859dc1
for Windows, but were never used on Linux.

Adding stubs will allow the host to compile on Linux.
These should be fixed later.
2021-01-15 08:49:30 +11:00
Tudor Brindus a46a3a2668 [all] use explicit void parameter lists
This makes it a compile-time error to call a function that semantically
takes no parameters with a nonzero number of arguments.

Previously, such code would still compile, but risk blowing up the stack
if a compiler chose to use something other than caller-cleanup calling
conventions.
2021-01-14 17:29:37 +11:00
Geoffrey McRae f85b6418b8 [common] linux: stop event signals accumulating after they are serviced 2021-01-08 01:18:02 +11:00
Quantum 7e4d323427 get display DPI info to scale mouse movement 2021-01-05 09:03:29 +11:00
Geoffrey McRae 5522e93fb9 [common] linux: added helpers for ivshmem DMA usage 2020-10-30 02:36:45 +11:00
Geoffrey McRae 0efe7dc63c [common] linux: added support for kvmfr dmabuf 2020-10-30 02:36:45 +11:00
Geoffrey McRae a70858aea0 [client] reworked frame timing waits for better responsiveness 2020-10-26 18:09:45 +11:00
Geoffrey McRae 9ff1859dc1 [host] windows: check the ivshmem device exists in the service 2020-10-19 02:49:15 +11:00
Geoffrey McRae 6650e58a4a [common] linux: print reason for failure to open the shm file/device 2020-10-12 17:48:31 +11:00