source: svn/newcon3bcm2_21bu/nexus/build/tools/kernelproxy/bapi_usercall.pm

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

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

  • Property svn:executable set to *
File size: 10.6 KB
Line 
1#!/usr/bin/perl
2#     (c)2004-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: bapi_usercall.pm $
39# $brcm_Revision: 17 $
40# $brcm_Date: 12/7/11 10:41a $
41#
42# File Description:
43#
44# Revision History:
45#
46# $brcm_Log: /nexus/build/tools/kernelproxy/bapi_usercall.pm $
47#
48# 17   12/7/11 10:41a erickson
49# SW7420-2141: merge as much duplicated kernelmode proxy/usermode ipc
50#  perl code as possible
51#
52# 16   11/1/11 9:57a erickson
53# SW7231-391: add typecast
54#
55# 15   3/17/11 12:00p erickson
56# SW7346-101: fix NEXUS_StopCallbacks for secondary destructors
57#  (specifically, NEXUS_Playpump_ClosePidChannel)
58#
59# 14   2/8/11 10:44a erickson
60# SW7420-1123: use separate #ifdef NEXUS_PROXY_THUNK_LAYER for proxy
61#  thunk
62#
63# 13   2/3/11 6:37p vsilyaev
64# SW7420-1441: Use local (non proxied) implementation for function that
65#  flush CPU cache
66#
67# 12   1/19/11 3:42p erickson
68# SW7420-1123: refactor kernelproxy to correspond to usermode changes
69#
70# 11   10/14/10 12:34p erickson
71# SW7420-1148: add secondary_destructor to support
72#  NEXUS_Playpump_ClosePidChannel, verify function attr in one place,
73#  support multiple param verifications per ioctl
74#
75# 10   6/15/10 4:46p erickson
76# SW7405-4011: add NEXUS_P_Proxy_StartCallbacks to proxy to clean up stop
77#  callbacks list
78#
79# 9   6/10/10 4:56p vsilyaev
80# SW7405-4011: Added StopCallbacks into the driver ioctl code
81#
82# 8   6/8/10 6:40p vsilyaev
83# SW7405-4011: Added user level StopCallbacks call
84#
85# 7   1/30/08 6:18p vsilyaev
86# PR 38682: Added support for callbacks that are passed directly as
87#  function arguments
88#
89# 6   1/28/08 12:33p vsilyaev
90# PR 38682: Added support for attribute tags applied to structure
91#  members.
92#
93# 5   1/25/08 2:35p vsilyaev
94# PR 38682: Added handling of 'attr' to the function arguments
95#
96# 4   1/24/08 4:38p vsilyaev
97# PR 38682: Improved kernel/proxy environment
98#
99# 3   1/23/08 9:21p vobadm
100# PR35457: update docs
101#
102# 2   1/23/08 3:14p vsilyaev
103# PR 38682: Added support for linux kernel/userspace proxy mode
104#
105# 1   1/18/08 2:15p jgarrett
106# PR 38808: Merging to main branch
107#
108# Nexus_Devel/2   1/11/08 4:27p vsilyaev
109# PR 38682: Adding kernel support
110#
111# 5   1/5/07 11:52a erickson
112# PR26790: for proxy-layer callback conversion, we must convert back on
113# callback out params.
114#
115# 4   3/15/06 4:51p vsilyaev
116# PR20221: NetIF DMA interface
117#
118# 3   9/12/05 12:35p mphillip
119# PR16870: Fix kernel-mode macrovision support
120#
121# 2   9/8/05 6:23p mphillip
122# PR16870: Support for the macrovision data in bdisplay_settings
123#
124# 1   2/7/05 6:56p dlwin
125# Merge down for release 2005_REFSW_MERGETOMAIN:
126#
127# Irvine_BSEAVSW_Devel/10   1/26/05 11:04a erickson
128# PR13837: convert buffer_base to user address
129#
130# Irvine_BSEAVSW_Devel/9   7/23/04 2:41p erickson
131# PR11771: updated proxy layer for settop api changes
132#
133# Irvine_BSEAVSW_Devel/8   7/9/04 1:38p erickson
134# PR11771: rebuilt proxy layer for settop api dataflow redesign, and
135# handle all callbacks with new perl module
136#
137# Irvine_BSEAVSW_Devel/7   6/24/04 10:24a erickson
138# PR11135: added "don't modify" headers
139#
140# Irvine_BSEAVSW_Devel/6   6/18/04 12:33p erickson
141# PR11135: added some timing debug code which can be uncommented if
142# needed
143#
144# Irvine_BSEAVSW_Devel/5   6/17/04 9:37a erickson
145# PR11135: recpump callback enabled
146#
147# Irvine_BSEAVSW_Devel/4   6/16/04 5:16p erickson
148# PR11135: added callback support
149#
150# Irvine_BSEAVSW_Devel/3   6/2/04 2:45p erickson
151# PR11204: changed/removed deprecated settop api functions
152#
153# Irvine_BSEAVSW_Devel/2   6/1/04 11:28a erickson
154# PR11135: added comment
155#
156# Irvine_BSEAVSW_Devel/1   5/17/04 11:14a erickson
157# PR11135: added initial linux proxy impl
158#
159#############################################################################
160use strict;
161use bapi_common;
162use bapi_classes;
163
164package bapi_usercall;
165
166sub generate
167{
168    my ($filename, $module, $structs, @funcs) = @_;
169    my $func;
170    my $destructors = bapi_classes::get_destructors \@funcs;
171    my $module_lc = lc $module;
172    open FILE, ">$filename";
173
174    print FILE bapi_util::header $module;
175
176    print FILE "#define NEXUS_PROXY_THUNK_LAYER\n";
177    print FILE "#include \"proxy/nexus_proxy_prologue.h\"\n";
178    print FILE "#include \"nexus_${module_lc}_module.h\"\n";
179    print FILE "#include \"nexus_core_utils.h\"\n";
180    print FILE "BDBG_MODULE(nexus_${module_lc}_proxy);\n";
181    print FILE "\n\n";
182    print FILE "#define nexus_proxy_module_init nexus_proxy_${module_lc}_init\n";
183    print FILE "#define nexus_proxy_module_uninit nexus_proxy_${module_lc}_uninit\n";
184    print FILE "#define nexus_proxy_module_state nexus_proxy_${module_lc}_state\n";
185    print FILE "#include \"" . (bapi_common::ioctl_header $module) . "\"\n";
186    print FILE "#define NEXUS_IOCTL_MODULE_INIT " .  (bapi_common::version_ioctl $module) . "\n";
187    print FILE "#define NEXUS_PROXY_MODULE_VERSION " .  (bapi_common::version_define $module) . "\n";
188    print FILE "#define NEXUS_PROXY_MODULE_NAME \"$module\"\n";
189    print FILE "#include \"proxy/nexus_proxy_body.h\"\n";
190
191    for $func (@funcs) {
192        my $params = $func->{PARAMS};
193        my $param;
194        my $ioctl = bapi_common::ioctl_name $module, $func;
195        my $arg = "NULL";
196        my $attr = bapi_common::process_function_attributes $func, $structs, \@funcs;
197
198        next if(exists $func->{ATTR}->{'local'}); # local function compiled verbatim into the proxy code
199
200        print FILE "$func->{PROTOTYPE}\n\{\n";
201        print FILE "  int rc;\n";
202        if ($func->{RETTYPE} eq "NEXUS_Error") {
203            print FILE "  NEXUS_Error result=NEXUS_SUCCESS;\n";
204        } elsif ($func->{RETTYPE} ne "void") {
205            print FILE "  $func->{RETTYPE} result=($func->{RETTYPE})NULL;\n";
206        }
207
208
209        print FILE "  NEXUS_PROXY_ENTER($func->{FUNCNAME});\n";
210        my $stopcallbacks_handle = bapi_classes::get_stopcallbacks_handle $func, $destructors;
211        if (defined $stopcallbacks_handle) {
212            print FILE "  NEXUS_StopCallbacks((void*)$stopcallbacks_handle);\n";
213        }
214
215        print FILE "  if(nexus_proxy_module_state.fd) {\n";
216        # If no params, no ioctl
217        unless ($func->{NOSTRUCT}) {
218            my $struct = bapi_common::ioctl_struct $module, $func;
219
220            print FILE "    $struct st;\n";
221            bapi_util::print_code \*FILE, $attr->{proxy_vars}, "    ";
222            print FILE "\n";
223
224            bapi_util::print_code \*FILE, $attr->{proxy_pre_call}, "    ";
225
226            for $param (@$params) {
227                if ($param->{ISREF}) {
228                    print FILE "    st.$param->{NAME} = $param->{NAME};\n";
229                } else {
230                    if($param->{ATTR}->{'memory'}) {
231                    }
232                    print FILE "    st.$param->{NAME} = $param->{NAME};\n";
233                }
234            }
235            $arg = "(void *)&st";
236        }
237        print FILE "    rc = ioctl( nexus_proxy_module_state.fd, $ioctl, $arg);\n";
238        if ($func->{RETTYPE} eq "NEXUS_Error") {
239            print FILE "    if (rc!=0) {result=BERR_TRACE(NEXUS_OS_ERROR);goto done;}\n";
240        } else {
241            print FILE "    if (rc!=0) {rc=BERR_TRACE(NEXUS_OS_ERROR);goto done;}\n";
242        }
243
244        if ($func->{RETTYPE} ne "void") {
245            print FILE "    result = st.__retval;\n";
246        }
247
248        if (defined $stopcallbacks_handle) {
249            print FILE "  NEXUS_P_Proxy_StartCallbacks((void*)$stopcallbacks_handle);\n";
250        }
251
252        if(exists $attr->{proxy_post_success})  {
253            # if postprocessing is required test error codee, and produce postprocessing
254            if ($func->{RETTYPE} eq "NEXUS_Error") {
255                print FILE "    if(result==NEXUS_SUCCESS) {\n";
256            } elsif ($func->{RETTYPE} ne "void") {
257                print FILE "    if(result!=NULL) {\n";
258            } else {
259                print FILE "    {\n";
260            }
261            bapi_util::print_code \*FILE, $attr->{proxy_post_success}, "    ";
262            print FILE "    }\n";
263        }
264
265        print FILE "  } else {\n";
266        if ($func->{RETTYPE} eq "NEXUS_Error") {
267            print FILE "    result=BERR_TRACE(NEXUS_OS_ERROR);goto done;\n";
268        } else {
269            print FILE "    rc=BERR_TRACE(NEXUS_OS_ERROR);goto done;\n";
270        }
271        print FILE "  }\n";
272
273
274        print FILE "\n\n done:\n";
275
276        print FILE "  NEXUS_PROXY_LEAVE($func->{FUNCNAME});\n";
277        if ($func->{RETTYPE} ne "void") {
278            print FILE "  return result;\n"
279        } else {
280            print FILE "  return ;\n"
281        }
282        print FILE "}\n\n\n";
283    }
284    close FILE;
285}
286
2871;
288
Note: See TracBrowser for help on using the repository browser.