Commit graph

271 commits

Author SHA1 Message Date
Mark Harmstone 43a8d871bf
[FREELDR] Set LDRP_IMAGE_INTEGRITY_FORCED if necessary. (Part of PR #1905)
+ Add extra information.
Co-authored-by: Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
2019-10-14 00:49:00 +02:00
Hermès Bélusca-Maïto 3c9e562bd3
[FREELDR] Fix build with the 'Grossly Crying Compiler' (aka. GCC). 2019-10-13 21:07:23 +02:00
Hermès Bélusca-Maïto c85ef31f6a
[FREELDR] Improvements for GDT descriptors initialization.
Triggered by a fix attempt by M.Harmstone in PR #1905.

- Introduce #defines and helper functions so as to initialize the
  descriptors in a human-readable and tractable way, without magic values.

- Rework some comments.

- Document what the changes are in (Longhorn and) Vista+.

Data has been obtained through using the WinDbg command: dg 0x00 0xFF
(for example), that lists all the selectors from 0x00 to 0xFF included.
See https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/dg--display-selector-
for more details.
2019-10-13 19:57:54 +02:00
Stanislav Motylkov 297abde716 [FREELDR][XBOXVMP] Retrieve screen resolution directly from NV2A GPU (#1962)
CORE-16216
2019-10-09 23:27:22 +02:00
Hermès Bélusca-Maïto 7909284220
[FREELDR] Advance the file pointers every time a read operation is performed, in accordance with the ARC specification. 2019-10-09 03:26:48 +02:00
Hermès Bélusca-Maïto db15c921e8
[FREELDR] Improvements for the RamDisk support.
- Implement support for the "RDIMAGELENGTH" and "RDIMAGEOFFSET" boot
  options. Fixes CORE-15432.

- Separate the initialization of the global gInitRamDiskBase /
  gInitRamDiskSize variables from the FreeLdr command-line, and the
  actual initialization of the internal variables of the RamDisk.
  The latter are initialized via calls to RamDiskInitialize().

- Implement 'SeekRelative' mode in RamDiskSeek().

- Make RamDiskLoadVirtualFile() internal function that gets called by
  RamDiskInitialize(), and we use the latter in the NT loader instead.
2019-10-09 03:26:41 +02:00
Stanislav Motylkov 034820ca55 [FREELDR] Xbox memory management improvements (#1961)
- Reuse the framebuffer address that was set up by the firmware.
- Get rid of XboxMemReserveMemory() and use ReserveMemory() instead.

CORE-16216
2019-10-09 02:35:07 +02:00
maharmstone 90ac794bf2 [FREELDR] Handle Btrfs sparse extents (#1959) 2019-10-08 16:50:57 +02:00
Hermès Bélusca-Maïto 63e22b8287
[FREELDR] Add support for loading Linux in x64 FreeLdr. Part 2/2: C code.
- Re-enable custom and Linux boot menu entries.
- Fix compilation and add address limit checks for x64 build of linux loader.
2019-10-08 01:30:25 +02:00
Hermès Bélusca-Maïto 0d6631c2da
[FREELDR] Fix an inconsistency bug when switching the CPU state back to 16-bit real mode.
Basically it appeared that without this fix, the CPU was somehow residing
in an inconsistent state, that made it crash when a full 16-bit real-mode
to 32-bit protected mode transition occurred. (Encountered when trying
to load Linux, see problem description below.)
In that situation, Bochs reports that the CPU is in "compatibility mode".

The fix is based from information from Fig.1-6 "Operating Modes of the
AMD64 Architecture" (page 12) and Chapter 14 (pages 429-446) of the
"AMD64 Architecture Programmer’s Manual Volume 2: System Programming"
https://www.amd.com/system/files/TechDocs/24593.pdf

*** THE PROBLEM ***

When booting Linux using x86 FreeLdr everything goes well.

When trying to do the same using x64 FreeLdr, the Linux code (both the
boot sector, the setup sector and the main kernel contents) is all
correctly loaded and relocated in memory as in the x86 case. We then pass
control to the decompressing code that appears to succeed. However, once
it has finished and "Parsing ELF file..." step has been run, the next
step "Booting the kernel..." crashes with a CPU Triple-Fault.

This problem **DOES NOT HAPPEN** when booting from GRUB.

Log excerpt from Bochs:

<snip>

00089459736i[BIOS  ] Booting from 07c0:0000
00089782775i[SER   ] com1: FIFO enabled
00095994535i[BIOS  ] int13_harddisk: function 41, unmapped device for ELDL=81
00095998517i[BIOS  ] int13_harddisk: function 08, unmapped device for ELDL=81
00397139785i[BIOS  ] KBD: unsupported int 16h function 03
00397143625i[BIOS  ] *** int 15h function AX=e980, BX=0000 not yet supported!
00523008104e[CPU0  ] interrupt(long mode): vector must be within IDT table limits, IDT.limit = 0x0
00523008104e[CPU0  ] interrupt(long mode): vector must be within IDT table limits, IDT.limit = 0x0
00523008104i[CPU0  ] CPU is in compatibility mode (active)
00523008104i[CPU0  ] CS.mode = 32 bit
00523008104i[CPU0  ] SS.mode = 32 bit
00523008104i[CPU0  ] EFER   = 0x00000500
00523008104i[CPU0  ] | RAX=00000000e0000011  RBX=0000000000000000
00523008104i[CPU0  ] | RCX=0000000000000000  RDX=0000000000000000
00523008104i[CPU0  ] | RSP=00000000004f8000  RBP=000000000082e003
00523008104i[CPU0  ] | RSI=0000000000099800  RDI=00000000c0611000
00523008104i[CPU0  ] |  R8=0000000000109000   R9=0000000000009020
00523008104i[CPU0  ] | R10=00000000000007e3  R11=000000000000e958
00523008104i[CPU0  ] | R12=0000000000000000  R13=0000000000000000
00523008104i[CPU0  ] | R14=0000000000000000  R15=0000000000000000
00523008104i[CPU0  ] | IOPL=0 id vip vif ac vm RF nt of df if tf SF zf af PF cf
00523008104i[CPU0  ] | SEG sltr(index|ti|rpl)     base    limit G D
00523008104i[CPU0  ] |  CS:0010( 0002| 0|  0) 00000000 ffffffff 1 1
00523008104i[CPU0  ] |  DS:0018( 0003| 0|  0) 00000000 ffffffff 1 1
00523008104i[CPU0  ] |  SS:0018( 0003| 0|  0) 00000000 ffffffff 1 1
00523008104i[CPU0  ] |  ES:0018( 0003| 0|  0) 00000000 ffffffff 1 1
00523008104i[CPU0  ] |  FS:0018( 0003| 0|  0) 00000000 ffffffff 1 1
00523008104i[CPU0  ] |  GS:0018( 0003| 0|  0) 00000000 ffffffff 1 1
00523008104i[CPU0  ] |  MSR_FS_BASE:0000000000000000
00523008104i[CPU0  ] |  MSR_GS_BASE:0000000000000000
00523008104i[CPU0  ] | RIP=0000000000409327 (0000000000409327)
00523008104i[CPU0  ] | CR0=0xe0000011 CR2=0x0000000000409327
00523008104i[CPU0  ] | CR3=0x005b5000 CR4=0x000000a0
00523008104i[CPU0  ] 0x0000000000409327: (instruction unavailable) page not present
00523008104p[CPU0  ] >>PANIC<< exception(): 3rd (13) exception with no resolution

<snip>
2019-10-08 01:30:15 +02:00
Hermès Bélusca-Maïto 25badcfbbd
[FREELDR] Add support for loading Linux in x64 FreeLdr. Part 1/2: ASM code.
Add also ASM implementation for intrinsics that may not be always
present on MSVC (e.g. MSVC 2010).
2019-10-07 02:57:48 +02:00
Hermès Bélusca-Maïto 21c51eed05
[FREELDR] Several changes regarding chainloading and Linux boot.
- Introduce "Relocator16Boot()". So far its aim is just to correctly set
  the CPU state (segments, registers, flags) to what is expected by a
  given boot image before running it.
  This function can be seen as the embryonic state of a future boot relocator
  (see e.g. GRUB or SYSLINUX) that would also relocate the boot image at
  the correct places. (Such feature is needed when boot images have to
  be loaded in memory areas that cover where the boot loader is in memory.)

- Implement ChainLoadBiosBootSectorCode() around it.

- Replace BootOldLinuxKernel() and BootNewLinuxKernel() by a new
  BootLinuxKernel() function (in assembly) that relocates the kernel
  to a given position and then boot it, using Relocator16Boot().
  Ideally the relocation should be done by a future boot relocator...

Implementation notes for Relocator16Boot():
===========================================

For setting the CPU state the function is based on a similar code as the
Int386() helper, namely it takes a pointer to REGS structure and pass
this information through the 32->16 bits call before setting the CPU state
in accordance.
New stack segment/pointer and code segment/pointer are also specified.
For passing these values through the 32->16 bits call the 16-bit BSS
memory offsets "BSS_CallbackReturn" and "BSS_RealModeEntry" (respectively)
are reused.
2019-10-07 02:54:07 +02:00
Hermès Bélusca-Maïto 2d1a6b2db9
[FREELDR] NT loader: Allocate the Loader Block Extension much earlier in the process. 2019-10-06 18:24:48 +02:00
Hermès Bélusca-Maïto eeeca29c6c
[FREELDR] INFFILE Parser: Fix while-loop conditions, this bug existed for 16+ years (commit 939d5316, revision 4758). 2019-10-06 18:18:34 +02:00
Mark Harmstone 9ad0dd1856
[FREELDR] Retrieve the correct ACPI RSDP table address. (#1951)
Use either the RSDT (ACPI 1.0) or the XSDT (ACPI >1.0).
This fixes ACPI issues with Vista on VirtualBox.
2019-10-05 23:20:53 +02:00
Mark Harmstone f551caa840
[FREELDR] Load the Firmware Errata file specified in the registry. (#1951)
On Windows <= 2003 (and current ReactOS), this is the "InfName" value
in the "HKEY_LOCAL_MACHINE\CurrentControlSet\Control\BiosInfo\" key.
(The default file name found there is 'biosinfo.inf'.)

On Vista+, this is the "InfName" value in the
"HKEY_LOCAL_MACHINE\CurrentControlSet\Control\Errata\" key.
(The default file name found there is 'errata.inf'.)

For 1st-stage setup, the file is specified in the "InfName" value of
the "BiosInfo" section in the TXTSETUP.SIF file.

Co-authored-by: Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
2019-10-05 23:20:53 +02:00
Mark Harmstone 22fbfb0df9
[FREELDR] Insert DLLs into load order before what references them. (#1951) 2019-10-05 23:20:52 +02:00
Mark Harmstone fc9c3fe6f7
[FREELDR] Set LDRP_DRIVER_DEPENDENT_DLL where necessary. (#1951) 2019-10-05 23:20:52 +02:00
Mark Harmstone b3f45a25c5
[FREELDR] Fix bug in Btrfs filename lookups. (#1951) 2019-10-05 23:20:51 +02:00
Pierre Schweitzer 17db4217a8
[FREELDR] Stop asking people to report bugs on ros-dev@reactos.org
That should be merged to 0.4.13
2019-10-03 02:55:45 +02:00
Victor Perevertkin 220bc820eb [FREELDR] Optimize and refactor the FAT driver.
Do not read the whole cluster chain for file on opening.
This removes restriction for opening files which span
within a large amount of clusters (>65k). That happened because
FrLdrTempAlloc cannot allocate more than about 256 KiB of memory.

Adjacent clusters for file are now read using one disk driver call.
2019-09-29 13:24:31 +03:00
Victor Perevertkin 195dc30484 [FREELDR] Add FAT caching to FAT filesystem driver.
This significantly increases the reading speed
2019-09-29 13:24:31 +03:00
Lee Schroeder 43f03da358 [MSXML3R] XML/XSL file description localization (#1926)
Add localization for the file description of both XML and XSL file formats.
Please check for copypasta errors!

CORE-16390

Co-Authored-By: Stanislav Motylkov <x86corez@gmail.com>
2019-09-23 23:30:53 +02:00
Hermès Bélusca-Maïto dff75d7162
OOPS - Nothing to see there :P
Revert commit 16a35353.
2019-09-21 04:38:47 +02:00
Hermès Bélusca-Maïto 16a3535378
WIP testing ISO 2019-09-21 04:28:28 +02:00
Adam Słaboń c81af08f51 [TRANSLATION] Polish translation update (#1916)
Added translation for netstat, utilman and netplwiz. Updated translation of find, reg, rapps, regedit, sndvol32, usetup, hivesys, mmsys, openglcfg, powercfg, sysdm, shellext, browseui, devmgr, msgina, netcfgx, shell32, syssetup, shortcuts and vcdcontroltool.
2019-09-20 21:51:47 +02:00
Eric Kohl 2ed695fc83 [FREELDR] Hack: Boot ReactOS even when a cdrom-drive does not report a proper geometry
We need to find a way to retrieve the LBA sector count of a drive, not only its CHS geometry.
2019-09-19 23:27:11 +02:00
Hermès Bélusca-Maïto 658d5a3ff5
[FREELDR] Rename the PE loader functions 'PeLdr*' instead of 'WinLdr*'. 2019-09-19 02:53:57 +02:00
Hermès Bélusca-Maïto e18e7b100c
[FREELDR] Implement 'SeekRelative' mode for the *Seek() methods for disks & filesystems. 2019-09-18 02:42:56 +02:00
Hermès Bélusca-Maïto dd46d40fd2
[FREELDR] Addendum / actual fix for ef76709b
According to the Advanced RISC Computing Specification v1.2, for partitions,
StartingAddress and EndingAddress are the start and end positions of the
partition in terms of byte offsets from the start of the disk.
CurrentAddress is the current offset into (i.e. relative to) the partition.

Fix also the FAT filesystem in accordance.

- FIXME fix: Retrieve the size of the disk in number of sectors in DiskOpen().
- Add extra validity checks in the DiskSeek() functions.
- Explicitly call PcDisk* functions in machpc.c and pcdisk.c, and
  XboxDisk* functions in machxbox.c (the code in these files is not
  called cross-platform).

CORE-16216 CORE-16248
2019-09-18 01:12:58 +02:00
Hermès Bélusca-Maïto ff85aa0c38
[FREELDR] Other enhancements.
- Modify DiskReportError() to use an internal "display counter", so that
  imbricated DiskReportError(FALSE) ... DiskReportError(TRUE) can behave
  as expected.
- Merge LoadAndBootDrive(), LoadAndBootPartition(),
  LoadAndBootBootSector() into one LoadAndBootDevice() function + its
  helpers (in progress...).
2019-09-18 00:27:53 +02:00
Hermès Bélusca-Maïto fc29a6c41c
[FREELDR] Minor code improvements + 1 bug-fix.
- "FrldrBootPath" -> "FrLdrBootPath";
- Get rid of GetFreeLoaderVersionString() and use FrLdrVersionString
  directly instead;
- Rephrase some comments;
- Use RTL_NUMBER_OF();
- Reduce indent level in LoadOperatingSystem() and EditOperatingSystemEntry().

Bug fix:
- Fix DissectArcPath() for "ramdisk(0)" case.
2019-09-17 23:24:51 +02:00
Hermès Bélusca-Maïto a9411fb658
[FREELDR] Minor code style - use RtlZeroMemory(); shorter member name; use different debug channel. 2019-09-13 15:18:28 +02:00
Hermès Bélusca-Maïto eeff926ede
[FREELDR] Limit the usage of DiskStopFloppyMotor() in hardware/platform-specific code.
- Move DiskStopFloppyMotor() calls into the implementations of
  Boot(New)LinuxKernel() and Reboot() HW functions, and the explanation
  comments in ChainLoadBiosBootSectorCode().

- Remove unneeded DiskStopFloppyMotor() dummies in ARM and PPC code.

- Use more adequate bitmask value to be sent to floppy's Digital Output
  Register for shutting down its motor (based on OSDev & our floppy
  controller driver).
2019-09-13 15:18:27 +02:00
Hermès Bélusca-Maïto 4843c1a954
[FREELDR] Other enhancements.
- Add optional arguments BootDrive and BootPartition to
  ChainLoadBiosBootSectorCode() so as not to modify explicitly the
  FrldrBootDrive and FrldrBootPartition variables, that should remain
  purely internal.

- Implement ChainLoadBiosBootSectorCode() for x64.

- Get rid of the machine-specific DiskGetBootPath(), and instead do its
  job only once in the machine-specific InitializeBootDevices() (or in
  MachInit() for PPC).
  Cache the result of this operation into the globally-accessible
  FrldrBootPath buffer. This avoids the unneeded calls to (Mach)DiskGetBootPath()
  we used to do before.
  Also remove the separate distinction between the PC and XBOX versions
  of this functionality.

- Move the PC-specific DiskIsDriveRemovable() and DiskGetBootPath()
  as well as the disk-IO-error functionality, back into the
  corresponding PC-arch files.

- Simplify IniFileInitialize(), getting rid of IniOpenIniFile().
2019-09-13 15:18:07 +02:00
Timo Kreuzer 85616bc8b2 [SETUP] Add support for archtitcure specific inf sections and use it for x64 computer type 2019-09-08 10:42:16 +02:00
Victor Perevertkin bc44b334d7
[TXTSETUP] Revert an accidental change 2019-09-04 17:54:00 +03:00
Victor Perevertkin 6392c5a78c
[USBHUB_NEW] Enable generic USB hubs (USB class 09)
They actually work, tested on a couple of real devices
2019-09-04 05:26:02 +03:00
Eric Kohl 90c9a67993 [BOOTDATA] Add missing descriptions for the wuauserv service 2019-08-31 18:19:53 +02:00
Eric Kohl fa0eef085c [BOOTDATA][LSASRV] Add the security service(s)
- Add the service routines for the SamSs service.
- Start the SamSs service.
2019-08-31 18:17:14 +02:00
Hermès Bélusca-Maïto bd451f240f
[FREELDR] Code fixes and enhancements.
CORE-9023

FIXES:
======

- Fix parsing of the multiboot options string.
  NOTE: They are not yet treated in a case-insensitive manner!

- Fix a bug in ArcOpen() so that it correctly skips the first path
  separator (after the adapter-controller-peripheral ARC descriptors).
  The path separator can be either a backslash or a slash (both are
  allowed according to the specs); they were also already handled
  correctly in other parts of the code.

- Fix DissectArcPath() so as to:
  * **OPTIONALLY** (and not mandatorily!) return the path part that follows
    the ARC adapter-controller-peripheral elements in the ARC path;

  * make it correctly handle the (yes, optional!!) partition() part in the
    ARC path, for the multi(x)disk(y)rdisk(z) cases.

ENHANCEMENTS:
=============

- Directly retrieve the default OS entry as we enumerate them and
  build their list (i.e. merge the GetDefaultOperatingSystem() helper
  within InitOperatingSystemList()).

- Directly use the opened 'FreeLoader' INI section via its ID in the
  different functions that need it.

- Make the custom-boot and linux loaders honour the boot options they are
  supposed to support (see FREELDR.INI documentation / template).
  This includes the 'BootDrive' and 'BootPartition' (alternatively the ARC
  'BootPath').
  This also allows them to take into account the user-specified choices in the
  FreeLdr custom-boot editors.

- Modify the FreeLdr custom-boot editors so as to correctly honour
  the  priorities of the boot options as specified in the FREELDR.INI
  documentation / template.

- Use stack trick (union of structs) to reduce stack usage in the
  FreeLdr custom-boot editors, because there are strings buffers that are
  used in an alternate manner.

- Extract out from the editors the LoadOperatingSystem() calls, and
  move it back into OptionMenuCustomBoot(), so that when this latter
  function is called there is no risk of having a stack almost full.

- When building the ARC-compatible argument vector for the loaders, add
  the mandatory "SystemPartition" path. This allows the loaders to NOT
  call the machine-specific MachDiskGetBootPath() later on (this data is
  indeed passed to them by the boot manager part of FreeLdr).

- Improve the FsOpenFile() helper so as to make it:
  * return an adequate ARC_STATUS instead of a mere uninformative BOOLEAN;
  * take open options, as well as a default path (optional) that would be
    prepended to the file name in case the latter is a relative one.

- Make RamDiskLoadVirtualFile() return an actual descriptive ARC_STATUS
  value, and make it take an optional default path (same usage as the one
  in FsOpenFile() ).
  + Remove useless NTAPI .

- UiInitialize() and TuiTextToColor(), TuiTextToFillStyle(): load or
  convert named settings into corresponding values using setting table and
  a tight for-loop, instead of duplicating 10x the same parameter reading
  logic.

- UiInitialize(): Open the "Display" INI section just once. Remove usage
  of DisplayModeText[] buffer.

- UiShowMessageBoxesInSection() and UiShowMessageBoxesInArgv(): reduce
  code indentation level.

ENHANCEMENTS for NT OS loader:
==============================

- Don't use MachDiskGetBootPath() but use instead the "SystemPartition"
  value passed via the ARC argument vector by the boot manager
  (+ validation checks). Use it as the "default path" when calling
  FsOpenFile() or loading the ramdisk.

- Honour the FreeLdr-specific "Hal=" and "Kernel=" options by converting
  them into NT standard "/HAL=" and "/KERNEL=" options in the boot
  command line.

  Note that if the latter ones are already present on the standard "Options="
  option line, they would take precedence over those passed via the separate
  "Hal=" and "Kernel=" FreeLdr-specific options.

  Also add some documentation links to Geoff Chappell's website about
  how the default HAL and KERNEL names are chosen depending on the
  detected underlying platform on which the NT OS loader is running.
2019-08-31 01:42:46 +02:00
Hermès Bélusca-Maïto 602fc29ad4
[FREELDR] Formatting only. 2019-08-31 01:42:40 +02:00
Hermès Bélusca-Maïto 98a44b4f9b
[FREELDR] Update the FREELDR.INI documentation / template. 2019-08-31 01:42:23 +02:00
Hermès Bélusca-Maïto 41ad62ea69
[FREELDR] Move around & static-ify some disk/partition functions. 2019-08-31 00:25:06 +02:00
Stanislav Motylkov 8c36145087 [XBOXVMP] Add Xbox video miniport driver
Also make XboxVmp driver compatible with Video Port driver, specify
vendor id and device id explicitly in VideoPortGetAccessRanges() call

CORE-16317
2019-08-31 00:19:03 +02:00
Mark Jansen 93b2d5597e
[FREELDR][ARM] Suppress error about unused var 2019-08-20 22:28:11 +02:00
Mark Jansen a380a61605
[BOOTLIB] Disable some x86 / x64 specific code for other architectures 2019-08-20 22:28:11 +02:00
Mark Jansen 9592728f55
[ROSLOAD] Disable some arch-specific code for arm 2019-08-20 22:28:10 +02:00
Mark Jansen 28b866cc9c
[CMAKE] Add explicit failure message
Previously this would show up as dependency cycle
2019-08-20 22:28:10 +02:00
Victor Perevertkin 88cf5b0a3c
[USB] Enable *_new usb stack 2019-08-20 01:34:58 +03:00