EE445M RTOS
Taken at the University of Texas Spring 2015
Des_api

Functions

void DESReset (uint32_t ui32Base)
 
void DESConfigSet (uint32_t ui32Base, uint32_t ui32Config)
 
void DESKeySet (uint32_t ui32Base, uint32_t *pui32Key)
 
bool DESIVSet (uint32_t ui32Base, uint32_t *pui32IVdata)
 
void DESLengthSet (uint32_t ui32Base, uint32_t ui32Length)
 
bool DESDataReadNonBlocking (uint32_t ui32Base, uint32_t *pui32Dest)
 
void DESDataRead (uint32_t ui32Base, uint32_t *pui32Dest)
 
bool DESDataWriteNonBlocking (uint32_t ui32Base, uint32_t *pui32Src)
 
void DESDataWrite (uint32_t ui32Base, uint32_t *pui32Src)
 
bool DESDataProcess (uint32_t ui32Base, uint32_t *pui32Src, uint32_t *pui32Dest, uint32_t ui32Length)
 
uint32_t DESIntStatus (uint32_t ui32Base, bool bMasked)
 
void DESIntEnable (uint32_t ui32Base, uint32_t ui32IntFlags)
 
void DESIntDisable (uint32_t ui32Base, uint32_t ui32IntFlags)
 
void DESIntClear (uint32_t ui32Base, uint32_t ui32IntFlags)
 
void DESIntRegister (uint32_t ui32Base, void(*pfnHandler)(void))
 
void DESIntUnregister (uint32_t ui32Base)
 
void DESDMAEnable (uint32_t ui32Base, uint32_t ui32Flags)
 
void DESDMADisable (uint32_t ui32Base, uint32_t ui32Flags)
 

Detailed Description

Function Documentation

void DESConfigSet ( uint32_t  ui32Base,
uint32_t  ui32Config 
)

Configures the DES module for operation.

Parameters
ui32Baseis the base address of the DES module.
ui32Configis the configuration of the DES module.

This function configures the DES module for operation.

The ui32Config parameter is a bit-wise OR of a number of configuration flags. The valid flags are grouped below based on their function.

The direction of the operation is specified with one of the following two flags. Only one is permitted.

  • DES_CFG_DIR_ENCRYPT - Encryption
  • DES_CFG_DIR_DECRYPT - Decryption

The operational mode of the DES engine is specified with one of the following flags. Only one is permitted.

  • DES_CFG_MODE_ECB - Electronic Codebook Mode
  • DES_CFG_MODE_CBC - Cipher-Block Chaining Mode
  • DES_CFG_MODE_CFB - Cipher Feedback Mode

The selection of single DES or triple DES is specified with one of the following two flags. Only one is permitted.

  • DES_CFG_SINGLE - Single DES
  • DES_CFG_TRIPLE - Triple DES
Returns
None.

Definition at line 125 of file des.c.

References ASSERT, DES_BASE, DES_CTRL_CONTEXT, DES_O_CTRL, and HWREG.

126 {
127  //
128  // Check the arguments.
129  //
130  ASSERT(ui32Base == DES_BASE);
131 
132  //
133  // Backup the save context field.
134  //
135  ui32Config |= (HWREG(ui32Base + DES_O_CTRL) & DES_CTRL_CONTEXT);
136 
137  //
138  // Write the control register.
139  //
140  HWREG(ui32Base + DES_O_CTRL) = ui32Config;
141 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define DES_CTRL_CONTEXT
Definition: hw_des.h:142
#define DES_BASE
Definition: hw_memmap.h:142
#define DES_O_CTRL
Definition: hw_des.h:56
bool DESDataProcess ( uint32_t  ui32Base,
uint32_t *  pui32Src,
uint32_t *  pui32Dest,
uint32_t  ui32Length 
)

Processes blocks of data through the DES module.

Parameters
ui32Baseis the base address of the DES module.
pui32Srcis a pointer to an array of words that contains the source data for processing.
pui32Destis a pointer to an array of words consisting of the processed data.
ui32Lengthis the length of the cryptographic data in bytes. It must be a multiple of eight.

This function takes the data contained in the pui32Src array and processes it using the DES engine. The resulting data is stored in the pui32Dest array. The function blocks until all of the data has been processed. If processing is successful, the function returns true.

Note
This functions assumes that the DES module has been configured, and initialization values and keys have been written.
Returns
true or false.

Definition at line 438 of file des.c.

References ASSERT, DES_BASE, DES_CTRL_INPUT_READY, DES_CTRL_OUTPUT_READY, DES_O_CTRL, DES_O_LENGTH, DESDataReadNonBlocking(), DESDataWriteNonBlocking(), and HWREG.

440 {
441  uint32_t ui32Count;
442 
443  //
444  // Check the arguments.
445  //
446  ASSERT(ui32Base == DES_BASE);
447  ASSERT((ui32Length % 8) == 0);
448 
449  //
450  // Write the length register first. This triggers the engine to start
451  // using this context.
452  //
453  HWREG(ui32Base + DES_O_LENGTH) = ui32Length;
454 
455  //
456  // Now loop until the blocks are written.
457  //
458  for(ui32Count = 0; ui32Count < (ui32Length / 4); ui32Count += 2)
459  {
460  //
461  // Check if the input ready is fine
462  //
463  while((DES_CTRL_INPUT_READY & (HWREG(ui32Base + DES_O_CTRL))) == 0)
464  {
465  }
466 
467  //
468  // Write the block data.
469  //
470  DESDataWriteNonBlocking(ui32Base, pui32Src + ui32Count);
471 
472  //
473  // Wait for the output ready
474  //
475  while((DES_CTRL_OUTPUT_READY & (HWREG(ui32Base + DES_O_CTRL))) == 0)
476  {
477  }
478 
479  //
480  // Read the processed data block.
481  //
482  DESDataReadNonBlocking(ui32Base, pui32Dest + ui32Count);
483  }
484 
485  //
486  // Return true to indicate the process was successful.
487  //
488  return(true);
489 }
#define DES_CTRL_INPUT_READY
Definition: hw_des.h:155
#define HWREG(x)
Definition: hw_types.h:48
bool DESDataReadNonBlocking(uint32_t ui32Base, uint32_t *pui32Dest)
Definition: des.c:274
#define ASSERT(expr)
Definition: debug.h:67
#define DES_O_LENGTH
Definition: hw_des.h:57
#define DES_CTRL_OUTPUT_READY
Definition: hw_des.h:157
#define DES_BASE
Definition: hw_memmap.h:142
#define DES_O_CTRL
Definition: hw_des.h:56
bool DESDataWriteNonBlocking(uint32_t ui32Base, uint32_t *pui32Src)
Definition: des.c:351

Here is the call graph for this function:

void DESDataRead ( uint32_t  ui32Base,
uint32_t *  pui32Dest 
)

Reads plaintext/ciphertext from data registers with blocking.

Parameters
ui32Baseis the base address of the DES module.
pui32Destis a pointer to an array of bytes.

This function waits until the DES module is finished and encrypted or decrypted data is ready. The output data is then stored in the pui32Dest array.

Returns
None

Definition at line 316 of file des.c.

References ASSERT, DES_BASE, DES_CTRL_OUTPUT_READY, DES_O_CTRL, DES_O_DATA_H, DES_O_DATA_L, and HWREG.

317 {
318  //
319  // Check the arguments.
320  //
321  ASSERT(ui32Base == DES_BASE);
322 
323  //
324  // Wait for data output to be ready.
325  //
326  while((HWREG(ui32Base + DES_O_CTRL) & DES_CTRL_OUTPUT_READY) == 0)
327  {
328  }
329 
330  //
331  // Read two words of data from the data registers.
332  //
333  pui32Dest[0] = HWREG(DES_BASE + DES_O_DATA_L);
334  pui32Dest[1] = HWREG(DES_BASE + DES_O_DATA_H);
335 }
#define HWREG(x)
Definition: hw_types.h:48
#define DES_O_DATA_L
Definition: hw_des.h:58
#define ASSERT(expr)
Definition: debug.h:67
#define DES_CTRL_OUTPUT_READY
Definition: hw_des.h:157
#define DES_BASE
Definition: hw_memmap.h:142
#define DES_O_DATA_H
Definition: hw_des.h:59
#define DES_O_CTRL
Definition: hw_des.h:56
bool DESDataReadNonBlocking ( uint32_t  ui32Base,
uint32_t *  pui32Dest 
)

Reads plaintext/ciphertext from data registers without blocking

Parameters
ui32Baseis the base address of the DES module.
pui32Destis a pointer to an array of 2 words.

This function returns true if the data was ready when the function was called. If the data was not ready, false is returned.

Returns
True or false.

Definition at line 274 of file des.c.

References ASSERT, DES_BASE, DES_CTRL_OUTPUT_READY, DES_O_CTRL, DES_O_DATA_H, DES_O_DATA_L, and HWREG.

Referenced by DESDataProcess().

275 {
276  //
277  // Check the arguments.
278  //
279  ASSERT(ui32Base == DES_BASE);
280 
281  //
282  // Check to see if the data is ready to be read.
283  //
284  if((DES_CTRL_OUTPUT_READY & (HWREG(ui32Base + DES_O_CTRL))) == 0)
285  {
286  return(false);
287  }
288 
289  //
290  // Read two words of data from the data registers.
291  //
292  pui32Dest[0] = HWREG(DES_BASE + DES_O_DATA_L);
293  pui32Dest[1] = HWREG(DES_BASE + DES_O_DATA_H);
294 
295  //
296  // Return true to indicate a successful write.
297  //
298  return(true);
299 }
#define HWREG(x)
Definition: hw_types.h:48
#define DES_O_DATA_L
Definition: hw_des.h:58
#define ASSERT(expr)
Definition: debug.h:67
#define DES_CTRL_OUTPUT_READY
Definition: hw_des.h:157
#define DES_BASE
Definition: hw_memmap.h:142
#define DES_O_DATA_H
Definition: hw_des.h:59
#define DES_O_CTRL
Definition: hw_des.h:56

Here is the caller graph for this function:

void DESDataWrite ( uint32_t  ui32Base,
uint32_t *  pui32Src 
)

Writes plaintext/ciphertext to data registers without blocking

Parameters
ui32Baseis the base address of the DES module.
pui32Srcis a pointer to an array of bytes.

This function waits until the DES module is ready before writing the data contained in the pui32Src array.

Returns
None.

Definition at line 393 of file des.c.

References ASSERT, DES_BASE, DES_CTRL_INPUT_READY, DES_O_CTRL, DES_O_DATA_H, DES_O_DATA_L, and HWREG.

394 {
395  //
396  // Check the arguments.
397  //
398  ASSERT(ui32Base == DES_BASE);
399 
400  //
401  // Wait for the input ready bit to go high.
402  //
403  while(((HWREG(ui32Base + DES_O_CTRL) & DES_CTRL_INPUT_READY)) == 0)
404  {
405  }
406 
407  //
408  // Write the data.
409  //
410  HWREG(DES_BASE + DES_O_DATA_L) = pui32Src[0];
411  HWREG(DES_BASE + DES_O_DATA_H) = pui32Src[1];
412 }
#define DES_CTRL_INPUT_READY
Definition: hw_des.h:155
#define HWREG(x)
Definition: hw_types.h:48
#define DES_O_DATA_L
Definition: hw_des.h:58
#define ASSERT(expr)
Definition: debug.h:67
#define DES_BASE
Definition: hw_memmap.h:142
#define DES_O_DATA_H
Definition: hw_des.h:59
#define DES_O_CTRL
Definition: hw_des.h:56
bool DESDataWriteNonBlocking ( uint32_t  ui32Base,
uint32_t *  pui32Src 
)

Writes plaintext/ciphertext to data registers without blocking

Parameters
ui32Baseis the base address of the DES module.
pui32Srcis a pointer to an array of 2 words.

This function returns false if the DES module is not ready to accept data. It returns true if the data was written successfully.

Returns
true or false.

Definition at line 351 of file des.c.

References ASSERT, DES_BASE, DES_CTRL_INPUT_READY, DES_O_CTRL, DES_O_DATA_H, DES_O_DATA_L, and HWREG.

Referenced by DESDataProcess().

352 {
353  //
354  // Check the arguments.
355  //
356  ASSERT(ui32Base == DES_BASE);
357 
358  //
359  // Check if the DES module is ready to encrypt or decrypt data. If it
360  // is not, return false.
361  //
362  if(!(DES_CTRL_INPUT_READY & (HWREG(ui32Base + DES_O_CTRL))))
363  {
364  return(false);
365  }
366 
367  //
368  // Write the data.
369  //
370  HWREG(DES_BASE + DES_O_DATA_L) = pui32Src[0];
371  HWREG(DES_BASE + DES_O_DATA_H) = pui32Src[1];
372 
373  //
374  // Return true to indicate a successful write.
375  //
376  return(true);
377 }
#define DES_CTRL_INPUT_READY
Definition: hw_des.h:155
#define HWREG(x)
Definition: hw_types.h:48
#define DES_O_DATA_L
Definition: hw_des.h:58
#define ASSERT(expr)
Definition: debug.h:67
#define DES_BASE
Definition: hw_memmap.h:142
#define DES_O_DATA_H
Definition: hw_des.h:59
#define DES_O_CTRL
Definition: hw_des.h:56

Here is the caller graph for this function:

void DESDMADisable ( uint32_t  ui32Base,
uint32_t  ui32Flags 
)

Disables DMA request sources in the DES module.

Parameters
ui32Baseis the base address of the DES module.
ui32Flagsis a bit mask of the DMA requests to be disabled.

This function disables DMA request sources in the DES module. The ui32Flags parameter should be the logical OR of any of the following:

  • DES_DMA_CONTEXT_IN - Context In
  • DES_DMA_DATA_OUT - Data Out
  • DES_DMA_DATA_IN - Data In
Returns
None.

Definition at line 786 of file des.c.

References ASSERT, DES_BASE, DES_DMA_CONTEXT_IN, DES_DMA_DATA_IN, DES_DMA_DATA_OUT, DES_O_SYSCONFIG, and HWREG.

787 {
788  //
789  // Check the arguments.
790  //
791  ASSERT(ui32Base == DES_BASE);
792  ASSERT((ui32Flags & DES_DMA_CONTEXT_IN) ||
793  (ui32Flags & DES_DMA_DATA_OUT) ||
794  (ui32Flags & DES_DMA_DATA_IN));
795 
796  //
797  // Disable the DMA sources.
798  //
799  HWREG(ui32Base + DES_O_SYSCONFIG) &= ~ui32Flags;
800 }
#define DES_DMA_DATA_OUT
Definition: des.h:103
#define HWREG(x)
Definition: hw_types.h:48
#define DES_DMA_CONTEXT_IN
Definition: des.h:102
#define ASSERT(expr)
Definition: debug.h:67
#define DES_DMA_DATA_IN
Definition: des.h:104
#define DES_BASE
Definition: hw_memmap.h:142
#define DES_O_SYSCONFIG
Definition: hw_des.h:61
void DESDMAEnable ( uint32_t  ui32Base,
uint32_t  ui32Flags 
)

Enables DMA request sources in the DES module.

Parameters
ui32Baseis the base address of the DES module.
ui32Flagsis a bit mask of the DMA requests to be enabled.

This function enables DMA request sources in the DES module. The ui32Flags parameter should be the logical OR of any of the following:

  • DES_DMA_CONTEXT_IN - Context In
  • DES_DMA_DATA_OUT - Data Out
  • DES_DMA_DATA_IN - Data In
Returns
None.

Definition at line 752 of file des.c.

References ASSERT, DES_BASE, DES_DMA_CONTEXT_IN, DES_DMA_DATA_IN, DES_DMA_DATA_OUT, DES_O_SYSCONFIG, and HWREG.

753 {
754  //
755  // Check the arguments.
756  //
757  ASSERT(ui32Base == DES_BASE);
758  ASSERT((ui32Flags & DES_DMA_CONTEXT_IN) ||
759  (ui32Flags & DES_DMA_DATA_OUT) ||
760  (ui32Flags & DES_DMA_DATA_IN));
761 
762  //
763  // Set the data in and data out DMA request enable bits.
764  //
765  HWREG(ui32Base + DES_O_SYSCONFIG) |= ui32Flags;
766 }
#define DES_DMA_DATA_OUT
Definition: des.h:103
#define HWREG(x)
Definition: hw_types.h:48
#define DES_DMA_CONTEXT_IN
Definition: des.h:102
#define ASSERT(expr)
Definition: debug.h:67
#define DES_DMA_DATA_IN
Definition: des.h:104
#define DES_BASE
Definition: hw_memmap.h:142
#define DES_O_SYSCONFIG
Definition: hw_des.h:61
void DESIntClear ( uint32_t  ui32Base,
uint32_t  ui32IntFlags 
)

Clears interrupts in the DES module.

Parameters
ui32Baseis the base address of the DES module.
ui32IntFlagsis a bit mask of the interrupts to be disabled.

This function disables interrupt sources in the DES module. ui32IntFlags should be a logical OR of one or more of the following values:

  • DES_INT_DMA_CONTEXT_IN - Context interrupt
  • DES_INT_DMA_DATA_IN - Data input interrupt
  • DES_INT_DMA_DATA_OUT - Data output interrupt
Note
The DMA done interrupts are the only interrupts that can be cleared. The remaining interrupts can be disabled instead using DESIntDisable().
Returns
None.

Definition at line 643 of file des.c.

References ASSERT, DES_BASE, DES_INT_DMA_CONTEXT_IN, DES_INT_DMA_DATA_IN, DES_INT_DMA_DATA_OUT, DES_O_DMAIC, and HWREG.

644 {
645  //
646  // Check the arguments.
647  //
648  ASSERT(ui32Base == DES_BASE);
649  ASSERT((ui32IntFlags & DES_INT_DMA_CONTEXT_IN) ||
650  (ui32IntFlags & DES_INT_DMA_DATA_IN) ||
651  (ui32IntFlags & DES_INT_DMA_DATA_OUT));
652 
653  HWREG(ui32Base + DES_O_DMAIC) = (ui32IntFlags & 0x00070000) >> 16;
654 }
#define DES_INT_DMA_DATA_OUT
Definition: des.h:94
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define DES_O_DMAIC
Definition: hw_des.h:69
#define DES_INT_DMA_DATA_IN
Definition: des.h:93
#define DES_BASE
Definition: hw_memmap.h:142
#define DES_INT_DMA_CONTEXT_IN
Definition: des.h:92
void DESIntDisable ( uint32_t  ui32Base,
uint32_t  ui32IntFlags 
)

Disables interrupts in the DES module.

Parameters
ui32Baseis the base address of the DES module.
ui32IntFlagsis a bit mask of the interrupts to be disabled.

This function disables interrupt sources in the DES module. ui32IntFlags should be a logical OR of one or more of the following values:

  • DES_INT_CONTEXT_IN - Context interrupt
  • DES_INT_DATA_IN - Data input interrupt
  • DES_INT_DATA_OUT - Data output interrupt
  • DES_INT_DMA_CONTEXT_IN - Context DMA done interrupt
  • DES_INT_DMA_DATA_IN - Data input DMA done interrupt
  • DES_INT_DMA_DATA_OUT - Data output DMA done interrupt
Returns
None.

Definition at line 601 of file des.c.

References ASSERT, DES_BASE, DES_INT_CONTEXT_IN, DES_INT_DATA_IN, DES_INT_DATA_OUT, DES_INT_DMA_CONTEXT_IN, DES_INT_DMA_DATA_IN, DES_INT_DMA_DATA_OUT, DES_O_DMAIM, DES_O_IRQENABLE, and HWREG.

602 {
603  //
604  // Check the arguments.
605  //
606  ASSERT(ui32Base == DES_BASE);
607  ASSERT((ui32IntFlags & DES_INT_CONTEXT_IN) ||
608  (ui32IntFlags & DES_INT_DATA_IN) ||
609  (ui32IntFlags & DES_INT_DATA_OUT) ||
610  (ui32IntFlags & DES_INT_DMA_CONTEXT_IN) ||
611  (ui32IntFlags & DES_INT_DMA_DATA_IN) ||
612  (ui32IntFlags & DES_INT_DMA_DATA_OUT));
613 
614  //
615  // Clear the interrupts from the flags.
616  //
617  HWREG(ui32Base + DES_O_DMAIM) &= ~((ui32IntFlags & 0x00070000) >> 16);
618  HWREG(ui32Base + DES_O_IRQENABLE) &= ~(ui32IntFlags & 0x0000ffff);
619 }
#define DES_INT_DMA_DATA_OUT
Definition: des.h:94
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define DES_INT_DATA_OUT
Definition: des.h:91
#define DES_O_DMAIM
Definition: hw_des.h:66
#define DES_INT_DMA_DATA_IN
Definition: des.h:93
#define DES_INT_DATA_IN
Definition: des.h:90
#define DES_BASE
Definition: hw_memmap.h:142
#define DES_INT_CONTEXT_IN
Definition: des.h:89
#define DES_INT_DMA_CONTEXT_IN
Definition: des.h:92
#define DES_O_IRQENABLE
Definition: hw_des.h:64
void DESIntEnable ( uint32_t  ui32Base,
uint32_t  ui32IntFlags 
)

Enables interrupts in the DES module.

Parameters
ui32Baseis the base address of the DES module.
ui32IntFlagsis a bit mask of the interrupts to be enabled.

ui32IntFlags should be a logical OR of one or more of the following values:

  • DES_INT_CONTEXT_IN - Context interrupt
  • DES_INT_DATA_IN - Data input interrupt
  • DES_INT_DATA_OUT - Data output interrupt
  • DES_INT_DMA_CONTEXT_IN - Context DMA done interrupt
  • DES_INT_DMA_DATA_IN - Data input DMA done interrupt
  • DES_INT_DMA_DATA_OUT - Data output DMA done interrupt
Returns
None.

Definition at line 559 of file des.c.

References ASSERT, DES_BASE, DES_INT_CONTEXT_IN, DES_INT_DATA_IN, DES_INT_DATA_OUT, DES_INT_DMA_CONTEXT_IN, DES_INT_DMA_DATA_IN, DES_INT_DMA_DATA_OUT, DES_O_DMAIM, DES_O_IRQENABLE, and HWREG.

560 {
561  //
562  // Check the arguments.
563  //
564  ASSERT(ui32Base == DES_BASE);
565  ASSERT((ui32IntFlags & DES_INT_CONTEXT_IN) ||
566  (ui32IntFlags & DES_INT_DATA_IN) ||
567  (ui32IntFlags & DES_INT_DATA_OUT) ||
568  (ui32IntFlags & DES_INT_DMA_CONTEXT_IN) ||
569  (ui32IntFlags & DES_INT_DMA_DATA_IN) ||
570  (ui32IntFlags & DES_INT_DMA_DATA_OUT));
571 
572  //
573  // Enable the interrupts from the flags.
574  //
575  HWREG(ui32Base + DES_O_DMAIM) |= (ui32IntFlags & 0x00070000) >> 16;
576  HWREG(ui32Base + DES_O_IRQENABLE) |= ui32IntFlags & 0x0000ffff;
577 }
#define DES_INT_DMA_DATA_OUT
Definition: des.h:94
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define DES_INT_DATA_OUT
Definition: des.h:91
#define DES_O_DMAIM
Definition: hw_des.h:66
#define DES_INT_DMA_DATA_IN
Definition: des.h:93
#define DES_INT_DATA_IN
Definition: des.h:90
#define DES_BASE
Definition: hw_memmap.h:142
#define DES_INT_CONTEXT_IN
Definition: des.h:89
#define DES_INT_DMA_CONTEXT_IN
Definition: des.h:92
#define DES_O_IRQENABLE
Definition: hw_des.h:64
void DESIntRegister ( uint32_t  ui32Base,
void(*)(void)  pfnHandler 
)

Registers an interrupt handler for the DES module.

Parameters
ui32Baseis the base address of the DES module.
pfnHandleris a pointer to the function to be called when the enabled DES interrupts occur.

This function registers the interrupt handler in the interrupt vector table, and enables DES interrupts on the interrupt controller; specific DES interrupt sources must be enabled using DESIntEnable(). The interrupt handler being registered must clear the source of the interrupt using DESIntClear().

If the application is using a static interrupt vector table stored in flash, then it is not necessary to register the interrupt handler this way. Instead, IntEnable() should be used to enable DES interrupts on the interrupt controller.

See also
IntRegister() for important information about registering interrupt handlers.
Returns
None.

Definition at line 682 of file des.c.

References ASSERT, DES_BASE, INT_DES0_TM4C129, IntEnable(), and IntRegister().

683 {
684  //
685  // Check the arguments.
686  //
687  ASSERT(ui32Base == DES_BASE);
688 
689  //
690  // Register the interrupt handler.
691  //
692  IntRegister(INT_DES0_TM4C129, pfnHandler);
693 
694  //
695  // Enable the interrupt.
696  //
698 }
#define INT_DES0_TM4C129
Definition: hw_ints.h:270
#define ASSERT(expr)
Definition: debug.h:67
#define DES_BASE
Definition: hw_memmap.h:142
void IntRegister(uint32_t ui32Interrupt, void(*pfnHandler)(void))
Definition: interrupt.c:309
void IntEnable(uint32_t ui32Interrupt)
Definition: interrupt.c:610

Here is the call graph for this function:

uint32_t DESIntStatus ( uint32_t  ui32Base,
bool  bMasked 
)

Returns the current interrupt status of the DES module.

Parameters
ui32Baseis the base address of the DES module.
bMaskedis false if the raw interrupt status is required and true if the masked interrupt status is required.

This function gets the current interrupt status of the DES module. The value returned is a logical OR of the following values:

  • DES_INT_CONTEXT_IN - Context interrupt
  • DES_INT_DATA_IN - Data input interrupt
  • DES_INT_DATA_OUT_INT - Data output interrupt
  • DES_INT_DMA_CONTEXT_IN - Context DMA done interrupt
  • DES_INT_DMA_DATA_IN - Data input DMA done interrupt
  • DES_INT_DMA_DATA_OUT - Data output DMA done interrupt
Returns
A bit mask of the current interrupt status.

Definition at line 513 of file des.c.

References ASSERT, DES_BASE, DES_O_DMAMIS, DES_O_DMARIS, DES_O_IRQENABLE, DES_O_IRQSTATUS, and HWREG.

514 {
515  uint32_t ui32Status, ui32Enable;
516 
517  //
518  // Check the arguments.
519  //
520  ASSERT(ui32Base == DES_BASE);
521 
522  //
523  // Read the status register and return the value.
524  //
525  ui32Status = HWREG(ui32Base + DES_O_IRQSTATUS);
526  if(bMasked)
527  {
528  ui32Enable = HWREG(ui32Base + DES_O_IRQENABLE);
529  return((ui32Status & ui32Enable) |
530  (HWREG(ui32Base + DES_O_DMAMIS) << 16));
531  }
532  else
533  {
534  return(ui32Status | (HWREG(ui32Base + DES_O_DMARIS) << 16));
535  }
536 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define DES_O_DMAMIS
Definition: hw_des.h:68
#define DES_BASE
Definition: hw_memmap.h:142
#define DES_O_IRQSTATUS
Definition: hw_des.h:63
#define DES_O_DMARIS
Definition: hw_des.h:67
#define DES_O_IRQENABLE
Definition: hw_des.h:64
void DESIntUnregister ( uint32_t  ui32Base)

Unregisters an interrupt handler for the DES module.

Parameters
ui32Baseis the base address of the DES module.

This function unregisters the previously registered interrupt handler and disables the interrupt in the interrupt controller.

See also
IntRegister() for important information about registering interrupt handlers.
Returns
None.

Definition at line 716 of file des.c.

References ASSERT, DES_BASE, INT_DES0_TM4C129, IntDisable(), and IntUnregister().

717 {
718  //
719  // Check the arguments.
720  //
721  ASSERT(ui32Base == DES_BASE);
722 
723  //
724  // Disable the interrupt.
725  //
727 
728  //
729  // Unregister the interrupt handler.
730  //
732 }
#define INT_DES0_TM4C129
Definition: hw_ints.h:270
#define ASSERT(expr)
Definition: debug.h:67
void IntUnregister(uint32_t ui32Interrupt)
Definition: interrupt.c:381
#define DES_BASE
Definition: hw_memmap.h:142
void IntDisable(uint32_t ui32Interrupt)
Definition: interrupt.c:684

Here is the call graph for this function:

bool DESIVSet ( uint32_t  ui32Base,
uint32_t *  pui32IVdata 
)

Sets the initialization vector in the DES module.

Parameters
ui32Baseis the base address of the DES module.
pui32IVdatais a pointer to an array of 64 bits (2 words) of data to be written into the initialization vectors registers.

This function sets the initialization vector in the DES module. It returns true if the registers were successfully written. If the context registers cannot be written at the time the function was called, then false is returned.

Returns
True or false.

Definition at line 202 of file des.c.

References ASSERT, DES_BASE, DES_CTRL_CONTEXT, DES_O_CTRL, DES_O_IV_H, DES_O_IV_L, and HWREG.

203 {
204  //
205  // Check the arguments.
206  //
207  ASSERT(ui32Base == DES_BASE);
208 
209  //
210  // Check to see if context registers can be overwritten. If not, return
211  // false.
212  //
213  if((HWREG(ui32Base + DES_O_CTRL) & DES_CTRL_CONTEXT) == 0)
214  {
215  return(false);
216  }
217 
218  //
219  // Write the initialization vector registers.
220  //
221  HWREG(ui32Base + DES_O_IV_L) = pui32IVdata[0];
222  HWREG(ui32Base + DES_O_IV_H) = pui32IVdata[1];
223 
224  //
225  // Return true to indicate the write was successful.
226  //
227  return(true);
228 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define DES_O_IV_L
Definition: hw_des.h:54
#define DES_O_IV_H
Definition: hw_des.h:55
#define DES_CTRL_CONTEXT
Definition: hw_des.h:142
#define DES_BASE
Definition: hw_memmap.h:142
#define DES_O_CTRL
Definition: hw_des.h:56
void DESKeySet ( uint32_t  ui32Base,
uint32_t *  pui32Key 
)

Sets the key used for DES operations.

Parameters
ui32Baseis the base address of the DES module.
pui32Keyis a pointer to an array that holds the key

This function sets the key used for DES operations.

pui32Key should be 64 bits long (2 words) if single DES is being used or 192 bits (6 words) if triple DES is being used.

Returns
None.

Definition at line 159 of file des.c.

References ASSERT, DES_BASE, DES_CFG_TRIPLE, DES_O_CTRL, DES_O_KEY1_H, DES_O_KEY1_L, DES_O_KEY2_H, DES_O_KEY2_L, DES_O_KEY3_H, DES_O_KEY3_L, and HWREG.

160 {
161  //
162  // Check the arguments.
163  //
164  ASSERT(ui32Base == DES_BASE);
165 
166  //
167  // Write the first part of the key.
168  //
169  HWREG(ui32Base + DES_O_KEY1_L) = pui32Key[0];
170  HWREG(ui32Base + DES_O_KEY1_H) = pui32Key[1];
171 
172  //
173  // If we are performing tripe DES, then write the key registers for
174  // the second and third rounds.
175  //
176  if(HWREG(ui32Base + DES_O_CTRL) & DES_CFG_TRIPLE)
177  {
178  HWREG(ui32Base + DES_O_KEY2_L) = pui32Key[2];
179  HWREG(ui32Base + DES_O_KEY2_H) = pui32Key[3];
180  HWREG(ui32Base + DES_O_KEY3_L) = pui32Key[4];
181  HWREG(ui32Base + DES_O_KEY3_H) = pui32Key[5];
182  }
183 }
#define HWREG(x)
Definition: hw_types.h:48
#define DES_CFG_TRIPLE
Definition: des.h:81
#define ASSERT(expr)
Definition: debug.h:67
#define DES_O_KEY1_L
Definition: hw_des.h:52
#define DES_O_KEY1_H
Definition: hw_des.h:53
#define DES_O_KEY2_L
Definition: hw_des.h:50
#define DES_O_KEY2_H
Definition: hw_des.h:51
#define DES_BASE
Definition: hw_memmap.h:142
#define DES_O_KEY3_H
Definition: hw_des.h:49
#define DES_O_KEY3_L
Definition: hw_des.h:48
#define DES_O_CTRL
Definition: hw_des.h:56
void DESLengthSet ( uint32_t  ui32Base,
uint32_t  ui32Length 
)

Sets the crytographic data length in the DES module.

Parameters
ui32Baseis the base address of the DES module.
ui32Lengthis the length of the data in bytes.

This function writes the cryptographic data length into the DES module. When this register is written, the engine is triggered to start using this context.

Note
Data lengths up to (2^32 - 1) bytes are allowed.
Returns
None.

Definition at line 247 of file des.c.

References ASSERT, DES_BASE, DES_O_LENGTH, and HWREG.

248 {
249  //
250  // Check the arguments.
251  //
252  ASSERT(ui32Base == DES_BASE);
253 
254  //
255  // Write the length register.
256  //
257  HWREG(ui32Base + DES_O_LENGTH) = ui32Length;
258 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define DES_O_LENGTH
Definition: hw_des.h:57
#define DES_BASE
Definition: hw_memmap.h:142
void DESReset ( uint32_t  ui32Base)

Resets the DES Module.

Parameters
ui32Baseis the base address of the DES module.

This function performs a soft-reset sequence of the DES module.

Returns
None.

Definition at line 69 of file des.c.

References ASSERT, DES_BASE, DES_O_SYSCONFIG, DES_O_SYSSTATUS, DES_SYSCONFIG_SOFTRESET, DES_SYSSTATUS_RESETDONE, and HWREG.

70 {
71  //
72  // Check the arguments.
73  //
74  ASSERT(ui32Base == DES_BASE);
75 
76  //
77  // Trigger the soft reset.
78  //
80 
81  //
82  // Wait for the reset to finish.
83  //
84  while((HWREG(ui32Base + DES_O_SYSSTATUS) &
86  {
87  }
88 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define DES_SYSSTATUS_RESETDONE
Definition: hw_des.h:219
#define DES_O_SYSSTATUS
Definition: hw_des.h:62
#define DES_BASE
Definition: hw_memmap.h:142
#define DES_SYSCONFIG_SOFTRESET
Definition: hw_des.h:211
#define DES_O_SYSCONFIG
Definition: hw_des.h:61