Commit graph

67 commits

Author SHA1 Message Date
Hermès Bélusca-Maïto d05be0da3f
[FREELDR] Some ARC-spec compatibility refactoring + simplifications & fixes.
CORE-9023

- During loading and initialization of the list of operating systems
  available in freeldr.ini, convert any legacy operating system entry
  encountered -- they are like those in NTLDR's boot.ini file, i.e.:

    ArcOsLoadPartition="LoadIdentifier" /List /of /Options

  into a new operating system INI entry, like those used by default in
  FreeLoader. This allows us to avoid treating this corner-case later in
  different parts of the code. Also, the "BootType" value is now
  determined there, only once.

- Convert the OS loaders entry-points to ARC-compatible ones, following
  the "Advanced RISC Computing Specification, Version 1.2" specification
  https://www.netbsd.org/docs/Hardware/Machines/ARC/riscspec.pdf

- Introduce helpers for retrieving options values from the argument vector
  in a simple way.

- Simplify LoadOperatingSystem(), since now the "BootType" value has
  been determined once while loading the list of OSes (see above) and
  is well-defined there. Use the BuildArgvForOsLoader() helper to build
  the ARC-compatible argument vector from the corresponding INI settings
  for the selected operating system entry, and use it when calling the
  corresponding OS loader.

- In the OS loaders, since we can now directly read the settings from
  the argument vector (instead of using INI settings), we can avoid
  using a bunch of fixed-size string buffers, and avoid potentially
  failing IniOpenSection() calls as well.

- Simplify code in the Linux loader (and the RemoveQuotes() function).

- Add UiShowMessageBoxesInArgv() that acts on the "MessageBox=" settings
  passed through the argument vector (equivalent to
  UiShowMessageBoxesInSection() ).

- Use string-safe functions where needed (copy/concatenation/printf on
  fixed-size buffers).
2019-08-06 23:40:05 +02:00
Hermès Bélusca-Maïto d21ffe6336
[FREELDR] Add an INI helper that allows modifying an existing setting's value in memory. 2019-08-06 23:39:53 +02:00
Hermès Bélusca-Maïto 909bfff460
[FREELDR] Some initialization fixes.
- Initialize BootPath and BootOptions buffers when fallback behaviour is not taken.
- Correctly skip all the understood whitespace (space & tabs) and the
  quotes before reading the boot options when using the alternative syntax:

  [Operating Systems]
  section_name = "ReactOS" /bootoptions

  Fixes the minor regression introduced in 370e8564 (r43875).
