PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Using physical memory

Anybody has any idea how to allocate memory, lock it in physical memory & get that physical memory address?
Read this:

http://columns.pocketnow.com/index.cgi? ... ategory=95

and if you have any problems post. I've got the whole memory mapping thing pretty much covered on the StrongARM :) A couple of my functions are adapted from the code there (where adapted="tweaked").

If only I had interrupts covered (or more free time :'() I'd have a proper page-flipping system for the iPAQ.

Cheers,

Ref.
I know this link. It unfortunately doesn't help me with what I want to do... Unless you can tell me where the RAM is mapped in the physical space =)

I am after page flipping and I need to allocate a second buffer and get it's physical address. I also need to "lock" it...

Do you have this memory map in electronic format? I'd love to get my hands on it: ttremblay-at-relic.com.

Thanks!
I'm still not sure entirely what you want?

If you just want the physical address of the Windows frame buffer, pull it out of the LCD DMA base register.

If you want a block of physical memory:


  • VirtualAlloc a logical block of memory

  • LockPages the number of pages in your block

  • Find the page number of the first page and shift it left to give you your physical address.


The only issue is that the pages it gives you won't necessarily be physically contiguous... so giving them to the DMA will go *splat*.

If somebody can find or think of a way of latching a screen-update to the VSYNC then I'll finish my hardware double-buffering code and release it (I have a working hardware multi-buffer system, but no proper way of flipping between them - you can only flip just after a VSYNC).

I'm sure there's a nice way of doing it, but I can't find it. If only I had more time, I'd play with so many things. :'(

Cheers,

Ref.
The part I don't know how to do is the "LockPages" and "Find the page number of the first page"...

I am not convinced you need to flip on an interrupt for double buffering. Of course it would be nice, but you could also poll on the DCAR1 register (DMA1 Current Address Register).

If DCAR1 is in buffer 1 and you want to flip to buffer 2, then no problem, just update DBAR1. But before you are allowed to draw anything in buffer 1, you must poll DCAR1 until it is inside buffer 2.

The efficiency of this system would be (almost) the same thing as an interrupt-driven switch. You have to wait anyways.

Then there is tripple buffering...
Ok, got LockPages() in the WinCE doc.

Now how do I get the physical address of my memory buffer allocated with VirtualAlloc?

Thanks for your help!
Damn it!

Gotta learn to RTFM before asking questions... It's all there.

Did you figure out a way to make sure the memory pages are continuous in physical memory?
Yeah, I'm aware polling could be done on the DCAR1, but the problem is that I'm not sure how large the timeframe is for the update. I guess you could make it wait until the address was greater than the first line of the current buffer and then stuff the new address in... Hrmmm.

The efficiency of this system would be (almost) the same thing as an interrupt-driven switch. You have to wait anyways.


The point of the interrupt is that it's called when the end of the frame is reached and sticks the new address into the DBAR. No polling goes on in the interrupt handler - it's triggered by the StrongARM itself - the interrupt handler will be just storing the address into the DBAR and exiting. (The efficiency won't be as good as an interrupt handler by far).


The system I wrote provides "multi-buffering". I think I capped the number of "extra" frames at 4 though... :)

I'll dig it out and have a play tonight to see if I can work out where I'd got to. :)

Thanks for the ideas.
Did you figure out a way to make sure the memory pages are continuous in physical memory?


Uhuh, but the routine is really, really ugly.


Did you figure out a way to make sure the memory pages are continuous in physical memory?



Uhuh, but the routine is really, really ugly.


Well what is the general idea? Can I see that routine?
Can I see that routine?


Part of me wants to post it, and part of me feels that as I spent so much effort (and it took effort) writing it, I shouldn't just give it away... it's late, I'm tired, let me sleep on it and I'll let you know tomorrow. I presume it's destined for PocketFrog?

Cheers,

Ref.