├── .gitignore
├── README.md
├── doc
├── GCC 中文手册.pdf
├── IA-32卷3:系统编程指南[1、2、3、5章节].pdf
├── INTEL保护模式数据结构.xls
├── Intel CPU.xls
├── Linux 0.11 内核完全注释.pdf
├── Linux下的汇编程序设计.docx
├── Makefile入门.md
├── NASM中文手册.pdf
├── X86指令集.pdf
├── bochs使用帮助
│ ├── .svn
│ │ ├── all-wcprops
│ │ ├── entries
│ │ ├── prop-base
│ │ │ ├── BOCHS使用简单教程.doc.svn-base
│ │ │ ├── Bochs的配置.doc.svn-base
│ │ │ └── 利用Bochs尽情享受虚拟世界 轻松体验多种操作系统.doc.svn-base
│ │ └── text-base
│ │ │ ├── BOCHS使用简单教程.doc.svn-base
│ │ │ ├── Bochs的配置.doc.svn-base
│ │ │ └── 利用Bochs尽情享受虚拟世界 轻松体验多种操作系统.doc.svn-base
│ ├── BOCHS使用简单教程.doc
│ ├── Bochs的配置.doc
│ ├── bochs-2.6.8.tar.gz
│ ├── dlxlinux4.tar.gz
│ └── 利用Bochs尽情享受虚拟世界 轻松体验多种操作系统.doc
├── fat.pdf
├── linux下c语言嵌入汇编.docx
├── nasmdoc.pdf
├── x86寄存器说明.docx
├── 使用nasm和gcc生成无格式的二进制文件.txt
├── 使用开源软件-自己动手写操作系统WriteOS.pdf
├── 保护模式下CPL、DPL、RPL的总结.pdf
├── 文件分配表.xlsx
├── 模拟器及调试器.md
├── 汇编字符显示.xlsx
├── 汇编指令.doc
├── 汇编显示字颜色.bmp
├── 汇编笔记.txt
├── 汇编语言_王爽.pdf
├── 用Bochs和GDB对内核进行源代码级调试.txt
├── 编译器.md
├── 编译源码.md
└── 详细易懂的Linux makefile 教程.pdf
├── src
├── V0.11
│ ├── Makefile
│ ├── boot
│ │ ├── bootsect.s
│ │ ├── head.s
│ │ └── setup.s
│ ├── fs
│ │ ├── Makefile
│ │ ├── bitmap.c
│ │ ├── block_dev.c
│ │ ├── buffer.c
│ │ ├── char_dev.c
│ │ ├── exec.c
│ │ ├── fcntl.c
│ │ ├── file_dev.c
│ │ ├── file_table.c
│ │ ├── inode.c
│ │ ├── ioctl.c
│ │ ├── namei.c
│ │ ├── open.c
│ │ ├── pipe.c
│ │ ├── read_write.c
│ │ ├── stat.c
│ │ ├── super.c
│ │ └── truncate.c
│ ├── include
│ │ ├── a.out.h
│ │ ├── asm
│ │ │ ├── io.h
│ │ │ ├── memory.h
│ │ │ ├── segment.h
│ │ │ └── system.h
│ │ ├── const.h
│ │ ├── ctype.h
│ │ ├── errno.h
│ │ ├── fcntl.h
│ │ ├── linux
│ │ │ ├── config.h
│ │ │ ├── fdreg.h
│ │ │ ├── fs.h
│ │ │ ├── hdreg.h
│ │ │ ├── head.h
│ │ │ ├── kernel.h
│ │ │ ├── mm.h
│ │ │ ├── sched.h
│ │ │ ├── sys.h
│ │ │ └── tty.h
│ │ ├── signal.h
│ │ ├── stdarg.h
│ │ ├── stddef.h
│ │ ├── string.h
│ │ ├── sys
│ │ │ ├── stat.h
│ │ │ ├── times.h
│ │ │ ├── types.h
│ │ │ ├── utsname.h
│ │ │ └── wait.h
│ │ ├── termios.h
│ │ ├── time.h
│ │ ├── unistd.h
│ │ └── utime.h
│ ├── init
│ │ └── main.c
│ ├── kernel
│ │ ├── Makefile
│ │ ├── asm.s
│ │ ├── blk_drv
│ │ │ ├── Makefile
│ │ │ ├── blk.h
│ │ │ ├── floppy.c
│ │ │ ├── hd.c
│ │ │ ├── ll_rw_blk.c
│ │ │ └── ramdisk.c
│ │ ├── chr_drv
│ │ │ ├── Makefile
│ │ │ ├── console.c
│ │ │ ├── keyboard.S
│ │ │ ├── rs_io.s
│ │ │ ├── serial.c
│ │ │ ├── tty_io.c
│ │ │ └── tty_ioctl.c
│ │ ├── exit.c
│ │ ├── fork.c
│ │ ├── math
│ │ │ ├── Makefile
│ │ │ └── math_emulate.c
│ │ ├── mktime.c
│ │ ├── panic.c
│ │ ├── printk.c
│ │ ├── sched.c
│ │ ├── signal.c
│ │ ├── sys.c
│ │ ├── system_call.s
│ │ ├── traps.c
│ │ └── vsprintf.c
│ ├── lib
│ │ ├── Makefile
│ │ ├── _exit.c
│ │ ├── close.c
│ │ ├── ctype.c
│ │ ├── dup.c
│ │ ├── errno.c
│ │ ├── execve.c
│ │ ├── malloc.c
│ │ ├── open.c
│ │ ├── setsid.c
│ │ ├── string.c
│ │ ├── wait.c
│ │ └── write.c
│ ├── mm
│ │ ├── Makefile
│ │ ├── memory.c
│ │ └── page.s
│ └── tools
│ │ └── build.c
├── V0.11_gcc4
│ ├── Makefile
│ ├── boot
│ │ ├── bootsect.s
│ │ ├── head.s
│ │ └── setup.s
│ ├── fs
│ │ ├── Makefile
│ │ ├── bitmap.c
│ │ ├── block_dev.c
│ │ ├── buffer.c
│ │ ├── char_dev.c
│ │ ├── exec.c
│ │ ├── fcntl.c
│ │ ├── file_dev.c
│ │ ├── file_table.c
│ │ ├── inode.c
│ │ ├── ioctl.c
│ │ ├── namei.c
│ │ ├── open.c
│ │ ├── pipe.c
│ │ ├── read_write.c
│ │ ├── stat.c
│ │ ├── super.c
│ │ └── truncate.c
│ ├── include
│ │ ├── a.out.h
│ │ ├── asm
│ │ │ ├── io.h
│ │ │ ├── memory.h
│ │ │ ├── segment.h
│ │ │ └── system.h
│ │ ├── const.h
│ │ ├── ctype.h
│ │ ├── errno.h
│ │ ├── fcntl.h
│ │ ├── linux
│ │ │ ├── config.h
│ │ │ ├── fdreg.h
│ │ │ ├── fs.h
│ │ │ ├── hdreg.h
│ │ │ ├── head.h
│ │ │ ├── kernel.h
│ │ │ ├── mm.h
│ │ │ ├── sched.h
│ │ │ ├── sched.h.cur1
│ │ │ ├── sched.h.old
│ │ │ ├── sys.h
│ │ │ └── tty.h
│ │ ├── signal.h
│ │ ├── stdarg.h
│ │ ├── stddef.h
│ │ ├── string.h
│ │ ├── sys
│ │ │ ├── stat.h
│ │ │ ├── times.h
│ │ │ ├── types.h
│ │ │ ├── utsname.h
│ │ │ └── wait.h
│ │ ├── termios.h
│ │ ├── time.h
│ │ ├── unistd.h
│ │ └── utime.h
│ ├── init
│ │ └── main.c
│ ├── kernel
│ │ ├── Makefile
│ │ ├── asm.s
│ │ ├── blk_drv
│ │ │ ├── Makefile
│ │ │ ├── blk.h
│ │ │ ├── floppy.c
│ │ │ ├── hd.c
│ │ │ ├── ll_rw_blk.c
│ │ │ └── ramdisk.c
│ │ ├── chr_drv
│ │ │ ├── Makefile
│ │ │ ├── console.c
│ │ │ ├── keyboard.S
│ │ │ ├── rs_io.s
│ │ │ ├── serial.c
│ │ │ ├── tty_io.c
│ │ │ └── tty_ioctl.c
│ │ ├── exit.c
│ │ ├── fork.c
│ │ ├── math
│ │ │ ├── Makefile
│ │ │ └── math_emulate.c
│ │ ├── mktime.c
│ │ ├── panic.c
│ │ ├── printk.c
│ │ ├── sched.c
│ │ ├── signal.c
│ │ ├── sys.c
│ │ ├── system_call.s
│ │ ├── traps.c
│ │ └── vsprintf.c
│ ├── lib
│ │ ├── Makefile
│ │ ├── _exit.c
│ │ ├── close.c
│ │ ├── ctype.c
│ │ ├── dup.c
│ │ ├── errno.c
│ │ ├── execve.c
│ │ ├── malloc.c
│ │ ├── open.c
│ │ ├── setsid.c
│ │ ├── string.c
│ │ ├── wait.c
│ │ └── write.c
│ ├── mm
│ │ ├── Makefile
│ │ ├── Makefile-gcc3.x
│ │ ├── Makefile-gcc4.1
│ │ ├── memory.c
│ │ └── page.s
│ └── tools
│ │ └── build.c
├── V0.11_rh9
│ ├── Makefile
│ ├── boot
│ │ ├── bootsect.s
│ │ ├── head.s
│ │ └── setup.s
│ ├── fs
│ │ ├── Makefile
│ │ ├── bitmap.c
│ │ ├── block_dev.c
│ │ ├── buffer.c
│ │ ├── char_dev.c
│ │ ├── exec.c
│ │ ├── fcntl.c
│ │ ├── file_dev.c
│ │ ├── file_table.c
│ │ ├── inode.c
│ │ ├── ioctl.c
│ │ ├── namei.c
│ │ ├── open.c
│ │ ├── pipe.c
│ │ ├── read_write.c
│ │ ├── stat.c
│ │ ├── super.c
│ │ └── truncate.c
│ ├── include
│ │ ├── a.out.h
│ │ ├── asm
│ │ │ ├── io.h
│ │ │ ├── memory.h
│ │ │ ├── segment.h
│ │ │ └── system.h
│ │ ├── const.h
│ │ ├── ctype.h
│ │ ├── errno.h
│ │ ├── fcntl.h
│ │ ├── linux
│ │ │ ├── config.h
│ │ │ ├── fdreg.h
│ │ │ ├── fs.h
│ │ │ ├── hdreg.h
│ │ │ ├── head.h
│ │ │ ├── kernel.h
│ │ │ ├── mm.h
│ │ │ ├── sched.h
│ │ │ ├── sched.h.cur1
│ │ │ ├── sched.h.old
│ │ │ ├── sys.h
│ │ │ └── tty.h
│ │ ├── signal.h
│ │ ├── stdarg.h
│ │ ├── stddef.h
│ │ ├── string.h
│ │ ├── sys
│ │ │ ├── stat.h
│ │ │ ├── times.h
│ │ │ ├── types.h
│ │ │ ├── utsname.h
│ │ │ └── wait.h
│ │ ├── termios.h
│ │ ├── time.h
│ │ ├── unistd.h
│ │ └── utime.h
│ ├── init
│ │ └── main.c
│ ├── kernel
│ │ ├── Makefile
│ │ ├── asm.s
│ │ ├── blk_drv
│ │ │ ├── Makefile
│ │ │ ├── blk.h
│ │ │ ├── floppy.c
│ │ │ ├── hd.c
│ │ │ ├── ll_rw_blk.c
│ │ │ └── ramdisk.c
│ │ ├── chr_drv
│ │ │ ├── Makefile
│ │ │ ├── console.c
│ │ │ ├── keyboard.S
│ │ │ ├── rs_io.s
│ │ │ ├── serial.c
│ │ │ ├── tty_io.c
│ │ │ └── tty_ioctl.c
│ │ ├── exit.c
│ │ ├── fork.c
│ │ ├── math
│ │ │ ├── Makefile
│ │ │ └── math_emulate.c
│ │ ├── mktime.c
│ │ ├── panic.c
│ │ ├── printk.c
│ │ ├── sched.c
│ │ ├── signal.c
│ │ ├── sys.c
│ │ ├── system_call.s
│ │ ├── traps.c
│ │ └── vsprintf.c
│ ├── lib
│ │ ├── Makefile
│ │ ├── _exit.c
│ │ ├── close.c
│ │ ├── ctype.c
│ │ ├── dup.c
│ │ ├── errno.c
│ │ ├── execve.c
│ │ ├── malloc.c
│ │ ├── open.c
│ │ ├── setsid.c
│ │ ├── string.c
│ │ ├── wait.c
│ │ └── write.c
│ ├── mm
│ │ ├── Makefile
│ │ ├── memory.c
│ │ └── page.s
│ └── tools
│ │ └── build.c
└── readme.txt
└── test
├── a.img
├── bochsrc
├── boot.asm
├── compile
├── debug
└── peter-bochs-debugger20110201.jar
/.gitignore:
--------------------------------------------------------------------------------
1 | # Object files
2 | *.o
3 |
4 | # Libraries
5 | *.lib
6 | *.a
7 |
8 | # Shared objects (inc. Windows DLLs)
9 | *.dll
10 | *.so
11 | *.so.*
12 | *.dylib
13 |
14 | # Executables
15 | *.exe
16 | *.out
17 | *.app
18 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Linux011
2 | ========
3 |
4 | Linux 0.11 版本源码
5 |
6 | 可参考 http://oldlinux.org/index_cn.html
7 | 源码在 http://oldlinux.org/Linux.old/
8 |
9 | - [http://oldlinux.org/Linux.old/images/](http://oldlinux.org/Linux.old/images/) 该目录包含已经制作好的内核映像文件bootimage和根文件系统映像文件 rootimage
10 | - [http://www.oldlinux.org/Linux.old/kernel/](http://www.oldlinux.org/Linux.old/kernel/)该目录包含内核原代码程序,包括 Linux 0.11 内核源代码程序。
11 | - [http://www.oldlinux.org/Linux.old/bochs/](http://www.oldlinux.org/Linux.old/bochs/)该目录中包含有已经设置好的运行在计算机仿真系统bochs下的linux系统。
12 | - [http://www.oldlinux.org/Linux.old/Linux-0.11/](http://www.oldlinux.org/Linux.old/Linux-0.11/)该目录中含有可以在 Linux 0.11 系统中使用的其他一些工具和原来发布的一些安装说明文档。
13 |
14 |
15 | 主页在 http://jinghang.github.io/Linux011/
16 |
17 | http://wiki.osdev.org/Main_Page
18 |
19 | # 源码说明
20 | - src/V0.11/ 目录放的是当年Linus写的源码,
21 | - src/V0.11_gcc4/ 目录放的是可以在gcc4编译通过的内核源码,
22 | - src/V0.11_rh9/ 目录放的是在RetHat9系统下编译通过的内核源码。
23 |
24 | # 编译记录
25 | - 2016.4.12
26 | 出现 strcpy 重定义 gcc5 和以前的 gcc 对 extern inline 理解不同,给 CFLAGS 加 -fgnu89-inline 表示使用旧版的 gcc ,详情[http://blog.csdn.net/force_eagle/article/details/11106571](http://blog.csdn.net/force_eagle/article/details/11106571)
27 | __stack_chk_fail找不到引用问题 CFLAGS 加 -fno-stack-protector
28 |
29 | # 编译 bochs
30 | - 安装所需类库
31 | `sudo apt-get install xorg-dev`
32 | - 配置
33 | `./configure --enable-debugger -- enable-disasm`
34 |
35 | `--enable-debugger` 加入调式功能,
36 | `--enable-disasm` 反汇编,
37 | `--enable-gdb-stub` GDB通信
38 |
39 | `--enable-debugger` 和 `--enable-gdb-stub` 只能放一个 http://blog.chinaunix.net/uid-26258259-id-3792406.html
40 |
41 | - 编译
42 | `make`
43 |
44 | - 安装
45 | `sudo make install`
46 |
47 | - 卸载
48 | `sudo make uninstall`
49 |
50 |
51 | ## gui调式
52 | https://code.google.com/archive/p/peter-bochs/
53 |
54 | https://github.com/mcheung63/GKD
55 |
56 |
57 | # 寄存器说明
58 | http://www.cnblogs.com/zhaoyl/archive/2012/05/15/2501972.html
59 | http://blog.csdn.net/knxw0001/article/details/7249248
60 |
61 |
--------------------------------------------------------------------------------
/doc/GCC 中文手册.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/GCC 中文手册.pdf
--------------------------------------------------------------------------------
/doc/IA-32卷3:系统编程指南[1、2、3、5章节].pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/IA-32卷3:系统编程指南[1、2、3、5章节].pdf
--------------------------------------------------------------------------------
/doc/INTEL保护模式数据结构.xls:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/INTEL保护模式数据结构.xls
--------------------------------------------------------------------------------
/doc/Intel CPU.xls:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/Intel CPU.xls
--------------------------------------------------------------------------------
/doc/Linux 0.11 内核完全注释.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/Linux 0.11 内核完全注释.pdf
--------------------------------------------------------------------------------
/doc/Linux下的汇编程序设计.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/Linux下的汇编程序设计.docx
--------------------------------------------------------------------------------
/doc/Makefile入门.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/Makefile入门.md
--------------------------------------------------------------------------------
/doc/NASM中文手册.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/NASM中文手册.pdf
--------------------------------------------------------------------------------
/doc/X86指令集.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/X86指令集.pdf
--------------------------------------------------------------------------------
/doc/bochs使用帮助/.svn/all-wcprops:
--------------------------------------------------------------------------------
1 | K 25
2 | svn:wc:ra_dav:version-url
3 | V 62
4 | /svn/!svn/ver/10/doc/bochs%E4%BD%BF%E7%94%A8%E5%B8%AE%E5%8A%A9
5 | END
6 | BOCHS使用简单教程.doc
7 | K 25
8 | svn:wc:ra_dav:version-url
9 | V 126
10 | /svn/!svn/ver/10/doc/bochs%E4%BD%BF%E7%94%A8%E5%B8%AE%E5%8A%A9/BOCHS%E4%BD%BF%E7%94%A8%E7%AE%80%E5%8D%95%E6%95%99%E7%A8%8B.doc
11 | END
12 | 利用Bochs尽情享受虚拟世界 轻松体验多种操作系统.doc
13 | K 25
14 | svn:wc:ra_dav:version-url
15 | V 258
16 | /svn/!svn/ver/10/doc/bochs%E4%BD%BF%E7%94%A8%E5%B8%AE%E5%8A%A9/%E5%88%A9%E7%94%A8Bochs%E5%B0%BD%E6%83%85%E4%BA%AB%E5%8F%97%E8%99%9A%E6%8B%9F%E4%B8%96%E7%95%8C%C2%A0%E8%BD%BB%E6%9D%BE%E4%BD%93%E9%AA%8C%E5%A4%9A%E7%A7%8D%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F.doc
17 | END
18 | Bochs的配置.doc
19 | K 25
20 | svn:wc:ra_dav:version-url
21 | V 99
22 | /svn/!svn/ver/10/doc/bochs%E4%BD%BF%E7%94%A8%E5%B8%AE%E5%8A%A9/Bochs%E7%9A%84%E9%85%8D%E7%BD%AE.doc
23 | END
24 |
--------------------------------------------------------------------------------
/doc/bochs使用帮助/.svn/entries:
--------------------------------------------------------------------------------
1 | 10
2 |
3 | dir
4 | 46
5 | https://develop-os.googlecode.com/svn/doc/bochs%E4%BD%BF%E7%94%A8%E5%B8%AE%E5%8A%A9
6 | https://develop-os.googlecode.com/svn
7 |
8 |
9 |
10 | 2011-10-29T17:42:20.196166Z
11 | 10
12 | jhang.cn@gmail.com
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | 45f3e677-5077-3fd3-8659-742012283c08
28 |
29 | BOCHS使用简单教程.doc
30 | file
31 |
32 |
33 |
34 |
35 | 2011-12-20T14:55:08.241758Z
36 | d2d89fefcbf01e7d8a7bc6a5fca5466d
37 | 2011-10-29T17:42:20.196166Z
38 | 10
39 | jhang.cn@gmail.com
40 | has-props
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | 25600
62 |
63 | 利用Bochs尽情享受虚拟世界 轻松体验多种操作系统.doc
64 | file
65 |
66 |
67 |
68 |
69 | 2011-12-20T14:55:08.245758Z
70 | 5e78cf650b76f7b464b4793275f4fa98
71 | 2011-10-29T17:42:20.196166Z
72 | 10
73 | jhang.cn@gmail.com
74 | has-props
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | 120832
96 |
97 | Bochs的配置.doc
98 | file
99 |
100 |
101 |
102 |
103 | 2011-12-20T14:55:08.245758Z
104 | 567576b248fb0f7ac2f441734bf7d28b
105 | 2011-10-29T17:42:20.196166Z
106 | 10
107 | jhang.cn@gmail.com
108 | has-props
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 | 35840
130 |
131 |
--------------------------------------------------------------------------------
/doc/bochs使用帮助/.svn/prop-base/BOCHS使用简单教程.doc.svn-base:
--------------------------------------------------------------------------------
1 | K 13
2 | svn:mime-type
3 | V 24
4 | application/octet-stream
5 | END
6 |
--------------------------------------------------------------------------------
/doc/bochs使用帮助/.svn/prop-base/Bochs的配置.doc.svn-base:
--------------------------------------------------------------------------------
1 | K 13
2 | svn:mime-type
3 | V 24
4 | application/octet-stream
5 | END
6 |
--------------------------------------------------------------------------------
/doc/bochs使用帮助/.svn/prop-base/利用Bochs尽情享受虚拟世界 轻松体验多种操作系统.doc.svn-base:
--------------------------------------------------------------------------------
1 | K 13
2 | svn:mime-type
3 | V 24
4 | application/octet-stream
5 | END
6 |
--------------------------------------------------------------------------------
/doc/bochs使用帮助/.svn/text-base/BOCHS使用简单教程.doc.svn-base:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/bochs使用帮助/.svn/text-base/BOCHS使用简单教程.doc.svn-base
--------------------------------------------------------------------------------
/doc/bochs使用帮助/.svn/text-base/Bochs的配置.doc.svn-base:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/bochs使用帮助/.svn/text-base/Bochs的配置.doc.svn-base
--------------------------------------------------------------------------------
/doc/bochs使用帮助/.svn/text-base/利用Bochs尽情享受虚拟世界 轻松体验多种操作系统.doc.svn-base:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/bochs使用帮助/.svn/text-base/利用Bochs尽情享受虚拟世界 轻松体验多种操作系统.doc.svn-base
--------------------------------------------------------------------------------
/doc/bochs使用帮助/BOCHS使用简单教程.doc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/bochs使用帮助/BOCHS使用简单教程.doc
--------------------------------------------------------------------------------
/doc/bochs使用帮助/Bochs的配置.doc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/bochs使用帮助/Bochs的配置.doc
--------------------------------------------------------------------------------
/doc/bochs使用帮助/bochs-2.6.8.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/bochs使用帮助/bochs-2.6.8.tar.gz
--------------------------------------------------------------------------------
/doc/bochs使用帮助/dlxlinux4.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/bochs使用帮助/dlxlinux4.tar.gz
--------------------------------------------------------------------------------
/doc/bochs使用帮助/利用Bochs尽情享受虚拟世界 轻松体验多种操作系统.doc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/bochs使用帮助/利用Bochs尽情享受虚拟世界 轻松体验多种操作系统.doc
--------------------------------------------------------------------------------
/doc/fat.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/fat.pdf
--------------------------------------------------------------------------------
/doc/linux下c语言嵌入汇编.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/linux下c语言嵌入汇编.docx
--------------------------------------------------------------------------------
/doc/nasmdoc.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/nasmdoc.pdf
--------------------------------------------------------------------------------
/doc/x86寄存器说明.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/x86寄存器说明.docx
--------------------------------------------------------------------------------
/doc/使用nasm和gcc生成无格式的二进制文件.txt:
--------------------------------------------------------------------------------
1 | 提供下面两种方法编译生成一个没有格式的二进制文件:
2 | 1.
3 | gcc -c test.c
4 | ld -o test -Ttext 0x0 -e main test.o
5 | objcopy -R .note -R .comment -S -O binary test test.bin
6 |
7 | 2.
8 | gcc -c test.c
9 | ld test.o -o test.bin -Ttext 0x0 -e main -oformat binary
10 |
11 | 现在假设我们有一个段使用汇编编写的程序,而我们又需要将它加入我们最后生成的文件中,我们可以使用下面的方法:
12 |
13 | nasm -f elf other.asm -o other.o
14 | gcc -c test.c
15 | ld other.o main.o -o kernal.bin -Ttext 0x0 -e _mian --oformat binary
16 |
17 | 目前linux大多都是elf格式目标文件,所以我们首先将汇编程序编译为elf的目标文件,然后使用ld将多个目标文件链接到一起即可。
18 |
--------------------------------------------------------------------------------
/doc/使用开源软件-自己动手写操作系统WriteOS.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/使用开源软件-自己动手写操作系统WriteOS.pdf
--------------------------------------------------------------------------------
/doc/保护模式下CPL、DPL、RPL的总结.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/保护模式下CPL、DPL、RPL的总结.pdf
--------------------------------------------------------------------------------
/doc/文件分配表.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/文件分配表.xlsx
--------------------------------------------------------------------------------
/doc/模拟器及调试器.md:
--------------------------------------------------------------------------------
1 | # Bochs
2 |
3 |
4 |
5 | # Peter-Bochs
--------------------------------------------------------------------------------
/doc/汇编字符显示.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/汇编字符显示.xlsx
--------------------------------------------------------------------------------
/doc/汇编指令.doc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/汇编指令.doc
--------------------------------------------------------------------------------
/doc/汇编显示字颜色.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/汇编显示字颜色.bmp
--------------------------------------------------------------------------------
/doc/汇编笔记.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/汇编笔记.txt
--------------------------------------------------------------------------------
/doc/汇编语言_王爽.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/汇编语言_王爽.pdf
--------------------------------------------------------------------------------
/doc/编译器.md:
--------------------------------------------------------------------------------
1 | # 汇编
2 |
3 |
4 | # C语言
--------------------------------------------------------------------------------
/doc/编译源码.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/编译源码.md
--------------------------------------------------------------------------------
/doc/详细易懂的Linux makefile 教程.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/doc/详细易懂的Linux makefile 教程.pdf
--------------------------------------------------------------------------------
/src/V0.11/fs/block_dev.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/fs/block_dev.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #include
8 |
9 | #include
10 | #include
11 | #include
12 | #include
13 |
14 | int block_write(int dev, long * pos, char * buf, int count)
15 | {
16 | int block = *pos >> BLOCK_SIZE_BITS;
17 | int offset = *pos & (BLOCK_SIZE-1);
18 | int chars;
19 | int written = 0;
20 | struct buffer_head * bh;
21 | register char * p;
22 |
23 | while (count>0) {
24 | chars = BLOCK_SIZE - offset;
25 | if (chars > count)
26 | chars=count;
27 | if (chars == BLOCK_SIZE)
28 | bh = getblk(dev,block);
29 | else
30 | bh = breada(dev,block,block+1,block+2,-1);
31 | block++;
32 | if (!bh)
33 | return written?written:-EIO;
34 | p = offset + bh->b_data;
35 | offset = 0;
36 | *pos += chars;
37 | written += chars;
38 | count -= chars;
39 | while (chars-->0)
40 | *(p++) = get_fs_byte(buf++);
41 | bh->b_dirt = 1;
42 | brelse(bh);
43 | }
44 | return written;
45 | }
46 |
47 | int block_read(int dev, unsigned long * pos, char * buf, int count)
48 | {
49 | int block = *pos >> BLOCK_SIZE_BITS;
50 | int offset = *pos & (BLOCK_SIZE-1);
51 | int chars;
52 | int read = 0;
53 | struct buffer_head * bh;
54 | register char * p;
55 |
56 | while (count>0) {
57 | chars = BLOCK_SIZE-offset;
58 | if (chars > count)
59 | chars = count;
60 | if (!(bh = breada(dev,block,block+1,block+2,-1)))
61 | return read?read:-EIO;
62 | block++;
63 | p = offset + bh->b_data;
64 | offset = 0;
65 | *pos += chars;
66 | read += chars;
67 | count -= chars;
68 | while (chars-->0)
69 | put_fs_byte(*(p++),buf++);
70 | brelse(bh);
71 | }
72 | return read;
73 | }
74 |
--------------------------------------------------------------------------------
/src/V0.11/fs/char_dev.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/fs/char_dev.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #include
8 | #include
9 |
10 | #include
11 | #include
12 |
13 | #include
14 | #include
15 |
16 | extern int tty_read(unsigned minor,char * buf,int count);
17 | extern int tty_write(unsigned minor,char * buf,int count);
18 |
19 | typedef (*crw_ptr)(int rw,unsigned minor,char * buf,int count,off_t * pos);
20 |
21 | static int rw_ttyx(int rw,unsigned minor,char * buf,int count,off_t * pos)
22 | {
23 | return ((rw==READ)?tty_read(minor,buf,count):
24 | tty_write(minor,buf,count));
25 | }
26 |
27 | static int rw_tty(int rw,unsigned minor,char * buf,int count, off_t * pos)
28 | {
29 | if (current->tty<0)
30 | return -EPERM;
31 | return rw_ttyx(rw,current->tty,buf,count,pos);
32 | }
33 |
34 | static int rw_ram(int rw,char * buf, int count, off_t *pos)
35 | {
36 | return -EIO;
37 | }
38 |
39 | static int rw_mem(int rw,char * buf, int count, off_t * pos)
40 | {
41 | return -EIO;
42 | }
43 |
44 | static int rw_kmem(int rw,char * buf, int count, off_t * pos)
45 | {
46 | return -EIO;
47 | }
48 |
49 | static int rw_port(int rw,char * buf, int count, off_t * pos)
50 | {
51 | int i=*pos;
52 |
53 | while (count-->0 && i<65536) {
54 | if (rw==READ)
55 | put_fs_byte(inb(i),buf++);
56 | else
57 | outb(get_fs_byte(buf++),i);
58 | i++;
59 | }
60 | i -= *pos;
61 | *pos += i;
62 | return i;
63 | }
64 |
65 | static int rw_memory(int rw, unsigned minor, char * buf, int count, off_t * pos)
66 | {
67 | switch(minor) {
68 | case 0:
69 | return rw_ram(rw,buf,count,pos);
70 | case 1:
71 | return rw_mem(rw,buf,count,pos);
72 | case 2:
73 | return rw_kmem(rw,buf,count,pos);
74 | case 3:
75 | return (rw==READ)?0:count; /* rw_null */
76 | case 4:
77 | return rw_port(rw,buf,count,pos);
78 | default:
79 | return -EIO;
80 | }
81 | }
82 |
83 | #define NRDEVS ((sizeof (crw_table))/(sizeof (crw_ptr)))
84 |
85 | static crw_ptr crw_table[]={
86 | NULL, /* nodev */
87 | rw_memory, /* /dev/mem etc */
88 | NULL, /* /dev/fd */
89 | NULL, /* /dev/hd */
90 | rw_ttyx, /* /dev/ttyx */
91 | rw_tty, /* /dev/tty */
92 | NULL, /* /dev/lp */
93 | NULL}; /* unnamed pipes */
94 |
95 | int rw_char(int rw,int dev, char * buf, int count, off_t * pos)
96 | {
97 | crw_ptr call_addr;
98 |
99 | if (MAJOR(dev)>=NRDEVS)
100 | return -ENODEV;
101 | if (!(call_addr=crw_table[MAJOR(dev)]))
102 | return -ENODEV;
103 | return call_addr(rw,MINOR(dev),buf,count,pos);
104 | }
105 |
--------------------------------------------------------------------------------
/src/V0.11/fs/fcntl.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/fs/fcntl.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 |
13 | #include
14 | #include
15 |
16 | extern int sys_close(int fd);
17 |
18 | static int dupfd(unsigned int fd, unsigned int arg)
19 | {
20 | if (fd >= NR_OPEN || !current->filp[fd])
21 | return -EBADF;
22 | if (arg >= NR_OPEN)
23 | return -EINVAL;
24 | while (arg < NR_OPEN)
25 | if (current->filp[arg])
26 | arg++;
27 | else
28 | break;
29 | if (arg >= NR_OPEN)
30 | return -EMFILE;
31 | current->close_on_exec &= ~(1<filp[arg] = current->filp[fd])->f_count++;
33 | return arg;
34 | }
35 |
36 | int sys_dup2(unsigned int oldfd, unsigned int newfd)
37 | {
38 | sys_close(newfd);
39 | return dupfd(oldfd,newfd);
40 | }
41 |
42 | int sys_dup(unsigned int fildes)
43 | {
44 | return dupfd(fildes,0);
45 | }
46 |
47 | int sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg)
48 | {
49 | struct file * filp;
50 |
51 | if (fd >= NR_OPEN || !(filp = current->filp[fd]))
52 | return -EBADF;
53 | switch (cmd) {
54 | case F_DUPFD:
55 | return dupfd(fd,arg);
56 | case F_GETFD:
57 | return (current->close_on_exec>>fd)&1;
58 | case F_SETFD:
59 | if (arg&1)
60 | current->close_on_exec |= (1<close_on_exec &= ~(1<f_flags;
66 | case F_SETFL:
67 | filp->f_flags &= ~(O_APPEND | O_NONBLOCK);
68 | filp->f_flags |= arg & (O_APPEND | O_NONBLOCK);
69 | return 0;
70 | case F_GETLK: case F_SETLK: case F_SETLKW:
71 | return -1;
72 | default:
73 | return -1;
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/src/V0.11/fs/file_dev.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/fs/file_dev.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #include
8 | #include
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | #define MIN(a,b) (((a)<(b))?(a):(b))
15 | #define MAX(a,b) (((a)>(b))?(a):(b))
16 |
17 | int file_read(struct m_inode * inode, struct file * filp, char * buf, int count)
18 | {
19 | int left,chars,nr;
20 | struct buffer_head * bh;
21 |
22 | if ((left=count)<=0)
23 | return 0;
24 | while (left) {
25 | if (nr = bmap(inode,(filp->f_pos)/BLOCK_SIZE)) {
26 | if (!(bh=bread(inode->i_dev,nr)))
27 | break;
28 | } else
29 | bh = NULL;
30 | nr = filp->f_pos % BLOCK_SIZE;
31 | chars = MIN( BLOCK_SIZE-nr , left );
32 | filp->f_pos += chars;
33 | left -= chars;
34 | if (bh) {
35 | char * p = nr + bh->b_data;
36 | while (chars-->0)
37 | put_fs_byte(*(p++),buf++);
38 | brelse(bh);
39 | } else {
40 | while (chars-->0)
41 | put_fs_byte(0,buf++);
42 | }
43 | }
44 | inode->i_atime = CURRENT_TIME;
45 | return (count-left)?(count-left):-ERROR;
46 | }
47 |
48 | int file_write(struct m_inode * inode, struct file * filp, char * buf, int count)
49 | {
50 | off_t pos;
51 | int block,c;
52 | struct buffer_head * bh;
53 | char * p;
54 | int i=0;
55 |
56 | /*
57 | * ok, append may not work when many processes are writing at the same time
58 | * but so what. That way leads to madness anyway.
59 | */
60 | if (filp->f_flags & O_APPEND)
61 | pos = inode->i_size;
62 | else
63 | pos = filp->f_pos;
64 | while (ii_dev,block)))
68 | break;
69 | c = pos % BLOCK_SIZE;
70 | p = c + bh->b_data;
71 | bh->b_dirt = 1;
72 | c = BLOCK_SIZE-c;
73 | if (c > count-i) c = count-i;
74 | pos += c;
75 | if (pos > inode->i_size) {
76 | inode->i_size = pos;
77 | inode->i_dirt = 1;
78 | }
79 | i += c;
80 | while (c-->0)
81 | *(p++) = get_fs_byte(buf++);
82 | brelse(bh);
83 | }
84 | inode->i_mtime = CURRENT_TIME;
85 | if (!(filp->f_flags & O_APPEND)) {
86 | filp->f_pos = pos;
87 | inode->i_ctime = CURRENT_TIME;
88 | }
89 | return (i?i:-1);
90 | }
91 |
--------------------------------------------------------------------------------
/src/V0.11/fs/file_table.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/fs/file_table.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #include
8 |
9 | struct file file_table[NR_FILE];
10 |
--------------------------------------------------------------------------------
/src/V0.11/fs/ioctl.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/fs/ioctl.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #include
8 | #include
9 | #include
10 |
11 | #include
12 |
13 | extern int tty_ioctl(int dev, int cmd, int arg);
14 |
15 | typedef int (*ioctl_ptr)(int dev,int cmd,int arg);
16 |
17 | #define NRDEVS ((sizeof (ioctl_table))/(sizeof (ioctl_ptr)))
18 |
19 | static ioctl_ptr ioctl_table[]={
20 | NULL, /* nodev */
21 | NULL, /* /dev/mem */
22 | NULL, /* /dev/fd */
23 | NULL, /* /dev/hd */
24 | tty_ioctl, /* /dev/ttyx */
25 | tty_ioctl, /* /dev/tty */
26 | NULL, /* /dev/lp */
27 | NULL}; /* named pipes */
28 |
29 |
30 | int sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
31 | {
32 | struct file * filp;
33 | int dev,mode;
34 |
35 | if (fd >= NR_OPEN || !(filp = current->filp[fd]))
36 | return -EBADF;
37 | mode=filp->f_inode->i_mode;
38 | if (!S_ISCHR(mode) && !S_ISBLK(mode))
39 | return -EINVAL;
40 | dev = filp->f_inode->i_zone[0];
41 | if (MAJOR(dev) >= NRDEVS)
42 | return -ENODEV;
43 | if (!ioctl_table[MAJOR(dev)])
44 | return -ENOTTY;
45 | return ioctl_table[MAJOR(dev)](dev,cmd,arg);
46 | }
47 |
--------------------------------------------------------------------------------
/src/V0.11/fs/stat.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/fs/stat.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #include
8 | #include
9 |
10 | #include
11 | #include
12 | #include
13 | #include
14 |
15 | static void cp_stat(struct m_inode * inode, struct stat * statbuf)
16 | {
17 | struct stat tmp;
18 | int i;
19 |
20 | verify_area(statbuf,sizeof (* statbuf));
21 | tmp.st_dev = inode->i_dev;
22 | tmp.st_ino = inode->i_num;
23 | tmp.st_mode = inode->i_mode;
24 | tmp.st_nlink = inode->i_nlinks;
25 | tmp.st_uid = inode->i_uid;
26 | tmp.st_gid = inode->i_gid;
27 | tmp.st_rdev = inode->i_zone[0];
28 | tmp.st_size = inode->i_size;
29 | tmp.st_atime = inode->i_atime;
30 | tmp.st_mtime = inode->i_mtime;
31 | tmp.st_ctime = inode->i_ctime;
32 | for (i=0 ; i= NR_OPEN || !(f=current->filp[fd]) || !(inode=f->f_inode))
53 | return -EBADF;
54 | cp_stat(inode,statbuf);
55 | return 0;
56 | }
57 |
--------------------------------------------------------------------------------
/src/V0.11/fs/truncate.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/fs/truncate.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #include
8 |
9 | #include
10 |
11 | static void free_ind(int dev,int block)
12 | {
13 | struct buffer_head * bh;
14 | unsigned short * p;
15 | int i;
16 |
17 | if (!block)
18 | return;
19 | if (bh=bread(dev,block)) {
20 | p = (unsigned short *) bh->b_data;
21 | for (i=0;i<512;i++,p++)
22 | if (*p)
23 | free_block(dev,*p);
24 | brelse(bh);
25 | }
26 | free_block(dev,block);
27 | }
28 |
29 | static void free_dind(int dev,int block)
30 | {
31 | struct buffer_head * bh;
32 | unsigned short * p;
33 | int i;
34 |
35 | if (!block)
36 | return;
37 | if (bh=bread(dev,block)) {
38 | p = (unsigned short *) bh->b_data;
39 | for (i=0;i<512;i++,p++)
40 | if (*p)
41 | free_ind(dev,*p);
42 | brelse(bh);
43 | }
44 | free_block(dev,block);
45 | }
46 |
47 | void truncate(struct m_inode * inode)
48 | {
49 | int i;
50 |
51 | if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)))
52 | return;
53 | for (i=0;i<7;i++)
54 | if (inode->i_zone[i]) {
55 | free_block(inode->i_dev,inode->i_zone[i]);
56 | inode->i_zone[i]=0;
57 | }
58 | free_ind(inode->i_dev,inode->i_zone[7]);
59 | free_dind(inode->i_dev,inode->i_zone[8]);
60 | inode->i_zone[7] = inode->i_zone[8] = 0;
61 | inode->i_size = 0;
62 | inode->i_dirt = 1;
63 | inode->i_mtime = inode->i_ctime = CURRENT_TIME;
64 | }
65 |
66 |
--------------------------------------------------------------------------------
/src/V0.11/include/asm/io.h:
--------------------------------------------------------------------------------
1 | #define outb(value,port) \
2 | __asm__ ("outb %%al,%%dx"::"a" (value),"d" (port))
3 |
4 |
5 | #define inb(port) ({ \
6 | unsigned char _v; \
7 | __asm__ volatile ("inb %%dx,%%al":"=a" (_v):"d" (port)); \
8 | _v; \
9 | })
10 |
11 | #define outb_p(value,port) \
12 | __asm__ ("outb %%al,%%dx\n" \
13 | "\tjmp 1f\n" \
14 | "1:\tjmp 1f\n" \
15 | "1:"::"a" (value),"d" (port))
16 |
17 | #define inb_p(port) ({ \
18 | unsigned char _v; \
19 | __asm__ volatile ("inb %%dx,%%al\n" \
20 | "\tjmp 1f\n" \
21 | "1:\tjmp 1f\n" \
22 | "1:":"=a" (_v):"d" (port)); \
23 | _v; \
24 | })
25 |
--------------------------------------------------------------------------------
/src/V0.11/include/asm/memory.h:
--------------------------------------------------------------------------------
1 | /*
2 | * NOTE!!! memcpy(dest,src,n) assumes ds=es=normal data segment. This
3 | * goes for all kernel functions (ds=es=kernel space, fs=local data,
4 | * gs=null), as well as for all well-behaving user programs (ds=es=
5 | * user data space). This is NOT a bug, as any user program that changes
6 | * es deserves to die if it isn't careful.
7 | */
8 | #define memcpy(dest,src,n) ({ \
9 | void * _res = dest; \
10 | __asm__ ("cld;rep;movsb" \
11 | ::"D" ((long)(_res)),"S" ((long)(src)),"c" ((long) (n)) \
12 | :"di","si","cx"); \
13 | _res; \
14 | })
15 |
--------------------------------------------------------------------------------
/src/V0.11/include/asm/segment.h:
--------------------------------------------------------------------------------
1 | extern inline unsigned char get_fs_byte(const char * addr)
2 | {
3 | unsigned register char _v;
4 |
5 | __asm__ ("movb %%fs:%1,%0":"=r" (_v):"m" (*addr));
6 | return _v;
7 | }
8 |
9 | extern inline unsigned short get_fs_word(const unsigned short *addr)
10 | {
11 | unsigned short _v;
12 |
13 | __asm__ ("movw %%fs:%1,%0":"=r" (_v):"m" (*addr));
14 | return _v;
15 | }
16 |
17 | extern inline unsigned long get_fs_long(const unsigned long *addr)
18 | {
19 | unsigned long _v;
20 |
21 | __asm__ ("movl %%fs:%1,%0":"=r" (_v):"m" (*addr)); \
22 | return _v;
23 | }
24 |
25 | extern inline void put_fs_byte(char val,char *addr)
26 | {
27 | __asm__ ("movb %0,%%fs:%1"::"r" (val),"m" (*addr));
28 | }
29 |
30 | extern inline void put_fs_word(short val,short * addr)
31 | {
32 | __asm__ ("movw %0,%%fs:%1"::"r" (val),"m" (*addr));
33 | }
34 |
35 | extern inline void put_fs_long(unsigned long val,unsigned long * addr)
36 | {
37 | __asm__ ("movl %0,%%fs:%1"::"r" (val),"m" (*addr));
38 | }
39 |
40 | /*
41 | * Someone who knows GNU asm better than I should double check the followig.
42 | * It seems to work, but I don't know if I'm doing something subtly wrong.
43 | * --- TYT, 11/24/91
44 | * [ nothing wrong here, Linus ]
45 | */
46 |
47 | extern inline unsigned long get_fs()
48 | {
49 | unsigned short _v;
50 | __asm__("mov %%fs,%%ax":"=a" (_v):);
51 | return _v;
52 | }
53 |
54 | extern inline unsigned long get_ds()
55 | {
56 | unsigned short _v;
57 | __asm__("mov %%ds,%%ax":"=a" (_v):);
58 | return _v;
59 | }
60 |
61 | extern inline void set_fs(unsigned long val)
62 | {
63 | __asm__("mov %0,%%fs"::"a" ((unsigned short) val));
64 | }
65 |
66 |
--------------------------------------------------------------------------------
/src/V0.11/include/asm/system.h:
--------------------------------------------------------------------------------
1 | #define move_to_user_mode() \
2 | __asm__ ("movl %%esp,%%eax\n\t" \
3 | "pushl $0x17\n\t" \
4 | "pushl %%eax\n\t" \
5 | "pushfl\n\t" \
6 | "pushl $0x0f\n\t" \
7 | "pushl $1f\n\t" \
8 | "iret\n" \
9 | "1:\tmovl $0x17,%%eax\n\t" \
10 | "movw %%ax,%%ds\n\t" \
11 | "movw %%ax,%%es\n\t" \
12 | "movw %%ax,%%fs\n\t" \
13 | "movw %%ax,%%gs" \
14 | :::"ax")
15 |
16 | #define sti() __asm__ ("sti"::)
17 | #define cli() __asm__ ("cli"::)
18 | #define nop() __asm__ ("nop"::)
19 |
20 | #define iret() __asm__ ("iret"::)
21 |
22 | #define _set_gate(gate_addr,type,dpl,addr) \
23 | __asm__ ("movw %%dx,%%ax\n\t" \
24 | "movw %0,%%dx\n\t" \
25 | "movl %%eax,%1\n\t" \
26 | "movl %%edx,%2" \
27 | : \
28 | : "i" ((short) (0x8000+(dpl<<13)+(type<<8))), \
29 | "o" (*((char *) (gate_addr))), \
30 | "o" (*(4+(char *) (gate_addr))), \
31 | "d" ((char *) (addr)),"a" (0x00080000))
32 |
33 | #define set_intr_gate(n,addr) \
34 | _set_gate(&idt[n],14,0,addr)
35 |
36 | #define set_trap_gate(n,addr) \
37 | _set_gate(&idt[n],15,0,addr)
38 |
39 | #define set_system_gate(n,addr) \
40 | _set_gate(&idt[n],15,3,addr)
41 |
42 | #define _set_seg_desc(gate_addr,type,dpl,base,limit) {\
43 | *(gate_addr) = ((base) & 0xff000000) | \
44 | (((base) & 0x00ff0000)>>16) | \
45 | ((limit) & 0xf0000) | \
46 | ((dpl)<<13) | \
47 | (0x00408000) | \
48 | ((type)<<8); \
49 | *((gate_addr)+1) = (((base) & 0x0000ffff)<<16) | \
50 | ((limit) & 0x0ffff); }
51 |
52 | #define _set_tssldt_desc(n,addr,type) \
53 | __asm__ ("movw $104,%1\n\t" \
54 | "movw %%ax,%2\n\t" \
55 | "rorl $16,%%eax\n\t" \
56 | "movb %%al,%3\n\t" \
57 | "movb $" type ",%4\n\t" \
58 | "movb $0x00,%5\n\t" \
59 | "movb %%ah,%6\n\t" \
60 | "rorl $16,%%eax" \
61 | ::"a" (addr), "m" (*(n)), "m" (*(n+2)), "m" (*(n+4)), \
62 | "m" (*(n+5)), "m" (*(n+6)), "m" (*(n+7)) \
63 | )
64 |
65 | #define set_tss_desc(n,addr) _set_tssldt_desc(((char *) (n)),addr,"0x89")
66 | #define set_ldt_desc(n,addr) _set_tssldt_desc(((char *) (n)),addr,"0x82")
67 |
--------------------------------------------------------------------------------
/src/V0.11/include/const.h:
--------------------------------------------------------------------------------
1 | #ifndef _CONST_H
2 | #define _CONST_H
3 |
4 | #define BUFFER_END 0x200000
5 |
6 | #define I_TYPE 0170000
7 | #define I_DIRECTORY 0040000
8 | #define I_REGULAR 0100000
9 | #define I_BLOCK_SPECIAL 0060000
10 | #define I_CHAR_SPECIAL 0020000
11 | #define I_NAMED_PIPE 0010000
12 | #define I_SET_UID_BIT 0004000
13 | #define I_SET_GID_BIT 0002000
14 |
15 | #endif
16 |
--------------------------------------------------------------------------------
/src/V0.11/include/ctype.h:
--------------------------------------------------------------------------------
1 | #ifndef _CTYPE_H
2 | #define _CTYPE_H
3 |
4 | #define _U 0x01 /* upper */
5 | #define _L 0x02 /* lower */
6 | #define _D 0x04 /* digit */
7 | #define _C 0x08 /* cntrl */
8 | #define _P 0x10 /* punct */
9 | #define _S 0x20 /* white space (space/lf/tab) */
10 | #define _X 0x40 /* hex digit */
11 | #define _SP 0x80 /* hard space (0x20) */
12 |
13 | extern unsigned char _ctype[];
14 | extern char _ctmp;
15 |
16 | #define isalnum(c) ((_ctype+1)[c]&(_U|_L|_D))
17 | #define isalpha(c) ((_ctype+1)[c]&(_U|_L))
18 | #define iscntrl(c) ((_ctype+1)[c]&(_C))
19 | #define isdigit(c) ((_ctype+1)[c]&(_D))
20 | #define isgraph(c) ((_ctype+1)[c]&(_P|_U|_L|_D))
21 | #define islower(c) ((_ctype+1)[c]&(_L))
22 | #define isprint(c) ((_ctype+1)[c]&(_P|_U|_L|_D|_SP))
23 | #define ispunct(c) ((_ctype+1)[c]&(_P))
24 | #define isspace(c) ((_ctype+1)[c]&(_S))
25 | #define isupper(c) ((_ctype+1)[c]&(_U))
26 | #define isxdigit(c) ((_ctype+1)[c]&(_D|_X))
27 |
28 | #define isascii(c) (((unsigned) c)<=0x7f)
29 | #define toascii(c) (((unsigned) c)&0x7f)
30 |
31 | #define tolower(c) (_ctmp=c,isupper(_ctmp)?_ctmp-('A'-'a'):_ctmp)
32 | #define toupper(c) (_ctmp=c,islower(_ctmp)?_ctmp-('a'-'A'):_ctmp)
33 |
34 | #endif
35 |
--------------------------------------------------------------------------------
/src/V0.11/include/errno.h:
--------------------------------------------------------------------------------
1 | #ifndef _ERRNO_H
2 | #define _ERRNO_H
3 |
4 | /*
5 | * ok, as I hadn't got any other source of information about
6 | * possible error numbers, I was forced to use the same numbers
7 | * as minix.
8 | * Hopefully these are posix or something. I wouldn't know (and posix
9 | * isn't telling me - they want $$$ for their f***ing standard).
10 | *
11 | * We don't use the _SIGN cludge of minix, so kernel returns must
12 | * see to the sign by themselves.
13 | *
14 | * NOTE! Remember to change strerror() if you change this file!
15 | */
16 |
17 | extern int errno;
18 |
19 | #define ERROR 99
20 | #define EPERM 1
21 | #define ENOENT 2
22 | #define ESRCH 3
23 | #define EINTR 4
24 | #define EIO 5
25 | #define ENXIO 6
26 | #define E2BIG 7
27 | #define ENOEXEC 8
28 | #define EBADF 9
29 | #define ECHILD 10
30 | #define EAGAIN 11
31 | #define ENOMEM 12
32 | #define EACCES 13
33 | #define EFAULT 14
34 | #define ENOTBLK 15
35 | #define EBUSY 16
36 | #define EEXIST 17
37 | #define EXDEV 18
38 | #define ENODEV 19
39 | #define ENOTDIR 20
40 | #define EISDIR 21
41 | #define EINVAL 22
42 | #define ENFILE 23
43 | #define EMFILE 24
44 | #define ENOTTY 25
45 | #define ETXTBSY 26
46 | #define EFBIG 27
47 | #define ENOSPC 28
48 | #define ESPIPE 29
49 | #define EROFS 30
50 | #define EMLINK 31
51 | #define EPIPE 32
52 | #define EDOM 33
53 | #define ERANGE 34
54 | #define EDEADLK 35
55 | #define ENAMETOOLONG 36
56 | #define ENOLCK 37
57 | #define ENOSYS 38
58 | #define ENOTEMPTY 39
59 |
60 | #endif
61 |
--------------------------------------------------------------------------------
/src/V0.11/include/fcntl.h:
--------------------------------------------------------------------------------
1 | #ifndef _FCNTL_H
2 | #define _FCNTL_H
3 |
4 | #include
5 |
6 | /* open/fcntl - NOCTTY, NDELAY isn't implemented yet */
7 | #define O_ACCMODE 00003
8 | #define O_RDONLY 00
9 | #define O_WRONLY 01
10 | #define O_RDWR 02
11 | #define O_CREAT 00100 /* not fcntl */
12 | #define O_EXCL 00200 /* not fcntl */
13 | #define O_NOCTTY 00400 /* not fcntl */
14 | #define O_TRUNC 01000 /* not fcntl */
15 | #define O_APPEND 02000
16 | #define O_NONBLOCK 04000 /* not fcntl */
17 | #define O_NDELAY O_NONBLOCK
18 |
19 | /* Defines for fcntl-commands. Note that currently
20 | * locking isn't supported, and other things aren't really
21 | * tested.
22 | */
23 | #define F_DUPFD 0 /* dup */
24 | #define F_GETFD 1 /* get f_flags */
25 | #define F_SETFD 2 /* set f_flags */
26 | #define F_GETFL 3 /* more flags (cloexec) */
27 | #define F_SETFL 4
28 | #define F_GETLK 5 /* not implemented */
29 | #define F_SETLK 6
30 | #define F_SETLKW 7
31 |
32 | /* for F_[GET|SET]FL */
33 | #define FD_CLOEXEC 1 /* actually anything with low bit set goes */
34 |
35 | /* Ok, these are locking features, and aren't implemented at any
36 | * level. POSIX wants them.
37 | */
38 | #define F_RDLCK 0
39 | #define F_WRLCK 1
40 | #define F_UNLCK 2
41 |
42 | /* Once again - not implemented, but ... */
43 | struct flock {
44 | short l_type;
45 | short l_whence;
46 | off_t l_start;
47 | off_t l_len;
48 | pid_t l_pid;
49 | };
50 |
51 | extern int creat(const char * filename,mode_t mode);
52 | extern int fcntl(int fildes,int cmd, ...);
53 | extern int open(const char * filename, int flags, ...);
54 |
55 | #endif
56 |
--------------------------------------------------------------------------------
/src/V0.11/include/linux/config.h:
--------------------------------------------------------------------------------
1 | #ifndef _CONFIG_H
2 | #define _CONFIG_H
3 |
4 | /*
5 | * The root-device is no longer hard-coded. You can change the default
6 | * root-device by changing the line ROOT_DEV = XXX in boot/bootsect.s
7 | */
8 |
9 | /*
10 | * define your keyboard here -
11 | * KBD_FINNISH for Finnish keyboards
12 | * KBD_US for US-type
13 | * KBD_GR for German keyboards
14 | * KBD_FR for Frech keyboard
15 | */
16 | /*#define KBD_US */
17 | /*#define KBD_GR */
18 | /*#define KBD_FR */
19 | #define KBD_FINNISH
20 |
21 | /*
22 | * Normally, Linux can get the drive parameters from the BIOS at
23 | * startup, but if this for some unfathomable reason fails, you'd
24 | * be left stranded. For this case, you can define HD_TYPE, which
25 | * contains all necessary info on your harddisk.
26 | *
27 | * The HD_TYPE macro should look like this:
28 | *
29 | * #define HD_TYPE { head, sect, cyl, wpcom, lzone, ctl}
30 | *
31 | * In case of two harddisks, the info should be sepatated by
32 | * commas:
33 | *
34 | * #define HD_TYPE { h,s,c,wpcom,lz,ctl },{ h,s,c,wpcom,lz,ctl }
35 | */
36 | /*
37 | This is an example, two drives, first is type 2, second is type 3:
38 |
39 | #define HD_TYPE { 4,17,615,300,615,8 }, { 6,17,615,300,615,0 }
40 |
41 | NOTE: ctl is 0 for all drives with heads<=8, and ctl=8 for drives
42 | with more than 8 heads.
43 |
44 | If you want the BIOS to tell what kind of drive you have, just
45 | leave HD_TYPE undefined. This is the normal thing to do.
46 | */
47 |
48 | #endif
49 |
--------------------------------------------------------------------------------
/src/V0.11/include/linux/fdreg.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file contains some defines for the floppy disk controller.
3 | * Various sources. Mostly "IBM Microcomputers: A Programmers
4 | * Handbook", Sanches and Canton.
5 | */
6 | #ifndef _FDREG_H
7 | #define _FDREG_H
8 |
9 | extern int ticks_to_floppy_on(unsigned int nr);
10 | extern void floppy_on(unsigned int nr);
11 | extern void floppy_off(unsigned int nr);
12 | extern void floppy_select(unsigned int nr);
13 | extern void floppy_deselect(unsigned int nr);
14 |
15 | /* Fd controller regs. S&C, about page 340 */
16 | #define FD_STATUS 0x3f4
17 | #define FD_DATA 0x3f5
18 | #define FD_DOR 0x3f2 /* Digital Output Register */
19 | #define FD_DIR 0x3f7 /* Digital Input Register (read) */
20 | #define FD_DCR 0x3f7 /* Diskette Control Register (write)*/
21 |
22 | /* Bits of main status register */
23 | #define STATUS_BUSYMASK 0x0F /* drive busy mask */
24 | #define STATUS_BUSY 0x10 /* FDC busy */
25 | #define STATUS_DMA 0x20 /* 0- DMA mode */
26 | #define STATUS_DIR 0x40 /* 0- cpu->fdc */
27 | #define STATUS_READY 0x80 /* Data reg ready */
28 |
29 | /* Bits of FD_ST0 */
30 | #define ST0_DS 0x03 /* drive select mask */
31 | #define ST0_HA 0x04 /* Head (Address) */
32 | #define ST0_NR 0x08 /* Not Ready */
33 | #define ST0_ECE 0x10 /* Equipment chech error */
34 | #define ST0_SE 0x20 /* Seek end */
35 | #define ST0_INTR 0xC0 /* Interrupt code mask */
36 |
37 | /* Bits of FD_ST1 */
38 | #define ST1_MAM 0x01 /* Missing Address Mark */
39 | #define ST1_WP 0x02 /* Write Protect */
40 | #define ST1_ND 0x04 /* No Data - unreadable */
41 | #define ST1_OR 0x10 /* OverRun */
42 | #define ST1_CRC 0x20 /* CRC error in data or addr */
43 | #define ST1_EOC 0x80 /* End Of Cylinder */
44 |
45 | /* Bits of FD_ST2 */
46 | #define ST2_MAM 0x01 /* Missing Addess Mark (again) */
47 | #define ST2_BC 0x02 /* Bad Cylinder */
48 | #define ST2_SNS 0x04 /* Scan Not Satisfied */
49 | #define ST2_SEH 0x08 /* Scan Equal Hit */
50 | #define ST2_WC 0x10 /* Wrong Cylinder */
51 | #define ST2_CRC 0x20 /* CRC error in data field */
52 | #define ST2_CM 0x40 /* Control Mark = deleted */
53 |
54 | /* Bits of FD_ST3 */
55 | #define ST3_HA 0x04 /* Head (Address) */
56 | #define ST3_TZ 0x10 /* Track Zero signal (1=track 0) */
57 | #define ST3_WP 0x40 /* Write Protect */
58 |
59 | /* Values for FD_COMMAND */
60 | #define FD_RECALIBRATE 0x07 /* move to track 0 */
61 | #define FD_SEEK 0x0F /* seek track */
62 | #define FD_READ 0xE6 /* read with MT, MFM, SKip deleted */
63 | #define FD_WRITE 0xC5 /* write with MT, MFM */
64 | #define FD_SENSEI 0x08 /* Sense Interrupt Status */
65 | #define FD_SPECIFY 0x03 /* specify HUT etc */
66 |
67 | /* DMA commands */
68 | #define DMA_READ 0x46
69 | #define DMA_WRITE 0x4A
70 |
71 | #endif
72 |
--------------------------------------------------------------------------------
/src/V0.11/include/linux/hdreg.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file contains some defines for the AT-hd-controller.
3 | * Various sources. Check out some definitions (see comments with
4 | * a ques).
5 | */
6 | #ifndef _HDREG_H
7 | #define _HDREG_H
8 |
9 | /* Hd controller regs. Ref: IBM AT Bios-listing */
10 | #define HD_DATA 0x1f0 /* _CTL when writing */
11 | #define HD_ERROR 0x1f1 /* see err-bits */
12 | #define HD_NSECTOR 0x1f2 /* nr of sectors to read/write */
13 | #define HD_SECTOR 0x1f3 /* starting sector */
14 | #define HD_LCYL 0x1f4 /* starting cylinder */
15 | #define HD_HCYL 0x1f5 /* high byte of starting cyl */
16 | #define HD_CURRENT 0x1f6 /* 101dhhhh , d=drive, hhhh=head */
17 | #define HD_STATUS 0x1f7 /* see status-bits */
18 | #define HD_PRECOMP HD_ERROR /* same io address, read=error, write=precomp */
19 | #define HD_COMMAND HD_STATUS /* same io address, read=status, write=cmd */
20 |
21 | #define HD_CMD 0x3f6
22 |
23 | /* Bits of HD_STATUS */
24 | #define ERR_STAT 0x01
25 | #define INDEX_STAT 0x02
26 | #define ECC_STAT 0x04 /* Corrected error */
27 | #define DRQ_STAT 0x08
28 | #define SEEK_STAT 0x10
29 | #define WRERR_STAT 0x20
30 | #define READY_STAT 0x40
31 | #define BUSY_STAT 0x80
32 |
33 | /* Values for HD_COMMAND */
34 | #define WIN_RESTORE 0x10
35 | #define WIN_READ 0x20
36 | #define WIN_WRITE 0x30
37 | #define WIN_VERIFY 0x40
38 | #define WIN_FORMAT 0x50
39 | #define WIN_INIT 0x60
40 | #define WIN_SEEK 0x70
41 | #define WIN_DIAGNOSE 0x90
42 | #define WIN_SPECIFY 0x91
43 |
44 | /* Bits for HD_ERROR */
45 | #define MARK_ERR 0x01 /* Bad address mark ? */
46 | #define TRK0_ERR 0x02 /* couldn't find track 0 */
47 | #define ABRT_ERR 0x04 /* ? */
48 | #define ID_ERR 0x10 /* ? */
49 | #define ECC_ERR 0x40 /* ? */
50 | #define BBD_ERR 0x80 /* ? */
51 |
52 | struct partition {
53 | unsigned char boot_ind; /* 0x80 - active (unused) */
54 | unsigned char head; /* ? */
55 | unsigned char sector; /* ? */
56 | unsigned char cyl; /* ? */
57 | unsigned char sys_ind; /* ? */
58 | unsigned char end_head; /* ? */
59 | unsigned char end_sector; /* ? */
60 | unsigned char end_cyl; /* ? */
61 | unsigned int start_sect; /* starting sector counting from 0 */
62 | unsigned int nr_sects; /* nr of sectors in partition */
63 | };
64 |
65 | #endif
66 |
--------------------------------------------------------------------------------
/src/V0.11/include/linux/head.h:
--------------------------------------------------------------------------------
1 | #ifndef _HEAD_H
2 | #define _HEAD_H
3 |
4 | typedef struct desc_struct {
5 | unsigned long a,b;
6 | } desc_table[256];
7 |
8 | extern unsigned long pg_dir[1024];
9 | extern desc_table idt,gdt;
10 |
11 | #define GDT_NUL 0
12 | #define GDT_CODE 1
13 | #define GDT_DATA 2
14 | #define GDT_TMP 3
15 |
16 | #define LDT_NUL 0
17 | #define LDT_CODE 1
18 | #define LDT_DATA 2
19 |
20 | #endif
21 |
--------------------------------------------------------------------------------
/src/V0.11/include/linux/kernel.h:
--------------------------------------------------------------------------------
1 | /*
2 | * 'kernel.h' contains some often-used function prototypes etc
3 | */
4 | void verify_area(void * addr,int count);
5 | volatile void panic(const char * str);
6 | int printf(const char * fmt, ...);
7 | int printk(const char * fmt, ...);
8 | int tty_write(unsigned ch,char * buf,int count);
9 | void * malloc(unsigned int size);
10 | void free_s(void * obj, int size);
11 |
12 | #define free(x) free_s((x), 0)
13 |
14 | /*
15 | * This is defined as a macro, but at some point this might become a
16 | * real subroutine that sets a flag if it returns true (to do
17 | * BSD-style accounting where the process is flagged if it uses root
18 | * privs). The implication of this is that you should do normal
19 | * permissions checks first, and check suser() last.
20 | */
21 | #define suser() (current->euid == 0)
22 |
23 |
--------------------------------------------------------------------------------
/src/V0.11/include/linux/mm.h:
--------------------------------------------------------------------------------
1 | #ifndef _MM_H
2 | #define _MM_H
3 |
4 | #define PAGE_SIZE 4096
5 |
6 | extern unsigned long get_free_page(void);
7 | extern unsigned long put_page(unsigned long page,unsigned long address);
8 | extern void free_page(unsigned long addr);
9 |
10 | #endif
11 |
--------------------------------------------------------------------------------
/src/V0.11/include/linux/sys.h:
--------------------------------------------------------------------------------
1 | extern int sys_setup();
2 | extern int sys_exit();
3 | extern int sys_fork();
4 | extern int sys_read();
5 | extern int sys_write();
6 | extern int sys_open();
7 | extern int sys_close();
8 | extern int sys_waitpid();
9 | extern int sys_creat();
10 | extern int sys_link();
11 | extern int sys_unlink();
12 | extern int sys_execve();
13 | extern int sys_chdir();
14 | extern int sys_time();
15 | extern int sys_mknod();
16 | extern int sys_chmod();
17 | extern int sys_chown();
18 | extern int sys_break();
19 | extern int sys_stat();
20 | extern int sys_lseek();
21 | extern int sys_getpid();
22 | extern int sys_mount();
23 | extern int sys_umount();
24 | extern int sys_setuid();
25 | extern int sys_getuid();
26 | extern int sys_stime();
27 | extern int sys_ptrace();
28 | extern int sys_alarm();
29 | extern int sys_fstat();
30 | extern int sys_pause();
31 | extern int sys_utime();
32 | extern int sys_stty();
33 | extern int sys_gtty();
34 | extern int sys_access();
35 | extern int sys_nice();
36 | extern int sys_ftime();
37 | extern int sys_sync();
38 | extern int sys_kill();
39 | extern int sys_rename();
40 | extern int sys_mkdir();
41 | extern int sys_rmdir();
42 | extern int sys_dup();
43 | extern int sys_pipe();
44 | extern int sys_times();
45 | extern int sys_prof();
46 | extern int sys_brk();
47 | extern int sys_setgid();
48 | extern int sys_getgid();
49 | extern int sys_signal();
50 | extern int sys_geteuid();
51 | extern int sys_getegid();
52 | extern int sys_acct();
53 | extern int sys_phys();
54 | extern int sys_lock();
55 | extern int sys_ioctl();
56 | extern int sys_fcntl();
57 | extern int sys_mpx();
58 | extern int sys_setpgid();
59 | extern int sys_ulimit();
60 | extern int sys_uname();
61 | extern int sys_umask();
62 | extern int sys_chroot();
63 | extern int sys_ustat();
64 | extern int sys_dup2();
65 | extern int sys_getppid();
66 | extern int sys_getpgrp();
67 | extern int sys_setsid();
68 | extern int sys_sigaction();
69 | extern int sys_sgetmask();
70 | extern int sys_ssetmask();
71 | extern int sys_setreuid();
72 | extern int sys_setregid();
73 |
74 | fn_ptr sys_call_table[] = { sys_setup, sys_exit, sys_fork, sys_read,
75 | sys_write, sys_open, sys_close, sys_waitpid, sys_creat, sys_link,
76 | sys_unlink, sys_execve, sys_chdir, sys_time, sys_mknod, sys_chmod,
77 | sys_chown, sys_break, sys_stat, sys_lseek, sys_getpid, sys_mount,
78 | sys_umount, sys_setuid, sys_getuid, sys_stime, sys_ptrace, sys_alarm,
79 | sys_fstat, sys_pause, sys_utime, sys_stty, sys_gtty, sys_access,
80 | sys_nice, sys_ftime, sys_sync, sys_kill, sys_rename, sys_mkdir,
81 | sys_rmdir, sys_dup, sys_pipe, sys_times, sys_prof, sys_brk, sys_setgid,
82 | sys_getgid, sys_signal, sys_geteuid, sys_getegid, sys_acct, sys_phys,
83 | sys_lock, sys_ioctl, sys_fcntl, sys_mpx, sys_setpgid, sys_ulimit,
84 | sys_uname, sys_umask, sys_chroot, sys_ustat, sys_dup2, sys_getppid,
85 | sys_getpgrp, sys_setsid, sys_sigaction, sys_sgetmask, sys_ssetmask,
86 | sys_setreuid,sys_setregid };
87 |
--------------------------------------------------------------------------------
/src/V0.11/include/linux/tty.h:
--------------------------------------------------------------------------------
1 | /*
2 | * 'tty.h' defines some structures used by tty_io.c and some defines.
3 | *
4 | * NOTE! Don't touch this without checking that nothing in rs_io.s or
5 | * con_io.s breaks. Some constants are hardwired into the system (mainly
6 | * offsets into 'tty_queue'
7 | */
8 |
9 | #ifndef _TTY_H
10 | #define _TTY_H
11 |
12 | #include
13 |
14 | #define TTY_BUF_SIZE 1024
15 |
16 | struct tty_queue {
17 | unsigned long data;
18 | unsigned long head;
19 | unsigned long tail;
20 | struct task_struct * proc_list;
21 | char buf[TTY_BUF_SIZE];
22 | };
23 |
24 | #define INC(a) ((a) = ((a)+1) & (TTY_BUF_SIZE-1))
25 | #define DEC(a) ((a) = ((a)-1) & (TTY_BUF_SIZE-1))
26 | #define EMPTY(a) ((a).head == (a).tail)
27 | #define LEFT(a) (((a).tail-(a).head-1)&(TTY_BUF_SIZE-1))
28 | #define LAST(a) ((a).buf[(TTY_BUF_SIZE-1)&((a).head-1)])
29 | #define FULL(a) (!LEFT(a))
30 | #define CHARS(a) (((a).head-(a).tail)&(TTY_BUF_SIZE-1))
31 | #define GETCH(queue,c) \
32 | (void)({c=(queue).buf[(queue).tail];INC((queue).tail);})
33 | #define PUTCH(c,queue) \
34 | (void)({(queue).buf[(queue).head]=(c);INC((queue).head);})
35 |
36 | #define INTR_CHAR(tty) ((tty)->termios.c_cc[VINTR])
37 | #define QUIT_CHAR(tty) ((tty)->termios.c_cc[VQUIT])
38 | #define ERASE_CHAR(tty) ((tty)->termios.c_cc[VERASE])
39 | #define KILL_CHAR(tty) ((tty)->termios.c_cc[VKILL])
40 | #define EOF_CHAR(tty) ((tty)->termios.c_cc[VEOF])
41 | #define START_CHAR(tty) ((tty)->termios.c_cc[VSTART])
42 | #define STOP_CHAR(tty) ((tty)->termios.c_cc[VSTOP])
43 | #define SUSPEND_CHAR(tty) ((tty)->termios.c_cc[VSUSP])
44 |
45 | struct tty_struct {
46 | struct termios termios;
47 | int pgrp;
48 | int stopped;
49 | void (*write)(struct tty_struct * tty);
50 | struct tty_queue read_q;
51 | struct tty_queue write_q;
52 | struct tty_queue secondary;
53 | };
54 |
55 | extern struct tty_struct tty_table[];
56 |
57 | /* intr=^C quit=^| erase=del kill=^U
58 | eof=^D vtime=\0 vmin=\1 sxtc=\0
59 | start=^Q stop=^S susp=^Z eol=\0
60 | reprint=^R discard=^U werase=^W lnext=^V
61 | eol2=\0
62 | */
63 | #define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
64 |
65 | void rs_init(void);
66 | void con_init(void);
67 | void tty_init(void);
68 |
69 | int tty_read(unsigned c, char * buf, int n);
70 | int tty_write(unsigned c, char * buf, int n);
71 |
72 | void rs_write(struct tty_struct * tty);
73 | void con_write(struct tty_struct * tty);
74 |
75 | void copy_to_cooked(struct tty_struct * tty);
76 |
77 | #endif
78 |
--------------------------------------------------------------------------------
/src/V0.11/include/signal.h:
--------------------------------------------------------------------------------
1 | #ifndef _SIGNAL_H
2 | #define _SIGNAL_H
3 |
4 | #include
5 |
6 | typedef int sig_atomic_t;
7 | typedef unsigned int sigset_t; /* 32 bits */
8 |
9 | #define _NSIG 32
10 | #define NSIG _NSIG
11 |
12 | #define SIGHUP 1
13 | #define SIGINT 2
14 | #define SIGQUIT 3
15 | #define SIGILL 4
16 | #define SIGTRAP 5
17 | #define SIGABRT 6
18 | #define SIGIOT 6
19 | #define SIGUNUSED 7
20 | #define SIGFPE 8
21 | #define SIGKILL 9
22 | #define SIGUSR1 10
23 | #define SIGSEGV 11
24 | #define SIGUSR2 12
25 | #define SIGPIPE 13
26 | #define SIGALRM 14
27 | #define SIGTERM 15
28 | #define SIGSTKFLT 16
29 | #define SIGCHLD 17
30 | #define SIGCONT 18
31 | #define SIGSTOP 19
32 | #define SIGTSTP 20
33 | #define SIGTTIN 21
34 | #define SIGTTOU 22
35 |
36 | /* Ok, I haven't implemented sigactions, but trying to keep headers POSIX */
37 | #define SA_NOCLDSTOP 1
38 | #define SA_NOMASK 0x40000000
39 | #define SA_ONESHOT 0x80000000
40 |
41 | #define SIG_BLOCK 0 /* for blocking signals */
42 | #define SIG_UNBLOCK 1 /* for unblocking signals */
43 | #define SIG_SETMASK 2 /* for setting the signal mask */
44 |
45 | #define SIG_DFL ((void (*)(int))0) /* default signal handling */
46 | #define SIG_IGN ((void (*)(int))1) /* ignore signal */
47 |
48 | struct sigaction {
49 | void (*sa_handler)(int);
50 | sigset_t sa_mask;
51 | int sa_flags;
52 | void (*sa_restorer)(void);
53 | };
54 |
55 | void (*signal(int _sig, void (*_func)(int)))(int);
56 | int raise(int sig);
57 | int kill(pid_t pid, int sig);
58 | int sigaddset(sigset_t *mask, int signo);
59 | int sigdelset(sigset_t *mask, int signo);
60 | int sigemptyset(sigset_t *mask);
61 | int sigfillset(sigset_t *mask);
62 | int sigismember(sigset_t *mask, int signo); /* 1 - is, 0 - not, -1 error */
63 | int sigpending(sigset_t *set);
64 | int sigprocmask(int how, sigset_t *set, sigset_t *oldset);
65 | int sigsuspend(sigset_t *sigmask);
66 | int sigaction(int sig, struct sigaction *act, struct sigaction *oldact);
67 |
68 | #endif /* _SIGNAL_H */
69 |
--------------------------------------------------------------------------------
/src/V0.11/include/stdarg.h:
--------------------------------------------------------------------------------
1 | #ifndef _STDARG_H
2 | #define _STDARG_H
3 |
4 | typedef char *va_list;
5 |
6 | /* Amount of space required in an argument list for an arg of type TYPE.
7 | TYPE may alternatively be an expression whose type is used. */
8 |
9 | #define __va_rounded_size(TYPE) \
10 | (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
11 |
12 | #ifndef __sparc__
13 | #define va_start(AP, LASTARG) \
14 | (AP = ((char *) &(LASTARG) + __va_rounded_size (LASTARG)))
15 | #else
16 | #define va_start(AP, LASTARG) \
17 | (__builtin_saveregs (), \
18 | AP = ((char *) &(LASTARG) + __va_rounded_size (LASTARG)))
19 | #endif
20 |
21 | void va_end (va_list); /* Defined in gnulib */
22 | #define va_end(AP)
23 |
24 | #define va_arg(AP, TYPE) \
25 | (AP += __va_rounded_size (TYPE), \
26 | *((TYPE *) (AP - __va_rounded_size (TYPE))))
27 |
28 | #endif /* _STDARG_H */
29 |
--------------------------------------------------------------------------------
/src/V0.11/include/stddef.h:
--------------------------------------------------------------------------------
1 | #ifndef _STDDEF_H
2 | #define _STDDEF_H
3 |
4 | #ifndef _PTRDIFF_T
5 | #define _PTRDIFF_T
6 | typedef long ptrdiff_t;
7 | #endif
8 |
9 | #ifndef _SIZE_T
10 | #define _SIZE_T
11 | typedef unsigned long size_t;
12 | #endif
13 |
14 | #undef NULL
15 | #define NULL ((void *)0)
16 |
17 | #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
18 |
19 | #endif
20 |
--------------------------------------------------------------------------------
/src/V0.11/include/sys/stat.h:
--------------------------------------------------------------------------------
1 | #ifndef _SYS_STAT_H
2 | #define _SYS_STAT_H
3 |
4 | #include
5 |
6 | struct stat {
7 | dev_t st_dev;
8 | ino_t st_ino;
9 | umode_t st_mode;
10 | nlink_t st_nlink;
11 | uid_t st_uid;
12 | gid_t st_gid;
13 | dev_t st_rdev;
14 | off_t st_size;
15 | time_t st_atime;
16 | time_t st_mtime;
17 | time_t st_ctime;
18 | };
19 |
20 | #define S_IFMT 00170000
21 | #define S_IFREG 0100000
22 | #define S_IFBLK 0060000
23 | #define S_IFDIR 0040000
24 | #define S_IFCHR 0020000
25 | #define S_IFIFO 0010000
26 | #define S_ISUID 0004000
27 | #define S_ISGID 0002000
28 | #define S_ISVTX 0001000
29 |
30 | #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
31 | #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
32 | #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
33 | #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
34 | #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
35 |
36 | #define S_IRWXU 00700
37 | #define S_IRUSR 00400
38 | #define S_IWUSR 00200
39 | #define S_IXUSR 00100
40 |
41 | #define S_IRWXG 00070
42 | #define S_IRGRP 00040
43 | #define S_IWGRP 00020
44 | #define S_IXGRP 00010
45 |
46 | #define S_IRWXO 00007
47 | #define S_IROTH 00004
48 | #define S_IWOTH 00002
49 | #define S_IXOTH 00001
50 |
51 | extern int chmod(const char *_path, mode_t mode);
52 | extern int fstat(int fildes, struct stat *stat_buf);
53 | extern int mkdir(const char *_path, mode_t mode);
54 | extern int mkfifo(const char *_path, mode_t mode);
55 | extern int stat(const char *filename, struct stat *stat_buf);
56 | extern mode_t umask(mode_t mask);
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------
/src/V0.11/include/sys/times.h:
--------------------------------------------------------------------------------
1 | #ifndef _TIMES_H
2 | #define _TIMES_H
3 |
4 | #include
5 |
6 | struct tms {
7 | time_t tms_utime;
8 | time_t tms_stime;
9 | time_t tms_cutime;
10 | time_t tms_cstime;
11 | };
12 |
13 | extern time_t times(struct tms * tp);
14 |
15 | #endif
16 |
--------------------------------------------------------------------------------
/src/V0.11/include/sys/types.h:
--------------------------------------------------------------------------------
1 | #ifndef _SYS_TYPES_H
2 | #define _SYS_TYPES_H
3 |
4 | #ifndef _SIZE_T
5 | #define _SIZE_T
6 | typedef unsigned int size_t;
7 | #endif
8 |
9 | #ifndef _TIME_T
10 | #define _TIME_T
11 | typedef long time_t;
12 | #endif
13 |
14 | #ifndef _PTRDIFF_T
15 | #define _PTRDIFF_T
16 | typedef long ptrdiff_t;
17 | #endif
18 |
19 | #ifndef NULL
20 | #define NULL ((void *) 0)
21 | #endif
22 |
23 | typedef int pid_t;
24 | typedef unsigned short uid_t;
25 | typedef unsigned char gid_t;
26 | typedef unsigned short dev_t;
27 | typedef unsigned short ino_t;
28 | typedef unsigned short mode_t;
29 | typedef unsigned short umode_t;
30 | typedef unsigned char nlink_t;
31 | typedef int daddr_t;
32 | typedef long off_t;
33 | typedef unsigned char u_char;
34 | typedef unsigned short ushort;
35 |
36 | typedef struct { int quot,rem; } div_t;
37 | typedef struct { long quot,rem; } ldiv_t;
38 |
39 | struct ustat {
40 | daddr_t f_tfree;
41 | ino_t f_tinode;
42 | char f_fname[6];
43 | char f_fpack[6];
44 | };
45 |
46 | #endif
47 |
--------------------------------------------------------------------------------
/src/V0.11/include/sys/utsname.h:
--------------------------------------------------------------------------------
1 | #ifndef _SYS_UTSNAME_H
2 | #define _SYS_UTSNAME_H
3 |
4 | #include
5 |
6 | struct utsname {
7 | char sysname[9];
8 | char nodename[9];
9 | char release[9];
10 | char version[9];
11 | char machine[9];
12 | };
13 |
14 | extern int uname(struct utsname * utsbuf);
15 |
16 | #endif
17 |
--------------------------------------------------------------------------------
/src/V0.11/include/sys/wait.h:
--------------------------------------------------------------------------------
1 | #ifndef _SYS_WAIT_H
2 | #define _SYS_WAIT_H
3 |
4 | #include
5 |
6 | #define _LOW(v) ( (v) & 0377)
7 | #define _HIGH(v) ( ((v) >> 8) & 0377)
8 |
9 | /* options for waitpid, WUNTRACED not supported */
10 | #define WNOHANG 1
11 | #define WUNTRACED 2
12 |
13 | #define WIFEXITED(s) (!((s)&0xFF)
14 | #define WIFSTOPPED(s) (((s)&0xFF)==0x7F)
15 | #define WEXITSTATUS(s) (((s)>>8)&0xFF)
16 | #define WTERMSIG(s) ((s)&0x7F)
17 | #define WSTOPSIG(s) (((s)>>8)&0xFF)
18 | #define WIFSIGNALED(s) (((unsigned int)(s)-1 & 0xFFFF) < 0xFF)
19 |
20 | pid_t wait(int *stat_loc);
21 | pid_t waitpid(pid_t pid, int *stat_loc, int options);
22 |
23 | #endif
24 |
--------------------------------------------------------------------------------
/src/V0.11/include/time.h:
--------------------------------------------------------------------------------
1 | #ifndef _TIME_H
2 | #define _TIME_H
3 |
4 | #ifndef _TIME_T
5 | #define _TIME_T
6 | typedef long time_t;
7 | #endif
8 |
9 | #ifndef _SIZE_T
10 | #define _SIZE_T
11 | typedef unsigned int size_t;
12 | #endif
13 |
14 | #define CLOCKS_PER_SEC 100
15 |
16 | typedef long clock_t;
17 |
18 | struct tm {
19 | int tm_sec;
20 | int tm_min;
21 | int tm_hour;
22 | int tm_mday;
23 | int tm_mon;
24 | int tm_year;
25 | int tm_wday;
26 | int tm_yday;
27 | int tm_isdst;
28 | };
29 |
30 | clock_t clock(void);
31 | time_t time(time_t * tp);
32 | double difftime(time_t time2, time_t time1);
33 | time_t mktime(struct tm * tp);
34 |
35 | char * asctime(const struct tm * tp);
36 | char * ctime(const time_t * tp);
37 | struct tm * gmtime(const time_t *tp);
38 | struct tm *localtime(const time_t * tp);
39 | size_t strftime(char * s, size_t smax, const char * fmt, const struct tm * tp);
40 | void tzset(void);
41 |
42 | #endif
43 |
--------------------------------------------------------------------------------
/src/V0.11/include/utime.h:
--------------------------------------------------------------------------------
1 | #ifndef _UTIME_H
2 | #define _UTIME_H
3 |
4 | #include /* I know - shouldn't do this, but .. */
5 |
6 | struct utimbuf {
7 | time_t actime;
8 | time_t modtime;
9 | };
10 |
11 | extern int utime(const char *filename, struct utimbuf *times);
12 |
13 | #endif
14 |
--------------------------------------------------------------------------------
/src/V0.11/kernel/blk_drv/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile for the FREAX-kernel block device drivers.
3 | #
4 | # Note! Dependencies are done automagically by 'make dep', which also
5 | # removes any old dependencies. DON'T put your own dependencies here
6 | # unless it's something special (ie not a .c file).
7 | #
8 |
9 | AR =gar
10 | AS =gas
11 | LD =gld
12 | LDFLAGS =-s -x
13 | CC =gcc
14 | CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer -fcombine-regs \
15 | -finline-functions -mstring-insns -nostdinc -I../../include
16 | CPP =gcc -E -nostdinc -I../../include
17 |
18 | .c.s:
19 | $(CC) $(CFLAGS) \
20 | -S -o $*.s $<
21 | .s.o:
22 | $(AS) -c -o $*.o $<
23 | .c.o:
24 | $(CC) $(CFLAGS) \
25 | -c -o $*.o $<
26 |
27 | OBJS = ll_rw_blk.o floppy.o hd.o ramdisk.o
28 |
29 | blk_drv.a: $(OBJS)
30 | $(AR) rcs blk_drv.a $(OBJS)
31 | sync
32 |
33 | clean:
34 | rm -f core *.o *.a tmp_make
35 | for i in *.c;do rm -f `basename $$i .c`.s;done
36 |
37 | dep:
38 | sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
39 | (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \
40 | $(CPP) -M $$i;done) >> tmp_make
41 | cp tmp_make Makefile
42 |
43 | ### Dependencies:
44 | floppy.s floppy.o : floppy.c ../../include/linux/sched.h ../../include/linux/head.h \
45 | ../../include/linux/fs.h ../../include/sys/types.h ../../include/linux/mm.h \
46 | ../../include/signal.h ../../include/linux/kernel.h \
47 | ../../include/linux/fdreg.h ../../include/asm/system.h \
48 | ../../include/asm/io.h ../../include/asm/segment.h blk.h
49 | hd.s hd.o : hd.c ../../include/linux/config.h ../../include/linux/sched.h \
50 | ../../include/linux/head.h ../../include/linux/fs.h \
51 | ../../include/sys/types.h ../../include/linux/mm.h ../../include/signal.h \
52 | ../../include/linux/kernel.h ../../include/linux/hdreg.h \
53 | ../../include/asm/system.h ../../include/asm/io.h \
54 | ../../include/asm/segment.h blk.h
55 | ll_rw_blk.s ll_rw_blk.o : ll_rw_blk.c ../../include/errno.h ../../include/linux/sched.h \
56 | ../../include/linux/head.h ../../include/linux/fs.h \
57 | ../../include/sys/types.h ../../include/linux/mm.h ../../include/signal.h \
58 | ../../include/linux/kernel.h ../../include/asm/system.h blk.h
59 |
--------------------------------------------------------------------------------
/src/V0.11/kernel/chr_drv/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile for the FREAX-kernel character device drivers.
3 | #
4 | # Note! Dependencies are done automagically by 'make dep', which also
5 | # removes any old dependencies. DON'T put your own dependencies here
6 | # unless it's something special (ie not a .c file).
7 | #
8 |
9 | AR =gar
10 | AS =gas
11 | LD =gld
12 | LDFLAGS =-s -x
13 | CC =gcc
14 | CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer -fcombine-regs \
15 | -finline-functions -mstring-insns -nostdinc -I../../include
16 | CPP =gcc -E -nostdinc -I../../include
17 |
18 | .c.s:
19 | $(CC) $(CFLAGS) \
20 | -S -o $*.s $<
21 | .s.o:
22 | $(AS) -c -o $*.o $<
23 | .c.o:
24 | $(CC) $(CFLAGS) \
25 | -c -o $*.o $<
26 |
27 | OBJS = tty_io.o console.o keyboard.o serial.o rs_io.o \
28 | tty_ioctl.o
29 |
30 | chr_drv.a: $(OBJS)
31 | $(AR) rcs chr_drv.a $(OBJS)
32 | sync
33 |
34 | keyboard.s: keyboard.S ../../include/linux/config.h
35 | $(CPP) -traditional keyboard.S -o keyboard.s
36 |
37 | clean:
38 | rm -f core *.o *.a tmp_make keyboard.s
39 | for i in *.c;do rm -f `basename $$i .c`.s;done
40 |
41 | dep:
42 | sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
43 | (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \
44 | $(CPP) -M $$i;done) >> tmp_make
45 | cp tmp_make Makefile
46 |
47 | ### Dependencies:
48 | console.s console.o : console.c ../../include/linux/sched.h \
49 | ../../include/linux/head.h ../../include/linux/fs.h \
50 | ../../include/sys/types.h ../../include/linux/mm.h ../../include/signal.h \
51 | ../../include/linux/tty.h ../../include/termios.h ../../include/asm/io.h \
52 | ../../include/asm/system.h
53 | serial.s serial.o : serial.c ../../include/linux/tty.h ../../include/termios.h \
54 | ../../include/linux/sched.h ../../include/linux/head.h \
55 | ../../include/linux/fs.h ../../include/sys/types.h ../../include/linux/mm.h \
56 | ../../include/signal.h ../../include/asm/system.h ../../include/asm/io.h
57 | tty_io.s tty_io.o : tty_io.c ../../include/ctype.h ../../include/errno.h \
58 | ../../include/signal.h ../../include/sys/types.h \
59 | ../../include/linux/sched.h ../../include/linux/head.h \
60 | ../../include/linux/fs.h ../../include/linux/mm.h ../../include/linux/tty.h \
61 | ../../include/termios.h ../../include/asm/segment.h \
62 | ../../include/asm/system.h
63 | tty_ioctl.s tty_ioctl.o : tty_ioctl.c ../../include/errno.h ../../include/termios.h \
64 | ../../include/linux/sched.h ../../include/linux/head.h \
65 | ../../include/linux/fs.h ../../include/sys/types.h ../../include/linux/mm.h \
66 | ../../include/signal.h ../../include/linux/kernel.h \
67 | ../../include/linux/tty.h ../../include/asm/io.h \
68 | ../../include/asm/segment.h ../../include/asm/system.h
69 |
--------------------------------------------------------------------------------
/src/V0.11/kernel/chr_drv/serial.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/kernel/serial.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | /*
8 | * serial.c
9 | *
10 | * This module implements the rs232 io functions
11 | * void rs_write(struct tty_struct * queue);
12 | * void rs_init(void);
13 | * and all interrupts pertaining to serial IO.
14 | */
15 |
16 | #include
17 | #include
18 | #include
19 | #include
20 |
21 | #define WAKEUP_CHARS (TTY_BUF_SIZE/4)
22 |
23 | extern void rs1_interrupt(void);
24 | extern void rs2_interrupt(void);
25 |
26 | static void init(int port)
27 | {
28 | outb_p(0x80,port+3); /* set DLAB of line control reg */
29 | outb_p(0x30,port); /* LS of divisor (48 -> 2400 bps */
30 | outb_p(0x00,port+1); /* MS of divisor */
31 | outb_p(0x03,port+3); /* reset DLAB */
32 | outb_p(0x0b,port+4); /* set DTR,RTS, OUT_2 */
33 | outb_p(0x0d,port+1); /* enable all intrs but writes */
34 | (void)inb(port); /* read data port to reset things (?) */
35 | }
36 |
37 | void rs_init(void)
38 | {
39 | set_intr_gate(0x24,rs1_interrupt);
40 | set_intr_gate(0x23,rs2_interrupt);
41 | init(tty_table[1].read_q.data);
42 | init(tty_table[2].read_q.data);
43 | outb(inb_p(0x21)&0xE7,0x21);
44 | }
45 |
46 | /*
47 | * This routine gets called when tty_write has put something into
48 | * the write_queue. It must check wheter the queue is empty, and
49 | * set the interrupt register accordingly
50 | *
51 | * void _rs_write(struct tty_struct * tty);
52 | */
53 | void rs_write(struct tty_struct * tty)
54 | {
55 | cli();
56 | if (!EMPTY(tty->write_q))
57 | outb(inb_p(tty->write_q.data+1)|0x02,tty->write_q.data+1);
58 | sti();
59 | }
60 |
--------------------------------------------------------------------------------
/src/V0.11/kernel/math/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile for the FREAX-kernel character device drivers.
3 | #
4 | # Note! Dependencies are done automagically by 'make dep', which also
5 | # removes any old dependencies. DON'T put your own dependencies here
6 | # unless it's something special (ie not a .c file).
7 | #
8 |
9 | AR =gar
10 | AS =gas
11 | LD =gld
12 | LDFLAGS =-s -x
13 | CC =gcc
14 | CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer -fcombine-regs \
15 | -finline-functions -mstring-insns -nostdinc -I../../include
16 | CPP =gcc -E -nostdinc -I../../include
17 |
18 | .c.s:
19 | $(CC) $(CFLAGS) \
20 | -S -o $*.s $<
21 | .s.o:
22 | $(AS) -c -o $*.o $<
23 | .c.o:
24 | $(CC) $(CFLAGS) \
25 | -c -o $*.o $<
26 |
27 | OBJS = math_emulate.o
28 |
29 | math.a: $(OBJS)
30 | $(AR) rcs math.a $(OBJS)
31 | sync
32 |
33 | clean:
34 | rm -f core *.o *.a tmp_make
35 | for i in *.c;do rm -f `basename $$i .c`.s;done
36 |
37 | dep:
38 | sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
39 | (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \
40 | $(CPP) -M $$i;done) >> tmp_make
41 | cp tmp_make Makefile
42 |
43 | ### Dependencies:
44 |
--------------------------------------------------------------------------------
/src/V0.11/kernel/math/math_emulate.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/kernel/math/math_emulate.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | /*
8 | * This directory should contain the math-emulation code.
9 | * Currently only results in a signal.
10 | */
11 |
12 | #include
13 |
14 | #include
15 | #include
16 | #include
17 |
18 | void math_emulate(long edi, long esi, long ebp, long sys_call_ret,
19 | long eax,long ebx,long ecx,long edx,
20 | unsigned short fs,unsigned short es,unsigned short ds,
21 | unsigned long eip,unsigned short cs,unsigned long eflags,
22 | unsigned short ss, unsigned long esp)
23 | {
24 | unsigned char first, second;
25 |
26 | /* 0x0007 means user code space */
27 | if (cs != 0x000F) {
28 | printk("math_emulate: %04x:%08x\n\r",cs,eip);
29 | panic("Math emulation needed in kernel");
30 | }
31 | first = get_fs_byte((char *)((*&eip)++));
32 | second = get_fs_byte((char *)((*&eip)++));
33 | printk("%04x:%08x %02x %02x\n\r",cs,eip-2,first,second);
34 | current->signal |= 1<<(SIGFPE-1);
35 | }
36 |
37 | void math_error(void)
38 | {
39 | __asm__("fnclex");
40 | if (last_task_used_math)
41 | last_task_used_math->signal |= 1<<(SIGFPE-1);
42 | }
43 |
--------------------------------------------------------------------------------
/src/V0.11/kernel/mktime.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/kernel/mktime.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #include
8 |
9 | /*
10 | * This isn't the library routine, it is only used in the kernel.
11 | * as such, we don't care about years<1970 etc, but assume everything
12 | * is ok. Similarly, TZ etc is happily ignored. We just do everything
13 | * as easily as possible. Let's find something public for the library
14 | * routines (although I think minix times is public).
15 | */
16 | /*
17 | * PS. I hate whoever though up the year 1970 - couldn't they have gotten
18 | * a leap-year instead? I also hate Gregorius, pope or no. I'm grumpy.
19 | */
20 | #define MINUTE 60
21 | #define HOUR (60*MINUTE)
22 | #define DAY (24*HOUR)
23 | #define YEAR (365*DAY)
24 |
25 | /* interestingly, we assume leap-years */
26 | static int month[12] = {
27 | 0,
28 | DAY*(31),
29 | DAY*(31+29),
30 | DAY*(31+29+31),
31 | DAY*(31+29+31+30),
32 | DAY*(31+29+31+30+31),
33 | DAY*(31+29+31+30+31+30),
34 | DAY*(31+29+31+30+31+30+31),
35 | DAY*(31+29+31+30+31+30+31+31),
36 | DAY*(31+29+31+30+31+30+31+31+30),
37 | DAY*(31+29+31+30+31+30+31+31+30+31),
38 | DAY*(31+29+31+30+31+30+31+31+30+31+30)
39 | };
40 |
41 | long kernel_mktime(struct tm * tm)
42 | {
43 | long res;
44 | int year;
45 |
46 | year = tm->tm_year - 70;
47 | /* magic offsets (y+1) needed to get leapyears right.*/
48 | res = YEAR*year + DAY*((year+1)/4);
49 | res += month[tm->tm_mon];
50 | /* and (y+2) here. If it wasn't a leap-year, we have to adjust */
51 | if (tm->tm_mon>1 && ((year+2)%4))
52 | res -= DAY;
53 | res += DAY*(tm->tm_mday-1);
54 | res += HOUR*tm->tm_hour;
55 | res += MINUTE*tm->tm_min;
56 | res += tm->tm_sec;
57 | return res;
58 | }
59 |
--------------------------------------------------------------------------------
/src/V0.11/kernel/panic.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/kernel/panic.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | /*
8 | * This function is used through-out the kernel (includeinh mm and fs)
9 | * to indicate a major problem.
10 | */
11 | #include
12 | #include
13 |
14 | void sys_sync(void); /* it's really int */
15 |
16 | volatile void panic(const char * s)
17 | {
18 | printk("Kernel panic: %s\n\r",s);
19 | if (current == task[0])
20 | printk("In swapper task - not syncing\n\r");
21 | else
22 | sys_sync();
23 | for(;;);
24 | }
25 |
--------------------------------------------------------------------------------
/src/V0.11/kernel/printk.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/kernel/printk.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | /*
8 | * When in kernel-mode, we cannot use printf, as fs is liable to
9 | * point to 'interesting' things. Make a printf with fs-saving, and
10 | * all is well.
11 | */
12 | #include
13 | #include
14 |
15 | #include
16 |
17 | static char buf[1024];
18 |
19 | extern int vsprintf(char * buf, const char * fmt, va_list args);
20 |
21 | int printk(const char *fmt, ...)
22 | {
23 | va_list args;
24 | int i;
25 |
26 | va_start(args, fmt);
27 | i=vsprintf(buf,fmt,args);
28 | va_end(args);
29 | __asm__("push %%fs\n\t"
30 | "push %%ds\n\t"
31 | "pop %%fs\n\t"
32 | "pushl %0\n\t"
33 | "pushl $_buf\n\t"
34 | "pushl $0\n\t"
35 | "call _tty_write\n\t"
36 | "addl $8,%%esp\n\t"
37 | "popl %0\n\t"
38 | "pop %%fs"
39 | ::"r" (i):"ax","cx","dx");
40 | return i;
41 | }
42 |
--------------------------------------------------------------------------------
/src/V0.11/lib/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile for some libs needed in the kernel.
3 | #
4 | # Note! Dependencies are done automagically by 'make dep', which also
5 | # removes any old dependencies. DON'T put your own dependencies here
6 | # unless it's something special (ie not a .c file).
7 | #
8 |
9 | AR =gar
10 | AS =gas
11 | LD =gld
12 | LDFLAGS =-s -x
13 | CC =gcc
14 | CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer -fcombine-regs \
15 | -finline-functions -mstring-insns -nostdinc -I../include
16 | CPP =gcc -E -nostdinc -I../include
17 |
18 | .c.s:
19 | $(CC) $(CFLAGS) \
20 | -S -o $*.s $<
21 | .s.o:
22 | $(AS) -c -o $*.o $<
23 | .c.o:
24 | $(CC) $(CFLAGS) \
25 | -c -o $*.o $<
26 |
27 | OBJS = ctype.o _exit.o open.o close.o errno.o write.o dup.o setsid.o \
28 | execve.o wait.o string.o malloc.o
29 |
30 | lib.a: $(OBJS)
31 | $(AR) rcs lib.a $(OBJS)
32 | sync
33 |
34 | clean:
35 | rm -f core *.o *.a tmp_make
36 | for i in *.c;do rm -f `basename $$i .c`.s;done
37 |
38 | dep:
39 | sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
40 | (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \
41 | $(CPP) -M $$i;done) >> tmp_make
42 | cp tmp_make Makefile
43 |
44 | ### Dependencies:
45 | _exit.s _exit.o : _exit.c ../include/unistd.h ../include/sys/stat.h \
46 | ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \
47 | ../include/utime.h
48 | close.s close.o : close.c ../include/unistd.h ../include/sys/stat.h \
49 | ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \
50 | ../include/utime.h
51 | ctype.s ctype.o : ctype.c ../include/ctype.h
52 | dup.s dup.o : dup.c ../include/unistd.h ../include/sys/stat.h \
53 | ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \
54 | ../include/utime.h
55 | errno.s errno.o : errno.c
56 | execve.s execve.o : execve.c ../include/unistd.h ../include/sys/stat.h \
57 | ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \
58 | ../include/utime.h
59 | malloc.s malloc.o : malloc.c ../include/linux/kernel.h ../include/linux/mm.h \
60 | ../include/asm/system.h
61 | open.s open.o : open.c ../include/unistd.h ../include/sys/stat.h \
62 | ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \
63 | ../include/utime.h ../include/stdarg.h
64 | setsid.s setsid.o : setsid.c ../include/unistd.h ../include/sys/stat.h \
65 | ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \
66 | ../include/utime.h
67 | string.s string.o : string.c ../include/string.h
68 | wait.s wait.o : wait.c ../include/unistd.h ../include/sys/stat.h \
69 | ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \
70 | ../include/utime.h ../include/sys/wait.h
71 | write.s write.o : write.c ../include/unistd.h ../include/sys/stat.h \
72 | ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \
73 | ../include/utime.h
74 |
--------------------------------------------------------------------------------
/src/V0.11/lib/_exit.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/_exit.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #define __LIBRARY__
8 | #include
9 |
10 | volatile void _exit(int exit_code)
11 | {
12 | __asm__("int $0x80"::"a" (__NR_exit),"b" (exit_code));
13 | }
14 |
--------------------------------------------------------------------------------
/src/V0.11/lib/close.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/close.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #define __LIBRARY__
8 | #include
9 |
10 | _syscall1(int,close,int,fd)
11 |
--------------------------------------------------------------------------------
/src/V0.11/lib/ctype.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/ctype.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #include
8 |
9 | char _ctmp;
10 | unsigned char _ctype[] = {0x00, /* EOF */
11 | _C,_C,_C,_C,_C,_C,_C,_C, /* 0-7 */
12 | _C,_C|_S,_C|_S,_C|_S,_C|_S,_C|_S,_C,_C, /* 8-15 */
13 | _C,_C,_C,_C,_C,_C,_C,_C, /* 16-23 */
14 | _C,_C,_C,_C,_C,_C,_C,_C, /* 24-31 */
15 | _S|_SP,_P,_P,_P,_P,_P,_P,_P, /* 32-39 */
16 | _P,_P,_P,_P,_P,_P,_P,_P, /* 40-47 */
17 | _D,_D,_D,_D,_D,_D,_D,_D, /* 48-55 */
18 | _D,_D,_P,_P,_P,_P,_P,_P, /* 56-63 */
19 | _P,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U, /* 64-71 */
20 | _U,_U,_U,_U,_U,_U,_U,_U, /* 72-79 */
21 | _U,_U,_U,_U,_U,_U,_U,_U, /* 80-87 */
22 | _U,_U,_U,_P,_P,_P,_P,_P, /* 88-95 */
23 | _P,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L, /* 96-103 */
24 | _L,_L,_L,_L,_L,_L,_L,_L, /* 104-111 */
25 | _L,_L,_L,_L,_L,_L,_L,_L, /* 112-119 */
26 | _L,_L,_L,_P,_P,_P,_P,_C, /* 120-127 */
27 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 128-143 */
28 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 144-159 */
29 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 160-175 */
30 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 176-191 */
31 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 192-207 */
32 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 208-223 */
33 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 224-239 */
34 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; /* 240-255 */
35 |
36 |
--------------------------------------------------------------------------------
/src/V0.11/lib/dup.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/dup.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #define __LIBRARY__
8 | #include
9 |
10 | _syscall1(int,dup,int,fd)
11 |
--------------------------------------------------------------------------------
/src/V0.11/lib/errno.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/errno.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | int errno;
8 |
--------------------------------------------------------------------------------
/src/V0.11/lib/execve.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/execve.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #define __LIBRARY__
8 | #include
9 |
10 | _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
11 |
--------------------------------------------------------------------------------
/src/V0.11/lib/open.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/open.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #define __LIBRARY__
8 | #include
9 | #include
10 |
11 | int open(const char * filename, int flag, ...)
12 | {
13 | register int res;
14 | va_list arg;
15 |
16 | va_start(arg,flag);
17 | __asm__("int $0x80"
18 | :"=a" (res)
19 | :"0" (__NR_open),"b" (filename),"c" (flag),
20 | "d" (va_arg(arg,int)));
21 | if (res>=0)
22 | return res;
23 | errno = -res;
24 | return -1;
25 | }
26 |
--------------------------------------------------------------------------------
/src/V0.11/lib/setsid.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/setsid.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #define __LIBRARY__
8 | #include
9 |
10 | _syscall0(pid_t,setsid)
11 |
--------------------------------------------------------------------------------
/src/V0.11/lib/string.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/string.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #ifndef __GNUC__
8 | #error I want gcc!
9 | #endif
10 |
11 | #define extern
12 | #define inline
13 | #define __LIBRARY__
14 | #include
15 |
--------------------------------------------------------------------------------
/src/V0.11/lib/wait.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/wait.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #define __LIBRARY__
8 | #include
9 | #include
10 |
11 | _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
12 |
13 | pid_t wait(int * wait_stat)
14 | {
15 | return waitpid(-1,wait_stat,0);
16 | }
17 |
--------------------------------------------------------------------------------
/src/V0.11/lib/write.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/write.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #define __LIBRARY__
8 | #include
9 |
10 | _syscall3(int,write,int,fd,const char *,buf,off_t,count)
11 |
--------------------------------------------------------------------------------
/src/V0.11/mm/Makefile:
--------------------------------------------------------------------------------
1 | CC =gcc
2 | CFLAGS =-O -Wall -fstrength-reduce -fcombine-regs -fomit-frame-pointer \
3 | -finline-functions -nostdinc -I../include
4 | AS =gas
5 | AR =gar
6 | LD =gld
7 | CPP =gcc -E -nostdinc -I../include
8 |
9 | .c.o:
10 | $(CC) $(CFLAGS) \
11 | -c -o $*.o $<
12 | .s.o:
13 | $(AS) -o $*.o $<
14 | .c.s:
15 | $(CC) $(CFLAGS) \
16 | -S -o $*.s $<
17 |
18 | OBJS = memory.o page.o
19 |
20 | all: mm.o
21 |
22 | mm.o: $(OBJS)
23 | $(LD) -r -o mm.o $(OBJS)
24 |
25 | clean:
26 | rm -f core *.o *.a tmp_make
27 | for i in *.c;do rm -f `basename $$i .c`.s;done
28 |
29 | dep:
30 | sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
31 | (for i in *.c;do $(CPP) -M $$i;done) >> tmp_make
32 | cp tmp_make Makefile
33 |
34 | ### Dependencies:
35 | memory.o : memory.c ../include/signal.h ../include/sys/types.h \
36 | ../include/asm/system.h ../include/linux/sched.h ../include/linux/head.h \
37 | ../include/linux/fs.h ../include/linux/mm.h ../include/linux/kernel.h
38 |
--------------------------------------------------------------------------------
/src/V0.11/mm/page.s:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/mm/page.s
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | /*
8 | * page.s contains the low-level page-exception code.
9 | * the real work is done in mm.c
10 | */
11 |
12 | .globl _page_fault
13 |
14 | _page_fault:
15 | xchgl %eax,(%esp)
16 | pushl %ecx
17 | pushl %edx
18 | push %ds
19 | push %es
20 | push %fs
21 | movl $0x10,%edx
22 | mov %dx,%ds
23 | mov %dx,%es
24 | mov %dx,%fs
25 | movl %cr2,%edx
26 | pushl %edx
27 | pushl %eax
28 | testl $1,%eax
29 | jne 1f
30 | call _do_no_page
31 | jmp 2f
32 | 1: call _do_wp_page
33 | 2: addl $8,%esp
34 | pop %fs
35 | pop %es
36 | pop %ds
37 | popl %edx
38 | popl %ecx
39 | popl %eax
40 | iret
41 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/fs/block_dev.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/fs/block_dev.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #include
8 |
9 | #include
10 | #include
11 | #include
12 | #include
13 |
14 | int block_write(int dev, long * pos, char * buf, int count)
15 | {
16 | int block = *pos >> BLOCK_SIZE_BITS;
17 | int offset = *pos & (BLOCK_SIZE-1);
18 | int chars;
19 | int written = 0;
20 | struct buffer_head * bh;
21 | register char * p;
22 |
23 | while (count>0) {
24 | chars = BLOCK_SIZE - offset;
25 | if (chars > count)
26 | chars=count;
27 | if (chars == BLOCK_SIZE)
28 | bh = getblk(dev,block);
29 | else
30 | bh = breada(dev,block,block+1,block+2,-1);
31 | block++;
32 | if (!bh)
33 | return written?written:-EIO;
34 | p = offset + bh->b_data;
35 | offset = 0;
36 | *pos += chars;
37 | written += chars;
38 | count -= chars;
39 | while (chars-->0)
40 | *(p++) = get_fs_byte(buf++);
41 | bh->b_dirt = 1;
42 | brelse(bh);
43 | }
44 | return written;
45 | }
46 |
47 | int block_read(int dev, unsigned long * pos, char * buf, int count)
48 | {
49 | int block = *pos >> BLOCK_SIZE_BITS;
50 | int offset = *pos & (BLOCK_SIZE-1);
51 | int chars;
52 | int read = 0;
53 | struct buffer_head * bh;
54 | register char * p;
55 |
56 | while (count>0) {
57 | chars = BLOCK_SIZE-offset;
58 | if (chars > count)
59 | chars = count;
60 | if (!(bh = breada(dev,block,block+1,block+2,-1)))
61 | return read?read:-EIO;
62 | block++;
63 | p = offset + bh->b_data;
64 | offset = 0;
65 | *pos += chars;
66 | read += chars;
67 | count -= chars;
68 | while (chars-->0)
69 | put_fs_byte(*(p++),buf++);
70 | brelse(bh);
71 | }
72 | return read;
73 | }
74 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/fs/char_dev.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/fs/char_dev.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #include
8 | #include
9 |
10 | #include
11 | #include
12 |
13 | #include
14 | #include
15 |
16 | extern int tty_read(unsigned minor,char * buf,int count);
17 | extern int tty_write(unsigned minor,char * buf,int count);
18 |
19 | typedef int (*crw_ptr)(int rw,unsigned minor,char * buf,int count,off_t * pos);
20 |
21 | static int rw_ttyx(int rw,unsigned minor,char * buf,int count,off_t * pos)
22 | {
23 | return ((rw==READ)?tty_read(minor,buf,count):
24 | tty_write(minor,buf,count));
25 | }
26 |
27 | static int rw_tty(int rw,unsigned minor,char * buf,int count, off_t * pos)
28 | {
29 | if (current->tty<0)
30 | return -EPERM;
31 | return rw_ttyx(rw,current->tty,buf,count,pos);
32 | }
33 |
34 | static int rw_ram(int rw,char * buf, int count, off_t *pos)
35 | {
36 | return -EIO;
37 | }
38 |
39 | static int rw_mem(int rw,char * buf, int count, off_t * pos)
40 | {
41 | return -EIO;
42 | }
43 |
44 | static int rw_kmem(int rw,char * buf, int count, off_t * pos)
45 | {
46 | return -EIO;
47 | }
48 |
49 | static int rw_port(int rw,char * buf, int count, off_t * pos)
50 | {
51 | int i=*pos;
52 |
53 | while (count-->0 && i<65536) {
54 | if (rw==READ)
55 | put_fs_byte(inb(i),buf++);
56 | else
57 | outb(get_fs_byte(buf++),i);
58 | i++;
59 | }
60 | i -= *pos;
61 | *pos += i;
62 | return i;
63 | }
64 |
65 | static int rw_memory(int rw, unsigned minor, char * buf, int count, off_t * pos)
66 | {
67 | switch(minor) {
68 | case 0:
69 | return rw_ram(rw,buf,count,pos);
70 | case 1:
71 | return rw_mem(rw,buf,count,pos);
72 | case 2:
73 | return rw_kmem(rw,buf,count,pos);
74 | case 3:
75 | return (rw==READ)?0:count; /* rw_null */
76 | case 4:
77 | return rw_port(rw,buf,count,pos);
78 | default:
79 | return -EIO;
80 | }
81 | }
82 |
83 | #define NRDEVS ((sizeof (crw_table))/(sizeof (crw_ptr)))
84 |
85 | static crw_ptr crw_table[]={
86 | NULL, /* nodev */
87 | rw_memory, /* /dev/mem etc */
88 | NULL, /* /dev/fd */
89 | NULL, /* /dev/hd */
90 | rw_ttyx, /* /dev/ttyx */
91 | rw_tty, /* /dev/tty */
92 | NULL, /* /dev/lp */
93 | NULL}; /* unnamed pipes */
94 |
95 | int rw_char(int rw,int dev, char * buf, int count, off_t * pos)
96 | {
97 | crw_ptr call_addr;
98 |
99 | if (MAJOR(dev)>=NRDEVS)
100 | return -ENODEV;
101 | if (!(call_addr=crw_table[MAJOR(dev)]))
102 | return -ENODEV;
103 | return call_addr(rw,MINOR(dev),buf,count,pos);
104 | }
105 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/fs/fcntl.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/fs/fcntl.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | /* #include */
8 | #include
9 | #include
10 | #include
11 | #include
12 |
13 | #include
14 | #include
15 |
16 | extern int sys_close(int fd);
17 |
18 | static int dupfd(unsigned int fd, unsigned int arg)
19 | {
20 | if (fd >= NR_OPEN || !current->filp[fd])
21 | return -EBADF;
22 | if (arg >= NR_OPEN)
23 | return -EINVAL;
24 | while (arg < NR_OPEN)
25 | if (current->filp[arg])
26 | arg++;
27 | else
28 | break;
29 | if (arg >= NR_OPEN)
30 | return -EMFILE;
31 | current->close_on_exec &= ~(1<filp[arg] = current->filp[fd])->f_count++;
33 | return arg;
34 | }
35 |
36 | int sys_dup2(unsigned int oldfd, unsigned int newfd)
37 | {
38 | sys_close(newfd);
39 | return dupfd(oldfd,newfd);
40 | }
41 |
42 | int sys_dup(unsigned int fildes)
43 | {
44 | return dupfd(fildes,0);
45 | }
46 |
47 | int sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg)
48 | {
49 | struct file * filp;
50 |
51 | if (fd >= NR_OPEN || !(filp = current->filp[fd]))
52 | return -EBADF;
53 | switch (cmd) {
54 | case F_DUPFD:
55 | return dupfd(fd,arg);
56 | case F_GETFD:
57 | return (current->close_on_exec>>fd)&1;
58 | case F_SETFD:
59 | if (arg&1)
60 | current->close_on_exec |= (1<close_on_exec &= ~(1<f_flags;
66 | case F_SETFL:
67 | filp->f_flags &= ~(O_APPEND | O_NONBLOCK);
68 | filp->f_flags |= arg & (O_APPEND | O_NONBLOCK);
69 | return 0;
70 | case F_GETLK: case F_SETLK: case F_SETLKW:
71 | return -1;
72 | default:
73 | return -1;
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/fs/file_dev.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/fs/file_dev.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #include
8 | #include
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | #define MIN(a,b) (((a)<(b))?(a):(b))
15 | #define MAX(a,b) (((a)>(b))?(a):(b))
16 |
17 | int file_read(struct m_inode * inode, struct file * filp, char * buf, int count)
18 | {
19 | int left,chars,nr;
20 | struct buffer_head * bh;
21 |
22 | if ((left=count)<=0)
23 | return 0;
24 | while (left) {
25 | if ((nr = bmap(inode,(filp->f_pos)/BLOCK_SIZE))) {
26 | if (!(bh=bread(inode->i_dev,nr)))
27 | break;
28 | } else
29 | bh = NULL;
30 | nr = filp->f_pos % BLOCK_SIZE;
31 | chars = MIN( BLOCK_SIZE-nr , left );
32 | filp->f_pos += chars;
33 | left -= chars;
34 | if (bh) {
35 | char * p = nr + bh->b_data;
36 | while (chars-->0)
37 | put_fs_byte(*(p++),buf++);
38 | brelse(bh);
39 | } else {
40 | while (chars-->0)
41 | put_fs_byte(0,buf++);
42 | }
43 | }
44 | inode->i_atime = CURRENT_TIME;
45 | return (count-left)?(count-left):-ERROR;
46 | }
47 |
48 | int file_write(struct m_inode * inode, struct file * filp, char * buf, int count)
49 | {
50 | off_t pos;
51 | int block,c;
52 | struct buffer_head * bh;
53 | char * p;
54 | int i=0;
55 |
56 | /*
57 | * ok, append may not work when many processes are writing at the same time
58 | * but so what. That way leads to madness anyway.
59 | */
60 | if (filp->f_flags & O_APPEND)
61 | pos = inode->i_size;
62 | else
63 | pos = filp->f_pos;
64 | while (ii_dev,block)))
68 | break;
69 | c = pos % BLOCK_SIZE;
70 | p = c + bh->b_data;
71 | bh->b_dirt = 1;
72 | c = BLOCK_SIZE-c;
73 | if (c > count-i) c = count-i;
74 | pos += c;
75 | if (pos > inode->i_size) {
76 | inode->i_size = pos;
77 | inode->i_dirt = 1;
78 | }
79 | i += c;
80 | while (c-->0)
81 | *(p++) = get_fs_byte(buf++);
82 | brelse(bh);
83 | }
84 | inode->i_mtime = CURRENT_TIME;
85 | if (!(filp->f_flags & O_APPEND)) {
86 | filp->f_pos = pos;
87 | inode->i_ctime = CURRENT_TIME;
88 | }
89 | return (i?i:-1);
90 | }
91 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/fs/file_table.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/fs/file_table.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #include
8 |
9 | struct file file_table[NR_FILE];
10 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/fs/ioctl.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/fs/ioctl.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | /* #include */
8 | #include
9 | #include
10 |
11 | #include
12 |
13 | extern int tty_ioctl(int dev, int cmd, int arg);
14 |
15 | typedef int (*ioctl_ptr)(int dev,int cmd,int arg);
16 |
17 | #define NRDEVS ((sizeof (ioctl_table))/(sizeof (ioctl_ptr)))
18 |
19 | static ioctl_ptr ioctl_table[]={
20 | NULL, /* nodev */
21 | NULL, /* /dev/mem */
22 | NULL, /* /dev/fd */
23 | NULL, /* /dev/hd */
24 | tty_ioctl, /* /dev/ttyx */
25 | tty_ioctl, /* /dev/tty */
26 | NULL, /* /dev/lp */
27 | NULL}; /* named pipes */
28 |
29 |
30 | int sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
31 | {
32 | struct file * filp;
33 | int dev,mode;
34 |
35 | if (fd >= NR_OPEN || !(filp = current->filp[fd]))
36 | return -EBADF;
37 | mode=filp->f_inode->i_mode;
38 | if (!S_ISCHR(mode) && !S_ISBLK(mode))
39 | return -EINVAL;
40 | dev = filp->f_inode->i_zone[0];
41 | if (MAJOR(dev) >= NRDEVS)
42 | return -ENODEV;
43 | if (!ioctl_table[MAJOR(dev)])
44 | return -ENOTTY;
45 | return ioctl_table[MAJOR(dev)](dev,cmd,arg);
46 | }
47 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/fs/stat.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/fs/stat.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #include
8 | #include
9 |
10 | #include
11 | #include
12 | #include
13 | #include
14 |
15 | static void cp_stat(struct m_inode * inode, struct stat * statbuf)
16 | {
17 | struct stat tmp;
18 | int i;
19 |
20 | verify_area(statbuf,sizeof (* statbuf));
21 | tmp.st_dev = inode->i_dev;
22 | tmp.st_ino = inode->i_num;
23 | tmp.st_mode = inode->i_mode;
24 | tmp.st_nlink = inode->i_nlinks;
25 | tmp.st_uid = inode->i_uid;
26 | tmp.st_gid = inode->i_gid;
27 | tmp.st_rdev = inode->i_zone[0];
28 | tmp.st_size = inode->i_size;
29 | tmp.st_atime = inode->i_atime;
30 | tmp.st_mtime = inode->i_mtime;
31 | tmp.st_ctime = inode->i_ctime;
32 | for (i=0 ; i= NR_OPEN || !(f=current->filp[fd]) || !(inode=f->f_inode))
53 | return -EBADF;
54 | cp_stat(inode,statbuf);
55 | return 0;
56 | }
57 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/fs/truncate.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/fs/truncate.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #include
8 |
9 | #include
10 |
11 | static void free_ind(int dev,int block)
12 | {
13 | struct buffer_head * bh;
14 | unsigned short * p;
15 | int i;
16 |
17 | if (!block)
18 | return;
19 | if ((bh=bread(dev,block))) {
20 | p = (unsigned short *) bh->b_data;
21 | for (i=0;i<512;i++,p++)
22 | if (*p)
23 | free_block(dev,*p);
24 | brelse(bh);
25 | }
26 | free_block(dev,block);
27 | }
28 |
29 | static void free_dind(int dev,int block)
30 | {
31 | struct buffer_head * bh;
32 | unsigned short * p;
33 | int i;
34 |
35 | if (!block)
36 | return;
37 | if ((bh=bread(dev,block))) {
38 | p = (unsigned short *) bh->b_data;
39 | for (i=0;i<512;i++,p++)
40 | if (*p)
41 | free_ind(dev,*p);
42 | brelse(bh);
43 | }
44 | free_block(dev,block);
45 | }
46 |
47 | void truncate(struct m_inode * inode)
48 | {
49 | int i;
50 |
51 | if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)))
52 | return;
53 | for (i=0;i<7;i++)
54 | if (inode->i_zone[i]) {
55 | free_block(inode->i_dev,inode->i_zone[i]);
56 | inode->i_zone[i]=0;
57 | }
58 | free_ind(inode->i_dev,inode->i_zone[7]);
59 | free_dind(inode->i_dev,inode->i_zone[8]);
60 | inode->i_zone[7] = inode->i_zone[8] = 0;
61 | inode->i_size = 0;
62 | inode->i_dirt = 1;
63 | inode->i_mtime = inode->i_ctime = CURRENT_TIME;
64 | }
65 |
66 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/include/asm/io.h:
--------------------------------------------------------------------------------
1 | #define outb(value,port) \
2 | __asm__ ("outb %%al,%%dx"::"a" (value),"d" (port))
3 |
4 |
5 | #define inb(port) ({ \
6 | unsigned char _v; \
7 | __asm__ volatile ("inb %%dx,%%al":"=a" (_v):"d" (port)); \
8 | _v; \
9 | })
10 |
11 | #define outb_p(value,port) \
12 | __asm__ ("outb %%al,%%dx\n" \
13 | "\tjmp 1f\n" \
14 | "1:\tjmp 1f\n" \
15 | "1:"::"a" (value),"d" (port))
16 |
17 | #define inb_p(port) ({ \
18 | unsigned char _v; \
19 | __asm__ volatile ("inb %%dx,%%al\n" \
20 | "\tjmp 1f\n" \
21 | "1:\tjmp 1f\n" \
22 | "1:":"=a" (_v):"d" (port)); \
23 | _v; \
24 | })
25 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/include/asm/memory.h:
--------------------------------------------------------------------------------
1 | /*
2 | * NOTE!!! memcpy(dest,src,n) assumes ds=es=normal data segment. This
3 | * goes for all kernel functions (ds=es=kernel space, fs=local data,
4 | * gs=null), as well as for all well-behaving user programs (ds=es=
5 | * user data space). This is NOT a bug, as any user program that changes
6 | * es deserves to die if it isn't careful.
7 | */
8 | #define memcpy(dest,src,n) ({ \
9 | void * _res = dest; \
10 | __asm__ ("cld;rep;movsb" \
11 | ::"D" ((long)(_res)),"S" ((long)(src)),"c" ((long) (n)) \
12 | ); \
13 | _res; \
14 | })
15 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/include/asm/segment.h:
--------------------------------------------------------------------------------
1 | static inline unsigned char get_fs_byte(const char * addr)
2 | {
3 | unsigned register char _v;
4 |
5 | __asm__ ("movb %%fs:%1,%0":"=r" (_v):"m" (*addr));
6 | return _v;
7 | }
8 |
9 | static inline unsigned short get_fs_word(const unsigned short *addr)
10 | {
11 | unsigned short _v;
12 |
13 | __asm__ ("movw %%fs:%1,%0":"=r" (_v):"m" (*addr));
14 | return _v;
15 | }
16 |
17 | static inline unsigned long get_fs_long(const unsigned long *addr)
18 | {
19 | unsigned long _v;
20 |
21 | __asm__ ("movl %%fs:%1,%0":"=r" (_v):"m" (*addr)); \
22 | return _v;
23 | }
24 |
25 | static inline void put_fs_byte(char val,char *addr)
26 | {
27 | __asm__ ("movb %0,%%fs:%1"::"r" (val),"m" (*addr));
28 | }
29 |
30 | static inline void put_fs_word(short val,short * addr)
31 | {
32 | __asm__ ("movw %0,%%fs:%1"::"r" (val),"m" (*addr));
33 | }
34 |
35 | static inline void put_fs_long(unsigned long val,unsigned long * addr)
36 | {
37 | __asm__ ("movl %0,%%fs:%1"::"r" (val),"m" (*addr));
38 | }
39 |
40 | /*
41 | * Someone who knows GNU asm better than I should double check the followig.
42 | * It seems to work, but I don't know if I'm doing something subtly wrong.
43 | * --- TYT, 11/24/91
44 | * [ nothing wrong here, Linus ]
45 | */
46 |
47 | static inline unsigned long get_fs()
48 | {
49 | unsigned short _v;
50 | __asm__("mov %%fs,%%ax":"=a" (_v):);
51 | return _v;
52 | }
53 |
54 | static inline unsigned long get_ds()
55 | {
56 | unsigned short _v;
57 | __asm__("mov %%ds,%%ax":"=a" (_v):);
58 | return _v;
59 | }
60 |
61 | static inline void set_fs(unsigned long val)
62 | {
63 | __asm__("mov %0,%%fs"::"a" ((unsigned short) val));
64 | }
65 |
66 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/include/asm/system.h:
--------------------------------------------------------------------------------
1 | #define move_to_user_mode() \
2 | __asm__ ("movl %%esp,%%eax\n\t" \
3 | "pushl $0x17\n\t" \
4 | "pushl %%eax\n\t" \
5 | "pushfl\n\t" \
6 | "pushl $0x0f\n\t" \
7 | "pushl $1f\n\t" \
8 | "iret\n" \
9 | "1:\tmovl $0x17,%%eax\n\t" \
10 | "movw %%ax,%%ds\n\t" \
11 | "movw %%ax,%%es\n\t" \
12 | "movw %%ax,%%fs\n\t" \
13 | "movw %%ax,%%gs" \
14 | :::"ax")
15 |
16 | #define sti() __asm__ ("sti"::)
17 | #define cli() __asm__ ("cli"::)
18 | #define nop() __asm__ ("nop"::)
19 |
20 | #define iret() __asm__ ("iret"::)
21 |
22 | #define _set_gate(gate_addr,type,dpl,addr) \
23 | __asm__ ("movw %%dx,%%ax\n\t" \
24 | "movw %0,%%dx\n\t" \
25 | "movl %%eax,%1\n\t" \
26 | "movl %%edx,%2" \
27 | : \
28 | : "i" ((short) (0x8000+(dpl<<13)+(type<<8))), \
29 | "o" (*((char *) (gate_addr))), \
30 | "o" (*(4+(char *) (gate_addr))), \
31 | "d" ((char *) (addr)),"a" (0x00080000))
32 |
33 | #define set_intr_gate(n,addr) \
34 | _set_gate(&idt[n],14,0,addr)
35 |
36 | #define set_trap_gate(n,addr) \
37 | _set_gate(&idt[n],15,0,addr)
38 |
39 | #define set_system_gate(n,addr) \
40 | _set_gate(&idt[n],15,3,addr)
41 |
42 | #define _set_seg_desc(gate_addr,type,dpl,base,limit) {\
43 | *(gate_addr) = ((base) & 0xff000000) | \
44 | (((base) & 0x00ff0000)>>16) | \
45 | ((limit) & 0xf0000) | \
46 | ((dpl)<<13) | \
47 | (0x00408000) | \
48 | ((type)<<8); \
49 | *((gate_addr)+1) = (((base) & 0x0000ffff)<<16) | \
50 | ((limit) & 0x0ffff); }
51 |
52 | #define _set_tssldt_desc(n,addr,type) \
53 | __asm__ ("movw $104,%1\n\t" \
54 | "movw %%ax,%2\n\t" \
55 | "rorl $16,%%eax\n\t" \
56 | "movb %%al,%3\n\t" \
57 | "movb $" type ",%4\n\t" \
58 | "movb $0x00,%5\n\t" \
59 | "movb %%ah,%6\n\t" \
60 | "rorl $16,%%eax" \
61 | ::"a" (addr), "m" (*(n)), "m" (*(n+2)), "m" (*(n+4)), \
62 | "m" (*(n+5)), "m" (*(n+6)), "m" (*(n+7)) \
63 | )
64 |
65 | #define set_tss_desc(n,addr) _set_tssldt_desc(((char *) (n)),((int)(addr)),"0x89")
66 | #define set_ldt_desc(n,addr) _set_tssldt_desc(((char *) (n)),((int)(addr)),"0x82")
67 |
68 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/include/const.h:
--------------------------------------------------------------------------------
1 | #ifndef _CONST_H
2 | #define _CONST_H
3 |
4 | #define BUFFER_END 0x200000
5 |
6 | #define I_TYPE 0170000
7 | #define I_DIRECTORY 0040000
8 | #define I_REGULAR 0100000
9 | #define I_BLOCK_SPECIAL 0060000
10 | #define I_CHAR_SPECIAL 0020000
11 | #define I_NAMED_PIPE 0010000
12 | #define I_SET_UID_BIT 0004000
13 | #define I_SET_GID_BIT 0002000
14 |
15 | #endif
16 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/include/ctype.h:
--------------------------------------------------------------------------------
1 | #ifndef _CTYPE_H
2 | #define _CTYPE_H
3 |
4 | #define _U 0x01 /* upper */
5 | #define _L 0x02 /* lower */
6 | #define _D 0x04 /* digit */
7 | #define _C 0x08 /* cntrl */
8 | #define _P 0x10 /* punct */
9 | #define _S 0x20 /* white space (space/lf/tab) */
10 | #define _X 0x40 /* hex digit */
11 | #define _SP 0x80 /* hard space (0x20) */
12 |
13 | extern unsigned char _ctype[];
14 | extern char _ctmp;
15 |
16 | #define isalnum(c) ((_ctype+1)[c]&(_U|_L|_D))
17 | #define isalpha(c) ((_ctype+1)[c]&(_U|_L))
18 | #define iscntrl(c) ((_ctype+1)[c]&(_C))
19 | #define isdigit(c) ((_ctype+1)[c]&(_D))
20 | #define isgraph(c) ((_ctype+1)[c]&(_P|_U|_L|_D))
21 | #define islower(c) ((_ctype+1)[c]&(_L))
22 | #define isprint(c) ((_ctype+1)[c]&(_P|_U|_L|_D|_SP))
23 | #define ispunct(c) ((_ctype+1)[c]&(_P))
24 | #define isspace(c) ((_ctype+1)[c]&(_S))
25 | #define isupper(c) ((_ctype+1)[c]&(_U))
26 | #define isxdigit(c) ((_ctype+1)[c]&(_D|_X))
27 |
28 | #define isascii(c) (((unsigned) c)<=0x7f)
29 | #define toascii(c) (((unsigned) c)&0x7f)
30 |
31 | #define tolower(c) (_ctmp=c,isupper(_ctmp)?_ctmp-('A'-'a'):_ctmp)
32 | #define toupper(c) (_ctmp=c,islower(_ctmp)?_ctmp-('a'-'A'):_ctmp)
33 |
34 | #endif
35 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/include/errno.h:
--------------------------------------------------------------------------------
1 | #ifndef _ERRNO_H
2 | #define _ERRNO_H
3 |
4 | /*
5 | * ok, as I hadn't got any other source of information about
6 | * possible error numbers, I was forced to use the same numbers
7 | * as minix.
8 | * Hopefully these are posix or something. I wouldn't know (and posix
9 | * isn't telling me - they want $$$ for their f***ing standard).
10 | *
11 | * We don't use the _SIGN cludge of minix, so kernel returns must
12 | * see to the sign by themselves.
13 | *
14 | * NOTE! Remember to change strerror() if you change this file!
15 | */
16 |
17 | extern int errno;
18 |
19 | #define ERROR 99
20 | #define EPERM 1
21 | #define ENOENT 2
22 | #define ESRCH 3
23 | #define EINTR 4
24 | #define EIO 5
25 | #define ENXIO 6
26 | #define E2BIG 7
27 | #define ENOEXEC 8
28 | #define EBADF 9
29 | #define ECHILD 10
30 | #define EAGAIN 11
31 | #define ENOMEM 12
32 | #define EACCES 13
33 | #define EFAULT 14
34 | #define ENOTBLK 15
35 | #define EBUSY 16
36 | #define EEXIST 17
37 | #define EXDEV 18
38 | #define ENODEV 19
39 | #define ENOTDIR 20
40 | #define EISDIR 21
41 | #define EINVAL 22
42 | #define ENFILE 23
43 | #define EMFILE 24
44 | #define ENOTTY 25
45 | #define ETXTBSY 26
46 | #define EFBIG 27
47 | #define ENOSPC 28
48 | #define ESPIPE 29
49 | #define EROFS 30
50 | #define EMLINK 31
51 | #define EPIPE 32
52 | #define EDOM 33
53 | #define ERANGE 34
54 | #define EDEADLK 35
55 | #define ENAMETOOLONG 36
56 | #define ENOLCK 37
57 | #define ENOSYS 38
58 | #define ENOTEMPTY 39
59 |
60 | #endif
61 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/include/fcntl.h:
--------------------------------------------------------------------------------
1 | #ifndef _FCNTL_H
2 | #define _FCNTL_H
3 |
4 | #include
5 |
6 | /* open/fcntl - NOCTTY, NDELAY isn't implemented yet */
7 | #define O_ACCMODE 00003
8 | #define O_RDONLY 00
9 | #define O_WRONLY 01
10 | #define O_RDWR 02
11 | #define O_CREAT 00100 /* not fcntl */
12 | #define O_EXCL 00200 /* not fcntl */
13 | #define O_NOCTTY 00400 /* not fcntl */
14 | #define O_TRUNC 01000 /* not fcntl */
15 | #define O_APPEND 02000
16 | #define O_NONBLOCK 04000 /* not fcntl */
17 | #define O_NDELAY O_NONBLOCK
18 |
19 | /* Defines for fcntl-commands. Note that currently
20 | * locking isn't supported, and other things aren't really
21 | * tested.
22 | */
23 | #define F_DUPFD 0 /* dup */
24 | #define F_GETFD 1 /* get f_flags */
25 | #define F_SETFD 2 /* set f_flags */
26 | #define F_GETFL 3 /* more flags (cloexec) */
27 | #define F_SETFL 4
28 | #define F_GETLK 5 /* not implemented */
29 | #define F_SETLK 6
30 | #define F_SETLKW 7
31 |
32 | /* for F_[GET|SET]FL */
33 | #define FD_CLOEXEC 1 /* actually anything with low bit set goes */
34 |
35 | /* Ok, these are locking features, and aren't implemented at any
36 | * level. POSIX wants them.
37 | */
38 | #define F_RDLCK 0
39 | #define F_WRLCK 1
40 | #define F_UNLCK 2
41 |
42 | /* Once again - not implemented, but ... */
43 | struct flock {
44 | short l_type;
45 | short l_whence;
46 | off_t l_start;
47 | off_t l_len;
48 | pid_t l_pid;
49 | };
50 |
51 | extern int creat(const char * filename,mode_t mode);
52 | extern int fcntl(int fildes,int cmd, ...);
53 | extern int open(const char * filename, int flags, ...);
54 |
55 | #endif
56 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/include/linux/config.h:
--------------------------------------------------------------------------------
1 | #ifndef _CONFIG_H
2 | #define _CONFIG_H
3 |
4 | /*
5 | * The root-device is no longer hard-coded. You can change the default
6 | * root-device by changing the line ROOT_DEV = XXX in boot/bootsect.s
7 | */
8 |
9 | /*
10 | * define your keyboard here -
11 | * KBD_FINNISH for Finnish keyboards
12 | * KBD_US for US-type
13 | * KBD_GR for German keyboards
14 | * KBD_FR for Frech keyboard
15 | */
16 | #define KBD_US
17 | /*#define KBD_GR */
18 | /*#define KBD_FR */
19 | /*#define KBD_FINNISH */
20 |
21 | /*
22 | * Normally, Linux can get the drive parameters from the BIOS at
23 | * startup, but if this for some unfathomable reason fails, you'd
24 | * be left stranded. For this case, you can define HD_TYPE, which
25 | * contains all necessary info on your harddisk.
26 | *
27 | * The HD_TYPE macro should look like this:
28 | *
29 | * #define HD_TYPE { head, sect, cyl, wpcom, lzone, ctl}
30 | *
31 | * In case of two harddisks, the info should be sepatated by
32 | * commas:
33 | *
34 | * #define HD_TYPE { h,s,c,wpcom,lz,ctl },{ h,s,c,wpcom,lz,ctl }
35 | */
36 | /*
37 | This is an example, two drives, first is type 2, second is type 3:
38 |
39 | #define HD_TYPE { 4,17,615,300,615,8 }, { 6,17,615,300,615,0 }
40 |
41 | NOTE: ctl is 0 for all drives with heads<=8, and ctl=8 for drives
42 | with more than 8 heads.
43 |
44 | If you want the BIOS to tell what kind of drive you have, just
45 | leave HD_TYPE undefined. This is the normal thing to do.
46 | */
47 |
48 | #endif
49 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/include/linux/fdreg.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file contains some defines for the floppy disk controller.
3 | * Various sources. Mostly "IBM Microcomputers: A Programmers
4 | * Handbook", Sanches and Canton.
5 | */
6 | #ifndef _FDREG_H
7 | #define _FDREG_H
8 |
9 | extern int ticks_to_floppy_on(unsigned int nr);
10 | extern void floppy_on(unsigned int nr);
11 | extern void floppy_off(unsigned int nr);
12 | extern void floppy_select(unsigned int nr);
13 | extern void floppy_deselect(unsigned int nr);
14 |
15 | /* Fd controller regs. S&C, about page 340 */
16 | #define FD_STATUS 0x3f4
17 | #define FD_DATA 0x3f5
18 | #define FD_DOR 0x3f2 /* Digital Output Register */
19 | #define FD_DIR 0x3f7 /* Digital Input Register (read) */
20 | #define FD_DCR 0x3f7 /* Diskette Control Register (write)*/
21 |
22 | /* Bits of main status register */
23 | #define STATUS_BUSYMASK 0x0F /* drive busy mask */
24 | #define STATUS_BUSY 0x10 /* FDC busy */
25 | #define STATUS_DMA 0x20 /* 0- DMA mode */
26 | #define STATUS_DIR 0x40 /* 0- cpu->fdc */
27 | #define STATUS_READY 0x80 /* Data reg ready */
28 |
29 | /* Bits of FD_ST0 */
30 | #define ST0_DS 0x03 /* drive select mask */
31 | #define ST0_HA 0x04 /* Head (Address) */
32 | #define ST0_NR 0x08 /* Not Ready */
33 | #define ST0_ECE 0x10 /* Equipment chech error */
34 | #define ST0_SE 0x20 /* Seek end */
35 | #define ST0_INTR 0xC0 /* Interrupt code mask */
36 |
37 | /* Bits of FD_ST1 */
38 | #define ST1_MAM 0x01 /* Missing Address Mark */
39 | #define ST1_WP 0x02 /* Write Protect */
40 | #define ST1_ND 0x04 /* No Data - unreadable */
41 | #define ST1_OR 0x10 /* OverRun */
42 | #define ST1_CRC 0x20 /* CRC error in data or addr */
43 | #define ST1_EOC 0x80 /* End Of Cylinder */
44 |
45 | /* Bits of FD_ST2 */
46 | #define ST2_MAM 0x01 /* Missing Addess Mark (again) */
47 | #define ST2_BC 0x02 /* Bad Cylinder */
48 | #define ST2_SNS 0x04 /* Scan Not Satisfied */
49 | #define ST2_SEH 0x08 /* Scan Equal Hit */
50 | #define ST2_WC 0x10 /* Wrong Cylinder */
51 | #define ST2_CRC 0x20 /* CRC error in data field */
52 | #define ST2_CM 0x40 /* Control Mark = deleted */
53 |
54 | /* Bits of FD_ST3 */
55 | #define ST3_HA 0x04 /* Head (Address) */
56 | #define ST3_TZ 0x10 /* Track Zero signal (1=track 0) */
57 | #define ST3_WP 0x40 /* Write Protect */
58 |
59 | /* Values for FD_COMMAND */
60 | #define FD_RECALIBRATE 0x07 /* move to track 0 */
61 | #define FD_SEEK 0x0F /* seek track */
62 | #define FD_READ 0xE6 /* read with MT, MFM, SKip deleted */
63 | #define FD_WRITE 0xC5 /* write with MT, MFM */
64 | #define FD_SENSEI 0x08 /* Sense Interrupt Status */
65 | #define FD_SPECIFY 0x03 /* specify HUT etc */
66 |
67 | /* DMA commands */
68 | #define DMA_READ 0x46
69 | #define DMA_WRITE 0x4A
70 |
71 | #endif
72 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/include/linux/hdreg.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file contains some defines for the AT-hd-controller.
3 | * Various sources. Check out some definitions (see comments with
4 | * a ques).
5 | */
6 | #ifndef _HDREG_H
7 | #define _HDREG_H
8 |
9 | /* Hd controller regs. Ref: IBM AT Bios-listing */
10 | #define HD_DATA 0x1f0 /* _CTL when writing */
11 | #define HD_ERROR 0x1f1 /* see err-bits */
12 | #define HD_NSECTOR 0x1f2 /* nr of sectors to read/write */
13 | #define HD_SECTOR 0x1f3 /* starting sector */
14 | #define HD_LCYL 0x1f4 /* starting cylinder */
15 | #define HD_HCYL 0x1f5 /* high byte of starting cyl */
16 | #define HD_CURRENT 0x1f6 /* 101dhhhh , d=drive, hhhh=head */
17 | #define HD_STATUS 0x1f7 /* see status-bits */
18 | #define HD_PRECOMP HD_ERROR /* same io address, read=error, write=precomp */
19 | #define HD_COMMAND HD_STATUS /* same io address, read=status, write=cmd */
20 |
21 | #define HD_CMD 0x3f6
22 |
23 | /* Bits of HD_STATUS */
24 | #define ERR_STAT 0x01
25 | #define INDEX_STAT 0x02
26 | #define ECC_STAT 0x04 /* Corrected error */
27 | #define DRQ_STAT 0x08
28 | #define SEEK_STAT 0x10
29 | #define WRERR_STAT 0x20
30 | #define READY_STAT 0x40
31 | #define BUSY_STAT 0x80
32 |
33 | /* Values for HD_COMMAND */
34 | #define WIN_RESTORE 0x10
35 | #define WIN_READ 0x20
36 | #define WIN_WRITE 0x30
37 | #define WIN_VERIFY 0x40
38 | #define WIN_FORMAT 0x50
39 | #define WIN_INIT 0x60
40 | #define WIN_SEEK 0x70
41 | #define WIN_DIAGNOSE 0x90
42 | #define WIN_SPECIFY 0x91
43 |
44 | /* Bits for HD_ERROR */
45 | #define MARK_ERR 0x01 /* Bad address mark ? */
46 | #define TRK0_ERR 0x02 /* couldn't find track 0 */
47 | #define ABRT_ERR 0x04 /* ? */
48 | #define ID_ERR 0x10 /* ? */
49 | #define ECC_ERR 0x40 /* ? */
50 | #define BBD_ERR 0x80 /* ? */
51 |
52 | struct partition {
53 | unsigned char boot_ind; /* 0x80 - active (unused) */
54 | unsigned char head; /* ? */
55 | unsigned char sector; /* ? */
56 | unsigned char cyl; /* ? */
57 | unsigned char sys_ind; /* ? */
58 | unsigned char end_head; /* ? */
59 | unsigned char end_sector; /* ? */
60 | unsigned char end_cyl; /* ? */
61 | unsigned int start_sect; /* starting sector counting from 0 */
62 | unsigned int nr_sects; /* nr of sectors in partition */
63 | };
64 |
65 | #endif
66 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/include/linux/head.h:
--------------------------------------------------------------------------------
1 | #ifndef _HEAD_H
2 | #define _HEAD_H
3 |
4 | typedef struct desc_struct {
5 | unsigned long a,b;
6 | } desc_table[256];
7 |
8 | extern unsigned long pg_dir[1024];
9 | extern desc_table idt,gdt;
10 |
11 | #define GDT_NUL 0
12 | #define GDT_CODE 1
13 | #define GDT_DATA 2
14 | #define GDT_TMP 3
15 |
16 | #define LDT_NUL 0
17 | #define LDT_CODE 1
18 | #define LDT_DATA 2
19 |
20 | #endif
21 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/include/linux/kernel.h:
--------------------------------------------------------------------------------
1 | /*
2 | * 'kernel.h' contains some often-used function prototypes etc
3 | */
4 | void verify_area(void * addr,int count);
5 | volatile void panic(const char * str);
6 | int printf(const char * fmt, ...);
7 | int printk(const char * fmt, ...);
8 | int tty_write(unsigned ch,char * buf,int count);
9 | void * malloc(unsigned int size);
10 | void free_s(void * obj, int size);
11 |
12 | #define free(x) free_s((x), 0)
13 |
14 | /*
15 | * This is defined as a macro, but at some point this might become a
16 | * real subroutine that sets a flag if it returns true (to do
17 | * BSD-style accounting where the process is flagged if it uses root
18 | * privs). The implication of this is that you should do normal
19 | * permissions checks first, and check suser() last.
20 | */
21 | #define suser() (current->euid == 0)
22 |
23 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/include/linux/mm.h:
--------------------------------------------------------------------------------
1 | #ifndef _MM_H
2 | #define _MM_H
3 |
4 | #define PAGE_SIZE 4096
5 |
6 | extern unsigned long get_free_page(void);
7 | extern unsigned long put_page(unsigned long page,unsigned long address);
8 | extern void free_page(unsigned long addr);
9 |
10 | #endif
11 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/include/linux/tty.h:
--------------------------------------------------------------------------------
1 | /*
2 | * 'tty.h' defines some structures used by tty_io.c and some defines.
3 | *
4 | * NOTE! Don't touch this without checking that nothing in rs_io.s or
5 | * con_io.s breaks. Some constants are hardwired into the system (mainly
6 | * offsets into 'tty_queue'
7 | */
8 |
9 | #ifndef _TTY_H
10 | #define _TTY_H
11 |
12 | #include
13 |
14 | #define TTY_BUF_SIZE 1024
15 |
16 | struct tty_queue {
17 | unsigned long data;
18 | unsigned long head;
19 | unsigned long tail;
20 | struct task_struct * proc_list;
21 | char buf[TTY_BUF_SIZE];
22 | };
23 |
24 | #define INC(a) ((a) = ((a)+1) & (TTY_BUF_SIZE-1))
25 | #define DEC(a) ((a) = ((a)-1) & (TTY_BUF_SIZE-1))
26 | #define EMPTY(a) ((a).head == (a).tail)
27 | #define LEFT(a) (((a).tail-(a).head-1)&(TTY_BUF_SIZE-1))
28 | #define LAST(a) ((a).buf[(TTY_BUF_SIZE-1)&((a).head-1)])
29 | #define FULL(a) (!LEFT(a))
30 | #define CHARS(a) (((a).head-(a).tail)&(TTY_BUF_SIZE-1))
31 | #define GETCH(queue,c) \
32 | (void)({c=(queue).buf[(queue).tail];INC((queue).tail);})
33 | #define PUTCH(c,queue) \
34 | (void)({(queue).buf[(queue).head]=(c);INC((queue).head);})
35 |
36 | #define INTR_CHAR(tty) ((tty)->termios.c_cc[VINTR])
37 | #define QUIT_CHAR(tty) ((tty)->termios.c_cc[VQUIT])
38 | #define ERASE_CHAR(tty) ((tty)->termios.c_cc[VERASE])
39 | #define KILL_CHAR(tty) ((tty)->termios.c_cc[VKILL])
40 | #define EOF_CHAR(tty) ((tty)->termios.c_cc[VEOF])
41 | #define START_CHAR(tty) ((tty)->termios.c_cc[VSTART])
42 | #define STOP_CHAR(tty) ((tty)->termios.c_cc[VSTOP])
43 | #define SUSPEND_CHAR(tty) ((tty)->termios.c_cc[VSUSP])
44 |
45 | struct tty_struct {
46 | struct termios termios;
47 | int pgrp;
48 | int stopped;
49 | void (*write)(struct tty_struct * tty);
50 | struct tty_queue read_q;
51 | struct tty_queue write_q;
52 | struct tty_queue secondary;
53 | };
54 |
55 | extern struct tty_struct tty_table[];
56 |
57 | /* intr=^C quit=^| erase=del kill=^U
58 | eof=^D vtime=\0 vmin=\1 sxtc=\0
59 | start=^Q stop=^S susp=^Z eol=\0
60 | reprint=^R discard=^U werase=^W lnext=^V
61 | eol2=\0
62 | */
63 | #define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
64 |
65 | void rs_init(void);
66 | void con_init(void);
67 | void tty_init(void);
68 |
69 | int tty_read(unsigned c, char * buf, int n);
70 | int tty_write(unsigned c, char * buf, int n);
71 |
72 | void rs_write(struct tty_struct * tty);
73 | void con_write(struct tty_struct * tty);
74 |
75 | void copy_to_cooked(struct tty_struct * tty);
76 |
77 | #endif
78 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/include/signal.h:
--------------------------------------------------------------------------------
1 | #ifndef _SIGNAL_H
2 | #define _SIGNAL_H
3 |
4 | #include
5 |
6 | typedef int sig_atomic_t;
7 | typedef unsigned int sigset_t; /* 32 bits */
8 |
9 | #define _NSIG 32
10 | #define NSIG _NSIG
11 |
12 | #define SIGHUP 1
13 | #define SIGINT 2
14 | #define SIGQUIT 3
15 | #define SIGILL 4
16 | #define SIGTRAP 5
17 | #define SIGABRT 6
18 | #define SIGIOT 6
19 | #define SIGUNUSED 7
20 | #define SIGFPE 8
21 | #define SIGKILL 9
22 | #define SIGUSR1 10
23 | #define SIGSEGV 11
24 | #define SIGUSR2 12
25 | #define SIGPIPE 13
26 | #define SIGALRM 14
27 | #define SIGTERM 15
28 | #define SIGSTKFLT 16
29 | #define SIGCHLD 17
30 | #define SIGCONT 18
31 | #define SIGSTOP 19
32 | #define SIGTSTP 20
33 | #define SIGTTIN 21
34 | #define SIGTTOU 22
35 |
36 | /* Ok, I haven't implemented sigactions, but trying to keep headers POSIX */
37 | #define SA_NOCLDSTOP 1
38 | #define SA_NOMASK 0x40000000
39 | #define SA_ONESHOT 0x80000000
40 |
41 | #define SIG_BLOCK 0 /* for blocking signals */
42 | #define SIG_UNBLOCK 1 /* for unblocking signals */
43 | #define SIG_SETMASK 2 /* for setting the signal mask */
44 |
45 | #define SIG_DFL ((void (*)(int))0) /* default signal handling */
46 | #define SIG_IGN ((void (*)(int))1) /* ignore signal */
47 |
48 | struct sigaction {
49 | void (*sa_handler)(int);
50 | sigset_t sa_mask;
51 | int sa_flags;
52 | void (*sa_restorer)(void);
53 | };
54 |
55 | void (*signal(int _sig, void (*_func)(int)))(int);
56 | int raise(int sig);
57 | int kill(pid_t pid, int sig);
58 | int sigaddset(sigset_t *mask, int signo);
59 | int sigdelset(sigset_t *mask, int signo);
60 | int sigemptyset(sigset_t *mask);
61 | int sigfillset(sigset_t *mask);
62 | int sigismember(sigset_t *mask, int signo); /* 1 - is, 0 - not, -1 error */
63 | int sigpending(sigset_t *set);
64 | int sigprocmask(int how, sigset_t *set, sigset_t *oldset);
65 | int sigsuspend(sigset_t *sigmask);
66 | int sigaction(int sig, struct sigaction *act, struct sigaction *oldact);
67 |
68 | #endif /* _SIGNAL_H */
69 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/include/stdarg.h:
--------------------------------------------------------------------------------
1 | #ifndef _STDARG_H
2 | #define _STDARG_H
3 |
4 | typedef char *va_list;
5 |
6 | /* Amount of space required in an argument list for an arg of type TYPE.
7 | TYPE may alternatively be an expression whose type is used. */
8 |
9 | #define __va_rounded_size(TYPE) \
10 | (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
11 |
12 | #ifndef __sparc__
13 | #define va_start(AP, LASTARG) \
14 | (AP = ((char *) &(LASTARG) + __va_rounded_size (LASTARG)))
15 | #else
16 | #define va_start(AP, LASTARG) \
17 | (__builtin_saveregs (), \
18 | AP = ((char *) &(LASTARG) + __va_rounded_size (LASTARG)))
19 | #endif
20 |
21 | void va_end (va_list); /* Defined in gnulib */
22 | #define va_end(AP)
23 |
24 | #define va_arg(AP, TYPE) \
25 | (AP += __va_rounded_size (TYPE), \
26 | *((TYPE *) (AP - __va_rounded_size (TYPE))))
27 |
28 | #endif /* _STDARG_H */
29 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/include/stddef.h:
--------------------------------------------------------------------------------
1 | #ifndef _STDDEF_H
2 | #define _STDDEF_H
3 |
4 | #ifndef _PTRDIFF_T
5 | #define _PTRDIFF_T
6 | typedef long ptrdiff_t;
7 | #endif
8 |
9 | #ifndef _SIZE_T
10 | #define _SIZE_T
11 | typedef unsigned long size_t;
12 | #endif
13 |
14 | #undef NULL
15 | #define NULL ((void *)0)
16 |
17 | #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
18 |
19 | #endif
20 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/include/sys/stat.h:
--------------------------------------------------------------------------------
1 | #ifndef _SYS_STAT_H
2 | #define _SYS_STAT_H
3 |
4 | #include
5 |
6 | struct stat {
7 | dev_t st_dev;
8 | ino_t st_ino;
9 | umode_t st_mode;
10 | nlink_t st_nlink;
11 | uid_t st_uid;
12 | gid_t st_gid;
13 | dev_t st_rdev;
14 | off_t st_size;
15 | time_t st_atime;
16 | time_t st_mtime;
17 | time_t st_ctime;
18 | };
19 |
20 | #define S_IFMT 00170000
21 | #define S_IFREG 0100000
22 | #define S_IFBLK 0060000
23 | #define S_IFDIR 0040000
24 | #define S_IFCHR 0020000
25 | #define S_IFIFO 0010000
26 | #define S_ISUID 0004000
27 | #define S_ISGID 0002000
28 | #define S_ISVTX 0001000
29 |
30 | #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
31 | #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
32 | #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
33 | #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
34 | #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
35 |
36 | #define S_IRWXU 00700
37 | #define S_IRUSR 00400
38 | #define S_IWUSR 00200
39 | #define S_IXUSR 00100
40 |
41 | #define S_IRWXG 00070
42 | #define S_IRGRP 00040
43 | #define S_IWGRP 00020
44 | #define S_IXGRP 00010
45 |
46 | #define S_IRWXO 00007
47 | #define S_IROTH 00004
48 | #define S_IWOTH 00002
49 | #define S_IXOTH 00001
50 |
51 | extern int chmod(const char *_path, mode_t mode);
52 | extern int fstat(int fildes, struct stat *stat_buf);
53 | extern int mkdir(const char *_path, mode_t mode);
54 | extern int mkfifo(const char *_path, mode_t mode);
55 | extern int stat(const char *filename, struct stat *stat_buf);
56 | extern mode_t umask(mode_t mask);
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/include/sys/times.h:
--------------------------------------------------------------------------------
1 | #ifndef _TIMES_H
2 | #define _TIMES_H
3 |
4 | #include
5 |
6 | struct tms {
7 | time_t tms_utime;
8 | time_t tms_stime;
9 | time_t tms_cutime;
10 | time_t tms_cstime;
11 | };
12 |
13 | extern time_t times(struct tms * tp);
14 |
15 | #endif
16 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/include/sys/types.h:
--------------------------------------------------------------------------------
1 | #ifndef _SYS_TYPES_H
2 | #define _SYS_TYPES_H
3 |
4 | #ifndef _SIZE_T
5 | #define _SIZE_T
6 | typedef unsigned int size_t;
7 | #endif
8 |
9 | #ifndef _TIME_T
10 | #define _TIME_T
11 | typedef long time_t;
12 | #endif
13 |
14 | #ifndef _PTRDIFF_T
15 | #define _PTRDIFF_T
16 | typedef long ptrdiff_t;
17 | #endif
18 |
19 | #ifndef NULL
20 | #define NULL ((void *) 0)
21 | #endif
22 |
23 | typedef int pid_t;
24 | typedef unsigned short uid_t;
25 | typedef unsigned char gid_t;
26 | typedef unsigned short dev_t;
27 | typedef unsigned short ino_t;
28 | typedef unsigned short mode_t;
29 | typedef unsigned short umode_t;
30 | typedef unsigned char nlink_t;
31 | typedef int daddr_t;
32 | typedef long off_t;
33 | typedef unsigned char u_char;
34 | typedef unsigned short ushort;
35 |
36 | typedef struct { int quot,rem; } div_t;
37 | typedef struct { long quot,rem; } ldiv_t;
38 |
39 | struct ustat {
40 | daddr_t f_tfree;
41 | ino_t f_tinode;
42 | char f_fname[6];
43 | char f_fpack[6];
44 | };
45 |
46 | #endif
47 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/include/sys/utsname.h:
--------------------------------------------------------------------------------
1 | #ifndef _SYS_UTSNAME_H
2 | #define _SYS_UTSNAME_H
3 |
4 | #include
5 |
6 | struct utsname {
7 | char sysname[9];
8 | char nodename[9];
9 | char release[9];
10 | char version[9];
11 | char machine[9];
12 | };
13 |
14 | extern int uname(struct utsname * utsbuf);
15 |
16 | #endif
17 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/include/sys/wait.h:
--------------------------------------------------------------------------------
1 | #ifndef _SYS_WAIT_H
2 | #define _SYS_WAIT_H
3 |
4 | #include
5 |
6 | #define _LOW(v) ( (v) & 0377)
7 | #define _HIGH(v) ( ((v) >> 8) & 0377)
8 |
9 | /* options for waitpid, WUNTRACED not supported */
10 | #define WNOHANG 1
11 | #define WUNTRACED 2
12 |
13 | #define WIFEXITED(s) (!((s)&0xFF)
14 | #define WIFSTOPPED(s) (((s)&0xFF)==0x7F)
15 | #define WEXITSTATUS(s) (((s)>>8)&0xFF)
16 | #define WTERMSIG(s) ((s)&0x7F)
17 | #define WSTOPSIG(s) (((s)>>8)&0xFF)
18 | #define WIFSIGNALED(s) (((unsigned int)(s)-1 & 0xFFFF) < 0xFF)
19 |
20 | pid_t wait(int *stat_loc);
21 | pid_t waitpid(pid_t pid, int *stat_loc, int options);
22 |
23 | #endif
24 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/include/time.h:
--------------------------------------------------------------------------------
1 | #ifndef _TIME_H
2 | #define _TIME_H
3 |
4 | #ifndef _TIME_T
5 | #define _TIME_T
6 | typedef long time_t;
7 | #endif
8 |
9 | #ifndef _SIZE_T
10 | #define _SIZE_T
11 | typedef unsigned int size_t;
12 | #endif
13 |
14 | #define CLOCKS_PER_SEC 100
15 |
16 | typedef long clock_t;
17 |
18 | struct tm {
19 | int tm_sec;
20 | int tm_min;
21 | int tm_hour;
22 | int tm_mday;
23 | int tm_mon;
24 | int tm_year;
25 | int tm_wday;
26 | int tm_yday;
27 | int tm_isdst;
28 | };
29 |
30 | clock_t clock(void);
31 | time_t time(time_t * tp);
32 | double difftime(time_t time2, time_t time1);
33 | time_t mktime(struct tm * tp);
34 |
35 | char * asctime(const struct tm * tp);
36 | char * ctime(const time_t * tp);
37 | struct tm * gmtime(const time_t *tp);
38 | struct tm *localtime(const time_t * tp);
39 | size_t strftime(char * s, size_t smax, const char * fmt, const struct tm * tp);
40 | void tzset(void);
41 |
42 | #endif
43 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/include/utime.h:
--------------------------------------------------------------------------------
1 | #ifndef _UTIME_H
2 | #define _UTIME_H
3 |
4 | #include /* I know - shouldn't do this, but .. */
5 |
6 | struct utimbuf {
7 | time_t actime;
8 | time_t modtime;
9 | };
10 |
11 | extern int utime(const char *filename, struct utimbuf *times);
12 |
13 | #endif
14 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/kernel/blk_drv/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile for the FREAX-kernel block device drivers.
3 | #
4 | # Note! Dependencies are done automagically by 'make dep', which also
5 | # removes any old dependencies. DON'T put your own dependencies here
6 | # unless it's something special (ie not a .c file).
7 | #
8 |
9 | AR =ar
10 | AS =as
11 | LD =ld
12 | LDFLAGS =-s -x
13 | CC =gcc -mcpu=i386
14 | CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \
15 | -finline-functions -fgnu89-inline -nostdinc -I../../include
16 | CPP =gcc -E -nostdinc -I../../include
17 |
18 | .c.s:
19 | $(CC) $(CFLAGS) \
20 | -S -o $*.s $<
21 | .s.o:
22 | $(AS) -o $*.o $<
23 | .c.o:
24 | $(CC) $(CFLAGS) \
25 | -c -o $*.o $<
26 |
27 | OBJS = ll_rw_blk.o floppy.o hd.o ramdisk.o
28 |
29 | blk_drv.a: $(OBJS)
30 | $(AR) rcs blk_drv.a $(OBJS)
31 | sync
32 |
33 | clean:
34 | rm -f core *.o *.a tmp_make
35 | for i in *.c;do rm -f `basename $$i .c`.s;done
36 |
37 | dep:
38 | sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
39 | (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \
40 | $(CPP) -M $$i;done) >> tmp_make
41 | cp tmp_make Makefile
42 |
43 | ### Dependencies:
44 | floppy.s floppy.o: floppy.c ../../include/linux/sched.h ../../include/linux/head.h \
45 | ../../include/linux/fs.h ../../include/sys/types.h \
46 | ../../include/linux/mm.h ../../include/signal.h \
47 | ../../include/linux/kernel.h ../../include/linux/fdreg.h \
48 | ../../include/asm/system.h ../../include/asm/io.h \
49 | ../../include/asm/segment.h blk.h
50 | hd.s hd.o: hd.c ../../include/linux/config.h ../../include/linux/sched.h \
51 | ../../include/linux/head.h ../../include/linux/fs.h \
52 | ../../include/sys/types.h ../../include/linux/mm.h \
53 | ../../include/signal.h ../../include/linux/kernel.h \
54 | ../../include/linux/hdreg.h ../../include/asm/system.h \
55 | ../../include/asm/io.h ../../include/asm/segment.h blk.h
56 | ll_rw_blk.s ll_rw_blk.o: ll_rw_blk.c ../../include/errno.h \
57 | ../../include/linux/sched.h ../../include/linux/head.h \
58 | ../../include/linux/fs.h ../../include/sys/types.h \
59 | ../../include/linux/mm.h ../../include/signal.h \
60 | ../../include/linux/kernel.h ../../include/asm/system.h blk.h
61 | ramdisk.s ramdisk.o: ramdisk.c ../../include/string.h ../../include/linux/config.h \
62 | ../../include/linux/sched.h ../../include/linux/head.h \
63 | ../../include/linux/fs.h ../../include/sys/types.h \
64 | ../../include/linux/mm.h ../../include/signal.h \
65 | ../../include/linux/kernel.h ../../include/asm/system.h \
66 | ../../include/asm/segment.h ../../include/asm/memory.h blk.h
67 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/kernel/chr_drv/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile for the FREAX-kernel character device drivers.
3 | #
4 | # Note! Dependencies are done automagically by 'make dep', which also
5 | # removes any old dependencies. DON'T put your own dependencies here
6 | # unless it's something special (ie not a .c file).
7 | #
8 |
9 | AR =ar
10 | AS =as
11 | LD =ld
12 | LDFLAGS =-s -x
13 | CC =gcc -march=i386
14 | CFLAGS =-Wall -O -g -fstrength-reduce -fomit-frame-pointer \
15 | -finline-functions -fgnu89-inline -fno-stack-protector -nostdinc -I../../include
16 | CPP =gcc -E -nostdinc -I../../include
17 |
18 | .c.s:
19 | $(CC) $(CFLAGS) \
20 | -S -o $*.s $<
21 | .s.o:
22 | $(AS) -o $*.o $<
23 | .c.o:
24 | $(CC) $(CFLAGS) \
25 | -c -o $*.o $<
26 |
27 | OBJS = tty_io.o console.o keyboard.o serial.o rs_io.o \
28 | tty_ioctl.o
29 |
30 | chr_drv.a: $(OBJS)
31 | $(AR) rcs chr_drv.a $(OBJS)
32 | sync
33 |
34 | keyboard.s: keyboard.S ../../include/linux/config.h
35 | $(CPP) -traditional keyboard.S -o keyboard.s
36 |
37 | clean:
38 | rm -f core *.o *.a tmp_make keyboard.s
39 | for i in *.c;do rm -f `basename $$i .c`.s;done
40 |
41 | dep:
42 | sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
43 | (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \
44 | $(CPP) -M $$i;done) >> tmp_make
45 | cp tmp_make Makefile
46 |
47 | ### Dependencies:
48 | console.s console.o: console.c ../../include/linux/sched.h \
49 | ../../include/linux/head.h ../../include/linux/fs.h \
50 | ../../include/sys/types.h ../../include/linux/mm.h \
51 | ../../include/signal.h ../../include/linux/tty.h \
52 | ../../include/termios.h ../../include/asm/io.h \
53 | ../../include/asm/system.h
54 | serial.s serial.o: serial.c ../../include/linux/tty.h ../../include/termios.h \
55 | ../../include/linux/sched.h ../../include/linux/head.h \
56 | ../../include/linux/fs.h ../../include/sys/types.h \
57 | ../../include/linux/mm.h ../../include/signal.h \
58 | ../../include/asm/system.h ../../include/asm/io.h
59 | tty_io.s tty_io.o: tty_io.c ../../include/ctype.h ../../include/errno.h \
60 | ../../include/signal.h ../../include/sys/types.h \
61 | ../../include/linux/sched.h ../../include/linux/head.h \
62 | ../../include/linux/fs.h ../../include/linux/mm.h \
63 | ../../include/linux/tty.h ../../include/termios.h \
64 | ../../include/asm/segment.h ../../include/asm/system.h
65 | tty_ioctl.s tty_ioctl.o: tty_ioctl.c ../../include/errno.h ../../include/termios.h \
66 | ../../include/linux/sched.h ../../include/linux/head.h \
67 | ../../include/linux/fs.h ../../include/sys/types.h \
68 | ../../include/linux/mm.h ../../include/signal.h \
69 | ../../include/linux/kernel.h ../../include/linux/tty.h \
70 | ../../include/asm/io.h ../../include/asm/segment.h \
71 | ../../include/asm/system.h
72 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/kernel/chr_drv/serial.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/kernel/serial.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | /*
8 | * serial.c
9 | *
10 | * This module implements the rs232 io functions
11 | * void rs_write(struct tty_struct * queue);
12 | * void rs_init(void);
13 | * and all interrupts pertaining to serial IO.
14 | */
15 |
16 | #include
17 | #include
18 | #include
19 | #include
20 |
21 | #define WAKEUP_CHARS (TTY_BUF_SIZE/4)
22 |
23 | extern void rs1_interrupt(void);
24 | extern void rs2_interrupt(void);
25 |
26 | static void init(int port)
27 | {
28 | outb_p(0x80,port+3); /* set DLAB of line control reg */
29 | outb_p(0x30,port); /* LS of divisor (48 -> 2400 bps */
30 | outb_p(0x00,port+1); /* MS of divisor */
31 | outb_p(0x03,port+3); /* reset DLAB */
32 | outb_p(0x0b,port+4); /* set DTR,RTS, OUT_2 */
33 | outb_p(0x0d,port+1); /* enable all intrs but writes */
34 | (void)inb(port); /* read data port to reset things (?) */
35 | }
36 |
37 | void rs_init(void)
38 | {
39 | set_intr_gate(0x24,rs1_interrupt);
40 | set_intr_gate(0x23,rs2_interrupt);
41 | init(tty_table[1].read_q.data);
42 | init(tty_table[2].read_q.data);
43 | outb(inb_p(0x21)&0xE7,0x21);
44 | }
45 |
46 | /*
47 | * This routine gets called when tty_write has put something into
48 | * the write_queue. It must check wheter the queue is empty, and
49 | * set the interrupt register accordingly
50 | *
51 | * void _rs_write(struct tty_struct * tty);
52 | */
53 | void rs_write(struct tty_struct * tty)
54 | {
55 | cli();
56 | if (!EMPTY(tty->write_q))
57 | outb(inb_p(tty->write_q.data+1)|0x02,tty->write_q.data+1);
58 | sti();
59 | }
60 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/kernel/math/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile for the FREAX-kernel character device drivers.
3 | #
4 | # Note! Dependencies are done automagically by 'make dep', which also
5 | # removes any old dependencies. DON'T put your own dependencies here
6 | # unless it's something special (ie not a .c file).
7 | #
8 |
9 | AR =ar
10 | AS =as
11 | LD =ld
12 | LDFLAGS =-s -x
13 | CC =gcc -mcpu=i386
14 | CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \
15 | -finline-functions -fgnu89-inline -nostdinc -I../../include
16 | CPP =gcc -E -nostdinc -I../../include
17 |
18 | .c.s:
19 | $(CC) $(CFLAGS) \
20 | -S -o $*.s $<
21 | .s.o:
22 | $(AS) -o $*.o $<
23 | .c.o:
24 | $(CC) $(CFLAGS) \
25 | -c -o $*.o $<
26 |
27 | OBJS = math_emulate.o
28 |
29 | math.a: $(OBJS)
30 | $(AR) rcs math.a $(OBJS)
31 | sync
32 |
33 | clean:
34 | rm -f core *.o *.a tmp_make
35 | for i in *.c;do rm -f `basename $$i .c`.s;done
36 |
37 | dep:
38 | sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
39 | (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \
40 | $(CPP) -M $$i;done) >> tmp_make
41 | cp tmp_make Makefile
42 |
43 | ### Dependencies:
44 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/kernel/math/math_emulate.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/kernel/math/math_emulate.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | /*
8 | * This directory should contain the math-emulation code.
9 | * Currently only results in a signal.
10 | */
11 |
12 | #include
13 |
14 | #include
15 | #include
16 | #include
17 |
18 | void math_emulate(long edi, long esi, long ebp, long sys_call_ret,
19 | long eax,long ebx,long ecx,long edx,
20 | unsigned short fs,unsigned short es,unsigned short ds,
21 | unsigned long eip,unsigned short cs,unsigned long eflags,
22 | unsigned short ss, unsigned long esp)
23 | {
24 | unsigned char first, second;
25 |
26 | /* 0x0007 means user code space */
27 | if (cs != 0x000F) {
28 | printk("math_emulate: %04x:%08x\n\r",cs,eip);
29 | panic("Math emulation needed in kernel");
30 | }
31 | first = get_fs_byte((char *)((*&eip)++));
32 | second = get_fs_byte((char *)((*&eip)++));
33 | printk("%04x:%08x %02x %02x\n\r",cs,eip-2,first,second);
34 | current->signal |= 1<<(SIGFPE-1);
35 | }
36 |
37 | void math_error(void)
38 | {
39 | __asm__("fnclex");
40 | if (last_task_used_math)
41 | last_task_used_math->signal |= 1<<(SIGFPE-1);
42 | }
43 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/kernel/mktime.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/kernel/mktime.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #include
8 |
9 | /*
10 | * This isn't the library routine, it is only used in the kernel.
11 | * as such, we don't care about years<1970 etc, but assume everything
12 | * is ok. Similarly, TZ etc is happily ignored. We just do everything
13 | * as easily as possible. Let's find something public for the library
14 | * routines (although I think minix times is public).
15 | */
16 | /*
17 | * PS. I hate whoever though up the year 1970 - couldn't they have gotten
18 | * a leap-year instead? I also hate Gregorius, pope or no. I'm grumpy.
19 | */
20 | #define MINUTE 60
21 | #define HOUR (60*MINUTE)
22 | #define DAY (24*HOUR)
23 | #define YEAR (365*DAY)
24 |
25 | /* interestingly, we assume leap-years */
26 | static int month[12] = {
27 | 0,
28 | DAY*(31),
29 | DAY*(31+29),
30 | DAY*(31+29+31),
31 | DAY*(31+29+31+30),
32 | DAY*(31+29+31+30+31),
33 | DAY*(31+29+31+30+31+30),
34 | DAY*(31+29+31+30+31+30+31),
35 | DAY*(31+29+31+30+31+30+31+31),
36 | DAY*(31+29+31+30+31+30+31+31+30),
37 | DAY*(31+29+31+30+31+30+31+31+30+31),
38 | DAY*(31+29+31+30+31+30+31+31+30+31+30)
39 | };
40 |
41 | long kernel_mktime(struct tm * tm)
42 | {
43 | long res;
44 | int year;
45 |
46 | year = tm->tm_year - 70;
47 | /* magic offsets (y+1) needed to get leapyears right.*/
48 | res = YEAR*year + DAY*((year+1)/4);
49 | res += month[tm->tm_mon];
50 | /* and (y+2) here. If it wasn't a leap-year, we have to adjust */
51 | if (tm->tm_mon>1 && ((year+2)%4))
52 | res -= DAY;
53 | res += DAY*(tm->tm_mday-1);
54 | res += HOUR*tm->tm_hour;
55 | res += MINUTE*tm->tm_min;
56 | res += tm->tm_sec;
57 | return res;
58 | }
59 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/kernel/panic.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/kernel/panic.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | /*
8 | * This function is used through-out the kernel (includeinh mm and fs)
9 | * to indicate a major problem.
10 | */
11 | #define PANIC
12 |
13 | #include
14 | #include
15 |
16 | void sys_sync(void); /* it's really int */
17 |
18 | volatile void panic(const char * s)
19 | {
20 | printk("Kernel panic: %s\n\r",s);
21 | if (current == task[0])
22 | printk("In swapper task - not syncing\n\r");
23 | else
24 | sys_sync();
25 | for(;;);
26 | }
27 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/kernel/printk.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/kernel/printk.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | /*
8 | * When in kernel-mode, we cannot use printf, as fs is liable to
9 | * point to 'interesting' things. Make a printf with fs-saving, and
10 | * all is well.
11 | */
12 | #include
13 | #include
14 |
15 | #include
16 |
17 | static char buf[1024];
18 |
19 | extern int vsprintf(char * buf, const char * fmt, va_list args);
20 |
21 | int printk(const char *fmt, ...)
22 | {
23 | va_list args;
24 | int i;
25 |
26 | va_start(args, fmt);
27 | i=vsprintf(buf,fmt,args);
28 | va_end(args);
29 | __asm__("push %%fs\n\t"
30 | "push %%ds\n\t"
31 | "pop %%fs\n\t"
32 | "pushl %0\n\t"
33 | "pushl $buf\n\t"
34 | "pushl $0\n\t"
35 | "call tty_write\n\t"
36 | "addl $8,%%esp\n\t"
37 | "popl %0\n\t"
38 | "pop %%fs"
39 | ::"r" (i):"ax","cx","dx");
40 | return i;
41 | }
42 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/lib/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile for some libs needed in the kernel.
3 | #
4 | # Note! Dependencies are done automagically by 'make dep', which also
5 | # removes any old dependencies. DON'T put your own dependencies here
6 | # unless it's something special (ie not a .c file).
7 | #
8 |
9 | AR =ar
10 | AS =as
11 | LD =ld
12 | LDFLAGS =-s -x
13 | CC =gcc -mcpu=i386
14 | CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \
15 | -finline-functions -fgnu89-inline -nostdinc -I../include
16 | CPP =gcc -E -nostdinc -I../include
17 |
18 | .c.s:
19 | $(CC) $(CFLAGS) \
20 | -S -o $*.s $<
21 | .s.o:
22 | $(AS) -o $*.o $<
23 | .c.o:
24 | $(CC) $(CFLAGS) \
25 | -c -o $*.o $<
26 |
27 | OBJS = ctype.o _exit.o open.o close.o errno.o write.o dup.o setsid.o \
28 | execve.o wait.o string.o malloc.o
29 |
30 | lib.a: $(OBJS)
31 | $(AR) rcs lib.a $(OBJS)
32 | sync
33 |
34 | clean:
35 | rm -f core *.o *.a tmp_make
36 | for i in *.c;do rm -f `basename $$i .c`.s;done
37 |
38 | dep:
39 | sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
40 | (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \
41 | $(CPP) -M $$i;done) >> tmp_make
42 | cp tmp_make Makefile
43 |
44 | ### Dependencies:
45 | _exit.s _exit.o : _exit.c ../include/unistd.h ../include/sys/stat.h \
46 | ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \
47 | ../include/utime.h
48 | close.s close.o : close.c ../include/unistd.h ../include/sys/stat.h \
49 | ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \
50 | ../include/utime.h
51 | ctype.s ctype.o : ctype.c ../include/ctype.h
52 | dup.s dup.o : dup.c ../include/unistd.h ../include/sys/stat.h \
53 | ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \
54 | ../include/utime.h
55 | errno.s errno.o : errno.c
56 | execve.s execve.o : execve.c ../include/unistd.h ../include/sys/stat.h \
57 | ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \
58 | ../include/utime.h
59 | malloc.s malloc.o : malloc.c ../include/linux/kernel.h ../include/linux/mm.h \
60 | ../include/asm/system.h
61 | open.s open.o : open.c ../include/unistd.h ../include/sys/stat.h \
62 | ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \
63 | ../include/utime.h ../include/stdarg.h
64 | setsid.s setsid.o : setsid.c ../include/unistd.h ../include/sys/stat.h \
65 | ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \
66 | ../include/utime.h
67 | string.s string.o : string.c ../include/string.h
68 | wait.s wait.o : wait.c ../include/unistd.h ../include/sys/stat.h \
69 | ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \
70 | ../include/utime.h ../include/sys/wait.h
71 | write.s write.o : write.c ../include/unistd.h ../include/sys/stat.h \
72 | ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \
73 | ../include/utime.h
74 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/lib/_exit.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/_exit.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #define __LIBRARY__
8 | #include
9 |
10 | volatile void _exit(int exit_code)
11 | {
12 | __asm__("int $0x80"::"a" (__NR_exit),"b" (exit_code));
13 | }
14 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/lib/close.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/close.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #define __LIBRARY__
8 | #include
9 |
10 | _syscall1(int,close,int,fd)
11 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/lib/ctype.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/ctype.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #include
8 |
9 | char _ctmp;
10 | unsigned char _ctype[] = {0x00, /* EOF */
11 | _C,_C,_C,_C,_C,_C,_C,_C, /* 0-7 */
12 | _C,_C|_S,_C|_S,_C|_S,_C|_S,_C|_S,_C,_C, /* 8-15 */
13 | _C,_C,_C,_C,_C,_C,_C,_C, /* 16-23 */
14 | _C,_C,_C,_C,_C,_C,_C,_C, /* 24-31 */
15 | _S|_SP,_P,_P,_P,_P,_P,_P,_P, /* 32-39 */
16 | _P,_P,_P,_P,_P,_P,_P,_P, /* 40-47 */
17 | _D,_D,_D,_D,_D,_D,_D,_D, /* 48-55 */
18 | _D,_D,_P,_P,_P,_P,_P,_P, /* 56-63 */
19 | _P,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U, /* 64-71 */
20 | _U,_U,_U,_U,_U,_U,_U,_U, /* 72-79 */
21 | _U,_U,_U,_U,_U,_U,_U,_U, /* 80-87 */
22 | _U,_U,_U,_P,_P,_P,_P,_P, /* 88-95 */
23 | _P,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L, /* 96-103 */
24 | _L,_L,_L,_L,_L,_L,_L,_L, /* 104-111 */
25 | _L,_L,_L,_L,_L,_L,_L,_L, /* 112-119 */
26 | _L,_L,_L,_P,_P,_P,_P,_C, /* 120-127 */
27 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 128-143 */
28 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 144-159 */
29 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 160-175 */
30 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 176-191 */
31 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 192-207 */
32 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 208-223 */
33 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 224-239 */
34 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; /* 240-255 */
35 |
36 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/lib/dup.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/dup.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #define __LIBRARY__
8 | #include
9 |
10 | _syscall1(int,dup,int,fd)
11 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/lib/errno.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/errno.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | int errno;
8 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/lib/execve.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/execve.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #define __LIBRARY__
8 | #include
9 |
10 | _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
11 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/lib/open.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/open.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #define __LIBRARY__
8 | #include
9 | #include
10 |
11 | int open(const char * filename, int flag, ...)
12 | {
13 | register int res;
14 | va_list arg;
15 |
16 | va_start(arg,flag);
17 | __asm__("int $0x80"
18 | :"=a" (res)
19 | :"0" (__NR_open),"b" (filename),"c" (flag),
20 | "d" (va_arg(arg,int)));
21 | if (res>=0)
22 | return res;
23 | errno = -res;
24 | return -1;
25 | }
26 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/lib/setsid.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/setsid.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #define __LIBRARY__
8 | #include
9 |
10 | _syscall0(pid_t,setsid)
11 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/lib/string.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/string.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #ifndef __GNUC__
8 | #error I want gcc!
9 | #endif
10 |
11 | #define extern
12 | #define inline
13 | #define static
14 | #define __LIBRARY__
15 | #include
16 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/lib/wait.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/wait.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #define __LIBRARY__
8 | #include
9 | #include
10 |
11 | _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
12 |
13 | pid_t wait(int * wait_stat)
14 | {
15 | return waitpid(-1,wait_stat,0);
16 | }
17 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/lib/write.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/write.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #define __LIBRARY__
8 | #include
9 |
10 | _syscall3(int,write,int,fd,const char *,buf,off_t,count)
11 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/mm/Makefile:
--------------------------------------------------------------------------------
1 | CC =gcc -mcpu=i386
2 | #CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \
3 | -finline-functions -nostdinc -I../include
4 | CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer -fgnu89-inline -fno-stack-protector -nostdinc -I../include
5 | AS =as
6 | AR =ar
7 | LD =ld
8 | CPP =gcc -E -nostdinc -I../include
9 |
10 | .c.o:
11 | $(CC) $(CFLAGS) \
12 | -c -o $*.o $<
13 | .s.o:
14 | $(AS) -o $*.o $<
15 | .c.s:
16 | $(CC) $(CFLAGS) \
17 | -S -o $*.s $<
18 |
19 | OBJS = memory.o page.o
20 |
21 | all: mm.o
22 |
23 | mm.o: $(OBJS)
24 | $(LD) -r -o mm.o $(OBJS)
25 |
26 | clean:
27 | rm -f core *.o *.a tmp_make
28 | for i in *.c;do rm -f `basename $$i .c`.s;done
29 |
30 | dep:
31 | sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
32 | (for i in *.c;do $(CPP) -M $$i;done) >> tmp_make
33 | cp tmp_make Makefile
34 |
35 | ### Dependencies:
36 | memory.o: memory.c ../include/signal.h ../include/sys/types.h \
37 | ../include/asm/system.h ../include/linux/sched.h \
38 | ../include/linux/head.h ../include/linux/fs.h ../include/linux/mm.h \
39 | ../include/linux/kernel.h
40 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/mm/Makefile-gcc3.x:
--------------------------------------------------------------------------------
1 | CC =gcc -mcpu=i386
2 | CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \
3 | -finline-functions -nostdinc -I../include
4 | #CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer -fgnu89-inline -nostdinc -I../include
5 | AS =as
6 | AR =ar
7 | LD =ld
8 | CPP =gcc -E -nostdinc -I../include
9 |
10 | .c.o:
11 | $(CC) $(CFLAGS) \
12 | -c -o $*.o $<
13 | .s.o:
14 | $(AS) -o $*.o $<
15 | .c.s:
16 | $(CC) $(CFLAGS) \
17 | -S -o $*.s $<
18 |
19 | OBJS = memory.o page.o
20 |
21 | all: mm.o
22 |
23 | mm.o: $(OBJS)
24 | $(LD) -r -o mm.o $(OBJS)
25 |
26 | clean:
27 | rm -f core *.o *.a tmp_make
28 | for i in *.c;do rm -f `basename $$i .c`.s;done
29 |
30 | dep:
31 | sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
32 | (for i in *.c;do $(CPP) -M $$i;done) >> tmp_make
33 | cp tmp_make Makefile
34 |
35 | ### Dependencies:
36 | memory.o: memory.c ../include/signal.h ../include/sys/types.h \
37 | ../include/asm/system.h ../include/linux/sched.h \
38 | ../include/linux/head.h ../include/linux/fs.h ../include/linux/mm.h \
39 | ../include/linux/kernel.h
40 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/mm/Makefile-gcc4.1:
--------------------------------------------------------------------------------
1 | CC =gcc -mcpu=i386
2 | #CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \
3 | -finline-functions -nostdinc -I../include
4 | CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer -fgnu89-inline -nostdinc -I../include
5 | AS =as
6 | AR =ar
7 | LD =ld
8 | CPP =gcc -E -nostdinc -I../include
9 |
10 | .c.o:
11 | $(CC) $(CFLAGS) \
12 | -c -o $*.o $<
13 | .s.o:
14 | $(AS) -o $*.o $<
15 | .c.s:
16 | $(CC) $(CFLAGS) \
17 | -S -o $*.s $<
18 |
19 | OBJS = memory.o page.o
20 |
21 | all: mm.o
22 |
23 | mm.o: $(OBJS)
24 | $(LD) -r -o mm.o $(OBJS)
25 |
26 | clean:
27 | rm -f core *.o *.a tmp_make
28 | for i in *.c;do rm -f `basename $$i .c`.s;done
29 |
30 | dep:
31 | sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
32 | (for i in *.c;do $(CPP) -M $$i;done) >> tmp_make
33 | cp tmp_make Makefile
34 |
35 | ### Dependencies:
36 | memory.o: memory.c ../include/signal.h ../include/sys/types.h \
37 | ../include/asm/system.h ../include/linux/sched.h \
38 | ../include/linux/head.h ../include/linux/fs.h ../include/linux/mm.h \
39 | ../include/linux/kernel.h
40 |
--------------------------------------------------------------------------------
/src/V0.11_gcc4/mm/page.s:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/mm/page.s
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | /*
8 | * page.s contains the low-level page-exception code.
9 | * the real work is done in mm.c
10 | */
11 |
12 | .globl page_fault
13 |
14 | page_fault:
15 | xchgl %eax,(%esp)
16 | pushl %ecx
17 | pushl %edx
18 | push %ds
19 | push %es
20 | push %fs
21 | movl $0x10,%edx
22 | mov %dx,%ds
23 | mov %dx,%es
24 | mov %dx,%fs
25 | movl %cr2,%edx
26 | pushl %edx
27 | pushl %eax
28 | testl $1,%eax
29 | jne 1f
30 | call do_no_page
31 | jmp 2f
32 | 1: call do_wp_page
33 | 2: addl $8,%esp
34 | pop %fs
35 | pop %es
36 | pop %ds
37 | popl %edx
38 | popl %ecx
39 | popl %eax
40 | iret
41 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/fs/block_dev.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/fs/block_dev.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #include
8 |
9 | #include
10 | #include
11 | #include
12 | #include
13 |
14 | int block_write(int dev, long * pos, char * buf, int count)
15 | {
16 | int block = *pos >> BLOCK_SIZE_BITS;
17 | int offset = *pos & (BLOCK_SIZE-1);
18 | int chars;
19 | int written = 0;
20 | struct buffer_head * bh;
21 | register char * p;
22 |
23 | while (count>0) {
24 | chars = BLOCK_SIZE - offset;
25 | if (chars > count)
26 | chars=count;
27 | if (chars == BLOCK_SIZE)
28 | bh = getblk(dev,block);
29 | else
30 | bh = breada(dev,block,block+1,block+2,-1);
31 | block++;
32 | if (!bh)
33 | return written?written:-EIO;
34 | p = offset + bh->b_data;
35 | offset = 0;
36 | *pos += chars;
37 | written += chars;
38 | count -= chars;
39 | while (chars-->0)
40 | *(p++) = get_fs_byte(buf++);
41 | bh->b_dirt = 1;
42 | brelse(bh);
43 | }
44 | return written;
45 | }
46 |
47 | int block_read(int dev, unsigned long * pos, char * buf, int count)
48 | {
49 | int block = *pos >> BLOCK_SIZE_BITS;
50 | int offset = *pos & (BLOCK_SIZE-1);
51 | int chars;
52 | int read = 0;
53 | struct buffer_head * bh;
54 | register char * p;
55 |
56 | while (count>0) {
57 | chars = BLOCK_SIZE-offset;
58 | if (chars > count)
59 | chars = count;
60 | if (!(bh = breada(dev,block,block+1,block+2,-1)))
61 | return read?read:-EIO;
62 | block++;
63 | p = offset + bh->b_data;
64 | offset = 0;
65 | *pos += chars;
66 | read += chars;
67 | count -= chars;
68 | while (chars-->0)
69 | put_fs_byte(*(p++),buf++);
70 | brelse(bh);
71 | }
72 | return read;
73 | }
74 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/fs/char_dev.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/fs/char_dev.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #include
8 | #include
9 |
10 | #include
11 | #include
12 |
13 | #include
14 | #include
15 |
16 | extern int tty_read(unsigned minor,char * buf,int count);
17 | extern int tty_write(unsigned minor,char * buf,int count);
18 |
19 | typedef int (*crw_ptr)(int rw,unsigned minor,char * buf,int count,off_t * pos);
20 |
21 | static int rw_ttyx(int rw,unsigned minor,char * buf,int count,off_t * pos)
22 | {
23 | return ((rw==READ)?tty_read(minor,buf,count):
24 | tty_write(minor,buf,count));
25 | }
26 |
27 | static int rw_tty(int rw,unsigned minor,char * buf,int count, off_t * pos)
28 | {
29 | if (current->tty<0)
30 | return -EPERM;
31 | return rw_ttyx(rw,current->tty,buf,count,pos);
32 | }
33 |
34 | static int rw_ram(int rw,char * buf, int count, off_t *pos)
35 | {
36 | return -EIO;
37 | }
38 |
39 | static int rw_mem(int rw,char * buf, int count, off_t * pos)
40 | {
41 | return -EIO;
42 | }
43 |
44 | static int rw_kmem(int rw,char * buf, int count, off_t * pos)
45 | {
46 | return -EIO;
47 | }
48 |
49 | static int rw_port(int rw,char * buf, int count, off_t * pos)
50 | {
51 | int i=*pos;
52 |
53 | while (count-->0 && i<65536) {
54 | if (rw==READ)
55 | put_fs_byte(inb(i),buf++);
56 | else
57 | outb(get_fs_byte(buf++),i);
58 | i++;
59 | }
60 | i -= *pos;
61 | *pos += i;
62 | return i;
63 | }
64 |
65 | static int rw_memory(int rw, unsigned minor, char * buf, int count, off_t * pos)
66 | {
67 | switch(minor) {
68 | case 0:
69 | return rw_ram(rw,buf,count,pos);
70 | case 1:
71 | return rw_mem(rw,buf,count,pos);
72 | case 2:
73 | return rw_kmem(rw,buf,count,pos);
74 | case 3:
75 | return (rw==READ)?0:count; /* rw_null */
76 | case 4:
77 | return rw_port(rw,buf,count,pos);
78 | default:
79 | return -EIO;
80 | }
81 | }
82 |
83 | #define NRDEVS ((sizeof (crw_table))/(sizeof (crw_ptr)))
84 |
85 | static crw_ptr crw_table[]={
86 | NULL, /* nodev */
87 | rw_memory, /* /dev/mem etc */
88 | NULL, /* /dev/fd */
89 | NULL, /* /dev/hd */
90 | rw_ttyx, /* /dev/ttyx */
91 | rw_tty, /* /dev/tty */
92 | NULL, /* /dev/lp */
93 | NULL}; /* unnamed pipes */
94 |
95 | int rw_char(int rw,int dev, char * buf, int count, off_t * pos)
96 | {
97 | crw_ptr call_addr;
98 |
99 | if (MAJOR(dev)>=NRDEVS)
100 | return -ENODEV;
101 | if (!(call_addr=crw_table[MAJOR(dev)]))
102 | return -ENODEV;
103 | return call_addr(rw,MINOR(dev),buf,count,pos);
104 | }
105 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/fs/fcntl.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/fs/fcntl.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | /* #include */
8 | #include
9 | #include
10 | #include
11 | #include
12 |
13 | #include
14 | #include
15 |
16 | extern int sys_close(int fd);
17 |
18 | static int dupfd(unsigned int fd, unsigned int arg)
19 | {
20 | if (fd >= NR_OPEN || !current->filp[fd])
21 | return -EBADF;
22 | if (arg >= NR_OPEN)
23 | return -EINVAL;
24 | while (arg < NR_OPEN)
25 | if (current->filp[arg])
26 | arg++;
27 | else
28 | break;
29 | if (arg >= NR_OPEN)
30 | return -EMFILE;
31 | current->close_on_exec &= ~(1<filp[arg] = current->filp[fd])->f_count++;
33 | return arg;
34 | }
35 |
36 | int sys_dup2(unsigned int oldfd, unsigned int newfd)
37 | {
38 | sys_close(newfd);
39 | return dupfd(oldfd,newfd);
40 | }
41 |
42 | int sys_dup(unsigned int fildes)
43 | {
44 | return dupfd(fildes,0);
45 | }
46 |
47 | int sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg)
48 | {
49 | struct file * filp;
50 |
51 | if (fd >= NR_OPEN || !(filp = current->filp[fd]))
52 | return -EBADF;
53 | switch (cmd) {
54 | case F_DUPFD:
55 | return dupfd(fd,arg);
56 | case F_GETFD:
57 | return (current->close_on_exec>>fd)&1;
58 | case F_SETFD:
59 | if (arg&1)
60 | current->close_on_exec |= (1<close_on_exec &= ~(1<f_flags;
66 | case F_SETFL:
67 | filp->f_flags &= ~(O_APPEND | O_NONBLOCK);
68 | filp->f_flags |= arg & (O_APPEND | O_NONBLOCK);
69 | return 0;
70 | case F_GETLK: case F_SETLK: case F_SETLKW:
71 | return -1;
72 | default:
73 | return -1;
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/fs/file_dev.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/fs/file_dev.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #include
8 | #include
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | #define MIN(a,b) (((a)<(b))?(a):(b))
15 | #define MAX(a,b) (((a)>(b))?(a):(b))
16 |
17 | int file_read(struct m_inode * inode, struct file * filp, char * buf, int count)
18 | {
19 | int left,chars,nr;
20 | struct buffer_head * bh;
21 |
22 | if ((left=count)<=0)
23 | return 0;
24 | while (left) {
25 | if ((nr = bmap(inode,(filp->f_pos)/BLOCK_SIZE))) {
26 | if (!(bh=bread(inode->i_dev,nr)))
27 | break;
28 | } else
29 | bh = NULL;
30 | nr = filp->f_pos % BLOCK_SIZE;
31 | chars = MIN( BLOCK_SIZE-nr , left );
32 | filp->f_pos += chars;
33 | left -= chars;
34 | if (bh) {
35 | char * p = nr + bh->b_data;
36 | while (chars-->0)
37 | put_fs_byte(*(p++),buf++);
38 | brelse(bh);
39 | } else {
40 | while (chars-->0)
41 | put_fs_byte(0,buf++);
42 | }
43 | }
44 | inode->i_atime = CURRENT_TIME;
45 | return (count-left)?(count-left):-ERROR;
46 | }
47 |
48 | int file_write(struct m_inode * inode, struct file * filp, char * buf, int count)
49 | {
50 | off_t pos;
51 | int block,c;
52 | struct buffer_head * bh;
53 | char * p;
54 | int i=0;
55 |
56 | /*
57 | * ok, append may not work when many processes are writing at the same time
58 | * but so what. That way leads to madness anyway.
59 | */
60 | if (filp->f_flags & O_APPEND)
61 | pos = inode->i_size;
62 | else
63 | pos = filp->f_pos;
64 | while (ii_dev,block)))
68 | break;
69 | c = pos % BLOCK_SIZE;
70 | p = c + bh->b_data;
71 | bh->b_dirt = 1;
72 | c = BLOCK_SIZE-c;
73 | if (c > count-i) c = count-i;
74 | pos += c;
75 | if (pos > inode->i_size) {
76 | inode->i_size = pos;
77 | inode->i_dirt = 1;
78 | }
79 | i += c;
80 | while (c-->0)
81 | *(p++) = get_fs_byte(buf++);
82 | brelse(bh);
83 | }
84 | inode->i_mtime = CURRENT_TIME;
85 | if (!(filp->f_flags & O_APPEND)) {
86 | filp->f_pos = pos;
87 | inode->i_ctime = CURRENT_TIME;
88 | }
89 | return (i?i:-1);
90 | }
91 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/fs/file_table.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/fs/file_table.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #include
8 |
9 | struct file file_table[NR_FILE];
10 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/fs/ioctl.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/fs/ioctl.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | /* #include */
8 | #include
9 | #include
10 |
11 | #include
12 |
13 | extern int tty_ioctl(int dev, int cmd, int arg);
14 |
15 | typedef int (*ioctl_ptr)(int dev,int cmd,int arg);
16 |
17 | #define NRDEVS ((sizeof (ioctl_table))/(sizeof (ioctl_ptr)))
18 |
19 | static ioctl_ptr ioctl_table[]={
20 | NULL, /* nodev */
21 | NULL, /* /dev/mem */
22 | NULL, /* /dev/fd */
23 | NULL, /* /dev/hd */
24 | tty_ioctl, /* /dev/ttyx */
25 | tty_ioctl, /* /dev/tty */
26 | NULL, /* /dev/lp */
27 | NULL}; /* named pipes */
28 |
29 |
30 | int sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
31 | {
32 | struct file * filp;
33 | int dev,mode;
34 |
35 | if (fd >= NR_OPEN || !(filp = current->filp[fd]))
36 | return -EBADF;
37 | mode=filp->f_inode->i_mode;
38 | if (!S_ISCHR(mode) && !S_ISBLK(mode))
39 | return -EINVAL;
40 | dev = filp->f_inode->i_zone[0];
41 | if (MAJOR(dev) >= NRDEVS)
42 | return -ENODEV;
43 | if (!ioctl_table[MAJOR(dev)])
44 | return -ENOTTY;
45 | return ioctl_table[MAJOR(dev)](dev,cmd,arg);
46 | }
47 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/fs/stat.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/fs/stat.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #include
8 | #include
9 |
10 | #include
11 | #include
12 | #include
13 | #include
14 |
15 | static void cp_stat(struct m_inode * inode, struct stat * statbuf)
16 | {
17 | struct stat tmp;
18 | int i;
19 |
20 | verify_area(statbuf,sizeof (* statbuf));
21 | tmp.st_dev = inode->i_dev;
22 | tmp.st_ino = inode->i_num;
23 | tmp.st_mode = inode->i_mode;
24 | tmp.st_nlink = inode->i_nlinks;
25 | tmp.st_uid = inode->i_uid;
26 | tmp.st_gid = inode->i_gid;
27 | tmp.st_rdev = inode->i_zone[0];
28 | tmp.st_size = inode->i_size;
29 | tmp.st_atime = inode->i_atime;
30 | tmp.st_mtime = inode->i_mtime;
31 | tmp.st_ctime = inode->i_ctime;
32 | for (i=0 ; i= NR_OPEN || !(f=current->filp[fd]) || !(inode=f->f_inode))
53 | return -EBADF;
54 | cp_stat(inode,statbuf);
55 | return 0;
56 | }
57 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/fs/truncate.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/fs/truncate.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #include
8 |
9 | #include
10 |
11 | static void free_ind(int dev,int block)
12 | {
13 | struct buffer_head * bh;
14 | unsigned short * p;
15 | int i;
16 |
17 | if (!block)
18 | return;
19 | if ((bh=bread(dev,block))) {
20 | p = (unsigned short *) bh->b_data;
21 | for (i=0;i<512;i++,p++)
22 | if (*p)
23 | free_block(dev,*p);
24 | brelse(bh);
25 | }
26 | free_block(dev,block);
27 | }
28 |
29 | static void free_dind(int dev,int block)
30 | {
31 | struct buffer_head * bh;
32 | unsigned short * p;
33 | int i;
34 |
35 | if (!block)
36 | return;
37 | if ((bh=bread(dev,block))) {
38 | p = (unsigned short *) bh->b_data;
39 | for (i=0;i<512;i++,p++)
40 | if (*p)
41 | free_ind(dev,*p);
42 | brelse(bh);
43 | }
44 | free_block(dev,block);
45 | }
46 |
47 | void truncate(struct m_inode * inode)
48 | {
49 | int i;
50 |
51 | if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)))
52 | return;
53 | for (i=0;i<7;i++)
54 | if (inode->i_zone[i]) {
55 | free_block(inode->i_dev,inode->i_zone[i]);
56 | inode->i_zone[i]=0;
57 | }
58 | free_ind(inode->i_dev,inode->i_zone[7]);
59 | free_dind(inode->i_dev,inode->i_zone[8]);
60 | inode->i_zone[7] = inode->i_zone[8] = 0;
61 | inode->i_size = 0;
62 | inode->i_dirt = 1;
63 | inode->i_mtime = inode->i_ctime = CURRENT_TIME;
64 | }
65 |
66 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/include/asm/io.h:
--------------------------------------------------------------------------------
1 | #define outb(value,port) \
2 | __asm__ ("outb %%al,%%dx"::"a" (value),"d" (port))
3 |
4 |
5 | #define inb(port) ({ \
6 | unsigned char _v; \
7 | __asm__ volatile ("inb %%dx,%%al":"=a" (_v):"d" (port)); \
8 | _v; \
9 | })
10 |
11 | #define outb_p(value,port) \
12 | __asm__ ("outb %%al,%%dx\n" \
13 | "\tjmp 1f\n" \
14 | "1:\tjmp 1f\n" \
15 | "1:"::"a" (value),"d" (port))
16 |
17 | #define inb_p(port) ({ \
18 | unsigned char _v; \
19 | __asm__ volatile ("inb %%dx,%%al\n" \
20 | "\tjmp 1f\n" \
21 | "1:\tjmp 1f\n" \
22 | "1:":"=a" (_v):"d" (port)); \
23 | _v; \
24 | })
25 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/include/asm/memory.h:
--------------------------------------------------------------------------------
1 | /*
2 | * NOTE!!! memcpy(dest,src,n) assumes ds=es=normal data segment. This
3 | * goes for all kernel functions (ds=es=kernel space, fs=local data,
4 | * gs=null), as well as for all well-behaving user programs (ds=es=
5 | * user data space). This is NOT a bug, as any user program that changes
6 | * es deserves to die if it isn't careful.
7 | */
8 | #define memcpy(dest,src,n) ({ \
9 | void * _res = dest; \
10 | __asm__ ("cld;rep;movsb" \
11 | ::"D" ((long)(_res)),"S" ((long)(src)),"c" ((long) (n)) \
12 | ); \
13 | _res; \
14 | })
15 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/include/asm/segment.h:
--------------------------------------------------------------------------------
1 | static inline unsigned char get_fs_byte(const char * addr)
2 | {
3 | unsigned register char _v;
4 |
5 | __asm__ ("movb %%fs:%1,%0":"=r" (_v):"m" (*addr));
6 | return _v;
7 | }
8 |
9 | static inline unsigned short get_fs_word(const unsigned short *addr)
10 | {
11 | unsigned short _v;
12 |
13 | __asm__ ("movw %%fs:%1,%0":"=r" (_v):"m" (*addr));
14 | return _v;
15 | }
16 |
17 | static inline unsigned long get_fs_long(const unsigned long *addr)
18 | {
19 | unsigned long _v;
20 |
21 | __asm__ ("movl %%fs:%1,%0":"=r" (_v):"m" (*addr)); \
22 | return _v;
23 | }
24 |
25 | static inline void put_fs_byte(char val,char *addr)
26 | {
27 | __asm__ ("movb %0,%%fs:%1"::"r" (val),"m" (*addr));
28 | }
29 |
30 | static inline void put_fs_word(short val,short * addr)
31 | {
32 | __asm__ ("movw %0,%%fs:%1"::"r" (val),"m" (*addr));
33 | }
34 |
35 | static inline void put_fs_long(unsigned long val,unsigned long * addr)
36 | {
37 | __asm__ ("movl %0,%%fs:%1"::"r" (val),"m" (*addr));
38 | }
39 |
40 | /*
41 | * Someone who knows GNU asm better than I should double check the followig.
42 | * It seems to work, but I don't know if I'm doing something subtly wrong.
43 | * --- TYT, 11/24/91
44 | * [ nothing wrong here, Linus ]
45 | */
46 |
47 | static inline unsigned long get_fs()
48 | {
49 | unsigned short _v;
50 | __asm__("mov %%fs,%%ax":"=a" (_v):);
51 | return _v;
52 | }
53 |
54 | static inline unsigned long get_ds()
55 | {
56 | unsigned short _v;
57 | __asm__("mov %%ds,%%ax":"=a" (_v):);
58 | return _v;
59 | }
60 |
61 | static inline void set_fs(unsigned long val)
62 | {
63 | __asm__("mov %0,%%fs"::"a" ((unsigned short) val));
64 | }
65 |
66 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/include/asm/system.h:
--------------------------------------------------------------------------------
1 | #define move_to_user_mode() \
2 | __asm__ ("movl %%esp,%%eax\n\t" \
3 | "pushl $0x17\n\t" \
4 | "pushl %%eax\n\t" \
5 | "pushfl\n\t" \
6 | "pushl $0x0f\n\t" \
7 | "pushl $1f\n\t" \
8 | "iret\n" \
9 | "1:\tmovl $0x17,%%eax\n\t" \
10 | "movw %%ax,%%ds\n\t" \
11 | "movw %%ax,%%es\n\t" \
12 | "movw %%ax,%%fs\n\t" \
13 | "movw %%ax,%%gs" \
14 | :::"ax")
15 |
16 | #define sti() __asm__ ("sti"::)
17 | #define cli() __asm__ ("cli"::)
18 | #define nop() __asm__ ("nop"::)
19 |
20 | #define iret() __asm__ ("iret"::)
21 |
22 | #define _set_gate(gate_addr,type,dpl,addr) \
23 | __asm__ ("movw %%dx,%%ax\n\t" \
24 | "movw %0,%%dx\n\t" \
25 | "movl %%eax,%1\n\t" \
26 | "movl %%edx,%2" \
27 | : \
28 | : "i" ((short) (0x8000+(dpl<<13)+(type<<8))), \
29 | "o" (*((char *) (gate_addr))), \
30 | "o" (*(4+(char *) (gate_addr))), \
31 | "d" ((char *) (addr)),"a" (0x00080000))
32 |
33 | #define set_intr_gate(n,addr) \
34 | _set_gate(&idt[n],14,0,addr)
35 |
36 | #define set_trap_gate(n,addr) \
37 | _set_gate(&idt[n],15,0,addr)
38 |
39 | #define set_system_gate(n,addr) \
40 | _set_gate(&idt[n],15,3,addr)
41 |
42 | #define _set_seg_desc(gate_addr,type,dpl,base,limit) {\
43 | *(gate_addr) = ((base) & 0xff000000) | \
44 | (((base) & 0x00ff0000)>>16) | \
45 | ((limit) & 0xf0000) | \
46 | ((dpl)<<13) | \
47 | (0x00408000) | \
48 | ((type)<<8); \
49 | *((gate_addr)+1) = (((base) & 0x0000ffff)<<16) | \
50 | ((limit) & 0x0ffff); }
51 |
52 | #define _set_tssldt_desc(n,addr,type) \
53 | __asm__ ("movw $104,%1\n\t" \
54 | "movw %%ax,%2\n\t" \
55 | "rorl $16,%%eax\n\t" \
56 | "movb %%al,%3\n\t" \
57 | "movb $" type ",%4\n\t" \
58 | "movb $0x00,%5\n\t" \
59 | "movb %%ah,%6\n\t" \
60 | "rorl $16,%%eax" \
61 | ::"a" (addr), "m" (*(n)), "m" (*(n+2)), "m" (*(n+4)), \
62 | "m" (*(n+5)), "m" (*(n+6)), "m" (*(n+7)) \
63 | )
64 |
65 | #define set_tss_desc(n,addr) _set_tssldt_desc(((char *) (n)),((int)(addr)),"0x89")
66 | #define set_ldt_desc(n,addr) _set_tssldt_desc(((char *) (n)),((int)(addr)),"0x82")
67 |
68 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/include/const.h:
--------------------------------------------------------------------------------
1 | #ifndef _CONST_H
2 | #define _CONST_H
3 |
4 | #define BUFFER_END 0x200000
5 |
6 | #define I_TYPE 0170000
7 | #define I_DIRECTORY 0040000
8 | #define I_REGULAR 0100000
9 | #define I_BLOCK_SPECIAL 0060000
10 | #define I_CHAR_SPECIAL 0020000
11 | #define I_NAMED_PIPE 0010000
12 | #define I_SET_UID_BIT 0004000
13 | #define I_SET_GID_BIT 0002000
14 |
15 | #endif
16 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/include/ctype.h:
--------------------------------------------------------------------------------
1 | #ifndef _CTYPE_H
2 | #define _CTYPE_H
3 |
4 | #define _U 0x01 /* upper */
5 | #define _L 0x02 /* lower */
6 | #define _D 0x04 /* digit */
7 | #define _C 0x08 /* cntrl */
8 | #define _P 0x10 /* punct */
9 | #define _S 0x20 /* white space (space/lf/tab) */
10 | #define _X 0x40 /* hex digit */
11 | #define _SP 0x80 /* hard space (0x20) */
12 |
13 | extern unsigned char _ctype[];
14 | extern char _ctmp;
15 |
16 | #define isalnum(c) ((_ctype+1)[c]&(_U|_L|_D))
17 | #define isalpha(c) ((_ctype+1)[c]&(_U|_L))
18 | #define iscntrl(c) ((_ctype+1)[c]&(_C))
19 | #define isdigit(c) ((_ctype+1)[c]&(_D))
20 | #define isgraph(c) ((_ctype+1)[c]&(_P|_U|_L|_D))
21 | #define islower(c) ((_ctype+1)[c]&(_L))
22 | #define isprint(c) ((_ctype+1)[c]&(_P|_U|_L|_D|_SP))
23 | #define ispunct(c) ((_ctype+1)[c]&(_P))
24 | #define isspace(c) ((_ctype+1)[c]&(_S))
25 | #define isupper(c) ((_ctype+1)[c]&(_U))
26 | #define isxdigit(c) ((_ctype+1)[c]&(_D|_X))
27 |
28 | #define isascii(c) (((unsigned) c)<=0x7f)
29 | #define toascii(c) (((unsigned) c)&0x7f)
30 |
31 | #define tolower(c) (_ctmp=c,isupper(_ctmp)?_ctmp-('A'-'a'):_ctmp)
32 | #define toupper(c) (_ctmp=c,islower(_ctmp)?_ctmp-('a'-'A'):_ctmp)
33 |
34 | #endif
35 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/include/errno.h:
--------------------------------------------------------------------------------
1 | #ifndef _ERRNO_H
2 | #define _ERRNO_H
3 |
4 | /*
5 | * ok, as I hadn't got any other source of information about
6 | * possible error numbers, I was forced to use the same numbers
7 | * as minix.
8 | * Hopefully these are posix or something. I wouldn't know (and posix
9 | * isn't telling me - they want $$$ for their f***ing standard).
10 | *
11 | * We don't use the _SIGN cludge of minix, so kernel returns must
12 | * see to the sign by themselves.
13 | *
14 | * NOTE! Remember to change strerror() if you change this file!
15 | */
16 |
17 | extern int errno;
18 |
19 | #define ERROR 99
20 | #define EPERM 1
21 | #define ENOENT 2
22 | #define ESRCH 3
23 | #define EINTR 4
24 | #define EIO 5
25 | #define ENXIO 6
26 | #define E2BIG 7
27 | #define ENOEXEC 8
28 | #define EBADF 9
29 | #define ECHILD 10
30 | #define EAGAIN 11
31 | #define ENOMEM 12
32 | #define EACCES 13
33 | #define EFAULT 14
34 | #define ENOTBLK 15
35 | #define EBUSY 16
36 | #define EEXIST 17
37 | #define EXDEV 18
38 | #define ENODEV 19
39 | #define ENOTDIR 20
40 | #define EISDIR 21
41 | #define EINVAL 22
42 | #define ENFILE 23
43 | #define EMFILE 24
44 | #define ENOTTY 25
45 | #define ETXTBSY 26
46 | #define EFBIG 27
47 | #define ENOSPC 28
48 | #define ESPIPE 29
49 | #define EROFS 30
50 | #define EMLINK 31
51 | #define EPIPE 32
52 | #define EDOM 33
53 | #define ERANGE 34
54 | #define EDEADLK 35
55 | #define ENAMETOOLONG 36
56 | #define ENOLCK 37
57 | #define ENOSYS 38
58 | #define ENOTEMPTY 39
59 |
60 | #endif
61 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/include/fcntl.h:
--------------------------------------------------------------------------------
1 | #ifndef _FCNTL_H
2 | #define _FCNTL_H
3 |
4 | #include
5 |
6 | /* open/fcntl - NOCTTY, NDELAY isn't implemented yet */
7 | #define O_ACCMODE 00003
8 | #define O_RDONLY 00
9 | #define O_WRONLY 01
10 | #define O_RDWR 02
11 | #define O_CREAT 00100 /* not fcntl */
12 | #define O_EXCL 00200 /* not fcntl */
13 | #define O_NOCTTY 00400 /* not fcntl */
14 | #define O_TRUNC 01000 /* not fcntl */
15 | #define O_APPEND 02000
16 | #define O_NONBLOCK 04000 /* not fcntl */
17 | #define O_NDELAY O_NONBLOCK
18 |
19 | /* Defines for fcntl-commands. Note that currently
20 | * locking isn't supported, and other things aren't really
21 | * tested.
22 | */
23 | #define F_DUPFD 0 /* dup */
24 | #define F_GETFD 1 /* get f_flags */
25 | #define F_SETFD 2 /* set f_flags */
26 | #define F_GETFL 3 /* more flags (cloexec) */
27 | #define F_SETFL 4
28 | #define F_GETLK 5 /* not implemented */
29 | #define F_SETLK 6
30 | #define F_SETLKW 7
31 |
32 | /* for F_[GET|SET]FL */
33 | #define FD_CLOEXEC 1 /* actually anything with low bit set goes */
34 |
35 | /* Ok, these are locking features, and aren't implemented at any
36 | * level. POSIX wants them.
37 | */
38 | #define F_RDLCK 0
39 | #define F_WRLCK 1
40 | #define F_UNLCK 2
41 |
42 | /* Once again - not implemented, but ... */
43 | struct flock {
44 | short l_type;
45 | short l_whence;
46 | off_t l_start;
47 | off_t l_len;
48 | pid_t l_pid;
49 | };
50 |
51 | extern int creat(const char * filename,mode_t mode);
52 | extern int fcntl(int fildes,int cmd, ...);
53 | extern int open(const char * filename, int flags, ...);
54 |
55 | #endif
56 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/include/linux/config.h:
--------------------------------------------------------------------------------
1 | #ifndef _CONFIG_H
2 | #define _CONFIG_H
3 |
4 | /*
5 | * The root-device is no longer hard-coded. You can change the default
6 | * root-device by changing the line ROOT_DEV = XXX in boot/bootsect.s
7 | */
8 |
9 | /*
10 | * define your keyboard here -
11 | * KBD_FINNISH for Finnish keyboards
12 | * KBD_US for US-type
13 | * KBD_GR for German keyboards
14 | * KBD_FR for Frech keyboard
15 | */
16 | #define KBD_US
17 | /*#define KBD_GR */
18 | /*#define KBD_FR */
19 | /*#define KBD_FINNISH */
20 |
21 | /*
22 | * Normally, Linux can get the drive parameters from the BIOS at
23 | * startup, but if this for some unfathomable reason fails, you'd
24 | * be left stranded. For this case, you can define HD_TYPE, which
25 | * contains all necessary info on your harddisk.
26 | *
27 | * The HD_TYPE macro should look like this:
28 | *
29 | * #define HD_TYPE { head, sect, cyl, wpcom, lzone, ctl}
30 | *
31 | * In case of two harddisks, the info should be sepatated by
32 | * commas:
33 | *
34 | * #define HD_TYPE { h,s,c,wpcom,lz,ctl },{ h,s,c,wpcom,lz,ctl }
35 | */
36 | /*
37 | This is an example, two drives, first is type 2, second is type 3:
38 |
39 | #define HD_TYPE { 4,17,615,300,615,8 }, { 6,17,615,300,615,0 }
40 |
41 | NOTE: ctl is 0 for all drives with heads<=8, and ctl=8 for drives
42 | with more than 8 heads.
43 |
44 | If you want the BIOS to tell what kind of drive you have, just
45 | leave HD_TYPE undefined. This is the normal thing to do.
46 | */
47 |
48 | #endif
49 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/include/linux/fdreg.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file contains some defines for the floppy disk controller.
3 | * Various sources. Mostly "IBM Microcomputers: A Programmers
4 | * Handbook", Sanches and Canton.
5 | */
6 | #ifndef _FDREG_H
7 | #define _FDREG_H
8 |
9 | extern int ticks_to_floppy_on(unsigned int nr);
10 | extern void floppy_on(unsigned int nr);
11 | extern void floppy_off(unsigned int nr);
12 | extern void floppy_select(unsigned int nr);
13 | extern void floppy_deselect(unsigned int nr);
14 |
15 | /* Fd controller regs. S&C, about page 340 */
16 | #define FD_STATUS 0x3f4
17 | #define FD_DATA 0x3f5
18 | #define FD_DOR 0x3f2 /* Digital Output Register */
19 | #define FD_DIR 0x3f7 /* Digital Input Register (read) */
20 | #define FD_DCR 0x3f7 /* Diskette Control Register (write)*/
21 |
22 | /* Bits of main status register */
23 | #define STATUS_BUSYMASK 0x0F /* drive busy mask */
24 | #define STATUS_BUSY 0x10 /* FDC busy */
25 | #define STATUS_DMA 0x20 /* 0- DMA mode */
26 | #define STATUS_DIR 0x40 /* 0- cpu->fdc */
27 | #define STATUS_READY 0x80 /* Data reg ready */
28 |
29 | /* Bits of FD_ST0 */
30 | #define ST0_DS 0x03 /* drive select mask */
31 | #define ST0_HA 0x04 /* Head (Address) */
32 | #define ST0_NR 0x08 /* Not Ready */
33 | #define ST0_ECE 0x10 /* Equipment chech error */
34 | #define ST0_SE 0x20 /* Seek end */
35 | #define ST0_INTR 0xC0 /* Interrupt code mask */
36 |
37 | /* Bits of FD_ST1 */
38 | #define ST1_MAM 0x01 /* Missing Address Mark */
39 | #define ST1_WP 0x02 /* Write Protect */
40 | #define ST1_ND 0x04 /* No Data - unreadable */
41 | #define ST1_OR 0x10 /* OverRun */
42 | #define ST1_CRC 0x20 /* CRC error in data or addr */
43 | #define ST1_EOC 0x80 /* End Of Cylinder */
44 |
45 | /* Bits of FD_ST2 */
46 | #define ST2_MAM 0x01 /* Missing Addess Mark (again) */
47 | #define ST2_BC 0x02 /* Bad Cylinder */
48 | #define ST2_SNS 0x04 /* Scan Not Satisfied */
49 | #define ST2_SEH 0x08 /* Scan Equal Hit */
50 | #define ST2_WC 0x10 /* Wrong Cylinder */
51 | #define ST2_CRC 0x20 /* CRC error in data field */
52 | #define ST2_CM 0x40 /* Control Mark = deleted */
53 |
54 | /* Bits of FD_ST3 */
55 | #define ST3_HA 0x04 /* Head (Address) */
56 | #define ST3_TZ 0x10 /* Track Zero signal (1=track 0) */
57 | #define ST3_WP 0x40 /* Write Protect */
58 |
59 | /* Values for FD_COMMAND */
60 | #define FD_RECALIBRATE 0x07 /* move to track 0 */
61 | #define FD_SEEK 0x0F /* seek track */
62 | #define FD_READ 0xE6 /* read with MT, MFM, SKip deleted */
63 | #define FD_WRITE 0xC5 /* write with MT, MFM */
64 | #define FD_SENSEI 0x08 /* Sense Interrupt Status */
65 | #define FD_SPECIFY 0x03 /* specify HUT etc */
66 |
67 | /* DMA commands */
68 | #define DMA_READ 0x46
69 | #define DMA_WRITE 0x4A
70 |
71 | #endif
72 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/include/linux/hdreg.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file contains some defines for the AT-hd-controller.
3 | * Various sources. Check out some definitions (see comments with
4 | * a ques).
5 | */
6 | #ifndef _HDREG_H
7 | #define _HDREG_H
8 |
9 | /* Hd controller regs. Ref: IBM AT Bios-listing */
10 | #define HD_DATA 0x1f0 /* _CTL when writing */
11 | #define HD_ERROR 0x1f1 /* see err-bits */
12 | #define HD_NSECTOR 0x1f2 /* nr of sectors to read/write */
13 | #define HD_SECTOR 0x1f3 /* starting sector */
14 | #define HD_LCYL 0x1f4 /* starting cylinder */
15 | #define HD_HCYL 0x1f5 /* high byte of starting cyl */
16 | #define HD_CURRENT 0x1f6 /* 101dhhhh , d=drive, hhhh=head */
17 | #define HD_STATUS 0x1f7 /* see status-bits */
18 | #define HD_PRECOMP HD_ERROR /* same io address, read=error, write=precomp */
19 | #define HD_COMMAND HD_STATUS /* same io address, read=status, write=cmd */
20 |
21 | #define HD_CMD 0x3f6
22 |
23 | /* Bits of HD_STATUS */
24 | #define ERR_STAT 0x01
25 | #define INDEX_STAT 0x02
26 | #define ECC_STAT 0x04 /* Corrected error */
27 | #define DRQ_STAT 0x08
28 | #define SEEK_STAT 0x10
29 | #define WRERR_STAT 0x20
30 | #define READY_STAT 0x40
31 | #define BUSY_STAT 0x80
32 |
33 | /* Values for HD_COMMAND */
34 | #define WIN_RESTORE 0x10
35 | #define WIN_READ 0x20
36 | #define WIN_WRITE 0x30
37 | #define WIN_VERIFY 0x40
38 | #define WIN_FORMAT 0x50
39 | #define WIN_INIT 0x60
40 | #define WIN_SEEK 0x70
41 | #define WIN_DIAGNOSE 0x90
42 | #define WIN_SPECIFY 0x91
43 |
44 | /* Bits for HD_ERROR */
45 | #define MARK_ERR 0x01 /* Bad address mark ? */
46 | #define TRK0_ERR 0x02 /* couldn't find track 0 */
47 | #define ABRT_ERR 0x04 /* ? */
48 | #define ID_ERR 0x10 /* ? */
49 | #define ECC_ERR 0x40 /* ? */
50 | #define BBD_ERR 0x80 /* ? */
51 |
52 | struct partition {
53 | unsigned char boot_ind; /* 0x80 - active (unused) */
54 | unsigned char head; /* ? */
55 | unsigned char sector; /* ? */
56 | unsigned char cyl; /* ? */
57 | unsigned char sys_ind; /* ? */
58 | unsigned char end_head; /* ? */
59 | unsigned char end_sector; /* ? */
60 | unsigned char end_cyl; /* ? */
61 | unsigned int start_sect; /* starting sector counting from 0 */
62 | unsigned int nr_sects; /* nr of sectors in partition */
63 | };
64 |
65 | #endif
66 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/include/linux/head.h:
--------------------------------------------------------------------------------
1 | #ifndef _HEAD_H
2 | #define _HEAD_H
3 |
4 | typedef struct desc_struct {
5 | unsigned long a,b;
6 | } desc_table[256];
7 |
8 | extern unsigned long pg_dir[1024];
9 | extern desc_table idt,gdt;
10 |
11 | #define GDT_NUL 0
12 | #define GDT_CODE 1
13 | #define GDT_DATA 2
14 | #define GDT_TMP 3
15 |
16 | #define LDT_NUL 0
17 | #define LDT_CODE 1
18 | #define LDT_DATA 2
19 |
20 | #endif
21 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/include/linux/kernel.h:
--------------------------------------------------------------------------------
1 | /*
2 | * 'kernel.h' contains some often-used function prototypes etc
3 | */
4 | void verify_area(void * addr,int count);
5 | volatile void panic(const char * str);
6 | int printf(const char * fmt, ...);
7 | int printk(const char * fmt, ...);
8 | int tty_write(unsigned ch,char * buf,int count);
9 | void * malloc(unsigned int size);
10 | void free_s(void * obj, int size);
11 |
12 | #define free(x) free_s((x), 0)
13 |
14 | /*
15 | * This is defined as a macro, but at some point this might become a
16 | * real subroutine that sets a flag if it returns true (to do
17 | * BSD-style accounting where the process is flagged if it uses root
18 | * privs). The implication of this is that you should do normal
19 | * permissions checks first, and check suser() last.
20 | */
21 | #define suser() (current->euid == 0)
22 |
23 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/include/linux/mm.h:
--------------------------------------------------------------------------------
1 | #ifndef _MM_H
2 | #define _MM_H
3 |
4 | #define PAGE_SIZE 4096
5 |
6 | extern unsigned long get_free_page(void);
7 | extern unsigned long put_page(unsigned long page,unsigned long address);
8 | extern void free_page(unsigned long addr);
9 |
10 | #endif
11 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/include/linux/tty.h:
--------------------------------------------------------------------------------
1 | /*
2 | * 'tty.h' defines some structures used by tty_io.c and some defines.
3 | *
4 | * NOTE! Don't touch this without checking that nothing in rs_io.s or
5 | * con_io.s breaks. Some constants are hardwired into the system (mainly
6 | * offsets into 'tty_queue'
7 | */
8 |
9 | #ifndef _TTY_H
10 | #define _TTY_H
11 |
12 | #include
13 |
14 | #define TTY_BUF_SIZE 1024
15 |
16 | struct tty_queue {
17 | unsigned long data;
18 | unsigned long head;
19 | unsigned long tail;
20 | struct task_struct * proc_list;
21 | char buf[TTY_BUF_SIZE];
22 | };
23 |
24 | #define INC(a) ((a) = ((a)+1) & (TTY_BUF_SIZE-1))
25 | #define DEC(a) ((a) = ((a)-1) & (TTY_BUF_SIZE-1))
26 | #define EMPTY(a) ((a).head == (a).tail)
27 | #define LEFT(a) (((a).tail-(a).head-1)&(TTY_BUF_SIZE-1))
28 | #define LAST(a) ((a).buf[(TTY_BUF_SIZE-1)&((a).head-1)])
29 | #define FULL(a) (!LEFT(a))
30 | #define CHARS(a) (((a).head-(a).tail)&(TTY_BUF_SIZE-1))
31 | #define GETCH(queue,c) \
32 | (void)({c=(queue).buf[(queue).tail];INC((queue).tail);})
33 | #define PUTCH(c,queue) \
34 | (void)({(queue).buf[(queue).head]=(c);INC((queue).head);})
35 |
36 | #define INTR_CHAR(tty) ((tty)->termios.c_cc[VINTR])
37 | #define QUIT_CHAR(tty) ((tty)->termios.c_cc[VQUIT])
38 | #define ERASE_CHAR(tty) ((tty)->termios.c_cc[VERASE])
39 | #define KILL_CHAR(tty) ((tty)->termios.c_cc[VKILL])
40 | #define EOF_CHAR(tty) ((tty)->termios.c_cc[VEOF])
41 | #define START_CHAR(tty) ((tty)->termios.c_cc[VSTART])
42 | #define STOP_CHAR(tty) ((tty)->termios.c_cc[VSTOP])
43 | #define SUSPEND_CHAR(tty) ((tty)->termios.c_cc[VSUSP])
44 |
45 | struct tty_struct {
46 | struct termios termios;
47 | int pgrp;
48 | int stopped;
49 | void (*write)(struct tty_struct * tty);
50 | struct tty_queue read_q;
51 | struct tty_queue write_q;
52 | struct tty_queue secondary;
53 | };
54 |
55 | extern struct tty_struct tty_table[];
56 |
57 | /* intr=^C quit=^| erase=del kill=^U
58 | eof=^D vtime=\0 vmin=\1 sxtc=\0
59 | start=^Q stop=^S susp=^Z eol=\0
60 | reprint=^R discard=^U werase=^W lnext=^V
61 | eol2=\0
62 | */
63 | #define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
64 |
65 | void rs_init(void);
66 | void con_init(void);
67 | void tty_init(void);
68 |
69 | int tty_read(unsigned c, char * buf, int n);
70 | int tty_write(unsigned c, char * buf, int n);
71 |
72 | void rs_write(struct tty_struct * tty);
73 | void con_write(struct tty_struct * tty);
74 |
75 | void copy_to_cooked(struct tty_struct * tty);
76 |
77 | #endif
78 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/include/signal.h:
--------------------------------------------------------------------------------
1 | #ifndef _SIGNAL_H
2 | #define _SIGNAL_H
3 |
4 | #include
5 |
6 | typedef int sig_atomic_t;
7 | typedef unsigned int sigset_t; /* 32 bits */
8 |
9 | #define _NSIG 32
10 | #define NSIG _NSIG
11 |
12 | #define SIGHUP 1
13 | #define SIGINT 2
14 | #define SIGQUIT 3
15 | #define SIGILL 4
16 | #define SIGTRAP 5
17 | #define SIGABRT 6
18 | #define SIGIOT 6
19 | #define SIGUNUSED 7
20 | #define SIGFPE 8
21 | #define SIGKILL 9
22 | #define SIGUSR1 10
23 | #define SIGSEGV 11
24 | #define SIGUSR2 12
25 | #define SIGPIPE 13
26 | #define SIGALRM 14
27 | #define SIGTERM 15
28 | #define SIGSTKFLT 16
29 | #define SIGCHLD 17
30 | #define SIGCONT 18
31 | #define SIGSTOP 19
32 | #define SIGTSTP 20
33 | #define SIGTTIN 21
34 | #define SIGTTOU 22
35 |
36 | /* Ok, I haven't implemented sigactions, but trying to keep headers POSIX */
37 | #define SA_NOCLDSTOP 1
38 | #define SA_NOMASK 0x40000000
39 | #define SA_ONESHOT 0x80000000
40 |
41 | #define SIG_BLOCK 0 /* for blocking signals */
42 | #define SIG_UNBLOCK 1 /* for unblocking signals */
43 | #define SIG_SETMASK 2 /* for setting the signal mask */
44 |
45 | #define SIG_DFL ((void (*)(int))0) /* default signal handling */
46 | #define SIG_IGN ((void (*)(int))1) /* ignore signal */
47 |
48 | struct sigaction {
49 | void (*sa_handler)(int);
50 | sigset_t sa_mask;
51 | int sa_flags;
52 | void (*sa_restorer)(void);
53 | };
54 |
55 | void (*signal(int _sig, void (*_func)(int)))(int);
56 | int raise(int sig);
57 | int kill(pid_t pid, int sig);
58 | int sigaddset(sigset_t *mask, int signo);
59 | int sigdelset(sigset_t *mask, int signo);
60 | int sigemptyset(sigset_t *mask);
61 | int sigfillset(sigset_t *mask);
62 | int sigismember(sigset_t *mask, int signo); /* 1 - is, 0 - not, -1 error */
63 | int sigpending(sigset_t *set);
64 | int sigprocmask(int how, sigset_t *set, sigset_t *oldset);
65 | int sigsuspend(sigset_t *sigmask);
66 | int sigaction(int sig, struct sigaction *act, struct sigaction *oldact);
67 |
68 | #endif /* _SIGNAL_H */
69 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/include/stdarg.h:
--------------------------------------------------------------------------------
1 | #ifndef _STDARG_H
2 | #define _STDARG_H
3 |
4 | typedef char *va_list;
5 |
6 | /* Amount of space required in an argument list for an arg of type TYPE.
7 | TYPE may alternatively be an expression whose type is used. */
8 |
9 | #define __va_rounded_size(TYPE) \
10 | (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
11 |
12 | #ifndef __sparc__
13 | #define va_start(AP, LASTARG) \
14 | (AP = ((char *) &(LASTARG) + __va_rounded_size (LASTARG)))
15 | #else
16 | #define va_start(AP, LASTARG) \
17 | (__builtin_saveregs (), \
18 | AP = ((char *) &(LASTARG) + __va_rounded_size (LASTARG)))
19 | #endif
20 |
21 | void va_end (va_list); /* Defined in gnulib */
22 | #define va_end(AP)
23 |
24 | #define va_arg(AP, TYPE) \
25 | (AP += __va_rounded_size (TYPE), \
26 | *((TYPE *) (AP - __va_rounded_size (TYPE))))
27 |
28 | #endif /* _STDARG_H */
29 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/include/stddef.h:
--------------------------------------------------------------------------------
1 | #ifndef _STDDEF_H
2 | #define _STDDEF_H
3 |
4 | #ifndef _PTRDIFF_T
5 | #define _PTRDIFF_T
6 | typedef long ptrdiff_t;
7 | #endif
8 |
9 | #ifndef _SIZE_T
10 | #define _SIZE_T
11 | typedef unsigned long size_t;
12 | #endif
13 |
14 | #undef NULL
15 | #define NULL ((void *)0)
16 |
17 | #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
18 |
19 | #endif
20 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/include/sys/stat.h:
--------------------------------------------------------------------------------
1 | #ifndef _SYS_STAT_H
2 | #define _SYS_STAT_H
3 |
4 | #include
5 |
6 | struct stat {
7 | dev_t st_dev;
8 | ino_t st_ino;
9 | umode_t st_mode;
10 | nlink_t st_nlink;
11 | uid_t st_uid;
12 | gid_t st_gid;
13 | dev_t st_rdev;
14 | off_t st_size;
15 | time_t st_atime;
16 | time_t st_mtime;
17 | time_t st_ctime;
18 | };
19 |
20 | #define S_IFMT 00170000
21 | #define S_IFREG 0100000
22 | #define S_IFBLK 0060000
23 | #define S_IFDIR 0040000
24 | #define S_IFCHR 0020000
25 | #define S_IFIFO 0010000
26 | #define S_ISUID 0004000
27 | #define S_ISGID 0002000
28 | #define S_ISVTX 0001000
29 |
30 | #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
31 | #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
32 | #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
33 | #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
34 | #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
35 |
36 | #define S_IRWXU 00700
37 | #define S_IRUSR 00400
38 | #define S_IWUSR 00200
39 | #define S_IXUSR 00100
40 |
41 | #define S_IRWXG 00070
42 | #define S_IRGRP 00040
43 | #define S_IWGRP 00020
44 | #define S_IXGRP 00010
45 |
46 | #define S_IRWXO 00007
47 | #define S_IROTH 00004
48 | #define S_IWOTH 00002
49 | #define S_IXOTH 00001
50 |
51 | extern int chmod(const char *_path, mode_t mode);
52 | extern int fstat(int fildes, struct stat *stat_buf);
53 | extern int mkdir(const char *_path, mode_t mode);
54 | extern int mkfifo(const char *_path, mode_t mode);
55 | extern int stat(const char *filename, struct stat *stat_buf);
56 | extern mode_t umask(mode_t mask);
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/include/sys/times.h:
--------------------------------------------------------------------------------
1 | #ifndef _TIMES_H
2 | #define _TIMES_H
3 |
4 | #include
5 |
6 | struct tms {
7 | time_t tms_utime;
8 | time_t tms_stime;
9 | time_t tms_cutime;
10 | time_t tms_cstime;
11 | };
12 |
13 | extern time_t times(struct tms * tp);
14 |
15 | #endif
16 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/include/sys/types.h:
--------------------------------------------------------------------------------
1 | #ifndef _SYS_TYPES_H
2 | #define _SYS_TYPES_H
3 |
4 | #ifndef _SIZE_T
5 | #define _SIZE_T
6 | typedef unsigned int size_t;
7 | #endif
8 |
9 | #ifndef _TIME_T
10 | #define _TIME_T
11 | typedef long time_t;
12 | #endif
13 |
14 | #ifndef _PTRDIFF_T
15 | #define _PTRDIFF_T
16 | typedef long ptrdiff_t;
17 | #endif
18 |
19 | #ifndef NULL
20 | #define NULL ((void *) 0)
21 | #endif
22 |
23 | typedef int pid_t;
24 | typedef unsigned short uid_t;
25 | typedef unsigned char gid_t;
26 | typedef unsigned short dev_t;
27 | typedef unsigned short ino_t;
28 | typedef unsigned short mode_t;
29 | typedef unsigned short umode_t;
30 | typedef unsigned char nlink_t;
31 | typedef int daddr_t;
32 | typedef long off_t;
33 | typedef unsigned char u_char;
34 | typedef unsigned short ushort;
35 |
36 | typedef struct { int quot,rem; } div_t;
37 | typedef struct { long quot,rem; } ldiv_t;
38 |
39 | struct ustat {
40 | daddr_t f_tfree;
41 | ino_t f_tinode;
42 | char f_fname[6];
43 | char f_fpack[6];
44 | };
45 |
46 | #endif
47 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/include/sys/utsname.h:
--------------------------------------------------------------------------------
1 | #ifndef _SYS_UTSNAME_H
2 | #define _SYS_UTSNAME_H
3 |
4 | #include
5 |
6 | struct utsname {
7 | char sysname[9];
8 | char nodename[9];
9 | char release[9];
10 | char version[9];
11 | char machine[9];
12 | };
13 |
14 | extern int uname(struct utsname * utsbuf);
15 |
16 | #endif
17 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/include/sys/wait.h:
--------------------------------------------------------------------------------
1 | #ifndef _SYS_WAIT_H
2 | #define _SYS_WAIT_H
3 |
4 | #include
5 |
6 | #define _LOW(v) ( (v) & 0377)
7 | #define _HIGH(v) ( ((v) >> 8) & 0377)
8 |
9 | /* options for waitpid, WUNTRACED not supported */
10 | #define WNOHANG 1
11 | #define WUNTRACED 2
12 |
13 | #define WIFEXITED(s) (!((s)&0xFF)
14 | #define WIFSTOPPED(s) (((s)&0xFF)==0x7F)
15 | #define WEXITSTATUS(s) (((s)>>8)&0xFF)
16 | #define WTERMSIG(s) ((s)&0x7F)
17 | #define WSTOPSIG(s) (((s)>>8)&0xFF)
18 | #define WIFSIGNALED(s) (((unsigned int)(s)-1 & 0xFFFF) < 0xFF)
19 |
20 | pid_t wait(int *stat_loc);
21 | pid_t waitpid(pid_t pid, int *stat_loc, int options);
22 |
23 | #endif
24 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/include/time.h:
--------------------------------------------------------------------------------
1 | #ifndef _TIME_H
2 | #define _TIME_H
3 |
4 | #ifndef _TIME_T
5 | #define _TIME_T
6 | typedef long time_t;
7 | #endif
8 |
9 | #ifndef _SIZE_T
10 | #define _SIZE_T
11 | typedef unsigned int size_t;
12 | #endif
13 |
14 | #define CLOCKS_PER_SEC 100
15 |
16 | typedef long clock_t;
17 |
18 | struct tm {
19 | int tm_sec;
20 | int tm_min;
21 | int tm_hour;
22 | int tm_mday;
23 | int tm_mon;
24 | int tm_year;
25 | int tm_wday;
26 | int tm_yday;
27 | int tm_isdst;
28 | };
29 |
30 | clock_t clock(void);
31 | time_t time(time_t * tp);
32 | double difftime(time_t time2, time_t time1);
33 | time_t mktime(struct tm * tp);
34 |
35 | char * asctime(const struct tm * tp);
36 | char * ctime(const time_t * tp);
37 | struct tm * gmtime(const time_t *tp);
38 | struct tm *localtime(const time_t * tp);
39 | size_t strftime(char * s, size_t smax, const char * fmt, const struct tm * tp);
40 | void tzset(void);
41 |
42 | #endif
43 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/include/utime.h:
--------------------------------------------------------------------------------
1 | #ifndef _UTIME_H
2 | #define _UTIME_H
3 |
4 | #include /* I know - shouldn't do this, but .. */
5 |
6 | struct utimbuf {
7 | time_t actime;
8 | time_t modtime;
9 | };
10 |
11 | extern int utime(const char *filename, struct utimbuf *times);
12 |
13 | #endif
14 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/kernel/blk_drv/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile for the FREAX-kernel block device drivers.
3 | #
4 | # Note! Dependencies are done automagically by 'make dep', which also
5 | # removes any old dependencies. DON'T put your own dependencies here
6 | # unless it's something special (ie not a .c file).
7 | #
8 |
9 | AR =ar
10 | AS =as
11 | LD =ld
12 | LDFLAGS =-s -x
13 | CC =gcc -mcpu=i386
14 | CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \
15 | -finline-functions -nostdinc -I../../include
16 | CPP =gcc -E -nostdinc -I../../include
17 |
18 | .c.s:
19 | $(CC) $(CFLAGS) \
20 | -S -o $*.s $<
21 | .s.o:
22 | $(AS) -o $*.o $<
23 | .c.o:
24 | $(CC) $(CFLAGS) \
25 | -c -o $*.o $<
26 |
27 | OBJS = ll_rw_blk.o floppy.o hd.o ramdisk.o
28 |
29 | blk_drv.a: $(OBJS)
30 | $(AR) rcs blk_drv.a $(OBJS)
31 | sync
32 |
33 | clean:
34 | rm -f core *.o *.a tmp_make
35 | for i in *.c;do rm -f `basename $$i .c`.s;done
36 |
37 | dep:
38 | sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
39 | (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \
40 | $(CPP) -M $$i;done) >> tmp_make
41 | cp tmp_make Makefile
42 |
43 | ### Dependencies:
44 | floppy.s floppy.o: floppy.c ../../include/linux/sched.h ../../include/linux/head.h \
45 | ../../include/linux/fs.h ../../include/sys/types.h \
46 | ../../include/linux/mm.h ../../include/signal.h \
47 | ../../include/linux/kernel.h ../../include/linux/fdreg.h \
48 | ../../include/asm/system.h ../../include/asm/io.h \
49 | ../../include/asm/segment.h blk.h
50 | hd.s hd.o: hd.c ../../include/linux/config.h ../../include/linux/sched.h \
51 | ../../include/linux/head.h ../../include/linux/fs.h \
52 | ../../include/sys/types.h ../../include/linux/mm.h \
53 | ../../include/signal.h ../../include/linux/kernel.h \
54 | ../../include/linux/hdreg.h ../../include/asm/system.h \
55 | ../../include/asm/io.h ../../include/asm/segment.h blk.h
56 | ll_rw_blk.s ll_rw_blk.o: ll_rw_blk.c ../../include/errno.h \
57 | ../../include/linux/sched.h ../../include/linux/head.h \
58 | ../../include/linux/fs.h ../../include/sys/types.h \
59 | ../../include/linux/mm.h ../../include/signal.h \
60 | ../../include/linux/kernel.h ../../include/asm/system.h blk.h
61 | ramdisk.s ramdisk.o: ramdisk.c ../../include/string.h ../../include/linux/config.h \
62 | ../../include/linux/sched.h ../../include/linux/head.h \
63 | ../../include/linux/fs.h ../../include/sys/types.h \
64 | ../../include/linux/mm.h ../../include/signal.h \
65 | ../../include/linux/kernel.h ../../include/asm/system.h \
66 | ../../include/asm/segment.h ../../include/asm/memory.h blk.h
67 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/kernel/chr_drv/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile for the FREAX-kernel character device drivers.
3 | #
4 | # Note! Dependencies are done automagically by 'make dep', which also
5 | # removes any old dependencies. DON'T put your own dependencies here
6 | # unless it's something special (ie not a .c file).
7 | #
8 |
9 | AR =ar
10 | AS =as
11 | LD =ld
12 | LDFLAGS =-s -x
13 | CC =gcc -mcpu=i386
14 | CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \
15 | -finline-functions -nostdinc -I../../include
16 | CPP =gcc -E -nostdinc -I../../include
17 |
18 | .c.s:
19 | $(CC) $(CFLAGS) \
20 | -S -o $*.s $<
21 | .s.o:
22 | $(AS) -o $*.o $<
23 | .c.o:
24 | $(CC) $(CFLAGS) \
25 | -c -o $*.o $<
26 |
27 | OBJS = tty_io.o console.o keyboard.o serial.o rs_io.o \
28 | tty_ioctl.o
29 |
30 | chr_drv.a: $(OBJS)
31 | $(AR) rcs chr_drv.a $(OBJS)
32 | sync
33 |
34 | keyboard.s: keyboard.S ../../include/linux/config.h
35 | $(CPP) -traditional keyboard.S -o keyboard.s
36 |
37 | clean:
38 | rm -f core *.o *.a tmp_make keyboard.s
39 | for i in *.c;do rm -f `basename $$i .c`.s;done
40 |
41 | dep:
42 | sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
43 | (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \
44 | $(CPP) -M $$i;done) >> tmp_make
45 | cp tmp_make Makefile
46 |
47 | ### Dependencies:
48 | console.s console.o: console.c ../../include/linux/sched.h \
49 | ../../include/linux/head.h ../../include/linux/fs.h \
50 | ../../include/sys/types.h ../../include/linux/mm.h \
51 | ../../include/signal.h ../../include/linux/tty.h \
52 | ../../include/termios.h ../../include/asm/io.h \
53 | ../../include/asm/system.h
54 | serial.s serial.o: serial.c ../../include/linux/tty.h ../../include/termios.h \
55 | ../../include/linux/sched.h ../../include/linux/head.h \
56 | ../../include/linux/fs.h ../../include/sys/types.h \
57 | ../../include/linux/mm.h ../../include/signal.h \
58 | ../../include/asm/system.h ../../include/asm/io.h
59 | tty_io.s tty_io.o: tty_io.c ../../include/ctype.h ../../include/errno.h \
60 | ../../include/signal.h ../../include/sys/types.h \
61 | ../../include/linux/sched.h ../../include/linux/head.h \
62 | ../../include/linux/fs.h ../../include/linux/mm.h \
63 | ../../include/linux/tty.h ../../include/termios.h \
64 | ../../include/asm/segment.h ../../include/asm/system.h
65 | tty_ioctl.s tty_ioctl.o: tty_ioctl.c ../../include/errno.h ../../include/termios.h \
66 | ../../include/linux/sched.h ../../include/linux/head.h \
67 | ../../include/linux/fs.h ../../include/sys/types.h \
68 | ../../include/linux/mm.h ../../include/signal.h \
69 | ../../include/linux/kernel.h ../../include/linux/tty.h \
70 | ../../include/asm/io.h ../../include/asm/segment.h \
71 | ../../include/asm/system.h
72 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/kernel/chr_drv/serial.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/kernel/serial.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | /*
8 | * serial.c
9 | *
10 | * This module implements the rs232 io functions
11 | * void rs_write(struct tty_struct * queue);
12 | * void rs_init(void);
13 | * and all interrupts pertaining to serial IO.
14 | */
15 |
16 | #include
17 | #include
18 | #include
19 | #include
20 |
21 | #define WAKEUP_CHARS (TTY_BUF_SIZE/4)
22 |
23 | extern void rs1_interrupt(void);
24 | extern void rs2_interrupt(void);
25 |
26 | static void init(int port)
27 | {
28 | outb_p(0x80,port+3); /* set DLAB of line control reg */
29 | outb_p(0x30,port); /* LS of divisor (48 -> 2400 bps */
30 | outb_p(0x00,port+1); /* MS of divisor */
31 | outb_p(0x03,port+3); /* reset DLAB */
32 | outb_p(0x0b,port+4); /* set DTR,RTS, OUT_2 */
33 | outb_p(0x0d,port+1); /* enable all intrs but writes */
34 | (void)inb(port); /* read data port to reset things (?) */
35 | }
36 |
37 | void rs_init(void)
38 | {
39 | set_intr_gate(0x24,rs1_interrupt);
40 | set_intr_gate(0x23,rs2_interrupt);
41 | init(tty_table[1].read_q.data);
42 | init(tty_table[2].read_q.data);
43 | outb(inb_p(0x21)&0xE7,0x21);
44 | }
45 |
46 | /*
47 | * This routine gets called when tty_write has put something into
48 | * the write_queue. It must check wheter the queue is empty, and
49 | * set the interrupt register accordingly
50 | *
51 | * void _rs_write(struct tty_struct * tty);
52 | */
53 | void rs_write(struct tty_struct * tty)
54 | {
55 | cli();
56 | if (!EMPTY(tty->write_q))
57 | outb(inb_p(tty->write_q.data+1)|0x02,tty->write_q.data+1);
58 | sti();
59 | }
60 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/kernel/math/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile for the FREAX-kernel character device drivers.
3 | #
4 | # Note! Dependencies are done automagically by 'make dep', which also
5 | # removes any old dependencies. DON'T put your own dependencies here
6 | # unless it's something special (ie not a .c file).
7 | #
8 |
9 | AR =ar
10 | AS =as
11 | LD =ld
12 | LDFLAGS =-s -x
13 | CC =gcc -mcpu=i386
14 | CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \
15 | -finline-functions -nostdinc -I../../include
16 | CPP =gcc -E -nostdinc -I../../include
17 |
18 | .c.s:
19 | $(CC) $(CFLAGS) \
20 | -S -o $*.s $<
21 | .s.o:
22 | $(AS) -o $*.o $<
23 | .c.o:
24 | $(CC) $(CFLAGS) \
25 | -c -o $*.o $<
26 |
27 | OBJS = math_emulate.o
28 |
29 | math.a: $(OBJS)
30 | $(AR) rcs math.a $(OBJS)
31 | sync
32 |
33 | clean:
34 | rm -f core *.o *.a tmp_make
35 | for i in *.c;do rm -f `basename $$i .c`.s;done
36 |
37 | dep:
38 | sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
39 | (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \
40 | $(CPP) -M $$i;done) >> tmp_make
41 | cp tmp_make Makefile
42 |
43 | ### Dependencies:
44 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/kernel/math/math_emulate.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/kernel/math/math_emulate.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | /*
8 | * This directory should contain the math-emulation code.
9 | * Currently only results in a signal.
10 | */
11 |
12 | #include
13 |
14 | #include
15 | #include
16 | #include
17 |
18 | void math_emulate(long edi, long esi, long ebp, long sys_call_ret,
19 | long eax,long ebx,long ecx,long edx,
20 | unsigned short fs,unsigned short es,unsigned short ds,
21 | unsigned long eip,unsigned short cs,unsigned long eflags,
22 | unsigned short ss, unsigned long esp)
23 | {
24 | unsigned char first, second;
25 |
26 | /* 0x0007 means user code space */
27 | if (cs != 0x000F) {
28 | printk("math_emulate: %04x:%08x\n\r",cs,eip);
29 | panic("Math emulation needed in kernel");
30 | }
31 | first = get_fs_byte((char *)((*&eip)++));
32 | second = get_fs_byte((char *)((*&eip)++));
33 | printk("%04x:%08x %02x %02x\n\r",cs,eip-2,first,second);
34 | current->signal |= 1<<(SIGFPE-1);
35 | }
36 |
37 | void math_error(void)
38 | {
39 | __asm__("fnclex");
40 | if (last_task_used_math)
41 | last_task_used_math->signal |= 1<<(SIGFPE-1);
42 | }
43 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/kernel/mktime.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/kernel/mktime.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #include
8 |
9 | /*
10 | * This isn't the library routine, it is only used in the kernel.
11 | * as such, we don't care about years<1970 etc, but assume everything
12 | * is ok. Similarly, TZ etc is happily ignored. We just do everything
13 | * as easily as possible. Let's find something public for the library
14 | * routines (although I think minix times is public).
15 | */
16 | /*
17 | * PS. I hate whoever though up the year 1970 - couldn't they have gotten
18 | * a leap-year instead? I also hate Gregorius, pope or no. I'm grumpy.
19 | */
20 | #define MINUTE 60
21 | #define HOUR (60*MINUTE)
22 | #define DAY (24*HOUR)
23 | #define YEAR (365*DAY)
24 |
25 | /* interestingly, we assume leap-years */
26 | static int month[12] = {
27 | 0,
28 | DAY*(31),
29 | DAY*(31+29),
30 | DAY*(31+29+31),
31 | DAY*(31+29+31+30),
32 | DAY*(31+29+31+30+31),
33 | DAY*(31+29+31+30+31+30),
34 | DAY*(31+29+31+30+31+30+31),
35 | DAY*(31+29+31+30+31+30+31+31),
36 | DAY*(31+29+31+30+31+30+31+31+30),
37 | DAY*(31+29+31+30+31+30+31+31+30+31),
38 | DAY*(31+29+31+30+31+30+31+31+30+31+30)
39 | };
40 |
41 | long kernel_mktime(struct tm * tm)
42 | {
43 | long res;
44 | int year;
45 |
46 | year = tm->tm_year - 70;
47 | /* magic offsets (y+1) needed to get leapyears right.*/
48 | res = YEAR*year + DAY*((year+1)/4);
49 | res += month[tm->tm_mon];
50 | /* and (y+2) here. If it wasn't a leap-year, we have to adjust */
51 | if (tm->tm_mon>1 && ((year+2)%4))
52 | res -= DAY;
53 | res += DAY*(tm->tm_mday-1);
54 | res += HOUR*tm->tm_hour;
55 | res += MINUTE*tm->tm_min;
56 | res += tm->tm_sec;
57 | return res;
58 | }
59 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/kernel/panic.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/kernel/panic.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | /*
8 | * This function is used through-out the kernel (includeinh mm and fs)
9 | * to indicate a major problem.
10 | */
11 | #define PANIC
12 |
13 | #include
14 | #include
15 |
16 | void sys_sync(void); /* it's really int */
17 |
18 | volatile void panic(const char * s)
19 | {
20 | printk("Kernel panic: %s\n\r",s);
21 | if (current == task[0])
22 | printk("In swapper task - not syncing\n\r");
23 | else
24 | sys_sync();
25 | for(;;);
26 | }
27 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/kernel/printk.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/kernel/printk.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | /*
8 | * When in kernel-mode, we cannot use printf, as fs is liable to
9 | * point to 'interesting' things. Make a printf with fs-saving, and
10 | * all is well.
11 | */
12 | #include
13 | #include
14 |
15 | #include
16 |
17 | static char buf[1024];
18 |
19 | extern int vsprintf(char * buf, const char * fmt, va_list args);
20 |
21 | int printk(const char *fmt, ...)
22 | {
23 | va_list args;
24 | int i;
25 |
26 | va_start(args, fmt);
27 | i=vsprintf(buf,fmt,args);
28 | va_end(args);
29 | __asm__("push %%fs\n\t"
30 | "push %%ds\n\t"
31 | "pop %%fs\n\t"
32 | "pushl %0\n\t"
33 | "pushl $buf\n\t"
34 | "pushl $0\n\t"
35 | "call tty_write\n\t"
36 | "addl $8,%%esp\n\t"
37 | "popl %0\n\t"
38 | "pop %%fs"
39 | ::"r" (i):"ax","cx","dx");
40 | return i;
41 | }
42 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/lib/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile for some libs needed in the kernel.
3 | #
4 | # Note! Dependencies are done automagically by 'make dep', which also
5 | # removes any old dependencies. DON'T put your own dependencies here
6 | # unless it's something special (ie not a .c file).
7 | #
8 |
9 | AR =ar
10 | AS =as
11 | LD =ld
12 | LDFLAGS =-s -x
13 | CC =gcc -mcpu=i386
14 | CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \
15 | -finline-functions -nostdinc -I../include
16 | CPP =gcc -E -nostdinc -I../include
17 |
18 | .c.s:
19 | $(CC) $(CFLAGS) \
20 | -S -o $*.s $<
21 | .s.o:
22 | $(AS) -o $*.o $<
23 | .c.o:
24 | $(CC) $(CFLAGS) \
25 | -c -o $*.o $<
26 |
27 | OBJS = ctype.o _exit.o open.o close.o errno.o write.o dup.o setsid.o \
28 | execve.o wait.o string.o malloc.o
29 |
30 | lib.a: $(OBJS)
31 | $(AR) rcs lib.a $(OBJS)
32 | sync
33 |
34 | clean:
35 | rm -f core *.o *.a tmp_make
36 | for i in *.c;do rm -f `basename $$i .c`.s;done
37 |
38 | dep:
39 | sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
40 | (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \
41 | $(CPP) -M $$i;done) >> tmp_make
42 | cp tmp_make Makefile
43 |
44 | ### Dependencies:
45 | _exit.s _exit.o : _exit.c ../include/unistd.h ../include/sys/stat.h \
46 | ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \
47 | ../include/utime.h
48 | close.s close.o : close.c ../include/unistd.h ../include/sys/stat.h \
49 | ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \
50 | ../include/utime.h
51 | ctype.s ctype.o : ctype.c ../include/ctype.h
52 | dup.s dup.o : dup.c ../include/unistd.h ../include/sys/stat.h \
53 | ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \
54 | ../include/utime.h
55 | errno.s errno.o : errno.c
56 | execve.s execve.o : execve.c ../include/unistd.h ../include/sys/stat.h \
57 | ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \
58 | ../include/utime.h
59 | malloc.s malloc.o : malloc.c ../include/linux/kernel.h ../include/linux/mm.h \
60 | ../include/asm/system.h
61 | open.s open.o : open.c ../include/unistd.h ../include/sys/stat.h \
62 | ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \
63 | ../include/utime.h ../include/stdarg.h
64 | setsid.s setsid.o : setsid.c ../include/unistd.h ../include/sys/stat.h \
65 | ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \
66 | ../include/utime.h
67 | string.s string.o : string.c ../include/string.h
68 | wait.s wait.o : wait.c ../include/unistd.h ../include/sys/stat.h \
69 | ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \
70 | ../include/utime.h ../include/sys/wait.h
71 | write.s write.o : write.c ../include/unistd.h ../include/sys/stat.h \
72 | ../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \
73 | ../include/utime.h
74 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/lib/_exit.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/_exit.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #define __LIBRARY__
8 | #include
9 |
10 | volatile void _exit(int exit_code)
11 | {
12 | __asm__("int $0x80"::"a" (__NR_exit),"b" (exit_code));
13 | }
14 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/lib/close.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/close.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #define __LIBRARY__
8 | #include
9 |
10 | _syscall1(int,close,int,fd)
11 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/lib/ctype.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/ctype.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #include
8 |
9 | char _ctmp;
10 | unsigned char _ctype[] = {0x00, /* EOF */
11 | _C,_C,_C,_C,_C,_C,_C,_C, /* 0-7 */
12 | _C,_C|_S,_C|_S,_C|_S,_C|_S,_C|_S,_C,_C, /* 8-15 */
13 | _C,_C,_C,_C,_C,_C,_C,_C, /* 16-23 */
14 | _C,_C,_C,_C,_C,_C,_C,_C, /* 24-31 */
15 | _S|_SP,_P,_P,_P,_P,_P,_P,_P, /* 32-39 */
16 | _P,_P,_P,_P,_P,_P,_P,_P, /* 40-47 */
17 | _D,_D,_D,_D,_D,_D,_D,_D, /* 48-55 */
18 | _D,_D,_P,_P,_P,_P,_P,_P, /* 56-63 */
19 | _P,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U, /* 64-71 */
20 | _U,_U,_U,_U,_U,_U,_U,_U, /* 72-79 */
21 | _U,_U,_U,_U,_U,_U,_U,_U, /* 80-87 */
22 | _U,_U,_U,_P,_P,_P,_P,_P, /* 88-95 */
23 | _P,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L, /* 96-103 */
24 | _L,_L,_L,_L,_L,_L,_L,_L, /* 104-111 */
25 | _L,_L,_L,_L,_L,_L,_L,_L, /* 112-119 */
26 | _L,_L,_L,_P,_P,_P,_P,_C, /* 120-127 */
27 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 128-143 */
28 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 144-159 */
29 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 160-175 */
30 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 176-191 */
31 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 192-207 */
32 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 208-223 */
33 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 224-239 */
34 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; /* 240-255 */
35 |
36 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/lib/dup.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/dup.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #define __LIBRARY__
8 | #include
9 |
10 | _syscall1(int,dup,int,fd)
11 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/lib/errno.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/errno.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | int errno;
8 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/lib/execve.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/execve.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #define __LIBRARY__
8 | #include
9 |
10 | _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
11 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/lib/open.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/open.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #define __LIBRARY__
8 | #include
9 | #include
10 |
11 | int open(const char * filename, int flag, ...)
12 | {
13 | register int res;
14 | va_list arg;
15 |
16 | va_start(arg,flag);
17 | __asm__("int $0x80"
18 | :"=a" (res)
19 | :"0" (__NR_open),"b" (filename),"c" (flag),
20 | "d" (va_arg(arg,int)));
21 | if (res>=0)
22 | return res;
23 | errno = -res;
24 | return -1;
25 | }
26 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/lib/setsid.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/setsid.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #define __LIBRARY__
8 | #include
9 |
10 | _syscall0(pid_t,setsid)
11 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/lib/string.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/string.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #ifndef __GNUC__
8 | #error I want gcc!
9 | #endif
10 |
11 | #define extern
12 | #define inline
13 | #define __LIBRARY__
14 | #include
15 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/lib/wait.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/wait.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #define __LIBRARY__
8 | #include
9 | #include
10 |
11 | _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
12 |
13 | pid_t wait(int * wait_stat)
14 | {
15 | return waitpid(-1,wait_stat,0);
16 | }
17 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/lib/write.c:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/lib/write.c
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | #define __LIBRARY__
8 | #include
9 |
10 | _syscall3(int,write,int,fd,const char *,buf,off_t,count)
11 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/mm/Makefile:
--------------------------------------------------------------------------------
1 | CC =gcc -mcpu=i386
2 | CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \
3 | -finline-functions -nostdinc -I../include
4 | AS =as
5 | AR =ar
6 | LD =ld
7 | CPP =gcc -E -nostdinc -I../include
8 |
9 | .c.o:
10 | $(CC) $(CFLAGS) \
11 | -c -o $*.o $<
12 | .s.o:
13 | $(AS) -o $*.o $<
14 | .c.s:
15 | $(CC) $(CFLAGS) \
16 | -S -o $*.s $<
17 |
18 | OBJS = memory.o page.o
19 |
20 | all: mm.o
21 |
22 | mm.o: $(OBJS)
23 | $(LD) -r -o mm.o $(OBJS)
24 |
25 | clean:
26 | rm -f core *.o *.a tmp_make
27 | for i in *.c;do rm -f `basename $$i .c`.s;done
28 |
29 | dep:
30 | sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
31 | (for i in *.c;do $(CPP) -M $$i;done) >> tmp_make
32 | cp tmp_make Makefile
33 |
34 | ### Dependencies:
35 | memory.o: memory.c ../include/signal.h ../include/sys/types.h \
36 | ../include/asm/system.h ../include/linux/sched.h \
37 | ../include/linux/head.h ../include/linux/fs.h ../include/linux/mm.h \
38 | ../include/linux/kernel.h
39 |
--------------------------------------------------------------------------------
/src/V0.11_rh9/mm/page.s:
--------------------------------------------------------------------------------
1 | /*
2 | * linux/mm/page.s
3 | *
4 | * (C) 1991 Linus Torvalds
5 | */
6 |
7 | /*
8 | * page.s contains the low-level page-exception code.
9 | * the real work is done in mm.c
10 | */
11 |
12 | .globl page_fault
13 |
14 | page_fault:
15 | xchgl %eax,(%esp)
16 | pushl %ecx
17 | pushl %edx
18 | push %ds
19 | push %es
20 | push %fs
21 | movl $0x10,%edx
22 | mov %dx,%ds
23 | mov %dx,%es
24 | mov %dx,%fs
25 | movl %cr2,%edx
26 | pushl %edx
27 | pushl %eax
28 | testl $1,%eax
29 | jne 1f
30 | call do_no_page
31 | jmp 2f
32 | 1: call do_wp_page
33 | 2: addl $8,%esp
34 | pop %fs
35 | pop %es
36 | pop %ds
37 | popl %edx
38 | popl %ecx
39 | popl %eax
40 | iret
41 |
--------------------------------------------------------------------------------
/src/readme.txt:
--------------------------------------------------------------------------------
1 | 此处放源码。
--------------------------------------------------------------------------------
/test/a.img:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/test/a.img
--------------------------------------------------------------------------------
/test/bochsrc:
--------------------------------------------------------------------------------
1 |
2 | # how much memory the emulated machine will have
3 | megs: 32
4 |
5 | #cpu
6 | #cpu: count=1, ips=100000000
7 | #clock: sync=slowddown
8 | cpu: ips=150000000
9 | clock: sync=both
10 |
11 |
12 | # filename of ROM images
13 | #romimage: file=/usr/share/bochs/BIOS-bochs-latest
14 | romimage: file=$BXSHARE/BIOS-bochs-latest
15 | #vgaromimage: file=/usr/share/vgabios/vgabios.bin
16 | vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest
17 |
18 | # what disk image will be used
19 | floppya: 1_44=a.img, status=inserted
20 | #floppyb: 1_44=pm.img, status=inserted
21 |
22 | # choose the boot disk
23 | boot: a
24 |
25 | # where do we send log message?
26 | log: bochsout.txt
27 |
28 | # disable the mouse
29 | mouse: enabled=0
30 |
31 | # enable key mapping,using US layout as default.
32 | keyboard: keymap=/usr/local/share/bochs/keymaps/x11-pc-us.map
33 |
34 | #debug by gdb
35 | #gdbstub: enabled=1, port=1234, text_base=0, data_base=0, bss_base=0
36 |
37 | #panic: action=fatal
38 | #error: action=report
39 | #info: action=ignore
40 | #debug: action=ask
41 |
--------------------------------------------------------------------------------
/test/boot.asm:
--------------------------------------------------------------------------------
1 | org 07c00h
2 | mov ax,cs
3 | mov ds,ax
4 | mov es,ax
5 | call DispStr
6 | hlt
7 |
8 | DispStr:
9 | mov ax, BootMsg
10 | mov bp,ax
11 | mov cx,16
12 | mov ax,01301h
13 | mov bx,000ch
14 | mov dl,0
15 | int 10h
16 | ret
17 |
18 | BootMsg: db "Hello World!"
19 | times 510-($-$$) db 0
20 | dw 0xaa55
21 |
--------------------------------------------------------------------------------
/test/compile:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | nasm boot.asm -o boot.bin
3 | dd if=boot.bin of=a.img bs=512 count=1 conv=notrunc
4 |
5 |
--------------------------------------------------------------------------------
/test/debug:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | java -jar peter-bochs-debugger20110201.jar bochs -f bochsrc
4 |
--------------------------------------------------------------------------------
/test/peter-bochs-debugger20110201.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jinghang/Linux011/1af9f925303abc674385fee215df2c82c85819e3/test/peter-bochs-debugger20110201.jar
--------------------------------------------------------------------------------