mirror of
https://github.com/0Nera/BMOSP.git
synced 2024-12-22 22:06:56 +03:00
Ускорение вывода на экран
This commit is contained in:
parent
cce42f26e6
commit
9a56ff681a
@ -77,7 +77,7 @@ void idt_set_int(uint8_t vector, int_entry_t handler);
|
||||
uint64_t arch_get_tick_b( );
|
||||
uint64_t arch_get_tick_l( );
|
||||
uint64_t arch_get_tick( );
|
||||
void com_write_byte(uint8_t byte);
|
||||
void com_write_byte(char byte);
|
||||
void com_write_bytes(char *c, uint64_t n);
|
||||
time_t rtc_get_time( );
|
||||
|
||||
@ -105,6 +105,26 @@ static inline void io_wait( ) {
|
||||
outb(0x80, 0);
|
||||
}
|
||||
|
||||
static inline void *hal_memset(void *s, char c, int64_t count) {
|
||||
int64_t d0, d1;
|
||||
asm volatile("rep\n\t"
|
||||
"stosb"
|
||||
: "=&c"(d0), "=&D"(d1)
|
||||
: "a"(c), "1"(s), "0"(count)
|
||||
: "memory");
|
||||
return s;
|
||||
}
|
||||
|
||||
static inline void *hal_memset_32(void *s, uint32_t c, int64_t count) {
|
||||
int64_t d0, d1;
|
||||
asm volatile("rep\n\t"
|
||||
"stosl"
|
||||
: "=&c"(d0), "=&D"(d1)
|
||||
: "a"(c), "1"(s), "0"(count)
|
||||
: "memory");
|
||||
return s;
|
||||
}
|
||||
|
||||
#define GET_TICK_BIG arch_get_tick_b( )
|
||||
#define GET_TICK_lOW arch_get_tick_l( )
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
void log_init( );
|
||||
void log_init_mem( );
|
||||
void log_printf(char *str, ...);
|
||||
char *utf8cp(char *str);
|
||||
|
||||
#ifndef NO_DEBUG
|
||||
#define LOG(...) \
|
||||
|
@ -41,6 +41,7 @@ static inline void pause( ) {
|
||||
|
||||
void tool_memcpy(void *dest, void *src, uint64_t n);
|
||||
void *tool_memset(void *ptr, uint8_t n, uint64_t size);
|
||||
void tool_memmove(void *dest, void *src, uint64_t n);
|
||||
uint64_t tool_strlen(const char *str);
|
||||
void tool_strcpy(char *dest, char *src);
|
||||
int tool_strcmp(const char *s1, const char *s2);
|
||||
|
@ -53,16 +53,17 @@ void fb_init( ) {
|
||||
|
||||
for (uint64_t i = 0; i < width * height; i++) { fb_addr[i] = background; }
|
||||
|
||||
LOG("0x%x %ux%u\n", fb_addr, width, height);
|
||||
|
||||
if (framebuffer_response->framebuffer_count == 1) { return; }
|
||||
|
||||
#ifdef DEBUG_FB
|
||||
LOG("Инициализация дополнительных: %u мониторов\n", framebuffer_response->framebuffer_count);
|
||||
|
||||
#endif
|
||||
for (uint64_t i = 1; i < framebuffer_response->framebuffer_count; i++) {
|
||||
struct limine_framebuffer *framebuffer = framebuffer_response->framebuffers[i];
|
||||
uint32_t *framebuffer_addr = (uint32_t *)framebuffer->address;
|
||||
#ifdef DEBUG_FB
|
||||
LOG("[%u]->0x%x %ux%u\n", i, framebuffer->address, framebuffer->width, framebuffer->height);
|
||||
#endif
|
||||
for (uint64_t ij = 0; ij < width * height; ij++) { framebuffer_addr[ij] = background; }
|
||||
}
|
||||
}
|
||||
|
30
kernel/log.c
30
kernel/log.c
@ -34,8 +34,9 @@ static inline uint32_t analyze(char glyth) {
|
||||
|
||||
// Вывод символа по координатам
|
||||
static void print_char(uint64_t x, uint64_t y, char glyth) {
|
||||
uint32_t glyth_index = analyze(glyth);
|
||||
for (uint64_t i = 0; i < FONT_6X8_SLIM_CHAR_HEIGHT; i++) {
|
||||
fb_print_bits(x, y + i, font_6x8_slim[analyze(glyth) + i]);
|
||||
fb_print_bits(x, y + i, font_6x8_slim[glyth_index + i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,7 +46,10 @@ void log_dump_buffer( ) {
|
||||
|
||||
static void log_fb_putchar(char c) {
|
||||
if (c == '\0' || fb_init_status < 1) { return; }
|
||||
if (c == '\t') {
|
||||
|
||||
if (c == '\r') {
|
||||
log_buffer[--buf_pos] = 0;
|
||||
} else if (c == '\t') {
|
||||
fb_pos_x += FONT_6X8_SLIM_CHAR_WIDTH * 4;
|
||||
} else if (c == '\n') {
|
||||
fb_pos_x = 4;
|
||||
@ -58,12 +62,8 @@ static void log_fb_putchar(char c) {
|
||||
|
||||
if (fb_pos_y + FONT_6X8_SLIM_CHAR_HEIGHT >= SCREEN_HEIGHT) {
|
||||
// Дошли до нижнего края экрана
|
||||
while (log_buffer[0] != '\n') {
|
||||
for (uint64_t i = 0; i < buf_max - 1; i++) { log_buffer[i] = log_buffer[i + 1]; }
|
||||
buf_pos--;
|
||||
}
|
||||
for (uint64_t i = 0; i < buf_max - 1; i++) { log_buffer[i] = log_buffer[i + 1]; }
|
||||
buf_pos--;
|
||||
while (log_buffer[0] != '\n') { tool_memmove(log_buffer, log_buffer + 1, --buf_pos); }
|
||||
tool_memmove(log_buffer, log_buffer + 1, --buf_pos);
|
||||
redraw_screen( );
|
||||
return;
|
||||
}
|
||||
@ -75,7 +75,7 @@ static void log_fb_putchar(char c) {
|
||||
|
||||
void redraw_screen( ) {
|
||||
// Перерисовка экрана
|
||||
for (uint64_t i = 0; i < SCREEN_WIDTH * SCREEN_HEIGHT; i++) { SCREEN_BUFFER[i] = DARK_GREEN; }
|
||||
hal_memset_32(SCREEN_BUFFER, DARK_GREEN, SCREEN_WIDTH * SCREEN_HEIGHT);
|
||||
|
||||
fb_pos_x = 4;
|
||||
fb_pos_y = 0;
|
||||
@ -87,8 +87,6 @@ void log_putchar(char c) {
|
||||
log_buffer[buf_pos] = c;
|
||||
com_write_byte(c);
|
||||
|
||||
log_buffer[buf_pos] = c;
|
||||
|
||||
if (buf_pos + 1 == buf_max) {
|
||||
// Смещение буфера на 1 символ влево
|
||||
for (uint64_t i = 0; i < buf_max - 1; i++) { log_buffer[i] = log_buffer[i + 1]; }
|
||||
@ -109,24 +107,18 @@ void log_printf(char *str, ...) {
|
||||
va_list args;
|
||||
va_start(args, str);
|
||||
tool_format(&log_putchar, str, args);
|
||||
|
||||
lock_release(log_lock);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void log_init_mem( ) {
|
||||
LOCK(log_lock);
|
||||
if (fb_init_status < 1) {
|
||||
LOG("Нет доступных фреймбуфферов для вывода\n");
|
||||
return;
|
||||
}
|
||||
|
||||
LOG("Полная инициализация отладчика занимает %u килобайт озу\n",
|
||||
(((SCREEN_WIDTH - 4) / FONT_WIDTH) * (SCREEN_HEIGHT / FONT_HEIGHT)) / 1024);
|
||||
|
||||
log_buffer = mem_alloc(((SCREEN_WIDTH - 4) / FONT_WIDTH) * (SCREEN_HEIGHT / FONT_HEIGHT));
|
||||
tool_memcpy(log_buffer, start_buffer, buf_max);
|
||||
buf_max = ((SCREEN_WIDTH - 4) / FONT_WIDTH) * (SCREEN_HEIGHT / FONT_HEIGHT);
|
||||
LOG("Размер буффера: %u символов\n", buf_max);
|
||||
LOG("%ux%u\n", width, height);
|
||||
redraw_screen( );
|
||||
lock_release(log_lock);
|
||||
}
|
||||
|
@ -23,6 +23,17 @@ void *tool_memset(void *ptr, uint8_t n, uint64_t size) {
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void tool_memmove(void *dest, void *src, uint64_t n) {
|
||||
unsigned char *cdest = (unsigned char *)dest;
|
||||
unsigned char *csrc = (unsigned char *)src;
|
||||
|
||||
if (cdest < csrc) {
|
||||
for (uint64_t i = 0; i < n; i++) { cdest[i] = csrc[i]; }
|
||||
} else {
|
||||
for (uint64_t i = n; i > 0; i--) { cdest[i - 1] = csrc[i - 1]; }
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t tool_strlen(const char *str) {
|
||||
uint64_t length = 0;
|
||||
while (*str) {
|
||||
|
Loading…
Reference in New Issue
Block a user