|
不点
银牌会员
     不甘寂寞的人
积分 2491
发帖 1115
注册 2003-9-24
状态 离线
|
『楼 主』:
关于 GRUB for DOS/Linux 回复 wengier 兄
使用 LLM 解释/回答一下
私人短信系统限制 500 字符,一不小心就会丢失输入的内容。我已经丢失多次了。所以改在这里回复,放心一些。
====== 在 2003-10-19 2:26:51 您来信中写道: ======
我想问一下,GRUB for Linux可以在纯Linux甚至X-Window的Linux窗口(Linux termin)下本地运行,而且可以随时用quit命令退出GRUB而回到Linux命令行下,那为什么不如真正使用DOS下的编译器来将GRUB移植到DOS环境下,成为一个本地化的DOS软件而提高兼容性和适应性呢?
=====================================
确实,在决定开发 grub for dos 之前,我曾经在 http://www.google.com/ 上搜索 grub.exe, 搜索到了有关的网页,但有些关键的网页打不开,想用 GOOGLE 的网页缓存,这个,在中国大陆已经被禁止了,所以很多珍贵的资料不能见到。
但是也搜索到了少数有关 grub.exe 的网页,这些都是 GNU GRUB 的 bug 跟踪网页,是一些信件。从这些信件中略微知道 grub for dos 这个目标曾经有人努力去做过,但是,似乎觉得没有了下文。其中也有人指出,用 gnu grub 在 DOS/Windows 平台进行直接编译的问题。但是,好像没有人去直接编译,或者也可能是虽然编译了,但未成功。
当我进一步考虑这个问题的时候,我发现,即使编译成功,也没有太大意义。为什么呢?看看 Linux 下的 grub shell 就知道了。这个 GRUB SHELL 只能用来安装 GRUB,测试 GRUB 的一些命令,但是不能用来从 LINUX 下直接 boot 到另外一个操作系统。几乎所有的 GRUB 命令,都可以在 LINUX 的 GRUB SHELL 下执行,但 boot 命令除外。试想,如果像这样来实现 GRUB for DOS ,那有什么意义呢?
Linux 下之所以不能用 GRUB 的 boot 命令,最根本的原因是,在 Linux 下无法回到实模式并执行一段用户设定的程序。在 LINUX 下,只有 reboot 和 halt 命令可以回到实模式,但是,它们是用途固定的,用户不能控制进入实模式之后的其它行为,例如在进入实模式后想立即执行 grub 的 stage2,这是不行的。
因此,在 DOS 下,我选择了对 DOS 进行 HACK 的方法,将 GRUB FOR DOS 予以实现。HACK 的目的是恢复 DOS 所修改了的 BIOS 中断向量。
这次不像在 LINUX 那样。因为在实模式的 DOS 下,我们可以进行任何编程,不会受到限制(这就是实模式的好处)。而 LINUX 和 Windows 的环境,是有很多限制的,它们都用到 CPU 的保护模式,拒绝执行某些指令,它们都没有已知的系统调用,来回到实模式,因此,在这些操作系统之上,都无法运行 grub 的 boot 命令。
GRUB 的 boot 命令可以引导任意的操作系统,引导这些操作系统所必须的一个条件是,CPU 处于实模式。因为历史上所有的操作系统都是设计成从实模式下启动的。电脑一开机就处于实模式的 CPU 状态。
因为对 DOS 进行了 HACK,所以,GRUB 能够在 DOS 下运行。这使得 GRUB for DOS 大概是(目前)唯一一个可以从某个操作系统(本例是从 DOS 命令行)内部来启动运行、并能引导任何操作系统的多重引导管理器。通常的情况是,当一个操作系统启动完成之后,就不能进入到另外一个操作系统了(除非重新启动机器)。【这里说的是”真实机器”的情况,不包括”虚拟机”里面的”操作系统”。】
Private messaging system limits 500 characters, and I've lost input content by accident many times. So I'm replying here, which makes me feel more at ease.
====== In your letter on 2003-10-19 2:26:51, you wrote: ======
I want to ask, GRUB for Linux can run locally in pure Linux or even in the Linux window (Linux termin) of X-Window Linux, and you can always use the quit command to exit GRUB and return to the Linux command line. Then why not really use the compiler under DOS to port GRUB to the DOS environment to become a localized DOS software to improve compatibility and adaptability?
=====================================
Indeed, before deciding to develop grub for dos, I once searched for grub.exe on http://www.google.com/, and found relevant web pages, but some key web pages couldn't be opened. I wanted to use GOOGLE's web cache, but this has been prohibited in mainland China, so many precious materials can't be seen.
But I also found a few web pages about grub.exe, which are all bug tracking web pages of GNU GRUB, some letters. From these letters, I slightly knew that the goal of grub for dos was once worked on by someone, but it seemed that there was no follow-up. Among them, some people pointed out the problems of directly compiling GNU GRUB on the DOS/Windows platform. But it seems that no one directly compiled it, or maybe although it was compiled, it wasn't successful.
When I further considered this problem, I found that even if it was successfully compiled, it didn't make much sense. Why? Just look at the GRUB shell under Linux. This GRUB SHELL can only be used to install GRUB and test some commands of GRUB, but it can't be used to directly boot to another operating system from under Linux. Almost all GRUB commands can be executed under the GRUB SHELL of Linux, except the boot command. Imagine, if we implement GRUB for DOS like this, what's the meaning?
The most fundamental reason why the boot command of GRUB can't be used under Linux is that under Linux, it's impossible to return to real mode and execute a user-set program. Under LINUX, only the reboot and halt commands can return to real mode, but they are fixed in use, and the user can't control other behaviors after entering real mode. For example, it's not possible to immediately execute stage2 of grub after entering real mode.
Therefore, under DOS, I chose the method of HACKING DOS to implement GRUB FOR DOS. The purpose of HACK is to restore the BIOS interrupt vectors modified by DOS.
This is different from under Linux. Because under real-mode DOS, we can program freely without restrictions (this is the benefit of real mode). While the environments of LINUX and Windows have many restrictions. They all use the protected mode of CPU, refuse to execute certain instructions, and they don't have known system calls to return to real mode. Therefore, on top of these operating systems, the boot command of grub can't run.
The boot command of GRUB can boot any operating system. A necessary condition to boot these operating systems is that the CPU is in real mode. Because all operating systems in history are designed to start from real mode. The CPU of the computer is in real mode when it starts up.
Because DOS has been HACKED, GRUB can run under DOS. This makes GRUB for DOS probably (currently) the only multi-boot manager that can start running from within an operating system (in this case, from the DOS command line) and can boot any operating system. Usually, after one operating system is started, you can't enter another operating system (unless you restart the machine).
|

