Dynamic memory allocation method and device, storage medium and product

The system firmware manages the memory allocation pointer of the network card device, which solves the problem of the failure of iPXE memory allocation during the boot stage, ensures that memory resources are updated, avoids memory leaks, and improves the success rate of operating system installation.

CN119003188AActive Publication Date: 2024-11-22INSPUR SUZHOU INTELLIGENT TECH CO LTD

Patent Information

Application Number
CN202411487409.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-23
Publication Date
2024-11-22
Estimated Expiration
2044-10-23

AI Technical Summary

Technical Problem

Under certain conditions, iPXE may experience memory allocation failure during the boot phase, resulting in the operating system installation failure.

Method used

The system firmware obtains the resource allocation pointer in the target data structure of the network card device. If it is empty, apply for memory. If it is not empty, read and judge the memory validity. If it is invalid, clear and reapply memory to ensure that the network card device Memory resource update.

Benefits of technology

It effectively avoids memory leakage problems, ensures that the memory resources of network card devices remain updated, and improves the success rate of operating system installation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119003188A_ABST
    Figure CN119003188A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a dynamic memory allocation method and device, a storage medium and a product, and relates to the technical field of memory resources, the method comprises the following steps: in response to a resource allocation instruction for a first network card device, obtaining a target data structure body corresponding to the first network card device through system firmware, and extracting a resource allocation pointer from the target data structure body; if the resource allocation pointer is a null pointer, applying for a first memory for the first network card device through the system firmware according to the resource allocation instruction, and writing the first memory information into the resource allocation pointer; if the pointer is not the null pointer, reading second memory information in the resource allocation pointer, and obtaining a second memory corresponding to the second memory information; and if the second memory is the invalid memory, clearing the second memory information through the system firmware, applying for the first memory for the network card equipment according to the resource allocation instruction, and writing the first memory information into the resource allocation pointer. The memory resources of the network card equipment are updated in time according to the resource allocation pointer, and memory allocation conflicts are avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of memory resource technology, and in particular to a memory dynamic allocation method, device, storage medium and product. Background Art

[0002] PXE (Preboot Execution Environment) is a network boot technology that allows a computer to boot an operating system from a server over the network. iPXE (Intelligent Platform Management Interface Extensions) is an enhanced version of PXE that supports more efficient network booting. It obtains the boot file address through DHCP, then downloads and executes the boot file to install the operating system.

[0003] IPXE is an open-source PXE boot loader widely used in scenarios such as diskless workstations, remote installation, and automated operating system deployment. Currently, PXE and iPXE are primarily used for network booting and operating system installation. However, during the IPXE operating system installation process, installation failures may occur due to various factors, including but not limited to network problems, hard disk read / write errors, boot file corruption, incomplete operating system images, and compatibility issues. Under specific conditions (such as using certain versions of RHEL and specific hardware configurations), iPXE may experience memory allocation failures during the boot phase, resulting in operating system installation failure. Summary of the Invention

[0004] The purpose of the embodiments of the present invention is to provide a method, device, storage medium, and product for dynamically allocating memory to solve the problem of memory allocation failure during the iPXE boot phase under certain conditions, resulting in system installation failure. The specific technical solution is as follows: In a first aspect of an embodiment of the present invention, a method for dynamically allocating memory is provided, which is applied to system firmware. The method includes: In response to a resource allocation instruction for a first network card device, obtaining a target data structure corresponding to the first network card device through the system firmware, and extracting a resource allocation pointer from the target data structure; If the resource allocation pointer is a null pointer, applying for a first memory for the first network card device according to the resource allocation instruction through the system firmware, obtaining first memory information of the first memory, and writing the first memory information into the resource allocation pointer; If the resource allocation pointer is not a null pointer, reading the second memory information in the resource allocation pointer through the system firmware, and obtaining the second memory corresponding to the second memory information; If the second memory is invalid memory, the second memory information is cleared by the system firmware, the first memory is applied for the network card device according to the resource allocation instruction, and the first memory information is written into the resource allocation pointer.

[0005] Optionally, the system firmware includes an initialization driver. Before responding to the resource allocation instruction for the first network card device, obtaining a target data structure related to the first network card device, and extracting a resource allocation pointer from the target data structure, the method further includes: Searching, by the system firmware, from the driver code of the initialization driver, a target data structure corresponding to the first network card device, wherein the target data structure is used to initialize the expansion bridge; Setting a resource allocation pointer in the target data structure, wherein the resource allocation pointer includes memory information of the first network card device; The resource allocation pointer is initialized to a null pointer by the initialization driver.

[0006] Optionally, initializing the resource allocation pointer to a null pointer by the initialization driver includes: Obtaining the initialization function of the expansion bridge through the initialization driver; At the beginning of the initialization function, a pointer initialization instruction for initializing the resource allocation pointer is set; In response to the initialization of the expansion bridge, the pointer initialization instruction is executed by the initialization driver, so that the resource allocation pointer is initialized to a null pointer.

[0007] Optionally, before searching the target data structure corresponding to the first network card device from the driver code of the initialization driver through the system firmware, the method further includes: Acquire all connected devices connected to the bus through the system firmware; Taking any one of the connected devices as a target connected device, and identifying a device class code of the target connected device; If the device class code matches the preset network card device code, confirming that the target connection device is a second network card device; The target device link where the second network card device is located is obtained through the system firmware, and a corresponding resource allocation pointer is set for each network card device in the target device link.

[0008] Optionally, obtaining, through the system firmware, a target device link where the second network card device is located, and setting a corresponding resource allocation pointer for each network card device in the target device link includes: Obtaining configuration information of the second network card device through the system firmware; Generate a device record of the second network card device and the configuration information, and extract a device address of a parent device of the second network card device from the configuration information; Updating the second network card device to the parent device, and returning to the step of obtaining the configuration information of the second network card device until the address information of the root port is extracted from the configuration information; A target device link where the second network card device is located is generated based on the plurality of second network card devices in the device record and the root port.

[0009] Optionally, generating a device record of the second network card device and the configuration information, and extracting a device address of a parent device of the second network card device from the configuration information includes: Generate the device record, wherein the device record is used to record the second network card device and configuration information; If the configuration information includes the identifier of the root port, extracting the address information of the root port from the configuration information by the system firmware; If the configuration information does not include the identifier of the root port, the system firmware extracts the device address of the parent device from the configuration information based on the configuration information and the bridge relationship.

[0010] Optionally, if the second memory is invalid memory, clearing the second memory information by the system firmware, applying for the first memory for the network card device according to the resource allocation instruction, and writing the first memory information into the resource allocation pointer, the method further includes: Acquire a first network status of the first network card device through the system firmware; If the first network status indicates that the first network card device is not connected, a third network card device is obtained and resources are allocated to the third network card device, where the third network card device is the next network card device of the first network card device.

[0011] Optionally, obtaining the first network status of the first network card device through the system firmware includes: Detecting the network cable connection status or network communication status of the first network card device; If the network cable of the first network card device is not connected, or the network is not accessible, the first network state is characterized as the first network card device being disconnected; If the network cable of the first network card device is connected and the network is unobstructed, the first network status is represented as the first network card device being connected.

[0012] Optionally, if the first network status indicates that the first network card device is not connected, obtaining the third network card device and allocating resources to the third network card device, and the third network card device is the next network card device of the first network card device, the method further includes: The first memory of the first network card device is released through the system firmware, and the first memory information in the resource allocation pointer corresponding to the first network card device is cleared.

[0013] Optionally, if the resource allocation pointer is a null pointer, applying for a first memory for the first network card device according to the resource allocation instruction by the system firmware, obtaining first memory information of the first memory, and writing the first memory information into the resource allocation pointer includes: If the value of the resource allocation pointer is null, confirming that the resource allocation pointer is a null pointer; extracting, by the system firmware, first memory information of the first memory from the resource allocation instruction, the first memory information including memory type, memory size, and memory address; Apply for the first memory for the first network card device according to the first memory information through the system firmware, and write the first memory information into the resource allocation pointer.

[0014] Optionally, if the resource allocation pointer is not a null pointer, reading, by the system firmware, the second memory information in the resource allocation pointer and obtaining the second memory corresponding to the second memory information includes: If the resource allocation pointer is not a null pointer, reading the second memory information in the resource allocation pointer through the system firmware; Obtaining a second memory corresponding to the second memory information, and using a memory detection tool to confirm whether the second memory is invalid; If the second memory is invalid, confirming that the second memory is invalid memory; If the second memory is not invalid, then the second memory is confirmed to be a valid memory.

[0015] Optionally, after reading, by the system firmware, the second memory information in the resource allocation pointer if the resource allocation pointer is not a null pointer and obtaining the second memory corresponding to the second memory information, the method further includes: If the second memory is a valid memory, the first network card device is used as a target network card device, and the target network card device is used to boot and install an operating system.

[0016] In a second aspect of an embodiment of the present invention, a dynamic memory allocation device is provided, which is applied to system firmware. The device includes: an allocation pointer extraction module, configured to, in response to a resource allocation instruction for a first network card device, obtain a target data structure corresponding to the first network card device through the system firmware, and extract a resource allocation pointer from the target data structure; a memory information allocation module, configured to, if the resource allocation pointer is a null pointer, apply for a first memory for the first network card device according to the resource allocation instruction through the system firmware, obtain first memory information of the first memory, and write the first memory information into the resource allocation pointer; a memory information reading module, which reads the second memory information in the resource allocation pointer through the system firmware if the resource allocation pointer is not a null pointer, and obtains the second memory corresponding to the second memory information; A memory information reallocation module is configured to clear the second memory information through the system firmware if the second memory is invalid memory, apply for the first memory for the network card device according to the resource allocation instruction, and write the first memory information into the resource allocation pointer.

[0017] In the third aspect of the embodiments of the present invention, an electronic device is also provided, including: one or more processors; a memory; and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute any of the above-mentioned dynamic memory allocation methods.

[0018] In a fourth aspect of an embodiment of the present invention, a non-volatile readable storage medium is further provided. When instructions in the non-volatile readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute any of the above-mentioned dynamic memory allocation methods.

[0019] In a fifth aspect of the embodiments of the present invention, a computer program product is further provided, including a computer program / instruction, which implements any of the above-mentioned dynamic memory allocation methods when executed by a processor.

[0020] The dynamic memory allocation method provided by an embodiment of the present invention responds to a resource allocation instruction for a first network card device, obtains a target data structure corresponding to the first network card device through system firmware, and extracts a resource allocation pointer from the target data structure; if the resource allocation pointer is a null pointer, applies for a first memory for the first network card device according to the resource allocation instruction through the system firmware, obtains first memory information of the first memory, and writes the first memory information into the resource allocation pointer; if the resource allocation pointer is not a null pointer, reads second memory information in the resource allocation pointer through the system firmware, and obtains second memory corresponding to the second memory information; if the second memory is invalid memory, clears the second memory information through the system firmware, applies for the first memory for the network card device according to the resource allocation instruction, and writes the first memory information into the resource allocation pointer. The present invention obtains a data structure corresponding to a network card device through system firmware, confirms the memory allocation status of the network card device according to a resource allocation pointer preset in the data structure, and further reads memory information in the network card device to judge the existing memory of the network card device. Thus, based on the memory allocation status of the network card device, it is decided whether to apply for memory for the network card device or clear the memory and then apply again during the current polling process, thereby ensuring that the memory resources of the network card device are kept updated. By improving the system firmware, optimizing the Polling mechanism, confirming the memory allocation status of the network card device, and checking the memory occupied by each network card device, the memory leakage problem caused by the continuous memory occupation of the unconnected network card device can be effectively avoided.

[0021] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0023] Figure 1 This is a flowchart of a method for dynamically allocating memory provided by an embodiment of the present invention; Figure 2 This is a schematic diagram of an example of a dynamic memory allocation method provided by an embodiment of the present invention; Figure 3 This is a structural block diagram of a dynamic memory allocation device provided by an embodiment of the present invention; Figure 4 This is a block diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0024] To make the above-mentioned objects, features, and advantages of the present invention more clearly understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0025] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention, some technical features involved in the embodiments of the present invention are explained and illustrated below: The Basic Input / Output System (BIOS) is the first software component loaded when a computer starts. It is primarily responsible for initializing the computer's hardware components. During computer startup, it performs key tasks such as initializing hardware devices, performing a self-test (POST, Power-On Self-Test), loading the operating system, and loading the operating system's boot loader.

[0026] PXE (Preboot eXecution Environment) is a network boot technology that allows a computer to download and boot an operating system or perform other tasks from a remote server over the network without having to boot from a local hard disk.

[0027] iPXE (Intel PXE Boot ROM open source version) is an open-source network boot firmware. It is an enhanced version of PXE that allows users to boot operating systems, virtual machines, containers, and more over the network. It provides more flexible and powerful features than traditional PXE, including network booting, disk image deployment, and script execution.

[0028] PCI (Peripheral Component Interconnect) is a local bus standard used to connect computer motherboards and external devices (such as graphics cards, sound cards, and network cards). The PCI bus standard allows high-speed data transmission between expansion slots on a computer motherboard and peripheral devices via the bus.

[0029] PCIe (PCI Express) is a high-speed serial computer expansion bus standard used to connect internal computer devices such as graphics cards, network cards, and storage devices. PCIe has higher bandwidth and lower latency than the traditional PCI bus.

[0030] DHCP (Dynamic Host Configuration Protocol) is a network protocol used to automatically assign network configuration information, such as IP address, subnet mask, gateway, and DNS server, to client devices. When a device connects to a network, it sends a DHCP request to obtain this configuration information.

[0031] In computer systems, a bridge is a hardware device or software component used to connect two different networks or systems, enabling them to communicate with each other. In PCI / PCIE systems, bridges play a crucial role, connecting different PCI / PCIE devices and buses.

[0032] In a PCI / PCIE system, an end device is a terminal device connected to the PCI / PCIE bus. These devices are typically functional devices, such as network cards, graphics cards, and storage controllers. End devices are the final nodes in a PCI / PCIE system. They connect to the system bus through a bridge and communicate directly with the CPU and other devices.

[0033] Initrd (Initial RAM Disk, temporary file system) is usually used during the Linux system startup process. The main function of Initrd is to provide the necessary drivers and file system support when the kernel starts until the root file system is mounted.

[0034] In computer networks and hardware, polling refers to a polling mechanism used to periodically check the status of a device or interface. Specifically, polling means that the system or driver periodically queries the device's status or data to ensure that the device is working properly or obtain the latest status information.

[0035] For example, the network card on a client host initiates an iPXE boot. The iPXE boot process sends a DHCP request to the server. Upon receiving the DHCP request, the server returns the address of the iPXE boot file to the client. Upon receiving the address, the client downloads the file from the server and executes it. During the IPXE boot process, IPXE sequentially checks each network interface in the system to determine which one can be used for network booting. The conditions for a network interface to be available are: allocated memory and a network connection. Failure to allocate memory resources for the network interface can cause the system installation to fail.

[0036] In this regard, in an embodiment of the present invention, in response to a resource allocation instruction for the first network card device, the target data structure corresponding to the first network card device is obtained through the system firmware, the resource allocation pointer is extracted from the target data structure, the memory allocation status of the first network card device is judged according to the resource allocation pointer, and it is decided to allocate memory or clear and reallocate memory for the current first network port device, thereby ensuring that the memory of the network port device is updated and effectively avoiding memory leakage problems.

[0037] Reference Figure 1 , shows a flowchart of a method for dynamically allocating memory provided in an embodiment of the present invention, wherein the method for dynamically allocating memory is applied to system firmware and may specifically include the following steps: Step 101: In response to a resource allocation instruction for a first network card device, a target data structure corresponding to the first network card device is obtained through system firmware, and a resource allocation pointer is extracted from the target data structure.

[0038] During the IPXE boot process, the client computer can use the DHCP protocol to poll the network interface card (NIC) port to obtain an IP address and other configuration information. Each network interface card (NIC) port can be considered a different logical NIC device, or NIC device. The DHCP server responds to the request and provides the necessary configuration parameters, such as the IP address, subnet mask, default gateway, and DNS server.

[0039] During the polling process for each network card device, memory must first be allocated for the device. After preparing the memory for iPXE startup, the network status of the device is further inquired. This is not detailed in the present invention. The resource allocation pointer is a memory space resource descriptor pointer pre-set within a data structure. It is typically used to indicate the allocation of resources such as memory, I / O ports, and interrupts for a device (such as a network card). The resource allocation pointer contains various necessary attribute information for the memory space resource, such as the type, starting address, ending address, and size of the memory resource. Optionally, the data structure can be obtained from the BIOS function implementation code.

[0040] When a resource allocation instruction for a first network card device is received, a target data structure corresponding to the network card device is obtained from the function implementation code through the system firmware. Further, a resource allocation pointer corresponding to the network card device is extracted from the target data structure, wherein each data structure is provided with a resource allocation pointer. After determining the target data structure corresponding to the first network card setting, the resource allocation pointer can be directly extracted from the target data structure without further screening. The first network card device can represent the current network card device in the polling process. Optionally, in an embodiment of the present invention, the system firmware can be BIOS firmware.

[0041] In a possible example, the system firmware further includes an initialization driver. Before obtaining the resource allocation pointer in response to the resource allocation instruction, the resource allocation pointer is set by the following method. Before step 101, the following method is further included: Searching, by the system firmware, for a target data structure corresponding to the first network card device from a driver code of the initialization driver, the target data structure being used to initialize the expansion bridge; Setting a resource allocation pointer in the target data structure, where the resource allocation pointer includes memory information of the first network card device; Initialize the resource allocation pointer to a null pointer by initializing the driver.

[0042] Optionally, the data structure is defined in the BIOS's functional implementation code. Typically, there is a dedicated data structure in the functional implementation code to describe the properties of the PCI / PCIE Root Bridge. The PCI / PCIE Root Bridge is responsible for managing communication between the CPU and PCI / PCIE devices and is the entry point to the PCI / PCIE system. For example, during the initialization process of the system firmware, i.e., the BIOS, an initialization driver is responsible for initializing the PCI / PCIE system topology and devices. This driver identifies each PCI / PCIE Root Bridge, intermediate Bridge, and EndDevice in the system and performs corresponding register configuration, resource allocation, and driver loading. The initialization driver can also be used to perform actions such as PXE initialization, memory allocation, and enumeration.

[0043] Among them, when initializing the PCI / PCIE Bridge, the PCI_ROOT_BRG_DATA data structure will be used. The variable X can be set in the data structure by initializing the driver to obtain the resource allocation pointer corresponding to the network card device. The variable X set in the data structure is a memory space resource descriptor pointer of type QWORD. QWORD is used to describe a data type, representing 64-bit data.

[0044] Preferably, the initialization driver is configured with multiple data structures corresponding to multiple network card devices. There is a one-to-one correspondence between the data structures and the network card devices. That is, the number of data structures matches the number of network card devices. Each data structure is configured with a resource allocation pointer, so that each network card device corresponds one-to-one to the data structure, and further, the network card device corresponds one-to-one to the resource allocation pointer in the data structure. By setting the variable X in the data structure, the resource allocation pointer for each network card device is obtained, allowing the BIOS to more effectively manage memory resources in the PCI / PCIE system and avoid IPXE boot failures caused by insufficient memory resources.

