asm: make use regular asserts that will just work on baremetal

Previously had wonky line pointer in asm_main. New interface simpler and more portable.

Add tests for ASSERT_EQ_ and family in arm and aarch64, previously on x86_64.

ASSERT_EQ_ and family in ARM can now either take =123, =addr or var, before this
the = was added on macros so var was not possible.

Define the main function directly in assembly, the C driver was useless.
This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-05-23 00:00:00 +00:00
parent 72200dee4e
commit c8c4f89854
90 changed files with 1003 additions and 978 deletions

View File

@@ -1,6 +1,6 @@
/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-loop-instruction-over-array */
#include "common.h"
#include <lkmc.h>
#define NELEM 4
#define ELEM_SIZE 4
@@ -11,7 +11,7 @@ my_array_0:
my_array_1:
.word 0x55555555, 0x66666666, 0x77777777, 0x88888888
LKMC_ENTRY
LKMC_PROLOGUE
/* Load r5, r6, r7 and r8 starting from the address in r4. Don't change r4 */
ldr r4, =my_array_0
@@ -20,11 +20,11 @@ LKMC_ENTRY
ldr r7, =0
ldr r8, =0
ldmia r4, {r5-r8}
LKMC_ASSERT_EQ(r4, my_array_0)
LKMC_ASSERT_EQ(r5, 0x11111111)
LKMC_ASSERT_EQ(r6, 0x22222222)
LKMC_ASSERT_EQ(r7, 0x33333333)
LKMC_ASSERT_EQ(r8, 0x44444444)
LKMC_ASSERT_EQ(r4, =my_array_0)
LKMC_ASSERT_EQ(r5, =0x11111111)
LKMC_ASSERT_EQ(r6, =0x22222222)
LKMC_ASSERT_EQ(r7, =0x33333333)
LKMC_ASSERT_EQ(r8, =0x44444444)
/* Swapping the order of r5 and r6 on the mnemonic makes no difference to load order.
*
@@ -38,8 +38,8 @@ LKMC_ENTRY
ldr r5, =0
ldr r6, =0
ldmia r4, {r6,r5}
LKMC_ASSERT_EQ(r5, 0x11111111)
LKMC_ASSERT_EQ(r6, 0x22222222)
LKMC_ASSERT_EQ(r5, =0x11111111)
LKMC_ASSERT_EQ(r6, =0x22222222)
#endif
/* Modify the array */
@@ -51,11 +51,11 @@ LKMC_ENTRY
stmdb r4, {r5-r8}
/* Verify that my_array_0 changed and is equal to my_array_1. */
LKMC_ASSERT_MEMCMP(my_array_0, my_array_1, 0x10)
LKMC_ASSERT_MEMCMP(my_array_0, my_array_1, =0x10)
/* Load registers and increment r4. */
ldr r4, =my_array_0
ldmia r4!, {r5-r8}
LKMC_ASSERT_EQ(r4, my_array_1)
LKMC_ASSERT_EQ(r4, =my_array_1)
LKMC_EXIT
LKMC_EPILOGUE