8a7deae238
- Remove dated 'Block::Driver' front end and implement 'Block::Request_stream' front end - Remove all dynamic memory allocations but DMA memory allocations - Remove 'Platform_hba' and implement platform specific functions in 'spec/<platform>/*' - Ata and Atapi don't inherit from 'Port' any more, but are a member of 'Port' as a protocol implementation - Use platform driver for MMIO mappings (x86) - Exchange stateful initialization of Ata/Atapi with a sequential initialization using 'wait_for_any' and 'retry' patterns - Fix Atapi initialization by setting the byte count limit - Set FIS receive base only when Cmd::FRE is disabled and Cmd::FR is 0 - Put everything in namespaces ('Ahci', 'Ata', or 'Atapi') - Ata decides during read/write operations to use native-command queuing or normal DMA requests - Remove port claiming logic (is now done via 'Constructibles') fixes #3636
72 lines
1.4 KiB
C++
72 lines
1.4 KiB
C++
/*
|
|
* \brief Utilitize used by the AHCI driver
|
|
* \author Josef Soentgen
|
|
* \date 2018-03-05
|
|
*/
|
|
|
|
/*
|
|
* Copyright (C) 2018 Genode Labs GmbH
|
|
*
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
* under the terms of the GNU Affero General Public License version 3.
|
|
*/
|
|
|
|
#ifndef _AHCI_UTIL_H_
|
|
#define _AHCI_UTIL_H_
|
|
|
|
/* Genode includes */
|
|
#include <base/fixed_stdint.h>
|
|
|
|
namespace Util {
|
|
|
|
using namespace Genode;
|
|
/*
|
|
* Wrap array into convinient interface
|
|
*
|
|
* The used datatype T must implement the following methods:
|
|
*
|
|
* bool valid() const returns true if the object is valid
|
|
* void invalidate() adjusts the object so that valid() returns false
|
|
*/
|
|
template <typename T, size_t CAP>
|
|
struct Slots
|
|
{
|
|
T _entries[CAP] { };
|
|
size_t _limit { CAP };
|
|
|
|
/**
|
|
* Get free slot
|
|
*/
|
|
T *get()
|
|
{
|
|
for (size_t i = 0; i < _limit; i++) {
|
|
if (!_entries[i].valid()) { return &_entries[i]; }
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
/**
|
|
* Iterate over all slots until FUNC returns true
|
|
*/
|
|
template <typename FUNC>
|
|
bool for_each(FUNC const &func)
|
|
{
|
|
for (size_t i = 0; i < _limit; i++) {
|
|
if (!_entries[i].valid()) { continue; }
|
|
if ( func(_entries[i])) { return true; }
|
|
}
|
|
return false;
|
|
}
|
|
|
|
size_t index(T const &entry) const
|
|
{
|
|
size_t index = &entry - _entries;
|
|
return index;
|
|
}
|
|
|
|
void limit(size_t limit) { _limit = limit; }
|
|
};
|
|
}
|
|
|
|
#endif /* _AHCI_UTIL_H_ */
|