www.usr.com/support/gpl/USR9113_release1.0.tar.gz
[bcm963xx.git] / userapps / broadcom / cfm / util / psi / board_api.c
index 3923bb0..4cdebb0 100755 (executable)
@@ -28,7 +28,6 @@
 
 #include <bcmtypes.h>
 #include <board_api.h>
-
 int boardIoctl(int board_ioctl, BOARD_IOCTL_ACTION action, char *string, int strLen, int offset, char *buf)
 {
     BOARD_IOCTL_PARMS IoctlParms;
@@ -73,9 +72,32 @@ int sysScratchPadGet(char *tokenId, char *tokBuf, int bufLen)
 */
 int sysScratchPadSet(char *tokenId, char *tokBuf, int bufLen)
 {
+    char *buf = malloc(bufLen);
+
+    //If the data associated with the tokenId already exists in the scratch pad,
+    //we don't want to set it again.
+       //Note that writing to the scratch pad is a non-preemptive time consuming
+       //operation that should be avoided.
+    if (buf != NULL &&
+        boardIoctl(BOARD_IOCTL_FLASH_READ, SCRATCH_PAD, tokenId, bufLen, bufLen, buf) >= 0) {
+        if (bcmp(buf, tokBuf, bufLen) == 0) {
+            free(buf);
+            return 0;
+        }
+    }
+    if (buf != NULL) free(buf);
+
     return (boardIoctl(BOARD_IOCTL_FLASH_WRITE, SCRATCH_PAD, tokenId, bufLen, bufLen, tokBuf));
 }
 
+/*****************************************************************************
+* sysScratchPadClearAll  - wipeout the scratch pad
+* RETURNS: 0 - ok, -1 fail.
+*/
+int sysScratchPadClearAll(void)
+{
+    return (boardIoctl(BOARD_IOCTL_FLASH_WRITE, SCRATCH_PAD, "", -1, -1, ""));
+}
 
 /*****************************************************************************
 * sysPersistentGet - get the contents of non-volatile RAM,
@@ -86,6 +108,8 @@ int sysNvRamGet(char *string, int strLen, int offset)
     return (boardIoctl(BOARD_IOCTL_FLASH_READ, NVRAM, string, strLen, offset, ""));
 }
 
+
+
 /*****************************************************************************
 * sysPersistentSet - write the contents of non-volatile RAM
 * RETURNS: OK, always.
@@ -197,7 +221,7 @@ int sysGetChipId( void )
 //********************************************************************************
 void sysWakeupMonitorTask(void)
 {
-    return (boardIoctl(BOARD_IOCTL_WAKEUP_MONITOR_TASK, 0, "", 0, 0, ""));
+    boardIoctl(BOARD_IOCTL_WAKEUP_MONITOR_TASK, 0, "", 0, 0, "");
 }
 
 #ifdef USE_ALL
@@ -311,5 +335,37 @@ int sysSetMonitorFd(int fd)
     return (boardIoctl(BOARD_IOCTL_SET_MONITOR_FD, 0, "", 0, fd, ""));
 }
 
+//******************************************************************************
+// Get VCOPE board information: cs, gpio, board revision
+//******************************************************************************
+int sysGetVcopeInfo(int info_type)
+{
+    return(boardIoctl(BOARD_IOCTL_GET_VCOPE_GPIO, 0, "", 0, info_type, ""));
+}
+
+//******************************************************************************
+// Configure Chip Select, by setting given parameter to a passed value
+//******************************************************************************
+int sysConfigCs (int cs_number, void *cs_info)
+{
+    return(boardIoctl(BOARD_IOCTL_SET_CS_PAR, 0, "", 0, cs_number, cs_info));
+}
+
+//******************************************************************************
+// Set up PLL clock register according to the passed values
+//******************************************************************************
+int  sysSetPllClockRegister(mask, value)
+{
+    return(boardIoctl(BOARD_IOCTL_SET_PLL, 0, "", mask, value, ""));
+}
+
+//******************************************************************************
+// Configure GPIO bit according to the passed values
+//******************************************************************************
+int  sysSetGpioBit (int gpio_bit, GPIO_STATE_t flag)
+{
+    return(boardIoctl(BOARD_IOCTL_SET_GPIO, 0, "", gpio_bit, flag, ""));
+}
+
 #endif // USE_ALL