Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
pengruiyang-cpu authored Jul 21, 2020
0 parents commit 1a5b649
Show file tree
Hide file tree
Showing 90 changed files with 10,281 additions and 0 deletions.
96 changes: 96 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#
# Makefile for linux.
# If you don't have '-mstring-insns' in your gcc (and nobody but me has :-)
# remove them from the CFLAGS defines.
#

AS86 =as -0 -a
CC86 =cc -0
LD86 =ld -0

AS =as
LD =ld
LDFLAGS =-s -x -M
CC =gcc
CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer -fcombine-regs
CPP =gcc -E -nostdinc -Iinclude

ARCHIVES=kernel/kernel.o mm/mm.o fs/fs.o
LIBS =lib/lib.a

.c.s:
$(CC) $(CFLAGS) \
-nostdinc -Iinclude -S -o $*.s $<
.s.o:
$(AS) -c -o $*.o $<
.c.o:
$(CC) $(CFLAGS) \
-nostdinc -Iinclude -c -o $*.o $<

all: Image

Image: boot/boot tools/system tools/build
tools/build boot/boot tools/system > Image
sync

tools/build: tools/build.c
$(CC) $(CFLAGS) \
-o tools/build tools/build.c
chmem +65000 tools/build

boot/head.o: boot/head.s

tools/system: boot/head.o init/main.o \
$(ARCHIVES) $(LIBS)
$(LD) $(LDFLAGS) boot/head.o init/main.o \
$(ARCHIVES) \
$(LIBS) \
-o tools/system > System.map

kernel/kernel.o:
(cd kernel; make)

mm/mm.o:
(cd mm; make)

fs/fs.o:
(cd fs; make)

lib/lib.a:
(cd lib; make)

boot/boot: boot/boot.s tools/system
(echo -n "SYSSIZE = (";ls -l tools/system | grep system \
| cut -c25-31 | tr '\012' ' '; echo "+ 15 ) / 16") > tmp.s
cat boot/boot.s >> tmp.s
$(AS86) -o boot/boot.o tmp.s
rm -f tmp.s
$(LD86) -s -o boot/boot boot/boot.o

clean:
rm -f Image System.map tmp_make boot/boot core
rm -f init/*.o boot/*.o tools/system tools/build
(cd mm;make clean)
(cd fs;make clean)
(cd kernel;make clean)
(cd lib;make clean)

backup: clean
(cd .. ; tar cf - linux | compress16 - > backup.Z)
sync

dep:
sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
(for i in init/*.c;do echo -n "init/";$(CPP) -M $$i;done) >> tmp_make
cp tmp_make Makefile
(cd fs; make dep)
(cd kernel; make dep)
(cd mm; make dep)

### Dependencies:
init/main.o : init/main.c include/unistd.h include/sys/stat.h \
include/sys/types.h include/sys/times.h include/sys/utsname.h \
include/utime.h include/time.h include/linux/tty.h include/termios.h \
include/linux/sched.h include/linux/head.h include/linux/fs.h \
include/linux/mm.h include/asm/system.h include/asm/io.h include/stddef.h \
include/stdarg.h include/fcntl.h
20 changes: 20 additions & 0 deletions README-EN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Source Code of Linux 0.0.1

[中文版? 点击这里](README.md)

## What is it?
This is the source code of Linux 0.0.1, the first version of Linux.

Linux forgot this version and this is his friend's.

## Why Linux 0.0.1?

Now, (2020) Linux source code has million lines. Linux 0.0.1 is Simpler than it.

## How I use it?

There was a [Makefile](Makefile). You must install GCC-ARM on your Computer (because Linux use ARM Assembly, not AT&T).

Then, type make (or mingw32-make) to terminal, Compiler is starting. It'll create a Image File and write data to it likes disk.

Finally, burn the Image File to your disk (or other media), and then restart your Computer. Linux 0.0.1 will start.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Linux 0.0.1的源代码
[using English? Click here](README-EN.md)

## 这是什么?
这个仓库中是Linux 0.0.1版本的源代码,就是Linux的第一个版本。

这个版本的源代码Linus本人已经丢失,这一份是它的同事保存的。如果有不完整或其它问题请通知<[email protected]>

## 为什么用0.0.1版?
Linux现在(2020年)的代码行数已经达到数以百万计。0.0.1版相对来说比较容易学习。

并且,在学习的时候主要学习的是Linux的思想,至于这一点,Linux所有的版本都几乎是一样的。所以,学习0.0.1和学习1.1.1是几乎一样的。

(
Linux的早期版本其实和后期版本不太一样,例如传参方式等等。但是,主要的思想是没有变化的。
)

## 怎么使用它?

源代码中包含了Makefile,你需要在你的操作系统中安装ARM汇编版的GCC(因为Linux汇编代码全部为ARM格式而不是AT&T格式)。

在终端中输入make或者mingw32-make就可以开始编译了。编译结束后会生成一个磁盘映像文件,将它刻录到你的光盘或其它储存介质上后启动就可以了。
Loading

0 comments on commit 1a5b649

Please sign in to comment.