OpenCores
URL https://opencores.org/ocsvn/rio/rio/trunk

Subversion Repositories rio

[/] [rio/] [tags/] [1.0.1-release/] [sw/] [stack/] [riostack.h] - Blame information for rev 30

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 20 magro732
/*******************************************************************************
2
 *
3
 * RapidIO IP Library Core
4
 *
5
 * This file is part of the RapidIO IP library project
6
 * http://www.opencores.org/cores/rio/
7
 *
8
 * Description:
9
 * This file contains the function prototypes and types that are needed to be
10
 * able to use the riostack.c module.
11
 *
12
 * To Do:
13
 * -
14
 *
15
 * Author(s):
16
 * - Magnus Rosenius, magro732@opencores.org
17
 *
18
 *******************************************************************************
19
 *
20
 * Copyright (C) 2013 Authors and OPENCORES.ORG
21
 *
22
 * This source file may be used and distributed without
23
 * restriction provided that this copyright statement is not
24
 * removed from the file and that any derivative work contains
25
 * the original copyright notice and the associated disclaimer.
26
 *
27
 * This source file is free software; you can redistribute it
28
 * and/or modify it under the terms of the GNU Lesser General
29
 * Public License as published by the Free Software Foundation;
30
 * either version 2.1 of the License, or (at your option) any
31
 * later version.
32
 *
33
 * This source is distributed in the hope that it will be
34
 * useful, but WITHOUT ANY WARRANTY; without even the implied
35
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
36
 * PURPOSE. See the GNU Lesser General Public License for more
37
 * details.
38
 *
39
 * You should have received a copy of the GNU Lesser General
40
 * Public License along with this source; if not, download it
41
 * from http://www.opencores.org/lgpl.shtml
42
 *
43
 *******************************************************************************/
44
 
45
/**
46
 * \file riostack.h
47
 */
48
 
49
#ifndef _RIOSTACK_H
50
#define _RIOSTACK_H
51
 
52
/*******************************************************************************
53
 * Includes
54
 *******************************************************************************/
55
 
56
#include "rioconfig.h"
57
 
58
 
59
/*******************************************************************************
60
 * Global typedefs
61
 *******************************************************************************/
62
 
63
/* The maximum size of a RapidIO packet. */
64
#define RIO_PACKET_SIZE ((uint8_t)69u)
65
 
66
/* The size of a maximum sized RapidIO packet when stored in memory. */
67
/* One entry contains a header with the used buffer size. */
68
#define RIO_BUFFER_SIZE (RIO_PACKET_SIZE+1u)
69
 
70
/* Configuration space offsets. */
71
#define DEVICE_IDENTITY_CAR ((uint32_t)0x00000000ul)
72
#define DEVICE_INFORMATION_CAR ((uint32_t)0x00000004ul)
73
#define ASSEMBLY_IDENTITY_CAR ((uint32_t)0x00000008ul)
74
#define ASSEMBLY_INFORMATION_CAR ((uint32_t)0x0000000cul)
75
#define PROCESSING_ELEMENT_FEATURES_CAR ((uint32_t)0x00000010ul)
76
#define SWITCH_PORT_INFORMATION_CAR ((uint32_t)0x00000014ul)
77
#define SOURCE_OPERATIONS_CAR ((uint32_t)0x00000018ul)
78
#define DESTINATION_OPERATIONS_CAR ((uint32_t)0x0000001cul)
79
#define SWITCH_ROUTE_TABLE_DESTINATION_ID_LIMIT_CAR ((uint32_t)0x00000034ul)
80
#define PROCESSING_ELEMENT_LOGICAL_LAYER_CONTROL_CSR ((uint32_t)0x0000004cul)
81
#define BASE_DEVICE_ID_CSR ((uint32_t)0x00000060ul)
82
#define HOST_BASE_DEVICE_ID_LOCK_CSR ((uint32_t)0x00000068ul)
83
#define COMPONENT_TAG_CSR ((uint32_t)0x0000006cul)
84
#define STANDARD_ROUTE_CONFIGURATION_DESTINATION_ID_SELECT_CSR ((uint32_t)0x00000070ul)
85
#define STANDARD_ROUTE_CONFIGURATION_PORT_SELECT_CSR ((uint32_t)0x00000074ul)
86
#define STANDARD_ROUTE_DEFAULT_PORT_CSR ((uint32_t)0x00000078ul)
87
#define EXTENDED_FEATURES_OFFSET ((uint32_t)0x00000100ul)
88
#define IMPLEMENTATION_DEFINED_OFFSET ((uint32_t)0x00010000ul)
89
#define LP_SERIAL_REGISTER_BLOCK_HEADER(offset) (offset)
90
#define PORT_LINK_TIMEOUT_CONTROL_CSR(offset) ((offset) + 0x00000020ul)
91
#define PORT_RESPONSE_TIMEOUT_CONTROL_CSR(offset) ((offset) + 0x00000024ul)
92
#define PORT_GENERAL_CONTROL_CSR(offset) ((offset) + 0x0000003cul)
93
#define PORT_N_LOCAL_ACKID_CSR(offset, n) ((offset) + (0x00000048ul+((n)*0x00000020ul)))
94
#define PORT_N_ERROR_AND_STATUS_CSR(offset, n) ((offset) + (0x00000058ul+((n)*0x00000020ul)))
95
#define PORT_N_CONTROL_CSR(offset, n) ((offset) + (0x0000005cul+((n)*0x00000020ul)))
96
 
97
 
98
/* Define the different types of RioSymbols. */
99
typedef enum
100
{
101
  RIO_SYMBOL_TYPE_IDLE, RIO_SYMBOL_TYPE_CONTROL,
102
  RIO_SYMBOL_TYPE_DATA, RIO_SYMBOL_TYPE_ERROR
103
} RioSymbolType;
104
 
105
 
106
/*
107
 * RapidIO symbol definition.
108
 * Idle symbol: Sent when nothing else to send. Does not use the data field.
109
 * Control symbol: Sent when starting, ending and acknowleding a packet. Data
110
 * is right aligned, (Unused, C0, C1, C2) where C0 is transmitted/received first.
111
 * Data symbol: Sent to transfer packets. Uses the full data field, (D0, D1,
112
 * D2, D3) where D0 is transmitted/received first.
113
 * Error symbols are created when a symbols could not be created and the stack
114
 * should know about it.
115
 */
116
typedef struct
117
{
118
  RioSymbolType type;
119
  uint32_t data;
120
} RioSymbol;
121
 
122
 
123
/* Define different events that may happen in the stack. */
124
typedef enum
125
{
126
  RIO_EVENT_NONE,
127
  RIO_EVENT_NREAD, RIO_EVENT_NWRITE, RIO_EVENT_NWRITE_R,
128
  RIO_EVENT_DOORBELL, RIO_EVENT_MESSAGE,
129
  RIO_EVENT_MAINT_READ_REQUEST, RIO_EVENT_MAINT_WRITE_REQUEST,
130
  RIO_EVENT_MAINT_READ_RESPONSE, RIO_EVENT_MAINT_WRITE_RESPONSE,
131
  RIO_EVENT_RESPONSE_DONE, RIO_EVENT_RESPONSE_DONE_PAYLOAD,
132
  RIO_EVENT_RESPONSE_RETRY, RIO_EVENT_RESPONSE_ERROR,
133
  RIO_EVENT_MESSAGE_RESPONSE_DONE, RIO_EVENT_MESSAGE_RESPONSE_RETRY,
134
  RIO_EVENT_MESSAGE_RESPONSE_ERROR
135
} RioEventType;
136
 
137
 
138
/* Define different states the link may be in. */
139
typedef enum
140
{
141
  RIO_STATUS_UNINITIALIZED,
142
  RIO_STATUS_ENUMERATION,
143
  RIO_STATUS_OPERATIONAL
144
} RioStatusType;
145
 
146
 
147
/* Receiver states. */
148
typedef enum
149
{
150
  RX_STATE_UNINITIALIZED, RX_STATE_PORT_INITIALIZED, RX_STATE_LINK_INITIALIZED,
151
  RX_STATE_INPUT_RETRY_STOPPED, RX_STATE_INPUT_ERROR_STOPPED
152
} RioReceiverState;
153
 
154
 
155
/* Transmitter states. */
156
typedef enum
157
{
158
  TX_STATE_UNINITIALIZED, TX_STATE_PORT_INITIALIZED, TX_STATE_LINK_INITIALIZED,
159
  TX_STATE_SEND_PACKET_RETRY, TX_STATE_SEND_PACKET_NOT_ACCEPTED, TX_STATE_SEND_LINK_RESPONSE,
160
  TX_STATE_OUTPUT_RETRY_STOPPED, TX_STATE_OUTPUT_ERROR_STOPPED
161
} RioTransmitterState;
162
 
163
 
164
/* Queue definition. */
165
typedef struct
166
{
167
  uint8_t size;
168
  uint8_t available;
169
  uint8_t windowSize;
170
  uint8_t windowIndex;
171
  uint8_t frontIndex;
172
  uint8_t backIndex;
173
  uint32_t *buffer_p;
174
} Queue_t;
175
 
176
/* Forward declaration for the RioStack-structure. */
177
struct RioStack_t;
178
 
179
/* Structure to enter callback function pointers in. */
180
typedef struct
181
{
182
  uint32_t (*configRead)(struct RioStack_t *stack, uint32_t offset);
183
  void (*configWrite)(struct RioStack_t *stack, uint32_t offset, uint32_t data);
184
} RioStackObserver_t;
185
 
186
 
187
/* Define the structure to keep all the RapidIO stack variables. */
188
typedef struct RioStack_t
189
{
190
  /* Receiver variables. */
191
  RioReceiverState rxState;
192
  uint8_t rxCounter;
193
  uint16_t rxCrc;
194
  uint8_t rxStatusReceived;
195
  uint8_t rxAckId;
196
  uint8_t rxAckIdAcked;
197
  uint8_t rxErrorCause;
198
  Queue_t rxQueue;
199
 
200
  /* Transmitter variables. */
201
  RioTransmitterState txState;
202
  uint8_t txCounter;
203
  uint16_t txStatusCounter;
204
  uint8_t txFrameState;
205
  uint32_t txFrameTimeout[32];
206
  uint8_t txAckId;
207
  uint8_t txAckIdWindow;
208
  uint8_t txBufferStatus;
209
  Queue_t txQueue;
210
 
211
  /* Common protocol stack variables. */
212
  uint32_t portTime;
213
  uint32_t portTimeout;
214
 
215
  /* Common protocol stack variables updated visible via the configuration space. */
216
  uint16_t deviceIdentity;
217
  uint16_t deviceVendorIdentity;
218
  uint32_t deviceRev;
219
  uint16_t assyIdentity;
220
  uint16_t assyVendorIdentity;
221
  uint16_t assyRev;
222
  uint16_t baseDeviceId;
223
  uint32_t hostBaseDeviceIdLock;
224
  uint32_t componentTag;
225
  uint8_t host;
226
  uint8_t masterEnable;
227
  uint8_t discovered;
228
 
229
  /** The number of successfully received packets. */
230
  uint32_t statusInboundPacketComplete;
231
 
232
  /** The number of retried received packets.
233
      This will happen if the receiver does not have resources available when an inbound packet is received. */
234
  uint32_t statusInboundPacketRetry;
235
 
236
  /** The number of received erronous control symbols.
237
      This may happen if the inbound link has a high bit-error-rate. */
238
  uint32_t statusInboundErrorControlCrc;
239
 
240
  /** The number of received packets with an unexpected ackId.
241
      This may happen if the inbound link has a high bit-error-rate. */
242
  uint32_t statusInboundErrorPacketAckId;
243
 
244
  /** The number of received packets with a checksum error.
245
      This may happen if the inbound link has a high bit-error-rate. */
246
  uint32_t statusInboundErrorPacketCrc;
247
 
248
  /** The number of received symbols that contains an illegals character.
249
      This may happen if the inbound link has a high bit-error-rate or if characters are missing in the
250
      inbound character stream. */
251
  uint32_t statusInboundErrorIllegalCharacter;
252
 
253
  /** The number of general errors encountered at the receiver that does not fit into the other categories.
254
      This happens if too short or too long packets are received. */
255
  uint32_t statusInboundErrorGeneral;
256
 
257
  /** The number of received packets that were discarded since they were unsupported by the stack.
258
      This will happen if an inbound packet contains information that cannot be accessed using the function API
259
      of the stack. */
260
  uint32_t statusInboundErrorPacketUnsupported;
261
 
262
  /** The number of successfully transmitted packets. */
263
  uint32_t statusOutboundPacketComplete;
264
 
265
  /** The number of retried transmitted packets.
266
      This will happen if the receiver at the link-partner does not have resources available when an outbound
267
      packet is received. */
268
  uint32_t statusOutboundPacketRetry;
269
 
270
  /** The number of outbound packets that has had its retransmission timer expired.
271
      This happens if the latency of the system is too high or if a packet is corrupted due to a high
272
      bit-error-rate on the outbound link. */
273
  uint32_t statusOutboundErrorTimeout;
274
 
275
  /** The number of packet-accepted that was received that contained an unexpected ackId.
276
      This happens if the transmitter and the link-partner is out of synchronization, probably due
277
      to a software error. */
278
  uint32_t statusOutboundErrorPacketAccepted;
279
 
280
  /** The number of packet-retry that was received that contained an unexpected ackId.
281
      This happens if the transmitter and the link-partner is out of synchronization, probably due to
282
      a software error. */
283
  uint32_t statusOutboundErrorPacketRetry;
284
 
285
  /** The number of received link-requests.
286
      This happens if the link-partner transmitter has found an error and need to resynchronize itself
287
      to the receiver. */
288
  uint32_t statusPartnerLinkRequest;
289
 
290
  /** The number of received erronous control symbols at the link-partner receiver.
291
      This may happen if the outbound link has a high bit-error-rate. */
292
  uint32_t statusPartnerErrorControlCrc;
293
 
294
  /** The number of received packets with an unexpected ackId at the link-partner receiver.
295
      This may happen if the outbound link has a high bit-error-rate. */
296
  uint32_t statusPartnerErrorPacketAckId;
297
 
298
  /** The number of received packets with a checksum error at the link-partner receiver.
299
      This may happen if the outbound link has a high bit-error-rate. */
300
  uint32_t statusPartnerErrorPacketCrc;
301
 
302
  /** The number of received symbols that contains an illegals character at the link-parter receiver.
303
      This may happen if the outbound link has a high bit-error-rate or if characters are missing in the
304
      outbound character stream. */
305
  uint32_t statusPartnerErrorIllegalCharacter;
306
 
307
  /** The number of general errors encountered at the receiver that does not fit into the other categories.
308
      This happens depending on the link-partner implementation. */
309
  uint32_t statusPartnerErrorGeneral;
310
 
311
  /* Callback structure. */
312
  const RioStackObserver_t *observer;
313
 
314
  /* Private user data. */
315
  const void *private;
316
} RioStack_t;
317
 
318
 
319
/*******************************************************************************
320
 * Global function prototypes
321
 *******************************************************************************/
322
 
323
/**
324
 * \brief Open the RapidIO stack for operation.
325
 *
326
 * \param[in] stack Stack instance to operate on.
327
 * \param[in] observer Callback structure to use when events happen.
328
 * \param[in] private Pointer to an opaque data area containing private user data.
329
 * \param[in] rxPacketBufferSize Number of words to use as reception buffer. This
330
 *            argument specifies the size of rxPacketBuffer.
331
 * \param[in] rxPacketBuffer Pointer to buffer to store inbound packets in.
332
 * \param[in] txPacketBufferSize Number of words to use as transmission buffer. This
333
 *            argument specifies the size of txPacketBuffer.
334
 * \param[in] txPacketBuffer Pointer to buffer to store outbound packets in.
335
 * \param[in] configDeviceVendorId Constant to use as deviceVendorIdentity when
336
 *            accessed in configuration space. (See Part 1, chapter 5.4.1)
337
 * \param[in] configDeviceId Constant to use as deviceIdentity when accessed in
338
 *            configuration space. (See Part 1, chapter 5.4.1)
339
 * \param[in] configDeviceRevisionId Constant to use as deviceRev when accessed in
340
 *            configuration space. (See Part 1, chapter 5.4.2)
341
 * \param[in] configAssyVendorId Constant to use as assyVendorIdentity when accessed in
342
 *            configuration space. (See Part 1, chapter 5.4.3)
343
 * \param[in] configAssyId Constant to use as assyIdentity when accessed in
344
 *            configuration space. (See Part 1, chapter 5.4.3)
345
 * \param[in] configAssyRevisionId Constant to use as assyRev when accessed in
346
 *            configuration space. (See Part 1, chapter 5.4.4)
347
 * \param[in] configBaseDeviceId The deviceId (source address) to use at startup when
348
 *            sending packets.
349
 *
350
 * This function initializes all internally used variables in the stack. The stack will
351
 * however not be operational until the transcoder has signalled that it is ready for
352
 * other symbols than idle. This is done using the function RIO_setPortStatus(). Once
353
 * this function has been called it is possible to get and set symbols and to issue
354
 * requests. The requests will be transmitted once the link initialization has
355
 * been completed.
356
 *
357
 * The rxPacket/txPacket arguments are word buffers that are used internally to store the
358
 * inbound and outbound packet queues.
359
 *
360
 * The config argument constants are used as identification when maintenance packets
361
 * are received and replied to. They should be set to make the device where the stack
362
 * is used easily identifiable on the net.
363
 *
364
 * \note The reception buffers can only support maximum 31 buffers.
365
 */
366
void RIO_open( RioStack_t *stack, const RioStackObserver_t *observer, const void *private,
367
               const uint32_t rxPacketBufferSize, uint32_t *rxPacketBuffer,
368
               const uint32_t txPacketBufferSize, uint32_t *txPacketBuffer,
369
               const uint16_t configDeviceVendorId, const uint16_t configDeviceId,
370
               const uint32_t configDeviceRevisionId, const uint16_t configAssyVendorId,
371
               const uint16_t configAssyId, const uint16_t configAssyRevisionId,
372
               const uint16_t configBaseDeviceId );
373
 
374
/*******************************************************************************************
375
 * Stack status functions.
376
 * Note that status counters are access directly in the stack-structure.
377
 *******************************************************************************************/
378
 
379
/**
380
 * \brief Get the status of the link.
381
 *
382
 * \param[in] stack The stack to operate on.
383
 * \return Returns the status of the link.
384
 *
385
 * This function indicates if the link is up and ready to relay packets.
386
 */
387
RioStatusType RIO_getStatus( RioStack_t *stack );
388
 
389
/**
390
 * \brief Get the number of pending outbound packets.
391
 *
392
 * \param[in] stack The stack to operate on.
393
 * \return Returns the number of pending outbound packets.
394
 *
395
 * This function checks the outbound queue and returns the number of packets
396
 * that are pending to be transmitted onto the link.
397
 */
398
uint8_t RIO_outboundQueueLength( RioStack_t *stack );
399
 
400
/**
401
 * \brief Get the number of pending inbound packets.
402
 *
403
 * \param[in] stack The stack to operate on.
404
 * \return Returns the number of pending inbound packets.
405
 *
406
 * This function checks the inbound queue and returns the number of packets
407
 * that has been received but not read by the user yet.
408
 */
409
uint8_t RIO_inboundQueueLength( RioStack_t *stack );
410
 
411
/*******************************************************************************************
412
 * Packet reception functions.
413
 *******************************************************************************************/
414
 
415
/**
416
 * \brief Check for new events.
417
 *
418
 * \param[in] stack The stack to operate on.
419
 * \return Returns the value RIO_EVENT_NONE if no event is pending and
420
 * something else if there are pending events.
421
 *
422
 * This function polls the incoming queue of packets and returns the
423
 * type of packet present there. The return value from this function
424
 * indicates which access functions that should be used to read the
425
 * received packet.
426
 *
427
 * \note When a packet has been processed, RIO_packetRemove() must be called to free the
428
 * used resources in the inbound queue.
429
 */
430
RioEventType RIO_eventPoll( RioStack_t *stack );
431
 
432
/**
433
 * \brief Remove a packet from the stack.
434
 * \param[in] stack The stack to operate on.
435
 *
436
 * Remove a pending packet from the stack. The incoming packet queue is updated
437
 * to remove the received packet.
438
 */
439
void RIO_packetRemove( RioStack_t *stack );
440
 
441
/**
442
 * \brief Check transmission buffers.
443
 *
444
 * \param[in] stack The stack to operate on.
445
 * \param[in] size The size of the buffer that is about to be sent.
446
 * \return Returns non-zero if a buffer with the specified size fits into the
447
 * internal transmission buffers.
448
 *
449
 * Return if there are buffers available to send a packet of a specified size.
450
 *
451
 * \note If the response is negative, it might be positive later if outbound
452
 * packets has been sent and new buffers becomes available.
453
 *
454
 * \note Set size to zero if there is no user definded payload.
455
 */
456
bool_t RIO_sendAvailable( RioStack_t *stack, const uint16_t size );
457
 
458
/**
459
 * \brief Get a raw packet from inbound queue.
460
 *
461
 * \param[in] stack The stack to operate on.
462
 * \param[in] length The size of the buffer to write the packet to.
463
 * \param[in] dest Pointer to where to copy the raw packet.
464
 * \return The number of words copied.
465
 *
466
 * This function copies a raw packet in the inbound queue into a word buffer. An assert
467
 * will occur if the packet does not fit into the provided buffer.
468
 *
469
 * \note The packet is automatically removed from the inbound queue. Do not use
470
 * RIO_packetRemove() to remove it.
471
 */
472
uint32_t RIO_packetGet( RioStack_t *stack, uint32_t length, uint32_t *dest);
473
 
474
/**
475
 * \brief Set a raw packet in outbound queue.
476
 *
477
 * \param[in] stack The stack to operate on.
478
 * \param[in] length The size of the packet to write.
479
 * \param[in] src Pointer to where to copy the raw packet from.
480
 *
481
 * This function copies a raw packet from a source buffer into the outbound queue.
482
 * An assert will occur if the packet does not fit into the internal buffer.
483
 *
484
 * \note Calling this function resembles a send-function, the packet will be placed in the
485
 * outbound queue for transmission.
486
 *
487
 * \note If the copied packet does not have a correct CRC it might lock the stack since
488
 * retransmissions will be done until forever.
489
 */
490
void RIO_packetSet( RioStack_t *stack, uint32_t length, uint32_t *src);
491
 
492
/*******************************************************************************************
493
 * Configuration-space access methods.
494
 *******************************************************************************************/
495
 
496
/**
497
 * \brief Read configuration space.
498
 *
499
 * \param[in] stack The stack to operate on.
500
 * \param[in] offset The configuration space address to read.
501
 * \return The data read on the configuration space address specified.
502
 *
503
 * This function reads a configuration space offset and returns the content of
504
 * the entry.
505
 */
506
uint32_t RIO_readConfig( RioStack_t *stack, const uint32_t offset );
507
 
508
/**
509
 * \brief Write configuration space.
510
 *
511
 * \param[in] stack The stack to operate on.
512
 * \param[in] offset The configuration space address to write to.
513
 * \param[in] data The data to write to the configuration space.
514
 *
515
 * This function writes to a configuration space offset and sets the
516
 * content to the specified data.
517
 */
518
void RIO_writeConfig( RioStack_t *stack, const uint32_t offset, const uint32_t data);
519
 
520
/*******************************************************************************************
521
 * Logical I/O MAINTENANCE-READ functions.
522
 *******************************************************************************************/
523
 
524
/**
525
 * \brief Send a maintenance read request.
526
 *
527
 * \param[in] stack The stack to operate on.
528
 * \param[in] destid The device id of the destination end point.
529
 * \param[in] tid The transaction id to be returned in the response.
530
 * \param[in] hopCount The hop_count to set in the read request.
531
 * \param[in] offset The byte address in the configuration space to read.
532
 *
533
 * This function creates and sends a maintenance read request packet.
534
 *
535
 * \note Call RIO_sendAvailable() before this function is called to make sure
536
 * the outbound queue has transmission buffers available.
537
 */
538
#ifdef RIO_TRANSPARENT
539
void RIO_sendMaintenanceReadRequest(RioStack_t *stack, const uint16_t destid, const uint16_t srcid, const uint8_t tid,
540
                                    const uint8_t hopCount, const uint32_t offset );
541
#else
542
void RIO_sendMaintenanceReadRequest(RioStack_t *stack, const uint16_t destid, const uint8_t tid,
543
                                    const uint8_t hopCount, const uint32_t offset );
544
#endif
545
 
546
/**
547
 * \brief Read a received maintenance read request.
548
 *
549
 * \param[in] stack The stack to operate on.
550
 * \param[out] srcid The device id of the destination end point.
551
 * \param[out] tid The transaction id to be returned in the response.
552
 * \param[out] hopCount The hop_count to set in the read request.
553
 * \param[out] offset The byte address in the configuration space to read.
554
 *
555
 * This function reads a received maintenance read request packet.
556
 *
557
 * \note In normal operational mode, the stack answers maintenance requests
558
 * automatically without user intervention. This function should only be
559
 * called if the stack is compiled in transparent mode.
560
 */
561
#ifdef RIO_TRANSPARENT
562
void RIO_receiveMaintenanceReadRequest(RioStack_t *stack, uint16_t *destid, uint16_t *srcid, uint8_t *tid,
563
                                       uint8_t *hopCount, uint32_t *offset);
564
#else
565
void RIO_receiveMaintenanceReadRequest(RioStack_t *stack, uint16_t *srcid, uint8_t *tid,
566
                                       uint8_t *hopCount, uint32_t *offset);
567
#endif
568
 
569
/**
570
 * \brief Send a maintenance read response.
571
 *
572
 * \param[in] stack The stack to operate on.
573
 * \param[in] destid The device id of the destination end point.
574
 * \param[in] tid The transaction id to be returned in the response.
575
 * \param[in] hopCount The hop_count to set in the read request.
576
 * \param[in] data The data to send in the response.
577
 *
578
 * This function creates a maintanance read response packet that should be
579
 * sent when a request is received.
580
 *
581
 * \note Call RIO_sendAvailable() before this function is called to make sure
582
 * the outbound queue has transmission buffers available.
583
 *
584
 * \note In normal operational mode, the stack answers maintenance requests
585
 * automatically without user intervention. This function should only be
586
 * called if the stack is compiled in transparent mode.
587
 */
588
#ifdef RIO_TRANSPARENT
589
void RIO_sendMaintenanceReadResponse( RioStack_t *stack, const uint16_t destid, const uint16_t srcid, const uint8_t tid,
590
                                      const uint8_t hopCount, const uint32_t data);
591
#else
592
void RIO_sendMaintenanceReadResponse( RioStack_t *stack, const uint16_t destid, const uint8_t tid,
593
                                      const uint8_t hopCount, const uint32_t data);
594
#endif
595
 
596
/**
597
 * \brief Read a received maintenance read response.
598
 *
599
 * \param[in] stack The stack to operate on.
600
 * \param[out] srcid The device id of the source end point.
601
 * \param[out] tid The transaction id in the response.
602
 * \param[out] hopCount The hop_count set in the read response.
603
 * \param[out] data The data in the response.
604
 *
605
 * This function reads a received maintanance read response packet.
606
 */
607
#ifdef RIO_TRANSPARENT
608
void RIO_receiveMaintenanceReadResponse( RioStack_t *stack, uint16_t *destid, uint16_t *srcid, uint8_t *tid,
609
                                         uint8_t *hopCount, uint32_t *data);
610
#else
611
void RIO_receiveMaintenanceReadResponse( RioStack_t *stack, uint16_t *srcid, uint8_t *tid,
612
                                         uint8_t *hopCount, uint32_t *data);
613
#endif
614
 
615
/*******************************************************************************************
616
 * Logical I/O MAINTENANCE-WRITE functions.
617
 *******************************************************************************************/
618
 
619
/**
620
 * \brief Send a maintenance write request.
621
 *
622
 * \param[in] stack The stack to operate on.
623
 * \param[in] destid The device id of the destination end point.
624
 * \param[in] tid The transaction id to be returned in the response.
625
 * \param[in] hopCount The hop_count to set in the write request.
626
 * \param[in] offset The byte address in the configuration space to write to.
627
 * \param[in] data The data to write in configuration space.
628
 *
629
 * This function creates and sends a maintenance write request packet.
630
 *
631
 * \note Call RIO_sendAvailable() before this function is called to make sure
632
 * the outbound queue has transmission buffers available.
633
 */
634
#ifdef RIO_TRANSPARENT
635
void RIO_sendMaintenanceWriteRequest( RioStack_t *stack, const uint16_t destid, const uint16_t srcid, const uint8_t tid,
636
                                      const uint8_t hopCount, const uint32_t offset, const uint32_t data );
637
#else
638
void RIO_sendMaintenanceWriteRequest( RioStack_t *stack, const uint16_t destid, const uint8_t tid,
639
                                      const uint8_t hopCount, const uint32_t offset, const uint32_t data );
640
#endif
641
 
642
/**
643
 * \brief Read a received maintenance write request.
644
 *
645
 * \param[in] stack The stack to operate on.
646
 * \param[out] destid The device id of the destination end point.
647
 * \param[out] tid The transaction id to be returned in the response.
648
 * \param[out] hopCount The hop_count to set in the write request.
649
 * \param[out] offset The byte address in the configuration space to write to.
650
 * \param[out] data The data to write in configuration space.
651
 *
652
 * This function creates and sends a maintenance write request packet. The reply
653
 * is received using RIO_eventPoll-function and RIO_packetTid together with the return
654
 * value from this function.
655
 *
656
 * \note Call RIO_sendAvailable() before this function is called to make sure
657
 * the outbound queue has transmission buffers available.
658
 *
659
 * \note In normal operational mode, the stack answers maintenance requests
660
 * automatically without user intervention. This function should only be
661
 * called if the stack is compiled in transparent mode.
662
 */
663
#ifdef RIO_TRANSPARENT
664
void RIO_receiveMaintenanceWriteRequest( RioStack_t *stack, uint16_t *destid, uint16_t *srcid, uint8_t *tid,
665
                                         uint8_t *hopCount, uint32_t *offset, uint32_t *data );
666
#else
667
void RIO_receiveMaintenanceWriteRequest( RioStack_t *stack, uint16_t *srcid, uint8_t *tid,
668
                                         uint8_t *hopCount, uint32_t *offset, uint32_t *data );
669
#endif
670
 
671
/**
672
 * \brief Send a maintenance write response.
673
 *
674
 * \param[in] stack The stack to operate on.
675
 * \param[in] destid The device id of the destination end point.
676
 * \param[in] tid The transaction id to be returned.
677
 * \param[in] hopCount The hop_count to set in the write response.
678
 *
679
 * This function creates a maintanance write response packet from a pending
680
 * maintenance read request. The generated packet are placed in the outbound
681
 * packet queue.
682
 *
683
 * \note In normal operational mode, the stack answers maintenance requests
684
 * automatically without user intervention. This function should only be
685
 * called if the stack is compiled in transparent mode.
686
 */
687
#ifdef RIO_TRANSPARENT
688
void RIO_sendMaintenanceWriteResponse( RioStack_t *stack, const uint16_t destid, const uint16_t srcid, const uint8_t tid,
689
                                       const uint8_t hopCount);
690
#else
691
void RIO_sendMaintenanceWriteResponse( RioStack_t *stack, const uint16_t destid, const uint8_t tid,
692
                                       const uint8_t hopCount);
693
#endif
694
 
695
/**
696
 * \brief Read a received maintenance write response.
697
 *
698
 * \param[in] stack The stack to operate on.
699
 * \param[out] srcid The device id of the source end point.
700
 * \param[out] tid The transaction id read in the response.
701
 * \param[out] hopCount The hop_count read in the write response.
702
 *
703
 * This function creates a maintanance write response packet from a pending
704
 * maintenance read request. The generated packet are placed in the outbound
705
 * packet queue.
706
 *
707
 * \note In normal operational mode, the stack answers maintenance requests
708
 * automatically without user intervention. This function should only be
709
 * called if the stack is compiled in transparent mode.
710
 */
711
#ifdef RIO_TRANSPARENT
712
void RIO_receiveMaintenanceWriteResponse( RioStack_t *stack, uint16_t *destid, uint16_t *srcid, uint8_t *tid,
713
                                          uint8_t *hopCount);
714
#else
715
void RIO_receiveMaintenanceWriteResponse( RioStack_t *stack, uint16_t *srcid, uint8_t *tid,
716
                                          uint8_t *hopCount);
717
#endif
718
 
719
/*******************************************************************************************
720
 * Logical I/O NWRITE/NWRITER functions.
721
 *******************************************************************************************/
722
 
723
/**
724
 * \brief Send an NWRITE request to write a byte array.
725
 *
726
 * \param[in] stack The stack to operate on.
727
 * \param[in] destid The device id of the destination end point.
728
 * \param[in] address The byte address to write to.
729
 * \param[in] dataLength The number of bytes to write. The largest allowed size is 256 bytes.
730
 * \param[in] data A pointer to the array of bytes to write.
731
 *
732
 * This function creates and sends an NWRITE request packet to write a number
733
 * of bytes to a specified address. No reply will be received.
734
 *
735
 * \note The address is a byte address, not a word address.
736
 *
737
 * \note Call RIO_sendAvailable() before this function is called to make sure
738
 * the outbound queue has transmission buffers available.
739
 *
740
 * \note Not all combinations of addresses and sizes are allowed. See table below:
741
 * -------------------------------------------------------------------------------------
742
 * size | valid byte in double-word
743
 * -------------------------------------------------------------------------------------
744
 *   1  | 10000000, 01000000, 00100000, 00010000, 00001000, 00000100, 00000010, 00000001
745
 *   2  | 11000000, 00110000, 00001100, 00000011
746
 *   3  | 11100000, 00000111
747
 *   4  | 11110000, 00001111
748
 *   5  | 11111000, 00011111
749
 *   6  | 11111100, 00111111
750
 *   7  | 11111110, 01111111
751
 *  8*N | 11111111 (N={1...32})
752
 * --------------------------------------------------------------------------------------
753
 * See RapidIO 2.2 part1 table 4-4 for more details. Asserts will occurr if an invalid
754
 * combination is detected.
755
 */
756
#ifdef RIO_TRANSPARENT
757
void RIO_sendNwrite( RioStack_t *stack, const uint16_t destid, const uint16_t srcid,
758
                     const uint32_t address,  const uint16_t dataLength, const uint8_t *data );
759
#else
760
void RIO_sendNwrite( RioStack_t *stack, const uint16_t destid,
761
                     const uint32_t address,  const uint16_t dataLength, const uint8_t *data );
762
#endif
763
 
764
/**
765
 * \brief Send an NWRITER request to write a byte array.
766
 *
767
 * \param[in] stack The stack to operate on.
768
 * \param[in] destid The device id of the destination end point.
769
 * \param[in] tid The transaction id to set in the response.
770
 * \param[in] address The byte address to write to.
771
 * \param[in] dataLength The number of bytes to write. The largest allowed size is 256 bytes.
772
 * \param[in] data A pointer to the array of bytes to write.
773
 *
774
 * This function creates and sends an NWRITE request packet to write a number
775
 * of bytes to a specified address. A reply will be received when the write has been completed.
776
 *
777
 * \note The address is a byte address, not a word address.
778
 *
779
 * \note Call RIO_sendAvailable() before this function is called to make sure
780
 * the outbound queue has transmission buffers available.
781
 *
782
 * \note Not all combinations of addresses and sizes are allowed. See table below:
783
 * -------------------------------------------------------------------------------------
784
 * size | valid byte in double-word
785
 * -------------------------------------------------------------------------------------
786
 *   1  | 10000000, 01000000, 00100000, 00010000, 00001000, 00000100, 00000010, 00000001
787
 *   2  | 11000000, 00110000, 00001100, 00000011
788
 *   3  | 11100000, 00000111
789
 *   4  | 11110000, 00001111
790
 *   5  | 11111000, 00011111
791
 *   6  | 11111100, 00111111
792
 *   7  | 11111110, 01111111
793
 *  8*N | 11111111 (N={1...32})
794
 * --------------------------------------------------------------------------------------
795
 * See RapidIO 2.2 part1 table 4-4 for more details. Asserts will occurr if an invalid
796
 * combination is detected.
797
 */
798
#ifdef RIO_TRANSPARENT
799
void RIO_sendNwriteR( RioStack_t *stack, const uint16_t destid, const uint16_t srcid, const uint8_t tid,
800
                      const uint32_t address, const uint16_t dataLength, const uint8_t *data );
801
#else
802
void RIO_sendNwriteR( RioStack_t *stack, const uint16_t destid, const uint8_t tid,
803
                      const uint32_t address, const uint16_t dataLength, const uint8_t *data );
804
#endif
805
 
806
/**
807
 * \brief Read a received  NWRITE/NWRITER request.
808
 *
809
 * \param[in] stack The stack to operate on.
810
 * \param[out] srcid The device id of the destination end point.
811
 * \param[out] tid The transaction id in the response. Undefined value when NWRITE is read.
812
 * \param[out] address The byte address to write to.
813
 * \param[in] dataLength The number of bytes allocated in data.
814
 * \param[in] data A pointer to the array of bytes to copy to.
815
 * \return The number of bytes copied into data.
816
 *
817
 * This function reads a received NWRITE/NWRITER request packet to write a number
818
 * of bytes to a specified address. Used to receive both NWRITE and NWRITER. The payload
819
 * of the packet is copied into the provided buffer pointed to by data.
820
 *
821
 * \note The address is a byte address, not a word address.
822
 */
823
#ifdef RIO_TRANSPARENT
824
uint16_t RIO_receiveNwrite( RioStack_t *stack, uint16_t *destid, uint16_t *srcid, uint8_t *tid,
825
                            uint32_t *address, const uint16_t dataLength, uint8_t *data );
826
#else
827
uint16_t RIO_receiveNwrite( RioStack_t *stack, uint16_t *srcid, uint8_t *tid,
828
                            uint32_t *address, const uint16_t dataLength, uint8_t *data );
829
#endif
830
 
831
/*******************************************************************************************
832
 * Logical I/O NREAD functions.
833
 *******************************************************************************************/
834
 
