Changes to allow building ring 0 or ring 3 (libc-based) libraries and unit tests for NetWare.
git-svn-id: https://svn.code.sf.net/p/flaim/code/trunk@508 0109f412-320b-0410-ab79-c3e0c5ffbbe6
This commit is contained in:
79
ftk/Makefile
79
ftk/Makefile
@@ -177,6 +177,7 @@ win_target =
|
||||
unix_target =
|
||||
netware_target =
|
||||
submake_targets =
|
||||
netware_ring_0_target =
|
||||
|
||||
# -- Enable command echoing --
|
||||
|
||||
@@ -346,6 +347,11 @@ ifneq (,$(findstring nlm,$(MAKECMDGOALS)))
|
||||
netware_target = yes
|
||||
target_os_family = netware
|
||||
host_os_family = win
|
||||
|
||||
ifneq (,$(findstring ring0,$(MAKECMDGOALS)))
|
||||
submake_targets += ring0
|
||||
netware_ring_0_target = yes
|
||||
endif
|
||||
endif
|
||||
|
||||
ifndef target_os_family
|
||||
@@ -1041,8 +1047,10 @@ ifdef netware_target
|
||||
|
||||
wc_dir := $(call normpath,$(wc_dir))
|
||||
|
||||
ifndef ndk_dir
|
||||
$(error Netware SDK could not be found. Please define ndk_dir)
|
||||
ifdef netware_ring_0_target
|
||||
ifndef ndk_dir
|
||||
$(error Netware SDK could not be found. Please define ndk_dir)
|
||||
endif
|
||||
endif
|
||||
|
||||
ndk_dir := $(call normpath,$(ndk_dir))
|
||||
@@ -1055,6 +1063,10 @@ ifdef netware_target
|
||||
ifneq ($(build),release)
|
||||
ccdefs += FLM_DEBUG
|
||||
endif
|
||||
|
||||
ifdef netware_ring_0_target
|
||||
ccdefs += FLM_RING_ZERO_NLM
|
||||
endif
|
||||
|
||||
ccflags += /ez /6s /w4 /za /zp1 /zq /zm /s /ei /of+ /we /bt=NETWARE
|
||||
|
||||
@@ -1075,7 +1087,43 @@ ifdef netware_target
|
||||
export wpp386 = /d$(subst $(sp), /d,$(strip $(ccdefs))) $(ccflags)
|
||||
export wcc386 = /d$(subst $(sp), /d,$(strip $(ccdefs))) $(ccflags)
|
||||
|
||||
define make_lis_file_cmd
|
||||
define make_ring_0_lis_file_cmd
|
||||
$(ec)$(gprintf) "option verbose\n" > $(4)
|
||||
$(ec)$(gprintf) "option stack=32k\n" >> $(4)
|
||||
$(ec)$(gprintf) "option synchronize\n" >> $(4)
|
||||
$(ec)$(gprintf) "option nod\n" >> $(4)
|
||||
$(ec)$(gprintf) "option map\n" >> $(4)
|
||||
$(ec)$(gprintf) "option nodefaultlibs\n" >> $(4)
|
||||
$(ec)$(gprintf) "option screenname 'NONE'\n" >> $(4)
|
||||
$(ec)$(gprintf) "option threadname '$(2)'\n" >> $(4)
|
||||
$(ec)$(gprintf) "option start = f_nlmEntryPoint\n" >> $(4)
|
||||
$(ec)$(gprintf) "option exit = f_nlmExitPoint\n" >> $(4)
|
||||
$(ec)$(gprintf) "option nodefaultlibs\n" >> $(4)
|
||||
$(ec)$(gprintf) "option pseudopreemption\n" >> $(4)
|
||||
$(ec)$(gprintf) "debug all debug novell\n" >> $(4)
|
||||
$(ec)$(gprintf) "form novell nlm '$(2)'\n" >> $(4)
|
||||
$(ec)$(gprintf) "name $(call ppath,$(1)/$(2)$(exe_suffix))\n" >> $(4)
|
||||
$(ec)$(gprintf) "file $(subst $(sp),\nfile ,$(call ppath,$(3)))\n" >> $(4)
|
||||
$(ec)$(gprintf) "library $(call ppath,$(ftk_static_lib))\n" >> $(4)
|
||||
$(ec)$(gprintf) "file $(call ppath,$(wc_dir)/lib386/plib3s.lib)(ctorarst)\n" >> $(4)
|
||||
$(ec)$(gprintf) "file $(call ppath,$(wc_dir)/lib386/plib3s.lib)(dtorarst)\n" >> $(4)
|
||||
$(ec)$(gprintf) "file $(call ppath,$(wc_dir)/lib386/plib3s.lib)(undefed)\n" >> $(4)
|
||||
$(ec)$(gprintf) "file $(call ppath,$(wc_dir)/lib386/plib3s.lib)(undefmbd)\n" >> $(4)
|
||||
$(ec)$(gprintf) "file $(call ppath,$(wc_dir)/lib386/plib3s.lib)(pure_err)\n" >> $(4)
|
||||
$(ec)$(gprintf) "file $(call ppath,$(wc_dir)/lib386/plib3s.lib)(stablcl)\n" >> $(4)
|
||||
$(ec)$(gprintf) "file $(call ppath,$(wc_dir)/lib386/plib3s.lib)(stabact)\n" >> $(4)
|
||||
$(ec)$(gprintf) "file $(call ppath,$(wc_dir)/lib386/plib3s.lib)(stabactv)\n" >> $(4)
|
||||
$(ec)$(gprintf) "file $(call ppath,$(wc_dir)/lib386/plib3s.lib)(stabmod)\n" >> $(4)
|
||||
$(ec)$(gprintf) "file $(call ppath,$(wc_dir)/lib386/plib3s.lib)(prwdata)\n" >> $(4)
|
||||
$(ec)$(gprintf) "file $(call ppath,$(wc_dir)/lib386/plib3s.lib)(moddtorr)\n" >> $(4)
|
||||
$(ec)$(gprintf) "file $(call ppath,$(wc_dir)/lib386/plib3s.lib)(stabadt)\n" >> $(4)
|
||||
$(ec)$(gprintf) "file $(call ppath,$(wc_dir)/lib386/netware/clib3s.lib)(i8d)\n" >> $(4)
|
||||
$(ec)$(gprintf) "file $(call ppath,$(wc_dir)/lib386/netware/clib3s.lib)(i8m)\n" >> $(4)
|
||||
$(ec)$(gprintf) "file $(call ppath,$(wc_dir)/lib386/netware/clib3s.lib)(i8s)\n" >> $(4)
|
||||
$(ec)$(gprintf) "alias __wcpp_4_fatal_runtime_error_=f_fatalRuntimeError\n" >> $(4)
|
||||
endef
|
||||
|
||||
define make_libc_lis_file_cmd
|
||||
$(ec)$(gprintf) "option verbose\n" > $(4)
|
||||
$(ec)$(gprintf) "option stack=32k\n" >> $(4)
|
||||
$(ec)$(gprintf) "option synchronize\n" >> $(4)
|
||||
@@ -1086,23 +1134,19 @@ ifdef netware_target
|
||||
$(ec)$(gprintf) "option threadname '$(2)'\n" >> $(4)
|
||||
$(ec)$(gprintf) "option start = _LibCPrelude\n" >> $(4)
|
||||
$(ec)$(gprintf) "option exit = _LibCPostlude\n" >> $(4)
|
||||
$(ec)$(gprintf) "option nodefaultlibs\n" >> $(4)
|
||||
$(ec)$(gprintf) "option pseudopreemption\n" >> $(4)
|
||||
$(ec)$(gprintf) "debug all debug novell\n" >> $(4)
|
||||
$(ec)$(gprintf) "form novell nlm '$(2)'\n" >> $(4)
|
||||
$(ec)$(gprintf) "name $(call ppath,$(1)/$(2)$(exe_suffix))\n" >> $(4)
|
||||
|
||||
$(ec)$(gprintf) "file $(subst $(sp),\nfile ,$(call ppath,$(3)))\n" >> $(4)
|
||||
$(ec)$(gprintf) "file $(call ppath,$(ndk_dir)/libc/imports/libcpre.obj)\n" >> $(4)
|
||||
$(ec)$(gprintf) "library $(call ppath,$(ftk_static_lib))\n" >> $(4)
|
||||
$(ec)$(gprintf) "library $(call ppath,$(wc_dir)/lib386/plib3s.lib)\n" >> $(4)
|
||||
$(ec)$(gprintf) "library $(call ppath,$(wc_dir)/lib386/netware/libc3s.lib)\n" >> $(4)
|
||||
$(ec)$(gprintf) "import CurrentProcess\n" >> $(4)
|
||||
$(ec)$(gprintf) "import @$(call ppath,$(ndk_dir)/libc/imports/libc.imp)\n" >> $(4)
|
||||
$(ec)$(gprintf) "import @$(call ppath,$(ndk_dir)/libc/imports/netware.imp)\n" >> $(4)
|
||||
$(ec)$(gprintf) "import @$(call ppath,$(ndk_dir)/libc/imports/ws2nlm.imp)\n" >> $(4)
|
||||
endef
|
||||
|
||||
define make_imp_file_cmd
|
||||
|
||||
define make_ring_0_imp_file_cmd
|
||||
$(ec)$(gprintf) "import __WSAFDIsSet\n" > $(1)
|
||||
$(ec)$(gprintf) "import ActivateScreen\n" >> $(1)
|
||||
$(ec)$(gprintf) "import Alloc\n" >> $(1)
|
||||
@@ -1253,9 +1297,16 @@ ifdef netware_target
|
||||
$(ec)$(gprintf) "import WSAStartup\n" >> $(1)
|
||||
endef
|
||||
|
||||
define make_libc_imp_file_cmd
|
||||
$(ec)$(gprintf) "import CurrentProcess\n" > $(1)
|
||||
$(ec)$(gprintf) "import @$(call ppath,$(ndk_dir)/libc/imports/libc.imp)\n" >> $(1)
|
||||
$(ec)$(gprintf) "import @$(call ppath,$(ndk_dir)/libc/imports/netware.imp)\n" >> $(1)
|
||||
$(ec)$(gprintf) "import @$(call ppath,$(ndk_dir)/libc/imports/ws2nlm.imp)\n" >> $(1)
|
||||
endef
|
||||
|
||||
define flm_exe_link_cmd
|
||||
$(call make_imp_file_cmd,$(call hostpath,$(1)/$(2).imp))
|
||||
$(call make_lis_file_cmd,$(1),$(2),$(3),$(call hostpath,$(1)/$(2).lis))
|
||||
$(call $(if $(netware_ring_0_target),make_ring_0_imp_file_cmd,make_libc_imp_file_cmd),$(call hostpath,$(1)/$(2).imp))
|
||||
$(call $(if $(netware_ring_0_target),make_ring_0_lis_file_cmd,make_libc_lis_file_cmd),$(1),$(2),$(3),$(call hostpath,$(1)/$(2).lis))
|
||||
$(ec)$(call hostpath,$(exe_linker)) @$(call hostpath,$(1)/$(2).lis) @$(call hostpath,$(1)/$(2).imp)
|
||||
$(ec)$(call rmcmd,$(target_path)/$(1).lis)
|
||||
$(ec)$(call rmcmd,$(target_path)/$(1).imp)
|
||||
@@ -1676,6 +1727,10 @@ osx:
|
||||
nlm:
|
||||
$(ec)$(gprintf) ""
|
||||
|
||||
.PHONY : ring0
|
||||
ring0:
|
||||
$(ec)$(gprintf) ""
|
||||
|
||||
.PHONY : verbose
|
||||
verbose:
|
||||
$(ec)$(gprintf) ""
|
||||
|
||||
@@ -884,6 +884,10 @@
|
||||
void FLMAPI operator delete(
|
||||
void * ptr); ///< Pointer to object being freed.
|
||||
|
||||
/// Overloaded delete operator (array) for objects of this class.
|
||||
void FLMAPI operator delete[](
|
||||
void * ptr); ///< Pointer to array of objects being freed.
|
||||
|
||||
#ifndef FLM_WATCOM_NLM
|
||||
/// Overloaded delete operator for objects of this class (with source file and line number).
|
||||
/// This delete operator passes in the current file and line number. This information is
|
||||
@@ -939,6 +943,9 @@
|
||||
void operator delete(
|
||||
void * ptr);
|
||||
|
||||
void operator delete[](
|
||||
void * ptr);
|
||||
|
||||
#ifndef FLM_WATCOM_NLM
|
||||
void operator delete(
|
||||
void * ptr,
|
||||
@@ -5939,5 +5946,11 @@
|
||||
char * pszStr,
|
||||
FBUCKET * pHashTbl,
|
||||
FLMUINT uiNumBuckets);
|
||||
|
||||
FLMUINT FLMAPI f_binHashBucket(
|
||||
void * pBuf,
|
||||
FLMUINT uiBufLen,
|
||||
FBUCKET * pHashTbl,
|
||||
FLMUINT uiNumBuckets);
|
||||
|
||||
#endif // FTK_H
|
||||
|
||||
@@ -2384,7 +2384,7 @@ RCODE FLMAPI f_filetobuf(
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
if( RC_BAD( rc = f_alloc( ui64FileSize + 1, &pszBuffer)))
|
||||
if( RC_BAD( rc = f_alloc( (FLMUINT)(ui64FileSize + 1), &pszBuffer)))
|
||||
{
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
@@ -5597,6 +5597,20 @@ void F_Object::operator delete(
|
||||
f_freeImp( &ptr, TRUE);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Desc:
|
||||
****************************************************************************/
|
||||
void F_Object::operator delete[](
|
||||
void * ptr)
|
||||
{
|
||||
if( !ptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
f_freeImp( &ptr, TRUE);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Desc:
|
||||
****************************************************************************/
|
||||
@@ -5653,6 +5667,15 @@ void F_OSBase::operator delete(
|
||||
os_free( ptr);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Desc:
|
||||
*************************************************************************/
|
||||
void F_OSBase::operator delete[](
|
||||
void * ptr)
|
||||
{
|
||||
os_free( ptr);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Desc:
|
||||
****************************************************************************/
|
||||
|
||||
@@ -105,16 +105,18 @@ RCODE FLMAPI ftkStartup( void)
|
||||
flmAssert( FB2UD( "\x0A\x0B\x0C\x0D") == 0x0D0C0B0A);
|
||||
flmAssert( FB2UW( "\x0A\x0B") == 0x0B0A);
|
||||
|
||||
f_memoryInit();
|
||||
|
||||
#if defined( FLM_RING_ZERO_NLM)
|
||||
if( RC_BAD( rc = f_nssInitialize()))
|
||||
if( RC_BAD( rc = f_netwareStartup()))
|
||||
{
|
||||
goto Exit;
|
||||
}
|
||||
#endif
|
||||
|
||||
f_memoryInit();
|
||||
|
||||
#if !defined( FLM_RING_ZERO_NLM)
|
||||
f_assert( sizeof( f_va_list) == sizeof( va_list));
|
||||
#endif
|
||||
|
||||
if( RC_BAD( rc = f_initCharMappingTables()))
|
||||
{
|
||||
@@ -225,12 +227,11 @@ void FLMAPI ftkShutdown( void)
|
||||
|
||||
f_freeRandomGenerator();
|
||||
f_freeCharMappingTables();
|
||||
f_memoryCleanup();
|
||||
|
||||
#if defined( FLM_RING_ZERO_NLM)
|
||||
f_nssUninitialize();
|
||||
f_netwareShutdown();
|
||||
#endif
|
||||
|
||||
f_memoryCleanup();
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -2210,3 +2211,31 @@ FLMUINT FLMAPI f_strHashBucket(
|
||||
|
||||
return( uiHashIndex);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Desc: This routine determines the hash bucket for a binary array of
|
||||
characters.
|
||||
****************************************************************************/
|
||||
FLMUINT FLMAPI f_binHashBucket(
|
||||
void * pBuf,
|
||||
FLMUINT uiBufLen,
|
||||
FBUCKET * pHashTbl,
|
||||
FLMUINT uiNumBuckets)
|
||||
{
|
||||
FLMUINT uiHashIndex;
|
||||
FLMBYTE * ptr = (FLMBYTE *)pBuf;
|
||||
|
||||
if ((uiHashIndex = (FLMUINT)*ptr) >= uiNumBuckets)
|
||||
uiHashIndex -= uiNumBuckets;
|
||||
while (uiBufLen)
|
||||
{
|
||||
if ((uiHashIndex =
|
||||
(FLMUINT)((pHashTbl [uiHashIndex].uiHashValue) ^ (FLMUINT)(*ptr))) >=
|
||||
uiNumBuckets)
|
||||
uiHashIndex -= uiNumBuckets;
|
||||
ptr++;
|
||||
uiBufLen--;
|
||||
}
|
||||
return( uiHashIndex);
|
||||
}
|
||||
|
||||
|
||||
@@ -606,6 +606,13 @@
|
||||
static FLMATOMIC gv_NetWareStartupCount = 0;
|
||||
rtag_t gv_lAllocRTag = 0;
|
||||
|
||||
static FLMINT64 gv_NssRootKey;
|
||||
static FLMBOOL gv_bNSSKeyInitialized = FALSE;
|
||||
static SEMAPHORE gv_lFlmSyncSem = 0;
|
||||
static FLMBOOL gv_bUnloadCalled = FALSE;
|
||||
static FLMBOOL gv_bMainRunning = FALSE;
|
||||
static F_EXIT_FUNC gv_fnExit = NULL;
|
||||
|
||||
struct OldPerCpuStruct
|
||||
{
|
||||
unsigned long reserved0[24];
|
||||
@@ -650,11 +657,12 @@
|
||||
FLMINT lStatus,
|
||||
RCODE defaultRc);
|
||||
|
||||
FLMINT64 gv_NssRootKey;
|
||||
FLMBOOL gv_bNSSKeyInitialized = FALSE;
|
||||
|
||||
extern "C" int nlm_main(
|
||||
int iArgC,
|
||||
char ** ppszArgV);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
Desc:
|
||||
***************************************************************************/
|
||||
@@ -4004,9 +4012,8 @@ RCODE f_netwareStartup( void)
|
||||
|
||||
// Allocate the needed resource tags
|
||||
|
||||
if( (gv_lAllocRTag = AllocateResourceTag(
|
||||
gv_MyModuleHandle,
|
||||
"NOVDB Memory", AllocSignature)) == NULL)
|
||||
if( (gv_lAllocRTag = AllocateResourceTag( gv_MyModuleHandle,
|
||||
"FLAIM Memory", AllocSignature)) == NULL)
|
||||
{
|
||||
rc = RC_SET( NE_FLM_MEM);
|
||||
goto Exit;
|
||||
@@ -4019,7 +4026,6 @@ RCODE f_netwareStartup( void)
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
|
||||
Exit:
|
||||
|
||||
if( RC_BAD( rc))
|
||||
@@ -4044,7 +4050,7 @@ void f_netwareShutdown( void)
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
f_nssShutdown();
|
||||
f_nssUninitialize();
|
||||
|
||||
if( gv_lAllocRTag)
|
||||
{
|
||||
@@ -4096,6 +4102,397 @@ RCODE FLMAPI f_getcwd(
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
Desc:
|
||||
**********************************************************************/
|
||||
#if defined( FLM_RING_ZERO_NLM)
|
||||
extern "C" void f_fatalRuntimeError( void)
|
||||
{
|
||||
EnterDebugger();
|
||||
}
|
||||
#endif
|
||||
|
||||
/********************************************************************
|
||||
Desc: Startup routine for the NLM - that gets the main going in
|
||||
its own thread.
|
||||
*********************************************************************/
|
||||
#if defined( FLM_RING_ZERO_NLM)
|
||||
extern "C" static void * f_nlmMainStub(
|
||||
void * hThread,
|
||||
void * pData)
|
||||
{
|
||||
ARG_DATA * pArgData = (ARG_DATA *)pData;
|
||||
struct LoadDefinitionStructure * moduleHandle = pArgData->moduleHandle;
|
||||
|
||||
(void)hThread;
|
||||
|
||||
(void)kSetThreadName( (void *)kCurrentThread(),
|
||||
(BYTE *)pArgData->pszThreadName);
|
||||
|
||||
nlm_main( pArgData->iArgC, pArgData->ppszArgV);
|
||||
|
||||
Free( pArgData->ppszArgV);
|
||||
Free( pArgData->pszArgs);
|
||||
Free( pArgData->pszThreadName);
|
||||
Free( pArgData);
|
||||
|
||||
gv_bMainRunning = FALSE;
|
||||
|
||||
if (!gv_bUnloadCalled)
|
||||
{
|
||||
KillMe( moduleHandle);
|
||||
}
|
||||
|
||||
kExitThread( NULL);
|
||||
return( NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
/********************************************************************
|
||||
Desc: Startup routine for the NLM.
|
||||
*********************************************************************/
|
||||
#if defined( FLM_RING_ZERO_NLM)
|
||||
extern "C" LONG f_nlmEntryPoint(
|
||||
struct LoadDefinitionStructure * moduleHandle,
|
||||
struct ScreenStruct * initScreen,
|
||||
char * commandLine,
|
||||
char * loadDirectoryPath,
|
||||
LONG uninitializedDataLength,
|
||||
LONG fileHandle,
|
||||
LONG (*ReadRoutine)
|
||||
(LONG handle,
|
||||
LONG offset,
|
||||
char * buffer,
|
||||
LONG length),
|
||||
LONG customDataOffset,
|
||||
LONG customDataSize)
|
||||
{
|
||||
char * pszTmp;
|
||||
char * pszArgStart;
|
||||
int iArgC;
|
||||
int iTotalArgChars;
|
||||
int iArgSize;
|
||||
char ** ppszArgV = NULL;
|
||||
char * pszArgs = NULL;
|
||||
char * pszDestArg;
|
||||
bool bFirstPass = true;
|
||||
char cEnd;
|
||||
ARG_DATA * pArgData = NULL;
|
||||
LONG sdRet = 0;
|
||||
char * pszThreadName;
|
||||
int iTmpLen;
|
||||
void * hThread = NULL;
|
||||
|
||||
(void)initScreen;
|
||||
(void)uninitializedDataLength;
|
||||
(void)fileHandle;
|
||||
(void)ReadRoutine;
|
||||
(void)customDataOffset;
|
||||
(void)customDataSize;
|
||||
|
||||
if( f_atomicInc( &gv_NetWareStartupCount) != 1)
|
||||
{
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
gv_MyModuleHandle = moduleHandle;
|
||||
gv_bUnloadCalled = FALSE;
|
||||
|
||||
// Allocate the needed resource tags
|
||||
|
||||
if( (gv_lAllocRTag = AllocateResourceTag( gv_MyModuleHandle,
|
||||
"FLAIM Memory", AllocSignature)) == NULL)
|
||||
{
|
||||
sdRet = 1;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
// Syncronized start
|
||||
|
||||
if (moduleHandle->LDFlags & 4)
|
||||
{
|
||||
gv_lFlmSyncSem = kSemaphoreAlloc( (BYTE *)"NOVDB", 0);
|
||||
}
|
||||
|
||||
// Initialize NSS
|
||||
|
||||
if( RC_BAD( f_nssInitialize()))
|
||||
{
|
||||
sdRet = 1;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
// First pass: Count the arguments in the command line
|
||||
// and determine how big of a buffer we will need.
|
||||
// Second pass: Put argments into allocated buffer.
|
||||
|
||||
Parse_Args:
|
||||
|
||||
iTotalArgChars = 0;
|
||||
iArgC = 0;
|
||||
|
||||
iArgSize = f_strlen( (const char *)loadDirectoryPath);
|
||||
if (!bFirstPass)
|
||||
{
|
||||
ppszArgV [iArgC] = pszDestArg;
|
||||
f_memcpy( pszDestArg, loadDirectoryPath, iArgSize);
|
||||
pszDestArg [iArgSize] = 0;
|
||||
pszDestArg += (iArgSize + 1);
|
||||
}
|
||||
|
||||
iArgC++;
|
||||
iTotalArgChars += iArgSize;
|
||||
pszTmp = commandLine;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
// Skip leading blanks.
|
||||
|
||||
while ((*pszTmp) && (*pszTmp == ' '))
|
||||
{
|
||||
pszTmp++;
|
||||
}
|
||||
|
||||
if (!(*pszTmp))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if ((*pszTmp == '"') || (*pszTmp == '\''))
|
||||
{
|
||||
cEnd = *pszTmp;
|
||||
pszTmp++;
|
||||
}
|
||||
else
|
||||
{
|
||||
cEnd = ' ';
|
||||
}
|
||||
pszArgStart = pszTmp;
|
||||
iArgSize = 0;
|
||||
|
||||
// Count the characters in the parameter.
|
||||
|
||||
while ((*pszTmp) && (*pszTmp != cEnd))
|
||||
{
|
||||
iArgSize++;
|
||||
pszTmp++;
|
||||
}
|
||||
|
||||
if ((!iArgSize) && (cEnd == ' '))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// If 2nd pass, save the argument.
|
||||
|
||||
if (!bFirstPass)
|
||||
{
|
||||
ppszArgV [iArgC] = pszDestArg;
|
||||
if (iArgSize)
|
||||
{
|
||||
f_memcpy( pszDestArg, pszArgStart, iArgSize);
|
||||
}
|
||||
pszDestArg [iArgSize] = 0;
|
||||
pszDestArg += (iArgSize + 1);
|
||||
}
|
||||
|
||||
iArgC++;
|
||||
iTotalArgChars += iArgSize;
|
||||
|
||||
// Skip trailing quote or blank.
|
||||
|
||||
if (*pszTmp)
|
||||
{
|
||||
pszTmp++;
|
||||
}
|
||||
}
|
||||
|
||||
if (bFirstPass)
|
||||
{
|
||||
if ((ppszArgV = (char **)Alloc( sizeof( char *) * iArgC,
|
||||
gv_lAllocRTag)) == NULL)
|
||||
{
|
||||
sdRet = 1;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
if ((pszArgs = (char *)Alloc( iTotalArgChars + iArgC,
|
||||
gv_lAllocRTag)) == NULL)
|
||||
{
|
||||
sdRet = 1;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
pszDestArg = pszArgs;
|
||||
bFirstPass = false;
|
||||
goto Parse_Args;
|
||||
}
|
||||
|
||||
pszTmp = (char *)(&moduleHandle->LDName [1]);
|
||||
iTmpLen = (int)(moduleHandle->LDName [0]);
|
||||
|
||||
if ((pszThreadName = (char *)Alloc( iTmpLen + 1, gv_lAllocRTag)) == NULL)
|
||||
{
|
||||
sdRet = 1;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
f_memcpy( pszThreadName, pszTmp, iTmpLen);
|
||||
pszThreadName [iTmpLen] = 0;
|
||||
|
||||
if ((pArgData = (ARG_DATA *)Alloc( sizeof( ARG_DATA),
|
||||
gv_lAllocRTag)) == NULL)
|
||||
{
|
||||
sdRet = 1;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
pArgData->ppszArgV = ppszArgV;
|
||||
pArgData->pszArgs = pszArgs;
|
||||
pArgData->iArgC = iArgC;
|
||||
pArgData->moduleHandle = moduleHandle;
|
||||
pArgData->pszThreadName = pszThreadName;
|
||||
|
||||
gv_bMainRunning = TRUE;
|
||||
|
||||
if ((hThread = kCreateThread( (BYTE *)"FTK main",
|
||||
f_nlmMainStub, NULL, 32768,
|
||||
(void *)pArgData)) == NULL)
|
||||
{
|
||||
gv_bMainRunning = FALSE;
|
||||
sdRet = 2;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
if (kSetThreadLoadHandle( hThread, (LONG)moduleHandle) != 0)
|
||||
{
|
||||
(void)kDestroyThread( hThread);
|
||||
gv_bMainRunning = FALSE;
|
||||
sdRet = 2;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
if (kScheduleThread( hThread) != 0)
|
||||
{
|
||||
(void)kDestroyThread( hThread);
|
||||
gv_bMainRunning = FALSE;
|
||||
sdRet = 2;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
// Synchronized start
|
||||
|
||||
if (moduleHandle->LDFlags & 4)
|
||||
{
|
||||
(void)kSemaphoreWait( gv_lFlmSyncSem);
|
||||
}
|
||||
|
||||
Exit:
|
||||
|
||||
if (sdRet != 0)
|
||||
{
|
||||
f_atomicDec( &gv_NetWareStartupCount);
|
||||
|
||||
if (ppszArgV)
|
||||
{
|
||||
Free( ppszArgV);
|
||||
}
|
||||
|
||||
if (pszArgs)
|
||||
{
|
||||
Free( pszArgs);
|
||||
}
|
||||
|
||||
if (pszThreadName)
|
||||
{
|
||||
Free( pszThreadName);
|
||||
}
|
||||
|
||||
if (pArgData)
|
||||
{
|
||||
Free( pArgData);
|
||||
}
|
||||
|
||||
if (gv_lFlmSyncSem)
|
||||
{
|
||||
kSemaphoreFree( gv_lFlmSyncSem);
|
||||
gv_lFlmSyncSem = 0;
|
||||
}
|
||||
|
||||
if (!gv_bUnloadCalled)
|
||||
{
|
||||
KillMe( moduleHandle);
|
||||
}
|
||||
}
|
||||
|
||||
return( sdRet);
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
Desc:
|
||||
****************************************************************************/
|
||||
#if defined( FLM_RING_ZERO_NLM)
|
||||
extern "C" void f_nlmExitPoint(void)
|
||||
{
|
||||
if( f_atomicDec( &gv_NetWareStartupCount) > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
gv_bUnloadCalled = TRUE;
|
||||
|
||||
if( gv_fnExit)
|
||||
{
|
||||
(*gv_fnExit)();
|
||||
gv_fnExit = NULL;
|
||||
}
|
||||
|
||||
while( gv_bMainRunning)
|
||||
{
|
||||
kYieldThread();
|
||||
}
|
||||
|
||||
f_nssUninitialize();
|
||||
|
||||
if( gv_lFlmSyncSem)
|
||||
{
|
||||
kSemaphoreFree( gv_lFlmSyncSem);
|
||||
gv_lFlmSyncSem = 0;
|
||||
}
|
||||
|
||||
if( gv_lAllocRTag)
|
||||
{
|
||||
ReturnResourceTag( gv_lAllocRTag, 1);
|
||||
gv_lAllocRTag = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
Desc:
|
||||
****************************************************************************/
|
||||
#if defined( FLM_RING_ZERO_NLM)
|
||||
extern "C" void exit(
|
||||
int exitCode)
|
||||
{
|
||||
(void)exitCode;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
Desc:
|
||||
****************************************************************************/
|
||||
#if defined( FLM_RING_ZERO_NLM)
|
||||
extern "C" int atexit(
|
||||
F_EXIT_FUNC fnExit)
|
||||
{
|
||||
gv_fnExit = fnExit;
|
||||
return( 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // FLM_NLM
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
typedef FLMUINT16 uint16_t;
|
||||
typedef FLMBYTE uint8_t;
|
||||
|
||||
typedef void (* FLM_EXIT_FUNC)( void);
|
||||
typedef void (* F_EXIT_FUNC)( void);
|
||||
|
||||
#define TimerSignature 0x524D4954
|
||||
#define SemaphoreSignature 0x504D4553
|
||||
@@ -406,11 +406,11 @@
|
||||
/*************************************************************************
|
||||
Desc:
|
||||
*************************************************************************/
|
||||
typedef struct LoadDefStruct
|
||||
typedef struct LoadDefinitionStructure
|
||||
{
|
||||
struct LoadDefStruct * LDLink;
|
||||
struct LoadDefStruct * LDKillLink;
|
||||
struct LoadDefStruct * LDScanLink;
|
||||
struct LoadDefinitionStructure * LDLink;
|
||||
struct LoadDefinitionStructure * LDKillLink;
|
||||
struct LoadDefinitionStructure * LDScanLink;
|
||||
struct ResourceTagStructure * LDResourceList;
|
||||
LONG LDIdentificationNumber;
|
||||
LONG LDCodeImageOffset;
|
||||
@@ -500,7 +500,7 @@
|
||||
LONG MPKStubSize;
|
||||
LONG LDBuildNumber;
|
||||
void * LDExtensionData;
|
||||
} LoadDefStruct;
|
||||
} LoadDefinitionStructure;
|
||||
|
||||
/*************************************************************************
|
||||
Desc:
|
||||
@@ -641,11 +641,11 @@
|
||||
*************************************************************************/
|
||||
typedef struct
|
||||
{
|
||||
char ** ppszArgV;
|
||||
char * pszArgs;
|
||||
char * pszThreadName;
|
||||
int iArgC;
|
||||
LoadDefStruct * moduleHandle;
|
||||
char ** ppszArgV;
|
||||
char * pszArgs;
|
||||
char * pszThreadName;
|
||||
int iArgC;
|
||||
LoadDefinitionStructure * moduleHandle;
|
||||
} ARG_DATA;
|
||||
|
||||
/*************************************************************************
|
||||
@@ -876,7 +876,7 @@
|
||||
extern "C" LONG GetRunningProcess( void);
|
||||
|
||||
extern "C" void KillMe(
|
||||
LoadDefStruct * LoadRecord);
|
||||
LoadDefinitionStructure * LoadRecord);
|
||||
|
||||
extern "C" void NWYieldIfTime( void);
|
||||
|
||||
@@ -1167,7 +1167,7 @@
|
||||
extern "C" void * CFindLoadModuleHandle( void *);
|
||||
|
||||
extern "C" int atexit(
|
||||
FLM_EXIT_FUNC fnExit);
|
||||
F_EXIT_FUNC fnExit);
|
||||
|
||||
extern "C" LONG LoadModule(
|
||||
void * screenID,
|
||||
|
||||
@@ -1410,6 +1410,10 @@
|
||||
|
||||
void f_memoryCleanup( void);
|
||||
|
||||
RCODE f_netwareStartup( void);
|
||||
|
||||
void f_netwareShutdown( void);
|
||||
|
||||
void f_initFastCheckSum( void);
|
||||
|
||||
RCODE f_initCRCTable( void);
|
||||
|
||||
@@ -27,7 +27,11 @@
|
||||
/****************************************************************************
|
||||
Desc:
|
||||
****************************************************************************/
|
||||
#ifdef FLM_RING_ZERO_NLM
|
||||
extern "C" int nlm_main( void)
|
||||
#else
|
||||
int main( void)
|
||||
#endif
|
||||
{
|
||||
RCODE rc = NE_FLM_OK;
|
||||
IF_DirHdl * pDirHdl = NULL;
|
||||
|
||||
Reference in New Issue
Block a user