source: svn/trunk/newcon3bcm2_21bu/nexus/modules/file/src/nexus_file_module.c

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

first commit

  • Property svn:executable set to *
File size: 4.7 KB
Line 
1/***************************************************************************
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: nexus_file_module.c $
39 * $brcm_Revision: 5 $
40 * $brcm_Date: 9/6/11 10:10a $
41 *
42 * Module Description:
43 *
44 * Revision History:
45 *
46 * $brcm_Log: /nexus/modules/file/src/nexus_file_module.c $
47 *
48 * 5   9/6/11 10:10a erickson
49 * SWNOOS-482: correct internal spelling
50 *
51 * 4   9/6/11 10:05a erickson
52 * SWNOOS-482: add NEXUS_FileModuleSettings.schedulerSettings[] per-thread
53 *  array
54 *
55 * 3   4/20/11 7:48p vsilyaev
56 * SW7425-394: Allow application to set number of I/O worker threads that
57 *  are serving I/O requests
58 *
59 * 2   11/11/10 5:17p vsilyaev
60 * SW7405-4995: Use BKNI_Memcmp to preinitialize structure used in
61 *  GetDefaultSettings
62 *
63 * 1   1/18/08 2:16p jgarrett
64 * PR 38808: Merging to main branch
65 *
66 * Nexus_Devel/2   10/11/07 6:24p vsilyaev
67 * PR 35824: Fixed naming
68 *
69 * Nexus_Devel/1   10/10/07 3:57p vsilyaev
70 * PR 35824: File I/O module
71 *
72 **************************************************************************/
73#include "nexus_file_module.h"
74
75BDBG_MODULE("nexus_file_module");
76
77NEXUS_ModuleHandle NEXUS_FileModule;
78
79void 
80NEXUS_FileModule_GetDefaultSettings(NEXUS_FileModuleSettings *pSettings)
81{
82    unsigned i;
83    BDBG_ASSERT(pSettings);
84    BKNI_Memset(pSettings, 0, sizeof(*pSettings));
85    pSettings->maxQueuedElements = 30;
86    pSettings->workerThreads = 2;
87    for (i=0;i<NEXUS_FILE_MAX_IOWORKERS;i++) {
88        NEXUS_Thread_GetDefaultSettings(&pSettings->schedulerSettings[i]);
89    }
90    return;
91}
92
93NEXUS_ModuleHandle
94NEXUS_FileModule_Init(const NEXUS_FileModuleSettings *pSettings)
95{
96    BERR_Code rc;
97    NEXUS_FileModuleSettings settings;
98
99    if(pSettings==NULL) {
100        NEXUS_FileModule_GetDefaultSettings(&settings);
101        pSettings = &settings;
102    }
103    NEXUS_FileModule = NEXUS_Module_Create("file", NULL);
104    if(!NEXUS_FileModule) { rc = BERR_TRACE(BERR_OUT_OF_SYSTEM_MEMORY); goto err_module; }
105    rc = NEXUS_File_P_Scheduler_Start(pSettings);
106    if(rc!=BERR_SUCCESS) { rc = BERR_TRACE(rc); goto err_scheduler;}
107    return NEXUS_FileModule;
108
109err_scheduler:
110    NEXUS_Module_Destroy(NEXUS_FileModule);
111err_module:
112    return NULL;
113}
114   
115void 
116NEXUS_FileModule_Uninit(void)
117{
118    NEXUS_File_P_Scheduler_Stop();
119    NEXUS_Module_Destroy(NEXUS_FileModule);
120    NEXUS_FileModule = NULL;
121    return;
122}
123
124
125
126
Note: See TracBrowser for help on using the repository browser.