Embodiments of the present invention pertain to computer initialization firmware. More specifically, embodiments of the present invention relate to synchronizing data and/or resource accesses within a Basic Input and Out System (BIOS) of a computer system.
A personal computer typically employs a BIOS program to initialize the computer. The BIOS also manages data flow between an operating system (OS) and various peripheral devices (e.g., hard disk, keyboard, cursor control device, display, and printer) of the computer. The BIOS is typically stored in a non-volatile memory, and is accessed by a processing unit (e.g., microprocessor) of the computer during initialization.
The BIOS is platform specific, meaning it is specific to particular processor architecture. This makes it rather difficult for independent software developers to expand its functionalities. To overcome this, a new standard known as Extensible Firmware Interface (EFI) (i.e., EFI 1.10 specification, published Jan. 7, 2003) has been introduced. The EFI standard defines an OS-BIOS interface that is not specific to any processor architecture. The interface includes data tables that contain platform-related information and EFI boot and runtime services that are available to the OS and its loader. The EFI interfaces with an EFI-based BIOS having EFI drivers and other routines. The EFI-based BIOS then interfaces with platform specific firmware and hardware of the computer.
The EFI-based BIOS adopts a Task Privilege Level (TPL) mechanism to provide synchronization for data or resource access by programs or routines within the EFI-based BIOS. Using the TPL synchronization mechanism, all the routines and data regions are assigned to different task privilege levels. A data region at a specific privilege level can only be accessed by routines at the same or higher privilege level. A routine can raise its current privilege level to a higher level before accessing a data region in order to protect that data region from being accessed by another routine at a privilege level lower than the raised privilege level. In addition, a routine running at a specific privilege level can be preempted by routines running at privilege levels higher than that specific privilege level. In other words, TPL is a shared variable.
While this prior approach provides the EFI-based BIOS with a basic synchronization mechanism, it has some significant drawbacks. One of the drawbacks is that the TPL-dependent synchronization mechanism is very coarse-grained. If a routine wants to access a data region, it has to raise its TPL to a certain level (e.g., TPLO), blocking any other routine running at a privilege level lower than or equal to the that privilege level from accessing the same data region, even though these routines actually do not want to access the same data region. As a result, the performance of the EFI-based BIOS is negatively impacted. This is illustrated in
Another drawback is that the prior TPL-dependent mechanism also does not support multiple data accesses to several data regions at the same time. This limitation means that when one routine needs to access, for example, two data regions at the same time, the routine has to release the control of the first data region before it is allowed to access the second data region (i.e., restore the TPL before going to second data). If the TPL of the second data region is lower than the first one, entering the second data region without exiting the first one actually breaks the assumption of this TPL mechanism that code running at lower privilege level can not access the data region at the higher privilege level.
Thus, what is needed is an improved synchronization mechanism that overcomes the drawbacks of the prior TPL-dependent synchronization mechanism.
The features and advantages of embodiments of the present invention are illustrated by way of example and are not intended to limit the scope of the embodiments of the present invention to the particular embodiments shown.
Here, the term resource refers to any hardware resource (e.g., memory, buffer, hard disk, removable non-volatile memory store, printer) of the computer system 10.
As will be described in more detail below and in accordance with one embodiment of the present invention, the synchronization module 20 first associates an access indicator (e.g., access indicator 41 in
The access indicator indicates the access status of the associated resource. The access indicator has an initial value that indicates the number of accesses the associated resource can receive at a given time. In an embodiment, when the value of the access indicator is equal to ZERO, it indicates that the associated resource cannot be accessed at the time. When the value of the access indicator is equal to ONE, it indicates that the associated resource can only be accessed by one program routine at the time. If the value of the access indicator is equal to a value of THREE, then it indicates that the associated resource can be accessed by three program routines at the same time. Whenever the resource is accessed by a program routine, the value of the access indicator is decreased by the incremental value of ONE.
When a program routine within the BIOS 14 wants to access a resource, the synchronization module 20 first determines the current value of the associated access indicator of the resource. If the value is ZERO, the synchronization module 20 denies the access to the resource. If the value of the access indicator is ONE, then the synchronization module 20 decreases the value by ONE to ZERO and allows the requesting program routine to access the resource. The resource now cannot be accessed by any other program routine because its access indicator has reached ZERO.
If the value of the access indicator is at a value greater than ONE, then the synchronization module 20 just simply decreases the value by ONE and allows the requesting program routine to access the resource. In this case, the resource is not blocked (because its access indicator has not reached the value of ZERO) and can be accessed by other program routines. Because the access indicator is resource specific, other resource access operations and non-resource access operations are not affected by this resource access operation, thus achieving a greater degree of concurrency.
The value of the access indicator is restored (i.e., increased by the value of ONE) once the requesting program routine completes its resource access. The synchronization module 20 will be described in more detail below, also in conjunction with
Referring again to
The computer system 10 includes an OS (Operating System) 11, an EFI OS loader 12, an EFI 13, and a platform specific firmware and hardware 15, in addition to the EFI-based BIOS 14. The OS 11 can be any known operating system. For example, the OS 11 can be a Linux-based operating system, or a Unix-based operating system.
The EFI OS loader 12 is used to launch or load the OS 11 (or at least a portion of the OS 11) into a memory (not shown in
The EFI 13 is an open standard interface that is platform-independent. The EFI 13 is written in high level programming language (e.g., C). The EFI 13 is implemented in accordance with the EFI specification published by Intel Corporation of Santa Clara, Calif. However, the actual implementation of the EFI 13 may vary in many different ways.
The EFI 13 includes data tables (not shown in
The EFI 13 interfaces with the EFI-based BIOS 14 having the EFI drivers and other routines. The EFI-based BIOS 14 then interfaces with the platform specific firmware and hardware 15 of the computer system 10. The structure and operation of the EFI 13 will not be described in more detail below.
The platform-specific firmware and hardware 15 includes a number of platform-specific firmware and hardware components. For example, the platform-specific firmware and hardware 15 includes a processor that executes instructions of program routines. The processor may include an on-chip cache. The hardware 15 may also include a memory, a hard disk, a removable non-volatile memory store, a printer, a display, a network interface card, and a keyboard. In addition, the network interface card may include shared and unshared buffers.
The EFI-based BIOS 14 is used to interface the EFI 13 with the platform-specific firmware and hardware 15 during initialization of the computer system 10. The EFI-based BIOS 14 includes a main engine 21 that includes the EFI drivers and other routines. Although
The main engine 21 of the EFI-based BIOS 14 handles many system initialization and input/output (I/O) routines. This function will not be described in more detail below. The main engine 21 of the EFI-based BIOS 14 includes many program routines. In particular and for the purpose of describing an embodiment of the present invention, the main engine 21 of the EFI-based BIOS 14 includes two types of program. One is referred to as EFI event handler routine and the other is non-EFI event handler routine (i.e., at APPLICATION TPL level). Both handlers may access resources within the platform-specific firmware and hardware 15 of the computer system 10.
To synchronize the resource accesses by the program routines within the BIOS 14, the EFI-based BIOS 14 includes the synchronization module 20. As described above, the synchronization module 20 synchronizes resource accesses by program routines within the EFI-based BIOS 14 in such a way that concurrent accesses to different resources are allowed. In addition, the synchronization module 20 allows a resource to be accessed by multiple program routines at the same time. Moreover, the synchronization module 20 allows program routines that do not require resource accesses to be running concurrently with the resource access operations.
The synchronization module 20 achieves the synchronization by associating an access indicator to each of the resources of the computer system 10.
Each access indicator indicates the access status of the associated resource. Each access indicator has an initial value that indicates the number of accesses the associated resource can receive at a given time. In an embodiment, when the value of the access indicator is equal to ZERO, it indicates that the associated resource cannot be accessed at the time. When the value of the access indicator is equal to ONE, it indicates that the associated resource can only be accessed by one program routine at the time. If the value of the access indicator is equal to a value of THREE, then it indicates that the associated resource can be accessed by three program routines at the same time. For example, when the value of the access indicator 50n is equal to ZERO, it indicates that the associated resource n cannot be accessed at the time. When the value of the access indicator 50n is equal to ONE, it indicates that the associated resource n can only be accessed by one program routine at the time. The synchronization module 20 manages the access indicators 41-50n.
When a program routine within the BIOS 14 wants to access a resource (e.g., the resource n), the synchronization module 20 employs one of three synchronization operations to synchronize the access operation. These synchronization operations include a WAIT operation, a BUSY_WAIT operation, and a TRY_LOCK operation. If the requesting program routine is an EFI event handler routine, then the synchronization module 20 employs the WAIT or TRY_LOCK operation to block the resource from being accessed by other asynchronous event handler. If the requesting program routine is a non-EFI event handler routine, then the synchronization module 20 employs the WAIT, BUSY_WAIT, or TRY_LOCK operation to block the resource from being accessed by other asynchronous event handler.
When a program routine within the BIOS 14 wants to access a resource (e.g., the resource n), the synchronization module 20 first determines the current value of the access indicator 50n. If the value is ZERO, the synchronization module 20 denies the access to the resource n. If the value of the access indicator is ONE, then the synchronization module 20 decreases the value by ONE to ZERO and allows the requesting program routine to access the resource n. The resource now cannot be accessed by any other program routine because its access indicator has reached ZERO.
If the value of the access indicator 50n is at a value greater than ONE, then the synchronization module 20 just simply decreases the value by ONE and allows the requesting program routine to access the resource n. In this case, the resource is not blocked (because its access indicator has not reached the value of ZERO) and can be accessed by other program routines. Because the access indicator is resource specific, other resource access operations and non-resource access operations are not affected by this resource access operation, thus achieving a greater degree of concurrency. The synchronization module 20 restores the value of the access indicator (i.e., increase the value by ONE) once the requesting program routine completes its resource access.
The synchronization module 20 can be implemented in software, firmware, or hardware form. In one embodiment, the synchronization module 20 is implemented in software. In another embodiment, the synchronization module 20 is implemented in firmware. The synchronization process of the synchronization module 20 is shown in
Referring to
There are three synchronization operations that can be called. These operations are the WAIT operation, the BUSY_WAIT operation, and the TRY_LOCK operation. The WAIT operation is an operation that waits for the release of the resource being accessed by other requesting routine(s) so that the present requesting routine can access the resource. In addition, the WAIT operation gives other routines a chance to access the resource first.
The BUSY_WAIT operation also waits for the release of the resource being accessed by other requesting routine(s), but it does not voluntarily give other routines a chance to have their accesses first. This means that the BUSY_WAIT operation will force the hardware 15 of the computer system 10 (
The TRY_LOCK operation is an operation that tests the resource to see if it is being accessed by another program routine. If the resource is not being accessed, then the TRY_LOCK operation causes the resource to be acquired.
At 52, the WAIT synchronization operation is called and performed. According to an embodiment of the present invention, the synchronization module 20 of
The BUSY_WAIT synchronization operation is called and performed. According to an embodiment of the present invention, the synchronization module 20 of
At 54, the TRY_LOCK synchronization operation is called and performed. According to an embodiment of the present invention, the synchronization module 20 of
At 55, a SIGNAL operation is called and performed to restore the access indicator of the accessed resource. The synchronization module 20 of
The actual implementation of these operations (i.e., WAIT, BUSY_WAIT, TRY_LOCK, and SIGNAL) is dependent on the platform hardware 15 (
Referring to
At 62, the synchronization module 20 of
At 63, the value of the access indicator is decreased by ONE. In accordance with one embodiment of the present invention, the synchronization module 20 of
At 64, the requesting routine is allowed to access the resource. In accordance with an embodiment of the present invention, the synchronization module 20 of
Referring to
At 72, the value of the access indicator is decreased by ONE. In accordance with one embodiment of the present invention, the synchronization module 20 of
At 73, the requesting routine is allowed to access the resource. In accordance with an embodiment of the present invention, the synchronization module 20 of
As can be seen from
At 82, the value of the access indicator is decreased by ONE. In accordance with one embodiment of the present invention, the synchronization module 20 of
At 83, the requesting routine is allowed to access the resource. In accordance with an embodiment of the present invention, the synchronization module 20 of
The TCP/IP protocol stack, when in operation, needs to access a shared buffer (not shown in
These routines include a packet handling routine that retrieves data packets from the buffer, an application polling routing that polls the network interface card to place incoming data packets into the buffer, and a system polling routine that polls the network interface card to place incoming data packets into the buffer. In one embodiment, in order to avoid the possibility of any potential deadlock situation, only the application polling routine is allowed to use the WAIT and BUSY_WAIT operation on a single processor. Alternatively, this restriction does not apply.
According to an embodiment of the present invention and as can be seen from
At 102, the TRY_LOCK operation is called to lock the buffer. This means to reduce the value of the access indicator for the buffer. In accordance with one embodiment of the present invention, the synchronization module 20 of
At 103, it is determined whether the lock is successful. The lock will be successful if the resource can be locked and acquired. The lock will be unsuccessful if the resource cannot be accessed at this time. In accordance with an embodiment of the present invention, the synchronization module 20 of
At 104, the packet handling routine is allowed to access the buffer to retrieve data packets. In accordance with an embodiment of the present invention, the synchronization module 20 of
If the lock is determined not to be successful at 103 (i.e., NO), it means that the buffer cannot be accessed (e.g., the value of the access indicator is current at ZERO). In this case, the process ends at block 111.
At 105, the BUSY_WAIT or WAIT operation is called to lock the buffer. This means to reduce the value of the access indicator for the buffer. Here, either the WAIT or BUSY_WAIT operation can be employed. But it is more efficient to use the WAIT operation in a single processor environment. In accordance with one embodiment of the present invention, the synchronization module 20 of
At 106, the application polling routine is allowed to access the buffer to place incoming data packets into the buffer. In accordance with an embodiment of the present invention, the synchronization module 20 of
At 107, the TRY_LOCK operation is called to lock the buffer. This means to reduce the value of the access indicator for the buffer. In accordance with an embodiment of the present invention, the synchronization module 20 of
At 108, it is determined whether the lock is successful. The lock will be successful if the resource can be locked and acquired. The lock will be unsuccessful if the resource cannot be accessed at this time. In accordance with an embodiment of the present invention, the synchronization module 20 of
At 109, the system polling routine is allowed to access the buffer to place incoming data packets into the buffer. In accordance with an embodiment of the present invention, the synchronization module 20 of
If the lock is determined not to be successful at 108 (i.e., NO), it means that the buffer cannot be accessed (e.g., the value of the access indicator is current at ZERO). In this case, the process ends at block 111.
At 110, the SIGNAL operation is called to unlock the buffer. In accordance with an embodiment of the present invention, the synchronization module 20 of
In the foregoing specification, the embodiments of the present invention have been described with reference to specific exemplary embodiments thereof. It will, however, be evident that various modifications and changes may be made thereto without departing from the broader spirit and scope of the embodiments of the present invention. The specification and drawings are, accordingly, to be regarded in an illustrative rather than restrictive sense.
Filing Document | Filing Date | Country | Kind | 371c Date |
---|---|---|---|---|
PCT/CN04/00984 | 8/25/2004 | WO | 00 | 12/20/2005 |