Real mode:(that is, real address access mode) It is an operating mode for Intel Corporation 80286 and later x86 (80386,80486 and 80586) compatible processors (CPUs) . Real mode is specifically defined as 20-bit address memory accessible space, which means that its capacity is 2 of the 20 power (1M) of the accessible memory space (physical memory and Bios-rom), the software through these addresses directly access to the BIOS program and peripheral hardware. Real-mode processors do not have hardware-level memory protection concepts and multi-tasking operation modes. But for backwards compatibility, the 80286 and later x86 series compatible processors are still working in real mode when booting up . 80186 and earlier processors had only one mode of operation, which was the real pattern we defined later. Although the real mode can access the address space of 1M, but because of the BIOS mapping function (that is, the BIOS occupies a portion of the Space Address resources ), so the real can use the physical memory space (memory bar), that is, between 640k to 924k . The composition of the 1M address space consists of a 16-bit segment address and a 16-bit offset address within the segment. The equation is expressed as: Physical address = Left 4-bit segment address + offset address.
286 Processor architecture introduces the concept of address protection mode , which allows the processor to make hardware-level protection settings for memory and some other peripheral devices (Protection settings are essentially blocking access to some addresses ). the use of these new features, however, is essential for some additional operating procedures that are not available in the 80186 and prior processors. Since the initial x86 microprocessor specifications, it is completely backwards compatible with the development of the program, the 80286 chip is made to inherit the characteristics of the previous version of the chip, working in real mode, in this mode is actually turned off the new protection features , so can Keep the previous software up and working under the new chip . Until today, even the newest x86 processors are working in real mode when the computer is power-up, and it can run programs written for the previous processor chip.
DOS operating systems (such as ms-dos,dr-dos) work in real mode, the earlier version of Microsoft Windows (which is essentially a graphical user interface application running on DOS, actually not an operating system in itself) is also running in real mode, Until Windows3.0, it runs in both real-mode and protected mode, so it is a mixed-mode operation. Its protection mode operates in two different ways (since 80286 does not fully implement the 80386 and later protection mode functions):
1〉 "Standard protection mode": This is the program running in protected mode;
2〉 "virtual protected mode (essentially real mode, protected mode modeled on Real mode)": It also uses 32-bit address addressing. Windows3.1 has completely removed support for real mode. After the 80286 processor chip, Windows3.1 became the mainstream operating system (windows/80286 is not a mainstream product). At present, almost all X86 series processor operating systems (LINUX,WINDOWS95 and LATER,OS/2, etc.) are configured at boot time to enter the protection mode.
protection mode: often abbreviated to P-mode, in the Intel iAPX 286 Programmer's Reference manual (iAPX 286 is another term for Intel 80286) It is also known as the virtual address protection mode . The virtual address protection mode has been proposed in the Intel 80286 manual, but in fact it is only a guideline and the true 32-bit address appears on Intel 80386. The protection mode itself is a mode of operation after 80286 and later compatible processor sequences, it has many features designed to improve the system's multi-channel tasks and system stability. For example, memory protection, paging mechanism, and hardware virtual storage support. The modern majority of x86 processor operating systems are run in protected mode, including Linux, free BSD, and Windows 3.0 (which also runs in real mode for compatibility with Windows 2.x applications) and later versions.
80286 and later the processor another mode of operation is real mode (only when the system starts for a moment), the principle of backward compatibility to shield the protection mode features, allowing the old software to run on the new chip. As a design specification, all x86 series processors, in addition to the embedded Intel80387, are system-initiated to work in real mode, ensuring that legacy operating systems are backwards compatible. All of them must be reset by the startup program (the operating system program is running the code) and go into protected mode before any of the protected mode features are invalid. In modern computers, this type of matching into protected mode is one of the most cutting-edge actions when operating system starts.
In a multi-tasking program that is mediated, it is possible to work from the new to real mode. The nature of the protection mode is to prevent the operation of an already unhealthy program from being broken by another task or system kernel, and the protection mode also has the support of hardware, such as interrupting the program, moving the document of running process to another process and the protection function of the empty multi-task.
386 and later series of processors not only has a protection mode and 32-bit registers, resulting in a confusion of processing functions, because 80286 supports the protection mode, but its register is 16-bit, it is programmed by its own program to simulate 32-bit, not 32-bit register processing. Attributed to this confusion, it prompted the windows/386 and later versions to completely abandon the 80286 virtual protection mode, the later protected mode operating system is running above 80386, no longer run at 80286 (although the 80286 mode supports protected mode), So say 80286 is a transition chip, it is a transition product.
If you want to access more memory, you must enter protected mode.
the difference between real mode and protected mode: on the surface, there is not much difference between protected mode and real mode, both of which use memory segments, interrupts, and device drivers to handle hardware, but there are many differences. We know that in real mode memory is divided into segments, each segment size is 64KB, and such a segment address can be represented by 16 bits. the processing of the memory segments is handled by the internal mechanisms associated with the segment registers, which form part of the physical address, which is the contents of CS, DS, SS, and Es. Specifically, the final physical address consists of a 16-bit segment address and a 16-bit offset address within the segment. The equation is expressed as: Physical address = Left 4-bit segment address + offset address.
in protected mode, the segment is defined by a series of tables called "Descriptor Table". segment Registers store pointers to these tables. There are two types of tables used to define memory segments: The Global Descriptor Table (GDT) and the Local Descriptor List (LDT). A GDT is an array of segment descriptors that contains the basic descriptors that all applications can use. In real mode, the section length is fixed (64KB), while in protected mode, the section segment is variable and can be up to 4GB. The LDT is also an array of segment descriptors. Unlike GDT, the LDT is a segment that holds local, non-global shared segment descriptors. Each operating system must define a GDT, and each running task will have a corresponding LDT. The length of each descriptor is 8 bytes, as shown in Format 3. When the segment register is loaded, the Subgrade address is obtained from the corresponding table entry. The contents of the descriptor are stored in a programmer's Invisible Image Register (shadow register) so that the next time the same segment can use the information without having to fetch it every time. The physical address consists of a 16-bit or 32-bit offset plus a base address in the image register.
Real-mode and protected mode under Linux