Re: HalAllocateCommonBuffer and virtual addresses

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



This memory is ONLY shared if the size you allocate is greater than 2MB (far
greater than the required size of the frame buffer). That is because
virtual memory allocations of size greater than 2MB come from shared memory
space instead of the local process space.

That little tidbit is not obvious from the code snippet or comments.

--
Dean Ramsier - eMVP
BSQUARE Corporation


"Aigor" <Aigor@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:48E00D07-348B-4395-8FD2-4F49B14E1B93@xxxxxxxxxxxxxxxx
Maybe this will help you.
This is code from pxa27x_lcd2 driver:

g_DisplayBaseVirtual = (DWORD)HalAllocateCommonBuffer(&Adapter,
DISPLAY_BUFFER_SIZE, &PhysAddr, FALSE);
g_DisplayBasePhysical = PhysAddr.LowPart;

if (!g_DisplayBaseVirtual)
{
Cleanup();
return FALSE;
}

// map shared virtual memory, and set the virtual ptr to that address
rather than local process
// address; from this point on, all processes (including DDraw apps)
will be able to access the
// display region using g_DisplayBaseVirtual
g_DisplayBaseVirtual = (DWORD)VirtualAlloc(NULL, DISPLAY_BUFFER_SIZE,
MEM_RESERVE, PAGE_NOACCESS);

if(!VirtualCopy((LPVOID)g_DisplayBaseVirtual, (LPVOID)((unsigned
long)g_DisplayBasePhysical >> 8), DISPLAY_BUFFER_SIZE, (PAGE_READWRITE |
PAGE_NOCACHE | PAGE_PHYSICAL)))
{
RETAILMSG(1,(TEXT("CRITICAL ERROR: display SDRAM region allocation
failed")));
}


bye.

"marco" wrote:

what I need is to use that buffer also from another process
is it possible ?
what do I have to map the same buffer into the virtual range of the
second
process ?

that is , I have the lcd driver (that is in process of gwes.exe) that
calls
the HalAllocateCommonBuffer for the frame buffer of the lcd, while I
would
like to read/write the frame buffer from an exe program .

what address value do I have to use with VirtualCopy in this second
process ?
maybe do I need the virtual uncached address ?
how can I translate the PhysAddr.LowPart value to a virtual uncached
addree ?

Marco




.



Relevant Pages

  • Re: HalAllocateCommonBuffer and virtual addresses
    ... You should be able to access the memory directly through that ... "Dean Ramsier" wrote: ... the HalAllocateCommonBuffer for the frame buffer of the lcd, ... what address value do I have to use with VirtualCopy in this second ...
    (microsoft.public.windowsce.platbuilder)
  • Re: HalAllocateCommonBuffer and virtual addresses
    ... how can I view that memory from another one process? ... greater than the required size of the frame buffer). ... the HalAllocateCommonBuffer for the frame buffer of the lcd, ... what address value do I have to use with VirtualCopy in this second ...
    (microsoft.public.windowsce.platbuilder)
  • Re: MmMapMemIoSpace & CE4.2 revisited
    ... I have 64MB of video memory I needed to access in the ... I ran into some trouble because VirtualCopy can only handle ... 1MB where our graphics registers were temporarily located. ... have trouble trying to allocate 18MB or 24MB after the OEMAddressTable ...
    (microsoft.public.windowsce.platbuilder)
  • Re: HalAllocateCommonBuffer and virtual addresses
    ... to ensure that it is in a shared memory space. ... like to read/write the frame buffer from an exe program. ... what address value do I have to use with VirtualCopy in this second ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Fill Frame Buffer in Video Driver Initialization
    ... This doesn't make sense, there is only 512Mb of memory, giving an address limit of 0x20000000. ... It is interesting to see that the flat physical address is given by the BIOS and passed to the BootArgs: this means that you should be able to use the VGA Flat display driver just as it. ... However, in the MSDN documentation for VirtualAlloc, it says that memory allocated will be initialized to zero. ... 0xEE000000 is not a physical address, unless you have a dedicated frame buffer mapped at physical 0x6E000000, or it is a window in PCI space. ...
    (microsoft.public.windowsce.platbuilder)