因为我们亲手创建,这个世界更加美丽。 |
|
2003-10-19 00:00 |
|
|
Wengier
系统支持
             “新DOS时代”站长
积分 27736
发帖 10521
注册 2002-10-9
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
那BasicLinux、386Minux、BeOS或ROM-DOS 7.10中的ROMDOS.EXE等,也可以直接从DOS命令行下直接启动相应的操作系统内核,而且即使在有VCPI内存时的V86模式(EMM386)下也可以启动呢。请问为什么GRUB for DOS不能做到这点呢?
Then BasicLinux, 386Minux, BeOS, or ROMDOS.EXE in ROM-DOS 7.10, etc., can also directly start the corresponding operating system kernel from the DOS command line, and even can start in V86 mode (EMM386) when there is VCPI memory. Then why can't GRUB for DOS do this?
|

Wengier - 新DOS时代
欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
http://wendos.mycool.net/
E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)
 |
|
2003-10-19 00:00 |
|
|
不点
银牌会员
     不甘寂寞的人
积分 2491
发帖 1115
注册 2003-9-24
状态 离线
|
『第 3 楼』:
关于 GRUB for DOS/Linux 回复 wengier 兄
使用 LLM 解释/回答一下
你说的这几种东东,我都没有接触过,不知道它们工作的方式。
有 EMM386 存在,不等于 CPU 处于 VM86 模式。检测 CPU 是否处于实模式,用 grub for dos 就行。当 GRUB 发送错误信息 Cannot run in protected mode 时,CPU 处于保护模式(VM86 也是一种特殊的保护模式),否则,CPU 处于实模式。
有些程序可以用来启动某个操作系统的内核,但这类程序还不能叫做“多重引导管理程序”。比如我知道 Loadlin.exe 是一个 DOS 下的程序,它可以引导 LINUX 内核,但是,它不是一个引导管理程序。它仅仅可以启动 LINUX 内核,而不能启动其它操作系统内核。操作系统一般都是从实模式启动的,我还没有发现 PC 机上从保护模式启动的操作系统。你提到的那些系统,实际上应当都是从实模式启动的。由于 LINUX 内核不再使用 BIOS,所以,LOADLIN 不需要为 LINUX 恢复 BIOS 中断向量。反之,如果要引导的操作系统内核需要用到 BIOS,那么,必须为它恢复 BIOS 的中断向量。还有一种情况,当你使用某种特殊的 DOS,而这种 DOS 根本不破坏重要的 BIOS 中断向量,那么,当然也就不用恢复了。还有,虽然某个 BIOS INT 被破坏了,但是新的内核根本不使用该 INT,这当然也没有什么问题。这些都是个别例子,它们是某个特殊用途的操作系统引导程序,不能用作一般的多重引导管理器来使用。
The things you mentioned, I haven't come into contact with any of them, and I don't know how they work.
The existence of EMM386 doesn't mean the CPU is in VM86 mode. To detect whether the CPU is in real mode, grub for dos can be used. When GRUB sends the error message "Cannot run in protected mode", the CPU is in protected mode (VM86 is also a special kind of protected mode). Otherwise, the CPU is in real mode.
Some programs can be used to boot the kernel of an operating system, but such programs can't be called "multiboot managers" yet. For example, I know that Loadlin.exe is a program under DOS, and it can boot the LINUX kernel, but it's not a boot manager. It can only boot the LINUX kernel, and can't boot the kernels of other operating systems. Operating systems generally start from real mode. I haven't found an operating system on a PC that starts from protected mode. The systems you mentioned should actually all start from real mode. Since the LINUX kernel no longer uses BIOS, LOADLIN doesn't need to restore the BIOS interrupt vectors for LINUX. On the contrary, if the operating system kernel to be booted needs to use BIOS, then the BIOS interrupt vectors must be restored for it. There is also a situation: when you use a certain special DOS, and this DOS doesn't destroy important BIOS interrupt vectors at all, then of course there's no need to restore them. Also, although a certain BIOS INT is destroyed, the new kernel doesn't use that INT at all, which is of course no problem. These are all individual examples. They are boot programs for operating systems with a special purpose and can't be used as general multiboot managers.
|