[0045] After successfully setting the resource allocation pointer, the resource allocation pointer can be initialized to a null pointer through the initialization driver to receive subsequent memory resource allocation information. Specifically, initializing the resource allocation pointer to a null pointer can be achieved through the initialization instruction in the initialization function. In the BIOS driver code, you can find the initialization function corresponding to the expansion bridge (such as PCI / PCIEBridge), also known as the driver entry function. This function is usually used to initialize the configuration and resource allocation of the expansion bridge. An initialization instruction can be set at the starting position of the initialization function to initialize the resource allocation pointer to a null pointer (NULL). In this way, whenever the initialization function of the expansion bridge is called and the expansion bridge is initialized, the pointer initialization instruction inserted in the initialization function is also executed. The resource allocation pointer is initialized to a null pointer by initializing the driver, thereby ensuring that the resource allocation pointer does not point to any memory address before resource allocation, avoiding potential problems in memory resource management.

[0046] In one possible implementation, since the present invention solves the problem of the PXE installation system of the network card port, the operation target is also limited to the network card device. According to actual needs, the system firmware can filter out the network card device from all PCI devices based on the device class code defined in the PCI / PCIE specification, and perform the above-mentioned resource allocation pointer setting for the network card device. Specifically, it can be performed through the following steps: Get all connected devices connected to the bus through the system firmware; Taking any one of the connected devices as a target connected device, and identifying the device class code of the target connected device; If the device class code matches the preset network card device code, then the target connection device is confirmed to be the second network card device; The target device link where the second network card device is located is obtained through the system firmware, and a corresponding resource allocation pointer is set for each network card device in the target device link.

[0047] Optionally, the system firmware can scan all buses in the system and identify all PCI / PCIE devices connected to the bus. By reading the configuration space of each device, the device class code, bus number, device number, function number and other information of the device can be obtained.

[0048] In PCI / PCIE systems, the device class code (Class Code) is a key field used to identify the device type and function. Each PCI / PCIE device has a unique device class code that describes the device's category, subcategory, and programming interface. The device class code is typically stored in the device's configuration space for use by the BIOS and operating system. The device class code typically consists of three bytes: a base class code, which identifies the basic category of the device, such as a storage controller, network controller, or multimedia device; a subclass code, which identifies the specific subcategory of the device, such as an IDE controller, SCSI controller, or Ethernet controller; and a programming interface, which identifies the device's programming interface and is used to further refine the device's functions and features.

[0049] Table 1: Correspondence between base class code and device type description in device class code

[0050] As shown in Table 1, when the base class code is 0x02, it can be determined that the device is an Ethernet controller, that is, a network card device. By matching the device class code by the system firmware, the network card device can be screened out from all PCI devices. Furthermore, starting from the second network card device obtained by screening, the target device link where the second network card device is located can be obtained, wherein the second network card device is the network card device obtained by matching the device class code.

[0051] In the PCI / PCIE system, the ownership relationship between devices and Bridges is described by bus numbers, device numbers, and function numbers. In order to obtain the network card terminal device and all levels of Bridge in its PCI / PCIE link, up to the root port RootPort, to form a complete PCIE link, specifically, the configuration information of the second network card device can be obtained. The configuration information may include its bus number, device number, function number, etc. The device address of the parent device of the second network card device is extracted from the configuration information. For example, the device address of the parent device is usually stored in a specific register in the configuration space of the network card device. By reading the value of the specific register, the parent device of the second network card device can be obtained; at the same time, in order to keep records, the second network card device and the configuration information of the second network card device are recorded by the generated device record; after the record is generated, the second network card device is updated to the parent device. device, and returns to the step of obtaining the configuration information of the second network card device, and iteratively executes the steps of obtaining the parent device, using the parent device as the second network card device, and then obtaining the parent device again, until the address information of the root port is extracted from the configuration information, indicating that the current second network card device is connected to the root port and no longer has a parent device, that is, the starting point of the device link is obtained, and the loop ends; since a device record is generated for each obtained second network card device in advance, the "first second network card device" and multiple parent devices can be found by generating the record. Therefore, based on the multiple second network card devices and root ports in the device record, the target device link where the second network card device is located can be generated in series, and the target device link includes the root port, the second network card device and the parent device of each level.

[0052] In most operating systems, you can use command-line tools in the system firmware (such as ifconfig, ip addr, and ethtool in Linux, or ipconfig and netsh in Windows) to view the network card configuration information. This information typically includes the network card's IP address, subnet mask, and gateway address. Based on this configuration information, you can also obtain the address of the parent device.

[0053] Optionally, in the process of iteratively obtaining the parent device, the identifier in the configuration information can be used to determine whether the upper level of the second network card device is a parent device or a root port. Specifically, a device record can be generated to record the second network card device and the configuration information corresponding to the second network card device. By extracting the configuration information, it is confirmed whether the configuration information contains the identifier of the root port. If the configuration information contains the identifier of the root port, it indicates that the second network card device is connected to the root port and there is no upper-level parent device. The address information of the root port is extracted from the configuration information; if the configuration information does not contain the identifier of the root port, it indicates that the second network card device is connected to the parent device. Based on the configuration information and the bridging relationship, the device address of the parent device is extracted from the configuration information, and the parent device is further obtained based on the device address of the parent device, and the loop continues.

[0054] Step 102: If the resource allocation pointer is a null pointer, the system firmware applies for a first memory for the first network card device according to the resource allocation instruction, obtains first memory information of the first memory, and writes the first memory information into the resource allocation pointer.

[0055] Step 103: If the resource allocation pointer is not a null pointer, the system firmware reads the second memory information in the resource allocation pointer and obtains the second memory corresponding to the second memory information.

[0056] During the polling process of the network card port, the network card device currently being queried needs to first allocate memory, prepare the memory, and then detect the network connection. If the memory allocation is successful and the network is connected, PXE is started by the current network port. If the memory allocation fails or the network is not connected, the PXE startup step is skipped and the next network card port is queried. Among them, the network card device can also be understood as the logical device of the network card port.

[0057] Illustratively, during the memory resource allocation process, by checking the value of the resource allocation pointer, the memory allocation status of the first network card device can be confirmed, and further confirmation can be made as to whether it is necessary to apply for the first memory for the first network card device to prepare for memory. Optionally, if the resource allocation pointer is a null pointer, this indicates that memory has not yet been allocated for the first network card device during the current resource allocation process. For example, during system startup or initialization, the resource allocation pointer may be initialized to a null pointer, indicating that memory allocation has not yet occurred. Alternatively, during a previous memory allocation process, memory allocation may have failed due to some reason (e.g., insufficient memory), resulting in the resource allocation pointer remaining a null pointer.

