Introduction to windows system programming, the different layers of the operating system

Tip: This article mainly introduces the basic concepts of windows programming and related materials


foreword

 The reference book is "Windows Programming" (5th Edition, Collector's Edition) authored by Chares Petzold, translated by Fang Min and others.

 32-bit operating system and 64-bit operating system, as well as 32-bit software and 64-bit software, among which 32 and 64 correspond to the concept of CPU, that is, the bit length that the CPU can process digits at a time.


一、DOS,BIOS,Windows

1.1 DOS

The DOS system is the mainstream operating system before the appearance of windows, that is, there is no interface. To display images on the screen, the user has to deal with the hardware by himself. The command-line programming interface under Windows is similar to DOS, but not DOS.

1.2 What is the BIOS system?

 BIOS is a set of programs solidified on a ROM chip on the motherboard of the computer. It stores the basic input and output programs of the computer, the self-test program after power-on and the system self-start program. It can read and write the specific information of the system settings from the CMOS. .
1. The BIOS checks the device itself, and then transfers the control to the operating system;
2. When the BIOS checks the memory, it checks the high-end memory to see if there is any damage;
3. Yes, and then the operating system takes over the control of the memory;
4. 、BIOS does not have a device driver, it just recognizes the device, and the operating system itself has a device driver
Reference link:
https://baike.baidu.com/item/bios/91424?fr=aladdin
https://bbs.csdn. net/topics/40419107

1.2 What is the Windows SDK?

 Windows SDK programming means using the software develope kit (software development kit) under windows for programming, such as Visual Studio or Visual C++. In terms of objects, it actually uses tools to call API library I functions for programming.
Reference link: https://blog.csdn.net/weixin_42466951/article/details/80789644

2. The bottom layer, driver, and application layer in the operating system

2.1 What is the bottom layer

 For the operating system, the bottom layer is the kernel Kernel, which is responsible for dealing with hardware

2.2 What is a driver

 A device driver, or driver for short, is a program that allows high-level computer software to interact with hardware. This program creates a hardware-to-hardware, or hardware-to-hardware, The interface that communicates with the software is a mechanism that forms a connection with the hardware via the bus on the motherboard or other communication subsystems. Such a mechanism makes it possible to exchange data on the hardware device.

 According to different computer architectures and different operating system platforms, the driver can be 8-bit (8-bit), 16-bit (16-bit), 32-bit (32-bit), or even the latest 64-bit (64-bit) , this is to reconcile the dependency between the operating system and the driver. For example, in the 16-bit operating system era of Windows 3.11, most of the drivers are 16-bit, and most of the drivers are 32-bit when it comes to 32-bit Windows XP. Driver (Microsoft provides Windows Driver Model to implement driver), as for 64-bit Linux or Windows Vista platform, you must use 64-bit driver (WDM and WDF can both implement 64-bit driver).

Driver Development
 The development of drivers is very challenging, because it must cooperate with fairly clear and advanced platform technologies in hardware and software. Since most device drivers run in kernel mode, software errors often cause serious system instability, such as blue screens, which are similar to programs in user mode in the past There are significant differences in design (eg Delphi, VB, Java).


 In order to reduce the burden of driver developers on the Windows platform, Microsoft has continuously improved the driver development software and architecture, from the early complex and obscure VxD to the Windows Driver Model (hereinafter referred to as WDM) development architecture on Windows XP. Today, Windows Driver Foundation (hereinafter referred to as WDF) has become a new generation of Windows platform driver development framework. This framework greatly simplifies the driver development process and better matches the object-oriented spirit. This framework includes User Mode Driver Framework and Kernel Mode Driver Framework Two development modes. Before developing the driver on the Windows platform, the DDK (Driver Development Kit) must be installed first. The DDK package supports both WDM and WDF architectures.

There are three basic types of devices under Linux
 : character devices, block devices, and network interfaces.

Application of Drivers
Because of common hardware and operating system differences, drivers exist in different ways. Used for:
Printers
Graphics cards
Network cards
Sound cards
Different kinds of buses
Different kinds of low-bandwidth I/O buses (such as pointing devices: mouse, keyboard, USB, etc.)
Hard drive buses (ATA, SCSI)
implement support for different file systems Support
Realize support for scanners and digital cameras

Common levels of abstraction for drivers :
In terms of hardware layer:
Direct connection (Interfacing directly)
uses some higher-level interface (such as: video BIOS)
uses another low-level driver (such as file system driver uses disk driver)
to simulate hardware work

In terms of software layer:
Allow the operating system to directly access hardware resources
Implement only its original style (primitives) Implement a higher-level language
for non-driver software interfaces (such as TWAIN) , such as PostScript virtual device drivers  have a special The driver is called a virtual device driver (virtual device drivers), which can be used in virtualization environments (virtualization environments). For example, if a DOS program is to run on a Windows platform, it must use this virtual device driver, such as VMware It is a kind of "virtual PC" software that can run two or more Windows, DOS, and LINUX systems on one machine at the same time. VMWare truly realizes "simultaneous" operation. platform, switching is as easy as standard Windows applications.


2.3 What is the application layer

Application layer programming is all about developing applications. Windows SDK is an example


3. The underlying driver and application program of the single-chip microcomputer

There are only two layers  of MCU program development without an operating system : the underlying driver and the application layer.
 The application program is a program written according to the actual application requirements, referring to the logic part of the code, which directly calls the interface reserved by the underlying driver, without caring about the implementation method and implementation process of the underlying hardware.
 The underlying development of single-chip microcomputer generally refers to the software and hardware development of the control function completed by using the inherent resources of the single-chip microcomputer, such as clock, communication protocol (232, 485, UART, SPI, IIC, CAN, IR, etc.), timer, AD conversion, GPIO, external Set drive (various on-site control, measurement and control of various environmental conditions, motor control, solenoid valve, relay control, keyboard scanning, LED and LCD display), etc.
 The underlying driver is related to the hardware. To write the underlying driver, you must understand the hardware very well, and at the same time provide the application layer with API function call interfaces. The application layer can access the hardware by calling these interfaces without knowing the specific hardware working conditions.

Reference link:
https://www.baidu.com/link?url=mvljwDvot9Gnp7MJLN98ZhA2c4Pkb_naEqzr-RRB2xOqlw_vVXziiigWJIEy5da7WMXrMXyLaMTyXjn-KYrQ8fmdOwuhWarXUeGEtlyhgnG&wd=&eqid=b ecd879c000103290000000560e8134a

Guess you like

Origin blog.csdn.net/weixin_41605297/article/details/118445575