From a3bc0fc76c2577ba2639fd796b40e938ae02948e Mon Sep 17 00:00:00 2001 From: Jozef Nagy Date: Thu, 15 May 2025 21:32:40 +0200 Subject: [PATCH] Added localization, datetime and power management --- boot/common/i18n/cs_CZ.c | 26 + boot/common/i18n/en_US.c | 26 + boot/common/i18n/i18n.c | 24 + boot/common/print.c | 13 +- boot/common/ui/terminal.c | 2 +- boot/common/ui/ui.c | 48 +- boot/include/i18n.h | 31 + boot/include/power.h | 30 + boot/include/print.h | 3 +- boot/include/sounds/chime.h | 33701 +++++++++++++++++++++++++++ boot/include/time/dt.h | 35 + boot/platform/uefi/power.c | 75 + boot/platform/uefi/time/datetime.c | 46 + 13 files changed, 34046 insertions(+), 14 deletions(-) create mode 100644 boot/common/i18n/cs_CZ.c create mode 100644 boot/common/i18n/en_US.c create mode 100644 boot/common/i18n/i18n.c create mode 100644 boot/include/i18n.h create mode 100644 boot/include/power.h create mode 100644 boot/include/sounds/chime.h create mode 100644 boot/include/time/dt.h create mode 100644 boot/platform/uefi/power.c create mode 100644 boot/platform/uefi/time/datetime.c diff --git a/boot/common/i18n/cs_CZ.c b/boot/common/i18n/cs_CZ.c new file mode 100644 index 0000000..951129a --- /dev/null +++ b/boot/common/i18n/cs_CZ.c @@ -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 + +struct language i18n_csCZ = { + .shutdown = "Vypnout", + .reboot = "Restartovat", + .reboot_to_firmware = "Přejít do nastavení firmwaru" +}; diff --git a/boot/common/i18n/en_US.c b/boot/common/i18n/en_US.c new file mode 100644 index 0000000..0d67ecd --- /dev/null +++ b/boot/common/i18n/en_US.c @@ -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 + +struct language i18n_enUS = { + .shutdown = "Shutdown", + .reboot = "Reboot", + .reboot_to_firmware = "Reboot to Firmware" +}; diff --git a/boot/common/i18n/i18n.c b/boot/common/i18n/i18n.c new file mode 100644 index 0000000..158591c --- /dev/null +++ b/boot/common/i18n/i18n.c @@ -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 + +extern struct language i18n_enUS; + +struct language *i18n_lang = &i18n_enUS; \ No newline at end of file diff --git a/boot/common/print.c b/boot/common/print.c index fe1bb66..758706a 100644 --- a/boot/common/print.c +++ b/boot/common/print.c @@ -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); } diff --git a/boot/common/ui/terminal.c b/boot/common/ui/terminal.c index 5816a20..f65e3c3 100644 --- a/boot/common/ui/terminal.c +++ b/boot/common/ui/terminal.c @@ -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) { diff --git a/boot/common/ui/ui.c b/boot/common/ui/ui.c index d2f7439..689e349 100644 --- a/boot/common/ui/ui.c +++ b/boot/common/ui/ui.c @@ -1,5 +1,5 @@ /*********************************************************************************/ -/* Module Name: ui.c */ +/* Module Name: ui.c */ /* Project: AurixOS */ /* */ /* Copyright (c) 2024-2025 Jozef Nagy */ @@ -23,11 +23,15 @@ #include #include #include +#include