From 329b5c86587a0eead99fb9c7999e13a87b0daf60 Mon Sep 17 00:00:00 2001 From: YanB25 Date: Tue, 3 Apr 2018 19:32:03 +0800 Subject: [PATCH 1/6] modify a lot of file to support stoneQ - Makefiles. - move stone.c directory - change name to stoneQ to datablock --- step_3/Makefile | 7 ++++--- step_3/filesystem/datablock.c | 2 +- step_3/kernel/Makefile | 6 +++++- step_3/user/Makefile | 12 ++++++------ step_3/user/stone.h | 4 ---- step_3/user/{ => stone}/stone.c | 15 ++++++++------- step_3/user/stone/stone.h | 19 +++++++++++++++++++ step_3/user/terminal.c | 1 - 8 files changed, 43 insertions(+), 23 deletions(-) delete mode 100644 step_3/user/stone.h rename step_3/user/{ => stone}/stone.c (73%) create mode 100644 step_3/user/stone/stone.h diff --git a/step_3/Makefile b/step_3/Makefile index bc292f6..edfc7c3 100644 --- a/step_3/Makefile +++ b/step_3/Makefile @@ -11,7 +11,8 @@ LOADER=loader ROOT=.. FILESYSTEM=filesystem USER=user -all: $(USER)/stone.bin $(KERNEL)/kernel.bin $(LOADER)/loader.bin build cleangch +STONE=stone +all: $(USER)/$(STONE)/stoneQ.bin $(KERNEL)/kernel.bin $(LOADER)/loader.bin build cleangch $(KERNEL)/kernel.bin: echo "\n" @@ -43,7 +44,7 @@ $(FILESYSTEM)/datablock.bin: cd $(FILESYSTEM)/ && make cd $(ROOT)/ -$(USER)/stone.bin: +$(USER)/$(STONE)/stoneQ.bin: echo "\n" cd $(USER)/ && make cd $(ROOT)/ @@ -56,7 +57,7 @@ build: $(LOADER)/loader.bin $(FILESYSTEM)/DBR.bin $(FILESYSTEM)/FAT.bin $(FILESY dd if=$(FILESYSTEM)/FAT.bin of=OS.img conv=notrunc oflag=seek_bytes seek=3584 dd if=$(FILESYSTEM)/datablock.bin of=OS.img conv=notrunc oflag=seek_bytes seek=6656 dd if=$(KERNEL)/kernel.bin of=OS.img conv=notrunc oflag=seek_bytes seek=7680 - dd if=$(USER)/stone.bin of=OS.img conv=notrunc oflag=seek_bytes seek=12800 + dd if=$(USER)/$(STONE)/stoneQ.bin of=OS.img conv=notrunc oflag=seek_bytes seek=12800 clean: echo "\n" find . -name "*.bin" -type f -delete diff --git a/step_3/filesystem/datablock.c b/step_3/filesystem/datablock.c index 6b663c7..98bdb07 100644 --- a/step_3/filesystem/datablock.c +++ b/step_3/filesystem/datablock.c @@ -64,7 +64,7 @@ FAT_ITEM msg = { 0 }; FAT_ITEM user_program = { - "stone", + "stoneQ", "bin", FAT_rw, 0, 0, 0, 0, 0, 0, diff --git a/step_3/kernel/Makefile b/step_3/kernel/Makefile index 38e73cc..b25f927 100644 --- a/step_3/kernel/Makefile +++ b/step_3/kernel/Makefile @@ -9,9 +9,10 @@ ROOT=.. INCLUDE=../include USER=../user FILESYSTEM=../filesystem +STONE=stone USER_HEADER=$(USER)/user.h $(USER)/terminal.h -USER_OBJ=$(USER)/user.o $(USER)/terminal.o $(USER)/stone.o +USER_OBJ=$(USER)/user.o $(USER)/terminal.o $(USER)/$(STONE)/stoneQ.o all: kernel.bin @@ -31,6 +32,9 @@ $(INCLUDE)/mystring.o: $(FILESYSTEM)/fsutilities.o: cd $(FILESYSTEM)/ && make cd ../kernel +$(USER)/$(STONE)/stoneQ.o: + cd $(USER)/ && make + cd ../kernel clean: rm *.bin -f rm *.o -f diff --git a/step_3/user/Makefile b/step_3/user/Makefile index 7c919c5..02bffd4 100644 --- a/step_3/user/Makefile +++ b/step_3/user/Makefile @@ -6,18 +6,18 @@ AS=nasm ASFLAGS= UTILITIES=../include - -all: user.o terminal.o stone.bin +STONE=stone +all: user.o terminal.o $(STONE)/stoneQ.bin user.o: user.c $(UTILITIES)/utilities.h $(CC) $(CCFLAGS) -c $^ -terminal.o: terminal.c $(UTILITIES)/utilities.h stone.h +terminal.o: terminal.c $(UTILITIES)/utilities.h $(CC) $(CCFLAGS) -c $^ -stone.bin: stone.o $(UTILITIES)/utilities.o +$(STONE)/stoneQ.bin: $(STONE)/stoneQ.o $(UTILITIES)/utilities.o $(LD) $(LDFLAGS) -Ttext 0x6C00 --oformat binary -o $@ $^ -stone.o: stone.c $(UTILITIES)/utilities.h - $(CC) $(CCFLAGS) -c $^ +$(STONE)/stoneQ.o: $(STONE)/stone.c $(UTILITIES)/utilities.h + $(CC) $(CCFLAGS) -c $< -D UL -o $@ $(UTILITIES)/utilities.o: cd $(UTILITIES)/ && make diff --git a/step_3/user/stone.h b/step_3/user/stone.h deleted file mode 100644 index de5ced0..0000000 --- a/step_3/user/stone.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef __STONE_H_ -#define __STONE_H_ -int stone(); -#endif \ No newline at end of file diff --git a/step_3/user/stone.c b/step_3/user/stone/stone.c similarity index 73% rename from step_3/user/stone.c rename to step_3/user/stone/stone.c index a4fe954..3d8982b 100644 --- a/step_3/user/stone.c +++ b/step_3/user/stone/stone.c @@ -1,6 +1,7 @@ __asm__("jmpl $0, $stone\n"); -#include "../include/utilities.h" +#include "../../include/utilities.h" +#include "stone.h" #define DELAY (1e5) int getKbHit(); void checkBound(); @@ -11,8 +12,8 @@ int deltax; int deltay; int stone() { // return 0; - x = 5; - y = 5; + x = _X; + y = _Y; deltax = 1; deltay = 1; @@ -41,8 +42,8 @@ int getKbHit() { return 0; } void checkBound() { - if (x == 0) deltax = 1; - if (x == 79) deltax = -1; - if (y == 0) deltay = 1; - if (y == 24) deltay = -1; + if (x <= LEFT_B) deltax = 1; + if (x >= RIGHT_B) deltax = -1; + if (y <= UP_B) deltay = 1; + if (y >= DOWN_B) deltay = -1; } \ No newline at end of file diff --git a/step_3/user/stone/stone.h b/step_3/user/stone/stone.h new file mode 100644 index 0000000..43b7d0d --- /dev/null +++ b/step_3/user/stone/stone.h @@ -0,0 +1,19 @@ +#ifndef __STONE_H_ +#define __STONE_H_ +#if defined(UL) + #define _X 5 + #define _Y 5 + #define LEFT_B 1 + #define RIGHT_B 40 + #define UP_B 1 + #define DOWN_B 12 +#elif defined(UR) + #define _X 70 + #define _Y 5 + #define LEFT_B 40 + #define RIGHT_B 79 + #define UP_B 1 + #define DOWN_B 12 +#endif + +#endif \ No newline at end of file diff --git a/step_3/user/terminal.c b/step_3/user/terminal.c index 579e9c0..1b764cd 100644 --- a/step_3/user/terminal.c +++ b/step_3/user/terminal.c @@ -1,6 +1,5 @@ #include "../include/utilities.h" #include "../include/mystring.h" -#include "stone.h" #include "../filesystem/API/fsapi.h" #define BACK_SPACE 8 From 17c148a1a5e38557d8545df2790f0d1ba6fb0c19 Mon Sep 17 00:00:00 2001 From: YanB25 Date: Tue, 3 Apr 2018 19:55:27 +0800 Subject: [PATCH 2/6] finish building stoneW fixs bugs that do not link properly in fat - README.md: change README.md in fs to record - makefile: modify a lot of makefile - FAT.c: bug fix. not allocate memory for stoneQ --- step_3/Makefile | 11 +++++++++-- step_3/filesystem/FAT.c | 14 +++++++++++++- step_3/filesystem/README.md | 1 + step_3/filesystem/datablock.c | 13 ++++++++++++- step_3/kernel/Makefile | 2 +- step_3/user/Makefile | 12 +++++++++++- step_3/user/terminal.c | 3 +++ 7 files changed, 50 insertions(+), 6 deletions(-) diff --git a/step_3/Makefile b/step_3/Makefile index edfc7c3..933af34 100644 --- a/step_3/Makefile +++ b/step_3/Makefile @@ -12,7 +12,8 @@ ROOT=.. FILESYSTEM=filesystem USER=user STONE=stone -all: $(USER)/$(STONE)/stoneQ.bin $(KERNEL)/kernel.bin $(LOADER)/loader.bin build cleangch +STONE_OBJ=$(USER)/$(STONE)/stoneQ.bin $(USER)/$(STONE)/stoneW.bin +all: $(STONE_OBJ) $(KERNEL)/kernel.bin $(LOADER)/loader.bin build cleangch $(KERNEL)/kernel.bin: echo "\n" @@ -48,8 +49,13 @@ $(USER)/$(STONE)/stoneQ.bin: echo "\n" cd $(USER)/ && make cd $(ROOT)/ +$(USER)/$(STONE)/stoneW.bin: + echo "\n" + cd $(USER)/ && make + cd $(ROOT)/ + -build: $(LOADER)/loader.bin $(FILESYSTEM)/DBR.bin $(FILESYSTEM)/FAT.bin $(FILESYSTEM)/datablock.bin +build: $(LOADER)/loader.bin $(FILESYSTEM)/DBR.bin $(FILESYSTEM)/FAT.bin $(FILESYSTEM)/datablock.bin $(STONE_OBJ) echo "\n" dd if=$(LOADER)/loader.bin of=OS.img conv=notrunc dd if=$(FILESYSTEM)/DBR.bin of=OS.img conv=notrunc oflag=seek_bytes seek=512 @@ -58,6 +64,7 @@ build: $(LOADER)/loader.bin $(FILESYSTEM)/DBR.bin $(FILESYSTEM)/FAT.bin $(FILESY dd if=$(FILESYSTEM)/datablock.bin of=OS.img conv=notrunc oflag=seek_bytes seek=6656 dd if=$(KERNEL)/kernel.bin of=OS.img conv=notrunc oflag=seek_bytes seek=7680 dd if=$(USER)/$(STONE)/stoneQ.bin of=OS.img conv=notrunc oflag=seek_bytes seek=12800 + dd if=$(USER)/$(STONE)/stoneW.bin of=OS.img conv=notrunc oflag=seek_bytes seek=14848 clean: echo "\n" find . -name "*.bin" -type f -delete diff --git a/step_3/filesystem/FAT.c b/step_3/filesystem/FAT.c index cd92d65..5c3d56f 100644 --- a/step_3/filesystem/FAT.c +++ b/step_3/filesystem/FAT.c @@ -15,5 +15,17 @@ FAT_ITEM_T fat_items[] = { 0xFFFF, // 11 0xFFFF, // 12 0xFFFF, // 13 - 0xFFFF, //14 + 0x000F, // 14 + 0x0010, // 15 + 0x0011, // 16 + 0xFFFF, // 17 + 0x0013, // 18 + 0x0014, // 19 + 0x0015, // 20 + 0xFFFF, // 21 + 0xFFFF, // 22 + 0xFFFF, // 23 + 0xFFFF, // 24 + 0xFFFF, // 25 + 0xFFFF, // 26 }; diff --git a/step_3/filesystem/README.md b/step_3/filesystem/README.md index ec42b31..585f69d 100644 --- a/step_3/filesystem/README.md +++ b/step_3/filesystem/README.md @@ -11,6 +11,7 @@ FAT表2 8-11扇区(4个)512*7 = 3584 [e00~1600] home/ 24 [2e00~3000] msg 25 [3000~3200] 用户程序 26-29 512*25=12800 [3200~3a00] +用户程序w 30-33 512*29=14848 [3a00~4200] ## 软盘结构 ; 磁道 面 扇区 ; 0~79 0~1 1~18 diff --git a/step_3/filesystem/datablock.c b/step_3/filesystem/datablock.c index 98bdb07..9ec1397 100644 --- a/step_3/filesystem/datablock.c +++ b/step_3/filesystem/datablock.c @@ -63,7 +63,7 @@ FAT_ITEM msg = { 13, 0 }; -FAT_ITEM user_program = { +FAT_ITEM user_programQ = { "stoneQ", "bin", FAT_rw, @@ -72,4 +72,15 @@ FAT_ITEM user_program = { 0, 14, 512*4 // 4 sectors +}; + +FAT_ITEM user_programW = { + "stoneW", + "bin", + FAT_rw, + 0, 0, 0, 0, 0, 0, + 0, + 0, + 18, + 512*4 // 4 sectors }; \ No newline at end of file diff --git a/step_3/kernel/Makefile b/step_3/kernel/Makefile index b25f927..f887e7a 100644 --- a/step_3/kernel/Makefile +++ b/step_3/kernel/Makefile @@ -12,7 +12,7 @@ FILESYSTEM=../filesystem STONE=stone USER_HEADER=$(USER)/user.h $(USER)/terminal.h -USER_OBJ=$(USER)/user.o $(USER)/terminal.o $(USER)/$(STONE)/stoneQ.o +USER_OBJ=$(USER)/user.o $(USER)/terminal.o all: kernel.bin diff --git a/step_3/user/Makefile b/step_3/user/Makefile index 02bffd4..ba95786 100644 --- a/step_3/user/Makefile +++ b/step_3/user/Makefile @@ -7,7 +7,7 @@ ASFLAGS= UTILITIES=../include STONE=stone -all: user.o terminal.o $(STONE)/stoneQ.bin +all: user.o terminal.o $(STONE)/stoneQ.bin $(STONE)/stoneW.bin user.o: user.c $(UTILITIES)/utilities.h $(CC) $(CCFLAGS) -c $^ @@ -19,6 +19,16 @@ $(STONE)/stoneQ.bin: $(STONE)/stoneQ.o $(UTILITIES)/utilities.o $(STONE)/stoneQ.o: $(STONE)/stone.c $(UTILITIES)/utilities.h $(CC) $(CCFLAGS) -c $< -D UL -o $@ +$(STONE)/stoneW.bin: $(STONE)/stoneW.o $(UTILITIES)/utilities.o + $(LD) $(LDFLAGS) -Ttext 0x6C00 --oformat binary -o $@ $^ +$(STONE)/stoneW.o: $(STONE)/stone.c $(UTILITIES)/utilities.h + $(CC) $(CCFLAGS) -c $< -D UR -o $@ + + + + + + $(UTILITIES)/utilities.o: cd $(UTILITIES)/ && make cd ../user/ diff --git a/step_3/user/terminal.c b/step_3/user/terminal.c index 1b764cd..9805a56 100644 --- a/step_3/user/terminal.c +++ b/step_3/user/terminal.c @@ -68,7 +68,9 @@ void parseCMD(int CMDindex) { if (strstr(CMD_BUFFER, "run") == 0 && strchr(CMD_BUFFER, ' ') == 3) { int16_t pos = strchr(CMD_BUFFER, ' '); const char* fn = CMD_BUFFER + pos + 1; + putln(fn); int16_t code = __load_program(fn); + putiln(code); int (*userProgram)() = (int (*)())(0x6c00); switch(code) { case ERR_SYS_PROTC: @@ -86,6 +88,7 @@ void parseCMD(int CMDindex) { case NO_ERR: userProgram(); clear_screen(); + putln("you entered"); break; } } else if (strcmp(CMD_BUFFER, "help") == 0) { From 29f7d1d44ea71ef2c9da2b83ee2db6a0477c8e0a Mon Sep 17 00:00:00 2001 From: YanB25 Date: Tue, 3 Apr 2018 20:29:09 +0800 Subject: [PATCH 3/6] ERROR, i don't what is bug. can not load stoneS --- step_3/Makefile | 12 +++++++++++- step_3/filesystem/FAT.c | 23 +++++++++++++++++++---- step_3/filesystem/README.md | 4 +++- step_3/filesystem/datablock.c | 20 ++++++++++++++++++++ step_3/user/Makefile | 13 ++++++++++--- step_3/user/stone/stone.h | 14 ++++++++++++++ step_3/user/terminal.c | 2 +- 7 files changed, 78 insertions(+), 10 deletions(-) diff --git a/step_3/Makefile b/step_3/Makefile index 933af34..bbfb5fb 100644 --- a/step_3/Makefile +++ b/step_3/Makefile @@ -12,7 +12,7 @@ ROOT=.. FILESYSTEM=filesystem USER=user STONE=stone -STONE_OBJ=$(USER)/$(STONE)/stoneQ.bin $(USER)/$(STONE)/stoneW.bin +STONE_OBJ=$(USER)/$(STONE)/stoneQ.bin $(USER)/$(STONE)/stoneW.bin $(USER)/$(STONE)/stoneA.bin $(USER)/$(STONE)/stoneS.bin all: $(STONE_OBJ) $(KERNEL)/kernel.bin $(LOADER)/loader.bin build cleangch $(KERNEL)/kernel.bin: @@ -53,6 +53,14 @@ $(USER)/$(STONE)/stoneW.bin: echo "\n" cd $(USER)/ && make cd $(ROOT)/ +$(USER)/$(STONE)/stoneA.bin: + echo "\n" + cd $(USER)/ && make + cd $(ROOT)/ +$(USER)/$(STONE)/stoneS.bin: + echo "\n" + cd $(USER)/ && make + cd $(ROOT)/ build: $(LOADER)/loader.bin $(FILESYSTEM)/DBR.bin $(FILESYSTEM)/FAT.bin $(FILESYSTEM)/datablock.bin $(STONE_OBJ) @@ -65,6 +73,8 @@ build: $(LOADER)/loader.bin $(FILESYSTEM)/DBR.bin $(FILESYSTEM)/FAT.bin $(FILESY dd if=$(KERNEL)/kernel.bin of=OS.img conv=notrunc oflag=seek_bytes seek=7680 dd if=$(USER)/$(STONE)/stoneQ.bin of=OS.img conv=notrunc oflag=seek_bytes seek=12800 dd if=$(USER)/$(STONE)/stoneW.bin of=OS.img conv=notrunc oflag=seek_bytes seek=14848 + dd if=$(USER)/$(STONE)/stoneS.bin of=OS.img conv=notrunc oflag=seek_bytes seek=16896 + dd if=$(USER)/$(STONE)/stoneA.bin of=OS.img conv=notrunc oflag=seek_bytes seek=18944 clean: echo "\n" find . -name "*.bin" -type f -delete diff --git a/step_3/filesystem/FAT.c b/step_3/filesystem/FAT.c index 5c3d56f..a1267b1 100644 --- a/step_3/filesystem/FAT.c +++ b/step_3/filesystem/FAT.c @@ -23,9 +23,24 @@ FAT_ITEM_T fat_items[] = { 0x0014, // 19 0x0015, // 20 0xFFFF, // 21 - 0xFFFF, // 22 - 0xFFFF, // 23 - 0xFFFF, // 24 + 0x0017, // 22 + 0x0018, // 23 + 0x0019, // 24 0xFFFF, // 25 - 0xFFFF, // 26 + 0x001B, // 26 + 0x001C, // 27 + 0x001D, // 28 + 0xFFFF, // 29 + 0xFFFF, // 30 + 0xFFFF, // 31 + 0xFFFF, // 32 + 0xFFFF, // 33 + 0xFFFF, // 34 + 0xFFFF, // 35 + 0xFFFF, // 36 + 0xFFFF, // 37 + 0xFFFF, // 38 + 0xFFFF, // 39 + 0xFFFF, // 40 + 0xFFFF, // 41 }; diff --git a/step_3/filesystem/README.md b/step_3/filesystem/README.md index 585f69d..3995c5b 100644 --- a/step_3/filesystem/README.md +++ b/step_3/filesystem/README.md @@ -10,8 +10,10 @@ FAT表2 8-11扇区(4个)512*7 = 3584 [e00~1600] 内核程序 16-23 512*15= 7680 [1e00~2e00] home/ 24 [2e00~3000] msg 25 [3000~3200] -用户程序 26-29 512*25=12800 [3200~3a00] +用户程序q 26-29 512*25=12800 [3200~3a00] 用户程序w 30-33 512*29=14848 [3a00~4200] +用户程序a 34-37 512*33=16896 [4200~4a00] +用户程序s 38-41 512*37=18944 [4a00~5200] ## 软盘结构 ; 磁道 面 扇区 ; 0~79 0~1 1~18 diff --git a/step_3/filesystem/datablock.c b/step_3/filesystem/datablock.c index 9ec1397..912fb19 100644 --- a/step_3/filesystem/datablock.c +++ b/step_3/filesystem/datablock.c @@ -83,4 +83,24 @@ FAT_ITEM user_programW = { 0, 18, 512*4 // 4 sectors +}; +FAT_ITEM user_programA = { + "stoneA", + "bin", + FAT_rw, + 0, 0, 0, 0, 0, 0, + 0, + 0, + 22, + 512*4 // 4 sectors +}; +FAT_ITEM user_programS = { + "stoneS", + "bin", + FAT_rw, + 0, 0, 0, 0, 0, 0, + 0, + 0, + 26, + 512*4 // 4 sectors }; \ No newline at end of file diff --git a/step_3/user/Makefile b/step_3/user/Makefile index ba95786..e0d2ac0 100644 --- a/step_3/user/Makefile +++ b/step_3/user/Makefile @@ -7,7 +7,8 @@ ASFLAGS= UTILITIES=../include STONE=stone -all: user.o terminal.o $(STONE)/stoneQ.bin $(STONE)/stoneW.bin +STONE_BIN = $(STONE)/stoneQ.bin $(STONE)/stoneW.bin $(STONE)/stoneA.bin $(STONE)/stoneS.bin +all: user.o terminal.o $(STONE_BIN) user.o: user.c $(UTILITIES)/utilities.h $(CC) $(CCFLAGS) -c $^ @@ -24,9 +25,15 @@ $(STONE)/stoneW.bin: $(STONE)/stoneW.o $(UTILITIES)/utilities.o $(STONE)/stoneW.o: $(STONE)/stone.c $(UTILITIES)/utilities.h $(CC) $(CCFLAGS) -c $< -D UR -o $@ +$(STONE)/stoneS.bin: $(STONE)/stoneS.o $(UTILITIES)/utilities.o + $(LD) $(LDFLAGS) -Ttext 0x6C00 --oformat binary -o $@ $^ +$(STONE)/stoneS.o: $(STONE)/stone.c $(UTILITIES)/utilities.h + $(CC) $(CCFLAGS) -c $< -D DR -o $@ - - +$(STONE)/stoneA.bin: $(STONE)/stoneA.o $(UTILITIES)/utilities.o + $(LD) $(LDFLAGS) -Ttext 0x6C00 --oformat binary -o $@ $^ +$(STONE)/stoneA.o: $(STONE)/stone.c $(UTILITIES)/utilities.h + $(CC) $(CCFLAGS) -c $< -D DL -o $@ $(UTILITIES)/utilities.o: diff --git a/step_3/user/stone/stone.h b/step_3/user/stone/stone.h index 43b7d0d..a68bce4 100644 --- a/step_3/user/stone/stone.h +++ b/step_3/user/stone/stone.h @@ -14,6 +14,20 @@ #define RIGHT_B 79 #define UP_B 1 #define DOWN_B 12 +#elif defined(DL) + #define _X 5 + #define _Y 20 + #define LEFT_B 1 + #define RIGHT_B 40 + #define UP_B 13 + #define DOWN_B 24 +#elif defined(DR) + #define _X 70 + #define _Y 20 + #define LEFT_B 40 + #define RIGHT_B 79 + #define UP_B 13 + #define DOWN_B 24 #endif #endif \ No newline at end of file diff --git a/step_3/user/terminal.c b/step_3/user/terminal.c index 9805a56..3bd3965 100644 --- a/step_3/user/terminal.c +++ b/step_3/user/terminal.c @@ -87,7 +87,7 @@ void parseCMD(int CMDindex) { break; case NO_ERR: userProgram(); - clear_screen(); + // clear_screen(); putln("you entered"); break; } From 5615be82361daeed3f93b357a6476bcfb301f513 Mon Sep 17 00:00:00 2001 From: YanB25 Date: Tue, 3 Apr 2018 22:28:52 +0800 Subject: [PATCH 4/6] IMPORTANT fix criticle bug - fsutilitites.h: error in calculating head of logic sector. it cause error in loading user program stoneS. it is becuase stoneS is at 38 sector, which should be head 0 but wrongly get head 3. --- step_3/filesystem/fsutilities.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/step_3/filesystem/fsutilities.h b/step_3/filesystem/fsutilities.h index 9ddee1d..b6eb067 100644 --- a/step_3/filesystem/fsutilities.h +++ b/step_3/filesystem/fsutilities.h @@ -2,7 +2,7 @@ #define __FS_UTILITIES_H_ #include #define lgsector2sector(X) (((X-1)%18)+1) -#define lgsector2head(X) ((X-1)/18) +#define lgsector2head(X) (((X-1)/18)%2) #define lgsector2track(X) ((X-1)/36) void loadSector(uint16_t track, uint16_t head, uint16_t sector, uint16_t addr, uint16_t num); static inline void loadLogicSector(uint16_t lgsector, uint16_t addr, uint16_t num) { From 968f75ea907c03e194eb67ce7bfe13d8f59fb915 Mon Sep 17 00:00:00 2001 From: YanB25 Date: Tue, 3 Apr 2018 22:30:21 +0800 Subject: [PATCH 5/6] finish all in running four user program. modified: Makefile modified: filesystem/README.md modified: kernel/kernel.c modified: user/terminal.c --- step_3/Makefile | 4 ++-- step_3/filesystem/README.md | 7 ++++++- step_3/kernel/kernel.c | 1 + step_3/user/terminal.c | 9 +++++---- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/step_3/Makefile b/step_3/Makefile index bbfb5fb..ed545c4 100644 --- a/step_3/Makefile +++ b/step_3/Makefile @@ -73,8 +73,8 @@ build: $(LOADER)/loader.bin $(FILESYSTEM)/DBR.bin $(FILESYSTEM)/FAT.bin $(FILESY dd if=$(KERNEL)/kernel.bin of=OS.img conv=notrunc oflag=seek_bytes seek=7680 dd if=$(USER)/$(STONE)/stoneQ.bin of=OS.img conv=notrunc oflag=seek_bytes seek=12800 dd if=$(USER)/$(STONE)/stoneW.bin of=OS.img conv=notrunc oflag=seek_bytes seek=14848 - dd if=$(USER)/$(STONE)/stoneS.bin of=OS.img conv=notrunc oflag=seek_bytes seek=16896 - dd if=$(USER)/$(STONE)/stoneA.bin of=OS.img conv=notrunc oflag=seek_bytes seek=18944 + dd if=$(USER)/$(STONE)/stoneA.bin of=OS.img conv=notrunc oflag=seek_bytes seek=16896 + dd if=$(USER)/$(STONE)/stoneS.bin of=OS.img conv=notrunc oflag=seek_bytes seek=18944 clean: echo "\n" find . -name "*.bin" -type f -delete diff --git a/step_3/filesystem/README.md b/step_3/filesystem/README.md index 3995c5b..9bc1b7f 100644 --- a/step_3/filesystem/README.md +++ b/step_3/filesystem/README.md @@ -17,7 +17,12 @@ msg 25 [3000~3200] ## 软盘结构 ; 磁道 面 扇区 ; 0~79 0~1 1~18 - +1 0 2 +逻辑扇区 面 运算后的结果 +1~18 0 -1/18-> 0 +19~36 1 -1/18-> 1 +37~54 0 -1/18-> 2 +55~72 1 -1/18-> 3 ## 内存结构 1:0x7C00: MBR(loader) 2:0x7E00: DBR diff --git a/step_3/kernel/kernel.c b/step_3/kernel/kernel.c index eed19df..571c7c5 100644 --- a/step_3/kernel/kernel.c +++ b/step_3/kernel/kernel.c @@ -7,6 +7,7 @@ #define true 1 #define false 0 int main() { + // __load_program("stoneS"); clear_screen(); draw_str("enter help to get help", 0, 30); //draw_char_style('A', 0, 10, G_DEFAULT); diff --git a/step_3/user/terminal.c b/step_3/user/terminal.c index 3bd3965..0236d7d 100644 --- a/step_3/user/terminal.c +++ b/step_3/user/terminal.c @@ -68,9 +68,7 @@ void parseCMD(int CMDindex) { if (strstr(CMD_BUFFER, "run") == 0 && strchr(CMD_BUFFER, ' ') == 3) { int16_t pos = strchr(CMD_BUFFER, ' '); const char* fn = CMD_BUFFER + pos + 1; - putln(fn); int16_t code = __load_program(fn); - putiln(code); int (*userProgram)() = (int (*)())(0x6c00); switch(code) { case ERR_SYS_PROTC: @@ -87,8 +85,7 @@ void parseCMD(int CMDindex) { break; case NO_ERR: userProgram(); - // clear_screen(); - putln("you entered"); + clear_screen(); break; } } else if (strcmp(CMD_BUFFER, "help") == 0) { @@ -97,11 +94,15 @@ void parseCMD(int CMDindex) { FAT_ITEM* pfat = CUR_DIR; if (__FAT_showable_item(pfat)) { putln(pfat->filename); + // putiln(pfat->blow_cluster); + // putiln(pfat->filesize); } while (__has_next_item(pfat)) { pfat = __next_item(pfat); if (__FAT_showable_item(pfat)) { putln(pfat->filename); + // putiln(pfat->blow_cluster); + // putiln(pfat->filesize); } } } From d7f546c227a203c3cec985db2c1845b67743e766 Mon Sep 17 00:00:00 2001 From: YanB25 Date: Tue, 3 Apr 2018 22:35:42 +0800 Subject: [PATCH 6/6] stone char change color - stone.c: add logic to change style --- step_3/user/stone/stone.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/step_3/user/stone/stone.c b/step_3/user/stone/stone.c index 3d8982b..8515ed9 100644 --- a/step_3/user/stone/stone.c +++ b/step_3/user/stone/stone.c @@ -2,7 +2,7 @@ __asm__("jmpl $0, $stone\n"); #include "../../include/utilities.h" #include "stone.h" -#define DELAY (1e5) +#define DELAY (5 * 1e5) int getKbHit(); void checkBound(); @@ -16,6 +16,7 @@ int stone() { y = _Y; deltax = 1; deltay = 1; + uint8_t style = 0; clear_screen(); while(1) { @@ -25,11 +26,13 @@ int stone() { int delay = DELAY; while ((--delay) >= 0) continue; + draw_str(" ", y, x); x += deltax; y += deltay; checkBound(); - draw_str("A", y, x); + draw_str_style("A", y, x, style & 15); + style++; } }