Share this

Research and Implementation of Serial Device Management in Embedded Systems

2026-04-06 03:23:53 · · #1
Introduction With the development of microelectronics technology, embedded systems are becoming increasingly powerful. Serial interfaces or devices such as UART, IrDA, USB, I2C, and SPI coexist within a single embedded system. Unified management of these devices can greatly improve the portability, usability, and development efficiency of the entire embedded system. This paper proposes a "serial management with USB" model based on research into serial device management technology in embedded systems and elaborates on the implementation process of serial device management. Serial Device Management Serial device management refers to the unified management of stream devices and interfaces such as COM, IrDA, I2C, and modem. Specifically, it involves unified management and transparent processing of serial devices through a unified upper-layer application layer interface and a lower-layer driver layer interface, thereby improving the usability and portability of the entire system. USB, as a new type of high-speed serial bus, is generally not included in serial device management in embedded operating systems due to its complexity and high speed. While this approach facilitates comprehensive management of USB hosts, USB hubs, and USB devices, the overall implementation code is large and complex. Furthermore, embedded systems typically use USB devices as the lower-level controller, rather than USB hosts and USB hubs. To address this, this paper incorporates USB device management into serial management, making access to USB devices as convenient as accessing a serial port, thus proposing a serial management model with USB. Serial Management Model with USB The entire management model consists of two layers: the upper layer is the operating system application layer interface function set, primarily consisting of unified serial stream interface functions such as OpenFile; the lower layer comprises hardware driver layer objects and functions. The serially managed device objects are defined by virtualized HWOBJ structures, and the registration and management of virtual objects are achieved through the management of the DEVICE_LIST structure. The HWOBJ structure is defined as follows: `typedef struct _HWOBJ { void *device_parent; // Pointer to the DEVICE_LIST structure unsigned short device_index; // Physical device number, pointing to the actual serial device or interface unsigned long bind_flags; // Interrupt service thread handling flags, reserved unsigned long IntID; // Specifies the interrupt type, reserved void *reserved; PHW_VTBL func_tbl; // Hardware driver function object table } HWOBJ, *PHWOBJ;` The DEVICE_LIST structure is defined as follows: `typedef struct _DEVICE_LIST { char *DllName; // Device DLL filename, reserved unsigned long NumberOf Devices; // Number of devices void *DeviceArray; // Device queue } DEVICE_LIST, *PDEVICE_LIST;` To address the high-speed buffering issue of USB, two separate circular queues are specifically employed: one for buffering USB IN data transmissions and the other for buffering USB OUT data transmissions. Implementation of Serial Management with USB To provide a user-friendly programming interface for application-layer and driver programmers, the interface functions use the same function names and parameters as the API functions provided in the Windows operating system. The entire implementation of serial management with USB includes the implementation of name resolution and application-layer interface functions, the low-level driver interface for serial devices, and the implementation of the data transmission channel between the application-layer interface functions and the low-level driver interface. Name Resolution and Application-Layer Interface Functions The main task of this layer is to implement the mapping from device files to corresponding device pointers. The main application-layer interface functions include CreateFile, OpenFile, WriteFile, ReadFile, and CloseFile. Specifically, the implementation mainly involves device name registration and device namespace management. Device name registration refers to registering the physical device file name, function operation pointers, and device namespace corresponding to the device file name through a device registry table. The device namespace refers to a unified file and device access interface table in the file system; applications access peripheral devices through special entries in the file system (device file name and device handle). Serial Device Low-Level Driver Interface Functions The serial device low-level driver interface is implemented by providing structures with function pointers as members. Each structure function pointer member corresponds to a specific hardware driver function. USB Serial Management Data Transfer Channel Since USB is a high-speed device compared to other serial devices and is a typical master-slave device, in addition to using two circular queues specifically for USB, a custom bidirectional access protocol packet is used to handle cases where the slave device actively initiates access, especially when USB is the master control device. Single-Channel Access to Serial Devices Since a serial device is abstracted as a special file at the operating system application layer, it is necessary to consider whether multiple applications can access this special file simultaneously. If simultaneous access is allowed, it is called multi-channel access; otherwise, it is called single-channel access. For simplicity, single-channel access to serial devices is implemented by recording the running status corresponding to the serial device number. Parallel Access of Multiple Devices Parallel operation of multiple different serial devices is achieved by tracking the device number and count value of the serial devices currently in operation. Data Transfer Channel The data transfer channel is shown in Figure 2. The data transmission process is roughly as follows: The program (thread) calls WriteFile or ReadFile to pass the address pointer to be sent or received and the data size to the corresponding hardware attribute table. The WriteFile or ReadFile function returns, and the application continues to run or suspends to wait for the data operation to complete (automatic completion by hardware interrupt). Finally, an interrupt returns a message to wake up the suspended program (thread). For USB devices, the data is first buffered through USB IN and OUT circular queues and then transmitted via USB interrupt. Conclusion Serial management in embedded operating systems is an important component of the operating system I/O subsystem. The serial management module introduced in this paper has been incorporated into a domestic commercial embedded operating system and applied in the SMARTPHONE project of a high-tech company in Shenzhen.
Read next

CATDOLL Hanako Hard Silicone Head

The head made from hard silicone does not have a usable oral cavity. You can choose the skin tone, eye color, and wig, ...

Articles 2026-02-22