source: svn/newcon3bcm2_21bu/magnum/portinginterface/hsm/7552/a0/common/bhsm.h

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

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

  • Property svn:executable set to *
File size: 23.2 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: bhsm.h $
39 * $brcm_Revision: Hydra_Software_Devel/4 $
40 * $brcm_Date: 3/27/12 8:35p $
41 *
42 * Module Description:
43 *
44 * Revision History:
45 *
46 * $brcm_Log: /magnum/portinginterface/hsm/7422/a0/common/bhsm.h $
47 *
48 * Hydra_Software_Devel/4   3/27/12 8:35p atruong
49 * SWSECURITY-116: Bug for BHCP_VER referencing fixed
50 *
51 * Hydra_Software_Devel/3   10/18/11 9:41a atruong
52 * SWSECURITY-69: Support for 40-nm B0 Zeus 2.0 platforms
53 *
54 * Hydra_Software_Devel/2   1/24/11 10:49a atruong
55 * SW7422-26: Add HSM PI Support For 7422A0  - CC header format
56 *
57 ******************************************************************************/
58
59#ifndef BHSM_H__
60#define BHSM_H__
61
62#include "bchp.h"
63
64/* To support Zeus 2.0 and pre-Zeus platforms */
65#if (BCHP_CHIP == 7422) || (BCHP_CHIP==7425) || (BCHP_CHIP == 7346) || (BCHP_CHIP==7231)  || \
66     (BCHP_CHIP == 7344) || (BCHP_CHIP==7358) || (BCHP_CHIP == 7552)
67#define HSM_IS_ASKM_40NM 1
68#if (BCHP_VER >= BCHP_VER_B0)
69#define HSM_IS_ASKM_40NM_ZEUS_2_0 1
70#endif
71#endif
72
73
74#include "breg_mem.h"
75
76/* The following is for debug printing in user mode (AppFrameWork apps) */
77#if 0
78#ifdef USER_MODE_BHSM_DEBUG
79#define BDBG_MSG(x) printf x
80#define BDBG_ERR(x) printf x
81#endif
82#endif
83
84/* added to remove header file dependency chain*/
85#include "bhsm_priv.h"
86
87#ifdef __cplusplus
88extern "C" {
89#endif
90
91/* ??? Cannot use EnterCriticalSection while submitting any commands */  /* ??? BSYT, get rid of this */
92
93/***************************************************************************
94Summary:
95Host Secure Module (HSM) module context handle.
96
97Description:
98Opaque handle that is created in BHSM_Open.
99BHSM_Handle holds the context of the Host Secure Module.  The system
100should have only one BHSM_Handle. Caller of BHSM_Open is responsible to store
101this BHSM_Handle and uses it for the future function call after BHSM_Open function
102returns successfully.
103
104See Also:
105BHSM_Open, BHSM_Channel_Open
106
107****************************************************************************/
108typedef struct BHSM_P_Handle            *BHSM_Handle;
109
110
111/***************************************************************************
112Summary:
113HSM channel context handle.
114
115Description:
116Opaque handle that is created in BHSM_Channel_Open.
117BHSM_ChannelHandle holds the context of the Host Secure Module channel.  The system
118may have more than one BHSM_ChannelHandle if the chip can support multiple
119interfaces to submit Aegis commands.  Caller of BHSM_Channel_Open is
120responsible to store this BHSM_ChannelHandle and uses it for the future function
121call after BHSM_Channel_Open function returns successfully.
122
123See Also:
124BHSM_Open, BHSM_Channel_Open
125
126****************************************************************************/
127typedef struct BHSM_P_ChannelHandle     *BHSM_ChannelHandle;
128
129
130
131
132
133
134/* Basic Module Functions */
135
136
137/*****************************************************************************
138Summary:
139This function returns a recommended default settings for HSM module.
140
141Description:
142This function shall return a recommended default settings for HSM module.
143This function shall be called before BHSM_Open
144and the caller can then over-ride any of the default settings
145required for the build and configuration by calling BHSM_Open.
146
147These default settings are always the same regardless of how
148many times this function is called or what other functions have
149been called in the porting interface.
150
151
152Calling Context:
153The function shall be called from application level (for example in
154VxWorks or no-os) or from driver level (for example in Linux,
155recommended ioctl: BHSM_IOCTL_GET_DEFAULT_SETTINGS)
156
157Performance and Timing:
158This is a synchronous function that will return when it is done.
159
160Input:
161in_chipHandle - BCHP_Handle,  chip handle.
162
163Output:
164outp_sSettings - BHSM_Settings, a ref/pointer to the default setting.
165
166Returns:
167BERR_SUCCESS - success. Otherwise, there is an error.
168
169See Also:
170BHSM_Open
171BHSM_UpdateDefaultSettings
172
173*****************************************************************************/
174BERR_Code BHSM_GetDefaultSettings(
175                BHSM_Settings           *outp_sSettings,
176                BCHP_Handle             in_chipHandle           
177); 
178
179
180/*****************************************************************************
181Summary:
182This function updates the HSM driver special controls, e.g. HSM run in ISR mode or polling mode.
183
184Description:
185The default setting is using ISR inside HSM driver when receiving data from BSP. This function is provided to
186select polling mode, or toggle ISR/Polling mode.   It can also be used to modify the timeout value for polling
187or ISR (the default is 2000 ms). It can only be invoked from non-critical calling code section.
188
189Calling Context:
190Any time it can be called after BHSM initialization.
191
192Performance and Timing:
193This will return immediately.
194
195Input:
196netSettings- BHSM_NewSettings_t, select what to be updated and provide their corresponding values in this
197                  structured data                 
198                  whichControl - BHSM_SpecialCtrol_Flag_e,  select what BHSM controls to update, one or multipe.
199                  control bits shall not be overlapped. 1 to update the corresponding control. 0 for no update of it.
200                     ctrlValue - unsigned long,  what value is set for this control field. Bit0 is for ISR or Polling selection.
201                     Other bits RFU.               
202                     timeoutMs  - unsigned long,  new timeout value for polling or wairt-for-ISR-from-BSP
203
204Output:
205outp_sSettings - BHSM_Settings, a ref/pointer to the updated setting.
206
207Returns:
208BERR_SUCCESS - success. Otherwise, there is an error.
209
210See Also:
211BHSM_GetDefaultSettings
212BHSM_SetSettings_isr
213
214*****************************************************************************/
215BERR_Code BHSM_SetSettings(
216                BHSM_Handle                                hHsm,
217                BHSM_NewSettings_t              * netSettings
218
219);
220
221
222/*****************************************************************************
223Summary:
224This function updates the HSM driver special controls, e.g. HSM run in ISR mode or polling mode.
225
226Description:
227The default setting is using ISR inside HSM driver when receiving data from BSP. This function is provided to
228select polling mode, or toggle ISR/Polling mode.   It can also be used to modify the timeout value for polling
229or ISR (the default is 2000 ms). It can only be invoked from critical calling code section.
230
231Calling Context:
232Any time it can be called after BHSM initialization.
233
234Performance and Timing:
235This will return immediately.
236
237Input:
238netSettings- BHSM_NewSettings_t, select what to be updated and provide their corresponding values in this
239                  structured data                 
240                  whichControl - BHSM_SpecialCtrol_Flag_e,  select what BHSM controls to update, one or multipe.
241                  control bits shall not be overlapped. 1 to update the corresponding control. 0 for no update of it.
242                     ctrlValue - unsigned long,  what value is set for this control field. Bit0 is for ISR or Polling selection.
243                     Other bits RFU.               
244                     timeoutMs  - unsigned long,  new timeout value for polling or wairt-for-ISR-from-BSP
245
246Output:
247outp_sSettings - BHSM_Settings, a ref/pointer to the updated setting.
248
249Returns:
250BERR_SUCCESS - success. Otherwise, there is an error.
251
252See Also:
253BHSM_GetDefaultSettings
254BHSM_SetSettings
255
256*****************************************************************************/
257BERR_Code BHSM_SetSettings_isr(
258                BHSM_Handle                                hHsm,
259                BHSM_NewSettings_t              * netSettings
260
261);
262
263
264/*****************************************************************************
265Summary:
266This function creates the Host Secure Module handle.
267
268Description:
269This function shall create the Host Secure module handle.
270It also initializes the Host Secure module
271and hardware using settings stored in the outp_sSettings pointer.
272All the associated channels are not ready to be access until
273BHSM_ChannelOpen is called and returns successfully.
274 
275The caller can pass a NULL pointer for inp_sSettings. If the
276p_Settings pointer is NULL, default settings should be used.
277
278It is the caller responsibility to store the outp_handle and uses
279it for the future function call after this function returns
280successfully.
281
282Before calling this function, the only function that the caller
283can call is BHSM_GetDefaultSettings. System shall not call
284any other Host Secure functions prior to this function.
285
286System shall not call this function more than once without calling BHSM_Close
287previously.
288
289If illegal settings are passed in an error should be
290returned and the hardware state should not be modified.
291
292The BINT_Handle is only required if this module needs to
293associate ISR callback routines with L2 interrupts.
294
295
296Calling Context:
297The function shall be called from application level (for example in
298VxWorks or no-os) or from driver level (for example in Linux,
299during insmod )
300
301Performance and Timing:
302This is a synchronous function that will return when it is done.
303
304Input:
305in_regHandle  - BREG_Handle, use to access Host Secure register.
306in_chipHandle - BCHP_Handle,  Chip handle.
307in_interruptHandle - BINT_Handle, Interrupt handle to handle Host Secure interrupt.
308in_xptHandle -  BXPT_Handle, Transport handle.
309inp_sSettings - BHSM_Settings, the settings that apply to multiple
310                                channels.  If NULL, a default setting shall be used.
311                       
312Output:
313outp_handle - BHSM_Handle, a ref/pointer to the Host Secure module handle.
314
315Returns:
316BERR_SUCCESS - success
317
318See Also:
319BHSM_GetDefaultSettings
320BHSM_Close
321
322******************************************************************************/
323BERR_Code BHSM_Open(
324                BHSM_Handle                     *outp_handle, 
325                BREG_Handle                     in_regHandle,     
326                BCHP_Handle                     in_chipHandle,
327                BINT_Handle                     in_interruptHandle,
328                const BHSM_Settings     *inp_sSettings
329); 
330
331
332/*****************************************************************************
333Summary:
334This function frees the main handle and any resources contained
335in the main handle.
336
337Description:
338This function shall free the main handle and any resources contained
339in the main handle. This function shall try to free any resources associated
340with sub handles created from the main handle. However, this function does not
341free any resources associated with channel handle.
342
343Regardless of the return value, this function always attempts to free all
344the allocated resources and inout_handle shall be NULL.
345
346Other than BHSM_GetDefaultSettings, system shall not call any other HSM
347functions after this function returns, regardless of the return result.
348
349
350Calling Context:
351The function shall be called from application level (for example in
352VxWorks or no-os) or from driver level (for example in Linux,
353during rmmod)
354
355Performance and Timing:
356This is a synchronous function that will return when it is done.
357
358Input:
359in_handle  - BHSM_Handle, Host Secure module handle.
360
361Returns:
362BERR_SUCCESS - success
363
364See Also:
365BHSM_Open
366BHSM_GetDefaultSettings
367
368******************************************************************************/
369BERR_Code BHSM_Close(
370                BHSM_Handle in_handle
371);
372
373
374/*****************************************************************************
375Summary:
376This function returns the number of Host Secure Module channels
377that we can support for the build and configuration.
378
379Description:
380This function returns the number of Aegis command interfaces
381that we can support for the build and configuration.
382
383The caller shall then call BHSM_Channel_Open or BHSM_GetChannelDefaultSettings
384with in_channelNo that smaller than outp_totalChannels.
385
386Currently we support 2 Hardware Aegis Command interfaces.
387
388Calling Context:
389The function shall be called from application level (for example in
390VxWorks or no-os) or from driver level (for example in Linux,
391recommended ioctl: BHSM_IOCTL_GET_TOTAL_CHANNELS or device open)
392
393Performance and Timing:
394This is a synchronous function that will return when it is done.
395
396Input:
397in_handle  - BHSM_Handle, a ref/pointer to the Host Secure module handle.
398                       
399Output:
400outp_ucTotalChannels - unsigned char, a ref/pointer to number of supported
401                                        Aegis command interfaces
402
403Returns:
404BERR_SUCCESS - success
405
406
407See Also:
408BHSM_GetChannel
409
410******************************************************************************/
411BERR_Code BHSM_GetTotalChannels(
412                BHSM_Handle             in_handle, 
413                unsigned char           *outp_ucTotalChannels
414);
415
416
417/*****************************************************************************
418Summary:
419This function returns a recommended default settings for HSM channel.
420
421Description:
422This function shall return a recommended default settings for HSM channel.
423This function shall be called before BHSM_Channel_Open
424and the caller can then over-ride any of the default settings
425required for the build and configuration by calling BHSM_Channel_Open.
426
427The caller shall pass in_channelNo that is smaller than outp_totalChannels in
428BHSM_GetTotalChannels. The in_channelNo for the first channel shall be zero.
429
430These default settings are always the same regardless of how
431many times this function is called or what other functions have
432been called in the porting interface.
433
434Calling Context:
435The function shall be called from application level (for example in
436VxWorks or no-os) or from driver level (for example in Linux,
437recommended ioctl: BHSM_IOCTL_GET_CHANNEL_DEFAULT_SETTINGS)
438
439Performance and Timing:
440This is a synchronous function that will return when it is done.
441
442Input:
443in_handle - BHSM_Handle,  Host Secure module handle.
444in_channelNo  - BHSM_HwModule, an index that indicates which channel or Aegis
445                                command interface that the caller want to access.
446Output:
447outp_sSettings - BHSM__ChannelSettings, a ref/pointer to the default channel
448                                        setting.
449
450Returns:
451BERR_SUCCESS - success
452
453See Also:
454BHSM_Open
455BHSM_GetTotalChannels
456BHSM_Channel_Open
457
458*****************************************************************************/
459BERR_Code BHSM_GetChannelDefaultSettings(
460                BHSM_Handle                             in_handle, 
461                BHSM_HwModule                   in_channelNo, 
462                BHSM_ChannelSettings            *outp_sSettings
463);
464
465
466
467/*****************************************************************************
468Summary:
469This function creates the Host Secure channel handle.
470
471Description:
472This function shall create the Host Secure channel handle.
473It also initializes the specified Host Secure interface and all the associated registers
474using settings stored in the inp_channelDefSettings pointer.
475
476The caller shall pass in_channelNo that is smaller than outp_totalChannels in
477BHSM_GetTotalChannels. The in_channelNo for the first channel shall be zero.
478
479It is the responsibility of caller to specify the correct in_channelNo for
480different Aegis command interface. 
481
482The caller can pass a NULL pointer for inp_channelDefSettings. If the
483inp_channelDefSettings pointer is NULL, default settings should be used.
484
485It is the caller responsibility to store the outp_channelHandle and uses
486it for the future function call after this function returns
487successfully.
488
489Before calling this function, the only channel related functions that the system
490can call are BHSM_GetTotalChannels and BHSM_GetChannelDefaultSettings.
491System shall not call any other channel related functions prior to this function.
492
493System shall not call this function more than once without calling BHSM_Channel_Close
494previously.
495
496If illegal settings are passed in an error should be
497returned and the hardware state should not be modified.
498
499
500Calling Context:
501The function shall be called from application level (for example in
502VxWorks or no-os) or from driver level (for example in Linux,
503recommended ioctl: BHSM_IOCTL_CHANNEL_OPEN
504
505Performance and Timing:
506This is a synchronous function that will return when it is done.
507
508Input:
509in_handle  - BHSM__Handle, Host Secure module handle.
510in_channelNo  - BHSM_HwModule, an index that indicates which channel
511                                that the caller want to access.       
512inp_channelDefSettings - BHSM_ChannelSettings, the channel settings that apply to this
513                                        specific channel.  If NULL, a default channel setting shall be used.
514                       
515Output:
516outp_channelHandle -BHSM_ChannelHandle, a ref/pointer to the host secure module.
517
518Returns:
519BERR_SUCCESS - success
520
521See Also:
522BHSM_Open
523BHSM_GetTotalChannels
524BHSM_Channel_Close
525
526
527*****************************************************************************/
528BERR_Code BHSM_Channel_Open(
529                BHSM_Handle                             in_handle, 
530                BHSM_ChannelHandle              *outp_channelHandle, 
531                BHSM_HwModule                           in_channelNo, 
532                const BHSM_ChannelSettings      *inp_channelDefSettings
533);
534
535
536/*****************************************************************************
537Summary:
538This function frees the channel handle and any resources contained
539in the channel handle.
540
541Description:
542This function shall free the channel handle and any resources contained
543in the channel handle.
544
545This function always returns successfully even if some of the resources cannot
546be freed successfully.
547
548Other than BHSM_GetTotalChannels and BHSM_GetChannelDefaultSettings, system
549shall not call any other channel related functions after this function returns,
550regardless of the return result.
551 
552Calling Context:
553The function shall be called from application level (for example in
554VxWorks or no-os) or from driver level (for example in Linux,
555recommended ioctl: BHSM_IOCTL_CHANNEL_CLOSE)
556
557Performance and Timing:
558This is a synchronous function that will return when it is done.
559
560Input:
561in_channelHandle  - BHSM_ChannelHandle,  host secure module channel handle.
562
563Returns:
564BERR_SUCCESS - success
565
566See Also:
567BHSM_Channel_Open
568
569******************************************************************************/
570BERR_Code BHSM_Channel_Close(
571                BHSM_ChannelHandle in_channelHandle
572);
573
574
575/*****************************************************************************
576Summary:
577This function gets the module handle based on the channel handle.
578
579Description:
580This function shall get the module handle based on the channel handle.
581
582Calling Context:
583The function shall be called from application level (for example in
584VxWorks or no-os) or from driver level (for example in Linux,
585recommended ioctl: BHSM_IOCTL_GET_DEVICE)
586
587Performance and Timing:
588This is a synchronous function that will return when it is done.
589
590Input:
591in_channelHandle  - BHSM_ChannelHandle, host secure module channel handle.
592                       
593Output:
594outp_handle - BHSM_Handle, a ref/pointer to the host secure module handle.
595
596Returns:
597BERR_SUCCESS - success
598
599See Also:
600BHSM_Open
601BHSM_Channel_Open
602
603*****************************************************************************/
604BERR_Code BHSM_GetDevice(
605                BHSM_ChannelHandle           in_channelHandle, 
606                BHSM_Handle                       *outp_handle
607);
608
609
610/*****************************************************************************
611Summary:
612This function returns the specific Host Secure Module channel handle.
613
614Description:
615This function returns the specific Host Secure module channel handle.
616The caller shall pass in_index that is smaller than outp_totalChannels in
617BHSM_GetTotalChannels. The in_index for the first channel
618shall be zero and the second channel shall be 1.
619It is the caller responsibility to store the return outp_channelHandle
620for the future function calls after this function returns successfully.
621
622Before calling this function, the only functions that the system
623can call are BHSM_GetDefaultSettings, BHSM_Open, BHSM_GetTotalChannels,
624and BHSM_Close.
625
626 
627Calling Context:
628The function shall be called from application level (for example in
629VxWorks or no-os) or from driver level (for example in Linux,
630recommended ioctl: BHSM_IOCTL_GET_CHANNEL )
631
632Performance and Timing:
633This is a synchronous function that will return when it is done.
634
635Input:
636in_handle  - BHSM_Handle, a ref/pointer to the Host Secure module handle.
637in_channelNo -  BHSM_HwModule, an index that indicate which channel or host secure module
638                        slot that the caller want to access.
639                       
640Output:
641outp_channelHandle - BHSM_ChannelHandle, a ref/pointer to the Host Secure
642                                         channel handle.
643
644Returns:
645BERR_SUCCESS - success
646
647
648See Also:
649BHSM_GetTotalChannels
650
651******************************************************************************/
652BERR_Code BHSM_GetChannel(
653                BHSM_Handle                     in_handle, 
654                BHSM_HwModule           in_channelNo, 
655                BHSM_ChannelHandle      *outp_channelHandle
656);
657
658/* End of Basic Module Functions */
659
660/* Module Specific Functions */
661
662
663
664/*****************************************************************************
665Summary:
666
667This function is reserved for Broadcom internal usage only.
668
669******************************************************************************/
670BERR_Code BHSM_SetIntrCallback(
671                BHSM_Handle                     in_handle,
672                BHSM_IntrType           in_eIntType,
673                BHSM_IsrCallbackFunc    in_callback             
674);
675
676
677
678
679#ifdef BHSM_AUTO_TEST
680/*****************************************************************************
681Summary:
682
683This function is reserved for Broadcom internal usage only.
684 
685******************************************************************************/
686BERR_Code BHSM_SubmitRawCommand (
687                BHSM_Handle             in_handle,
688                BHSM_HwModule   in_interface,
689                uint32_t                        in_unInputParamLenInWord,
690                uint32_t                        *inp_unInputParamsBuf,
691                uint32_t                        *outp_unOutputParamLenInWord,
692                uint32_t                        *outp_unOutputParamsBuf
693);
694#endif
695
696/* End of Module Specific Functions */
697
698
699#ifdef __cplusplus
700}
701#endif
702
703
704#endif /* BHSM_H__ */
705
706
707
708
709
710
711
Note: See TracBrowser for help on using the repository browser.