1 /*-
2  * Copyright (C) 2001-2003 by NBMK Encryption Technologies.
3  * All rights reserved.
4  *
5  * NBMK Encryption Technologies provides no support of any kind for
6  * this software.  Questions or concerns about it may be addressed to
7  * the members of the relevant open-source community at
8  * <tech-crypto@netbsd.org>.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions are
12  * met:
13  *
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  *
17  * 2. Redistributions in binary form must reproduce the above
18  *    copyright notice, this list of conditions and the following
19  *    disclaimer in the documentation and/or other materials provided
20  *    with the distribution.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 /*****************************************************************************
36  * @(#) n8_pub_service.h 1.13@(#)
37  *****************************************************************************/
38 
39 /*****************************************************************************/
40 /** @file n8_pub_service
41  *  @brief Common type declarations used in public interface.
42  *
43  * Public header file for service functions for NSP2000 project.
44  *
45  *****************************************************************************/
46 
47 /*****************************************************************************
48  * Revision history:
49  * 06/06/03 brr   Eliminate unused N8_HardwareType_t to avoid confusion with
50  *                N8_Hardware_t.
51  * 04/25/03 brr   Modified N8_EventPoll to return the number of completed
52  *                events.
53  * 03/13/04 brr   Added prototype for N8_EventPoll.
54  * 03/02/03 bac   Added N8_HARDWAREREVISION parameter to N8_GetSystemParameter.
55  * 03/01/03 brr   Added support for API callbacks.
56  * 07/08/02 brr   Added N8_FILEDESCRIPTOR parameter to N8_GetSystemParameter.
57  * 04/05/02 brr   Added N8_SWVERSIONTEXT parameter to N8_GetSystemParameter.
58  * 04/03/02 brr   Added prototype for N8_PrintSoftwareVersion.
59  * 03/22/02 brr   Added N8_EVENT_NONE_AVAILABLE. (Bug 635)
60  * 03/22/02 brr   Moved N8_EVENT constants from n8_event.h.
61  * 10/31/01 hml   Added latest set of enums.
62  * 10/12/01 dkm   Original version.
63  ****************************************************************************/
64 #ifndef N8_PUB_SERVICE_H
65 #define N8_PUB_SERVICE_H
66 
67 #ifdef __cplusplus
68 extern "C"
69 {
70 #endif
71 
72 #include "n8_pub_common.h"
73 
74 /*****************************************************************************
75  * Structures/type definitions
76  *****************************************************************************/
77 typedef enum
78 {
79     N8_EACOUNT,         /* Number of EA execution units. */
80     N8_EATYPE,          /* An array of types of the EA units. The size n (number
81                            ofelements in the array) is equal to the value
82                            returned for N8_EACOUNT. Entry i in the array,
83                            0 <= i < n is the type of the EA unit */
84     N8_PKCOUNT,         /* Number of PK execution units. */
85     N8_PKTYPE,          /* An array of types of the PK units. The size n (number
86                            ofelements in the array) is equal to the value
87                            returned for N8_PKCOUNT. Entry i in the array,
88                            0 <= i < n is the type of the PK unit */
89     N8_HPCOUNT,         /* Number of hash processor (HP) execution units. */
90     N8_HPTYPE,          /* An array of types of the HP units. The size n (number
91                            ofelements in the array) is equal to the value
92                            returned for N8_HPCOUNT. Entry i in the array,
93                            0 <= i < n is the type of the HP unit */
94     N8_HARDWAREVERSION, /* The version of the NSP2000 chip, from the
95                            configuration register. */
96     N8_SOFTWAREVERSION, /* The version number of the API software, major
97                            minor, maintainence version and build number */
98     N8_CONTEXTMEMSIZE,  /* The size in bytes of the E/A
99                            unit's context memory. The size n (number of
100                            elements in the array) is equal to the value
101                            returned for N8_EACOUNT. Entry i in the array,
102                            0 <= i < n is the number of context memory entries
103                            in the E/A of E/A unit i+1. */
104     N8_SKSMEMSIZE,      /* The size in bytes of the Secure Key Storage. The
105                            size n (number of elements in the array) is equal
106                            to the value returned for N8_PKCOUNT. Entry i in
107                            the array, 0 <= i < n, is the number of context
108                            memoryentries in the SKS of PKP unit i+1 */
109     N8_NUMBEROFCHIPS,   /* The number of NetOctave chips on the system */
110     N8_SWVERSIONTEXT,   /* ASCII string describing the API software version */
111     N8_FILEDESCRIPTOR,  /* The file descriptor for the NSP2000 device */
112     N8_INITIALIZE_INFO, /* The configuration parameters used to initialize */
113 	                /* the API.                                        */
114     N8_HARDWAREREVISION /* The revision id as reported by 'lspci' under Linux.
115                          * The results are returned as an array of unsigned
116                          * ints. */
117 } N8_Parameter_t;
118 
119 /*****************************************************************************
120  * Enumeration for hardware types. These are used with the N8_HARDWAREVERSION
121  * query of the N8_GetSystemParameter call as well as the N8_EATYPE, N8_PKTYPE
122  * and N8_HPTYPE queries.
123  *****************************************************************************/
124 #define   N8_NSP2000           0xffffff00  /* The unit is implemented by an NSP2000 */
125 #define   N8_NSP2000EMULATED   0xffffff01  /* The unit is an NSP2000 emulator */
126 
127 /*****************************************************************************
128  * Defines for N8_Event functions
129  *****************************************************************************/
130 #define N8_EVENT_MAX    (18 * 1024)  /* this value was arbitrarily selected */
131 #define N8_EVENT_SLEEP  (1000)       /* sleep 1 millisecond */
132 #define N8_EVENT_NONE_READY -1
133 
134 /*****************************************************************************
135  * Function prototypes
136  *****************************************************************************/
137 N8_Status_t N8_GetSystemParameter(N8_Parameter_t parameter, void *value_p, size_t value_l);
138 N8_Status_t N8_InitializeAPI(N8_ConfigAPI_t *parameters_p);
139 N8_Status_t N8_EventCheck(N8_Event_t *events_p, const int count, int *ready_p);
140 N8_Status_t N8_EventWait (N8_Event_t *events_p, const int count, int *ready_p);
141 N8_Status_t N8_TerminateAPI(void);
142 
143 #ifdef SUPPORT_CALLBACKS
144 int N8_EventPoll(void);
145 #endif
146 
147 #ifdef __cplusplus
148 }
149 #endif
150 
151 #endif
152 
153 
154