├── README.md ├── chapter1 ├── a │ ├── bochsrc │ └── boot.asm └── b │ ├── bochsrc │ └── boot.asm ├── chapter10 ├── a │ ├── 80m.img.gz │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── fs │ │ ├── disklog.c │ │ ├── link.c │ │ ├── main.c │ │ ├── misc.c │ │ ├── open.c │ │ └── read_write.c │ ├── include │ │ ├── stdio.h │ │ ├── string.h │ │ ├── sys │ │ │ ├── config.h │ │ │ ├── console.h │ │ │ ├── const.h │ │ │ ├── fs.h │ │ │ ├── global.h │ │ │ ├── hd.h │ │ │ ├── keyboard.h │ │ │ ├── keymap.h │ │ │ ├── proc.h │ │ │ ├── protect.h │ │ │ ├── proto.h │ │ │ ├── sconst.inc │ │ │ └── tty.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── console.c │ │ ├── global.c │ │ ├── hd.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── keyboard.c │ │ ├── main.c │ │ ├── proc.c │ │ ├── protect.c │ │ ├── start.c │ │ ├── systask.c │ │ └── tty.c │ ├── lib │ │ ├── close.c │ │ ├── exit.c │ │ ├── fork.c │ │ ├── getpid.c │ │ ├── klib.c │ │ ├── kliba.asm │ │ ├── misc.c │ │ ├── open.c │ │ ├── printf.c │ │ ├── read.c │ │ ├── string.asm │ │ ├── syscall.asm │ │ ├── syslog.c │ │ ├── unlink.c │ │ ├── vsprintf.c │ │ ├── wait.c │ │ └── write.c │ ├── mm │ │ ├── forkexit.c │ │ └── main.c │ └── scripts │ │ ├── genlog │ │ └── splitgraphs ├── b │ ├── 80m.img.gz │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── fs │ │ ├── disklog.c │ │ ├── link.c │ │ ├── main.c │ │ ├── misc.c │ │ ├── open.c │ │ └── read_write.c │ ├── include │ │ ├── stdio.h │ │ ├── string.h │ │ ├── sys │ │ │ ├── config.h │ │ │ ├── console.h │ │ │ ├── const.h │ │ │ ├── fs.h │ │ │ ├── global.h │ │ │ ├── hd.h │ │ │ ├── keyboard.h │ │ │ ├── keymap.h │ │ │ ├── proc.h │ │ │ ├── protect.h │ │ │ ├── proto.h │ │ │ ├── sconst.inc │ │ │ └── tty.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── console.c │ │ ├── global.c │ │ ├── hd.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── keyboard.c │ │ ├── main.c │ │ ├── proc.c │ │ ├── protect.c │ │ ├── start.c │ │ ├── systask.c │ │ └── tty.c │ ├── lib │ │ ├── close.c │ │ ├── exit.c │ │ ├── fork.c │ │ ├── getpid.c │ │ ├── klib.c │ │ ├── kliba.asm │ │ ├── misc.c │ │ ├── open.c │ │ ├── printf.c │ │ ├── read.c │ │ ├── string.asm │ │ ├── syscall.asm │ │ ├── syslog.c │ │ ├── unlink.c │ │ ├── vsprintf.c │ │ ├── wait.c │ │ └── write.c │ ├── mm │ │ ├── forkexit.c │ │ └── main.c │ └── scripts │ │ ├── genlog │ │ └── splitgraphs ├── c │ ├── 80m.img.gz │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── command │ │ ├── Makefile │ │ ├── echo.c │ │ ├── pwd.c │ │ └── start.asm │ ├── fs │ │ ├── disklog.c │ │ ├── link.c │ │ ├── main.c │ │ ├── misc.c │ │ ├── open.c │ │ └── read_write.c │ ├── include │ │ ├── stdio.h │ │ ├── string.h │ │ ├── sys │ │ │ ├── config.h │ │ │ ├── console.h │ │ │ ├── const.h │ │ │ ├── fs.h │ │ │ ├── global.h │ │ │ ├── hd.h │ │ │ ├── keyboard.h │ │ │ ├── keymap.h │ │ │ ├── proc.h │ │ │ ├── protect.h │ │ │ ├── proto.h │ │ │ ├── sconst.inc │ │ │ └── tty.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── console.c │ │ ├── global.c │ │ ├── hd.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── keyboard.c │ │ ├── klib.c │ │ ├── kliba.asm │ │ ├── main.c │ │ ├── proc.c │ │ ├── protect.c │ │ ├── start.c │ │ ├── systask.c │ │ └── tty.c │ ├── lib │ │ ├── close.c │ │ ├── exit.c │ │ ├── fork.c │ │ ├── getpid.c │ │ ├── misc.c │ │ ├── open.c │ │ ├── printf.c │ │ ├── read.c │ │ ├── string.asm │ │ ├── syscall.asm │ │ ├── syslog.c │ │ ├── unlink.c │ │ ├── vsprintf.c │ │ ├── wait.c │ │ └── write.c │ ├── mm │ │ ├── forkexit.c │ │ └── main.c │ └── scripts │ │ ├── genlog │ │ └── splitgraphs ├── d │ ├── 80m.img.gz │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── command │ │ ├── Makefile │ │ ├── echo.c │ │ ├── pwd.c │ │ └── start.asm │ ├── fs │ │ ├── disklog.c │ │ ├── link.c │ │ ├── main.c │ │ ├── misc.c │ │ ├── open.c │ │ └── read_write.c │ ├── include │ │ ├── stdio.h │ │ ├── string.h │ │ ├── sys │ │ │ ├── config.h │ │ │ ├── console.h │ │ │ ├── const.h │ │ │ ├── fs.h │ │ │ ├── global.h │ │ │ ├── hd.h │ │ │ ├── keyboard.h │ │ │ ├── keymap.h │ │ │ ├── proc.h │ │ │ ├── protect.h │ │ │ ├── proto.h │ │ │ ├── sconst.inc │ │ │ └── tty.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── console.c │ │ ├── global.c │ │ ├── hd.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── keyboard.c │ │ ├── klib.c │ │ ├── kliba.asm │ │ ├── main.c │ │ ├── proc.c │ │ ├── protect.c │ │ ├── start.c │ │ ├── systask.c │ │ └── tty.c │ ├── lib │ │ ├── close.c │ │ ├── exec.c │ │ ├── exit.c │ │ ├── fork.c │ │ ├── getpid.c │ │ ├── misc.c │ │ ├── open.c │ │ ├── printf.c │ │ ├── read.c │ │ ├── stat.c │ │ ├── string.asm │ │ ├── syscall.asm │ │ ├── syslog.c │ │ ├── unlink.c │ │ ├── vsprintf.c │ │ ├── wait.c │ │ └── write.c │ ├── mm │ │ ├── exec.c │ │ ├── forkexit.c │ │ └── main.c │ └── scripts │ │ ├── genlog │ │ └── splitgraphs └── e │ ├── 80m.img.gz │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ ├── boot.asm │ ├── include │ │ ├── fat12hdr.inc │ │ ├── load.inc │ │ └── pm.inc │ └── loader.asm │ ├── command │ ├── Makefile │ ├── echo.c │ ├── pwd.c │ └── start.asm │ ├── fs │ ├── disklog.c │ ├── link.c │ ├── main.c │ ├── misc.c │ ├── open.c │ └── read_write.c │ ├── include │ ├── stdio.h │ ├── string.h │ ├── sys │ │ ├── config.h │ │ ├── console.h │ │ ├── const.h │ │ ├── fs.h │ │ ├── global.h │ │ ├── hd.h │ │ ├── keyboard.h │ │ ├── keymap.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ └── tty.h │ └── type.h │ ├── kernel │ ├── clock.c │ ├── console.c │ ├── global.c │ ├── hd.c │ ├── i8259.c │ ├── kernel.asm │ ├── keyboard.c │ ├── klib.c │ ├── kliba.asm │ ├── main.c │ ├── proc.c │ ├── protect.c │ ├── start.c │ ├── systask.c │ └── tty.c │ ├── lib │ ├── close.c │ ├── exec.c │ ├── exit.c │ ├── fork.c │ ├── getpid.c │ ├── misc.c │ ├── open.c │ ├── printf.c │ ├── read.c │ ├── stat.c │ ├── string.asm │ ├── syscall.asm │ ├── syslog.c │ ├── unlink.c │ ├── vsprintf.c │ ├── wait.c │ └── write.c │ ├── mm │ ├── exec.c │ ├── forkexit.c │ └── main.c │ └── scripts │ ├── genlog │ └── splitgraphs ├── chapter11 ├── a │ ├── 80m.img.gz │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── hdboot.asm │ │ ├── hdloader.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── command │ │ ├── Makefile │ │ ├── echo.c │ │ ├── pwd.c │ │ └── start.asm │ ├── fs │ │ ├── disklog.c │ │ ├── link.c │ │ ├── main.c │ │ ├── misc.c │ │ ├── open.c │ │ └── read_write.c │ ├── include │ │ ├── stdio.h │ │ ├── string.h │ │ ├── sys │ │ │ ├── config.h │ │ │ ├── console.h │ │ │ ├── const.h │ │ │ ├── fs.h │ │ │ ├── global.h │ │ │ ├── hd.h │ │ │ ├── keyboard.h │ │ │ ├── keymap.h │ │ │ ├── proc.h │ │ │ ├── protect.h │ │ │ ├── proto.h │ │ │ ├── sconst.inc │ │ │ └── tty.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── console.c │ │ ├── global.c │ │ ├── hd.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── keyboard.c │ │ ├── klib.c │ │ ├── kliba.asm │ │ ├── main.c │ │ ├── proc.c │ │ ├── protect.c │ │ ├── start.c │ │ ├── systask.c │ │ └── tty.c │ ├── lib │ │ ├── close.c │ │ ├── exec.c │ │ ├── exit.c │ │ ├── fork.c │ │ ├── getpid.c │ │ ├── lseek.c │ │ ├── misc.c │ │ ├── open.c │ │ ├── printf.c │ │ ├── read.c │ │ ├── stat.c │ │ ├── string.asm │ │ ├── syscall.asm │ │ ├── syslog.c │ │ ├── unlink.c │ │ ├── vsprintf.c │ │ ├── wait.c │ │ └── write.c │ ├── mm │ │ ├── exec.c │ │ ├── forkexit.c │ │ └── main.c │ └── scripts │ │ ├── genlog │ │ └── splitgraphs ├── b │ ├── 80m.img.gz │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── hdboot.asm │ │ ├── hdldr.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── command │ │ ├── Makefile │ │ ├── echo.c │ │ ├── pwd.c │ │ └── start.asm │ ├── fs │ │ ├── disklog.c │ │ ├── link.c │ │ ├── main.c │ │ ├── misc.c │ │ ├── open.c │ │ └── read_write.c │ ├── grubinst │ ├── include │ │ ├── stdio.h │ │ ├── string.h │ │ ├── sys │ │ │ ├── config.h │ │ │ ├── console.h │ │ │ ├── const.h │ │ │ ├── fs.h │ │ │ ├── global.h │ │ │ ├── hd.h │ │ │ ├── keyboard.h │ │ │ ├── keymap.h │ │ │ ├── proc.h │ │ │ ├── protect.h │ │ │ ├── proto.h │ │ │ ├── sconst.inc │ │ │ └── tty.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── console.c │ │ ├── global.c │ │ ├── hd.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── keyboard.c │ │ ├── klib.c │ │ ├── kliba.asm │ │ ├── main.c │ │ ├── proc.c │ │ ├── protect.c │ │ ├── start.c │ │ ├── systask.c │ │ └── tty.c │ ├── lib │ │ ├── close.c │ │ ├── exec.c │ │ ├── exit.c │ │ ├── fork.c │ │ ├── getpid.c │ │ ├── lseek.c │ │ ├── misc.c │ │ ├── open.c │ │ ├── printf.c │ │ ├── read.c │ │ ├── stat.c │ │ ├── string.asm │ │ ├── syscall.asm │ │ ├── syslog.c │ │ ├── unlink.c │ │ ├── vsprintf.c │ │ ├── wait.c │ │ └── write.c │ ├── mm │ │ ├── exec.c │ │ ├── forkexit.c │ │ └── main.c │ └── scripts │ │ ├── genlog │ │ └── splitgraphs └── c │ ├── 100m.img │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ ├── boot.asm │ ├── hdboot.asm │ ├── hdldr.asm │ ├── include │ │ ├── fat12hdr.inc │ │ ├── load.inc │ │ └── pm.inc │ └── loader.asm │ ├── command │ ├── Makefile │ ├── echo.c │ ├── pwd.c │ └── start.asm │ ├── fs │ ├── disklog.c │ ├── link.c │ ├── main.c │ ├── misc.c │ ├── open.c │ └── read_write.c │ ├── include │ ├── stdio.h │ ├── string.h │ ├── sys │ │ ├── config.h │ │ ├── console.h │ │ ├── const.h │ │ ├── fs.h │ │ ├── global.h │ │ ├── hd.h │ │ ├── keyboard.h │ │ ├── keymap.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ └── tty.h │ └── type.h │ ├── kernel │ ├── clock.c │ ├── console.c │ ├── global.c │ ├── hd.c │ ├── i8259.c │ ├── kernel.asm │ ├── keyboard.c │ ├── klib.c │ ├── kliba.asm │ ├── main.c │ ├── proc.c │ ├── protect.c │ ├── start.c │ ├── systask.c │ └── tty.c │ ├── lib │ ├── close.c │ ├── exec.c │ ├── exit.c │ ├── fork.c │ ├── getpid.c │ ├── lseek.c │ ├── misc.c │ ├── open.c │ ├── printf.c │ ├── read.c │ ├── stat.c │ ├── string.asm │ ├── syscall.asm │ ├── syslog.c │ ├── unlink.c │ ├── vsprintf.c │ ├── wait.c │ └── write.c │ ├── mm │ ├── exec.c │ ├── forkexit.c │ └── main.c │ └── scripts │ ├── genlog │ ├── invalidate.hd │ └── splitgraphs ├── chapter2 ├── linux │ ├── bochsrc │ └── boot.asm └── win │ ├── bochsrc.bxrc │ └── run.bat ├── chapter3 ├── a │ ├── a.img │ ├── bochsrc │ ├── pm.inc │ ├── pmtest1.asm │ └── pmtest1b.asm ├── b │ ├── Makefile │ ├── bochsrc │ ├── freedos.img │ ├── pm.img │ ├── pm.inc │ └── pmtest2.asm ├── c │ ├── Makefile │ ├── bochsrc │ ├── freedos.img │ ├── pm.img │ ├── pm.inc │ └── pmtest3.asm ├── d │ ├── Makefile │ ├── bochsrc │ ├── freedos.img │ ├── pm.img │ ├── pm.inc │ └── pmtest4.asm ├── e │ ├── Makefile │ ├── bochsrc │ ├── freedos.img │ ├── pm.img │ ├── pm.inc │ ├── pmtest5.asm │ ├── pmtest5a.asm │ ├── pmtest5b.asm │ └── pmtest5c.asm ├── f │ ├── Makefile │ ├── bochsrc │ ├── freedos.img │ ├── pm.img │ ├── pm.inc │ └── pmtest6.asm ├── g │ ├── Makefile │ ├── bochsrc │ ├── freedos.img │ ├── lib.inc │ ├── pm.img │ ├── pm.inc │ └── pmtest7.asm ├── h │ ├── Makefile │ ├── bochsrc │ ├── freedos.img │ ├── lib.inc │ ├── pm.img │ ├── pm.inc │ └── pmtest8.asm └── i │ ├── Makefile │ ├── bochsrc │ ├── freedos.img │ ├── lib.inc │ ├── pm.img │ ├── pm.inc │ ├── pmtest9.asm │ ├── pmtest9a.asm │ ├── pmtest9b.asm │ └── pmtest9c.asm ├── chapter4 ├── a │ ├── Makefile │ ├── a.img │ ├── bochsrc │ └── boot.asm ├── b │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot.asm │ └── loader.asm └── c │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot.asm │ └── loader.asm ├── chapter5 ├── a │ └── hello.asm ├── b │ ├── Makefile │ ├── bar.c │ └── foo.asm ├── c │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot.asm │ ├── fat12hdr.inc │ ├── kernel.asm │ └── loader.asm ├── d │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot.asm │ ├── fat12hdr.inc │ ├── kernel.asm │ ├── lib.inc │ ├── load.inc │ ├── loader.asm │ └── pm.inc ├── e │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot.asm │ ├── fat12hdr.inc │ ├── kernel.asm │ ├── load.inc │ ├── loader.asm │ └── pm.inc ├── f │ ├── a.img │ ├── bochsrc │ ├── boot.asm │ ├── const.h │ ├── fat12hdr.inc │ ├── kernel.asm │ ├── kliba.asm │ ├── load.inc │ ├── loader.asm │ ├── pm.inc │ ├── protect.h │ ├── start.c │ ├── string.asm │ └── type.h ├── g │ ├── Makefile │ ├── Makefile.boot │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── Makefile │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── const.h │ │ ├── protect.h │ │ └── type.h │ ├── kernel │ │ ├── kernel.asm │ │ └── start.c │ └── lib │ │ ├── kliba.asm │ │ └── string.asm ├── h │ ├── Makefile │ ├── Makefile.1 │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── const.h │ │ ├── global.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── string.h │ │ └── type.h │ ├── kernel │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── protect.c │ │ └── start.c │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm └── i │ ├── Makefile │ ├── Makefile.1 │ ├── a.img │ ├── bochsrc │ ├── boot │ ├── boot.asm │ ├── include │ │ ├── fat12hdr.inc │ │ ├── load.inc │ │ └── pm.inc │ └── loader.asm │ ├── include │ ├── const.h │ ├── global.h │ ├── protect.h │ ├── proto.h │ ├── string.h │ └── type.h │ ├── kernel │ ├── global.c │ ├── i8259.c │ ├── kernel.asm │ ├── protect.c │ └── start.c │ └── lib │ ├── klib.c │ ├── kliba.asm │ └── string.asm ├── chapter6 ├── a │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── const.h │ │ ├── global.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ └── type.h │ ├── kernel │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── main.c │ │ ├── protect.c │ │ └── start.c │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm ├── b │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── const.h │ │ ├── global.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ └── type.h │ ├── kernel │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.final.asm │ │ ├── kernel1.asm │ │ ├── kernel2.asm │ │ ├── kernel3.asm │ │ ├── kernel4.asm │ │ ├── kernel5.asm │ │ ├── main.c │ │ ├── protect.c │ │ └── start.c │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm ├── c │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── const.h │ │ ├── global.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ └── type.h │ ├── kernel │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── kernel1.asm │ │ ├── kernel2.asm │ │ ├── kernel3.asm │ │ ├── main.c │ │ ├── protect.c │ │ └── start.c │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm ├── d │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── const.h │ │ ├── global.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── main.c │ │ ├── protect.c │ │ └── start.c │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm ├── e │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── const.h │ │ ├── global.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── main.c │ │ ├── protect.c │ │ └── start.c │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm ├── f │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── const.h │ │ ├── global.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── main.c │ │ ├── protect.c │ │ └── start.c │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm ├── g │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── const.h │ │ ├── global.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── main.c │ │ ├── protect.c │ │ └── start.c │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm ├── h │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── const.h │ │ ├── global.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── main.c │ │ ├── protect.c │ │ └── start.c │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm ├── i │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── const.h │ │ ├── global.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── main.c │ │ ├── protect.c │ │ └── start.c │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm ├── j │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── const.h │ │ ├── global.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── main.c │ │ ├── protect.c │ │ └── start.c │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm ├── k │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── const.h │ │ ├── global.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── main.c │ │ ├── protect.c │ │ └── start.c │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm ├── l │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── const.h │ │ ├── global.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── main.c │ │ ├── proc.c │ │ ├── protect.c │ │ ├── start.c │ │ └── syscall.asm │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm ├── m │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── const.h │ │ ├── global.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── main.c │ │ ├── proc.c │ │ ├── protect.c │ │ ├── start.c │ │ └── syscall.asm │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm ├── n │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── const.h │ │ ├── global.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── main.c │ │ ├── proc.c │ │ ├── protect.c │ │ ├── start.c │ │ └── syscall.asm │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm ├── o │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── const.h │ │ ├── global.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── main.c │ │ ├── proc.c │ │ ├── protect.c │ │ ├── start.c │ │ └── syscall.asm │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm ├── p │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── const.h │ │ ├── global.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── main.c │ │ ├── proc.c │ │ ├── protect.c │ │ ├── start.c │ │ └── syscall.asm │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm ├── q │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── const.h │ │ ├── global.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── main.c │ │ ├── proc.c │ │ ├── protect.c │ │ ├── start.c │ │ └── syscall.asm │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm └── r │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ ├── boot.asm │ ├── include │ │ ├── fat12hdr.inc │ │ ├── load.inc │ │ └── pm.inc │ └── loader.asm │ ├── include │ ├── const.h │ ├── global.h │ ├── proc.h │ ├── protect.h │ ├── proto.h │ ├── sconst.inc │ ├── string.h │ └── type.h │ ├── kernel │ ├── clock.c │ ├── global.c │ ├── i8259.c │ ├── kernel.asm │ ├── main.c │ ├── proc.c │ ├── protect.c │ ├── start.c │ └── syscall.asm │ └── lib │ ├── klib.c │ ├── kliba.asm │ └── string.asm ├── chapter7 ├── a │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── const.h │ │ ├── global.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── keyboard.c │ │ ├── main.c │ │ ├── proc.c │ │ ├── protect.c │ │ ├── start.c │ │ └── syscall.asm │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm ├── b │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── const.h │ │ ├── global.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── keyboard.c │ │ ├── main.c │ │ ├── proc.c │ │ ├── protect.c │ │ ├── start.c │ │ └── syscall.asm │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm ├── c │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── const.h │ │ ├── global.h │ │ ├── keyboard.h │ │ ├── keymap.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── keyboard.c │ │ ├── main.c │ │ ├── proc.c │ │ ├── protect.c │ │ ├── start.c │ │ ├── syscall.asm │ │ └── tty.c │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm ├── d │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── const.h │ │ ├── global.h │ │ ├── keyboard.h │ │ ├── keymap.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── keyboard.c │ │ ├── main.c │ │ ├── proc.c │ │ ├── protect.c │ │ ├── start.c │ │ ├── syscall.asm │ │ └── tty.c │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm ├── e │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── const.h │ │ ├── global.h │ │ ├── keyboard.h │ │ ├── keymap.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── keyboard.c │ │ ├── main.c │ │ ├── proc.c │ │ ├── protect.c │ │ ├── start.c │ │ ├── syscall.asm │ │ └── tty.c │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm ├── f │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── const.h │ │ ├── global.h │ │ ├── keyboard.h │ │ ├── keymap.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── keyboard.c │ │ ├── main.c │ │ ├── proc.c │ │ ├── protect.c │ │ ├── start.c │ │ ├── syscall.asm │ │ └── tty.c │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm ├── g │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── const.h │ │ ├── global.h │ │ ├── keyboard.h │ │ ├── keymap.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── keyboard.c │ │ ├── main.c │ │ ├── proc.c │ │ ├── protect.c │ │ ├── start.c │ │ ├── syscall.asm │ │ └── tty.c │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm ├── h │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── const.h │ │ ├── global.h │ │ ├── keyboard.h │ │ ├── keymap.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── keyboard.c │ │ ├── main.c │ │ ├── proc.c │ │ ├── protect.c │ │ ├── start.c │ │ ├── syscall.asm │ │ └── tty.c │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm ├── i │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── console.h │ │ ├── const.h │ │ ├── global.h │ │ ├── keyboard.h │ │ ├── keymap.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ ├── tty.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── console.c │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── keyboard.c │ │ ├── main.c │ │ ├── proc.c │ │ ├── protect.c │ │ ├── start.c │ │ ├── syscall.asm │ │ └── tty.c │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm ├── j │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── console.h │ │ ├── const.h │ │ ├── global.h │ │ ├── keyboard.h │ │ ├── keymap.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ ├── tty.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── console.c │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── keyboard.c │ │ ├── main.c │ │ ├── proc.c │ │ ├── protect.c │ │ ├── start.c │ │ ├── syscall.asm │ │ └── tty.c │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm ├── k │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── console.h │ │ ├── const.h │ │ ├── global.h │ │ ├── keyboard.h │ │ ├── keymap.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ ├── tty.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── console.c │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── keyboard.c │ │ ├── main.c │ │ ├── proc.c │ │ ├── protect.c │ │ ├── start.c │ │ ├── syscall.asm │ │ └── tty.c │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm ├── l │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── console.h │ │ ├── const.h │ │ ├── global.h │ │ ├── keyboard.h │ │ ├── keymap.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ ├── tty.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── console.c │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── keyboard.c │ │ ├── main.c │ │ ├── proc.c │ │ ├── protect.c │ │ ├── start.c │ │ ├── syscall.asm │ │ └── tty.c │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm ├── m │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── console.h │ │ ├── const.h │ │ ├── global.h │ │ ├── keyboard.h │ │ ├── keymap.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ ├── tty.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── console.c │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── keyboard.c │ │ ├── main.c │ │ ├── proc.c │ │ ├── protect.c │ │ ├── start.c │ │ ├── syscall.asm │ │ └── tty.c │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm ├── n │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── console.h │ │ ├── const.h │ │ ├── global.h │ │ ├── keyboard.h │ │ ├── keymap.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ ├── tty.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── console.c │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── keyboard.c │ │ ├── main.c │ │ ├── proc.c │ │ ├── protect.c │ │ ├── start.c │ │ ├── syscall.asm │ │ └── tty.c │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm └── o │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ ├── boot.asm │ ├── include │ │ ├── fat12hdr.inc │ │ ├── load.inc │ │ └── pm.inc │ └── loader.asm │ ├── include │ ├── console.h │ ├── const.h │ ├── global.h │ ├── keyboard.h │ ├── keymap.h │ ├── proc.h │ ├── protect.h │ ├── proto.h │ ├── sconst.inc │ ├── string.h │ ├── tty.h │ └── type.h │ ├── kernel │ ├── clock.c │ ├── console.c │ ├── global.c │ ├── i8259.c │ ├── kernel.asm │ ├── keyboard.c │ ├── main.c │ ├── printf.c │ ├── proc.c │ ├── protect.c │ ├── start.c │ ├── syscall.asm │ ├── tty.c │ └── vsprintf.c │ └── lib │ ├── klib.c │ ├── kliba.asm │ └── string.asm ├── chapter8 ├── _base_ │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ │ ├── boot.asm │ │ ├── include │ │ │ ├── fat12hdr.inc │ │ │ ├── load.inc │ │ │ └── pm.inc │ │ └── loader.asm │ ├── include │ │ ├── console.h │ │ ├── const.h │ │ ├── global.h │ │ ├── keyboard.h │ │ ├── keymap.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ ├── string.h │ │ ├── tty.h │ │ └── type.h │ ├── kernel │ │ ├── clock.c │ │ ├── console.c │ │ ├── global.c │ │ ├── i8259.c │ │ ├── kernel.asm │ │ ├── keyboard.c │ │ ├── main.c │ │ ├── printf.c │ │ ├── proc.c │ │ ├── protect.c │ │ ├── start.c │ │ ├── syscall.asm │ │ ├── tty.c │ │ └── vsprintf.c │ └── lib │ │ ├── klib.c │ │ ├── kliba.asm │ │ └── string.asm └── a │ ├── Makefile │ ├── a.img │ ├── bochsrc │ ├── boot │ ├── boot.asm │ ├── include │ │ ├── fat12hdr.inc │ │ ├── load.inc │ │ └── pm.inc │ └── loader.asm │ ├── include │ ├── console.h │ ├── const.h │ ├── global.h │ ├── keyboard.h │ ├── keymap.h │ ├── proc.h │ ├── protect.h │ ├── proto.h │ ├── sconst.inc │ ├── string.h │ ├── tty.h │ └── type.h │ ├── kernel │ ├── clock.c │ ├── console.c │ ├── global.c │ ├── i8259.c │ ├── kernel.asm │ ├── keyboard.c │ ├── main.c │ ├── printf.c │ ├── proc.c │ ├── protect.c │ ├── start.c │ ├── syscall.asm │ ├── systask.c │ ├── tty.c │ └── vsprintf.c │ └── lib │ ├── klib.c │ ├── kliba.asm │ ├── misc.c │ └── string.asm └── chapter9 ├── a ├── 80m.img.gz ├── Makefile ├── a.img ├── bochsrc ├── boot │ ├── boot.asm │ ├── include │ │ ├── fat12hdr.inc │ │ ├── load.inc │ │ └── pm.inc │ └── loader.asm ├── fs │ └── main.c ├── include │ ├── console.h │ ├── const.h │ ├── fs.h │ ├── global.h │ ├── hd.h │ ├── keyboard.h │ ├── keymap.h │ ├── proc.h │ ├── protect.h │ ├── proto.h │ ├── sconst.inc │ ├── string.h │ ├── tty.h │ └── type.h ├── kernel │ ├── clock.c │ ├── console.c │ ├── global.c │ ├── hd.c │ ├── i8259.c │ ├── kernel.asm │ ├── keyboard.c │ ├── main.c │ ├── printf.c │ ├── proc.c │ ├── protect.c │ ├── start.c │ ├── syscall.asm │ ├── systask.c │ ├── tty.c │ └── vsprintf.c └── lib │ ├── klib.c │ ├── kliba.asm │ ├── misc.c │ └── string.asm ├── b ├── 80m.img.gz ├── Makefile ├── a.img ├── bochsrc ├── boot │ ├── boot.asm │ ├── include │ │ ├── fat12hdr.inc │ │ ├── load.inc │ │ └── pm.inc │ └── loader.asm ├── fs │ └── main.c ├── include │ ├── config.h │ ├── console.h │ ├── const.h │ ├── fs.h │ ├── global.h │ ├── hd.h │ ├── keyboard.h │ ├── keymap.h │ ├── proc.h │ ├── protect.h │ ├── proto.h │ ├── sconst.inc │ ├── string.h │ ├── tty.h │ └── type.h ├── kernel │ ├── clock.c │ ├── console.c │ ├── global.c │ ├── hd.c │ ├── i8259.c │ ├── kernel.asm │ ├── keyboard.c │ ├── main.c │ ├── printf.c │ ├── proc.c │ ├── protect.c │ ├── start.c │ ├── syscall.asm │ ├── systask.c │ ├── tty.c │ └── vsprintf.c └── lib │ ├── klib.c │ ├── kliba.asm │ ├── misc.c │ └── string.asm ├── c ├── 80m.img.gz ├── Makefile ├── a.img ├── bochsrc ├── boot │ ├── boot.asm │ ├── include │ │ ├── fat12hdr.inc │ │ ├── load.inc │ │ └── pm.inc │ └── loader.asm ├── fs │ └── main.c ├── include │ ├── config.h │ ├── console.h │ ├── const.h │ ├── fs.h │ ├── global.h │ ├── hd.h │ ├── keyboard.h │ ├── keymap.h │ ├── proc.h │ ├── protect.h │ ├── proto.h │ ├── sconst.inc │ ├── string.h │ ├── tty.h │ └── type.h ├── kernel │ ├── clock.c │ ├── console.c │ ├── global.c │ ├── hd.c │ ├── i8259.c │ ├── kernel.asm │ ├── keyboard.c │ ├── main.c │ ├── printf.c │ ├── proc.c │ ├── protect.c │ ├── start.c │ ├── syscall.asm │ ├── systask.c │ ├── tty.c │ └── vsprintf.c └── lib │ ├── klib.c │ ├── kliba.asm │ ├── misc.c │ └── string.asm ├── d ├── 80m.img.gz ├── Makefile ├── a.img ├── bochsrc ├── boot │ ├── boot.asm │ ├── include │ │ ├── fat12hdr.inc │ │ ├── load.inc │ │ └── pm.inc │ └── loader.asm ├── fs │ └── main.c ├── include │ ├── config.h │ ├── console.h │ ├── const.h │ ├── fs.h │ ├── global.h │ ├── hd.h │ ├── keyboard.h │ ├── keymap.h │ ├── proc.h │ ├── protect.h │ ├── proto.h │ ├── sconst.inc │ ├── string.h │ ├── tty.h │ └── type.h ├── kernel │ ├── clock.c │ ├── console.c │ ├── global.c │ ├── hd.c │ ├── i8259.c │ ├── kernel.asm │ ├── keyboard.c │ ├── main.c │ ├── printf.c │ ├── proc.c │ ├── protect.c │ ├── start.c │ ├── syscall.asm │ ├── systask.c │ ├── tty.c │ └── vsprintf.c └── lib │ ├── klib.c │ ├── kliba.asm │ ├── misc.c │ └── string.asm ├── e ├── 80m.img.gz ├── Makefile ├── a.img ├── bochsrc ├── boot │ ├── boot.asm │ ├── include │ │ ├── fat12hdr.inc │ │ ├── load.inc │ │ └── pm.inc │ └── loader.asm ├── fs │ ├── main.c │ ├── misc.c │ └── open.c ├── include │ ├── stdio.h │ ├── string.h │ ├── sys │ │ ├── config.h │ │ ├── console.h │ │ ├── const.h │ │ ├── fs.h │ │ ├── global.h │ │ ├── hd.h │ │ ├── keyboard.h │ │ ├── keymap.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ └── tty.h │ └── type.h ├── kernel │ ├── clock.c │ ├── console.c │ ├── global.c │ ├── hd.c │ ├── i8259.c │ ├── kernel.asm │ ├── keyboard.c │ ├── main.c │ ├── proc.c │ ├── protect.c │ ├── start.c │ ├── systask.c │ └── tty.c ├── lib │ ├── close.c │ ├── klib.c │ ├── kliba.asm │ ├── misc.c │ ├── open.c │ ├── printf.c │ ├── string.asm │ ├── syscall.asm │ └── vsprintf.c └── tmp │ ├── Makefile │ └── f.c ├── f ├── 80m.img.gz ├── Makefile ├── a.img ├── bochsrc ├── boot │ ├── boot.asm │ ├── include │ │ ├── fat12hdr.inc │ │ ├── load.inc │ │ └── pm.inc │ └── loader.asm ├── fs │ ├── main.c │ ├── misc.c │ ├── open.c │ └── read_write.c ├── include │ ├── stdio.h │ ├── string.h │ ├── sys │ │ ├── config.h │ │ ├── console.h │ │ ├── const.h │ │ ├── fs.h │ │ ├── global.h │ │ ├── hd.h │ │ ├── keyboard.h │ │ ├── keymap.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ └── tty.h │ └── type.h ├── kernel │ ├── clock.c │ ├── console.c │ ├── global.c │ ├── hd.c │ ├── i8259.c │ ├── kernel.asm │ ├── keyboard.c │ ├── main.c │ ├── proc.c │ ├── protect.c │ ├── start.c │ ├── systask.c │ └── tty.c └── lib │ ├── close.c │ ├── klib.c │ ├── kliba.asm │ ├── misc.c │ ├── open.c │ ├── printf.c │ ├── read.c │ ├── string.asm │ ├── syscall.asm │ ├── vsprintf.c │ └── write.c ├── g ├── 80m.img.gz ├── Makefile ├── a.img ├── bochsrc ├── boot │ ├── boot.asm │ ├── include │ │ ├── fat12hdr.inc │ │ ├── load.inc │ │ └── pm.inc │ └── loader.asm ├── fs │ ├── disklog.c │ ├── main.c │ ├── misc.c │ ├── open.c │ └── read_write.c ├── genlog ├── include │ ├── stdio.h │ ├── string.h │ ├── sys │ │ ├── config.h │ │ ├── console.h │ │ ├── const.h │ │ ├── fs.h │ │ ├── global.h │ │ ├── hd.h │ │ ├── keyboard.h │ │ ├── keymap.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ └── tty.h │ └── type.h ├── kernel │ ├── clock.c │ ├── console.c │ ├── global.c │ ├── hd.c │ ├── i8259.c │ ├── kernel.asm │ ├── keyboard.c │ ├── main.c │ ├── proc.c │ ├── protect.c │ ├── start.c │ ├── systask.c │ └── tty.c ├── lib │ ├── close.c │ ├── getpid.c │ ├── klib.c │ ├── kliba.asm │ ├── misc.c │ ├── open.c │ ├── printf.c │ ├── read.c │ ├── string.asm │ ├── syscall.asm │ ├── syslog.c │ ├── vsprintf.c │ └── write.c └── splitgraphs ├── h ├── 80m.img.gz ├── Makefile ├── a.img ├── bochsrc ├── boot │ ├── boot.asm │ ├── include │ │ ├── fat12hdr.inc │ │ ├── load.inc │ │ └── pm.inc │ └── loader.asm ├── fs │ ├── disklog.c │ ├── link.c │ ├── main.c │ ├── misc.c │ ├── open.c │ └── read_write.c ├── include │ ├── stdio.h │ ├── string.h │ ├── sys │ │ ├── config.h │ │ ├── console.h │ │ ├── const.h │ │ ├── fs.h │ │ ├── global.h │ │ ├── hd.h │ │ ├── keyboard.h │ │ ├── keymap.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ └── tty.h │ └── type.h ├── kernel │ ├── clock.c │ ├── console.c │ ├── global.c │ ├── hd.c │ ├── i8259.c │ ├── kernel.asm │ ├── keyboard.c │ ├── main.c │ ├── proc.c │ ├── protect.c │ ├── start.c │ ├── systask.c │ └── tty.c ├── lib │ ├── close.c │ ├── getpid.c │ ├── klib.c │ ├── kliba.asm │ ├── misc.c │ ├── open.c │ ├── printf.c │ ├── read.c │ ├── string.asm │ ├── syscall.asm │ ├── syslog.c │ ├── unlink.c │ ├── vsprintf.c │ └── write.c └── scripts │ ├── genlog │ └── splitgraphs ├── i ├── 80m.img.gz ├── Makefile ├── a.img ├── bochsrc ├── boot │ ├── boot.asm │ ├── include │ │ ├── fat12hdr.inc │ │ ├── load.inc │ │ └── pm.inc │ └── loader.asm ├── fs │ ├── disklog.c │ ├── link.c │ ├── main.c │ ├── misc.c │ ├── open.c │ └── read_write.c ├── include │ ├── stdio.h │ ├── string.h │ ├── sys │ │ ├── config.h │ │ ├── console.h │ │ ├── const.h │ │ ├── fs.h │ │ ├── global.h │ │ ├── hd.h │ │ ├── keyboard.h │ │ ├── keymap.h │ │ ├── proc.h │ │ ├── protect.h │ │ ├── proto.h │ │ ├── sconst.inc │ │ └── tty.h │ └── type.h ├── kernel │ ├── clock.c │ ├── console.c │ ├── global.c │ ├── hd.c │ ├── i8259.c │ ├── kernel.asm │ ├── keyboard.c │ ├── main.c │ ├── proc.c │ ├── protect.c │ ├── start.c │ ├── systask.c │ └── tty.c ├── lib │ ├── close.c │ ├── getpid.c │ ├── klib.c │ ├── kliba.asm │ ├── misc.c │ ├── open.c │ ├── printf.c │ ├── read.c │ ├── string.asm │ ├── syscall.asm │ ├── syslog.c │ ├── unlink.c │ ├── vsprintf.c │ └── write.c └── scripts │ ├── genlog │ └── splitgraphs └── j ├── 80m.img.gz ├── Makefile ├── a.img ├── bochsrc ├── boot ├── boot.asm ├── include │ ├── fat12hdr.inc │ ├── load.inc │ └── pm.inc └── loader.asm ├── fs ├── disklog.c ├── link.c ├── main.c ├── misc.c ├── open.c └── read_write.c ├── include ├── stdio.h ├── string.h ├── sys │ ├── config.h │ ├── console.h │ ├── const.h │ ├── fs.h │ ├── global.h │ ├── hd.h │ ├── keyboard.h │ ├── keymap.h │ ├── proc.h │ ├── protect.h │ ├── proto.h │ ├── sconst.inc │ └── tty.h └── type.h ├── kernel ├── clock.c ├── console.c ├── global.c ├── hd.c ├── i8259.c ├── kernel.asm ├── keyboard.c ├── main.c ├── proc.c ├── protect.c ├── start.c ├── systask.c └── tty.c ├── lib ├── close.c ├── getpid.c ├── klib.c ├── kliba.asm ├── misc.c ├── open.c ├── printf.c ├── read.c ├── string.asm ├── syscall.asm ├── syslog.c ├── unlink.c ├── vsprintf.c └── write.c └── scripts ├── genlog └── splitgraphs /README.md: -------------------------------------------------------------------------------- 1 | Orange's一个操作系统的实现(随书光盘) -------------------------------------------------------------------------------- /chapter1/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # choose the boot disk. 16 | boot: floppy 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter1/a/boot.asm: -------------------------------------------------------------------------------- 1 | org 07c00h ; 告诉编译器程序加载到7c00处 2 | mov ax, cs 3 | mov ds, ax 4 | mov es, ax 5 | call DispStr ; 调用显示字符串例程 6 | jmp $ ; 无限循环 7 | DispStr: 8 | mov ax, BootMessage 9 | mov bp, ax ; ES:BP = 串地址 10 | mov cx, 16 ; CX = 串长度 11 | mov ax, 01301h ; AH = 13, AL = 01h 12 | mov bx, 000ch ; 页号为0(BH = 0) 黑底红字(BL = 0Ch,高亮) 13 | mov dl, 0 14 | int 10h ; 10h 号中断 15 | ret 16 | BootMessage: db "Hello, OS world!" 17 | times 510-($-$$) db 0 ; 填充剩下的空间,使生成的二进制代码恰好为512字节 18 | dw 0xaa55 ; 结束标志 19 | -------------------------------------------------------------------------------- /chapter1/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # choose the boot disk. 16 | boot: floppy 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter1/b/boot.asm: -------------------------------------------------------------------------------- 1 | ;%define _BOOT_DEBUG_ ; 制作 Boot Sector 时一定将此行注释掉! 2 | ; 去掉此行注释后可做成.COM文件易于调试: 3 | ; nasm Boot.asm -o Boot.com 4 | 5 | %ifdef _BOOT_DEBUG_ 6 | org 0100h ; 调试状态, 做成 .COM 文件, 可调试 7 | %else 8 | org 07c00h ; BIOS 将把 Boot Sector 加载到 0:7C00 处 9 | %endif 10 | 11 | mov ax, cs 12 | mov ds, ax 13 | mov es, ax 14 | call DispStr ; 调用显示字符串例程 15 | jmp $ ; 无限循环 16 | DispStr: 17 | mov ax, BootMessage 18 | mov bp, ax ; ES:BP = 串地址 19 | mov cx, 16 ; CX = 串长度 20 | mov ax, 01301h ; AH = 13, AL = 01h 21 | mov bx, 000ch ; 页号为0(BH = 0) 黑底红字(BL = 0Ch,高亮) 22 | mov dl, 0 23 | int 10h ; int 10h 24 | ret 25 | BootMessage: db "Hello, OS world!" 26 | times 510-($-$$) db 0 ; 填充剩下的空间,使生成的二进制代码恰好为512字节 27 | dw 0xaa55 ; 结束标志 28 | -------------------------------------------------------------------------------- /chapter10/a/80m.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter10/a/80m.img.gz -------------------------------------------------------------------------------- /chapter10/a/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter10/a/a.img -------------------------------------------------------------------------------- /chapter10/a/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 | -------------------------------------------------------------------------------- /chapter10/b/80m.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter10/b/80m.img.gz -------------------------------------------------------------------------------- /chapter10/b/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter10/b/a.img -------------------------------------------------------------------------------- /chapter10/b/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 | -------------------------------------------------------------------------------- /chapter10/c/80m.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter10/c/80m.img.gz -------------------------------------------------------------------------------- /chapter10/c/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter10/c/a.img -------------------------------------------------------------------------------- /chapter10/c/command/echo.c: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | 3 | int main(int argc, char * argv[]) 4 | { 5 | int i; 6 | for (i = 1; i < argc; i++) 7 | printf("%s%s", i == 1 ? "" : " ", argv[i]); 8 | printf("\n"); 9 | 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /chapter10/c/command/pwd.c: -------------------------------------------------------------------------------- 1 | #include "type.h" 2 | #include "stdio.h" 3 | 4 | int main(int argc, char * argv[]) 5 | { 6 | printf("/\n"); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /chapter10/c/command/start.asm: -------------------------------------------------------------------------------- 1 | ;; start.asm 2 | 3 | extern main 4 | extern exit 5 | 6 | bits 32 7 | 8 | [section .text] 9 | 10 | global _start 11 | 12 | _start: 13 | push eax 14 | push ecx 15 | call main 16 | ;; need not clean up the stack here 17 | 18 | push eax 19 | call exit 20 | 21 | hlt ; should never arrive here 22 | 23 | -------------------------------------------------------------------------------- /chapter10/c/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 | -------------------------------------------------------------------------------- /chapter10/d/80m.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter10/d/80m.img.gz -------------------------------------------------------------------------------- /chapter10/d/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter10/d/a.img -------------------------------------------------------------------------------- /chapter10/d/command/echo.c: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | 3 | int main(int argc, char * argv[]) 4 | { 5 | int i; 6 | for (i = 1; i < argc; i++) 7 | printf("%s%s", i == 1 ? "" : " ", argv[i]); 8 | printf("\n"); 9 | 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /chapter10/d/command/pwd.c: -------------------------------------------------------------------------------- 1 | #include "type.h" 2 | #include "stdio.h" 3 | 4 | int main(int argc, char * argv[]) 5 | { 6 | printf("/\n"); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /chapter10/d/command/start.asm: -------------------------------------------------------------------------------- 1 | ;; start.asm 2 | 3 | extern main 4 | extern exit 5 | 6 | bits 32 7 | 8 | [section .text] 9 | 10 | global _start 11 | 12 | _start: 13 | push eax 14 | push ecx 15 | call main 16 | ;; need not clean up the stack here 17 | 18 | push eax 19 | call exit 20 | 21 | hlt ; should never arrive here 22 | 23 | -------------------------------------------------------------------------------- /chapter10/d/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 | -------------------------------------------------------------------------------- /chapter10/e/80m.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter10/e/80m.img.gz -------------------------------------------------------------------------------- /chapter10/e/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter10/e/a.img -------------------------------------------------------------------------------- /chapter10/e/command/echo.c: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | 3 | int main(int argc, char * argv[]) 4 | { 5 | int i; 6 | for (i = 1; i < argc; i++) 7 | printf("%s%s", i == 1 ? "" : " ", argv[i]); 8 | printf("\n"); 9 | 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /chapter10/e/command/pwd.c: -------------------------------------------------------------------------------- 1 | #include "type.h" 2 | #include "stdio.h" 3 | 4 | int main(int argc, char * argv[]) 5 | { 6 | printf("/\n"); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /chapter10/e/command/start.asm: -------------------------------------------------------------------------------- 1 | ;; start.asm 2 | 3 | extern main 4 | extern exit 5 | 6 | bits 32 7 | 8 | [section .text] 9 | 10 | global _start 11 | 12 | _start: 13 | push eax 14 | push ecx 15 | call main 16 | ;; need not clean up the stack here 17 | 18 | push eax 19 | call exit 20 | 21 | hlt ; should never arrive here 22 | 23 | -------------------------------------------------------------------------------- /chapter10/e/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 | -------------------------------------------------------------------------------- /chapter11/a/80m.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter11/a/80m.img.gz -------------------------------------------------------------------------------- /chapter11/a/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter11/a/a.img -------------------------------------------------------------------------------- /chapter11/a/command/echo.c: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | 3 | int main(int argc, char * argv[]) 4 | { 5 | int i; 6 | for (i = 1; i < argc; i++) 7 | printf("%s%s", i == 1 ? "" : " ", argv[i]); 8 | printf("\n"); 9 | 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /chapter11/a/command/pwd.c: -------------------------------------------------------------------------------- 1 | #include "type.h" 2 | #include "stdio.h" 3 | 4 | int main(int argc, char * argv[]) 5 | { 6 | printf("/\n"); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /chapter11/a/command/start.asm: -------------------------------------------------------------------------------- 1 | ;; start.asm 2 | 3 | extern main 4 | extern exit 5 | 6 | bits 32 7 | 8 | [section .text] 9 | 10 | global _start 11 | 12 | _start: 13 | push eax 14 | push ecx 15 | call main 16 | ;; need not clean up the stack here 17 | 18 | push eax 19 | call exit 20 | 21 | hlt ; should never arrive here 22 | 23 | -------------------------------------------------------------------------------- /chapter11/a/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 | -------------------------------------------------------------------------------- /chapter11/b/80m.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter11/b/80m.img.gz -------------------------------------------------------------------------------- /chapter11/b/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter11/b/a.img -------------------------------------------------------------------------------- /chapter11/b/command/echo.c: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | 3 | int main(int argc, char * argv[]) 4 | { 5 | int i; 6 | for (i = 1; i < argc; i++) 7 | printf("%s%s", i == 1 ? "" : " ", argv[i]); 8 | printf("\n"); 9 | 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /chapter11/b/command/pwd.c: -------------------------------------------------------------------------------- 1 | #include "type.h" 2 | #include "stdio.h" 3 | 4 | int main(int argc, char * argv[]) 5 | { 6 | printf("/\n"); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /chapter11/b/command/start.asm: -------------------------------------------------------------------------------- 1 | ;; start.asm 2 | 3 | extern main 4 | extern exit 5 | 6 | bits 32 7 | 8 | [section .text] 9 | 10 | global _start 11 | 12 | _start: 13 | push eax 14 | push ecx 15 | call main 16 | ;; need not clean up the stack here 17 | 18 | push eax 19 | call exit 20 | 21 | hlt ; should never arrive here 22 | 23 | -------------------------------------------------------------------------------- /chapter11/b/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 | -------------------------------------------------------------------------------- /chapter11/c/100m.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter11/c/100m.img -------------------------------------------------------------------------------- /chapter11/c/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter11/c/a.img -------------------------------------------------------------------------------- /chapter11/c/command/echo.c: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | 3 | int main(int argc, char * argv[]) 4 | { 5 | int i; 6 | for (i = 1; i < argc; i++) 7 | printf("%s%s", i == 1 ? "" : " ", argv[i]); 8 | printf("\n"); 9 | 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /chapter11/c/command/pwd.c: -------------------------------------------------------------------------------- 1 | #include "type.h" 2 | #include "stdio.h" 3 | 4 | int main(int argc, char * argv[]) 5 | { 6 | printf("/\n"); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /chapter11/c/command/start.asm: -------------------------------------------------------------------------------- 1 | ;; start.asm 2 | 3 | extern main 4 | extern exit 5 | 6 | bits 32 7 | 8 | [section .text] 9 | 10 | global _start 11 | 12 | _start: 13 | push eax 14 | push ecx 15 | call main 16 | ;; need not clean up the stack here 17 | 18 | push eax 19 | call exit 20 | 21 | hlt ; should never arrive here 22 | 23 | -------------------------------------------------------------------------------- /chapter11/c/scripts/invalidate.hd: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | printusage(){ 4 | echo "Usage:" 5 | echo -e "\t`basename $0` file" 6 | echo 7 | } 8 | 9 | if [ $# -ne 1 ]; then 10 | printusage 11 | exit 1 12 | fi 13 | 14 | out_file=$1 15 | 16 | echo -e "\0invalidated" > /tmp/invalid.hd.file 17 | 18 | dd if=/tmp/invalid.hd.file of=$out_file seek=`echo "obase=10;ibase=16;(\`egrep -e '^ROOT_BASE' ./boot/include/load.inc | sed -e 's/.*0x//g'\`+1)*200" | bc` bs=1 count=12 conv=notrunc 19 | 20 | -------------------------------------------------------------------------------- /chapter11/c/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 | -------------------------------------------------------------------------------- /chapter2/linux/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 | # choose the boot disk. 16 | boot: floppy 17 | 18 | # where do we send log messages? 19 | log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter2/linux/boot.asm: -------------------------------------------------------------------------------- 1 | org 07c00h ; 告诉编译器程序加载到7c00处 2 | mov ax, cs 3 | mov ds, ax 4 | mov es, ax 5 | call DispStr ; 调用显示字符串例程 6 | jmp $ ; 无限循环 7 | DispStr: 8 | mov ax, BootMessage 9 | mov bp, ax ; ES:BP = 串地址 10 | mov cx, 16 ; CX = 串长度 11 | mov ax, 01301h ; AH = 13, AL = 01h 12 | mov bx, 000ch ; 页号为0(BH = 0) 黑底红字(BL = 0Ch,高亮) 13 | mov dl, 0 14 | int 10h ; 10h 号中断 15 | ret 16 | BootMessage: db "Hello, OS world!" 17 | times 510-($-$$) db 0 ; 填充剩下的空间,使生成的二进制代码恰好为512字节 18 | dw 0xaa55 ; 结束标志 19 | -------------------------------------------------------------------------------- /chapter2/win/run.bat: -------------------------------------------------------------------------------- 1 | cd "d:\Program Files\Bochs-2.1.1\OrangeS" 2 | ..\bochs -q -f bochsrc.bxrc 3 | -------------------------------------------------------------------------------- /chapter3/a/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter3/a/a.img -------------------------------------------------------------------------------- /chapter3/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 | # choose the boot disk. 16 | boot: floppy 17 | 18 | # where do we send log messages? 19 | log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter3/b/Makefile: -------------------------------------------------------------------------------- 1 | ################################################## 2 | # Makefile of pmtestx.asm (x=[1,2,3...]) 3 | ################################################## 4 | 5 | SRC:=pmtest2.asm 6 | BIN:=$(subst .asm,.com,$(SRC)) 7 | 8 | .PHONY : everything 9 | 10 | everything : $(BIN) 11 | sudo mount -o loop pm.img /mnt/floppy/ 12 | sudo cp $(BIN) /mnt/floppy/ -v 13 | sudo umount /mnt/floppy/ 14 | 15 | $(BIN) : $(SRC) 16 | nasm $< -o $@ 17 | 18 | -------------------------------------------------------------------------------- /chapter3/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=freedos.img, status=inserted 14 | floppyb: 1_44=pm.img, status=inserted 15 | 16 | # choose the boot disk. 17 | boot: a 18 | 19 | # where do we send log messages? 20 | # log: bochsout.txt 21 | 22 | # disable the mouse 23 | mouse: enabled=0 24 | 25 | # enable key mapping, using US layout as default. 26 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 27 | -------------------------------------------------------------------------------- /chapter3/b/freedos.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter3/b/freedos.img -------------------------------------------------------------------------------- /chapter3/b/pm.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter3/b/pm.img -------------------------------------------------------------------------------- /chapter3/c/Makefile: -------------------------------------------------------------------------------- 1 | ################################################## 2 | # Makefile of pmtestx.asm (x=[1,2,3...]) 3 | ################################################## 4 | 5 | SRC:=pmtest3.asm 6 | BIN:=$(subst .asm,.com,$(SRC)) 7 | 8 | .PHONY : everything 9 | 10 | everything : $(BIN) 11 | sudo mount -o loop pm.img /mnt/floppy/ 12 | sudo cp $(BIN) /mnt/floppy/ -v 13 | sudo umount /mnt/floppy/ 14 | 15 | $(BIN) : $(SRC) 16 | nasm $< -o $@ 17 | 18 | -------------------------------------------------------------------------------- /chapter3/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=freedos.img, status=inserted 14 | floppyb: 1_44=pm.img, status=inserted 15 | 16 | # choose the boot disk. 17 | boot: a 18 | 19 | # where do we send log messages? 20 | # log: bochsout.txt 21 | 22 | # disable the mouse 23 | mouse: enabled=0 24 | 25 | # enable key mapping, using US layout as default. 26 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 27 | -------------------------------------------------------------------------------- /chapter3/c/freedos.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter3/c/freedos.img -------------------------------------------------------------------------------- /chapter3/c/pm.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter3/c/pm.img -------------------------------------------------------------------------------- /chapter3/d/Makefile: -------------------------------------------------------------------------------- 1 | ################################################## 2 | # Makefile of pmtestx.asm (x=[1,2,3...]) 3 | ################################################## 4 | 5 | SRC:=pmtest4.asm 6 | BIN:=$(subst .asm,.com,$(SRC)) 7 | 8 | .PHONY : everything 9 | 10 | everything : $(BIN) 11 | sudo mount -o loop pm.img /mnt/floppy/ 12 | sudo cp $(BIN) /mnt/floppy/ -v 13 | sudo umount /mnt/floppy/ 14 | 15 | $(BIN) : $(SRC) 16 | nasm $< -o $@ 17 | 18 | -------------------------------------------------------------------------------- /chapter3/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=freedos.img, status=inserted 14 | floppyb: 1_44=pm.img, status=inserted 15 | 16 | # choose the boot disk. 17 | boot: a 18 | 19 | # where do we send log messages? 20 | # log: bochsout.txt 21 | 22 | # disable the mouse 23 | mouse: enabled=0 24 | 25 | # enable key mapping, using US layout as default. 26 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 27 | -------------------------------------------------------------------------------- /chapter3/d/freedos.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter3/d/freedos.img -------------------------------------------------------------------------------- /chapter3/d/pm.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter3/d/pm.img -------------------------------------------------------------------------------- /chapter3/e/Makefile: -------------------------------------------------------------------------------- 1 | ################################################## 2 | # Makefile of pmtestx.asm (x=[1,2,3...]) 3 | ################################################## 4 | 5 | SRC:=pmtest5.asm 6 | BIN:=$(subst .asm,.com,$(SRC)) 7 | 8 | .PHONY : everything 9 | 10 | everything : $(BIN) 11 | sudo mount -o loop pm.img /mnt/floppy/ 12 | sudo cp $(BIN) /mnt/floppy/ -v 13 | sudo umount /mnt/floppy/ 14 | 15 | $(BIN) : $(SRC) 16 | nasm $< -o $@ 17 | 18 | -------------------------------------------------------------------------------- /chapter3/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=freedos.img, status=inserted 14 | floppyb: 1_44=pm.img, status=inserted 15 | 16 | # choose the boot disk. 17 | boot: a 18 | 19 | # where do we send log messages? 20 | # log: bochsout.txt 21 | 22 | # disable the mouse 23 | mouse: enabled=0 24 | 25 | # enable key mapping, using US layout as default. 26 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 27 | -------------------------------------------------------------------------------- /chapter3/e/freedos.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter3/e/freedos.img -------------------------------------------------------------------------------- /chapter3/e/pm.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter3/e/pm.img -------------------------------------------------------------------------------- /chapter3/f/Makefile: -------------------------------------------------------------------------------- 1 | ################################################## 2 | # Makefile of pmtestx.asm (x=[1,2,3...]) 3 | ################################################## 4 | 5 | SRC:=pmtest6.asm 6 | BIN:=$(subst .asm,.com,$(SRC)) 7 | 8 | .PHONY : everything 9 | 10 | everything : $(BIN) 11 | sudo mount -o loop pm.img /mnt/floppy/ 12 | sudo cp $(BIN) /mnt/floppy/ -v 13 | sudo umount /mnt/floppy/ 14 | 15 | $(BIN) : $(SRC) 16 | nasm $< -o $@ 17 | 18 | -------------------------------------------------------------------------------- /chapter3/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=freedos.img, status=inserted 14 | floppyb: 1_44=pm.img, status=inserted 15 | 16 | # choose the boot disk. 17 | boot: a 18 | 19 | # where do we send log messages? 20 | # log: bochsout.txt 21 | 22 | # disable the mouse 23 | mouse: enabled=0 24 | 25 | # enable key mapping, using US layout as default. 26 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 27 | -------------------------------------------------------------------------------- /chapter3/f/freedos.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter3/f/freedos.img -------------------------------------------------------------------------------- /chapter3/f/pm.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter3/f/pm.img -------------------------------------------------------------------------------- /chapter3/g/Makefile: -------------------------------------------------------------------------------- 1 | ################################################## 2 | # Makefile of pmtestx.asm (x=[1,2,3...]) 3 | ################################################## 4 | 5 | SRC:=pmtest7.asm 6 | BIN:=$(subst .asm,.com,$(SRC)) 7 | 8 | .PHONY : everything 9 | 10 | everything : $(BIN) 11 | sudo mount -o loop pm.img /mnt/floppy/ 12 | sudo cp $(BIN) /mnt/floppy/ -v 13 | sudo umount /mnt/floppy/ 14 | 15 | $(BIN) : $(SRC) 16 | nasm $< -o $@ 17 | 18 | -------------------------------------------------------------------------------- /chapter3/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=freedos.img, status=inserted 14 | floppyb: 1_44=pm.img, status=inserted 15 | 16 | # choose the boot disk. 17 | boot: a 18 | 19 | # where do we send log messages? 20 | # log: bochsout.txt 21 | 22 | # disable the mouse 23 | mouse: enabled=0 24 | 25 | # enable key mapping, using US layout as default. 26 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 27 | -------------------------------------------------------------------------------- /chapter3/g/freedos.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter3/g/freedos.img -------------------------------------------------------------------------------- /chapter3/g/pm.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter3/g/pm.img -------------------------------------------------------------------------------- /chapter3/h/Makefile: -------------------------------------------------------------------------------- 1 | ################################################## 2 | # Makefile of pmtestx.asm (x=[1,2,3...]) 3 | ################################################## 4 | 5 | SRC:=pmtest8.asm 6 | BIN:=$(subst .asm,.com,$(SRC)) 7 | 8 | .PHONY : everything 9 | 10 | everything : $(BIN) 11 | sudo mount -o loop pm.img /mnt/floppy/ 12 | sudo cp $(BIN) /mnt/floppy/ -v 13 | sudo umount /mnt/floppy/ 14 | 15 | $(BIN) : $(SRC) 16 | nasm $< -o $@ 17 | 18 | -------------------------------------------------------------------------------- /chapter3/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=freedos.img, status=inserted 14 | floppyb: 1_44=pm.img, status=inserted 15 | 16 | # choose the boot disk. 17 | boot: a 18 | 19 | # where do we send log messages? 20 | # log: bochsout.txt 21 | 22 | # disable the mouse 23 | mouse: enabled=0 24 | 25 | # enable key mapping, using US layout as default. 26 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 27 | -------------------------------------------------------------------------------- /chapter3/h/freedos.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter3/h/freedos.img -------------------------------------------------------------------------------- /chapter3/h/pm.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter3/h/pm.img -------------------------------------------------------------------------------- /chapter3/i/Makefile: -------------------------------------------------------------------------------- 1 | ################################################## 2 | # Makefile of pmtestx.asm (x=[1,2,3...]) 3 | ################################################## 4 | 5 | SRC:=pmtest9.asm 6 | BIN:=$(subst .asm,.com,$(SRC)) 7 | 8 | .PHONY : everything 9 | 10 | everything : $(BIN) 11 | sudo mount -o loop pm.img /mnt/floppy/ 12 | sudo cp $(BIN) /mnt/floppy/ -v 13 | sudo umount /mnt/floppy/ 14 | 15 | $(BIN) : $(SRC) 16 | nasm $< -o $@ 17 | 18 | -------------------------------------------------------------------------------- /chapter3/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=freedos.img, status=inserted 14 | floppyb: 1_44=pm.img, status=inserted 15 | 16 | # choose the boot disk. 17 | boot: a 18 | 19 | # where do we send log messages? 20 | # log: bochsout.txt 21 | 22 | # disable the mouse 23 | mouse: enabled=0 24 | 25 | # enable key mapping, using US layout as default. 26 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 27 | -------------------------------------------------------------------------------- /chapter3/i/freedos.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter3/i/freedos.img -------------------------------------------------------------------------------- /chapter3/i/pm.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter3/i/pm.img -------------------------------------------------------------------------------- /chapter4/a/Makefile: -------------------------------------------------------------------------------- 1 | ################################################## 2 | # Makefile of pmtestx.asm (x=[1,2,3...]) 3 | ################################################## 4 | 5 | SRC:=boot.asm 6 | BIN:=$(subst .asm,.bin,$(SRC)) 7 | 8 | .PHONY : everything 9 | 10 | everything : $(BIN) 11 | dd if=$(BIN) of=a.img bs=512 count=1 conv=notrunc 12 | 13 | $(BIN) : $(SRC) 14 | nasm $< -o $@ 15 | 16 | -------------------------------------------------------------------------------- /chapter4/a/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter4/a/a.img -------------------------------------------------------------------------------- /chapter4/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter4/b/Makefile: -------------------------------------------------------------------------------- 1 | ################################################## 2 | # Makefile 3 | ################################################## 4 | 5 | BOOT:=boot.asm 6 | LDR:=loader.asm 7 | BOOT_BIN:=$(subst .asm,.bin,$(BOOT)) 8 | LDR_BIN:=$(subst .asm,.bin,$(LDR)) 9 | 10 | .PHONY : everything 11 | 12 | everything : $(BOOT_BIN) $(LDR_BIN) 13 | dd if=$(BOOT_BIN) of=a.img bs=512 count=1 conv=notrunc 14 | sudo mount -o loop a.img /mnt/floppy/ 15 | sudo cp $(LDR_BIN) /mnt/floppy/ -v 16 | sudo umount /mnt/floppy/ 17 | 18 | clean : 19 | rm -f $(BOOT_BIN) $(LDR_BIN) 20 | 21 | $(BOOT_BIN) : $(BOOT) 22 | nasm $< -o $@ 23 | 24 | $(LDR_BIN) : $(LDR) 25 | nasm $< -o $@ 26 | 27 | -------------------------------------------------------------------------------- /chapter4/b/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter4/b/a.img -------------------------------------------------------------------------------- /chapter4/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter4/b/loader.asm: -------------------------------------------------------------------------------- 1 | org 0100h 2 | 3 | mov ax, 0B800h 4 | mov gs, ax 5 | mov ah, 0Fh ; 0000: 黑底 1111: 白字 6 | mov al, 'L' 7 | mov [gs:((80 * 0 + 39) * 2)], ax ; 屏幕第 0 行, 第 39 列。 8 | 9 | jmp $ ; 到此停住 10 | -------------------------------------------------------------------------------- /chapter4/c/Makefile: -------------------------------------------------------------------------------- 1 | ################################################## 2 | # Makefile 3 | ################################################## 4 | 5 | BOOT:=boot.asm 6 | LDR:=loader.asm 7 | BOOT_BIN:=$(subst .asm,.bin,$(BOOT)) 8 | LDR_BIN:=$(subst .asm,.bin,$(LDR)) 9 | 10 | IMG:=a.img 11 | FLOPPY:=/mnt/floppy/ 12 | 13 | .PHONY : everything 14 | 15 | everything : $(BOOT_BIN) $(LDR_BIN) 16 | dd if=$(BOOT_BIN) of=$(IMG) bs=512 count=1 conv=notrunc 17 | sudo mount -o loop $(IMG) $(FLOPPY) 18 | sudo cp $(LDR_BIN) $(FLOPPY) -v 19 | sudo umount $(FLOPPY) 20 | 21 | clean : 22 | rm -f $(BOOT_BIN) $(LDR_BIN) 23 | 24 | $(BOOT_BIN) : $(BOOT) 25 | nasm $< -o $@ 26 | 27 | $(LDR_BIN) : $(LDR) 28 | nasm $< -o $@ 29 | 30 | -------------------------------------------------------------------------------- /chapter4/c/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter4/c/a.img -------------------------------------------------------------------------------- /chapter4/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter4/c/loader.asm: -------------------------------------------------------------------------------- 1 | 2 | org 0100h 3 | 4 | mov ax, 0B800h 5 | mov gs, ax 6 | mov ah, 0Fh ; 0000: 黑底 1111: 白字 7 | mov al, 'L' 8 | mov [gs:((80 * 0 + 39) * 2)], ax ; 屏幕第 0 行, 第 39 列。 9 | 10 | jmp $ ; Start 11 | -------------------------------------------------------------------------------- /chapter5/a/hello.asm: -------------------------------------------------------------------------------- 1 | ; 编译链接方法 2 | ; (ld 的‘-s’选项意为“strip all”) 3 | ; 4 | ; $ nasm -f elf hello.asm -o hello.o 5 | ; $ ld -s hello.o -o hello 6 | ; $ ./hello 7 | ; Hello, world! 8 | ; $ 9 | 10 | [section .data] ; 数据在此 11 | 12 | strHello db "Hello, world!", 0Ah 13 | STRLEN equ $ - strHello 14 | 15 | [section .text] ; 代码在此 16 | 17 | global _start ; 我们必须导出 _start 这个入口,以便让链接器识别 18 | 19 | _start: 20 | mov edx, STRLEN 21 | mov ecx, strHello 22 | mov ebx, 1 23 | mov eax, 4 ; sys_write 24 | int 0x80 ; 系统调用 25 | mov ebx, 0 26 | mov eax, 1 ; sys_exit 27 | int 0x80 ; 系统调用 28 | -------------------------------------------------------------------------------- /chapter5/b/Makefile: -------------------------------------------------------------------------------- 1 | ####################### 2 | # Makefile for foobar # 3 | ####################### 4 | 5 | # Programs, flags, etc. 6 | ASM = nasm 7 | CC = gcc 8 | LD = ld 9 | ASMFLAGS = -f elf 10 | CFLAGS = -c 11 | LDFLAGS = -s 12 | 13 | # This Program 14 | BIN = foobar 15 | OBJS = foo.o bar.o 16 | 17 | # All Phony Targets 18 | .PHONY : everything final image clean realclean disasm all buildimg 19 | 20 | # Default starting position 21 | everything : $(BIN) 22 | 23 | all : realclean everything 24 | 25 | final : all clean 26 | 27 | clean : 28 | rm -f $(OBJS) 29 | 30 | realclean : 31 | rm -f $(OBJS) $(BIN) 32 | 33 | $(BIN) : $(OBJS) 34 | $(LD) $(LDFLAGS) -o $(BIN) $(OBJS) 35 | 36 | foo.o : foo.asm 37 | $(ASM) $(ASMFLAGS) -o $@ $< 38 | 39 | bar.o: bar.c 40 | $(CC) $(CFLAGS) -o $@ $< 41 | -------------------------------------------------------------------------------- /chapter5/b/bar.c: -------------------------------------------------------------------------------- 1 | void myprint(char* msg, int len); 2 | 3 | int choose(int a, int b) 4 | { 5 | if(a >= b){ 6 | myprint("the 1st one\n", 13); 7 | } 8 | else{ 9 | myprint("the 2nd one\n", 13); 10 | } 11 | 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /chapter5/c/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter5/c/a.img -------------------------------------------------------------------------------- /chapter5/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter5/c/kernel.asm: -------------------------------------------------------------------------------- 1 | ; 编译链接方法 2 | ; $ nasm -f elf kernel.asm -o kernel.o 3 | ; $ ld -s kernel.o -o kernel.bin #‘-s’选项意为“strip all” 4 | 5 | [section .text] ; 代码在此 6 | 7 | global _start ; 导出 _start 8 | 9 | _start: ; 跳到这里来的时候,我们假设 gs 指向显存 10 | mov ah, 0Fh ; 0000: 黑底 1111: 白字 11 | mov al, 'K' 12 | mov [gs:((80 * 1 + 39) * 2)], ax ; 屏幕第 1 行, 第 39 列。 13 | jmp $ 14 | -------------------------------------------------------------------------------- /chapter5/d/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter5/d/a.img -------------------------------------------------------------------------------- /chapter5/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter5/d/kernel.asm: -------------------------------------------------------------------------------- 1 | 2 | ; 编译链接方法 3 | ; (ld 的‘-s’选项意为“strip all”) 4 | ; 5 | ; [root@XXX XXX]# nasm -f elf kernel.asm -o kernel.o 6 | ; [root@XXX XXX]# ld -s kernel.o -o kernel.bin 7 | ; [root@XXX XXX]# 8 | 9 | [section .text] ; 代码在此 10 | 11 | global _start ; 导出 _start 12 | 13 | _start: ; 跳到这里来的时候,我们假设 gs 指向显存 14 | mov ah, 0Fh ; 0000: 黑底 1111: 白字 15 | mov al, 'K' 16 | mov [gs:((80 * 1 + 39) * 2)], ax ; 屏幕第 1 行, 第 39 列。 17 | jmp $ 18 | -------------------------------------------------------------------------------- /chapter5/d/load.inc: -------------------------------------------------------------------------------- 1 | BaseOfLoader equ 09000h ; LOADER.BIN 被加载到的位置 ---- 段地址 2 | OffsetOfLoader equ 0100h ; LOADER.BIN 被加载到的位置 ---- 偏移地址 3 | 4 | BaseOfLoaderPhyAddr equ BaseOfLoader*10h ; LOADER.BIN 被加载到的位置 ---- 物理地址 5 | 6 | BaseOfKernelFile equ 08000h ; KERNEL.BIN 被加载到的位置 ---- 段地址 7 | OffsetOfKernelFile equ 0h ; KERNEL.BIN 被加载到的位置 ---- 偏移地址 8 | -------------------------------------------------------------------------------- /chapter5/e/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter5/e/a.img -------------------------------------------------------------------------------- /chapter5/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter5/e/kernel.asm: -------------------------------------------------------------------------------- 1 | 2 | ; 编译链接方法 3 | ; [root@XXX XXX]# nasm -f elf kernel.asm -o kernel.o 4 | ; [root@XXX XXX]# ld -s -Ttext 0x30400 -o kernel.bin kernel.o 5 | ; [root@XXX XXX]# 6 | 7 | [section .text] ; 代码在此 8 | 9 | global _start ; 导出 _start 10 | 11 | _start: ; 跳到这里来的时候,我们假设 gs 指向显存 12 | mov ah, 0Fh ; 0000: 黑底 1111: 白字 13 | mov al, 'K' 14 | mov [gs:((80 * 1 + 39) * 2)], ax ; 屏幕第 1 行, 第 39 列。 15 | jmp $ 16 | -------------------------------------------------------------------------------- /chapter5/e/load.inc: -------------------------------------------------------------------------------- 1 | 2 | 3 | BaseOfLoader equ 09000h ; LOADER.BIN 被加载到的位置 ---- 段地址 4 | OffsetOfLoader equ 0100h ; LOADER.BIN 被加载到的位置 ---- 偏移地址 5 | 6 | BaseOfLoaderPhyAddr equ BaseOfLoader * 10h ; LOADER.BIN 被加载到的位置 ---- 物理地址 (= BaseOfLoader * 10h) 7 | 8 | 9 | BaseOfKernelFile equ 08000h ; KERNEL.BIN 被加载到的位置 ---- 段地址 10 | OffsetOfKernelFile equ 0h ; KERNEL.BIN 被加载到的位置 ---- 偏移地址 11 | 12 | BaseOfKernelFilePhyAddr equ BaseOfKernelFile * 10h 13 | KernelEntryPointPhyAddr equ 030400h ; 注意:1、必须与 MAKEFILE 中参数 -Ttext 的值相等!! 14 | ; 2、这是个地址而非仅仅是个偏移,如果 -Ttext 的值为 0x400400,则它的值也应该是 0x400400。 15 | 16 | PageDirBase equ 200000h ; 页目录开始地址: 2M 17 | PageTblBase equ 201000h ; 页表开始地址: 2M + 4K 18 | 19 | -------------------------------------------------------------------------------- /chapter5/f/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter5/f/a.img -------------------------------------------------------------------------------- /chapter5/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter5/f/const.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | const.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_CONST_H_ 9 | #define _ORANGES_CONST_H_ 10 | 11 | 12 | /* 函数类型 */ 13 | #define PUBLIC /* PUBLIC is the opposite of PRIVATE */ 14 | #define PRIVATE static /* PRIVATE x limits the scope of x */ 15 | 16 | /* GDT 和 IDT 中描述符的个数 */ 17 | #define GDT_SIZE 128 18 | 19 | 20 | #endif /* _ORANGES_CONST_H_ */ 21 | -------------------------------------------------------------------------------- /chapter5/f/protect.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | protect.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_PROTECT_H_ 9 | #define _ORANGES_PROTECT_H_ 10 | 11 | /* 存储段描述符/系统段描述符 */ 12 | typedef struct s_descriptor /* 共 8 个字节 */ 13 | { 14 | u16 limit_low; /* Limit */ 15 | u16 base_low; /* Base */ 16 | u8 base_mid; /* Base */ 17 | u8 attr1; /* P(1) DPL(2) DT(1) TYPE(4) */ 18 | u8 limit_high_attr2; /* G(1) D(1) 0(1) AVL(1) LimitHigh(4) */ 19 | u8 base_high; /* Base */ 20 | }DESCRIPTOR; 21 | 22 | #endif /* _ORANGES_PROTECT_H_ */ 23 | -------------------------------------------------------------------------------- /chapter5/f/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 | typedef unsigned int u32; 12 | typedef unsigned short u16; 13 | typedef unsigned char u8; 14 | 15 | #endif /* _ORANGES_TYPE_H_ */ 16 | -------------------------------------------------------------------------------- /chapter5/g/Makefile.boot: -------------------------------------------------------------------------------- 1 | # Makefile for boot 2 | 3 | # Programs, flags, etc. 4 | ASM = nasm 5 | ASMFLAGS = -I boot/include/ 6 | 7 | # This Program 8 | ORANGESBOOT = boot/boot.bin boot/loader.bin 9 | 10 | # All Phony Targets 11 | .PHONY : everything clean all 12 | 13 | # Default starting position 14 | everything : $(ORANGESBOOT) 15 | 16 | clean : 17 | rm -f $(ORANGESBOOT) 18 | 19 | all : clean everything 20 | 21 | boot/boot.bin : boot/boot.asm boot/include/load.inc boot/include/fat12hdr.inc 22 | $(ASM) $(ASMFLAGS) -o $@ $< 23 | 24 | boot/loader.bin : boot/loader.asm boot/include/load.inc \ 25 | boot/include/fat12hdr.inc boot/include/pm.inc 26 | $(ASM) $(ASMFLAGS) -o $@ $< 27 | 28 | -------------------------------------------------------------------------------- /chapter5/g/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter5/g/a.img -------------------------------------------------------------------------------- /chapter5/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter5/g/boot/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for boot 2 | 3 | # Programs, flags, etc. 4 | ASM = nasm 5 | ASMFLAGS = -I include/ 6 | 7 | # This Program 8 | TARGET = boot.bin loader.bin 9 | 10 | # All Phony Targets 11 | .PHONY : everything clean all 12 | 13 | # Default starting position 14 | everything : $(TARGET) 15 | 16 | clean : 17 | rm -f $(TARGET) 18 | 19 | all : clean everything 20 | 21 | boot.bin : boot.asm include/load.inc include/fat12hdr.inc 22 | $(ASM) $(ASMFLAGS) -o $@ $< 23 | 24 | loader.bin : loader.asm include/load.inc include/fat12hdr.inc include/pm.inc 25 | $(ASM) $(ASMFLAGS) -o $@ $< 26 | 27 | -------------------------------------------------------------------------------- /chapter5/g/include/const.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | const.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_CONST_H_ 9 | #define _ORANGES_CONST_H_ 10 | 11 | 12 | /* 函数类型 */ 13 | #define PUBLIC /* PUBLIC is the opposite of PRIVATE */ 14 | #define PRIVATE static /* PRIVATE x limits the scope of x */ 15 | 16 | /* GDT 和 IDT 中描述符的个数 */ 17 | #define GDT_SIZE 128 18 | 19 | 20 | #endif /* _ORANGES_CONST_H_ */ 21 | -------------------------------------------------------------------------------- /chapter5/g/include/protect.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | protect.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #ifndef _ORANGES_PROTECT_H_ 9 | #define _ORANGES_PROTECT_H_ 10 | 11 | 12 | /* 存储段描述符/系统段描述符 */ 13 | typedef struct s_descriptor /* 共 8 个字节 */ 14 | { 15 | u16 limit_low; /* Limit */ 16 | u16 base_low; /* Base */ 17 | u8 base_mid; /* Base */ 18 | u8 attr1; /* P(1) DPL(2) DT(1) TYPE(4) */ 19 | u8 limit_high_attr2; /* G(1) D(1) 0(1) AVL(1) LimitHigh(4) */ 20 | u8 base_high; /* Base */ 21 | }DESCRIPTOR; 22 | 23 | 24 | 25 | #endif /* _ORANGES_PROTECT_H_ */ 26 | -------------------------------------------------------------------------------- /chapter5/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 | 12 | typedef unsigned int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | #endif /* _ORANGES_TYPE_H_ */ 18 | -------------------------------------------------------------------------------- /chapter5/h/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter5/h/a.img -------------------------------------------------------------------------------- /chapter5/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter5/h/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 disp_pos; 15 | EXTERN u8 gdt_ptr[6]; /* 0~15:Limit 16~47:Base */ 16 | EXTERN DESCRIPTOR gdt[GDT_SIZE]; 17 | EXTERN u8 idt_ptr[6]; /* 0~15:Limit 16~47:Base */ 18 | EXTERN GATE idt[IDT_SIZE]; 19 | -------------------------------------------------------------------------------- /chapter5/h/include/proto.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | proto.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | /* klib.asm */ 9 | PUBLIC void out_byte(u16 port, u8 value); 10 | PUBLIC u8 in_byte(u16 port); 11 | PUBLIC void disp_str(char * info); 12 | PUBLIC void disp_color_str(char * info, int color); 13 | PUBLIC void init_prot(); 14 | PUBLIC void init_8259A(); 15 | 16 | -------------------------------------------------------------------------------- /chapter5/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 | 10 | -------------------------------------------------------------------------------- /chapter5/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 | 12 | typedef unsigned int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | typedef void (*int_handler) (); 17 | 18 | 19 | #endif /* _ORANGES_TYPE_H_ */ 20 | -------------------------------------------------------------------------------- /chapter5/h/kernel/global.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | global.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #define GLOBAL_VARIABLES_HERE 9 | 10 | #include "type.h" 11 | #include "const.h" 12 | #include "protect.h" 13 | #include "proto.h" 14 | #include "global.h" 15 | 16 | -------------------------------------------------------------------------------- /chapter5/i/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter5/i/a.img -------------------------------------------------------------------------------- /chapter5/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter5/i/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 disp_pos; 15 | EXTERN u8 gdt_ptr[6]; /* 0~15:Limit 16~47:Base */ 16 | EXTERN DESCRIPTOR gdt[GDT_SIZE]; 17 | EXTERN u8 idt_ptr[6]; /* 0~15:Limit 16~47:Base */ 18 | EXTERN GATE idt[IDT_SIZE]; 19 | -------------------------------------------------------------------------------- /chapter5/i/include/proto.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | proto.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | /* klib.asm */ 9 | PUBLIC void out_byte(u16 port, u8 value); 10 | PUBLIC u8 in_byte(u16 port); 11 | PUBLIC void disp_str(char * info); 12 | PUBLIC void disp_color_str(char * info, int color); 13 | PUBLIC void init_prot(); 14 | PUBLIC void init_8259A(); 15 | 16 | -------------------------------------------------------------------------------- /chapter5/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 | 10 | -------------------------------------------------------------------------------- /chapter5/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 | 12 | typedef unsigned int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | typedef void (*int_handler) (); 17 | 18 | 19 | #endif /* _ORANGES_TYPE_H_ */ 20 | -------------------------------------------------------------------------------- /chapter5/i/kernel/global.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | global.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #define GLOBAL_VARIABLES_HERE 9 | 10 | #include "type.h" 11 | #include "const.h" 12 | #include "protect.h" 13 | #include "proto.h" 14 | #include "global.h" 15 | 16 | -------------------------------------------------------------------------------- /chapter6/a/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter6/a/a.img -------------------------------------------------------------------------------- /chapter6/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter6/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 disp_pos; 15 | EXTERN u8 gdt_ptr[6]; // 0~15:Limit 16~47:Base 16 | EXTERN DESCRIPTOR gdt[GDT_SIZE]; 17 | EXTERN u8 idt_ptr[6]; // 0~15:Limit 16~47:Base 18 | EXTERN GATE idt[IDT_SIZE]; 19 | 20 | EXTERN TSS tss; 21 | EXTERN PROCESS* p_proc_ready; 22 | 23 | extern PROCESS proc_table[]; 24 | extern char task_stack[]; 25 | -------------------------------------------------------------------------------- /chapter6/a/include/proto.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | proto.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | /* klib.asm */ 9 | PUBLIC void out_byte(u16 port, u8 value); 10 | PUBLIC u8 in_byte(u16 port); 11 | PUBLIC void disp_str(char * info); 12 | PUBLIC void disp_color_str(char * info, int color); 13 | 14 | /* protect.c */ 15 | PUBLIC void init_prot(); 16 | PUBLIC u32 seg2phys(u16 seg); 17 | 18 | /* klib.c */ 19 | PUBLIC void delay(int time); 20 | 21 | /* kernel.asm */ 22 | void restart(); 23 | 24 | /* main.c */ 25 | void TestA(); 26 | -------------------------------------------------------------------------------- /chapter6/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 | -------------------------------------------------------------------------------- /chapter6/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 int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | 19 | 20 | #endif /* _ORANGES_TYPE_H_ */ 21 | -------------------------------------------------------------------------------- /chapter6/a/kernel/global.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | global.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #define GLOBAL_VARIABLES_HERE 9 | 10 | #include "type.h" 11 | #include "const.h" 12 | #include "protect.h" 13 | #include "proto.h" 14 | #include "proc.h" 15 | #include "global.h" 16 | 17 | 18 | PUBLIC PROCESS proc_table[NR_TASKS]; 19 | 20 | PUBLIC char task_stack[STACK_SIZE_TOTAL]; 21 | 22 | -------------------------------------------------------------------------------- /chapter6/b/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter6/b/a.img -------------------------------------------------------------------------------- /chapter6/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter6/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 disp_pos; 15 | EXTERN u8 gdt_ptr[6]; // 0~15:Limit 16~47:Base 16 | EXTERN DESCRIPTOR gdt[GDT_SIZE]; 17 | EXTERN u8 idt_ptr[6]; // 0~15:Limit 16~47:Base 18 | EXTERN GATE idt[IDT_SIZE]; 19 | 20 | EXTERN TSS tss; 21 | EXTERN PROCESS* p_proc_ready; 22 | 23 | extern PROCESS proc_table[]; 24 | extern char task_stack[]; 25 | -------------------------------------------------------------------------------- /chapter6/b/include/proto.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | proto.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | /* klib.asm */ 9 | PUBLIC void out_byte(u16 port, u8 value); 10 | PUBLIC u8 in_byte(u16 port); 11 | PUBLIC void disp_str(char * info); 12 | PUBLIC void disp_color_str(char * info, int color); 13 | 14 | /* protect.c */ 15 | PUBLIC void init_prot(); 16 | PUBLIC u32 seg2phys(u16 seg); 17 | 18 | /* klib.c */ 19 | PUBLIC void delay(int time); 20 | 21 | /* kernel.asm */ 22 | void restart(); 23 | 24 | /* main.c */ 25 | void TestA(); 26 | -------------------------------------------------------------------------------- /chapter6/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 | -------------------------------------------------------------------------------- /chapter6/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 int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | 19 | 20 | #endif /* _ORANGES_TYPE_H_ */ 21 | -------------------------------------------------------------------------------- /chapter6/b/kernel/global.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | global.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #define GLOBAL_VARIABLES_HERE 9 | 10 | #include "type.h" 11 | #include "const.h" 12 | #include "protect.h" 13 | #include "proto.h" 14 | #include "proc.h" 15 | #include "global.h" 16 | 17 | 18 | PUBLIC PROCESS proc_table[NR_TASKS]; 19 | 20 | PUBLIC char task_stack[STACK_SIZE_TOTAL]; 21 | 22 | -------------------------------------------------------------------------------- /chapter6/c/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter6/c/a.img -------------------------------------------------------------------------------- /chapter6/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter6/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 disp_pos; 15 | EXTERN u8 gdt_ptr[6]; // 0~15:Limit 16~47:Base 16 | EXTERN DESCRIPTOR gdt[GDT_SIZE]; 17 | EXTERN u8 idt_ptr[6]; // 0~15:Limit 16~47:Base 18 | EXTERN GATE idt[IDT_SIZE]; 19 | 20 | EXTERN u32 k_reenter; 21 | 22 | EXTERN TSS tss; 23 | EXTERN PROCESS* p_proc_ready; 24 | 25 | extern PROCESS proc_table[]; 26 | extern char task_stack[]; 27 | -------------------------------------------------------------------------------- /chapter6/c/include/proto.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | proto.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | /* klib.asm */ 9 | PUBLIC void out_byte(u16 port, u8 value); 10 | PUBLIC u8 in_byte(u16 port); 11 | PUBLIC void disp_str(char * info); 12 | PUBLIC void disp_color_str(char * info, int color); 13 | 14 | /* protect.c */ 15 | PUBLIC void init_prot(); 16 | PUBLIC u32 seg2phys(u16 seg); 17 | 18 | /* klib.c */ 19 | PUBLIC void delay(int time); 20 | 21 | /* kernel.asm */ 22 | void restart(); 23 | 24 | /* main.c */ 25 | void TestA(); 26 | -------------------------------------------------------------------------------- /chapter6/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 | -------------------------------------------------------------------------------- /chapter6/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 int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | 19 | 20 | #endif /* _ORANGES_TYPE_H_ */ 21 | -------------------------------------------------------------------------------- /chapter6/c/kernel/global.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | global.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #define GLOBAL_VARIABLES_HERE 9 | 10 | #include "type.h" 11 | #include "const.h" 12 | #include "protect.h" 13 | #include "proto.h" 14 | #include "proc.h" 15 | #include "global.h" 16 | 17 | 18 | PUBLIC PROCESS proc_table[NR_TASKS]; 19 | 20 | PUBLIC char task_stack[STACK_SIZE_TOTAL]; 21 | 22 | -------------------------------------------------------------------------------- /chapter6/d/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter6/d/a.img -------------------------------------------------------------------------------- /chapter6/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter6/d/include/proto.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | proto.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | /* klib.asm */ 9 | PUBLIC void out_byte(u16 port, u8 value); 10 | PUBLIC u8 in_byte(u16 port); 11 | PUBLIC void disp_str(char * info); 12 | PUBLIC void disp_color_str(char * info, int color); 13 | 14 | /* protect.c */ 15 | PUBLIC void init_prot(); 16 | PUBLIC u32 seg2phys(u16 seg); 17 | 18 | /* klib.c */ 19 | PUBLIC void delay(int time); 20 | 21 | /* kernel.asm */ 22 | void restart(); 23 | 24 | /* main.c */ 25 | void TestA(); 26 | void TestB(); 27 | -------------------------------------------------------------------------------- /chapter6/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 | -------------------------------------------------------------------------------- /chapter6/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 int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | typedef void (*task_f) (); 19 | 20 | 21 | #endif /* _ORANGES_TYPE_H_ */ 22 | -------------------------------------------------------------------------------- /chapter6/d/kernel/clock.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | clock.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #include "type.h" 9 | #include "const.h" 10 | #include "protect.h" 11 | #include "proto.h" 12 | #include "string.h" 13 | #include "proc.h" 14 | #include "global.h" 15 | 16 | 17 | /*======================================================================* 18 | clock_handler 19 | *======================================================================*/ 20 | PUBLIC void clock_handler(int irq) 21 | { 22 | disp_str("#"); 23 | } 24 | -------------------------------------------------------------------------------- /chapter6/d/kernel/global.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | global.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #define GLOBAL_VARIABLES_HERE 9 | 10 | #include "type.h" 11 | #include "const.h" 12 | #include "protect.h" 13 | #include "proto.h" 14 | #include "proc.h" 15 | #include "global.h" 16 | 17 | 18 | PUBLIC PROCESS proc_table[NR_TASKS]; 19 | 20 | PUBLIC char task_stack[STACK_SIZE_TOTAL]; 21 | 22 | PUBLIC TASK task_table[NR_TASKS] = {{TestA, STACK_SIZE_TESTA, "TestA"}, 23 | {TestB, STACK_SIZE_TESTB, "TestB"}}; 24 | 25 | -------------------------------------------------------------------------------- /chapter6/e/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter6/e/a.img -------------------------------------------------------------------------------- /chapter6/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter6/e/include/proto.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | proto.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | /* klib.asm */ 9 | PUBLIC void out_byte(u16 port, u8 value); 10 | PUBLIC u8 in_byte(u16 port); 11 | PUBLIC void disp_str(char * info); 12 | PUBLIC void disp_color_str(char * info, int color); 13 | 14 | /* protect.c */ 15 | PUBLIC void init_prot(); 16 | PUBLIC u32 seg2phys(u16 seg); 17 | 18 | /* klib.c */ 19 | PUBLIC void delay(int time); 20 | 21 | /* kernel.asm */ 22 | void restart(); 23 | 24 | /* main.c */ 25 | void TestA(); 26 | void TestB(); 27 | -------------------------------------------------------------------------------- /chapter6/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 | -------------------------------------------------------------------------------- /chapter6/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 | 12 | typedef unsigned int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | typedef void (*task_f) (); 19 | 20 | 21 | #endif /* _ORANGES_TYPE_H_ */ 22 | -------------------------------------------------------------------------------- /chapter6/e/kernel/global.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | global.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #define GLOBAL_VARIABLES_HERE 9 | 10 | #include "type.h" 11 | #include "const.h" 12 | #include "protect.h" 13 | #include "proto.h" 14 | #include "proc.h" 15 | #include "global.h" 16 | 17 | 18 | PUBLIC PROCESS proc_table[NR_TASKS]; 19 | 20 | PUBLIC char task_stack[STACK_SIZE_TOTAL]; 21 | 22 | PUBLIC TASK task_table[NR_TASKS] = {{TestA, STACK_SIZE_TESTA, "TestA"}, 23 | {TestB, STACK_SIZE_TESTB, "TestB"}}; 24 | 25 | -------------------------------------------------------------------------------- /chapter6/f/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter6/f/a.img -------------------------------------------------------------------------------- /chapter6/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter6/f/include/proto.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | proto.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | /* klib.asm */ 9 | PUBLIC void out_byte(u16 port, u8 value); 10 | PUBLIC u8 in_byte(u16 port); 11 | PUBLIC void disp_str(char * info); 12 | PUBLIC void disp_color_str(char * info, int color); 13 | 14 | /* protect.c */ 15 | PUBLIC void init_prot(); 16 | PUBLIC u32 seg2phys(u16 seg); 17 | 18 | /* klib.c */ 19 | PUBLIC void delay(int time); 20 | 21 | /* kernel.asm */ 22 | void restart(); 23 | 24 | /* main.c */ 25 | void TestA(); 26 | void TestB(); 27 | void TestC(); 28 | -------------------------------------------------------------------------------- /chapter6/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 | -------------------------------------------------------------------------------- /chapter6/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 | 12 | typedef unsigned int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | typedef void (*task_f) (); 19 | 20 | 21 | #endif /* _ORANGES_TYPE_H_ */ 22 | -------------------------------------------------------------------------------- /chapter6/f/kernel/global.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | global.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #define GLOBAL_VARIABLES_HERE 9 | 10 | #include "type.h" 11 | #include "const.h" 12 | #include "protect.h" 13 | #include "proto.h" 14 | #include "proc.h" 15 | #include "global.h" 16 | 17 | 18 | PUBLIC PROCESS proc_table[NR_TASKS]; 19 | 20 | PUBLIC char task_stack[STACK_SIZE_TOTAL]; 21 | 22 | PUBLIC TASK task_table[NR_TASKS] = {{TestA, STACK_SIZE_TESTA, "TestA"}, 23 | {TestB, STACK_SIZE_TESTB, "TestB"}, 24 | {TestC, STACK_SIZE_TESTC, "TestC"}}; 25 | 26 | -------------------------------------------------------------------------------- /chapter6/g/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter6/g/a.img -------------------------------------------------------------------------------- /chapter6/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter6/g/include/proto.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | proto.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | /* klib.asm */ 9 | PUBLIC void out_byte(u16 port, u8 value); 10 | PUBLIC u8 in_byte(u16 port); 11 | PUBLIC void disp_str(char * info); 12 | PUBLIC void disp_color_str(char * info, int color); 13 | 14 | /* protect.c */ 15 | PUBLIC void init_prot(); 16 | PUBLIC u32 seg2phys(u16 seg); 17 | 18 | /* klib.c */ 19 | PUBLIC void delay(int time); 20 | 21 | /* kernel.asm */ 22 | void restart(); 23 | 24 | /* main.c */ 25 | void TestA(); 26 | void TestB(); 27 | void TestC(); 28 | -------------------------------------------------------------------------------- /chapter6/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 | -------------------------------------------------------------------------------- /chapter6/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 | 12 | typedef unsigned int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | typedef void (*task_f) (); 19 | 20 | 21 | #endif /* _ORANGES_TYPE_H_ */ 22 | -------------------------------------------------------------------------------- /chapter6/g/kernel/global.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | global.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #define GLOBAL_VARIABLES_HERE 9 | 10 | #include "type.h" 11 | #include "const.h" 12 | #include "protect.h" 13 | #include "proto.h" 14 | #include "proc.h" 15 | #include "global.h" 16 | 17 | 18 | PUBLIC PROCESS proc_table[NR_TASKS]; 19 | 20 | PUBLIC char task_stack[STACK_SIZE_TOTAL]; 21 | 22 | PUBLIC TASK task_table[NR_TASKS] = {{TestA, STACK_SIZE_TESTA, "TestA"}, 23 | {TestB, STACK_SIZE_TESTB, "TestB"}, 24 | {TestC, STACK_SIZE_TESTC, "TestC"}}; 25 | 26 | -------------------------------------------------------------------------------- /chapter6/h/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter6/h/a.img -------------------------------------------------------------------------------- /chapter6/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter6/h/include/proto.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | proto.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | /* klib.asm */ 9 | PUBLIC void out_byte(u16 port, u8 value); 10 | PUBLIC u8 in_byte(u16 port); 11 | PUBLIC void disp_str(char * info); 12 | PUBLIC void disp_color_str(char * info, int color); 13 | 14 | /* protect.c */ 15 | PUBLIC void init_prot(); 16 | PUBLIC u32 seg2phys(u16 seg); 17 | 18 | /* klib.c */ 19 | PUBLIC void delay(int time); 20 | 21 | /* kernel.asm */ 22 | void restart(); 23 | 24 | /* main.c */ 25 | void TestA(); 26 | void TestB(); 27 | void TestC(); 28 | -------------------------------------------------------------------------------- /chapter6/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 | -------------------------------------------------------------------------------- /chapter6/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 | 12 | typedef unsigned int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | typedef void (*task_f) (); 19 | 20 | 21 | #endif /* _ORANGES_TYPE_H_ */ 22 | -------------------------------------------------------------------------------- /chapter6/h/kernel/global.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | global.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #define GLOBAL_VARIABLES_HERE 9 | 10 | #include "type.h" 11 | #include "const.h" 12 | #include "protect.h" 13 | #include "proto.h" 14 | #include "proc.h" 15 | #include "global.h" 16 | 17 | 18 | PUBLIC PROCESS proc_table[NR_TASKS]; 19 | 20 | PUBLIC char task_stack[STACK_SIZE_TOTAL]; 21 | 22 | PUBLIC TASK task_table[NR_TASKS] = {{TestA, STACK_SIZE_TESTA, "TestA"}, 23 | {TestB, STACK_SIZE_TESTB, "TestB"}, 24 | {TestC, STACK_SIZE_TESTC, "TestC"}}; 25 | 26 | -------------------------------------------------------------------------------- /chapter6/i/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter6/i/a.img -------------------------------------------------------------------------------- /chapter6/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter6/i/include/proto.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | proto.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | /* klib.asm */ 9 | PUBLIC void out_byte(u16 port, u8 value); 10 | PUBLIC u8 in_byte(u16 port); 11 | PUBLIC void disp_str(char * info); 12 | PUBLIC void disp_color_str(char * info, int color); 13 | 14 | /* protect.c */ 15 | PUBLIC void init_prot(); 16 | PUBLIC u32 seg2phys(u16 seg); 17 | 18 | /* klib.c */ 19 | PUBLIC void delay(int time); 20 | 21 | /* kernel.asm */ 22 | void restart(); 23 | 24 | /* main.c */ 25 | void TestA(); 26 | void TestB(); 27 | void TestC(); 28 | -------------------------------------------------------------------------------- /chapter6/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 | -------------------------------------------------------------------------------- /chapter6/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 | 12 | typedef unsigned int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | typedef void (*task_f) (); 19 | 20 | 21 | #endif /* _ORANGES_TYPE_H_ */ 22 | -------------------------------------------------------------------------------- /chapter6/i/kernel/global.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | global.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #define GLOBAL_VARIABLES_HERE 9 | 10 | #include "type.h" 11 | #include "const.h" 12 | #include "protect.h" 13 | #include "proto.h" 14 | #include "proc.h" 15 | #include "global.h" 16 | 17 | 18 | PUBLIC PROCESS proc_table[NR_TASKS]; 19 | 20 | PUBLIC char task_stack[STACK_SIZE_TOTAL]; 21 | 22 | PUBLIC TASK task_table[NR_TASKS] = {{TestA, STACK_SIZE_TESTA, "TestA"}, 23 | {TestB, STACK_SIZE_TESTB, "TestB"}, 24 | {TestC, STACK_SIZE_TESTC, "TestC"}}; 25 | 26 | -------------------------------------------------------------------------------- /chapter6/j/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter6/j/a.img -------------------------------------------------------------------------------- /chapter6/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter6/j/include/proto.h: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | proto.h 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | /* klib.asm */ 9 | PUBLIC void out_byte(u16 port, u8 value); 10 | PUBLIC u8 in_byte(u16 port); 11 | PUBLIC void disp_str(char * info); 12 | PUBLIC void disp_color_str(char * info, int color); 13 | 14 | /* protect.c */ 15 | PUBLIC void init_prot(); 16 | PUBLIC u32 seg2phys(u16 seg); 17 | 18 | /* klib.c */ 19 | PUBLIC void delay(int time); 20 | 21 | /* kernel.asm */ 22 | void restart(); 23 | 24 | /* main.c */ 25 | void TestA(); 26 | void TestB(); 27 | void TestC(); 28 | -------------------------------------------------------------------------------- /chapter6/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 | -------------------------------------------------------------------------------- /chapter6/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 | 12 | typedef unsigned int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | typedef void (*task_f) (); 19 | 20 | 21 | #endif /* _ORANGES_TYPE_H_ */ 22 | -------------------------------------------------------------------------------- /chapter6/j/kernel/global.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | global.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #define GLOBAL_VARIABLES_HERE 9 | 10 | #include "type.h" 11 | #include "const.h" 12 | #include "protect.h" 13 | #include "proto.h" 14 | #include "proc.h" 15 | #include "global.h" 16 | 17 | 18 | PUBLIC PROCESS proc_table[NR_TASKS]; 19 | 20 | PUBLIC char task_stack[STACK_SIZE_TOTAL]; 21 | 22 | PUBLIC TASK task_table[NR_TASKS] = {{TestA, STACK_SIZE_TESTA, "TestA"}, 23 | {TestB, STACK_SIZE_TESTB, "TestB"}, 24 | {TestC, STACK_SIZE_TESTC, "TestC"}}; 25 | 26 | -------------------------------------------------------------------------------- /chapter6/k/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter6/k/a.img -------------------------------------------------------------------------------- /chapter6/k/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter6/k/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 | -------------------------------------------------------------------------------- /chapter6/k/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 int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | typedef void (*task_f) (); 19 | typedef void (*irq_handler) (int irq); 20 | 21 | 22 | #endif /* _ORANGES_TYPE_H_ */ 23 | -------------------------------------------------------------------------------- /chapter6/k/kernel/global.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | global.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #define GLOBAL_VARIABLES_HERE 9 | 10 | #include "type.h" 11 | #include "const.h" 12 | #include "protect.h" 13 | #include "proto.h" 14 | #include "proc.h" 15 | #include "global.h" 16 | 17 | 18 | PUBLIC PROCESS proc_table[NR_TASKS]; 19 | 20 | PUBLIC char task_stack[STACK_SIZE_TOTAL]; 21 | 22 | PUBLIC TASK task_table[NR_TASKS] = {{TestA, STACK_SIZE_TESTA, "TestA"}, 23 | {TestB, STACK_SIZE_TESTB, "TestB"}, 24 | {TestC, STACK_SIZE_TESTC, "TestC"}}; 25 | 26 | PUBLIC irq_handler irq_table[NR_IRQ]; 27 | -------------------------------------------------------------------------------- /chapter6/l/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter6/l/a.img -------------------------------------------------------------------------------- /chapter6/l/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter6/l/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 | -------------------------------------------------------------------------------- /chapter6/l/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 int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | typedef void (*task_f) (); 19 | typedef void (*irq_handler) (int irq); 20 | 21 | typedef void* system_call; 22 | 23 | 24 | #endif /* _ORANGES_TYPE_H_ */ 25 | -------------------------------------------------------------------------------- /chapter6/l/kernel/proc.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | proc.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #include "type.h" 9 | #include "const.h" 10 | #include "protect.h" 11 | #include "proto.h" 12 | #include "string.h" 13 | #include "proc.h" 14 | #include "global.h" 15 | 16 | 17 | /*======================================================================* 18 | sys_get_ticks 19 | *======================================================================*/ 20 | PUBLIC int sys_get_ticks() 21 | { 22 | disp_str("+"); 23 | return 0; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /chapter6/l/kernel/syscall.asm: -------------------------------------------------------------------------------- 1 | 2 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | ; syscall.asm 4 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | ; Forrest Yu, 2005 6 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | 8 | %include "sconst.inc" 9 | 10 | _NR_get_ticks equ 0 ; 要跟 global.c 中 sys_call_table 的定义相对应! 11 | INT_VECTOR_SYS_CALL equ 0x90 12 | 13 | global get_ticks ; 导出符号 14 | 15 | bits 32 16 | [section .text] 17 | 18 | get_ticks: 19 | mov eax, _NR_get_ticks 20 | int INT_VECTOR_SYS_CALL 21 | ret 22 | 23 | -------------------------------------------------------------------------------- /chapter6/m/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter6/m/a.img -------------------------------------------------------------------------------- /chapter6/m/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: /usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter6/m/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 | -------------------------------------------------------------------------------- /chapter6/m/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 int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | typedef void (*task_f) (); 19 | typedef void (*irq_handler) (int irq); 20 | 21 | typedef void* system_call; 22 | 23 | 24 | #endif /* _ORANGES_TYPE_H_ */ 25 | -------------------------------------------------------------------------------- /chapter6/m/kernel/proc.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | proc.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #include "type.h" 9 | #include "const.h" 10 | #include "protect.h" 11 | #include "proto.h" 12 | #include "string.h" 13 | #include "proc.h" 14 | #include "global.h" 15 | 16 | 17 | /*======================================================================* 18 | sys_get_ticks 19 | *======================================================================*/ 20 | PUBLIC int sys_get_ticks() 21 | { 22 | return ticks; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /chapter6/m/kernel/syscall.asm: -------------------------------------------------------------------------------- 1 | 2 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | ; syscall.asm 4 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | ; Forrest Yu, 2005 6 | ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | 8 | %include "sconst.inc" 9 | 10 | _NR_get_ticks equ 0 ; 要跟 global.c 中 sys_call_table 的定义相对应! 11 | INT_VECTOR_SYS_CALL equ 0x90 12 | 13 | ; 导出符号 14 | global get_ticks 15 | 16 | bits 32 17 | [section .text] 18 | 19 | ; ==================================================================== 20 | ; get_ticks 21 | ; ==================================================================== 22 | get_ticks: 23 | mov eax, _NR_get_ticks 24 | int INT_VECTOR_SYS_CALL 25 | ret 26 | 27 | -------------------------------------------------------------------------------- /chapter6/n/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter6/n/a.img -------------------------------------------------------------------------------- /chapter6/n/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 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter6/n/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 | -------------------------------------------------------------------------------- /chapter6/n/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 int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | typedef void (*task_f) (); 19 | typedef void (*irq_handler) (int irq); 20 | 21 | typedef void* system_call; 22 | 23 | 24 | #endif /* _ORANGES_TYPE_H_ */ 25 | -------------------------------------------------------------------------------- /chapter6/n/kernel/proc.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | proc.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #include "type.h" 9 | #include "const.h" 10 | #include "protect.h" 11 | #include "proto.h" 12 | #include "string.h" 13 | #include "proc.h" 14 | #include "global.h" 15 | 16 | 17 | /*======================================================================* 18 | sys_get_ticks 19 | *======================================================================*/ 20 | PUBLIC int sys_get_ticks() 21 | { 22 | return ticks; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /chapter6/o/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter6/o/a.img -------------------------------------------------------------------------------- /chapter6/o/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 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter6/o/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 | -------------------------------------------------------------------------------- /chapter6/o/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 int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | typedef void (*task_f) (); 19 | typedef void (*irq_handler) (int irq); 20 | 21 | typedef void* system_call; 22 | 23 | 24 | #endif /* _ORANGES_TYPE_H_ */ 25 | -------------------------------------------------------------------------------- /chapter6/o/kernel/proc.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | proc.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #include "type.h" 9 | #include "const.h" 10 | #include "protect.h" 11 | #include "proto.h" 12 | #include "string.h" 13 | #include "proc.h" 14 | #include "global.h" 15 | 16 | 17 | /*======================================================================* 18 | sys_get_ticks 19 | *======================================================================*/ 20 | PUBLIC int sys_get_ticks() 21 | { 22 | return ticks; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /chapter6/p/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter6/p/a.img -------------------------------------------------------------------------------- /chapter6/p/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 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter6/p/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 | -------------------------------------------------------------------------------- /chapter6/p/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 int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | typedef void (*task_f) (); 19 | typedef void (*irq_handler) (int irq); 20 | 21 | typedef void* system_call; 22 | 23 | 24 | #endif /* _ORANGES_TYPE_H_ */ 25 | -------------------------------------------------------------------------------- /chapter6/q/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter6/q/a.img -------------------------------------------------------------------------------- /chapter6/q/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 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter6/q/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 | -------------------------------------------------------------------------------- /chapter6/q/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 int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | typedef void (*task_f) (); 19 | typedef void (*irq_handler) (int irq); 20 | 21 | typedef void* system_call; 22 | 23 | 24 | #endif /* _ORANGES_TYPE_H_ */ 25 | -------------------------------------------------------------------------------- /chapter6/r/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter6/r/a.img -------------------------------------------------------------------------------- /chapter6/r/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 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter6/r/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 | -------------------------------------------------------------------------------- /chapter6/r/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 int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | typedef void (*task_f) (); 19 | typedef void (*irq_handler) (int irq); 20 | 21 | typedef void* system_call; 22 | 23 | 24 | #endif /* _ORANGES_TYPE_H_ */ 25 | -------------------------------------------------------------------------------- /chapter7/a/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter7/a/a.img -------------------------------------------------------------------------------- /chapter7/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 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter7/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 | -------------------------------------------------------------------------------- /chapter7/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 int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | typedef void (*task_f) (); 19 | typedef void (*irq_handler) (int irq); 20 | 21 | typedef void* system_call; 22 | 23 | 24 | #endif /* _ORANGES_TYPE_H_ */ 25 | -------------------------------------------------------------------------------- /chapter7/b/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter7/b/a.img -------------------------------------------------------------------------------- /chapter7/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 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter7/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 | -------------------------------------------------------------------------------- /chapter7/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 int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | typedef void (*task_f) (); 19 | typedef void (*irq_handler) (int irq); 20 | 21 | typedef void* system_call; 22 | 23 | 24 | #endif /* _ORANGES_TYPE_H_ */ 25 | -------------------------------------------------------------------------------- /chapter7/c/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter7/c/a.img -------------------------------------------------------------------------------- /chapter7/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 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter7/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 | -------------------------------------------------------------------------------- /chapter7/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 int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | typedef void (*task_f) (); 19 | typedef void (*irq_handler) (int irq); 20 | 21 | typedef void* system_call; 22 | 23 | 24 | #endif /* _ORANGES_TYPE_H_ */ 25 | -------------------------------------------------------------------------------- /chapter7/c/kernel/tty.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | tty.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #include "type.h" 9 | #include "const.h" 10 | #include "protect.h" 11 | #include "proto.h" 12 | #include "string.h" 13 | #include "proc.h" 14 | #include "global.h" 15 | #include "keyboard.h" 16 | 17 | 18 | /*======================================================================* 19 | task_tty 20 | *======================================================================*/ 21 | PUBLIC void task_tty() 22 | { 23 | while (1) { 24 | keyboard_read(); 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /chapter7/d/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter7/d/a.img -------------------------------------------------------------------------------- /chapter7/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 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter7/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 | -------------------------------------------------------------------------------- /chapter7/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 int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | typedef void (*task_f) (); 19 | typedef void (*irq_handler) (int irq); 20 | 21 | typedef void* system_call; 22 | 23 | 24 | #endif /* _ORANGES_TYPE_H_ */ 25 | -------------------------------------------------------------------------------- /chapter7/d/kernel/tty.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | tty.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #include "type.h" 9 | #include "const.h" 10 | #include "protect.h" 11 | #include "proto.h" 12 | #include "string.h" 13 | #include "proc.h" 14 | #include "global.h" 15 | #include "keyboard.h" 16 | 17 | 18 | /*======================================================================* 19 | task_tty 20 | *======================================================================*/ 21 | PUBLIC void task_tty() 22 | { 23 | while (1) { 24 | keyboard_read(); 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /chapter7/e/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter7/e/a.img -------------------------------------------------------------------------------- /chapter7/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 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter7/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 | -------------------------------------------------------------------------------- /chapter7/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 | 12 | typedef unsigned int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | typedef void (*task_f) (); 19 | typedef void (*irq_handler) (int irq); 20 | 21 | typedef void* system_call; 22 | 23 | 24 | #endif /* _ORANGES_TYPE_H_ */ 25 | -------------------------------------------------------------------------------- /chapter7/e/kernel/tty.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | tty.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #include "type.h" 9 | #include "const.h" 10 | #include "protect.h" 11 | #include "proto.h" 12 | #include "string.h" 13 | #include "proc.h" 14 | #include "global.h" 15 | #include "keyboard.h" 16 | 17 | 18 | /*======================================================================* 19 | task_tty 20 | *======================================================================*/ 21 | PUBLIC void task_tty() 22 | { 23 | while (1) { 24 | keyboard_read(); 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /chapter7/f/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter7/f/a.img -------------------------------------------------------------------------------- /chapter7/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 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter7/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 | -------------------------------------------------------------------------------- /chapter7/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 | 12 | typedef unsigned int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | typedef void (*task_f) (); 19 | typedef void (*irq_handler) (int irq); 20 | 21 | typedef void* system_call; 22 | 23 | 24 | #endif /* _ORANGES_TYPE_H_ */ 25 | -------------------------------------------------------------------------------- /chapter7/f/kernel/tty.c: -------------------------------------------------------------------------------- 1 | 2 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 | tty.c 4 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 | Forrest Yu, 2005 6 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 7 | 8 | #include "type.h" 9 | #include "const.h" 10 | #include "protect.h" 11 | #include "proto.h" 12 | #include "string.h" 13 | #include "proc.h" 14 | #include "global.h" 15 | #include "keyboard.h" 16 | 17 | 18 | /*======================================================================* 19 | task_tty 20 | *======================================================================*/ 21 | PUBLIC void task_tty() 22 | { 23 | while (1) { 24 | keyboard_read(); 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /chapter7/g/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter7/g/a.img -------------------------------------------------------------------------------- /chapter7/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 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter7/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 | -------------------------------------------------------------------------------- /chapter7/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 | 12 | typedef unsigned int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | typedef void (*task_f) (); 19 | typedef void (*irq_handler) (int irq); 20 | 21 | typedef void* system_call; 22 | 23 | 24 | #endif /* _ORANGES_TYPE_H_ */ 25 | -------------------------------------------------------------------------------- /chapter7/h/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter7/h/a.img -------------------------------------------------------------------------------- /chapter7/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 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter7/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 | -------------------------------------------------------------------------------- /chapter7/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 | 12 | typedef unsigned int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | typedef void (*task_f) (); 19 | typedef void (*irq_handler) (int irq); 20 | 21 | typedef void* system_call; 22 | 23 | 24 | #endif /* _ORANGES_TYPE_H_ */ 25 | -------------------------------------------------------------------------------- /chapter7/i/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter7/i/a.img -------------------------------------------------------------------------------- /chapter7/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 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter7/i/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 | 22 | #define DEFAULT_CHAR_COLOR 0x07 /* 0000 0111 黑底白字 */ 23 | 24 | 25 | #endif /* _ORANGES_CONSOLE_H_ */ 26 | -------------------------------------------------------------------------------- /chapter7/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 | -------------------------------------------------------------------------------- /chapter7/i/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 | -------------------------------------------------------------------------------- /chapter7/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 | 12 | typedef unsigned int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | typedef void (*task_f) (); 19 | typedef void (*irq_handler) (int irq); 20 | 21 | typedef void* system_call; 22 | 23 | 24 | #endif /* _ORANGES_TYPE_H_ */ 25 | -------------------------------------------------------------------------------- /chapter7/j/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter7/j/a.img -------------------------------------------------------------------------------- /chapter7/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 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter7/j/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 | 22 | #define DEFAULT_CHAR_COLOR 0x07 /* 0000 0111 黑底白字 */ 23 | 24 | 25 | #endif /* _ORANGES_CONSOLE_H_ */ 26 | -------------------------------------------------------------------------------- /chapter7/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 | -------------------------------------------------------------------------------- /chapter7/j/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 | -------------------------------------------------------------------------------- /chapter7/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 | 12 | typedef unsigned int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | typedef void (*task_f) (); 19 | typedef void (*irq_handler) (int irq); 20 | 21 | typedef void* system_call; 22 | 23 | 24 | #endif /* _ORANGES_TYPE_H_ */ 25 | -------------------------------------------------------------------------------- /chapter7/k/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter7/k/a.img -------------------------------------------------------------------------------- /chapter7/k/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 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter7/k/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 | -------------------------------------------------------------------------------- /chapter7/k/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 | -------------------------------------------------------------------------------- /chapter7/k/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 int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | typedef void (*task_f) (); 19 | typedef void (*irq_handler) (int irq); 20 | 21 | typedef void* system_call; 22 | 23 | 24 | #endif /* _ORANGES_TYPE_H_ */ 25 | -------------------------------------------------------------------------------- /chapter7/l/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter7/l/a.img -------------------------------------------------------------------------------- /chapter7/l/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 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter7/l/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 | -------------------------------------------------------------------------------- /chapter7/l/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 | -------------------------------------------------------------------------------- /chapter7/l/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 int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | typedef void (*task_f) (); 19 | typedef void (*irq_handler) (int irq); 20 | 21 | typedef void* system_call; 22 | 23 | 24 | #endif /* _ORANGES_TYPE_H_ */ 25 | -------------------------------------------------------------------------------- /chapter7/m/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter7/m/a.img -------------------------------------------------------------------------------- /chapter7/m/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 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter7/m/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 | -------------------------------------------------------------------------------- /chapter7/m/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 | -------------------------------------------------------------------------------- /chapter7/m/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 int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | typedef void (*task_f) (); 19 | typedef void (*irq_handler) (int irq); 20 | 21 | typedef void* system_call; 22 | 23 | 24 | #endif /* _ORANGES_TYPE_H_ */ 25 | -------------------------------------------------------------------------------- /chapter7/n/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter7/n/a.img -------------------------------------------------------------------------------- /chapter7/n/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 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter7/n/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 | -------------------------------------------------------------------------------- /chapter7/n/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 | -------------------------------------------------------------------------------- /chapter7/n/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 int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | 17 | typedef void (*int_handler) (); 18 | typedef void (*task_f) (); 19 | typedef void (*irq_handler) (int irq); 20 | 21 | typedef void* system_call; 22 | 23 | 24 | #endif /* _ORANGES_TYPE_H_ */ 25 | -------------------------------------------------------------------------------- /chapter7/o/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter7/o/a.img -------------------------------------------------------------------------------- /chapter7/o/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 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter7/o/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 | -------------------------------------------------------------------------------- /chapter7/o/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 | -------------------------------------------------------------------------------- /chapter7/o/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 int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | typedef char * va_list; 17 | 18 | typedef void (*int_handler) (); 19 | typedef void (*task_f) (); 20 | typedef void (*irq_handler) (int irq); 21 | 22 | typedef void* system_call; 23 | 24 | 25 | #endif /* _ORANGES_TYPE_H_ */ 26 | -------------------------------------------------------------------------------- /chapter8/_base_/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter8/_base_/a.img -------------------------------------------------------------------------------- /chapter8/_base_/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 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter8/_base_/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 | -------------------------------------------------------------------------------- /chapter8/_base_/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 | -------------------------------------------------------------------------------- /chapter8/_base_/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 int u32; 13 | typedef unsigned short u16; 14 | typedef unsigned char u8; 15 | 16 | typedef char * va_list; 17 | 18 | typedef void (*int_handler) (); 19 | typedef void (*task_f) (); 20 | typedef void (*irq_handler) (int irq); 21 | 22 | typedef void* system_call; 23 | 24 | 25 | #endif /* _ORANGES_TYPE_H_ */ 26 | -------------------------------------------------------------------------------- /chapter8/a/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter8/a/a.img -------------------------------------------------------------------------------- /chapter8/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 | # choose the boot disk. 16 | boot: a 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /chapter8/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 | -------------------------------------------------------------------------------- /chapter9/a/80m.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter9/a/80m.img.gz -------------------------------------------------------------------------------- /chapter9/a/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter9/a/a.img -------------------------------------------------------------------------------- /chapter9/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 | -------------------------------------------------------------------------------- /chapter9/b/80m.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter9/b/80m.img.gz -------------------------------------------------------------------------------- /chapter9/b/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter9/b/a.img -------------------------------------------------------------------------------- /chapter9/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 | -------------------------------------------------------------------------------- /chapter9/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 | -------------------------------------------------------------------------------- /chapter9/c/80m.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter9/c/80m.img.gz -------------------------------------------------------------------------------- /chapter9/c/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter9/c/a.img -------------------------------------------------------------------------------- /chapter9/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 | -------------------------------------------------------------------------------- /chapter9/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 | -------------------------------------------------------------------------------- /chapter9/d/80m.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter9/d/80m.img.gz -------------------------------------------------------------------------------- /chapter9/d/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter9/d/a.img -------------------------------------------------------------------------------- /chapter9/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 | -------------------------------------------------------------------------------- /chapter9/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 | -------------------------------------------------------------------------------- /chapter9/e/80m.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter9/e/80m.img.gz -------------------------------------------------------------------------------- /chapter9/e/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter9/e/a.img -------------------------------------------------------------------------------- /chapter9/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 | -------------------------------------------------------------------------------- /chapter9/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 | -------------------------------------------------------------------------------- /chapter9/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 | -------------------------------------------------------------------------------- /chapter9/f/80m.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter9/f/80m.img.gz -------------------------------------------------------------------------------- /chapter9/f/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter9/f/a.img -------------------------------------------------------------------------------- /chapter9/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 | -------------------------------------------------------------------------------- /chapter9/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 | -------------------------------------------------------------------------------- /chapter9/g/80m.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter9/g/80m.img.gz -------------------------------------------------------------------------------- /chapter9/g/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter9/g/a.img -------------------------------------------------------------------------------- /chapter9/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 | -------------------------------------------------------------------------------- /chapter9/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 | -------------------------------------------------------------------------------- /chapter9/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 | -------------------------------------------------------------------------------- /chapter9/h/80m.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter9/h/80m.img.gz -------------------------------------------------------------------------------- /chapter9/h/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter9/h/a.img -------------------------------------------------------------------------------- /chapter9/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 | -------------------------------------------------------------------------------- /chapter9/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 | -------------------------------------------------------------------------------- /chapter9/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 | -------------------------------------------------------------------------------- /chapter9/i/80m.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter9/i/80m.img.gz -------------------------------------------------------------------------------- /chapter9/i/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter9/i/a.img -------------------------------------------------------------------------------- /chapter9/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 | -------------------------------------------------------------------------------- /chapter9/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 | -------------------------------------------------------------------------------- /chapter9/j/80m.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter9/j/80m.img.gz -------------------------------------------------------------------------------- /chapter9/j/a.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangasia/OrangeOS/4fbf5b23e42f40b408c6b6622dca25fa78429ca0/chapter9/j/a.img -------------------------------------------------------------------------------- /chapter9/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 | -------------------------------------------------------------------------------- /chapter9/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 | --------------------------------------------------------------------------------