30天自制操作系统期末实验报告.doc

上传人:李医生 文档编号:6076719 上传时间:2020-09-05 格式:DOC 页数:23 大小:639.50KB
返回 下载 相关 举报
30天自制操作系统期末实验报告.doc_第1页
第1页 / 共23页
30天自制操作系统期末实验报告.doc_第2页
第2页 / 共23页
30天自制操作系统期末实验报告.doc_第3页
第3页 / 共23页
30天自制操作系统期末实验报告.doc_第4页
第4页 / 共23页
30天自制操作系统期末实验报告.doc_第5页
第5页 / 共23页
点击查看更多>>
资源描述

《30天自制操作系统期末实验报告.doc》由会员分享,可在线阅读,更多相关《30天自制操作系统期末实验报告.doc(23页珍藏版)》请在三一文库上搜索。

1、浙江工业大学计算机学院计算机实验班1101 章鹏 201126100329实验报告名称:创新实践(30天自制操作系统)实验目标:根据教材从零开始使用C与汇编语言编写一个简单的操作系统,实现操作系统的基本功能。实验背景:为了让学生对操作系统的底层有更清晰的了解,选取了一本名为30天自制操作系统的书作为两学期创新实践课程的教材,并根据该教材一步步从零开始完成每个人自己特色的简易版操作系统,锻炼学生动手能力,提高学生对操作系统的知识理解。实验进度:第28天成果界面截图:截图1:操作系统初始化界面截图2:运行命令获取操作系统基本信息截图2.1 Mem:读取系统内存与存储空间截图2.2 Dir:读取当前

2、系统允许使用的应用程序截图2.3 Exit:关闭当前console命令窗截图2.4 应用程序名:在当前窗口下运行应用程序截图2.5 Start+应用程序名:新建一个console命令窗并运行程序截图2.6 Ncst(no console start):无新建窗口运行程序截图2.7 Shift+f2:新建一个空的console窗口截图2.8 F11:将下一层的console窗口切至最顶层截图2.9 Tab:将当前工作区间(键盘)在窗口间循环截图3应用程序截图:截图3.1 a(显示字符A):截图3.2 Winhelo/winhelo2/winhelo3:截图3.3 Color:截图3.4 Colo

3、r2:截图3.5 Hello3:截图3.6 Hello4与hello5:截图3.7 Lines:画线程序截图3.8 Noddle:计时程序(三分钟)截图3.9 Sosu:显示1-1000内的素数截图3.10 Sosu3:显示1-10000内的素数截图3.11 Star1:显示一个点截图3.12 Stars:显示多个点截图3.13 Walk:使用方向键控制点的移动源代码截取:操作系统代码:haribote文件夹(以graphic界面颜色与图形控制为例)/graphic.c#include bootpack.hvoid init_palette(void)static unsigned char

4、table_rgb16 * 3 = 0x00, 0x00, 0x00,/* 0:黑 */0xff, 0x00, 0x00,/* 1:亮红 */0x00, 0xff, 0x00,/* 2:亮绿 */0xff, 0xff, 0x00,/* 3:亮黄 */0x00, 0x00, 0xff,/* 4:亮蓝*/0xff, 0x00, 0xff,/* 5:亮紫 */0x00, 0xff, 0xff,/* 6:浅亮蓝 */0xff, 0xff, 0xff,/* 7:白 */0xc6, 0xc6, 0xc6,/* 8:亮灰 */0x84, 0x00, 0x00,/* 9:暗红 */0x00, 0x84, 0x

5、00,/* 10:暗绿 */0x84, 0x84, 0x00,/* 11:暗黄 */0x00, 0x00, 0x84,/* 12:暗青 */0x84, 0x00, 0x84,/* 13:暗紫 */0x00, 0x84, 0x84,/* 14:浅暗蓝 */0x84, 0x84, 0x84/* 15:暗灰 */;unsigned char table2216*3;int r,g,b;set_palette(0, 15, table_rgb);for(b=0;b6;b+)for(g=0;g6;g+)for(r=0;r6;r+)table2(r+g*6+b*36)*3+0=r*51;table2(r+

6、g*6+b*36)*3+1=g*51;table2(r+g*6+b*36)*3+2=b*51;set_palette(16,231,table2);return;void set_palette(int start, int end, unsigned char *rgb)int i, eflags;eflags = io_load_eflags();io_cli(); io_out8(0x03c8, start);for (i = start; i = end; i+) io_out8(0x03c9, rgb0 / 4);io_out8(0x03c9, rgb1 / 4);io_out8(0

7、x03c9, rgb2 / 4);rgb += 3;io_store_eflags(eflags);return;void boxfill8(unsigned char *vram, int xsize, unsigned char c, int x0, int y0, int x1, int y1)int x, y;for (y = y0; y = y1; y+) for (x = x0; x = x1; x+)vramy * xsize + x = c;return;void init_screen8(char *vram, int x, int y)boxfill8(vram, x, C

8、OL8_008484, 0, 0, x - 1, y - 29);boxfill8(vram, x, COL8_C6C6C6, 0, y - 28, x - 1, y - 28);boxfill8(vram, x, COL8_FFFFFF, 0, y - 27, x - 1, y - 27);boxfill8(vram, x, COL8_C6C6C6, 0, y - 26, x - 1, y - 1);boxfill8(vram, x, COL8_FFFFFF, 3, y - 24, 59, y - 24);boxfill8(vram, x, COL8_FFFFFF, 2, y - 24, 2

9、, y - 4);boxfill8(vram, x, COL8_848484, 3, y - 4, 59, y - 4);boxfill8(vram, x, COL8_848484, 59, y - 23, 59, y - 5);boxfill8(vram, x, COL8_000000, 2, y - 3, 59, y - 3);boxfill8(vram, x, COL8_000000, 60, y - 24, 60, y - 3);boxfill8(vram, x, COL8_848484, x - 47, y - 24, x - 4, y - 24);boxfill8(vram, x,

10、 COL8_848484, x - 47, y - 23, x - 47, y - 4);boxfill8(vram, x, COL8_FFFFFF, x - 47, y - 3, x - 4, y - 3);boxfill8(vram, x, COL8_FFFFFF, x - 3, y - 24, x - 3, y - 3);return;void putfont8(char *vram, int xsize, int x, int y, char c, char *font)int i;char *p, d /* data */;for (i = 0; i 16; i+) p = vram

11、 + (y + i) * xsize + x;d = fonti;if (d & 0x80) != 0) p0 = c; if (d & 0x40) != 0) p1 = c; if (d & 0x20) != 0) p2 = c; if (d & 0x10) != 0) p3 = c; if (d & 0x08) != 0) p4 = c; if (d & 0x04) != 0) p5 = c; if (d & 0x02) != 0) p6 = c; if (d & 0x01) != 0) p7 = c; return;void putfonts8_asc(char *vram, int x

12、size, int x, int y, char c, unsigned char *s)extern char hankaku4096;for (; *s != 0x00; s+) putfont8(vram, xsize, x, y, c, hankaku + *s * 16);x += 8;return;void init_mouse_cursor8(char *mouse, char bc)int x, y;for (y = 0; y 16; y+) for (x = 0; x 16; x+) if (cursoryx = *) mousey * 16 + x = COL8_00000

13、0;if (cursoryx = 0) mousey * 16 + x = COL8_FFFFFF;if (cursoryx = .) mousey * 16 + x = bc;return;void putblock8_8(char *vram, int vxsize, int pxsize,int pysize, int px0, int py0, char *buf, int bxsize)int x, y;for (y = 0; y pysize; y+) for (x = 0; x pxsize; x+) vram(py0 + y) * vxsize + (px0 + x) = bu

14、fy * bxsize + x;return;操作系统api(以api002输出单个字符为例):/api002.nasFORMAT WCOFFINSTRSET i486pBITS 32FILE api002.nasGLOBAL_api_putstr0SECTION .text_api_putstr0:; void api_putstr0(char *s);PUSHEBXMOVEDX,2MOVEBX,ESP+8; sINT0x40POPEBXRET应用程序(以stars为例):/stars.c#include apilib.hint rand(void);void HariMain(void)c

15、har *buf;int win,i,x,y;api_initmalloc();buf=api_malloc(150*100);win=api_openwin(buf,150,100,-1,stars);api_boxfilwin(win,6,26,143,93,0);for(i=0;i50;i+)x=(rand()%137)+6;y=(rand()%67)+26;api_point(win,x,y,3);for(;)if(api_getkey(1)=0x0a)break;api_end();操作系统Makefile文件:TOOLPATH = ./z_tools/INCPATH = ./z_t

16、ools/haribote/MAKE = $(TOOLPATH)make.exe -rEDIMG = $(TOOLPATH)edimg.exeIMGTOL = $(TOOLPATH)COPY = copyDEL = deldefault :$(MAKE) haribote.imgharibote.img : haribote/ipl10.bin haribote/haribote.sys Makefile a/a.hrb hello3/hello3.hrb hello4/hello4.hrb hello5/hello5.hrb winhelo/winhelo.hrb winhelo2/winh

17、elo2.hrb winhelo3/winhelo3.hrb star1/star1.hrb stars/stars.hrb stars2/stars2.hrb lines/lines.hrb walk/walk.hrb noodle/noodle.hrb beepdown/beepdown.hrb color/color.hrb color2/color2.hrb$(EDIMG) imgin:./z_tools/fdimg0at.tek wbinimg src:haribote/ipl10.bin len:512 from:0 to:0 copy from:haribote/haribote

18、.sys to: copy from:haribote/ipl10.nas to:copy from:make.bat to:copy from:a/a.hrb to:copy from:hello3/hello3.hrb to: copy from:hello4/hello4.hrb to: copy from:hello5/hello5.hrb to: copy from:winhelo/winhelo.hrb to:copy from:winhelo2/winhelo2.hrb to:copy from:winhelo3/winhelo3.hrb to:copy from:star1/s

19、tar1.hrb to:copy from:stars/stars.hrb to:copy from:stars2/stars2.hrb to:copy from:lines/lines.hrb to:copy from:walk/walk.hrb to:copy from:noodle/noodle.hrb to:copy from:beepdown/beepdown.hrb to:copy from:color/color.hrb to:copy from:color2/color2.hrb to:imgout:haribote.imgrun :$(MAKE) haribote.img$(

20、COPY) haribote.img .z_toolsqemufdimage0.bin$(MAKE) -C ./z_tools/qemuinstall :$(MAKE) haribote.img$(IMGTOL) w a: haribote.imgfull :$(MAKE) -C haribote$(MAKE) -C apilib$(MAKE) -C a$(MAKE) -C hello3$(MAKE) -C hello4$(MAKE) -C hello5$(MAKE) -C winhelo$(MAKE) -C winhelo2$(MAKE) -C winhelo3$(MAKE) -C star

21、1$(MAKE) -C stars$(MAKE) -C stars2$(MAKE) -C lines$(MAKE) -C walk$(MAKE) -C noodle$(MAKE) -C beepdown$(MAKE) -C color$(MAKE) -C color2$(MAKE) haribote.imgrun_full :$(MAKE) full$(COPY) haribote.img .z_toolsqemufdimage0.bin$(MAKE) -C ./z_tools/qemuinstall_full :$(MAKE) full$(IMGTOL) w a: haribote.imgr

22、un_os :$(MAKE) -C haribote$(MAKE) runclean :src_only :$(MAKE) clean-$(DEL) haribote.imgclean_full :$(MAKE) -C hariboteclean$(MAKE) -C apilibclean$(MAKE) -C aclean$(MAKE) -C hello3clean$(MAKE) -C hello4clean$(MAKE) -C hello5clean$(MAKE) -C winheloclean$(MAKE) -C winhelo2clean$(MAKE) -C winhelo3clean$

23、(MAKE) -C star1clean$(MAKE) -C starsclean$(MAKE) -C stars2clean$(MAKE) -C linesclean$(MAKE) -C walkclean$(MAKE) -C noodleclean$(MAKE) -C beepdownclean$(MAKE) -C colorclean$(MAKE) -C color2cleansrc_only_full :$(MAKE) -C haribotesrc_only$(MAKE) -C apilibsrc_only$(MAKE) -C asrc_only$(MAKE) -C hello3src

24、_only$(MAKE) -C hello4src_only$(MAKE) -C hello5src_only$(MAKE) -C winhelosrc_only$(MAKE) -C winhelo2src_only$(MAKE) -C winhelo3src_only$(MAKE) -C star1src_only$(MAKE) -C starssrc_only$(MAKE) -C stars2src_only$(MAKE) -C linessrc_only$(MAKE) -C walksrc_only$(MAKE) -C noodlesrc_only$(MAKE) -C beepdownsrc_only$(MAKE) -C colorsrc_only$(MAKE) -C color2src_only-$(DEL) haribote.imgrefresh :$(MAKE) full$(MAKE) clean_full-$(DEL) haribote.img

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 科普知识


经营许可证编号:宁ICP备18001539号-1