diff --git a/CMakeLists.txt b/CMakeLists.txt index b9bf79e..c635dc0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,7 +66,7 @@ file(RELATIVE_PATH _PATH_PREFIX ${EXECTOS_BINARY_DIR} ${EXECTOS_SOURCE_DIR}) add_compiler_flags(-D__RELFILE__="&__FILE__[__FILE__[0] == '.' ? sizeof \\\"${_PATH_PREFIX}\\\" - 1 : sizeof XTOS_SOURCE_DIR]") # Set the virtual disk image size (in MiB) -set_disk_image_size(128) +set_disk_image_size(16) # Build all subprojects add_subdirectory(bootdata) diff --git a/xtldr2/config.c b/xtldr2/config.c index aa7f10e..d5aa967 100644 --- a/xtldr2/config.c +++ b/xtldr2/config.c @@ -13,7 +13,7 @@ * Parses configuration INI file contents. * * @param FileContents - * Supplies a pointer to a string containing contents of the configuration file. + * 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. @@ -27,76 +27,83 @@ XTSTATUS BlConfigParseIniFile(IN PWCHAR FileContents, OUT PLIST_ENTRY Sections) { - PWCHAR Line, LastLine, Key, Value; - SIZE_T Length, KeyLength; + PWCHAR CurrentSectionName, Key, Value; + PWCHAR Input; + UINT SectionLength, KeyLength, ValueLength; - UINT Error; + Input = FileContents; + CurrentSectionName = L"None"; - /* There's not error at the moment */ - Error = 0; - - /* Tokenize provided options */ - Line = RtlWideStringTokenize(FileContents, L"\n", &LastLine); - - while(Line != NULL) + while(*Input != 0) { - Length = RtlWideStringLength(Line, 0); + SectionLength = 0; + KeyLength = 0; + ValueLength = 0; - /* Parse */ - if (Length < 1) + if(*Input == ';' || *Input == '#') { - /* Blank line */ + /* Skip comments */ + while(*Input != 0 && *Input != '\n') + { + Input++; + } } - else if (RtlWideStringCompare(Line, L"#", 1) == 0 || - RtlWideStringCompare(Line, L";", 1) == 0) + else if(*Input == '\n') { - /* Don't parse a comment */ + /* Skip newline */ + Input++; } - else if (RtlWideStringCompare(Line, L"[", 1) == 0 && - RtlWideStringCompare(Line + Length - 3, L"]", 1) == 0) + else if(*Input == '[') { - - /* Remove brackets around section name */ - PWCHAR SectionName = Line + 1; - SectionName[Length - 3] = 0; + /* Get the section name */ + Input++; + CurrentSectionName = Input; - /* Save section name */ - BlConsolePrint(L"Section: %S\n", SectionName); + /* Skip to the next line */ + while(*Input != ']' && *Input != 0 && *Input != '\n') + { + Input++; + SectionLength++; + } + CurrentSectionName[SectionLength] = 0; + Input++; + + BlConsolePrint(L"[%S]\n", CurrentSectionName); } else { - KeyLength = 0; - - /* Set key=value pair to the entire line for further processing */ - Value = Line; - Key = Line; - - /* Get the value */ - while(Value != 0 && - RtlWideStringCompare(Value, L"=", 1) != 0) + /* Get the length of key */ + while(*Input != '=' && *Input != 0 && *Input != '\n') { - Value++; + Input++; KeyLength++; } - /* Get rid of the leading '=' */ - Value++; - - /* Set the key */ + /* Set key */ + Input -= KeyLength; + Key = Input; Key[KeyLength] = 0; + BlConsolePrint(L"%S=", Key); - BlConsolePrint(L"Key: %S\n Value: %S\n", Key, Value); + /* Skip to the value */ + Input += KeyLength + 1; + + /* Get the length of value */ + while(*Input != 0 && *Input != '\n') + { + Input++; + ValueLength++; + } + + /* Set value */ + Input -= ValueLength; + Value = Input; + Value[ValueLength] = 0; + BlConsolePrint(L"%S\n", Value); + Input += ValueLength; + + Input++; } - - if(Error == 1) - { - /* Display error message and exit */ - BlConsolePrint(L"Syntax error\n"); - return STATUS_INVALID_PARAMETER; - } - - /* Take next line */ - Line = RtlWideStringTokenize(NULL, L"\n", &LastLine); } return STATUS_SUCCESS; diff --git a/xtldr2/xtldr.c b/xtldr2/xtldr.c index b21c1c8..b76332b 100644 --- a/xtldr2/xtldr.c +++ b/xtldr2/xtldr.c @@ -38,13 +38,13 @@ BlStartXtLoader(IN EFI_HANDLE ImageHandle, RtlInitializeListHead(&ConfigSections); /* Initialize UEFI console and early print XTLDR version */ - BlConsoleInitialize(); + BlpConsoleInitialize(); /* Parse INI Configuration file */ - BlConfigParseIniFile(L"# This is the XT Boot Loader (XTLDR) configuration file. It follows an INI format and is divided into sections, which\n# contain a properties. Each property has a name and value delimited by an equal (=) character. Comments must start\n# with a semicolon (;) or a hash character (#) and run to the end of the line.\n#\n# Basic section is [XTLDR] which contains a bootloader specific options:\n# Debug - enables the debugging port and consists of two comma-separated parameters: com port and baud rate;\n# it is also possible to specify custom port address with: COM0:[address],[baud_rate]\n# Default - specifies which operating system listen in config file will be started if no choice is made\n# Theme - allows to set a custom theme to personalize XTLDR's look'n'feel\n# Timeout - sets the countdown timer (in seconds) before the default OS get started automatically\n# Tune - plays a tune on the pcspeaker right before the XTLDR loads\n#\n# Another type of section is [OS-Section] which adds a new position (operating system) to the boot menu. Each type\n# of the operating system provides a set of available parameters. If unsupported option is added, it is being ignored\n# by the XT Boot Loader. The available options are:\n# SystemName - sets a long operating system name that will be shown on the boot menu\n# SystemType - specifies an OS type from a predefined list of supported boot protocols\n# SystemPath - the ARC path, eg. multi(0)disk(0)rdisk(0)partition(1)\n# KernelFile - sets kernel filename with optional path relative to SystemPath\n# InitrdFile - sets initramfs image filename with optional path relative to SystemPath\n# HalFile - sets HAL filename with optional path relative to SystemPath\n# Parameters - specifies extra boot options for the kernel\n[XTLDR]Tune=400 880 2 988 2 783 2 392 2 587 3Debug=COM1,115200Timeout=30Theme=FancyDefault=ExectOS[ExectOS]SystemName=\"ExectOS Operating System\"SystemType=XTOSSystemPath=multi(0)disk(0)rdisk(0)partition(1)/ExectOSKernelFile=xtoskrnl.exeParameters=DEBUG DEBUGPORT=COM1,115200[Windows]SystemName=\"Microsoft Windows 2000\"SystemType=NT50SystemPath=multi(0)disk(0)rdisk(0)partition(2)/WindowsKernelFile=ntoskrnl.exeHalFile=hal.dllParameters=/NOGUIBOOT /MININT[Linux]SystemName=\"GNU/Linux\"SystemType=LINUXSystemPath=multi(0)disk(0)rdisk(0)partition(3)/bootKernelFile=vmlinuzInitrdFile=initramfs.cpio.gzParameters=root=/dev/xvda3 rootfstype=ext4", &ConfigSections); /* Initialize XTLDR and early print XTLDR version */ BlpInitializeEfiBootLoader(); + BlConfigParseIniFile(L"# This is the XT Boot Loader (XTLDR) configuration file. It follows an INI format and is divided into sections, which\n# contain a properties. Each property has a name and value delimited by an equal (=) character. Comments must start\n# with a semicolon (;) or a hash character (#) and run to the end of the line.\n#\n# Basic section is [XTLDR] which contains a bootloader specific options:\n# Debug - enables the debugging port and consists of two comma-separated parameters: com port and baud rate;\n# it is also possible to specify custom port address with: COM0:[address],[baud_rate]\n# Default - specifies which operating system listen in config file will be started if no choice is made\n# Timeout - sets the countdown timer (in seconds) before the default OS get started automatically\n# Tune - plays a tune on the pcspeaker right before the XTLDR loads\n#\n# Another type of section is [OS-Section] which adds a new position (operating system) to the boot menu. Each type\n# of the operating system provides a set of available parameters. If unsupported option is added, it is being ignored\n# by the XT Boot Loader. The available options are:\n# SystemName - sets a long operating system name that will be shown on the boot menu\n# SystemType - specifies an OS type from a predefined list of supported boot protocols\n# SystemPath - the ARC path, eg. multi(0)disk(0)rdisk(0)partition(1)\n# KernelFile - sets kernel filename with optional path relative to SystemPath\n# InitrdFile - sets initramfs image filename with optional path relative to SystemPath\n# HalFile - sets HAL filename with optional path relative to SystemPath\n# Parameters - specifies extra boot options for the kernel\n\n[XTLDR]\nTune=400 880 2 988 2 783 2 392 2 587 3\nDebug=COM1,115200\nTimeout=30\nDefault=ExectOS\n\n[ExectOS]\nSystemName=\"ExectOS Operating System\"\nSystemType=XTOS\nSystemPath=multi(0)disk(0)rdisk(0)partition(1)/ExectOS\nKernelFile=xtoskrnl.exe\nParameters=DEBUG DEBUGPORT=COM1,115200\n\n[Windows]\nSystemName=\"Microsoft Windows 2000\"\nSystemType=NT50\nSystemPath=multi(0)disk(0)rdisk(0)partition(2)/Windows\nKernelFile=ntoskrnl.exe\nHalFile=hal.dll\nParameters=/NOGUIBOOT /MININT\n\n[Linux]\nSystemName=\"GNU/Linux\"\nSystemType=LINUX\nSystemPath=multi(0)disk(0)rdisk(0)partition(3)/boot\nKernelFile=vmlinuz\nInitrdFile=initramfs.cpio.gz\nParameters=root=/dev/xvda3 rootfstype=ext4", &ConfigSections); BlConsolePrint(L"XTLDR boot loader v%s\n", XTOS_VERSION); /* Parse configuration options passed from UEFI shell */