2020-05-24 15:30:55 -05:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#ifndef DISPLAY_H
|
|
|
|
#define DISPLAY_H
|
2022-02-19 10:17:40 -06:00
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
*
|
2020-05-24 15:30:55 -05:00
|
|
|
* Provides (macro) functions that implement the UI display.
|
|
|
|
* All knowledge about the display layout is encapsulated here.
|
|
|
|
*
|
2022-02-19 13:56:55 -06:00
|
|
|
*//*
|
2022-01-28 16:01:36 -06:00
|
|
|
* Copyright (C) 2020-2022 Martin Whitaker.
|
2020-05-24 15:30:55 -05:00
|
|
|
*/
|
|
|
|
|
2021-12-05 07:47:31 -06:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
2020-05-24 15:30:55 -05:00
|
|
|
#include "screen.h"
|
|
|
|
|
|
|
|
#include "print.h"
|
|
|
|
#include "string.h"
|
|
|
|
|
|
|
|
#include "test.h"
|
|
|
|
|
2022-01-28 16:01:36 -06:00
|
|
|
#define ROW_MESSAGE_T 10
|
2022-03-13 23:35:36 -05:00
|
|
|
#define ROW_MESSAGE_B (SCREEN_HEIGHT - 2)
|
2020-05-24 15:30:55 -05:00
|
|
|
|
|
|
|
#define ROW_SCROLL_T (ROW_MESSAGE_T + 2)
|
|
|
|
#define ROW_SCROLL_B (SCREEN_HEIGHT - 2)
|
|
|
|
|
|
|
|
#define ROW_FOOTER (SCREEN_HEIGHT - 1)
|
|
|
|
|
|
|
|
#define BAR_LENGTH 40
|
|
|
|
|
|
|
|
#define ERROR_LIMIT UINT64_C(999999999999)
|
|
|
|
|
|
|
|
#define display_cpu_model(str) \
|
|
|
|
prints(0, 30, str)
|
|
|
|
|
|
|
|
#define display_cpu_clk(freq) \
|
2022-03-11 20:09:22 -06:00
|
|
|
printf(1, 10, "%i MHz", freq)
|
2020-05-24 15:30:55 -05:00
|
|
|
|
|
|
|
#define display_cpu_addr_mode(str) \
|
|
|
|
prints(1, 20, str)
|
|
|
|
|
|
|
|
#define display_l1_cache_size(size) \
|
2022-04-07 20:21:18 -05:00
|
|
|
printf(2, 9, "%6kB", (uintptr_t)(size));
|
2020-05-24 15:30:55 -05:00
|
|
|
|
|
|
|
#define display_l2_cache_size(size) \
|
2022-04-07 20:21:18 -05:00
|
|
|
printf(3, 9, "%6kB", (uintptr_t)(size));
|
2020-05-24 15:30:55 -05:00
|
|
|
|
|
|
|
#define display_l3_cache_size(size) \
|
2022-04-07 20:21:18 -05:00
|
|
|
printf(4, 9, "%6kB", (uintptr_t)(size));
|
|
|
|
|
|
|
|
#define display_memory_size(size) \
|
|
|
|
printf(5, 9, "%6kB", (uintptr_t)(size));
|
2020-05-24 15:30:55 -05:00
|
|
|
|
2022-03-20 13:49:56 -05:00
|
|
|
#define display_l1_cache_speed(size) \
|
2022-04-07 20:21:18 -05:00
|
|
|
printf(2, 18, "%S6kB/s", (uintptr_t)(size))
|
2022-03-20 13:49:56 -05:00
|
|
|
|
|
|
|
#define display_l2_cache_speed(size) \
|
2022-04-07 20:21:18 -05:00
|
|
|
printf(3, 18, "%S6kB/s", (uintptr_t)(size))
|
2022-03-20 13:49:56 -05:00
|
|
|
|
|
|
|
#define display_l3_cache_speed(size) \
|
2022-04-07 20:21:18 -05:00
|
|
|
printf(4, 18, "%S6kB/s", (uintptr_t)(size))
|
2022-03-20 13:49:56 -05:00
|
|
|
|
|
|
|
#define display_ram_speed(size) \
|
2022-04-07 20:21:18 -05:00
|
|
|
printf(5, 18, "%S6kB/s", (uintptr_t)(size))
|
2020-05-24 15:30:55 -05:00
|
|
|
|
2022-04-08 12:26:31 -05:00
|
|
|
#define display_status(status) \
|
|
|
|
prints(7, 67, status)
|
|
|
|
|
2022-03-23 15:11:56 -05:00
|
|
|
#define display_dmi_mb(sys_ma, sys_sku) \
|
|
|
|
dmicol = prints(23, dmicol, sys_man); \
|
|
|
|
prints(23, dmicol + 1, sys_sku);
|
|
|
|
|
2022-01-28 16:01:36 -06:00
|
|
|
#define display_available_cpus(count) \
|
|
|
|
printi(7, 10, count, 4, false, false)
|
2020-05-24 15:30:55 -05:00
|
|
|
|
2022-01-28 16:01:36 -06:00
|
|
|
#define display_enabled_cpus(count) \
|
|
|
|
printi(7, 25, count, 4, false, false)
|
2020-05-24 15:30:55 -05:00
|
|
|
|
2022-01-28 16:01:36 -06:00
|
|
|
#define display_cpu_mode(str) \
|
|
|
|
prints(8, 11, str)
|
2020-05-24 15:30:55 -05:00
|
|
|
|
2022-01-31 16:59:14 -06:00
|
|
|
#define display_active_cpu(cpu_num) \
|
2022-01-29 07:45:42 -06:00
|
|
|
prints(8, 25, "core #"); \
|
2022-01-31 16:59:14 -06:00
|
|
|
printi(8, 31, cpu_num, 3, false, true)
|
2020-05-24 15:30:55 -05:00
|
|
|
|
2022-01-28 16:01:36 -06:00
|
|
|
#define display_all_active \
|
|
|
|
prints(8, 25, "all cores")
|
|
|
|
|
|
|
|
#define display_spinner(spin_state) \
|
2022-04-08 12:26:31 -05:00
|
|
|
printc(7, 76, spin_state)
|
2020-05-24 15:30:55 -05:00
|
|
|
|
|
|
|
#define display_pass_percentage(pct) \
|
|
|
|
printi(1, 34, pct, 3, false, false)
|
|
|
|
|
|
|
|
#define display_pass_bar(length) \
|
|
|
|
while (length > pass_bar_length) { \
|
|
|
|
printc(1, 39 + pass_bar_length, '#'); \
|
|
|
|
pass_bar_length++; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define display_test_percentage(pct) \
|
|
|
|
printi(2, 34, pct, 3, false, false)
|
|
|
|
|
|
|
|
#define display_test_bar(length) \
|
|
|
|
while (length > test_bar_length) { \
|
|
|
|
printc(2, 39 + test_bar_length, '#'); \
|
|
|
|
test_bar_length++; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define display_test_number(number) \
|
|
|
|
printi(3, 36, number, 2, false, true)
|
|
|
|
|
|
|
|
#define display_test_description(str) \
|
|
|
|
prints(3, 39, str)
|
|
|
|
|
|
|
|
#define display_test_addresses(pb, pe, total) \
|
|
|
|
{ \
|
|
|
|
clear_screen_region(4, 39, 4, SCREEN_WIDTH - 1); \
|
|
|
|
printf(4, 39, "%kB - %kB %kB of %kB", pb, pe, (pe) - (pb), total); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define display_test_stage_description(...) \
|
|
|
|
{ \
|
|
|
|
clear_screen_region(4, 39, 4, SCREEN_WIDTH - 1); \
|
|
|
|
printf(4, 39, __VA_ARGS__); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define display_test_pattern_name(str) \
|
|
|
|
{ \
|
|
|
|
clear_screen_region(5, 39, 5, SCREEN_WIDTH - 1); \
|
|
|
|
prints(5, 39, str); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define display_test_pattern_value(pattern) \
|
|
|
|
{ \
|
|
|
|
clear_screen_region(5, 39, 5, SCREEN_WIDTH - 1); \
|
|
|
|
printf(5, 39, "0x%0*x", TESTWORD_DIGITS, pattern); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define display_test_pattern_values(pattern, offset) \
|
|
|
|
{ \
|
|
|
|
clear_screen_region(5, 39, 5, SCREEN_WIDTH - 1); \
|
|
|
|
printf(5, 39, "0x%0*x - %i", TESTWORD_DIGITS, pattern, offset); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define display_run_time(hours, mins, secs) \
|
2022-04-08 12:26:31 -05:00
|
|
|
printf(7, 50, "%i:%02i:%02i", hours, mins, secs)
|
2020-05-24 15:30:55 -05:00
|
|
|
|
2022-04-06 19:27:41 -05:00
|
|
|
#define display_temperature(temp, maxtemp) \
|
|
|
|
printf(1, 20, "%2i/%2i%cC", temp, maxtemp, 0xf8)
|
2020-05-24 15:30:55 -05:00
|
|
|
|
|
|
|
#define display_pass_count(count) \
|
2022-04-08 12:26:31 -05:00
|
|
|
printi(8, 50, count, 0, false, true)
|
2020-05-24 15:30:55 -05:00
|
|
|
|
|
|
|
#define display_error_count(count) \
|
2022-04-08 12:26:31 -05:00
|
|
|
printi(8, 67, count, 0, false, true);
|
2020-05-24 15:30:55 -05:00
|
|
|
|
|
|
|
#define clear_message_area() \
|
|
|
|
{ \
|
|
|
|
clear_screen_region(ROW_MESSAGE_T, 0, ROW_MESSAGE_B, SCREEN_WIDTH - 1); \
|
|
|
|
scroll_message_row = ROW_SCROLL_T - 1; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define display_pinned_message(row, col, ...) \
|
|
|
|
printf(ROW_MESSAGE_T + row, col, __VA_ARGS__)
|
|
|
|
|
|
|
|
#define display_scrolled_message(col, ...) \
|
|
|
|
printf(scroll_message_row, col, __VA_ARGS__)
|
|
|
|
|
|
|
|
#define display_notice(str) \
|
|
|
|
prints(ROW_MESSAGE_T + 6, (SCREEN_WIDTH - strlen(str)) / 2, str)
|
|
|
|
|
2022-01-31 13:47:32 -06:00
|
|
|
#define display_notice_with_args(length, ...) \
|
|
|
|
printf(ROW_MESSAGE_T + 6, (SCREEN_WIDTH - length) / 2, __VA_ARGS__)
|
|
|
|
|
2020-05-24 15:30:55 -05:00
|
|
|
#define clear_footer_message() \
|
|
|
|
{ \
|
|
|
|
set_background_colour(WHITE); \
|
|
|
|
clear_screen_region(ROW_FOOTER, 56, ROW_FOOTER, SCREEN_WIDTH - 1); \
|
|
|
|
set_background_colour(BLUE); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define display_footer_message(str) \
|
|
|
|
{ \
|
|
|
|
set_foreground_colour(BLUE); \
|
|
|
|
prints(ROW_FOOTER, 56, str); \
|
|
|
|
set_foreground_colour(WHITE); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define trace(my_cpu, ...) \
|
|
|
|
if (enable_trace) do_trace(my_cpu, __VA_ARGS__)
|
|
|
|
|
|
|
|
extern int scroll_message_row;
|
|
|
|
|
|
|
|
void display_init(void);
|
|
|
|
|
2022-03-13 23:35:36 -05:00
|
|
|
void post_display_init(void);
|
|
|
|
|
2020-05-24 15:30:55 -05:00
|
|
|
void display_start_run(void);
|
|
|
|
|
|
|
|
void display_start_pass(void);
|
|
|
|
|
|
|
|
void display_start_test(void);
|
|
|
|
|
|
|
|
void check_input(void);
|
|
|
|
|
|
|
|
void set_scroll_lock(bool enabled);
|
|
|
|
|
|
|
|
void toggle_scroll_lock(void);
|
|
|
|
|
|
|
|
void scroll(void);
|
|
|
|
|
2022-01-31 16:59:14 -06:00
|
|
|
void do_tick(int my_cpu);
|
2020-05-24 15:30:55 -05:00
|
|
|
|
2022-01-31 16:59:14 -06:00
|
|
|
void do_trace(int my_cpu, const char *fmt, ...);
|
2020-05-24 15:30:55 -05:00
|
|
|
|
|
|
|
#endif // DISPLAY_H
|