aboutsummaryrefslogblamecommitdiff
path: root/sw/test-sha256/test-sha256.c
blob: 25845d0f75307d39e462f72ef5b129e3cc70f146 (plain) (tree)
1
2
3
4
5
6
7
8







                                                                        




                                                                                
                   




                                                                                
          
                                                                                

                                                




                                                                                


                                                                                
         
                                                                                
          
 





















                                                              

 


                                                                        
//======================================================================
//
// test-sha256.c
// -------------
// test program for Cryptech Novena framwwork with EIM interface
// using the sha256 core.
//
//======================================================================

//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include "novena-eim.h"


//------------------------------------------------------------------------------
// Defines
//------------------------------------------------------------------------------
#define SHA256_PREFIX (0x14)
#define SHA_BASE (EIM_BASE_ADDR + SHA256_PREFIX)


//------------------------------------------------------------------------------
// Testing Parameters
//------------------------------------------------------------------------------


//------------------------------------------------------------------------------
// main()
//------------------------------------------------------------------------------
int main()
{
  unsigned int read_addr;
  unsigned int read_data;

  // try to setup eim (return value should be 1)
  printf("Configuring EIM .. ");
  int ok = eim_setup();
  if (ok < 1) {
    printf("ERROR\n");
    return EXIT_FAILURE;
  }
  else {
    printf("EIM Setup ok.\n");
  }

  // Dump register contents. See if we have the core.
  for (unsigned int i = 0 ; i < 100 ; i += 3) {
    read_addr = SHA_BASE + i;
    eim_read_32(read_addr, &read_data);
    printf("address 0x%08x = 0x%08x\n", read_addr, read_data);
  }

  return 0;
}

//======================================================================
// EOF test-sha256.c
//======================================================================