allocating physically contiguous memory
Matt (481) 28 posts |
I’m struggling to allocate the above using the new PMP dynamic areas – although this would appear to be the correct way for what I want. I just want to be able to allocate a number of large buffers, and be able to temporarily map them in (which I’m finding hard). I was wondering if anyone had visited this and maybe share some code or help. I’m targeting an iMX6 5.23. Thanks for reading, |
Jeffrey Lee (213) 6046 posts |
The basic procedure you’ll want to follow is:
You might find this post useful, since that attempts to explain the many different ID/indexing schemes and how they relate to logical and physical addresses. |
Matt (481) 28 posts |
Thanyou, that has made things much clearer. However one thing I haven’t quite understood is deciding/calculating the value of the DA page number’s indicating the logical address when I map them in. Do I calculate, choose or obtain the logical address’s? Thanks, |
Matt (481) 28 posts |
Ah, sorry – I think I see now – the logical base is automatic, and you only have to decide index – correct? Many thanks, |
Jeffrey Lee (213) 6046 posts |
Yes – the kernel picks the base logical address of your dynamic area, you just control the index/offset from that base (up to the max logical size specified when the DA was created) |
Matt (481) 28 posts |
Hi, I’m struggling with this. Reason 21 fails for me – even if I set the page numbers to -2. I’m assuming the problem is related to my handler which doesnt seem to get called. If I can get my handler to be called properly ( I’m using the cmhg generic-veneers wrapper currently – I will try something else ) is there something I’m missing? Dump out: swi(&66,0, -1, 0, -1, (1<<8)+(1<<20), 64*1024*1024, (int)dynamic_area, -1, “IPU Surface Area”, 1024) → 0, 281, 0, 1201696768 ( 16/16 not processed ) Thanks, |
Jeffrey Lee (213) 6046 posts |
I can’t see anything obviously wrong with the way you’re setting up the DA or the page list. However this makes me think that you might be passing in a pointer to a pointer?
In C an array is generally handled exactly the same as a pointer (the main difference being that the compiler will try and do bounds checking for an array). Try replacing it with just “(int) mem” and see how you get on. If it’s still not working, it would be good to check what the error returned by OS_ReadDynamicArea is (the V flag will be set and R0 will be a pointer to an error block)
A generic-veneer wrapper should be fine, and I wouldn’t expect your handler to get called in this situation. For basic PMP DAs, the handler is only called when someone uses OS_ChangeDynamicArea to adjust the size of your DA – e.g. this could happen as the result of someone dragging the bar in the task manager (if you don’t set bit 7 of the DA flags to prevent this). If your DA is only used internally by your code, then you could implement your handler so that it always returns an error, preventing any resizing by OS_ChangeDynamicArea. |
Matt (481) 28 posts |
Eeek – well spotted – I’d looked over that so many times… And that’s great that I dont have to worry about the handler. It’s interesting that the C language allows referencing a simple array – what is the result? Another pointer would need to be allocated just to make it work !? You could say an array points to itself. Note that &func returns the same as func when used as a pointer – but with arrays I imagine its undefined.. Anyway many thanks, |