/*******************************************************************************
NCom - ARM DCC Access. This functionality of this file is separated out of
NCom_ARM_DCC.c to allow NMon to be compiled in Thumb mode. THIS FILE MUST BE
COMPILED AS ARM MODE.

Creator: Sten Larsson
$Header: /NCARM_Misc/Monitor/LdMac71xx/DCC.c 10    1/17/06 8:33a Mikeq $
--------------------------------------------------------------------------------
DO NOT MODIFY THIS FILE - IT IS A PART OF NMON (Nohau Monitor) AND MAY BE
UPDATED IN FUTURE RELEASES OF SEEHAU.

This computer software is owned by Nohau Corp, and is protected by U.S.
copyright laws and other laws and by international treaties. Customers of Nohau
emulators/debuggers are allowed include it in their products for the purpose of
enhancing the debug capabilities of Nohau products. It is not allowed to use it
for any other purpose. The source code may not be provided or otherwise made
available to third parties, except with the purpose of using it with Nohau
tools. Nohau may elect to grant exceptions to the above statement in a written
agreement.

Copyright  ©  2002, Nohau Corporation. All Rights Reserved.
Copyright (c) 2002, Nohau Corporation. All Rights Reserved.
*******************************************************************************/
#ifdef ARMMODE
#undef ARMMODE
#endif

#ifdef __IAR_SYSTEMS_ICC__
  #define ARMMODE __arm
#endif
#ifdef HI_TECH_C
  #define ARMMODE arm
#endif
#ifndef ARMMODE
  #define ARMMODE
#endif

#ifdef __IAR_SYSTEMS_ICC__
  #pragma diag_suppress=Pe940  /* Ignore missing return statements */
#endif

/*******************************************************************************
Read the DCC control register - MUST BE DONE IN ARM MODE.
MRC = Move to ARM Register from Coprocessor

MRC P14, 0, R0, c0, c0 - Return the DCC Control register into R0.
*******************************************************************************/
ARMMODE unsigned dccControl(void)
{
   #ifdef HI_TECH_C
   return asm("MRC P14, 0, R0, C0, C0");    /* HI-TECH Compiler */
   #endif

   #ifdef __IAR_SYSTEMS_ICC__
   asm("MRC P14, 0, R0, C0, C0");    /* IAR Compiler */
   #endif

   #ifdef __arm
   __asm{ MRC P14, 0, R0, c0, c0; }  /* ARM Compiler */
   #endif
}

/*******************************************************************************
Read the DCC data register - MUST BE DONE IN ARM MODE.
MRC = Move to ARM Register from Coprocessor

MRC P14, 0, R0, c1, c0 - Write the value in R0 to the DCC Data Write register.
*******************************************************************************/
ARMMODE unsigned dccRead(void)
{
   #ifdef HI_TECH_C
   return asm ("MRC P14, 0, R0, C1, C0");   /* HI-TECH Compiler */
   #endif

   #ifdef __IAR_SYSTEMS_ICC__
   asm ("MRC P14, 0, R0, C1, C0");   /* IAR Compiler */
   #endif

   #ifdef __arm
   __asm{ MRC P14, 0, R0, c1, c0 };  /* ARM Compiler */
   #endif
}

/*******************************************************************************
Write to the DCC data register - MUST BE DONE IN ARM MODE.
MCR = Move to Coprocessor from ARM Register

MCR P14, 0, R0, c1, c0 - Returns the DCC Data Read register into R0.
*******************************************************************************/
ARMMODE void dccWrite(unsigned data)
{
   /* Default is for first parameter to sit in R0 */

   #ifdef HI_TECH_C
   return asm ("MCR P14, 0, R0, C1, C0");   /* HI-TECH Compiler */
   #endif

   #ifdef __IAR_SYSTEMS_ICC__
   asm ("MCR P14, 0, R0, C1, C0");   /* IAR Compiler */
   #endif

   #ifdef __arm
   __asm { MCR P14, 0, R0, c1, c0 }; /* ARM Compiler */
   #endif
}
