Methods and devices for setting BIOS Setup options under an operating system
Patent Information
- Application Number
- CN202311758169.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-20
- Publication Date
- 2026-09-01
- Estimated Expiration
- 2043-12-20
AI Technical Summary
[0005]有鉴于此,本发明提供了一种操作系统下设置BIOS的Setup选项的方法及装置,能够解决现有技术中修改BIOS选项复杂的技术问题
[0033](1)本发明构建自定义的ACPI表,记录了便于设置BIOS的Setup选项的相关信息,便于更新及修改。
Smart Images

Figure CN117785300B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer firmware technology, and more specifically to a method and apparatus for setting BIOS Setup options under an operating system. Background Technology
[0002] Existing methods for modifying BIOS options involve applications directly manipulating fixed offset addresses on the SPI ROM region of the electronic device.
[0003] BIOS engineers inform application engineers of details such as the offset and length of configurable options in the SPI ROM through technical specifications and other documents. Applications in the operating system directly manipulate the SPI ROM to update the values at the agreed-upon offset addresses, thereby modifying the corresponding BIOS configuration options.
[0004] However, existing technologies describe the details of modifiable options through technical specifications. If the parameters of modifiable options change in a project, the specifications need to be updated frequently, and the application cannot automatically obtain the modifiable options on the current machine's BIOS, making the operation complex. Furthermore, existing technologies modify BIOS options by directly manipulating the SPI ROM. Since there are many types of SPI ROMs, the application needs to support reading and writing various models, increasing development difficulty. Moreover, due to the security mechanisms of some computer platforms, applications under the operating system cannot directly write to the SPI ROM, thus preventing the modification of BIOS options. Summary of the Invention
[0005] In view of this, the present invention provides a method and apparatus for setting BIOS Setup options under an operating system, which can solve the technical problem of complex modification of BIOS options in the prior art.
[0006] To solve the above-mentioned technical problems, the present invention is implemented as follows.
[0007] A method for configuring BIOS Setup options under an operating system, the method includes:
[0008] Step S1: The BIOS summarizes all modifiable Setup options and the option information corresponding to each Setup option. The option information includes the variable name of the variable corresponding to the Setup option in EFI, the globally unique identifier (GUID) of the variable, the offset value, and the length.
[0009] Step S2: The BIOS compiles a list of modifiable items, consisting of all modifiable Setup options and the option information corresponding to each Setup option, and copies the list of modifiable items to a custom ACPI table built in the BIOS.
[0010] Step S3: The BIOS reports the custom ACPI table to the operating system; wherein, before the operating system loader hands over control to the operating system, it obtains pointers to the ACPI root system description table RSDT and the extended system description table XSDT from the EFI system table. Both RSDP and XSDT have a physical pointer set after the table header pointing to the custom ACPI table, thereby reporting the custom ACPI table to the operating system.
[0011] Step S4: The application obtains the custom ACPI table through the interface provided by the operating system to obtain the list of modifiable items, and uses the Runtime Service provided by UEFI BIOS mode to transfer the information corresponding to the list of modifiable items into memory, thereby setting the BIOS Setup options.
[0012] Preferably, the custom ACPI table is created when the BIOS acquires and summarizes all modifiable options and their corresponding option information during the boot process to generate the custom ACPI table; the custom ACPI table is a leaf node of the ACPI table under the operating system.
[0013] Preferably, step S4: the application obtains the custom ACPI table through the interface provided by the operating system to obtain the list of modifiable items, including:
[0014] Step S41: The application obtains the identifier corresponding to the custom ACPI table through the interface provided by the operating system, thereby confirming that the custom ACPI table has been found;
[0015] Step S42: Obtain the list of modifiable items from the custom ACPI table based on the identifier;
[0016] Step S43: Display the modification options interface on the user interface, which is used to receive user input information for modifying the BIOS Setup options.
[0017] Preferably, step S4: using the Runtime Service provided by the UEFI BIOS mode to transfer the information corresponding to the list of modifiable items into memory, thereby setting the BIOS Setup options, includes:
[0018] Step S44: Use the GetVariable service in the Runtime Service provided by the UEFI BIOS to obtain the original value of the EFI variable from the BIOS variable area. The original value of the EFI variable is a collection of option values of a series of modifiable Setup options, used to indicate the current value of the modifiable Setup options in the BIOS. The modifiable Setup options occupy one or more bytes in the EFI variable. The EFI variable is obtained through the GetVariable service, and the parameters for obtaining the EFI variable are the variable name and the globally unique identifier (GUID) of the variable. The original value of the EFI variable is stored in memory, and at the same time, the original value of the EFI variable is displayed on the modification option interface. The variable corresponding to the original value of the EFI variable is the EFI variable corresponding to the modifiable Setup option.
[0019] Step S45: Based on the modified option interface and the original value of the variable, the user determines the target option value of the modifiable Setup option of the BIOS. The target option value is the option value of the Setup option of the BIOS set by the user, and the target option value is determined based on the optional option values of the Setup option.
[0020] Step S46: Use the GetVariable function in the Runtime Service provided by the UEFI BIOS mode to read the EFI variable corresponding to the target option value into memory, update the value of the corresponding EFI variable in memory to the target option value; write the updated EFI variable and EFI variable value back to the variable area of the BIOS through the GetVariable function, and restart the electronic device; at this time, the BIOS Setup option value set by the user takes effect.
[0021] Preferably, the custom ACPI table is stored by the BIOS in the address range of type AddressRangeACPI defined in the ACPI specification.
[0022] The present invention provides an apparatus for setting BIOS Setup options in an operating system, the apparatus comprising:
[0023] Initialization module: Configured for the BIOS to summarize all modifiable Setup options and the option information corresponding to each Setup option. The option information includes the variable name of the variable corresponding to the Setup option in EFI, the globally unique identifier (GUID) of the variable, the offset value, and the length.
[0024] Custom module: Configure the BIOS to compile a list of modifiable items, consisting of all modifiable Setup options and the option information corresponding to each Setup option, and copy the list of modifiable items to a custom ACPI table built in the BIOS;
[0025] The reporting module to the operating system is configured so that the BIOS reports the custom ACPI table to the operating system. Before the operating system loader hands over control to the operating system, it obtains pointers to the ACPI root system description table RSDT and the extended system description table XSDT from the EFI system table. Both RSDP and XSDT have a physical pointer set after the table header pointing to the custom ACPI table, thereby reporting the custom ACPI table to the operating system.
[0026] The configuration module is configured so that the application obtains the custom ACPI table through the interface provided by the operating system to obtain the list of modifiable items, and uses the Runtime Service provided by the UEFI BIOS mode to pass the information corresponding to the list of modifiable items into memory, thereby setting the BIOS Setup options.
[0027] The present invention provides a computer-readable storage medium storing a plurality of instructions; the plurality of instructions are used by a processor to load and execute the method as described above.
[0028] The present invention provides an electronic device, characterized in that the electronic device comprises:
[0029] A processor is used to execute multiple instructions;
[0030] Memory, used to store multiple instructions;
[0031] The plurality of instructions are to be stored in the memory and loaded and executed by the processor as described above.
[0032] The beneficial technical effects of this invention are as follows:
[0033] (1) The present invention constructs a custom ACPI table, which records relevant information for setting up BIOS setup options, making it easy to update and modify.
[0034] (2) The present invention reports all the details of the BIOS configuration options that can be modified to the operating system through a custom ACPI table, and the application can easily obtain this information automatically.
[0035] (3) The application program of this invention updates the EFIVariable containing the BIOS configuration options through the EFI Runtime Service, avoiding direct operation of the various types of SPI ROMs and greatly simplifying the program complexity. Furthermore, the EFI Runtime Service is a runtime service provided by the BIOS, a basic service provided by the UEFI BIOS to the operating system. That is, the SetVariable service in the EFI Runtime Service is not affected by security mechanisms such as SPI Lock. Attached Figure Description
[0036] Figure 1 This is a schematic diagram of the method for setting the BIOS Setup option under the operating system of this invention;
[0037] Figure 2 A schematic diagram illustrating the process of generating a custom ACPI table for this invention;
[0038] Figure 3 This is a schematic diagram illustrating the principle of setting the BIOS Setup option under the operating system of this invention;
[0039] Figure 4 This is a schematic diagram illustrating the process by which the application of this invention obtains a custom ACPI table and updates the BIOS Setup options under the operating system.
[0040] Figure 5 This is a schematic diagram of the device structure for setting the BIOS Setup option under the operating system of this invention. Detailed Implementation
[0041] The present invention will now be described in detail with reference to the accompanying drawings and embodiments.
[0042] like Figures 1-4 As shown, this invention proposes a method for setting BIOS Setup options under an operating system, the method comprising:
[0043] Step S1: The BIOS summarizes all modifiable Setup options and the option information corresponding to each Setup option. The option information includes the variable name of the variable corresponding to the Setup option in EFI, the globally unique identifier (GUID) of the variable, the offset value, and the length.
[0044] Step S2: The BIOS compiles a list of modifiable items, consisting of all modifiable Setup options and the option information corresponding to each Setup option, and copies the list of modifiable items to a custom ACPI table built in the BIOS.
[0045] Step S3: The BIOS reports the custom ACPI table to the operating system; wherein, before the operating system loader hands over control to the operating system, it obtains pointers to the ACPI root system description table RSDT and the extended system description table XSDT from the EFI system table. Both RSDP and XSDT have a physical pointer set after the table header pointing to the custom ACPI table, thereby reporting the custom ACPI table to the operating system.
[0046] Step S4: The application obtains the custom ACPI table through the interface provided by the operating system to obtain the list of modifiable items, and uses the Runtime Service provided by UEFI BIOS mode to transfer the information corresponding to the list of modifiable items into memory, thereby setting the BIOS Setup options.
[0047] In this embodiment, the pointers to the ACPI root system description table RSDT and the extended system description table XSDT are RSDP structures.
[0048] Furthermore, the custom ACPI table is created during the BIOS startup process, when it acquires and summarizes all modifiable options and their corresponding option information to generate the custom ACPI table; the custom ACPI table is a leaf node of the ACPI table under the operating system.
[0049] ACPI (Advanced Configuration and Power Interface) is created by the BIOS / UEFI during system startup, collecting information from various aspects of the system. It exists in the system's physical memory in a roughly tree-like organization. Specifically, the ACPI table passed from the BIOS to the operating system is a tree structure with pointers to RSDP structures as entry points, and the custom ACPI table is a leaf node in the operating system's ACPI table.
[0050] The entire ACPI table uses the RSDP (Root System Descriptor Pointer Table) as its entry point. Each non-leaf node contains pointers to other sub-tables. Each table has a header containing a signature that identifies the table, essentially serving as its ID. The header also includes checksum, version number, OEM ID, and other information. The key to finding the ACPI table is locating the pointer to the RSDP structure in memory. This pointer points to the ACPI Root System Descriptor Table (RSDT) and the Extended System Descriptor Table (XSDT). One of the physical pointers following the header of either the RSDP or XSDT (when greater than 32 bits) points to the custom ACPI table.
[0051] The custom ACPI table is stored by the BIOS within the address range of type AddressRangeACPI defined in the ACPI specification. The operating system loader, through the UEFI boot service, uses the GetMemoryMap() function to obtain the memory resources within the AddressRangeACPI address range and passes these resources to the operating system; these memory resources are not corrupted before the operating system reads the ACPI. Therefore, the list of modifiable items can be passed from the BIOS to the OS.
[0052] Further, step S4: the application obtains the custom ACPI table through the interface provided by the operating system to obtain the list of modifiable items, including:
[0053] Step S41: The application obtains the identifier corresponding to the custom ACPI table through the interface provided by the operating system, thereby confirming that the custom ACPI table has been found;
[0054] Step S42: Obtain the list of modifiable items from the custom ACPI table based on the identifier;
[0055] Step S43: Display the modification options interface on the user interface, which is used to receive user input information for modifying the BIOS Setup options.
[0056] Further, in step S4, the Runtime Service provided by the UEFI BIOS mode is used to transfer the information corresponding to the list of modifiable items into memory, thereby setting the BIOS Setup options, including:
[0057] Step S44: Use the GetVariable service in the Runtime Service provided by the UEFI BIOS to obtain the original value of the EFI variable from the BIOS variable area. The original value of the EFI variable is a collection of option values of a series of modifiable Setup options, used to indicate the current value of the modifiable Setup options in the BIOS. The modifiable Setup options occupy one or more bytes in the EFI variable. The EFI variable is obtained through the GetVariable service, and the parameters for obtaining the EFI variable are the variable name and the globally unique identifier (GUID) of the variable. The original value of the EFI variable is stored in memory, and at the same time, the original value of the EFI variable is displayed on the modification option interface. The variable corresponding to the original value of the EFI variable is the EFI variable corresponding to the modifiable Setup option.
[0058] Step S45: Based on the modified option interface and the original value of the variable, the user determines the target option value of the modifiable Setup option of the BIOS. The target option value is the option value of the Setup option of the BIOS set by the user, and the target option value is determined based on the optional option values of the Setup option.
[0059] Step S46: Use the GetVariable function in the Runtime Service provided by the UEFI BIOS mode to read the EFI variable corresponding to the target option value into memory, update the value of the corresponding EFI variable in memory to the target option value; write the updated EFI variable and EFI variable value back to the variable area of the BIOS through the GetVariable function, and restart the electronic device; at this time, the BIOS Setup option value set by the user takes effect.
[0060] In other words, the application modifies the EFI variable temporarily stored in memory based on the offset value in the description information of the modifiable item. Finally, the SetVariable service in the Runtime Service writes the EFI variable temporarily stored in memory back to the BIOS variable area, thereby setting the BIOS Setup options.
[0061] In this invention, EFI variables are structures with a fixed header format and a variable content length. For example... Figure 3 As shown in the dotted box in the lower left corner, the optional "NumLock" is stored in an EFI variable named "L"SystemSetupConfig". This EFI variable is one of the EFI variables in the EFI variable area.
[0062] The list of modifiable options is obtained through an ACPI custom table. This table contains information about the options that can be set. Taking the "NumLock" option as an example, the option information provides details such as the EFI variable name "L"SystemSetupConfig", the GUID 3336B68B-9F08-47DA-BC4F-C995C0A47C4C, and the offset value 103. The variable name and GUID are retrieved from the EFI variable area by the user and stored in memory as the contents of the "L"SystemSetupConfig" EFI variable. The offset value indicates the location of the option to be modified within the EFI variable. For example, to change the "NumLock" option from "On" to "Off", the 103rd byte of the EFI variable copy in memory is changed from 1 to 0. Then, the modified EFI variable memory copy is written back to the EFI variable area using the SetVariable function provided by the Runtime Service. This completes the modification of the setting value.
[0063] In this invention, for UEFI-based systems, the RSDP structure is located in the EFI_SYSTEM_TABLE, so the Linux kernel can directly look up the RSDP structure in this table and then locate all ACPI tables.
[0064] In Windows, the following function can be used to retrieve EFI_SYSTEM_TABLE.
[0065] UINT GetSystemFirmwareTable(
[0066] [in]DWORD FirmwareTableProviderSignature,
[0067] [in]DWORD FirmwareTableID,
[0068] [out]PVOID pFirmwareTableBuffer,
[0069] [in]DWORD BufferSize )
[0071] In this invention, runtime services are initialized upon entering the DXE stage and continue to exist and provide services to upper layers until the operating system terminates. Runtime services mainly include: time services, reading and writing system variables, virtual memory services, and other services.
[0072] The EFI Runtime Services Table contains a header and pointers to all Runtime Services. Unlike the EFI Boot Services Table, the function pointers in this table remain valid after the operating system loader and the OS have gained platform control by calling EFI_BOOT_SERVICES.ExitBootServices(). If the operating system calls SetVirtualAddressMap(), the function pointers in this table will be fixed to point to the new virtual address map entry point.
[0073] UEFI system variable services include: GetVariable, SetVariable, and GetNextVariableName.
[0074] GetVariable is used to retrieve the value and properties of a variable based on its name.
[0075] SetVariable has three functions: creating, updating, and deleting variables.
[0076] This invention provides a specific embodiment of a method for setting BIOS Setup options under an operating system.
[0077] Step A1: The BIOS summarizes all modifiable options, including the EFI Variable name, Variable GUID, offset value, length, menu display name, available values, and the corresponding string for each option.
[0078] Step A2: The BIOS copies the list of modifiable items to the Acci Reserved Memory.
[0079] Step A3: The BIOS creates a custom ACPI table that points to the ACPI Reserved Memory mentioned in the previous step.
[0080] Step A4: The BIOS reports the ACPI table to the OS.
[0081] Step B1: The application finds the ACPI table of the custom signature (such as "BSCT") through the interface provided by the OS.
[0082] Step B2: Based on the Setup Table Region pointers stored in the "BSCT" table.
[0083] Step B3: Locate the list of modifiable BIOS Setup items stored in ACPI Reserved Memory using the pointer.
[0084] Step B4: The application uses GetVariable in the Runtime Service provided by UEFI BIOS to read the data of the UEFI Variable containing the above-mentioned modifiable items into memory, such as the variable with Variable Name L"SystemSetupConfig".
[0085] Step B5: The application creates user interface options based on the data in the list of modifiable items in the BIOS Setup.
[0086] Step B6: The user modifies the option value, and the application modifies the variable stored in memory in step B4.
[0087] Step B7: The application updates variables via the EFI Runtime Service, thereby modifying the BIOS Setup options.
[0088] Step B8: Restart the system to make the changes to the BIOS Setup take effect.
[0089] like Figure 5 As shown, the present invention provides an apparatus for setting BIOS Setup options under an operating system, the apparatus comprising:
[0090] Initialization module: Configured for the BIOS to summarize all modifiable Setup options and the option information corresponding to each Setup option. The option information includes the variable name of the variable corresponding to the Setup option in EFI, the globally unique identifier (GUID) of the variable, the offset value, and the length.
[0091] Custom module: Configure the BIOS to compile a list of modifiable items, consisting of all modifiable Setup options and the option information corresponding to each Setup option, and copy the list of modifiable items to a custom ACPI table built in the BIOS;
[0092] The reporting module to the operating system is configured so that the BIOS reports the custom ACPI table to the operating system. Before the operating system loader hands over control to the operating system, it obtains pointers to the ACPI root system description table RSDT and the extended system description table XSDT from the EFI system table. Both RSDP and XSDT have a physical pointer set after the table header pointing to the custom ACPI table, thereby reporting the custom ACPI table to the operating system.
[0093] The configuration module is configured so that the application obtains the custom ACPI table through the interface provided by the operating system to obtain the list of modifiable items, and uses the Runtime Service provided by the UEFI BIOS mode to pass the information corresponding to the list of modifiable items into memory, thereby setting the BIOS Setup options.
[0094] The present invention provides a computer-readable storage medium storing a plurality of instructions; the plurality of instructions are used by a processor to load and execute the method as described above.
[0095] The present invention provides an electronic device, characterized in that the electronic device comprises:
[0096] A processor is used to execute multiple instructions;
[0097] Memory, used to store multiple instructions;
[0098] The plurality of instructions are to be stored in the memory and loaded and executed by the processor as described above.
[0099] The specific embodiments described above only illustrate the design principles of the present invention. The shapes and names of the components in this description may differ and are not limited. Therefore, those skilled in the art can modify or make equivalent substitutions to the technical solutions described in the foregoing embodiments; and these modifications and substitutions do not depart from the inventive spirit and technical solutions of the present invention, and should all fall within the protection scope of the present invention.
Claims
1. A method for setting BIOS Setup options under an operating system, characterized in that, include: Step S1: The BIOS summarizes all modifiable Setup options and the option information corresponding to each Setup option. The option information includes the variable name of the variable corresponding to the Setup option in EFI, the globally unique identifier (GUID) of the variable, the offset value, and the length. Step S2: The BIOS compiles a list of modifiable items, consisting of all modifiable Setup options and the option information corresponding to each Setup option, and copies the list of modifiable items to a custom ACPI table built in the BIOS. Step S3: The BIOS reports the custom ACPI table to the operating system; wherein, before the operating system loader hands over control to the operating system, it obtains pointers to the ACPI root system description table RSDT and the extended system description table XSDT from the EFI system table. Both RSDT and XSDT have a physical pointer set after the table header pointing to the custom ACPI table, thereby reporting the custom ACPI table to the operating system. Step S4: The application obtains the custom ACPI table through the interface provided by the operating system to obtain the list of modifiable items, and uses the Runtime Service provided by UEFI BIOS mode to transfer the information corresponding to the list of modifiable items to memory, thereby setting the BIOS Setup options; Step S4 involves using the Runtime Service provided by the UEFI BIOS mode to transfer the information corresponding to the list of modifiable items into memory, thereby setting the BIOS Setup options, including: Step S44: Use the GetVariable service in the Runtime Service provided by the UEFI BIOS to obtain the original value of the EFI variable from the BIOS variable area. The original value of the EFI variable is a collection of option values of a series of modifiable Setup options, used to indicate the current value of the modifiable Setup options in the BIOS. The modifiable Setup options occupy one or more bytes in the EFI variable. The EFI variable is obtained through the GetVariable service, and the parameters for obtaining the EFI variable are the variable name and the globally unique identifier (GUID) of the variable. The original value of the EFI variable is stored in memory, and at the same time, the original value of the EFI variable is displayed on the modification option interface. The variable corresponding to the original value of the EFI variable is the EFI variable corresponding to the modifiable Setup option. Step S45: Based on the modified option interface and the original value of the variable, the user determines the target option value of the modifiable Setup option of the BIOS. The target option value is the option value of the Setup option of the BIOS set by the user, and the target option value is determined based on the optional option values of the Setup option. Step S46: Use the GetVariable function in the Runtime Service provided by the UEFI BIOS mode to read the EFI variable corresponding to the target option value into memory, update the value of the corresponding EFI variable in memory to the target option value; write the updated EFI variable and EFI variable value back to the variable area of the BIOS through the SetVariable function, and restart the electronic device; at this time, the BIOS Setup option value set by the user takes effect.
2. The method as described in claim 1, characterized in that, The custom ACPI table is created during the BIOS startup process, when it acquires and summarizes all modifiable options and their corresponding information to generate the custom ACPI table; the custom ACPI table is a leaf node of the ACPI table under the operating system.
3. The method as described in claim 1, characterized in that, In step S4, the application obtains the custom ACPI table through an interface provided by the operating system to obtain the list of modifiable items, including: Step S41: The application obtains the identifier corresponding to the custom ACPI table through the interface provided by the operating system, thereby confirming that the custom ACPI table has been found; Step S42: Obtain the list of modifiable items from the custom ACPI table based on the identifier; Step S43: Display the modification options interface on the user interface, which is used to receive user input information for modifying the BIOS Setup options.
4. The method according to any one of claims 1-3, characterized in that, The custom ACPI table is stored by the BIOS in the address range of type AddressRangeACPI defined in the ACPI specification.
5. An apparatus for setting BIOS Setup options under an operating system using the method described in any one of claims 1-3, characterized in that, include: Initialization module: Configured for the BIOS to summarize all modifiable Setup options and the option information corresponding to each Setup option. The option information includes the variable name of the variable corresponding to the Setup option in EFI, the globally unique identifier (GUID) of the variable, the offset value, and the length. Custom module: Configure the BIOS to compile a list of modifiable items, consisting of all modifiable Setup options and the option information corresponding to each Setup option, and copy the list of modifiable items to a custom ACPI table built in the BIOS; The operating system reporting module is configured to have the BIOS report the custom ACPI table to the operating system. Before the operating system loader hands over control to the operating system, it obtains pointers to the ACPI root system description table RSDT and the extended system description table XSDT from the EFI system table. Both RSDT and XSDT have a physical pointer set after the table header to point to the custom ACPI table, thereby reporting the custom ACPI table to the operating system. The configuration module is configured so that the application obtains the custom ACPI table through the interface provided by the operating system to obtain the list of modifiable items, and uses the Runtime Service provided by the UEFI BIOS mode to pass the information corresponding to the list of modifiable items into memory, thereby setting the BIOS Setup options.
6. A computer-readable storage medium storing a plurality of instructions; the plurality of instructions being loaded by a processor and executing the method as claimed in any one of claims 1-4.
7. An electronic device, characterized in that, The electronic device includes: A processor is used to execute multiple instructions; Memory, used to store multiple instructions; The plurality of instructions are to be stored in the memory and loaded by the processor and executed as described in any one of claims 1-4.
Citation Information
Patent Citations
Data processing method, computer system and electronic equipment
CN115686695A
Method and device for updating BIOS (Basic Input / Output System)
CN116737196A