mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Thread secured ATA driver.
This commit is contained in:
parent
eb4f179330
commit
f3f33e22e7
2 changed files with 17 additions and 10 deletions
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
Sortix. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
ata.cpp
|
||||
Allowes access to block devices over ATA PIO.
|
||||
|
||||
******************************************************************************/
|
||||
*******************************************************************************/
|
||||
|
||||
#include <sortix/kernel/platform.h>
|
||||
#include <sortix/kernel/kthread.h>
|
||||
#include "cpu.h"
|
||||
#include <libmaxsi/error.h>
|
||||
#include <libmaxsi/memory.h>
|
||||
|
@ -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++ )
|
||||
|
|
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.
|
||||
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
Sortix. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
ata.cpp
|
||||
Allowes access to block devices over ATA PIO.
|
||||
|
||||
******************************************************************************/
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef SORTIX_ATA_H
|
||||
#define SORTIX_ATA_H
|
||||
|
||||
#include <sortix/kernel/kthread.h>
|
||||
|
||||
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;
|
||||
|
|
Loading…
Add table
Reference in a new issue