1 /* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the name of Freescale Semiconductor nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
16 * ALTERNATIVELY, this software may be distributed under the terms of the
17 * GNU General Public License ("GPL") as published by the Free Software
18 * Foundation, either version 2 of that License or (at your option) any
21 * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
22 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
25 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 /**************************************************************************//**
36 @Description Prototypes, externals and typedefs for system-supplied
38 *//***************************************************************************/
46 #if defined(__MWERKS__) && defined(OPTIMIZED_FOR_SPEED)
47 #include "xx_integration_ext.h"
48 #endif /* defined(__MWERKS__) && defined(OPTIMIZED_FOR_SPEED) */
51 /**************************************************************************//**
52 @Group xx_id XX Interface (System call hooks)
54 @Description Prototypes, externals and typedefs for system-supplied
58 *//***************************************************************************/
60 #if (defined(REPORT_EVENTS) && (REPORT_EVENTS > 0))
61 /**************************************************************************//**
62 @Function XX_EventById
64 @Description Event reporting routine - executed only when REPORT_EVENTS=1.
66 @Param[in] event - Event code (e_Event).
67 @Param[in] appId - Application identifier.
68 @Param[in] flags - Event flags.
69 @Param[in] msg - Event message.
72 *//***************************************************************************/
73 void XX_EventById(uint32_t event, t_Handle appId, uint16_t flags, char *msg);
75 #else /* not REPORT_EVENTS */
76 #define XX_EventById(event, appId, flags, msg)
77 #endif /* REPORT_EVENTS */
80 #ifdef DEBUG_XX_MALLOC
81 void * XX_MallocDebug(uint32_t size, char *fname, int line);
83 void * XX_MallocSmartDebug(uint32_t size,
89 #define XX_Malloc(sz) \
90 XX_MallocDebug((sz), __FILE__, __LINE__)
92 #define XX_MallocSmart(sz, memt, al) \
93 XX_MallocSmartDebug((sz), (memt), (al), __FILE__, __LINE__)
95 #else /* not DEBUG_XX_MALLOC */
96 /**************************************************************************//**
99 @Description allocates contiguous block of memory.
101 @Param[in] size - Number of bytes to allocate.
103 @Return The address of the newly allocated block on success, NULL on failure.
104 *//***************************************************************************/
105 void * XX_Malloc(uint32_t size);
107 /**************************************************************************//**
108 @Function XX_MallocSmartInit
110 @Description Initializes SmartMalloc allocator.
112 @Return E_OK on success, error code otherwise.
113 *//***************************************************************************/
114 int XX_MallocSmartInit(void);
116 /**************************************************************************//**
117 @Function XX_MallocSmart
119 @Description Allocates contiguous block of memory in a specified
120 alignment and from the specified segment.
122 @Param[in] size - Number of bytes to allocate.
123 @Param[in] memPartitionId - Memory partition ID; The value zero must
124 be mapped to the default heap partition.
125 @Param[in] alignment - Required memory alignment (in bytes).
127 @Return The address of the newly allocated block on success, NULL on failure.
128 *//***************************************************************************/
129 void * XX_MallocSmart(uint32_t size, int memPartitionId, uint32_t alignment);
130 #endif /* not DEBUG_XX_MALLOC */
132 /**************************************************************************//**
133 @Function XX_FreeSmart
135 @Description Frees the memory block pointed to by "p".
136 Only for memory allocated by XX_MallocSmart
138 @Param[in] p_Memory - pointer to the memory block.
141 *//***************************************************************************/
142 void XX_FreeSmart(void *p_Memory);
144 /**************************************************************************//**
147 @Description frees the memory block pointed to by "p".
149 @Param[in] p_Memory - pointer to the memory block.
152 *//***************************************************************************/
153 void XX_Free(void *p_Memory);
156 /**************************************************************************//**
157 @Function XX_GetMemPartitionBase
159 @Description This routine gets the address of a memory segment according to
162 @Param[in] memPartitionId - Memory partition ID; The value zero must
163 be mapped to the default heap partition.
165 @Return The address of the required memory type.
166 *//***************************************************************************/
167 void * XX_GetMemPartitionBase(int memPartitionId);
170 /**************************************************************************//**
173 @Description print a string.
175 @Param[in] str - string to print.
178 *//***************************************************************************/
179 void XX_Print(char *str, ...);
181 /**************************************************************************//**
184 @Description Get character from console.
186 @Return Character is returned on success. Zero is returned otherwise.
187 *//***************************************************************************/
188 char XX_GetChar(void);
190 /**************************************************************************//**
191 @Function XX_PreallocAndBindIntr
193 @Description Preallocate and optionally bind it to given CPU.
195 @Param[in] irq - Interrupt ID (system-specific number).
196 @Param[in] cpu - CPU to bind to or -1 if iRQ should be unbound.
198 @Return E_OK on success; error code otherwise..
199 *//***************************************************************************/
200 t_Error XX_PreallocAndBindIntr(int irq, unsigned int cpu);
202 /**************************************************************************//**
203 @Function XX_DeallocIntr
205 @Description Deallocate preallocated interupt.
207 @Param[in] irq - Interrupt ID (system-specific number).
209 @Return E_OK on success; error code otherwise..
210 *//***************************************************************************/
211 t_Error XX_DeallocIntr(int irq);
213 /**************************************************************************//**
216 @Description Set an interrupt service routine for a specific interrupt source.
218 @Param[in] irq - Interrupt ID (system-specific number).
219 @Param[in] f_Isr - Callback routine that will be called when the interrupt occurs.
220 @Param[in] handle - The argument for the user callback routine.
222 @Return E_OK on success; error code otherwise..
223 *//***************************************************************************/
224 t_Error XX_SetIntr(int irq, t_Isr *f_Isr, t_Handle handle);
226 /**************************************************************************//**
227 @Function XX_FreeIntr
229 @Description Free a specific interrupt and a specific callback routine.
231 @Param[in] irq - Interrupt ID (system-specific number).
233 @Return E_OK on success; error code otherwise..
234 *//***************************************************************************/
235 t_Error XX_FreeIntr(int irq);
237 /**************************************************************************//**
238 @Function XX_EnableIntr
240 @Description Enable a specific interrupt.
242 @Param[in] irq - Interrupt ID (system-specific number).
244 @Return E_OK on success; error code otherwise..
245 *//***************************************************************************/
246 t_Error XX_EnableIntr(int irq);
248 /**************************************************************************//**
249 @Function XX_DisableIntr
251 @Description Disable a specific interrupt.
253 @Param[in] irq - Interrupt ID (system-specific number).
255 @Return E_OK on success; error code otherwise..
256 *//***************************************************************************/
257 t_Error XX_DisableIntr(int irq);
259 #if !(defined(__MWERKS__) && defined(OPTIMIZED_FOR_SPEED))
260 /**************************************************************************//**
261 @Function XX_DisableAllIntr
263 @Description Disable all interrupts by masking them at the CPU.
265 @Return A value that represents the interrupts state before the
266 operation, and should be passed to the matching
267 XX_RestoreAllIntr() call.
268 *//***************************************************************************/
269 uint32_t XX_DisableAllIntr(void);
271 /**************************************************************************//**
272 @Function XX_RestoreAllIntr
274 @Description Restore previous state of interrupts level at the CPU.
276 @Param[in] flags - A value that represents the interrupts state to restore,
277 as returned by the matching call for XX_DisableAllIntr().
280 *//***************************************************************************/
281 void XX_RestoreAllIntr(uint32_t flags);
282 #endif /* !(defined(__MWERKS__) && defined(OPTIMIZED_FOR_SPEED)) */
284 /**************************************************************************//**
287 @Description Call a service in another task.
289 Activate the routine "f" via the queue identified by "IntrManagerId". The
290 parameter to "f" is Id - the handle of the destination object
292 @Param[in] intrManagerId - Queue ID.
293 @Param[in] f - routine pointer.
294 @Param[in] Id - the parameter to be passed to f().
295 @Param[in] h_App - Application handle.
296 @Param[in] flags - Unused,
298 @Return E_OK is returned on success. E_FAIL is returned otherwise (usually an operating system level failure).
299 *//***************************************************************************/
300 t_Error XX_Call( uint32_t intrManagerId,
301 t_Error (* f)(t_Handle),
306 /**************************************************************************//**
309 @Description Stop execution and report status (where it is applicable)
311 @Param[in] status - exit status
312 *//***************************************************************************/
313 void XX_Exit(int status);
315 /*****************************************************************************/
316 /* Tasklet Service Routines */
317 /*****************************************************************************/
318 typedef t_Handle t_TaskletHandle;
320 /**************************************************************************//**
321 @Function XX_InitTasklet
323 @Description Create and initialize a tasklet object.
325 @Param[in] routine - A routine to be ran as a tasklet.
326 @Param[in] data - An argument to pass to the tasklet.
328 @Return Tasklet handle is returned on success. NULL is returned otherwise.
329 *//***************************************************************************/
330 t_TaskletHandle XX_InitTasklet (void (*routine)(void *), void *data);
332 /**************************************************************************//**
333 @Function XX_FreeTasklet
335 @Description Free a tasklet object.
337 @Param[in] h_Tasklet - A handle to a tasklet to be free.
340 *//***************************************************************************/
341 void XX_FreeTasklet (t_TaskletHandle h_Tasklet);
343 /**************************************************************************//**
344 @Function XX_ScheduleTask
346 @Description Schedule a tasklet object.
348 @Param[in] h_Tasklet - A handle to a tasklet to be scheduled.
349 @Param[in] immediate - Indicate whether to schedule this tasklet on
350 the immediate queue or on the delayed one.
352 @Return 0 - on success. Error code - otherwise.
353 *//***************************************************************************/
354 int XX_ScheduleTask(t_TaskletHandle h_Tasklet, int immediate);
356 /**************************************************************************//**
357 @Function XX_FlushScheduledTasks
359 @Description Flush all tasks there are in the scheduled tasks queue.
362 *//***************************************************************************/
363 void XX_FlushScheduledTasks(void);
365 /**************************************************************************//**
366 @Function XX_TaskletIsQueued
368 @Description Check if task is queued.
370 @Param[in] h_Tasklet - A handle to a tasklet to be scheduled.
372 @Return 1 - task is queued. 0 - otherwise.
373 *//***************************************************************************/
374 int XX_TaskletIsQueued(t_TaskletHandle h_Tasklet);
376 /**************************************************************************//**
377 @Function XX_SetTaskletData
379 @Description Set data to a scheduled task. Used to change data of already
382 @Param[in] h_Tasklet - A handle to a tasklet to be scheduled.
383 @Param[in] data - Data to be set.
384 *//***************************************************************************/
385 void XX_SetTaskletData(t_TaskletHandle h_Tasklet, t_Handle data);
387 /**************************************************************************//**
388 @Function XX_GetTaskletData
390 @Description Get the data of scheduled task.
392 @Param[in] h_Tasklet - A handle to a tasklet to be scheduled.
394 @Return handle to the data of the task.
395 *//***************************************************************************/
396 t_Handle XX_GetTaskletData(t_TaskletHandle h_Tasklet);
398 /**************************************************************************//**
399 @Function XX_BottomHalf
401 @Description Bottom half implementation, invoked by the interrupt handler.
403 This routine handles all bottom-half tasklets with interrupts
407 *//***************************************************************************/
408 void XX_BottomHalf(void);
411 /*****************************************************************************/
412 /* Spinlock Service Routines */
413 /*****************************************************************************/
415 /**************************************************************************//**
416 @Function XX_InitSpinlock
418 @Description Creates a spinlock.
420 @Return Spinlock handle is returned on success; NULL otherwise.
421 *//***************************************************************************/
422 t_Handle XX_InitSpinlock(void);
424 /**************************************************************************//**
425 @Function XX_FreeSpinlock
427 @Description Frees the memory allocated for the spinlock creation.
429 @Param[in] h_Spinlock - A handle to a spinlock.
432 *//***************************************************************************/
433 void XX_FreeSpinlock(t_Handle h_Spinlock);
435 /**************************************************************************//**
436 @Function XX_LockSpinlock
438 @Description Locks a spinlock.
440 @Param[in] h_Spinlock - A handle to a spinlock.
443 *//***************************************************************************/
444 void XX_LockSpinlock(t_Handle h_Spinlock);
446 /**************************************************************************//**
447 @Function XX_UnlockSpinlock
449 @Description Unlocks a spinlock.
451 @Param[in] h_Spinlock - A handle to a spinlock.
454 *//***************************************************************************/
455 void XX_UnlockSpinlock(t_Handle h_Spinlock);
457 /**************************************************************************//**
458 @Function XX_LockIntrSpinlock
460 @Description Locks a spinlock (interrupt safe).
462 @Param[in] h_Spinlock - A handle to a spinlock.
464 @Return A value that represents the interrupts state before the
465 operation, and should be passed to the matching
466 XX_UnlockIntrSpinlock() call.
467 *//***************************************************************************/
468 uint32_t XX_LockIntrSpinlock(t_Handle h_Spinlock);
470 /**************************************************************************//**
471 @Function XX_UnlockIntrSpinlock
473 @Description Unlocks a spinlock (interrupt safe).
475 @Param[in] h_Spinlock - A handle to a spinlock.
476 @Param[in] intrFlags - A value that represents the interrupts state to
477 restore, as returned by the matching call for
478 XX_LockIntrSpinlock().
481 *//***************************************************************************/
482 void XX_UnlockIntrSpinlock(t_Handle h_Spinlock, uint32_t intrFlags);
485 /*****************************************************************************/
486 /* Timers Service Routines */
487 /*****************************************************************************/
489 /**************************************************************************//**
490 @Function XX_CurrentTime
492 @Description Returns current system time.
494 @Return Current system time (in milliseconds).
495 *//***************************************************************************/
496 uint32_t XX_CurrentTime(void);
498 /**************************************************************************//**
499 @Function XX_CreateTimer
501 @Description Creates a timer.
503 @Return Timer handle is returned on success; NULL otherwise.
504 *//***************************************************************************/
505 t_Handle XX_CreateTimer(void);
507 /**************************************************************************//**
508 @Function XX_FreeTimer
510 @Description Frees the memory allocated for the timer creation.
512 @Param[in] h_Timer - A handle to a timer.
515 *//***************************************************************************/
516 void XX_FreeTimer(t_Handle h_Timer);
518 /**************************************************************************//**
519 @Function XX_StartTimer
521 @Description Starts a timer.
523 The user can select to start the timer as periodic timer or as
524 one-shot timer. The user should provide a callback routine that
525 will be called when the timer expires.
527 @Param[in] h_Timer - A handle to a timer.
528 @Param[in] msecs - Timer expiration period (in milliseconds).
529 @Param[in] periodic - TRUE for a periodic timer;
530 FALSE for a one-shot timer..
531 @Param[in] f_TimerExpired - A callback routine to be called when the
533 @Param[in] h_Arg - The argument to pass in the timer-expired
537 *//***************************************************************************/
538 void XX_StartTimer(t_Handle h_Timer,
541 void (*f_TimerExpired)(t_Handle h_Arg),
544 /**************************************************************************//**
545 @Function XX_StopTimer
547 @Description Frees the memory allocated for the timer creation.
549 @Param[in] h_Timer - A handle to a timer.
552 *//***************************************************************************/
553 void XX_StopTimer(t_Handle h_Timer);
555 /**************************************************************************//**
556 @Function XX_GetExpirationTime
558 @Description Returns the time (in milliseconds) remaining until the
559 expiration of a timer.
561 @Param[in] h_Timer - A handle to a timer.
563 @Return The time left until the timer expires.
564 *//***************************************************************************/
565 uint32_t XX_GetExpirationTime(t_Handle h_Timer);
567 /**************************************************************************//**
568 @Function XX_ModTimer
570 @Description Updates the expiration time of a timer.
572 This routine adds the given time to the current system time,
573 and sets this value as the new expiration time of the timer.
575 @Param[in] h_Timer - A handle to a timer.
576 @Param[in] msecs - The new interval until timer expiration
580 *//***************************************************************************/
581 void XX_ModTimer(t_Handle h_Timer, uint32_t msecs);
583 /**************************************************************************//**
584 @Function XX_TimerIsActive
586 @Description Checks whether a timer is active (pending) or not.
588 @Param[in] h_Timer - A handle to a timer.
590 @Return 0 - the timer is inactive; Non-zero value - the timer is active;
591 *//***************************************************************************/
592 int XX_TimerIsActive(t_Handle h_Timer);
594 /**************************************************************************//**
597 @Description Non-busy wait until the desired time (in milliseconds) has passed.
599 @Param[in] msecs - The requested sleep time (in milliseconds).
603 @Cautions This routine enables interrupts during its wait time.
604 *//***************************************************************************/
605 uint32_t XX_Sleep(uint32_t msecs);
607 /**************************************************************************//**
610 @Description Busy-wait until the desired time (in microseconds) has passed.
612 @Param[in] usecs - The requested delay time (in microseconds).
616 @Cautions It is highly unrecommended to call this routine during interrupt
617 time, because the system time may not be updated properly during
618 the delay loop. The behavior of this routine during interrupt
620 *//***************************************************************************/
621 void XX_UDelay(uint32_t usecs);
624 /*****************************************************************************/
625 /* Other Service Routines */
626 /*****************************************************************************/
628 /**************************************************************************//**
629 @Function XX_PhysToVirt
631 @Description Translates a physical address to the matching virtual address.
633 @Param[in] addr - The physical address to translate.
635 @Return Virtual address.
636 *//***************************************************************************/
637 void * XX_PhysToVirt(physAddress_t addr);
639 /**************************************************************************//**
640 @Function XX_VirtToPhys
642 @Description Translates a virtual address to the matching physical address.
644 @Param[in] addr - The virtual address to translate.
646 @Return Physical address.
647 *//***************************************************************************/
648 physAddress_t XX_VirtToPhys(void *addr);
650 /**************************************************************************//**
651 @Function XX_PortalSetInfo
653 @Description Save physical and virtual adresses of the portals.
655 @Param[in] dev - Portals device - either bman or qman.
657 @Return Physical, virtual addresses and size.
658 *//***************************************************************************/
659 void XX_PortalSetInfo(device_t dev);
661 /**************************************************************************//**
662 @Function XX_FmanSetIntrInfo
664 @Description Workaround for FMan interrupt, which must be binded to one CPU
667 @Param[in] irq - Interrupt number.
670 *//***************************************************************************/
671 void XX_FmanFixIntr(int irq);
673 /**************************************************************************//**
674 @Group xx_ipc XX Inter-Partition-Communication API
676 @Description The following API is to be used when working with multiple
677 partitions configuration.
680 *//***************************************************************************/
682 #define XX_IPC_MAX_ADDR_NAME_LENGTH 16 /**< Maximum length of an endpoint name string;
683 The IPC service can use this constant to limit
684 the storage space for IPC endpoint names. */
687 /**************************************************************************//**
688 @Function t_IpcMsgCompletion
690 @Description Callback function used upon IPC non-blocking transaction completion
691 to return message buffer to the caller and to forward reply if available.
693 This callback function may be attached by the source endpoint to any outgoing
694 IPC message to indicate a non-blocking send (see also XX_IpcSendMessage() routine).
695 Upon completion of an IPC transaction (consisting of a message and an optional reply),
696 the IPC service invokes this callback routine to return the message buffer to the sender
697 and to provide the received reply, if requested.
699 User provides this function. Driver invokes it.
701 @Param[in] h_Module - Abstract handle to the sending module - the same handle as was passed
702 in the XX_IpcSendMessage() function; This handle is typically used to point
703 to the internal data structure of the source endpoint.
704 @Param[in] p_Msg - Pointer to original (sent) message buffer;
705 The source endpoint can free (or reuse) this buffer when message
706 completion callback is called.
707 @Param[in] p_Reply - Pointer to (received) reply buffer;
708 This pointer is the same as was provided by the source endpoint in
710 @Param[in] replyLength - Length (in bytes) of actual data in the reply buffer.
711 @Param[in] status - Completion status - E_OK or failure indication, e.g. IPC transaction completion
715 *//***************************************************************************/
716 typedef void (t_IpcMsgCompletion)(t_Handle h_Module,
719 uint32_t replyLength,
722 /**************************************************************************//**
723 @Function t_IpcMsgHandler
725 @Description Callback function used as IPC message handler.
727 The IPC service invokes message handlers for each IPC message received.
728 The actual function pointer should be registered by each destination endpoint
729 via the XX_IpcRegisterMsgHandler() routine.
731 User provides this function. Driver invokes it.
733 @Param[in] h_Module - Abstract handle to the message handling module - the same handle as
734 was passed in the XX_IpcRegisterMsgHandler() function; this handle is
735 typically used to point to the internal data structure of the destination
737 @Param[in] p_Msg - Pointer to message buffer with data received from peer.
738 @Param[in] msgLength - Length (in bytes) of message data.
739 @Param[in] p_Reply - Pointer to reply buffer, to be filled by the message handler and then sent
741 The reply buffer is allocated by the IPC service with size equals to the
742 replyLength parameter provided in message handler registration (see
743 XX_IpcRegisterMsgHandler() function);
744 If replyLength was initially specified as zero during message handler registration,
745 the IPC service may set this pointer to NULL and assume that a reply is not needed;
746 The IPC service is also responsible for freeing the reply buffer after the
747 reply has been sent or dismissed.
748 @Param[in,out] p_ReplyLength - Pointer to reply length, which has a dual role in this function:
749 [In] equals the replyLength parameter provided in message handler
750 registration (see XX_IpcRegisterMsgHandler() function), and
751 [Out] should be updated by message handler to the actual reply length; if
752 this value is set to zero, the IPC service must assume that a reply should
754 Note: If p_Reply is not NULL, p_ReplyLength must not be NULL as well.
756 @Return E_OK on success; Error code otherwise.
757 *//***************************************************************************/
758 typedef t_Error (t_IpcMsgHandler)(t_Handle h_Module,
762 uint32_t *p_ReplyLength);
764 /**************************************************************************//**
765 @Function XX_IpcRegisterMsgHandler
767 @Description IPC mailbox registration.
769 This function is used for registering an IPC message handler in the IPC service.
770 This function is called by each destination endpoint to indicate that it is ready
771 to handle incoming messages. The IPC service invokes the message handler upon receiving
772 a message addressed to the specified destination endpoint.
774 @Param[in] addr - The address name string associated with the destination endpoint;
775 This address must be unique across the IPC service domain to ensure
776 correct message routing.
777 @Param[in] f_MsgHandler - Pointer to the message handler callback for processing incoming
778 message; invoked by the IPC service upon receiving a message
779 addressed to the destination endpoint specified by the addr
781 @Param[in] h_Module - Abstract handle to the message handling module, passed unchanged
782 to f_MsgHandler callback function.
783 @Param[in] replyLength - The maximal data length (in bytes) of any reply that the specified message handler
784 may generate; the IPC service provides the message handler with buffer
785 for reply according to the length specified here (refer also to the description
786 of #t_IpcMsgHandler callback function type);
787 This size shall be zero if the message handler never generates replies.
789 @Return E_OK on success; Error code otherwise.
790 *//***************************************************************************/
791 t_Error XX_IpcRegisterMsgHandler(char addr[XX_IPC_MAX_ADDR_NAME_LENGTH],
792 t_IpcMsgHandler *f_MsgHandler,
794 uint32_t replyLength);
796 /**************************************************************************//**
797 @Function XX_IpcUnregisterMsgHandler
799 @Description Release IPC mailbox routine.
801 This function is used for unregistering an IPC message handler from the IPC service.
802 This function is called by each destination endpoint to indicate that it is no longer
803 capable of handling incoming messages.
805 @Param[in] addr - The address name string associated with the destination endpoint;
806 This address is the same as was used when the message handler was
807 registered via XX_IpcRegisterMsgHandler().
809 @Return E_OK on success; Error code otherwise.
810 *//***************************************************************************/
811 t_Error XX_IpcUnregisterMsgHandler(char addr[XX_IPC_MAX_ADDR_NAME_LENGTH]);
813 /**************************************************************************//**
814 @Function XX_IpcInitSession
816 @Description This function is used for creating an IPC session between the source endpoint
817 and the destination endpoint.
819 The actual implementation and representation of a session is left for the IPC service.
820 The function returns an abstract handle to the created session. This handle shall be used
821 by the source endpoint in subsequent calls to XX_IpcSendMessage().
822 The IPC service assumes that before this function is called, no messages are sent from
823 the specified source endpoint to the specified destination endpoint.
825 The IPC service may use a connection-oriented approach or a connectionless approach (or both)
828 @par Connection-Oriented Approach
830 The IPC service may implement a session in a connection-oriented approach - when this function is called,
831 the IPC service should take the necessary steps to bring up a source-to-destination channel for messages
832 and a destination-to-source channel for replies. The returned handle should represent the internal
833 representation of these channels.
835 @par Connectionless Approach
837 The IPC service may implement a session in a connectionless approach - when this function is called, the
838 IPC service should not perform any particular steps, but it must store the pair of source and destination
839 addresses in some session representation and return it as a handle. When XX_IpcSendMessage() shall be
840 called, the IPC service may use this handle to provide the necessary identifiers for routing the messages
841 through the connectionless medium.
843 @Param[in] destAddr - The address name string associated with the destination endpoint.
844 @Param[in] srcAddr - The address name string associated with the source endpoint.
846 @Return Abstract handle to the initialized session, or NULL on error.
847 *//***************************************************************************/
848 t_Handle XX_IpcInitSession(char destAddr[XX_IPC_MAX_ADDR_NAME_LENGTH],
849 char srcAddr[XX_IPC_MAX_ADDR_NAME_LENGTH]);
851 /**************************************************************************//**
852 @Function XX_IpcFreeSession
854 @Description This function is used for terminating an existing IPC session between a source endpoint
855 and a destination endpoint.
857 The IPC service assumes that after this function is called, no messages shall be sent from
858 the associated source endpoint to the associated destination endpoint.
860 @Param[in] h_Session - Abstract handle to the IPC session - the same handle as was originally
861 returned by the XX_IpcInitSession() function.
863 @Return E_OK on success; Error code otherwise.
864 *//***************************************************************************/
865 t_Error XX_IpcFreeSession(t_Handle h_Session);
867 /**************************************************************************//**
868 @Function XX_IpcSendMessage
870 @Description IPC message send routine.
872 This function may be used by a source endpoint to send an IPC message to a destination
873 endpoint. The source endpoint cannot send a message to the destination endpoint without
874 first initiating a session with that destination endpoint via XX_IpcInitSession() routine.
876 The source endpoint must provide the buffer pointer and length of the outgoing message.
877 Optionally, it may also provide a buffer for an expected reply. In the latter case, the
878 transaction is not considered complete by the IPC service until the reply has been received.
879 If the source endpoint does not provide a reply buffer, the transaction is considered
880 complete after the message has been sent. The source endpoint must keep the message (and
881 optional reply) buffers valid until the transaction is complete.
883 @par Non-blocking mode
885 The source endpoint may request a non-blocking send by providing a non-NULL pointer to a message
886 completion callback function (f_Completion). Upon completion of the IPC transaction (consisting of a
887 message and an optional reply), the IPC service invokes this callback routine to return the message
888 buffer to the sender and to provide the received reply, if requested.
892 The source endpoint may request a blocking send by setting f_Completion to NULL. The function is
893 expected to block until the IPC transaction is complete - either the reply has been received or (if no reply
894 was requested) the message has been sent.
896 @Param[in] h_Session - Abstract handle to the IPC session - the same handle as was originally
897 returned by the XX_IpcInitSession() function.
898 @Param[in] p_Msg - Pointer to message buffer to send.
899 @Param[in] msgLength - Length (in bytes) of actual data in the message buffer.
900 @Param[in] p_Reply - Pointer to reply buffer - if this buffer is not NULL, the IPC service
901 fills this buffer with the received reply data;
902 In blocking mode, the reply data must be valid when the function returns;
903 In non-blocking mode, the reply data is valid when f_Completion is called;
904 If this pointer is NULL, no reply is expected.
905 @Param[in,out] p_ReplyLength - Pointer to reply length, which has a dual role in this function:
906 [In] specifies the maximal length (in bytes) of the reply buffer pointed by
908 [Out] in non-blocking mode this value is updated by the IPC service to the
909 actual reply length (in bytes).
910 @Param[in] f_Completion - Pointer to a completion callback to be used in non-blocking send mode;
911 The completion callback is invoked by the IPC service upon
912 completion of the IPC transaction (consisting of a message and an optional
914 If this pointer is NULL, the function is expected to block until the IPC
915 transaction is complete.
916 @Param[in] h_Arg - Abstract handle to the sending module; passed unchanged to the f_Completion
917 callback function as the first argument.
919 @Return E_OK on success; Error code otherwise.
920 *//***************************************************************************/
921 t_Error XX_IpcSendMessage(t_Handle h_Session,
925 uint32_t *p_ReplyLength,
926 t_IpcMsgCompletion *f_Completion,
930 /** @} */ /* end of xx_ipc group */
931 /** @} */ /* end of xx_id group */
933 /** FreeBSD Specific additions. */
934 void XX_TrackInit(void);
935 physAddress_t XX_TrackAddress(void *addr);
936 void XX_UntrackAddress(void *addr);
938 #endif /* __XX_EXT_H */