mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-28 04:24:26 +01:00
baremetal: create an assert_fail C helper
Create a test for it under interactive/assert_fail.c Move prompt under interactive Create baremetal/arch/aarch64/c_from_as.S as an example of calling C functions from assembly.
This commit is contained in:
6
baremetal/interactive/assert_fail.c
Normal file
6
baremetal/interactive/assert_fail.c
Normal file
@@ -0,0 +1,6 @@
|
||||
#include <common.h>
|
||||
|
||||
void main(void) {
|
||||
assert_fail();
|
||||
}
|
||||
|
||||
22
baremetal/interactive/prompt.c
Normal file
22
baremetal/interactive/prompt.c
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void main(void) {
|
||||
char c;
|
||||
char *ptr = NULL;
|
||||
size_t alloc_size = 1;
|
||||
while (1) {
|
||||
printf("enter a character\n");
|
||||
c = getchar();
|
||||
printf("got: %c\n", c);
|
||||
ptr = realloc(ptr, alloc_size);
|
||||
if (ptr == NULL) {
|
||||
puts("out of memory");
|
||||
break;
|
||||
} else {
|
||||
printf("new alloc of %d bytes at address 0x%p\n", alloc_size, ptr);
|
||||
alloc_size <<= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user