Linux core-hardware Basics

Source: Internet
Author: User
Linux core-hardware basics-Linux general technology-Linux programming and kernel information. The following is a detailed description. The operating system must work closely with the basic hardware system. It requires services that can only be provided by hardware. To fully understand the Linux operating system, you must understand some hardware-related knowledge. This chapter briefly introduces the hardware: Modern PC. A revolution began when the magazine "Popular Electronics" published in January 1975 took pictures of 8080 of Altair as its cover. Altair 8080, which can be independently assembled by household appliances enthusiasts, was priced at only 397 US dollars. The 256 processor with 8080-byte memory does not have a display or keyboard, and it is negligible as it is today's standard. Its creator, Ed Roberts, invented "personal computer" to describe his new invention. But now the term PC has been used to name computers that can be carried by yourself. In this definition, very powerful computers such as Alpha AXP can also be called PCs. Enthusiastic hackers saw the great potential of Altair, so they began to write software and design hardware for it. For the early pioneers, this meant some kind of freedom, a kind of freedom freed from the stubborn super batch processing host. Many college students fascinated by the surging wealth (a computer that can be placed on a kitchen table) drop out of school. Many of the various hardware began to emerge, and software hackers were busy writing software for these new machines. What is interesting is that IBM was the first to firmly design and manufacture modern PCs and launched products in 1982. The product is constructed as follows: 8080 CPU, 64 K Bytes primary memory, two floppy disk drives, and 25 rows of 80 columns of color CGA display. Although from the current point of view those are not so advanced, but the sales at that time is very good. Then, in 1983, the IBM PC-XT with an expensive 10 MB hard drive appeared. Shortly after the ibm pc architecture became a de facto standard, many counterfeits such as COMPAQ emerged. Due to the existence of such fact standards, multiple hardware companies are fiercely competitive in this rapidly growing market. However, users benefit from low prices. Many of the structural features of early PCs remain in modern PC systems. For example, Intel's most advanced Pentium Pro processor retains the Intel 8086 addressing model. When Linus Torvalds started to write Linux, he chose Intel 80386 PC, which was the most widely used and reasonably priced at the time.. 1 typical PC motherboard. From the outside of the PC, the most striking is the chassis, keyboard, mouse and display. There are some buttons at the front of the chassis, a micro-monitor displays some numbers, and a soft drive. Most machines today also contain a cd rom. In addition, if you want to protect your data, you can add a tape drive for backup. These devices are collectively referred to as external devices. Although the CPU is the system manager, it is only a smart device. All these peripheral controllers have a certain level of intelligence, such as the IDE controller. Inside the PC, you can see a motherboard (. 1) that includes a CPU or microprocessor, primary memory, and many ISA or PCI Peripheral Controller slots ). Some controllers, such as the IDE disk controller, must be built on the system board.



 
Figure 1.1: typical PC Motherboard.
  

1.1 CPU
CPU, or microprocessor, is the core of a computer system. The microprocessor performs computing or logical operations and manages and executes commands from the primary storage. In the early age of computers, the functional components of the microprocessor were discrete components (with a large appearance ). This is the origin of the term central processing unit. Modern microprocessor combines components into an integrated circuit on a small silicon wafer. In this book, CPU and microprocessor have the same meaning. The operation object of the microprocessor is binary data, and the data is composed of 0 and 1. Values 1 and 0 correspond to the open and open states of electronic switches. Just as the decimal 42 represents four 10 and two, a binary number is composed of a series of binary numbers that represent the power of two. Binary 0001 corresponds to 1 in decimal format, binary 0010 corresponds to 2 in decimal format, binary 0011 represents 3, and binary 0100 corresponds to 4. The binary value of decimal 42 is 101010. However, in computer programs, people often use decimal to represent numbers rather than directly using binary. When binary numbers are required, hexadecimal numbers are often used. If the decimal number can only be from 0 to 9, The hexadecimal number can be diverted from 0 to 15, the numbers 10 to 15 are represented by letters A, B, C, D, E, and F, respectively. In this way, the hexadecimal 2A decimal is expressed as 42-2*16 + 10 = 42. In C programming language, the prefix of the hexadecimal number is "0x"; the hexadecimal 2A is written as 0x2A. The microprocessor can perform logical operations such as addition, multiplication, division, and "X is bigger than Y. The execution of the processor is monitored by an external clock. The system clock sends a pulse to the CPU at the same interval. The processor performs some work on each clock pulse. For example, the processor executes an instruction on each clock pulse. The processor speed is generally described at the system clock rate. A 100,000,000 MHz processor will receive ticking clocks per second. However, it is incorrect to use the clock frequency of the CPU to describe the CPU performance because they execute different commands. However, a fast clock can represent a high-performance CPU to some extent. The commands executed by the processor are very simple. For example, "read the content in memory X into Register Y ". A register is an internal storage component of a microprocessor used to store data and execute certain commands on the data. Some commands may cause the processor to stop the current job and jump to another command execution in the memory. The compact design of modern microprocessor makes it possible to execute millions or even hundreds of millions of commands per second. The command must be obtained from the memory before execution. The data to be used by the command itself must also be retrieved from the memory and placed in a proper place. The size, quantity, and type of registers in a microprocessor depend on the type of the microprocessor. Intel 80486 processor and Alpha AXP have very different registers. The most obvious difference is that Intel registers are 32 bits and Alpha AXP is 64 bits. Generally, any processor has many General registers and a small number of specialized registers. Many microprocessors have the following specific registers.

