原创 我的學習之旅(29)Makefile

調整好目錄後還要補充增加最外邊的Makefile,主要功能是進入到boot、init、schedule、tools、drivers目錄編譯並做連接後用build_image工具打包成一個image 整個image分佈應該是這樣: 0~0x

原创 我的學習之旅(28) 目錄結構調整

kernel_start()函數增加對trap_init()的調用。 void kernel_start(void) {            clear_screen(DISP_FG_WHITE + DISP_BG_BLACK);  

原创 我的學習之旅(33) sched.h

sched.h主要定義了時鐘頻率、任務數據結構、和sleep宏。sleep宏的實現主要功能是設置當前任務的sleep_time,然後通過軟中斷0x80做任務軟切換。 #ifndef __SCHED_H__ #define __SCHED_

原创 我的學習之旅(23)traps.c和 start32.h

接下來就要先初始化中斷向量。如書上所說,intel默認保留使用了0~31箇中斷給自己使用。這些中斷目前不想處理。所以這些中斷的處理函數只是打印一下就可以。 traps.c源代碼: #include <io.h> #include <sta

原创 我的學習之旅(20)vsprintf.c

switch (*fmt) { case 'c': if (!(flags & LEFT)) { while (--field_width

原创 我的學習之旅(14)printk.c

void clear_row(unsigned char y,unsigned char color) { unsigned char *p; unsigned char i; p = (unsigned cha

原创 我的學習指旅(30) Makefile

boot_partition:  @echo  @echo Making boot...  (cd boot; make clean; make;) kernel: $(OBJS) $(LIBS) $(DRIVERS)  @echo  @

原创 我的學習之旅(16)stdarg.h和vsprintf.c

//格式化字符串實現在stdarg.h和vsprintf.c,stdarg.h和vsprintf.c文件沿用linux的stdarg.h文件。 stdarg.h源代碼: #ifndef __STDARG_H__ #define __STD

原创 我的學習之旅(21)vsprintf.c

            case 'd':             case 'i':                 flags |= SIGN;             case 'u':                 str =

原创 我的學習之旅(25)system.h

#define int80() __asm__ ("int $0x80"::) /*copy from linux source code:system.h*/ #define move_to_start_task() \ __asm__

原创 我的學習之旅(27)io.h

IO.h代碼主要涉及對端口的訪問實現,大部分代碼拷貝linux源代碼 outx_p()具有延時作用,outx()則是實現對byte,short和int的寫 io.h: #ifndef __IO_H__ #define __IO_H__

原创 我的學習之旅(15)tty.c

模仿linux tty,建立一個console,通過對console的寫操作完成字符的顯示。 tty.c源代碼: #include <stdarg.h> #include <mem.h> #include <tty.h> #include

原创 我的學習之旅(24)system.h

system.h主要定義一些常用的x86彙編宏和字節序的處理。大部分都是拷貝linux中源代碼. system.h源代碼: #ifndef __SYSTEM_H__ #define __SYSTEM_H__ #ifndef NULL

原创 我的學習之旅(26)system.h

#define lidt(_idt) \ __asm__ __volatile__ ( \ "lidtl (%%ebx)" \ : \ :"b"(_idt) \

原创 我的學習之旅(31) schedule和tools目錄下的Makefile

INCLUDE = ../include CC = gcc -march=i386 LD = ld AS = as CCFLG   = -O2 -c -nostdinc -fno-builtin -fstrength-reduce -f