[0058] In this case, it is necessary to apply for memory for the first network card device according to the resource allocation instruction through the system firmware, and write the memory information into the resource allocation pointer. Specifically, the pointer status can be confirmed by the value of the resource allocation pointer. For example, when the resource allocation pointer is empty, it indicates that the resource allocation pointer is a null pointer (NULL). It is necessary to apply for memory for the first network card device. The first memory information of the first memory can be extracted from the resource allocation instruction, wherein the first memory information may include a variety of necessary memory information such as memory type, memory size, memory address, etc. According to the extracted first memory information, the first memory is applied for the first network card device through the memory management function provided by the BIOS. After applying for the memory, the memory information of the first memory is obtained, including the memory address, size, etc., and the first memory information is written into the resource allocation pointer to ensure that the resource allocation pointer is no longer a null pointer, indicating that the memory has been successfully allocated.

[0059] If the resource allocation pointer is not a null pointer, this typically means that memory has already been allocated to the first network card device and that the resource allocation pointer contains the corresponding memory information. For example, during a previous resource allocation process, the system firmware successfully allocated memory resources to the first network card device and stored the memory information in the resource allocation pointer. In this case, it is necessary to obtain the existing memory of the first network card device and further determine whether memory resources need to be allocated to the first network card device again.

[0060] Specifically, the existing memory of the first network card device can be further judged through the following steps: If the resource allocation pointer is not a null pointer, reading the second memory information in the resource allocation pointer through the system firmware; Obtaining a second memory corresponding to the second memory information, and using a memory detection tool to confirm whether the second memory is invalid; If the second memory is invalid, confirming that the second memory is invalid memory; If the second memory is not invalid, the second memory is confirmed to be a valid memory.

[0061] In the driver code of the initialization driver, if the resource allocation pointer corresponding to the first network card device is not a null pointer, it indicates that the first network card device has been allocated memory resources. In order to determine the existing memory status of the first network card device, it is necessary to obtain the existing memory of the first network card device. Optionally, the second memory information can be read from the resource allocation pointer, including the memory address and size of the existing memory, and the second memory corresponding to the second memory information can be obtained to confirm the validity of the second memory. The validity of the second memory can be confirmed by the memory detection tool in the system firmware, or by running a stress test, checking the system log, etc. The validity of the second memory can be quickly confirmed by existing means, which will not be elaborated again in the present invention. The second memory is the existing memory of the first network card device.

[0062] By checking whether the resource allocation pointer is null, it can be determined whether memory needs to be allocated for the first network interface card device. If the pointer is null, the memory request is made, the memory information is obtained, and this information is written to the resource allocation pointer. If the pointer is not null, the memory information in the resource allocation pointer is read and the corresponding memory is obtained. This ensures that memory resources are correctly allocated and managed during the resource allocation process, avoiding system problems caused by insufficient memory resources.

[0063] Step 104: If the second memory is invalid memory, the system firmware clears the second memory information, applies for the first memory for the network card device according to the resource allocation instruction, and writes the first memory information into the resource allocation pointer.

[0064] When the second memory is confirmed as valid memory, it indicates that the second memory has at least no hardware failure, no data error, high stability and normal performance. In this case, the second memory can be directly used as the memory resource of the first network card device, and there is no need to apply for memory resources for the first network card device again. Optionally, based on the confirmation that the second memory is valid memory, it indicates that the memory preparation of the first network card device has been completed, and the first network card device can be used as the target network card device for booting and installing the operating system, that is, starting PXE through the first network card device to further detect the network status of the first network card device.

[0065] When the second memory is confirmed as invalid memory, it indicates that the second memory may have a memory stick hardware failure, such as circuit damage, chip damage, poor contact and other damage or defects, or there may be data errors, which cause errors in the second memory when reading and writing data, making it impossible to ensure data integrity, such as bit errors, block errors, check errors, etc. When the second memory is confirmed as invalid memory, it is necessary to clear the existing second memory and allocate new memory resources for the first network card device again. Optionally, the relevant information of the second memory can be cleared through the BIOS driver code to ensure that the first network card device no longer uses invalid memory, and the first memory information can be extracted from the resource allocation instruction. According to the first memory information, the first memory is re-applied for the network card device to ensure that the system has sufficient memory resources. After the memory is successfully applied for again, the first memory information of the first memory can be written into the resource allocation pointer to ensure that the memory resources can be correctly allocated and managed.

[0066] In a possible implementation, after completing the memory application for the first network card device and completing the memory preparation for the network card device, the network status of the network card device may be further detected. Specifically, this may be achieved through the following steps: Obtaining a first network status of a first network card device through system firmware; If the first network status indicates that the first network card device is not connected, a third network card device is obtained and resources are allocated to the third network card device.

[0067] Optionally, a network status detection request can be sent through the first network card device, and whether the first network card device is connected can be determined based on the return result of the network status detection request, thereby obtaining the network status of the first network card device. Exemplarily, the network status of the first network card device can be determined by detecting the network cable connection status, or the network communication status. Specifically, whether the network cable is connected can be detected through the hardware signal of the first network card device, wherein whether the network cable is connected refers to the connection status between the network cable and the network card device at the physical level. If the network cable is connected, it means that a physical connection is established between the network cable plug and the network port of the network card device. Since the network cable connection is the basis of network communication, data cannot be transmitted without physical connection. Therefore, when the network cable of the first network card device is in the disconnected state, it can be confirmed that the first network state of the first network card device is disconnected. At this time, PXE cannot be started through the first network card device, and it is necessary to poll the next network card device, that is, poll the third network card device, where the third network card device is the next network card device of the current first network card device; when it is confirmed that the network cable of the first network card device is in the connected state, it is necessary to further detect the network communication state. If due to network configuration errors, such as IP address conflict, gateway configuration error, etc., the network communication still cannot proceed normally when the network cable is connected, it can be confirmed that the network communication state of the first network card device is network down, and data still cannot be transmitted at this time. Therefore, when the network cable of the first network card device is in the connected state and the network communication state is network down, it can still be confirmed that the first network state of the first network card device is disconnected.

[0068] Optionally, only when the network cable of the first network card device is connected and the network configuration is correct, that is, when the network is detected to be unobstructed, can the network communication be confirmed to be normal and the first network status is connected. In this case, the first network card device can be used as the target network card device to start PXE. Therefore, during the PXE startup process, if it is detected that the server is configured with multiple network card ports (network card devices), the polling mechanism will try to obtain DHCP service through each network port to find an available network connection. This will help to automatically switch to other network ports when the current network port connection fails, so as to improve the success rate of startup. Especially in the case of a complex network environment or hardware failure, network port polling can increase the fault tolerance of the system startup and avoid startup failure due to a single network port failure.

