diff --git a/Makefile b/Makefile index d51bd55..2cf31f5 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ OBJDUMP := objdump # 查询可重定位文件符号表 NM := nm -DEFS := -D USE_FBCON +DEFS := # gcc的相关命令参数 # $(DEFS) 定义一些可能的参数 @@ -182,4 +182,4 @@ $(OBJDIR)/.deps: $(foreach dir, $(OBJDIRS), $(wildcard $(OBJDIR)/$(dir)/*.d)) -include $(OBJDIR)/.deps -.PHONY: all clean run gdb gdb-no-graphic monitor disassemble \ No newline at end of file +.PHONY: all clean run gdb gdb-no-graphic monitor disassemble diff --git a/kernel/bga.c b/kernel/bga.c index 84986fa..cd0a4e4 100644 --- a/kernel/bga.c +++ b/kernel/bga.c @@ -112,7 +112,7 @@ int init_bga(pci_dev_t *dev) { } bga_buf_paddr = pci_read_bar(dev, 0) & 0xfffffff0; - bga_set_resolution(800, 600); + bga_set_resolution(1024, 768); kprintf("bga buf paddr=%p; buf size= %d KB\n", bga_buf_paddr, bga_screen_buffer_size / 1024); kprintf("bga mapped in kernel cr3=%p\n", read_cr3()); diff --git a/kernel/exec.c b/kernel/exec.c index b8681bb..e6ba753 100644 --- a/kernel/exec.c +++ b/kernel/exec.c @@ -141,6 +141,7 @@ static u32 exec_elfcpy(u32 fd, Elf32_Phdr Echo_Phdr, u32 attribute) // 这部分 // 已初始化数据段拷贝完毕,剩下的是未初始化的数据段,在内存中填0 *((u8 *)lin_addr) = 0; // memset((void*)lin_addr,0,1); } + if (!(lin_addr & 0x3f)) kprintf("."); } return 0; } @@ -158,6 +159,7 @@ static u32 exec_load(u32 fd, const Elf32_Ehdr *Echo_Ehdr, const Elf32_Phdr Echo_ kprintf("\x1b[31;47mexec_load: elf ERROR!\x1b[m", 0x74); return -1; } + kprintf("loading elf from file"); // 我们还不能确定elf中一共能有几个program,但就目前我们查看过的elf文件中,只出现过两中program,一种.text(R-E)和一种.data(RW-) for (ph_num = 0; ph_num < Echo_Ehdr->e_phnum; ph_num++) @@ -186,6 +188,7 @@ static u32 exec_load(u32 fd, const Elf32_Ehdr *Echo_Ehdr, const Elf32_Phdr Echo_ return -1; } } + kprintf("[\x1b[32mok\x1b[0m]\n"); return 0; } diff --git a/kernel/ktest.c b/kernel/ktest.c index 9ebf2aa..59bcafb 100644 --- a/kernel/ktest.c +++ b/kernel/ktest.c @@ -151,9 +151,9 @@ void initial() do_vclose(stdout); do_vclose(stderr); #ifdef USE_FBCON - exec("orange/shell_0.bin"); + exec("orange/shell_chn.bin"); #else - exec("orange/shell_1.bin"); + exec("orange/shell_mix.bin"); #endif while (1) ; diff --git a/lib/kprintf.c b/lib/kprintf.c index 003ade1..3e72a88 100644 --- a/lib/kprintf.c +++ b/lib/kprintf.c @@ -10,8 +10,8 @@ static void kprintfputch(int ch, int *cnt) { write_serial(ch); #ifndef USE_FBCON - char _ch = ch; - tty_write(cur_ntty, &_ch, 1); + // char _ch = ch; + //tty_write(cur_ntty, &_ch, 1); #endif (*cnt)++; } diff --git a/user/Makefrag b/user/Makefrag index 18b2e3e..66537ae 100644 --- a/user/Makefrag +++ b/user/Makefrag @@ -6,11 +6,13 @@ USERLIB_OBJS := $(patsubst %.c, $(OBJDIR)/%.o, $(USERLIB_SRCS)) USERLIB_OBJS := $(patsubst %.asm, $(OBJDIR)/%.o, $(USERLIB_OBJS)) # 这里给我整不会了,文件名只能长度为16位,否则会寄,原因还挺难找 -USER_SRCS := user/shell_1.c \ - user/shell_0.c \ - user/test.c \ - user/test2.c \ - user/chtest.c \ +USER_SRCS := user/shell_2con.c \ + user/shell_chn.c \ + user/shell_mix.c \ + user/shell_uart.c \ + user/test2con.c \ + user/testchn.c \ + user/testscr.c \ USER_BINS := $(patsubst %.c, $(OBJDIR)/%.bin, $(USER_SRCS)) USER_BASENAMES := $(patsubst $(OBJDIR)/user/%, %, $(USER_BINS)) diff --git a/user/ptTest.c b/user/ptTest.c deleted file mode 100644 index 8c169b0..0000000 --- a/user/ptTest.c +++ /dev/null @@ -1,41 +0,0 @@ -#include "stdio.h" - -int global=0; - -char *str2,*str3; - - -void pthread_test1() -{ - int i; - //pthread(pthread_test2); - while(1) - { - printf("pth1"); - printf("%d",++global); - printf(" "); - i=10000000; - while(--i){} - } -} - -/*======================================================================* - Syscall Pthread Test -added by xw, 18/4/27 - *======================================================================*/ - -int main(int arg,char *argv[]) -{ - int i=0; - - pthread(pthread_test1); - while(1) - { - printf("init"); - printf("%d",++global); - printf(" "); - i=10000000; - while(--i){} - } - return 0; -} diff --git a/user/shell_1.c b/user/shell_2con.c similarity index 97% rename from user/shell_1.c rename to user/shell_2con.c index b6914f6..21b189a 100644 --- a/user/shell_1.c +++ b/user/shell_2con.c @@ -43,7 +43,6 @@ int main(int arg, char *argv[]) printf("\nminiOS:/ $ "); if (gets(buf) && strlen(buf) != 0) { - printf("received\n"); if (exec(buf) != 0) { printf("exec failed: file not found!\n"); diff --git a/user/shell_0.c b/user/shell_chn.c similarity index 100% rename from user/shell_0.c rename to user/shell_chn.c diff --git a/user/shell_mix.c b/user/shell_mix.c new file mode 100644 index 0000000..3eb018d --- /dev/null +++ b/user/shell_mix.c @@ -0,0 +1,31 @@ +#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_tty2", O_RDWR); + int stdout = open("dev_tty0", O_RDWR); + int stderr = open("dev_tty0", O_RDWR); + + char buf[1024]; + int pid; + int times = 0; + while (1) + { + printf("miniOS:/ $ "); + if (gets(buf) && strlen(buf) != 0) + { + if (exec(buf) != 0) + { + printf("exec failed: file not found!\n"); + continue; + } + } + } +} \ No newline at end of file diff --git a/user/shell_uart.c b/user/shell_uart.c new file mode 100644 index 0000000..7e69ded --- /dev/null +++ b/user/shell_uart.c @@ -0,0 +1,31 @@ +#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_tty2", O_RDWR); + int stdout = open("dev_tty2", O_RDWR); + int stderr = open("dev_tty2", O_RDWR); + + char buf[1024]; + int pid; + int times = 0; + while (1) + { + printf("\nminiOS:/ $ "); + if (gets(buf) && strlen(buf) != 0) + { + if (exec(buf) != 0) + { + printf("exec failed: file not found!\n"); + continue; + } + } + } +} \ No newline at end of file diff --git a/user/test.c b/user/test.c deleted file mode 100644 index 8b4e992..0000000 --- a/user/test.c +++ /dev/null @@ -1,86 +0,0 @@ -#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); - - char buf[1024]; - int pid; - int times = 0; - for (int i = 0; i < 50; ++i) - { - printf("test %d\n", i); - for (int j = 0; j < 2000000; ++ j); - } - // for (int i = 0; i < 2; ++i) - // { - // printf("\x1b[42;31m1111111111"); - // // printf("\x1b[m1111111111"); - // printf("2222222222"); - // printf("3333333333"); - // printf("4444444444"); - // printf("5555555555"); - // printf("6666666666"); - // printf("7777777777"); - // // printf("\x1b[5F"); - // printf("8888888888"); - // printf("9999999999\r\b\b\n"); - // } - printf("\x1b[33m"); - - for (int i = 0; i < 40; i++) - { - printf("%d", i); - printf("11111111111111111\n"); - } - printf("\x1b[31;47m555555555555\x1b[m"); - - // Cursor Up - // printf("\x1b[2A"); - - // Cursor down - // printf("\x1b[2B"); - - // Cursor Forward - // printf("\x1b[20C"); - - // Cursor Back - // printf("\x1b[2D"); - - // Cursor Next Line - // printf("\x1b[3E"); - - // Cursor Previous Line - // printf("\x1b[3F"); - - // Cursor Horizontal Absolute - // printf("\x1b[2G"); - - // Cursor Position ; H or f - // printf("\x1b[3;5H"); - - // Erase in Display - // printf("\x1b[3J"); - - // Erase in Line - // printf("\x1b[K"); - - // Scroll Up - // printf("\x1b[13S"); - - // Scroll Down - // printf("\x1b[13T"); - - while (1) - ; - return 0; -} diff --git a/user/test2.c b/user/test2con.c similarity index 100% rename from user/test2.c rename to user/test2con.c diff --git a/user/chtest.c b/user/testchn.c similarity index 100% rename from user/chtest.c rename to user/testchn.c diff --git a/user/testscr.c b/user/testscr.c new file mode 100644 index 0000000..57e04b0 --- /dev/null +++ b/user/testscr.c @@ -0,0 +1,29 @@ +#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); + + for (int i = 0; i < 40; i++) + { + printf("%02d ", i); + } + for (int i = 0; i < 50; ++i) + { + printf("test %d\n", i); + for (int j = 0; j < 2000000; ++ j); + } + + while (1) + ; + return 0; +}