Add support for host based protocol code

This commit is contained in:
MelwareDE 2011-04-13 10:39:05 +00:00
parent c4bc7f524b
commit c5a0982ee5
8 changed files with 32 additions and 13 deletions

View File

@ -217,7 +217,8 @@ void capi_DivaStreamingOn(struct capi_pvt *i, byte streamCommand, _cword message
ret = diva_stream_create (&pE->diva_stream, NULL, 255, divaStreamingMessageRx, pE, trace_ident);
if (ret == 0) {
byte* description = (byte*)pE->diva_stream->description (pE->diva_stream);
static byte addie[] = { 0x2d, 0x01, 0x00, 0x00 };
byte* description = (byte*)pE->diva_stream->description (pE->diva_stream, addie, (byte)sizeof(addie));
MESSAGE_EXCHANGE_ERROR error;
description[1] = streamCommand;

View File

@ -33,7 +33,7 @@ typedef struct _diva_segment_alloc_access {
void* (*segment_alloc)(struct _diva_segment_alloc* ifc, dword* lo, dword* hi);
void (*segment_free)(struct _diva_segment_alloc* ifc, void* addr, dword lo, dword hi);
dword (*get_segment_length)(struct _diva_segment_alloc* ifc);
void* (*map_address)(struct _diva_segment_alloc* ifc, dword lo, dword hi);
void* (*map_address)(struct _diva_segment_alloc* ifc, dword lo, dword hi, int map_host);
void* (*umap_address)(struct _diva_segment_alloc* ifc, dword lo, dword hi, void* local);
int (*write_address)(struct _diva_segment_alloc* ifc, dword lo, dword hi, dword data);
void (*resource_removed)(struct _diva_segment_alloc* ifc);

View File

@ -50,7 +50,7 @@ typedef struct _diva_streaming_idi_host_ifc_w_access {
dword (*get_free)(const struct _diva_streaming_idi_host_ifc_w* ifc);
dword (*get_length)(const struct _diva_streaming_idi_host_ifc_w* ifc);
byte (*description)(struct _diva_streaming_idi_host_ifc_w* ifc, byte* dst, byte max_length);
int (*init)(struct _diva_streaming_idi_host_ifc_w* ifc, dword version, dword counter);
int (*init)(struct _diva_streaming_idi_host_ifc_w* ifc, dword version, dword counter, dword info);
diva_streaming_idi_result_t (*sync)(struct _diva_streaming_idi_host_ifc_w* ifc, dword ident);
diva_streaming_idi_result_t (*trace_ident)(struct _diva_streaming_idi_host_ifc_w* ifc);
} diva_streaming_idi_host_ifc_w_access_t;

View File

@ -43,7 +43,7 @@ static int write_message (struct _diva_streaming_idi_host_ifc_w* ifc,
const void* data,
dword data_length);
static byte description (diva_streaming_idi_host_ifc_w_t* ifc, byte* dst, byte max_length);
static int init (struct _diva_streaming_idi_host_ifc_w* ifc, dword version, dword counter);
static int init (struct _diva_streaming_idi_host_ifc_w* ifc, dword version, dword counter, dword info);
static diva_streaming_idi_result_t sync_req (struct _diva_streaming_idi_host_ifc_w* ifc, dword ident);
static int ack_data (struct _diva_streaming_idi_host_ifc_w* ifc, dword length);
static int ack_rx_data (struct _diva_streaming_idi_host_ifc_w* ifc, dword length, int flush_ack);
@ -322,13 +322,15 @@ static byte description (diva_streaming_idi_host_ifc_w_t* ifc, byte* dst, byte m
return (length);
}
static int init (struct _diva_streaming_idi_host_ifc_w* ifc, dword version, dword counter) {
static int init (struct _diva_streaming_idi_host_ifc_w* ifc, dword version, dword counter, dword info) {
diva_segment_alloc_access_t* segment_alloc_access = diva_get_segment_alloc_ifc (ifc->segment_alloc);
ifc->remote_counter_offset = counter % (4*1024);
ifc->remote_counter_base = counter - ifc->remote_counter_offset;
ifc->remote_counter_mapped_base = segment_alloc_access->map_address (ifc->segment_alloc, ifc->remote_counter_base, 0);
ifc->remote_counter_mapped_base = segment_alloc_access->map_address (ifc->segment_alloc,
ifc->remote_counter_base, 0,
(info & DIVA_STREAMING_MANAGER_HOST_USER_MODE_STREAM) != 0);
if (ifc->remote_counter_mapped_base != 0) {
byte* p = ifc->remote_counter_mapped_base;
ifc->remote_counter_mapped = (dword*)&p[ifc->remote_counter_offset];

View File

@ -253,7 +253,7 @@ static int diva_streaming_idi_host_rx_process_message (struct _diva_streaming_id
DBG_TRC(("version:%u counter:%08x info:%08x [%s]", version, counter, info, ifc->trace_ident))
ifc->tx_ifc->init (ifc->tx, version, counter);
ifc->tx_ifc->init (ifc->tx, version, counter, info);
ifc->tx_ifc->trace_ident (ifc->tx);
ifc->notify_user_proc (ifc->user_context, DIVA_STREAM_MESSAGE_INIT << 8 | 0xffU, 0, 0, 0);
}

View File

@ -57,7 +57,7 @@ static diva_streaming_idi_result_t diva_stream_manager_release (struct _diva_str
static diva_streaming_idi_result_t diva_stream_manager_release_stream (struct _diva_stream* ifc);
static diva_streaming_idi_result_t diva_stream_manager_write (struct _diva_stream* ifc, dword message, const void* data, dword length);
static diva_streaming_idi_result_t diva_stream_manager_wakeup (struct _diva_stream* ifc);
static const byte* diva_stream_manager_description (struct _diva_stream* ifc);
static const byte* diva_stream_manager_description (struct _diva_stream* ifc, const byte* addie, byte addielen);
static diva_streaming_idi_result_t diva_stream_manager_sync_req (struct _diva_stream* ifc, dword ident);
static diva_streaming_idi_result_t diva_stream_flush (struct _diva_stream* ifc);
static dword diva_stream_get_tx_free (const struct _diva_stream* ifc);
@ -193,7 +193,7 @@ static diva_streaming_idi_result_t diva_stream_manager_wakeup (struct _diva_stre
return (pI->rx_ifc->wakeup (pI->rx));
}
const byte* diva_stream_manager_description (struct _diva_stream* ifc) {
const byte* diva_stream_manager_description (struct _diva_stream* ifc, const byte* addie, byte addielen) {
diva_stream_manager_t* pI = DIVAS_CONTAINING_RECORD(ifc, diva_stream_manager_t, ifc);
byte length = 4, len_tx, len_rx;
@ -209,6 +209,21 @@ const byte* diva_stream_manager_description (struct _diva_stream* ifc) {
pI->description[2] = len_rx+len_tx+1; /* Structure length */
pI->description[3] = 0; /* Version */
if (addie != 0 && addielen != 0) {
byte* description = &pI->description[0];
byte* start = &description[3];
start[0] |= 2U;
start = start + start[-1];
memcpy (start, addie, addielen);
start += addielen;
*start++ = 0;
description[2] += addielen+1;
description[0] += addielen+1;
length += addielen+1;
}
DBG_TRC(("description length %u [%s]", length, pI->trace_ident))
DBG_BLK(((void*)pI->description, length))

View File

@ -33,7 +33,7 @@ typedef struct _diva_stream {
diva_streaming_idi_result_t (*release_stream)(struct _diva_stream* ifc); /**< destroy stream */
diva_streaming_idi_result_t (*write)(struct _diva_stream* ifc, dword message, const void* data, dword length); /**< write data to stream */
diva_streaming_idi_result_t (*wakeup)(struct _diva_stream* ifc);
const byte* (*description)(struct _diva_stream* ifc);
const byte* (*description)(struct _diva_stream* ifc, const byte* addie, byte addielength);
diva_streaming_idi_result_t (*sync)(struct _diva_stream* ifc, dword ident);
diva_streaming_idi_result_t (*flush_stream)(struct _diva_stream* ifc);
dword (*get_tx_free)(const struct _diva_stream* ifc);
@ -57,6 +57,7 @@ typedef struct _diva_stream {
#define DIVA_STREAM_MESSAGE_INIT_ERROR 0x00000007 /** Stream init error */
#define DIVA_STREAM_MESSAGE_RELEASED 0x00000008 /** Not message, used internally */
#define DIVA_STREAMING_MANAGER_HOST_USER_MODE_STREAM 0x40000000U
diva_streaming_idi_result_t diva_stream_create_with_user_segment_alloc (struct _diva_stream** ifc,
void* os_context,

View File

@ -80,7 +80,7 @@ static dword get_segment_length_proc(struct _diva_segment_alloc*);
#if defined(DIVA_USERMODE)
static int map_entry (struct _diva_segment_alloc* pI, diva_map_entry_t* pE);
#endif
static void* map_address (struct _diva_segment_alloc* ifc, dword lo, dword hi);
static void* map_address (struct _diva_segment_alloc* ifc, dword lo, dword hi, int map_host);
static void* umap_address (struct _diva_segment_alloc* ifc, dword lo, dword hi, void* local);
static int write_address (struct _diva_segment_alloc* ifc, dword lo, dword hi, dword data);
static void resource_removed (struct _diva_segment_alloc* ifc);
@ -331,14 +331,14 @@ static int map_entry (struct _diva_segment_alloc* pI, diva_map_entry_t* pE) {
}
#endif
static void* map_address (struct _diva_segment_alloc* pI, dword lo, dword hi) {
static void* map_address (struct _diva_segment_alloc* pI, dword lo, dword hi, int map_host) {
void* ret = 0;
#if defined(DIVA_USERMODE)
#if defined(LINUX)
qword addr = ((qword)lo) | (((qword)hi) << 32);
ret = mmap (0, 4*1024, PROT_READ|PROT_WRITE, MAP_SHARED, pI->fd_mem, addr);
ret = mmap (0, 4*1024, PROT_READ|PROT_WRITE, MAP_SHARED, (map_host == 0) ? pI->fd_mem : pI->fd, addr);
if (ret == ((void*)-1)) {
ret = 0;
}