From 342ebce798fe98ede64939a49bbc3770d8214649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 8 May 2016 22:59:02 +0200 Subject: Imported Upstream version 1.8.17 --- src/plugins/imb/imbapi.c | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) (limited to 'src/plugins/imb/imbapi.c') diff --git a/src/plugins/imb/imbapi.c b/src/plugins/imb/imbapi.c index 899c47a..84eec2e 100644 --- a/src/plugins/imb/imbapi.c +++ b/src/plugins/imb/imbapi.c @@ -97,7 +97,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #endif #include "imbapi.h" -#include +#include #ifdef SCO_UW #define NO_MACRO_ARGS 1 @@ -105,9 +105,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define IMB_DEVICE "/dev/instru/mismic" #else #define IMB_DEVICE "/dev/imb" -#ifndef PAGESIZE -# define PAGESIZE EXEC_PAGESIZE #endif + +#if !defined(PAGESIZE) && defined(PAGE_SIZE) +# define PAGESIZE PAGE_SIZE +#endif + +#if !defined(_SC_PAGESIZE) && defined(_SC_PAGE_SIZE) +# define _SC_PAGESIZE _SC_PAGE_SIZE #endif /*Just to make the DEBUG code cleaner.*/ @@ -545,7 +550,7 @@ SendTimedI2cRequest ( if( status != TRUE ) { DWORD error; error = GetLastError(); - return ACCESN_ERROR; + return error; } if( respLength == 0 ) { return ACCESN_ERROR; @@ -1134,7 +1139,7 @@ SendTimedImbpRequest ( if( status != TRUE ) { DWORD error; error = GetLastError(); - return ACCESN_ERROR; + return error; } if( respLength == 0 ) { return ACCESN_ERROR; @@ -1211,7 +1216,7 @@ SendAsyncImbpRequest ( if( status != TRUE ) { DWORD error; error = GetLastError(); - return ACCESN_ERROR; + return error; } if( respLength != 2 ) { return ACCESN_ERROR; @@ -1985,6 +1990,16 @@ MapPhysicalMemory(int startAddress,int addressLength, int *virtualAddress ) off_t startpAddress = (off_t)startAddress; unsigned int diff; char *startvAddress; +#if defined(PAGESIZE) + long int pagesize = PAGESIZE; +#elif defined(_SC_PAGESIZE) + long int pagesize = sysconf(_SC_PAGESIZE); + if (pagesize < 1) { + perror("Invalid pagesize"); + } +#else +# error PAGESIZE unsupported +#endif if ((startAddress == 0) || (addressLength <= 0)) return ACCESN_ERROR; @@ -1999,7 +2014,7 @@ MapPhysicalMemory(int startAddress,int addressLength, int *virtualAddress ) } /* aliging the offset to a page boundary and adjusting the length */ - diff = (int)startpAddress % PAGESIZE; + diff = (int)startpAddress % pagesize; startpAddress -= diff; length += diff; @@ -2043,9 +2058,19 @@ ACCESN_STATUS UnmapPhysicalMemory( int virtualAddress, int Length ) { unsigned int diff = 0; +#if defined(PAGESIZE) + long int pagesize = PAGESIZE; +#elif defined(_SC_PAGESIZE) + long int pagesize = sysconf(_SC_PAGESIZE); + if (pagesize < 1) { + perror("Invalid pagesize"); + } +#else +# error PAGESIZE unsupported +#endif /* page align the virtual address and adjust length accordingly */ - diff = ((unsigned int) virtualAddress) % PAGESIZE; + diff = ((unsigned int) virtualAddress) % pagesize; virtualAddress -= diff; Length += diff; #ifndef NO_MACRO_ARGS -- cgit v1.2.3