fsctl/src/menu/test.c

129 lines
3.0 KiB
C

#include "fsctl/menu.h"
#include "fsctl/fugue.h"
#include "fsctl/utils/fs_table.h"
#include "fsctl/utils/display.h"
//---
// Internal
//---
/* internal information */
static int test_selected;
static int __find_ls;
static int __find_lb;
static int __find_fs;
static int __find_fb;
/* test_search() : search Fugue entry using sector */
static void __test_search(
int *info,
uintptr_t start,
uintptr_t end,
size_t block
) {
uintptr_t saved_start;
fugue_fs_t fs;
int counter;
dclear(C_WHITE);
_printXY(0, 0, "search from %p...", start);
dupdate();
counter = 0;
saved_start = start;
while (start < end)
{
if (fugue_fs_mount(&fs, (void *)start) == 0) {
dclear(C_WHITE);
_printXY(0, 0, "search from %p...", saved_start);
_printXY(0, 1, "- found = %d", counter);
dupdate();
*info += 1;
}
start += block;
}
dclear(C_WHITE);
}
/* test_search_sector() : search Fugue entry using sector */
static void test_search_sector(int *info, uintptr_t start, uintptr_t end)
{
__test_search(info, start, end, 512);
}
/* test_search_byte() : search Fugue entry using byte */
static void test_search_byte(int *info, uintptr_t start, uintptr_t end)
{
__test_search(info, start, end, 1);
}
//---
// Public
//---
/* test_menu_init() : init menu */
void test_menu_init(void)
{
test_selected = -1;
__find_ls = 0;
__find_lb = 0;
__find_fs = 0;
__find_fb = 0;
}
/* test_menu_display() : display menu */
void test_menu_display(void)
{
int y;
y = 0;
switch(test_selected)
{
case 1:
test_search_sector(&__find_ls, 0xa1000000, 0xa2000000);
break;
case 2:
test_search_byte(&__find_ls, 0xa1000000, 0xa2000000);
break;
case 3:
test_search_sector(&__find_ls, 0xa0000000, 0xa1000000);
break;
case 4:
test_search_byte(&__find_ls, 0xa0000000, 0xa1000000);
break;
}
test_selected = -1;
_printXY(0, ++y, "[1] last 16Mo entry search (sector)");
_printXY(0, ++y, "[2] last 16Mo entry search (byte)");
_printXY(0, ++y, "[3] first 16Mo entry search (sector)");
_printXY(0, ++y, "[4] first 16Mo entry search (byte)");
_printXY(0, ++y, "");
_printXY(0, ++y, "");
_printXY(0, ++y, "last 16Mo sector found = %d", __find_ls);
_printXY(0, ++y, "last 16Mo byte found = %d", __find_lb);
_printXY(0, ++y, "first 16Mo sector found = %d", __find_fs);
_printXY(0, ++y, "first 16Mo byte found = %d", __find_fb);
}
/* test_menu_keyboard() : handle keyboard */
void test_menu_keyboard(int key)
{
switch (key)
{
case KEY_1:
test_selected = 1;
break;
case KEY_2:
test_selected = 2;
break;
case KEY_3:
test_selected = 3;
break;
case KEY_4:
test_selected = 4;
break;
}
}