修复tty显示字符串时遍历字符串无法停止的问题
This commit is contained in:
parent
325e0a01bd
commit
bdccf4add6
|
@ -5,5 +5,6 @@
|
||||||
|
|
||||||
extern void memset(void *__dest, u8 __src, usize len);
|
extern void memset(void *__dest, u8 __src, usize len);
|
||||||
extern void memcpy(void *__dest, void *__src, usize len);
|
extern void memcpy(void *__dest, void *__src, usize len);
|
||||||
|
extern usize strlen(void *__dest);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -40,7 +40,6 @@ void kmain(void *mb2_bootinfo)
|
||||||
|
|
||||||
framebuffer fb;
|
framebuffer fb;
|
||||||
get_frame_buffer_with_bootinfo(&fb, &bootinfo);
|
get_frame_buffer_with_bootinfo(&fb, &bootinfo);
|
||||||
KERNEL_TODO();
|
|
||||||
tty *tty0 = tty_new(tty_type_raw_framebuffer, tty_mode_text);
|
tty *tty0 = tty_new(tty_type_raw_framebuffer, tty_mode_text);
|
||||||
tty_set_framebuffer(tty0, &fb);
|
tty_set_framebuffer(tty0, &fb);
|
||||||
|
|
||||||
|
@ -66,9 +65,9 @@ void get_frame_buffer_with_bootinfo(framebuffer *fb, bootinfo_t *bootinfo)
|
||||||
fb->width = fbinfo->framebuffer_width;
|
fb->width = fbinfo->framebuffer_width;
|
||||||
fb->height = fbinfo->framebuffer_height;
|
fb->height = fbinfo->framebuffer_height;
|
||||||
fb->pixsize = fbinfo->framebuffer_bpp / 8;
|
fb->pixsize = fbinfo->framebuffer_bpp / 8;
|
||||||
memm_map_pageframes_to( // TODO 总共需要映射8MB空间,但是它只映射了2MB
|
fb->pixtype = rgb;
|
||||||
|
memm_map_pageframes_to(
|
||||||
(u64)fb->pointer, (u64)fb->pointer,
|
(u64)fb->pointer, (u64)fb->pointer,
|
||||||
fb->width * fb->height * fb->pixsize,
|
fb->width * fb->height * fb->pixsize,
|
||||||
false, true);
|
false, true);
|
||||||
KERNEL_TODO();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -933,14 +933,14 @@ u64 font[256][64] = {
|
||||||
// M
|
// M
|
||||||
0b00000000,
|
0b00000000,
|
||||||
0b00000000,
|
0b00000000,
|
||||||
0b10000001, ///
|
0b00100010, ///
|
||||||
0b11000011,
|
0b00100010,
|
||||||
0b11000011,
|
0b00100110,
|
||||||
0b10100101,
|
0b01010101,
|
||||||
0b10101001,
|
0b01001001,
|
||||||
0b10011001,
|
0b01001001,
|
||||||
0b10011001,
|
0b01001001,
|
||||||
0b10000001,
|
0b01000001,
|
||||||
0b10000001,
|
0b10000001,
|
||||||
0b10000001, //
|
0b10000001, //
|
||||||
0b00000000,
|
0b00000000,
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <kernel/kernel.h>
|
#include <kernel/kernel.h>
|
||||||
|
|
||||||
|
#include <libk/string.h>
|
||||||
#include <libk/string.h>
|
#include <libk/string.h>
|
||||||
|
|
||||||
tty_controller_t tty_ctrler;
|
tty_controller_t tty_ctrler;
|
||||||
|
@ -125,7 +126,7 @@ inline static void newline(tty *ttyx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tty_text_print(tty *ttyx, char *restrict string, u32 color, u32 bgcolor)
|
void tty_text_print(tty *ttyx, char *string, u32 color, u32 bgcolor)
|
||||||
{
|
{
|
||||||
if (ttyx->mode != tty_mode_text)
|
if (ttyx->mode != tty_mode_text)
|
||||||
return;
|
return;
|
||||||
|
@ -142,7 +143,8 @@ void tty_text_print(tty *ttyx, char *restrict string, u32 color, u32 bgcolor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
simple_lock_lock(ttyx->text.lock);
|
simple_lock_lock(ttyx->text.lock);
|
||||||
while (*string != '\0')
|
usize len = strlen(string);
|
||||||
|
for (char *str = string; string - str < len; string++)
|
||||||
{
|
{
|
||||||
char c = *string;
|
char c = *string;
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
|
@ -200,7 +202,6 @@ void tty_text_print(tty *ttyx, char *restrict string, u32 color, u32 bgcolor)
|
||||||
}
|
}
|
||||||
putchar(ttyx, c, color, bgcolor);
|
putchar(ttyx, c, color, bgcolor);
|
||||||
ttyx->text.column++;
|
ttyx->text.column++;
|
||||||
++string;
|
|
||||||
}
|
}
|
||||||
if (ttyx->text.column == ttyx->text.width)
|
if (ttyx->text.column == ttyx->text.width)
|
||||||
newline(ttyx);
|
newline(ttyx);
|
||||||
|
|
|
@ -38,7 +38,7 @@ endif
|
||||||
|
|
||||||
ASMFLAGS := ${ASMFLAGS}
|
ASMFLAGS := ${ASMFLAGS}
|
||||||
|
|
||||||
S_SRCS = memset.s memcpy.s
|
S_SRCS = memset.s memcpy.s strlen.s
|
||||||
S_OBJS = ${S_SRCS:.s=.s.o}
|
S_OBJS = ${S_SRCS:.s=.s.o}
|
||||||
|
|
||||||
################################
|
################################
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
section .text
|
||||||
|
|
||||||
|
global strlen
|
||||||
|
; usize strlen(char *)
|
||||||
|
strlen:
|
||||||
|
push rcx
|
||||||
|
|
||||||
|
cld
|
||||||
|
mov al, 0
|
||||||
|
xor rcx, rcx
|
||||||
|
dec rcx
|
||||||
|
repne scasb
|
||||||
|
|
||||||
|
not rcx
|
||||||
|
dec rcx
|
||||||
|
|
||||||
|
mov rax, rcx
|
||||||
|
pop rcx
|
||||||
|
ret
|
Reference in New Issue