# AboutLinuxKernel **Repository Path**: shunzi20220/AboutLinuxKernel ## Basic Information - **Project Name**: AboutLinuxKernel - **Description**: linux内核源码学习 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-02-10 - **Last Updated**: 2025-02-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ### Windows安装WSL 用管理权限打开Powershell ```shell # 安装WSL wsl --install # 进入linux系统 wsl # WSL访问win C盘 cd /mnt/c #win访问WSL home explorer.exe ``` ### ubuntu安装bochs ```shell sudo apt install bochs bochs-x # 启动bochs,验证是否安装成功 bochs bochs-x ``` 源码安装 下载网址:https://sourceforge.net/projects/bochs/files/bochs/ ```shell tar -zxvf bochs-2.8.tar.gz cd bochs-2.8 ./configure --prefix=/home/shun/work/library/bochs-2.8/output --enable-debugger --enable-disasm --enable-iodebug --enable-x86-debugger --with-x --with-x11 make -j8 make install ``` 创建镜像文件 ```shell ./bximage ``` 创建bochsrc ```shell # how much memory the emulated machine will have megs: 32 # filename for ROM images romimage: file=/home/shun/work/library/bochs-2.8/output/share/bochs/BIOS-bochs-latest vgaromimage: file=/home/shun/work/library/bochs-2.8/output/share/bochs/VGABIOS-lgpl-latest # what disk images will be used floppya: image="/home/shun/work/library/bochs-2.8/output/bin/f.img", status=inserted # choose the boot disk boot: floppy # where do we send log messages log: bochsout_floppy.txt # disable the mouse mouse: enabled=0 # enable key mapping, using US layout as default keyboard: keymap=/home/shun/work/library/bochs-2.8/output/share/bochs/keymaps/x11-pc-us.map ``` 启动bochs ```shell ./bochs -f bochsrc ``` https://www.cnblogs.com/dylaris/p/18342018 ### ubuntu安装QEMU ```shell sudo apt update sudo apt install qemu qemu-kvm libvirt-daemon libvirt-clients bridge-utils virt-manager # 验证安装 qemu-system-x86_64 -version # 启动 virt-manager ``` https://blog.csdn.net/weixin_45139984/article/details/136655911 ### bootsect.S ```shell as -o bootsect.o bootsect.S # -Ttext 0x0 将目标文件bootsect.O的代码段放到linux.img的开头,即第一扇区 ld -m elf_x86_64 -Ttext 0x0 -s --oformat binary -o linux.img bootsect.o ``` 用qemu运行 ```shell qemu-system-i386 -boot a -fda linux.img ``` bootsect.S setup.S linux_kernel_012/kernel/head.S:内核镜像的开头 linux_kernel_012/kernel/main.c linux_kernel_012/kernel/sched.c : 进程调度 linux_kernel_012/kernel/chr_drv/console.c: 控制台初始化 linux_kernel_012/kernel/vsprintf.c:格式化字符串 linux_kernel_012/mm/memory.c: 内存管理 linux_kernel_012/kernel/asm.S:中断服务程序 linux_kernel_012/mm/swap.c : 寻找空闲物理页表 linux_kernel_012/kernel/sys_call.S:时钟中断服务 linux_kernel_012/kernel/chr_drv/keyboard.S:键盘中断服务 ### 资料 [《从零开始写Linux内核 一书学透核心原理与实现》](https://item.jd.com/10130776838286.html) 配套代码: https://gitee.com/hinus/linux_kernel_012/tree/books/ linux0.11注释:https://github.com/beride/linux0.11-1 https://github.com/yifengyou/linux-0.12 Linux内核源码分析: https://www.bilibili.com/video/BV1aE421w7NY 《Linux内核API完全参考手册(第2版)》 《Linux内核深度解析》