📄 hostif_pc.c
字号:
/*
* +-------------------------------------------------------------------+
* | Copyright (c) 1995,1996,1997 by Philips Semiconductors. |
* | |
* | This software is furnished under a license and may only be used |
* | and copied in accordance with the terms and conditions of such a |
* | license and with the inclusion of this copyright notice. This |
* | software or any other copies of this software may not be provided |
* | or otherwise made available to any other person. The ownership |
* | and title of this software is not transferred. |
* | |
* | The information in this software is subject to change without |
* | any prior notice and should not be construed as a commitment by |
* | Philips Semiconductors. |
* | |
* | This code and information is provided "as is" without any |
* | warranty of any kind, either expressed or implied, including but |
* | not limited to the implied warranties of merchantability and/or |
* | fitness for any particular purpose. |
* +-------------------------------------------------------------------+
*
*
* Module name : HostIF_pc.c 1.2
*
* Last update : 13:05:40 - 97/10/09
*
* Title : Low level WinNT communication, TM-1 part
*
* Reviewed :
*
* Revision history :
*
* Description :
*
* This module is part of an implementation of the HostCall interface.
* HostCall is the software component which is required by
* the TCS toolset to adapt the programs generated by this toolset
* to a specific host (see file HostCall.h in the TCS include dir).
*
* HostIF is one of two modules which form an implementation of
* the HostCall interface (the other one is RPCClient), and provides
* the necessary communication layer.
* This communication layer consists of functions for sending and
* receiving pointer values to/from the RPCServer running on the
* host.
*
* The implementation of HostCall is partitioned between RPCClient
* and HostIF as follows:
*
* - _HostCall_notify is provided in HostIF
* - _HostCall_host_send is provided in RPCClient.
* - _HostCall_init and -terminate are provided in RPCClient.
* - Module RPCClient provides the general implementation strategy
* and solves all cache problems.
* - HostIF provides a simple communication interface for sending
* pointers hence and forth.
* - RPCClient communicates with a RPCServer on the host.
*
* More specific, HostIF should provide for the following:
*
* 1) It must implement functions _HostIF_init and _HostIF_term,
* for whatever initialisation and termination is needed.
* 2) It must implement a function _HostIF_send for sending a pointer
* (to a command buffer) to the RPCServer on the host.
* This function must return a success status.
* 3) It must be able to receive similar pointers from the
* RPCServer on the host, which must each be passed to a call
* to function _RPCClient_notify.
* 4) A debug print routine to whatever destination
*
* This is an HostIF implementation for communicating with
* an RPCServer running on a PC under the Windows NT OS.
* This module is implemented on top of the TM Manager.
*/
/*----------------------------includes----------------------------------------*/
#include "HostIF.h"
#include <stdarg.h>
#include <tmlib/tmtypes.h>
#include <tmlib/dprintf.h>
#include "tmmanapi.h"
#include "tmmanerr.h"
/*-----------------------------module state-----------------------------------*/
static UInt32 hostcall_channel; /* Created communication channel */
/*----------------------------functions---------------------------------------*/
Bool _HostIF_send( Pointer command )
{
tmmanPacket packet;
packet.Argument[0]= (UInt32)command;
while (tmmanMessageSend(hostcall_channel, &packet) == statusChannelMailboxFullError) ;
return True;
}
/*--------------------------- Initialisation / Termination -------------------*/
static TMStatus notify()
{
tmmanPacket Packet;
while (tmmanMessageReceive(hostcall_channel, &Packet) == statusSuccess) {
Pointer command = Packet.Argument[0];
_RPCClient_notify(command);
}
return statusSuccess;
}
Bool _HostIF_init()
{
UInt32 DSPHandle;
tmmanInit( 0, Null);
if ( tmmanDSPOpen ( 0, &DSPHandle ) != statusSuccess ) {
return False;
}
if ( tmmanMessageCreate (
DSPHandle,
"CRunTime", /* message ID - should be the same on the host */
(UInt32)notify,
constTMManModuleTargetCallback, /* Synchronizaton Flags */
&hostcall_channel ) != statusSuccess
) {
tmmanExit( 0 );
return False;
}
return True;
}
void _HostIF_term()
{
tmmanMessageDestroy ( hostcall_channel );
tmmanExit ( 0 );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -