OpenCores
URL https://opencores.org/ocsvn/avs_aes/avs_aes/trunk

Subversion Repositories avs_aes

[/] [avs_aes/] [trunk/] [sw/] [avs_aes.h] - Blame information for rev 21

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 ruschi
/**
2 21 ruschi
 *  \file avs_aes.h
3
 *  \brief header file for AES Avalon IP Core software driver
4
 *  offers interfaces to convinient access to the core
5
 *
6
 *  This file is part of the project     avs_aes
7
 *  see: http://opencores.org/project,avs_aes
8
 *
9
 *
10
 * \section AUTHORS
11
 *         Thomas Ruschival -- ruschi@opencores.org (www.ruschival.de)
12
 *
13
 * \section LICENSE
14
 *  Copyright (c) 2009, Authors and opencores.org
15
 *  All rights reserved.
16
 *
17
 *  Redistribution and use in source and binary forms, with or without modification,
18
 *  are permitted provided that the following conditions are met:
19
 *        * Redistributions of source code must retain the above copyright notice,
20
 *        this list of conditions and the following disclaimer.
21
 *        * Redistributions in binary form must reproduce the above copyright notice,
22
 *        this list of conditions and the following disclaimer in the documentation
23
 *        and/or other materials provided with the distribution.
24
 *        * Neither the name of the organization nor the names of its contributors
25
 *        may be used to endorse or promote products derived from this software without
26
 *        specific prior written permission.
27
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28
 *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29
 *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30
 *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
31
 *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
32
 *  OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33
 *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34
 *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35
 *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36
 *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
37
 *  THE POSSIBILITY OF SUCH DAMAGE
38
 */
39 11 ruschi
 
40 5 ruschi
#ifndef AVS_AES_H_
41
#define AVS_AES_H_
42
 
43 11 ruschi
/**
44
 * \section Configuration
45
 * Configuration items for the Avalon Slave component
46
 * change them or define them elsewhere
47
 */
48
#ifndef KEYWORDS
49
/**
50
 * Keylength 256 Bit AES
51 21 ruschi
 */
52 11 ruschi
#define KEYWORDS        8
53
#endif  /*  KEYWORDS  */
54 5 ruschi
 
55 11 ruschi
#ifndef AES_BASEADDR
56 21 ruschi
/**
57 11 ruschi
 * base address of the Avalon Slave component in memory map
58 21 ruschi
 */
59 5 ruschi
#define AES_BASEADDR    0x40000 
60 11 ruschi
#endif /* AES_BASEADDR */
61
 
62
/**
63 21 ruschi
 * \addtogroup control-register
64
 * Bits in Control Register
65
 * \see{avs_aes_handle::control}
66
 * \{
67 11 ruschi
 */
68 5 ruschi
 
69 21 ruschi
/** Signal load of new key valid \see{avs_aes_handle::control} */
70
#define KEY_VALID       (1 << 7)
71
/** Enable interrupt bit \see{avs_aes_handle::control} */
72
#define IRQ_ENA         (1 << 6)
73
/** Start decryption bit \see{avs_aes_handle::control} */
74
#define DECRYPT         (1 << 1)
75
/** start encryption bit \see{avs_aes_handle::control} */
76
#define ENCRYPT         (1 << 0)
77
 
78
/** \} */
79
 
80 11 ruschi
/**
81
 * \brief object storing addresses for this Avalon AES slave
82
 * might be useful in case there are more attached, also for convinience
83
 */
84 21 ruschi
typedef struct {
85
        /**
86
         * \brief pointer to key field in memory mapping
87
         */
88 5 ruschi
        volatile unsigned int* key;
89 21 ruschi
        /**
90
         * \brief pointer to data field in memory mapping
91
         *                used for both decryption and encryption
92 11 ruschi
         */
93 5 ruschi
        volatile unsigned int* payload;
94 21 ruschi
        /**
95
         * \brief pointer to result field in memory mapping
96 11 ruschi
         */
97 5 ruschi
        volatile unsigned int* result;
98 21 ruschi
        /**
99
         * \brief pointer to control word
100
         */
101
        volatile unsigned int* control;
102
 
103 5 ruschi
} avs_aes_handle;
104
 
105 11 ruschi
/**
106
 * \section functions
107
 **/
108 5 ruschi
 
109 11 ruschi
/**
110
 * \brief setup the context to be used later.
111
 * initializes the pointers to the correct memory locations
112
 * \param context : struct grouping address information
113
 */
114 5 ruschi
void avs_aes_init(avs_aes_handle* context);
115 11 ruschi
 
116
/**
117 21 ruschi
 * \brief Set a new key
118
 *  This call asserts the KEY_VALID flag and triggers the key-expansion in the core
119 11 ruschi
 * \param context  struct grouping address information
120
 * \param key user key to load
121
 */
122 5 ruschi
void avs_aes_setKey(avs_aes_handle* context, unsigned int* key);
123 11 ruschi
 
124
/**
125
 * \brief loads payload for processing to the core
126
 * basically memcopy...
127
 * \param context  struct grouping address information
128
 * \param payload user data to be processed
129
 */
130 5 ruschi
void avs_aes_setPayload(avs_aes_handle* context, unsigned int* payload);
131 11 ruschi
 
132
/**
133
 * \brief set the KEY_VALID flag in the control word
134
 * used to signal the completion of writing the key ( \ref avs_aes_setKey )
135
 * \param context  struct grouping address information
136
 */
137 5 ruschi
void avs_aes_setKeyvalid(avs_aes_handle* context);
138
 
139 11 ruschi
/**
140
 * \brief set the ENCRYPT flag in the control word
141
 * start encryption of (hopefully) previously loaded payload
142
 * \param context  struct grouping address information
143
 */
144 5 ruschi
void avs_aes_encrypt(avs_aes_handle* context);
145 11 ruschi
 
146
/**
147
 * \brief set the DECRYPT flag in the control word
148
 * start encryption of (hopefully) previously loaded payload
149
 * \param context  struct grouping address information
150
 */
151 21 ruschi
void avs_aes_decrypt(avs_aes_handle* context);
152 11 ruschi
 
153
/**
154
 * \brief checks the COMPLETED flag
155
 * can be used for ugly polling the slave if IRQs are not used
156
 * \param context  struct grouping address information
157
 * \return 1 if still computing 0 if done.
158
 */
159 5 ruschi
int avs_aes_isBusy(avs_aes_handle* context);
160
 
161
#endif /*AVS_AES_H_*/

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.