summaryrefslogtreecommitdiff
path: root/Source/Kernel/Devices
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Kernel/Devices')
-rw-r--r--Source/Kernel/Devices/Floppy/FloppyController.class.cpp3
-rw-r--r--Source/Kernel/Devices/Floppy/FloppyDrive.class.cpp27
-rw-r--r--Source/Kernel/Devices/Floppy/FloppyDrive.class.h2
3 files changed, 18 insertions, 14 deletions
diff --git a/Source/Kernel/Devices/Floppy/FloppyController.class.cpp b/Source/Kernel/Devices/Floppy/FloppyController.class.cpp
index db148d0..7201c5c 100644
--- a/Source/Kernel/Devices/Floppy/FloppyController.class.cpp
+++ b/Source/Kernel/Devices/Floppy/FloppyController.class.cpp
@@ -153,7 +153,6 @@ void FloppyController::setDOR() {
checkInterrupt(&st0, &cyl);
m_first = false;
}
- //PANIC("test");
}
void FloppyController::setActiveDrive(u8int drive) {
@@ -190,10 +189,10 @@ u8int FloppyController::readData() {
bool FloppyController::reset() {
outb(m_base + FR_DOR, 0x00); //Disable controller
m_first = true;
- setNoActiveDrive();
if (m_drives[0] != NULL) m_drives[0]->m_motorState = 0;
if (m_drives[1] != NULL) m_drives[1]->m_motorState = 0;
+ setNoActiveDrive();
for (int i = 0; i < 2; i++) {
if (m_drives[i] != NULL) {
diff --git a/Source/Kernel/Devices/Floppy/FloppyDrive.class.cpp b/Source/Kernel/Devices/Floppy/FloppyDrive.class.cpp
index 4036927..b7fd69b 100644
--- a/Source/Kernel/Devices/Floppy/FloppyDrive.class.cpp
+++ b/Source/Kernel/Devices/Floppy/FloppyDrive.class.cpp
@@ -92,7 +92,10 @@ bool FloppyDrive::calibrate() {
int st0, cyl = -1;
- if (!setMotorState(true)) return false;
+ if (!setMotorState(true)) {
+ *kvt << getName() << ": calibrate fail\n";
+ return false;
+ }
for (int i = 0; i < 10; i++) {
m_fdc->resetIrq();
@@ -138,18 +141,17 @@ bool FloppyDrive::killMotor() {
return true;
}
-bool FloppyDrive::seek(u32int cyli, s32int head) {
+bool FloppyDrive::seek(u32int cyli, s32int head, bool recursive) {
if (cyli >= m_cylinders) return false;
- m_fdc->setActiveDrive(m_driveNumber);
setMotorState(true); //Turn on motor
int st0, cyl = -1;
- for (u32int i = 0; i < 10; i++) {
+ for (u32int i = 0; i < (recursive ? 10 : 5); i++) {
m_fdc->resetIrq();
m_fdc->writeCmd(FC_SEEK);
- m_fdc->writeCmd(head << 2);
+ m_fdc->writeCmd(head << 2 | m_driveNumber);
m_fdc->writeCmd(cyl);
m_fdc->waitIrq();
@@ -160,20 +162,23 @@ bool FloppyDrive::seek(u32int cyli, s32int head) {
}
if (cyl == 0xFF or cyl == 0x00 or cyl == (int)cyli) { //0xFF for bochs, 0x00 for qemu :D
setMotorState(false);
- m_fdc->setNoActiveDrive();
return true;
}
}
- setMotorState(false);
- m_fdc->setNoActiveDrive();
- *kvt << getName() << ": seek fail\n";
- return false;
+ if (recursive) {
+ setMotorState(false);
+ *kvt << getName() << ": seek fail\n";
+ return false;
+ } else {
+ calibrate();
+ return seek(cyli, head, true);
+ }
}
bool FloppyDrive::doTrack(u32int cyl, u8int dir) {
+ m_fdc->setActiveDrive(m_driveNumber);
if (!seek(cyl, 0)) return false;
if (!seek(cyl, 1)) return false;
- m_fdc->setActiveDrive(m_driveNumber);
u8int cmd, flags = 0xC0;
switch (dir) {
diff --git a/Source/Kernel/Devices/Floppy/FloppyDrive.class.h b/Source/Kernel/Devices/Floppy/FloppyDrive.class.h
index 75926ea..73229b1 100644
--- a/Source/Kernel/Devices/Floppy/FloppyDrive.class.h
+++ b/Source/Kernel/Devices/Floppy/FloppyDrive.class.h
@@ -22,7 +22,7 @@ class FloppyDrive : public BlockDevice {
bool calibrate();
bool setMotorState(bool on);
bool killMotor();
- bool seek(u32int cyli, s32int head);
+ bool seek(u32int cyli, s32int head, bool recursive = false);
bool doTrack(u32int cyl, u8int dir);
public: