[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).
This commit is contained in:
Hermès Bélusca-Maïto 2019-09-13 14:02:44 +02:00
parent 4843c1a954
commit eeff926ede
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
14 changed files with 42 additions and 41 deletions

View file

@ -5,6 +5,8 @@
EXTERN BootMain:PROC
// EXTERN cmdline:DWORD
EXTERN DiskStopFloppyMotor:PROC
#ifdef _USE_ML
EXTERN __bss_start__:FWORD
EXTERN __bss_end__:FWORD
@ -70,6 +72,9 @@ stop:
PUBLIC Reboot
Reboot:
/* Stop the floppy drive motor */
call DiskStopFloppyMotor
/* Set the function ID */
mov bx, FNID_Reboot
@ -102,6 +107,14 @@ continue:
/* Store the 1-byte truncated partition number in DH */
mov dh, al
/*
* Don't stop the floppy drive motor when we are just booting a bootsector,
* a drive, or a partition. If we were to stop the floppy motor, the BIOS
* wouldn't be informed and if the next read is to a floppy then the BIOS
* will still think the motor is on and this will result in a read error.
*/
// call DiskStopFloppyMotor
/* Set the function ID */
mov bx, FNID_ChainLoadBiosBootSectorCode
@ -109,6 +122,11 @@ continue:
jmp SwitchToReal
/*
* U16 PxeCallApi(U16 Segment, U16 Offset, U16 Service, VOID *Parameter);
*
* RETURNS:
*/
PUBLIC PxeCallApi
PxeCallApi:
xor eax, eax

View file

