Files
linux-kernel-module-cheat/userland/posix/virt_to_phys_test.c
Ciro Santilli 六四事件 法轮功 476e109c81 mark physical address stuff as BSD
2020-08-06 02:00:01 +00:00

25 lines
540 B
C

/* https://cirosantilli.com/linux-kernel-module-cheat#userland-physical-address-experiments
*
* This file is dual licensed as both 3-Clause BSD and GPLv3.
*/
#define _XOPEN_SOURCE 700
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
enum { I0 = 0x12345678 };
static volatile uint32_t i = I0;
int main(void) {
printf("vaddr %p\n", (void *)&i);
printf("pid %ju\n", (uintmax_t)getpid());
while (i == I0) {
sleep(1);
}
printf("i %jx\n", (uintmax_t)i);
return EXIT_SUCCESS;
}