How can I get physical address memory from logical address memory?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: How can I get physical address memory from logical address memory?

  1. #1
    Join Date
    Mar 2000
    Location
    Aveiro, Portugal
    Posts
    4

    How can I get physical address memory from logical address memory?

    Hi!
    I need to allocate memory and I used malloc, but the problem is that I get only the logical address of memory. How can I get the corresponding physical memory?

    Thanks
    Pedro Fernandes


  2. #2
    igbrus is offline Elite Member Power Poster
    Join Date
    Aug 2000
    Location
    Los Angeles
    Posts
    4,658

    Re: How can I get physical address memory from logical address memory?

    You can't, because it's virtual memory in modern OS. Why you need it at all?


  3. #3
    Join Date
    Mar 2000
    Location
    Aveiro, Portugal
    Posts
    4

    Re: How can I get physical address memory from logical address memory?

    My problem is that I have to configure DMA of the DS3134 (Chateau - Channelized T1 and E1 And Universal HDLC Controller) and it only works with the physical address memory. I can't pass logical addresses to it.


  4. #4
    igbrus is offline Elite Member Power Poster
    Join Date
    Aug 2000
    Location
    Los Angeles
    Posts
    4,658

    Re: How can I get physical address memory from logical address memory?

    You have to be in kernel mode and use corresponding functions. malloc isn't appropriate for you( I suppose, that we are speaking about NT )


  5. #5
    Join Date
    Oct 2000
    Location
    Ireland
    Posts
    32

    Re: How can I get physical address memory from logical address memory?

    If you really want to access physical memory on
    your system, use this method. This code is sure
    to break your program if you do not know 100% how the physical
    circuitry of your computer works.
    If you know the physical address of the memory buffer, you must obtain an address that you can physically access.Windows NT is a virtual memory operating system, requiring us to map the physical address. This is a two-step process


    m_nBufferMemorySize = 4 * 1024 * 1024;
    m_pLAW = (unsigned char *)VirtualAlloc(
    0,
    m_nBufferMemorySize,
    MEM_RESERVE,
    PAGE_NOACCESS);
    VirtualCopy(m_pLAW,
    (LPVOID)(m_nLAWPhysical>>8),
    m_nBufferMemorySize,
    PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL);

    First, reserve space in the virtual address space for the size of the mapped region, in this case 4MB, using VirtualAlloc. This is equivalent to saving a contiguous range of addresses within the 4GB virtual address range. Next, use the function VirtualCopy to set the page table entries to map the physical frame buffer address in m_nLAWPhysical into the reserved address range. The variable m_pLAW can now be used to directly access the frame buffer and memory-mapped registers on the chip. You can now read and write to physical RAM.

    The library that contains the VirtualCopy function is not available on all
    releases of Visual C++. So look around for it.


  6. #6
    Join Date
    Oct 2000
    Posts
    379

    Re: How can I get physical address memory from logical address memory?

    You may consult the Articles in the Win2000 Device Driver Kit:
    Virtual Device Drivers\...\Memory-Mapped IO, and
    Virtual Device Drivers\...\DMA

    clem


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center