[Armadeus-commitlog] SF.net SVN: armadeus: [768] trunk/target/linux/debug/fpgaregs/fpgaregs.c
Brought to you by:
sszy
|
From: <Fa...@us...> - 2008-03-12 10:17:08
|
Revision: 768
http://armadeus.svn.sourceforge.net/armadeus/?rev=768&view=rev
Author: FabM
Date: 2008-03-12 03:17:13 -0700 (Wed, 12 Mar 2008)
Log Message:
-----------
Immonde ^M supprim?\195?\169s
Modified Paths:
--------------
trunk/target/linux/debug/fpgaregs/fpgaregs.c
Modified: trunk/target/linux/debug/fpgaregs/fpgaregs.c
===================================================================
--- trunk/target/linux/debug/fpgaregs/fpgaregs.c 2008-03-07 18:07:11 UTC (rev 767)
+++ trunk/target/linux/debug/fpgaregs/fpgaregs.c 2008-03-12 10:17:13 UTC (rev 768)
@@ -1,12 +1,12 @@
-/*
- * fpgaregs.h - Tool to display and modify fpga registers from Linux's userspace
- *
- * Author/Maintainer: --- armadeus -----
- * Derivated from pxaregs (c) Copyright 2002 by M&N Logistik-L�ungen Online GmbH
- *
- * This tool is placed under the GPL.
- *
-*/
+/*
+ * fpgaregs.h - Tool to display and modify fpga registers from Linux's userspace
+ *
+ * Author/Maintainer: --- armadeus -----
+ * Derivated from pxaregs (c) Copyright 2002 by M&N Logistik-L�ungen Online GmbH
+ *
+ * This tool is placed under the GPL.
+ *
+*/
#include <stdio.h>
#include <unistd.h>
@@ -23,15 +23,15 @@
// fd for /dev/mem
static int fd = -1;
-typedef unsigned short u16;
-typedef unsigned int u32;
+typedef unsigned short u16;
+typedef unsigned int u32;
-#define FPGA_BASE_ADDR 0x12000000
-// Size of mmapping:
-#define MAP_SIZE 4096
-#define MAP_MASK ( MAP_SIZE - 1 )
-
+#define FPGA_BASE_ADDR 0x12000000
+// Size of mmapping:
+#define MAP_SIZE 4096
+#define MAP_MASK ( MAP_SIZE - 1 )
+
// Get value of the register at the given address
static u16 getmem(u32 addr)
{
@@ -58,9 +58,9 @@
}
regaddr = map + (addr & MAP_MASK);
- val = *(u32*) regaddr;
+ val = *(u32*) regaddr;
munmap(0,MAP_SIZE);
- printf("read 0x%04x at 0x%08x\n", val, addr);
+ printf("read 0x%04x at 0x%08x\n", val, addr);
return val;
}
@@ -68,7 +68,7 @@
// Modify register value at given address
static void putmem(u32 addr, u32 val)
{
- void *map=0;
+ void *map=0;
void *regaddr=0;
static int fd = -1;
@@ -92,32 +92,32 @@
}
regaddr = map + (addr & MAP_MASK);
- // printf("Mapped addr: 0x%04x\n", regaddr);
+ // printf("Mapped addr: 0x%04x\n", regaddr);
*(u32*) regaddr = val;
munmap(0,MAP_SIZE);
}
-
-u16 toInt(char * string)
-{
- char temp;
- u16 result = 0;
-
- while( *string )
- {
- temp = *string;
- if( (temp>='0') && (temp<='9') )
- temp = temp - '0';
- else if( (temp>='a') && (temp<='f') )
- temp = temp -'a' + 10;
-
- result = (result<<4) + temp;
- string++;
- }
- return result;
-}
-
-
+
+u16 toInt(char * string)
+{
+ char temp;
+ u16 result = 0;
+
+ while( *string )
+ {
+ temp = *string;
+ if( (temp>='0') && (temp<='9') )
+ temp = temp - '0';
+ else if( (temp>='a') && (temp<='f') )
+ temp = temp -'a' + 10;
+
+ result = (result<<4) + temp;
+ string++;
+ }
+ return result;
+}
+
+
/////////////////////////////////////////////////////////////////////////////////////
// MAIN
//
@@ -125,22 +125,22 @@
{
// Dump the content of the provided register
if (argc == 2)
- {
+ {
getmem(toInt(argv[1])+FPGA_BASE_ADDR);
return 0;
}
// Put value to given register
if (argc == 3)
- {
+ {
putmem( toInt(argv[1])+FPGA_BASE_ADDR, toInt(argv[2]) );
return 0;
}
-
+
// In all other cases, print Usage
- printf("Usage: fpgareg addr [value]\n"
- "addr: address in fpga (max 2ffe)\n"
- "value: value to write (16bit max ffff). Option \n");
+ printf("Usage: fpgareg addr [value]\n"
+ "addr: address in fpga (max 2ffe)\n"
+ "value: value to write (16bit max ffff). Option \n");
return 1;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|