Prepare new LBA representation
This commit is contained in:
@@ -44,7 +44,7 @@ namespace JabyEngine {
|
||||
return const_cast<volatile State&>(current_state);
|
||||
}
|
||||
|
||||
void read_file(FileInfo file_info, const SectorBufferAllocator& buffer_allocator);
|
||||
void read_file(AutoLBAEntry file_info, const SectorBufferAllocator& buffer_allocator);
|
||||
void continue_reading();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,15 +17,6 @@ namespace JabyEngine {
|
||||
Error,
|
||||
};
|
||||
|
||||
struct FileInfo {
|
||||
uint16_t lba;
|
||||
uint16_t sectors;
|
||||
|
||||
static constexpr FileInfo from(const AutoLBAEntry& entry) {
|
||||
return FileInfo{entry.lba, CD_IO::DataSector::words_to_sectors(entry.size_words)};
|
||||
}
|
||||
};
|
||||
|
||||
class SectorBufferAllocator {
|
||||
private:
|
||||
typedef CD_IO::DataSector* (*AllocatorFunction)(void* ctx);
|
||||
@@ -61,17 +52,13 @@ namespace JabyEngine {
|
||||
uint8_t sec;
|
||||
uint8_t sector;
|
||||
|
||||
static constexpr CDTimeStamp from(uint16_t lba) {
|
||||
const auto [min, new_lba] = div_and_mod(lba, static_cast<uint16_t>(MaxSector*MaxSeconds));
|
||||
const auto [sec, sectors] = div_and_mod(new_lba, static_cast<uint16_t>(MaxSector));
|
||||
static constexpr CDTimeStamp from(uint32_t lba) {
|
||||
const auto [min, new_lba] = div_and_mod(lba, MaxSector*MaxSeconds);
|
||||
const auto [sec, sectors] = div_and_mod(new_lba, MaxSector);
|
||||
|
||||
return CDTimeStamp{static_cast<uint8_t>(min), static_cast<uint8_t>(sec), static_cast<uint8_t>(sectors)};
|
||||
}
|
||||
|
||||
static constexpr CDTimeStamp from(const FileInfo& file_info) {
|
||||
return CDTimeStamp::from(file_info.lba);
|
||||
}
|
||||
|
||||
constexpr uint8_t get_min_cd() const {
|
||||
return to_bcd(this->min);
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ namespace JabyEngine {
|
||||
static void interrupt_handler(uint32_t);
|
||||
|
||||
static SectorBufferAllocator sector_allocator;
|
||||
static uint16_t cur_lba;
|
||||
static uint16_t dst_lba;
|
||||
static uint32_t cur_lba;
|
||||
static uint32_t dst_lba;
|
||||
|
||||
CD_IO::Interrupt::Type last_interrupt = CD_IO::Interrupt::Type::None;
|
||||
uint8_t cmd_interrupt_bit = 0;
|
||||
@@ -30,7 +30,7 @@ namespace JabyEngine {
|
||||
}
|
||||
|
||||
// Requires Index0
|
||||
static void read_cd(uint16_t lba) {
|
||||
static void read_cd(uint32_t lba) {
|
||||
const auto loc = CDTimeStamp::from(lba);
|
||||
|
||||
Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::SetLoc, loc.get_min_cd(), loc.get_sec_cd(), loc.get_sector_cd());
|
||||
@@ -117,16 +117,16 @@ namespace JabyEngine {
|
||||
__syscall_ReturnFromException();
|
||||
}
|
||||
|
||||
void read_file(FileInfo file_info, const SectorBufferAllocator& buffer_allocator) {
|
||||
cur_lba = file_info.lba;
|
||||
dst_lba = file_info.lba + file_info.sectors;
|
||||
void read_file(AutoLBAEntry file_info, const SectorBufferAllocator& buffer_allocator) {
|
||||
cur_lba = file_info.get_lba();
|
||||
dst_lba = cur_lba + file_info.get_size_in_sectors();
|
||||
sector_allocator = buffer_allocator;
|
||||
|
||||
Command::wait_completed();
|
||||
CD_IO::PortIndex0::change_to();
|
||||
Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::SetMode, DataSectorMode);
|
||||
|
||||
read_cd(file_info.lba);
|
||||
read_cd(cur_lba);
|
||||
}
|
||||
|
||||
void continue_reading() {
|
||||
|
||||
@@ -7,7 +7,6 @@ namespace JabyEngine {
|
||||
static constexpr auto DisabledCircularBufferSize = 512;
|
||||
|
||||
void CDFileProcessor :: start_cur_job() {
|
||||
using CD::internal::FileInfo;
|
||||
using CD::internal::SectorBufferAllocator;
|
||||
const auto configurate_for = [this](const CDFile& file) {
|
||||
const auto disable_lz4 = [this](uint32_t* work_area, size_t size, uint32_t* overwrite_dst = nullptr) -> uint32_t* {
|
||||
@@ -47,13 +46,13 @@ namespace JabyEngine {
|
||||
const auto& cur_lba = this->lba[cur_job.rel_lba_idx];
|
||||
|
||||
configurate_for(cur_job);
|
||||
CD::internal::read_file(FileInfo::from(cur_lba), SectorBufferAllocator::create(this,
|
||||
CD::internal::read_file(cur_lba, SectorBufferAllocator::create(this,
|
||||
[](void* ctx) -> CD_IO::DataSector* {
|
||||
CDFileProcessor &self = *reinterpret_cast<CDFileProcessor*>(ctx);
|
||||
return self.circular_buffer.allocate();
|
||||
}));
|
||||
|
||||
printf(">>> CD needs to load LBA: %i -> %i\n", cur_lba.lba, cur_lba.size_words);
|
||||
printf(">>> CD needs to load LBA: %i -> %i\n", cur_lba.get_lba(), cur_lba.get_size_in_sectors());
|
||||
}
|
||||
|
||||
bool CDFileProcessor :: process_data() {
|
||||
|
||||
Reference in New Issue
Block a user