835
/**
836
 * \brief Send an NREAD request to read a byte array.
837
 *
838
 * \param[in] stack The stack to operate on.
839
 * \param[in] destid The device id of the destination end point.
840
 * \param[in] tid The transaction id to set in the response.
841
 * \param[in] address The byte address to write to.
842
 * \param[in] dataLength The number of bytes to write. The largest allowed size is 256 bytes.
843
 *
844
 * This function creates and sends an NWRITE request packet to write a number
845
 * of bytes to a specified address. A reply will be received when the write has been completed.
846
 *
847
 * \note The address is a byte address, not a word address.
848
 *
849
 * \note Call RIO_sendAvailable() before this function is called to make sure
850
 * the outbound queue has transmission buffers available.
851
 *
852
 * \note Not all combinations of address and length are allowed. See table below:
853
 * -------------------------------------------------------------------------------------
854
 * size | valid byte in double-word
855
 * -------------------------------------------------------------------------------------
856
 *   1  | 10000000, 01000000, 00100000, 00010000, 00001000, 00000100, 00000010, 00000001
857
 *   2  | 11000000, 00110000, 00001100, 00000011
858
 *   3  | 11100000, 00000111
859
 *   4  | 11110000, 00001111
860
 *   5  | 11111000, 00011111
861
 *   6  | 11111100, 00111111
862
 *   7  | 11111110, 01111111
863
 * -------------------------------------------------------------------------------------
864
 * For full double-words the following byte sizes are allowed:
865
 *  8, 16, 32, 64, 96, 128, 160, 192, 224, 256
866
 * --------------------------------------------------------------------------------------
867
 * See RapidIO 2.2 part1 table 4-4 for more details. Asserts will occurr if an invalid
868
 * combination is detected.
869
 */
870
#ifdef RIO_TRANSPARENT
871
void RIO_sendNread( RioStack_t *stack, const uint16_t destid, const uint16_t srcid, const uint8_t tid,
872
                    const uint32_t address, const uint16_t dataLength);
873
#else
874
void RIO_sendNread( RioStack_t *stack, const uint16_t destid, const uint8_t tid,
875
                    const uint32_t address, const uint16_t dataLength);
876
#endif
877
 
878
/**
879
 * \brief Read a received  NREAD request.
880
 *
881
 * \param[in] stack The stack to operate on.
882
 * \param[out] srcid The device id of the destination end point.
883
 * \param[out] tid The transaction id in the response.
884
 * \param[out] address The byte address to write to.
885
 * \param[in] dataLength The number of bytes allocated in data.
886
 *
887
 * This function reads a received NREAD request packet to read a number
888
 * of bytes at a specified address.
889
 *
890
 * \note The address is a byte address, not a word address.
891
 */
892
#ifdef RIO_TRANSPARENT
893
void RIO_receiveNread( RioStack_t *stack, uint16_t *destid, uint16_t *srcid, uint8_t *tid,
894
                       uint32_t *address, uint16_t *dataLength);
895
#else
896
void RIO_receiveNread( RioStack_t *stack, uint16_t *srcid, uint8_t *tid,
897
                       uint32_t *address, uint16_t *dataLength);
898
#endif
899
 
900
/*******************************************************************************************
901
 * Logical I/O RESPONSE-DONE-PAYLOAD, RESPONSE-DONE, RESPONSE-RETRY and RESPONSE-ERROR
902
 * functions.
903
 *******************************************************************************************/
904
 
905
/**
906
 * \brief Send a response with data payload.
907
 *
908
 * \param[in] stack The stack to operate on.
909
 * \param[in] destid The destination identifier of the response.
910
 * \param[in] tid The transaction identifier for the reply. It should correspond to
911
 * the tid in the received packet for which this response is sent.
912
 * \param[in] address The byte address that was read. It should correspond to
913
 * the address in the received packet for which this response is sent.
914
 * \param[in] dataLength The size of the data buffer to return in the reply. It
915
 * should correspond to the dataLength in the received packet for which this response
916
 * is sent.
917
 * \param[in] data The data buffer to return in the reply.
918
 *
919
 * This function creates a response packet with the specified destination
920
 * identifier, transaction id and data payload. The generated packet are placed
921
 * in the outbound packet queue.
922
 *
923
 * \note Call RIO_sendAvailable() before this function is called to make sure
924
 * the outbound queue has transmission buffers available.
925
 */
926
#ifdef RIO_TRANSPARENT
927
void RIO_sendResponseDonePayload( RioStack_t *stack, const uint16_t destid, const uint16_t srcid, const uint8_t tid,
928
                                  const uint32_t address, const uint16_t dataLength, const uint8_t *data);
929
#else
930
void RIO_sendResponseDonePayload( RioStack_t *stack, const uint16_t destid, const uint8_t tid,
931
                                  const uint32_t address, const uint16_t dataLength, const uint8_t *data);
932
#endif
933
 
934
/**
935
 * \brief Read payload from a response with payload.
936
 *
937
 * \param[in] stack The stack to operate on.
938
 * \param[out] srcid The device id of the destination end point.
939
 * \param[out] tid The transaction id in the response.
940
 * \param[in] address The byte address that was read. It should correspond to
941
 * the address in the received packet for which this response is sent.
942
 * \param[in] dataLength The size of the data buffer to return in the reply. It
943
 * should correspond to the dataLength in the received packet for which this response
944
 * is sent.
945
 * \param[in] data Pointer to a buffer to where the data in the response will be copied.
946
 * \return The number of bytes copied from the data payload contained in the response.
947
 *
948
 * This function reads a response packet and returns a the byte payload contained within.
949
 */
950
#ifdef RIO_TRANSPARENT
951
uint16_t RIO_receiveResponseDonePayload( RioStack_t *stack, uint16_t *destid, uint16_t *srcid, uint8_t *tid,
952
                                         const uint32_t address, const uint16_t dataLength, uint8_t *data );
953
#else
954
uint16_t RIO_receiveResponseDonePayload( RioStack_t *stack, uint16_t *srcid, uint8_t *tid,
955
                                         const uint32_t address, const uint16_t dataLength, uint8_t *data );
956
#endif
957
 
958
/**
959
 * \brief Send a response.
960
 *
961
 * \param[in] stack The stack to operate on.
962
 * \param[in] destid The device identifier of the target to send the response to.
963
 * \param[in] tid The transaction id to send the response for. This should be the
964
 * same value as the packet that this response was received with.
965
 *
966
 * This function is used to send a response indicating a successfull
967
 * completion in reply to a previously received packet.
968
 *
969
 * \note Call RIO_sendAvailable() before this function is called to make sure
970
 * the outbound queue has transmission buffers available.
971
 */
972
#ifdef RIO_TRANSPARENT
973
void RIO_sendResponseDone( RioStack_t *stack, const uint16_t destid, const uint16_t srcid, const uint8_t tid );
974
 
975
#else
976
void RIO_sendResponseDone( RioStack_t *stack, const uint16_t destid, const uint8_t tid );
977
 
978
#endif
979
/**
980
 * \brief Read a received response.
981
 *
982
 * \param[in] stack The stack to operate on.
983
 * \param[out] srcid The device identifier of the source of the response.
984
 * \param[out] tid The transaction id in the response.
985
 *
986
 * This function is used to read a received response indicating a successfull
987
 * completion in reply to a previously sent packet.
988
 *
989
 * \note Call RIO_sendAvailable() before this function is called to make sure
990
 * the outbound queue has transmission buffers available.
991
 */
992
#ifdef RIO_TRANSPARENT
993
void RIO_receiveResponseDone( RioStack_t *stack, uint16_t *destid, uint16_t *srcid, uint8_t *tid );
994
 
995
#else
996
void RIO_receiveResponseDone( RioStack_t *stack, uint16_t *srcid, uint8_t *tid );
997
 
998
#endif
999
/**
1000
 * \brief Send a retry response.
1001
 *
1002
 * \param[in] stack The stack to operate on.
1003
 * \param[in] destid The device identifier of the target to send the response to.
1004
 * \param[in] tid The transaction id to send the response for. This should be the
1005
 * same value as the packet that this response was received with.
1006
 *
1007
 * This function is used to send a response indicating a busy resource
1008
 * in reply to a previously received packet.
1009
 *
1010
 * \note Call RIO_sendAvailable() before this function is called to make sure
1011
 * the outbound queue has transmission buffers available.
1012
 */
1013
#ifdef RIO_TRANSPARENT
1014
void RIO_sendResponseRetry( RioStack_t *stack, const uint16_t destid, const uint16_t srcid, const uint8_t tid );
1015
 
1016
#else
1017
void RIO_sendResponseRetry( RioStack_t *stack, const uint16_t destid, const uint8_t tid );
1018
 
1019
#endif
1020
/**
1021
 * \brief Read a received retry response.
1022
 *
1023
 * \param[in] stack The stack to operate on.
1024
 * \param[out] srcid The device identifier of the source of the response.
1025
 * \param[out] tid The transaction id in the response.
1026
 *
1027
 * This function is used to read a received response indicating a retry condition
1028
 * in reply to a previously sent packet.
1029
 *
1030
 * \note Call RIO_sendAvailable() before this function is called to make sure
1031
 * the outbound queue has transmission buffers available.
1032
 */
1033
#ifdef RIO_TRANSPARENT
1034
void RIO_receiveResponseRetry( RioStack_t *stack, uint16_t *destid, uint16_t *srcid, uint8_t *tid );
1035
 
1036
#else
1037
void RIO_receiveResponseRetry( RioStack_t *stack, uint16_t *srcid, uint8_t *tid );
1038
 
1039
#endif
1040
/**
1041
 * \brief Send a error response.
1042
 *
1043
 * \param[in] stack The stack to operate on.
1044
 * \param[in] destid The device identifier of the target to send the response to.
1045
 * \param[in] tid The transaction id to send the response for. This should be the
1046
 * same value as the packet that this response was received with.
1047
 *
1048
 * This function is used to send a response indicating a busy resource
1049
 * in reply to a previously received packet.
1050
 *
1051
 * \note Call RIO_sendAvailable() before this function is called to make sure
1052
 * the outbound queue has transmission buffers available.
1053
 */
