Prepare new LBA representation

This commit is contained in:
2023-04-12 21:59:36 +02:00
parent 1a0d175779
commit 320fa8934c
8 changed files with 114 additions and 50 deletions

View File

@@ -1,6 +1,6 @@
#ifndef __JABYENGINE_AUTO_LBA_HPP__
#define __JABYENGINE_AUTO_LBA_HPP__
#include "../../stdint.h"
#include "../Auxiliary/bits.hpp"
namespace JabyEngine {
#define __jabyengine_start_lba_request
@@ -8,8 +8,36 @@ namespace JabyEngine {
#define __jabyengine_end_lba_request EndOfRequest
struct __attribute__((packed)) AutoLBAEntry {
uint16_t lba;
uint16_t size_words;
// This layout should make it a bit easier to read the "BitRange" values
static constexpr auto SizeInSectors = BitRange::from_to(22, 31);
static constexpr auto IsLZ4Compressed = Bit(19);
static constexpr auto LBAValue = BitRange::from_to(0, 18);
uint32_t value;
constexpr uint32_t get_lba() const {
return bit::value::get_normalized(this->value, AutoLBAEntry::LBAValue);
}
constexpr uint32_t get_lba() const volatile {
return const_cast<const AutoLBAEntry*>(this)->get_lba();
}
constexpr uint32_t get_size_in_sectors() const {
return this->value >> SizeInSectors.pos;
}
constexpr uint32_t get_size_in_sectors() const volatile {
return const_cast<const AutoLBAEntry*>(this)->get_size_in_sectors();
}
constexpr bool isLZ4() const {
return bit::is_set(this->value, AutoLBAEntry::IsLZ4Compressed);
}
constexpr bool isLZ4() const volatile {
return const_cast<const AutoLBAEntry*>(this)->isLZ4();
}
};
}