replace disp_*

This commit is contained in:
xiaoxiao 2023-01-02 12:45:23 +08:00
parent f9ed0ed420
commit f70a22b8c2
13 changed files with 1288 additions and 1265 deletions

View File

@ -49,7 +49,6 @@ typedef struct s_tty
struct s_console *console;
} TTY;
typedef struct n_tty
{
int driver_type; // 1-vga&kbd; 2-serial
@ -75,13 +74,15 @@ typedef struct vga_buf
int cur_row;
int cur_col; // cursor position, on screen
bool Is2param;
enum CSI_state CSI;
i16 param1; // the first param of CSI
i16 param2; // the second of CSI
u16 color;
} vga_buf;
typedef struct keyboard_buf {
typedef struct keyboard_buf
{
void *buf; // 1d array, buffer input virtual line, works as a ldisc
int tail;
int head;
@ -89,7 +90,8 @@ typedef struct keyboard_buf {
int readable;
} keyboard_buf;
typedef struct serial_buf {
typedef struct serial_buf
{
void *buf;
int tail;
int head;
@ -116,7 +118,6 @@ void vga_tty_select(NTTY *tty);
void ps2_tty_init(NTTY *tty);
int ps2_tty_read(NTTY *tty, char *buf, int nr);
#define CYCLE_SUB(head, tail, _max) ((head) <= (tail) ? (tail) - (head) : (tail) + (_max) - (head))
#define NEXT(x, _max) (((x) + 1) % (_max))
#define LAST(x, _max) (((x)-1) >= 0 ? ((x)-1) % (_max) : (_max)-1)

View File

@ -13,14 +13,10 @@
#include "vfs.h"
#include "stdio.h"
static u32 exec_elfcpy(u32 fd, Elf32_Phdr Echo_Phdr, u32 attribute);
static u32 exec_load(u32 fd, const Elf32_Ehdr *Echo_Ehdr, const Elf32_Phdr Echo_Phdr[]);
static int exec_pcb_init(char *path);
/*======================================================================*
* sys_exec add by visual 2016.5.23
*exec系统调用功能实现部分
@ -36,7 +32,7 @@ u32 sys_exec(char *path)
if (0 == path)
{
disp_color_str("exec: path ERROR!",0x74);
printf("\x1b[31,47mexec: path ERROR!\x1b[m");
return -1;
}
@ -62,7 +58,8 @@ u32 sys_exec(char *path)
// 目前还没有实现 思路是数据、代码根据text_info和data_info属性决定释放深度其余内存段可以完全释放
/*************根据elf的program复制文件信息**************/
if(-1==exec_load(fd,Echo_Ehdr,Echo_Phdr)) return -1;//使用了const指针传递
if (-1 == exec_load(fd, Echo_Ehdr, Echo_Phdr))
return -1; // 使用了const指针传递
/*****************重新初始化该进程的进程表信息包括LDT、线性地址布局、进程树属性********************/
exec_pcb_init(path);
@ -87,7 +84,8 @@ u32 sys_exec(char *path)
if (err_temp != 0)
{
disp_color_str("kernel_main Error:lin_mapping_phy",0x74);
kprintf("\x1b[31;47mkernel_main Error:lin_mapping_phy\x1b[m");
return -1;
}
}
@ -99,9 +97,9 @@ u32 sys_exec(char *path)
if (Echo_Phdr != NULL)
sys_free(Echo_Phdr);
//disp_color_str("\n[exec success:",0x72);//灰底绿字
//disp_color_str(path,0x72);//灰底绿字
//disp_color_str("]",0x72);//灰底绿字
// kprintf("\n\x1b[32;47m[exec success:");//灰底绿字
// kprintf(path);//灰底绿字
// kpritff("]\x1b[m");//灰底绿字
return 0;
}
@ -147,7 +145,6 @@ static u32 exec_elfcpy(u32 fd,Elf32_Phdr Echo_Phdr,u32 attribute) // 这部分
return 0;
}
/*======================================================================*
* exec_load add by visual 2016.5.23
*elf的program复制文件信息
@ -158,7 +155,7 @@ static u32 exec_load(u32 fd,const Elf32_Ehdr* Echo_Ehdr,const Elf32_Phdr Echo_Ph
if (0 == Echo_Ehdr->e_phnum)
{
disp_color_str("exec_load: elf ERROR!",0x74);
kprintf("\x1b[31;47mexec_load: elf ERROR!\x1b[m", 0x74);
return -1;
}
@ -185,14 +182,13 @@ static u32 exec_load(u32 fd,const Elf32_Ehdr* Echo_Ehdr,const Elf32_Phdr Echo_Ph
}
else
{
disp_color_str("exec_load: unKnown elf'program!",0x74);
kprintf("\x1b[31;47mexec_load: unKnown elf'program!\x1b[m");
return -1;
}
}
return 0;
}
/*======================================================================*
* exec_init add by visual 2016.5.23
* 线
@ -247,5 +243,3 @@ static int exec_pcb_init(char* path)
return 0;
}

View File

@ -123,10 +123,14 @@ STATE OpenDir(const char* dirname)
if (strcmp(dirname, ".") == 0)
{
return OK;
}else if(strcmp(dirname,"..")==0||strcmp(dirname,"\\")==0){
}
else if (strcmp(dirname, "..") == 0 || strcmp(dirname, "\\") == 0)
{
ChangeCurrentPath((PCHAR)dirname);
return OK;
}else{
}
else
{
if (IsFullPath((PCHAR)dirname))
{
strcpy(fullpath, (PCHAR)dirname);
@ -139,7 +143,9 @@ STATE OpenDir(const char* dirname)
return OK;
}
GetNameFromPath(fullpath, name);
}else{
}
else
{
MakeFullPath(cur_path, (PCHAR)dirname, fullpath);
strcpy(parent, cur_path);
strcpy(name, (PCHAR)dirname);
@ -158,14 +164,15 @@ STATE OpenDir(const char* dirname)
{
strcpy(cur_path, fullpath);
return OK;
}else{
}
else
{
return WRONGPATH;
}
}
return OK;
}
STATE ReadFile(int fd, void *buf, int length)
{
int size = 0;
@ -179,7 +186,7 @@ STATE ReadFile(int fd,void *buf, int length)
return ACCESSDENIED;
}
disp_str("read:");
kprintf("read:");
if (pfile->off >= pfile->size)
{
return 0;
@ -197,17 +204,23 @@ STATE ReadFile(int fd,void *buf, int length)
if (pfile->size % Bytes_Per_Sector == 0)
{
free_in_sector = Bytes_Per_Sector - off_in_sector;
}else{
}
else
{
free_in_sector = pfile->size % Bytes_Per_Sector - off_in_sector; // 最后一个扇区的剩余量
}
tag = 1; // 置跳出标志
}else{
}
else
{
free_in_sector = Bytes_Per_Sector - off_in_sector; // 本扇区的剩余量
}
if (free_in_sector < length - (size)) // 缓冲区装不满
{
readsize = free_in_sector;
}else{//缓冲区能装满
}
else
{ // 缓冲区能装满
readsize = length - (size);
tag = 1; // 置跳出标志
}
@ -218,7 +231,9 @@ STATE ReadFile(int fd,void *buf, int length)
if (tag == 1) // 最后一个扇区或缓冲区装满了
{
break;
}else{//缓冲区还没装满并且还没到最后一个扇区
}
else
{ // 缓冲区还没装满并且还没到最后一个扇区
GetNextSector(pfile, curSectorIndex, &nextSectorIndex, &isLastSector);
curSectorIndex = nextSectorIndex;
off_in_sector = 0;
@ -259,7 +274,9 @@ STATE WriteFile(int fd, const void *buf, int length)
sys_free(sector);
return state; // 虚拟磁盘空间不足
}
}else{
}
else
{
if (NeedMoreCluster(pfile, length, &clusterNum))
{
state = AddCluster(pfile->start, clusterNum); // 空间不足
@ -309,7 +326,9 @@ STATE CloseFile(int fd)
if (pfile->flag == R)
{
return OK;
}else{
}
else
{
if (pfile->off < pfile->size)
{
GetFileOffset(pfile, &curSectorIndex, NULL, &isLastSector);
@ -351,8 +370,8 @@ STATE OpenFile(const char *filename,int mode)
GetNameFromPath(fullpath, name);
state = PathToCluster(parent, &parentCluster);
disp_str("\nstate=");
disp_int(state);
kprintf("\nstate=");
kprintf("%d", state);
if (state != OK)
{
return -1;
@ -364,7 +383,7 @@ STATE OpenFile(const char *filename,int mode)
{
if (state == NAMEEXIST) // 文件存在使用O_CREAT是多余的继续执行OpenFile即可
{
disp_str("file exists, O_CREAT is no use!");
kprintf("file exists, O_CREAT is no use!");
}
else // 文件不存在需要使用O_CREAT先创建文件再执行OpenFile
{
@ -376,36 +395,41 @@ STATE OpenFile(const char *filename,int mode)
{
if (state != NAMEEXIST) // 文件不存在需要使用O_CREAT用户没有使用则报错并返回-1表示路径有误
{
disp_str("no file, use O_CREAT!");
kprintf("no file, use O_CREAT!");
return -1;
}
else{} //文件存在使用O_CREAT是多余的继续执行OpenFile即可
else
{
} // 文件存在使用O_CREAT是多余的继续执行OpenFile即可
}
//~mingxuan 2019-5-19
state = ReadRecord(parentCluster, name, &record, NULL, NULL);
disp_str("state=");
disp_int(state);
kprintf("state=");
kprintf("%d", state);
if (state != OK)
{
disp_str("ReadRecord Fail!");
kprintf("ReadRecord Fail!");
return -1;
}
int i;
int fd = -1;
for (i = 3; i < NR_FILES; i++) {
if (p_proc_current->task.filp[i] == 0) {
for (i = 3; i < NR_FILES; i++)
{
if (p_proc_current->task.filp[i] == 0)
{
fd = i;
break;
}
}
if ((fd < 0) || (fd >= NR_FILES)) {
if ((fd < 0) || (fd >= NR_FILES))
{
// panic("filp[] is full (PID:%d)", proc2pid(p_proc_current));
disp_str("filp[] is full (PID:");
disp_int(proc2pid(p_proc_current));
disp_str(")\n");
kprintf("filp[] is full (PID:");
kprintf("%d", (int)proc2pid(p_proc_current));
kprintf(")\n");
return -1;
}
@ -413,10 +437,11 @@ STATE OpenFile(const char *filename,int mode)
for (i = 0; i < NR_FILE_DESC; i++)
if ((f_desc_table[i].flag == 0))
break;
if (i >= NR_FILE_DESC) {
disp_str("f_desc_table[] is full (PID:");
disp_int(proc2pid(p_proc_current));
disp_str(")\n");
if (i >= NR_FILE_DESC)
{
kprintf("f_desc_table[] is full (PID:");
kprintf("%d", (int)proc2pid(p_proc_current));
kprintf(")\n");
return -1;
}
@ -427,10 +452,11 @@ STATE OpenFile(const char *filename,int mode)
for (i = 0; i < NR_FILE_DESC; i++)
if (f_desc_table_fat[i].flag == 0)
break;
if (i >= NR_FILE_DESC) {
disp_str("f_desc_table[] is full (PID:");
disp_int(proc2pid(p_proc_current));
disp_str(")\n");
if (i >= NR_FILE_DESC)
{
kprintf("f_desc_table[] is full (PID:");
kprintf("%d", (int)proc2pid(p_proc_current));
kprintf(")\n");
}
// 以下是给File结构体赋值
@ -442,9 +468,9 @@ STATE OpenFile(const char *filename,int mode)
f_desc_table_fat[i].off = 0;
f_desc_table_fat[i].size = record.filelength;
f_desc_table_fat[i].flag = mode;
// disp_str("flag:");
// kprintf("flag:");
// deint(f_desc_table_fat[i].flag);
// disp_str("index:");
// kprintf("index:");
// deint(i);
p_proc_current->task.filp[fd]->fd_node.fd_file = &f_desc_table_fat[i];
@ -470,7 +496,8 @@ STATE CreateFile(const char *filename)
}
state = FindSpaceInDir(parentCluster, name, &sectorIndex, &off_in_sector);
if(state != OK) {
if (state != OK)
{
return state;
}
@ -544,7 +571,9 @@ STATE IsFile(PCHAR path,PUINT tag)
if (record.proByte == 0x10)
{
*tag = D;
}else{
}
else
{
*tag = F;
}
return OK;
@ -552,7 +581,7 @@ STATE IsFile(PCHAR path,PUINT tag)
void init_fs_fat()
{
disp_str("Initializing fat32 file system... \n");
kprintf("Initializing fat32 file system... \n");
buf = (u8 *)K_PHY2LIN(sys_kmalloc(FSBUF_SIZE));
@ -560,18 +589,21 @@ void init_fs_fat()
// load_disk(FAT_DEV); // deleted by mingxuan 2020-10-27
load_disk(fat32_dev); // modified by mingxuan 2020-10-27
if (TotalSectors == 0) {
if (TotalSectors == 0)
{
mkfs_fat();
// load_disk(FAT_DEV); //deleted by mingxuan 2020-10-27
load_disk(fat32_dev); // modified by mingxuan 2020-10-27
}
int i;
for (i = 0; i < NR_FILE_DESC; ++i) {
for (i = 0; i < NR_FILE_DESC; ++i)
{
f_desc_table_fat[i].flag = 0;
}
}
static void load_disk(int dev) {
static void load_disk(int dev)
{
MESSAGE driver_msg;
PCHAR cur = "V:\\";
@ -595,7 +627,8 @@ static void load_disk(int dev) {
strcpy(cur_path, cur);
}
static void mkfs_fat() {
static void mkfs_fat()
{
MESSAGE driver_msg;
int fat32_dev = get_fs_dev(PRIMARY_MASTER, FAT32_TYPE); // added by mingxuan 2020-10-27
@ -611,9 +644,9 @@ static void mkfs_fat() {
driver_msg.PROC_NR = proc2pid(p_proc_current);
hd_ioctl(&driver_msg);
disp_str("dev size: ");
disp_int(geo.size);
disp_str(" sectors\n");
kprintf("dev size: ");
kprintf("%d", geo.size);
kprintf(" sectors\n");
TotalSectors = geo.size;
@ -711,7 +744,8 @@ int sys_CreateFile(void *uesp)
{
kprintf(" create file success");
}
else {
else
{
DisErrorInfo(state);
}
@ -725,7 +759,8 @@ int sys_DeleteFile(void *uesp)
{
kprintf(" delete file success");
}
else {
else
{
DisErrorInfo(state);
}
return state;
@ -757,7 +792,8 @@ int sys_CloseFile(void *uesp)
{
kprintf(" close file success");
}
else {
else
{
DisErrorInfo(state);
}
return state;
@ -772,7 +808,8 @@ int sys_WriteFile(void *uesp)
{
kprintf(" write file success");
}
else {
else
{
DisErrorInfo(state);
}
return state;
@ -841,7 +878,8 @@ int sys_DeleteDir(void *uesp)
return 0;
}
int sys_ListDir(void *uesp) {
int sys_ListDir(void *uesp)
{
// DArray *array=NULL;
// char *s = get_arg(uesp, 1);
@ -870,7 +908,7 @@ int sys_ListDir(void *uesp) {
// DirCheckup(array);
// }else {
// DisErrorInfo(state);
// disp_str("\n");
// kprintf("\n");
// }
// DestroyDArray(array);
return 0;
@ -880,31 +918,30 @@ void DisErrorInfo(STATE state)
{
if (state == SYSERROR)
{
disp_str(" system error\n");
kprintf(" system error\n");
}
else if (state == VDISKERROR)
{
disp_str(" disk error\n");
kprintf(" disk error\n");
}
else if (state == INSUFFICIENTSPACE)
{
disp_str(" no much space\n");
kprintf(" no much space\n");
}
else if (state == WRONGPATH)
{
disp_str(" path error\n");
kprintf(" path error\n");
}
else if (state == NAMEEXIST)
{
disp_str(" name exists\n");
kprintf(" name exists\n");
}
else if (state == ACCESSDENIED)
{
disp_str(" deny access\n");
kprintf(" deny access\n");
}
else
{
disp_str(" unknown error\n");
kprintf(" unknown error\n");
}
}

View File

@ -15,7 +15,6 @@ static int fork_mem_cpy(u32 ppid,u32 pid);
static int fork_pcb_cpy(PROCESS *p_child);
static int fork_update_info(PROCESS *p_child);
/**********************************************************
* sys_fork //add by visual 2016.5.25
*sys_fork的具体实现部分
@ -29,7 +28,7 @@ int sys_fork()
p_child = alloc_PCB();
if (0 == p_child)
{
disp_color_str("PCB NULL,fork faild!",0x74);
kprintf("\x1b[31;47mPCB NULL,fork faild!\x1b[m");
return -1;
}
else
@ -65,7 +64,6 @@ int sys_fork()
return p_child->task.pid;
}
/**********************************************************
* fork_mem_cpy //add by visual 2016.5.24
*
@ -203,8 +201,6 @@ static int fork_pcb_cpy(PROCESS* p_child)
return 0;
}
/**********************************************************
* fork_update_info //add by visual 2016.5.26
*info

View File

@ -132,7 +132,8 @@ void initial()
do_vclose(stdout);
do_vclose(stderr);
exec("orange/shell_1.bin");
// exec("orange/shell_1.bin");
exec("orange/test.bin");
while (1)
;

View File

@ -204,7 +204,7 @@ static int initialize_processes()
/***************初始化PID进程页表*****************************/
if (0 != init_page_pte(pid))
{
disp_color_str("kernel_main Error:init_page_pte", 0x74);
kprintf("\x1b[31;47mkernel_main Error:init_page_pte\x1b[m");
return -1;
}
// pde_addr_phy_temp = get_pde_phy_addr(pid);//获取该进程页目录物理地址 //delete by visual 2016.5.19
@ -219,7 +219,7 @@ static int initialize_processes()
// addr_phy_temp = (u32)do_kmalloc_4k();//为栈申请一个物理页,Task的栈是在内核里面 //delete by visual 2016.5.19
// if( addr_phy_temp<0 || (addr_phy_temp&0x3FF)!=0 )
//{
// disp_color_str("kernel_main Error:addr_phy_temp",0x74);
// kprintf("\x1b[31;47mkernel_main Error:addr_phy_temp\x1b[m");
// return -1;
// }
err_temp = lin_mapping_phy(AddrLin, // 线性地址 //add by visual 2016.5.9
@ -229,7 +229,7 @@ static int initialize_processes()
PG_P | PG_USU | PG_RWW); // 页表的属性位
if (err_temp != 0)
{
disp_color_str("kernel_main Error:lin_mapping_phy", 0x74);
kprintf("\x1b[31;47mkernel_main Error:lin_mapping_phy\x1b[m");
return -1;
}
}
@ -357,7 +357,7 @@ static int initialize_processes()
/***************初始化PID进程页表*****************************/
if (0 != init_page_pte(pid))
{
disp_color_str("kernel_main Error:init_page_pte", 0x74);
kprintf("\x1b[mkernel_main Error:init_page_pte\x1b[m");
return -1;
}
// pde_addr_phy_temp = get_pde_phy_addr(pid);//获取该进程页目录物理地址 //edit by visual 2016.5.19
@ -372,7 +372,7 @@ static int initialize_processes()
// addr_phy_temp = (u32)do_kmalloc_4k();//为栈申请一个物理页,Task的栈是在内核里面 //delete by visual 2016.5.19
// if( addr_phy_temp<0 || (addr_phy_temp&0x3FF)!=0 )
//{
// disp_color_str("kernel_main Error:addr_phy_temp",0x74);
// kprintf("\x1b[31;47mkernel_main Error:addr_phy_temp\x1b[m");
// return -1;
// }
err_temp = lin_mapping_phy(AddrLin, // 线性地址
@ -382,7 +382,7 @@ static int initialize_processes()
PG_P | PG_USU | PG_RWW); // 页表的属性位
if (err_temp != 0)
{
disp_color_str("kernel_main Error:lin_mapping_phy", 0x74);
kprintf("\x1b[31;47mkernel_main Error:lin_mapping_phy\x1b[m");
return -1;
}
}

