Reactos

[FREELDR] Implement NOSERIALMICE and FASTDETECT options (#5886)

Enable FASTDETECT by default, as done in NT 5+. This is because
the serial mouse is recognized by the serial stack since NT 5.x.

authored by

Dmitry Borisov and committed by
Hermès Bélusca-Maïto
8d7153c8 10e7643c

+86 -18
+1 -1
base/setup/lib/bootsup.c
··· 73 73 /* ReactOS */ 74 74 // BootEntry->BootEntryKey = MAKESTRKEY(L"ReactOS"); 75 75 BootEntry->FriendlyName = L"\"ReactOS\""; 76 - Options->OsLoadOptions = NULL; // L""; 76 + Options->OsLoadOptions = L"/FASTDETECT"; 77 77 AddBootStoreEntry(BootStoreHandle, BootEntry, MAKESTRKEY(L"ReactOS")); 78 78 79 79 /* ReactOS_Debug */
+7 -7
boot/bootdata/livecd.ini
··· 18 18 [LiveCD] 19 19 BootType=Windows2003 20 20 SystemPath=\reactos 21 - Options=/MININT 21 + Options=/FASTDETECT /MININT 22 22 23 23 [LiveCD_Debug] 24 24 BootType=Windows2003 25 25 SystemPath=\reactos 26 - Options=/DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200 /SOS /MININT 26 + Options=/DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200 /SOS /FASTDETECT /MININT 27 27 28 28 [LiveCD_Macpi] 29 29 BootType=Windows2003 30 30 SystemPath=\reactos 31 - Options=/HAL=halmacpi.dll /KERNEL=ntkrnlmp.exe /DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200 /SOS /MININT 31 + Options=/HAL=halmacpi.dll /KERNEL=ntkrnlmp.exe /DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200 /SOS /FASTDETECT /MININT 32 32 33 33 [LiveCD_Aacpi] 34 34 BootType=Windows2003 35 35 SystemPath=\reactos 36 - Options=/HAL=halaacpi.dll /DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200 /SOS /MININT 36 + Options=/HAL=halaacpi.dll /DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200 /SOS /FASTDETECT /MININT 37 37 38 38 [LiveCD_VBoxDebug] 39 39 BootType=Windows2003 40 40 SystemPath=\reactos 41 - Options=/DEBUG /DEBUGPORT=VBOX /SOS /MININT 41 + Options=/DEBUG /DEBUGPORT=VBOX /SOS /FASTDETECT /MININT 42 42 43 43 [LiveCD_Screen] 44 44 BootType=Windows2003 45 45 SystemPath=\reactos 46 - Options=/DEBUG /DEBUGPORT=SCREEN /SOS /MININT 46 + Options=/DEBUG /DEBUGPORT=SCREEN /SOS /FASTDETECT /MININT 47 47 48 48 [LiveCD_LogFile] 49 49 BootType=Windows2003 50 50 SystemPath=\reactos 51 - Options=/DEBUG /DEBUGPORT=FILE:\Device\HarddiskX\PartitionY\debug.log /SOS /MININT 51 + Options=/DEBUG /DEBUGPORT=FILE:\Device\HarddiskX\PartitionY\debug.log /SOS /FASTDETECT /MININT
+1 -1
boot/bootdata/txtsetup.sif
··· 216 216 DefaultPath = \ReactOS 217 217 SetupDebugOptions = "/DEBUG /KDSERIAL /DEBUGPORT=COM1 /FIRSTCHANCE" 218 218 ;SetupDebugOptions = "/DEBUG /SOS /DEBUGPORT=SCREEN" 219 - OsLoadOptions = "/NOGUIBOOT /NODEBUG" 219 + OsLoadOptions = "/FASTDETECT /NOGUIBOOT /NODEBUG" 220 220 221 221 [NLS] 222 222 AnsiCodepage = c_1252.nls
+66 -5
boot/freeldr/freeldr/arch/i386/pc/machpc.c
··· 19 19 #include <freeldr.h> 20 20 #include <cportlib/cportlib.h> 21 21 22 + #include "../ntldr/ntldropts.h" 23 + 22 24 #include <debug.h> 23 25 DBG_DEFAULT_CHANNEL(HWDETECT); 24 26 ··· 710 712 } 711 713 } 712 714 715 + static 713 716 ULONG 714 717 PcGetSerialPort(ULONG Index, PULONG Irq) 715 718 { ··· 727 730 return (ULONG) *(BasePtr + Index); 728 731 } 729 732 733 + /* 734 + * Parse the serial mouse detection options. 735 + * Format: /FASTDETECT 736 + * or: /NOSERIALMICE=COM[0-9],[0-9],[0-9]... 737 + * or: /NOSERIALMICE:COM[0-9]... 738 + * If we have /FASTDETECT, then nothing can be detected. 739 + */ 740 + static 741 + ULONG 742 + GetSerialMouseDetectionBitmap( 743 + _In_opt_ PCSTR Options) 744 + { 745 + PCSTR Option, c; 746 + ULONG OptionLength, PortBitmap, i; 747 + 748 + if (NtLdrGetOption(Options, "FASTDETECT")) 749 + return (1 << MAX_COM_PORTS) - 1; 750 + 751 + Option = NtLdrGetOptionEx(Options, "NOSERIALMICE=", &OptionLength); 752 + if (!Option) 753 + Option = NtLdrGetOptionEx(Options, "NOSERIALMICE:", &OptionLength); 754 + 755 + if (!Option) 756 + return 0; 757 + 758 + /* Invalid port list */ 759 + if (OptionLength < (sizeof("NOSERIALMICE=COM9") - 1)) 760 + return (1 << MAX_COM_PORTS) - 1; 761 + 762 + /* Move to the port list */ 763 + Option += sizeof("NOSERIALMICE=COM") - 1; 764 + OptionLength -= sizeof("NOSERIALMICE=COM") - 1; 765 + 766 + PortBitmap = 0; 767 + c = Option; 768 + for (i = 0; i < OptionLength; i += 2) 769 + { 770 + UCHAR PortNumber = *c - '0'; 771 + 772 + if (PortNumber > 0 && PortNumber <= 9) 773 + PortBitmap |= 1 << (PortNumber - 1); 774 + 775 + c += 2; 776 + } 777 + 778 + return PortBitmap; 779 + } 780 + 730 781 VOID 731 - DetectSerialPorts(PCONFIGURATION_COMPONENT_DATA BusKey, GET_SERIAL_PORT MachGetSerialPort, ULONG Count) 782 + DetectSerialPorts( 783 + _In_opt_ PCSTR Options, 784 + _Inout_ PCONFIGURATION_COMPONENT_DATA BusKey, 785 + _In_ GET_SERIAL_PORT MachGetSerialPort, 786 + _In_ ULONG Count) 732 787 { 733 788 PCM_PARTIAL_RESOURCE_LIST PartialResourceList; 734 789 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor; ··· 740 795 PCONFIGURATION_COMPONENT_DATA ControllerKey; 741 796 ULONG i; 742 797 ULONG Size; 798 + ULONG PortBitmap; 743 799 744 800 TRACE("DetectSerialPorts()\n"); 801 + 802 + PortBitmap = GetSerialMouseDetectionBitmap(Options); 745 803 746 804 for (i = 0; i < Count; i++) 747 805 { ··· 813 871 Size, 814 872 &ControllerKey); 815 873 816 - if (!Rs232PortInUse(UlongToPtr(Base))) 874 + if (!(PortBitmap & (1 << i)) && !Rs232PortInUse(UlongToPtr(Base))) 817 875 { 818 876 /* Detect serial mouse */ 819 877 DetectSerialPointerPeripheral(ControllerKey, UlongToPtr(Base)); ··· 1561 1619 1562 1620 static 1563 1621 VOID 1564 - DetectIsaBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber) 1622 + DetectIsaBios( 1623 + _In_opt_ PCSTR Options, 1624 + _Inout_ PCONFIGURATION_COMPONENT_DATA SystemKey, 1625 + _Out_ ULONG *BusNumber) 1565 1626 { 1566 1627 PCM_PARTIAL_RESOURCE_LIST PartialResourceList; 1567 1628 PCONFIGURATION_COMPONENT_DATA BusKey; ··· 1600 1661 1601 1662 /* Detect ISA/BIOS devices */ 1602 1663 DetectBiosDisks(SystemKey, BusKey); 1603 - DetectSerialPorts(BusKey, PcGetSerialPort, MAX_COM_PORTS); 1664 + DetectSerialPorts(Options, BusKey, PcGetSerialPort, MAX_COM_PORTS); 1604 1665 DetectParallelPorts(BusKey); 1605 1666 DetectKeyboardController(BusKey); 1606 1667 DetectPS2Mouse(BusKey); ··· 1647 1708 DetectPciBios(SystemKey, &BusNumber); 1648 1709 DetectApmBios(SystemKey, &BusNumber); 1649 1710 DetectPnpBios(SystemKey, &BusNumber); 1650 - DetectIsaBios(SystemKey, &BusNumber); // TODO: Detect first EISA or MCA, before ISA 1711 + DetectIsaBios(Options, SystemKey, &BusNumber); // TODO: Detect first EISA or MCA, before ISA 1651 1712 DetectAcpiBios(SystemKey, &BusNumber); 1652 1713 1653 1714 // TODO: Collect the ROM blocks from 0xC0000 to 0xF0000 and append their
+11 -4
boot/freeldr/freeldr/arch/i386/xbox/machxbox.c
··· 73 73 74 74 extern 75 75 VOID 76 - DetectSerialPorts(PCONFIGURATION_COMPONENT_DATA BusKey, GET_SERIAL_PORT MachGetSerialPort, ULONG Count); 76 + DetectSerialPorts( 77 + _In_opt_ PCSTR Options, 78 + _Inout_ PCONFIGURATION_COMPONENT_DATA BusKey, 79 + _In_ GET_SERIAL_PORT MachGetSerialPort, 80 + _In_ ULONG Count); 77 81 78 82 VOID 79 83 XboxGetExtendedBIOSData(PULONG ExtendedBIOSDataArea, PULONG ExtendedBIOSDataSize) ··· 201 205 202 206 static 203 207 VOID 204 - DetectIsaBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber) 208 + DetectIsaBios( 209 + _In_opt_ PCSTR Options, 210 + _Inout_ PCONFIGURATION_COMPONENT_DATA SystemKey, 211 + _Out_ ULONG *BusNumber) 205 212 { 206 213 PCM_PARTIAL_RESOURCE_LIST PartialResourceList; 207 214 PCONFIGURATION_COMPONENT_DATA BusKey; ··· 240 247 241 248 /* Detect ISA/BIOS devices */ 242 249 DetectBiosDisks(SystemKey, BusKey); 243 - DetectSerialPorts(BusKey, XboxGetSerialPort, MAX_XBOX_COM_PORTS); 250 + DetectSerialPorts(Options, BusKey, XboxGetSerialPort, MAX_XBOX_COM_PORTS); 244 251 DetectDisplayController(BusKey); 245 252 246 253 /* FIXME: Detect more ISA devices */ ··· 279 286 280 287 /* TODO: Build actual xbox's hardware configuration tree */ 281 288 DetectPciBios(SystemKey, &BusNumber); 282 - DetectIsaBios(SystemKey, &BusNumber); 289 + DetectIsaBios(Options, SystemKey, &BusNumber); 283 290 284 291 TRACE("DetectHardware() Done\n"); 285 292 return SystemKey;