summaryrefslogtreecommitdiffstats
path: root/main/common/cache.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/common/cache.c')
-rw-r--r--main/common/cache.c102
1 files changed, 53 insertions, 49 deletions
diff --git a/main/common/cache.c b/main/common/cache.c
index 5f230bf..0ed9c97 100644
--- a/main/common/cache.c
+++ b/main/common/cache.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
* Copyright (c) 2013 Alcatel-Lucent
- *
+ *
* Alcatel Lucent licenses this file to You under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. A copy of the License is contained the
@@ -19,25 +19,25 @@
**************************************************************************
*
* cache.c:
- * This code is the front-end to CPU-specific code that may or may not
- * support basic I & D cache operations. Various facilities in the
+ * This code is the front-end to CPU-specific code that may or may not
+ * support basic I & D cache operations. Various facilities in the
* monitor call the wrapper functions below for carrying out cpu-specific
* cache operations. This code provides that wrapper allowing the other
- * portions of the monitor to be unaware of what the specific CPU actually
- * supports.
+ * portions of the monitor to be unaware of what the specific CPU actually
+ * supports.
+ *
+ * The cacheInit() function must be called at monitor startup, then
+ * cacheInit() calls cacheInitForTarget(), a function that must be provided
+ * by the target-specific code to fill in the CPU-specific functionality.
+ * This function should establish the cache as it is to be used in
+ * the monitor (typically i-cache enabled, d-cache disabled), plus, if
+ * applicable, the dcacheFlush and icacheInvalidate function pointers should
+ * be initialized to CPU-specific functions that match the API...
*
- * The cacheInit() function must be called at monitor startup, then
- * cacheInit() calls cacheInitForTarget(), a function that must be provided
- * by the target-specific code to fill in the CPU-specific functionality.
- * This function should establish the cache as it is to be used in
- * the monitor (typically i-cache enabled, d-cache disabled), plus, if
- * applicable, the dcacheFlush and icacheInvalidate function pointers should
- * be initialized to CPU-specific functions that match the API...
- *
- * int (*dcacheDisable)(void);
- * int (*icacheDisable)(void);
- * int (*dcacheFlush)(char *base,int size);
- * int (*icacheInvalidate)(char *base, int size);
+ * int (*dcacheDisable)(void);
+ * int (*icacheDisable)(void);
+ * int (*dcacheFlush)(char *base,int size);
+ * int (*icacheInvalidate)(char *base, int size);
*
*
* Original author: Ed Sutter (ed.sutter@alcatel-lucent.com)
@@ -46,8 +46,8 @@
#include "genlib.h"
#include "cache.h"
-int (*dcacheFlush)(char *,int), (*icacheInvalidate)(char *, int);
-int (*dcacheDisable)(void), (*icacheDisable)(void);
+int (*dcacheFlush)(char *,int), (*icacheInvalidate)(char *, int);
+int (*dcacheDisable)(void), (*icacheDisable)(void);
/* flushDcache():
* Flush the address range specified, or if address and size are both
@@ -56,12 +56,13 @@ int (*dcacheDisable)(void), (*icacheDisable)(void);
int
flushDcache(char *addr, int size)
{
- /* The dcacheFlush function pointer should be initialized in the
- * port-specific function "cacheInitForTarget".
- */
- if (dcacheFlush)
- return(dcacheFlush(addr,size));
- return(0);
+ /* The dcacheFlush function pointer should be initialized in the
+ * port-specific function "cacheInitForTarget".
+ */
+ if(dcacheFlush) {
+ return(dcacheFlush(addr,size));
+ }
+ return(0);
}
/* disableDcache():
@@ -70,12 +71,13 @@ flushDcache(char *addr, int size)
int
disableDcache(void)
{
- /* The dcacheDisable function pointer should be initialized in the
- * port-specific function "cacheInitForTarget".
- */
- if (dcacheDisable)
- return(dcacheDisable());
- return(0);
+ /* The dcacheDisable function pointer should be initialized in the
+ * port-specific function "cacheInitForTarget".
+ */
+ if(dcacheDisable) {
+ return(dcacheDisable());
+ }
+ return(0);
}
/* invalidateIcache():
@@ -85,12 +87,13 @@ disableDcache(void)
int
invalidateIcache(char *addr, int size)
{
- /* The icacheInvalidate function pointer should be initialized in the
- * port-specific function "cacheInitForTarget".
- */
- if (icacheInvalidate)
- return(icacheInvalidate(addr,size));
- return(0);
+ /* The icacheInvalidate function pointer should be initialized in the
+ * port-specific function "cacheInitForTarget".
+ */
+ if(icacheInvalidate) {
+ return(icacheInvalidate(addr,size));
+ }
+ return(0);
}
/* disableIcache():
@@ -99,21 +102,22 @@ invalidateIcache(char *addr, int size)
int
disableIcache(void)
{
- /* The icacheDisable function pointer should be initialized in the
- * port-specific function "cacheInitForTarget".
- */
- if (icacheDisable)
- return(icacheDisable());
- return(0);
+ /* The icacheDisable function pointer should be initialized in the
+ * port-specific function "cacheInitForTarget".
+ */
+ if(icacheDisable) {
+ return(icacheDisable());
+ }
+ return(0);
}
int
cacheInit()
{
- dcacheDisable = (int(*)(void))0;
- icacheDisable = (int(*)(void))0;
- dcacheFlush = (int(*)(char *,int))0;
- icacheInvalidate = (int(*)(char *,int))0;
- cacheInitForTarget(); /* Target-specific initialization. */
- return(0);
+ dcacheDisable = (int(*)(void))0;
+ icacheDisable = (int(*)(void))0;
+ dcacheFlush = (int(*)(char *,int))0;
+ icacheInvalidate = (int(*)(char *,int))0;
+ cacheInitForTarget(); /* Target-specific initialization. */
+ return(0);
}