[Spice-devel] [PATCH spice-win-qxl] spice: windows qxl drivers: support x64 build
Alon Levy
alevy at redhat.com
Wed Feb 2 07:03:28 PST 2011
Looks good. FreeSurfaceImage is a little tricky to read, but if you
say you tested this an it works, I'm all ACK.
On Wed, Feb 02, 2011 at 03:41:27PM +0200, Arnon Gilboa wrote:
> -fix types & casts for correctness in x64
> -add #ifndef _WIN64 for all the SSE2/FPU/fast_memcpy stuff
> -miniport/makefile: remove IFNDEF AMD64 to enable x64 build
> -miniport/qxl.inf: add x64 support
> ---
> display/driver.c | 2 +
> display/makefile | 1 -
> display/quic.c | 4 +-
> display/qxldd.h | 22 ++++++++++----------
> display/res.c | 54 +++++++++++++++++++++++++++++++------------------
> display/res.h | 2 +
> display/surface.h | 4 +-
> display/utils.h | 2 +-
> include/qxl_driver.h | 22 ++++++++++----------
> include/stdint.h | 4 ++-
> miniport/makefile | 18 +---------------
> miniport/qxl.c | 4 +-
> miniport/qxl.inf | 35 +++++++++++++++++++++++++++----
> 13 files changed, 101 insertions(+), 73 deletions(-)
>
> diff --git a/display/driver.c b/display/driver.c
> index 1d5576f..a92eb03 100644
> --- a/display/driver.c
> +++ b/display/driver.c
> @@ -246,7 +246,9 @@ BOOL DrvEnableDriver(ULONG engine_version, ULONG enable_data_size, PDRVENABLEDAT
> mspace_set_abort_func(mspace_abort);
> mspace_set_print_func(mspace_print);
> ResInitGlobals();
> +#ifndef _WIN64
> CheckAndSetSSE2();
> +#endif
> InitGlobalRes();
> DEBUG_PRINT((NULL, 1, "%s: end\n", __FUNCTION__));
> return TRUE;
> diff --git a/display/makefile b/display/makefile
> index f719f40..53b9a3d 100644
> --- a/display/makefile
> +++ b/display/makefile
> @@ -1,2 +1 @@
> !INCLUDE $(NTMAKEENV)\makefile.def
> -
> diff --git a/display/quic.c b/display/quic.c
> index b2ee9c5..2c23d9a 100644
> --- a/display/quic.c
> +++ b/display/quic.c
> @@ -1137,7 +1137,7 @@ static int encoder_reste(Encoder *encoder, uint32_t *io_ptr, uint32_t *io_ptr_en
> encoder_init_rle(&encoder->rgb_state);
> #endif
>
> - encoder->io_words_count = io_ptr_end - io_ptr;
> + encoder->io_words_count = (uint32_t)(io_ptr_end - io_ptr);
> encoder->io_now = io_ptr;
> encoder->io_end = io_ptr_end;
> encoder->rows_completed = 0;
> @@ -1409,7 +1409,7 @@ int quic_encode(QuicContext *quic, QuicImageType type, int width, int height,
> }
>
> flush(encoder);
> - encoder->io_words_count -= (encoder->io_end - encoder->io_now);
> + encoder->io_words_count -= (uint32_t)(encoder->io_end - encoder->io_now);
>
> return encoder->io_words_count;
> }
> diff --git a/display/qxldd.h b/display/qxldd.h
> index 6fd84c4..0f90af1 100644
> --- a/display/qxldd.h
> +++ b/display/qxldd.h
> @@ -261,14 +261,14 @@ typedef struct PDev {
> QXLCommandRing *cmd_ring;
> QXLCursorRing *cursor_ring;
> QXLReleaseRing *release_ring;
> - UINT32 notify_cmd_port;
> - UINT32 notify_cursor_port;
> - UINT32 notify_oom_port;
> + PUCHAR notify_cmd_port;
> + PUCHAR notify_cursor_port;
> + PUCHAR notify_oom_port;
> PEVENT display_event;
> PEVENT cursor_event;
> PEVENT sleep_event;
>
> - UINT32 log_port;
> + PUCHAR log_port;
> UINT8 *log_buf;
> UINT32 *log_level;
>
> @@ -288,7 +288,7 @@ typedef struct PDev {
>
> UINT32 *dev_update_id;
>
> - UINT32 update_area_port;
> + PUCHAR update_area_port;
> QXLRect *update_area;
> UINT32 *update_surface;
>
> @@ -302,12 +302,12 @@ typedef struct PDev {
> PQXLWaitForEvent WaitForEvent;
> #endif
>
> - UINT32 create_primary_port;
> - UINT32 destroy_primary_port;
> - UINT32 destroy_surface_wait_port;
> - UINT32 memslot_add_port;
> - UINT32 memslot_del_port;
> - UINT32 destroy_all_surfaces_port;
> + PUCHAR create_primary_port;
> + PUCHAR destroy_primary_port;
> + PUCHAR destroy_surface_wait_port;
> + PUCHAR memslot_add_port;
> + PUCHAR memslot_del_port;
> + PUCHAR destroy_all_surfaces_port;
>
> UINT8* primary_memory_start;
> UINT32 primary_memory_size;
> diff --git a/display/res.c b/display/res.c
> index 3b8a81e..ccbb110 100644
> --- a/display/res.c
> +++ b/display/res.c
> @@ -19,7 +19,6 @@
> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> */
>
> -#include <ddrawi.h>
> #include <ddraw.h>
> #include <dxmini.h>
> #include "os_dep.h"
> @@ -856,7 +855,7 @@ static void __GetPathCommon(PDev *pdev, PATHOBJ *path, QXLDataChunk **chunk_ptr,
> NEW_DATA_CHUNK(page_counter, alloc_size);
> }
>
> - cp_size = MIN(end - now, pt_buf_size);
> + cp_size = (int)MIN(end - now, pt_buf_size);
> memcpy(now, pt_buf, cp_size);
> chunk->data_size += cp_size;
> *data_size += cp_size;
> @@ -1040,6 +1039,8 @@ static BOOL SetClip(PDev *pdev, CLIPOBJ *clip, QXLDrawable *drawable)
> return TRUE;
> }
>
> +#ifndef _WIN64
> +
> static _inline void fast_memcpy_aligment(void *dest, const void *src, size_t len)
> {
> _asm
> @@ -1242,6 +1243,8 @@ static _inline void fast_memcpy_unaligment(void *dest, const void *src, size_t l
> }
> }
>
> +#endif
> +
> #ifdef DBG
> #define PutBytesAlign __PutBytesAlign
> #define PutBytes(pdev, chunk, now, end, src, size, page_counter, alloc_size, use_sse)\
> @@ -1266,17 +1269,17 @@ static void __PutBytesAlign(PDev *pdev, QXLDataChunk **chunk_ptr, UINT8 **now_pt
>
> DEBUG_PRINT((pdev, 12, "%s\n", __FUNCTION__));
> while (size) {
> - int cp_size = MIN(end - now, size);
> + int cp_size = (int)MIN(end - now, size);
> if (!cp_size) {
> size_t aligned_size;
> ASSERT(pdev, alloc_size > 0);
> ASSERT(pdev, BITS_BUF_MAX > alignment);
> - aligned_size = MIN(alloc_size + alignment - 1, BITS_BUF_MAX);
> + aligned_size = (int)MIN(alloc_size + alignment - 1, BITS_BUF_MAX);
> aligned_size -= aligned_size % alignment;
> NEW_DATA_CHUNK(page_counter, aligned_size);
> - cp_size = MIN(end - now, size);
> + cp_size = (int)MIN(end - now, size);
> }
> -
> +#ifndef _WIN64
> if (use_sse) {
> offset = (size_t)now & SSE_MASK;
> if (offset) {
> @@ -1305,6 +1308,9 @@ static void __PutBytesAlign(PDev *pdev, QXLDataChunk **chunk_ptr, UINT8 **now_pt
> } else {
> RtlCopyMemory(now, src, cp_size);
> }
> +#else
> + RtlCopyMemory(now, src, cp_size);
> +#endif
> src += cp_size;
> now += cp_size;
> chunk->data_size += cp_size;
> @@ -1716,7 +1722,7 @@ static _inline Resource *GetQuicImage(PDev *pdev, SURFOBJ *surf, XLATEOBJ *color
> quic_data->chunk->prev_chunk = 0;
> quic_data->chunk->next_chunk = 0;
> quic_data->prev_chunks_io_words = 0;
> - quic_data->chunk_io_words = ((UINT8 *)image_res + alloc_size - quic_data->chunk->data) >> 2;
> + quic_data->chunk_io_words = (int)(((UINT8 *)image_res + alloc_size - quic_data->chunk->data) >> 2);
> quic_data->rows = height;
> quic_data->raw_row_size = line_size;
>
> @@ -1776,6 +1782,8 @@ static void FreeBitmapImage(PDev *pdev, Resource *res) // todo: defer
> DEBUG_PRINT((pdev, 13, "%s: done\n", __FUNCTION__));
> }
>
> +#ifndef _WIN64
> +
> static _inline void RestoreFPU(PDev *pdev, UINT8 FPUSave[])
> {
> void *align_addr = (void *)ALIGN((size_t)(FPUSave), SSE_ALIGN);
> @@ -1806,6 +1814,8 @@ static _inline void SaveFPU(PDev *pdev, UINT8 FPUSave[])
> }
> }
>
> +#endif
> +
> static void FreeSurfaceImage(PDev *pdev, Resource *res)
> {
> DEBUG_PRINT((pdev, 12, "%s\n", __FUNCTION__));
> @@ -1828,6 +1838,8 @@ static _inline Resource *GetBitmapImage(PDev *pdev, SURFOBJ *surf, XLATEOBJ *col
> UINT8 *src_end;
> UINT8 *dest;
> UINT8 *dest_end;
> + UINT8 FPUSave[16 * 4 + 15];
> + BOOL use_sse = FALSE;
>
> DEBUG_PRINT((pdev, 12, "%s\n", __FUNCTION__));
> ASSERT(pdev, width > 0 && height > 0);
> @@ -1860,23 +1872,21 @@ static _inline Resource *GetBitmapImage(PDev *pdev, SURFOBJ *surf, XLATEOBJ *col
> dest_end = (UINT8 *)image_res + alloc_size;
> alloc_size = height * line_size;
>
> +#ifndef _WIN64
> if (have_sse2 && alloc_size >= 1024) {
> - UINT8 FPUSave[16 * 4 + 15];
> -
> + use_sse = TRUE;
> SaveFPU(pdev, FPUSave);
> -
> - for (; src != src_end; src -= surf->lDelta, alloc_size -= line_size) {
> - PutBytesAlign(pdev, &chunk, &dest, &dest_end, src, line_size,
> - &pdev->Res->num_bits_pages, alloc_size, line_size, TRUE);
> - }
> -
> + }
> +#endif
> + for (; src != src_end; src -= surf->lDelta, alloc_size -= line_size) {
> + PutBytesAlign(pdev, &chunk, &dest, &dest_end, src, line_size,
> + &pdev->Res->num_bits_pages, alloc_size, line_size, use_sse);
> + }
> +#ifndef _WIN64
> + if (use_sse) {
> RestoreFPU(pdev, FPUSave);
> - } else {
> - for (; src != src_end; src -= surf->lDelta, alloc_size -= line_size) {
> - PutBytesAlign(pdev, &chunk, &dest, &dest_end, src, line_size,
> - &pdev->Res->num_bits_pages, alloc_size, line_size, FALSE);
> - }
> }
> +#endif
>
> GetPallette(pdev, &internal->image.bitmap, color_trans);
> DEBUG_PRINT((pdev, 13, "%s: done\n", __FUNCTION__));
> @@ -3310,6 +3320,8 @@ void ResDestroyGlobals()
> image_id_sem = NULL;
> }
>
> +#ifndef _WIN64
> +
> void CheckAndSetSSE2()
> {
> _asm
> @@ -3325,6 +3337,8 @@ void CheckAndSetSSE2()
> }
> }
>
> +#endif
> +
> void ResetAllDevices()
> {
> UINT32 i;
> diff --git a/display/res.h b/display/res.h
> index 3417c02..ae4ad14 100644
> --- a/display/res.h
> +++ b/display/res.h
> @@ -66,7 +66,9 @@ BOOL ResInit(PDev *pdev);
> void ResDestroy(PDev *pdev);
> void ResInitGlobals();
> void ResDestroyGlobals();
> +#ifndef _WIN64
> void CheckAndSetSSE2();
> +#endif
> void ResetAllDevices();
>
> #endif
> diff --git a/display/surface.h b/display/surface.h
> index 028f97e..d741690 100644
> --- a/display/surface.h
> +++ b/display/surface.h
> @@ -11,7 +11,7 @@ static _inline UINT32 GetSurfaceIdFromInfo(SurfaceInfo *info)
> if (info == &pdev->surface0_info) {
> return 0;
> }
> - return info - pdev->Res->surfaces_info;
> + return (UINT32)(info - pdev->Res->surfaces_info);
> }
>
> static _inline SurfaceInfo *GetSurfaceInfo(PDev *pdev, UINT32 id)
> @@ -62,7 +62,7 @@ static UINT32 GetFreeSurface(PDev *pdev)
> } else {
> pdev->Res->free_surfaces = surface->u.next_free;
>
> - id = surface - pdev->Res->surfaces_info;
> + id = (UINT32)(surface - pdev->Res->surfaces_info);
> }
>
> EngReleaseSemaphore(pdev->Res->surface_sem);
> diff --git a/display/utils.h b/display/utils.h
> index b0d075f..a8d0de6 100644
> --- a/display/utils.h
> +++ b/display/utils.h
> @@ -27,7 +27,7 @@
> #define ALIGN(a, b) (((a) + ((b) - 1)) & ~((b) - 1))
>
>
> -#define OFFSETOF(type, member) ((unsigned)&((type *)0)->member)
> +#define OFFSETOF(type, member) ((UINT64)&((type *)0)->member)
> #define CONTAINEROF(ptr, type, member) \
> ((type *) ((UINT8 *)(ptr) - OFFSETOF(type, member)))
>
> diff --git a/include/qxl_driver.h b/include/qxl_driver.h
> index 728e2a2..b2e1c78 100644
> --- a/include/qxl_driver.h
> +++ b/include/qxl_driver.h
> @@ -51,9 +51,9 @@ typedef struct QXLDriverInfo {
> QXLCommandRing *cmd_ring;
> QXLCursorRing *cursor_ring;
> QXLReleaseRing *release_ring;
> - UINT32 notify_cmd_port;
> - UINT32 notify_cursor_port;
> - UINT32 notify_oom_port;
> + PUCHAR notify_cmd_port;
> + PUCHAR notify_cursor_port;
> + PUCHAR notify_oom_port;
> PEVENT display_event;
> PEVENT cursor_event;
> PEVENT sleep_event;
> @@ -68,13 +68,13 @@ typedef struct QXLDriverInfo {
> UINT32 *update_id;
> UINT32 *compression_level;
>
> - UINT32 update_area_port;
> + PUCHAR update_area_port;
> QXLRect *update_area;
> UINT32 *update_surface;
>
> UINT32 *mm_clock;
>
> - UINT32 log_port;
> + PUCHAR log_port;
> UINT8 *log_buf;
> UINT32 *log_level;
> #if (WINVER < 0x0501)
> @@ -89,12 +89,12 @@ typedef struct QXLDriverInfo {
> UINT64 *ram_slot_end;
> MemSlot main_mem_slot;
>
> - UINT32 destroy_surface_wait_port;
> - UINT32 create_primary_port;
> - UINT32 destroy_primary_port;
> - UINT32 memslot_add_port;
> - UINT32 memslot_del_port;
> - UINT32 destroy_all_surfaces_port;
> + PUCHAR destroy_surface_wait_port;
> + PUCHAR create_primary_port;
> + PUCHAR destroy_primary_port;
> + PUCHAR memslot_add_port;
> + PUCHAR memslot_del_port;
> + PUCHAR destroy_all_surfaces_port;
>
> UINT32 dev_id;
>
> diff --git a/include/stdint.h b/include/stdint.h
> index 25920dc..f825d4b 100644
> --- a/include/stdint.h
> +++ b/include/stdint.h
> @@ -136,11 +136,13 @@ typedef unsigned long long uint_fast64_t;
>
> /* 7.18.1.4 Integer types capable of holding object pointers */
>
> +#ifndef _WIN64
> +
> typedef int intptr_t;
>
> typedef unsigned uintptr_t;
>
> -
> +#endif
>
> /* 7.18.1.5 Greatest-width integer types */
>
> diff --git a/miniport/makefile b/miniport/makefile
> index bc5d75a..53b9a3d 100644
> --- a/miniport/makefile
> +++ b/miniport/makefile
> @@ -1,17 +1 @@
> -#
> -# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
> -# file to this component. This file merely indirects to the real make file
> -# that is shared by all the components of Windows NT
> -#
> -
> -!IF DEFINED(_NT_TARGET_VERSION)
> -! IFNDEF AMD64
> -! INCLUDE $(NTMAKEENV)\makefile.def
> -! ELSE
> -! message BUILDMSG: Warning : miniport is not supported on AMD64.
> -! ENDIF
> -!ELSE
> -! INCLUDE $(NTMAKEENV)\makefile.def
> -!ENDIF
> -
> -
> +!INCLUDE $(NTMAKEENV)\makefile.def
> diff --git a/miniport/qxl.c b/miniport/qxl.c
> index e321ee4..855b08b 100644
> --- a/miniport/qxl.c
> +++ b/miniport/qxl.c
> @@ -64,7 +64,7 @@ BOOLEAN Interrupt(PVOID HwDeviceExtension);
>
> typedef struct QXLExtension {
> PVOID io_base;
> - ULONG io_port;
> + PUCHAR io_port;
>
> QXLRom *rom;
> ULONG rom_size;
> @@ -152,7 +152,7 @@ VP_STATUS InitIO(QXLExtension *dev, PVIDEO_ACCESS_RANGE range)
> }
>
> dev->io_base = io_base;
> - dev->io_port = range->RangeStart.LowPart;
> + dev->io_port = (PUCHAR)range->RangeStart.LowPart;
>
> DEBUG_PRINT((0, "%s: OK, io 0x%x size %lu\n", __FUNCTION__,
> (ULONG)range->RangeStart.LowPart, range->RangeLength));
> diff --git a/miniport/qxl.inf b/miniport/qxl.inf
> index 63afd2a..3739ac7 100644
> --- a/miniport/qxl.inf
> +++ b/miniport/qxl.inf
> @@ -5,26 +5,45 @@
> Signature = "$CHICAGO$"
> DriverVer = 09/29/2010,1.4.1.0
> Provider = %RHAT%
> +CatalogFile = qxl.cat
> Class = Display
> ClassGUID = {4d36e968-e325-11ce-bfc1-08002be10318}
>
> [DestinationDirs]
> DefaultDestDir = 11 ; system32
> -qxl.Miniport = 12 ; drivers
> -qxl.Display = 11 ; system32
> +qxl.Miniport = 12 ; drivers
> +qxl.Display = 11 ; system32
>
> [Manufacturer]
> -%RHAT% = q.Mfg
> +%RHAT% = q, NTx86, NTamd64, NTx86.6.0, NTamd64.6.0
>
> -[q.Mfg]
> +; WinXP x86 and up
> +[q.NTx86]
> %RHAT% %QXL% = qxl, PCI\VEN_1b36&DEV_0100&SUBSYS_11001af4&REV_02
>
> +; WinXP x64 and up
> +[q.NTamd64]
> +%RHAT% %QXL% = qxl, PCI\VEN_1b36&DEV_0100&SUBSYS_11001af4&REV_02
> +
> +; Vista x86 and up
> +[q.NTx86.6.0]
> +%RHAT% %QXL% = qxl_vista, PCI\VEN_1b36&DEV_0100&SUBSYS_11001af4&REV_02
> +
> +; Vista x64 and up
> +[q.NTamd64.6.0]
> +%RHAT% %QXL% = qxl_vista, PCI\VEN_1b36&DEV_0100&SUBSYS_11001af4&REV_02
> +
> +
> [ControlFlags]
> ExcludeFromSelect = *
>
> [qxl]
> CopyFiles = qxl.Miniport, qxl.Display
>
> +[qxl_vista]
> +FeatureScore = FC
> +CopyFiles = qxl.Miniport, qxl.Display
> +
> [qxl.Miniport]
> qxl.sys
>
> @@ -41,6 +60,9 @@ qxldd.dll = 1
> [qxl.SoftwareSettings]
> AddReg = qxl_SoftwareDeviceSettings
>
> +[qxl_vista.SoftwareSettings]
> +AddReg = qxl_SoftwareDeviceSettings
> +
> [qxl_SoftwareDeviceSettings]
> HKR,, InstalledDisplayDrivers, %REG_MULTI_SZ%, qxldd
> HKR,, VgaCompatible, %REG_DWORD%, 0
> @@ -50,7 +72,10 @@ HKR,, DefaultSettings.YResolution, %REG_DWORD%, 600
> HKR,, Acceleration.Level, %REG_DWORD%, 0
>
> [qxl.Services]
> -AddService = qxl, 0x00000002, qxl_Service_Inst ; Assign the named service as the PnP function driver
> +AddService = qxl, 0x00000002, qxl_Service_Inst ; Assign the named service as the PnP function driver
> +
> +[qxl_vista.Services]
> +AddService = qxl, 0x00000002, qxl_Service_Inst ; Assign the named service as the PnP function driver
>
> [qxl_Service_Inst]
> ServiceType = 1 ; SERVICE_KERNEL_DRIVER
> --
> 1.5.5.6
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
More information about the Spice-devel
mailing list