diff --git a/sortix/ata.cpp b/sortix/ata.cpp
index 30b95923..173e6698 100644
--- a/sortix/ata.cpp
+++ b/sortix/ata.cpp
@@ -1,6 +1,6 @@
-/******************************************************************************
+/*******************************************************************************
- COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011.
+ Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
This file is part of Sortix.
@@ -14,15 +14,16 @@
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
- You should have received a copy of the GNU General Public License along
- with Sortix. If not, see .
+ You should have received a copy of the GNU General Public License along with
+ Sortix. If not, see .
ata.cpp
Allowes access to block devices over ATA PIO.
-******************************************************************************/
+*******************************************************************************/
#include
+#include
#include "cpu.h"
#include
#include
@@ -186,6 +187,7 @@ namespace Sortix
ATADrive::ATADrive(ATABus* bus, unsigned driveid, uint16_t portoffset, uint16_t altport)
{
+ this->atalock = KTHREAD_MUTEX_INITIALIZER;
this->bus = bus;
this->driveid = driveid;
this->iobase = portoffset;
@@ -264,6 +266,7 @@ namespace Sortix
bool ATADrive::ReadSector(off_t sector, uint8_t* dest)
{
+ ScopedLock lock(&atalock);
if ( !PrepareIO(false, sector) ) { return false; }
uint16_t* destword = (uint16_t*) dest;
for ( size_t i = 0; i < sectorsize/2; i++ )
@@ -277,6 +280,7 @@ namespace Sortix
bool ATADrive::WriteSector(off_t sector, const uint8_t* src)
{
+ ScopedLock lock(&atalock);
if ( !PrepareIO(true, sector) ) { return false; }
const uint16_t* srcword = (const uint16_t*) src;
for ( size_t i = 0; i < sectorsize/2; i++ )
diff --git a/sortix/ata.h b/sortix/ata.h
index 3357ae49..a6afa5d9 100644
--- a/sortix/ata.h
+++ b/sortix/ata.h
@@ -1,6 +1,6 @@
-/******************************************************************************
+/*******************************************************************************
- COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011.
+ Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
This file is part of Sortix.
@@ -14,17 +14,19 @@
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
- You should have received a copy of the GNU General Public License along
- with Sortix. If not, see .
+ You should have received a copy of the GNU General Public License along with
+ Sortix. If not, see .
ata.cpp
Allowes access to block devices over ATA PIO.
-******************************************************************************/
+*******************************************************************************/
#ifndef SORTIX_ATA_H
#define SORTIX_ATA_H
+#include
+
namespace Sortix
{
class ATABus;
@@ -67,6 +69,7 @@ namespace Sortix
bool PrepareIO(bool write, off_t sector);
private:
+ kthread_mutex_t atalock;
unsigned driveid;
uint16_t meta[256];
uint16_t iobase;