Program counter (PC)
This register contains the address for executing the next command. Each time a command is retrieved, the PC content is automatically increased.
Stack pointer (SP)
The microprocessor often needs to access the external RAM that stores temporary data. A stack is a convenient way to store temporary data. The processor provides special commands to press a value into the stack and then pop it up from the stack. Stack later in the first-in-first-out (LIFO) mode. In other words, if you press two values X and Y and then execute the stack action, you will get the value of Y. Some processor stacks grow down from the top of the memory, but some vice versa. However, some processors support both methods, such as ARM.

Processor status (PS)
The command execution result is obtained. For example, "is the content in register X greater than that in register Y? "The result is correct or incorrect. The PS register contains the information and other information about the current state of the processor. For example, most processors have at least two execution modes: core (or canonicalized) and user mode. The PS register contains information about the current execution method.

1.2 memory
All computer systems have a hierarchical structure consisting of memory of different speeds and sizes. The fastest memory is high-speed cache, which is used to store content in the primary storage. This memory is very fast but very expensive, and most processors have a small amount of on-chip high-speed cache or put it on the motherboard. Some processor caches contain both data and commands, but some split them into two parts. The Alpha AXP processor has two internal caches, one for caching data (D-Cache) and the other for caching commands (I-Cache ). The external high-speed Cache (B-Cache) combines the two. In this way, the primary storage is very slow relative to the external high-speed cache memory. The cache must be consistent with the content in the primary storage. In other words, if the data at the same location of the address space is cached in the cache, the content must be consistent with that in the primary storage. Hardware and operating systems share the work to ensure high-speed cache consistency. This is why hardware and software in the system must work closely together.

Bus 1.3
Separate components on the motherboard are connected through a line called bus. The functions of the system bus are logically divided into three parts: Address Bus, data bus, and control bus. The address bus specifies the memory location (Address) for data transmission ). The data bus contains transmitted data. The data bus is bidirectional. It allows reading data into the CPU and reading data from the CPU. The control bus contains several control signals that indicate the route time and system. Of course, there are other bus, such as ISA and PCI bus, which are commonly used to connect peripherals to the system.

1.4 controller and peripherals
Peripherals are some physical devices, such as image cards or disks, which are controlled by the control chip located in the motherboard or on the motherboard slot. The IDE disk is controlled by the IDE controller chip, while the SCSI disk is controlled by the SCSI disk controller chip. These controllers connect to the CPU or interconnect with each other through various bus. Most systems currently manufactured use PCI and ISA bus to connect to major system components. The controller is a CPU-like processor, which can be seen as a smart helper for the CPU. CPU is the overall control of the system. Although all these controllers are different, their register functions are similar. The software running on the CPU must be able to read or write these control registers. One register may contain a status code indicating an error. The other is used for control purposes to change the running mode of the controller. Each controller on the bus can be individually addressed by the CPU, Which is why software device drivers can write registers and control these controllers.

1.5 address space
The system bus connects the CPU and the primary memory, and isolates the CPU from the bus connected to the system hardware peripherals. Generally, the primary storage space of hardware peripherals is called I/O space. I/O space can be further subdivided, but we will not go into it here. The CPU can access both the system memory and the I/O memory, while the controller can only indirectly access the system memory with the assistance of the CPU. From the device's point of view, for example, a floppy controller can only see the control registers on the ISA bus rather than the system memory. A typical CPU uses different commands to access memory and I/O space. For example, there may be a command "reading the content of I/O address 0x3F0 into Register X ". This is exactly how the hardware device of the CPU control system reads and writes the peripheral registers in the I/O address space. Registers on general peripherals (IDE controller, serial port, floppy disk controller, etc.) in the I/O space have remained unchanged after years of PC architecture development. I/O address space 0x3f0 is one of the control registers of the serial port (COM1. Sometimes the controller needs to read and write a large amount of data directly from the system's primary storage. For example, when a user writes data to a hard disk. In this case, the Direct Memory Access (DMA) controller will be used to allow hardware peripherals to directly access the system's primary memory, but this will be under strict CPU monitoring.

Clock 1.6
All operating systems must obtain the current time accurately, so modern PCs contain a special peripherals called real-time clock (RTC ). It provides two services: reliable date and time and precise time interval. RTC has its own battery so that it can work even when the PC loses power, which is why the PC always "knows" the correct time and date. The time interval timer enables the operating system to schedule tasks accurately.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.