因为我们亲手创建,这个世界更加美丽。 |
|
2003-10-20 00:00 |
|
|
Wengier
系统支持
             “新DOS时代”站长
积分 27736
发帖 10521
注册 2002-10-9
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
后面说的有道理,不过前面那段话中关于V86模式和保护模式的问题,你好像没有说得很清楚。V86也说不上是“特殊的保护模式”,而是在系统先已在保护模式环境中用于虚拟86实模式的一种准模式,即介于两者之间的中间CPU模式,在386以上CPU中才有。
What you said later makes sense, but regarding the issues of V86 mode and protected mode in the previous passage, you don't seem to have explained it clearly. V86 cannot be said to be a "special protected mode", but rather a quasi-mode used for virtual 86 real mode in the protected mode environment of the system first, that is, an intermediate CPU mode between the two, and it exists in CPUs above 386.
|

Wengier - 新DOS时代
欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
http://wendos.mycool.net/
E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)
 |
|
2003-10-20 00:00 |
|
|
不点
银牌会员
     不甘寂寞的人
积分 2491
发帖 1115
注册 2003-9-24
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
vm86 模式确实在某些情况下也算做保护模式的范畴. 一个广义的保护模式, 是指当 CPU 的 PE 位设置为 1 的时候. VM86 模式的 PE 位就是 1. 所以, 在 Intel 公司的技术参考手册中, 有时候把 VM86 也说成属于保护模式了.
The VM86 mode is indeed sometimes considered to fall within the scope of protected mode in certain situations. A broad sense of protected mode means that when the PE bit of the CPU is set to 1. The PE bit in VM86 mode is 1. Therefore, in Intel's technical reference manuals, sometimes VM86 is also said to belong to protected mode.
|

因为我们亲手创建,这个世界更加美丽。 |
|
2003-10-20 00:00 |
|
|