memory-mapping

PCI-e memory space access with mmap

穿精又带淫゛_ 提交于 2019-12-05 08:50:34
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 descriptor located at : "/sys/devices/pci0000:00/0000:00:00.0/resource0" which was exactly 256 MB (equal to

How would I design and implement a non-blocking memory mapping module for node.js

余生颓废 提交于 2019-12-05 05:33:33
There exists the mmap module for node.js: https://github.com/bnoordhuis/node-mmap/ As the author Ben Noordhuis notes, accesing mapped memory can block, which is why he does not recommend it anymore and discontinued it. So I wonder how would I design a non-blocking memory mapping module for node.js? Threading, Fibers, ? Obviously this nearby raises the question if threading in node.js would just happen elsewhere instead of the request handler. josh3736 When talking about implementing some native facility in a non-blocking fashion, the first place to look is libuv . It is how node's core modules

How to memory map (mmap) a linux block device (e.g. /dev/sdb) in Java?

依然范特西╮ 提交于 2019-12-04 05:13:10
I can read/write a linux block device with Java using java.nio . The following code works: Path fp = FileSystems.getDefault().getPath("/dev", "sdb"); FileChannel fc = null; try { fc = FileChannel.open(fp, EnumSet.of(StandardOpenOption.READ, StandardOpenOption.WRITE)); } catch (Exception e) { System.out.println("Error opening file: " + e.getMessage()); } ByteBuffer buf = ByteBuffer.allocate(50); try { if(fc != null) fc.write(buf); } catch (Exception e) { System.out.println("Error writing to file: " + e.getMessage()); } However, memory mapping does not work. The following code fails :

segments within a executable C program

瘦欲@ 提交于 2019-12-03 19:13:24
问题 I was reading about sections and segments. Seems you could list the mapping between sections and segments as below. $ readelf -l test Elf file type is EXEC (Executable file) Entry point 0x8048330 There are 9 program headers, starting at offset 52 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align PHDR 0x000034 0x08048034 0x08048034 0x00120 0x00120 R E 0x4 INTERP 0x000154 0x08048154 0x08048154 0x00013 0x00013 R 0x1 [Requesting program interpreter: /lib/ld-linux.so.2] LOAD

What real platforms map hardware ports to memory addresses?

喜欢而已 提交于 2019-12-02 21:09:50
I sometimes see statements that on some platforms the following C or C++ code: int* ptr; *ptr = 0; can result in writing to a hardware input-output port if ptr happens to store the address to which that port is mapped. Usually they are called "embedded platforms". What are real examples of such platforms? Most systems in my experience use memory-mapped I/O. The x86 platform has a separate, non-memory-mapped I/O address space (that uses the in / out family of processor op-codes), but the PC architecture also extensively uses the standard memory address space for device I/O, which has a larger

Further question with memory mapped interface

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 08:01:41
问题 I still have some issues with my c code that deals with an memory mapped device. At the moment I declare the address space for the registers I write as volatile pointer and I write data to them as shown below: volatile unsigned int *wr_register = (int *) 0x40000000; volatile unsigned int *c_register = (int *) 0x40000100; ... main{ *wr_register = 0x01234567; *c_register = 0x01234567; *(c_register+1) = 0x89abcdef; } This works more or less fine. However, I would like to have specific read and

Why in mmap PROT_READ equals PROT_EXEC

萝らか妹 提交于 2019-12-01 06:57:27
问题 I tried to allocate some memory pages with read only access using mmap function. I printed /proc/self/maps to check if the memory protection was working. It showed like this even though the protection argument of mmap was PROT_READ 7fec0c585000-7fec0c785000 r-xp 00000000 00:00 0 This means that when I ask the kernel to allocate some read only memory pages it mark them as executable too. I did some other test and I realized that when I ask for a write only pages, PROT_WRITE without PROT_READ ,

munmap() failure with ENOMEM with private anonymous mapping

岁酱吖の 提交于 2019-11-30 17:15:53
I have recently discovered that Linux does not guarantee that memory allocated with mmap can be freed with munmap if this leads to situation when number of VMA (Virtual Memory Area) structures exceed vm.max_map_count . Manpage states this (almost) clearly: ENOMEM The process's maximum number of mappings would have been exceeded. This error can also occur for munmap(), when unmapping a region in the middle of an existing mapping, since this results in two smaller mappings on either side of the region being unmapped. The problem is that Linux kernel always tries to merge VMA structures if

How to store data in and get data out of memory mapping files using CopyMemory in VBA?

瘦欲@ 提交于 2019-11-30 07:25:23
I am trying to build a distributive computing system that uses memory mapping files to coordinate work among several networked PCs all via VBA. Put another way, I want to get a group of networked computers to do work at the same time in a coordinated way on a single project that can be easily divided up into different parts. One PC takes 13+ hours to complete the project, which is not practical for my client. I want to store information in the memory mapping files that will help the PCs work on the project in a coordinated way (i.e. no duplication of work, avoid race issues, etc). I've tried

How to store data in and get data out of memory mapping files using CopyMemory in VBA?

让人想犯罪 __ 提交于 2019-11-29 10:28:34
问题 I am trying to build a distributive computing system that uses memory mapping files to coordinate work among several networked PCs all via VBA. Put another way, I want to get a group of networked computers to do work at the same time in a coordinated way on a single project that can be easily divided up into different parts. One PC takes 13+ hours to complete the project, which is not practical for my client. I want to store information in the memory mapping files that will help the PCs work