1054
#ifdef RIO_TRANSPARENT
1055
void RIO_sendResponseError( RioStack_t *stack, const uint16_t destid, const uint16_t srcid, const uint8_t tid );
1056
#else
1057
void RIO_sendResponseError( RioStack_t *stack, const uint16_t destid, const uint8_t tid );
1058
#endif
1059
 
1060
/**
1061
 * \brief Read a received error response.
1062
 *
1063
 * \param[in] stack The stack to operate on.
1064
 * \param[out] srcid The device identifier of the source of the response.
1065
 * \param[out] tid The transaction id in the response.
1066
 *
1067
 * This function is used to read a received response indicating an error condition
1068
 * in reply to a previously sent packet.
1069
 *
1070
 * \note Call RIO_sendAvailable() before this function is called to make sure
1071
 * the outbound queue has transmission buffers available.
1072
 */
1073
#ifdef RIO_TRANSPARENT
1074
void RIO_receiveResponseError( RioStack_t *stack, uint16_t *destid, uint16_t *srcid, uint8_t *tid );
1075
#else
1076
void RIO_receiveResponseError( RioStack_t *stack, uint16_t *srcid, uint8_t *tid );
1077
#endif
1078
 
1079
/*******************************************************************************************
1080
 * Logical message passing DOORBELL and MESSAGE functions.
1081
 *******************************************************************************************/
1082
 
1083
/**
1084
 * \brief Send a doorbell.
1085
 *
1086
 * \param[in] stack The stack to operate on.
1087
 * \param[in] destid The device id of the destination end point.
1088
 * \param[in] tid The transaction id to be returned in the response.
1089
 * \param[in] info The information to send with the doorbell.
1090
 * \return An identifier that maps to the doorbell response that are received using
1091
 * RIO_packetTid.
1092
 *
1093
 * This function is used to send a doorbell to a remote endpoint. A response
1094
 * should be sent when the doorbell has been processed using the RIO_sendResponseDone(),
1095
 * RIO_sendResponseRetry() or RIO_sendResponseError() functions.
1096
 *
1097
 * \note Call RIO_sendAvailable() before this function is called to make sure
1098
 * the outbound queue has transmission buffers available.
1099
 */
1100
#ifdef RIO_TRANSPARENT
1101
void RIO_sendDoorbell( RioStack_t *stack, const uint16_t destid, const uint16_t srcid, const uint8_t tid,
1102
                       const uint16_t info);
1103
#else
1104
void RIO_sendDoorbell( RioStack_t *stack, const uint16_t destid, const uint8_t tid,
1105
                       const uint16_t info);
1106
#endif
1107
 
1108
/**
1109
 * \brief Read a received a doorbell.
1110
 *
1111
 * \param[in] stack The stack to operate on.
1112
 * \param[out] srcid The device id of the source end point.
1113
 * \param[out] tid The transaction id to be returned in the response.
1114
 * \param[out] info The information to send with the doorbell.
1115
 *
1116
 * This function is used to read a received doorbell from a remote endpoint.
1117
 */
1118
#ifdef RIO_TRANSPARENT
1119
void RIO_receiveDoorbell( RioStack_t *stack, uint16_t *destid, uint16_t *srcid, uint8_t *tid,
1120
                          uint16_t *info);
1121
#else
1122
void RIO_receiveDoorbell( RioStack_t *stack, uint16_t *srcid, uint8_t *tid,
1123
                          uint16_t *info);
1124
#endif
1125
 
1126
/**
1127
 * \brief Send a message.
1128
 *
1129
 * \param[in] stack The stack to operate on.
1130
 * \param[in] destid The device id of the destination endpoint.
1131
 * \param[in] mailbox The mailbox to send the message to.
1132
 * \param[in] dataLength The size of the buffer to copy to.
1133
 * \param[in] buffer A byte pointer to the message payload to send.
1134
 *
1135
 * This function sends a single packet message to a destination mailbox.
1136
 *
1137
 * \note Mailbox 0-15 can support multipacket (when support is enabled)
1138
 * messages and 16-255 can only handle singlepacket messages. Dont use mailbox
1139
 * 0-15 unless you know that there will be large packets transmitted on it.
1140
 */
1141
#ifdef RIO_TRANSPARENT
1142
void RIO_sendMessage( RioStack_t *stack, const uint16_t destid, const uint16_t srcid, const uint8_t mailbox,
1143
                      const uint16_t dataLength, const uint8_t *data );
1144
#else
1145
void RIO_sendMessage( RioStack_t *stack, const uint16_t destid, const uint8_t mailbox,
1146
                      const uint16_t dataLength, const uint8_t *data );
1147
#endif
1148
 
1149
/**
1150
 * \brief Read a received message.
1151
 *
1152
 * \param[in] stack The stack to operate on.
1153
 * \param[out] srcid The device id of the source endpoint.
1154
 * \param[out] mailbox The mailbox the message is received on.
1155
 * \param[in] dataLength The size of the buffer to copy to.
1156
 * \param[in] data A byte pointer to the message payload to read.
1157
 * \return The number of bytes copied. A zero will be returned if unable to copy.
1158
 *
1159
 * This function reads a single packet message to a destination mailbox.
1160
 */
1161
#ifdef RIO_TRANSPARENT
1162
uint16_t RIO_receiveMessage( RioStack_t *stack, uint16_t *destid, uint16_t *srcid, uint8_t *mailbox,
1163
                             const uint16_t dataLength, uint8_t *data );
1164
#else
1165
uint16_t RIO_receiveMessage( RioStack_t *stack, uint16_t *srcid, uint8_t *mailbox,
1166
                             const uint16_t dataLength, uint8_t *data );
1167
#endif
1168
 
1169
/*******************************************************************************************
1170
 * Logical message passing MESSAGE-RESPONSE functions.
1171
 *******************************************************************************************/
1172
 
1173
/**
1174
 * \brief Send a message response.
1175
 *
1176
 * \param[in] stack The stack to operate on.
1177
 * \param[in] destid The device identifier of the target to send the response to.
1178
 * \param[in] mailbox The mailbox to send the response to.
1179
 *
1180
 * This function is used to send a message response indicating a successfull
1181
 * completion in reply to a previously received message.
1182
 *
1183
 * \note Call RIO_sendAvailable() before this function is called to make sure
1184
 * the outbound queue has transmission buffers available.
1185
 */
1186
#ifdef RIO_TRANSPARENT
1187
void RIO_sendMessageResponseDone( RioStack_t *stack, const uint16_t destid, const uint16_t srcid, const uint8_t mailbox );
1188
#else
1189
void RIO_sendMessageResponseDone( RioStack_t *stack, const uint16_t destid, const uint8_t mailbox );
1190
#endif
1191
 
1192
/**
1193
 * \brief Read a received message response.
1194
 *
1195
 * \param[in] stack The stack to operate on.
1196
 * \param[out] srcid The device identifier of the source endpoint.
1197
 * \param[out] mailbox The mailbox the response is for.
1198
 *
1199
 * This function is used to read a received message response indicating a successfull
1200
 * completion in reply to a previously sent message.
1201
 */
1202
#ifdef RIO_TRANSPARENT
1203
void RIO_receiveMessageResponseDone( RioStack_t *stack, uint16_t *destid, uint16_t *srcid, uint8_t *mailbox );
1204
#else
1205
void RIO_receiveMessageResponseDone( RioStack_t *stack, uint16_t *srcid, uint8_t *mailbox );
1206
#endif
1207
 
1208
/**
1209
 * \brief Send a message retry response.
1210
 *
1211
 * \param[in] stack The stack to operate on.
1212
 * \param[in] destid The device identifier of the target to send the response to.
1213
 * \param[in] mailbox The mailbox to send the response to.
1214
 *
1215
 * This function is used to send a message response indicating a busy resource
1216
 * in reply to a previously received message.
1217
 *
1218
 * \note Call RIO_sendAvailable() before this function is called to make sure
1219
 * the outbound queue has transmission buffers available.
1220
 */
1221
#ifdef RIO_TRANSPARENT
1222
void RIO_sendMessageResponseRetry( RioStack_t *stack, const uint16_t destid, const uint16_t srcid, const uint8_t mailbox );
1223
#else
1224
void RIO_sendMessageResponseRetry( RioStack_t *stack, const uint16_t destid, const uint8_t mailbox );
1225
#endif
1226
 
1227
/**
1228
 * \brief Read a received message retry response.
1229
 *
1230
 * \param[in] stack The stack to operate on.
1231
 * \param[out] srcid The device identifier of the source endpoint.
1232
 * \param[out] mailbox The mailbox the response is for.
1233
 *
1234
 * This function is used to read a received message retry response indicating a retry
1235
 * condition in reply to a previously sent message.
1236
 */
1237
#ifdef RIO_TRANSPARENT
1238
void RIO_receiveMessageResponseRetry( RioStack_t *stack, uint16_t *destid, uint16_t *srcid, uint8_t *mailbox );
1239
#else
1240
void RIO_receiveMessageResponseRetry( RioStack_t *stack, uint16_t *srcid, uint8_t *mailbox );
1241
#endif
1242
 
1243
/**
1244
 * \brief Send a message error response.
1245
 *
1246
 * \param[in] stack The stack to operate on.
1247
 * \param[in] destid The device identifier of the target to send the response to.
1248
 * \param[in] mailbox The mailbox to send the response to.
1249
 *
1250
 * This function is used to send a message response indicating a busy resource
1251
 * in reply to a previously received message.
1252
 *
1253
 * \note Call RIO_sendAvailable() before this function is called to make sure
1254
 * the outbound queue has transmission buffers available.
1255
 */
1256
#ifdef RIO_TRANSPARENT
1257
void RIO_sendMessageResponseError( RioStack_t *stack, const uint16_t destid, const uint16_t srcid, const uint8_t mailbox );
1258
#else
1259
void RIO_sendMessageResponseError( RioStack_t *stack, const uint16_t destid, const uint8_t mailbox );
1260
#endif
1261
 