@ -59,10 +59,6 @@ ULONG LenBits[] =
/* FUNCTIONS ******************************************************************/
VOID DiskStopFloppyMotor(VOID)
{
}
VOID
FrLdrCheckCpuCompatibility(VOID)
{

View file

@ -27,6 +27,8 @@ EXTERN _i386Idt:DWORD
//EXTERN _i386idtptr:FWORD
EXTERN cmdline:DWORD
EXTERN _DiskStopFloppyMotor:PROC
#ifdef _USE_ML
EXTERN __bss_start__:DWORD
EXTERN __bss_end__:DWORD
@ -101,6 +103,9 @@ stop:
PUBLIC _Reboot
_Reboot:
/* Stop the floppy drive motor */
call _DiskStopFloppyMotor
/* Set the function ID */
mov bx, FNID_Reboot
@ -133,6 +138,14 @@ continue:
/* Store the 1-byte truncated partition number in DH */
mov dh, al
/*
* Don't stop the floppy drive motor when we are just booting a bootsector,
* a drive, or a partition. If we were to stop the floppy motor, the BIOS
* wouldn't be informed and if the next read is to a floppy then the BIOS
* will still think the motor is on and this will result in a read error.
*/
// call _DiskStopFloppyMotor
/* Set the function ID */
mov bx, FNID_ChainLoadBiosBootSectorCode

View file

@ -20,6 +20,7 @@
#include <asm.inc>
#include <arch/pc/x86common.h>
EXTERN _DiskStopFloppyMotor:PROC
EXTERN i386CallRealMode:PROC
.code32
@ -45,6 +46,8 @@ _BootOldLinuxKernel:
PUBLIC _BootNewLinuxKernel
_BootNewLinuxKernel:
/* Stop the floppy drive motor */
call _DiskStopFloppyMotor
mov bx, FNID_BootLinuxKernel
call i386CallRealMode

View file

@ -478,10 +478,12 @@ BOOLEAN PcDiskReadLogicalSectors(UCHAR DriveNumber, ULONGLONG SectorNumber, ULON
return TRUE;
}
VOID DiskStopFloppyMotor(VOID)
#if defined(__i386__) || defined(_M_AMD64)
VOID __cdecl DiskStopFloppyMotor(VOID)
{
WRITE_PORT_UCHAR((PUCHAR)0x3F2, 0);
WRITE_PORT_UCHAR((PUCHAR)0x3F2, 0x0C); // DOR_FDC_ENABLE | DOR_DMA_IO_INTERFACE_ENABLE
}
#endif // defined __i386__ || defined(_M_AMD64)
BOOLEAN DiskGetExtendedDriveParameters(UCHAR DriveNumber, PVOID Buffer, USHORT BufferSize)
{

View file

@ -534,9 +534,6 @@ void WRITE_PORT_UCHAR(PUCHAR Address, UCHAR Value) {
SetPhysByte(((ULONG)Address)+0x80000000, Value);
}
void DiskStopFloppyMotor() {
}
void BootOldLinuxKernel( unsigned long size ) {
ofw_exit();
}

View file

@ -346,9 +346,9 @@ stack16:
#include "int386.inc"
#include "helpers.inc"
#include "pxe.inc"
#include "pnp.inc"
#include "helpers.inc"
.org (FREELDR_PE_BASE - FREELDR_BASE - 1)
.byte 0

View file

@ -110,6 +110,7 @@ writehex_common:
popfd
ret
Reboot:
cli

View file

@ -198,10 +198,10 @@ rmode_idtptr:
.long 0 /* Base Address */
#include "int386.inc"
#include "helpers.inc"
#include "pxe.inc"
#include "pnp.inc"
#include "linux.inc"
#include "helpers.inc"
.org (FREELDR_PE_BASE - FREELDR_BASE - 1)
.byte 0

View file

@ -705,10 +705,6 @@ EditCustomBootReactOS(
VOID OptionMenuReboot(VOID)
{
UiMessageBox("The system will now reboot.");
#if defined(__i386__) || defined(_M_AMD64)
DiskStopFloppyMotor();
#endif
Reboot();
}

View file

@ -65,9 +65,6 @@ VOID __cdecl BootMain(IN PCCH CmdLine)
Quit:
/* If we reach this point, something went wrong before, therefore reboot */
#if defined(__i386__) || defined(_M_AMD64)
DiskStopFloppyMotor();
#endif
Reboot();
}

View file

@ -114,7 +114,7 @@ typedef struct _MASTER_BOOT_RECORD
//
///////////////////////////////////////////////////////////////////////////////////////
#if defined(__i386__) || defined(_M_AMD64)
VOID DiskStopFloppyMotor(VOID);
VOID __cdecl DiskStopFloppyMotor(VOID);
#endif // defined __i386__ || defined(_M_AMD64)
/* Buffer for disk reads (hwdisk.c) */

View file

@ -259,8 +259,6 @@ LoadAndBootLinux(
UiUnInitialize("Booting Linux...");
IniCleanup();
DiskStopFloppyMotor();
if (LinuxSetupSector->LoadFlags & LINUX_FLAG_LOAD_HIGH)
BootNewLinuxKernel();
else

View file

@ -118,16 +118,6 @@ LoadAndBootBootSector(
UiUnInitialize("Booting...");
IniCleanup();
/*
* Don't stop the floppy drive motor when we
* are just booting a bootsector, or drive, or partition.
* If we were to stop the floppy motor then
* the BIOS wouldn't be informed and if the
* next read is to a floppy then the BIOS will
* still think the motor is on and this will
* result in a read error.
*/
// DiskStopFloppyMotor();
ChainLoadBiosBootSectorCode(0 /*DriveNumber*/, 0 /*PartitionNumber*/);
/* Must not return! */
return ESUCCESS;
@ -204,16 +194,6 @@ LoadAndBootPartitionOrDrive(
UiUnInitialize("Booting...");
IniCleanup();
/*
* Don't stop the floppy drive motor when we
* are just booting a bootsector, or drive, or partition.
* If we were to stop the floppy motor then
* the BIOS wouldn't be informed and if the
* next read is to a floppy then the BIOS will
* still think the motor is on and this will
* result in a read error.
*/
// DiskStopFloppyMotor();
ChainLoadBiosBootSectorCode(DriveNumber, PartitionNumber);
/* Must not return! */
return ESUCCESS;