source: svn/newcon3bcm2_21bu/nexus/build/tools/ipcthunk/bapi_thunks.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: 8.3 KB
Line 
1#!/usr/bin/perl
2#     (c)2007-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_thunks.pm $
39# $brcm_Revision: 3 $
40# $brcm_Date: 3/17/11 11:59a $
41#
42# File Description:
43#
44# Revision History:
45#
46# $brcm_Log: /nexus/build/tools/ipcthunk/bapi_thunks.pm $
47#
48# 3   3/17/11 11:59a erickson
49# SW7346-101: fix NEXUS_StopCallbacks for secondary destructors
50#  (specifically, NEXUS_Playpump_ClosePidChannel)
51#
52# 2   1/19/11 2:03p erickson
53# SW7420-1123: socket-based usermode IPC
54#
55# 1   9/29/10 9:34a erickson
56# SW7420-1123: add linux usermode IPC
57#
58# 8   9/22/09 1:54p gmohile
59# SW7405-3060 : Export kernel symbols
60#
61# 7   3/28/08 10:47a vsilyaev
62# PR 40863: Call NEXUS_StopCalbacks prior to the 'destructor' call, since
63#  StopCallback is sticky it would prevent further callback to fire
64#
65# 6   3/24/08 6:58p vsilyaev
66# PR 40863: Changed order of calls to NEXUS_StopCallbacks and
67#  "destructors" in ordder to stop callbacks that were fired during call
68#  to the destructor function
69#
70# 5   3/24/08 6:42p vsilyaev
71# PR 40863: Added injection of NEXUS_StopCallbacks into all destructors
72#
73# 4   3/21/08 11:57a vsilyaev
74# PR 38682: Fixed typo in description
75#
76# 3   1/25/08 4:24p vsilyaev
77# PR 38682: Reduce code size of the generated code
78#
79# 2   1/24/08 4:34p vsilyaev
80# PR 38682: Reduced size and made optional tracing of thunk layer
81#
82# 1   1/18/08 2:15p jgarrett
83# PR 38808: Merging to main branch
84#
85# Nexus_Devel/5   10/15/07 2:53p vsilyaev
86# PR 35824: Fixed handling of (void) functions
87#
88# Nexus_Devel/4   10/12/07 11:49a erickson
89# PR36066: added "or die" to file opens
90#
91# Nexus_Devel/3   10/8/07 3:21p erickson
92# PR35395: added params and retval to trace
93#
94# Nexus_Devel/2   10/3/07 12:14p erickson
95# PR35395: enable thunk trace
96#
97# Nexus_Devel/1   9/27/07 1:33p erickson
98# PR35395: initial impl
99#
100#############################################################################
101use strict;
102
103package bapi_thunks;
104use bapi_common;
105
106sub build_thunks
107{
108    my ($module, $filename, $funcs) = @_;
109    my $func;
110    my $destructors = bapi_common::get_destructors $funcs;
111    open FILE, ">$filename" or die;
112
113    print FILE "/*********************************\n";
114    print FILE "*\n";
115    print FILE "* This file is autogenerated by the Nexus Platform makefile.\n";
116    print FILE "*\n";
117    print FILE "* This file acquires the module lock for every public API call into that module. The actual implementation of each function is remapped to _impl.\n";
118    print FILE "*\n";
119    print FILE "*********************************/\n";
120    print FILE "#define NEXUS_THUNK_LAYER\n";
121    print FILE "#include \"nexus_${module}_module.h\"\n";
122    if(scalar keys %$destructors) {
123        print FILE "#include \"nexus_core_utils.h\"\n";
124    }
125    print FILE "BDBG_MODULE(nexus_${module}_thunks);\n";
126    print FILE "#define BDBG_MSG_TRACE(x) \n";
127    print FILE "/* use local static function in order to reduce size of compiled code, size would reduce since NEXUS_XXXModule expanded to function call with three arguments (where at least one is a global symbol) */\n";
128    print FILE "static void module_lock(void) { NEXUS_LockModule();}\n";
129    print FILE "static void module_unlock(void) { NEXUS_UnlockModule();}\n";
130
131
132    # generate prototypes for all the _impl functions
133    for $func (@$funcs) {
134        # NOTE: If there's an exception and a function does not belong in the thunk layer, add it here.
135
136        my $impl = $func->{PROTOTYPE};
137        $impl =~ s/$func->{FUNCNAME}/$func->{FUNCNAME}_impl/;
138        print FILE "$impl;\n";
139    }
140
141    # generate the actual thunk layer functions which call the impl functions
142    for $func (@$funcs) {
143        my $params = $func->{PARAMS};
144        my $param;
145
146        print FILE "$func->{PROTOTYPE}\n\{\n";
147        if ($func->{RETTYPE} eq "void") {
148        }
149        else {
150            print FILE "  $func->{RETTYPE} result;\n";
151        }
152
153        # enter MSG
154        print FILE "  BDBG_MSG_TRACE((\">%s\(";
155        for $param (@$params) {
156            print FILE "%#lx";
157            if ($param != $params->[-1]) { print FILE ", "; }
158        }
159        print FILE ")\" ";
160        print FILE ", \"$func->{FUNCNAME}\"";
161        for $param (@$params) {
162            print FILE ", ";
163            print FILE "(unsigned long)$param->{NAME}";
164        }
165        print FILE "));\n";
166
167        my $stopcallbacks_handle = bapi_common::get_stopcallbacks_handle $func, $destructors;
168        if (defined $stopcallbacks_handle) {
169            print FILE "  NEXUS_StopCallbacks($stopcallbacks_handle);\n";
170        }
171
172        # make call
173        print FILE "  module_lock();\n";
174        if ($func->{RETTYPE} eq "void") {
175            print FILE "  $func->{FUNCNAME}_impl(";
176        }
177        else {
178            print FILE "  result = $func->{FUNCNAME}_impl(";
179        }
180        for $param (@$params) {
181            print FILE "$param->{NAME}";
182            if ($param != $params->[-1]) { print FILE ", "; }
183        }
184        print FILE ");\n";
185        print FILE "  module_unlock();\n";
186
187        # leave MSG and return value
188        if ($func->{RETTYPE} eq "void") {
189            print FILE "  BDBG_MSG_TRACE((\"<%s\", \"$func->{FUNCNAME}\"));\n";
190            print FILE "  return;\n";
191        }
192        else {
193            print FILE "  BDBG_MSG_TRACE((\"<%s\=%#lx\", \"$func->{FUNCNAME}\", (unsigned long)result));\n";
194            print FILE "  return result;\n";
195        }
196        print FILE "}\n\n";
197    }
198    close FILE;
199}
200
201sub build_remapping
202{
203    my ($filename, $funcs) = @_;
204    my $func;
205    open FILE, ">$filename" or die;
206
207    print FILE "/*********************************\n";
208    print FILE "*\n";
209    print FILE "* This file is autogenerated by the Nexus Platform makefile.\n";
210    print FILE "*\n";
211    print FILE "* This file remaps every public API function to _impl. This allows the Nexus modules to call their own public API without reacquiring the module lock.\n";
212    print FILE "*\n";
213    print FILE "*********************************/\n";
214    print FILE "#ifndef NEXUS_THUNK_LAYER\n";
215
216    for $func (@$funcs) {
217        print FILE "#define $func->{FUNCNAME} $func->{FUNCNAME}_impl\n";
218    }
219    print FILE "#endif\n";
220    print FILE "\n";
221    close FILE;
222}
223
2241;
Note: See TracBrowser for help on using the repository browser.