/**************************************************************************** * * * Copyright 2004-2011 LSI Corporation. All rights reserved. This file is * * confidential and a trade secret of LSI Corporation. The receipt or * * possession of this file does not convey any rights to reproduce or * * disclose its contents or to manufacture, use, or sell anything it may * * describe, in whole, or in part, without the specific written consent of * * LSI Corporation. * * * ****************************************************************************/ /**************************************************************************** * * * NAME Makefile * * SUMMARY * * VERSION %version: % * * UPDATE DATE %date_modified: % * * PROGRAMMER %created_by: Shawn Wang % * * * * Copyright 2002-2011 LSI Corporation. All Rights Reserved. * * * * DESCRIPTION: * * * ****************************************************************************/ #include #include #include #include #include #include #include extern VOID fpgaNvsramUnlockAll(VOID); #include "entry.h" /**************************/ /* /proc/usrconf function */ /**************************/ int userConfEntryRead ( char *buf, char **start, off_t offset, int length, int *eof, void *data ) { int table_len, nbytes=0; void* nvsram_virtual_base; int i; //get virtual address nvsram_virtual_base = gFpgaBar2VirtualP; if (nvsram_virtual_base == NULL){ printk("[PROC_USER_CONF] Cannot get virtual space for NVSRAM!! \n"); return -EFAULT; } //get file size table_len = *(volatile unsigned int*)(nvsram_virtual_base + DIAG_USER_CONF_SIZE_LOCATION); //move content from table_buf to NVSRAM for(i=0; i < table_len; i++){ nbytes += sprintf(buf+nbytes, "%c", *(volatile unsigned char*)(nvsram_virtual_base + DIAG_USER_CONF_OFFSET + i)); } return table_len; } int userConfEntryWrite ( struct file *file, const char *buf, unsigned long length, void *data ) { char table_buf[DIAG_USER_CONF_SIZE]; void* nvsram_virtual_base; int i; printk("[PROC_USER_CONF] Write User Config to NVSRAM!! \n"); printk("[PROC_USER_CONF] File length: 0x%08X \n", (unsigned int)length); if(length >= DIAG_USER_CONF_SIZE){ printk("[PROC_USER_CONF] File is bigger than 4KBytes!! Abort writing progress.\n"); return length; } nvsram_virtual_base = gFpgaBar2VirtualP; if (nvsram_virtual_base == NULL){ printk("[PROC_USER_CONF] Cannot get virtual space for NVSRAM!! \n"); return -EFAULT; } //unlock entire NVSRAM fpgaNvsramUnlockAll(); //copy data from user if (copy_from_user(table_buf, buf, length) ) { return -EFAULT; } //move content from table_buf to NVSRAM for(i=0; i < length; i++){ *(volatile unsigned char*)(nvsram_virtual_base + DIAG_USER_CONF_OFFSET + i) = table_buf[i]; } *(volatile unsigned int*)(nvsram_virtual_base + DIAG_USER_CONF_SIZE_LOCATION) = (unsigned int)length; return length; }