构建我的ASM X86 OS,从哪里开始 [英] Building my asm x86 os, where to start

查看:99
本文介绍了构建我的ASM X86 OS,从哪里开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解MIPS汇编语言,并且我正在研究x86汇编语言(我使用masm),最近我阅读了有关mikeos的信息,尤其是关于此的信息: http://mikeos.sourceforge.net/write-your-own-os. html 我有一些问题:

i know MIPS asm and i'm studying a little bit of x86 asm (i use masm), recently i'v read about mikeos and in particular about this: http://mikeos.sourceforge.net/write-your-own-os.html And i have some questions:

1)Windows上是否有任何IDE可以帮助我编译和执行此低级代码?如果该想法不存在,我该如何调试?

1) Is there any IDE on windows that can help me compile and execute this low level code? How can i debug it if this ide does not exist?

2)通过这些教程,我位于引导加载程序部分中,如果我需要访问文件怎么办?例如.我想在引导程序中创建一个简单的文本编辑器,如何访问位于硬盘上的文件?

2) With these tutorials i'm in the bootloader section, what if i need to access to a file? eg. i want to make a simple text editor in my bootloader, how can i access to a hard-disk located file?

3)这是引导程序吗?假设我在这里实现了一些功能,并创建了一个不错的引导程序,下一步是什么?

3) this is the bootloader right? let's suppose that i implement some functions here and i create a nice bootloader, what is the next step?

也要感谢我在哪里可以找到其他资料?

Thanks in advance, also, where can i find some other material?

推荐答案

学习Linux.因为它对开发人员友好,所以可以使用它(并可能以某种方式进行研究,例如 ALP ...).不要花几个月的时间在自己的引导加载程序上,而要使用现有的引导加载程序(例如 GRUB ).

Learn Linux. Use it (and perhaps study it somehow, e.g. ALP...) since it is developer friendly. Don't spend months on your own bootloader, use an existing one (e.g. GRUB).

请参见 OSDEV Wiki(恕我直言,最好https://stackoverflow.com/a/51944435/841108than 您的MikeOS链接)&绝对阅读 操作系统:三件简单的书 .花费几周的时间来阅读和学习内容(甚至在 甚至编码之前).

See OSDEV wiki (IMHO it is better https://stackoverflow.com/a/51944435/841108than your MikeOS link) & read absolutely Operating Systems: Three Easy Pieces. Take several weeks to read and learn stuff (before even coding).

Windows上是否有任何IDE可以帮助我编译和执行此低级代码?

Is there any IDE on windows that can help me compile and execute this low level code?

您应该更喜欢使用Linux,并且您当然不需要IDE,而是一个很好的源代码编辑器(您不应该使用IDE,因为它会隐藏您需要了解的详细信息;您需要使用命令并了解每个命令的作用).我的偏好是 emacs ,但是您可以使用其他编辑器(例如 gedit 等).

You should prefer using Linux, and you certainly do not need an IDE, but a good source code editor (you should not use an IDE, because it hides you details that you need to understand; you need to use commands and understand what each command is doing). My preference is emacs but you might use other editors (like vim, gedit, etc...).

您将使用C编译器(以某种方式作为交叉编译器;您可能希望选择类似于现有他们).我的建议是 GCC (还有调用gcc .您当然希望所有警告(因此-Wall -Wextra).您可能需要 DWARF 格式的调试信息构建自动化工具(例如 make ,...)和某些版本控制系统(选择免费软件,在 github 或其他工具上;要尽快做到这一点就可以以获得反馈).

You'll use a C compiler (somehow as cross-compiler; you may want to choose calling conventions similar to existing ABIs, so study them). My recommendation is GCC (and there is also Clang). You need to understand in details how to invoke gcc. You certainly want all warnings (so -Wall -Wextra). You might want debug information in DWARF format with -g, and some optimizations flags (e.g. -O1 or -O2). You'll want to use some build automation tool (e.g. ninja, make, ...) and some version control system (choose git and publish your code as free software, on github or something else; do that quickly to be able to get feedback).

您将使用链接器(您可以阅读Levine的 链接器和加载器 书).因此, binutils 及其ld(当然,您会有一些汇编代码).您需要了解链接器脚本,以及可能的有关以下内容的详细信息 ELF 格式.

You'll use a linker (you could read Levine's Linkers and Loaders book). So binutils and its ld (of course you'll have some assembler code). You'll need to understand linker scripts and probably details about ELF format.

如果这个想法不存在,我该如何调试?

How can i debug it if this ide does not exist?

非常痛苦.也许您将使用一些仿真器或虚拟机,并进行使用gdb 进行远程调试(这并不简单;因此一开始就不会有这么奢侈).实际上,您首先要对一些屏幕输出进行编码(也许是您自己的console_printf,但不使用<stdio.h>)并使用它.

Painfully. Perhaps you'll use some emulator or virtual machine, and do remote debugging with gdb (it is not simple; so you won't have that luxury at first). Practically, you first want to code some screen output (perhaps your own console_printf, but without using <stdio.h>) and use that.

如果我需要访问文件怎么办?

what if i need to access to a file?

您真的很困惑(无需编写或借用大量代码,就无法访​​问任何文件).一个操作系统(甚至是您的玩具操作系统)正在实施 文件系统,没有那个就没有任何东西.因此,您的操作系统将(稍后)提供一些文件抽象(针对能够运行的任何软件).您一开始将无法访问任何文件(但 GRUB 可以,但只能在启动时访问)加载),甚至很难从原始磁盘(或某个分区)读取块( SATA DMA 中断等).顺便说一句,您可以设计不带文件的操作系统,但是可以通过其他一些方式来实现持久性.而且,如果您要查找文件,则需要实现一个文件系统.

You really are confused (without writing or borrowing a lot of code, you cannot access any files). An OS (even your toy OS) is implementing file systems, and don't have any without that. So your OS will (later) provide some file abstraction (to whatever software it is able to run). You won't access to any files at first (but GRUB can, but only at boot loading), and even reading blocks from the raw disk (or some partition) is difficult (SATA, DMA, interrupts, etc...). BTW, you could design your OS without files, but with some other ways to have persistence. And if you go for files, you'll need to implement a file system.

请注意,操作系统很复杂,因为它必须在硬件上方实现所有功能(包括屏幕显示,磁盘访问,键盘处理,鼠标操作,进程及其调度,内存管理和虚拟内存).而且PC硬件(USB,SATA,以太网等)比25年前要复杂得多.

Be aware that an OS is complex, because it has to implement everything (including screen display, disk access, keyboard handling, mouse handing, processes and their scheduling, memory management and virtual memory) above the hardware. And a PC hardware is much more complex (USB, SATA, Ethernet, ...) than it was 25 years ago.

下一步是什么?

what is the next step?

考虑操作系统设计(调度程序& 多任务,持续性,进程隔离系统调用).因此,请多多阅读.调查现有项目( Pliant NewOS Haiku Tunes -无效但有趣--)您将无法实现许多功能,因此请逐步进行.您可能首先希望能够在屏幕上显示一些文本(研究其他现有的自由软件OS的操作方式!).如果您从自由软件项目中获取一些代码,请确保遵守其许可证.

Think about OS design (scheduler & multitasking, persistency, process isolation, system calls). So read a lot. Look into existing projects (Pliant, HURD, NewOS, Haiku, Tunes -inactive but interesting- ...) You won't be able to implement many features, so work progressively. You probably want first to be able to display some text on your screen (study how other existing free software OSes are doing that!). If you take some code from a free software project, be sure to respect its license.

玩得开心,要有耐心.也许和一个好朋友一起工作是值得的(因为即使是一个很小的操作系统,对于一个人来说也是一个巨大的项目). 答案与您的动机有关.

Have fun and be patient. Perhaps working with a good friend might be worthwhile (since even a tiny OS is a huge project for a single person). This answer is related to your motivations.

这篇关于构建我的ASM X86 OS,从哪里开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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