Add ACE HW support for SHA 256
Subsystems (4)
v3 cover Add ACE HW support for SHA 256
This patch set adds hardware acceleration for SHA 256 with the help of ACE.
Changes since v2:
- Patch-1:
- Added falling back to software sha256 in case length exceeds buffer limit.
- Reduced one tab at lines 533, 559 and 571 in the patch.
- Removed space after a cast at line 506 in the patch.
- Removed blank line at line 561 in the patch.
- Removed space before semicolon at line 576 in the patch.
- Patch-2:
- Added "SHA1" in the comment for config.
- Patch-3:
- Added new nodes for SHA1 and SHA256 in struct hash_algo for the case when ACE is enabled.
- Added new declaration for function pointer hash_func_ws with different return type.
- Patch-4:
- New patch to enable config for hash command.
Akshay Saraswat (4):
Exynos: Add hardware accelerated SHA 256
Exynos: config: Enable ACE HW for SHA 256 for Exynos
gen: Add ACE acceleration to hash
Exynos: config: Enable hash command
Makefile | 1 + arch/arm/include/asm/arch-exynos/cpu.h | 4 + common/hash.c | 15 ++ drivers/crypto/Makefile | 47 +++++ drivers/crypto/ace_sfr.h | 310 +++++++++++++++++++++++++++++++++ drivers/crypto/ace_sha.c | 127 ++++++++++++++ include/ace_sha.h | 42 +++++ include/configs/exynos5250-dt.h | 4 + include/hash.h | 5 + 9 files changed, 555 insertions(+) create mode 100644 drivers/crypto/Makefile create mode 100644 drivers/crypto/ace_sfr.h create mode 100644 drivers/crypto/ace_sha.c create mode 100644 include/ace_sha.h
Signature · 1 line
1.8.0
PATCH v3 1/4 Exynos: Add hardware accelerated SHA 256
SHA-256 and SHA-1 accelerated using ACE hardware.
Tested with command "hash sha256 0x40008000 0x2B 0x40009000". Used mm and md to write a standard string to memory location 0x40008000 and ran the above command to verify the output.
---
Changes since v2:
- Added falling back to software sha256 in case length exceeds buffer limit.
- Reduced one tab at lines 533, 559 and 571 in this patch.
- Removed space after a cast at line 506 in this patch.
- Removed blank line at line 561 in this patch.
- Removed space before semicolon at line 576 in this patch.
Makefile | 1 + arch/arm/include/asm/arch-exynos/cpu.h | 4 + drivers/crypto/Makefile | 47 +++++ drivers/crypto/ace_sfr.h | 310 +++++++++++++++++++++++++++++++++ drivers/crypto/ace_sha.c | 127 ++++++++++++++ include/ace_sha.h | 42 +++++ 6 files changed, 531 insertions(+) create mode 100644 drivers/crypto/Makefile create mode 100644 drivers/crypto/ace_sfr.h create mode 100644 drivers/crypto/ace_sha.c create mode 100644 include/ace_sha.h
Makefile +1 -0
@@ -272,6 +272,7 @@ LIBS-y += disk/libdisk.o LIBS-y += drivers/bios_emulator/libatibiosemu.o LIBS-y += drivers/block/libblock.o LIBS-$(CONFIG_BOOTCOUNT_LIMIT) += drivers/bootcount/libbootcount.o +LIBS-y += drivers/crypto/libcrypto.o LIBS-y += drivers/dma/libdma.o LIBS-y += drivers/fpga/libfpga.o LIBS-y += drivers/gpio/libgpio.o
arch/arm/include/asm/arch-exynos/cpu.h +4 -0
@@ -62,6 +62,7 @@#define EXYNOS4_GPIO_PART4_BASE DEVICE_NOT_AVAILABLE#define EXYNOS4_DP_BASE DEVICE_NOT_AVAILABLE#define EXYNOS4_SPI_ISP_BASE DEVICE_NOT_AVAILABLE +#define EXYNOS4_ACE_SFR_BASE DEVICE_NOT_AVAILABLE/* EXYNOS4X12 */ #define EXYNOS4X12_GPIO_PART3_BASE 0x03860000
@@ -95,6 +96,7 @@#define EXYNOS4X12_I2S_BASE DEVICE_NOT_AVAILABLE#define EXYNOS4X12_SPI_BASE DEVICE_NOT_AVAILABLE#define EXYNOS4X12_SPI_ISP_BASE DEVICE_NOT_AVAILABLE +#define EXYNOS4X12_ACE_SFR_BASE DEVICE_NOT_AVAILABLE/* EXYNOS5 Common*/ #define EXYNOS5_I2C_SPACING 0x10000
@@ -106,6 +108,7 @@#define EXYNOS5_SWRESET 0x10040400#define EXYNOS5_SYSREG_BASE 0x10050000#define EXYNOS5_WATCHDOG_BASE 0x101D0000 +#define EXYNOS5_ACE_SFR_BASE 0x10830000#define EXYNOS5_DMC_PHY0_BASE 0x10C00000#define EXYNOS5_DMC_PHY1_BASE 0x10C10000#define EXYNOS5_GPIO_PART3_BASE 0x10D10000
@@ -205,6 +208,7 @@ static inline unsigned int samsung_get_base_##device(void) \ SAMSUNG_BASE(adc, ADC_BASE) SAMSUNG_BASE(clock, CLOCK_BASE) +SAMSUNG_BASE(ace_sfr, ACE_SFR_BASE) SAMSUNG_BASE(dp, DP_BASE) SAMSUNG_BASE(sysreg, SYSREG_BASE)SAMSUNG_BASE (fimd,FIMD_BASE )
drivers/crypto/Makefile new file +47 -0
47 lines not on this page · raw message
drivers/crypto/ace_sfr.h new file +310 -0
310 lines not on this page · raw message
drivers/crypto/ace_sha.c new file +127 -0
127 lines not on this page · raw message
include/ace_sha.h new file +42 -0
42 lines not on this page · raw message
Signature · 1 line
1.8.0
PATCH v3 1/4 Exynos: Add hardware accelerated SHA 256
Hi Akshay,
Quoted 28 lines · Akshay Saraswat
SHA-256 and SHA-1 accelerated using ACE hardware.
Tested with command "hash sha256
0x400080000x2B0x40009000". Used mm and md to write a standard string to memory location0x40008000and ran the above command to verify the output.Signed-off-by ARUN MANKUZHI <[email protected]>Signed-off-by Akshay Saraswat <[email protected]>---
Changes since v2:
- Added falling back to software sha256 in case length exceeds buffer limit.
- Reduced one tab at lines 533, 559 and 571 in this patch.
- Removed space after a cast at line 506 in this patch.
- Removed blank line at line 561 in this patch.
- Removed space before semicolon at line 576 in this patch.Makefile | 1 + arch/arm/include/asm/arch-exynos/cpu.h | 4 + drivers/crypto/Makefile | 47 +++++ drivers/crypto/ace_sfr.h | 310 +++++++++++++++++++++++++++++++++ drivers/crypto/ace_sha.c | 127 ++++++++++++++ include/ace_sha.h | 42 +++++ 6 files changed, 531 insertions(+) create mode 100644 drivers/crypto/Makefile create mode 100644 drivers/crypto/ace_sfr.h create mode 100644 drivers/crypto/ace_sha.c create mode 100644 include/ace_sha.h
[...]
Quoted 21 lines
+++
b/drivers/crypto/ace_sha.cdrivers/crypto/ace_sha.c new file +19
-0@@ -0,0 +1,127 @@ +/* +* Advanced Crypto Engine - SHA Firmware +* Copyright (c) 2012 Samsung Electronics +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +*/
drivers/crypto/ace_sha.c line 29
Quoted 10 lines
drivers/crypto/ace_sha.c new file +10
-0+#include <common.h> +#include <sha256.h> +#include <sha1.h> +#include <ace_sha.h> +#include "ace_sfr.h" + +/* Timeout for data size above 8MB */ +#define TIMEOUT_MS 100 +/* Maximum input data size is 8 MB */ +#define BUF_LIMIT 8*1024*1024
brackets around this
spaces around *
Quoted 29 lines
drivers/crypto/ace_sha.c new file +29
-0+ +/* SHA1 value for the message of zero length */ +static const unsigned char sha1_digest_emptymsg[SHA1_SUM_LEN ] = { +0xDA ,0x39 ,0xA3 ,0xEE ,0x5E ,0x6B ,0x4B ,0x0D , +0x32 ,0x55 ,0xBF ,0xFF ,0x95 ,0x60 ,0x18 ,0x90 , +0xAF ,0xD8 ,0x07 ,0x09 }; + +/* SHA256 value for the message of zero length */ +static const unsigned char sha256_digest_emptymsg[SHA256_SUM_LEN ] = { +0xE3 ,0xB0 ,0xC4 ,0x42 ,0x98 ,0xFC ,0x1C ,0x14 , +0x9A ,0xFB ,0xF4 ,0xC8 ,0x99 ,0x6F ,0xB9 ,0x24 , +0x27 ,0xAE ,0x41 ,0xE4 ,0x64 ,0x9B ,0x93 ,0x4C , +0xA4 ,0x95 ,0x99 ,0x1B ,0x78 ,0x52 ,0xB8 ,0x55 }; + +int ace_sha_hash_digest (const unsigned char *pbuf,unsigned int buf_len, +unsigned char *pout,unsigned int hash_type) +{ +unsigned int i, reg, len; +unsigned int *pdigest; +ulong start; +struct exynos_ace_sfr *ace_sha_reg = + (struct exynos_ace_sfr *)samsung_get_base_ace_sfr (); + +if (buf_len ==0 ) { +/* ACE H/W cannot compute hash value for empty string */ +if (hash_type ==ACE_SHA_TYPE_SHA1 ) +memcpy (pout, sha1_digest_emptymsg,SHA1_SUM_LEN ); +else +memcpy (pout, sha256_digest_emptymsg,SHA256_SUM_LEN );
drivers/crypto/ace_sha.c line 68
Quoted 10 lines
drivers/crypto/ace_sha.c new file +10
-0+return 0 ; + }else if (buf_len >BUF_LIMIT ) { +/* +* ACE H/W cannot compute hash value for buffer > 8 MB. +* Falling back to software. +*/ +if (hash_type ==ACE_SHA_TYPE_SHA1 ) +sha1_csum_wd (pbuf, buf_len, pout,CHUNKSZ_SHA1 ); +else +sha256_csum_wd (pbuf, buf_len, pout,CHUNKSZ_SHA256 );
This is kind-of odd, but I suppose it is OK for now. Perhaps we should support dealing with errors and falling back to the next available algorithm in hash.c. But for now this is OK.
Quoted 30 lines
drivers/crypto/ace_sha.c new file +30
-0+return 0 ; + } + +/* Flush HRDMA */ +writel (ACE_FC_HRDMACFLUSH_ON , &ace_sha_reg->fc_hrdmac); +writel (ACE_FC_HRDMACFLUSH_OFF , &ace_sha_reg->fc_hrdmac); + +/* Set byte swap of data in */ +writel (ACE_HASH_SWAPDI_ON |ACE_HASH_SWAPDO_ON |ACE_HASH_SWAPIV_ON , + &ace_sha_reg->hash_byteswap); + +/* Select Hash input mux as external source */ + reg =readl (&ace_sha_reg->fc_fifoctrl); + reg = (reg & ~ACE_FC_SELHASH_MASK ) |ACE_FC_SELHASH_EXOUT ; +writel (reg, &ace_sha_reg->fc_fifoctrl); + +/* Set Hash as SHA1 or SHA256 and start Hash engine */ + reg = (hash_type ==ACE_SHA_TYPE_SHA1 ) ? +ACE_HASH_ENGSEL_SHA1HASH :ACE_HASH_ENGSEL_SHA256HASH ; + reg |=ACE_HASH_STARTBIT_ON ; +writel (reg, &ace_sha_reg->hash_control); + +/* Enable FIFO mode */ +writel (ACE_HASH_FIFO_ON , &ace_sha_reg->hash_fifo_mode); + +/* Set message length */ +writel (buf_len, &ace_sha_reg->hash_msgsize_low); +writel (0 , &ace_sha_reg->hash_msgsize_high); + +/* Set HRDMA */
drivers/crypto/ace_sha.c line 108
Quoted 10 lines
drivers/crypto/ace_sha.c new file +10
-0+writel ((unsigned int )pbuf, &ace_sha_reg->fc_hrdmas); +writel (buf_len, &ace_sha_reg->fc_hrdmal); + + start =get_timer (0 ); + +while ((readl (&ace_sha_reg->hash_status) &ACE_HASH_MSGDONE_MASK ) == +ACE_HASH_MSGDONE_OFF ) { +if (get_timer (start) >TIMEOUT_MS ) { +debug ("%s: Timeout waiting for ACE\n" , __func__); +return -1 ;
return -ETIMEDOUT;
You need into #include <asm/errno.h>
drivers/crypto/ace_sha.c line 118
Quoted 10 lines
drivers/crypto/ace_sha.c new file +10
-0+ } + } + +/* Clear MSG_DONE bit */ +writel (ACE_HASH_MSGDONE_ON , &ace_sha_reg->hash_status); + +/* Read hash result */ + pdigest = (unsigned int *)pout; + len = (hash_type ==ACE_SHA_TYPE_SHA1 ) ?SHA1_SUM_LEN /4 + :SHA256_SUM_LEN /4 ;
Suggest removing / 4 here...
drivers/crypto/ace_sha.c line 120
Quoted 2 lines
drivers/crypto/ace_sha.c new file +2
-0+ +for (i =0 ; i < len; i++)
...and putting i += 4 here
Quoted 40 lines
drivers/crypto/ace_sha.c new file +7
-0+ pdigest[i] =readl (&ace_sha_reg->hash_result[i]); + +/* Clear HRDMA pending bit */ +writel (ACE_FC_HRDMA , &ace_sha_reg->fc_intpend); + +return 0 ; +}include/ace_sha.h new file +27
-0@@ -0,0 +1,42 @@ +/* +* Header file for SHA firmware +* +* Copyright (c) 2012 Samsung Electronics +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +*/ +#ifndef __ACE_FW_SHA1_H +#define __ACE_FW_SHA1_H + +#define ACE_SHA_TYPE_SHA1 1 +#define ACE_SHA_TYPE_SHA256 2 + +/**
include/ace_sha.h line 37
Quoted 10 lines
include/ace_sha.h new file +10
-0+* Computes hash value of input pbuf using ACE +* +* @param in_addr A pointer to the input buffer +* @param bufleni Byte length of input buffer +* @param out_addr A pointer to the output buffer. When complete +* 32 bytes are copied to pout[0]...pout[31]. Thus, a user +* should allocate at least 32 bytes at pOut in advance. +* @param hash_type SHA1 or SHA256 +* +* @return 0 Success
-1 on failure (timeout)
Quoted 8 lines
include/ace_sha.h new file +5
-1+*/ +int ace_sha_hash_digest (const uchar *in_addr,uint buflen, +uchar *out_addr,uint hash_type); + +#endif --1.8.0
Regards,
Simon
PATCH v3 1/4 Exynos: Add hardware accelerated SHA 256
In reply to Akshay SaraswatQuoted 1 line · On Fri, 1 Mar 2013 11:16:22 -0500 Akshay Saraswat <[email protected]> wrote:
SHA-256 and SHA-1 accelerated using ACE hardware.
curious about the rationale: how much faster is this than software?
Quoted 7 lines
---
Changes since v2:
- Added falling back to software sha256 in case length exceeds buffer limit.
- Reduced one tab at lines 533, 559 and 571 in this patch.
- Removed space after a cast at line 506 in this patch.
- Removed blank line at line 561 in this patch.
- Removed space before semicolon at line 576 in this patch.
you should retain the list of changes since v1 here. Read:
http://www.denx.de/wiki/view/U-Boot/Patches#Sending_updated_patch_versions
drivers/crypto/ace_sfr.h line 299
Quoted 13 lines
drivers/crypto/ace_sfr.h new file +13
-0+/* Hash status */ +#define ACE_HASH_BUFRDY_MASK (1 << 0) +#define ACE_HASH_BUFRDY_OFF (0 << 0) +#define ACE_HASH_BUFRDY_ON (1 << 0) +#define ACE_HASH_SEEDSETTING_MASK (1 << 1) +#define ACE_HASH_SEEDSETTING_OFF (0 << 1) +#define ACE_HASH_SEEDSETTING_ON (1 << 1) +#define ACE_HASH_PRNGBUSY_MASK (1 << 2) +#define ACE_HASH_PRNGBUSY_OFF (0 << 2) +#define ACE_HASH_PRNGBUSY_ON (1 << 2) +#define ACE_HASH_PARTIALDONE_MASK (1 << 4) +#define ACE_HASH_PARTIALDONE_OFF (0 << 4) +#define ACE_HASH_PARTIALDONE_ON (1 << 4)
based on the nomenclature of the above definitions, this hardware obviously has support for breaking up hash requests into multiple buffer submissions, so do that, and not this:
drivers/crypto/ace_sha.c line 70
Quoted 11 lines
drivers/crypto/ace_sha.c new file +11
-0+ }else if (buf_len >BUF_LIMIT ) { +/* +* ACE H/W cannot compute hash value for buffer > 8 MB. +* Falling back to software. +*/ +if (hash_type ==ACE_SHA_TYPE_SHA1 ) +sha1_csum_wd (pbuf, buf_len, pout,CHUNKSZ_SHA1 ); +else +sha256_csum_wd (pbuf, buf_len, pout,CHUNKSZ_SHA256 ); +return 0 ; + }
Kim
PATCH v3 2/4 Exynos: config: Enable ACE HW for SHA 256 for Exynos
In reply to Akshay SaraswatThis enables SHA 256 for exynos.
Tested with command "hash sha256 0x40008000 0x2B 0x40009000". Used mm and md to write a standard string to memory location 0x40008000 and ran the above command to verify the output.
---
Changes sice v2:
- Added "SHA1" in the comment for config.
include/configs/exynos5250-dt.h | 3 +++ 1 file changed, 3 insertions(+)
include/configs/exynos5250-dt.h +3 -0
@@ -45,6 +45,9 @@/* Keep L2 Cache Disabled */ #define CONFIG_SYS_DCACHE_OFF +/* Enable ACE acceleration for SHA1 and SHA256 */ +#define CONFIG_EXYNOS_ACE_SHA +#define CONFIG_SYS_SDRAM_BASE 0x40000000#define CONFIG_SYS_TEXT_BASE 0x43E00000
Signature · 1 line
1.8.0
PATCH v3 2/4 Exynos: config: Enable ACE HW for SHA 256 for Exynos
Quoted 9 lines · Akshay Saraswat
This enables SHA 256 for exynos.
Tested with command "hash sha256
0x400080000x2B0x40009000". Used mm and md to write a standard string to memory location0x40008000and ran the above command to verify the output.Change-Id Iff1bb2833686f5a0c5869cc86d20078260ec955eSigned-off-by ARUN MANKUZHI <[email protected]>Signed-off-by Akshay Saraswat <[email protected]>
Quoted 24 lines
---
Changes sice v2:
- Added "SHA1" in the comment for config.include/configs/exynos5250-dt.h | 3 +++ 1 file changed, 3 insertions(+)include/configs/exynos5250-dt.h +3
-1@@ -45,6 +45,9 @@/* Keep L2 Cache Disabled */ #define CONFIG_SYS_DCACHE_OFF +/* Enable ACE acceleration for SHA1 and SHA256 */ +#define CONFIG_EXYNOS_ACE_SHA +#define CONFIG_SYS_SDRAM_BASE 0x40000000#define CONFIG_SYS_TEXT_BASE 0x43E00000 --1.8.0
PATCH v3 3/4 gen: Add ACE acceleration to hash
In reply to Akshay SaraswatACE H/W acceleration support is added to hash
which can be used to test SHA 256 hash algorithm.
Tested with command "hash sha256 0x40008000 0x2B 0x40009000". Used mm and md to write a standard string to memory location 0x40008000 and ran the above command to verify the output.
---
Changes sice v2:
- Added new nodes for SHA1 and SHA256 in struct hash_algo for the case when ACE is enabled.
- Added new declaration for function pointer hash_func_ws with different return type.
common/hash.c | 15 +++++++++++++++ include/hash.h | 5 +++++ 2 files changed, 20 insertions(+)
common/hash.c +15 -0
@@ -28,12 +28,26 @@#include <hash.h> #include <sha1.h> #include <sha256.h> +#include <ace_sha.h> /* * These are the hash algorithms we support. Chips which support accelerated * crypto could perhaps add named version of these algorithms here. */ static struct hash_algo hash_algo[] = { +#ifdef CONFIG_EXYNOS_ACE_SHA + { + "SHA1", + SHA1_SUM_LEN, + ace_sha_hash_digest, + ACE_SHA_TYPE_SHA1, + }, { + "SHA256", + SHA256_SUM_LEN, + ace_sha_hash_digest, + ACE_SHA_TYPE_SHA256, + }, +#else #ifdef CONFIG_SHA1 { "SHA1",
@@ -50,6 +64,7 @@ static struct hash_algo hash_algo[] = { CHUNKSZ_SHA256, },#endif +#endif };/**
include/hash.h +5 -0
@@ -40,8 +40,13 @@ struct hash_algo {* @output: Checksum result (length depends on algorithm) * @chunk_sz: Trigger watchdog after processing this many bytes */ +#ifdef CONFIG_EXYNOS_ACE_SHA +int (*hash_func_ws)(const unsigned char *input,unsigned int ilen, +unsigned char *output,unsigned int chunk_sz); +#else void (*hash_func_ws)(const unsigned char *input,unsigned int ilen,unsigned char *output,unsigned int chunk_sz); +#endif int chunk_size;/* Watchdog chunk size */ };
Signature · 1 line
1.8.0
PATCH v3 3/4 gen: Add ACE acceleration to hash
Hi Akshay,
Quoted 27 lines · Akshay Saraswat
ACE H/W acceleration support is added to hash
which can be used to test SHA 256 hash algorithm.Tested with command "hash sha256
0x400080000x2B0x40009000". Used mm and md to write a standard string to memory location0x40008000and ran the above command to verify the output.Change-Id If76820057763e833a6150e55bffea3d010b86721Signed-off-by ARUN MANKUZHI <[email protected]>Signed-off-by Akshay Saraswat <[email protected]>---
Changes sice v2:
- Added new nodes for SHA1 and SHA256 in structhash_algofor the case when ACE is enabled.
- Added new declaration for function pointerhash_func_wswith different return type.common/hash.c | 15 +++++++++++++++ include/hash.h | 5 +++++ 2 files changed, 20 insertions(+)common/hash.c +0
-0@@ -28,12 +28,26 @@#include <hash.h> #include <sha1.h> #include <sha256.h>
common/hash.c line 40
Quoted 10 lines
common/hash.c +4
-0+#include <ace_sha.h> /* * These are the hash algorithms we support. Chips which support accelerated * crypto could perhaps add named version of these algorithms here. */ static struct hash_algo hash_algo[] = { +#ifdef CONFIG_EXYNOS_ACE_SHA + { + "SHA1",
Please use lower case here, since there is a pending patch that changes all these to lower case
common/hash.c line 45
Quoted 5 lines
common/hash.c +5
-0+SHA1_SUM_LEN , + ace_sha_hash_digest, +ACE_SHA_TYPE_SHA1 , + }, { + "SHA256",
lower case
common/hash.c line 50
Quoted 5 lines
common/hash.c +5
-0+SHA256_SUM_LEN , + ace_sha_hash_digest, + ACE_SHA_TYPE_SHA256, + }, +#else
I don't think you need the #else. It is OK to have multiple SHA implements - the hash module will just use the first.
Quoted 16 lines
common/hash.c +1
-0#ifdef CONFIG_SHA1 { "SHA1",@@ -50,6 +64,7 @@ static struct hash_algo hash_algo[] = { CHUNKSZ_SHA256, },#endif +#endif };/** include/hash.h +0
-0
include/hash.h struct hash_algo { · line 45
Quoted 6 lines
include/hash.h +3
-0@@ -40,8 +40,13 @@ struct hash_algo {* @output: Checksum result (length depends on algorithm) * @chunk_sz: Trigger watchdog after processing this many bytes */ +#ifdef CONFIG_EXYNOS_ACE_SHA +int (*hash_func_ws)(const unsigned char *input,unsigned int ilen, +unsigned char *output,unsigned int chunk_sz);
Hmmm you can't do that :-) Let's change hash_func_ws to return an integer. You should create a separate patch to change over existing functions (sha1, sha256) to return 0. Then this patch doesn't need the #ifdef.
Quoted 10 lines
include/hash.h +2
-1+#else void (*hash_func_ws)(const unsigned char *input,unsigned int ilen,unsigned char *output,unsigned int chunk_sz); +#endif int chunk_size;/* Watchdog chunk size */ }; --1.8.0
Regards,
Simon
PATCH v3 3/4 gen: Add ACE acceleration to hash
In reply to Akshay SaraswatQuoted 9 lines · On Fri, 1 Mar 2013 11:16:24 -0500 Akshay Saraswat <[email protected]> wrote:
common/hash.c +3
-0+#include <ace_sha.h> /* * These are the hash algorithms we support. Chips which support accelerated * crypto could perhaps add named version of these algorithms here. */ static struct hash_algo hash_algo[] = { +#ifdef CONFIG_EXYNOS_ACE_SHA + {
common/hash.c line 49
Quoted 10 lines
common/hash.c +10
-0+"SHA1" , +SHA1_SUM_LEN , + ace_sha_hash_digest, +ACE_SHA_TYPE_SHA1 , + }, { +"SHA256" , +SHA256_SUM_LEN , + ace_sha_hash_digest, + ACE_SHA_TYPE_SHA256, + },
Can we make this a generic "hardware accelerated SHA", not tied to vendor-SoC-specific defines? I don't see more than one h/w implementation being used on any one instance of u-boot...
include/hash.h struct hash_algo { · line 49
Quoted 7 lines
include/hash.h +5
-0+#ifdef CONFIG_EXYNOS_ACE_SHA +int (*hash_func_ws)(const unsigned char *input,unsigned int ilen, +unsigned char *output,unsigned int chunk_sz); +#else void (*hash_func_ws)(const unsigned char *input,unsigned int ilen,unsigned char *output,unsigned int chunk_sz); +#endif
function signature mismatch, but I see Simon already got this.
Kim
PATCH v3 4/4 Exynos: config: Enable hash command
In reply to Akshay SaraswatThis enables hash command.
Tested with command "hash sha256 0x40008000 0x2B 0x40009000". Used mm and md to write a standard string to memory location 0x40008000 and ran the above command to verify the output.
---
Chenges since v2:
- New patch to enable config for hash command.
include/configs/exynos5250-dt.h | 1 + 1 file changed, 1 insertion(+)
include/configs/exynos5250-dt.h +1 -0
@@ -116,6 +116,7 @@#define CONFIG_CMD_EXT2 #define CONFIG_CMD_FAT #define CONFIG_CMD_NET +#define CONFIG_CMD_HASH #define CONFIG_BOOTDELAY 3#define CONFIG_ZERO_BOOTDELAY_CHECK
Signature · 1 line
1.8.0
PATCH v3 4/4 Exynos: config: Enable hash command
Quoted 9 lines · Akshay Saraswat
This enables hash command.
Tested with command "hash sha256
0x400080000x2B0x40009000". Used mm and md to write a standard string to memory location0x40008000and ran the above command to verify the output.Change-Id Ia22095b9391cc5889910a60acbc2e970090ea244Signed-off-by ARUN MANKUZHI <[email protected]>Signed-off-by Akshay Saraswat <[email protected]>
Quoted 22 lines
---
Chenges since v2:
- New patch to enable config for hash command.include/configs/exynos5250-dt.h | 1 + 1 file changed, 1 insertion(+)include/configs/exynos5250-dt.h +1
-1@@ -116,6 +116,7 @@#define CONFIG_CMD_EXT2 #define CONFIG_CMD_FAT #define CONFIG_CMD_NET +#define CONFIG_CMD_HASH #define CONFIG_BOOTDELAY 3#define CONFIG_ZERO_BOOTDELAY_CHECK --1.8.0