1262
/**
1263
 * \brief Read a received message error response.
1264
 *
1265
 * \param[in] stack The stack to operate on.
1266
 * \param[out] srcid The device identifier of the source endpoint.
1267
 * \param[out] mailbox The mailbox the response is for.
1268
 *
1269
 * This function is used to read a received message error response indicating an error
1270
 * condition in reply to a previously sent message.
1271
 */
1272
#ifdef RIO_TRANSPARENT
1273
void RIO_receiveMessageResponseError( RioStack_t *stack, uint16_t *destid, uint16_t *srcid, uint8_t *mailbox );
1274
#else
1275
void RIO_receiveMessageResponseError( RioStack_t *stack, uint16_t *srcid, uint8_t *mailbox );
1276
#endif
1277
 
1278
/*******************************************************************************************
1279
 * Port functions (backend API towards physical device)
1280
 *******************************************************************************************/
1281
 
1282
/**
1283
 * \brief Set a port current time.
1284
 *
1285
 * \param[in] stack The stack to operate on.
1286
 * \param[in] time The current time without unit.
1287
 *
1288
 * This function indicates to the stack the current time and this is used internally
1289
 * to calculate when a packet timeout should be triggered. Use this together with RIO_setPortTimeout()
1290
 * to allow for the stack to handle timeouts.
1291
 */
1292
void RIO_portSetTime( RioStack_t *stack, const uint32_t time);
1293
 
1294
/**
1295
 * \brief Set a port timeout limit.
1296
 *
1297
 * \param[in] stack The stack to operate on.
1298
 * \param[in] time The time out threshold.
1299
 *
1300
 * The time to wait for a response from the link partner. The unit of the
1301
 * timeout value should be the same as the time used in RIO_setPortTime().
1302
 *
1303
 * This function is used to set a timeout threshold value and is used to know when
1304
 * an acknowledge should have been received from a link partner.
1305
 */
1306
void RIO_portSetTimeout( RioStack_t *stack, const uint32_t time);
1307
 
1308
/**
1309
 * \brief Set a ports status.
1310
 *
1311
 * \param[in] stack The stack to operate on.
1312
 * \param[in] initialized The state of the port.
1313
 *
1314
 * If set to non-zero, the symbol encoder/decoder indicates to the stack that
1315
 * it is successfully encoding/decoding symbol, i.e. synchronized to the link.
1316
 *
1317
 * This function indicates to the stack if the port that are encoding/decoding
1318
 * symbols are ready to accept other symbols than idle-symbols. If the
1319
 * encoding/decoding loses synchronization then this function should be called
1320
 * with an argument equal to zero to force the stack to resynchronize the link.
1321
 */
1322
void RIO_portSetStatus( RioStack_t *stack, const uint8_t initialized );
1323
 
1324
/**
1325
 * \brief Add a new symbol to the RapidIO stack.
1326
 *
1327
 * \param[in] stack The stack to operate on.
1328
 * \param[in] s A symbol received from a port.
1329
 *
1330
 * This function is used to insert new data, read from a port, into the stack. The
1331
 * symbols will be concatenated to form packets that can be accessed using other
1332
 * functions.
1333
 */
1334
void RIO_portAddSymbol( RioStack_t *stack, const RioSymbol s );
1335
 
1336
/**
1337
 * \brief Get the next symbol to transmit on a port.
1338
 *
1339
 * \param[in] stack The stack to operate on.
1340
 * \return A symbol that should be sent on a port.
1341
 *
1342
 * This function is used to fetch new symbols to transmit on a port. Packets that
1343
 * are inserted are split into symbols that are accessed with this function.
1344
 */
1345
RioSymbol RIO_portGetSymbol( RioStack_t *stack );
1346
 
1347
 
1348
/*******************************************************************************************
1349
 * DEPRECATED
1350
 * Will be removed.
1351
 *******************************************************************************************/
1352
 
1353
/**
1354
 * \brief Read packet transaction identification.
1355
 * \param[in] stack The stack to operate on.
1356
 * \return The identification of the packet. This matches a transaction identifier
1357
 * that are set as argument when a send-function are called.
1358
 *
1359
 * This function is used to correlate a sent packet to a received response.
1360
 *
1361
 * \note This function cannot be used when receiving messages on mailboxes. Use
1362
 * RIO_readMessageMailbox() instead.
1363
 */
1364
uint8_t RIO_packetTid( RioStack_t *stack );
1365
 
1366
/**
1367
 * \brief Read packet destination identification.
1368
 * \param[in] stack The stack to operate on.
1369
 * \return The destination device identifier of the packet.
1370
 *
1371
 * This function is used to get the destination device identifier of a received packet.
1372
 */
1373
uint16_t RIO_packetDestination( RioStack_t *stack );
1374
 
1375
/**
1376
 * \brief Read packet source identification.
1377
 * \param[in] stack The stack to operate on.
1378
 * \return The source device identifier of the packet.
1379
 *
1380
 * This function is used to get the source device identifier of a received packet.
1381
 */
1382
uint16_t RIO_packetSource( RioStack_t *stack );
1383
 
1384
/**
1385
 * \brief Read a maintenance read request hop count value.
1386
 *
1387
 * \param[in] stack The stack to operate on.
1388
 * \return The hopcount value of the packet.
1389
 *
1390
 * This function returns the hop count value of a received maintenance read
1391
 * request packet.
1392
 *
1393
 * \note In normal operational mode, the stack answers maintenance requests
1394
 * automatically without user intervention. This function should only be
1395
 * called if the stack is compiled in transparent mode.
1396
 */
1397
uint8_t RIO_readMaintenanceReadRequestHop( RioStack_t *stack );
1398
 
1399
/**
1400
 * \brief Read a maintenance read request offset value.
1401
 *
1402
 * \param[in] stack The stack to operate on.
1403
 * \return The offset value of the packet.
1404
 *
1405
 * This function returns the offset value of a received maintenance read
1406
 * request packet.
1407
 *
1408
 * \note In normal operational mode, the stack answers maintenance requests
1409
 * automatically without user intervention. This function should only be
1410
 * called if the stack is compiled in transparent mode.
1411
 */
1412
uint32_t RIO_readMaintenanceReadRequestOffset( RioStack_t *stack );
1413
 
1414
/**
1415
 * \brief Read a maintenance read response hop count value.
1416
 *
1417
 * \param[in] stack The stack to operate on.
1418
 * \return The hop count value of the packet.
1419
 *
1420
 * This function returns the hop count value of a received maintenance read
1421
 * response packet.
1422
 *
1423
 * \note In normal operational mode, the stack answers maintenance requests
1424
 * automatically without user intervention. This function should only be
1425
 * called if the stack is compiled in transparent mode.
1426
 */
1427
uint8_t RIO_readMaintenanceReadResponseHop( RioStack_t *stack );
1428
 
1429
/**
1430
 * \brief Read a maintenance read response offset value.
1431
 *
1432
 * \param[in] stack The stack to operate on.
1433
 * \return The offset value of the packet.
1434
 *
1435
 * This function returns the offset value of a received maintenance read
1436
 * response packet.
1437
 *
1438
 * \note In normal operational mode, the stack answers maintenance requests
1439
 * automatically without user intervention. This function should only be
1440
 * called if the stack is compiled in transparent mode.
1441
 */
1442
uint32_t RIO_readMaintenanceReadResponse( RioStack_t *stack );
1443
 
1444
/**
1445
 * \brief Read a maintenance write request hop count value.
1446
 *
1447
 * \param[in] stack The stack to operate on.
1448
 * \return The hopcount value of the packet.
1449
 *
1450
 * This function returns the hop count value of a received maintenance write
1451
 * request packet.
1452
 *
1453
 * \note In normal operational mode, the stack answers maintenance requests
1454
 * automatically without user intervention. This function should only be
1455
 * called if the stack is compiled in transparent mode.
1456
 */
1457
uint8_t RIO_readMaintenanceWriteRequestHop( RioStack_t *stack );
1458
 
1459
/**
1460
 * \brief Read a maintenance write request offset value.
1461
 *
1462
 * \param[in] stack The stack to operate on.
1463
 * \return The offset value of the packet.
1464
 *
1465
 * This function returns the offset value of a received maintenance write
1466
 * request packet.
1467
 *
1468
 * \note In normal operational mode, the stack answers maintenance requests
1469
 * automatically without user intervention. This function should only be
1470
 * called if the stack is compiled in transparent mode.
1471
 */
1472
uint32_t RIO_readMaintenanceWriteRequestOffset( RioStack_t *stack );
1473
 
1474
/**
1475
 * \brief Read a maintenance write request data value.
1476
 *
1477
 * \param[in] stack The stack to operate on.
1478
 * \return The data value of the packet.
1479
 *
1480
 * This function returns the data value of a received maintenance write
1481
 * request packet.
1482
 *
1483
 * \note In normal operational mode, the stack answers maintenance requests
1484
 * automatically without user intervention. This function should only be
1485
 * called if the stack is compiled in transparent mode.
1486
 */
1487
uint32_t RIO_readMaintenanceWriteRequestData( RioStack_t *stack );
1488
 
1489
/**
1490
 * \brief Read a maintenance write response hop count value.
1491
 *
1492
 * \param[in] stack The stack to operate on.
1493
 * \return The hopcount value of the packet.
1494
 *
1495
 * This function returns the hop count value of a received maintenance write
1496
 * response packet.
1497
 *
1498
 * \note In normal operational mode, the stack answers maintenance requests
1499
 * automatically without user intervention. This function should only be
1500
 * called if the stack is compiled in transparent mode.
1501
 */
1502
uint8_t RIO_readMaintenanceWriteResponseHop( RioStack_t *stack );
1503
 
