n2rng.h revision e3d6ebc24700cc84a56f7c08c0ec5fb9564a759b
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_N2RNG_H
#define _SYS_N2RNG_H
/* skip following stuff when included in n2rng_hcall.s */
#ifndef _ASM
#endif /* !_ASM */
#ifdef __cplusplus
extern "C" {
#endif
#define HV_RNG_GET_DIAG_CONTROL 0x130
#define HV_RNG_CTL_READ 0x131
#define HV_RNG_CTL_WRITE 0x132
#define HV_RNG_DATA_READ_DIAG 0x133
#define HV_RNG_DATA_READ 0x134
#define CTL_STATE_UNCONFIGURED 0
#define CTL_STATE_CONFIGURED 1
#define CTL_STATE_HEALTHCHECK 2
#define CTL_STATE_ERROR 3
#define NRNGCTL 4
#define DRIVER "n2rng"
#define N2RNG_MANUFACTURER_ID "SUNWn2rng"
#define N2RNG_BINDNAME_N2 "SUNW,n2-rng"
#define N2RNG_BINDNAME_VF "SUNW,vf-rng"
#define N2RNG_MAX_RNGS 4
#define N2RNG_INVALID_ID (-1)
#ifndef _ASM
typedef enum {
typedef union n2rngctl {
struct {
} fields;
} n2rng_ctl_t;
typedef struct {
#if defined(_KERNEL)
/*
* Our contiguous memory alignment requirement is
* only for 8 bytes, however contig mem allocation
* routines requirement minimum of 64.
*/
#define CONTIG_ALIGNMENT 64
/*
* Returns 1 only if the address range of a variable of type type at
* ptr falls entirely on one page. Based on page size of 4K. May
* give some false negatives on larger page sizes.
*/
& PAGEMASK) == 0)
/*
* The RNG hardware can send certain internal analog signals to an
* external pin on the chip. Setting the rnc_anlg_sel bit to
* N2RNG_NOANALOGOUT deselects all analog signals (perhaps selects
* ground). Choosing any other value would aid an attacker with
* physical access to the chip.
*/
#define N2RNG_NOANALOGOUT 0x2
/*
* There can only be N2_RNG_FIPS_INSTANCES concurrent RNG requsts from
* the framework. Making this value large helps benchmarks. It
* should probably come from a conf file, but for now it is hard
* coded. The code computes i % N2RNG_FIPS_INSTANCES, which is more
* efficient when N2RNG_FIPS_INSTANCES is a power of 2.
*/
#define N2RNG_FIPS_INSTANCES 8
typedef struct fipsrandomstruct fipsrandomstruct_t;
struct fipsrandomstruct {
};
typedef struct {
/*
* volatile, since it is not protected by a mutex. (That is
* okay since it is operated on and accessed via atomic ops.)
*/
volatile unsigned int fips_round_robin_j;
/*
* Device flags (n2rng_t.n_flags)
*/
#define N2RNG_CONTROL 0x00000001
#define N2RNG_FAILED 0x00000002
#define N2RNG_CONFIGURED 0x00000004
#define N2RNG_INITIALIZED 0x00000008
#define N2RNG_REGISTERED 0x00000010
#define DS_RNGBYTES 0
#define DS_RNGJOBS 1
#define DS_RNGHEALTHCHECKS 2
#define DS_MAX 3
#define N2RNG_NOSC 3
#define N2RNG_BIASBITS 2
#define N2RNG_PROP_NUM_UNITS "rng-#units"
typedef struct {
typedef struct {
typedef struct {
} rng_entry_t;
typedef struct {
int n_num_rngs;
int n_num_rngs_online;
typedef struct n2rng {
unsigned n_flags; /* dev state flags */
char *n_binding_name;
} n2rng_t;
typedef struct n2rng_stat n2rng_stat_t;
struct n2rng_stat {
};
#define RNG_MODE_NORMAL 1
#define RNG_MODE_DIAGNOSTIC 0
#define RNG_MAX_DATA_READ_ATTEMPTS 100
#define RNG_MAX_LOGIC_TEST_ATTEMPTS 3
#define RNG_MAX_BUSY_ATTEMPTS 100
#define RNG_MAX_BLOCK_ATTEMPTS 50000
#define RNG_RETRY_BUSY_DELAY 1
#define RNG_DEFAULT_ACCUMULATE_CYCLES 2048
#define RNG_DEFAULT_HC_SECS 0 /* seconds between health checks */
#define LOG_ARG_SCALE 49
#define LOG_VAL_SCALE 32
#if defined(DEBUG)
#define DWARN 0x00000001
#define DMA_ARGS 0x00000002
#define DMA_LDST 0x00000004
#define DNCS_QTAIL 0x00000008
#define DATTACH 0x00000010
#define DCFG 0x00000020
#define DHEALTH 0x00000100
#define DCHATTY 0x00000200
#define DKCF 0x00000400
#define DALL 0xFFFFFFFF
#define DBG0 n2rng_dprintf
#define DBG1 n2rng_dprintf
#define DBG2 n2rng_dprintf
#define DBG3 n2rng_dprintf
#define DBG4 n2rng_dprintf
#define DBG5 n2rng_dprintf
#define DBG6 n2rng_dprintf
void n2rng_dprintf(n2rng_t *, int, const char *, ...);
void n2rng_dumphex(void *, int);
int n2rng_dflagset(int);
#else /* !defined(DEBUG) */
#endif /* !defined(DEBUG) */
/*
*/
int n2rng_herr2kerr(uint64_t);
int n2rng_logic_test(n2rng_t *, int);
int n2rng_noise_gen_test_set(void);
/*
*/
void n2rng_error(n2rng_t *, const char *, ...);
void n2rng_diperror(dev_info_t *, const char *, ...);
uint64_t hv_rng_get_diag_control(void);
#endif /* _KERNEL */
#endif /* !_ASM */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_N2RNG_H */