fix bug
This commit is contained in:
parent
7febffdda1
commit
0eb609914b
49
kernel/csi.c
49
kernel/csi.c
@ -124,15 +124,17 @@ void cursor_move(i16 move_row, i16 move_col, vga_buf *vgabuf)
|
||||
while (move_row < 0) // up
|
||||
{
|
||||
move_row++;
|
||||
vgabuf->scr_cur_line = LASTLINE(vgabuf->scr_cur_line);
|
||||
if (vgabuf->scr_cur_line == vgabuf->scr_top_line)
|
||||
{
|
||||
if (vgabuf->scr_top_line == vgabuf->head_line)
|
||||
break;
|
||||
// vgabuf->scr_cur_line = LASTLINE(vgabuf->scr_cur_line);
|
||||
vgabuf->scr_top_line = LASTLINE(vgabuf->scr_top_line);
|
||||
vgabuf->scr_bot_line = LASTLINE(vgabuf->scr_bot_line);
|
||||
}
|
||||
break;
|
||||
vgabuf->scr_cur_line = LASTLINE(vgabuf->scr_cur_line);
|
||||
// if (vgabuf->scr_cur_line == vgabuf->scr_top_line)
|
||||
// {
|
||||
// if (vgabuf->scr_top_line == vgabuf->head_line)
|
||||
// break;
|
||||
// // vgabuf->scr_cur_line = LASTLINE(vgabuf->scr_cur_line);
|
||||
// vgabuf->scr_top_line = LASTLINE(vgabuf->scr_top_line);
|
||||
// vgabuf->scr_bot_line = LASTLINE(vgabuf->scr_bot_line);
|
||||
// }
|
||||
}
|
||||
vgabuf->cur_row = CYCLE_SUB(vgabuf->scr_top_line, vgabuf->scr_cur_line, SCR_MAXLINE);
|
||||
vgabuf->cur_col += move_col;
|
||||
@ -214,15 +216,10 @@ void set_color(vga_buf *vgabuf)
|
||||
{
|
||||
if (vgabuf->param1 == 0)
|
||||
{
|
||||
vgabuf->color = DEFAULT_CHAR_COLOR;
|
||||
disable_reverse(vgabuf);
|
||||
disable_hide(vgabuf);
|
||||
vgabuf->color = DEFAULT_CHAR_COLOR;
|
||||
}
|
||||
// else if (vgabuf->param1 == 5 || vgabuf->param1 == 6)
|
||||
// {
|
||||
// enable_blink();
|
||||
// vgabuf->color |= FLASH_CHAR;
|
||||
// }
|
||||
else if (vgabuf->param1 == 7)
|
||||
{
|
||||
enable_reverse(vgabuf);
|
||||
@ -282,15 +279,15 @@ void set_color(vga_buf *vgabuf)
|
||||
}
|
||||
else
|
||||
{
|
||||
warn("unsupport CSI: color");
|
||||
warn("\x1b[47;93munsupport CSI: sgr param:%d\x1b[m\n", vgabuf->param1);
|
||||
}
|
||||
if (vgabuf->Is2param == true)
|
||||
{
|
||||
if (vgabuf->param2 == 0)
|
||||
{
|
||||
vgabuf->color = DEFAULT_CHAR_COLOR;
|
||||
disable_reverse(vgabuf);
|
||||
disable_hide(vgabuf);
|
||||
vgabuf->color = DEFAULT_CHAR_COLOR;
|
||||
}
|
||||
// else if (vgabuf->param2 == 5 || vgabuf->param2 == 6)
|
||||
// {
|
||||
@ -356,7 +353,7 @@ void set_color(vga_buf *vgabuf)
|
||||
}
|
||||
else
|
||||
{
|
||||
warn("unsupport CSI: color");
|
||||
warn("\x1b[47;93unsupport CSI: sgr param:%d\n", vgabuf->param2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -412,45 +409,45 @@ void CSI_handler(u8 terminator, vga_buf *vgabuf)
|
||||
{
|
||||
case 'A': // Cursor Up
|
||||
if (vgabuf->param1 == 0)
|
||||
vgabuf->param1 == 1;
|
||||
vgabuf->param1 = 1;
|
||||
cursor_move(-vgabuf->param1, 0, vgabuf);
|
||||
break;
|
||||
case 'B': // Cursor Down
|
||||
if (vgabuf->param1 == 0)
|
||||
vgabuf->param1 == 1;
|
||||
vgabuf->param1 = 1;
|
||||
cursor_move(+vgabuf->param1, 0, vgabuf);
|
||||
break;
|
||||
case 'C': // Cursor Forward
|
||||
if (vgabuf->param1 == 0)
|
||||
vgabuf->param1 == 1;
|
||||
vgabuf->param1 = 1;
|
||||
cursor_move(0, +vgabuf->param1, vgabuf);
|
||||
break;
|
||||
case 'D': // Cursor Back
|
||||
if (vgabuf->param1 == 0)
|
||||
vgabuf->param1 == 1;
|
||||
vgabuf->param1 = 1;
|
||||
cursor_move(0, -vgabuf->param1, vgabuf); // nothing
|
||||
break;
|
||||
case 'E': // Cursor Next Line
|
||||
if (vgabuf->param1 == 0)
|
||||
vgabuf->param1 == 1;
|
||||
vgabuf->param1 = 1;
|
||||
cursor_move(+vgabuf->param1, -vgabuf->cur_col, vgabuf);
|
||||
break;
|
||||
case 'F': // Cursor Previous Line
|
||||
if (vgabuf->param1 == 0)
|
||||
vgabuf->param1 == 1;
|
||||
vgabuf->param1 = 1;
|
||||
cursor_move(-vgabuf->param1, -vgabuf->cur_col, vgabuf);
|
||||
break;
|
||||
case 'G': // Cursor Horizontal Absolute
|
||||
if (vgabuf->param1 == 0)
|
||||
vgabuf->param1 == 1;
|
||||
vgabuf->param1 = 1;
|
||||
cursor_locate(CYCLE_SUB(vgabuf->scr_top_line, vgabuf->scr_cur_line, SCR_MAXLINE), vgabuf->param1 - 1, vgabuf);
|
||||
break;
|
||||
case 'H': // Cursor Position
|
||||
case 'f':
|
||||
if (vgabuf->param1 == 0)
|
||||
vgabuf->param1 == 1;
|
||||
vgabuf->param1 = 1;
|
||||
if (vgabuf->param2 == 0)
|
||||
vgabuf->param2 == 1;
|
||||
vgabuf->param2 = 1;
|
||||
cursor_locate(vgabuf->param1 - 1, vgabuf->param2 - 1, vgabuf);
|
||||
break;
|
||||
case 'J': // Erase in Display
|
||||
|
||||
@ -132,8 +132,7 @@ void initial()
|
||||
do_vclose(stdout);
|
||||
do_vclose(stderr);
|
||||
|
||||
// exec("orange/shell_1.bin");
|
||||
exec("orange/test.bin");
|
||||
exec("orange/shell_1.bin");
|
||||
|
||||
while (1)
|
||||
;
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
|
||||
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
start.c
|
||||
start.c
|
||||
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
Forrest Yu, 2005
|
||||
Forrest Yu, 2005
|
||||
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
|
||||
|
||||
#include "stdio.h"
|
||||
@ -17,8 +17,7 @@
|
||||
/*
|
||||
* 当发生不可挽回的错误时就打印错误信息并使CPU核休眠
|
||||
*/
|
||||
void
|
||||
_panic(const char *file, int line, const char *fmt,...)
|
||||
void _panic(const char *file, int line, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
@ -32,49 +31,47 @@ _panic(const char *file, int line, const char *fmt,...)
|
||||
kprintf("\n");
|
||||
va_end(ap);
|
||||
// 休眠CPU核,直接罢工
|
||||
while(1)
|
||||
while (1)
|
||||
asm volatile("hlt");
|
||||
}
|
||||
|
||||
/*
|
||||
* 很像panic,但是不会休眠CPU核,就是正常打印信息
|
||||
*/
|
||||
void
|
||||
_warn(const char *file, int line, const char *fmt,...)
|
||||
void _warn(const char *file, int line, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
kprintf("kernel warning at %s:%d: ", file, line);
|
||||
kprintf("\x1b[47;93mkernel warning at %s:%d: \x1b[m", file, line);
|
||||
vkprintf(fmt, ap);
|
||||
kprintf("\n");
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
||||
/*======================================================================*
|
||||
cstart
|
||||
cstart
|
||||
*======================================================================*/
|
||||
void cstart()
|
||||
{
|
||||
kprintf("-----\"cstart\" begins-----\n");
|
||||
|
||||
// 将 LOADER 中的 GDT 复制到新的 GDT 中
|
||||
memcpy( &gdt, // New GDT
|
||||
(void*)(*((u32*)(&gdt_ptr[2]))), // Base of Old GDT
|
||||
*((u16*)(&gdt_ptr[0])) + 1 // Limit of Old GDT
|
||||
);
|
||||
memcpy(&gdt, // New GDT
|
||||
(void *)(*((u32 *)(&gdt_ptr[2]))), // Base of Old GDT
|
||||
*((u16 *)(&gdt_ptr[0])) + 1 // Limit of Old GDT
|
||||
);
|
||||
// gdt_ptr[6] 共 6 个字节:0~15:Limit 16~47:Base。用作 sgdt 以及 lgdt 的参数。
|
||||
u16* p_gdt_limit = (u16*)(&gdt_ptr[0]);
|
||||
u32* p_gdt_base = (u32*)(&gdt_ptr[2]);
|
||||
u16 *p_gdt_limit = (u16 *)(&gdt_ptr[0]);
|
||||
u32 *p_gdt_base = (u32 *)(&gdt_ptr[2]);
|
||||
*p_gdt_limit = GDT_SIZE * sizeof(DESCRIPTOR) - 1;
|
||||
*p_gdt_base = (u32)&gdt;
|
||||
*p_gdt_base = (u32)&gdt;
|
||||
|
||||
// idt_ptr[6] 共 6 个字节:0~15:Limit 16~47:Base。用作 sidt 以及 lidt 的参数。
|
||||
u16* p_idt_limit = (u16*)(&idt_ptr[0]);
|
||||
u32* p_idt_base = (u32*)(&idt_ptr[2]);
|
||||
u16 *p_idt_limit = (u16 *)(&idt_ptr[0]);
|
||||
u32 *p_idt_base = (u32 *)(&idt_ptr[2]);
|
||||
*p_idt_limit = IDT_SIZE * sizeof(GATE) - 1;
|
||||
*p_idt_base = (u32)&idt;
|
||||
*p_idt_base = (u32)&idt;
|
||||
|
||||
init_prot();
|
||||
|
||||
|
||||
@ -10,6 +10,8 @@ USER_SRCS := user/shell_1.c \
|
||||
user/shell_0.c \
|
||||
user/test.c \
|
||||
user/test2.c \
|
||||
user/sgr_test.c \
|
||||
user/cur_test.c
|
||||
|
||||
USER_BINS := $(patsubst %.c, $(OBJDIR)/%.bin, $(USER_SRCS))
|
||||
USER_BASENAMES := $(patsubst $(OBJDIR)/user/%, %, $(USER_BINS))
|
||||
|
||||
99
user/cur_test.c
Normal file
99
user/cur_test.c
Normal file
@ -0,0 +1,99 @@
|
||||
#include "type.h"
|
||||
#include "const.h"
|
||||
#include "protect.h"
|
||||
#include "string.h"
|
||||
#include "proc.h"
|
||||
#include "global.h"
|
||||
#include "proto.h"
|
||||
#include "stdio.h"
|
||||
|
||||
void delay(int time)
|
||||
{
|
||||
int i, j, k;
|
||||
for (k = 0; k < time; k++)
|
||||
{
|
||||
for (i = 0; i < 10000; i++)
|
||||
{
|
||||
for (j = 0; j < 10000; j++)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int main(int arg, char *argv[])
|
||||
{
|
||||
int stdin = open("dev_tty0", O_RDWR);
|
||||
int stdout = open("dev_tty0", O_RDWR);
|
||||
int stderr = open("dev_tty0", O_RDWR);
|
||||
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
for (int j = 0; j < 10; j++)
|
||||
printf("%d*", i);
|
||||
printf("\n");
|
||||
}
|
||||
delay(2);
|
||||
|
||||
// clear line and cursor to the start of line
|
||||
printf("\x1b[2K\x1b[1G");
|
||||
printf("\x1b[31mCursor Up and Cursor Forward\x1b[m");
|
||||
delay(2);
|
||||
for (int i = 1; i < 90; i++)
|
||||
{
|
||||
printf("\x1b[%dA\x1b[%dC", i, i);
|
||||
i += i;
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(3);
|
||||
printf("\x1b[2K\x1b[1G");
|
||||
printf("\x1b[32mCursor Down and Cursor Back\x1b[m");
|
||||
delay(2);
|
||||
for (int i = 1; i < 90; i++)
|
||||
{
|
||||
printf("\x1b[%dB\x1b[%dD", i, i);
|
||||
i += i;
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(3);
|
||||
printf("\x1b[2K\x1b[G");
|
||||
printf("\x1b[33mCursor Previous Line\x1b[m");
|
||||
delay(2);
|
||||
for (int i = 1; i < 90; i++)
|
||||
{
|
||||
printf("\x1b[%dF", i, i);
|
||||
i += i;
|
||||
delay(1);
|
||||
}
|
||||
// Scroll Up:5 lines
|
||||
delay(1);
|
||||
printf("\x1b[2K\x1b[G");
|
||||
printf("\x1b[34mScroll Up:5 lines\x1b[m");
|
||||
delay(6);
|
||||
printf("\x1b[5S");
|
||||
delay(10);
|
||||
|
||||
// Scroll Up:27 lines
|
||||
printf("\x1b[2K\x1b[G");
|
||||
printf("\x1b[34mScroll Up:27 lines\x1b[m");
|
||||
delay(6);
|
||||
printf("\x1b[27S");
|
||||
delay(10);
|
||||
|
||||
// Erase in Display n=3
|
||||
printf("\x1b[2K\x1b[G");
|
||||
printf("\x1b[35mErase in Display n=3 \x1b[m");
|
||||
delay(6);
|
||||
printf("\x1b[3J");
|
||||
delay(10);
|
||||
|
||||
// Erase in Display n=0
|
||||
printf("\x1b[2K\x1b[G");
|
||||
printf("\x1b[36mErase in Display n=1 \x1b[m");
|
||||
delay(6);
|
||||
printf("\x1b[1J");
|
||||
while (1)
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
42
user/sgr_test.c
Normal file
42
user/sgr_test.c
Normal file
@ -0,0 +1,42 @@
|
||||
#include "type.h"
|
||||
#include "const.h"
|
||||
#include "protect.h"
|
||||
#include "string.h"
|
||||
#include "proc.h"
|
||||
#include "global.h"
|
||||
#include "proto.h"
|
||||
#include "stdio.h"
|
||||
|
||||
int main(int arg, char *argv[])
|
||||
{
|
||||
int stdin = open("dev_tty0", O_RDWR);
|
||||
int stdout = open("dev_tty0", O_RDWR);
|
||||
int stderr = open("dev_tty0", O_RDWR);
|
||||
|
||||
printf("set color:\n");
|
||||
for (int i = 30; i <= 37; i++)
|
||||
{
|
||||
printf(" \x1b[%d;%dm Hello minios!! \x1b[m\n", i, 47 - (i - 30));
|
||||
}
|
||||
for (int i = 90; i <= 97; i++)
|
||||
{
|
||||
printf(" \x1b[%d;%dm Hello minios!! \x1b[m\n", i, 107 - (i - 90));
|
||||
}
|
||||
|
||||
printf("reverse:\n");
|
||||
printf(" \x1b[32;47m Hello minios!! \n");
|
||||
printf(" \x1b[7m Hello minios!! \x1b[m\n");
|
||||
|
||||
printf("hide:\n");
|
||||
printf(" \x1b[32;47;m Hello minios!! \n");
|
||||
printf(" \x1b[8m Hello minios!! \x1b[m\n");
|
||||
|
||||
printf("reset:\n");
|
||||
printf(" \x1b[m Hello minios!! \n");
|
||||
|
||||
printf("\n\n");
|
||||
printf(" \x1b[5m Hello minios!!\n \x1b[29m \n\x1b[61;67m\n");
|
||||
while (1)
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user