[0069] In one example, when a client uses iPXE to install RHEL 7.6, it may experience a chance of freezing during the boot phase and receive the prompt "EFI stub: ERROR: Failed to alloc highmem for initrds". After upgrading the software version and analyzing the logs, the cause of the freezing problem was located in the memory application phase. Further analysis revealed that when the network card device driver performs the Link Up action, the memory requested is not released after each polling of the network card device status, resulting in abnormal usage of available memory. Therefore, when the polling time reaches 14 seconds, all available memory is occupied, causing IPXE to be unable to apply for available memory for Initrd. For example, the network card device driver can be an MLX driver. The Link Up action refers to the process in which the network interface card (NIC) detects that the physical link connection status becomes available (that is, the link is connected) and starts data transmission.

[0070] To address the boot phase jamming issue caused by the above-mentioned memory allocation, a memory release mechanism can be added to the MLX Driver to ensure that memory resources that are no longer in use are released after each polling. This prevents the network card port that cannot achieve PXE boot from continuously occupying the requested memory, resulting in an increasing amount of memory occupied during the polling process and less and less remaining available memory until all memory is occupied. When each network card port attempts to establish a connection, it only occupies the memory resources required to start IPXE on the current port, without accumulating the demand for memory resources, effectively avoiding downtime and installation failure caused by memory occupation.

[0071] Specifically, during the polling process, when the first network status of the currently polled first network card device is determined to be disconnected and the next network card device needs to be queried, the system firmware can release the first memory of the first network card device and clear the first memory information in the resource allocation pointer corresponding to the first network card device, ensuring that the pointer no longer points to the released memory area. The resource allocation pointer is then updated to be empty. For example, when the first network status is determined to be disconnected, the first memory can be released immediately to avoid additional memory resource usage, or the first memory can be released after a period of time to avoid data errors caused by frequent memory operations. The release of the first memory can be achieved by calling a memory release function, such as free() or a corresponding driver memory management function. By optimizing the polling mechanism, the memory of disconnected network card devices is released in a timely manner, and the memory information in the resource allocation pointer is cleared, effectively avoiding memory leaks. Combining memory pool technology with dynamic memory management strategies further improves memory usage efficiency and system stability. This embodiment of the present invention addresses the issue of memory not being released by the MLX Driver by invoking the BIOS when modifying the MLX Driver network card polling link up state. Memory is only allocated once and then reinitialized for use with each polling.

[0072] Reference Figure 2, shows a schematic diagram of an example of a dynamic memory allocation method provided by an embodiment of the present invention. After the initialization instruction is set in the initialization function, as the system starts and the hot plug action is performed, the initialization instruction is executed while the expansion bridge is initialized, so that the resource allocation pointer is initialized to a null pointer. After entering the polling process, for the first network card device currently polled, it is confirmed whether the resource allocation pointer of the first network card device is null. If the resource allocation pointer is null, it indicates that the first null device has not allocated memory. The system firmware applies for the first memory for the first network card device according to the resource allocation instruction, and further obtains the first network status of the first network card device, and detects the network connection of the first network card device. If the resource allocation pointer is not null, it indicates that the first network card device has occupied memory resources, and further detection of the occupied memory of the first network card device is required. The system firmware can read the second memory information in the resource allocation pointer and judge the validity of the second memory. If the second memory is valid memory, it indicates that the first network card device is set If the occupied memory of the device can continue to be used, the network connection status of the first network card device can be continued to be detected. If the second memory is invalid memory, it indicates that the occupied memory of the first network card device cannot continue to be used, and new memory resources need to be reallocated for the first network card device. The system firmware applies for the first memory for the first network card device according to the resource allocation instruction, thereby confirming the current memory occupation status of the first network card device by setting the resource allocation pointer of the first network card device, and keeping the first memory updated; in the process of detecting the network connection status of the network card device, if the current first network status of the first network card device is not connected, it indicates that the network cable of the first network card device is not connected or the network is not accessible, and data transmission cannot be performed normally, and the next network card device needs to be inquired. The system firmware releases the first memory of the first network card device, thereby effectively avoiding the invalid network port that cannot start iPXE from continuing to occupy memory resources, resulting in the remaining network ports being unable to apply for the required memory resources, and ultimately causing the installation system to be interrupted due to memory application failure.

[0073] The present invention obtains a data structure corresponding to a network card device through system firmware, confirms the memory allocation status of the network card device according to a resource allocation pointer preset in the data structure, and further reads memory information in the network card device to judge the existing memory of the network card device. Thus, based on the memory allocation status of the network card device, it is decided whether to apply for memory for the network card device or clear the memory and then apply again during the current polling process, thereby ensuring that the memory resources of the network card device are kept updated. By optimizing the Polling mechanism in the firmware BIOS, the memory allocation status of the network card device is confirmed, and the memory occupied by each network card device is checked, which can effectively avoid the memory leakage problem caused by the continuous memory occupation of the unconnected network card device.

[0074] It should be noted that for the sake of simplicity, the method embodiments are described as a series of actions. However, those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.

[0075] Reference Figure 3 , shows a structural block diagram of a dynamic memory allocation device provided by an embodiment of the present invention, wherein the dynamic memory allocation device is applied to system firmware and may specifically include the following modules: The allocation pointer extraction module 301 is configured to, in response to a resource allocation instruction for the first network card device, obtain a target data structure corresponding to the first network card device through the system firmware, and extract a resource allocation pointer from the target data structure; The memory information allocation module 302 is configured to, if the resource allocation pointer is a null pointer, apply for a first memory for the first network card device according to the resource allocation instruction through the system firmware, obtain first memory information of the first memory, and write the first memory information into the resource allocation pointer; The memory information reading module 303 reads the second memory information in the resource allocation pointer through the system firmware if the resource allocation pointer is not a null pointer, and obtains the second memory corresponding to the second memory information; The memory information reallocation module 304 is configured to clear the second memory information through the system firmware if the second memory is invalid memory, apply for the first memory for the network card device according to the resource allocation instruction, and write the first memory information into the resource allocation pointer.

[0076] Furthermore, the system firmware includes an initialization driver, and the dynamic memory allocation device also includes: A target structure search module is used to search for a target data structure corresponding to the first network card device from the driver code of the initialization driver through the system firmware, and the target data structure is used to initialize the expansion bridge; A resource pointer setting module, configured to set a resource allocation pointer in a target data structure, wherein the resource allocation pointer includes memory information of the first network card device; The resource pointer initialization module is used to initialize the resource allocation pointer to a null pointer by initializing the driver.

