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 11

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 ruschi
/**
2
*  \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
 
40
 
41 5 ruschi
#ifndef AVS_AES_H_
42
#define AVS_AES_H_
43
 
44 11 ruschi
/**
45
 * \section Configuration
46
 * Configuration items for the Avalon Slave component
47
 * change them or define them elsewhere
48
 */
49
#ifndef KEYWORDS
50
/**
51
 * Keylength 256 Bit AES
52
*/
53
#define KEYWORDS        8
54
#endif  /*  KEYWORDS  */
55 5 ruschi
 
56 11 ruschi
#ifndef AES_BASEADDR
57
/**
58
 * base address of the Avalon Slave component in memory map
59
*/
60 5 ruschi
#define AES_BASEADDR    0x40000 
61 11 ruschi
#endif /* AES_BASEADDR */
62
 
63
 
64
/**
65
 * \section Constants
66
 * Constants no need to change them!
67
 */
68
/** memory offset for key  DON'T CHANGE!  */
69 5 ruschi
#define KEY_ADDR        AES_BASEADDR+0x00
70 11 ruschi
/** memory offset of payload   DON'T CHANGE!*/
71 5 ruschi
#define DATA_ADDR       AES_BASEADDR+0x08
72 11 ruschi
/** memory offset of result   DON'T CHANGE! */
73 5 ruschi
#define RESULT_ADDR     AES_BASEADDR+0x10
74 11 ruschi
/** memory offset for control word   DON'T CHANGE! */
75 5 ruschi
#define AESCTRLWD       AES_BASEADDR+0x18 
76
 
77 11 ruschi
/**
78
 * \brief object storing addresses for this Avalon AES slave
79
 * might be useful in case there are more attached, also for convinience
80
 */
81 5 ruschi
typedef struct{
82 11 ruschi
         /**
83
          * \brief pointer "KEY" field in memory mapping
84
        */
85 5 ruschi
        volatile unsigned int* key;
86 11 ruschi
         /**
87
         * \brief pointer "data" field in memory mapping
88
         * used for both decryption and encryption
89
         */
90 5 ruschi
        volatile unsigned int* payload;
91 11 ruschi
         /**
92
          * \brief pointer "RESULT" field in memory mapping
93
         */
94 5 ruschi
        volatile unsigned int* result;
95 11 ruschi
         /**
96
          * \brief pointer to control word
97
        */
98 5 ruschi
        volatile unsigned int* control;
99
} avs_aes_handle;
100
 
101 11 ruschi
/**
102
 * \section functions
103
 **/
104 5 ruschi
 
105 11 ruschi
 
106
/**
107
 * \brief setup the context to be used later.
108
 * initializes the pointers to the correct memory locations
109
 * \param context : struct grouping address information
110
 */
111 5 ruschi
void avs_aes_init(avs_aes_handle* context);
112 11 ruschi
 
113
/**
114
 * \brief setup the context to be used later.
115
 * initializes the pointers to the correct memory locations
116
 * \param context  struct grouping address information
117
 * \param key user key to load
118
 */
119 5 ruschi
void avs_aes_setKey(avs_aes_handle* context, unsigned int* key);
120 11 ruschi
 
121
/**
122
 * \brief loads payload for processing to the core
123
 * basically memcopy...
124
 * \param context  struct grouping address information
125
 * \param payload user data to be processed
126
 */
127 5 ruschi
void avs_aes_setPayload(avs_aes_handle* context, unsigned int* payload);
128 11 ruschi
 
129
/**
130
 * \brief set the KEY_VALID flag in the control word
131
 * used to signal the completion of writing the key ( \ref avs_aes_setKey )
132
 * \param context  struct grouping address information
133
 */
134 5 ruschi
void avs_aes_setKeyvalid(avs_aes_handle* context);
135
 
136 11 ruschi
/**
137
 * \brief set the ENCRYPT flag in the control word
138
 * start encryption of (hopefully) previously loaded payload
139
 * \param context  struct grouping address information
140
 */
141 5 ruschi
void avs_aes_encrypt(avs_aes_handle* context);
142 11 ruschi
 
143
/**
144
 * \brief set the DECRYPT flag in the control word
145
 * start encryption of (hopefully) previously loaded payload
146
 * \param context  struct grouping address information
147
 */
148 5 ruschi
void avs_aes_decrypt( avs_aes_handle* context);
149 11 ruschi
 
150
/**
151
 * \brief checks the COMPLETED flag
152
 * can be used for ugly polling the slave if IRQs are not used
153
 * \param context  struct grouping address information
154
 * \return 1 if still computing 0 if done.
155
 */
156 5 ruschi
int avs_aes_isBusy(avs_aes_handle* context);
157
 
158
 
159
#endif /*AVS_AES_H_*/

powered by: WebSVN 2.1.0

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