source: svn/newcon3bcm2_21bu/nexus/lib/ipc/build/bipc_server_test.c

Last change on this file was 76, checked in by megakiss, 10 years ago

1W 대기전력을 만족시키기 위하여 POWEROFF시 튜너를 Standby 상태로 함

  • Property svn:executable set to *
File size: 8.7 KB
Line 
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_server_test.c $
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/build/bipc_server_test.c $
47 *
48 * 1   10/4/11 5:44p vsilyaev
49 * SW7425-1364: Reference applicaion IPC and reference server
50 *
51 *****************************************************************************/
52#include "bstd.h"
53#include "bkni_multi.h"
54#include "bipc_server.h"
55
56#include "bsspk_decoder.h"
57#include "bsac_session.h"
58#include <unistd.h>
59#include <sys/types.h>
60#include <unistd.h>
61#include <sys/wait.h>
62#include "bipc_test.h"
63
64
65BDBG_MODULE(bipc_server_test);
66
67#include "ipc_server.h"
68
69static const bipc_server_descriptor * const interfaces[] = {
70   &bipc_bsac_session_server_descriptor,
71   &bipc_bsspk_decoder_server_descriptor
72};
73
74int main(int argc, const char *argv[])
75{
76    int recv_fd[2];
77    int send_fd[2];
78    int rc;
79    pid_t child;
80    bipc_t ipc;
81    bipc_server_client_t client;
82    bipc_server_create_settings settings;
83    bipc_server_client_create_settings client_settings;
84
85    BSTD_UNUSED(argc);
86    BSTD_UNUSED(argv);
87    BKNI_Init();
88    BDBG_Init();
89
90    bipc_server_get_default_create_settings(&settings);
91    settings.interfaces = interfaces;
92    settings.interface_count = sizeof(interfaces)/sizeof(*interfaces);
93    ipc = bipc_server_create(&settings);
94    BDBG_ASSERT(ipc);
95
96    rc = pipe(recv_fd);
97    BDBG_ASSERT(rc==0);
98
99    rc = pipe(send_fd);
100    BDBG_ASSERT(rc==0);
101
102    BDBG_LOG(("Fork"));
103    child = fork();
104    BDBG_LOG(("Fork -> %u", getpid() ));
105    BDBG_ASSERT(child!=-1);
106
107    if(child == 0) {
108        /* child */
109        rc = dup2(recv_fd[1], CLIENT_SEND_FD);
110        BDBG_ASSERT(rc==CLIENT_SEND_FD);
111        close(recv_fd[1]);
112        rc = dup2(send_fd[0], CLIENT_RECV_FD);
113        BDBG_ASSERT(rc==CLIENT_RECV_FD);
114        close(send_fd[0]);
115        rc = execlp(argv[1], argv[1], NULL);
116        BDBG_ASSERT(rc==0);
117        _exit(0);
118    }
119    close(recv_fd[1]);
120    close(send_fd[0]);
121    bipc_server_get_default_client_create_settings(&client_settings);
122    client_settings.recv_fd = recv_fd[0];
123    client_settings.send_fd = send_fd[1];
124    client_settings.ipc_context = "client";
125    client = bipc_server_client_create(ipc, &client_settings);
126    for(;;) {
127        unsigned processed;
128        BDBG_LOG(("Process"));
129        rc = bipc_server_client_process(ipc, client);
130        if(rc!=0) {
131            break;
132        }
133    }
134    BDBG_LOG(("Done"));
135    bipc_server_client_destroy(ipc, client);
136    close(client_settings.recv_fd);
137    close(client_settings.send_fd);
138    waitpid(child, NULL, 0);
139    bipc_server_destroy(ipc);
140    BDBG_Uninit();
141    BKNI_Uninit();
142    return 0;
143}
144
145
146struct bsac_session {
147    int unused;
148};
149
150bsac_session_t  bsac_session_create(bipc_t ipc, const bsac_session_client_configuration *config)
151{
152    bsac_session_t session;
153    BSTD_UNUSED(ipc);
154    BSTD_UNUSED(config);
155    BDBG_LOG(("bsac_session_create:%s '%s'", (char *)ipc, config->name.string));
156    session = BKNI_Malloc(sizeof(*session));
157    BDBG_LOG(("bsac_session_create:>%#lx", (unsigned long)session ));
158    return  session;
159}
160
161int   bsac_session_get_clientinfo(bsac_session_t session, bsac_session_client_info *info)
162{
163    BDBG_LOG(("bsac_session_get_clientinfo:%#lx %#lx", (unsigned long)session, (unsigned long)info ));
164    BKNI_Memset(info, 0, sizeof(*info));
165    info->client = (unsigned long)session;
166    info->certificate.length = BKNI_Snprintf(info->certificate.data, sizeof(info->certificate.data), "client %#x", session);
167    return 0;
168}
169
170void  bsac_session_destroy(bsac_session_t session)
171{
172    BDBG_LOG(("bsac_session_destroy:%#lx", (unsigned long)session ));
173    BKNI_Free(session);
174    return;
175}
176
177struct bsspk_decoder {
178    int unused;
179};
180
181bsspk_decoder_t  bsspk_decoder_open(bipc_t ipc)
182{
183    bsspk_decoder_t decoder;
184    BDBG_LOG(("bsspk_decoder_open:%s", (char *)ipc));
185    BSTD_UNUSED(ipc);
186    decoder = BKNI_Malloc(sizeof(*decoder));
187    BDBG_LOG(("bsspk_decoder_open:>%#lx", (unsigned long)decoder));
188    return  decoder;
189}
190
191int bsspk_decoder_get_resources(bsspk_decoder_t decoder, bsspk_decoder_resources *resources)
192{
193    BDBG_LOG(("bsspk_decoder_get_resources:%#lx", (unsigned long)decoder));
194    BKNI_Memset(resources, 0, sizeof(*resources));
195    return 0;
196}
197
198int bsspk_decoder_get_default_audio_settings(bsspk_decoder_t decoder, bsspk_decoder_audio_settings *settings)
199{
200    BDBG_LOG(("bsspk_decoder_get_default_audio_settings:%#lx", (unsigned long)decoder));
201    BSTD_UNUSED(decoder);
202    BKNI_Memset(settings, 0, sizeof(*settings));
203    return 0;
204}
205
206int bsspk_decoder_set_audio_settings(bsspk_decoder_t decoder, unsigned id, const bsspk_decoder_audio_settings *settings)
207{
208    BDBG_LOG(("bsspk_decoder_set_audio_settings:%#lx", (unsigned long)decoder));
209    BSTD_UNUSED(decoder);
210    BSTD_UNUSED(id);
211    BSTD_UNUSED(settings);
212    return 0;
213}
214
215int bsspk_decoder_get_default_video_settings(bsspk_decoder_t decoder, bsspk_decoder_video_settings *settings)
216{
217    BDBG_LOG(("bsspk_decoder_get_default_video_settings:%#lx", (unsigned long)decoder));
218    BSTD_UNUSED(decoder);
219    BKNI_Memset(settings, 0, sizeof(*settings));
220    return 0;
221}
222
223int bsspk_decoder_set_video_settings(bsspk_decoder_t decoder, unsigned id, const bsspk_decoder_video_settings *settings)
224{
225    BDBG_LOG(("bsspk_decoder_set_video_settings:%#lx", (unsigned long)decoder));
226    BSTD_UNUSED(decoder);
227    BSTD_UNUSED(id);
228    BSTD_UNUSED(settings);
229    return 0;
230}
231
232void bsspk_decoder_close(bsspk_decoder_t decoder)
233{
234    BDBG_LOG(("bsspk_decoder_close:%#lx", (unsigned long)decoder));
235    BSTD_UNUSED(decoder);
236    return;
237}
238
239int bsspk_decoder_clock_get(bsspk_decoder_t decoder, uint32_t *clock)
240{
241    BDBG_LOG(("bsspk_decoder_clock_get:%#lx", (unsigned long)decoder));
242    BSTD_UNUSED(decoder);
243    BSTD_UNUSED(clock);
244    return 0;
245}
246
247int bsspk_decoder_clock_set(bsspk_decoder_t decoder, uint32_t clock)
248{
249    BDBG_LOG(("bsspk_decoder_clock_set:%#lx", (unsigned long)decoder));
250    BSTD_UNUSED(decoder);
251    BSTD_UNUSED(clock);
252    return 0;
253}
254
255int bsspk_decoder_clock_stop(bsspk_decoder_t decoder)
256{
257    BDBG_LOG(("bsspk_decoder_clock_stop:%#lx", (unsigned long)decoder));
258    BSTD_UNUSED(decoder);
259    return 0;
260}
261
262int bsspk_decoder_clock_start(bsspk_decoder_t decoder)
263{
264    BDBG_LOG(("bsspk_decoder_clock_start:%#lx", (unsigned long)decoder));
265    BSTD_UNUSED(decoder);
266    return 0;
267}
268   
269
Note: See TracBrowser for help on using the repository browser.