diff --git a/ExectOS.code-workspace b/ExectOS.code-workspace index 6c383fe..1647a29 100644 --- a/ExectOS.code-workspace +++ b/ExectOS.code-workspace @@ -20,5 +20,8 @@ } }, "terminal.integrated.defaultProfile.linux": "xtchain", + "files.associations": { + "globals.h": "c" + }, } } \ No newline at end of file diff --git a/sdk/xtdk/bmtypes.h b/sdk/xtdk/bmtypes.h new file mode 100644 index 0000000..c5cda46 --- /dev/null +++ b/sdk/xtdk/bmtypes.h @@ -0,0 +1,39 @@ +/** + * PROJECT: ExectOS + * COPYRIGHT: See COPYING.md in the top level directory + * FILE: sdk/xtdk/bmtypes.h + * DESCRIPTION: XT Boot Manager structures definitions + * DEVELOPERS: Rafal Kupiec + */ + +#ifndef __XTDK_BMTYPES_H +#define __XTDK_BMTYPES_H + +#include + +typedef struct _XTBL_INI_SECTION +{ + LIST_ENTRY Flink; + LIST_ENTRY Options; + PWCHAR SectionName; +} XTBL_INI_SECTION, *PXTBL_INI_SECTION; + +typedef struct _XTBL_INI_OPTION +{ + LIST_ENTRY Flink; + PWCHAR Name; + PWCHAR Value; +} XTBL_INI_OPTION, *PXTBL_INI_OPTION; + +/* XTLDR configuration data */ +typedef struct _XTBM_CONFIGURATION +{ + PWCHAR Default; + PWCHAR Debug; + BOOLEAN Shell; + PWCHAR Theme; + ULONG Timeout; + PWCHAR Tune; +} XTBM_CONFIGURATION, *PXTBM_CONFIGURATION; + +#endif /* __XTDK_BMTYPES_H */ diff --git a/xtldr2/config.c b/xtldr2/config.c index 45869f5..36a9cb1 100644 --- a/xtldr2/config.c +++ b/xtldr2/config.c @@ -4,10 +4,97 @@ * FILE: xtldr/config.c * DESCRIPTION: XT Boot Loader Configuration * DEVELOPERS: Rafal Kupiec + * Jozef Nagy */ #include +/** + * Parses configuration INI file contents. + * + * @param FileContents + * Supplies a pointer to a wide string containing contents of the configuration file. + * + * @param Sections + * Supplies a pointer to a linked list which will be written by this routine. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTCDECL +VOID +BlpConfigParseIniFile(IN PWCHAR FileContents, + OUT PLIST_ENTRY SectionsHead) +{ + PWCHAR CurrentSectionName, Key, Value; + PWCHAR Input; + UINT SectionLength, KeyLength, ValueLength; + + Input = FileContents; + CurrentSectionName = L"None"; + + while(*Input != 0) + { + SectionLength = 0; + KeyLength = 0; + ValueLength = 0; + + if(*Input == ';' || *Input == '#') + { + /* Skip comments */ + while(*Input != 0 && *Input != '\n') + { + Input++; + } + } + else if(*Input == '\n') + { + /* Skip newline */ + Input++; + } + else if(*Input == '[') + { + /* Get the section name */ + Input++; + CurrentSectionName = Input; + + /* Skip to the next line */ + while(*Input != ']' && *Input != 0 && *Input != '\n') + { + SectionLength++; + Input++; + } + Input++; + } + else + { + /* Get the length of key */ + while(*Input != '=' && *Input != 0 && *Input != '\n') + { + KeyLength++; + Input++; + } + + /* Set key */ + Key = Input - KeyLength; + Key[KeyLength] = 0; + Input++; + + /* Get the length of value */ + while(*Input != 0 && *Input != '\n') + { + Input++; + ValueLength++; + } + + /* Set value */ + Value = Input - ValueLength; + Value[ValueLength] = 0; + Input++; + } + } +} /** * Parses command line arguments and updates global configuration. diff --git a/xtldr2/includes/bootman.h b/xtldr2/includes/bootman.h index 2a1647a..329658e 100644 --- a/xtldr2/includes/bootman.h +++ b/xtldr2/includes/bootman.h @@ -134,6 +134,11 @@ BlpFindParentBlockDevice(IN PLIST_ENTRY BlockDevices, IN PEFI_BLOCK_DEVICE_DATA ChildNode, OUT PEFI_BLOCK_DEVICE_DATA ParentNode); +XTCDECL +VOID +BlpConfigParseIniFile(IN PWCHAR FileContents, + OUT PLIST_ENTRY SectionsHead); + XTCDECL VOID BlpParseCommandLineOptions(VOID); diff --git a/xtldr2/includes/globals.h b/xtldr2/includes/globals.h index c43b052..81c9f67 100644 --- a/xtldr2/includes/globals.h +++ b/xtldr2/includes/globals.h @@ -11,7 +11,6 @@ #include - /* XT Boot Loader configuration data */ EXTERN XTBL_CONFIGURATION BlpConfiguration; diff --git a/xtldr2/xtldr.c b/xtldr2/xtldr.c index 37edbe9..95e084f 100644 --- a/xtldr2/xtldr.c +++ b/xtldr2/xtldr.c @@ -33,6 +33,9 @@ BlStartXtLoader(IN EFI_HANDLE ImageHandle, EfiImageHandle = ImageHandle; EfiSystemTable = SystemTable; + /* Initialize UEFI console and early print XTLDR version */ + BlpConsoleInitialize(); + /* Initialize XTLDR and early print XTLDR version */ BlpInitializeEfiBootLoader(); BlConsolePrint(L"XTLDR boot loader v%s\n", XTOS_VERSION);