2021-11-26 06:46:05 +03:00
|
|
|
/**
|
|
|
|
* @file modules/test.c
|
|
|
|
* @brief Test module.
|
2022-02-06 16:08:20 +03:00
|
|
|
* @package x86_64
|
|
|
|
* @package aarch64
|
2021-11-26 06:46:05 +03:00
|
|
|
*
|
|
|
|
* Load with various arguments to do things like crash the
|
|
|
|
* kernel or print tracebacks.
|
|
|
|
*
|
|
|
|
* @copyright
|
|
|
|
* This file is part of ToaruOS and is released under the terms
|
|
|
|
* of the NCSA / University of Illinois License - see LICENSE.md
|
|
|
|
* Copyright (C) 2021 K. Lange
|
|
|
|
*/
|
2021-05-31 04:47:02 +03:00
|
|
|
#include <kernel/printf.h>
|
2021-07-17 12:55:54 +03:00
|
|
|
#include <kernel/module.h>
|
2021-10-20 04:33:35 +03:00
|
|
|
#include <kernel/assert.h>
|
|
|
|
#include <kernel/misc.h>
|
2021-05-31 04:47:02 +03:00
|
|
|
|
|
|
|
static int init(int argc, char * argv[]) {
|
2021-10-20 04:33:35 +03:00
|
|
|
dprintf("Hello, modules.\n");
|
|
|
|
dprintf("Received %d arguments.\n", argc);
|
|
|
|
|
|
|
|
if (argc > 1 && !strcmp(argv[1], "--traceback")) {
|
|
|
|
arch_dump_traceback();
|
|
|
|
} else if (argc > 1 && !strcmp(argv[1], "--fail")) {
|
|
|
|
return 1;
|
|
|
|
} else if (argc > 1 && !strcmp(argv[1], "--crash")) {
|
|
|
|
*(volatile int*)0x60000000 = 42;
|
|
|
|
} else if (argc > 1 && !strcmp(argv[1], "--assert")) {
|
|
|
|
assert(0 && "Intentional failure.");
|
|
|
|
}
|
|
|
|
|
2021-05-31 04:47:02 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fini(void) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-07-17 12:55:54 +03:00
|
|
|
struct Module metadata = {
|
2021-05-31 04:47:02 +03:00
|
|
|
.name = "test",
|
|
|
|
.init = init,
|
|
|
|
.fini = fini,
|
|
|
|
};
|
|
|
|
|