source: svn/trunk/newcon3bcm2_21bu/nexus/build/tools/kernelproxy/bapi_build.pl

Last change on this file was 2, checked in by phkim, 11 years ago

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 5.2 KB
Line 
1#!/usr/bin/perl
2#     (c)2003-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_build.pl $
39# $brcm_Revision: 9 $
40# $brcm_Date: 8/8/11 5:10p $
41#
42# File Description:
43#
44# Revision History:
45#
46# $brcm_Log: /nexus/build/tools/kernelproxy/bapi_build.pl $
47#
48# 9   8/8/11 5:10p erickson
49# SW7420-1689: add untrusted client api enforcement
50#
51# 6   12/7/10 5:47p erickson
52# SW7420-1148: refactor kernel mode proxy for process isolation
53#
54# 5   11/3/10 5:32p erickson
55# SW7420-1223: exclude nexus_base_mmap.h from thunks
56#
57# 4   9/15/10 3:44p jtna
58# SW7420-1004: add synthunk for CORE and PLATFORM
59#
60# 3   7/14/10 11:56a erickson
61# SW7405-4621: exclude nexus_base_os.h from thunk
62#
63# 2   9/22/09 1:54p gmohile
64# SW7405-3060 : Export kernel symbols
65#
66# 1   1/18/08 2:15p jgarrett
67# PR 38808: Merging to main branch
68#
69# Nexus_Devel/2   1/11/08 4:27p vsilyaev
70# PR 38682: Adding kernel support
71#
72# Nexus_Devel/1   9/27/07 1:33p erickson
73# PR35395: initial impl
74#
75#############################################################################
76use strict;
77
78use lib "../common";
79use bapi_parse_c;
80use bapi_ioctl_def;
81use bapi_usercall;
82use bapi_driver_ioctl;
83use bapi_kernel_export;
84use bapi_untrusted_api;
85
86my $file;
87my @funcs;
88my %structs;
89
90if ($#ARGV == -1) {
91    print "Usage: perl bapi_build.pl module destdir class_handles file1.h file2.h ...\n";
92    exit;
93}
94
95# Process all files on the command line
96my $module = shift @ARGV;
97my $module_lc = lc $module;
98my $destdir = shift @ARGV;
99
100# read class_handles.inc file into a list
101my $class_list_file = shift @ARGV;
102open FILE, $class_list_file;
103my @class_handles = <FILE>;
104close FILE;
105chomp @class_handles;
106
107for $file (@ARGV) {
108    #print "Parsing $file\n";
109    if (($file =~ /_init.h$/ && $file !~ /nexus_platform_init.h$/) ||
110        $file =~ /nexus_base_\w+.h$/) {
111        next;
112    }
113    push @funcs, bapi_parse_c::get_func_prototypes $file;
114
115    my $file_structs = bapi_parse_c::parse_struct $file;
116    my $name;
117    my $members;
118    while (($name, $members) = each %$file_structs) {
119        $structs{$name} = $members;
120    }
121}
122
123# Build the perl datastructure
124my @funcrefs = bapi_parse_c::parse_funcs @funcs;
125
126# Print out the perl datastructure
127#bapi_parse_c::print_api @funcrefs;
128#bapi_parse_c::print_struct \%structs;
129
130my $version = bapi_parse_c::version_api @funcrefs;
131$version = ($version * 0x10000) + bapi_parse_c::version_struct \%structs;
132
133my $untrusted_api = bapi_untrusted_api::parse "../common/nexus_untrusted_api.txt";
134
135# Build thunk layer
136bapi_ioctl_def::generate "${destdir}/" . (bapi_common::ioctl_header $module) , $module, 101, $version, @funcrefs;
137bapi_usercall::generate "${destdir}/nexus_${module_lc}_proxy.c", $module, \%structs, @funcrefs;
138bapi_kernel_export::generate "${destdir}/nexus_${module_lc}_kernel_export.c", $module_lc, @funcrefs;
139bapi_driver_ioctl::generate "${destdir}/nexus_${module_lc}_driver.c", $module, $version, \%structs, \@funcrefs, \@class_handles, $untrusted_api;
140
Note: See TracBrowser for help on using the repository browser.