Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / dev / pci / n8 / common / n8_rn_common.h
blobe0375be975ccef22523daae9925e0a60a729bde5
1 /*-
2 * Copyright (C) 2001-2003 by NBMK Encryption Technologies.
3 * All rights reserved.
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:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
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.
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.
35 /*****************************************************************************
36 * @(#) n8_rn_common.h 1.23@(#)
37 *****************************************************************************/
39 /*****************************************************************************/
40 /** @file n8_rn_common.h
41 * @brief Random number functionality
43 * Common random number functions.
45 *****************************************************************************/
47 /*****************************************************************************
48 * Revision history:
49 * 05/15/03 brr Added definition for DEF_RNH_BIGERROR_IRQ_BITS.
50 * 11/25/02 brr Removed definition of RNG_ALL_UNITS.
51 * 03/27/02 hml Removed obsolete include file
52 * 03/01/02 brr Moved RNG_ALL_UNITS to this file since its used by SAPI.
53 * 10/23/01 dkm Moved seed defines to n8_pub_rng.h.
54 * 10/12/01 dkm Moved public portion to n8_pub_rng.h.
55 * 09/17/01 bac Removed buffer_lenLog2 from N8_RNG_Parameter_t.
56 * 09/17/01 bac Removed buffer_source from N8_RNG_Parameter_t.
57 * 09/14/01 msz Fixed circular dependency.
58 * 09/14/01 bac Changed seed source values from enums to #defines so that they
59 * cannot inadvertantly change again. Removed N8_RNG_BufferSrc_t
60 * as it is no longer needed.
61 * 09/07/01 msz Changes to support host seed, and cleanup work
62 * 09/06/01 bac Renumbered enums to start with non-zero (BUG #190).
63 * 07/19/01 bac Moved RN_Request_t to n8_enqueue_common.h.
64 * 06/28/01 bac Added userBuffer_p and numBytesRequested to RN_Request_t in
65 * order to facilitate the callback function.
66 * 06/21/01 msz Added RN_QUEUE_INIT_OPEN_FAILED
67 * 06/19/01 hml Added requestStatus, numElementsProvided, unit and chip to
68 * the RN_Request_t. Moved protos to RN_queue.h.
69 * 05/07/01 bac Added RNG_Status_Seed_Shift.
70 * 04/24/01 dws Fixed bracket style for RNG_Sample_t.
71 * 04/11/01 bac Standardization by changing type names to include _t.
72 * 04/09/01 jke Original version.
73 ****************************************************************************/
75 #ifndef N8_RN_COMMON_H
76 #define N8_RN_COMMON_H
78 #include "n8_common.h"
79 #include "n8_pub_rng.h"
81 typedef struct
83 uint32_t high;
84 uint32_t low;
85 } RNG_Sample_t;
87 /* RNG control/status register values */
88 #define RNG_Status_RNG_Enable 0x80000000
89 #define RNG_Status_TOD_Enable 0x40000000
90 #define RNG_Status_Ext_Clock_Enable 0x20000000
91 #define RNG_Status_Diag_Enable 0x10000000
92 #define RNG_Status_Buffer_Use_Host3 0x0c000000
93 #define RNG_Status_Buffer_Use_Host2 0x08000000
94 #define RNG_Status_Buffer_Use_Seed_Generator 0x04000000
95 #define RNG_Status_Buffer_Use_X917 0x00000000
96 #define RNG_Status_Buffer_Mask 0x0c000000
97 #define RNG_Status_Seed_Use_Host3 0x03000000
98 #define RNG_Status_Seed_Use_Host2 0x02000000
99 #define RNG_Status_Seed_Use_External 0x01000000
100 #define RNG_Status_Seed_Use_Internal 0x00000000
101 #define RNG_Status_Seed_Mask 0x03000000
102 #define RNG_Status_Seed_Shift 24
103 #define RNG_Status_Seed_Error 0x00008000
104 #define RNG_Status_X917_Error 0x00004000
105 #define RNG_Status_Key1_Parity_Error 0x00002000
106 #define RNG_Status_Key2_Parity_Error 0x00001000
107 #define RNG_Status_Host_Seed_Valid 0x00000400
108 #define RNG_Status_Buffer_Write_Ready 0x00000200
109 #define RNG_Status_Iteration_Count_Mask 0x000000ff
111 #define RNG_Status_Writeable_Mask 0xff0000ff
112 #define RNG_Status_Any_Condition_Mask 0x00f00000
114 /* RNH control/status register values */
115 #define RNH_Status_Transfer_Enable 0x80000000
116 #define RNH_Status_Transfer_Busy 0x40000000
117 #define RNH_Status_Key_Error 0x00800000 /* Parity error on loaded key */
118 #define RNH_Status_Bus_Error 0x00400000 /* PCI bus mastering error */
119 #define RNH_Status_Duplicate_Error 0x00200000 /* Duplicate successive seeds */
120 #define RNH_Status_Access_Error 0x00100000 /* Mem access error or busy */
121 #define RNH_Status_Key_Error_Enable 0x00080000
122 #define RNH_Status_Bus_Error_Enable 0x00040000
123 #define RNH_Status_Duplicate_Error_Enable 0x00020000
124 #define RNH_Status_Access_Error_Enable 0x00010000
126 #define RNH_Status_Any_Condition_Mask 0x00f00000
127 #define RNH_Status_All_Enable_Mask 0x000f0000
128 #define RNH_Status_Enables_Shift 8
129 #define RNH_Status_Halting_Error_Mask 0x00f00000
130 #define DEF_RNH_BIGERROR_IRQ_BITS 0x00b00000
133 /* RNG REGISTERS - RNG Buffer - RNH REGISTERS */
134 /* 64-bit regsisters in the RNG must be read/written using the Most */
135 /* Significant Word first, in order to access the full 64bit value. */
137 typedef struct
139 volatile uint32_t rng_reserved0; /* C000 */
140 volatile uint32_t rng_tod_seconds; /* C004 */
141 volatile uint32_t rng_reserved1; /* C008 */
142 volatile uint32_t rng_tod_prescale; /* C00C */
143 volatile uint32_t rng_tod_msw; /* C010 */
144 volatile uint32_t rng_tod_lsw; /* C014 */
145 volatile uint32_t rng_key1_msw; /* C018 */
146 volatile uint32_t rng_key1_lsw; /* C01C */
147 volatile uint32_t rng_key2_msw; /* C020 */
148 volatile uint32_t rng_key2_lsw; /* C024 */
149 volatile uint32_t rng_hostseed_msw; /* C028 */
150 volatile uint32_t rng_hostseed_lsw; /* C02C */
151 volatile uint32_t rng_reserved2; /* C030 */
152 volatile uint32_t rng_sample_interval; /* C034 */
153 volatile uint32_t rng_reserved3; /* C038 */
154 volatile uint32_t rng_external_clock_scalar; /* C03C */
155 volatile uint32_t rng_reserved4; /* C040 */
156 volatile uint32_t rng_buffer_write_ptr; /* C044 */
157 volatile uint32_t rng_sample_seed_msw; /* C048 */
158 volatile uint32_t rng_sample_seed_lsw; /* C04C */
159 volatile uint32_t rng_reserved5; /* C050 */
160 volatile uint32_t rng_lsfr_diag; /* C054 */
161 volatile uint32_t rng_lsfr1_history_msw; /* C058 */
162 volatile uint32_t rng_lsfr1_history_lsw; /* C05C */
163 volatile uint32_t rng_lsfr2_history_msw; /* C060 */
164 volatile uint32_t rng_lsfr2_history_lsw; /* C064 */
165 volatile uint32_t rng_lsfr3_history_msw; /* C068 */
166 volatile uint32_t rng_lsfr3_history_lsw; /* C06C */
167 volatile uint32_t rng_lsfr4_history_msw; /* C070 */
168 volatile uint32_t rng_lsfr4_history_lsw; /* C074 */
169 volatile uint32_t rng_reserved6; /* C078 */
170 volatile uint32_t rng_control_status; /* C07C */
171 volatile uint32_t rng_reserved7[480]; /* C080 */
173 volatile uint32_t rng_buffer[512]; /* This buffer is to be */
174 /* interpreted as 256 64-bit */
175 /* value. Software must */
176 /* access MSB first - 0 then */
177 /* 1. */
179 volatile uint32_t rnh_test1; /* D000 */
180 volatile uint32_t rnh_test0; /* D004 */
181 volatile uint32_t rnh_q_length; /* D008 */
182 volatile uint32_t rnh_q_ptr; /* D00C */
183 volatile uint32_t rnh_q_bar1; /* D010 */
184 volatile uint32_t rnh_q_bar0; /* D014 */
185 volatile uint32_t rnh_control_status; /* D018 */
186 volatile uint32_t rnh_reserved; /* D01C */
187 volatile uint32_t rng_unused[3064]; /* D020 */
188 } N8RNGRegs_t;
191 #endif