[0077] Furthermore, the resource pointer initialization module also includes: Initialization function acquisition module, used to obtain the initialization function of the expansion bridge through the initialization driver; An initialization setting module, used for setting a pointer initialization instruction for initializing a resource allocation pointer at the start position of the initialization function; The initialization instruction execution module is used for executing the pointer initialization instruction through the initialization driver in response to the initialization of the expansion bridge, so that the resource allocation pointer is initialized to a null pointer.

[0078] Furthermore, the dynamic memory allocation device also includes: A bus device acquisition module is used to acquire all connected devices connected to the bus through the system firmware; A device class identification module is used to take any one of the connected devices as a target connected device and identify the device class code of the target connected device; a network card device matching module, configured to confirm that the target connection device is a second network card device if the device class code matches a preset network card device code; The device link acquisition module is used to acquire the target device link where the second network card device is located through the system firmware, and set a corresponding resource allocation pointer for each network card device in the target device link.

[0079] Furthermore, the device link acquisition module also includes: A network card device configuration acquisition module, configured to acquire configuration information of a second network card device through system firmware; a parent device address extraction module, configured to generate a device record of the second network card device and configuration information, and extract the device address of the parent device of the second network card device from the configuration information; a parent device acquisition loop module, configured to update the second network card device to the parent device and return to the step of acquiring the configuration information of the second network card device until the address information of the root port is extracted from the configuration information; The device link generation module is used to generate a target device link where the second network card device is located based on the plurality of second network card devices and the root port in the device record.

[0080] Furthermore, the parent device address extraction module also includes: A device record generating module, configured to generate a device record, wherein the device record is used to record the second network card device and configuration information; A root port address extraction module, configured to extract the address information of the root port from the configuration information through the system firmware if the configuration information includes the identification of the root port; The parent device address extraction submodule is used to extract the device address of the parent device from the configuration information based on the configuration information and the bridge relationship through the system firmware if the configuration information does not contain the root port identifier.

[0081] Furthermore, the dynamic memory allocation device also includes: A network status confirmation module, configured to obtain a first network status of a first network card device through system firmware; The network card device polling module is used to obtain a third network card device and allocate resources to the third network card device if the first network status indicates that the first network card device is not connected. The third network card device is the next network card device of the first network card device.

[0082] Furthermore, the network status confirmation module also includes: A network status detection module, configured to detect the network cable connection status of the first network card device, or the network communication status; a network disconnection confirmation module, configured to indicate that the first network state is characterized as the first network card device being disconnected if the network cable of the first network card device is not connected or the network is not accessible; The network connection confirmation module is configured to indicate that the first network state is represented as the first network card device being connected if the network cable of the first network card device is connected and the network is unobstructed.

[0083] Furthermore, the dynamic memory allocation device also includes: The device memory release module is used to release the first memory of the first network card device through the system firmware and clear the first memory information in the resource allocation pointer corresponding to the first network card device.

[0084] Furthermore, the memory information allocation module 302 further includes: A null pointer confirmation module, configured to confirm that the resource allocation pointer is a null pointer if the value of the resource allocation pointer is null; A memory information extraction module, configured to extract first memory information of a first memory from a resource allocation instruction through system firmware, wherein the first memory information includes a memory type, a memory size, and a memory address; The first memory allocation module is configured to apply for a first memory for the first network card device according to the first memory information through the system firmware, and write the first memory information into the resource allocation pointer.

[0085] Furthermore, the memory information reading module 303 also includes: a second memory information reading module, configured to read the second memory information in the resource allocation pointer through the system firmware if the resource allocation pointer is not a null pointer; A second memory detection module is used to obtain the second memory corresponding to the second memory information and use a memory detection tool to confirm whether the second memory is invalid; an invalid memory confirmation module, configured to confirm that the second memory is invalid memory if the second memory is invalid; The valid memory confirmation module is used to confirm that the second memory is valid memory if the second memory is not invalid.

[0086] Furthermore, the dynamic memory allocation device also includes: The target network card device confirmation module is used to use the first network card device as the target network card device if the second memory is a valid memory, and the target network card device is used to boot and install the operating system.

[0087] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0088] refer to Figure 4 The embodiment of the present invention further provides an electronic device, including a processor 401, a communication interface 402, a memory 403 and a communication bus 404, wherein the processor 401, the communication interface 402 and the memory 403 communicate with each other via the communication bus 404. Memory 403, used for storing computer programs; The processor 401 is configured to execute the program stored in the memory 403 by performing the following steps: In response to a resource allocation instruction for the first network card device, obtaining a target data structure corresponding to the first network card device through the system firmware, and extracting a resource allocation pointer from the target data structure; If the resource allocation pointer is a null pointer, applying for a first memory for the first network card device according to the resource allocation instruction through the system firmware, obtaining first memory information of the first memory, and writing the first memory information into the resource allocation pointer; If the resource allocation pointer is not a null pointer, reading the second memory information in the resource allocation pointer through the system firmware, and obtaining the second memory corresponding to the second memory information; If the second memory is invalid memory, the second memory information is cleared by the system firmware, the first memory is applied for the network card device according to the resource allocation instruction, and the first memory information is written into the resource allocation pointer.

[0089] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage. Alternatively, the memory may be at least one storage device located away from the processor.

[0090] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.

[0091] The present invention also provides a non-volatile readable storage medium. When the instructions in the non-volatile readable storage medium are executed by the processor of an electronic device, the electronic device can perform the various processes of the above-mentioned embodiment of the dynamic memory allocation method and achieve the same technical effect. To avoid repetition, the above-mentioned computer-readable storage medium is not described here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0092] In another embodiment provided by the present invention, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute the dynamic memory allocation method described in any one of the above embodiments.

[0093] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.

[0094] In the description provided herein, numerous specific details are described. However, it is understood that embodiments of the present invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques are not shown in detail so as not to obscure the understanding of this description.

[0095] Through the above description of the embodiments, those skilled in the art will clearly understand that the methods of the above embodiments can be implemented using software plus the necessary general-purpose hardware platform. Of course, hardware can also be used, but in many cases the former is the more preferred implementation method. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, or optical disk) and includes a number of instructions for enabling a terminal (such as a mobile phone, computer, server, air conditioner, or network device) to execute the methods described in the various embodiments of the present invention.

[0096] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the embodiments of the present invention can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0097] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any modifications or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be based on the scope of protection of the claims.

Claims