2019-08-04 17:47:04 +02:00
Hermès Bélusca-Maïto b978d42bd9
[FREELDR] Whitespace, minor code styles and comments fixes only. 2019-08-04 17:47:04 +02:00
Hermès Bélusca-Maïto e79e7bf53c
[FREELDR] Unload freeldr.ini file before booting. 2019-08-04 17:47:03 +02:00
Hermès Bélusca-Maïto 5cdb76094c
[FREELDR] Use NOGUIBOOT when booting in Safe-Mode. 2019-08-04 17:47:03 +02:00
Hermès Bélusca-Maïto b382145539
[FREELDR] Improve some *GetFileInformation() traces. 2019-07-30 00:57:22 +02:00
Stanislav Motylkov ef76709b3d [FREELDR] Fix remaining hwdisk and FATX bugs (#1766)
- DiskGetFileInformation() should return relative addresses -- relative to the beginning of the "device" (partition, or disk) in question.
- FatXSearchDirectoryBufferForFile() should assign file attributes.
- Minor code style improvements in FatOpenVolume().

CORE-16216 CORE-16248

Co-authored-by: Victor Perevertkin <victor@perevertkin.ru>
2019-07-30 00:27:36 +02:00
Stanislav Motylkov 06b77b8572 [FREELDR] Implement proper partition type detection and handling (#1762)
- This allows to detect and dynamically handle different partitioning schemes.
- Implemented detection of MBR, GPT, Xbox-BRFR, and partitionless disks.
- Currently only MBR and Xbox-BRFR partitions are handled and tested.

CORE-9841 CORE-15768 CORE-16216 CORE-16248
2019-07-29 14:25:54 +02:00
Stanislav Motylkov 8f25e464c2 [FREELDR] Trivial improvements (#1757)
* [FREELDR] Fix uninitialized string in DiskGetBootPath()

CORE-16216 CORE-16248

* [FREELDR] xboxdisk: Add comment and fix code style
2019-07-28 18:20:53 +02:00
Timo Kreuzer 8f050e66fd [FREELDR] Use RtlStringCbPrintfA instead of sprintf
Fixes GCC 8 warnings like:
boot/freeldr/freeldr/disk/scsiport.c:806:31: error: 'partition(0)' directive writing 12 bytes into a region of size between 1 and 64 [-Werror=format-overflow=]
     sprintf(PartitionName, "%spartition(0)", ArcName);
                               ^~~~~~~~~~~~
boot/freeldr/freeldr/disk/scsiport.c:806:5: note: 'sprintf' output between 13 and 76 bytes into a destination of size 64
     sprintf(PartitionName, "%spartition(0)", ArcName);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2019-07-20 13:56:18 +02:00
Stanislav Motylkov 74bcf3083d [FREELDR] Abstract VGA BIOS specific code (#1736)
* [FREELDR] Abstract VGA BIOS specific code

WinLdrSetupSpecialDataPointers() uses INT 10h video interrupts, but they are not available on Xbox, so make them machine-specific.

CORE-16204 CORE-16210

* [FREELDR] Abstract getting extended BIOS data area

WinLdrSetupSpecialDataPointers() uses INT 15h AH=C1h to get extended BIOS data area, but it's not available on Xbox, so make it machine-specific.

CORE-16204 CORE-16210
2019-07-18 23:09:59 +02:00
Stanislav Motylkov 7547f85b7e [FREELDR] Abstract floppy drive detection code (#1735)
Make floppy detection code machine-specific, because Xbox CMOS cannot be used to detect floppies. Based on a patch by Matt Borgerson.

CORE-16204 CORE-16207

Co-authored-by: Matt Borgerson <contact@mborgerson.com>
2019-07-18 22:50:48 +02:00
Stanislav Motylkov bca8093b89 [FREELDR] Fix memory initialization on Xbox
- Refactor and use PC memory map init functions
- This fixes filesystem detection and probably some other problems

Based on a patch by Matt Borgerson.

CORE-16204 CORE-16206

Co-authored-by: Matt Borgerson <contact@mborgerson.com>
2019-07-18 22:49:51 +02:00
Stanislav Motylkov 8c55fdd17c [FREELDR] Whitespace improvements - no code changes 2019-07-18 22:49:51 +02:00
Stanislav Motylkov 31aca248a1 [FREELDR] hwdisk: Add sanity checks to avoid infinite loop (#1731)
CORE-16204 CORE-16205
2019-07-18 22:49:11 +02:00
Victor Perevertkin 12542f271d
[FREELDR] Fix Release build 2019-06-26 00:56:21 +03:00
Yaroslav Kibysh f37fb1f7f8
[FREELDR] Always change video mode back to text-mode before starting up ReactOS.
CORE-16116

- This allows getting the /NOGUIBOOT mode working correctly, as the latter
  expects text-mode. Then, usetup (via BLUE driver) will change to a
  different text-mode, or, GUI boot will change (via BOOTVID) to VGA
  640*480 16-color.

- Always hide the VGA cursor.

- Remove also the deprecated boolean "Setup" in the *PrepareForReactOS()
  functions.

Co-authored-by: Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
2019-06-25 02:32:09 +02:00
Hermès Bélusca-Maïto 2e1f594d5e
[FREELDR] Add some missing UiDrawBackdrop() calls. 2019-04-22 19:33:20 +02:00
Timo Kreuzer f9a967b2ae [REACTOS] Fix misc 64 bit issues 2019-04-13 14:07:50 +02:00
Jérôme Gardou 157a509a0f [CMAKE] Also set blank DEFINE_SYMBOL property for freeldr helpers 2019-04-06 17:43:38 +02:00
Hervé Poussineau a15160cd45 [FREELDR] Prevent a warning in Xbox memory initialization 2019-04-01 11:38:32 +02:00
Michael Fritscher 4928e800a6 [FREELDR] PXE: Fix network packet size
1024 bytes should fit into a single network packet. CORE-15706
2019-02-19 16:04:20 +01:00
Hermès Bélusca-Maïto 7d0cd6e937
[FREELDR][SDK:CMAKE] Move the `MSVC "linker script" file' functionality out of FreeLdr's cmake file and place it in the dedicated files instead. 2019-02-10 00:43:31 +01:00
Oleksandr Shaposhnikov a5c5ba17e5 [FREELDR] Fix VSSolution configuring and build
"configure.cmd VSSolution" was failing due to add_asm_files macro
 expansion. It was using the same 'freeldr_linker_file' variable name
 as a temporary filename base twice. This patch uses '_target'
 parameter to make those variable names differ.
2019-02-10 00:25:04 +01:00
Andrew Cook d8e92b5a0a Merge pull request #1335 from ariscop/CMP0065
Fixes for upstream cmake
2019-02-03 12:57:20 +01:00
Hermès Bélusca-Maïto 8077da05e0
[FREELDR] Remove unneeded ASSUME line. 2019-01-31 23:51:00 +01:00
Mark Jansen 71e13274ee [FREELDR] Fix msvc boot (#1329)
CORE-15700
2019-01-31 23:42:20 +01:00
Hermès Bélusca-Maïto 6b1e1df5c9
[FREELDR] Re-integrate the ASM files (and corresponding C code) in MSVC builds, that were previously compiled just for GCC builds. (#1224)
- Multiboot support added back in FreeLdr MSVC builds so that it can be
  booted using e.g. GRUB. See CORE-15563.

- Re-introduce the disk drive mapper code.
2019-01-27 00:51:26 +01:00
Hermès Bélusca-Maïto ed83552229
[FREELDR] Introduce a MSVC "linker script" file that centralizes the commands for defining section-limit symbols, and the ordering and merging of PE sections, and the necessary CMake code to use it. (#1224)
As the MSVC linker alone doesn't permit such control, the file uses
ASM language (C can alternatively be used), together with extra linker
command-line switches.

It is pre-processed 3 times: first for generating the ASM code, second
for the C code and the third time for generating the linker response
file.

In our case, the ASM code defines the __bss_start__ and __bss_end__
symbols that allow us to find the limits of the .bss section (which is
by the way automatically appended to the .data section by the MSVC linker).
The C code is used to specify the list of linker switches that can be
passed through the `#pragma comment(linker, ...)' directive (the can be
alternatively specified in the linker response section).
Finally the linker response section contains all the linker switches
that cannot be specified with the `#pragma comment(linker, ...)'
directive.

Using all this we can recycle the BSS initialization code, that has been
written originally for GCC only, also for the MSVC builds.

Also, remove the outdated .text16 section merging.
2019-01-27 00:51:25 +01:00
Hermès Bélusca-Maïto aaee856cea
[FREELDR] Minor code maintenance.
- Whitespace;

- Explicitly use string pooling (option "/GF"), so that even if it's
  used globally in the main ReactOS CMAKE file or not, we still have it
  there, because we are quite size-constrained;

- Rename the source lists (OK, we understand it's _COMMON_ ...);
- Remove redundant double inclusion of linuxboot.c;
- In the 'freeldr_common' static library, compile the ASM code first.
2019-01-27 00:51:19 +01:00
Hermès Bélusca-Maïto d272866550
[FREELDR] Minor code formatting; constify some non-mutable data. 2019-01-06 18:42:01 +01:00
Hermès Bélusca-Maïto 5053f1f571
[FREELDR] Simplify code by using a AddReactOSArcDiskInfo() helper, and few extra additions.
- Introduce the AddReactOSArcDiskInfo() helper to get rid of the
  duplicated reactos_arc_disk_info usage scattered amongst different
  files.

- GetHarddiskInformation(): If we cannot read the disk that has been
  enumerated by the BIOS, return a default identifier string.

- GetHarddiskInformation(): The last character of the disk identifier
  string corresponds to whether its MBR is "valid"/has the 0xAA55
  signature (use 'A') or whether it's not (use 'X'). Tested on Windows.

- Split PcInitializeBootDevices() in two: the first part of this
  function that enumerates hard disks from the BIOS is now moved into
  EnumerateHarddisks().

- The 'ValidPartitionTable' field of the ARC disk signature records must
  be initialized with correct value that is specified in the different
  AddReactOSArcDiskInfo() calls.
2019-01-05 19:39:32 +01:00
Timo Kreuzer cfd1647914
[REACTOS] Fix misc 64 bit issues (#783)
* [WIN32K] Fix handle calculation in DbgGdiHTIntegrityCheck
* [NOTEPAD] Fix MSVC warnings
* [PSDK] Simplify *PROC definitions in windef.h
* [VIDEOPRT] Don't try to use NtVdmControl on x64
* [FREELDR] Fix some macros
* [CRT] Make qsort 64 bit compatible
* [NTOS] Use #ifndef _WIN64 instead of #ifdef _M_IX86 around C_ASSERTs
* [FAST486] Fix 64 bit warnings and change DWORD to ULONG, so it can be used in kernel mode
* [APPHELP_APITEST] Fix 64 bit issue
2019-01-05 10:50:11 +01:00
Hermès Bélusca-Maïto 6d5a7b1ce3
[FREELDR] Explicitly call RamDiskInitialize() in RamDiskLoadVirtualFile(). 2018-12-30 15:26:44 +01:00
Timo Kreuzer 71fefa32db
[NDK][NTOS] Add global definition of INIT_FUNCTION/INIT_SECTION (#779)
* Add an NDK header to define INIT_FUNCTION/INIT_SECTION globally
* Use _declspec(allocate(x)) and _declspec(code_seg(x)) on MSVC versions that support it
* Use INIT_FUNCTION on functions only and INIT_SECTION on data only (required by MSVC)
* Place INIT_FUNCTION before the return type (required by MSVC)
* Make sure declarations and implementations share the same modifiers (required by MSVC)
* Add a global linker option to suppress warnings about defined but unused INIT section
* Merge INIT section into .text in freeldr
2018-12-30 12:19:11 +01:00
Hermès Bélusca-Maïto f8d3f9de29
[FREELDR] Check for any user keypress in menu even when the timeout is zero.
Before taking any default action if there is no timeout, check whether
the supplied key filter callback function may handle a specific user
keypress. If it does, the menu timeout is cancelled.

This allows e.g. handling F8 press for displaying boot options even when
the timeout is zero.

CORE-14046
2018-11-25 17:09:19 +01:00
Hermès Bélusca-Maïto c34fc6329f
[FREELDR] Silence a debug print. 2018-10-28 18:17:33 +01:00
Hermès Bélusca-Maïto 0b2b53b9c3
[FREELDR] Adjust WinLdrInitSystemHive() and its callers to load at startup either the regular SYSTEM hive, or the SETUPREG.HIV setup system hive.
We now run the 1st-stage setup with a regular system hive, similarly to
what's done for the LiveCD, or for a regular ROS installation.
The ExpInTextModeSetup hacks I previously removed are now completely unneeded.

svn path=/branches/setup_improvements/; revision=74762
2018-10-25 00:40:05 +02:00
Hermès Bélusca-Maïto 5e705d0683
[FREELDR] Small code re-organization for the "ntldr" sub-module.
Split the "main" winldr.h header into the one containing global code
that actually doesn't really depend on the "windows" NT loader part,
and one that actually concerns code just for the NT Loader.
The latter goes into "ntldr".

svn path=/branches/setup_improvements/; revision=74743
2018-10-25 00:40:04 +02:00
Extravert-ir d0e29db1cb [FREELDR] Fix MSVC warnings C4146 (#863) 2018-09-16 16:14:07 +02:00
Victor Perevertkin 3b69eee7a6 [FREELDR][BTRFS] Implemented BTRFS support in Free Loader. Now it supports case-insensitive path lookup, symlink folowing and reading uncompressed files.
Volume boot record is also implemented, it supports reading BTRFS tree structures with upto 64k node size.
This support required to change all path in Free Loader to lowercase for better performance.
CORE-13769
2018-08-20 08:26:56 +02:00
Timo Kreuzer 81a9ce44e9
[FREELDR] Don't insert a driver into the BootDriver list twice (#755)
This happened for the livecd, where the cdfs driver was inserted twice - once since it is the driver for the boot device, and the 2nd time, because it was specified in the registry - which was then initialized twice by the kernel, leading to a name conflict when trying to create another device object, which resulted in the newly created device object to be dereferenced again and the driver unloaded. This can be seen from the debug message "(ntoskrnl\mm\ARM3\sysldr.c:955) Leaking driver: cdfs.sys"
2018-08-18 16:41:30 +02:00
Timo Kreuzer 6da93539a9
[FREELDR] Fix calculation of page lookup table (#761)
On x64 we only map 1GB of pages, so adjust MM_MAX_PAGE accordingly and also respect that value when searching for the best location of the page lookup table.
CORE-11048 #resolve
2018-08-18 12:16:33 +02:00
Serge Gautherie 7d6bda16c6
[REACTOS] Improve how some ASSERTMSG() message values are printed: enforce ending "\n".
NB: Not touching calls in "third-party" code: class and classpnp.
2018-08-08 22:03:45 +02:00
Serge Gautherie 97d3b3ce33
[REACTOS] RtlAssert(): use "%lu" as LineNumber format. 2018-08-08 21:24:07 +02:00
Timo Kreuzer 6dcf3c29e0 [FREELDR] Fix 64 bit issues 2018-08-04 19:19:34 +02:00
Victor Perevertkin 2ae1675208 [ASM] Fixed ".double" macro in asm.inc.
GAS uses ".double" symbol for declaring floating-point constants and
".quad" symbol for declaring 64-bit numbers.
This is not compatible with our macro for MASM and introduces bugs.
Now 64-bit constants are supposed to be declared using ".quad" macro.
2018-07-15 23:25:23 +02:00
Serge Gautherie c1d0d409e7 [FREELDR] PcMemGetBiosMemoryMap(): Add a default handling of entry with "EA.ErrorLog = 1". CORE-14150
This FIXME is meant as a reminder/help to actually use this data.
2018-07-01 12:03:50 +02:00
Serge Gautherie a0313c750f [FREELDR] pcmem.c: Improve output strings. No functional changes. CORE-13332
- Plus: Add missing email address in 74f92c3d86.
- Remove superfluous blank lines.
- Add 2 TRACE("FunctionName()\n").
- Use "0x%llx", not "%lu", for BaseAddress and Length. (Copypasta in my recent commits.)
- Add "0x" to 1 "%p" and 1 "%lx".
2018-07-01 12:03:50 +02:00