Skip to content

Commit b21fce4

Browse files
committed
IdManager improved
lv2_obj for kernel objects Simple lookup (vector) Another idm API refactoring
1 parent be8d8de commit b21fce4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+797
-750
lines changed

.clang-format

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ IndentWidth: 1
55
AccessModifierOffset: -1
66
PointerAlignment: Left
77
NamespaceIndentation: All
8-
ColumnLimit: 100
8+
ColumnLimit: 200
99
BreakBeforeBraces: Allman
1010
BreakConstructorInitializersBeforeComma: true
1111
BreakBeforeBinaryOperators: false

rpcs3/Emu/Cell/Modules/cellAudio.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ void audio_config::on_task()
278278

279279
for (u64 key : keys)
280280
{
281-
if (auto&& queue = lv2_event_queue_t::find(key))
281+
if (auto&& queue = lv2_event_queue::find(key))
282282
{
283283
if (queue->events() < queue->size)
284284
queue->push(lv2_lock, 0, 0, 0, 0); // TODO: check arguments
@@ -656,7 +656,7 @@ s32 cellAudioCreateNotifyEventQueue(vm::ptr<u32> id, vm::ptr<u64> key)
656656
const u64 key_value = 0x80004d494f323221ull + k;
657657

658658
// Create an event queue "bruteforcing" an available key
659-
if (auto&& queue = lv2_event_queue_t::make(SYS_SYNC_FIFO, SYS_PPU_QUEUE, 0, key_value, 32))
659+
if (auto&& queue = lv2_event_queue::make(SYS_SYNC_FIFO, SYS_PPU_QUEUE, 0, key_value, 32))
660660
{
661661
*id = queue->id;
662662
*key = key_value;

rpcs3/Emu/Cell/Modules/cellDmux.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class ElementaryStream
145145
public:
146146
static const u32 id_base = 1;
147147
static const u32 id_step = 1;
148-
static const u32 id_count = 32767;
148+
static const u32 id_count = 1023;
149149

150150
ElementaryStream(Demuxer* dmux, u32 addr, u32 size, u32 fidMajor, u32 fidMinor, u32 sup1, u32 sup2, vm::ptr<CellDmuxCbEsMsg> cbFunc, u32 cbArg, u32 spec);
151151

rpcs3/Emu/Cell/Modules/cellJpgDec.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ struct CellJpgDecSubHandle
111111
{
112112
static const u32 id_base = 1;
113113
static const u32 id_step = 1;
114-
static const u32 id_count = 32767;
114+
static const u32 id_count = 1023;
115115

116116
u32 fd;
117117
u64 fileSize;

rpcs3/Emu/Cell/Modules/cellVpost.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ class VpostInstance
323323
public:
324324
static const u32 id_base = 1;
325325
static const u32 id_step = 1;
326-
static const u32 id_count = 32767;
326+
static const u32 id_count = 1023;
327327

328328
const bool to_rgba;
329329

rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct trophy_context_t
2020
{
2121
static const u32 id_base = 1;
2222
static const u32 id_step = 1;
23-
static const u32 id_count = 32767;
23+
static const u32 id_count = 1023;
2424

2525
const u32 id = idm::last_id();
2626

@@ -33,7 +33,7 @@ struct trophy_handle_t
3333
{
3434
static const u32 id_base = 1;
3535
static const u32 id_step = 1;
36-
static const u32 id_count = 32767;
36+
static const u32 id_count = 1023;
3737

3838
const u32 id = idm::last_id();
3939
};

rpcs3/Emu/Cell/Modules/sys_heap.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ struct HeapInfo
1111
{
1212
static const u32 id_base = 1;
1313
static const u32 id_step = 1;
14-
static const u32 id_count = 32767;
14+
static const u32 id_count = 1023;
1515

1616
const std::string name;
1717

rpcs3/Emu/Cell/Modules/sys_lwcond_.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ s32 sys_lwcond_create(vm::ptr<sys_lwcond_t> lwcond, vm::ptr<sys_lwmutex_t> lwmut
1313
{
1414
sysPrxForUser.warning("sys_lwcond_create(lwcond=*0x%x, lwmutex=*0x%x, attr=*0x%x)", lwcond, lwmutex, attr);
1515

16-
lwcond->lwcond_queue = idm::make<lv2_lwcond_t>(reinterpret_cast<u64&>(attr->name));
16+
lwcond->lwcond_queue = idm::make<lv2_obj, lv2_lwcond>(reinterpret_cast<u64&>(attr->name));
1717
lwcond->lwmutex = lwmutex;
1818

1919
return CELL_OK;

rpcs3/Emu/Cell/Modules/sys_lwmutex_.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ s32 sys_lwmutex_create(vm::ptr<sys_lwmutex_t> lwmutex, vm::ptr<sys_lwmutex_attri
3434
lwmutex->lock_var.store({ lwmutex_free, 0 });
3535
lwmutex->attribute = attr->recursive | attr->protocol;
3636
lwmutex->recursive_count = 0;
37-
lwmutex->sleep_queue = idm::make<lv2_lwmutex_t>(protocol, reinterpret_cast<u64&>(attr->name));
37+
lwmutex->sleep_queue = idm::make<lv2_obj, lv2_lwmutex>(protocol, reinterpret_cast<u64&>(attr->name));
3838

3939
return CELL_OK;
4040
}

rpcs3/Emu/Cell/Modules/sys_mempool.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ struct memory_pool_t
1313
{
1414
static const u32 id_base = 1;
1515
static const u32 id_step = 1;
16-
static const u32 id_count = 32767;
16+
static const u32 id_count = 1023;
1717

1818
vm::ptr<void> chunk;
1919
u64 chunk_size;

rpcs3/Emu/Cell/Modules/sys_ppu_thread_.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ s32 sys_ppu_thread_create(vm::ptr<u64> thread_id, u32 entry, u64 arg, s32 prio,
4545
// Dirty hack for sound: confirm the creation of _mxr000 event queue
4646
if (threadname && std::memcmp(threadname.get_ptr(), "_cellsurMixerMain", 18) == 0)
4747
{
48-
while (!idm::select<lv2_event_queue_t>([](u32, lv2_event_queue_t& eq)
48+
while (!idm::select<lv2_obj, lv2_event_queue>([](u32, lv2_event_queue& eq)
4949
{
5050
return eq.name == "_mxr000\0"_u64;
5151
}))

rpcs3/Emu/Cell/PPUModule.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ static void ppu_load_imports(const std::shared_ptr<ppu_linkage_info>& link, u32
733733
}
734734
}
735735

736-
std::shared_ptr<lv2_prx_t> ppu_load_prx(const ppu_prx_object& elf)
736+
std::shared_ptr<lv2_prx> ppu_load_prx(const ppu_prx_object& elf)
737737
{
738738
std::vector<std::pair<u32, u32>> segments;
739739
std::vector<std::pair<u32, u32>> sections;
@@ -887,7 +887,7 @@ std::shared_ptr<lv2_prx_t> ppu_load_prx(const ppu_prx_object& elf)
887887
const auto link = fxm::get_always<ppu_linkage_info>();
888888

889889
// Create new PRX object
890-
auto prx = idm::make_ptr<lv2_prx_t>();
890+
auto prx = idm::make_ptr<lv2_obj, lv2_prx>();
891891

892892
if (!elf.progs.empty() && elf.progs[0].p_paddr)
893893
{

rpcs3/Emu/Cell/PPUThread.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ppu_thread : public cpu_thread
2222
public:
2323
static const u32 id_base = 0x01000000; // TODO (used to determine thread type)
2424
static const u32 id_step = 1;
25-
static const u32 id_count = 65535;
25+
static const u32 id_count = 2048;
2626

2727
virtual std::string get_name() const override;
2828
virtual std::string dump() const override;

rpcs3/Emu/Cell/SPUThread.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ bool SPUThread::set_ch_value(u32 ch, u32 value)
867867

868868
LOG_TRACE(SPU, "sys_event_flag_set_bit(id=%d, value=0x%x (flag=%d))", data, value, flag);
869869

870-
const auto eflag = idm::get<lv2_event_flag_t>(data);
870+
const auto eflag = idm::get<lv2_obj, lv2_event_flag>(data);
871871

872872
if (!eflag)
873873
{
@@ -908,7 +908,7 @@ bool SPUThread::set_ch_value(u32 ch, u32 value)
908908

909909
LOG_TRACE(SPU, "sys_event_flag_set_bit_impatient(id=%d, value=0x%x (flag=%d))", data, value, flag);
910910

911-
const auto eflag = idm::get<lv2_event_flag_t>(data);
911+
const auto eflag = idm::get<lv2_obj, lv2_event_flag>(data);
912912

913913
if (!eflag)
914914
{
@@ -1179,7 +1179,7 @@ bool SPUThread::stop_and_signal(u32 code)
11791179
return ch_in_mbox.set_values(1, CELL_EINVAL), true;
11801180
}
11811181

1182-
std::shared_ptr<lv2_event_queue_t> queue;
1182+
std::shared_ptr<lv2_event_queue> queue;
11831183

11841184
for (auto& v : this->spuq)
11851185
{

rpcs3/Emu/Cell/SPUThread.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
#include "Emu/Cell/SPUInterpreter.h"
66
#include "MFC.h"
77

8-
class lv2_event_queue_t;
9-
struct lv2_spu_group_t;
10-
struct lv2_int_tag_t;
8+
class lv2_event_queue;
9+
struct lv2_spu_group;
10+
struct lv2_int_tag;
1111

1212
// SPU Channels
1313
enum : u32
@@ -343,7 +343,7 @@ struct spu_int_ctrl_t
343343
atomic_t<u64> mask;
344344
atomic_t<u64> stat;
345345

346-
std::shared_ptr<struct lv2_int_tag_t> tag;
346+
std::shared_ptr<struct lv2_int_tag> tag;
347347

348348
void set(u64 ints);
349349

@@ -503,7 +503,7 @@ class SPUThread : public cpu_thread
503503
public:
504504
static const u32 id_base = 0x02000000; // TODO (used to determine thread type)
505505
static const u32 id_step = 1;
506-
static const u32 id_count = 65535;
506+
static const u32 id_count = 2048;
507507

508508
SPUThread(const std::string& name, u32 index);
509509

@@ -544,10 +544,10 @@ class SPUThread : public cpu_thread
544544

545545
std::array<spu_int_ctrl_t, 3> int_ctrl; // SPU Class 0, 1, 2 Interrupt Management
546546

547-
std::weak_ptr<lv2_spu_group_t> tg; // SPU Thread Group
547+
std::weak_ptr<lv2_spu_group> tg; // SPU Thread Group
548548

549-
std::array<std::pair<u32, std::weak_ptr<lv2_event_queue_t>>, 32> spuq; // Event Queue Keys for SPU Thread
550-
std::weak_ptr<lv2_event_queue_t> spup[64]; // SPU Ports
549+
std::array<std::pair<u32, std::weak_ptr<lv2_event_queue>>, 32> spuq; // Event Queue Keys for SPU Thread
550+
std::weak_ptr<lv2_event_queue> spup[64]; // SPU Ports
551551

552552
u32 pc = 0; //
553553
const u32 index; // SPU index

rpcs3/Emu/Cell/lv2/sys_cond.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ logs::channel sys_cond("sys_cond", logs::level::notice);
1616

1717
extern u64 get_system_time();
1818

19-
void lv2_cond_t::notify(lv2_lock_t, cpu_thread* thread)
19+
void lv2_cond::notify(lv2_lock_t, cpu_thread* thread)
2020
{
2121
if (mutex->owner)
2222
{
@@ -36,7 +36,7 @@ s32 sys_cond_create(vm::ptr<u32> cond_id, u32 mutex_id, vm::ptr<sys_cond_attribu
3636

3737
LV2_LOCK;
3838

39-
const auto mutex = idm::get<lv2_mutex_t>(mutex_id);
39+
const auto mutex = idm::get<lv2_obj, lv2_mutex>(mutex_id);
4040

4141
if (!mutex)
4242
{
@@ -54,7 +54,7 @@ s32 sys_cond_create(vm::ptr<u32> cond_id, u32 mutex_id, vm::ptr<sys_cond_attribu
5454
fmt::throw_exception("Unexpected cond_count" HERE);
5555
}
5656

57-
*cond_id = idm::make<lv2_cond_t>(mutex, attr->name_u64);
57+
*cond_id = idm::make<lv2_obj, lv2_cond>(mutex, attr->name_u64);
5858

5959
return CELL_OK;
6060
}
@@ -65,7 +65,7 @@ s32 sys_cond_destroy(u32 cond_id)
6565

6666
LV2_LOCK;
6767

68-
const auto cond = idm::get<lv2_cond_t>(cond_id);
68+
const auto cond = idm::get<lv2_obj, lv2_cond>(cond_id);
6969

7070
if (!cond)
7171
{
@@ -82,7 +82,7 @@ s32 sys_cond_destroy(u32 cond_id)
8282
fmt::throw_exception("Unexpected cond_count" HERE);
8383
}
8484

85-
idm::remove<lv2_cond_t>(cond_id);
85+
idm::remove<lv2_obj, lv2_cond>(cond_id);
8686

8787
return CELL_OK;
8888
}
@@ -93,7 +93,7 @@ s32 sys_cond_signal(u32 cond_id)
9393

9494
LV2_LOCK;
9595

96-
const auto cond = idm::get<lv2_cond_t>(cond_id);
96+
const auto cond = idm::get<lv2_obj, lv2_cond>(cond_id);
9797

9898
if (!cond)
9999
{
@@ -116,7 +116,7 @@ s32 sys_cond_signal_all(u32 cond_id)
116116

117117
LV2_LOCK;
118118

119-
const auto cond = idm::get<lv2_cond_t>(cond_id);
119+
const auto cond = idm::get<lv2_obj, lv2_cond>(cond_id);
120120

121121
if (!cond)
122122
{
@@ -140,7 +140,7 @@ s32 sys_cond_signal_to(u32 cond_id, u32 thread_id)
140140

141141
LV2_LOCK;
142142

143-
const auto cond = idm::get<lv2_cond_t>(cond_id);
143+
const auto cond = idm::get<lv2_obj, lv2_cond>(cond_id);
144144

145145
if (!cond)
146146
{
@@ -173,7 +173,7 @@ s32 sys_cond_wait(ppu_thread& ppu, u32 cond_id, u64 timeout)
173173

174174
LV2_LOCK;
175175

176-
const auto cond = idm::get<lv2_cond_t>(cond_id);
176+
const auto cond = idm::get<lv2_obj, lv2_cond>(cond_id);
177177

178178
if (!cond)
179179
{

rpcs3/Emu/Cell/lv2/sys_cond.h

+4-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include "sys_sync.h"
44

5-
struct lv2_mutex_t;
5+
struct lv2_mutex;
66

77
struct sys_cond_attribute_t
88
{
@@ -17,18 +17,16 @@ struct sys_cond_attribute_t
1717
};
1818
};
1919

20-
struct lv2_cond_t
20+
struct lv2_cond final : lv2_obj
2121
{
2222
static const u32 id_base = 0x86000000;
23-
static const u32 id_step = 0x100;
24-
static const u32 id_count = 8192;
2523

2624
const u64 name;
27-
const std::shared_ptr<lv2_mutex_t> mutex; // associated mutex
25+
const std::shared_ptr<lv2_mutex> mutex; // associated mutex
2826

2927
sleep_queue<cpu_thread> sq;
3028

31-
lv2_cond_t(const std::shared_ptr<lv2_mutex_t>& mutex, u64 name)
29+
lv2_cond(const std::shared_ptr<lv2_mutex>& mutex, u64 name)
3230
: mutex(mutex)
3331
, name(name)
3432
{

0 commit comments

Comments
 (0)