随笔分类 - Kernel
摘要:FreeDOS可以运行在实模式或保护模式下,在启动FreeDOS时有4种运行模式选择: 前两种运行在保护模式下, 后两种运行在实模式下。 根据How to tell whether your CPU is running in real mode or protected mode,可以通过如下方式
阅读全文
摘要:How to tell whether your CPU is running in real mode or protected mode
阅读全文
摘要:QEMU/FreeDOS
阅读全文
摘要:1. code 2. 编译成bin文件 nasm -f bin boot.asm -o boot.bin 3.运行 1) qemu qemu-system-i386 boot.bin 2) 虚拟机从floppy启动 dd if=/dev/zero of=floppy.img bs=512 count
阅读全文
摘要:Kernel 101 –Let’s write a Kernel
阅读全文
摘要:参考:1)《LINUX设备驱动程序》第十四章 Linux 设备模型2)内核源码2.6.38内核初始化的时候会对设备模型作初始化,见init/main.c: start_kernel->rest_init->kernel_init->do_basic_setup->driver_init设备模型中重要...
阅读全文
摘要:本文代码参考《LINUX设备驱动程序》第十七章 网络驱动程序网络地址和虚拟主机地址为:snullnet0 192.168.0.0snullnet1 192.168.1.0local0 192.168.0.1remote0 192.168.0.2local1 192.168.1.2remote1 192.168.1.1注:ldd自带网络驱动程序中的很多函数和数据结构在最新2.6.32内核上有所变动,导致编译不通过。修改源码参考:http://blog.csdn.net/xiebiwei/article/details/6210887#quote修改后的代码下载测试功能1) #make2) #in
阅读全文
摘要:本文代码参考《LINUX设备驱动程序》第十六章 块设备驱动程序本文中的“块设备”是一段大小为PAGE_SIZE的内存空间(两个扇区,每个扇区512字节)功能:向块设备中输入内容,从块设备中读出内容注:ldd自带块设备驱动源码在2.6.32内核的发行版上编译时会提示很多API未定义,原因是kernel 2.6中block layer API已经变更了很多,本文的程序参考了http://hi.baidu.com/casualfish/item/7931bbb58925fb951846977d,感谢!代码:1. sbull.c 1 #include 2 #include 3 #includ...
阅读全文
摘要:本文代码参考《LINUX设备驱动程序》第三章 字符设备驱动程序本文中的“字符设备”是一段大小为PAGE_SIZE的内存空间功能:向字符设备写入字符串;从字符设备读出字符串代码:1. scull.c 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 10 #include "scull.h" 11 12 int scull_major = SCULL_MAJOR; 13 int scull_minor = 0; 14 15 mo...
阅读全文
摘要:本文模仿linux内核源码fs/proc/下各.c文件的写法,在/proc下创建一个文件读取CR3寄存器的值。1. reg_cr3.c 1 #include 2 #include 3 #include 4 #include 5 6 MODULE_LICENSE("GPL"); 7 8 static int get_reg_cr3(struct seq_file *m, void *v) 9 {10 unsigned int cr3;11 12 cr3 = read_cr3();13 seq_printf(m, "%X\n", cr3);14 15 r..
阅读全文
摘要:1. hello.c 1 #include 2 #include 3 #include 4 5 MODULE_AUTHOR("TangHuimin"); 6 MODULE_DESCRIPTION("My First Try to Kernel Module"); 7 MODULE_LICENSE("GPL"); 8 9 static int hello_init(void)10 {11 printk(KERN_ALERT "Hello World Enter\n");12 return 0;13 }14 15 mo
阅读全文