Skip to content

Commit eeff926

Browse files
committed
[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).
1 parent 4843c1a commit eeff926

File tree

14 files changed

+42
-41
lines changed

14 files changed

+42
-41
lines changed

boot/freeldr/freeldr/arch/amd64/entry.S

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
EXTERN BootMain:PROC
66
// EXTERN cmdline:DWORD
77

8+
EXTERN DiskStopFloppyMotor:PROC
9+
810
#ifdef _USE_ML
911
EXTERN __bss_start__:FWORD
1012
EXTERN __bss_end__:FWORD
@@ -70,6 +72,9 @@ stop:
7072

7173
PUBLIC Reboot
7274
Reboot:
75+
/* Stop the floppy drive motor */
76+
call DiskStopFloppyMotor
77+
7378
/* Set the function ID */
7479
mov bx, FNID_Reboot
7580

@@ -102,13 +107,26 @@ continue:
102107
/* Store the 1-byte truncated partition number in DH */
103108
mov dh, al
104109

110+
/*
111+
* Don't stop the floppy drive motor when we are just booting a bootsector,
112+
* a drive, or a partition. If we were to stop the floppy motor, the BIOS
113+
* wouldn't be informed and if the next read is to a floppy then the BIOS
114+
* will still think the motor is on and this will result in a read error.
115+
*/
116+
// call DiskStopFloppyMotor
117+
105118
/* Set the function ID */
106119
mov bx, FNID_ChainLoadBiosBootSectorCode
107120

108121
/* Switch to real mode (we don't return) */
109122
jmp SwitchToReal
110123

111124

125+
/*
126+
* U16 PxeCallApi(U16 Segment, U16 Offset, U16 Service, VOID *Parameter);
127+
*
128+
* RETURNS:
129+
*/
112130
PUBLIC PxeCallApi
113131
PxeCallApi:
114132
xor eax, eax

boot/freeldr/freeldr/arch/arm/macharm.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ ULONG LenBits[] =
5959

6060
/* FUNCTIONS ******************************************************************/
6161

62-
VOID DiskStopFloppyMotor(VOID)
63-
{
64-
}
65-
6662
VOID
6763
FrLdrCheckCpuCompatibility(VOID)
6864
{

boot/freeldr/freeldr/arch/i386/entry.S

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ EXTERN _i386Idt:DWORD
2727
//EXTERN _i386idtptr:FWORD
2828
EXTERN cmdline:DWORD
2929

30+
EXTERN _DiskStopFloppyMotor:PROC
31+
3032
#ifdef _USE_ML
3133
EXTERN __bss_start__:DWORD
3234
EXTERN __bss_end__:DWORD
@@ -101,6 +103,9 @@ stop:
101103

102104
PUBLIC _Reboot
103105
_Reboot:
106+
/* Stop the floppy drive motor */
107+
call _DiskStopFloppyMotor
108+
104109
/* Set the function ID */
105110
mov bx, FNID_Reboot
106111

@@ -133,6 +138,14 @@ continue:
133138
/* Store the 1-byte truncated partition number in DH */
134139
mov dh, al
135140

141+
/*
142+
* Don't stop the floppy drive motor when we are just booting a bootsector,
143+
* a drive, or a partition. If we were to stop the floppy motor, the BIOS
144+
* wouldn't be informed and if the next read is to a floppy then the BIOS
145+
* will still think the motor is on and this will result in a read error.
146+
*/
147+
// call _DiskStopFloppyMotor
148+
136149
/* Set the function ID */
137150
mov bx, FNID_ChainLoadBiosBootSectorCode
138151

boot/freeldr/freeldr/arch/i386/linux.S

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <asm.inc>
2121
#include <arch/pc/x86common.h>
2222

23+
EXTERN _DiskStopFloppyMotor:PROC
2324
EXTERN i386CallRealMode:PROC
2425

2526
.code32
@@ -45,6 +46,8 @@ _BootOldLinuxKernel:
4546

4647
PUBLIC _BootNewLinuxKernel
4748
_BootNewLinuxKernel:
49+
/* Stop the floppy drive motor */
50+
call _DiskStopFloppyMotor
4851

4952
mov bx, FNID_BootLinuxKernel
5053
call i386CallRealMode

boot/freeldr/freeldr/arch/i386/pcdisk.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,10 +478,12 @@ BOOLEAN PcDiskReadLogicalSectors(UCHAR DriveNumber, ULONGLONG SectorNumber, ULON
478478
return TRUE;
479479
}
480480

481-
VOID DiskStopFloppyMotor(VOID)
481+
#if defined(__i386__) || defined(_M_AMD64)
482+
VOID __cdecl DiskStopFloppyMotor(VOID)
482483
{
483-
WRITE_PORT_UCHAR((PUCHAR)0x3F2, 0);
484+
WRITE_PORT_UCHAR((PUCHAR)0x3F2, 0x0C); // DOR_FDC_ENABLE | DOR_DMA_IO_INTERFACE_ENABLE
484485
}
486+
#endif // defined __i386__ || defined(_M_AMD64)
485487

486488
BOOLEAN DiskGetExtendedDriveParameters(UCHAR DriveNumber, PVOID Buffer, USHORT BufferSize)
487489
{

boot/freeldr/freeldr/arch/powerpc/mach.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,9 +534,6 @@ void WRITE_PORT_UCHAR(PUCHAR Address, UCHAR Value) {
534534
SetPhysByte(((ULONG)Address)+0x80000000, Value);
535535
}
536536

537-
void DiskStopFloppyMotor() {
538-
}
539-
540537
void BootOldLinuxKernel( unsigned long size ) {
541538
ofw_exit();
542539
}

boot/freeldr/freeldr/arch/realmode/amd64.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,9 @@ stack16:
346346

347347

348348
#include "int386.inc"
349+
#include "helpers.inc"
349350
#include "pxe.inc"
350351
#include "pnp.inc"
351-
#include "helpers.inc"
352352

353353
.org (FREELDR_PE_BASE - FREELDR_BASE - 1)
354354
.byte 0

boot/freeldr/freeldr/arch/realmode/helpers.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ writehex_common:
110110
popfd
111111
ret
112112

113+
113114
Reboot:
114115
cli
115116

boot/freeldr/freeldr/arch/realmode/i386.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,10 @@ rmode_idtptr:
198198
.long 0 /* Base Address */
199199

200200
#include "int386.inc"
201+
#include "helpers.inc"
201202
#include "pxe.inc"
202203
#include "pnp.inc"
203204
#include "linux.inc"
204-
#include "helpers.inc"
205205

206206
.org (FREELDR_PE_BASE - FREELDR_BASE - 1)
207207
.byte 0

boot/freeldr/freeldr/custom.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -705,10 +705,6 @@ EditCustomBootReactOS(
705705
VOID OptionMenuReboot(VOID)
706706
{
707707
UiMessageBox("The system will now reboot.");
708-
709-
#if defined(__i386__) || defined(_M_AMD64)
710-
DiskStopFloppyMotor();
711-
#endif
712708
Reboot();
713709
}
714710

0 commit comments

Comments
 (0)