memory-mapping

Is accessing registers through predefined static addresses undefined behaviour in C++?

不羁岁月 提交于 2019-12-13 14:29:36
问题 I'm compiling a C++ program to run in a freestanding environment and the CPU I'm running on defines a 32-bit peripheral register to be available ( edit: memory-mapped ) at PERIPH_ADDRESS (aligned correctly, and not overlapping with any other C++ object, stack etc.). I compile the following code with PERIPH_ADDRESS predefined, later link it with a full program and run it. #include <cstdint> struct Peripheral { const volatile uint32_t REG; }; static Peripheral* const p = reinterpret_cast

Retrieving the memory map of its own process in QNX

青春壹個敷衍的年華 提交于 2019-12-13 05:21:59
问题 In Linux if we look at the /proc/self/maps: 00400000-004ef000 r-xp 00000000 08:01 12845058 /bin/bash 006ef000-006f0000 r--p 000ef000 08:01 12845058 /bin/bash 006f0000-006f9000 rw-p 000f0000 08:01 12845058 /bin/bash 006f9000-006ff000 rw-p 00000000 00:00 0 00d5a000-010a2000 rw-p 00000000 00:00 0 [heap] 7f6fe582a000-7f6fe5835000 r-xp 00000000 08:01 1048595 /lib/x86_64-linux-gnu/libnss_files-2.19.so 7f6fe5835000-7f6fe5a34000 ---p 0000b000 08:01 1048595 /lib/x86_64-linux-gnu/libnss_files-2.19.so

memory-mapping in python using numpy error

爱⌒轻易说出口 提交于 2019-12-11 19:27:11
问题 OUT_DIR = '/media/sf_3dAnalysis/simMatrix/' SIM_FILE = 'similarity.npy' data = np.lib.format.open_memmap(OUT_DIR+SIM_FILE, mode='w+', dtype='float32', shape=(len(filelist),len(filelist))) del data So I get the following error message when running this code... mmap.error: [Errno 22] Invalid argument . I really don't understand what I am doing wrong. I am running this in a Linux VM if that's relevant. Also, what's particularly curious is the matrix is created after the code runs, but it still

vxWorks 6.8 mapping physical to virtual memory

馋奶兔 提交于 2019-12-11 18:46:42
问题 This is my first question here :). I been trying for while now to map physical memory to virtual memory in vxWorks 6.8 with no success, I'm trying to use "vmMap" function but somehow it keeps return with: errno = 0x30065 S_taskLib_NAME_NOT_FOUND. my code is: int page_size=0; PHYS_ADDR GPIO_BASE_VIRTUAL_ADDR = 0x40E00000; VIRT_ADDR VIRTUAL_ADDR=0; page_size =vmPageSizeGet(); if((VIRTUAL_ADDR = (VIRT_ADDR)memalign(page_size,page_size*2))==NULL)// allocate 2 pages { printf("error in memalign()

Simple process loader memory mapping

假装没事ソ 提交于 2019-12-10 22:04:47
问题 I'm writing a very simple process loader for Linux. The executables I'm loading are already compiled, and I know where each one expects to be found in memory. The first approach I tried was using mmap() to manually place each code or data section at the correct location, like mmap(addr, size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0) which segfaults unless I remove the MAP_FIXED flag because, it seems, the address of one block conflicts with something already in

why proc/ID/maps has multiple entries for shared libraries

我的梦境 提交于 2019-12-08 03:00:15
问题 I'm looking at proc/ID/maps under embedded Linux, And I've noticed that some shared libraries appear few times at the memory map of a process why is it so ? 40094000-400d9000 r-xp 00000000 b3:09 723 /system/lib/libc.so 400d9000-400da000 ---p 00000000 00:00 0 400da000-400dc000 r-xp 00045000 b3:09 723 /system/lib/libc.so 400dc000-400de000 rwxp 00047000 b3:09 723 /system/lib/libc.so 400de000-400e9000 rwxp 00000000 00:00 0 400e9000-400ed000 r-xp 00000000 b3:09 770 /system/lib/libgccdemangle.so

PCI-e memory space access with mmap

跟風遠走 提交于 2019-12-07 04:50:57
问题 I'm using PCI-e port on Freescale MPC8308 processor (which is based on PowerPC architecture) and I have some problems when trying to use it. The endpoint PCI-e device has memory space equal to 256 MB. I can easily read and write configuration space of the endpoint device by using "pciutils" package. After writing correct values in configuration registers and getting the permission to access the memory space; I tried to access memory space by using "mmap()" function in C and used the file

Access SQLite db from MMF

空扰寡人 提交于 2019-12-07 04:47:03
问题 I'm using System.Data.SQLite lib to access my SQLite database. I want to load the db file to memory and use MMF (Memory Mapped Files) to access the database. Is this possible using the default SQLite library? edit: Alternatives on how I can have an in-memory database are welcome. 回答1: no... You can: create an in-memory DB instance (specify in connection string Data Source=:memory: ) and load the contents from the DB file into that instance... when you change contents of the in-memory instance

Convert a pointer to an array in C++

倖福魔咒の 提交于 2019-12-06 11:01:46
The CreateFileMapping function returns a pointer to a memory mapped file, and I want to treat that memory mapping as an array. Here's what I basically want to do: char Array[] = (char*) CreateFileMapping(...); Except apparently I can't simply wave my arms and declare that a pointer is now an array. Do you guys have any idea how I can do this? I don't want to copy the the values the pointer is pointing to into the array because that will use too much memory with large files. Thanks a bunch, You do not need to. You can index a pointer as if it was an array: char* p = (char*)CreateFileMapping(...

Access SQLite db from MMF

☆樱花仙子☆ 提交于 2019-12-05 12:29:42
I'm using System.Data.SQLite lib to access my SQLite database. I want to load the db file to memory and use MMF (Memory Mapped Files) to access the database. Is this possible using the default SQLite library? edit: Alternatives on how I can have an in-memory database are welcome. no... You can: create an in-memory DB instance (specify in connection string Data Source=:memory: ) and load the contents from the DB file into that instance... when you change contents of the in-memory instance your DB file won't get updated... you could later on save the in-memory instance content into a DB file...