summaryrefslogtreecommitdiffstats
path: root/src/include/usr/mbox/mboxif.H
blob: f9846cbc3a8209d0182a01474893abf950cc189b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/include/usr/mbox/mboxif.H $                               */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2012,2014              */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
#ifndef __MBOX_MBOXIF_H
#define __MBOX_MBOXIF_H

#include <sys/msg.h>
#include <errl/errlentry.H>
#include <mbox/mbox_queues.H>

#define MBOX_TRACE_NAME MBOX_COMP_NAME
#define MBOXMSG_TRACE_NAME "MBOXMSG"

namespace MBOX
{
    enum
    {
        MBOX_NODE_FSP = -1,
    };

    /**
     * Register a message queue to receive mailbox messages
     * @param[in] i_queueu_id, The queue identifier
     * @param[in] i_msgQ, The message queue created with msg_q_create()
     *                    @see sys/msg.h
     * @return errlHndl_t on error
     */
    errlHndl_t msgq_register(queue_id_t i_queue_id, msg_q_t i_msgQ);

    /**
     * Un register a message queue from the mailbox service
     * @param[in] i_queue_id, The queue identifier
     * @return The message queue | NULL if i_queue_id not registered.
     */
    msg_q_t msgq_unregister(queue_id_t i_queue_id);

    /**
     * Send message asynchronously
     * @param[in] i_q_id id, of the FSP message queue to send the msg to.
     * @param[in] i_msg. The message to send.
     * @param[in] i_node The destination node [0-7] for IPC messages, 
     *                   otherwise the default is FSP
     *
     * @return errlHndl_t on error.
     *
     * @note extra_data payload is not supported for interprocessor
     *       communication(IPC) messages therefore the i_msg->extra_data field
     *       may be used as another user data field
     *
     * @pre For FSP mbox messages, i_msg->extra_data must be NULL If there is
     *      no payload associated with the message.
     *
     * @pre For FSP mbox messages, 
     *      i_msg->extra_data = malloc(size); i_msg->data[1] = size; 
     *      Any extra data associated with i_msg was obtained from the heap
     *      using malloc and i_msg->data[1] contains the length of that data.
     *
     * @post free(i_msg->extra_dat)  was done (if no error)
     * @post msg_free(i_msg) was done (if no error)
     */
    errlHndl_t send(queue_id_t i_q_id,
                    msg_t * i_msg,
                    int i_node = MBOX_NODE_FSP);

    /**
     * Send message synchronously
     * @param[in] i_q_id id, of the FSP message queue to send the msg to.
     * @param[in/out] io_msg. The message sent and returned.
     *
     * @return errlHndl_t on error
     *
     * @pre io_msg->extra_data ==  NULL If there is no extra data is associated
     *      with the message.
     *
     * @pre io_msg->extra_data = malloc(size); io_msg->data[1] = size; 
     *      Any extra data associated with io_msg was obtained from the heap
     *      using malloc and io_msg->data[1] contains the length of that data.
     *
     * @post free(i_msg->extra_data)  was done (if no error)
     *
     * @note: On return, if io_msg->extra_data != NULL, the caller must
     * call free(io_msg->extra_data);
     */
    errlHndl_t sendrecv(queue_id_t i_q_id, msg_t * io_msg);

    /**
     * Determine if the mailbox is enabled
     *
     * @return bool
     *             true    -> mailbox is enabled
     *             flalse  -> mailbox is disabled (spless system)
     */
    bool mailbox_enabled();

    /**
     * Suspend the mailbox. 
     *
     * @return error handle on error
     *
     * @note:
     *     Any message sent to the FSP will be queued and send after the mailbox
     *     is resumed. Interrupts from the FSP MBox will be masked.
     */
    errlHndl_t suspend();

    /**
     * Resume the mailbox
     *
     * @return error handle on error
     *
     * @note  FSP Mbox re-enabled, queued messages sent.
     */
    errlHndl_t resume();

}; // end namespace MBOX

#endif
OpenPOWER on IntegriCloud