1. A method for dynamic memory allocation, characterized in that: Applied to system firmware, the method includes: In response to a resource allocation instruction for a first network card device, obtaining a target data structure corresponding to the first network card device through the system firmware, and extracting a resource allocation pointer from the target data structure; If the resource allocation pointer is a null pointer, applying for a first memory for the first network card device according to the resource allocation instruction through the system firmware, obtaining first memory information of the first memory, and writing the first memory information into the resource allocation pointer; If the resource allocation pointer is not a null pointer, reading the second memory information in the resource allocation pointer through the system firmware, and acquiring the second memory corresponding to the second memory information; If the second memory is invalid memory, the second memory information is cleared by the system firmware, the first memory is applied for the network card device according to the resource allocation instruction, and the first memory information is written into the resource allocation pointer.

2. The method according to claim 1, characterized in that The system firmware includes an initialization driver. Before the method responds to the resource allocation instruction for the first network card device, obtains the target data structure of the first network card device, and extracts the resource allocation pointer from the target data structure, the method further includes: Searching, through the system firmware, from the driver code of the initialization driver, a target data structure corresponding to the first network card device, wherein the target data structure is used to initialize the expansion bridge; Setting a resource allocation pointer in the target data structure, wherein the resource allocation pointer includes memory information of the first network card device; The resource allocation pointer is initialized to a null pointer through the initialization driver.

3. The method according to claim 2, characterized in that Initializing the resource allocation pointer to a null pointer by the initialization driver includes: Obtaining the initialization function of the expansion bridge through the initialization driver; At the start position of the initialization function, a pointer initialization instruction for initializing the resource allocation pointer is set; In response to the initialization of the expansion bridge, the pointer initialization instruction is executed by the initialization driver, so that the resource allocation pointer is initialized to a null pointer.

4. The method according to claim 2, characterized in that: Before searching the target data structure corresponding to the first network card device from the driver code of the initialization driver through the system firmware, the method further includes: Acquire all connected devices connected to the bus through the system firmware; Taking any one of the connection devices as a target connection device, and identifying a device class code of the target connection device; If the device class code matches the preset network card device code, confirming that the target connection device is a second network card device; The target device link where the second network card device is located is obtained through the system firmware, and a corresponding resource allocation pointer is set for each network card device in the target device link.

5. The method according to claim 4, characterized in that The step of obtaining the target device link where the second network card device is located through the system firmware and setting a corresponding resource allocation pointer for each network card device in the target device link includes: Acquire the configuration information of the second network card device through the system firmware; Generate a device record of the second network card device and the configuration information, and extract a device address of a parent device of the second network card device from the configuration information; Updating the second network card device to the parent device, and returning to the step of obtaining the configuration information of the second network card device until the address information of the root port is extracted from the configuration information; A target device link where the second network card device is located is generated based on the plurality of second network card devices in the device record and the root port.

6. The method according to claim 5, characterized in that The step of generating a device record of the second network card device and the configuration information, and extracting a device address of a parent device of the second network card device from the configuration information includes: Generate the device record, where the device record is used to record the second network card device and configuration information; If the configuration information includes the identifier of the root port, extracting the address information of the root port from the configuration information by the system firmware; If the configuration information does not include the identifier of the root port, the device address of the parent device is extracted from the configuration information by the system firmware based on the configuration information and the bridge relationship.

7. The method according to claim 1, characterized in that If the second memory is invalid memory, clearing the second memory information by the system firmware, applying for the first memory for the network card device according to the resource allocation instruction, and writing the first memory information into the resource allocation pointer, the method further includes: Acquire a first network status of the first network card device through the system firmware; If the first network status indicates that the first network card device is not connected, a third network card device is obtained and resources are allocated to the third network card device, where the third network card device is the next network card device of the first network card device.

8. The method according to claim 7, characterized in that The obtaining the first network status of the first network card device through the system firmware includes: Detecting the network cable connection status or network communication status of the first network card device; If the network cable of the first network card device is not connected, or the network is not accessible, the first network state is characterized as the first network card device being not connected; If the network cable of the first network card device is connected and the network is unobstructed, the first network status is characterized as the first network card device being connected.

9. The method according to claim 7, characterized in that: After the step of acquiring the third network card device and allocating resources to the third network card device if the first network status indicates that the first network card device is not connected, and the third network card device is the next network card device of the first network card device, the method further includes: The first memory of the first network card device is released through the system firmware, and the first memory information in the resource allocation pointer corresponding to the first network card device is cleared.

10. The method according to claim 1, characterized in that If the resource allocation pointer is a null pointer, applying for a first memory for the first network card device according to the resource allocation instruction through the system firmware, obtaining first memory information of the first memory, and writing the first memory information into the resource allocation pointer, including: If the value of the resource allocation pointer is null, confirming that the resource allocation pointer is a null pointer; extracting first memory information of the first memory from the resource allocation instruction by the system firmware, wherein the first memory information includes a memory type, a memory size, and a memory address; The system firmware applies for the first memory for the first network card device according to the first memory information, and writes the first memory information into the resource allocation pointer.

11. The method according to claim 1, characterized in that: If the resource allocation pointer is not a null pointer, reading the second memory information in the resource allocation pointer through the system firmware, and acquiring the second memory corresponding to the second memory information, includes: If the resource allocation pointer is not a null pointer, reading the second memory information in the resource allocation pointer through the system firmware; Acquire a second memory corresponding to the second memory information, and use a memory detection tool to confirm whether the second memory is invalid; If the second memory is invalid, confirming that the second memory is invalid memory; If the second memory is not invalid, then the second memory is confirmed to be a valid memory.

12. The method according to claim 1, characterized in that After the step of reading the second memory information in the resource allocation pointer through the system firmware if the resource allocation pointer is not a null pointer and acquiring the second memory corresponding to the second memory information, the method further includes: If the second memory is a valid memory, the first network card device is used as a target network card device, and the target network card device is used to boot and install an operating system.

13. An electronic device comprising: one or more processors; Memory; One or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the dynamic memory allocation method described in any one of claims 1 to 12.

14. A non-volatile readable storage medium, when instructions in the non-volatile readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the dynamic memory allocation method as described in any one of claims 1 to 12.

15. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the method for dynamically allocating memory according to any one of claims 1 to 12 is implemented.

Citation Information

Patent Citations

  • Network card configuration method and resource management center

    CN105518620A

  • Equipment starting method and device and computer readable storage medium

    CN113204384A

  • Resource allocation method and device, storage medium and electronic equipment

    CN117539629A

  • Information processing method and device, electronic equipment and storage medium

    CN117687695A

  • Resource allocation method and apparatus for peripheral, server, and storage medium

    WO2024113884A1

Cited By

  • Dynamic memory allocation method, device, storage medium, and product

    WO2026086487A1