Hello community,
here is the log from the commit of package devmem2 for openSUSE:Factory checked in at 2017-05-09 18:02:57
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/devmem2 (Old)
and /work/SRC/openSUSE:Factory/.devmem2.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "devmem2"
Tue May 9 18:02:57 2017 rev:7 rq:493002 version:1.0
Changes:
--------
--- /work/SRC/openSUSE:Factory/devmem2/devmem2.changes 2015-11-16 18:51:33.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.devmem2.new/devmem2.changes 2017-05-09 18:03:02.025877745 +0200
@@ -1,0 +2,7 @@
+Fri May 5 11:19:38 UTC 2017 - guillaume@opensuse.org
+
+- Add fix_usage_on_64_bits.patch to fix boo#1032032
+ It updates the current devmem2.c file by the one provided by
+ Russel King to fix usage on 64 bits systems.
+
+-------------------------------------------------------------------
New:
----
fix_usage_on_64_bits.patch
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ devmem2.spec ++++++
--- /var/tmp/diff_new_pack.7phvM6/_old 2017-05-09 18:03:03.145719499 +0200
+++ /var/tmp/diff_new_pack.7phvM6/_new 2017-05-09 18:03:03.149718934 +0200
@@ -1,7 +1,7 @@
#
# spec file for package devmem2
#
-# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2012 Guillaume GARDET
#
# All modifications and additions to the file contributed by third parties
@@ -25,6 +25,7 @@
Group: Hardware/Other
Url: http://free-electrons.com/pub/mirror/devmem2.c
Source: devmem2-1.0.tar.gz
+Patch1: fix_usage_on_64_bits.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
@@ -35,6 +36,7 @@
%prep
%setup -q
+%patch1
%build
cc %{optflags} devmem2.c -o devmem2
++++++ fix_usage_on_64_bits.patch ++++++
--- devmem2.c.orig 2004-09-09 21:19:29.000000000 +0200
+++ devmem2.c 2017-05-05 13:17:10.682241495 +0200
@@ -1,7 +1,7 @@
/*
* devmem2.c: Simple program to read/write from/to any location in memory.
*
- * Copyright (C) 2000, Jan-Derk Bakker (J.D.Bakker@its.tudelft.nl)
+ * Copyright (C) 2000, Jan-Derk Bakker (jdb@lartmaker.nl)
*
*
* This software has been developed for the LART computing board
@@ -10,16 +10,6 @@
* and Ubiquitous Communications (http://www.ubicom.tudelft.nl/)
* projects.
*
- * The author can be reached at:
- *
- * Jan-Derk Bakker
- * Information and Communication Theory Group
- * Faculty of Information Technology and Systems
- * Delft University of Technology
- * P.O. Box 5031
- * 2600 GA Delft
- * The Netherlands
- *
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -46,6 +36,7 @@
#include
#include
#include
+#include
#include
#include
@@ -55,77 +46,99 @@
#define MAP_SIZE 4096UL
#define MAP_MASK (MAP_SIZE - 1)
-int main(int argc, char **argv) {
- int fd;
- void *map_base, *virt_addr;
- unsigned long read_result, writeval;
+int main(int argc, char **argv)
+{
+ uint64_t read_result, writeval;
+ unsigned int access_size = sizeof(uint32_t);
+ void *map_base, *virt_addr;
off_t target;
+ int fd;
int access_type = 'w';
if(argc < 2) {
fprintf(stderr, "\nUsage:\t%s { address } [ type [ data ] ]\n"
"\taddress : memory address to act upon\n"
- "\ttype : access operation type : [b]yte, [h]alfword, [w]ord\n"
+ "\ttype : access operation type:\n"
+ "\t [b]yte (8bit), [h]alfword (16bit), [w]ord (32bit), [l]ong (64bit)\n"
"\tdata : data to be written\n\n",
argv[0]);
exit(1);
}
- target = strtoul(argv[1], 0, 0);
+ target = strtoul(argv[1], 0, 0);
if(argc > 2)
access_type = tolower(argv[2][0]);
+ fd = open("/dev/mem", O_RDWR | O_SYNC);
+ if (fd == -1)
+ FATAL;
+
+ /* Map one page */
+ map_base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED,
+ fd, target & ~MAP_MASK);
+ if (map_base == (void *)-1)
+ FATAL;
+
+ close(fd);
+
+ virt_addr = map_base + (target & MAP_MASK);
+ switch (access_type) {
+ case 'b':
+ read_result = *(uint8_t *)virt_addr;
+ access_size = sizeof(uint8_t);
+ break;
+ case 'h':
+ read_result = *(uint16_t *)virt_addr;
+ access_size = sizeof(uint16_t);
+ break;
+ case 'w':
+ read_result = *(uint32_t *)virt_addr;
+ access_size = sizeof(uint32_t);
+ break;
+ case 'l':
+ read_result = *(uint64_t *)virt_addr;
+ access_size = sizeof(uint64_t);
+ break;
+ default:
+ fprintf(stderr, "Illegal data type '%c'.\n", access_type);
+ exit(2);
+ }
+
+ printf("Value at address 0x%08lx: 0x%0*llx\n",
+ (unsigned long)target, access_size * 2,
+ (unsigned long long)read_result);
+ fflush(stdout);
- if((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) FATAL;
- printf("/dev/mem opened.\n");
- fflush(stdout);
-
- /* Map one page */
- map_base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, target & ~MAP_MASK);
- if(map_base == (void *) -1) FATAL;
- printf("Memory mapped at address %p.\n", map_base);
- fflush(stdout);
-
- virt_addr = map_base + (target & MAP_MASK);
- switch(access_type) {
+ if(argc > 3) {
+ writeval = strtoull(argv[3], 0, 0);
+ switch(access_type) {
case 'b':
- read_result = *((unsigned char *) virt_addr);
+ *(volatile uint8_t *)virt_addr = writeval;
+ read_result = *(volatile uint8_t *)virt_addr;
break;
case 'h':
- read_result = *((unsigned short *) virt_addr);
+ *(volatile uint16_t *) virt_addr = writeval;
+ read_result = *(volatile uint16_t *)virt_addr;
break;
case 'w':
- read_result = *((unsigned long *) virt_addr);
+ *(volatile uint32_t *)virt_addr = writeval;
+ read_result = *(volatile uint32_t *)virt_addr;
+ break;
+ case 'l':
+ *(volatile uint64_t *)virt_addr = writeval;
+ read_result = *(volatile uint64_t *)virt_addr;
break;
- default:
- fprintf(stderr, "Illegal data type '%c'.\n", access_type);
- exit(2);
- }
- printf("Value at address 0x%X (%p): 0x%X\n", target, virt_addr, read_result);
- fflush(stdout);
-
- if(argc > 3) {
- writeval = strtoul(argv[3], 0, 0);
- switch(access_type) {
- case 'b':
- *((unsigned char *) virt_addr) = writeval;
- read_result = *((unsigned char *) virt_addr);
- break;
- case 'h':
- *((unsigned short *) virt_addr) = writeval;
- read_result = *((unsigned short *) virt_addr);
- break;
- case 'w':
- *((unsigned long *) virt_addr) = writeval;
- read_result = *((unsigned long *) virt_addr);
- break;
}
- printf("Written 0x%X; readback 0x%X\n", writeval, read_result);
+ printf("Written 0x%0*llx; readback 0x%0*llx\n",
+ access_size * 2,
+ (unsigned long long)writeval,
+ access_size * 2,
+ (unsigned long long)read_result);
fflush(stdout);
}
if(munmap(map_base, MAP_SIZE) == -1) FATAL;
- close(fd);
- return 0;
+
+ return 0;
}