Repos / kernel.git / commitdiff
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0bdeaf5)
raw | patch | inline | side by side (parent: 0bdeaf5)
| author | zhaoyanbai <zhaoyanbai@126.com> | |
| Sat, 27 Dec 2025 02:51:54 +0000 (10:51 +0800) | ||
| committer | zhaoyanbai <zhaoyanbai@126.com> | |
| Sat, 27 Dec 2025 02:51:54 +0000 (10:51 +0800) |
| README.md | patch | blob | history | |
| bin/Makefile | patch | blob | history | |
| kernel/wait.c | patch | blob | history | |
| mkiso.sh | patch | blob | history | |
| qemu.sh | patch | blob | history |
diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
-kernel
-======
+# KERNEL
-I can't find a satisfactory name for my kernel.
+## Mac环境准备
-### HOW TO GET THE LATEST SOURCECODE?
- git clone https://github.com/acevest/kernel.git
-### WHEN DID YOU START TO DO THIS WORK?
- Maybe 2006.12
-### HOW TO COMPILE THIS KERNEL?
+
+### mac
+
+```bash
+brew install i686-elf-binutils
+brew install i686-elf-gcc
+brew install i386-elf-gdb
+brew install qemu
+```
+
+### docker
+
+安装 fedora docker, 注意如果是arm Mac是要指定`--platform=linux/amd64`
+这个docker 主要是用来打包kernel.iso的。
+
+```bash
+docker pull --platform=linux/amd64 fedora:latest
+dnf install grub2-mkrescue
+# 不安装grub2-pc-modules就没有/usr/lib/grub/i386-pc/就无法正确生成iso
+dnf install grub2-pc-modules
+dnf install xorriso
+
+# mke2fs
+dnf install e2fsprogs.x86_64
+
+# 以下选装
+# 如果要安装 chsh
+dnf install util-linux-user
+
+dnf install gcc-x86_64-linux-gnu.x86_64
+dnf install binutils-x86_64-linux-gnu.x86_64
+dnf install vim
+dnf install git
+```
+
+运行
+```
+docker run -h kernel -itv kernel:/root/kernel --privileged=true --name kernel fedora
+```
+
+然后就可以在本地用`mkiso.sh`通过指定docker container的id来生成`kernel.iso`了
diff --git a/bin/Makefile b/bin/Makefile
--- a/bin/Makefile
+++ b/bin/Makefile
-CFLAGS = -g -c -fno-builtin -m32 -DBUILDER='"$(shell whoami)"'
+CFLAGS := -g -c -fno-builtin -m32 -DBUILDER='"$(shell whoami)"'
+CFLAGS += -m32 -c -I../include -fno-builtin
+CFLAGS += -std=gnu11
LDFLAG = -e _start
-CFLAGS = -m32 -c -I../include -fno-builtin
LIBC_DIRS = ../lib
LIBC_SRCS := $(foreach DIR, $(LIBC_DIRS), $(wildcard $(DIR)/*.[cS]))
LIBC_OBJS := $(patsubst %,%.o,$(LIBC_SRCS))
-BINS := shell hello
+BINS := init
all:$(BINS)
diff --git a/kernel/wait.c b/kernel/wait.c
--- a/kernel/wait.c
+++ b/kernel/wait.c
p->task->state = TASK_READY;
p->task->reason = "wake_up";
- list_del(&p->entry);
+ list_del_init(&p->entry);
--nr;
if (nr == 0) {
diff --git a/mkiso.sh b/mkiso.sh
--- a/mkiso.sh
+++ b/mkiso.sh
IFS=':' read -ra parts <<< "${file_line}"
src_file="${parts[0]}"
dst_file="${parts[1]}"
+
+ if [ ! -f "$src_file" ]; then
+ echo -e "\033[31merror: file $src_file not found\033[0m"
+ exit 1
+ fi
+
src_file_md5=$($MD5 "$src_file" | awk '{ print $1 }')
docker cp $src_file $CONTAINER_ID:$dst_file