[Armadeus-commitlog] SF.net SVN: armadeus: [803] trunk/target/linux/modules/fpga/fpgaaccess
Brought to you by:
sszy
|
From: <th...@us...> - 2008-05-08 12:00:08
|
Revision: 803
http://armadeus.svn.sourceforge.net/armadeus/?rev=803&view=rev
Author: thom25
Date: 2008-05-08 05:00:06 -0700 (Thu, 08 May 2008)
Log Message:
-----------
fix bug when writing 16bits values in fpgaregs.c
fix hard coded path in Makefile
remove specific lines in Makefile
fix warning in fpgaaccess.c
Modified Paths:
--------------
trunk/target/linux/modules/fpga/fpgaaccess/Makefile
trunk/target/linux/modules/fpga/fpgaaccess/fpgaaccess.c
trunk/target/linux/modules/fpga/fpgaaccess/fpgaregs.c
Modified: trunk/target/linux/modules/fpga/fpgaaccess/Makefile
===================================================================
--- trunk/target/linux/modules/fpga/fpgaaccess/Makefile 2008-05-04 12:12:52 UTC (rev 802)
+++ trunk/target/linux/modules/fpga/fpgaaccess/Makefile 2008-05-08 12:00:06 UTC (rev 803)
@@ -22,12 +22,9 @@
default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
- -cp fpgaaccess.ko /tftpboot/
fpgaregs: fpgaregs.c
- ~/armadeus/buildroot/build_arm/staging_dir/bin/arm-linux-gcc -Wall fpgaregs.c -o fpgaregs
- chmod 755 fpgaregs
- cp fpgaregs /tftpboot/
+ $(BASE_DIR)build_arm/staging_dir/bin/arm-linux-gcc -Wall fpgaregs.c -o fpgaregs
clean:
rm -f *.*o \
Modified: trunk/target/linux/modules/fpga/fpgaaccess/fpgaaccess.c
===================================================================
--- trunk/target/linux/modules/fpga/fpgaaccess/fpgaaccess.c 2008-05-04 12:12:52 UTC (rev 802)
+++ trunk/target/linux/modules/fpga/fpgaaccess/fpgaaccess.c 2008-05-08 12:00:06 UTC (rev 803)
@@ -44,7 +44,7 @@
data = ioread16(sdev->fpga_virtual_base_address + *offp);
/* return data for user */
- if(copy_to_user(buff,&data,2)){
+ if(copy_to_user(buff,&data,count)){
printk(KERN_WARNING "read : copy to user data error\n");
return -EFAULT;
}
@@ -63,14 +63,14 @@
if(count != 2) /* only one word can be wrote (two bytes)*/
count = 2;
- if(copy_from_user(&data,buff,2)){
+ if(copy_from_user(&data,buff,count)){
printk(KERN_WARNING "write : copy from user error\n");
return -EFAULT;
}
iowrite16(data,sdev->fpga_virtual_base_address + *offp);
- return 2;
+ return count;
}
int fpgaaccess_open(struct inode *inode, struct file *filp){
@@ -92,7 +92,6 @@
static int __init fpgaaccess_init(void){
int result;
int fpgaaccess_major,fpgaaccess_minor;
- u16 data;
struct fpgaaccess_dev *sdev;
fpgaaccess_major = 250;
Modified: trunk/target/linux/modules/fpga/fpgaaccess/fpgaregs.c
===================================================================
--- trunk/target/linux/modules/fpga/fpgaaccess/fpgaregs.c 2008-05-04 12:12:52 UTC (rev 802)
+++ trunk/target/linux/modules/fpga/fpgaaccess/fpgaregs.c 2008-05-08 12:00:06 UTC (rev 803)
@@ -41,18 +41,16 @@
/* converting string */
#include <string.h>
-int ffpga;
int main(int argc, char *argv[])
{
- unsigned short address;
+ unsigned int address;
unsigned short value;
- int retval;
+ int retval, error = 0;
+ int ffpga;
- printf( "Testing button driver\n" );
-
if((argc < 2) || (argc > 3)){
- perror("invalid arguments number\nfpgaregs fpga_reg_add [value]\n");
+ perror("invalid arguments number\nfpgaregs fpga_reg_add [value].\n Ex: fpgaregs 0x10 0x0008");
exit(EXIT_FAILURE);
}
@@ -62,33 +60,35 @@
exit(EXIT_FAILURE);
}
- address = (unsigned char )strtol(argv[1], (char **)NULL, 16);
+ address = (unsigned int)strtol(argv[1], (char **)NULL, 16);
- if(address%2!=0){
- perror("error address must be pair\n");
- exit(EXIT_FAILURE);
+ if(argc<2){
+ perror("invalid command line");
}
-
- /* write value at address */
- if(argc == 3){
- value = (unsigned char )strtol(argv[2], (char **)NULL, 16);
- retval = pwrite(ffpga,(void *)&value,2,address);
- if(retval<0){
- perror("write error\n");
- exit(EXIT_FAILURE);
+ else {
+ /* write value at address */
+ if(argc == 3){
+ value = strtol(argv[2], (char **)NULL, 16);
+ retval = pwrite(ffpga,(void *)&value,2,address);
+ if(retval<0){
+ perror("write error\n");
+ error = EXIT_FAILURE;
+ }
+ else
+ printf("Wrote %04x at %08x\n",value,address);
+
+ /* read address value */
+ }else if(argc == 2){
+ retval = pread(ffpga,(void *)&value,2,address);
+ if(retval<0){
+ perror("Read error\n");
+ error = EXIT_FAILURE;
+ }
+ else
+ printf("Read %04x at %08x\n",value,address);
+ }
}
- printf("Wrote %04x at %08x\n",value,address+0x12000000);
-
- /* read address value */
- }else{
- retval = pread(ffpga,(void *)&value,2,address);
- if(retval<0){
- perror("Read error\n");
- exit(EXIT_FAILURE);
- }
- printf("Read %04x at %08x\n",value,address+0x12000000);
- }
-
close(ffpga);
- exit(0);
+ exit(error);
}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|