mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-29 04:54:27 +01:00
userland: support arch specific examples
This commit is contained in:
1
userland/arch/aarch64/Makefile
Symbolic link
1
userland/arch/aarch64/Makefile
Symbolic link
@@ -0,0 +1 @@
|
||||
../../Makefile
|
||||
8
userland/arch/aarch64/asm_hello.c
Normal file
8
userland/arch/aarch64/asm_hello.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <assert.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
int main(void) {
|
||||
register uint32_t x0 __asm__ ("x0");
|
||||
__asm__ ("mov x0, #1;" : : : "%x0");
|
||||
assert(x0 == 1);
|
||||
}
|
||||
1
userland/arch/aarch64/params.mk
Normal file
1
userland/arch/aarch64/params.mk
Normal file
@@ -0,0 +1 @@
|
||||
COMMON_DIR = ../../..
|
||||
1
userland/arch/x86_64/Makefile
Symbolic link
1
userland/arch/x86_64/Makefile
Symbolic link
@@ -0,0 +1 @@
|
||||
../../Makefile
|
||||
16
userland/arch/x86_64/asm_hello.c
Normal file
16
userland/arch/x86_64/asm_hello.c
Normal file
@@ -0,0 +1,16 @@
|
||||
#include <assert.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
int main(void) {
|
||||
uint32_t in = 1;
|
||||
uint32_t out = 0;
|
||||
__asm__ (
|
||||
"movl %1, %%eax;"
|
||||
"inc %%eax;"
|
||||
"movl %%eax, %0"
|
||||
: "=m" (out)
|
||||
: "m" (in)
|
||||
: "%eax"
|
||||
);
|
||||
assert(out == in + 1);
|
||||
}
|
||||
19
userland/arch/x86_64/freestanding/hello.S
Normal file
19
userland/arch/x86_64/freestanding/hello.S
Normal file
@@ -0,0 +1,19 @@
|
||||
.data
|
||||
s:
|
||||
.ascii "hello\n"
|
||||
len = . - s
|
||||
.text
|
||||
.global _start
|
||||
_start:
|
||||
|
||||
/* Write. */
|
||||
mov $1, %rax
|
||||
mov $1, %rdi
|
||||
mov $s, %rsi
|
||||
mov $len, %rdx
|
||||
syscall
|
||||
|
||||
/* Exit. */
|
||||
mov $60, %rax
|
||||
mov $0, %rdi
|
||||
syscall
|
||||
1
userland/arch/x86_64/params.mk
Normal file
1
userland/arch/x86_64/params.mk
Normal file
@@ -0,0 +1 @@
|
||||
COMMON_DIR = ../../..
|
||||
Reference in New Issue
Block a user