summaryrefslogtreecommitdiff
path: root/src/include/cpu/x86/mem.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/cpu/x86/mem.h')
-rw-r--r--src/include/cpu/x86/mem.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/include/cpu/x86/mem.h b/src/include/cpu/x86/mem.h
new file mode 100644
index 0000000000..4849ed289a
--- /dev/null
+++ b/src/include/cpu/x86/mem.h
@@ -0,0 +1,18 @@
+#ifndef CPU_X86_MEM_H
+#define CPU_X86_MEM_H
+
+/* Optimized generic x86 assembly for clearing memory */
+static inline void clear_memory(void *addr, unsigned long size)
+{
+ asm volatile(
+ "1: \n\t"
+ "movl %0, (%1)\n\t"
+ "addl $4, %1\n\t"
+ "subl $4, %2\n\t"
+ "jnz 1b\n\t"
+ : /* No outputs */
+ : "a" (0), "D" (addr), "c" (size)
+ );
+}
+
+#endif /* CPU_X86_MEM_H */