Method for obtaining transmission GPU information based on BIOS, storage medium and device
Patent Information
- Application Number
- CN202610915108.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-24
- Publication Date
- 2026-10-09
AI Technical Summary
[0003]本发明的目的在于提供一种基于BIOS获取传输GPU信息的方法、存储介质及设备,旨在解决无法在BIOS/UEFI启动阶段查找到GPU的问题
[0013]本发明的有益效果是:即使系统未初始化完成或无法正常加载,仍然可以在BIOSSetup界面查看到GPU基本信息,减少了对操作系统的需求性,更便于客户后期的使用以及维护,即使在无操作环境下,还是可以方便快速的获取到机器上的GPU信息,实现了对信息便捷化的特性,对于问题的定位以及功能开发都有帮助。
Smart Images

Figure CN122884547A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer system operation technology, and in particular relates to a method, storage medium and device for obtaining and transmitting GPU information based on BIOS. Background Technology
[0002] Currently, the display and acquisition of GPU information depends on the operating system environment. For example, commands such as NVIDIA-SMI (NVIDIA System Management Interface) and lspci (Linux PCI device query tool) need to be called through the operating system kernel or driver layer and cannot run during the BIOS / UEFI boot stage or in an environment without an operating system. This makes it impossible to quickly identify which GPU on the server is faulty during low-level development or when a graphics card problem occurs. This is not conducive to development, debugging, and later maintenance processes, and affects work efficiency. Summary of the Invention
[0003] The purpose of this invention is to provide a method, storage medium, and device for obtaining and transmitting GPU information based on BIOS, aiming to solve the problem of not being able to find the GPU during the BIOS / UEFI boot phase.
[0004] This invention is implemented as follows: a method for obtaining and transmitting GPU information based on BIOS, the method comprising the following steps: Step S1: Pre-configure the GPU adaptation database, which stores information about various GPU devices; Step S2: When the BIOS reaches the DXE driver execution stage, it loads the complete set of HII support drivers; Step S3: While performing step S2, initialize the interface opcode resources, create start resource handles and end resource handles to define the start and end of the opcode sequence, and allocate memory for the two types of resource handles through the UEFI memory allocation mechanism. Step S4: Based on the initialized start and end resource handles, generate an extensible boot type opcode, use the boot type opcode to define the IFR data range corresponding to the GPU information, and build a unique GPU information visualization interface framework. Step S5: After creating the BIOS display interface, the data of the GPU is acquired. During the DXE stage, the BIOS will complete the enumeration of PCIe devices. After the enumeration is completed, the BIOS will fill in the information of the created interface and display it. Step S6: After the information display is complete, release all initialized opcode resource handles.
[0005] A further technical solution of the present invention is that the GPU adaptation database includes device identification code, manufacturer name and specific GPU model.
[0006] A further technical solution of the present invention is: a complete set of HII support drivers includes HII database driver, interface form driver, string driver and dynamic opcode driver.
[0007] A further technical solution of the present invention is: step S3 includes the following steps: Step S31: After loading the HII-related drivers, initialize the starting resource handle, mark the starting position of the opcode sequence, call the function to allocate memory for the starting resource handle, and judge the starting resource handle. If the starting resource handle is not NULL, the allocation is successful. If the starting resource handle is NULL, the allocation fails and the current process is terminated. Step S32: Initialize the end resource handle, mark the end position of the opcode sequence, use it in conjunction with the start resource handle to define a complete opcode block, call the function to allocate memory for the end resource handle, judge the end resource handle, if the end resource handle is not NULL, the allocation is successful, if the end resource handle is NULL, the allocation fails, release the memory resources allocated in step S31, return null value, and end the current process.
[0008] A further technical solution of the present invention is: the guiding type opcode includes a start label opcode and an end label opcode, the type is defined as an extensible opcode, the start label opcode marks the beginning of the IFR table, and the end label opcode marks the end of the IFR table.
[0009] A further technical solution of the present invention is: step S5 includes the following steps: Step S51: Using a global variable as a pointer, find the protocol handle that is mounted with EFI_PCI_IO_PROTOCOL, and represent the found protocol handle as the enumerated PCIe device; Step S52: Traverse the found protocol handles, then obtain the interface between the BIOS and GPU read / write channels from the handle array through global variables, access the PCIe configuration space through the PciIo pointer, which contains information about the PCIe device; Step S53: Based on the base class code in the PCIe class code, the hexadecimal value corresponding to the base class code of the GPU is 0x03. Determine whether the PCIe configuration space in step S52 belongs to the GPU. Step S54: Write information to the BIOS display interface, including the number of GPUs, manufacturer, model, bandwidth and speed.
[0010] A further technical solution of the present invention is: step S53 specifically includes the following steps: If the base class code is 0x03, the GPU adaptation database created in step S1 will be searched for and matched. The pointer PciIo can access the GPU device identification code of the device and compare it with the device identification code in the GPU adaptation database. If they are the same, the corresponding manufacturer and specific model will be obtained from the GPU adaptation database. If they are different, it means that no corresponding manufacturer and model have been matched and the GPU adaptation database needs to be updated.
[0011] Another object of the present invention is to provide a storage medium on which a computer program is stored, which, when executed by a processor, implements the above-described method for obtaining and transmitting GPU information based on BIOS.
[0012] Another object of the present invention is to provide a computer device, including a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the processor executes the program to implement the above-described method for obtaining and transmitting GPU information based on BIOS.
[0013] The beneficial effects of this invention are: even if the system is not fully initialized or cannot be loaded normally, the basic information of the GPU can still be viewed in the BIOSSetup interface, which reduces the need for the operating system and makes it easier for customers to use and maintain it later. Even in an environment without operation, the GPU information on the machine can still be obtained quickly and easily, realizing the characteristic of convenient information access, which is helpful for problem localization and function development. Attached Figure Description
[0014] Figure 1 This is a flowchart of the method of the present invention. Detailed Implementation
[0015] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments.
[0016] Driven by cutting-edge technologies such as artificial intelligence (AI), cloud computing, and big data, GPUs (Graphics Processing Units) have evolved from traditional graphics rendering tools into the core engine of high-performance computing. With the exponential growth in the scale of AI models (such as the trillion-parameter scale of GPT-4), the surge in demand for cloud computing resource pooling, and the stringent requirements of real-time big data analysis for parallel computing capabilities, GPUs will play an indispensable role in the future era of intelligent computing. However, in scenarios without an operating system environment or under-level hardware verification, obtaining GPU information has limitations, hindering the rapid location and resolution of problems. Therefore, obtaining GPU information based on the BIOS (Basic Input Output System) can solve this problem.
[0017] This invention is based on the fact that during the BIOS boot initialization process, the PCIe (Peripheral Component Interconnect Express) configuration space is scanned to find PCIe devices. The BIOS will then determine whether the class code of the scanned PCIe devices belongs to the graphics card device. After that, the Vendor and Devid of the identified graphics card device will be matched with the GPU adaptation database prepared in the code. Based on the matching result, an option will be created on the BIOS Setup page through the HII (Human Interface Infrastructure) in the UEFI specification to complete the display of GPU information.
[0018] This invention provides a method for obtaining and transmitting GPU information based on BIOS, the method comprising the following steps: Step S1: Pre-configure the GPU adaptation database, which stores information about various GPU devices; preferably, the GPU adaptation database includes device identification code, manufacturer name and specific GPU model.
[0019] The GPU adaptation database includes the parameters Ven_Dev_ID, Manufacture, and Description. Ven_Dev_ID is used to represent both VendorID (vendor identifier) and DeviceID (device identifier), Manufacture represents the manufacturer, and Description represents the specific model of the GPU.
[0020] Step S2: When the BIOS reaches the DXE driver execution stage, it loads the complete set of HII support drivers; Preferably, the complete set of HII support drivers includes HII database driver, interface form driver, string driver and dynamic opcode driver.
[0021] After powering on, the BIOS loads relevant HII drivers during the DXE (Driver Execution Environment) stage, such as the HII Database Driver, Form, String, and Operation Code drivers, to support the dynamic generation and management of the Setup interface.
[0022] Step S3: While performing step S2, initialize the interface opcode resources, create start resource handles and end resource handles to define the start and end of the opcode sequence, and allocate memory for the two types of resource handles through the UEFI memory allocation mechanism. Preferably, step S3 includes the following steps: Step S31: After loading the HII-related drivers, initialize the starting resource handle, mark the starting position of the opcode sequence, call the function to allocate memory for the starting resource handle, and judge the starting resource handle. If the starting resource handle is not NULL, the allocation is successful. If the starting resource handle is NULL, the allocation fails and the current process is terminated. Step S32: Initialize the end resource handle, mark the end position of the opcode sequence, use it in conjunction with the start resource handle to define a complete opcode block, call the function to allocate memory for the end resource handle, judge the end resource handle, if the end resource handle is not NULL, the allocation is successful, if the end resource handle is NULL, the allocation fails, release the memory resources allocated in step S31, return null value, and end the current process.
[0023] At this stage, the UpdateGPUSetupString function is called to obtain GPU information and display it in the BIOS Setup interface. The specific process is as follows: After loading the HII-related drivers, HiiAllocateOpCodeHandle is called to initialize the Opcode handle (an identifier used to identify certain objects and manage resources), i.e., the starting resource handle StartOpCodeHandle. HiiAllocateOpCodeHandle is a function in the HII (Human Interface Infrastructure) library of UEFI, used to dynamically create an empty IFR opcode buffer. HiiAllocateOpCodeHandle uses AllocatePool() (UEFI's memory allocation function) to allocate memory, and checks the starting resource handle StartOpCodeHandle. If the starting resource handle StartOpCodeHandle is not NULL, the allocation is successful; if the starting resource handle StartOpCodeHandle is NULL, it means the allocation failed, and the UpdateGPUSetupString function (UpdateGPUSetupString is a function in the BIOS specifically responsible for refreshing the graphics card information to the settings interface in real time) returns an empty value, ending the function. Next, the end resource handle EndOpCodeHandle is initialized using HiiAllocateOpCodeHandle to mark the end position of the opcode sequence. It is used in conjunction with the start resource handle StartOpCodeHandle to define a complete opcode block (such as a form). If HiiAllocateOpCodeHandle fails to allocate memory to the end resource handle EndOpCodeHandle, the memory resources allocated in step S31 are released using HiiFreeOpCodeHandle (HiiFreeOpCodeHandle is a release function in the library that releases the opcode buffer memory), and a null value is returned, ending the function.
[0024] Step S4: Based on the initialized start and end resource handles, generate an extensible boot type opcode, use the boot type opcode to define the IFR data range corresponding to the GPU information, and build a unique GPU information visualization interface framework. The HiiCreateGuidOpCode function creates GUID type opcodes in the start and end resource handles StartOpCodeHandle and EndOpCodeHandle. StartLabel and EndLabel are defined as start and end label opcodes, and then the type is defined as ExtendLabelOpCode (extendable opcode). StartLabel marks the beginning of the IFR (IFR is a binary encoding for HII-related objects) table (GPU_SET_LABEL_BEGIN); EndLabel marks the end of the IFR table (GPU_SET_LABEL_END).
[0025] Step S5: After creating the BIOS display interface, the data of the GPU is acquired. During the DXE stage, the BIOS will complete the enumeration of PCIe devices. After the enumeration is completed, the BIOS will fill in the information of the created interface and display it. Preferably, step S5 includes the following steps: Step S51: Using a global variable as a pointer, find the protocol handle that is mounted with EFI_PCI_IO_PROTOCOL, and represent the found protocol handle as the enumerated PCIe device; Step S52: Traverse the found protocol handles, then obtain the interface between the BIOS and GPU read / write channels from the handle array through global variables, access the PCIe configuration space through the PciIo pointer, which contains information about the PCIe device; Step S53: Based on the base class code in the PCIe class code, the hexadecimal value corresponding to the base class code of the GPU is 0x03. Determine whether the PCIe configuration space in step S52 belongs to the GPU. Step S54: Write information to the BIOS display interface, including the number of GPUs, manufacturer, model, bandwidth and speed.
[0026] Preferably, step S53 specifically includes the following steps: If the base class code is 0x03, the GPU adaptation database created in step S1 will be searched for and matched. The pointer PciIo can access the GPU device identification code of the device and compare it with the device identification code in the GPU adaptation database. If they are the same, the corresponding manufacturer and specific model will be obtained from the GPU adaptation database. If they are different, it means that no corresponding manufacturer and model have been matched and the GPU adaptation database needs to be updated.
[0027] After creating the BIOS Setup interface, the GPU data is acquired. During the DXE stage, the BIOS enumerates the PCIe devices. After enumeration, the BIOS fills in the information in the created interface. The specific process is as follows: The function LocateHandleBuffer (which searches for protocol handles that meet specific conditions) in gBS (a global variable that represents a pointer to the UEFI Boot Services Table, which provides various services) finds the protocol handles that implement EFI_PCI_IO_PROTOCOL and represents these handles as enumerated PCIe devices. Then, these handles are traversed, that is, the PCIe devices are traversed. The HandleProtocol is called through gBS. The HandleProtocol can obtain the EfiPciIoProtocol (BIOS and GPU read / write channel) interface from the handle array in step S51, and then access the PCIe Configuration Space through the specified PciIo pointer. This space contains information such as the PCIe device's VendorID, DeviceID, and Width. According to the Base ClassCode (basic class code, which defines the main functional category of the device) in the PCIe ClassCode (class code, used to identify the type, subtype and programming interface of the device), the GPU belongs to the Display Controller, and its BaseClasscode corresponds to the hexadecimal value 0x03. Based on the BaseClasscode, it can be determined whether the PCIe device in step S52 belongs to the GPU. If BaseClassCode is 0x03, a search and match is performed using the GPU compatibility database created in step S1 via SysGraphicsTableSearch. The pointer PciIo can access the Vendor and DeviceID parameters of the GPU connected to the machine, which are compared with the Ven_Dev_ID parameter in the GPU compatibility database. If they match, the corresponding manufacturer and specific model are retrieved from the GPU compatibility database. If they do not match, it means that no matching manufacturer and model were found, and the GPU compatibility database needs to be updated.
[0028] The UpdateTokenValue function writes information to the created GPU information display interface, including the number of GPUs, manufacturer, model, bandwidth, and speed. The number of GPUs can be obtained by iterating through the GPUs, the manufacturer and model can be obtained from the GPU adaptation database, and the bandwidth and speed can be obtained by accessing the configuration space via PCIo.
[0029] Step S6: After the information display is completed, release all initialized opcode resource handles in a unified manner; preferably, the bootstrap type opcode includes a start label opcode and an end label opcode, the type is defined as an extensible opcode, the start label opcode marks the beginning of the IFR table, and the end label opcode marks the end of the IFR table; After filling all the acquired information into the GPU display interface, release the previously allocated OpcodeHandle by calling HiiFreeOpCodeHandle to release StartOpCodeHandle and EndOpCodeHandle.
[0030] The present invention also provides a storage medium storing a computer program thereon, which, when executed by a processor, implements the above-described method for obtaining and transmitting GPU information based on BIOS.
[0031] The present invention also provides a computer device, including a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the processor executes the program to implement the above-described method for obtaining and transmitting GPU information based on BIOS.
[0032] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for obtaining and transmitting GPU information based on BIOS, characterized in that, The method includes the following steps: Step S1: Pre-configure the GPU adaptation database, which stores information about various GPU devices; Step S2: When the BIOS reaches the DXE driver execution stage, it loads the complete set of HII support drivers; Step S3: While performing step S2, initialize the interface opcode resources, create start resource handles and end resource handles to define the start and end of the opcode sequence, and allocate memory for the two types of resource handles through the UEFI memory allocation mechanism. Step S4: Based on the initialized start and end resource handles, generate an extensible boot type opcode, use the boot type opcode to define the IFR data range corresponding to the GPU information, and build a unique GPU information visualization interface framework. Step S5: After creating the BIOS display interface, the data of the GPU is acquired. During the DXE stage, the BIOS will complete the enumeration of PCIe devices. After the enumeration is completed, the BIOS will fill in the information of the created interface and display it. Step S6: After the information display is complete, release all initialized opcode resource handles.
2. The method for obtaining and transmitting GPU information based on BIOS according to claim 1, characterized in that, The GPU compatibility database contains device identification codes, manufacturer names, and specific GPU models.
3. The method for obtaining and transmitting GPU information based on BIOS according to claim 1, characterized in that, The complete set of HII support drivers includes HII database driver, interface form driver, string driver, and dynamic opcode driver.
4. The method for obtaining and transmitting GPU information based on BIOS according to claim 1, characterized in that, Step S3 includes the following steps: Step S31: After loading the HII-related drivers, initialize the starting resource handle, mark the starting position of the opcode sequence, call the function to allocate memory for the starting resource handle, and judge the starting resource handle. If the starting resource handle is not NULL, the allocation is successful. If the starting resource handle is NULL, the allocation fails and the current process is terminated. Step S32: Initialize the end resource handle, mark the end position of the opcode sequence, use it in conjunction with the start resource handle to define a complete opcode block, call the function to allocate memory for the end resource handle, judge the end resource handle, if the end resource handle is not NULL, the allocation is successful, if the end resource handle is NULL, the allocation fails, release the memory resources allocated in step S31, return null value, and end the current process.
5. The method for obtaining and transmitting GPU information based on BIOS according to claim 1, characterized in that, The type-guided opcode includes a start-label opcode and an end-label opcode. The type is defined as an extensible opcode. The start-label opcode marks the beginning of the IFR table, and the end-label opcode marks the end of the IFR table.
6. The method for obtaining and transmitting GPU information based on BIOS according to claim 1, characterized in that, Step S5 includes the following steps: Step S51: Using a global variable as a pointer, find the protocol handle that is mounted with EFI_PCI_IO_PROTOCOL, and represent the found protocol handle as the enumerated PCIe device; Step S52: Traverse the found protocol handles, then obtain the interface between the BIOS and GPU read / write channels from the handle array through global variables, access the PCIe configuration space through the PciIo pointer, which contains information about the PCIe device; Step S53: Based on the base class code in the PCIe class code, the hexadecimal value corresponding to the base class code of the GPU is 0x03. Determine whether the PCIe configuration space in step S52 belongs to the GPU. Step S54: Write information to the BIOS display interface, including the number of GPUs, manufacturer, model, bandwidth and speed.
7. The method for obtaining and transmitting GPU information based on BIOS according to claim 6, characterized in that, Step S53 specifically includes the following steps: If the base class code is 0x03, the GPU adaptation database created in step S1 will be searched for and matched. The pointer PciIo can access the GPU device identification code of the device and compare it with the device identification code in the GPU adaptation database. If they are the same, the corresponding manufacturer and specific model will be obtained from the GPU adaptation database. If they are different, it means that no corresponding manufacturer and model have been matched and the GPU adaptation database needs to be updated.
8. A storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method for obtaining and transmitting GPU information based on BIOS as described in any one of claims 1 to 7.
9. A computer device, comprising a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, characterized in that, When the processor executes the program, it implements the method for obtaining and transmitting GPU information based on BIOS as described in any one of claims 1 to 7.