-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"mem" feature doesn't affect analogous AEABI symbols #253
Comments
I suspect what you are trying to do maybe undefined behaviour. For anything but normal memory you will need volatile writes. How exactly is memcpy being called from your code? |
I defined a |
Yeah I think that's probably UB. You will have to write your own memcpy like function that uses volatile stores and explicitly call it to do the copy. |
I have to profess ignorance here. I don't understand why supplying a Meanwhile your suggestion is to do things in a completely un-Rustlike manner - check on each compile for any time the compiler might sneak a |
Replacing
Yes that is one thing volatile does but the other thing it does it ensures the compiler generates a load/store of the width you specify (if possible). e.g. if you do a volatile store of |
@ketsuban could you provide more details about the complete operation you want to do? It sounds like you are dealing with MMIO and that will require volatile operation to prevent the compiler from reordering memory operations and from optimizing them away. I haven't done graphical stuff before but I imagine that the operation you are doing is actually a two-step operation:
Both of these operations need to be volatile or the compile is free to reorder or eliminate them. You also mention a |
It sounds flippant, but I really am just copying some data into memory which happens to have a particular bus characteristic. There are some memory-mapped IO registers, but they're in a different part of the address space, and I already have a system in place for those which uses volatile writes. There's no two-step operation; the screen is always drawing regardless of what the processor does (unless disabled by a bit in the display control register). There's a number of background layers, each of which take tilemap data from part of VRAM based on the value of a control register (one for each background layer) and use tiles from the rest of VRAM based on the values in the tilemap. Tile data is 4bpp (or 8bpp, but there's only 512 bytes of palette RAM for backgrounds, and sixteen palettes of sixteen is more flexible), so my |
@ketsuban on x86_64, we deal with something similar, the VGA memory buffer. This isn't MMIO per-se, but still needs volatile writes. For your example, you could make your As a general rule, if the memory isn't normal RAM, you must use @japaric I think this can be closed, as it's not a problem |
On the platform I'm targeting, byte writes to some parts of memory (palette data at 0x5000000, tile data at 0x6000000 and OAM at 0x7000000) are invalid - writing a byte will copy it over both bytes of the halfword. As such I need to use custom implementations of
memcpy
(etc.) which operate on halfword or word data so as not to silently corrupt data copied to these sections of memory.I disabled the
mem
feature, but that only coversmemcpy
(etc.) themselves;__aeabi_memcpy
(etc.) still exist, and since they callmemcpy
directly whether or not the names are mangled makes no difference - I end up with a VRAM-unsafememcpy
in my program.The text was updated successfully, but these errors were encountered: