[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 BootMain:PROC
// EXTERN cmdline:DWORD // EXTERN cmdline:DWORD
EXTERN DiskStopFloppyMotor:PROC
#ifdef _USE_ML #ifdef _USE_ML
EXTERN __bss_start__:FWORD EXTERN __bss_start__:FWORD
EXTERN __bss_end__:FWORD EXTERN __bss_end__:FWORD
@ -70,6 +72,9 @@ stop:
PUBLIC Reboot PUBLIC Reboot
Reboot: Reboot:
/* Stop the floppy drive motor */
call DiskStopFloppyMotor
/* Set the function ID */ /* Set the function ID */
mov bx, FNID_Reboot mov bx, FNID_Reboot
@ -102,6 +107,14 @@ continue:
/* Store the 1-byte truncated partition number in DH */ /* Store the 1-byte truncated partition number in DH */
mov dh, al 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 */ /* Set the function ID */
mov bx, FNID_ChainLoadBiosBootSectorCode mov bx, FNID_ChainLoadBiosBootSectorCode
@ -109,6 +122,11 @@ continue:
jmp SwitchToReal jmp SwitchToReal
/*
* U16 PxeCallApi(U16 Segment, U16 Offset, U16 Service, VOID *Parameter);
*
* RETURNS:
*/
PUBLIC PxeCallApi PUBLIC PxeCallApi
PxeCallApi: PxeCallApi:
xor eax, eax xor eax, eax

View file

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

View file

@ -27,6 +27,8 @@ EXTERN _i386Idt:DWORD
//EXTERN _i386idtptr:FWORD //EXTERN _i386idtptr:FWORD
EXTERN cmdline:DWORD EXTERN cmdline:DWORD
EXTERN _DiskStopFloppyMotor:PROC
#ifdef _USE_ML #ifdef _USE_ML
EXTERN __bss_start__:DWORD EXTERN __bss_start__:DWORD
EXTERN __bss_end__:DWORD EXTERN __bss_end__:DWORD
@ -101,6 +103,9 @@ stop:
PUBLIC _Reboot PUBLIC _Reboot
_Reboot: _Reboot:
/* Stop the floppy drive motor */
call _DiskStopFloppyMotor
/* Set the function ID */ /* Set the function ID */
mov bx, FNID_Reboot mov bx, FNID_Reboot
@ -133,6 +138,14 @@ continue:
/* Store the 1-byte truncated partition number in DH */ /* Store the 1-byte truncated partition number in DH */
mov dh, al 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 */ /* Set the function ID */
mov bx, FNID_ChainLoadBiosBootSectorCode mov bx, FNID_ChainLoadBiosBootSectorCode

View file

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

View file

@ -478,10 +478,12 @@ BOOLEAN PcDiskReadLogicalSectors(UCHAR DriveNumber, ULONGLONG SectorNumber, ULON
return TRUE; 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) 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); SetPhysByte(((ULONG)Address)+0x80000000, Value);
} }
void DiskStopFloppyMotor() {
}
void BootOldLinuxKernel( unsigned long size ) { void BootOldLinuxKernel( unsigned long size ) {
ofw_exit(); ofw_exit();
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -118,16 +118,6 @@ LoadAndBootBootSector(
UiUnInitialize("Booting..."); UiUnInitialize("Booting...");
IniCleanup(); 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*/); ChainLoadBiosBootSectorCode(0 /*DriveNumber*/, 0 /*PartitionNumber*/);
/* Must not return! */ /* Must not return! */
return ESUCCESS; return ESUCCESS;
@ -204,16 +194,6 @@ LoadAndBootPartitionOrDrive(
UiUnInitialize("Booting..."); UiUnInitialize("Booting...");
IniCleanup(); 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); ChainLoadBiosBootSectorCode(DriveNumber, PartitionNumber);
/* Must not return! */ /* Must not return! */
return ESUCCESS; return ESUCCESS;