📄 tm1if_pc.c
字号:
RPCServ_SeekFunc seek,
RPCServ_IsattyFunc isatty,
RPCServ_FstatFunc fstat,
RPCServ_FcntlFunc fcntl,
RPCServ_StatFunc stat,
RPCServ_ExitFunc exit,
Endian endian
)
{
static WSADATA WSAData;
serving_stopped= False;
same_endian = endian==LCURRENT_ENDIAN;
WSAStartup(MAKEWORD(1, 1), &WSAData);
nrof_dsps= tmmanDSPGetNum();
nodedata= malloc( nrof_dsps * sizeof(NodeData) );
if (nodedata == Null) {
return False;
}
memset( nodedata, 0, nrof_dsps * sizeof(NodeData) );
MessageSynchHandle = CreateEvent( NULL, FALSE, FALSE, NULL );
if ( MessageSynchHandle == NULL ) {
return False;
}
return
RPCServ_init(
open,
open_dll,
close,
read,
write,
seek,
isatty,
fstat,
fcntl,
stat,
exit,
endian
);
}
/*
* Function : Add information on new node
* Parameters : node_number (I) Node number assigned to executable
* via TMDownLoader interface.
* argc, argv (I) Command line arguments
* Stdin,Stdout,Stderr (I) file descriptors to be used as
* standard file descriptors.
* NB: these must be legal parameter
* values for the IO functions
* address_shift (I) the difference between the virtual
* and physical address of the each location
* in the node's SDRAM, as seen from the host
* sdram_base (I) physical address of the node's SDRAM start
* sdram_limit (I) physical address of the node's SDRAM limit
* data (I) additional, monitor specific data
* Function Result : True iff add succeeded.
*/
static void terminate( NodeData *data )
{
data->valid= False;
tmmanMessageDestroy( data->hostcall_channel );
}
Bool TM1IF_add_node_info(
UInt32 node_number,
UInt32 argc,
String *argv,
UInt32 Stdin,
UInt32 Stdout,
UInt32 Stderr,
UInt32 address_shift,
UInt32 sdram_base,
UInt32 sdram_limit,
Pointer data
)
{
Int dsp_number;
NodeData *newdata;
dsp_number = (DWORD)data;
newdata = &nodedata[dsp_number];
newdata->dsp_number = dsp_number;
if (newdata->valid) {
return False;
}
if ( tmmanDSPOpen( dsp_number, &newdata->dsp_handle ) != statusSuccess
|| tmmanMessageCreate (
newdata->dsp_handle,
"CRunTime",
MessageSynchHandle,
constTMManModuleHostUser,
&newdata->hostcall_channel ) != statusSuccess
) {
return False;
}
if ( RPCServ_add_node_info(
node_number,
argc,
argv,
Stdin,
Stdout,
Stderr,
address_shift,
sdram_base,
sdram_limit,
terminate,
newdata
)) {
newdata->valid= True;
return True;
} else {
terminate(newdata);
return False;
}
}
/*
* Function : Remove information on node, when present.
* Parameters : node_number (I) Node number assigned to executable
* via TMDownLoader interface.
* Function Result : -
*/
void TM1IF_remove_node_info( UInt32 node_number )
{
RPCServ_remove_node_info(node_number);
}
/*
* Function : Stops and deletes the previously started
* TM-1 application serving task(s), and return
* *after* they have been stopped (this makes sure
* that the servers stopped writing into TM memory).
* Parameters :
* Function Result :
* Precondition : -
* Postcondition : -
* Sideeffects :
*/
void TM1IF_term()
{
Int32 i;
serving_stopped= True;
SetEvent ( MessageSynchHandle );
WaitForMultipleObjects( nrof_created_servers, created_servers, TRUE, 2000 );
CloseHandle ( MessageSynchHandle );
RPCServ_term();
WSACleanup();
free( created_servers );
free( nodedata );
}
/*
* Function : Allocate a range of pagelocked memory,
* and return scatter information.
* Parameters : node_number (I) allocating node
* size (I) size to allocate
* address (O) returned virtual start address,
* or Null when pagelocked allocation failed
* scatter (O) an array of scatter block descriptors,
* to contain the returned scatter desctiptor
* size (IO) input: capacity of 'scatter', in nrof entries
* output: number of scatter entries of result
* Function Result : -
*/
void TM1IF_malloc_pagelocked(
UInt node_number,
UInt size,
Pointer *retval,
HostCall_MemoryBlock *scatter,
UInt *scatter_size )
{
*retval= Null;
}
/*
* Function : Free a range of pagelocked memory.
* Parameters : node_number (I) freeing node
* address (I) virtual start address of previously
* allocated pagelocked memory
* Function Result : -
*/
void TM1IF_free_pagelocked( UInt node_number, Pointer address )
{
}
UInt32 TM1IF_endian_swap( UInt32 value )
{
return (same_endian
? value
: LIENDIAN_SWAP4(value));
}
UInt32 TM1IF_endian_swap_short (UInt32 value)
{
return same_endian? value: LIENDIAN_SWAP2 (value);
}
Address TM1IF_tm2host( RPCServ_NodeInfo *ninfo, Address tm_address )
{
return (tm_address == Null
? Null
: (Address)(TM1IF_endian_swap((Int32)tm_address)+ninfo->address_shift));
}
Address TM1IF_host2tm( RPCServ_NodeInfo *ninfo, Address host_address )
{
return (host_address == Null
? Null
: (Address)TM1IF_endian_swap(((Int32)host_address)-ninfo->address_shift));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -