├── a ├── a.img.gz ├── 80m.img.gz ├── include │ ├── tty.h │ ├── string.h │ ├── console.h │ ├── global.h │ ├── type.h │ └── sconst.inc ├── boot │ └── include │ │ └── load.inc ├── bochsrc ├── fs │ └── main.c └── kernel │ ├── systask.c │ ├── syscall.asm │ └── start.c ├── b ├── a.img.gz ├── 80m.img.gz ├── include │ ├── config.h │ ├── tty.h │ ├── string.h │ ├── console.h │ ├── global.h │ ├── type.h │ └── sconst.inc ├── boot │ └── include │ │ └── load.inc ├── bochsrc ├── kernel │ ├── systask.c │ ├── syscall.asm │ └── start.c └── fs │ └── main.c ├── c ├── a.img.gz ├── 80m.img.gz ├── include │ ├── config.h │ ├── tty.h │ ├── string.h │ ├── console.h │ ├── global.h │ ├── type.h │ └── sconst.inc ├── boot │ └── include │ │ └── load.inc ├── bochsrc ├── kernel │ ├── systask.c │ ├── syscall.asm │ └── start.c └── fs │ └── main.c ├── d ├── a.img.gz ├── 80m.img.gz ├── include │ ├── config.h │ ├── tty.h │ ├── string.h │ ├── console.h │ ├── global.h │ ├── type.h │ └── sconst.inc ├── boot │ └── include │ │ └── load.inc ├── bochsrc └── kernel │ ├── systask.c │ ├── syscall.asm │ └── start.c ├── e ├── a.img.gz ├── 80m.img.gz ├── tmp │ ├── Makefile │ └── f.c ├── include │ ├── sys │ │ ├── config.h │ │ ├── tty.h │ │ ├── console.h │ │ ├── global.h │ │ └── sconst.inc │ ├── string.h │ ├── stdio.h │ └── type.h ├── boot │ └── include │ │ └── load.inc ├── bochsrc ├── lib │ ├── close.c │ ├── syscall.asm │ └── open.c └── kernel │ ├── systask.c │ └── start.c ├── f ├── a.img.gz ├── 80m.img.gz ├── include │ ├── sys │ │ ├── config.h │ │ ├── tty.h │ │ ├── console.h │ │ ├── global.h │ │ └── sconst.inc │ ├── string.h │ ├── stdio.h │ └── type.h ├── boot │ └── include │ │ └── load.inc ├── bochsrc ├── lib │ ├── close.c │ ├── syscall.asm │ ├── read.c │ ├── open.c │ └── write.c └── kernel │ ├── systask.c │ └── start.c ├── g ├── a.img.gz ├── 80m.img.gz ├── splitgraphs ├── include │ ├── sys │ │ ├── config.h │ │ ├── tty.h │ │ ├── console.h │ │ ├── global.h │ │ └── sconst.inc │ ├── string.h │ ├── type.h │ └── stdio.h ├── boot │ └── include │ │ └── load.inc ├── bochsrc ├── genlog ├── lib │ ├── getpid.c │ ├── close.c │ ├── syscall.asm │ ├── read.c │ ├── open.c │ └── write.c └── kernel │ ├── systask.c │ └── start.c ├── h ├── a.img.gz ├── 80m.img.gz ├── scripts │ ├── splitgraphs │ └── genlog ├── include │ ├── sys │ │ ├── config.h │ │ ├── tty.h │ │ ├── console.h │ │ ├── global.h │ │ └── sconst.inc │ ├── string.h │ ├── type.h │ └── stdio.h ├── bochsrc ├── lib │ ├── getpid.c │ ├── close.c │ ├── unlink.c │ ├── syscall.asm │ ├── read.c │ ├── open.c │ └── write.c └── kernel │ ├── systask.c │ └── start.c ├── i ├── a.img.gz ├── 80m.img.gz ├── scripts │ ├── splitgraphs │ └── genlog ├── include │ ├── sys │ │ ├── config.h │ │ ├── tty.h │ │ ├── console.h │ │ ├── sconst.inc │ │ └── global.h │ ├── string.h │ ├── type.h │ └── stdio.h ├── bochsrc ├── lib │ ├── getpid.c │ ├── close.c │ ├── unlink.c │ ├── syscall.asm │ ├── read.c │ ├── open.c │ └── write.c └── kernel │ ├── systask.c │ └── start.c └── j ├── a.img.gz ├── 80m.img.gz ├── scripts ├── splitgraphs └── genlog ├── include ├── sys │ ├── config.h │ ├── tty.h │ ├── console.h │ ├── sconst.inc │ └── global.h ├── string.h ├── type.h └── stdio.h ├── bochsrc ├── lib ├── getpid.c ├── close.c ├── unlink.c ├── read.c ├── open.c ├── write.c └── syscall.asm └── kernel ├── systask.c └── start.c /a/a.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyu/osfs09/HEAD/a/a.img.gz -------------------------------------------------------------------------------- /b/a.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyu/osfs09/HEAD/b/a.img.gz -------------------------------------------------------------------------------- /c/a.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyu/osfs09/HEAD/c/a.img.gz -------------------------------------------------------------------------------- /d/a.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyu/osfs09/HEAD/d/a.img.gz -------------------------------------------------------------------------------- /e/a.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyu/osfs09/HEAD/e/a.img.gz -------------------------------------------------------------------------------- /f/a.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyu/osfs09/HEAD/f/a.img.gz -------------------------------------------------------------------------------- /g/a.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyu/osfs09/HEAD/g/a.img.gz -------------------------------------------------------------------------------- /h/a.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyu/osfs09/HEAD/h/a.img.gz -------------------------------------------------------------------------------- /i/a.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyu/osfs09/HEAD/i/a.img.gz -------------------------------------------------------------------------------- /j/a.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyu/osfs09/HEAD/j/a.img.gz -------------------------------------------------------------------------------- /a/80m.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyu/osfs09/HEAD/a/80m.img.gz -------------------------------------------------------------------------------- /b/80m.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyu/osfs09/HEAD/b/80m.img.gz -------------------------------------------------------------------------------- /c/80m.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyu/osfs09/HEAD/c/80m.img.gz -------------------------------------------------------------------------------- /d/80m.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyu/osfs09/HEAD/d/80m.img.gz -------------------------------------------------------------------------------- /e/80m.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyu/osfs09/HEAD/e/80m.img.gz -------------------------------------------------------------------------------- /f/80m.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyu/osfs09/HEAD/f/80m.img.gz -------------------------------------------------------------------------------- /g/80m.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyu/osfs09/HEAD/g/80m.img.gz -------------------------------------------------------------------------------- /h/80m.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyu/osfs09/HEAD/h/80m.img.gz -------------------------------------------------------------------------------- /i/80m.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyu/osfs09/HEAD/i/80m.img.gz -------------------------------------------------------------------------------- /j/80m.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyu/osfs09/HEAD/j/80m.img.gz -------------------------------------------------------------------------------- /e/tmp/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile 2 | CC = gcc 3 | CFLAGS = -g 4 | SRC = f.c 5 | BIN = f 6 | 7 | # All Phony Targets 8 | .PHONY : everything final clean realclean all 9 | 10 | # Default starting position 11 | everything : $(BIN) 12 | 13 | all : realclean everything 14 | 15 | final : all clean 16 | 17 | clean : 18 | rm -f *.o 19 | 20 | realclean : 21 | rm -f $(BIN) *.o 22 | 23 | $(BIN): $(SRC) 24 | $(CC) $(CFLAGS) -o $@ $< 25 | 26 | -------------------------------------------------------------------------------- /b/include/config.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file config.h 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #define MINOR_BOOT MINOR_hd2a 11 | -------------------------------------------------------------------------------- /c/include/config.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file config.h 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #define MINOR_BOOT MINOR_hd2a 11 | -------------------------------------------------------------------------------- /d/include/config.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file config.h 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #define MINOR_BOOT MINOR_hd2a 11 | -------------------------------------------------------------------------------- /e/include/sys/config.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file config.h 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #define MINOR_BOOT MINOR_hd2a 11 | -------------------------------------------------------------------------------- /f/include/sys/config.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file config.h 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #define MINOR_BOOT MINOR_hd2a 11 | -------------------------------------------------------------------------------- /g/splitgraphs: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | while read line 4 | do 5 | kw=`echo $line | awk -F "[ ]" '{print $1}'` 6 | if [ "$kw" == "digraph" ]; then 7 | gname=`echo $line | awk -F "[ ]" '{print $2}'` 8 | fname=$gname".dot" 9 | pname=$gname".png" 10 | echo $kw" "$gname 11 | 12 | echo $line > $fname 13 | while read line 14 | do 15 | if [ "$line" == "--separator--" ]; then 16 | dot -Tpng $fname -o $pname 17 | break 18 | fi 19 | 20 | echo $line >> $fname 21 | done 22 | fi 23 | done 24 | 25 | -------------------------------------------------------------------------------- /h/scripts/splitgraphs: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | while read line 4 | do 5 | kw=`echo $line | awk -F "[ ]" '{print $1}'` 6 | if [ "$kw" == "digraph" ]; then 7 | gname=`echo $line | awk -F "[ ]" '{print $2}'` 8 | fname=$gname".dot" 9 | pname=$gname".png" 10 | echo $kw" "$gname 11 | 12 | echo $line > $fname 13 | while read line 14 | do 15 | if [ "$line" == "--separator--" ]; then 16 | dot -Tpng $fname -o $pname 17 | break 18 | fi 19 | 20 | echo $line >> $fname 21 | done 22 | fi 23 | done 24 | 25 | -------------------------------------------------------------------------------- /i/scripts/splitgraphs: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | while read line 4 | do 5 | kw=`echo $line | awk -F "[ ]" '{print $1}'` 6 | if [ "$kw" == "digraph" ]; then 7 | gname=`echo $line | awk -F "[ ]" '{print $2}'` 8 | fname=$gname".dot" 9 | pname=$gname".png" 10 | echo $kw" "$gname 11 | 12 | echo $line > $fname 13 | while read line 14 | do 15 | if [ "$line" == "--separator--" ]; then 16 | dot -Tpng $fname -o $pname 17 | break 18 | fi 19 | 20 | echo $line >> $fname 21 | done 22 | fi 23 | done 24 | 25 | -------------------------------------------------------------------------------- /j/scripts/splitgraphs: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | while read line 4 | do 5 | kw=`echo $line | awk -F "[ ]" '{print $1}'` 6 | if [ "$kw" == "digraph" ]; then 7 | gname=`echo $line | awk -F "[ ]" '{print $2}'` 8 | fname=$gname".dot" 9 | pname=$gname".png" 10 | echo $kw" "$gname 11 | 12 | echo $line > $fname 13 | while read line 14 | do 15 | if [ "$line" == "--separator--" ]; then 16 | dot -Tpng $fname -o $pname 17 | break 18 | fi 19 | 20 | echo $line >> $fname 21 | done 22 | fi 23 | done 24 | 25 | -------------------------------------------------------------------------------- /g/include/sys/config.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file config.h 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #define MINOR_BOOT MINOR_hd2a 11 | 12 | /* 13 | * disk log 14 | */ 15 | #define ENABLE_DISK_LOG 16 | #define SET_LOG_SECT_SMAP_AT_STARTUP 17 | #define MEMSET_LOG_SECTS 18 | #define NR_SECTS_FOR_LOG NR_DEFAULT_FILE_SECTS 19 | -------------------------------------------------------------------------------- /h/include/sys/config.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file config.h 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #define MINOR_BOOT MINOR_hd2a 11 | 12 | /* 13 | * disk log 14 | */ 15 | #define ENABLE_DISK_LOG 16 | #define SET_LOG_SECT_SMAP_AT_STARTUP 17 | #define MEMSET_LOG_SECTS 18 | #define NR_SECTS_FOR_LOG NR_DEFAULT_FILE_SECTS 19 | -------------------------------------------------------------------------------- /i/include/sys/config.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file config.h 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #define MINOR_BOOT MINOR_hd2a 11 | 12 | /* 13 | * disk log 14 | */ 15 | #define ENABLE_DISK_LOG 16 | #define SET_LOG_SECT_SMAP_AT_STARTUP 17 | #define MEMSET_LOG_SECTS 18 | #define NR_SECTS_FOR_LOG NR_DEFAULT_FILE_SECTS 19 | -------------------------------------------------------------------------------- /j/include/sys/config.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file config.h 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #define MINOR_BOOT MINOR_hd2a 11 | 12 | /* 13 | * disk log 14 | */ 15 | #define ENABLE_DISK_LOG 16 | #define SET_LOG_SECT_SMAP_AT_STARTUP 17 | #define MEMSET_LOG_SECTS 18 | #define NR_SECTS_FOR_LOG NR_DEFAULT_FILE_SECTS 19 | -------------------------------------------------------------------------------- /a/include/tty.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | tty.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_TTY_H_ 9 | #define _ORANGES_TTY_H_ 10 | 11 | 12 | #define TTY_IN_BYTES 256 /* tty input queue size */ 13 | 14 | struct s_console; 15 | 16 | /* TTY */ 17 | typedef struct s_tty 18 | { 19 | u32 in_buf[TTY_IN_BYTES]; /* TTY 输入缓冲区 */ 20 | u32* p_inbuf_head; /* 指向缓冲区中下一个空闲位置 */ 21 | u32* p_inbuf_tail; /* 指向键盘任务应处理的键值 */ 22 | int inbuf_count; /* 缓冲区中已经填充了多少 */ 23 | 24 | struct s_console * p_console; 25 | }TTY; 26 | 27 | 28 | #endif /* _ORANGES_TTY_H_ */ 29 | -------------------------------------------------------------------------------- /b/include/tty.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | tty.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_TTY_H_ 9 | #define _ORANGES_TTY_H_ 10 | 11 | 12 | #define TTY_IN_BYTES 256 /* tty input queue size */ 13 | 14 | struct s_console; 15 | 16 | /* TTY */ 17 | typedef struct s_tty 18 | { 19 | u32 in_buf[TTY_IN_BYTES]; /* TTY 输入缓冲区 */ 20 | u32* p_inbuf_head; /* 指向缓冲区中下一个空闲位置 */ 21 | u32* p_inbuf_tail; /* 指向键盘任务应处理的键值 */ 22 | int inbuf_count; /* 缓冲区中已经填充了多少 */ 23 | 24 | struct s_console * p_console; 25 | }TTY; 26 | 27 | 28 | #endif /* _ORANGES_TTY_H_ */ 29 | -------------------------------------------------------------------------------- /c/include/tty.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | tty.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_TTY_H_ 9 | #define _ORANGES_TTY_H_ 10 | 11 | 12 | #define TTY_IN_BYTES 256 /* tty input queue size */ 13 | 14 | struct s_console; 15 | 16 | /* TTY */ 17 | typedef struct s_tty 18 | { 19 | u32 in_buf[TTY_IN_BYTES]; /* TTY 输入缓冲区 */ 20 | u32* p_inbuf_head; /* 指向缓冲区中下一个空闲位置 */ 21 | u32* p_inbuf_tail; /* 指向键盘任务应处理的键值 */ 22 | int inbuf_count; /* 缓冲区中已经填充了多少 */ 23 | 24 | struct s_console * p_console; 25 | }TTY; 26 | 27 | 28 | #endif /* _ORANGES_TTY_H_ */ 29 | -------------------------------------------------------------------------------- /d/include/tty.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | tty.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_TTY_H_ 9 | #define _ORANGES_TTY_H_ 10 | 11 | 12 | #define TTY_IN_BYTES 256 /* tty input queue size */ 13 | 14 | struct s_console; 15 | 16 | /* TTY */ 17 | typedef struct s_tty 18 | { 19 | u32 in_buf[TTY_IN_BYTES]; /* TTY 输入缓冲区 */ 20 | u32* p_inbuf_head; /* 指向缓冲区中下一个空闲位置 */ 21 | u32* p_inbuf_tail; /* 指向键盘任务应处理的键值 */ 22 | int inbuf_count; /* 缓冲区中已经填充了多少 */ 23 | 24 | struct s_console * p_console; 25 | }TTY; 26 | 27 | 28 | #endif /* _ORANGES_TTY_H_ */ 29 | -------------------------------------------------------------------------------- /e/include/sys/tty.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | tty.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_TTY_H_ 9 | #define _ORANGES_TTY_H_ 10 | 11 | 12 | #define TTY_IN_BYTES 256 /* tty input queue size */ 13 | 14 | struct s_console; 15 | 16 | /* TTY */ 17 | typedef struct s_tty 18 | { 19 | u32 in_buf[TTY_IN_BYTES]; /* TTY 输入缓冲区 */ 20 | u32* p_inbuf_head; /* 指向缓冲区中下一个空闲位置 */ 21 | u32* p_inbuf_tail; /* 指向键盘任务应处理的键值 */ 22 | int inbuf_count; /* 缓冲区中已经填充了多少 */ 23 | 24 | struct s_console * p_console; 25 | }TTY; 26 | 27 | 28 | #endif /* _ORANGES_TTY_H_ */ 29 | -------------------------------------------------------------------------------- /f/include/sys/tty.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | tty.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_TTY_H_ 9 | #define _ORANGES_TTY_H_ 10 | 11 | 12 | #define TTY_IN_BYTES 256 /* tty input queue size */ 13 | 14 | struct s_console; 15 | 16 | /* TTY */ 17 | typedef struct s_tty 18 | { 19 | u32 in_buf[TTY_IN_BYTES]; /* TTY 输入缓冲区 */ 20 | u32* p_inbuf_head; /* 指向缓冲区中下一个空闲位置 */ 21 | u32* p_inbuf_tail; /* 指向键盘任务应处理的键值 */ 22 | int inbuf_count; /* 缓冲区中已经填充了多少 */ 23 | 24 | struct s_console * p_console; 25 | }TTY; 26 | 27 | 28 | #endif /* _ORANGES_TTY_H_ */ 29 | -------------------------------------------------------------------------------- /g/include/sys/tty.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | tty.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_TTY_H_ 9 | #define _ORANGES_TTY_H_ 10 | 11 | 12 | #define TTY_IN_BYTES 256 /* tty input queue size */ 13 | 14 | struct s_console; 15 | 16 | /* TTY */ 17 | typedef struct s_tty 18 | { 19 | u32 in_buf[TTY_IN_BYTES]; /* TTY 输入缓冲区 */ 20 | u32* p_inbuf_head; /* 指向缓冲区中下一个空闲位置 */ 21 | u32* p_inbuf_tail; /* 指向键盘任务应处理的键值 */ 22 | int inbuf_count; /* 缓冲区中已经填充了多少 */ 23 | 24 | struct s_console * p_console; 25 | }TTY; 26 | 27 | 28 | #endif /* _ORANGES_TTY_H_ */ 29 | -------------------------------------------------------------------------------- /h/include/sys/tty.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | tty.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_TTY_H_ 9 | #define _ORANGES_TTY_H_ 10 | 11 | 12 | #define TTY_IN_BYTES 256 /* tty input queue size */ 13 | 14 | struct s_console; 15 | 16 | /* TTY */ 17 | typedef struct s_tty 18 | { 19 | u32 in_buf[TTY_IN_BYTES]; /* TTY 输入缓冲区 */ 20 | u32* p_inbuf_head; /* 指向缓冲区中下一个空闲位置 */ 21 | u32* p_inbuf_tail; /* 指向键盘任务应处理的键值 */ 22 | int inbuf_count; /* 缓冲区中已经填充了多少 */ 23 | 24 | struct s_console * p_console; 25 | }TTY; 26 | 27 | 28 | #endif /* _ORANGES_TTY_H_ */ 29 | -------------------------------------------------------------------------------- /a/include/string.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | string.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | PUBLIC void* memcpy(void* p_dst, void* p_src, int size); 9 | PUBLIC void memset(void* p_dst, char ch, int size); 10 | PUBLIC int strlen(char* p_str); 11 | 12 | /** 13 | * `phys_copy' and `phys_set' are used only in the kernel, where segments 14 | * are all flat (based on 0). In the meanwhile, currently linear address 15 | * space is mapped to the identical physical address space. Therefore, 16 | * a `physical copy' will be as same as a common copy, so does `phys_set'. 17 | */ 18 | #define phys_copy memcpy 19 | #define phys_set memset 20 | 21 | -------------------------------------------------------------------------------- /b/include/string.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | string.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | PUBLIC void* memcpy(void* p_dst, void* p_src, int size); 9 | PUBLIC void memset(void* p_dst, char ch, int size); 10 | PUBLIC int strlen(char* p_str); 11 | 12 | /** 13 | * `phys_copy' and `phys_set' are used only in the kernel, where segments 14 | * are all flat (based on 0). In the meanwhile, currently linear address 15 | * space is mapped to the identical physical address space. Therefore, 16 | * a `physical copy' will be as same as a common copy, so does `phys_set'. 17 | */ 18 | #define phys_copy memcpy 19 | #define phys_set memset 20 | 21 | -------------------------------------------------------------------------------- /c/include/string.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | string.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | PUBLIC void* memcpy(void* p_dst, void* p_src, int size); 9 | PUBLIC void memset(void* p_dst, char ch, int size); 10 | PUBLIC int strlen(char* p_str); 11 | 12 | /** 13 | * `phys_copy' and `phys_set' are used only in the kernel, where segments 14 | * are all flat (based on 0). In the meanwhile, currently linear address 15 | * space is mapped to the identical physical address space. Therefore, 16 | * a `physical copy' will be as same as a common copy, so does `phys_set'. 17 | */ 18 | #define phys_copy memcpy 19 | #define phys_set memset 20 | 21 | -------------------------------------------------------------------------------- /d/include/string.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | string.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | PUBLIC void* memcpy(void* p_dst, void* p_src, int size); 9 | PUBLIC void memset(void* p_dst, char ch, int size); 10 | PUBLIC int strlen(char* p_str); 11 | 12 | /** 13 | * `phys_copy' and `phys_set' are used only in the kernel, where segments 14 | * are all flat (based on 0). In the meanwhile, currently linear address 15 | * space is mapped to the identical physical address space. Therefore, 16 | * a `physical copy' will be as same as a common copy, so does `phys_set'. 17 | */ 18 | #define phys_copy memcpy 19 | #define phys_set memset 20 | 21 | -------------------------------------------------------------------------------- /i/include/sys/tty.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | tty.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_TTY_H_ 9 | #define _ORANGES_TTY_H_ 10 | 11 | 12 | #define TTY_IN_BYTES 256 /* tty input queue size */ 13 | #define TTY_OUT_BUF_LEN 2 /* tty output buffer size */ 14 | 15 | struct s_tty; 16 | struct s_console; 17 | 18 | /* TTY */ 19 | typedef struct s_tty 20 | { 21 | u32 ibuf[TTY_IN_BYTES]; /* TTY input buffer */ 22 | u32* ibuf_head; /* the next free slot */ 23 | u32* ibuf_tail; /* the val to be processed by TTY */ 24 | int ibuf_cnt; /* how many */ 25 | 26 | int tty_caller; 27 | int tty_procnr; 28 | void* tty_req_buf; 29 | int tty_left_cnt; 30 | int tty_trans_cnt; 31 | 32 | struct s_console * console; 33 | }TTY; 34 | 35 | #endif /* _ORANGES_TTY_H_ */ 36 | -------------------------------------------------------------------------------- /j/include/sys/tty.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | tty.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_TTY_H_ 9 | #define _ORANGES_TTY_H_ 10 | 11 | 12 | #define TTY_IN_BYTES 256 /* tty input queue size */ 13 | #define TTY_OUT_BUF_LEN 2 /* tty output buffer size */ 14 | 15 | struct s_tty; 16 | struct s_console; 17 | 18 | /* TTY */ 19 | typedef struct s_tty 20 | { 21 | u32 ibuf[TTY_IN_BYTES]; /* TTY input buffer */ 22 | u32* ibuf_head; /* the next free slot */ 23 | u32* ibuf_tail; /* the val to be processed by TTY */ 24 | int ibuf_cnt; /* how many */ 25 | 26 | int tty_caller; 27 | int tty_procnr; 28 | void* tty_req_buf; 29 | int tty_left_cnt; 30 | int tty_trans_cnt; 31 | 32 | struct s_console * console; 33 | }TTY; 34 | 35 | #endif /* _ORANGES_TTY_H_ */ 36 | -------------------------------------------------------------------------------- /a/include/console.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | console.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_CONSOLE_H_ 9 | #define _ORANGES_CONSOLE_H_ 10 | 11 | 12 | /* CONSOLE */ 13 | typedef struct s_console 14 | { 15 | unsigned int current_start_addr; /* 当前显示到了什么位置 */ 16 | unsigned int original_addr; /* 当前控制台对应显存位置 */ 17 | unsigned int v_mem_limit; /* 当前控制台占的显存大小 */ 18 | unsigned int cursor; /* 当前光标位置 */ 19 | }CONSOLE; 20 | 21 | #define SCR_UP 1 /* scroll forward */ 22 | #define SCR_DN -1 /* scroll backward */ 23 | 24 | #define SCR_SIZE (80 * 25) 25 | #define SCR_WIDTH 80 26 | 27 | #define DEFAULT_CHAR_COLOR (MAKE_COLOR(BLACK, WHITE)) 28 | #define GRAY_CHAR (MAKE_COLOR(BLACK, BLACK) | BRIGHT) 29 | #define RED_CHAR (MAKE_COLOR(BLUE, RED) | BRIGHT) 30 | 31 | 32 | #endif /* _ORANGES_CONSOLE_H_ */ 33 | -------------------------------------------------------------------------------- /b/include/console.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | console.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_CONSOLE_H_ 9 | #define _ORANGES_CONSOLE_H_ 10 | 11 | 12 | /* CONSOLE */ 13 | typedef struct s_console 14 | { 15 | unsigned int current_start_addr; /* 当前显示到了什么位置 */ 16 | unsigned int original_addr; /* 当前控制台对应显存位置 */ 17 | unsigned int v_mem_limit; /* 当前控制台占的显存大小 */ 18 | unsigned int cursor; /* 当前光标位置 */ 19 | }CONSOLE; 20 | 21 | #define SCR_UP 1 /* scroll forward */ 22 | #define SCR_DN -1 /* scroll backward */ 23 | 24 | #define SCR_SIZE (80 * 25) 25 | #define SCR_WIDTH 80 26 | 27 | #define DEFAULT_CHAR_COLOR (MAKE_COLOR(BLACK, WHITE)) 28 | #define GRAY_CHAR (MAKE_COLOR(BLACK, BLACK) | BRIGHT) 29 | #define RED_CHAR (MAKE_COLOR(BLUE, RED) | BRIGHT) 30 | 31 | 32 | #endif /* _ORANGES_CONSOLE_H_ */ 33 | -------------------------------------------------------------------------------- /c/include/console.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | console.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_CONSOLE_H_ 9 | #define _ORANGES_CONSOLE_H_ 10 | 11 | 12 | /* CONSOLE */ 13 | typedef struct s_console 14 | { 15 | unsigned int current_start_addr; /* 当前显示到了什么位置 */ 16 | unsigned int original_addr; /* 当前控制台对应显存位置 */ 17 | unsigned int v_mem_limit; /* 当前控制台占的显存大小 */ 18 | unsigned int cursor; /* 当前光标位置 */ 19 | }CONSOLE; 20 | 21 | #define SCR_UP 1 /* scroll forward */ 22 | #define SCR_DN -1 /* scroll backward */ 23 | 24 | #define SCR_SIZE (80 * 25) 25 | #define SCR_WIDTH 80 26 | 27 | #define DEFAULT_CHAR_COLOR (MAKE_COLOR(BLACK, WHITE)) 28 | #define GRAY_CHAR (MAKE_COLOR(BLACK, BLACK) | BRIGHT) 29 | #define RED_CHAR (MAKE_COLOR(BLUE, RED) | BRIGHT) 30 | 31 | 32 | #endif /* _ORANGES_CONSOLE_H_ */ 33 | -------------------------------------------------------------------------------- /d/include/console.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | console.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_CONSOLE_H_ 9 | #define _ORANGES_CONSOLE_H_ 10 | 11 | 12 | /* CONSOLE */ 13 | typedef struct s_console 14 | { 15 | unsigned int current_start_addr; /* 当前显示到了什么位置 */ 16 | unsigned int original_addr; /* 当前控制台对应显存位置 */ 17 | unsigned int v_mem_limit; /* 当前控制台占的显存大小 */ 18 | unsigned int cursor; /* 当前光标位置 */ 19 | }CONSOLE; 20 | 21 | #define SCR_UP 1 /* scroll forward */ 22 | #define SCR_DN -1 /* scroll backward */ 23 | 24 | #define SCR_SIZE (80 * 25) 25 | #define SCR_WIDTH 80 26 | 27 | #define DEFAULT_CHAR_COLOR (MAKE_COLOR(BLACK, WHITE)) 28 | #define GRAY_CHAR (MAKE_COLOR(BLACK, BLACK) | BRIGHT) 29 | #define RED_CHAR (MAKE_COLOR(BLUE, RED) | BRIGHT) 30 | 31 | 32 | #endif /* _ORANGES_CONSOLE_H_ */ 33 | -------------------------------------------------------------------------------- /e/include/sys/console.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | console.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_CONSOLE_H_ 9 | #define _ORANGES_CONSOLE_H_ 10 | 11 | 12 | /* CONSOLE */ 13 | typedef struct s_console 14 | { 15 | unsigned int current_start_addr; /* 当前显示到了什么位置 */ 16 | unsigned int original_addr; /* 当前控制台对应显存位置 */ 17 | unsigned int v_mem_limit; /* 当前控制台占的显存大小 */ 18 | unsigned int cursor; /* 当前光标位置 */ 19 | }CONSOLE; 20 | 21 | #define SCR_UP 1 /* scroll forward */ 22 | #define SCR_DN -1 /* scroll backward */ 23 | 24 | #define SCR_SIZE (80 * 25) 25 | #define SCR_WIDTH 80 26 | 27 | #define DEFAULT_CHAR_COLOR (MAKE_COLOR(BLACK, WHITE)) 28 | #define GRAY_CHAR (MAKE_COLOR(BLACK, BLACK) | BRIGHT) 29 | #define RED_CHAR (MAKE_COLOR(BLUE, RED) | BRIGHT) 30 | 31 | 32 | #endif /* _ORANGES_CONSOLE_H_ */ 33 | -------------------------------------------------------------------------------- /f/include/sys/console.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | console.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_CONSOLE_H_ 9 | #define _ORANGES_CONSOLE_H_ 10 | 11 | 12 | /* CONSOLE */ 13 | typedef struct s_console 14 | { 15 | unsigned int current_start_addr; /* 当前显示到了什么位置 */ 16 | unsigned int original_addr; /* 当前控制台对应显存位置 */ 17 | unsigned int v_mem_limit; /* 当前控制台占的显存大小 */ 18 | unsigned int cursor; /* 当前光标位置 */ 19 | }CONSOLE; 20 | 21 | #define SCR_UP 1 /* scroll forward */ 22 | #define SCR_DN -1 /* scroll backward */ 23 | 24 | #define SCR_SIZE (80 * 25) 25 | #define SCR_WIDTH 80 26 | 27 | #define DEFAULT_CHAR_COLOR (MAKE_COLOR(BLACK, WHITE)) 28 | #define GRAY_CHAR (MAKE_COLOR(BLACK, BLACK) | BRIGHT) 29 | #define RED_CHAR (MAKE_COLOR(BLUE, RED) | BRIGHT) 30 | 31 | 32 | #endif /* _ORANGES_CONSOLE_H_ */ 33 | -------------------------------------------------------------------------------- /g/include/sys/console.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | console.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_CONSOLE_H_ 9 | #define _ORANGES_CONSOLE_H_ 10 | 11 | 12 | /* CONSOLE */ 13 | typedef struct s_console 14 | { 15 | unsigned int current_start_addr; /* 当前显示到了什么位置 */ 16 | unsigned int original_addr; /* 当前控制台对应显存位置 */ 17 | unsigned int v_mem_limit; /* 当前控制台占的显存大小 */ 18 | unsigned int cursor; /* 当前光标位置 */ 19 | }CONSOLE; 20 | 21 | #define SCR_UP 1 /* scroll forward */ 22 | #define SCR_DN -1 /* scroll backward */ 23 | 24 | #define SCR_SIZE (80 * 25) 25 | #define SCR_WIDTH 80 26 | 27 | #define DEFAULT_CHAR_COLOR (MAKE_COLOR(BLACK, WHITE)) 28 | #define GRAY_CHAR (MAKE_COLOR(BLACK, BLACK) | BRIGHT) 29 | #define RED_CHAR (MAKE_COLOR(BLUE, RED) | BRIGHT) 30 | 31 | 32 | #endif /* _ORANGES_CONSOLE_H_ */ 33 | -------------------------------------------------------------------------------- /h/include/sys/console.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | console.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_CONSOLE_H_ 9 | #define _ORANGES_CONSOLE_H_ 10 | 11 | 12 | /* CONSOLE */ 13 | typedef struct s_console 14 | { 15 | unsigned int current_start_addr; /* 当前显示到了什么位置 */ 16 | unsigned int original_addr; /* 当前控制台对应显存位置 */ 17 | unsigned int v_mem_limit; /* 当前控制台占的显存大小 */ 18 | unsigned int cursor; /* 当前光标位置 */ 19 | }CONSOLE; 20 | 21 | #define SCR_UP 1 /* scroll forward */ 22 | #define SCR_DN -1 /* scroll backward */ 23 | 24 | #define SCR_SIZE (80 * 25) 25 | #define SCR_WIDTH 80 26 | 27 | #define DEFAULT_CHAR_COLOR (MAKE_COLOR(BLACK, WHITE)) 28 | #define GRAY_CHAR (MAKE_COLOR(BLACK, BLACK) | BRIGHT) 29 | #define RED_CHAR (MAKE_COLOR(BLUE, RED) | BRIGHT) 30 | 31 | 32 | #endif /* _ORANGES_CONSOLE_H_ */ 33 | -------------------------------------------------------------------------------- /i/include/sys/console.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | console.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_CONSOLE_H_ 9 | #define _ORANGES_CONSOLE_H_ 10 | 11 | /* CONSOLE */ 12 | typedef struct s_console 13 | { 14 | unsigned int crtc_start; /* set CRTC start addr reg */ 15 | unsigned int orig; /* start addr of the console */ 16 | unsigned int con_size; /* how many words does the console have */ 17 | unsigned int cursor; 18 | int is_full; 19 | }CONSOLE; 20 | 21 | 22 | #define SCR_UP 1 /* scroll upward */ 23 | #define SCR_DN -1 /* scroll downward */ 24 | 25 | #define SCR_SIZE (80 * 25) 26 | #define SCR_WIDTH 80 27 | 28 | #define DEFAULT_CHAR_COLOR (MAKE_COLOR(BLACK, WHITE)) 29 | #define GRAY_CHAR (MAKE_COLOR(BLACK, BLACK) | BRIGHT) 30 | #define RED_CHAR (MAKE_COLOR(BLUE, RED) | BRIGHT) 31 | 32 | #endif /* _ORANGES_CONSOLE_H_ */ 33 | -------------------------------------------------------------------------------- /j/include/sys/console.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | console.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_CONSOLE_H_ 9 | #define _ORANGES_CONSOLE_H_ 10 | 11 | /* CONSOLE */ 12 | typedef struct s_console 13 | { 14 | unsigned int crtc_start; /* set CRTC start addr reg */ 15 | unsigned int orig; /* start addr of the console */ 16 | unsigned int con_size; /* how many words does the console have */ 17 | unsigned int cursor; 18 | int is_full; 19 | }CONSOLE; 20 | 21 | 22 | #define SCR_UP 1 /* scroll upward */ 23 | #define SCR_DN -1 /* scroll downward */ 24 | 25 | #define SCR_SIZE (80 * 25) 26 | #define SCR_WIDTH 80 27 | 28 | #define DEFAULT_CHAR_COLOR (MAKE_COLOR(BLACK, WHITE)) 29 | #define GRAY_CHAR (MAKE_COLOR(BLACK, BLACK) | BRIGHT) 30 | #define RED_CHAR (MAKE_COLOR(BLUE, RED) | BRIGHT) 31 | 32 | #endif /* _ORANGES_CONSOLE_H_ */ 33 | -------------------------------------------------------------------------------- /a/boot/include/load.inc: -------------------------------------------------------------------------------- 1 | 2 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | ; load.inc 4 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | ; Forrest Yu, 2005 6 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | 8 | 9 | BaseOfLoader equ 09000h ; LOADER.BIN 被加载到的位置 ---- 段地址 10 | OffsetOfLoader equ 0100h ; LOADER.BIN 被加载到的位置 ---- 偏移地址 11 | 12 | BaseOfLoaderPhyAddr equ BaseOfLoader * 10h ; LOADER.BIN 被加载到的位置 ---- 物理地址 (= BaseOfLoader * 10h) 13 | 14 | 15 | BaseOfKernelFile equ 08000h ; KERNEL.BIN 被加载到的位置 ---- 段地址 16 | OffsetOfKernelFile equ 0h ; KERNEL.BIN 被加载到的位置 ---- 偏移地址 17 | 18 | BaseOfKernelFilePhyAddr equ BaseOfKernelFile * 10h 19 | KernelEntryPointPhyAddr equ 030400h ; 注意:1、必须与 MAKEFILE 中参数 -Ttext 的值相等!! 20 | ; 2、这是个地址而非仅仅是个偏移,如果 -Ttext 的值为 0x400400,则它的值也应该是 0x400400。 21 | 22 | PageDirBase equ 200000h ; 页目录开始地址: 2M 23 | PageTblBase equ 201000h ; 页表开始地址: 2M + 4K 24 | 25 | -------------------------------------------------------------------------------- /b/boot/include/load.inc: -------------------------------------------------------------------------------- 1 | 2 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | ; load.inc 4 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | ; Forrest Yu, 2005 6 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | 8 | 9 | BaseOfLoader equ 09000h ; LOADER.BIN 被加载到的位置 ---- 段地址 10 | OffsetOfLoader equ 0100h ; LOADER.BIN 被加载到的位置 ---- 偏移地址 11 | 12 | BaseOfLoaderPhyAddr equ BaseOfLoader * 10h ; LOADER.BIN 被加载到的位置 ---- 物理地址 (= BaseOfLoader * 10h) 13 | 14 | 15 | BaseOfKernelFile equ 08000h ; KERNEL.BIN 被加载到的位置 ---- 段地址 16 | OffsetOfKernelFile equ 0h ; KERNEL.BIN 被加载到的位置 ---- 偏移地址 17 | 18 | BaseOfKernelFilePhyAddr equ BaseOfKernelFile * 10h 19 | KernelEntryPointPhyAddr equ 030400h ; 注意:1、必须与 MAKEFILE 中参数 -Ttext 的值相等!! 20 | ; 2、这是个地址而非仅仅是个偏移,如果 -Ttext 的值为 0x400400,则它的值也应该是 0x400400。 21 | 22 | PageDirBase equ 200000h ; 页目录开始地址: 2M 23 | PageTblBase equ 201000h ; 页表开始地址: 2M + 4K 24 | 25 | -------------------------------------------------------------------------------- /c/boot/include/load.inc: -------------------------------------------------------------------------------- 1 | 2 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | ; load.inc 4 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | ; Forrest Yu, 2005 6 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | 8 | 9 | BaseOfLoader equ 09000h ; LOADER.BIN 被加载到的位置 ---- 段地址 10 | OffsetOfLoader equ 0100h ; LOADER.BIN 被加载到的位置 ---- 偏移地址 11 | 12 | BaseOfLoaderPhyAddr equ BaseOfLoader * 10h ; LOADER.BIN 被加载到的位置 ---- 物理地址 (= BaseOfLoader * 10h) 13 | 14 | 15 | BaseOfKernelFile equ 08000h ; KERNEL.BIN 被加载到的位置 ---- 段地址 16 | OffsetOfKernelFile equ 0h ; KERNEL.BIN 被加载到的位置 ---- 偏移地址 17 | 18 | BaseOfKernelFilePhyAddr equ BaseOfKernelFile * 10h 19 | KernelEntryPointPhyAddr equ 030400h ; 注意:1、必须与 MAKEFILE 中参数 -Ttext 的值相等!! 20 | ; 2、这是个地址而非仅仅是个偏移,如果 -Ttext 的值为 0x400400,则它的值也应该是 0x400400。 21 | 22 | PageDirBase equ 200000h ; 页目录开始地址: 2M 23 | PageTblBase equ 201000h ; 页表开始地址: 2M + 4K 24 | 25 | -------------------------------------------------------------------------------- /d/boot/include/load.inc: -------------------------------------------------------------------------------- 1 | 2 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | ; load.inc 4 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | ; Forrest Yu, 2005 6 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | 8 | 9 | BaseOfLoader equ 09000h ; LOADER.BIN 被加载到的位置 ---- 段地址 10 | OffsetOfLoader equ 0100h ; LOADER.BIN 被加载到的位置 ---- 偏移地址 11 | 12 | BaseOfLoaderPhyAddr equ BaseOfLoader * 10h ; LOADER.BIN 被加载到的位置 ---- 物理地址 (= BaseOfLoader * 10h) 13 | 14 | 15 | BaseOfKernelFile equ 08000h ; KERNEL.BIN 被加载到的位置 ---- 段地址 16 | OffsetOfKernelFile equ 0h ; KERNEL.BIN 被加载到的位置 ---- 偏移地址 17 | 18 | BaseOfKernelFilePhyAddr equ BaseOfKernelFile * 10h 19 | KernelEntryPointPhyAddr equ 030400h ; 注意:1、必须与 MAKEFILE 中参数 -Ttext 的值相等!! 20 | ; 2、这是个地址而非仅仅是个偏移,如果 -Ttext 的值为 0x400400,则它的值也应该是 0x400400。 21 | 22 | PageDirBase equ 200000h ; 页目录开始地址: 2M 23 | PageTblBase equ 201000h ; 页表开始地址: 2M + 4K 24 | 25 | -------------------------------------------------------------------------------- /e/boot/include/load.inc: -------------------------------------------------------------------------------- 1 | 2 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | ; load.inc 4 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | ; Forrest Yu, 2005 6 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | 8 | 9 | BaseOfLoader equ 09000h ; LOADER.BIN 被加载到的位置 ---- 段地址 10 | OffsetOfLoader equ 0100h ; LOADER.BIN 被加载到的位置 ---- 偏移地址 11 | 12 | BaseOfLoaderPhyAddr equ BaseOfLoader * 10h ; LOADER.BIN 被加载到的位置 ---- 物理地址 (= BaseOfLoader * 10h) 13 | 14 | 15 | BaseOfKernelFile equ 08000h ; KERNEL.BIN 被加载到的位置 ---- 段地址 16 | OffsetOfKernelFile equ 0h ; KERNEL.BIN 被加载到的位置 ---- 偏移地址 17 | 18 | BaseOfKernelFilePhyAddr equ BaseOfKernelFile * 10h 19 | KernelEntryPointPhyAddr equ 030400h ; 注意:1、必须与 MAKEFILE 中参数 -Ttext 的值相等!! 20 | ; 2、这是个地址而非仅仅是个偏移,如果 -Ttext 的值为 0x400400,则它的值也应该是 0x400400。 21 | 22 | PageDirBase equ 200000h ; 页目录开始地址: 2M 23 | PageTblBase equ 201000h ; 页表开始地址: 2M + 4K 24 | 25 | -------------------------------------------------------------------------------- /f/boot/include/load.inc: -------------------------------------------------------------------------------- 1 | 2 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | ; load.inc 4 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | ; Forrest Yu, 2005 6 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | 8 | 9 | BaseOfLoader equ 09000h ; LOADER.BIN 被加载到的位置 ---- 段地址 10 | OffsetOfLoader equ 0100h ; LOADER.BIN 被加载到的位置 ---- 偏移地址 11 | 12 | BaseOfLoaderPhyAddr equ BaseOfLoader * 10h ; LOADER.BIN 被加载到的位置 ---- 物理地址 (= BaseOfLoader * 10h) 13 | 14 | 15 | BaseOfKernelFile equ 08000h ; KERNEL.BIN 被加载到的位置 ---- 段地址 16 | OffsetOfKernelFile equ 0h ; KERNEL.BIN 被加载到的位置 ---- 偏移地址 17 | 18 | BaseOfKernelFilePhyAddr equ BaseOfKernelFile * 10h 19 | KernelEntryPointPhyAddr equ 030400h ; 注意:1、必须与 MAKEFILE 中参数 -Ttext 的值相等!! 20 | ; 2、这是个地址而非仅仅是个偏移,如果 -Ttext 的值为 0x400400,则它的值也应该是 0x400400。 21 | 22 | PageDirBase equ 200000h ; 页目录开始地址: 2M 23 | PageTblBase equ 201000h ; 页表开始地址: 2M + 4K 24 | 25 | -------------------------------------------------------------------------------- /g/boot/include/load.inc: -------------------------------------------------------------------------------- 1 | 2 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | ; load.inc 4 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | ; Forrest Yu, 2005 6 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | 8 | 9 | BaseOfLoader equ 09000h ; LOADER.BIN 被加载到的位置 ---- 段地址 10 | OffsetOfLoader equ 0100h ; LOADER.BIN 被加载到的位置 ---- 偏移地址 11 | 12 | BaseOfLoaderPhyAddr equ BaseOfLoader * 10h ; LOADER.BIN 被加载到的位置 ---- 物理地址 (= BaseOfLoader * 10h) 13 | 14 | 15 | BaseOfKernelFile equ 08000h ; KERNEL.BIN 被加载到的位置 ---- 段地址 16 | OffsetOfKernelFile equ 0h ; KERNEL.BIN 被加载到的位置 ---- 偏移地址 17 | 18 | BaseOfKernelFilePhyAddr equ BaseOfKernelFile * 10h 19 | KernelEntryPointPhyAddr equ 030400h ; 注意:1、必须与 MAKEFILE 中参数 -Ttext 的值相等!! 20 | ; 2、这是个地址而非仅仅是个偏移,如果 -Ttext 的值为 0x400400,则它的值也应该是 0x400400。 21 | 22 | PageDirBase equ 200000h ; 页目录开始地址: 2M 23 | PageTblBase equ 201000h ; 页表开始地址: 2M + 4K 24 | 25 | -------------------------------------------------------------------------------- /e/include/string.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | string.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | PUBLIC void* memcpy(void* p_dst, void* p_src, int size); 9 | PUBLIC void memset(void* p_dst, char ch, int size); 10 | PUBLIC int strlen(const char* p_str); 11 | PUBLIC int memcmp(const void * s1, const void *s2, int n); 12 | PUBLIC int strcmp(const char * s1, const char *s2); 13 | PUBLIC char* strcat(char * s1, const char *s2); 14 | 15 | /** 16 | * `phys_copy' and `phys_set' are used only in the kernel, where segments 17 | * are all flat (based on 0). In the meanwhile, currently linear address 18 | * space is mapped to the identical physical address space. Therefore, 19 | * a `physical copy' will be as same as a common copy, so does `phys_set'. 20 | */ 21 | #define phys_copy memcpy 22 | #define phys_set memset 23 | 24 | -------------------------------------------------------------------------------- /f/include/string.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | string.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | PUBLIC void* memcpy(void* p_dst, void* p_src, int size); 9 | PUBLIC void memset(void* p_dst, char ch, int size); 10 | PUBLIC int strlen(const char* p_str); 11 | PUBLIC int memcmp(const void * s1, const void *s2, int n); 12 | PUBLIC int strcmp(const char * s1, const char *s2); 13 | PUBLIC char* strcat(char * s1, const char *s2); 14 | 15 | /** 16 | * `phys_copy' and `phys_set' are used only in the kernel, where segments 17 | * are all flat (based on 0). In the meanwhile, currently linear address 18 | * space is mapped to the identical physical address space. Therefore, 19 | * a `physical copy' will be as same as a common copy, so does `phys_set'. 20 | */ 21 | #define phys_copy memcpy 22 | #define phys_set memset 23 | 24 | -------------------------------------------------------------------------------- /g/include/string.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | string.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | PUBLIC void* memcpy(void* p_dst, void* p_src, int size); 9 | PUBLIC void memset(void* p_dst, char ch, int size); 10 | PUBLIC int strlen(const char* p_str); 11 | PUBLIC int memcmp(const void * s1, const void *s2, int n); 12 | PUBLIC int strcmp(const char * s1, const char *s2); 13 | PUBLIC char* strcat(char * s1, const char *s2); 14 | 15 | /** 16 | * `phys_copy' and `phys_set' are used only in the kernel, where segments 17 | * are all flat (based on 0). In the meanwhile, currently linear address 18 | * space is mapped to the identical physical address space. Therefore, 19 | * a `physical copy' will be as same as a common copy, so does `phys_set'. 20 | */ 21 | #define phys_copy memcpy 22 | #define phys_set memset 23 | 24 | -------------------------------------------------------------------------------- /h/include/string.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | string.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | PUBLIC void* memcpy(void* p_dst, void* p_src, int size); 9 | PUBLIC void memset(void* p_dst, char ch, int size); 10 | PUBLIC int strlen(const char* p_str); 11 | PUBLIC int memcmp(const void * s1, const void *s2, int n); 12 | PUBLIC int strcmp(const char * s1, const char *s2); 13 | PUBLIC char* strcat(char * s1, const char *s2); 14 | 15 | /** 16 | * `phys_copy' and `phys_set' are used only in the kernel, where segments 17 | * are all flat (based on 0). In the meanwhile, currently linear address 18 | * space is mapped to the identical physical address space. Therefore, 19 | * a `physical copy' will be as same as a common copy, so does `phys_set'. 20 | */ 21 | #define phys_copy memcpy 22 | #define phys_set memset 23 | 24 | -------------------------------------------------------------------------------- /i/include/string.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | string.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | PUBLIC void* memcpy(void* p_dst, void* p_src, int size); 9 | PUBLIC void memset(void* p_dst, char ch, int size); 10 | PUBLIC int strlen(const char* p_str); 11 | PUBLIC int memcmp(const void * s1, const void *s2, int n); 12 | PUBLIC int strcmp(const char * s1, const char *s2); 13 | PUBLIC char* strcat(char * s1, const char *s2); 14 | 15 | /** 16 | * `phys_copy' and `phys_set' are used only in the kernel, where segments 17 | * are all flat (based on 0). In the meanwhile, currently linear address 18 | * space is mapped to the identical physical address space. Therefore, 19 | * a `physical copy' will be as same as a common copy, so does `phys_set'. 20 | */ 21 | #define phys_copy memcpy 22 | #define phys_set memset 23 | 24 | -------------------------------------------------------------------------------- /j/include/string.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | string.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | PUBLIC void* memcpy(void* p_dst, void* p_src, int size); 9 | PUBLIC void memset(void* p_dst, char ch, int size); 10 | PUBLIC int strlen(const char* p_str); 11 | PUBLIC int memcmp(const void * s1, const void *s2, int n); 12 | PUBLIC int strcmp(const char * s1, const char *s2); 13 | PUBLIC char* strcat(char * s1, const char *s2); 14 | 15 | /** 16 | * `phys_copy' and `phys_set' are used only in the kernel, where segments 17 | * are all flat (based on 0). In the meanwhile, currently linear address 18 | * space is mapped to the identical physical address space. Therefore, 19 | * a `physical copy' will be as same as a common copy, so does `phys_set'. 20 | */ 21 | #define phys_copy memcpy 22 | #define phys_set memset 23 | 24 | -------------------------------------------------------------------------------- /a/bochsrc: -------------------------------------------------------------------------------- 1 | ############################################################### 2 | # Configuration file for Bochs 3 | ############################################################### 4 | 5 | # how much memory the emulated machine will have 6 | megs: 32 7 | 8 | # filename of ROM images 9 | romimage: file=/usr/share/bochs/BIOS-bochs-latest 10 | vgaromimage: file=/usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # hard disk 16 | ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14 17 | # !! Remember to change these if the hd img is changed: 18 | # 1. include/sys/config.h::MINOR_BOOT 19 | # 2. boot/include/load.inc::ROOT_BASE 20 | # 3. Makefile::HD 21 | # 4. commands/Makefile::HD 22 | ata0-master: type=disk, path="80m.img", mode=flat, cylinders=162, heads=16, spt=63 23 | 24 | # choose the boot disk. 25 | boot: a 26 | 27 | # where do we send log messages? 28 | # log: bochsout.txt 29 | 30 | # disable the mouse 31 | mouse: enabled=0 32 | 33 | # enable key mapping, using US layout as default. 34 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 35 | -------------------------------------------------------------------------------- /b/bochsrc: -------------------------------------------------------------------------------- 1 | ############################################################### 2 | # Configuration file for Bochs 3 | ############################################################### 4 | 5 | # how much memory the emulated machine will have 6 | megs: 32 7 | 8 | # filename of ROM images 9 | romimage: file=/usr/share/bochs/BIOS-bochs-latest 10 | vgaromimage: file=/usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # hard disk 16 | ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14 17 | # !! Remember to change these if the hd img is changed: 18 | # 1. include/sys/config.h::MINOR_BOOT 19 | # 2. boot/include/load.inc::ROOT_BASE 20 | # 3. Makefile::HD 21 | # 4. commands/Makefile::HD 22 | ata0-master: type=disk, path="80m.img", mode=flat, cylinders=162, heads=16, spt=63 23 | 24 | # choose the boot disk. 25 | boot: a 26 | 27 | # where do we send log messages? 28 | # log: bochsout.txt 29 | 30 | # disable the mouse 31 | mouse: enabled=0 32 | 33 | # enable key mapping, using US layout as default. 34 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 35 | -------------------------------------------------------------------------------- /c/bochsrc: -------------------------------------------------------------------------------- 1 | ############################################################### 2 | # Configuration file for Bochs 3 | ############################################################### 4 | 5 | # how much memory the emulated machine will have 6 | megs: 32 7 | 8 | # filename of ROM images 9 | romimage: file=/usr/share/bochs/BIOS-bochs-latest 10 | vgaromimage: file=/usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # hard disk 16 | ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14 17 | # !! Remember to change these if the hd img is changed: 18 | # 1. include/sys/config.h::MINOR_BOOT 19 | # 2. boot/include/load.inc::ROOT_BASE 20 | # 3. Makefile::HD 21 | # 4. commands/Makefile::HD 22 | ata0-master: type=disk, path="80m.img", mode=flat, cylinders=162, heads=16, spt=63 23 | 24 | # choose the boot disk. 25 | boot: a 26 | 27 | # where do we send log messages? 28 | # log: bochsout.txt 29 | 30 | # disable the mouse 31 | mouse: enabled=0 32 | 33 | # enable key mapping, using US layout as default. 34 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 35 | -------------------------------------------------------------------------------- /d/bochsrc: -------------------------------------------------------------------------------- 1 | ############################################################### 2 | # Configuration file for Bochs 3 | ############################################################### 4 | 5 | # how much memory the emulated machine will have 6 | megs: 32 7 | 8 | # filename of ROM images 9 | romimage: file=/usr/share/bochs/BIOS-bochs-latest 10 | vgaromimage: file=/usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # hard disk 16 | ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14 17 | # !! Remember to change these if the hd img is changed: 18 | # 1. include/sys/config.h::MINOR_BOOT 19 | # 2. boot/include/load.inc::ROOT_BASE 20 | # 3. Makefile::HD 21 | # 4. commands/Makefile::HD 22 | ata0-master: type=disk, path="80m.img", mode=flat, cylinders=162, heads=16, spt=63 23 | 24 | # choose the boot disk. 25 | boot: a 26 | 27 | # where do we send log messages? 28 | # log: bochsout.txt 29 | 30 | # disable the mouse 31 | mouse: enabled=0 32 | 33 | # enable key mapping, using US layout as default. 34 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 35 | -------------------------------------------------------------------------------- /e/bochsrc: -------------------------------------------------------------------------------- 1 | ############################################################### 2 | # Configuration file for Bochs 3 | ############################################################### 4 | 5 | # how much memory the emulated machine will have 6 | megs: 32 7 | 8 | # filename of ROM images 9 | romimage: file=/usr/share/bochs/BIOS-bochs-latest 10 | vgaromimage: file=/usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # hard disk 16 | ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14 17 | # !! Remember to change these if the hd img is changed: 18 | # 1. include/sys/config.h::MINOR_BOOT 19 | # 2. boot/include/load.inc::ROOT_BASE 20 | # 3. Makefile::HD 21 | # 4. commands/Makefile::HD 22 | ata0-master: type=disk, path="80m.img", mode=flat, cylinders=162, heads=16, spt=63 23 | 24 | # choose the boot disk. 25 | boot: a 26 | 27 | # where do we send log messages? 28 | # log: bochsout.txt 29 | 30 | # disable the mouse 31 | mouse: enabled=0 32 | 33 | # enable key mapping, using US layout as default. 34 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 35 | -------------------------------------------------------------------------------- /f/bochsrc: -------------------------------------------------------------------------------- 1 | ############################################################### 2 | # Configuration file for Bochs 3 | ############################################################### 4 | 5 | # how much memory the emulated machine will have 6 | megs: 32 7 | 8 | # filename of ROM images 9 | romimage: file=/usr/share/bochs/BIOS-bochs-latest 10 | vgaromimage: file=/usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # hard disk 16 | ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14 17 | # !! Remember to change these if the hd img is changed: 18 | # 1. include/sys/config.h::MINOR_BOOT 19 | # 2. boot/include/load.inc::ROOT_BASE 20 | # 3. Makefile::HD 21 | # 4. commands/Makefile::HD 22 | ata0-master: type=disk, path="80m.img", mode=flat, cylinders=162, heads=16, spt=63 23 | 24 | # choose the boot disk. 25 | boot: a 26 | 27 | # where do we send log messages? 28 | # log: bochsout.txt 29 | 30 | # disable the mouse 31 | mouse: enabled=0 32 | 33 | # enable key mapping, using US layout as default. 34 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 35 | -------------------------------------------------------------------------------- /g/bochsrc: -------------------------------------------------------------------------------- 1 | ############################################################### 2 | # Configuration file for Bochs 3 | ############################################################### 4 | 5 | # how much memory the emulated machine will have 6 | megs: 32 7 | 8 | # filename of ROM images 9 | romimage: file=/usr/share/bochs/BIOS-bochs-latest 10 | vgaromimage: file=/usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # hard disk 16 | ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14 17 | # !! Remember to change these if the hd img is changed: 18 | # 1. include/sys/config.h::MINOR_BOOT 19 | # 2. boot/include/load.inc::ROOT_BASE 20 | # 3. Makefile::HD 21 | # 4. commands/Makefile::HD 22 | ata0-master: type=disk, path="80m.img", mode=flat, cylinders=162, heads=16, spt=63 23 | 24 | # choose the boot disk. 25 | boot: a 26 | 27 | # where do we send log messages? 28 | # log: bochsout.txt 29 | 30 | # disable the mouse 31 | mouse: enabled=0 32 | 33 | # enable key mapping, using US layout as default. 34 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 35 | -------------------------------------------------------------------------------- /h/bochsrc: -------------------------------------------------------------------------------- 1 | ############################################################### 2 | # Configuration file for Bochs 3 | ############################################################### 4 | 5 | # how much memory the emulated machine will have 6 | megs: 32 7 | 8 | # filename of ROM images 9 | romimage: file=/usr/share/bochs/BIOS-bochs-latest 10 | vgaromimage: file=/usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # hard disk 16 | ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14 17 | # !! Remember to change these if the hd img is changed: 18 | # 1. include/sys/config.h::MINOR_BOOT 19 | # 2. boot/include/load.inc::ROOT_BASE 20 | # 3. Makefile::HD 21 | # 4. commands/Makefile::HD 22 | ata0-master: type=disk, path="80m.img", mode=flat, cylinders=162, heads=16, spt=63 23 | 24 | # choose the boot disk. 25 | boot: a 26 | 27 | # where do we send log messages? 28 | # log: bochsout.txt 29 | 30 | # disable the mouse 31 | mouse: enabled=0 32 | 33 | # enable key mapping, using US layout as default. 34 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 35 | -------------------------------------------------------------------------------- /i/bochsrc: -------------------------------------------------------------------------------- 1 | ############################################################### 2 | # Configuration file for Bochs 3 | ############################################################### 4 | 5 | # how much memory the emulated machine will have 6 | megs: 32 7 | 8 | # filename of ROM images 9 | romimage: file=/usr/share/bochs/BIOS-bochs-latest 10 | vgaromimage: file=/usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # hard disk 16 | ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14 17 | # !! Remember to change these if the hd img is changed: 18 | # 1. include/sys/config.h::MINOR_BOOT 19 | # 2. boot/include/load.inc::ROOT_BASE 20 | # 3. Makefile::HD 21 | # 4. commands/Makefile::HD 22 | ata0-master: type=disk, path="80m.img", mode=flat, cylinders=162, heads=16, spt=63 23 | 24 | # choose the boot disk. 25 | boot: a 26 | 27 | # where do we send log messages? 28 | # log: bochsout.txt 29 | 30 | # disable the mouse 31 | mouse: enabled=0 32 | 33 | # enable key mapping, using US layout as default. 34 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 35 | -------------------------------------------------------------------------------- /j/bochsrc: -------------------------------------------------------------------------------- 1 | ############################################################### 2 | # Configuration file for Bochs 3 | ############################################################### 4 | 5 | # how much memory the emulated machine will have 6 | megs: 32 7 | 8 | # filename of ROM images 9 | romimage: file=/usr/share/bochs/BIOS-bochs-latest 10 | vgaromimage: file=/usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # hard disk 16 | ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14 17 | # !! Remember to change these if the hd img is changed: 18 | # 1. include/sys/config.h::MINOR_BOOT 19 | # 2. boot/include/load.inc::ROOT_BASE 20 | # 3. Makefile::HD 21 | # 4. commands/Makefile::HD 22 | ata0-master: type=disk, path="80m.img", mode=flat, cylinders=162, heads=16, spt=63 23 | 24 | # choose the boot disk. 25 | boot: a 26 | 27 | # where do we send log messages? 28 | # log: bochsout.txt 29 | 30 | # disable the mouse 31 | mouse: enabled=0 32 | 33 | # enable key mapping, using US layout as default. 34 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 35 | -------------------------------------------------------------------------------- /e/tmp/f.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | int main() 9 | { 10 | int fd; 11 | int n; 12 | const char filename[] = "blah"; 13 | const char bufw[] = "abcde"; 14 | const int rd_bytes = 3; 15 | char bufr[rd_bytes]; 16 | 17 | assert(rd_bytes <= strlen(bufw)); 18 | 19 | /* create & write */ 20 | fd = open(filename, O_CREAT | O_RDWR | O_TRUNC, 0644); 21 | if (fd == -1) { 22 | printf("failed to open %s\n", filename); 23 | return 1; 24 | } 25 | 26 | n = write(fd, bufw, strlen(bufw)); 27 | if (n != strlen(bufw)) { 28 | printf("failed to write to %s\n", filename); 29 | close(fd); 30 | return 2; 31 | } 32 | 33 | close(fd); 34 | 35 | /* open & read */ 36 | fd = open(filename, O_RDWR); 37 | if (fd == -1) { 38 | printf("failed to open %s\n", filename); 39 | return 3; 40 | } 41 | 42 | n = read(fd, bufr, rd_bytes); 43 | if(n != rd_bytes) { 44 | printf("failed to read from %s\n", filename); 45 | close(fd); 46 | return 4; 47 | } 48 | bufr[n] = 0; 49 | printf("%d bytes read: %s\n", n, bufr); 50 | 51 | close(fd); 52 | 53 | return 0; 54 | } 55 | 56 | -------------------------------------------------------------------------------- /g/genlog: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ################################################################################################################# 4 | # Usage: 5 | # ./genlog 6 | # Note: 7 | # extract syslog from disk 8 | # 9 | # BUGS: 10 | # Forrest Y. Yu 11 | # Nov. 21, 2008 12 | ################################################################################################################# 13 | 14 | echo 15 | echo "[syslog]" 16 | echo "--------" 17 | syslog_tmp_file=/tmp/prntdisk.tmp 18 | syslog_file=./llsyslog 19 | dd if=80m.img of=$syslog_tmp_file bs=1 count=32 skip=`echo "obase=10;ibase=16;1C88000" | bc` 2> /dev/null 20 | dd if=80m.img of=$syslog_file bs=1 count=`head -n 1 $syslog_tmp_file | sed 's/\ //g'` skip=`echo "obase=10;ibase=16;1C88000" | bc` 2> /dev/null 21 | echo >> $syslog_file 22 | echo "time: "`cat $syslog_file | head -n 3 | tail -n 1` 23 | echo 24 | cat $syslog_file | sed '1,3d' > filedesc.dot 25 | cat filedesc.dot | ./splitgraphs 26 | gthumb . & 27 | echo 28 | 29 | exit 0 30 | 31 | -------------------------------------------------------------------------------- /h/scripts/genlog: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ################################################################################################################# 4 | # Usage: 5 | # ./genlog 6 | # Note: 7 | # extract syslog from disk 8 | # 9 | # BUGS: 10 | # Forrest Y. Yu 11 | # Nov. 21, 2008 12 | ################################################################################################################# 13 | 14 | echo 15 | echo "[syslog]" 16 | echo "--------" 17 | syslog_tmp_file=/tmp/prntdisk.tmp 18 | syslog_file=./llsyslog 19 | dd if=80m.img of=$syslog_tmp_file bs=1 count=32 skip=`echo "obase=10;ibase=16;1C88000" | bc` 2> /dev/null 20 | dd if=80m.img of=$syslog_file bs=1 count=`head -n 1 $syslog_tmp_file | sed 's/\ //g'` skip=`echo "obase=10;ibase=16;1C88000" | bc` 2> /dev/null 21 | echo >> $syslog_file 22 | echo "time: "`cat $syslog_file | head -n 3 | tail -n 1` 23 | echo 24 | cat $syslog_file | sed '1,3d' > filedesc.dot 25 | cat filedesc.dot | ./splitgraphs 26 | gthumb . & 27 | echo 28 | 29 | exit 0 30 | 31 | -------------------------------------------------------------------------------- /i/scripts/genlog: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ################################################################################################################# 4 | # Usage: 5 | # ./genlog 6 | # Note: 7 | # extract syslog from disk 8 | # 9 | # BUGS: 10 | # Forrest Y. Yu 11 | # Nov. 21, 2008 12 | ################################################################################################################# 13 | 14 | echo 15 | echo "[syslog]" 16 | echo "--------" 17 | syslog_tmp_file=/tmp/prntdisk.tmp 18 | syslog_file=./llsyslog 19 | dd if=80m.img of=$syslog_tmp_file bs=1 count=32 skip=`echo "obase=10;ibase=16;1C88000" | bc` 2> /dev/null 20 | dd if=80m.img of=$syslog_file bs=1 count=`head -n 1 $syslog_tmp_file | sed 's/\ //g'` skip=`echo "obase=10;ibase=16;1C88000" | bc` 2> /dev/null 21 | echo >> $syslog_file 22 | echo "time: "`cat $syslog_file | head -n 3 | tail -n 1` 23 | echo 24 | cat $syslog_file | sed '1,3d' > filedesc.dot 25 | cat filedesc.dot | ./splitgraphs 26 | gthumb . & 27 | echo 28 | 29 | exit 0 30 | 31 | -------------------------------------------------------------------------------- /j/scripts/genlog: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ################################################################################################################# 4 | # Usage: 5 | # ./genlog 6 | # Note: 7 | # extract syslog from disk 8 | # 9 | # BUGS: 10 | # Forrest Y. Yu 11 | # Nov. 21, 2008 12 | ################################################################################################################# 13 | 14 | echo 15 | echo "[syslog]" 16 | echo "--------" 17 | syslog_tmp_file=/tmp/prntdisk.tmp 18 | syslog_file=./llsyslog 19 | dd if=80m.img of=$syslog_tmp_file bs=1 count=32 skip=`echo "obase=10;ibase=16;1C88000" | bc` 2> /dev/null 20 | dd if=80m.img of=$syslog_file bs=1 count=`head -n 1 $syslog_tmp_file | sed 's/\ //g'` skip=`echo "obase=10;ibase=16;1C88000" | bc` 2> /dev/null 21 | echo >> $syslog_file 22 | echo "time: "`cat $syslog_file | head -n 3 | tail -n 1` 23 | echo 24 | cat $syslog_file | sed '1,3d' > filedesc.dot 25 | cat filedesc.dot | ./splitgraphs 26 | gthumb . & 27 | echo 28 | 29 | exit 0 30 | 31 | -------------------------------------------------------------------------------- /a/include/global.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | global.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | /* EXTERN is defined as extern except in global.c */ 9 | #ifdef GLOBAL_VARIABLES_HERE 10 | #undef EXTERN 11 | #define EXTERN 12 | #endif 13 | 14 | EXTERN int ticks; 15 | 16 | EXTERN int disp_pos; 17 | 18 | EXTERN u8 gdt_ptr[6]; /* 0~15:Limit 16~47:Base */ 19 | EXTERN struct descriptor gdt[GDT_SIZE]; 20 | EXTERN u8 idt_ptr[6]; /* 0~15:Limit 16~47:Base */ 21 | EXTERN struct gate idt[IDT_SIZE]; 22 | 23 | EXTERN u32 k_reenter; 24 | EXTERN int nr_current_console; 25 | 26 | EXTERN struct tss tss; 27 | EXTERN struct proc* p_proc_ready; 28 | 29 | extern char task_stack[]; 30 | extern struct proc proc_table[]; 31 | extern struct task task_table[]; 32 | extern struct task user_proc_table[]; 33 | extern irq_handler irq_table[]; 34 | extern TTY tty_table[]; 35 | extern CONSOLE console_table[]; 36 | 37 | /* FS */ 38 | extern struct dev_drv_map dd_map[]; 39 | 40 | -------------------------------------------------------------------------------- /b/include/global.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | global.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | /* EXTERN is defined as extern except in global.c */ 9 | #ifdef GLOBAL_VARIABLES_HERE 10 | #undef EXTERN 11 | #define EXTERN 12 | #endif 13 | 14 | EXTERN int ticks; 15 | 16 | EXTERN int disp_pos; 17 | 18 | EXTERN u8 gdt_ptr[6]; /* 0~15:Limit 16~47:Base */ 19 | EXTERN struct descriptor gdt[GDT_SIZE]; 20 | EXTERN u8 idt_ptr[6]; /* 0~15:Limit 16~47:Base */ 21 | EXTERN struct gate idt[IDT_SIZE]; 22 | 23 | EXTERN u32 k_reenter; 24 | EXTERN int nr_current_console; 25 | 26 | EXTERN struct tss tss; 27 | EXTERN struct proc* p_proc_ready; 28 | 29 | extern char task_stack[]; 30 | extern struct proc proc_table[]; 31 | extern struct task task_table[]; 32 | extern struct task user_proc_table[]; 33 | extern irq_handler irq_table[]; 34 | extern TTY tty_table[]; 35 | extern CONSOLE console_table[]; 36 | 37 | /* FS */ 38 | extern struct dev_drv_map dd_map[]; 39 | 40 | -------------------------------------------------------------------------------- /c/include/global.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | global.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | /* EXTERN is defined as extern except in global.c */ 9 | #ifdef GLOBAL_VARIABLES_HERE 10 | #undef EXTERN 11 | #define EXTERN 12 | #endif 13 | 14 | EXTERN int ticks; 15 | 16 | EXTERN int disp_pos; 17 | 18 | EXTERN u8 gdt_ptr[6]; /* 0~15:Limit 16~47:Base */ 19 | EXTERN struct descriptor gdt[GDT_SIZE]; 20 | EXTERN u8 idt_ptr[6]; /* 0~15:Limit 16~47:Base */ 21 | EXTERN struct gate idt[IDT_SIZE]; 22 | 23 | EXTERN u32 k_reenter; 24 | EXTERN int nr_current_console; 25 | 26 | EXTERN struct tss tss; 27 | EXTERN struct proc* p_proc_ready; 28 | 29 | extern char task_stack[]; 30 | extern struct proc proc_table[]; 31 | extern struct task task_table[]; 32 | extern struct task user_proc_table[]; 33 | extern irq_handler irq_table[]; 34 | extern TTY tty_table[]; 35 | extern CONSOLE console_table[]; 36 | 37 | /* FS */ 38 | extern struct dev_drv_map dd_map[]; 39 | 40 | -------------------------------------------------------------------------------- /e/include/stdio.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file stdio.h 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | /* the assert macro */ 11 | #define ASSERT 12 | #ifdef ASSERT 13 | void assertion_failure(char *exp, char *file, char *base_file, int line); 14 | #define assert(exp) if (exp) ; \ 15 | else assertion_failure(#exp, __FILE__, __BASE_FILE__, __LINE__) 16 | #else 17 | #define assert(exp) 18 | #endif 19 | 20 | /* EXTERN */ 21 | #define EXTERN extern /* EXTERN is defined as extern except in global.c */ 22 | 23 | /* string */ 24 | #define STR_DEFAULT_LEN 1024 25 | 26 | #define O_CREAT 1 27 | #define O_RDWR 2 28 | 29 | #define SEEK_SET 1 30 | #define SEEK_CUR 2 31 | #define SEEK_END 3 32 | 33 | #define MAX_PATH 128 34 | 35 | /*--------*/ 36 | /* 库函数 */ 37 | /*--------*/ 38 | 39 | /* lib/open.c */ 40 | PUBLIC int open (const char *pathname, int flags); 41 | 42 | /* lib/close.c */ 43 | PUBLIC int close (int fd); 44 | -------------------------------------------------------------------------------- /g/lib/getpid.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file getpid.c 4 | * @brief getpid() 5 | * @author Forrest Y. Yu 6 | * @date Mon Nov 10 19:04:07 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | 23 | /***************************************************************************** 24 | * getpid 25 | *****************************************************************************/ 26 | /** 27 | * Get the PID. 28 | * 29 | * @return The PID. 30 | *****************************************************************************/ 31 | PUBLIC int getpid() 32 | { 33 | MESSAGE msg; 34 | msg.type = GET_PID; 35 | 36 | send_recv(BOTH, TASK_SYS, &msg); 37 | assert(msg.type == SYSCALL_RET); 38 | 39 | return msg.PID; 40 | } 41 | -------------------------------------------------------------------------------- /h/lib/getpid.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file getpid.c 4 | * @brief getpid() 5 | * @author Forrest Y. Yu 6 | * @date Mon Nov 10 19:04:07 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | 23 | /***************************************************************************** 24 | * getpid 25 | *****************************************************************************/ 26 | /** 27 | * Get the PID. 28 | * 29 | * @return The PID. 30 | *****************************************************************************/ 31 | PUBLIC int getpid() 32 | { 33 | MESSAGE msg; 34 | msg.type = GET_PID; 35 | 36 | send_recv(BOTH, TASK_SYS, &msg); 37 | assert(msg.type == SYSCALL_RET); 38 | 39 | return msg.PID; 40 | } 41 | -------------------------------------------------------------------------------- /i/lib/getpid.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file getpid.c 4 | * @brief getpid() 5 | * @author Forrest Y. Yu 6 | * @date Mon Nov 10 19:04:07 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | 23 | /***************************************************************************** 24 | * getpid 25 | *****************************************************************************/ 26 | /** 27 | * Get the PID. 28 | * 29 | * @return The PID. 30 | *****************************************************************************/ 31 | PUBLIC int getpid() 32 | { 33 | MESSAGE msg; 34 | msg.type = GET_PID; 35 | 36 | send_recv(BOTH, TASK_SYS, &msg); 37 | assert(msg.type == SYSCALL_RET); 38 | 39 | return msg.PID; 40 | } 41 | -------------------------------------------------------------------------------- /j/lib/getpid.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file getpid.c 4 | * @brief getpid() 5 | * @author Forrest Y. Yu 6 | * @date Mon Nov 10 19:04:07 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | 23 | /***************************************************************************** 24 | * getpid 25 | *****************************************************************************/ 26 | /** 27 | * Get the PID. 28 | * 29 | * @return The PID. 30 | *****************************************************************************/ 31 | PUBLIC int getpid() 32 | { 33 | MESSAGE msg; 34 | msg.type = GET_PID; 35 | 36 | send_recv(BOTH, TASK_SYS, &msg); 37 | assert(msg.type == SYSCALL_RET); 38 | 39 | return msg.PID; 40 | } 41 | -------------------------------------------------------------------------------- /d/include/global.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | global.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | /* EXTERN is defined as extern except in global.c */ 9 | #ifdef GLOBAL_VARIABLES_HERE 10 | #undef EXTERN 11 | #define EXTERN 12 | #endif 13 | 14 | EXTERN int ticks; 15 | 16 | EXTERN int disp_pos; 17 | 18 | EXTERN u8 gdt_ptr[6]; /* 0~15:Limit 16~47:Base */ 19 | EXTERN struct descriptor gdt[GDT_SIZE]; 20 | EXTERN u8 idt_ptr[6]; /* 0~15:Limit 16~47:Base */ 21 | EXTERN struct gate idt[IDT_SIZE]; 22 | 23 | EXTERN u32 k_reenter; 24 | EXTERN int nr_current_console; 25 | 26 | EXTERN struct tss tss; 27 | EXTERN struct proc* p_proc_ready; 28 | 29 | extern char task_stack[]; 30 | extern struct proc proc_table[]; 31 | extern struct task task_table[]; 32 | extern struct task user_proc_table[]; 33 | extern irq_handler irq_table[]; 34 | extern TTY tty_table[]; 35 | extern CONSOLE console_table[]; 36 | 37 | /* FS */ 38 | extern u8 * fsbuf; 39 | extern const int FSBUF_SIZE; 40 | extern struct dev_drv_map dd_map[]; 41 | 42 | -------------------------------------------------------------------------------- /a/fs/main.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file main.c 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date 2007 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | //#include "config.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | #include "hd.h" 23 | 24 | 25 | 26 | /***************************************************************************** 27 | * task_fs 28 | *****************************************************************************/ 29 | /** 30 | * The main loop of TASK FS. 31 | * 32 | *****************************************************************************/ 33 | PUBLIC void task_fs() 34 | { 35 | printl("Task FS begins.\n"); 36 | 37 | /* open the device: hard disk */ 38 | MESSAGE driver_msg; 39 | driver_msg.type = DEV_OPEN; 40 | send_recv(BOTH, TASK_HD, &driver_msg); 41 | 42 | spin("FS"); 43 | } 44 | -------------------------------------------------------------------------------- /e/lib/close.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file close.c 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date Mon Apr 21 17:08:19 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | /***************************************************************************** 23 | * close 24 | *****************************************************************************/ 25 | /** 26 | * Close a file descriptor. 27 | * 28 | * @param fd File descriptor. 29 | * 30 | * @return Zero if successful, otherwise -1. 31 | *****************************************************************************/ 32 | PUBLIC int close(int fd) 33 | { 34 | MESSAGE msg; 35 | msg.type = CLOSE; 36 | msg.FD = fd; 37 | 38 | send_recv(BOTH, TASK_FS, &msg); 39 | 40 | return msg.RETVAL; 41 | } 42 | -------------------------------------------------------------------------------- /f/lib/close.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file close.c 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date Mon Apr 21 17:08:19 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | /***************************************************************************** 23 | * close 24 | *****************************************************************************/ 25 | /** 26 | * Close a file descriptor. 27 | * 28 | * @param fd File descriptor. 29 | * 30 | * @return Zero if successful, otherwise -1. 31 | *****************************************************************************/ 32 | PUBLIC int close(int fd) 33 | { 34 | MESSAGE msg; 35 | msg.type = CLOSE; 36 | msg.FD = fd; 37 | 38 | send_recv(BOTH, TASK_FS, &msg); 39 | 40 | return msg.RETVAL; 41 | } 42 | -------------------------------------------------------------------------------- /g/lib/close.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file close.c 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date Mon Apr 21 17:08:19 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | /***************************************************************************** 23 | * close 24 | *****************************************************************************/ 25 | /** 26 | * Close a file descriptor. 27 | * 28 | * @param fd File descriptor. 29 | * 30 | * @return Zero if successful, otherwise -1. 31 | *****************************************************************************/ 32 | PUBLIC int close(int fd) 33 | { 34 | MESSAGE msg; 35 | msg.type = CLOSE; 36 | msg.FD = fd; 37 | 38 | send_recv(BOTH, TASK_FS, &msg); 39 | 40 | return msg.RETVAL; 41 | } 42 | -------------------------------------------------------------------------------- /h/lib/close.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file close.c 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date Mon Apr 21 17:08:19 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | /***************************************************************************** 23 | * close 24 | *****************************************************************************/ 25 | /** 26 | * Close a file descriptor. 27 | * 28 | * @param fd File descriptor. 29 | * 30 | * @return Zero if successful, otherwise -1. 31 | *****************************************************************************/ 32 | PUBLIC int close(int fd) 33 | { 34 | MESSAGE msg; 35 | msg.type = CLOSE; 36 | msg.FD = fd; 37 | 38 | send_recv(BOTH, TASK_FS, &msg); 39 | 40 | return msg.RETVAL; 41 | } 42 | -------------------------------------------------------------------------------- /i/lib/close.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file close.c 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date Mon Apr 21 17:08:19 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | /***************************************************************************** 23 | * close 24 | *****************************************************************************/ 25 | /** 26 | * Close a file descriptor. 27 | * 28 | * @param fd File descriptor. 29 | * 30 | * @return Zero if successful, otherwise -1. 31 | *****************************************************************************/ 32 | PUBLIC int close(int fd) 33 | { 34 | MESSAGE msg; 35 | msg.type = CLOSE; 36 | msg.FD = fd; 37 | 38 | send_recv(BOTH, TASK_FS, &msg); 39 | 40 | return msg.RETVAL; 41 | } 42 | -------------------------------------------------------------------------------- /j/lib/close.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file close.c 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date Mon Apr 21 17:08:19 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | /***************************************************************************** 23 | * close 24 | *****************************************************************************/ 25 | /** 26 | * Close a file descriptor. 27 | * 28 | * @param fd File descriptor. 29 | * 30 | * @return Zero if successful, otherwise -1. 31 | *****************************************************************************/ 32 | PUBLIC int close(int fd) 33 | { 34 | MESSAGE msg; 35 | msg.type = CLOSE; 36 | msg.FD = fd; 37 | 38 | send_recv(BOTH, TASK_FS, &msg); 39 | 40 | return msg.RETVAL; 41 | } 42 | -------------------------------------------------------------------------------- /a/include/type.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | type.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_TYPE_H_ 9 | #define _ORANGES_TYPE_H_ 10 | 11 | 12 | typedef unsigned long long u64; 13 | typedef unsigned int u32; 14 | typedef unsigned short u16; 15 | typedef unsigned char u8; 16 | 17 | typedef char * va_list; 18 | 19 | typedef void (*int_handler) (); 20 | typedef void (*task_f) (); 21 | typedef void (*irq_handler) (int irq); 22 | 23 | typedef void* system_call; 24 | 25 | 26 | /** 27 | * MESSAGE mechanism is borrowed from MINIX 28 | */ 29 | struct mess1 { 30 | int m1i1; 31 | int m1i2; 32 | int m1i3; 33 | int m1i4; 34 | }; 35 | struct mess2 { 36 | void* m2p1; 37 | void* m2p2; 38 | void* m2p3; 39 | void* m2p4; 40 | }; 41 | struct mess3 { 42 | int m3i1; 43 | int m3i2; 44 | int m3i3; 45 | int m3i4; 46 | u64 m3l1; 47 | u64 m3l2; 48 | void* m3p1; 49 | void* m3p2; 50 | }; 51 | typedef struct { 52 | int source; 53 | int type; 54 | union { 55 | struct mess1 m1; 56 | struct mess2 m2; 57 | struct mess3 m3; 58 | } u; 59 | } MESSAGE; 60 | 61 | 62 | #endif /* _ORANGES_TYPE_H_ */ 63 | -------------------------------------------------------------------------------- /b/include/type.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | type.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_TYPE_H_ 9 | #define _ORANGES_TYPE_H_ 10 | 11 | 12 | typedef unsigned long long u64; 13 | typedef unsigned int u32; 14 | typedef unsigned short u16; 15 | typedef unsigned char u8; 16 | 17 | typedef char * va_list; 18 | 19 | typedef void (*int_handler) (); 20 | typedef void (*task_f) (); 21 | typedef void (*irq_handler) (int irq); 22 | 23 | typedef void* system_call; 24 | 25 | 26 | /** 27 | * MESSAGE mechanism is borrowed from MINIX 28 | */ 29 | struct mess1 { 30 | int m1i1; 31 | int m1i2; 32 | int m1i3; 33 | int m1i4; 34 | }; 35 | struct mess2 { 36 | void* m2p1; 37 | void* m2p2; 38 | void* m2p3; 39 | void* m2p4; 40 | }; 41 | struct mess3 { 42 | int m3i1; 43 | int m3i2; 44 | int m3i3; 45 | int m3i4; 46 | u64 m3l1; 47 | u64 m3l2; 48 | void* m3p1; 49 | void* m3p2; 50 | }; 51 | typedef struct { 52 | int source; 53 | int type; 54 | union { 55 | struct mess1 m1; 56 | struct mess2 m2; 57 | struct mess3 m3; 58 | } u; 59 | } MESSAGE; 60 | 61 | 62 | #endif /* _ORANGES_TYPE_H_ */ 63 | -------------------------------------------------------------------------------- /c/include/type.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | type.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_TYPE_H_ 9 | #define _ORANGES_TYPE_H_ 10 | 11 | 12 | typedef unsigned long long u64; 13 | typedef unsigned int u32; 14 | typedef unsigned short u16; 15 | typedef unsigned char u8; 16 | 17 | typedef char * va_list; 18 | 19 | typedef void (*int_handler) (); 20 | typedef void (*task_f) (); 21 | typedef void (*irq_handler) (int irq); 22 | 23 | typedef void* system_call; 24 | 25 | 26 | /** 27 | * MESSAGE mechanism is borrowed from MINIX 28 | */ 29 | struct mess1 { 30 | int m1i1; 31 | int m1i2; 32 | int m1i3; 33 | int m1i4; 34 | }; 35 | struct mess2 { 36 | void* m2p1; 37 | void* m2p2; 38 | void* m2p3; 39 | void* m2p4; 40 | }; 41 | struct mess3 { 42 | int m3i1; 43 | int m3i2; 44 | int m3i3; 45 | int m3i4; 46 | u64 m3l1; 47 | u64 m3l2; 48 | void* m3p1; 49 | void* m3p2; 50 | }; 51 | typedef struct { 52 | int source; 53 | int type; 54 | union { 55 | struct mess1 m1; 56 | struct mess2 m2; 57 | struct mess3 m3; 58 | } u; 59 | } MESSAGE; 60 | 61 | 62 | #endif /* _ORANGES_TYPE_H_ */ 63 | -------------------------------------------------------------------------------- /d/include/type.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | type.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_TYPE_H_ 9 | #define _ORANGES_TYPE_H_ 10 | 11 | 12 | typedef unsigned long long u64; 13 | typedef unsigned int u32; 14 | typedef unsigned short u16; 15 | typedef unsigned char u8; 16 | 17 | typedef char * va_list; 18 | 19 | typedef void (*int_handler) (); 20 | typedef void (*task_f) (); 21 | typedef void (*irq_handler) (int irq); 22 | 23 | typedef void* system_call; 24 | 25 | 26 | /** 27 | * MESSAGE mechanism is borrowed from MINIX 28 | */ 29 | struct mess1 { 30 | int m1i1; 31 | int m1i2; 32 | int m1i3; 33 | int m1i4; 34 | }; 35 | struct mess2 { 36 | void* m2p1; 37 | void* m2p2; 38 | void* m2p3; 39 | void* m2p4; 40 | }; 41 | struct mess3 { 42 | int m3i1; 43 | int m3i2; 44 | int m3i3; 45 | int m3i4; 46 | u64 m3l1; 47 | u64 m3l2; 48 | void* m3p1; 49 | void* m3p2; 50 | }; 51 | typedef struct { 52 | int source; 53 | int type; 54 | union { 55 | struct mess1 m1; 56 | struct mess2 m2; 57 | struct mess3 m3; 58 | } u; 59 | } MESSAGE; 60 | 61 | 62 | #endif /* _ORANGES_TYPE_H_ */ 63 | -------------------------------------------------------------------------------- /a/kernel/systask.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file systask.c 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date 2007 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "const.h" 12 | #include "protect.h" 13 | #include "string.h" 14 | #include "fs.h" 15 | #include "proc.h" 16 | #include "tty.h" 17 | #include "console.h" 18 | #include "global.h" 19 | #include "keyboard.h" 20 | #include "proto.h" 21 | 22 | 23 | /***************************************************************************** 24 | * task_sys 25 | *****************************************************************************/ 26 | /** 27 | * The main loop of TASK SYS. 28 | * 29 | *****************************************************************************/ 30 | PUBLIC void task_sys() 31 | { 32 | MESSAGE msg; 33 | while (1) { 34 | send_recv(RECEIVE, ANY, &msg); 35 | int src = msg.source; 36 | 37 | switch (msg.type) { 38 | case GET_TICKS: 39 | msg.RETVAL = ticks; 40 | send_recv(SEND, src, &msg); 41 | break; 42 | default: 43 | panic("unknown msg type"); 44 | break; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /b/kernel/systask.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file systask.c 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date 2007 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "const.h" 12 | #include "protect.h" 13 | #include "string.h" 14 | #include "fs.h" 15 | #include "proc.h" 16 | #include "tty.h" 17 | #include "console.h" 18 | #include "global.h" 19 | #include "keyboard.h" 20 | #include "proto.h" 21 | 22 | 23 | /***************************************************************************** 24 | * task_sys 25 | *****************************************************************************/ 26 | /** 27 | * The main loop of TASK SYS. 28 | * 29 | *****************************************************************************/ 30 | PUBLIC void task_sys() 31 | { 32 | MESSAGE msg; 33 | while (1) { 34 | send_recv(RECEIVE, ANY, &msg); 35 | int src = msg.source; 36 | 37 | switch (msg.type) { 38 | case GET_TICKS: 39 | msg.RETVAL = ticks; 40 | send_recv(SEND, src, &msg); 41 | break; 42 | default: 43 | panic("unknown msg type"); 44 | break; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /c/kernel/systask.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file systask.c 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date 2007 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "const.h" 12 | #include "protect.h" 13 | #include "string.h" 14 | #include "fs.h" 15 | #include "proc.h" 16 | #include "tty.h" 17 | #include "console.h" 18 | #include "global.h" 19 | #include "keyboard.h" 20 | #include "proto.h" 21 | 22 | 23 | /***************************************************************************** 24 | * task_sys 25 | *****************************************************************************/ 26 | /** 27 | * The main loop of TASK SYS. 28 | * 29 | *****************************************************************************/ 30 | PUBLIC void task_sys() 31 | { 32 | MESSAGE msg; 33 | while (1) { 34 | send_recv(RECEIVE, ANY, &msg); 35 | int src = msg.source; 36 | 37 | switch (msg.type) { 38 | case GET_TICKS: 39 | msg.RETVAL = ticks; 40 | send_recv(SEND, src, &msg); 41 | break; 42 | default: 43 | panic("unknown msg type"); 44 | break; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /d/kernel/systask.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file systask.c 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date 2007 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "const.h" 12 | #include "protect.h" 13 | #include "string.h" 14 | #include "fs.h" 15 | #include "proc.h" 16 | #include "tty.h" 17 | #include "console.h" 18 | #include "global.h" 19 | #include "keyboard.h" 20 | #include "proto.h" 21 | 22 | 23 | /***************************************************************************** 24 | * task_sys 25 | *****************************************************************************/ 26 | /** 27 | * The main loop of TASK SYS. 28 | * 29 | *****************************************************************************/ 30 | PUBLIC void task_sys() 31 | { 32 | MESSAGE msg; 33 | while (1) { 34 | send_recv(RECEIVE, ANY, &msg); 35 | int src = msg.source; 36 | 37 | switch (msg.type) { 38 | case GET_TICKS: 39 | msg.RETVAL = ticks; 40 | send_recv(SEND, src, &msg); 41 | break; 42 | default: 43 | panic("unknown msg type"); 44 | break; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /f/include/stdio.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file stdio.h 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | /* the assert macro */ 11 | #define ASSERT 12 | #ifdef ASSERT 13 | void assertion_failure(char *exp, char *file, char *base_file, int line); 14 | #define assert(exp) if (exp) ; \ 15 | else assertion_failure(#exp, __FILE__, __BASE_FILE__, __LINE__) 16 | #else 17 | #define assert(exp) 18 | #endif 19 | 20 | /* EXTERN */ 21 | #define EXTERN extern /* EXTERN is defined as extern except in global.c */ 22 | 23 | /* string */ 24 | #define STR_DEFAULT_LEN 1024 25 | 26 | #define O_CREAT 1 27 | #define O_RDWR 2 28 | 29 | #define SEEK_SET 1 30 | #define SEEK_CUR 2 31 | #define SEEK_END 3 32 | 33 | #define MAX_PATH 128 34 | 35 | /*--------*/ 36 | /* 库函数 */ 37 | /*--------*/ 38 | 39 | /* lib/open.c */ 40 | PUBLIC int open (const char *pathname, int flags); 41 | 42 | /* lib/close.c */ 43 | PUBLIC int close (int fd); 44 | 45 | /* lib/read.c */ 46 | PUBLIC int read (int fd, void *buf, int count); 47 | 48 | /* lib/write.c */ 49 | PUBLIC int write (int fd, const void *buf, int count); 50 | -------------------------------------------------------------------------------- /h/lib/unlink.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file unlink.c 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date Tue Jun 3 16:12:05 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | /***************************************************************************** 23 | * unlink 24 | *****************************************************************************/ 25 | /** 26 | * Delete a file. 27 | * 28 | * @param pathname The full path of the file to delete. 29 | * 30 | * @return Zero if successful, otherwise -1. 31 | *****************************************************************************/ 32 | PUBLIC int unlink(const char * pathname) 33 | { 34 | MESSAGE msg; 35 | msg.type = UNLINK; 36 | 37 | msg.PATHNAME = (void*)pathname; 38 | msg.NAME_LEN = strlen(pathname); 39 | 40 | send_recv(BOTH, TASK_FS, &msg); 41 | 42 | return msg.RETVAL; 43 | } 44 | -------------------------------------------------------------------------------- /i/lib/unlink.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file unlink.c 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date Tue Jun 3 16:12:05 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | /***************************************************************************** 23 | * unlink 24 | *****************************************************************************/ 25 | /** 26 | * Delete a file. 27 | * 28 | * @param pathname The full path of the file to delete. 29 | * 30 | * @return Zero if successful, otherwise -1. 31 | *****************************************************************************/ 32 | PUBLIC int unlink(const char * pathname) 33 | { 34 | MESSAGE msg; 35 | msg.type = UNLINK; 36 | 37 | msg.PATHNAME = (void*)pathname; 38 | msg.NAME_LEN = strlen(pathname); 39 | 40 | send_recv(BOTH, TASK_FS, &msg); 41 | 42 | return msg.RETVAL; 43 | } 44 | -------------------------------------------------------------------------------- /j/lib/unlink.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file unlink.c 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date Tue Jun 3 16:12:05 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | /***************************************************************************** 23 | * unlink 24 | *****************************************************************************/ 25 | /** 26 | * Delete a file. 27 | * 28 | * @param pathname The full path of the file to delete. 29 | * 30 | * @return Zero if successful, otherwise -1. 31 | *****************************************************************************/ 32 | PUBLIC int unlink(const char * pathname) 33 | { 34 | MESSAGE msg; 35 | msg.type = UNLINK; 36 | 37 | msg.PATHNAME = (void*)pathname; 38 | msg.NAME_LEN = strlen(pathname); 39 | 40 | send_recv(BOTH, TASK_FS, &msg); 41 | 42 | return msg.RETVAL; 43 | } 44 | -------------------------------------------------------------------------------- /e/lib/syscall.asm: -------------------------------------------------------------------------------- 1 | 2 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | ; syscall.asm 4 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | ; Forrest Yu, 2005 6 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | 8 | %include "sconst.inc" 9 | 10 | INT_VECTOR_SYS_CALL equ 0x90 11 | _NR_printx equ 0 12 | _NR_sendrec equ 1 13 | 14 | ; 导出符号 15 | global printx 16 | global sendrec 17 | 18 | bits 32 19 | [section .text] 20 | 21 | ; ==================================================================================== 22 | ; sendrec(int function, int src_dest, MESSAGE* msg); 23 | ; ==================================================================================== 24 | ; Never call sendrec() directly, call send_recv() instead. 25 | sendrec: 26 | mov eax, _NR_sendrec 27 | mov ebx, [esp + 4] ; function 28 | mov ecx, [esp + 8] ; src_dest 29 | mov edx, [esp + 12] ; p_msg 30 | int INT_VECTOR_SYS_CALL 31 | ret 32 | 33 | ; ==================================================================================== 34 | ; void printx(char* s); 35 | ; ==================================================================================== 36 | printx: 37 | mov eax, _NR_printx 38 | mov edx, [esp + 4] 39 | int INT_VECTOR_SYS_CALL 40 | ret 41 | 42 | -------------------------------------------------------------------------------- /f/lib/syscall.asm: -------------------------------------------------------------------------------- 1 | 2 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | ; syscall.asm 4 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | ; Forrest Yu, 2005 6 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | 8 | %include "sconst.inc" 9 | 10 | INT_VECTOR_SYS_CALL equ 0x90 11 | _NR_printx equ 0 12 | _NR_sendrec equ 1 13 | 14 | ; 导出符号 15 | global printx 16 | global sendrec 17 | 18 | bits 32 19 | [section .text] 20 | 21 | ; ==================================================================================== 22 | ; sendrec(int function, int src_dest, MESSAGE* msg); 23 | ; ==================================================================================== 24 | ; Never call sendrec() directly, call send_recv() instead. 25 | sendrec: 26 | mov eax, _NR_sendrec 27 | mov ebx, [esp + 4] ; function 28 | mov ecx, [esp + 8] ; src_dest 29 | mov edx, [esp + 12] ; p_msg 30 | int INT_VECTOR_SYS_CALL 31 | ret 32 | 33 | ; ==================================================================================== 34 | ; void printx(char* s); 35 | ; ==================================================================================== 36 | printx: 37 | mov eax, _NR_printx 38 | mov edx, [esp + 4] 39 | int INT_VECTOR_SYS_CALL 40 | ret 41 | 42 | -------------------------------------------------------------------------------- /g/lib/syscall.asm: -------------------------------------------------------------------------------- 1 | 2 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | ; syscall.asm 4 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | ; Forrest Yu, 2005 6 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | 8 | %include "sconst.inc" 9 | 10 | INT_VECTOR_SYS_CALL equ 0x90 11 | _NR_printx equ 0 12 | _NR_sendrec equ 1 13 | 14 | ; 导出符号 15 | global printx 16 | global sendrec 17 | 18 | bits 32 19 | [section .text] 20 | 21 | ; ==================================================================================== 22 | ; sendrec(int function, int src_dest, MESSAGE* msg); 23 | ; ==================================================================================== 24 | ; Never call sendrec() directly, call send_recv() instead. 25 | sendrec: 26 | mov eax, _NR_sendrec 27 | mov ebx, [esp + 4] ; function 28 | mov ecx, [esp + 8] ; src_dest 29 | mov edx, [esp + 12] ; p_msg 30 | int INT_VECTOR_SYS_CALL 31 | ret 32 | 33 | ; ==================================================================================== 34 | ; void printx(char* s); 35 | ; ==================================================================================== 36 | printx: 37 | mov eax, _NR_printx 38 | mov edx, [esp + 4] 39 | int INT_VECTOR_SYS_CALL 40 | ret 41 | 42 | -------------------------------------------------------------------------------- /h/lib/syscall.asm: -------------------------------------------------------------------------------- 1 | 2 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | ; syscall.asm 4 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | ; Forrest Yu, 2005 6 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | 8 | %include "sconst.inc" 9 | 10 | INT_VECTOR_SYS_CALL equ 0x90 11 | _NR_printx equ 0 12 | _NR_sendrec equ 1 13 | 14 | ; 导出符号 15 | global printx 16 | global sendrec 17 | 18 | bits 32 19 | [section .text] 20 | 21 | ; ==================================================================================== 22 | ; sendrec(int function, int src_dest, MESSAGE* msg); 23 | ; ==================================================================================== 24 | ; Never call sendrec() directly, call send_recv() instead. 25 | sendrec: 26 | mov eax, _NR_sendrec 27 | mov ebx, [esp + 4] ; function 28 | mov ecx, [esp + 8] ; src_dest 29 | mov edx, [esp + 12] ; p_msg 30 | int INT_VECTOR_SYS_CALL 31 | ret 32 | 33 | ; ==================================================================================== 34 | ; void printx(char* s); 35 | ; ==================================================================================== 36 | printx: 37 | mov eax, _NR_printx 38 | mov edx, [esp + 4] 39 | int INT_VECTOR_SYS_CALL 40 | ret 41 | 42 | -------------------------------------------------------------------------------- /i/lib/syscall.asm: -------------------------------------------------------------------------------- 1 | 2 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | ; syscall.asm 4 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | ; Forrest Yu, 2005 6 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | 8 | %include "sconst.inc" 9 | 10 | INT_VECTOR_SYS_CALL equ 0x90 11 | _NR_printx equ 0 12 | _NR_sendrec equ 1 13 | 14 | ; 导出符号 15 | global printx 16 | global sendrec 17 | 18 | bits 32 19 | [section .text] 20 | 21 | ; ==================================================================================== 22 | ; sendrec(int function, int src_dest, MESSAGE* msg); 23 | ; ==================================================================================== 24 | ; Never call sendrec() directly, call send_recv() instead. 25 | sendrec: 26 | mov eax, _NR_sendrec 27 | mov ebx, [esp + 4] ; function 28 | mov ecx, [esp + 8] ; src_dest 29 | mov edx, [esp + 12] ; p_msg 30 | int INT_VECTOR_SYS_CALL 31 | ret 32 | 33 | ; ==================================================================================== 34 | ; void printx(char* s); 35 | ; ==================================================================================== 36 | printx: 37 | mov eax, _NR_printx 38 | mov edx, [esp + 4] 39 | int INT_VECTOR_SYS_CALL 40 | ret 41 | 42 | -------------------------------------------------------------------------------- /a/kernel/syscall.asm: -------------------------------------------------------------------------------- 1 | 2 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | ; syscall.asm 4 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | ; Forrest Yu, 2005 6 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | 8 | %include "sconst.inc" 9 | 10 | INT_VECTOR_SYS_CALL equ 0x90 11 | _NR_printx equ 0 12 | _NR_sendrec equ 1 13 | 14 | ; 导出符号 15 | global printx 16 | global sendrec 17 | 18 | bits 32 19 | [section .text] 20 | 21 | ; ==================================================================================== 22 | ; sendrec(int function, int src_dest, MESSAGE* msg); 23 | ; ==================================================================================== 24 | ; Never call sendrec() directly, call send_recv() instead. 25 | sendrec: 26 | mov eax, _NR_sendrec 27 | mov ebx, [esp + 4] ; function 28 | mov ecx, [esp + 8] ; src_dest 29 | mov edx, [esp + 12] ; p_msg 30 | int INT_VECTOR_SYS_CALL 31 | ret 32 | 33 | ; ==================================================================================== 34 | ; void printx(char* s); 35 | ; ==================================================================================== 36 | printx: 37 | mov eax, _NR_printx 38 | mov edx, [esp + 4] 39 | int INT_VECTOR_SYS_CALL 40 | ret 41 | 42 | -------------------------------------------------------------------------------- /b/kernel/syscall.asm: -------------------------------------------------------------------------------- 1 | 2 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | ; syscall.asm 4 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | ; Forrest Yu, 2005 6 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | 8 | %include "sconst.inc" 9 | 10 | INT_VECTOR_SYS_CALL equ 0x90 11 | _NR_printx equ 0 12 | _NR_sendrec equ 1 13 | 14 | ; 导出符号 15 | global printx 16 | global sendrec 17 | 18 | bits 32 19 | [section .text] 20 | 21 | ; ==================================================================================== 22 | ; sendrec(int function, int src_dest, MESSAGE* msg); 23 | ; ==================================================================================== 24 | ; Never call sendrec() directly, call send_recv() instead. 25 | sendrec: 26 | mov eax, _NR_sendrec 27 | mov ebx, [esp + 4] ; function 28 | mov ecx, [esp + 8] ; src_dest 29 | mov edx, [esp + 12] ; p_msg 30 | int INT_VECTOR_SYS_CALL 31 | ret 32 | 33 | ; ==================================================================================== 34 | ; void printx(char* s); 35 | ; ==================================================================================== 36 | printx: 37 | mov eax, _NR_printx 38 | mov edx, [esp + 4] 39 | int INT_VECTOR_SYS_CALL 40 | ret 41 | 42 | -------------------------------------------------------------------------------- /c/kernel/syscall.asm: -------------------------------------------------------------------------------- 1 | 2 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | ; syscall.asm 4 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | ; Forrest Yu, 2005 6 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | 8 | %include "sconst.inc" 9 | 10 | INT_VECTOR_SYS_CALL equ 0x90 11 | _NR_printx equ 0 12 | _NR_sendrec equ 1 13 | 14 | ; 导出符号 15 | global printx 16 | global sendrec 17 | 18 | bits 32 19 | [section .text] 20 | 21 | ; ==================================================================================== 22 | ; sendrec(int function, int src_dest, MESSAGE* msg); 23 | ; ==================================================================================== 24 | ; Never call sendrec() directly, call send_recv() instead. 25 | sendrec: 26 | mov eax, _NR_sendrec 27 | mov ebx, [esp + 4] ; function 28 | mov ecx, [esp + 8] ; src_dest 29 | mov edx, [esp + 12] ; p_msg 30 | int INT_VECTOR_SYS_CALL 31 | ret 32 | 33 | ; ==================================================================================== 34 | ; void printx(char* s); 35 | ; ==================================================================================== 36 | printx: 37 | mov eax, _NR_printx 38 | mov edx, [esp + 4] 39 | int INT_VECTOR_SYS_CALL 40 | ret 41 | 42 | -------------------------------------------------------------------------------- /d/kernel/syscall.asm: -------------------------------------------------------------------------------- 1 | 2 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | ; syscall.asm 4 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | ; Forrest Yu, 2005 6 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | 8 | %include "sconst.inc" 9 | 10 | INT_VECTOR_SYS_CALL equ 0x90 11 | _NR_printx equ 0 12 | _NR_sendrec equ 1 13 | 14 | ; 导出符号 15 | global printx 16 | global sendrec 17 | 18 | bits 32 19 | [section .text] 20 | 21 | ; ==================================================================================== 22 | ; sendrec(int function, int src_dest, MESSAGE* msg); 23 | ; ==================================================================================== 24 | ; Never call sendrec() directly, call send_recv() instead. 25 | sendrec: 26 | mov eax, _NR_sendrec 27 | mov ebx, [esp + 4] ; function 28 | mov ecx, [esp + 8] ; src_dest 29 | mov edx, [esp + 12] ; p_msg 30 | int INT_VECTOR_SYS_CALL 31 | ret 32 | 33 | ; ==================================================================================== 34 | ; void printx(char* s); 35 | ; ==================================================================================== 36 | printx: 37 | mov eax, _NR_printx 38 | mov edx, [esp + 4] 39 | int INT_VECTOR_SYS_CALL 40 | ret 41 | 42 | -------------------------------------------------------------------------------- /e/kernel/systask.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file systask.c 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date 2007 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "keyboard.h" 21 | #include "proto.h" 22 | 23 | 24 | /***************************************************************************** 25 | * task_sys 26 | *****************************************************************************/ 27 | /** 28 | * The main loop of TASK SYS. 29 | * 30 | *****************************************************************************/ 31 | PUBLIC void task_sys() 32 | { 33 | MESSAGE msg; 34 | while (1) { 35 | send_recv(RECEIVE, ANY, &msg); 36 | int src = msg.source; 37 | 38 | switch (msg.type) { 39 | case GET_TICKS: 40 | msg.RETVAL = ticks; 41 | send_recv(SEND, src, &msg); 42 | break; 43 | default: 44 | panic("unknown msg type"); 45 | break; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /f/kernel/systask.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file systask.c 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date 2007 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "keyboard.h" 21 | #include "proto.h" 22 | 23 | 24 | /***************************************************************************** 25 | * task_sys 26 | *****************************************************************************/ 27 | /** 28 | * The main loop of TASK SYS. 29 | * 30 | *****************************************************************************/ 31 | PUBLIC void task_sys() 32 | { 33 | MESSAGE msg; 34 | while (1) { 35 | send_recv(RECEIVE, ANY, &msg); 36 | int src = msg.source; 37 | 38 | switch (msg.type) { 39 | case GET_TICKS: 40 | msg.RETVAL = ticks; 41 | send_recv(SEND, src, &msg); 42 | break; 43 | default: 44 | panic("unknown msg type"); 45 | break; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /b/fs/main.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file main.c 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date 2007 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "config.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | #include "hd.h" 23 | 24 | 25 | 26 | /***************************************************************************** 27 | * task_fs 28 | *****************************************************************************/ 29 | /** 30 | * The main loop of TASK FS. 31 | * 32 | *****************************************************************************/ 33 | PUBLIC void task_fs() 34 | { 35 | printl("Task FS begins.\n"); 36 | 37 | /* open the device: hard disk */ 38 | MESSAGE driver_msg; 39 | driver_msg.type = DEV_OPEN; 40 | driver_msg.DEVICE = MINOR(ROOT_DEV); 41 | assert(dd_map[MAJOR(ROOT_DEV)].driver_nr != INVALID_DRIVER); 42 | send_recv(BOTH, dd_map[MAJOR(ROOT_DEV)].driver_nr, &driver_msg); 43 | 44 | spin("FS"); 45 | } 46 | -------------------------------------------------------------------------------- /c/fs/main.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file main.c 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date 2007 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "config.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | #include "hd.h" 23 | 24 | 25 | 26 | /***************************************************************************** 27 | * task_fs 28 | *****************************************************************************/ 29 | /** 30 | * The main loop of TASK FS. 31 | * 32 | *****************************************************************************/ 33 | PUBLIC void task_fs() 34 | { 35 | printl("Task FS begins.\n"); 36 | 37 | /* open the device: hard disk */ 38 | MESSAGE driver_msg; 39 | driver_msg.type = DEV_OPEN; 40 | driver_msg.DEVICE = MINOR(ROOT_DEV); 41 | assert(dd_map[MAJOR(ROOT_DEV)].driver_nr != INVALID_DRIVER); 42 | send_recv(BOTH, dd_map[MAJOR(ROOT_DEV)].driver_nr, &driver_msg); 43 | 44 | spin("FS"); 45 | } 46 | -------------------------------------------------------------------------------- /e/include/type.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | type.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_TYPE_H_ 9 | #define _ORANGES_TYPE_H_ 10 | 11 | /* routine types */ 12 | #define PUBLIC /* PUBLIC is the opposite of PRIVATE */ 13 | #define PRIVATE static /* PRIVATE x limits the scope of x */ 14 | 15 | typedef unsigned long long u64; 16 | typedef unsigned int u32; 17 | typedef unsigned short u16; 18 | typedef unsigned char u8; 19 | 20 | typedef char * va_list; 21 | 22 | typedef void (*int_handler) (); 23 | typedef void (*task_f) (); 24 | typedef void (*irq_handler) (int irq); 25 | 26 | typedef void* system_call; 27 | 28 | 29 | /** 30 | * MESSAGE mechanism is borrowed from MINIX 31 | */ 32 | struct mess1 { 33 | int m1i1; 34 | int m1i2; 35 | int m1i3; 36 | int m1i4; 37 | }; 38 | struct mess2 { 39 | void* m2p1; 40 | void* m2p2; 41 | void* m2p3; 42 | void* m2p4; 43 | }; 44 | struct mess3 { 45 | int m3i1; 46 | int m3i2; 47 | int m3i3; 48 | int m3i4; 49 | u64 m3l1; 50 | u64 m3l2; 51 | void* m3p1; 52 | void* m3p2; 53 | }; 54 | typedef struct { 55 | int source; 56 | int type; 57 | union { 58 | struct mess1 m1; 59 | struct mess2 m2; 60 | struct mess3 m3; 61 | } u; 62 | } MESSAGE; 63 | 64 | 65 | #endif /* _ORANGES_TYPE_H_ */ 66 | -------------------------------------------------------------------------------- /f/include/type.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | type.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_TYPE_H_ 9 | #define _ORANGES_TYPE_H_ 10 | 11 | /* routine types */ 12 | #define PUBLIC /* PUBLIC is the opposite of PRIVATE */ 13 | #define PRIVATE static /* PRIVATE x limits the scope of x */ 14 | 15 | typedef unsigned long long u64; 16 | typedef unsigned int u32; 17 | typedef unsigned short u16; 18 | typedef unsigned char u8; 19 | 20 | typedef char * va_list; 21 | 22 | typedef void (*int_handler) (); 23 | typedef void (*task_f) (); 24 | typedef void (*irq_handler) (int irq); 25 | 26 | typedef void* system_call; 27 | 28 | 29 | /** 30 | * MESSAGE mechanism is borrowed from MINIX 31 | */ 32 | struct mess1 { 33 | int m1i1; 34 | int m1i2; 35 | int m1i3; 36 | int m1i4; 37 | }; 38 | struct mess2 { 39 | void* m2p1; 40 | void* m2p2; 41 | void* m2p3; 42 | void* m2p4; 43 | }; 44 | struct mess3 { 45 | int m3i1; 46 | int m3i2; 47 | int m3i3; 48 | int m3i4; 49 | u64 m3l1; 50 | u64 m3l2; 51 | void* m3p1; 52 | void* m3p2; 53 | }; 54 | typedef struct { 55 | int source; 56 | int type; 57 | union { 58 | struct mess1 m1; 59 | struct mess2 m2; 60 | struct mess3 m3; 61 | } u; 62 | } MESSAGE; 63 | 64 | 65 | #endif /* _ORANGES_TYPE_H_ */ 66 | -------------------------------------------------------------------------------- /g/include/type.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | type.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_TYPE_H_ 9 | #define _ORANGES_TYPE_H_ 10 | 11 | /* routine types */ 12 | #define PUBLIC /* PUBLIC is the opposite of PRIVATE */ 13 | #define PRIVATE static /* PRIVATE x limits the scope of x */ 14 | 15 | typedef unsigned long long u64; 16 | typedef unsigned int u32; 17 | typedef unsigned short u16; 18 | typedef unsigned char u8; 19 | 20 | typedef char * va_list; 21 | 22 | typedef void (*int_handler) (); 23 | typedef void (*task_f) (); 24 | typedef void (*irq_handler) (int irq); 25 | 26 | typedef void* system_call; 27 | 28 | 29 | /** 30 | * MESSAGE mechanism is borrowed from MINIX 31 | */ 32 | struct mess1 { 33 | int m1i1; 34 | int m1i2; 35 | int m1i3; 36 | int m1i4; 37 | }; 38 | struct mess2 { 39 | void* m2p1; 40 | void* m2p2; 41 | void* m2p3; 42 | void* m2p4; 43 | }; 44 | struct mess3 { 45 | int m3i1; 46 | int m3i2; 47 | int m3i3; 48 | int m3i4; 49 | u64 m3l1; 50 | u64 m3l2; 51 | void* m3p1; 52 | void* m3p2; 53 | }; 54 | typedef struct { 55 | int source; 56 | int type; 57 | union { 58 | struct mess1 m1; 59 | struct mess2 m2; 60 | struct mess3 m3; 61 | } u; 62 | } MESSAGE; 63 | 64 | 65 | #endif /* _ORANGES_TYPE_H_ */ 66 | -------------------------------------------------------------------------------- /h/include/type.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | type.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_TYPE_H_ 9 | #define _ORANGES_TYPE_H_ 10 | 11 | /* routine types */ 12 | #define PUBLIC /* PUBLIC is the opposite of PRIVATE */ 13 | #define PRIVATE static /* PRIVATE x limits the scope of x */ 14 | 15 | typedef unsigned long long u64; 16 | typedef unsigned int u32; 17 | typedef unsigned short u16; 18 | typedef unsigned char u8; 19 | 20 | typedef char * va_list; 21 | 22 | typedef void (*int_handler) (); 23 | typedef void (*task_f) (); 24 | typedef void (*irq_handler) (int irq); 25 | 26 | typedef void* system_call; 27 | 28 | 29 | /** 30 | * MESSAGE mechanism is borrowed from MINIX 31 | */ 32 | struct mess1 { 33 | int m1i1; 34 | int m1i2; 35 | int m1i3; 36 | int m1i4; 37 | }; 38 | struct mess2 { 39 | void* m2p1; 40 | void* m2p2; 41 | void* m2p3; 42 | void* m2p4; 43 | }; 44 | struct mess3 { 45 | int m3i1; 46 | int m3i2; 47 | int m3i3; 48 | int m3i4; 49 | u64 m3l1; 50 | u64 m3l2; 51 | void* m3p1; 52 | void* m3p2; 53 | }; 54 | typedef struct { 55 | int source; 56 | int type; 57 | union { 58 | struct mess1 m1; 59 | struct mess2 m2; 60 | struct mess3 m3; 61 | } u; 62 | } MESSAGE; 63 | 64 | 65 | #endif /* _ORANGES_TYPE_H_ */ 66 | -------------------------------------------------------------------------------- /i/include/type.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | type.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_TYPE_H_ 9 | #define _ORANGES_TYPE_H_ 10 | 11 | /* routine types */ 12 | #define PUBLIC /* PUBLIC is the opposite of PRIVATE */ 13 | #define PRIVATE static /* PRIVATE x limits the scope of x */ 14 | 15 | typedef unsigned long long u64; 16 | typedef unsigned int u32; 17 | typedef unsigned short u16; 18 | typedef unsigned char u8; 19 | 20 | typedef char * va_list; 21 | 22 | typedef void (*int_handler) (); 23 | typedef void (*task_f) (); 24 | typedef void (*irq_handler) (int irq); 25 | 26 | typedef void* system_call; 27 | 28 | 29 | /** 30 | * MESSAGE mechanism is borrowed from MINIX 31 | */ 32 | struct mess1 { 33 | int m1i1; 34 | int m1i2; 35 | int m1i3; 36 | int m1i4; 37 | }; 38 | struct mess2 { 39 | void* m2p1; 40 | void* m2p2; 41 | void* m2p3; 42 | void* m2p4; 43 | }; 44 | struct mess3 { 45 | int m3i1; 46 | int m3i2; 47 | int m3i3; 48 | int m3i4; 49 | u64 m3l1; 50 | u64 m3l2; 51 | void* m3p1; 52 | void* m3p2; 53 | }; 54 | typedef struct { 55 | int source; 56 | int type; 57 | union { 58 | struct mess1 m1; 59 | struct mess2 m2; 60 | struct mess3 m3; 61 | } u; 62 | } MESSAGE; 63 | 64 | 65 | #endif /* _ORANGES_TYPE_H_ */ 66 | -------------------------------------------------------------------------------- /j/include/type.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | type.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_TYPE_H_ 9 | #define _ORANGES_TYPE_H_ 10 | 11 | /* routine types */ 12 | #define PUBLIC /* PUBLIC is the opposite of PRIVATE */ 13 | #define PRIVATE static /* PRIVATE x limits the scope of x */ 14 | 15 | typedef unsigned long long u64; 16 | typedef unsigned int u32; 17 | typedef unsigned short u16; 18 | typedef unsigned char u8; 19 | 20 | typedef char * va_list; 21 | 22 | typedef void (*int_handler) (); 23 | typedef void (*task_f) (); 24 | typedef void (*irq_handler) (int irq); 25 | 26 | typedef void* system_call; 27 | 28 | 29 | /** 30 | * MESSAGE mechanism is borrowed from MINIX 31 | */ 32 | struct mess1 { 33 | int m1i1; 34 | int m1i2; 35 | int m1i3; 36 | int m1i4; 37 | }; 38 | struct mess2 { 39 | void* m2p1; 40 | void* m2p2; 41 | void* m2p3; 42 | void* m2p4; 43 | }; 44 | struct mess3 { 45 | int m3i1; 46 | int m3i2; 47 | int m3i3; 48 | int m3i4; 49 | u64 m3l1; 50 | u64 m3l2; 51 | void* m3p1; 52 | void* m3p2; 53 | }; 54 | typedef struct { 55 | int source; 56 | int type; 57 | union { 58 | struct mess1 m1; 59 | struct mess2 m2; 60 | struct mess3 m3; 61 | } u; 62 | } MESSAGE; 63 | 64 | 65 | #endif /* _ORANGES_TYPE_H_ */ 66 | -------------------------------------------------------------------------------- /f/lib/read.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file read.c 4 | * @brief read() 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | /***************************************************************************** 23 | * read 24 | *****************************************************************************/ 25 | /** 26 | * Read from a file descriptor. 27 | * 28 | * @param fd File descriptor. 29 | * @param buf Buffer to accept the bytes read. 30 | * @param count How many bytes to read. 31 | * 32 | * @return On success, the number of bytes read are returned. 33 | * On error, -1 is returned. 34 | *****************************************************************************/ 35 | PUBLIC int read(int fd, void *buf, int count) 36 | { 37 | MESSAGE msg; 38 | msg.type = READ; 39 | msg.FD = fd; 40 | msg.BUF = buf; 41 | msg.CNT = count; 42 | 43 | send_recv(BOTH, TASK_FS, &msg); 44 | 45 | return msg.CNT; 46 | } 47 | -------------------------------------------------------------------------------- /g/lib/read.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file read.c 4 | * @brief read() 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | /***************************************************************************** 23 | * read 24 | *****************************************************************************/ 25 | /** 26 | * Read from a file descriptor. 27 | * 28 | * @param fd File descriptor. 29 | * @param buf Buffer to accept the bytes read. 30 | * @param count How many bytes to read. 31 | * 32 | * @return On success, the number of bytes read are returned. 33 | * On error, -1 is returned. 34 | *****************************************************************************/ 35 | PUBLIC int read(int fd, void *buf, int count) 36 | { 37 | MESSAGE msg; 38 | msg.type = READ; 39 | msg.FD = fd; 40 | msg.BUF = buf; 41 | msg.CNT = count; 42 | 43 | send_recv(BOTH, TASK_FS, &msg); 44 | 45 | return msg.CNT; 46 | } 47 | -------------------------------------------------------------------------------- /h/lib/read.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file read.c 4 | * @brief read() 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | /***************************************************************************** 23 | * read 24 | *****************************************************************************/ 25 | /** 26 | * Read from a file descriptor. 27 | * 28 | * @param fd File descriptor. 29 | * @param buf Buffer to accept the bytes read. 30 | * @param count How many bytes to read. 31 | * 32 | * @return On success, the number of bytes read are returned. 33 | * On error, -1 is returned. 34 | *****************************************************************************/ 35 | PUBLIC int read(int fd, void *buf, int count) 36 | { 37 | MESSAGE msg; 38 | msg.type = READ; 39 | msg.FD = fd; 40 | msg.BUF = buf; 41 | msg.CNT = count; 42 | 43 | send_recv(BOTH, TASK_FS, &msg); 44 | 45 | return msg.CNT; 46 | } 47 | -------------------------------------------------------------------------------- /i/lib/read.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file read.c 4 | * @brief read() 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | /***************************************************************************** 23 | * read 24 | *****************************************************************************/ 25 | /** 26 | * Read from a file descriptor. 27 | * 28 | * @param fd File descriptor. 29 | * @param buf Buffer to accept the bytes read. 30 | * @param count How many bytes to read. 31 | * 32 | * @return On success, the number of bytes read are returned. 33 | * On error, -1 is returned. 34 | *****************************************************************************/ 35 | PUBLIC int read(int fd, void *buf, int count) 36 | { 37 | MESSAGE msg; 38 | msg.type = READ; 39 | msg.FD = fd; 40 | msg.BUF = buf; 41 | msg.CNT = count; 42 | 43 | send_recv(BOTH, TASK_FS, &msg); 44 | 45 | return msg.CNT; 46 | } 47 | -------------------------------------------------------------------------------- /j/lib/read.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file read.c 4 | * @brief read() 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | /***************************************************************************** 23 | * read 24 | *****************************************************************************/ 25 | /** 26 | * Read from a file descriptor. 27 | * 28 | * @param fd File descriptor. 29 | * @param buf Buffer to accept the bytes read. 30 | * @param count How many bytes to read. 31 | * 32 | * @return On success, the number of bytes read are returned. 33 | * On error, -1 is returned. 34 | *****************************************************************************/ 35 | PUBLIC int read(int fd, void *buf, int count) 36 | { 37 | MESSAGE msg; 38 | msg.type = READ; 39 | msg.FD = fd; 40 | msg.BUF = buf; 41 | msg.CNT = count; 42 | 43 | send_recv(BOTH, TASK_FS, &msg); 44 | 45 | return msg.CNT; 46 | } 47 | -------------------------------------------------------------------------------- /e/lib/open.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file open.c 4 | * @brief open() 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | /***************************************************************************** 23 | * open 24 | *****************************************************************************/ 25 | /** 26 | * open/create a file. 27 | * 28 | * @param pathname The full path of the file to be opened/created. 29 | * @param flags O_CREAT, O_RDWR, etc. 30 | * 31 | * @return File descriptor if successful, otherwise -1. 32 | *****************************************************************************/ 33 | PUBLIC int open(const char *pathname, int flags) 34 | { 35 | MESSAGE msg; 36 | 37 | msg.type = OPEN; 38 | 39 | msg.PATHNAME = (void*)pathname; 40 | msg.FLAGS = flags; 41 | msg.NAME_LEN = strlen(pathname); 42 | 43 | send_recv(BOTH, TASK_FS, &msg); 44 | assert(msg.type == SYSCALL_RET); 45 | 46 | return msg.FD; 47 | } 48 | -------------------------------------------------------------------------------- /f/lib/open.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file open.c 4 | * @brief open() 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | /***************************************************************************** 23 | * open 24 | *****************************************************************************/ 25 | /** 26 | * open/create a file. 27 | * 28 | * @param pathname The full path of the file to be opened/created. 29 | * @param flags O_CREAT, O_RDWR, etc. 30 | * 31 | * @return File descriptor if successful, otherwise -1. 32 | *****************************************************************************/ 33 | PUBLIC int open(const char *pathname, int flags) 34 | { 35 | MESSAGE msg; 36 | 37 | msg.type = OPEN; 38 | 39 | msg.PATHNAME = (void*)pathname; 40 | msg.FLAGS = flags; 41 | msg.NAME_LEN = strlen(pathname); 42 | 43 | send_recv(BOTH, TASK_FS, &msg); 44 | assert(msg.type == SYSCALL_RET); 45 | 46 | return msg.FD; 47 | } 48 | -------------------------------------------------------------------------------- /g/lib/open.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file open.c 4 | * @brief open() 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | /***************************************************************************** 23 | * open 24 | *****************************************************************************/ 25 | /** 26 | * open/create a file. 27 | * 28 | * @param pathname The full path of the file to be opened/created. 29 | * @param flags O_CREAT, O_RDWR, etc. 30 | * 31 | * @return File descriptor if successful, otherwise -1. 32 | *****************************************************************************/ 33 | PUBLIC int open(const char *pathname, int flags) 34 | { 35 | MESSAGE msg; 36 | 37 | msg.type = OPEN; 38 | 39 | msg.PATHNAME = (void*)pathname; 40 | msg.FLAGS = flags; 41 | msg.NAME_LEN = strlen(pathname); 42 | 43 | send_recv(BOTH, TASK_FS, &msg); 44 | assert(msg.type == SYSCALL_RET); 45 | 46 | return msg.FD; 47 | } 48 | -------------------------------------------------------------------------------- /h/lib/open.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file open.c 4 | * @brief open() 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | /***************************************************************************** 23 | * open 24 | *****************************************************************************/ 25 | /** 26 | * open/create a file. 27 | * 28 | * @param pathname The full path of the file to be opened/created. 29 | * @param flags O_CREAT, O_RDWR, etc. 30 | * 31 | * @return File descriptor if successful, otherwise -1. 32 | *****************************************************************************/ 33 | PUBLIC int open(const char *pathname, int flags) 34 | { 35 | MESSAGE msg; 36 | 37 | msg.type = OPEN; 38 | 39 | msg.PATHNAME = (void*)pathname; 40 | msg.FLAGS = flags; 41 | msg.NAME_LEN = strlen(pathname); 42 | 43 | send_recv(BOTH, TASK_FS, &msg); 44 | assert(msg.type == SYSCALL_RET); 45 | 46 | return msg.FD; 47 | } 48 | -------------------------------------------------------------------------------- /i/lib/open.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file open.c 4 | * @brief open() 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | /***************************************************************************** 23 | * open 24 | *****************************************************************************/ 25 | /** 26 | * open/create a file. 27 | * 28 | * @param pathname The full path of the file to be opened/created. 29 | * @param flags O_CREAT, O_RDWR, etc. 30 | * 31 | * @return File descriptor if successful, otherwise -1. 32 | *****************************************************************************/ 33 | PUBLIC int open(const char *pathname, int flags) 34 | { 35 | MESSAGE msg; 36 | 37 | msg.type = OPEN; 38 | 39 | msg.PATHNAME = (void*)pathname; 40 | msg.FLAGS = flags; 41 | msg.NAME_LEN = strlen(pathname); 42 | 43 | send_recv(BOTH, TASK_FS, &msg); 44 | assert(msg.type == SYSCALL_RET); 45 | 46 | return msg.FD; 47 | } 48 | -------------------------------------------------------------------------------- /j/lib/open.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file open.c 4 | * @brief open() 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | /***************************************************************************** 23 | * open 24 | *****************************************************************************/ 25 | /** 26 | * open/create a file. 27 | * 28 | * @param pathname The full path of the file to be opened/created. 29 | * @param flags O_CREAT, O_RDWR, etc. 30 | * 31 | * @return File descriptor if successful, otherwise -1. 32 | *****************************************************************************/ 33 | PUBLIC int open(const char *pathname, int flags) 34 | { 35 | MESSAGE msg; 36 | 37 | msg.type = OPEN; 38 | 39 | msg.PATHNAME = (void*)pathname; 40 | msg.FLAGS = flags; 41 | msg.NAME_LEN = strlen(pathname); 42 | 43 | send_recv(BOTH, TASK_FS, &msg); 44 | assert(msg.type == SYSCALL_RET); 45 | 46 | return msg.FD; 47 | } 48 | -------------------------------------------------------------------------------- /e/include/sys/global.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | global.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | /* EXTERN is defined as extern except in global.c */ 9 | #ifdef GLOBAL_VARIABLES_HERE 10 | #undef EXTERN 11 | #define EXTERN 12 | #endif 13 | 14 | EXTERN int ticks; 15 | 16 | EXTERN int disp_pos; 17 | 18 | EXTERN u8 gdt_ptr[6]; /* 0~15:Limit 16~47:Base */ 19 | EXTERN struct descriptor gdt[GDT_SIZE]; 20 | EXTERN u8 idt_ptr[6]; /* 0~15:Limit 16~47:Base */ 21 | EXTERN struct gate idt[IDT_SIZE]; 22 | 23 | EXTERN u32 k_reenter; 24 | EXTERN int nr_current_console; 25 | 26 | EXTERN struct tss tss; 27 | EXTERN struct proc* p_proc_ready; 28 | 29 | extern char task_stack[]; 30 | extern struct proc proc_table[]; 31 | extern struct task task_table[]; 32 | extern struct task user_proc_table[]; 33 | extern irq_handler irq_table[]; 34 | extern TTY tty_table[]; 35 | extern CONSOLE console_table[]; 36 | 37 | /* FS */ 38 | EXTERN struct file_desc f_desc_table[NR_FILE_DESC]; 39 | EXTERN struct inode inode_table[NR_INODE]; 40 | EXTERN struct super_block super_block[NR_SUPER_BLOCK]; 41 | extern u8 * fsbuf; 42 | extern const int FSBUF_SIZE; 43 | EXTERN MESSAGE fs_msg; 44 | EXTERN struct proc * pcaller; 45 | EXTERN struct inode * root_inode; 46 | extern struct dev_drv_map dd_map[]; 47 | 48 | -------------------------------------------------------------------------------- /f/include/sys/global.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | global.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | /* EXTERN is defined as extern except in global.c */ 9 | #ifdef GLOBAL_VARIABLES_HERE 10 | #undef EXTERN 11 | #define EXTERN 12 | #endif 13 | 14 | EXTERN int ticks; 15 | 16 | EXTERN int disp_pos; 17 | 18 | EXTERN u8 gdt_ptr[6]; /* 0~15:Limit 16~47:Base */ 19 | EXTERN struct descriptor gdt[GDT_SIZE]; 20 | EXTERN u8 idt_ptr[6]; /* 0~15:Limit 16~47:Base */ 21 | EXTERN struct gate idt[IDT_SIZE]; 22 | 23 | EXTERN u32 k_reenter; 24 | EXTERN int nr_current_console; 25 | 26 | EXTERN struct tss tss; 27 | EXTERN struct proc* p_proc_ready; 28 | 29 | extern char task_stack[]; 30 | extern struct proc proc_table[]; 31 | extern struct task task_table[]; 32 | extern struct task user_proc_table[]; 33 | extern irq_handler irq_table[]; 34 | extern TTY tty_table[]; 35 | extern CONSOLE console_table[]; 36 | 37 | /* FS */ 38 | EXTERN struct file_desc f_desc_table[NR_FILE_DESC]; 39 | EXTERN struct inode inode_table[NR_INODE]; 40 | EXTERN struct super_block super_block[NR_SUPER_BLOCK]; 41 | extern u8 * fsbuf; 42 | extern const int FSBUF_SIZE; 43 | EXTERN MESSAGE fs_msg; 44 | EXTERN struct proc * pcaller; 45 | EXTERN struct inode * root_inode; 46 | extern struct dev_drv_map dd_map[]; 47 | 48 | -------------------------------------------------------------------------------- /g/include/sys/global.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | global.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | /* EXTERN is defined as extern except in global.c */ 9 | #ifdef GLOBAL_VARIABLES_HERE 10 | #undef EXTERN 11 | #define EXTERN 12 | #endif 13 | 14 | EXTERN int ticks; 15 | 16 | EXTERN int disp_pos; 17 | 18 | EXTERN u8 gdt_ptr[6]; /* 0~15:Limit 16~47:Base */ 19 | EXTERN struct descriptor gdt[GDT_SIZE]; 20 | EXTERN u8 idt_ptr[6]; /* 0~15:Limit 16~47:Base */ 21 | EXTERN struct gate idt[IDT_SIZE]; 22 | 23 | EXTERN u32 k_reenter; 24 | EXTERN int nr_current_console; 25 | 26 | EXTERN struct tss tss; 27 | EXTERN struct proc* p_proc_ready; 28 | 29 | extern char task_stack[]; 30 | extern struct proc proc_table[]; 31 | extern struct task task_table[]; 32 | extern struct task user_proc_table[]; 33 | extern irq_handler irq_table[]; 34 | extern TTY tty_table[]; 35 | extern CONSOLE console_table[]; 36 | 37 | /* FS */ 38 | EXTERN struct file_desc f_desc_table[NR_FILE_DESC]; 39 | EXTERN struct inode inode_table[NR_INODE]; 40 | EXTERN struct super_block super_block[NR_SUPER_BLOCK]; 41 | extern u8 * fsbuf; 42 | extern const int FSBUF_SIZE; 43 | EXTERN MESSAGE fs_msg; 44 | EXTERN struct proc * pcaller; 45 | EXTERN struct inode * root_inode; 46 | extern struct dev_drv_map dd_map[]; 47 | 48 | -------------------------------------------------------------------------------- /h/include/sys/global.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | global.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | /* EXTERN is defined as extern except in global.c */ 9 | #ifdef GLOBAL_VARIABLES_HERE 10 | #undef EXTERN 11 | #define EXTERN 12 | #endif 13 | 14 | EXTERN int ticks; 15 | 16 | EXTERN int disp_pos; 17 | 18 | EXTERN u8 gdt_ptr[6]; /* 0~15:Limit 16~47:Base */ 19 | EXTERN struct descriptor gdt[GDT_SIZE]; 20 | EXTERN u8 idt_ptr[6]; /* 0~15:Limit 16~47:Base */ 21 | EXTERN struct gate idt[IDT_SIZE]; 22 | 23 | EXTERN u32 k_reenter; 24 | EXTERN int nr_current_console; 25 | 26 | EXTERN struct tss tss; 27 | EXTERN struct proc* p_proc_ready; 28 | 29 | extern char task_stack[]; 30 | extern struct proc proc_table[]; 31 | extern struct task task_table[]; 32 | extern struct task user_proc_table[]; 33 | extern irq_handler irq_table[]; 34 | extern TTY tty_table[]; 35 | extern CONSOLE console_table[]; 36 | 37 | /* FS */ 38 | EXTERN struct file_desc f_desc_table[NR_FILE_DESC]; 39 | EXTERN struct inode inode_table[NR_INODE]; 40 | EXTERN struct super_block super_block[NR_SUPER_BLOCK]; 41 | extern u8 * fsbuf; 42 | extern const int FSBUF_SIZE; 43 | EXTERN MESSAGE fs_msg; 44 | EXTERN struct proc * pcaller; 45 | EXTERN struct inode * root_inode; 46 | extern struct dev_drv_map dd_map[]; 47 | 48 | -------------------------------------------------------------------------------- /f/lib/write.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file write.c 4 | * @brief write() 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | /***************************************************************************** 23 | * write 24 | *****************************************************************************/ 25 | /** 26 | * Write to a file descriptor. 27 | * 28 | * @param fd File descriptor. 29 | * @param buf Buffer including the bytes to write. 30 | * @param count How many bytes to write. 31 | * 32 | * @return On success, the number of bytes written are returned. 33 | * On error, -1 is returned. 34 | *****************************************************************************/ 35 | PUBLIC int write(int fd, const void *buf, int count) 36 | { 37 | MESSAGE msg; 38 | msg.type = WRITE; 39 | msg.FD = fd; 40 | msg.BUF = (void*)buf; 41 | msg.CNT = count; 42 | 43 | send_recv(BOTH, TASK_FS, &msg); 44 | 45 | return msg.CNT; 46 | } 47 | -------------------------------------------------------------------------------- /g/lib/write.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file write.c 4 | * @brief write() 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | /***************************************************************************** 23 | * write 24 | *****************************************************************************/ 25 | /** 26 | * Write to a file descriptor. 27 | * 28 | * @param fd File descriptor. 29 | * @param buf Buffer including the bytes to write. 30 | * @param count How many bytes to write. 31 | * 32 | * @return On success, the number of bytes written are returned. 33 | * On error, -1 is returned. 34 | *****************************************************************************/ 35 | PUBLIC int write(int fd, const void *buf, int count) 36 | { 37 | MESSAGE msg; 38 | msg.type = WRITE; 39 | msg.FD = fd; 40 | msg.BUF = (void*)buf; 41 | msg.CNT = count; 42 | 43 | send_recv(BOTH, TASK_FS, &msg); 44 | 45 | return msg.CNT; 46 | } 47 | -------------------------------------------------------------------------------- /h/lib/write.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file write.c 4 | * @brief write() 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | /***************************************************************************** 23 | * write 24 | *****************************************************************************/ 25 | /** 26 | * Write to a file descriptor. 27 | * 28 | * @param fd File descriptor. 29 | * @param buf Buffer including the bytes to write. 30 | * @param count How many bytes to write. 31 | * 32 | * @return On success, the number of bytes written are returned. 33 | * On error, -1 is returned. 34 | *****************************************************************************/ 35 | PUBLIC int write(int fd, const void *buf, int count) 36 | { 37 | MESSAGE msg; 38 | msg.type = WRITE; 39 | msg.FD = fd; 40 | msg.BUF = (void*)buf; 41 | msg.CNT = count; 42 | 43 | send_recv(BOTH, TASK_FS, &msg); 44 | 45 | return msg.CNT; 46 | } 47 | -------------------------------------------------------------------------------- /i/lib/write.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file write.c 4 | * @brief write() 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | /***************************************************************************** 23 | * write 24 | *****************************************************************************/ 25 | /** 26 | * Write to a file descriptor. 27 | * 28 | * @param fd File descriptor. 29 | * @param buf Buffer including the bytes to write. 30 | * @param count How many bytes to write. 31 | * 32 | * @return On success, the number of bytes written are returned. 33 | * On error, -1 is returned. 34 | *****************************************************************************/ 35 | PUBLIC int write(int fd, const void *buf, int count) 36 | { 37 | MESSAGE msg; 38 | msg.type = WRITE; 39 | msg.FD = fd; 40 | msg.BUF = (void*)buf; 41 | msg.CNT = count; 42 | 43 | send_recv(BOTH, TASK_FS, &msg); 44 | 45 | return msg.CNT; 46 | } 47 | -------------------------------------------------------------------------------- /j/lib/write.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file write.c 4 | * @brief write() 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "proto.h" 21 | 22 | /***************************************************************************** 23 | * write 24 | *****************************************************************************/ 25 | /** 26 | * Write to a file descriptor. 27 | * 28 | * @param fd File descriptor. 29 | * @param buf Buffer including the bytes to write. 30 | * @param count How many bytes to write. 31 | * 32 | * @return On success, the number of bytes written are returned. 33 | * On error, -1 is returned. 34 | *****************************************************************************/ 35 | PUBLIC int write(int fd, const void *buf, int count) 36 | { 37 | MESSAGE msg; 38 | msg.type = WRITE; 39 | msg.FD = fd; 40 | msg.BUF = (void*)buf; 41 | msg.CNT = count; 42 | 43 | send_recv(BOTH, TASK_FS, &msg); 44 | 45 | return msg.CNT; 46 | } 47 | -------------------------------------------------------------------------------- /a/include/sconst.inc: -------------------------------------------------------------------------------- 1 | 2 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | ; sconst.inc 4 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | ; Forrest Yu, 2005 6 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | 8 | P_STACKBASE equ 0 9 | GSREG equ P_STACKBASE 10 | FSREG equ GSREG + 4 11 | ESREG equ FSREG + 4 12 | DSREG equ ESREG + 4 13 | EDIREG equ DSREG + 4 14 | ESIREG equ EDIREG + 4 15 | EBPREG equ ESIREG + 4 16 | KERNELESPREG equ EBPREG + 4 17 | EBXREG equ KERNELESPREG + 4 18 | EDXREG equ EBXREG + 4 19 | ECXREG equ EDXREG + 4 20 | EAXREG equ ECXREG + 4 21 | RETADR equ EAXREG + 4 22 | EIPREG equ RETADR + 4 23 | CSREG equ EIPREG + 4 24 | EFLAGSREG equ CSREG + 4 25 | ESPREG equ EFLAGSREG + 4 26 | SSREG equ ESPREG + 4 27 | P_STACKTOP equ SSREG + 4 28 | P_LDT_SEL equ P_STACKTOP 29 | P_LDT equ P_LDT_SEL + 4 30 | 31 | TSS3_S_SP0 equ 4 32 | 33 | INT_M_CTL equ 0x20 ; I/O port for interrupt controller 34 | INT_M_CTLMASK equ 0x21 ; setting bits in this port disables ints 35 | INT_S_CTL equ 0xA0 ; I/O port for second interrupt controller 36 | INT_S_CTLMASK equ 0xA1 ; setting bits in this port disables ints 37 | 38 | EOI equ 0x20 39 | 40 | ; 以下选择子值必须与 protect.h 中保持一致!!! 41 | SELECTOR_FLAT_C equ 0x08 ; LOADER 里面已经确定了的. 42 | SELECTOR_TSS equ 0x20 ; TSS. 从外层跳到内存时 SS 和 ESP 的值从里面获得. 43 | SELECTOR_KERNEL_CS equ SELECTOR_FLAT_C 44 | 45 | -------------------------------------------------------------------------------- /b/include/sconst.inc: -------------------------------------------------------------------------------- 1 | 2 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | ; sconst.inc 4 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | ; Forrest Yu, 2005 6 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | 8 | P_STACKBASE equ 0 9 | GSREG equ P_STACKBASE 10 | FSREG equ GSREG + 4 11 | ESREG equ FSREG + 4 12 | DSREG equ ESREG + 4 13 | EDIREG equ DSREG + 4 14 | ESIREG equ EDIREG + 4 15 | EBPREG equ ESIREG + 4 16 | KERNELESPREG equ EBPREG + 4 17 | EBXREG equ KERNELESPREG + 4 18 | EDXREG equ EBXREG + 4 19 | ECXREG equ EDXREG + 4 20 | EAXREG equ ECXREG + 4 21 | RETADR equ EAXREG + 4 22 | EIPREG equ RETADR + 4 23 | CSREG equ EIPREG + 4 24 | EFLAGSREG equ CSREG + 4 25 | ESPREG equ EFLAGSREG + 4 26 | SSREG equ ESPREG + 4 27 | P_STACKTOP equ SSREG + 4 28 | P_LDT_SEL equ P_STACKTOP 29 | P_LDT equ P_LDT_SEL + 4 30 | 31 | TSS3_S_SP0 equ 4 32 | 33 | INT_M_CTL equ 0x20 ; I/O port for interrupt controller 34 | INT_M_CTLMASK equ 0x21 ; setting bits in this port disables ints 35 | INT_S_CTL equ 0xA0 ; I/O port for second interrupt controller 36 | INT_S_CTLMASK equ 0xA1 ; setting bits in this port disables ints 37 | 38 | EOI equ 0x20 39 | 40 | ; 以下选择子值必须与 protect.h 中保持一致!!! 41 | SELECTOR_FLAT_C equ 0x08 ; LOADER 里面已经确定了的. 42 | SELECTOR_TSS equ 0x20 ; TSS. 从外层跳到内存时 SS 和 ESP 的值从里面获得. 43 | SELECTOR_KERNEL_CS equ SELECTOR_FLAT_C 44 | 45 | -------------------------------------------------------------------------------- /c/include/sconst.inc: -------------------------------------------------------------------------------- 1 | 2 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | ; sconst.inc 4 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | ; Forrest Yu, 2005 6 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | 8 | P_STACKBASE equ 0 9 | GSREG equ P_STACKBASE 10 | FSREG equ GSREG + 4 11 | ESREG equ FSREG + 4 12 | DSREG equ ESREG + 4 13 | EDIREG equ DSREG + 4 14 | ESIREG equ EDIREG + 4 15 | EBPREG equ ESIREG + 4 16 | KERNELESPREG equ EBPREG + 4 17 | EBXREG equ KERNELESPREG + 4 18 | EDXREG equ EBXREG + 4 19 | ECXREG equ EDXREG + 4 20 | EAXREG equ ECXREG + 4 21 | RETADR equ EAXREG + 4 22 | EIPREG equ RETADR + 4 23 | CSREG equ EIPREG + 4 24 | EFLAGSREG equ CSREG + 4 25 | ESPREG equ EFLAGSREG + 4 26 | SSREG equ ESPREG + 4 27 | P_STACKTOP equ SSREG + 4 28 | P_LDT_SEL equ P_STACKTOP 29 | P_LDT equ P_LDT_SEL + 4 30 | 31 | TSS3_S_SP0 equ 4 32 | 33 | INT_M_CTL equ 0x20 ; I/O port for interrupt controller 34 | INT_M_CTLMASK equ 0x21 ; setting bits in this port disables ints 35 | INT_S_CTL equ 0xA0 ; I/O port for second interrupt controller 36 | INT_S_CTLMASK equ 0xA1 ; setting bits in this port disables ints 37 | 38 | EOI equ 0x20 39 | 40 | ; 以下选择子值必须与 protect.h 中保持一致!!! 41 | SELECTOR_FLAT_C equ 0x08 ; LOADER 里面已经确定了的. 42 | SELECTOR_TSS equ 0x20 ; TSS. 从外层跳到内存时 SS 和 ESP 的值从里面获得. 43 | SELECTOR_KERNEL_CS equ SELECTOR_FLAT_C 44 | 45 | -------------------------------------------------------------------------------- /d/include/sconst.inc: -------------------------------------------------------------------------------- 1 | 2 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | ; sconst.inc 4 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | ; Forrest Yu, 2005 6 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | 8 | P_STACKBASE equ 0 9 | GSREG equ P_STACKBASE 10 | FSREG equ GSREG + 4 11 | ESREG equ FSREG + 4 12 | DSREG equ ESREG + 4 13 | EDIREG equ DSREG + 4 14 | ESIREG equ EDIREG + 4 15 | EBPREG equ ESIREG + 4 16 | KERNELESPREG equ EBPREG + 4 17 | EBXREG equ KERNELESPREG + 4 18 | EDXREG equ EBXREG + 4 19 | ECXREG equ EDXREG + 4 20 | EAXREG equ ECXREG + 4 21 | RETADR equ EAXREG + 4 22 | EIPREG equ RETADR + 4 23 | CSREG equ EIPREG + 4 24 | EFLAGSREG equ CSREG + 4 25 | ESPREG equ EFLAGSREG + 4 26 | SSREG equ ESPREG + 4 27 | P_STACKTOP equ SSREG + 4 28 | P_LDT_SEL equ P_STACKTOP 29 | P_LDT equ P_LDT_SEL + 4 30 | 31 | TSS3_S_SP0 equ 4 32 | 33 | INT_M_CTL equ 0x20 ; I/O port for interrupt controller 34 | INT_M_CTLMASK equ 0x21 ; setting bits in this port disables ints 35 | INT_S_CTL equ 0xA0 ; I/O port for second interrupt controller 36 | INT_S_CTLMASK equ 0xA1 ; setting bits in this port disables ints 37 | 38 | EOI equ 0x20 39 | 40 | ; 以下选择子值必须与 protect.h 中保持一致!!! 41 | SELECTOR_FLAT_C equ 0x08 ; LOADER 里面已经确定了的. 42 | SELECTOR_TSS equ 0x20 ; TSS. 从外层跳到内存时 SS 和 ESP 的值从里面获得. 43 | SELECTOR_KERNEL_CS equ SELECTOR_FLAT_C 44 | 45 | -------------------------------------------------------------------------------- /g/kernel/systask.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file systask.c 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date 2007 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "keyboard.h" 21 | #include "proto.h" 22 | 23 | 24 | /***************************************************************************** 25 | * task_sys 26 | *****************************************************************************/ 27 | /** 28 | * The main loop of TASK SYS. 29 | * 30 | *****************************************************************************/ 31 | PUBLIC void task_sys() 32 | { 33 | MESSAGE msg; 34 | while (1) { 35 | send_recv(RECEIVE, ANY, &msg); 36 | int src = msg.source; 37 | 38 | switch (msg.type) { 39 | case GET_TICKS: 40 | msg.RETVAL = ticks; 41 | send_recv(SEND, src, &msg); 42 | break; 43 | case GET_PID: 44 | msg.type = SYSCALL_RET; 45 | msg.PID = src; 46 | send_recv(SEND, src, &msg); 47 | break; 48 | default: 49 | panic("unknown msg type"); 50 | break; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /h/kernel/systask.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file systask.c 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date 2007 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "keyboard.h" 21 | #include "proto.h" 22 | 23 | 24 | /***************************************************************************** 25 | * task_sys 26 | *****************************************************************************/ 27 | /** 28 | * The main loop of TASK SYS. 29 | * 30 | *****************************************************************************/ 31 | PUBLIC void task_sys() 32 | { 33 | MESSAGE msg; 34 | while (1) { 35 | send_recv(RECEIVE, ANY, &msg); 36 | int src = msg.source; 37 | 38 | switch (msg.type) { 39 | case GET_TICKS: 40 | msg.RETVAL = ticks; 41 | send_recv(SEND, src, &msg); 42 | break; 43 | case GET_PID: 44 | msg.type = SYSCALL_RET; 45 | msg.PID = src; 46 | send_recv(SEND, src, &msg); 47 | break; 48 | default: 49 | panic("unknown msg type"); 50 | break; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /i/kernel/systask.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file systask.c 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date 2007 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "keyboard.h" 21 | #include "proto.h" 22 | 23 | 24 | /***************************************************************************** 25 | * task_sys 26 | *****************************************************************************/ 27 | /** 28 | * The main loop of TASK SYS. 29 | * 30 | *****************************************************************************/ 31 | PUBLIC void task_sys() 32 | { 33 | MESSAGE msg; 34 | while (1) { 35 | send_recv(RECEIVE, ANY, &msg); 36 | int src = msg.source; 37 | 38 | switch (msg.type) { 39 | case GET_TICKS: 40 | msg.RETVAL = ticks; 41 | send_recv(SEND, src, &msg); 42 | break; 43 | case GET_PID: 44 | msg.type = SYSCALL_RET; 45 | msg.PID = src; 46 | send_recv(SEND, src, &msg); 47 | break; 48 | default: 49 | panic("unknown msg type"); 50 | break; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /j/kernel/systask.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file systask.c 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date 2007 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | #include "type.h" 11 | #include "stdio.h" 12 | #include "const.h" 13 | #include "protect.h" 14 | #include "string.h" 15 | #include "fs.h" 16 | #include "proc.h" 17 | #include "tty.h" 18 | #include "console.h" 19 | #include "global.h" 20 | #include "keyboard.h" 21 | #include "proto.h" 22 | 23 | 24 | /***************************************************************************** 25 | * task_sys 26 | *****************************************************************************/ 27 | /** 28 | * The main loop of TASK SYS. 29 | * 30 | *****************************************************************************/ 31 | PUBLIC void task_sys() 32 | { 33 | MESSAGE msg; 34 | while (1) { 35 | send_recv(RECEIVE, ANY, &msg); 36 | int src = msg.source; 37 | 38 | switch (msg.type) { 39 | case GET_TICKS: 40 | msg.RETVAL = ticks; 41 | send_recv(SEND, src, &msg); 42 | break; 43 | case GET_PID: 44 | msg.type = SYSCALL_RET; 45 | msg.PID = src; 46 | send_recv(SEND, src, &msg); 47 | break; 48 | default: 49 | panic("unknown msg type"); 50 | break; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /e/include/sys/sconst.inc: -------------------------------------------------------------------------------- 1 | 2 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | ; sconst.inc 4 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | ; Forrest Yu, 2005 6 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | 8 | P_STACKBASE equ 0 9 | GSREG equ P_STACKBASE 10 | FSREG equ GSREG + 4 11 | ESREG equ FSREG + 4 12 | DSREG equ ESREG + 4 13 | EDIREG equ DSREG + 4 14 | ESIREG equ EDIREG + 4 15 | EBPREG equ ESIREG + 4 16 | KERNELESPREG equ EBPREG + 4 17 | EBXREG equ KERNELESPREG + 4 18 | EDXREG equ EBXREG + 4 19 | ECXREG equ EDXREG + 4 20 | EAXREG equ ECXREG + 4 21 | RETADR equ EAXREG + 4 22 | EIPREG equ RETADR + 4 23 | CSREG equ EIPREG + 4 24 | EFLAGSREG equ CSREG + 4 25 | ESPREG equ EFLAGSREG + 4 26 | SSREG equ ESPREG + 4 27 | P_STACKTOP equ SSREG + 4 28 | P_LDT_SEL equ P_STACKTOP 29 | P_LDT equ P_LDT_SEL + 4 30 | 31 | TSS3_S_SP0 equ 4 32 | 33 | INT_M_CTL equ 0x20 ; I/O port for interrupt controller 34 | INT_M_CTLMASK equ 0x21 ; setting bits in this port disables ints 35 | INT_S_CTL equ 0xA0 ; I/O port for second interrupt controller 36 | INT_S_CTLMASK equ 0xA1 ; setting bits in this port disables ints 37 | 38 | EOI equ 0x20 39 | 40 | ; 以下选择子值必须与 protect.h 中保持一致!!! 41 | SELECTOR_FLAT_C equ 0x08 ; LOADER 里面已经确定了的. 42 | SELECTOR_TSS equ 0x20 ; TSS. 从外层跳到内存时 SS 和 ESP 的值从里面获得. 43 | SELECTOR_KERNEL_CS equ SELECTOR_FLAT_C 44 | 45 | -------------------------------------------------------------------------------- /f/include/sys/sconst.inc: -------------------------------------------------------------------------------- 1 | 2 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | ; sconst.inc 4 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | ; Forrest Yu, 2005 6 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | 8 | P_STACKBASE equ 0 9 | GSREG equ P_STACKBASE 10 | FSREG equ GSREG + 4 11 | ESREG equ FSREG + 4 12 | DSREG equ ESREG + 4 13 | EDIREG equ DSREG + 4 14 | ESIREG equ EDIREG + 4 15 | EBPREG equ ESIREG + 4 16 | KERNELESPREG equ EBPREG + 4 17 | EBXREG equ KERNELESPREG + 4 18 | EDXREG equ EBXREG + 4 19 | ECXREG equ EDXREG + 4 20 | EAXREG equ ECXREG + 4 21 | RETADR equ EAXREG + 4 22 | EIPREG equ RETADR + 4 23 | CSREG equ EIPREG + 4 24 | EFLAGSREG equ CSREG + 4 25 | ESPREG equ EFLAGSREG + 4 26 | SSREG equ ESPREG + 4 27 | P_STACKTOP equ SSREG + 4 28 | P_LDT_SEL equ P_STACKTOP 29 | P_LDT equ P_LDT_SEL + 4 30 | 31 | TSS3_S_SP0 equ 4 32 | 33 | INT_M_CTL equ 0x20 ; I/O port for interrupt controller 34 | INT_M_CTLMASK equ 0x21 ; setting bits in this port disables ints 35 | INT_S_CTL equ 0xA0 ; I/O port for second interrupt controller 36 | INT_S_CTLMASK equ 0xA1 ; setting bits in this port disables ints 37 | 38 | EOI equ 0x20 39 | 40 | ; 以下选择子值必须与 protect.h 中保持一致!!! 41 | SELECTOR_FLAT_C equ 0x08 ; LOADER 里面已经确定了的. 42 | SELECTOR_TSS equ 0x20 ; TSS. 从外层跳到内存时 SS 和 ESP 的值从里面获得. 43 | SELECTOR_KERNEL_CS equ SELECTOR_FLAT_C 44 | 45 | -------------------------------------------------------------------------------- /g/include/sys/sconst.inc: -------------------------------------------------------------------------------- 1 | 2 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | ; sconst.inc 4 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | ; Forrest Yu, 2005 6 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | 8 | P_STACKBASE equ 0 9 | GSREG equ P_STACKBASE 10 | FSREG equ GSREG + 4 11 | ESREG equ FSREG + 4 12 | DSREG equ ESREG + 4 13 | EDIREG equ DSREG + 4 14 | ESIREG equ EDIREG + 4 15 | EBPREG equ ESIREG + 4 16 | KERNELESPREG equ EBPREG + 4 17 | EBXREG equ KERNELESPREG + 4 18 | EDXREG equ EBXREG + 4 19 | ECXREG equ EDXREG + 4 20 | EAXREG equ ECXREG + 4 21 | RETADR equ EAXREG + 4 22 | EIPREG equ RETADR + 4 23 | CSREG equ EIPREG + 4 24 | EFLAGSREG equ CSREG + 4 25 | ESPREG equ EFLAGSREG + 4 26 | SSREG equ ESPREG + 4 27 | P_STACKTOP equ SSREG + 4 28 | P_LDT_SEL equ P_STACKTOP 29 | P_LDT equ P_LDT_SEL + 4 30 | 31 | TSS3_S_SP0 equ 4 32 | 33 | INT_M_CTL equ 0x20 ; I/O port for interrupt controller 34 | INT_M_CTLMASK equ 0x21 ; setting bits in this port disables ints 35 | INT_S_CTL equ 0xA0 ; I/O port for second interrupt controller 36 | INT_S_CTLMASK equ 0xA1 ; setting bits in this port disables ints 37 | 38 | EOI equ 0x20 39 | 40 | ; 以下选择子值必须与 protect.h 中保持一致!!! 41 | SELECTOR_FLAT_C equ 0x08 ; LOADER 里面已经确定了的. 42 | SELECTOR_TSS equ 0x20 ; TSS. 从外层跳到内存时 SS 和 ESP 的值从里面获得. 43 | SELECTOR_KERNEL_CS equ SELECTOR_FLAT_C 44 | 45 | -------------------------------------------------------------------------------- /h/include/sys/sconst.inc: -------------------------------------------------------------------------------- 1 | 2 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | ; sconst.inc 4 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | ; Forrest Yu, 2005 6 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | 8 | P_STACKBASE equ 0 9 | GSREG equ P_STACKBASE 10 | FSREG equ GSREG + 4 11 | ESREG equ FSREG + 4 12 | DSREG equ ESREG + 4 13 | EDIREG equ DSREG + 4 14 | ESIREG equ EDIREG + 4 15 | EBPREG equ ESIREG + 4 16 | KERNELESPREG equ EBPREG + 4 17 | EBXREG equ KERNELESPREG + 4 18 | EDXREG equ EBXREG + 4 19 | ECXREG equ EDXREG + 4 20 | EAXREG equ ECXREG + 4 21 | RETADR equ EAXREG + 4 22 | EIPREG equ RETADR + 4 23 | CSREG equ EIPREG + 4 24 | EFLAGSREG equ CSREG + 4 25 | ESPREG equ EFLAGSREG + 4 26 | SSREG equ ESPREG + 4 27 | P_STACKTOP equ SSREG + 4 28 | P_LDT_SEL equ P_STACKTOP 29 | P_LDT equ P_LDT_SEL + 4 30 | 31 | TSS3_S_SP0 equ 4 32 | 33 | INT_M_CTL equ 0x20 ; I/O port for interrupt controller 34 | INT_M_CTLMASK equ 0x21 ; setting bits in this port disables ints 35 | INT_S_CTL equ 0xA0 ; I/O port for second interrupt controller 36 | INT_S_CTLMASK equ 0xA1 ; setting bits in this port disables ints 37 | 38 | EOI equ 0x20 39 | 40 | ; 以下选择子值必须与 protect.h 中保持一致!!! 41 | SELECTOR_FLAT_C equ 0x08 ; LOADER 里面已经确定了的. 42 | SELECTOR_TSS equ 0x20 ; TSS. 从外层跳到内存时 SS 和 ESP 的值从里面获得. 43 | SELECTOR_KERNEL_CS equ SELECTOR_FLAT_C 44 | 45 | -------------------------------------------------------------------------------- /i/include/sys/sconst.inc: -------------------------------------------------------------------------------- 1 | 2 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | ; sconst.inc 4 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | ; Forrest Yu, 2005 6 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | 8 | P_STACKBASE equ 0 9 | GSREG equ P_STACKBASE 10 | FSREG equ GSREG + 4 11 | ESREG equ FSREG + 4 12 | DSREG equ ESREG + 4 13 | EDIREG equ DSREG + 4 14 | ESIREG equ EDIREG + 4 15 | EBPREG equ ESIREG + 4 16 | KERNELESPREG equ EBPREG + 4 17 | EBXREG equ KERNELESPREG + 4 18 | EDXREG equ EBXREG + 4 19 | ECXREG equ EDXREG + 4 20 | EAXREG equ ECXREG + 4 21 | RETADR equ EAXREG + 4 22 | EIPREG equ RETADR + 4 23 | CSREG equ EIPREG + 4 24 | EFLAGSREG equ CSREG + 4 25 | ESPREG equ EFLAGSREG + 4 26 | SSREG equ ESPREG + 4 27 | P_STACKTOP equ SSREG + 4 28 | P_LDT_SEL equ P_STACKTOP 29 | P_LDT equ P_LDT_SEL + 4 30 | 31 | TSS3_S_SP0 equ 4 32 | 33 | INT_M_CTL equ 0x20 ; I/O port for interrupt controller 34 | INT_M_CTLMASK equ 0x21 ; setting bits in this port disables ints 35 | INT_S_CTL equ 0xA0 ; I/O port for second interrupt controller 36 | INT_S_CTLMASK equ 0xA1 ; setting bits in this port disables ints 37 | 38 | EOI equ 0x20 39 | 40 | ; 以下选择子值必须与 protect.h 中保持一致!!! 41 | SELECTOR_FLAT_C equ 0x08 ; LOADER 里面已经确定了的. 42 | SELECTOR_TSS equ 0x20 ; TSS. 从外层跳到内存时 SS 和 ESP 的值从里面获得. 43 | SELECTOR_KERNEL_CS equ SELECTOR_FLAT_C 44 | 45 | -------------------------------------------------------------------------------- /j/include/sys/sconst.inc: -------------------------------------------------------------------------------- 1 | 2 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | ; sconst.inc 4 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | ; Forrest Yu, 2005 6 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | 8 | P_STACKBASE equ 0 9 | GSREG equ P_STACKBASE 10 | FSREG equ GSREG + 4 11 | ESREG equ FSREG + 4 12 | DSREG equ ESREG + 4 13 | EDIREG equ DSREG + 4 14 | ESIREG equ EDIREG + 4 15 | EBPREG equ ESIREG + 4 16 | KERNELESPREG equ EBPREG + 4 17 | EBXREG equ KERNELESPREG + 4 18 | EDXREG equ EBXREG + 4 19 | ECXREG equ EDXREG + 4 20 | EAXREG equ ECXREG + 4 21 | RETADR equ EAXREG + 4 22 | EIPREG equ RETADR + 4 23 | CSREG equ EIPREG + 4 24 | EFLAGSREG equ CSREG + 4 25 | ESPREG equ EFLAGSREG + 4 26 | SSREG equ ESPREG + 4 27 | P_STACKTOP equ SSREG + 4 28 | P_LDT_SEL equ P_STACKTOP 29 | P_LDT equ P_LDT_SEL + 4 30 | 31 | TSS3_S_SP0 equ 4 32 | 33 | INT_M_CTL equ 0x20 ; I/O port for interrupt controller 34 | INT_M_CTLMASK equ 0x21 ; setting bits in this port disables ints 35 | INT_S_CTL equ 0xA0 ; I/O port for second interrupt controller 36 | INT_S_CTLMASK equ 0xA1 ; setting bits in this port disables ints 37 | 38 | EOI equ 0x20 39 | 40 | ; 以下选择子值必须与 protect.h 中保持一致!!! 41 | SELECTOR_FLAT_C equ 0x08 ; LOADER 里面已经确定了的. 42 | SELECTOR_TSS equ 0x20 ; TSS. 从外层跳到内存时 SS 和 ESP 的值从里面获得. 43 | SELECTOR_KERNEL_CS equ SELECTOR_FLAT_C 44 | 45 | -------------------------------------------------------------------------------- /g/include/stdio.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file stdio.h 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | /* the assert macro */ 11 | #define ASSERT 12 | #ifdef ASSERT 13 | void assertion_failure(char *exp, char *file, char *base_file, int line); 14 | #define assert(exp) if (exp) ; \ 15 | else assertion_failure(#exp, __FILE__, __BASE_FILE__, __LINE__) 16 | #else 17 | #define assert(exp) 18 | #endif 19 | 20 | /* EXTERN */ 21 | #define EXTERN extern /* EXTERN is defined as extern except in global.c */ 22 | 23 | /* string */ 24 | #define STR_DEFAULT_LEN 1024 25 | 26 | #define O_CREAT 1 27 | #define O_RDWR 2 28 | 29 | #define SEEK_SET 1 30 | #define SEEK_CUR 2 31 | #define SEEK_END 3 32 | 33 | #define MAX_PATH 128 34 | 35 | /*--------*/ 36 | /* 库函数 */ 37 | /*--------*/ 38 | 39 | #ifdef ENABLE_DISK_LOG 40 | #define SYSLOG syslog 41 | #endif 42 | 43 | /* lib/open.c */ 44 | PUBLIC int open (const char *pathname, int flags); 45 | 46 | /* lib/close.c */ 47 | PUBLIC int close (int fd); 48 | 49 | /* lib/read.c */ 50 | PUBLIC int read (int fd, void *buf, int count); 51 | 52 | /* lib/write.c */ 53 | PUBLIC int write (int fd, const void *buf, int count); 54 | 55 | /* lib/getpid.c */ 56 | PUBLIC int getpid (); 57 | 58 | /* lib/syslog.c */ 59 | PUBLIC int syslog (const char *fmt, ...); 60 | 61 | -------------------------------------------------------------------------------- /j/lib/syscall.asm: -------------------------------------------------------------------------------- 1 | 2 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | ; syscall.asm 4 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | ; Forrest Yu, 2005 6 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | 8 | %include "sconst.inc" 9 | 10 | INT_VECTOR_SYS_CALL equ 0x90 11 | _NR_printx equ 0 12 | _NR_sendrec equ 1 13 | 14 | ; 导出符号 15 | global printx 16 | global sendrec 17 | 18 | bits 32 19 | [section .text] 20 | 21 | ; ==================================================================================== 22 | ; sendrec(int function, int src_dest, MESSAGE* msg); 23 | ; ==================================================================================== 24 | ; Never call sendrec() directly, call send_recv() instead. 25 | sendrec: 26 | push ebx ; . 27 | push ecx ; > 12 bytes 28 | push edx ; / 29 | 30 | mov eax, _NR_sendrec 31 | mov ebx, [esp + 12 + 4] ; function 32 | mov ecx, [esp + 12 + 8] ; src_dest 33 | mov edx, [esp + 12 + 12] ; p_msg 34 | int INT_VECTOR_SYS_CALL 35 | 36 | pop edx 37 | pop ecx 38 | pop ebx 39 | 40 | ret 41 | 42 | ; ==================================================================================== 43 | ; void printx(char* s); 44 | ; ==================================================================================== 45 | printx: 46 | push edx ; 4 bytes 47 | 48 | mov eax, _NR_printx 49 | mov edx, [esp + 4 + 4] ; s 50 | int INT_VECTOR_SYS_CALL 51 | 52 | pop edx 53 | 54 | ret 55 | 56 | -------------------------------------------------------------------------------- /h/include/stdio.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file stdio.h 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | /* the assert macro */ 11 | #define ASSERT 12 | #ifdef ASSERT 13 | void assertion_failure(char *exp, char *file, char *base_file, int line); 14 | #define assert(exp) if (exp) ; \ 15 | else assertion_failure(#exp, __FILE__, __BASE_FILE__, __LINE__) 16 | #else 17 | #define assert(exp) 18 | #endif 19 | 20 | /* EXTERN */ 21 | #define EXTERN extern /* EXTERN is defined as extern except in global.c */ 22 | 23 | /* string */ 24 | #define STR_DEFAULT_LEN 1024 25 | 26 | #define O_CREAT 1 27 | #define O_RDWR 2 28 | 29 | #define SEEK_SET 1 30 | #define SEEK_CUR 2 31 | #define SEEK_END 3 32 | 33 | #define MAX_PATH 128 34 | 35 | /*--------*/ 36 | /* 库函数 */ 37 | /*--------*/ 38 | 39 | #ifdef ENABLE_DISK_LOG 40 | #define SYSLOG syslog 41 | #endif 42 | 43 | /* lib/open.c */ 44 | PUBLIC int open (const char *pathname, int flags); 45 | 46 | /* lib/close.c */ 47 | PUBLIC int close (int fd); 48 | 49 | /* lib/read.c */ 50 | PUBLIC int read (int fd, void *buf, int count); 51 | 52 | /* lib/write.c */ 53 | PUBLIC int write (int fd, const void *buf, int count); 54 | 55 | /* lib/unlink.c */ 56 | PUBLIC int unlink (const char *pathname); 57 | 58 | /* lib/getpid.c */ 59 | PUBLIC int getpid (); 60 | 61 | /* lib/syslog.c */ 62 | PUBLIC int syslog (const char *fmt, ...); 63 | 64 | -------------------------------------------------------------------------------- /i/include/stdio.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file stdio.h 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | /* the assert macro */ 11 | #define ASSERT 12 | #ifdef ASSERT 13 | void assertion_failure(char *exp, char *file, char *base_file, int line); 14 | #define assert(exp) if (exp) ; \ 15 | else assertion_failure(#exp, __FILE__, __BASE_FILE__, __LINE__) 16 | #else 17 | #define assert(exp) 18 | #endif 19 | 20 | /* EXTERN */ 21 | #define EXTERN extern /* EXTERN is defined as extern except in global.c */ 22 | 23 | /* string */ 24 | #define STR_DEFAULT_LEN 1024 25 | 26 | #define O_CREAT 1 27 | #define O_RDWR 2 28 | 29 | #define SEEK_SET 1 30 | #define SEEK_CUR 2 31 | #define SEEK_END 3 32 | 33 | #define MAX_PATH 128 34 | 35 | /*--------*/ 36 | /* 库函数 */ 37 | /*--------*/ 38 | 39 | #ifdef ENABLE_DISK_LOG 40 | #define SYSLOG syslog 41 | #endif 42 | 43 | /* lib/open.c */ 44 | PUBLIC int open (const char *pathname, int flags); 45 | 46 | /* lib/close.c */ 47 | PUBLIC int close (int fd); 48 | 49 | /* lib/read.c */ 50 | PUBLIC int read (int fd, void *buf, int count); 51 | 52 | /* lib/write.c */ 53 | PUBLIC int write (int fd, const void *buf, int count); 54 | 55 | /* lib/unlink.c */ 56 | PUBLIC int unlink (const char *pathname); 57 | 58 | /* lib/getpid.c */ 59 | PUBLIC int getpid (); 60 | 61 | /* lib/syslog.c */ 62 | PUBLIC int syslog (const char *fmt, ...); 63 | 64 | -------------------------------------------------------------------------------- /j/include/stdio.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************//** 2 | ***************************************************************************** 3 | * @file stdio.h 4 | * @brief 5 | * @author Forrest Y. Yu 6 | * @date 2008 7 | ***************************************************************************** 8 | *****************************************************************************/ 9 | 10 | /* the assert macro */ 11 | #define ASSERT 12 | #ifdef ASSERT 13 | void assertion_failure(char *exp, char *file, char *base_file, int line); 14 | #define assert(exp) if (exp) ; \ 15 | else assertion_failure(#exp, __FILE__, __BASE_FILE__, __LINE__) 16 | #else 17 | #define assert(exp) 18 | #endif 19 | 20 | /* EXTERN */ 21 | #define EXTERN extern /* EXTERN is defined as extern except in global.c */ 22 | 23 | /* string */ 24 | #define STR_DEFAULT_LEN 1024 25 | 26 | #define O_CREAT 1 27 | #define O_RDWR 2 28 | 29 | #define SEEK_SET 1 30 | #define SEEK_CUR 2 31 | #define SEEK_END 3 32 | 33 | #define MAX_PATH 128 34 | 35 | /*--------*/ 36 | /* 库函数 */ 37 | /*--------*/ 38 | 39 | #ifdef ENABLE_DISK_LOG 40 | #define SYSLOG syslog 41 | #endif 42 | 43 | /* lib/open.c */ 44 | PUBLIC int open (const char *pathname, int flags); 45 | 46 | /* lib/close.c */ 47 | PUBLIC int close (int fd); 48 | 49 | /* lib/read.c */ 50 | PUBLIC int read (int fd, void *buf, int count); 51 | 52 | /* lib/write.c */ 53 | PUBLIC int write (int fd, const void *buf, int count); 54 | 55 | /* lib/unlink.c */ 56 | PUBLIC int unlink (const char *pathname); 57 | 58 | /* lib/getpid.c */ 59 | PUBLIC int getpid (); 60 | 61 | /* lib/syslog.c */ 62 | PUBLIC int syslog (const char *fmt, ...); 63 | 64 | -------------------------------------------------------------------------------- /i/include/sys/global.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | global.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | /* EXTERN is defined as extern except in global.c */ 9 | #ifdef GLOBAL_VARIABLES_HERE 10 | #undef EXTERN 11 | #define EXTERN 12 | #endif 13 | 14 | EXTERN int ticks; 15 | 16 | EXTERN int disp_pos; 17 | 18 | EXTERN u8 gdt_ptr[6]; /* 0~15:Limit 16~47:Base */ 19 | EXTERN struct descriptor gdt[GDT_SIZE]; 20 | EXTERN u8 idt_ptr[6]; /* 0~15:Limit 16~47:Base */ 21 | EXTERN struct gate idt[IDT_SIZE]; 22 | 23 | EXTERN u32 k_reenter; 24 | EXTERN int current_console; 25 | 26 | EXTERN int key_pressed; /** 27 | * used for clock_handler 28 | * to wake up TASK_TTY when 29 | * a key is pressed 30 | */ 31 | 32 | EXTERN struct tss tss; 33 | EXTERN struct proc* p_proc_ready; 34 | 35 | extern char task_stack[]; 36 | extern struct proc proc_table[]; 37 | extern struct task task_table[]; 38 | extern struct task user_proc_table[]; 39 | extern irq_handler irq_table[]; 40 | extern TTY tty_table[]; 41 | extern CONSOLE console_table[]; 42 | 43 | /* FS */ 44 | EXTERN struct file_desc f_desc_table[NR_FILE_DESC]; 45 | EXTERN struct inode inode_table[NR_INODE]; 46 | EXTERN struct super_block super_block[NR_SUPER_BLOCK]; 47 | extern u8 * fsbuf; 48 | extern const int FSBUF_SIZE; 49 | EXTERN MESSAGE fs_msg; 50 | EXTERN struct proc * pcaller; 51 | EXTERN struct inode * root_inode; 52 | extern struct dev_drv_map dd_map[]; 53 | 54 | -------------------------------------------------------------------------------- /j/include/sys/global.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | global.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | /* EXTERN is defined as extern except in global.c */ 9 | #ifdef GLOBAL_VARIABLES_HERE 10 | #undef EXTERN 11 | #define EXTERN 12 | #endif 13 | 14 | EXTERN int ticks; 15 | 16 | EXTERN int disp_pos; 17 | 18 | EXTERN u8 gdt_ptr[6]; /* 0~15:Limit 16~47:Base */ 19 | EXTERN struct descriptor gdt[GDT_SIZE]; 20 | EXTERN u8 idt_ptr[6]; /* 0~15:Limit 16~47:Base */ 21 | EXTERN struct gate idt[IDT_SIZE]; 22 | 23 | EXTERN u32 k_reenter; 24 | EXTERN int current_console; 25 | 26 | EXTERN int key_pressed; /** 27 | * used for clock_handler 28 | * to wake up TASK_TTY when 29 | * a key is pressed 30 | */ 31 | 32 | EXTERN struct tss tss; 33 | EXTERN struct proc* p_proc_ready; 34 | 35 | extern char task_stack[]; 36 | extern struct proc proc_table[]; 37 | extern struct task task_table[]; 38 | extern struct task user_proc_table[]; 39 | extern irq_handler irq_table[]; 40 | extern TTY tty_table[]; 41 | extern CONSOLE console_table[]; 42 | 43 | /* FS */ 44 | EXTERN struct file_desc f_desc_table[NR_FILE_DESC]; 45 | EXTERN struct inode inode_table[NR_INODE]; 46 | EXTERN struct super_block super_block[NR_SUPER_BLOCK]; 47 | extern u8 * fsbuf; 48 | extern const int FSBUF_SIZE; 49 | EXTERN MESSAGE fs_msg; 50 | EXTERN struct proc * pcaller; 51 | EXTERN struct inode * root_inode; 52 | extern struct dev_drv_map dd_map[]; 53 | 54 | -------------------------------------------------------------------------------- /a/kernel/start.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | start.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #include "type.h" 9 | #include "const.h" 10 | #include "protect.h" 11 | #include "string.h" 12 | #include "fs.h" 13 | #include "proc.h" 14 | #include "tty.h" 15 | #include "console.h" 16 | #include "global.h" 17 | #include "proto.h" 18 | 19 | 20 | /*======================================================================* 21 | cstart 22 | *======================================================================*/ 23 | PUBLIC void cstart() 24 | { 25 | disp_str("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n-----\"cstart\" begins-----\n"); 26 | 27 | /* 将 LOADER 中的 GDT 复制到新的 GDT 中 */ 28 | memcpy( &gdt, /* New GDT */ 29 | (void*)(*((u32*)(&gdt_ptr[2]))), /* Base of Old GDT */ 30 | *((u16*)(&gdt_ptr[0])) + 1 /* Limit of Old GDT */ 31 | ); 32 | /* gdt_ptr[6] 共 6 个字节:0~15:Limit 16~47:Base。用作 sgdt 以及 lgdt 的参数。 */ 33 | u16* p_gdt_limit = (u16*)(&gdt_ptr[0]); 34 | u32* p_gdt_base = (u32*)(&gdt_ptr[2]); 35 | *p_gdt_limit = GDT_SIZE * sizeof(struct descriptor) - 1; 36 | *p_gdt_base = (u32)&gdt; 37 | 38 | /* idt_ptr[6] 共 6 个字节:0~15:Limit 16~47:Base。用作 sidt 以及 lidt 的参数。 */ 39 | u16* p_idt_limit = (u16*)(&idt_ptr[0]); 40 | u32* p_idt_base = (u32*)(&idt_ptr[2]); 41 | *p_idt_limit = IDT_SIZE * sizeof(struct gate) - 1; 42 | *p_idt_base = (u32)&idt; 43 | 44 | init_prot(); 45 | 46 | disp_str("-----\"cstart\" finished-----\n"); 47 | } 48 | -------------------------------------------------------------------------------- /b/kernel/start.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | start.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #include "type.h" 9 | #include "const.h" 10 | #include "protect.h" 11 | #include "string.h" 12 | #include "fs.h" 13 | #include "proc.h" 14 | #include "tty.h" 15 | #include "console.h" 16 | #include "global.h" 17 | #include "proto.h" 18 | 19 | 20 | /*======================================================================* 21 | cstart 22 | *======================================================================*/ 23 | PUBLIC void cstart() 24 | { 25 | disp_str("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n-----\"cstart\" begins-----\n"); 26 | 27 | /* 将 LOADER 中的 GDT 复制到新的 GDT 中 */ 28 | memcpy( &gdt, /* New GDT */ 29 | (void*)(*((u32*)(&gdt_ptr[2]))), /* Base of Old GDT */ 30 | *((u16*)(&gdt_ptr[0])) + 1 /* Limit of Old GDT */ 31 | ); 32 | /* gdt_ptr[6] 共 6 个字节:0~15:Limit 16~47:Base。用作 sgdt 以及 lgdt 的参数。 */ 33 | u16* p_gdt_limit = (u16*)(&gdt_ptr[0]); 34 | u32* p_gdt_base = (u32*)(&gdt_ptr[2]); 35 | *p_gdt_limit = GDT_SIZE * sizeof(struct descriptor) - 1; 36 | *p_gdt_base = (u32)&gdt; 37 | 38 | /* idt_ptr[6] 共 6 个字节:0~15:Limit 16~47:Base。用作 sidt 以及 lidt 的参数。 */ 39 | u16* p_idt_limit = (u16*)(&idt_ptr[0]); 40 | u32* p_idt_base = (u32*)(&idt_ptr[2]); 41 | *p_idt_limit = IDT_SIZE * sizeof(struct gate) - 1; 42 | *p_idt_base = (u32)&idt; 43 | 44 | init_prot(); 45 | 46 | disp_str("-----\"cstart\" finished-----\n"); 47 | } 48 | -------------------------------------------------------------------------------- /c/kernel/start.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | start.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #include "type.h" 9 | #include "const.h" 10 | #include "protect.h" 11 | #include "string.h" 12 | #include "fs.h" 13 | #include "proc.h" 14 | #include "tty.h" 15 | #include "console.h" 16 | #include "global.h" 17 | #include "proto.h" 18 | 19 | 20 | /*======================================================================* 21 | cstart 22 | *======================================================================*/ 23 | PUBLIC void cstart() 24 | { 25 | disp_str("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n-----\"cstart\" begins-----\n"); 26 | 27 | /* 将 LOADER 中的 GDT 复制到新的 GDT 中 */ 28 | memcpy( &gdt, /* New GDT */ 29 | (void*)(*((u32*)(&gdt_ptr[2]))), /* Base of Old GDT */ 30 | *((u16*)(&gdt_ptr[0])) + 1 /* Limit of Old GDT */ 31 | ); 32 | /* gdt_ptr[6] 共 6 个字节:0~15:Limit 16~47:Base。用作 sgdt 以及 lgdt 的参数。 */ 33 | u16* p_gdt_limit = (u16*)(&gdt_ptr[0]); 34 | u32* p_gdt_base = (u32*)(&gdt_ptr[2]); 35 | *p_gdt_limit = GDT_SIZE * sizeof(struct descriptor) - 1; 36 | *p_gdt_base = (u32)&gdt; 37 | 38 | /* idt_ptr[6] 共 6 个字节:0~15:Limit 16~47:Base。用作 sidt 以及 lidt 的参数。 */ 39 | u16* p_idt_limit = (u16*)(&idt_ptr[0]); 40 | u32* p_idt_base = (u32*)(&idt_ptr[2]); 41 | *p_idt_limit = IDT_SIZE * sizeof(struct gate) - 1; 42 | *p_idt_base = (u32)&idt; 43 | 44 | init_prot(); 45 | 46 | disp_str("-----\"cstart\" finished-----\n"); 47 | } 48 | -------------------------------------------------------------------------------- /d/kernel/start.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | start.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #include "type.h" 9 | #include "const.h" 10 | #include "protect.h" 11 | #include "string.h" 12 | #include "fs.h" 13 | #include "proc.h" 14 | #include "tty.h" 15 | #include "console.h" 16 | #include "global.h" 17 | #include "proto.h" 18 | 19 | 20 | /*======================================================================* 21 | cstart 22 | *======================================================================*/ 23 | PUBLIC void cstart() 24 | { 25 | disp_str("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n-----\"cstart\" begins-----\n"); 26 | 27 | /* 将 LOADER 中的 GDT 复制到新的 GDT 中 */ 28 | memcpy( &gdt, /* New GDT */ 29 | (void*)(*((u32*)(&gdt_ptr[2]))), /* Base of Old GDT */ 30 | *((u16*)(&gdt_ptr[0])) + 1 /* Limit of Old GDT */ 31 | ); 32 | /* gdt_ptr[6] 共 6 个字节:0~15:Limit 16~47:Base。用作 sgdt 以及 lgdt 的参数。 */ 33 | u16* p_gdt_limit = (u16*)(&gdt_ptr[0]); 34 | u32* p_gdt_base = (u32*)(&gdt_ptr[2]); 35 | *p_gdt_limit = GDT_SIZE * sizeof(struct descriptor) - 1; 36 | *p_gdt_base = (u32)&gdt; 37 | 38 | /* idt_ptr[6] 共 6 个字节:0~15:Limit 16~47:Base。用作 sidt 以及 lidt 的参数。 */ 39 | u16* p_idt_limit = (u16*)(&idt_ptr[0]); 40 | u32* p_idt_base = (u32*)(&idt_ptr[2]); 41 | *p_idt_limit = IDT_SIZE * sizeof(struct gate) - 1; 42 | *p_idt_base = (u32)&idt; 43 | 44 | init_prot(); 45 | 46 | disp_str("-----\"cstart\" finished-----\n"); 47 | } 48 | -------------------------------------------------------------------------------- /e/kernel/start.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | start.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #include "type.h" 9 | #include "stdio.h" 10 | #include "const.h" 11 | #include "protect.h" 12 | #include "string.h" 13 | #include "fs.h" 14 | #include "proc.h" 15 | #include "tty.h" 16 | #include "console.h" 17 | #include "global.h" 18 | #include "proto.h" 19 | 20 | 21 | /*======================================================================* 22 | cstart 23 | *======================================================================*/ 24 | PUBLIC void cstart() 25 | { 26 | disp_str("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n-----\"cstart\" begins-----\n"); 27 | 28 | /* 将 LOADER 中的 GDT 复制到新的 GDT 中 */ 29 | memcpy( &gdt, /* New GDT */ 30 | (void*)(*((u32*)(&gdt_ptr[2]))), /* Base of Old GDT */ 31 | *((u16*)(&gdt_ptr[0])) + 1 /* Limit of Old GDT */ 32 | ); 33 | /* gdt_ptr[6] 共 6 个字节:0~15:Limit 16~47:Base。用作 sgdt 以及 lgdt 的参数。 */ 34 | u16* p_gdt_limit = (u16*)(&gdt_ptr[0]); 35 | u32* p_gdt_base = (u32*)(&gdt_ptr[2]); 36 | *p_gdt_limit = GDT_SIZE * sizeof(struct descriptor) - 1; 37 | *p_gdt_base = (u32)&gdt; 38 | 39 | /* idt_ptr[6] 共 6 个字节:0~15:Limit 16~47:Base。用作 sidt 以及 lidt 的参数。 */ 40 | u16* p_idt_limit = (u16*)(&idt_ptr[0]); 41 | u32* p_idt_base = (u32*)(&idt_ptr[2]); 42 | *p_idt_limit = IDT_SIZE * sizeof(struct gate) - 1; 43 | *p_idt_base = (u32)&idt; 44 | 45 | init_prot(); 46 | 47 | disp_str("-----\"cstart\" finished-----\n"); 48 | } 49 | -------------------------------------------------------------------------------- /f/kernel/start.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | start.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #include "type.h" 9 | #include "stdio.h" 10 | #include "const.h" 11 | #include "protect.h" 12 | #include "string.h" 13 | #include "fs.h" 14 | #include "proc.h" 15 | #include "tty.h" 16 | #include "console.h" 17 | #include "global.h" 18 | #include "proto.h" 19 | 20 | 21 | /*======================================================================* 22 | cstart 23 | *======================================================================*/ 24 | PUBLIC void cstart() 25 | { 26 | disp_str("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n-----\"cstart\" begins-----\n"); 27 | 28 | /* 将 LOADER 中的 GDT 复制到新的 GDT 中 */ 29 | memcpy( &gdt, /* New GDT */ 30 | (void*)(*((u32*)(&gdt_ptr[2]))), /* Base of Old GDT */ 31 | *((u16*)(&gdt_ptr[0])) + 1 /* Limit of Old GDT */ 32 | ); 33 | /* gdt_ptr[6] 共 6 个字节:0~15:Limit 16~47:Base。用作 sgdt 以及 lgdt 的参数。 */ 34 | u16* p_gdt_limit = (u16*)(&gdt_ptr[0]); 35 | u32* p_gdt_base = (u32*)(&gdt_ptr[2]); 36 | *p_gdt_limit = GDT_SIZE * sizeof(struct descriptor) - 1; 37 | *p_gdt_base = (u32)&gdt; 38 | 39 | /* idt_ptr[6] 共 6 个字节:0~15:Limit 16~47:Base。用作 sidt 以及 lidt 的参数。 */ 40 | u16* p_idt_limit = (u16*)(&idt_ptr[0]); 41 | u32* p_idt_base = (u32*)(&idt_ptr[2]); 42 | *p_idt_limit = IDT_SIZE * sizeof(struct gate) - 1; 43 | *p_idt_base = (u32)&idt; 44 | 45 | init_prot(); 46 | 47 | disp_str("-----\"cstart\" finished-----\n"); 48 | } 49 | -------------------------------------------------------------------------------- /g/kernel/start.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | start.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #include "type.h" 9 | #include "stdio.h" 10 | #include "const.h" 11 | #include "protect.h" 12 | #include "string.h" 13 | #include "fs.h" 14 | #include "proc.h" 15 | #include "tty.h" 16 | #include "console.h" 17 | #include "global.h" 18 | #include "proto.h" 19 | 20 | 21 | /*======================================================================* 22 | cstart 23 | *======================================================================*/ 24 | PUBLIC void cstart() 25 | { 26 | disp_str("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n-----\"cstart\" begins-----\n"); 27 | 28 | /* 将 LOADER 中的 GDT 复制到新的 GDT 中 */ 29 | memcpy( &gdt, /* New GDT */ 30 | (void*)(*((u32*)(&gdt_ptr[2]))), /* Base of Old GDT */ 31 | *((u16*)(&gdt_ptr[0])) + 1 /* Limit of Old GDT */ 32 | ); 33 | /* gdt_ptr[6] 共 6 个字节:0~15:Limit 16~47:Base。用作 sgdt 以及 lgdt 的参数。 */ 34 | u16* p_gdt_limit = (u16*)(&gdt_ptr[0]); 35 | u32* p_gdt_base = (u32*)(&gdt_ptr[2]); 36 | *p_gdt_limit = GDT_SIZE * sizeof(struct descriptor) - 1; 37 | *p_gdt_base = (u32)&gdt; 38 | 39 | /* idt_ptr[6] 共 6 个字节:0~15:Limit 16~47:Base。用作 sidt 以及 lidt 的参数。 */ 40 | u16* p_idt_limit = (u16*)(&idt_ptr[0]); 41 | u32* p_idt_base = (u32*)(&idt_ptr[2]); 42 | *p_idt_limit = IDT_SIZE * sizeof(struct gate) - 1; 43 | *p_idt_base = (u32)&idt; 44 | 45 | init_prot(); 46 | 47 | disp_str("-----\"cstart\" finished-----\n"); 48 | } 49 | -------------------------------------------------------------------------------- /h/kernel/start.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | start.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #include "type.h" 9 | #include "stdio.h" 10 | #include "const.h" 11 | #include "protect.h" 12 | #include "string.h" 13 | #include "fs.h" 14 | #include "proc.h" 15 | #include "tty.h" 16 | #include "console.h" 17 | #include "global.h" 18 | #include "proto.h" 19 | 20 | 21 | /*======================================================================* 22 | cstart 23 | *======================================================================*/ 24 | PUBLIC void cstart() 25 | { 26 | disp_str("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n-----\"cstart\" begins-----\n"); 27 | 28 | /* 将 LOADER 中的 GDT 复制到新的 GDT 中 */ 29 | memcpy( &gdt, /* New GDT */ 30 | (void*)(*((u32*)(&gdt_ptr[2]))), /* Base of Old GDT */ 31 | *((u16*)(&gdt_ptr[0])) + 1 /* Limit of Old GDT */ 32 | ); 33 | /* gdt_ptr[6] 共 6 个字节:0~15:Limit 16~47:Base。用作 sgdt 以及 lgdt 的参数。 */ 34 | u16* p_gdt_limit = (u16*)(&gdt_ptr[0]); 35 | u32* p_gdt_base = (u32*)(&gdt_ptr[2]); 36 | *p_gdt_limit = GDT_SIZE * sizeof(struct descriptor) - 1; 37 | *p_gdt_base = (u32)&gdt; 38 | 39 | /* idt_ptr[6] 共 6 个字节:0~15:Limit 16~47:Base。用作 sidt 以及 lidt 的参数。 */ 40 | u16* p_idt_limit = (u16*)(&idt_ptr[0]); 41 | u32* p_idt_base = (u32*)(&idt_ptr[2]); 42 | *p_idt_limit = IDT_SIZE * sizeof(struct gate) - 1; 43 | *p_idt_base = (u32)&idt; 44 | 45 | init_prot(); 46 | 47 | disp_str("-----\"cstart\" finished-----\n"); 48 | } 49 | -------------------------------------------------------------------------------- /i/kernel/start.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | start.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #include "type.h" 9 | #include "stdio.h" 10 | #include "const.h" 11 | #include "protect.h" 12 | #include "string.h" 13 | #include "fs.h" 14 | #include "proc.h" 15 | #include "tty.h" 16 | #include "console.h" 17 | #include "global.h" 18 | #include "proto.h" 19 | 20 | 21 | /*======================================================================* 22 | cstart 23 | *======================================================================*/ 24 | PUBLIC void cstart() 25 | { 26 | disp_str("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n-----\"cstart\" begins-----\n"); 27 | 28 | /* 将 LOADER 中的 GDT 复制到新的 GDT 中 */ 29 | memcpy( &gdt, /* New GDT */ 30 | (void*)(*((u32*)(&gdt_ptr[2]))), /* Base of Old GDT */ 31 | *((u16*)(&gdt_ptr[0])) + 1 /* Limit of Old GDT */ 32 | ); 33 | /* gdt_ptr[6] 共 6 个字节:0~15:Limit 16~47:Base。用作 sgdt 以及 lgdt 的参数。 */ 34 | u16* p_gdt_limit = (u16*)(&gdt_ptr[0]); 35 | u32* p_gdt_base = (u32*)(&gdt_ptr[2]); 36 | *p_gdt_limit = GDT_SIZE * sizeof(struct descriptor) - 1; 37 | *p_gdt_base = (u32)&gdt; 38 | 39 | /* idt_ptr[6] 共 6 个字节:0~15:Limit 16~47:Base。用作 sidt 以及 lidt 的参数。 */ 40 | u16* p_idt_limit = (u16*)(&idt_ptr[0]); 41 | u32* p_idt_base = (u32*)(&idt_ptr[2]); 42 | *p_idt_limit = IDT_SIZE * sizeof(struct gate) - 1; 43 | *p_idt_base = (u32)&idt; 44 | 45 | init_prot(); 46 | 47 | disp_str("-----\"cstart\" finished-----\n"); 48 | } 49 | -------------------------------------------------------------------------------- /j/kernel/start.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | start.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #include "type.h" 9 | #include "stdio.h" 10 | #include "const.h" 11 | #include "protect.h" 12 | #include "string.h" 13 | #include "fs.h" 14 | #include "proc.h" 15 | #include "tty.h" 16 | #include "console.h" 17 | #include "global.h" 18 | #include "proto.h" 19 | 20 | 21 | /*======================================================================* 22 | cstart 23 | *======================================================================*/ 24 | PUBLIC void cstart() 25 | { 26 | disp_str("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n-----\"cstart\" begins-----\n"); 27 | 28 | /* 将 LOADER 中的 GDT 复制到新的 GDT 中 */ 29 | memcpy( &gdt, /* New GDT */ 30 | (void*)(*((u32*)(&gdt_ptr[2]))), /* Base of Old GDT */ 31 | *((u16*)(&gdt_ptr[0])) + 1 /* Limit of Old GDT */ 32 | ); 33 | /* gdt_ptr[6] 共 6 个字节:0~15:Limit 16~47:Base。用作 sgdt 以及 lgdt 的参数。 */ 34 | u16* p_gdt_limit = (u16*)(&gdt_ptr[0]); 35 | u32* p_gdt_base = (u32*)(&gdt_ptr[2]); 36 | *p_gdt_limit = GDT_SIZE * sizeof(struct descriptor) - 1; 37 | *p_gdt_base = (u32)&gdt; 38 | 39 | /* idt_ptr[6] 共 6 个字节:0~15:Limit 16~47:Base。用作 sidt 以及 lidt 的参数。 */ 40 | u16* p_idt_limit = (u16*)(&idt_ptr[0]); 41 | u32* p_idt_base = (u32*)(&idt_ptr[2]); 42 | *p_idt_limit = IDT_SIZE * sizeof(struct gate) - 1; 43 | *p_idt_base = (u32)&idt; 44 | 45 | init_prot(); 46 | 47 | disp_str("-----\"cstart\" finished-----\n"); 48 | } 49 | --------------------------------------------------------------------------------