]> Zhao Yanbai Git Server - kernel.git/commitdiff
解决新遇到的环境问题
authoracevest <zhaoyanbai@126.com>
Sat, 27 Dec 2025 02:51:54 +0000 (10:51 +0800)
committeracevest <zhaoyanbai@126.com>
Sat, 27 Dec 2025 02:51:54 +0000 (10:51 +0800)
README.md
bin/Makefile
kernel/wait.c
mkiso.sh
qemu.sh

index 40ee1b674702a2e591c4e9a41fa527179f1180ce..e17342f509e63b4ca72212f8fcd6a5b64cb72aea 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,10 +1,45 @@
-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`了
index 9fce26c1b9d2b0db78caf2ee5c116d29f81d7e7a..3fd0cbe45eacdce0d88443399dea1dc8deab15d5 100644 (file)
@@ -24,13 +24,14 @@ endif
 
 
 
-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)
 
index d9879552750001770fc2308e87c3ea0d3a462f2d..9536f1f009ec6239c4d01ad464c49e0869e80dfe 100644 (file)
@@ -62,7 +62,7 @@ volatile void __wake_up(wait_queue_head_t *head, int nr) {
         p->task->state = TASK_READY;
         p->task->reason = "wake_up";
 
-        list_del(&p->entry);
+        list_del_init(&p->entry);
 
         --nr;
         if (nr == 0) {
index 9026e71685dc73b571d8808b36c87c42efead7ba..3b3645fbbe8918652b601cd32d8430c046718e06 100755 (executable)
--- a/mkiso.sh
+++ b/mkiso.sh
@@ -54,6 +54,12 @@ for i in "${!files[@]}"; do
     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
diff --git a/qemu.sh b/qemu.sh
index e62084672c8daf41965bc618126d01fb28349850..f1b5adfec3f8225d2c77b0fffe7182050862f37a 100755 (executable)
--- a/qemu.sh
+++ b/qemu.sh
@@ -21,7 +21,7 @@ qemu-system-i386 \
     -boot d \
     -m 128 \
     -serial tcp::6666,server,nowait \
-    -drive file=HD.IMG,format=raw,index=0,media=disk \
+    -drive file=hd.img,format=raw,index=0,media=disk \
     -drive file=kernel.iso,index=1,media=cdrom \
     -name kernel \
     -device ich9-ahci,id=ahci \