mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
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.
47 lines
1.1 KiB
ArmAsm
47 lines
1.1 KiB
ArmAsm
/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-vcvtrr-instruction */
|
|
|
|
#include <lkmc.h>
|
|
|
|
LKMC_PROLOGUE
|
|
.data
|
|
vcvtr_0: .float 1.25, 2.5, 3.75, 4.0
|
|
vcvtr_expect_zero: .word 1, 2, 3, 4
|
|
vcvtr_expect_plus_infinity: .word 2, 3, 4, 4
|
|
.bss
|
|
vcvtr_result_zero: .skip 0x10
|
|
vcvtr_result_plus_infinity: .skip 0x10
|
|
.text
|
|
ldr r0, =vcvtr_0
|
|
vld1.32 {q0}, [r0]
|
|
|
|
/* zero */
|
|
vmrs r0, fpscr
|
|
orr r0, r0, (3 << 22)
|
|
vmsr fpscr, r0
|
|
vcvtr.u32.f32 q1, q0
|
|
ldr r0, =vcvtr_result_zero
|
|
vst1.32 {q1}, [r0]
|
|
LKMC_ASSERT_MEMCMP(
|
|
vcvtr_result_zero,
|
|
vcvtr_expect_zero,
|
|
=0x10
|
|
)
|
|
|
|
#if 0
|
|
/* TODO why is this not working? Rounds to zero still. */
|
|
/* plus infinity */
|
|
vmrs r0, fpscr
|
|
mov r1, 1
|
|
bfi r0, r1, 22, 2
|
|
vmsr fpscr, r0
|
|
vcvtr.u32.f32 q1, q0
|
|
ldr r0, =vcvtr_result_plus_infinity
|
|
vst1.32 {q1}, [r0]
|
|
LKMC_ASSERT_MEMCMP(
|
|
vcvtr_result_plus_infinity,
|
|
vcvtr_expect_plus_infinity,
|
|
=0x10
|
|
)
|
|
#endif
|
|
LKMC_EPILOGUE
|