Nugget
Loading...
Searching...
No Matches
sio0-bus.hh
Go to the documentation of this file.
1/*
2
3MIT License
4
5Copyright (c) 2026 PCSX-Redux authors
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25*/
26
27#pragma once
28
29#include <stdint.h>
30
31namespace psyqo {
32
54class SIO0Bus {
55 public:
59 static void acquire() { s_depth = s_depth + 1; }
60
64 static void release() {
65 if (s_depth) s_depth = s_depth - 1;
66 }
67
71 static bool owned() { return s_depth != 0; }
72
79 struct Lock {
80 Lock() { acquire(); }
81 ~Lock() { release(); }
82 Lock(const Lock &) = delete;
83 Lock &operator=(const Lock &) = delete;
84 };
85
86 private:
87 static inline volatile uint32_t s_depth = 0;
88};
89
90} // namespace psyqo
Ownership arbiter for the SIO0 serial bus.
Definition sio0-bus.hh:54
static bool owned()
Returns whether the bus is currently owned by a card transaction.
Definition sio0-bus.hh:71
static void release()
Releases one level of ownership taken by acquire.
Definition sio0-bus.hh:64
static void acquire()
Takes ownership of the bus for the calling transaction.
Definition sio0-bus.hh:59
Definition lua.hh:38
RAII helper that owns the bus for the lifetime of the object.
Definition sio0-bus.hh:79
Lock(const Lock &)=delete
Lock & operator=(const Lock &)=delete
Lock()
Definition sio0-bus.hh:80
~Lock()
Definition sio0-bus.hh:81
void uint32_t(classId, spec)