| 1 | /****************************************************************************** |
|---|
| 2 | * (c)2011 Broadcom Corporation |
|---|
| 3 | * |
|---|
| 4 | * This program is the proprietary software of Broadcom Corporation and/or its licensors, |
|---|
| 5 | * and may only be used, duplicated, modified or distributed pursuant to the terms and |
|---|
| 6 | * conditions of a separate, written license agreement executed between you and Broadcom |
|---|
| 7 | * (an "Authorized License"). Except as set forth in an Authorized License, Broadcom grants |
|---|
| 8 | * no license (express or implied), right to use, or waiver of any kind with respect to the |
|---|
| 9 | * Software, and Broadcom expressly reserves all rights in and to the Software and all |
|---|
| 10 | * intellectual property rights therein. IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU |
|---|
| 11 | * HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY |
|---|
| 12 | * NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE. |
|---|
| 13 | * |
|---|
| 14 | * Except as expressly set forth in the Authorized License, |
|---|
| 15 | * |
|---|
| 16 | * 1. This program, including its structure, sequence and organization, constitutes the valuable trade |
|---|
| 17 | * secrets of Broadcom, and you shall use all reasonable efforts to protect the confidentiality thereof, |
|---|
| 18 | * and to use this information only in connection with your use of Broadcom integrated circuit products. |
|---|
| 19 | * |
|---|
| 20 | * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" |
|---|
| 21 | * AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR |
|---|
| 22 | * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO |
|---|
| 23 | * THE SOFTWARE. BROADCOM SPECIFICALLY DISCLAIMS ANY AND ALL IMPLIED WARRANTIES |
|---|
| 24 | * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, |
|---|
| 25 | * LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION |
|---|
| 26 | * OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF |
|---|
| 27 | * USE OR PERFORMANCE OF THE SOFTWARE. |
|---|
| 28 | * |
|---|
| 29 | * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS |
|---|
| 30 | * LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR |
|---|
| 31 | * EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR |
|---|
| 32 | * USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF |
|---|
| 33 | * THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT |
|---|
| 34 | * ACTUALLY PAID FOR THE SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE |
|---|
| 35 | * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF |
|---|
| 36 | * ANY LIMITED REMEDY. |
|---|
| 37 | * |
|---|
| 38 | * $brcm_Workfile: bipc_impl.h $ |
|---|
| 39 | * $brcm_Revision: 1 $ |
|---|
| 40 | * $brcm_Date: 10/4/11 5:44p $ |
|---|
| 41 | * |
|---|
| 42 | * Module Description: |
|---|
| 43 | * |
|---|
| 44 | * Revision History: |
|---|
| 45 | * |
|---|
| 46 | * $brcm_Log: /nexus/lib/ipc/bipc_impl.h $ |
|---|
| 47 | * |
|---|
| 48 | * 1 10/4/11 5:44p vsilyaev |
|---|
| 49 | * SW7425-1364: Reference applicaion IPC and reference server |
|---|
| 50 | * |
|---|
| 51 | *****************************************************************************/ |
|---|
| 52 | #ifndef BIPC_IMPL_H__ |
|---|
| 53 | #define BIPC_IMPL_H__ |
|---|
| 54 | |
|---|
| 55 | #include "blst_list.h" |
|---|
| 56 | #include "bkni_multi.h" |
|---|
| 57 | #include "bipc_client.h" |
|---|
| 58 | #include "bipc_client_priv.h" |
|---|
| 59 | #include "bipc_server.h" |
|---|
| 60 | #include "berr_ids.h" |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | typedef struct bipc_client { |
|---|
| 64 | BDBG_OBJECT(bipc_client) |
|---|
| 65 | BKNI_MutexHandle lock; |
|---|
| 66 | int recv_fd; |
|---|
| 67 | int send_fd; |
|---|
| 68 | size_t ipc_buf_size; |
|---|
| 69 | const bipc_interface_descriptor * const *interfaces; |
|---|
| 70 | size_t interface_count; |
|---|
| 71 | uint8_t buf[1]; /* variable length buffer */ |
|---|
| 72 | } bipc_client ; |
|---|
| 73 | |
|---|
| 74 | typedef struct b_ipc_server_instance { |
|---|
| 75 | const bipc_server_descriptor *interface; |
|---|
| 76 | void *object; |
|---|
| 77 | unsigned generation; /* counter that is used to auto-close in reverse order */ |
|---|
| 78 | } b_ipc_server_instance; |
|---|
| 79 | |
|---|
| 80 | struct bipc_server_client; |
|---|
| 81 | |
|---|
| 82 | |
|---|
| 83 | typedef struct bipc_server { |
|---|
| 84 | BDBG_OBJECT(bipc_server) |
|---|
| 85 | BKNI_MutexHandle lock; |
|---|
| 86 | BLST_D_HEAD(bipc_server_client_list, bipc_server_client) clients; |
|---|
| 87 | bipc_server_create_settings create_settings; |
|---|
| 88 | size_t ipc_buf_size; |
|---|
| 89 | uint8_t buf[1]; /* variable length buffer */ |
|---|
| 90 | } bipc_server ; |
|---|
| 91 | |
|---|
| 92 | struct bipc { |
|---|
| 93 | union { |
|---|
| 94 | bipc_server server; |
|---|
| 95 | bipc_client client; |
|---|
| 96 | } t; |
|---|
| 97 | }; |
|---|
| 98 | |
|---|
| 99 | typedef struct b_ipc_pkt_in { |
|---|
| 100 | unsigned pkt_size; |
|---|
| 101 | unsigned instance; |
|---|
| 102 | unsigned method; |
|---|
| 103 | } b_ipc_pkt_in; |
|---|
| 104 | |
|---|
| 105 | typedef struct b_ipc_pkt_out { |
|---|
| 106 | unsigned pkt_size; |
|---|
| 107 | } b_ipc_pkt_out; |
|---|
| 108 | |
|---|
| 109 | |
|---|
| 110 | #define BERR_END_OF_FILE BERR_MAKE_CODE(BERR_APP_ID, 1) |
|---|
| 111 | |
|---|
| 112 | int b_safe_write(int fd, const void *buf, size_t buf_size); |
|---|
| 113 | int b_safe_read(int fd, void *buf, size_t buf_size); |
|---|
| 114 | |
|---|
| 115 | #endif /* BIPC_IMPL_H__ */ |
|---|
| 116 | |
|---|