-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add EFI_RUNTIME_SERVICES and EFI_TIME (#15)
It is now possible to get the current date and time with unsafe code using the GetTime function.
- Loading branch information
1 parent
d936da7
commit 8325720
Showing
5 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace EfiSharp | ||
{ | ||
[StructLayout(LayoutKind.Sequential)] | ||
public readonly unsafe struct EFI_RUNTIME_SERVICES | ||
{ | ||
private readonly EFI_TABLE_HEADER Hdr; | ||
|
||
// Time Services | ||
private readonly delegate*<EFI_TIME*, void*, EFI_STATUS> _getTime; | ||
|
||
//TODO Add EFI_TIME_CAPABILITIES and support EFI_RT_PROPERTIES_TABLE configuration table, then update the summary and returns to indicate that. | ||
/// <summary> | ||
/// <para>This function returns a time that was valid sometime during the call to the function.</para> | ||
/// <para>This function should take approximately the same amount of time to read the time each time it is called.</para> | ||
/// </summary> | ||
/// <param name="time">Out variable to receive a snapshot of the current time.</param> | ||
/// <returns> | ||
/// <para><see cref="EFI_STATUS.EFI_SUCCESS"/> if the operation completed successfully.</para> | ||
/// <para><see cref="EFI_STATUS.EFI_INVALID_PARAMETER"/> if <paramref name="time"/> is null.</para> | ||
/// <para><see cref="EFI_STATUS.EFI_DEVICE_ERROR"/> if the time could not be retrieved due to a hardware error.</para> | ||
/// <para><see cref="EFI_STATUS.EFI_UNSUPPORTED"/> if this call is not supported by this platform at the time the call is made.</para> | ||
/// </returns> | ||
public EFI_STATUS GetTime(out EFI_TIME time) | ||
{ | ||
fixed (EFI_TIME* pTime = &time) | ||
{ | ||
return _getTime(pTime, null); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System.Runtime.InteropServices; | ||
|
||
namespace EfiSharp | ||
{ | ||
|
||
[StructLayout(LayoutKind.Sequential)] | ||
public readonly struct EFI_TIME | ||
{ | ||
public readonly ushort Year; | ||
public readonly byte Month; | ||
public readonly byte Day; | ||
public readonly byte Hour; | ||
public readonly byte Minute; | ||
public readonly byte Second; | ||
public readonly byte Pad1; | ||
public readonly uint Nanosecond; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters