Skip to content

Commit 6d733a6

Browse files
committed
Address review concerns and suggestions
1 parent d80e48f commit 6d733a6

File tree

4 files changed

+27
-8
lines changed

4 files changed

+27
-8
lines changed

src/mips/psyqo/cdrom-commandbuffer.hh

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ SOFTWARE.
3131
#include <concepts>
3232
#include <type_traits>
3333

34+
namespace psyqo::Hardware::CDRom {
35+
3436
template <typename T>
3537
concept CDRomArgumentType = std::is_integral<T>::value;
3638

@@ -53,3 +55,4 @@ struct CDRomCommandBuffer {
5355
recursiveSet(pos + 1, args...);
5456
}
5557
};
58+
} // namespace psyqo::Hardware::CDRom

src/mips/psyqo/cdrom-device.hh

+3-3
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,9 @@ class CDRomDevice final : public CDRom {
418418
*
419419
* @param callback The callback to call when the command operation is complete.
420420
*/
421-
void test(CDRomCommandBuffer commandBuffer, eastl::function<void(bool)> &&callback);
422-
TaskQueue::Task scheduleTest(CDRomCommandBuffer commandBuffer);
423-
void testBlocking(GPU &, CDRomCommandBuffer commandBuffer);
421+
void test(const psyqo::Hardware::CDRom::CDRomCommandBuffer &commandBuffer, eastl::function<void(bool)> &&callback);
422+
TaskQueue::Task scheduleTest(const psyqo::Hardware::CDRom::CDRomCommandBuffer &commandBuffer);
423+
void testBlocking(GPU &, const psyqo::Hardware::CDRom::CDRomCommandBuffer &commandBuffer);
424424

425425
/**
426426
* @brief The action base class for the internal state machine.

src/mips/psyqo/examples/cdrom-demo/cdrom-demo.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ SOFTWARE.
2727
#include "common/syscalls/syscalls.h"
2828
#include "psyqo/application.hh"
2929
#include "psyqo/cdrom-device.hh"
30+
#include "psyqo/cdrom-commandbuffer.hh"
3031
#include "psyqo/font.hh"
3132
#include "psyqo/gpu.hh"
3233
#include "psyqo/scene.hh"
@@ -75,6 +76,11 @@ void CDRomDemo::createScene() {
7576
syscall_puts("Failure\n");
7677
}
7778
});
79+
80+
81+
psyqo::Hardware::CDRom::CDRomCommandBuffer commandBuffer;
82+
commandBuffer.set(0x50, 0xf2, 0xde, 0xad);
83+
m_cdrom.testBlocking(gpu(), commandBuffer);
7884
}
7985

8086
void CDRomDemoScene::frame() {

src/mips/psyqo/src/cdrom-device-test.cpp

+15-5
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,18 @@ class TestAction : public psyqo::CDRomDevice::Action<TestActionState> {
4343
public:
4444
TestAction() : Action("TestAction") {}
4545

46-
void start(psyqo::CDRomDevice *device, CDRomCommandBuffer commandBuffer, eastl::function<void(bool)> &&callback) {
46+
void start(psyqo::CDRomDevice *device, const psyqo::Hardware::CDRom::CDRomCommandBuffer &commandBuffer,
47+
eastl::function<void(bool)> &&callback) {
4748
psyqo::Kernel::assert(device->isIdle(), "CDRomDevice::test() called while another action is in progress");
4849
registerMe(device);
4950
setCallback(eastl::move(callback));
5051
setState(TestActionState::TEST);
5152
eastl::atomic_signal_fence(eastl::memory_order_release);
5253
psyqo::Hardware::CDRom::Command.send(psyqo::Hardware::CDRom::CDL::TEST, commandBuffer);
5354
}
55+
void start(psyqo::CDRomDevice *device, eastl::function<void(bool)> &&callback) {
56+
start(device, m_commandBuffer, eastl::move(callback));
57+
}
5458
bool complete(const psyqo::CDRomDevice::Response &) override {
5559
setSuccess(true);
5660
return true;
@@ -59,23 +63,29 @@ class TestAction : public psyqo::CDRomDevice::Action<TestActionState> {
5963
setSuccess(true);
6064
return true;
6165
}
66+
67+
psyqo::Hardware::CDRom::CDRomCommandBuffer m_commandBuffer;
6268
};
6369

6470
TestAction s_testAction;
6571

6672
} // namespace
6773

68-
void psyqo::CDRomDevice::test(CDRomCommandBuffer commandBuffer, eastl::function<void(bool)> &&callback) {
74+
void psyqo::CDRomDevice::test(const psyqo::Hardware::CDRom::CDRomCommandBuffer &commandBuffer,
75+
eastl::function<void(bool)> &&callback) {
6976
Kernel::assert(m_callback == nullptr, "CDRomDevice::test called with pending action");
7077
s_testAction.start(this, commandBuffer, eastl::move(callback));
7178
}
7279

73-
psyqo::TaskQueue::Task psyqo::CDRomDevice::scheduleTest(CDRomCommandBuffer commandBuffer) {
80+
psyqo::TaskQueue::Task psyqo::CDRomDevice::scheduleTest(
81+
const psyqo::Hardware::CDRom::CDRomCommandBuffer &commandBuffer) {
82+
s_testAction.m_commandBuffer = commandBuffer;
83+
7484
return TaskQueue::Task(
75-
[this, commandBuffer](auto task) { test(commandBuffer, [task](bool success) { task->complete(success); }); });
85+
[this](auto task) { s_testAction.start(this, [task](bool success) { task->complete(success); }); });
7686
}
7787

78-
void psyqo::CDRomDevice::testBlocking(GPU &gpu, CDRomCommandBuffer commandBuffer) {
88+
void psyqo::CDRomDevice::testBlocking(GPU &gpu, const psyqo::Hardware::CDRom::CDRomCommandBuffer &commandBuffer) {
7989
Kernel::assert(m_callback == nullptr, "CDRomDevice::testBlocking called with pending action");
8090
bool success = false;
8191
{

0 commit comments

Comments
 (0)