* KernelModeDriver module support

* Build afd.sys


svn path=/branches/xmlbuildsystem/; revision=13078
This commit is contained in:
Casper Hornstrup
2005-01-16 13:51:33 +00:00
parent 41c7d92f46
commit 40a6da67c4
11 changed files with 198 additions and 59 deletions
+1
View File
@@ -19,6 +19,7 @@
<include>include</include>
<include>w32api/include</include>
<include>w32api/include/ddk</include>
<directory name="drivers">
<xi:include href="drivers/directory.xml" />
+4 -1
View File
@@ -1,3 +1,6 @@
<directory name="lib">
<xi:include href="lib/directory.xml" />
</directory>
</directory>
<directory name="net">
<xi:include href="net/directory.xml" />
</directory>
+24
View File
@@ -0,0 +1,24 @@
<module name="afd" type="kernelmodedriver">
<importlibrary definition="afd.def" />
<include base="afd">include</include>
<include base="ReactOS">include/afd</include>
<define name="__USE_W32API" />
<library>ntoskrnl</library>
<library>hal</library>
<library>pseh</library>
<directory name="afd">
<file>bind.c</file>
<file>connect.c</file>
<file>context.c</file>
<file>info.c</file>
<file>listen.c</file>
<file>lock.c</file>
<file>main.c</file>
<file>read.c</file>
<file>select.c</file>
<file>tdi.c</file>
<file>tdiconn.c</file>
<file>write.c</file>
</directory>
<file>afd.rc</file>
</module>
+3
View File
@@ -0,0 +1,3 @@
<directory name="afd">
<xi:include href="afd/afd.xml" />
</directory>
+4
View File
@@ -1 +1,5 @@
#ifdef __USE_W32API
#include_next <ndis.h>
#else
#include "net/ndis.h"
#endif
+1
View File
@@ -1,4 +1,5 @@
<module name="ntoskrnl" type="kernel">
<importlibrary definition="ntoskrnl.def" />
<dependency>buildno</dependency>
<dependency>genntdll</dependency>
<dependency>wmc</dependency>
@@ -640,6 +640,13 @@ MingwModuleHandler::GenerateArchiveTarget ( const Module& module,
return archiveFilename;
}
string
MingwModuleHandler::GetCFlagsMacro ( const Module& module ) const
{
return ssprintf ( "$(%s_CFLAGS)",
module.name.c_str () );
}
string
MingwModuleHandler::GetObjectsMacro ( const Module& module ) const
{
@@ -658,7 +665,8 @@ void
MingwModuleHandler::GenerateMacrosAndTargets (
const Module& module,
const string& cc,
const string& ar ) const
const string& ar,
const string* cflags ) const
{
string cflagsMacro = ssprintf ("%s_CFLAGS", module.name.c_str ());
string nasmflagsMacro = ssprintf ("%s_NASMFLAGS", module.name.c_str ());
@@ -673,12 +681,20 @@ MingwModuleHandler::GenerateMacrosAndTargets (
linkerFlagsMacro,
objectsMacro );
if ( cflags != NULL )
{
fprintf ( fMakefile,
"%s += %s\n\n",
cflagsMacro.c_str (),
cflags->c_str () );
}
// generate phony target for module name
fprintf ( fMakefile, ".PHONY: %s\n",
module.name.c_str() );
module.name.c_str () );
fprintf ( fMakefile, "%s: %s\n\n",
module.name.c_str(),
module.GetPath().c_str() );
module.name.c_str (),
module.GetPath ().c_str () );
// future references to the macros will be to get their values
cflagsMacro = ssprintf ("$(%s)", cflagsMacro.c_str ());
@@ -710,13 +726,21 @@ MingwModuleHandler::GenerateMacrosAndTargets (
void
MingwModuleHandler::GenerateMacrosAndTargetsHost ( const Module& module ) const
{
GenerateMacrosAndTargets ( module, "${host_gcc}", "${host_ar}" );
GenerateMacrosAndTargets ( module, "${host_gcc}", "${host_ar}", NULL );
}
void
MingwModuleHandler::GenerateMacrosAndTargetsTarget ( const Module& module ) const
{
GenerateMacrosAndTargets ( module, "${gcc}", "${ar}" );
GenerateMacrosAndTargetsTarget ( module,
NULL );
}
void
MingwModuleHandler::GenerateMacrosAndTargetsTarget ( const Module& module,
const string* clags ) const
{
GenerateMacrosAndTargets ( module, "${gcc}", "${ar}", clags );
}
string
@@ -857,6 +881,22 @@ MingwModuleHandler::GeneratePreconditionDependencies ( const Module& module ) co
fprintf ( fMakefile, "\n" );
}
void
MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ( const Module& module ) const
{
if ( module.importLibrary != NULL )
{
fprintf ( fMakefile, "%s:\n",
module.GetDependencyPath ().c_str () );
fprintf ( fMakefile,
"\t${dlltool} --dllname %s --def %s --output-lib %s --kill-at\n\n",
module.GetTargetName ().c_str (),
FixupTargetFilename ( module.GetBasePath () + SSEP + module.importLibrary->definition ).c_str (),
FixupTargetFilename ( module.GetDependencyPath () ).c_str () );
}
}
static MingwBuildToolModuleHandler buildtool_handler;
@@ -922,6 +962,8 @@ MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module& module )
GenerateMacrosAndTargetsTarget ( module );
GenerateImportLibraryTargetIfNeeded ( module );
fprintf ( fMakefile, "%s: %s %s\n",
target.c_str (),
objectsMacro.c_str (),
@@ -1005,19 +1047,9 @@ MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ( const Modul
string archiveFilename = GetModuleArchiveFilename ( module );
string importLibraryDependencies = GetImportLibraryDependencies ( module );
if (module.importLibrary != NULL)
{
fprintf ( fMakefile, "%s:\n",
module.GetDependencyPath ().c_str () );
GenerateImportLibraryTargetIfNeeded ( module );
fprintf ( fMakefile,
"\t${dlltool} --dllname %s --def %s --output-lib %s --kill-at\n\n",
module.GetTargetName ().c_str (),
FixupTargetFilename ( module.GetBasePath () + SSEP + module.importLibrary->definition ).c_str (),
FixupTargetFilename ( module.GetDependencyPath () ).c_str () );
}
if (module.files.size () > 0)
if ( module.files.size () > 0 )
{
GenerateMacrosAndTargetsTarget ( module );
@@ -1045,6 +1077,63 @@ MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ( const Modul
}
static MingwKernelModeDriverModuleHandler kernelmodedriver_handler;
MingwKernelModeDriverModuleHandler::MingwKernelModeDriverModuleHandler ()
: MingwModuleHandler ( KernelModeDriver )
{
}
void
MingwKernelModeDriverModuleHandler::Process ( const Module& module )
{
GeneratePreconditionDependencies ( module );
GenerateKernelModeDriverModuleTarget ( module );
GenerateInvocations ( module );
}
void
MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ( const Module& module )
{
static string ros_junk ( "$(ROS_TEMPORARY)" );
string target ( FixupTargetFilename ( module.GetPath () ) );
string workingDirectory = GetWorkingDirectory ( );
string archiveFilename = GetModuleArchiveFilename ( module );
string importLibraryDependencies = GetImportLibraryDependencies ( module );
GenerateImportLibraryTargetIfNeeded ( module );
if ( module.files.size () > 0 )
{
string* cflags = new string ( "-D__NTDRIVER__" );
GenerateMacrosAndTargetsTarget ( module,
cflags );
delete cflags;
fprintf ( fMakefile, "%s: %s %s\n",
target.c_str (),
archiveFilename.c_str (),
importLibraryDependencies.c_str () );
string linkerParameters ( "-Wl,--subsystem,native -Wl,--entry,_DriverEntry@8 -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll" );
string linkerCommand = GenerateLinkerCommand ( module,
"${gcc}",
linkerParameters,
archiveFilename );
fprintf ( fMakefile,
"\t%s\n\n",
linkerCommand.c_str () );
}
else
{
fprintf ( fMakefile, "%s:\n",
target.c_str ());
fprintf ( fMakefile, ".PHONY: %s\n\n",
target.c_str ());
}
}
static MingwNativeDLLModuleHandler nativedll_handler;
MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler ()
@@ -1068,20 +1157,10 @@ MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ( const Module& modul
string workingDirectory = GetWorkingDirectory ( );
string archiveFilename = GetModuleArchiveFilename ( module );
string importLibraryDependencies = GetImportLibraryDependencies ( module );
GenerateImportLibraryTargetIfNeeded ( module );
if (module.importLibrary != NULL)
{
fprintf ( fMakefile, "%s:\n",
module.GetDependencyPath ().c_str () );
fprintf ( fMakefile,
"\t${dlltool} --dllname %s --def %s --output-lib %s --kill-at\n\n",
module.GetTargetName ().c_str (),
FixupTargetFilename ( module.GetBasePath () + SSEP + module.importLibrary->definition ).c_str (),
FixupTargetFilename ( module.GetDependencyPath () ).c_str () );
}
if (module.files.size () > 0)
if ( module.files.size () > 0 )
{
GenerateMacrosAndTargetsTarget ( module );
@@ -1133,19 +1212,9 @@ MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ( const Module& module
string archiveFilename = GetModuleArchiveFilename ( module );
string importLibraryDependencies = GetImportLibraryDependencies ( module );
if (module.importLibrary != NULL)
{
fprintf ( fMakefile, "%s:\n",
module.GetDependencyPath ().c_str () );
GenerateImportLibraryTargetIfNeeded ( module );
fprintf ( fMakefile,
"\t${dlltool} --dllname %s --def %s --output-lib %s --kill-at\n\n",
module.GetTargetName ().c_str (),
FixupTargetFilename ( module.GetBasePath () + SSEP + module.importLibrary->definition ).c_str (),
FixupTargetFilename ( module.GetDependencyPath () ).c_str () );
}
if (module.files.size () > 0)
if ( module.files.size () > 0 )
{
GenerateMacrosAndTargetsTarget ( module );
@@ -1197,7 +1266,9 @@ MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ( const Module& module
string objectFilenames = GetObjectFilenames ( module );
string importLibraryDependencies = GetImportLibraryDependencies ( module );
if (module.files.size () > 0)
GenerateImportLibraryTargetIfNeeded ( module );
if ( module.files.size () > 0 )
{
GenerateMacrosAndTargetsTarget ( module );
@@ -32,16 +32,20 @@ protected:
std::string GetObjectFilenames ( const Module& module ) const;
void GenerateMacrosAndTargetsHost ( const Module& module ) const;
void GenerateMacrosAndTargetsTarget ( const Module& module ) const;
void GenerateMacrosAndTargetsTarget ( const Module& module,
const std::string* clags ) const;
std::string GetInvocationDependencies ( const Module& module ) const;
std::string GetInvocationParameters ( const Invoke& invoke ) const;
void GenerateInvocations ( const Module& module ) const;
void GeneratePreconditionDependencies ( const Module& module ) const;
std::string GetCFlagsMacro ( const Module& module ) const;
std::string GetObjectsMacro ( const Module& module ) const;
std::string GetLinkerMacro ( const Module& module ) const;
std::string GenerateLinkerCommand ( const Module& module,
const std::string& linker,
const std::string& linkerParameters,
const std::string& objectFilenames ) const;
void GenerateImportLibraryTargetIfNeeded ( const Module& module ) const;
static FILE* fMakefile;
private:
std::string ConcatenatePaths ( const std::string& path1,
@@ -115,7 +119,8 @@ private:
const std::string& objs_macro ) const;
void GenerateMacrosAndTargets ( const Module& module,
const std::string& cc,
const std::string& ar ) const;
const std::string& ar,
const std::string* clags ) const;
std::string GetPreconditionDependenciesName ( const Module& module ) const;
};
@@ -160,6 +165,16 @@ private:
};
class MingwKernelModeDriverModuleHandler : public MingwModuleHandler
{
public:
MingwKernelModeDriverModuleHandler ();
virtual void Process ( const Module& module );
private:
void GenerateKernelModeDriverModuleTarget ( const Module& module );
};
class MingwNativeDLLModuleHandler : public MingwModuleHandler
{
public:
+24 -12
View File
@@ -8,10 +8,9 @@ using std::vector;
Include::Include ( const Project& project_,
const XMLElement& includeNode )
: project(project_),
module(NULL),
node(includeNode),
base(NULL)
: project (project_),
module (NULL),
node (includeNode)
{
Initialize();
}
@@ -19,10 +18,9 @@ Include::Include ( const Project& project_,
Include::Include ( const Project& project_,
const Module* module_,
const XMLElement& includeNode )
: project(project_),
module(module_),
node(includeNode),
base(NULL)
: project (project_),
module (module_),
node (includeNode)
{
Initialize();
}
@@ -48,13 +46,27 @@ Include::ProcessXML()
throw InvalidBuildFileException (
node.location,
"'base' attribute illegal from global <include>" );
base = project.LocateModule ( att->value );
if ( !base )
bool referenceResolved = false;
if ( att->value == project.name )
{
basePath = ".";
referenceResolved = true;
}
else
{
const Module* base = project.LocateModule ( att->value );
if ( base != NULL )
{
basePath = base->GetBasePath ();
referenceResolved = true;
}
}
if ( !referenceResolved )
throw InvalidBuildFileException (
node.location,
"<include> attribute 'base' references non-existant module '%s'",
"<include> attribute 'base' references non-existant project or module '%s'",
att->value.c_str() );
directory = FixSeparator ( base->GetBasePath() + "/" + node.value );
directory = FixSeparator ( basePath + "/" + node.value );
}
else
directory = FixSeparator ( node.value );
+4
View File
@@ -214,6 +214,8 @@ Module::GetModuleType ( const string& location, const XMLAttribute& attribute )
return Kernel;
if ( attribute.value == "kernelmodedll" )
return KernelModeDLL;
if ( attribute.value == "kernelmodedriver" )
return KernelModeDriver;
if ( attribute.value == "nativedll" )
return NativeDLL;
if ( attribute.value == "win32dll" )
@@ -241,6 +243,8 @@ Module::GetDefaultModuleExtension () const
case NativeDLL:
case Win32DLL:
return ".dll";
case KernelModeDriver:
return ".sys";
}
throw InvalidOperationException ( __FILE__,
__LINE__ );
+2 -1
View File
@@ -73,6 +73,7 @@ enum ModuleType
StaticLibrary,
Kernel,
KernelModeDLL,
KernelModeDriver,
NativeDLL,
Win32DLL,
Win32GUI
@@ -128,7 +129,7 @@ public:
const Module* module;
const XMLElement& node;
std::string directory;
const Module* base;
std::string basePath;
Include ( const Project& project,
const XMLElement& includeNode );