Home | History | Annotate | Line # | Download | only in include
via_padlock.h revision 1.6.4.1
      1  1.6.4.1      yamt /*	$NetBSD: via_padlock.h,v 1.6.4.1 2012/04/17 00:07:05 yamt Exp $	*/
      2      1.1    daniel 
      3      1.1    daniel /*-
      4      1.1    daniel  * Copyright (c) 2003 Jason Wright
      5      1.1    daniel  * Copyright (c) 2003, 2004 Theo de Raadt
      6      1.1    daniel  * All rights reserved.
      7      1.1    daniel  *
      8      1.1    daniel  * Permission to use, copy, modify, and distribute this software for any
      9      1.1    daniel  * purpose with or without fee is hereby granted, provided that the above
     10      1.1    daniel  * copyright notice and this permission notice appear in all copies.
     11      1.1    daniel  *
     12      1.1    daniel  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     13      1.1    daniel  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     14      1.1    daniel  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     15      1.1    daniel  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     16      1.1    daniel  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     17      1.1    daniel  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     18      1.1    daniel  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     19      1.1    daniel  */
     20      1.1    daniel 
     21      1.1    daniel #ifndef _X86_VIA_PADLOCK_H_
     22      1.1    daniel #define _X86_VIA_PADLOCK_H_
     23      1.1    daniel 
     24      1.5  drochner #if defined(_KERNEL)
     25      1.1    daniel 
     26      1.4       tls #include <sys/rnd.h>
     27      1.4       tls #include <sys/callout.h>
     28      1.1    daniel #include <crypto/rijndael/rijndael.h>
     29      1.1    daniel 
     30      1.1    daniel /* VIA C3 xcrypt-* instruction context control options */
     31      1.1    daniel #define C3_CRYPT_CWLO_ROUND_M		0x0000000f
     32      1.1    daniel #define C3_CRYPT_CWLO_ALG_M		0x00000070
     33      1.1    daniel #define C3_CRYPT_CWLO_ALG_AES		0x00000000
     34      1.1    daniel #define C3_CRYPT_CWLO_KEYGEN_M		0x00000080
     35      1.1    daniel #define C3_CRYPT_CWLO_KEYGEN_HW		0x00000000
     36      1.1    daniel #define C3_CRYPT_CWLO_KEYGEN_SW		0x00000080
     37      1.1    daniel #define C3_CRYPT_CWLO_NORMAL		0x00000000
     38      1.1    daniel #define C3_CRYPT_CWLO_INTERMEDIATE	0x00000100
     39      1.1    daniel #define C3_CRYPT_CWLO_ENCRYPT		0x00000000
     40      1.1    daniel #define C3_CRYPT_CWLO_DECRYPT		0x00000200
     41      1.1    daniel #define C3_CRYPT_CWLO_KEY128		0x0000000a      /* 128bit, 10 rds */
     42      1.1    daniel #define C3_CRYPT_CWLO_KEY192		0x0000040c      /* 192bit, 12 rds */
     43      1.1    daniel #define C3_CRYPT_CWLO_KEY256		0x0000080e      /* 256bit, 15 rds */
     44      1.1    daniel 
     45      1.1    daniel struct via_padlock_session {
     46      1.2    cegger         uint32_t	ses_ekey[4 * (RIJNDAEL_MAXNR + 1) + 4];	/* 128 bit aligned */
     47      1.2    cegger         uint32_t	ses_dkey[4 * (RIJNDAEL_MAXNR + 1) + 4];	/* 128 bit aligned */
     48      1.2    cegger         uint8_t	ses_iv[16];				/* 128 bit aligned */
     49      1.2    cegger         uint32_t	ses_cw0;
     50      1.1    daniel         struct swcr_data	*swd;
     51      1.1    daniel         int	ses_klen;
     52      1.1    daniel         int	ses_used;
     53      1.1    daniel };
     54      1.1    daniel 
     55      1.1    daniel struct via_padlock_softc {
     56      1.6  jmcneill 	device_t	sc_dev;
     57      1.6  jmcneill 
     58      1.2    cegger 	uint32_t	op_cw[4];	/* 128 bit aligned */
     59      1.2    cegger 	uint8_t	op_iv[16];	/* 128 bit aligned */
     60      1.1    daniel 	void		*op_buf;
     61      1.1    daniel 
     62      1.4       tls 	int			sc_rnd_hz;
     63      1.4       tls 	struct callout		sc_rnd_co;
     64  1.6.4.1      yamt 	krndsource_t	sc_rnd_source;
     65      1.6  jmcneill 	bool			sc_rnd_attached;
     66      1.4       tls 
     67      1.1    daniel 	/* normal softc stuff */
     68      1.1    daniel 	int32_t		sc_cid;
     69      1.6  jmcneill 	bool		sc_cid_attached;
     70      1.1    daniel 	int		sc_nsessions;
     71      1.1    daniel 	struct via_padlock_session *sc_sessions;
     72      1.1    daniel };
     73      1.1    daniel 
     74      1.1    daniel #define VIAC3_SESSION(sid)	((sid) & 0x0fffffff)
     75      1.1    daniel #define VIAC3_SID(crd,ses)	(((crd) << 28) | ((ses) & 0x0fffffff))
     76      1.1    daniel 
     77      1.4       tls #define VIAC3_RNG_BUFSIZ	16
     78      1.4       tls 
     79      1.5  drochner #endif /* _KERNEL */
     80      1.5  drochner 
     81      1.5  drochner #if defined(_KERNEL) || defined(_KMEMUSER)
     82      1.1    daniel struct cpu_info;
     83      1.1    daniel 
     84      1.1    daniel struct via_padlock {
     85      1.1    daniel 	struct cpu_info		*vp_ci;
     86      1.1    daniel 	int			vp_freq;
     87      1.1    daniel };
     88      1.1    daniel 
     89      1.3        ad #endif /* _KERNEL || _KMEMUSER */
     90      1.1    daniel #endif /* _X86_VIA_PADLOCK_H_ */
     91