libkernaux/src/pfa.c

49 lines
1.0 KiB
C
Raw Normal View History

#include <kernaux/pfa.h>
2020-11-29 23:58:13 +00:00
2020-11-30 00:12:25 +00:00
kernaux_bool KernAux_PFA_initialize_start(
2020-11-29 23:58:13 +00:00
struct KernAux_PFA *const pfa,
const unsigned long long page_size
) {
if (pfa->initialized) {
2020-11-30 00:12:25 +00:00
return KERNAUX_FALSE;
2020-11-29 23:58:13 +00:00
}
if (page_size < KERNAUX_PFA_PAGE_SIZE_MIN) {
2020-11-30 00:12:25 +00:00
return KERNAUX_FALSE;
2020-11-29 23:58:13 +00:00
}
if (page_size > KERNAUX_PFA_PAGE_SIZE_MAX) {
2020-11-30 00:12:25 +00:00
return KERNAUX_FALSE;
2020-11-29 23:58:13 +00:00
}
for (unsigned long long i = 0; i < sizeof(*pfa); ++i) {
*((unsigned char*)pfa + i) = 0;
}
pfa->page_size = page_size;
pfa->zones_count = 0;
}
2020-11-30 00:12:25 +00:00
kernaux_bool KernAux_PFA_initialize_add_zone(
2020-11-29 23:58:13 +00:00
struct KernAux_PFA *const pfa,
const char *const name,
const unsigned long long start,
const unsigned long long end
) {
if (pfa->initialized) {
2020-11-30 00:12:25 +00:00
return KERNAUX_FALSE;
2020-11-29 23:58:13 +00:00
}
if (pfa->zones_count >= KERNAUX_PFA_ZONES_COUNT_MAX) {
2020-11-30 00:12:25 +00:00
return KERNAUX_FALSE;
2020-11-29 23:58:13 +00:00
}
}
2020-11-30 00:12:25 +00:00
kernaux_bool KernAux_PFA_initialize_finish(
2020-11-29 23:58:13 +00:00
struct KernAux_PFA *const pfa
) {
if (pfa->initialized) {
2020-11-30 00:12:25 +00:00
return KERNAUX_FALSE;
2020-11-29 23:58:13 +00:00
}
}