Skip to content

Commit

Permalink
Import various scaffolding and helper libraries from the tracer project.
Browse files Browse the repository at this point in the history
  • Loading branch information
tpn committed Jan 19, 2018
1 parent 6e18aa8 commit f135f08
Show file tree
Hide file tree
Showing 164 changed files with 83,619 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Asm/Asm.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
LIBRARY Asm
EXPORTS
CopyPagesNonTemporalAvx2_v1 @1
CopyPagesNonTemporalAvx2_v2 @2
CopyPagesNonTemporalAvx2_v3 @3
CopyPagesNonTemporalAvx2_v4 @4
CopyPagesNonTemporal=CopyPagesNonTemporalAvx2_v4 @5
FillPagesNonTemporalAvx2_v1 @6
FillPagesNonTemporal=FillPagesNonTemporalAvx2_v1 @7
InjectionThunk=InjectionThunk @8
118 changes: 118 additions & 0 deletions Asm/Asm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/*++
Copyright (c) 2016 Trent Nelson <trent@trent.me>
Module Name:
Asm.h
Abstract:
This is the main header file for the Asm (Assembly) component.
--*/

#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#ifdef _ASM_INTERNAL_BUILD

//
// This is an internal build of the Asm component.
//

#define ASM_API __declspec(dllexport)
#define ASM_DATA extern __declspec(dllexport)

#include "stdafx.h"

#elif _ASM_NO_API_EXPORT_IMPORT

//
// We're being included by someone who doesn't want dllexport or dllimport.
// This is useful for creating new .exe-based projects for things like unit
// testing or performance testing/profiling.
//

#define ASM_API
#define ASM_DATA extern

#else

//
// We're being included by an external component.
//

#define ASM_API __declspec(dllimport)
#define ASM_DATA extern __declspec(dllimport)

#endif

#include "../Rtl/DisableWarnings.h"

//
// Define page copying structures and function pointer typedefs.
//

typedef struct _PAGE_COPY_TYPE {
ULONG Movsb:1;
ULONG Movsw:1;
ULONG Movsq:1;
ULONG Avx2C:1;
ULONG Avx2NonTemporal:1;
} PAGE_COPY_TYPE, *PPAGE_COPY_TYPE;

typedef
VOID
(COPY_PAGES)(
_Out_writes_bytes_all_(NumberOfPages << PAGE_SHIFT) PCHAR Dest,
_In_reads_bytes_(NumberOfPages << PAGE_SHIFT) _Const_ PCHAR Source,
_In_ ULONG NumberOfPages
);
typedef COPY_PAGES *PCOPY_PAGES;

typedef
VOID
(COPY_PAGES_EX)(
_Out_writes_bytes_all_(NumberOfPages << PAGE_SHIFT) PCHAR Dest,
_In_reads_bytes_(NumberOfPages << PAGE_SHIFT) _Const_ PCHAR Source,
_In_ ULONG NumberOfPages,
_Out_opt_ PPAGE_COPY_TYPE PageCopyType
);
typedef COPY_PAGES_EX *PCOPY_PAGES_EX;

typedef struct _COPY_PAGES_FUNCTIONS {
PCOPY_PAGES CopyPagesNonTemporalAvx2_v1;
PCOPY_PAGES CopyPagesNonTemporalAvx2_v2;
PCOPY_PAGES CopyPagesNonTemporalAvx2_v3;
PCOPY_PAGES CopyPagesNonTemporalAvx2_v4;
} COPY_PAGES_FUNCTIONS;
typedef COPY_PAGES_FUNCTIONS *PCOPY_PAGES_FUNCTIONS;

ASM_API COPY_PAGES CopyPagesNonTemporalAvx2_v1;
ASM_API COPY_PAGES CopyPagesNonTemporalAvx2_v2;
ASM_API COPY_PAGES CopyPagesNonTemporalAvx2_v3;
ASM_API COPY_PAGES CopyPagesNonTemporalAvx2_v4;

//
// Define page filling function prototypes.
//

typedef
VOID
(FILL_PAGES)(
_Out_writes_bytes_all_(NumberOfPages << PAGE_SHIFT) PCHAR Dest,
_In_opt_ BYTE Byte,
_In_ ULONG NumberOfPages
);
typedef FILL_PAGES *PFILL_PAGES;
ASM_API FILL_PAGES FillPagesNonTemporalAvx2_v1;