1504
/**
1505
 * \brief Send an NWRITE request to write a byte.
1506
 *
1507
 * \param[in] stack The stack to operate on.
1508
 * \param[in] destid The device id of the destination end point.
1509
 * \param[in] address The byte address to write to.
1510
 * \param[in] data The byte data to write.
1511
 * This function creates and sends an NWRITE request packet. No reply will be received.
1512
 *
1513
 * \note The address is a byte address, not a word address.
1514
 *
1515
 * \note Call RIO_sendAvailable() before this function is called to make sure
1516
 * the outbound queue has transmission buffers available.
1517
 */
1518
void RIO_sendNwrite8( RioStack_t *stack, const uint16_t destid, const uint32_t address, const uint8_t data );
1519
 
1520
/**
1521
 * \brief Send an NWRITE_R request to write a byte.
1522
 *
1523
 * \param[in] stack The stack to operate on.
1524
 * \param[in] destid The device id of the destination end point.
1525
 * \param[in] tid The transaction id to be returned in the response.
1526
 * \param[in] address The byte address to write to.
1527
 * \param[in] data The byte data to write.
1528
 * \return An identifier that maps to the packet transaction identifier that are received using
1529
 * RIO_packetTid.
1530
 *
1531
 * This function creates and sends an NWRITE_R request packet. A reply should be received
1532
 * when the write has been completed.
1533
 *
1534
 * \note The address is a byte address, not a word address.
1535
 *
1536
 * \note Call RIO_sendAvailable() before this function is called to make sure
1537
 * the outbound queue has transmission buffers available.
1538
 */
1539
void RIO_sendNwriteR8( RioStack_t *stack, const uint16_t destid, const uint8_t tid, const uint32_t address, const uint8_t data );
1540
 
1541
/**
1542
 * \brief Get the byte address from an NWRITE or NWRITE_R packet.
1543
 *
1544
 * \param[in] stack The stack to operate on.
1545
 * \return The byte address contained in the NWRITE or NWRITE_R packet.
1546
 *
1547
 * This function reads a received an NWRITE or NWRITE_R request packet and fetches the address
1548
 * contained within.
1549
 *
1550
 * \note The address is a byte address, not a word address.
1551
 */
1552
uint32_t RIO_readNwriteAddress8( RioStack_t *stack );
1553
 
1554
/**
1555
 * \brief Get the number of bytes to write from an NWRITE or NWRITE_R packet.
1556
 *
1557
 * \param[in] stack The stack to operate on.
1558
 * \return The number of bytes requested to be written in a NWRITE or NWRITE_R packet.
1559
 *
1560
 * This function reads a received an NWRITE or NWRITE_R request packet and fetches the
1561
 * number of bytes requested to be written.
1562
 *
1563
 * \note The returned size is the number of bytes.
1564
 */
1565
uint8_t RIO_readNwriteSize8( RioStack_t *stack );
1566
 
1567
/**
1568
 * \brief Get the byte to write from a NWRITE or NWRITE_R packet.
1569
 *
1570
 * \param[in] stack The stack to operate on.
1571
 * \return The byte requested to be written in a NWRITE or NWRITE_R packet.
1572
 *
1573
 * This function reads a received an NWRITE or NWRITE_R request packet and fetches the
1574
 * byte to write.
1575
 */
1576
uint8_t RIO_readNwritePayload8( RioStack_t *stack );
1577
 
1578
 
1579
/**
1580
 * \brief Send a NREAD request to read a byte.
1581
 *
1582
 * \param[in] stack The stack to operate on.
1583
 * \param[in] destid The device id of the destination end point.
1584
 * \param[in] tid The transaction id to be returned in the response.
1585
 * \param[in] address The byte address to read.
1586
 * \return An identifier that maps to the packet identifier that are received using
1587
 * RIO_packetTid.
1588
 *
1589
 * This function creates and sends an NREAD request packet. The response packet will
1590
 * contain one byte of data. The reply is received using RIO_readResponseDone8().
1591
 *
1592
 * \note The address is a byte address, not a word address.
1593
 *
1594
 * \note Call RIO_sendAvailable() before this function is called to make sure
1595
 * the outbound queue has transmission buffers available.
1596
 */
1597
void RIO_sendNread8( RioStack_t *stack, const uint16_t destid, const uint8_t tid, const uint32_t address );
1598
 
1599
 
1600
/**
1601
 * \brief Get the byte address from a NREAD packet.
1602
 *
1603
 * \param[in] stack The stack to operate on.
1604
 * \return The byte address contained in a NREAD packet.
1605
 *
1606
 * This function reads a received an NREAD request packet and fetches the address
1607
 * contained within.
1608
 *
1609
 * \note The address is a byte address, not a word address.
1610
 */
1611
uint32_t RIO_readNreadAddress8( RioStack_t *stack );
1612
 
1613
/**
1614
 * \brief Get the number of bytes to read from a NREAD packet.
1615
 *
1616
 * \param[in] stack The stack to operate on.
1617
 * \return The number of bytes requested to read in a NREAD packet.
1618
 *
1619
 * This function reads a received an NREAD request packet and fetches the
1620
 * number of bytes to return in the reply.
1621
 *
1622
 * \note The returned size is the number of bytes.
1623
 */
1624
uint8_t RIO_readNreadSize8( RioStack_t *stack );
1625
 
1626
/**
1627
 * \brief Get a doorbell info field.
1628
 *
1629
 * \param[in] stack The stack to operate on.
1630
 * \return The info field of a doorbell.
1631
 *
1632
 * This function is used to read and return the info field of a received doorbell.
1633
 */
1634
uint16_t RIO_readDoorbellInfo( RioStack_t *stack );
1635
 
1636
/**
1637
 * \brief Send a byte message.
1638
 *
1639
 * \param[in] stack The stack to operate on.
1640
 * \param[in] destid The device identifier of the target to send the message to.
1641
 * \param[in] mbox The mailbox to send the message to.
1642
 * \param[in] size The number of bytes to send.
1643
 * \param[in] data A pointer to an array of bytes to send. The parameter size indicates
1644
 * the number of bytes to send.
1645
 *
1646
 * This functions sends a message to a mailbox in an end-point target. A message response
1647
 * should be sent when the message has been processed using the RIO_sendMessageResponseDone(),
1648
 * RIO_sendMessageResponseRetry() or RIO_sendMessageResponseError() functions.
1649
 *
1650
 * \note All sizes that are transmitted are even double words. If 48-bits are
1651
 * sent then 64 bits will be received on the other side with the last bits
1652
 * padded to zero.
1653
 *
1654
 * \note Call RIO_sendAvailable() before this function is called to make sure
1655
 * the outbound queue has transmission buffers available.
1656
 */
1657
void RIO_sendMessage8( RioStack_t *stack, const uint16_t destid, const uint8_t mbox, const uint16_t size, const uint8_t *data );
1658
 
1659
/**
1660
 * \brief Read a received message mailbox.
1661
 *
1662
 * \param[in] stack The stack to operate on.
1663
 * \return The mailbox of a received message.
1664
 *
1665
 * This function returns the mailbox of an incoming message.
1666
 */
1667
uint8_t RIO_readMessageMbox( RioStack_t *stack );
1668
 
1669
/**
1670
 * \brief Read a received message payload size in bytes.
1671
 *
1672
 * \param[in] stack The stack to operate on.
1673
 * \return The size in bytes of the received message payload.
1674
 *
1675
 * This function returns the number of bytes that was received in
1676
 * an incoming message.
1677
 *
1678
 * \note All sizes that are actually transmitted are even double words. If
1679
 * 48-bits are sent then 64 bits will be received on the other side with
1680
 * the last bits padded to zero.
1681
 */
1682
uint16_t RIO_readMessageSize8( RioStack_t *stack );
1683
 
1684
/**
1685
 * \brief Get the payload of a received message.
1686
 *
1687
 * \param[in] stack The stack to operate on.
1688
 * \param[out] buffer A byte pointer to where to place the payload.
1689
 * \return None
1690
 * This function is used to copy the byte content of a received message.
1691
 */
1692
void RIO_readMessagePayload8( RioStack_t *stack, uint8_t *buffer );
1693
 
1694
/**
1695
 * \brief Send a response with one byte data payload.
1696
 *
1697
 * \param[in] stack The stack to operate on.
1698
 * \param[in] destid The destination identifier of the response.
1699
 * \param[in] tid The transaction identifier for the reply. It should correspond to
1700
 * the tid in the received packet for which this response is sent.
1701
 * \param[in] address The byte address that was read.
1702
 * \param[in] data The data to return in the reply.
1703
 *
1704
 * This function creates a response packet with the specified destination
1705
 * identifier, transaction id and data payload. The generated packet are placed
1706
 * in the outbound packet queue.
1707
 *
1708
 * \note Call RIO_sendAvailable() before this function is called to make sure
1709
 * the outbound queue has transmission buffers available.
1710
 */
1711
void RIO_sendResponseDone8( RioStack_t *stack, const uint16_t destid, const uint8_t tid, const uint32_t address, const uint8_t data );
1712
 
1713
/**
1714
 * \brief Read a one byte payload from a response.
1715
 *
1716
 * \param[in] stack The stack to operate on.
1717
 * \return The byte data payload contained in the response.
1718
 *
1719
 * This function reads a response packet and returns a one byte payload
1720
 * contained within.
1721
 */
1722
uint8_t RIO_readResponseDone8( RioStack_t *stack );
1723
 
1724
/**
1725
 * \brief Get the target mailbox.
1726
 *
1727
 * \param[in] stack The stack to operate on.
1728
 * \return The target mailbox.
1729
 *
1730
 * This function is used to get the target mailbox of a message response.
1731
 */
1732
uint8_t RIO_readMessageResponseMbox( RioStack_t *stack );
1733
 
1734
#endif /* _RIO_STACK_H */
1735
 
1736
/*************************** end of file **************************************/

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.