+/* idea of this simple AES engine test:
+ * show how the malloc/free pair fails concerning dma access from i/o devices -
+ * we don't use real encryption mode here but just copy the data from source to
+ * destination - this is achieved by setting the ENA flag in AES_CMD to zero. */
+void simple_aes_copy(void)
+{
+ /* first, allocate memory for source and destination */
+ u8* source = memalign(16, 16); // 16 byte aligned, 16 byte length
+ u8* destination = memalign(16, 16); // 16 byte aligned, 16 byte length
+
+ /* fill source with some evil data, and set destination to all the same bytes ('?')
+ * to see quickly see whether the copying has worked or not */
+ memset(source, '\0', 16);
+ strlcpy(source, "please copy me", 16);
+ memset(destination, '?', 16);
+
+ printf("----- source addr: %08X, dest addr: %08X -----\n", source, destination);
+ hexdump(source, 16);
+ hexdump(destination, 16);
+
+ /* reset aes controller */
+ write32(AES_CMD, 0);
+ while(read32(AES_CMD) != 0);
+
+ /* flush buffers and tell the controller their addresses */
+ sync_after_write(source, 16);
+ sync_after_write(destination, 16);
+ write32(AES_SRC, virt_to_phys(source));
+ write32(AES_DEST, virt_to_phys(destination));
+
+ /* fire up copying! */
+ write32(AES_CMD, 0x80000000);
+ while(read32(AES_CMD) & 0x80000000);
+
+ /* show result */
+ printf("result is there:\n");
+ sync_before_read(source, 16); // should not be needed, but just to get sure...
+ sync_before_read(destination, 16);
+ hexdump(source, 16);
+ hexdump(destination, 16);
+
+ /* now THIS should show that something is wrong with memory (MMU stuff etc.?) */
+ free(source);
+ free(destination);
+}
+