Current progress
This commit is contained in:
parent
4e445b2b91
commit
3dee2a8d74
|
@ -49,6 +49,10 @@ namespace JabyEngine {
|
||||||
constexpr BitRangeValue<T> with(T value) const {
|
constexpr BitRangeValue<T> with(T value) const {
|
||||||
return {value, this->begin, this->length};
|
return {value, this->begin, this->length};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr BitRangeValue<T> max() const {
|
||||||
|
return BitRange<T>::with((1 << this->length) - 1);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
|
@ -23,23 +23,63 @@ namespace JabyEngine {
|
||||||
static constexpr auto IsTransmissionBusy = Bit<uint8_t>(7);
|
static constexpr auto IsTransmissionBusy = Bit<uint8_t>(7);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct __no_align InterruptEnable : public ComplexBitMap<uint8_t> {
|
||||||
|
__io_port_inherit_complex_bit_map(InterruptEnable);
|
||||||
|
|
||||||
|
static constexpr auto InterruptTypValue = BitRange<uint8_t>::from_to(0, 2);
|
||||||
|
static constexpr auto UnknownIRQ = Bit<uint8_t>(3);
|
||||||
|
static constexpr auto CommandStartIRQ = Bit<uint8_t>(4);
|
||||||
|
};
|
||||||
|
typedef InterruptEnable InterruptFlag;
|
||||||
|
|
||||||
|
struct __no_align Request : public ComplexBitMap<uint8_t> {
|
||||||
|
__io_port_inherit_complex_bit_map(Request);
|
||||||
|
|
||||||
|
static constexpr auto WantCommandStartIRQ = Bit<uint8_t>(5);
|
||||||
|
static constexpr auto WantData = Bit<uint8_t>(7);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Interrupt {
|
||||||
|
/*static void enable_all(IOPort<InterruptEnable>& port) {
|
||||||
|
port.write_combined(InterruptEnable::InterruptTypValue.max(), InterruptEnable::UnknownIRQ, InterruptEnable::CommandStartIRQ);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t get_type(const IOPort<InterruptFlag>& port) {
|
||||||
|
return port.read().get_value(InterruptFlag::InterruptTypValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ack(IOPort<InterruptFlag>& port) {
|
||||||
|
port.write_combined(InterruptFlag::InterruptTypValue.max());
|
||||||
|
}*/
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef uint8_t ResponseFifo;
|
||||||
|
typedef uint8_t CommandFifo;
|
||||||
|
typedef uint8_t DataFifo;
|
||||||
|
typedef uint16_t DataFifo16;
|
||||||
|
typedef uint8_t ParameterFifo;
|
||||||
|
|
||||||
namespace Index0Types {
|
namespace Index0Types {
|
||||||
struct __no_align IndexTriplet {
|
struct __no_align IndexTriplet {
|
||||||
// Replace with proper types later
|
// Replace with proper types later
|
||||||
union __no_align {
|
union __no_align {
|
||||||
const IOPort<uint8_t> response_fifo;
|
const IOPort<ResponseFifo> response_fifo;
|
||||||
IOPort<uint8_t> command;
|
IOPort<CommandFifo> command;
|
||||||
};
|
};
|
||||||
|
|
||||||
union __no_align {
|
union __no_align {
|
||||||
const IOPort<uint8_t> data_fifo;
|
const IOPort<DataFifo> data_fifo;
|
||||||
IOPort<uint8_t> parameter_fifo;
|
IOPort<ParameterFifo> parameter_fifo;
|
||||||
};
|
};
|
||||||
|
|
||||||
union __no_align {
|
union __no_align {
|
||||||
const IOPort<uint8_t> irq_enable;
|
const IOPort<InterruptEnable> irq_enable;
|
||||||
IOPort<uint8_t> irq_request;
|
IOPort<Request> request;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const IOPort<uint16_t>& get_data_fifo_16() const {
|
||||||
|
return *reinterpret_cast<const IOPort<uint16_t>*>(&this->data_fifo);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert(sizeof(IndexTriplet) == 3);
|
static_assert(sizeof(IndexTriplet) == 3);
|
||||||
|
|
Loading…
Reference in New Issue