Chinaunix
标题:
Welcome to BiscuitOS
[打印本页]
作者:
Buddy_Zhang1
时间:
2017-12-02 11:42
标题:
Welcome to BiscuitOS
本帖最后由 Buddy_Zhang1 于 2017-12-16 16:31 编辑
大家好:
终于又回到 ChinaUnix 啦,这次给各位喜欢 Linux 内核的小伙伴带来了一份礼物。
长话短说,我和我的小伙伴经过八个月的开发,基于 Linux0.11 内核制作了一个完整的 Distro: BiscuitOS
为什么说这是给内核开发者的一份礼物呢?
对于学习 Linux 内核的小伙伴会遇到同一个问题,那就是现代版的内核实在是太大,无法顾及每个子系统,
也许你熟练某一个子系统,但对于其他子系统云里雾里,没有一个整体的架构感。于是 BiscuitOS 就诞生了!
BiscuitOS 是一款基于 Linux0.11 内核的发行版,我们从编译到内核实现,再到 rootfs 的制作,甚至 utils-linux 的制作
都提供了一套实现机制,这会让你 top to down 的完全了解一个发行版的操作系统是如何制作和运行的。
用户手册:
https://github.com/BiscuitOS/Documentation/tree/master/Usermanual
不多说,直接上图:
mainmenu.jpg
(86.83 KB, 下载次数: 87)
下载附件
2017-12-12 11:29 上传
BiscuitOS 的特点
Kernel 部分
1. 完整的内核机制,Linux 具有最小的代码数,2 万行左右。麻雀虽小,各种内核机制都支持
2. 支持 Intel 32 位保护模式,地址总线 32bit,与现代 32 操作系统无异
3. 完整的中断机制,包括缺页中断等,给想研究中断机制的小伙伴一个最好的实践平台
4. 支持字符设备,并实现 console 输入输出
5. 支持内存管理,支持机制的内存管理
6. 支持文件系统,提供了 ramdisk 和 harddisk 根文件系统
7. 支持多任务调度,完整的段和系统门机制
8. 支持块设备,包括硬盘,软盘和 ramdisk
9. 支持 POIX 系统调用
10. 支持 gdb 调试内核
11. 支持完整的 Kbuild系统与 Kconfig 语法
12. 支持链接脚本
13. 支持 qemu 运行系统
14. 支持页表管理机制
15. 支持 GNU as 和 ATT 汇编,已经弃用 as86 汇编
Rootfs 部分
1. 支持 MINIX V1 版本的文件系统
2. 支持 Legacy MINIX 版本的文件系统
3. 提供 MINIX 文件系统制作工具及源码(对想了解文件系统如何制作和内核如何构建文件系统的小伙伴有帮助)
Userland 部分
1. 提供基础 linux 的 utils 二进制工具
2. 提供 gcc1.4 glibc gdb 等 GNU 工具
3. 提供用户程序编译环境
其它部分
1. 实现现代的 Kbuild 编译系统,构建一套完整的编译体系
2. 提供一套定制的 buildroot,让小伙伴可以定制自己的发行版
3. 提供一套完成的补丁机制,小伙伴可以按照标准的内核补丁机制提交你的 patch
4. 如果你发现系统中没有你需要的命令,请不要慌张,你可以自己动手开发一个,trust U
如何参加我们的开源项目呢?
这是我们的开源信息,一起加入我们吧!
* 开源 github
https://github.com/BiscuitOS/BiscuitOS.git
复制代码
维护者:
进程子系统: Buddy Zhang <buddy.zhang@aliyun.com>
文件子系统: Rock Lee <rockdotlee@gmail.com>
内存子系统: Buddy Zhang <buddy.zhang@aliyun.com>
设备驱动子系统: Buddy Zhang <buddy.zhang@aliyun.com>
复制代码
作者:
Buddy_Zhang1
时间:
2017-12-02 11:43
Reserverpage
作者:
Buddy_Zhang1
时间:
2017-12-02 11:43
Reserverpage
作者:
nswcfd
时间:
2017-12-11 11:24
好久不见了, 一回归就是重磅作品,赞👍
作者:
nswcfd
时间:
2017-12-11 13:33
必须赞一下啊,从来没有在5s之内编译完linux内核的
有个依赖建议在README.md里面声明一下,mkfs.minix,有些老系统缺少对minix文件系统的支持。
作者:
Buddy_Zhang1
时间:
2017-12-12 11:28
本帖最后由 Buddy_Zhang1 于 2017-12-12 11:31 编辑
回复
5#
nswcfd
我在内核代码里添加了对 1991 年时候的 minixfs 文件系统的支持,也提供了现代版本工具 mkfs.minix -1 制作出来的文件系统支持
你的建议我会在下一次更新的时候添加上去
作者:
zhaohuig
时间:
2017-12-14 19:56
非常感谢楼主, 让我们这些内核新手有了一个实践的平台, 给你个大大的赞啦。
自己按照readme里的教程 执行make start时失败,
折腾一番后 qemu-system-x86_64 -m 512 -kernel /root/git/BiscuitOS/kernel/arch/x86/kernel/BiscuitOS /root/git/BiscuitOS/output/BiscuitOS-0.11.img -vnc 0.0.0.0:1000 -s -S 引导成功
接下来就是自己慢慢研究了。。
作者:
Buddy_Zhang1
时间:
2017-12-16 16:31
回复
7#
zhaohuig
Hi 中文用户手册:
https://github.com/BiscuitOS/Documentation/tree/master/Usermanual
作者:
Buddy_Zhang1
时间:
2017-12-16 16:32
BiscuitOS 中文用户手册
https://github.com/BiscuitOS/Documentation/tree/master/Usermanual
作者:
zhaohuig
时间:
2017-12-18 12:35
回复
8#
Buddy_Zhang1
再次感谢
!
作者:
shang2010
时间:
2017-12-18 12:45
是不是又来造轮子了,,,才4个人就可以了
作者:
Buddy_Zhang1
时间:
2017-12-19 10:34
回复
11#
shang2010
人不在数量,在于质量
作者:
Buddy_Zhang1
时间:
2018-01-19 15:06
BiscuitOS 内核(linux0.11) 关于逻辑地址,虚拟地址,线性地址和物理地址的转换过程:
/*
* Logical Address Mechanism on MMU
*
* (C) 2018.01 BiscuitOS <buddy.zhang@aliyun.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/kernel.h>
#include <linux/head.h>
#include <linux/sched.h>
#include <test/debug.h>
static char var[50] = "BiscuitOS";
/*
* Logical address convent to physical address
*/
static void logic_to_physic(void)
{
struct logic_addr la;
unsigned long virtual, linear, physic;
unsigned long base, limit;
unsigned long cs, ds, cr3, cr4;
unsigned char cpl, dpl;
struct desc_struct *desc;
unsigned long PDE, PTE;
/* Obtain specific segment selector */
__asm__ ("movl %%cs, %0\n\r"
"movl %%ds, %1"
: "=r" (cs), "=r" (ds));
/* Establish a logical address */
la.offset = (unsigned long)&var;
la.sel = ds;
/* Obtain virtual address */
virtual = la.offset;
/* violation COW */
var[48] = 'A';
/* Uses the offset in the segment selector to locate the segment
* descriptor for the segment in the GDT or LDT and reads it into
* the processor. (This step is needed only when a new segment selector
* is loaded into a segment register.) */
if ((la.sel >> 2) & 0x1)
desc = ¤t->ldt[la.sel >> 3];
else
desc = &gdt[la.sel >> 3];
/* Examines the segment descriptor to check the access rights and range
* of the segment to insure that the segment is accessible and that
* offset is within the limit of the segment */
base = get_base(*desc);
limit = get_limit(*desc) * 4096;
if (la.offset > limit)
panic("Out of segment\n");
cpl = cs & 0x3;
dpl = desc->b >> 13 & 0x3;
if (cpl > dpl)
panic("Trigger #GP");
/* Obtain linear address on flat-protect model */
linear = base + la.offset;
/* Obtain physical address of pgdir from CR3 register, the contents of
* 'cr3' is point to the physical of pg_dir, so refers it as a pointer. */
__asm__ ("movl %%cr3, %0" : "=r" (cr3));
/* A 4-KByte naturally aligned page directory is located at the
* physical address specified in bits 31:12 of CR3. A page directory
* comprises 1024 32-bit entries (PDEs). A PDE is selected using
* the physical address defined as follow:
*
* -- Bits 39:32 are all 0
* -- Bits 31:12 are from CR3.
* -- Bits 11:2 are bits 31:22 of the linear address
* -- Bits 1:0 are 0.
*
* Becasue a PDE is identified using bits 31:22 of the linear address,
* it control access to a 4-Mbytes region of the linear-address space.
* Use of the PDE depends on CR4.PSE and PDE's PS flag (bit 7)*/
PDE = ((unsigned char)(((cr3 >> 12) & 0xFFFFF) << 12) +
(((linear >> 22) & 0x3FF) << 2)) & 0xFFFFFFFC;
/* Another way to compute PDE:
* PDE = (unsigned long *)cr3[linear >> 22] */
__asm__ ("movl %%cr4, %0" : "=r" (cr4));
if (((cr4 >> 4) & 0x1) && ((PDE >> 4) & 0x1)) {
/* If CR4.PSE = 1 and the PDE's PS flag is 1, the PDE maps a 4-MByte
* page. The final physical address is computed as follows:
*
* -- Bits 39:32 are bits 20:13 of the PDE.
* -- Bits 31:22 are bits 31:22 of the PDE.
* -- Bits 21:0 are from the original linear address.
*/
PTE = 0x0; /* No complete on BiscuitOS */
} else if (!((cr4 >> 4) & 0x1) && !((PDE >> 4) & 0x1)) {
/* If CR4.PSE = 0 or the PDE's PS flag is 0, a 4-KByte naturally
* aligned page table is located at the physical address specified
* in bits 31:12 of the PDE. A page table comprises 1024 32-bit
* entries (PTEs). A PTE is selected using the physical address
* defined as follows:
*
* -- Bits 39:32 are all 0
* -- Bits 31:12 are from the PDE.
* -- Bits 11:2 are bits 21:12 of the linear address.
* -- Bits 1:0 are 0.
*/
PTE = (unsigned long)((unsigned char *)(
((*(unsigned long *)PDE >> 12) & 0xFFFFF) << 12) +
(((linear >> 12) & 0x3FF) << 2)) & 0xFFFFFFFC;
/* Anther way to compute PTE:
* PTE = (unsigned long *)PDE[(linear >> 12) & 0x3FF] */
}
/* Because a PTE is identified using bits 31:12 of the linear address,
* every PTE maps a 4-KByte page. The final physical address is
* computed as follows:
*
* -- Bits 39:32 are all 0
* -- Bits 31:12 are from the PTE.
* -- Bits 11:0 are from the original linear address.
*/
physic = (unsigned long)(unsigned char *)(
((*(unsigned long *)PTE >> 12) & 0xFFFFF) << 12) +
(linear & 0xFFF);
printk("Logical Address: %#x:%#x\n", la.sel, la.offset);
printk("Virtual Address: %#x\n", virtual);
printk("Linear Address: %#x\n", linear);
printk("Physic Address: %#x\n", physic);
printk("Original: %s\n", la.offset);
printk("Translate: %s\n", physic);
}
复制代码
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2