Get rough shape of CD file processing code

This commit is contained in:
2023-02-18 09:35:15 +01:00
parent dbeb12bc73
commit a8cef82e58
7 changed files with 121 additions and 24 deletions

View File

@@ -5,7 +5,61 @@
namespace JabyEngine {
namespace CD {
namespace internal {
enum struct State {
Free = 0,
Done = 0,
Reading,
BufferFull,
Error,
};
extern VolatilePOD<CD_IO::Interrupt::Type> last_interrupt;
extern VolatilePOD<State> state;
struct Sector {
uint32_t data[512];
};
struct FileInfo {
uint16_t lba;
uint16_t sectors;
constexpr FileInfo(uint16_t lba, uint16_t sectors) : lba(lba), sectors(sectors) {
}
};
class SectorBufferAllocator {
private:
struct Dummy {
};
typedef Sector* (*SimpleAllocator)();
typedef Sector* (Dummy::*ComplexAllocator)();
private:
Dummy* this_ctx = nullptr;
union {
SimpleAllocator allocate;
ComplexAllocator this_allocate;
};
SectorBufferAllocator(SimpleAllocator allocate) : this_ctx(nullptr), allocate(allocate) {
}
SectorBufferAllocator(Dummy* ctx, ComplexAllocator this_allocate) : this_ctx(ctx), this_allocate(this_allocate) {
}
public:
static SectorBufferAllocator create(SimpleAllocator allocate) {
return SectorBufferAllocator(allocate);
}
template<typename T>
static SectorBufferAllocator create(T &obj, Sector* (T::*obj_allocate)()) {
return SectorBufferAllocator(reinterpret_cast<Dummy*>(&obj), reinterpret_cast<ComplexAllocator>(obj_allocate));
}
};
struct Command {
static void wait_until(CD_IO::Interrupt::Type irq) {
@@ -26,6 +80,8 @@ namespace JabyEngine {
wait_until(cmd.complete_irq);
}
};
State start_reading(FileInfo file_info, const SectorBufferAllocator& buffer_allocator);
}
}
}

View File

@@ -1,6 +1,8 @@
#include "../../../include/BootLoader/boot_loader.hpp"
#include <stdio.h>
#include <PSX/File/Processor/cd_file_processor.hpp>
extern JabyEngine::NextRoutine main();
namespace JabyEngine {

View File

@@ -2,6 +2,8 @@
#include <PSX/System/IOPorts/interrupt_io.hpp>
#include <PSX/System/syscalls.h>
#include <stdio.h>
namespace JabyEngine {
namespace CD {
namespace internal {
@@ -35,6 +37,11 @@ namespace JabyEngine {
.handler_function = reinterpret_cast<InterruptHandler>(interrupt_handler),
.verifier_function = interrupt_verifier
};
State start_reading(FileInfo file_info, const SectorBufferAllocator& buffer_allocator) {
printf("I'm not implemented! %s\n", __FUNCTION__);
return State::Error;
}
}
}
}

View File

@@ -1,2 +1,22 @@
#include <PSX/File/Processor/cd_file_processor.hpp>
#include <stdio.h>
namespace JabyEngine {
void CDFileProcessor :: start_cur_job() {
const auto& cur_lba = this->lba[this->jobs.files->rel_lba_idx];
printf(">>> CD needs to load LBA: %i -> %i\n", cur_lba.lba, cur_lba.size_words);
}
void CDFileProcessor :: setup(const volatile AutoLBAEntry* lba, JobArray jobs, uint8_t* work_area) {
this->lba = const_cast<const AutoLBAEntry*>(lba);
this->work_area = work_area;
this->jobs = jobs;
CDFileProcessor::start_cur_job();
}
Progress CDFileProcessor :: process() {
return Progress::Error;
}
}