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