Added localization, datetime and power management
This commit is contained in:
parent
dd4fda27bb
commit
a3bc0fc76c
13 changed files with 34046 additions and 14 deletions
26
boot/common/i18n/cs_CZ.c
Normal file
26
boot/common/i18n/cs_CZ.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*********************************************************************************/
|
||||
/* Module Name: cs_CZ.c */
|
||||
/* Project: AurixOS */
|
||||
/* */
|
||||
/* Copyright (c) 2024-2025 Jozef Nagy */
|
||||
/* */
|
||||
/* This source is subject to the MIT License. */
|
||||
/* See License.txt in the root of this repository. */
|
||||
/* All other rights reserved. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
|
||||
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
|
||||
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
|
||||
/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
|
||||
/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
|
||||
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */
|
||||
/* SOFTWARE. */
|
||||
/*********************************************************************************/
|
||||
|
||||
#include <i18n.h>
|
||||
|
||||
struct language i18n_csCZ = {
|
||||
.shutdown = "Vypnout",
|
||||
.reboot = "Restartovat",
|
||||
.reboot_to_firmware = "Přejít do nastavení firmwaru"
|
||||
};
|
26
boot/common/i18n/en_US.c
Normal file
26
boot/common/i18n/en_US.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*********************************************************************************/
|
||||
/* Module Name: en_US.c */
|
||||
/* Project: AurixOS */
|
||||
/* */
|
||||
/* Copyright (c) 2024-2025 Jozef Nagy */
|
||||
/* */
|
||||
/* This source is subject to the MIT License. */
|
||||
/* See License.txt in the root of this repository. */
|
||||
/* All other rights reserved. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
|
||||
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
|
||||
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
|
||||
/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
|
||||
/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
|
||||
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */
|
||||
/* SOFTWARE. */
|
||||
/*********************************************************************************/
|
||||
|
||||
#include <i18n.h>
|
||||
|
||||
struct language i18n_enUS = {
|
||||
.shutdown = "Shutdown",
|
||||
.reboot = "Reboot",
|
||||
.reboot_to_firmware = "Reboot to Firmware"
|
||||
};
|
24
boot/common/i18n/i18n.c
Normal file
24
boot/common/i18n/i18n.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*********************************************************************************/
|
||||
/* Module Name: i18n.c */
|
||||
/* Project: AurixOS */
|
||||
/* */
|
||||
/* Copyright (c) 2024-2025 Jozef Nagy */
|
||||
/* */
|
||||
/* This source is subject to the MIT License. */
|
||||
/* See License.txt in the root of this repository. */
|
||||
/* All other rights reserved. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
|
||||
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
|
||||
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
|
||||
/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
|
||||
/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
|
||||
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */
|
||||
/* SOFTWARE. */
|
||||
/*********************************************************************************/
|
||||
|
||||
#include <i18n.h>
|
||||
|
||||
extern struct language i18n_enUS;
|
||||
|
||||
struct language *i18n_lang = &i18n_enUS;
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#define NANOPRINTF_IMPLEMENTATION
|
||||
#define NANOPRINTF_USE_FIELD_WIDTH_FORMAT_SPECIFIERS 1
|
||||
#define NANOPRINTF_USE_PRECISION_FORMAT_SPECIFIERS 0
|
||||
#define NANOPRINTF_USE_PRECISION_FORMAT_SPECIFIERS 1
|
||||
#define NANOPRINTF_USE_FLOAT_FORMAT_SPECIFIERS 0
|
||||
#define NANOPRINTF_USE_LARGE_FORMAT_SPECIFIERS 1
|
||||
#define NANOPRINTF_USE_BINARY_FORMAT_SPECIFIERS 0
|
||||
|
@ -62,7 +62,16 @@ void debug(const char *fmt, ...)
|
|||
uart_sendstr(buf);
|
||||
}
|
||||
|
||||
void snprintf(char *buf, size_t size, const char *fmt, va_list args)
|
||||
void snprintf(char *buf, size_t size, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
npf_vsnprintf(buf, size, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
|
||||
{
|
||||
npf_vsnprintf(buf, size, fmt, args);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ void terminal_print(struct ui_context *ctx, char *fmt, ...)
|
|||
char *s = (char *)&buf;
|
||||
|
||||
va_start(args, fmt);
|
||||
snprintf((char *)&buf, sizeof(buf), fmt, args);
|
||||
vsnprintf((char *)&buf, sizeof(buf), fmt, args);
|
||||
va_end(args);
|
||||
|
||||
while (*s) {
|
||||
|
|
|
@ -23,11 +23,15 @@
|
|||
#include <ui/mouse.h>
|
||||
#include <ui/font.h>
|
||||
#include <ui/ui.h>
|
||||
#include <time/dt.h>
|
||||
#include <i18n.h>
|
||||
#include <axboot.h>
|
||||
|
||||
#include <print.h>
|
||||
#include <stdint.h>
|
||||
|
||||
struct datetime last_dt;
|
||||
|
||||
bool gui_init(struct ui_context *ctx)
|
||||
{
|
||||
if (!font_init(ctx, "\\AxBoot\\fonts\\vera\\Vera.sfn", 16)) {
|
||||
|
@ -43,26 +47,50 @@ bool tui_init(struct ui_context *ctx)
|
|||
return false;
|
||||
}
|
||||
|
||||
char *top_string = BOOTLOADER_NAME_STR " ver. " BOOTLOADER_VERSION_STR;
|
||||
int top_string_w;
|
||||
ssfn_bbox(&(ctx->font), top_string, &top_string_w, NULL, NULL, NULL);
|
||||
int w;
|
||||
|
||||
terminal_setcur(ctx, ctx->fb_modes[ctx->current_mode].width / 2 - (top_string_w / 2), ctx->fb_modes[ctx->current_mode].height / 32);
|
||||
// display string at the top center of the screen
|
||||
char *top_string = BOOTLOADER_NAME_STR " v" BOOTLOADER_VERSION_STR;
|
||||
ssfn_bbox(&(ctx->font), top_string, &w, NULL, NULL, NULL);
|
||||
|
||||
terminal_setcur(ctx, ctx->fb_modes[ctx->current_mode].width / 2 - (w / 2), ctx->fb_modes[ctx->current_mode].height / 32);
|
||||
terminal_print(ctx, top_string);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void gui_draw(void *mouse_status, void *event)
|
||||
void gui_draw(struct ui_context *ctx, void *mouse_status, void *event)
|
||||
{
|
||||
(void)ctx;
|
||||
(void)mouse_status;
|
||||
(void)event;
|
||||
}
|
||||
|
||||
void tui_draw(void *mouse_status, void *event)
|
||||
void tui_draw(struct ui_context *ctx, void *mouse_status, void *event)
|
||||
{
|
||||
(void)mouse_status;
|
||||
(void)event;
|
||||
|
||||
// display the current date and time at the bottom left corner of the screen
|
||||
int w, h;
|
||||
struct datetime dt;
|
||||
get_datetime(&dt);
|
||||
if (memcmp(&dt, &last_dt, sizeof(struct datetime)) != 0) {
|
||||
char dt_str[20] = {0}; // YYYY/mm/dd HH:MM:SS
|
||||
snprintf((char *)&dt_str, 20, "%.4u/%.2u/%.2u %.2u:%.2u:%.2u", dt.year, dt.month, dt.day, dt.h, dt.m, dt.s);
|
||||
|
||||
ssfn_bbox(&(ctx->font), (char *)dt_str, &w, &h, NULL, NULL);
|
||||
|
||||
for (uint32_t y = ctx->fb_modes[ctx->current_mode].height - (2*h); y < ctx->fb_modes[ctx->current_mode].height - h; y++) {
|
||||
for (int x = 0; x < w; x++) {
|
||||
*((uint32_t *)ctx->fb_addr + (ctx->fb_modes[ctx->current_mode].pitch / ctx->fb_modes[ctx->current_mode].bpp) * y + x) = 0xFF000000;
|
||||
}
|
||||
}
|
||||
terminal_setcur(ctx, 0, ctx->fb_modes[ctx->current_mode].height - h);
|
||||
terminal_print(ctx, (char *)dt_str);
|
||||
|
||||
last_dt = dt;
|
||||
}
|
||||
}
|
||||
|
||||
void ui_init()
|
||||
|
@ -83,7 +111,7 @@ void ui_init()
|
|||
for (int i = 0; i < ctx.total_modes; i++) {
|
||||
debug("Mode %u:%s | ", i, (i == ctx.current_mode) ? " (current)" : "");
|
||||
debug("Resolution: %ux%u | ", ctx.fb_modes[i].width, ctx.fb_modes[i].height);
|
||||
debug("Bits Per Pixel: %u | ", ctx.fb_modes[i].bpp);
|
||||
debug("Bytes Per Pixel: %u | ", ctx.fb_modes[i].bpp);
|
||||
debug("Pitch: %u | ", ctx.fb_modes[i].pitch);
|
||||
debug("Format: %s\n", ctx.fb_modes[i].format == FB_RGBA ? "RGBA" : "BGRA");
|
||||
}
|
||||
|
@ -96,7 +124,7 @@ void ui_init()
|
|||
ctx.font_buf.y = 0;
|
||||
ctx.font_buf.fg = 0xFFFFFFFF;
|
||||
|
||||
void (*ui_callback)(void*,void*) = NULL;
|
||||
void (*ui_callback)(struct ui_context*,void*,void*) = NULL;
|
||||
|
||||
switch (ctx.ui) {
|
||||
case UI_MODERN: {
|
||||
|
@ -119,7 +147,7 @@ void ui_init()
|
|||
}
|
||||
|
||||
while (1) {
|
||||
ui_callback(NULL, NULL);
|
||||
ui_callback(&ctx, NULL, NULL);
|
||||
//get_mouse(&m_x, &m_y, &m_but);
|
||||
//debug("Mouse X = %u | Mouse Y = %u\n", m_x, m_y);
|
||||
}
|
||||
|
|
31
boot/include/i18n.h
Normal file
31
boot/include/i18n.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*********************************************************************************/
|
||||
/* Module Name: i18n.h */
|
||||
/* Project: AurixOS */
|
||||
/* */
|
||||
/* Copyright (c) 2024-2025 Jozef Nagy */
|
||||
/* */
|
||||
/* This source is subject to the MIT License. */
|
||||
/* See License.txt in the root of this repository. */
|
||||
/* All other rights reserved. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
|
||||
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
|
||||
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
|
||||
/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
|
||||
/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
|
||||
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */
|
||||
/* SOFTWARE. */
|
||||
/*********************************************************************************/
|
||||
|
||||
#ifndef _I18N_H
|
||||
#define _I18N_H
|
||||
|
||||
struct language {
|
||||
char *shutdown;
|
||||
char *reboot;
|
||||
char *reboot_to_firmware;
|
||||
};
|
||||
|
||||
extern struct language *i18n_lang;
|
||||
|
||||
#endif /* _I18N_H */
|
30
boot/include/power.h
Normal file
30
boot/include/power.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*********************************************************************************/
|
||||
/* Module Name: power.h */
|
||||
/* Project: AurixOS */
|
||||
/* */
|
||||
/* Copyright (c) 2024-2025 Jozef Nagy */
|
||||
/* */
|
||||
/* This source is subject to the MIT License. */
|
||||
/* See License.txt in the root of this repository. */
|
||||
/* All other rights reserved. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
|
||||
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
|
||||
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
|
||||
/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
|
||||
/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
|
||||
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */
|
||||
/* SOFTWARE. */
|
||||
/*********************************************************************************/
|
||||
|
||||
#ifndef _POWER_H
|
||||
#define _POWER_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool platform_is_reboot_to_fw_possible();
|
||||
void platform_reboot_to_fw();
|
||||
void platform_reboot();
|
||||
void platform_shutdown();
|
||||
|
||||
#endif /* _POWER_H */
|
|
@ -30,6 +30,7 @@ void debug(const char *fmt, ...);
|
|||
|
||||
void printstr(const char *str);
|
||||
|
||||
void snprintf(char *buf, size_t size, const char *fmt, va_list args);
|
||||
void snprintf(char *buf, size_t size, const char *fmt, ...);
|
||||
void vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
|
||||
|
||||
#endif /* _PRINT_H */
|
33701
boot/include/sounds/chime.h
Normal file
33701
boot/include/sounds/chime.h
Normal file
File diff suppressed because it is too large
Load diff
35
boot/include/time/dt.h
Normal file
35
boot/include/time/dt.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*********************************************************************************/
|
||||
/* Module Name: dt.h */
|
||||
/* Project: AurixOS */
|
||||
/* */
|
||||
/* Copyright (c) 2024-2025 Jozef Nagy */
|
||||
/* */
|
||||
/* This source is subject to the MIT License. */
|
||||
/* See License.txt in the root of this repository. */
|
||||
/* All other rights reserved. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
|
||||
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
|
||||
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
|
||||
/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
|
||||
/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
|
||||
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */
|
||||
/* SOFTWARE. */
|
||||
/*********************************************************************************/
|
||||
|
||||
#ifndef _TIME_DT_H
|
||||
#define _TIME_DT_H
|
||||
|
||||
struct datetime {
|
||||
int year;
|
||||
int month;
|
||||
int day;
|
||||
|
||||
int h;
|
||||
int m;
|
||||
int s;
|
||||
};
|
||||
|
||||
void get_datetime(struct datetime *dt);
|
||||
|
||||
#endif /* _TIME_DT_H */
|
75
boot/platform/uefi/power.c
Normal file
75
boot/platform/uefi/power.c
Normal file
|
@ -0,0 +1,75 @@
|
|||
/*********************************************************************************/
|
||||
/* Module Name: power.c */
|
||||
/* Project: AurixOS */
|
||||
/* */
|
||||
/* Copyright (c) 2024-2025 Jozef Nagy */
|
||||
/* */
|
||||
/* This source is subject to the MIT License. */
|
||||
/* See License.txt in the root of this repository. */
|
||||
/* All other rights reserved. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
|
||||
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
|
||||
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
|
||||
/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
|
||||
/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
|
||||
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */
|
||||
/* SOFTWARE. */
|
||||
/*********************************************************************************/
|
||||
|
||||
#include <power.h>
|
||||
#include <efi.h>
|
||||
#include <efilib.h>
|
||||
#include <axboot.h>
|
||||
#include <print.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool platform_is_reboot_to_fw_possible()
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_UINT64 OsIndications;
|
||||
EFI_UINTN OsIndicationsSize = sizeof(EFI_UINT64);
|
||||
EFI_GUID GlobalVarGuid = EFI_GLOBAL_VARIABLE;
|
||||
|
||||
Status = gSystemTable->RuntimeServices->GetVariable(L"OsIndicationsSupported", &GlobalVarGuid, NULL, &OsIndicationsSize, &OsIndications);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
if (OsIndications & EFI_OS_INDICATIONS_BOOT_TO_FW_UI) {
|
||||
debug("platform_is_reboot_to_fw_possible(): Boot to firmware UI is possible!\n");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
debug("platform_is_reboot_to_fw_possible(): Failed to get OsIndications variable: 0x%llx (%s) \n", Status, efi_status_to_str(Status));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void platform_reboot_to_fw()
|
||||
{
|
||||
if (!platform_is_reboot_to_fw_possible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
EFI_STATUS Status;
|
||||
EFI_UINT64 OsIndications = EFI_OS_INDICATIONS_BOOT_TO_FW_UI;
|
||||
EFI_UINTN OsIndicationsSize = sizeof(EFI_UINT64);
|
||||
EFI_GUID GlobalVarGuid = EFI_GLOBAL_VARIABLE;
|
||||
|
||||
Status = gSystemTable->RuntimeServices->SetVariable(L"OsIndications", &GlobalVarGuid, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, OsIndicationsSize, &OsIndications);
|
||||
if (EFI_ERROR(Status)) {
|
||||
debug("platform_reboot_to_fw(): Failed to set OsIndications variable: 0x%llx (%s) \n", Status, efi_status_to_str(Status));
|
||||
}
|
||||
|
||||
gSystemTable->RuntimeServices->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL);
|
||||
}
|
||||
|
||||
void platform_reboot()
|
||||
{
|
||||
gSystemTable->RuntimeServices->ResetSystem(EfiResetWarm, EFI_SUCCESS, 0, NULL);
|
||||
}
|
||||
|
||||
void platform_shutdown()
|
||||
{
|
||||
gSystemTable->RuntimeServices->ResetSystem(EfiResetShutdown, EFI_SUCCESS, 0, NULL);
|
||||
}
|
46
boot/platform/uefi/time/datetime.c
Normal file
46
boot/platform/uefi/time/datetime.c
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*********************************************************************************/
|
||||
/* Module Name: datetime.c */
|
||||
/* Project: AurixOS */
|
||||
/* */
|
||||
/* Copyright (c) 2024-2025 Jozef Nagy */
|
||||
/* */
|
||||
/* This source is subject to the MIT License. */
|
||||
/* See License.txt in the root of this repository. */
|
||||
/* All other rights reserved. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
|
||||
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
|
||||
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
|
||||
/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
|
||||
/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
|
||||
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */
|
||||
/* SOFTWARE. */
|
||||
/*********************************************************************************/
|
||||
|
||||
#include <time/dt.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <axboot.h>
|
||||
#include <print.h>
|
||||
|
||||
#include <efi.h>
|
||||
#include <efilib.h>
|
||||
|
||||
void get_datetime(struct datetime *dt)
|
||||
{
|
||||
EFI_STATUS status;
|
||||
EFI_TIME uefi_dt;
|
||||
|
||||
status = gSystemTable->RuntimeServices->GetTime(&uefi_dt, NULL);
|
||||
if (EFI_ERROR(status)) {
|
||||
debug("get_datetime(): Failed to acquire current time, setting to 1970/01/01 00:00:00!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
dt->year = uefi_dt.Year;
|
||||
dt->month = uefi_dt.Month;
|
||||
dt->day = uefi_dt.Day;
|
||||
dt->h = uefi_dt.Hour;
|
||||
dt->m = uefi_dt.Minute;
|
||||
dt->s = uefi_dt.Second;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue