arm exception level emulator entry examples

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2018-11-20 00:00:01 +00:00
parent 07000300ab
commit 35684b1b7e
3 changed files with 79 additions and 8 deletions

View File

@@ -1,9 +1,11 @@
/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-exception-level */
#include <stdio.h>
#include <inttypes.h>
int main(void) {
register uint64_t x0 __asm__ ("x0");
__asm__ ("mrs x0, CurrentEL;" : : : "%x0");
printf("%" PRIu64 "\n", x0);
register uint64_t x0 __asm__ ("x0");
__asm__ ("mrs x0, CurrentEL;" : : : "%x0");
printf("%" PRIu64 "\n", x0 >> 2);
return 0;
}

11
baremetal/arch/arm/el.c Normal file
View File

@@ -0,0 +1,11 @@
/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-exception-level */
#include <stdio.h>
#include <inttypes.h>
int main(void) {
register uint32_t r0 __asm__ ("r0");
__asm__ ("mrs r0, CPSR" : : : "%r0");
printf("%" PRIu32 "\n", r0 & 0x1F);
return 0;
}