View File

@ -40,7 +40,7 @@ u32 init_page_pte(u32 pid)
if (pde_addr_phy_temp < 0 || (pde_addr_phy_temp & 0x3FF) != 0) // add by visual 2016.5.9
{
disp_color_str("init_page_pte Error:pde_addr_phy_temp", 0x74);
kprintf("\x1b[31;47minit_page_pte Error:pde_addr_phy_temp\x1b[m");
return -1;
}
@ -57,7 +57,7 @@ u32 init_page_pte(u32 pid)
PG_P | PG_USS | PG_RWW); // 页表的属性位(系统权限) //edit by visual 2016.5.17
if (err_temp != 0)
{
disp_color_str("init_page_pte Error:lin_mapping_phy", 0x74);
kprintf("\x1b[31;47minit_page_pte Error:lin_mapping_phy\x1b[m");
return -1;
}
}
@ -278,7 +278,7 @@ int lin_mapping_phy(u32 AddrLin, //线性地址
if (pte_addr_phy < 0 || (pte_addr_phy & 0x3FF) != 0) // add by visual 2016.5.9
{
disp_color_str("lin_mapping_phy Error:pte_addr_phy", 0x74);
kprintf("\x1b[31;47mlin_mapping_phy Error:pte_addr_phy\x1b[m");
return -1;
}
@ -301,7 +301,6 @@ int lin_mapping_phy(u32 AddrLin, //线性地址
phy_addr = do_kmalloc_4k(); // 从内核物理地址申请一页
else
{
// disp_str("%");
phy_addr = do_malloc_4k(); // 从用户物理地址空间申请一页
}
}
@ -318,7 +317,7 @@ int lin_mapping_phy(u32 AddrLin, //线性地址
if (phy_addr < 0 || (phy_addr & 0x3FF) != 0)
{
disp_color_str("lin_mapping_phy:phy_addr ERROR", 0x74);
kprintf("\x1b[31;47mlin_mapping_phy:phy_addr ERROR\x1b[m");
return -1;
}

View File

@ -13,12 +13,10 @@
#include "proto.h"
#include "string.h"
/* 本文件内函数声明 */
static void init_idt_desc(unsigned char vector, u8 desc_type, int_handler handler, unsigned char privilege);
static void init_descriptor(DESCRIPTOR *p_desc, u32 base, u32 limit, u16 attribute);
/* 中断处理函数 */
void divide_error();
void single_step_exception();
@ -53,7 +51,6 @@ void hwint13();
void hwint14();
void hwint15();
/*======================================================================*
init_prot
*----------------------------------------------------------------------*
@ -182,7 +179,8 @@ void init_prot()
int i;
PROCESS *p_proc = proc_table;
u16 selector_ldt = INDEX_LDT_FIRST << 3;
for(i=0;i<NR_PCBS;i++){ //edit by visual 2016.4.5
for (i = 0; i < NR_PCBS; i++)
{ // edit by visual 2016.4.5
init_descriptor(&gdt[selector_ldt >> 3],
vir2phys(seg2phys(SELECTOR_KERNEL_DS), proc_table[i].task.ldts),
LDT_SIZE * sizeof(DESCRIPTOR) - 1,
@ -192,7 +190,6 @@ void init_prot()
}
}
/*======================================================================*
init_idt_desc
*----------------------------------------------------------------------*
@ -209,7 +206,6 @@ void init_idt_desc(unsigned char vector, u8 desc_type, int_handler handler, unsi
p_gate->offset_high = (base >> 16) & 0xFFFF;
}
/*======================================================================*
seg2phys
*----------------------------------------------------------------------*
@ -266,33 +262,34 @@ static void init_descriptor(DESCRIPTOR * p_desc, u32 base, u32 limit, u16 attrib
"#MF x87 FPU Floating-Point Error (Math Fault)",
"#AC Alignment Check",
"#MC Machine Check",
"#XF SIMD Floating-Point Exception"
};
"#XF SIMD Floating-Point Exception"};
/* 通过打印空格的方式清空屏幕的前五行,并把 disp_pos 清零 */
disp_pos = 0;
for(i=0;i<80*5;i++){
disp_str(" ");
for (i = 0; i < 80 * 5; i++)
{
printf(" ");
}
disp_pos = 0;
disp_color_str("Exception! --> ", text_color);
disp_color_str(err_description[vec_no], text_color);
disp_color_str("\n\n", text_color);
disp_color_str("EFLAGS:", text_color);
disp_int(eflags);
disp_color_str("CS:", text_color);
disp_int(cs);
disp_color_str("EIP:", text_color);
disp_int(eip);
printf("\x1b[31;47mException! --> ");
printf(err_description[vec_no]);
printf("\n\n");
printf("EFLAGS:\x1b[m");
printf("%d", eflags);
printf("\x1b[31;47mCS:\x1b[m");
printf("%d", cs);
printf("\x1b[31;47mEIP:\x1b[m");
printf("%d", eip);
if(err_code != 0xFFFFFFFF){
disp_color_str("Error code:", text_color);
disp_int(err_code);
if (err_code != 0xFFFFFFFF)
{
printf("\x1b[31;47mError code:\x1b[m");
printf("%d", err_code);
}
// added by xw, 18/12/19
disp_str("\n");
printf("\n");
// added by xw, 18/12/19
p_proc_current->task.stat = KILLED;
@ -314,21 +311,20 @@ static void init_descriptor(DESCRIPTOR * p_desc, u32 base, u32 limit, u16 attrib
"mov 20(%%ebp), %3\n\t" // get cs from stack
"mov 24(%%ebp), %4\n\t" // get eflags from stack
: "=r"(vec_no), "=r"(err_code), "=r"(eip),
"=r"(cs), "=r"(eflags)
);
"=r"(cs), "=r"(eflags));
exception_handler(vec_no, err_code, eip, cs, eflags);
while (1)
{
disp_str("Loop in divide error handler...\n");
printf("Loop in divide error handler...\n");
i = 100;
while(--i){
while (--i)
{
j = 1000;
while(--j){}
while (--j)
{
}
}
}
}

View File

@ -27,16 +27,16 @@ int sys_pthread(void *entry)
/*if(p_proc_current->task.info.type == TYPE_THREAD )
{//线程不能创建线程
disp_color_str("[pthread failed:",0x74);
disp_color_str(p_proc_current->task.p_name,0x74);
disp_color_str("]",0x74);
printf("\x1b[31;47m[pthread failed:");
printf(p_proc_current->task.p_name);
printf("]\x1b[m");
return -1;
}*/
/*****************申请空白PCB表**********************/
p_child = alloc_PCB();
if (0 == p_child)
{
disp_color_str("PCB NULL,pthread faild!",0x74);
printf("\x1b[31;47mPCB NULL,pthread faild!\x1b[m");
return -1;
}
else
@ -78,9 +78,9 @@ int sys_pthread(void *entry)
/****************用户进程数+1****************************/
u_proc_sum += 1;
disp_color_str("[pthread success:",0x72);
disp_color_str(p_proc_current->task.p_name,0x72);
disp_color_str("]",0x72);
printf("\x1b[32;47m[pthread success:");
printf(p_proc_current->task.p_name);
printf("]\x1b[m");
// anything child need is prepared now, set its state to ready. added by xw, 17/12/11
p_child->task.stat = READY;
@ -88,7 +88,6 @@ int sys_pthread(void *entry)
return p_child->task.pid;
}
/**********************************************************
* pthread_pcb_cpy //add by visual 2016.5.26
*PCB表
@ -140,8 +139,6 @@ static int pthread_pcb_cpy(PROCESS *p_child,PROCESS *p_parent)
return 0;
}
/**********************************************************
* pthread_update_info //add by visual 2016.5.26
*线info

View File

@ -21,15 +21,18 @@ void sys_print_E()
{
int i, j;
disp_str("E( ");
printf("E( ");
i = 100;
while(--i){
while (--i)
{
j = 1000;
while(--j){}
while (--j)
{
}
}
disp_str(") ");
printf(") ");
}
/*
@ -41,13 +44,16 @@ void sys_print_F()
{
int i, j;
disp_str("F( ");
printf("F( ");
i = 100;
while(--i){
while (--i)
{
j = 1000;
while(--j){}
while (--j)
{
}
}
disp_str(") ");
printf(") ");
}

View File

@ -357,7 +357,7 @@ static void set_color(vga_buf *vgabuf)
{
warn("unsupport CSI: color");
}
if (vgabuf->CSI == CSI_PARAM2)
if (vgabuf->Is2param == true)
{
if (vgabuf->param2 == 0 && vgabuf->param1 == 0)
{
@ -564,6 +564,7 @@ void vga_tty_write(NTTY *tty, char ch)
break;
case '\x1b':
vga->CSI = CSI_BRACKET;
vga->Is2param = false;
break;
default:
if (vga->color == 0)
@ -615,6 +616,7 @@ void vga_tty_write(NTTY *tty, char ch)
break;
case ';':
vga->CSI = CSI_PARAM2;
vga->Is2param = true;
break;
default:
if (!(0x20 <= ch && ch <= 0x7e))

View File

@ -6,21 +6,14 @@
#include "tty.h"
#include "serialport.h"
static void serialputch(int ch, void * cnt) {
write_serial(ch);
// char _ch = ch;
// tty_write(cur_ntty, &_ch, 1);
}
static void
kprintfputch(int ch, void *b)
static void serialputch(int ch, void *cnt)
{
char buf[2]={(char)ch,'\0'};
disp_str(buf);
// write_serial(ch);
char _ch = ch;
tty_write(cur_ntty, &_ch, 1);
}
int
vkprintf(const char *fmt, va_list ap)
int vkprintf(const char *fmt, va_list ap)
{
// vprintfmt((void*)kprintfputch, NULL, fmt, ap);
@ -29,8 +22,7 @@ vkprintf(const char *fmt, va_list ap)
return 0;
}
int
kprintf(const char *fmt, ...)
int kprintf(const char *fmt, ...)
{
va_list ap;
int rc;

View File

@ -34,16 +34,18 @@ int main(int arg, char *argv[])
// printf("8888888888");
// printf("9999999999\r\b\b\n");
// }
printf("\x1b[36m");
printf("\x1b[33m");
for (int i = 0; i < 40; i++)
{
printf("%d", i);
printf("11111111111111111\n");
}
printf("\x1b[31;47mexec: path ERROR!\x1b[m");
printf("555555");
// Cursor Up
printf("\x1b[2A");
// printf("\x1b[2A");
// Cursor down
// printf("\x1b[2B");
@ -52,7 +54,7 @@ int main(int arg, char *argv[])
// printf("\x1b[20C");
// Cursor Back
printf("\x1b[2D");
// printf("\x1b[2D");
// Cursor Next Line
// printf("\x1b[3E");
@ -70,7 +72,7 @@ int main(int arg, char *argv[])
// printf("\x1b[3J");
// Erase in Line
printf("\x1b[K");
// printf("\x1b[K");
// Scroll Up
// printf("\x1b[13S");