Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
BroadcastCommunity.qnx.com will be offline from May 31 6:00pm until June 2 12:00AM for upcoming system upgrades. For more information please go to https://community.qnx.com/sf/discussion/do/listPosts/projects.bazaar/discussion.bazaar.topc28418
Forum Topic - Allocating physically contiguous memory below/above/across 4 GB boundary: (9 Items)
   
Allocating physically contiguous memory below/above/across 4 GB boundary  
Hi All

x86 archi, I am playing around with some memory blocks being excahnged between processes (and hardware DMA-capable).

I always used mmap64() with (MAP_PHYS | MAP_ANON | MAP_NOINIT) flags for asking some physically contiguous memory, but 
now I'm running on a machine with more than 4 GB of RAM, and I want to exploit all the available memory, launching 
processes with "on -P".

Is there a way to control mmap64() for forcing allocation below 4GB? Processes where 32-bit DMA hardware is managed need
 it.
And conversely,  it there a way for leaving the kernel free to look for available phys memory also above (or crossing) 4
 GB ?

Thanks in advance.
Davide

Re: Allocating physically contiguous memory below/above/across 4 GB boundary  
You will first need to update your boot image by adding option -x to
startup-bios in the build file to enable extended addressing.
Re: Allocating physically contiguous memory below/above/across 4 GB boundary  
Sure, I know...

I am able to use the memory over 4 GB for "normal" processes, but I am wondering how to manage the 32-bits addressing 
issue when playing with physically contiguous blocks.

Davide
Re: Allocating physically contiguous memory below/above/across 4 GB boundary  
use function call like this:
posix_typed_mem_open("sysram&below4G", ...)
Re: Allocating physically contiguous memory below/above/across 4 GB boundary  
Thanks Jerry and all, your answers are really useful.

A last curiosity: what about the SPAWN_PADDR64_SAFE flag (on -P) ?

A call to mmap64(MAP_PHYS|MAP_ANON) or posix_typed_mem_open("sysram") from a process flagged SPAWN_PADDR64_SAFE will *
always* return contiguous RAM below 4 GB ?

Davide
RE: Allocating physically contiguous memory below/above/across 4 GB boundary  
No, it is on the opposite side. If a process is flagged
SPAWN_PADDR64_SAFE, the kernel always try to allocate memory beyond 4G
first. Because if the process has SPAWN_PADDR64_SAFE flags, the kernel
assumes the process can handle physical memory beyound 4G.

Jerry

-----Original Message-----
From: Davide Ancri [mailto:community-noreply@qnx.com] 
Sent: December 28, 2010 4:09 AM
To: ostech-core_os
Subject: Re: Allocating physically contiguous memory below/above/across
4 GB boundary

Thanks Jerry and all, your answers are really useful.

A last curiosity: what about the SPAWN_PADDR64_SAFE flag (on -P) ?

A call to mmap64(MAP_PHYS|MAP_ANON) or posix_typed_mem_open("sysram")
from a process flagged SPAWN_PADDR64_SAFE will *always* return
contiguous RAM below 4 GB ?

Davide



_______________________________________________

OSTech
http://community.qnx.com/sf/go/post80509
Re: Allocating physically contiguous memory below/above/across 4 GB boundary  
Have you considered using the MAP_BELOW flag?
Re: Allocating physically contiguous memory below/above/across 4 GB boundary  
MAP_BELOW is not for physical memory, it is for virtual memory. It is used to map the stack address.
Re: Allocating physically contiguous memory below/above/across 4 GB boundary  
Yes you are right - and using the typed memory route which enforces the below4G requirement makes this a future-proofed 
solution - before today I did not know this.

Thanks!