#ifdef __cplusplus
} // extern "C"
#endif

// vim:set ts=8 sw=4 sts=4 tw=80 expandtab nowrap :
41 changes: 41 additions & 0 deletions Asm/Asm.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
;++
;
; Copyright (c) 2017 Trent Nelson <trent@trent.me>
;
; Module Name:
;
; Asm.inc
;
; Abstract:
;
; This is the main include file for all assembly language modules. It
; contains includes, constant definitions and macros that are used in
; subroutines.
;
;--

;
; Include the main Windows DDK MASM header.
;

include ksamd64.inc

;
; Define macros for inserting start and end markers that can be detected by
; Intel's code analysis tool IACA.
;

IACA_VC_START macro Name

mov byte ptr gs:[06fh], 06fh

endm

IACA_VC_END macro Name

mov byte ptr gs:[0deh], 0deh

endm

; vim:set tw=80 ts=8 sw=4 sts=4 et syntax=masm fo=croql comments=:; :

100 changes: 100 additions & 0 deletions Asm/Asm.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="PGOptimize|Win32">
<Configuration>PGOptimize</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="PGOptimize|x64">
<Configuration>PGOptimize</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="PGInstrument|Win32">
<Configuration>PGInstrument</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="PGInstrument|x64">
<Configuration>PGInstrument</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="PGUpdate|Win32">
<Configuration>PGUpdate</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="PGUpdate|x64">
<Configuration>PGUpdate</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{A74874AC-5F74-42B8-9E94-4028DE4D1829}</ProjectGuid>
<RootNamespace>Asm</RootNamespace>
<PlatformToolset>v141</PlatformToolset>
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
</PropertyGroup>
<Import Project="..\Tracer.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="PropertySheets" Condition="'$(Platform)'=='Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Platform)'=='x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>_ASM_INTERNAL_BUILD;_ASM_DLL_BUILD;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<ModuleDefinitionFile>Asm.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="AsmPrivate.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="Asm.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.c">
<PrecompiledHeader />
</ClCompile>
<ClCompile Include="stdafx.c">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<MASM Include="CopyPages.asm" Condition="'$(Platform)' == 'x64'" />
<MASM Include="FillPages.asm" />
<MASM Include="InjectionThunk.asm" />
<MASM Include="Misc.asm" />
</ItemGroup>
<ItemGroup>
<None Include="Asm.def" />
<None Include="Asm.inc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
</ImportGroup>
</Project>
61 changes: 61 additions & 0 deletions Asm/Asm.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{854B640E-74DE-40B2-8380-A8C3DFA729E1}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{3073B21C-730B-450B-A39F-E56908DC9023}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{060C681D-4033-4CB7-9DFE-ABA03C19E7D3}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="AsmPrivate.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Asm.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="dllmain.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="Asm.def">
<Filter>Source Files</Filter>
</None>
<None Include="Asm.inc">
<Filter>Header Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<MASM Include="CopyPages.asm">
<Filter>Source Files</Filter>
</MASM>
<MASM Include="FillPages.asm">
<Filter>Source Files</Filter>
</MASM>
<MASM Include="Misc.asm">
<Filter>Source Files</Filter>
</MASM>
<MASM Include="InjectionThunk.asm">
<Filter>Source Files</Filter>
</MASM>
</ItemGroup>
</Project>
34 changes: 34 additions & 0 deletions Asm/AsmPrivate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*++
Copyright (c) 2017 Trent Nelson <trent@trent.me>
Module Name:
AsmPrivate.h
Abstract:
This is the private header file for the Asm component. It defines function
typedefs and function declarations for all major (i.e. not local to the
module) functions available for use by individual modules within this
component.
--*/

#ifndef _ASM_INTERNAL_BUILD
#error AsmPrivate.h being included but _ASM_INTERNAL_BUILD not set.
#endif

#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#include "stdafx.h"

#ifdef __cplusplus
} // extern "C"
#endif

// vim:set ts=8 sw=4 sts=4 tw=80 expandtab :
Loading

0 comments on commit f135f08

Please sign in to comment.