如何在旧台式计算机上构建小型操作系统? [英] How can I build a small operating system on an old desktop computer?

查看:23
本文介绍了如何在旧台式计算机上构建小型操作系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是徒劳的,因为我知道编写操作系统非常复杂(尤其是自己编写).

This might be in vain, as I know writing an operating system is unbearably complicated (especially by oneself).

  • 我不希望构建下一个 linux 或 windows.

  • I don't expect to build the next linux, or windows.

我知道这会很糟糕,而且很麻烦,而且不会起作用,但没关系.

I know it will be horrible, and buggy, and won't work, but that's fine.

我想自己编写所有东西,用 AssemblyC 和(一些)C++.

I want to write everything myself, in Assembly, C, and (some) C++.

这是一个未来的项目,因为我目前正忙于其他事情,没有时间,但我想我现在会问它,所以也许我可以得到很多答案,它可以构建并成为这种方法的有用资源(我所看到的所有其他事情都涉及构建 minix、使用现有的引导加载程序、在虚拟引导程序中构建它等等).

This is a future project, as I'm busy with some other things at the moment and don't have the time immediately, but I figured I would ask it now, so maybe I could get lots of answers to this, and it could build up and be a useful resource for this kind of approach (everything else I have seen involved building off of minix, using an existing bootloader, building it in a virtual booting program thing, etc).

我想用显示器、键盘和鼠标设置我的一台旧台式机,然后开始使用空白硬盘.

I want to set up one of my older desktops with a monitor, keyboard and mouse, and start working on a blank hard drive.

我想学习如何编写自己的引导加载程序(我找到了很多关于这方面的资源,但为了完整起见,仍然请添加一些好的),我自己的 USB 驱动程序(如果有必要的话),CD 驱动程序(如果有必要)等等.一切,从头开始.

I want to learn how to write my own bootloader (I've found lots of resources about this, but for completeness, please still add some good ones), my own USB driver (if that's necessary), a CD driver (if that's necessary), etc. Everything, from the ground up.

  • 如何将代码放到电脑上?最好用软盘来做吗?大多数计算机都可以通过 U 盘进行操作吗?

  • How do I put the code onto the computer? Is it best to do it with a floppy disk? Can most computers do it from a USB stick?

我需要什么驱动程序,您能否建议任何构建这些驱动程序的参考?

What drivers do I need, and can you suggest any references to building those?

在启动序列之后——然后呢?如何进入保护模式等.

After the booting sequence--then what? How do I get into protected mode etc.

如何在没有操作系统帮助的情况下管理内存?我只是使用我想要的任何地址吗?不需要初始化?

How do I manage memory without the help of an operating system? Do I just use whatever addresses I want? No initialization necessary?

毫无疑问,我会遇到什么让我困惑的事情?

What will I undoubtedly run into that will confuse me?

我怎样才能让它既是命令行操作系统,又是图形操作系统?

How can I make it either a command line O/S, and a graphical one?

什么是图形操作系统?比如,我将如何做一个命令行、字体和顶部的图片?

What is a graphical O/S built on? Like, how would I do something like, a command line, with a font, and a picture at the top?

我在哪里可以阅读有关设置多任务环境的信息?(即,有两个类似图形的命令行并排运行).

Where can I read about setting up a multitasking environment? (ie., having two graphical-like command lines running side-by-side).

我将如何设置一种窗口系统?设置简单的多任务处理后,如何在屏幕上显示图形?

How would I set up a sort of windowing system? How do I display graphics on the screen once simple multitasking is set up?

相信我,我知道这是一个非常复杂的项目,而且我可能永远不会完成它或在上面写任何有用的东西.

Believe me, I understand that this is a very complicated project, and I probably will never get around to completing it or writing anything on it of any use.

还有很多我没有提到的其他部分,如果您想到任何,也请随时添加.

There are lots of other pieces to this I haven't mentioned, if you think of any, feel free to add those too.

请为每个答案添加一个主题"——例如,USB 驱动程序,然后可能是资源列表、需要注意的事项等.

Please put one "topic" per answer--for example, USB drivers, and then maybe a list of resources, things to look out for, etc.

另外,请不要建议构建另一个操作系统或预先存在的代码.我知道我会阅读很多预先存在的代码(例如 linux 内核、或示例资源、现有驱动程序等),但最终我想自己完成所有编写工作.我知道我应该建立在其他东西的基础上,如果我改变主意并走那条路,我可以阅读关于 SO 的许多其他问题.但这就是从头开始做整个事情.

Also, please don't suggest building off of another O/S or pre-existing code. I know I will read a lot of pre-existing code (such as the linux kernel, or example resources, existing drivers, etc) but ultimately I want to do all the writing myself. I know I should build off of something else, and there are lots of other questions on SO about that that I can read if I change my mind and go that route. But this one is all about doing the whole thing from scratch.

关于如何获得图形化的任何建议?不同的视频模式以及如何使用它们等?

Any suggestions on how to get it graphical? Different video modes and how to work with them, etc?

推荐答案

第一件事.读,读,读,读,读.在您希望实现自己的操作系统之前,您需要对操作系统的工作原理有一个深刻的了解.

First things first. Read, read, read, read, read. You need to have a firm understanding of how the OS works before you can hope to implement your own.

阅读 Andrew Tanenbaum 的一本关于操作系统的书籍.这是我们在大学操作系统课上使用的:

Grab one of Andrew Tanenbaum's books on operating systems. This is the one we used in my OS class in college:

现代操作系统 PDF

亚马逊上的现代操作系统

尽管封面很荒谬,但它是一本很棒的读物,尤其是作为教科书.Tanenbaum 确实是该领域的专家,他对操作系统如何在底层工作的解释清晰易懂.这本书主要是理论,但我相信他也有一本书讨论了更多的实现.不过,我从未读过它,所以我无法评论它.

Despite the ridiculous cover, it's a fantastic read, especially for a textbook. Tanenbaum is really an expert in this area and his explanations of how the OS works underneath the hood are clear and easy to understand. This book is mostly theory, but I believe he also has a book that discusses more of the implementation. I've never read it, though, so I can't comment on it.

这应该可以帮助您了解进程管理、内存管理、文件系统以及您的操作系统内核需要执行的所有其他操作以使其进入可引导状态.从那时起,基本上就是为您需要支持的硬件编写设备驱动程序,并提供 C 库函数的实现以使内核调用诸如打开文件和设备、读取和写入、在进程之间传递消息等.

That should help you bone up on process management, memory management, filesystems, and everything else your OS kernel needs to do to get it up to a bootable state. From that point on it's basically a matter of writing device drivers for the hardware you need to support, and offering implementations of the C library functions to make kernel calls for things like opening files and devices, reading and writing, passing messages between processes, etc.

阅读 x86 程序集(假设您正在为 x86 机器设计此程序).这应该可以回答您关于在处理器操作模式之间切换的许多问题.

Read up on x86 assembly (assuming you are designing this for an x86 machine). That should answer a lot of your questions with regards to moving between processor operating modes.

如果您有任何电子知识,那么从为具有大量文档的嵌入式设备编写操作系统开始可能会更容易,因为它通常比 x86 PC 更简单.我也一直想编写自己的操作系统,我开始为 这个开发板来自 Digilent.它可以运行 Xilinx 的软核 MicroBlaze 处理器,该处理器具有非常详尽的文档.它还有一些 RAM、闪存数据存储、LED、开关、按钮、VGA 输出等.编写简单的驱动程序可以玩很多东西.

If you've got any electronics knowledge, it may be easier to start with writing an operating system for an embedded device that has ample documentation, because it will generally be simpler than an x86 PC. I've always wanted to write my own OS as well, and I'm starting with writing a microkernel embedded OS for This Development Board from Digilent. It can run the soft-core MicroBlaze processor from Xilinx, which has very thorough documentation. It's also got some RAM, flash data storage, LEDs, switches, buttons, VGA output, etc. Plenty of stuff to play around with writing simple drivers for.

嵌入式设备的好处之一是您可以避免长时间编写 VGA 驱动程序.就我而言,Digilent 开发板有一个板载 UART,因此我可以有效地将串行输出用作我的控制台来启动整个系统并以最小的麻烦启动到命令行.

One of the benefits of an embedded device is also that you may be able to avoid writing a VGA driver for a long time. In my case, the Digilent development board has an onboard UART, so I can effectively use the serial output as my console to get the whole thing up and booting to a command line with minimal fuss.

只要确保您选择的任何目标都具有现成可用且经过良好测试的编译器即可.您确实希望同时编写操作系统和编译器.

Just make sure that whatever you choose to target has a readily available and well-tested compiler for it. You do not want to be writing an OS and a compiler at the same time.

这篇关于如何在旧台式计算机上构建小型操作系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