mirror of
https://github.com/tailix/kernel.git
synced 2025-02-03 15:27:11 -05:00
Add function "kernelmq_info_validate_and_copy" and example output
This commit is contained in:
parent
03f20e2e8f
commit
78d54a1700
4 changed files with 35 additions and 3 deletions
|
@ -1,8 +1,12 @@
|
|||
AS = $(CCPREFIX)as
|
||||
CC = $(CCPREFIX)gcc
|
||||
|
||||
# Architecture-dependent
|
||||
OBJS = start.s.o
|
||||
OBJS += init.c.o
|
||||
|
||||
# Architecture-independent
|
||||
OBJS += info.c.o
|
||||
OBJS += main.c.o
|
||||
|
||||
OBJS += logger.c.o
|
||||
|
|
14
arch/info.c
Normal file
14
arch/info.c
Normal file
|
@ -0,0 +1,14 @@
|
|||
#include <kernelmq/info.h>
|
||||
|
||||
unsigned char kernelmq_info_validate_and_copy(
|
||||
struct KernelMQ_Info *const dest,
|
||||
const struct KernelMQ_Info *const src
|
||||
) {
|
||||
if (!src) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
*dest = *src;
|
||||
|
||||
return 1;
|
||||
}
|
18
arch/main.c
18
arch/main.c
|
@ -3,6 +3,7 @@
|
|||
#include "protected.h"
|
||||
#include "paging.h"
|
||||
#include "timer.h"
|
||||
#include "kprintf.h"
|
||||
|
||||
#include <kernelmq/info.h>
|
||||
#include <kernelmq/stdlib.h>
|
||||
|
@ -17,12 +18,23 @@ void main(const struct KernelMQ_Info *const kinfo_ptr)
|
|||
|
||||
kmemset(&kinfo, 0, sizeof(struct KernelMQ_Info));
|
||||
|
||||
if (!kinfo_ptr) {
|
||||
logger_fail("No kernel information. Halt.");
|
||||
if (!kernelmq_info_validate_and_copy(&kinfo, kinfo_ptr)) {
|
||||
logger_fail("Invalid kernel information. Halt.");
|
||||
return;
|
||||
}
|
||||
|
||||
kinfo = *kinfo_ptr;
|
||||
kprintf("Kernel command line: %s\n", kinfo.cmdline);
|
||||
|
||||
for (unsigned int i = 0; i < kinfo.modules_count; ++i) {
|
||||
struct KernelMQ_Info_Module *module = &kinfo.modules[i];
|
||||
|
||||
kprintf(
|
||||
"Module at 0x%x, size 0x%x, command line: %s\n",
|
||||
module->base,
|
||||
module->size,
|
||||
module->cmdline
|
||||
);
|
||||
}
|
||||
|
||||
protected_initialize();
|
||||
|
||||
|
|
|
@ -62,6 +62,8 @@ struct KernelMQ_Info {
|
|||
unsigned long kernel_and_modules_total_size;
|
||||
};
|
||||
|
||||
unsigned char kernelmq_info_validate_and_copy(struct KernelMQ_Info *dest, const struct KernelMQ_Info *src);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue