Thread secured ATA driver.
This commit is contained in:
parent
eb4f179330
commit
f3f33e22e7
|
@ -1,6 +1,6 @@
|
||||||
/******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
||||||
COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011.
|
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
|
||||||
|
|
||||||
This file is part of Sortix.
|
This file is part of Sortix.
|
||||||
|
|
||||||
|
@ -14,15 +14,16 @@
|
||||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
details.
|
details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License along
|
You should have received a copy of the GNU General Public License along with
|
||||||
with Sortix. If not, see <http://www.gnu.org/licenses/>.
|
Sortix. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
ata.cpp
|
ata.cpp
|
||||||
Allowes access to block devices over ATA PIO.
|
Allowes access to block devices over ATA PIO.
|
||||||
|
|
||||||
******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <sortix/kernel/platform.h>
|
#include <sortix/kernel/platform.h>
|
||||||
|
#include <sortix/kernel/kthread.h>
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include <libmaxsi/error.h>
|
#include <libmaxsi/error.h>
|
||||||
#include <libmaxsi/memory.h>
|
#include <libmaxsi/memory.h>
|
||||||
|
@ -186,6 +187,7 @@ namespace Sortix
|
||||||
|
|
||||||
ATADrive::ATADrive(ATABus* bus, unsigned driveid, uint16_t portoffset, uint16_t altport)
|
ATADrive::ATADrive(ATABus* bus, unsigned driveid, uint16_t portoffset, uint16_t altport)
|
||||||
{
|
{
|
||||||
|
this->atalock = KTHREAD_MUTEX_INITIALIZER;
|
||||||
this->bus = bus;
|
this->bus = bus;
|
||||||
this->driveid = driveid;
|
this->driveid = driveid;
|
||||||
this->iobase = portoffset;
|
this->iobase = portoffset;
|
||||||
|
@ -264,6 +266,7 @@ namespace Sortix
|
||||||
|
|
||||||
bool ATADrive::ReadSector(off_t sector, uint8_t* dest)
|
bool ATADrive::ReadSector(off_t sector, uint8_t* dest)
|
||||||
{
|
{
|
||||||
|
ScopedLock lock(&atalock);
|
||||||
if ( !PrepareIO(false, sector) ) { return false; }
|
if ( !PrepareIO(false, sector) ) { return false; }
|
||||||
uint16_t* destword = (uint16_t*) dest;
|
uint16_t* destword = (uint16_t*) dest;
|
||||||
for ( size_t i = 0; i < sectorsize/2; i++ )
|
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)
|
bool ATADrive::WriteSector(off_t sector, const uint8_t* src)
|
||||||
{
|
{
|
||||||
|
ScopedLock lock(&atalock);
|
||||||
if ( !PrepareIO(true, sector) ) { return false; }
|
if ( !PrepareIO(true, sector) ) { return false; }
|
||||||
const uint16_t* srcword = (const uint16_t*) src;
|
const uint16_t* srcword = (const uint16_t*) src;
|
||||||
for ( size_t i = 0; i < sectorsize/2; i++ )
|
for ( size_t i = 0; i < sectorsize/2; i++ )
|
||||||
|
|
13
sortix/ata.h
13
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.
|
This file is part of Sortix.
|
||||||
|
|
||||||
|
@ -14,17 +14,19 @@
|
||||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
details.
|
details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License along
|
You should have received a copy of the GNU General Public License along with
|
||||||
with Sortix. If not, see <http://www.gnu.org/licenses/>.
|
Sortix. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
ata.cpp
|
ata.cpp
|
||||||
Allowes access to block devices over ATA PIO.
|
Allowes access to block devices over ATA PIO.
|
||||||
|
|
||||||
******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#ifndef SORTIX_ATA_H
|
#ifndef SORTIX_ATA_H
|
||||||
#define SORTIX_ATA_H
|
#define SORTIX_ATA_H
|
||||||
|
|
||||||
|
#include <sortix/kernel/kthread.h>
|
||||||
|
|
||||||
namespace Sortix
|
namespace Sortix
|
||||||
{
|
{
|
||||||
class ATABus;
|
class ATABus;
|
||||||
|
@ -67,6 +69,7 @@ namespace Sortix
|
||||||
bool PrepareIO(bool write, off_t sector);
|
bool PrepareIO(bool write, off_t sector);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
kthread_mutex_t atalock;
|
||||||
unsigned driveid;
|
unsigned driveid;
|
||||||
uint16_t meta[256];
|
uint16_t meta[256];
|
||||||
uint16_t iobase;
|
uint16_t iobase;
|
||||||
|
|
Loading…
Reference in New Issue