/**************************************************************************** * * * 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 #include "entry.h" extern VOID fpgaNvsramUnlockAll(VOID); extern unsigned long gDiagAvailAddr; /************************/ /* /proc/table function */ /************************/ int diagTableEntryRead ( 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_TABLE] Cannot get virtual space for NVSRAM!! \n"); return -EFAULT; } //get file size table_len = *(volatile unsigned int*)(nvsram_virtual_base + DIAG_TABLE_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_TABLE_BASE_OFFSET + i)); } return table_len; } int diagTableEntryWrite ( struct file *file, const char *buf, unsigned long length, void *data ) { char table_buf[DIAG_TABLE_CHAR_SIZE]; void* nvsram_virtual_base; int i; printk("[PROC_TABLE] Write test item list to NVSRAM!! \n"); printk("[PROC_TABLE] File length: 0x%08X \n", (unsigned int)length); if(length >= DIAG_TABLE_CHAR_SIZE){ printk("[PROC_TABLE] File is bigger than 2KBytes!! Abort writing progress.\n"); return length; } //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; } //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_TABLE_BASE_OFFSET + i) = table_buf[i]; } *(volatile unsigned int*)(nvsram_virtual_base + DIAG_TABLE_SIZE_LOCATION) = (unsigned int)length; return length; }