Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmake/aurora_os.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ add_library(aurora_os STATIC lib/dolphin/os/OSInit.cpp
lib/dolphin/os/OSBootInfo.cpp
lib/dolphin/os/OSTime.cpp
lib/dolphin/os/OSArena.cpp
lib/dolphin/os/OSAlloc.cpp
lib/dolphin/os/OSAddress.cpp
lib/dolphin/os/OSReport.cpp
lib/dolphin/AR.cpp)
Expand Down
7 changes: 2 additions & 5 deletions include/dolphin/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ void OSVAttention(const char* fmt, va_list args);
extern "C" {
#endif

typedef s64 OSTime;
typedef u32 OSTick;

#include <dolphin/os/OSAlloc.h>
#include <dolphin/os/OSCache.h>
#include <dolphin/os/OSContext.h>
Expand Down Expand Up @@ -100,8 +97,8 @@ u8 __gUnknown800030E3 AT_ADDRESS(OS_BASE_CACHED | 0x30E3);
#endif

#define OS_TIMER_CLOCK_DIVIDER 4
#define OS_BUS_CLOCK 162'000'000
#define OS_CORE_CLOCK 162'000'000
#define OS_BUS_CLOCK 162000000
#define OS_CORE_CLOCK 162000000
#define OS_TIMER_CLOCK (OS_BUS_CLOCK/OS_TIMER_CLOCK_DIVIDER)

#define OSTicksToSeconds(ticks) ((ticks) / (OS_TIMER_CLOCK))
Expand Down
18 changes: 9 additions & 9 deletions include/dolphin/os/OSAlloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ typedef int OSHeapHandle;

extern volatile OSHeapHandle __OSCurrHeap;

void* OSAllocFromHeap(int heap, u32 size);
void* OSAllocFromHeap(OSHeapHandle heap, u32 size);
void* OSAllocFixed(void* rstart, void* rend);
void OSFreeToHeap(int heap, void* ptr);
int OSSetCurrentHeap(int heap);
void OSFreeToHeap(OSHeapHandle heap, void* ptr);
OSHeapHandle OSSetCurrentHeap(OSHeapHandle heap);
void* OSInitAlloc(void* arenaStart, void* arenaEnd, int maxHeaps);
int OSCreateHeap(void* start, void* end);
void OSDestroyHeap(int heap);
void OSAddToHeap(int heap, void* start, void* end);
s32 OSCheckHeap(int heap);
OSHeapHandle OSCreateHeap(void* start, void* end);
void OSDestroyHeap(OSHeapHandle heap);
void OSAddToHeap(OSHeapHandle heap, void* start, void* end);
s32 OSCheckHeap(OSHeapHandle heap);
u32 OSReferentSize(void* ptr);
void OSDumpHeap(int heap);
void OSDumpHeap(OSHeapHandle heap);
void OSVisitAllocated(void (*visitor)(void*, u32));

#define OSAlloc(size) OSAllocFromHeap(__OSCurrHeap, (size))
#define OSFree(ptr) OSFreeToHeap(__OSCurrHeap, (ptr))
#define OSFree(ptr) OSFreeToHeap(__OSCurrHeap, (ptr))

#ifdef __cplusplus
}
Expand Down
3 changes: 2 additions & 1 deletion include/dolphin/os/OSError.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ typedef void (*OSErrorHandler)(OSError error, OSContext* context, ...);
#define OS_ERROR_BREAKPOINT 12
#define OS_ERROR_SYSTEM_INTERRUPT 13
#define OS_ERROR_THERMAL_INTERRUPT 14
#define OS_ERROR_MAX (OS_ERROR_THERMAL_INTERRUPT + 1)
#define OS_ERROR_PROTECTION 15
#define OS_ERROR_MAX (OS_ERROR_PROTECTION + 1)

OSErrorHandler OSSetErrorHandler(OSError error, OSErrorHandler handler);
extern u32 __OSFpscrEnableBits;
Expand Down
1 change: 1 addition & 0 deletions include/dolphin/os/OSInterrupt.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <dolphin/types.h>
#include <dolphin/os/OSException.h>
#include <dolphin/os/OSTime.h>

#ifdef __cplusplus
extern "C" {
Expand Down
19 changes: 12 additions & 7 deletions include/dolphin/os/OSReset.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,30 @@
extern "C" {
#endif

#define OS_RESET_RESTART 0
#define OS_RESET_RESTART 0
#define OS_RESET_HOTRESET 1
#define OS_RESET_SHUTDOWN 2

typedef struct OSResetFunctionInfo OSResetFunctionInfo;
typedef struct OSResetFunctionQueue {
OSResetFunctionInfo* head;
OSResetFunctionInfo* tail;
OSResetFunctionInfo* head;
OSResetFunctionInfo* tail;
} OSResetFunctionQueue;

typedef BOOL (*OSResetFunction)(BOOL);

struct OSResetFunctionInfo {
OSResetFunction func;
u32 priority;
OSResetFunctionInfo* next;
OSResetFunctionInfo* prev;
OSResetFunction func;
u32 priority;
OSResetFunctionInfo* next;
OSResetFunctionInfo* prev;
};

#define OS_RESET_RESTART 0
#define OS_RESET_HOTRESET 1
#define OS_RESET_SHUTDOWN 2
#define OS_RESETCODE_RESTART 0x80000000

void OSRegisterResetFunction(OSResetFunctionInfo* info);
void OSUnregisterResetFunction(OSResetFunctionInfo* info);
void OSResetSystem(int reset, u32 resetCode, BOOL forceMenu);
Expand Down
9 changes: 7 additions & 2 deletions include/dolphin/os/OSTime.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@
extern "C" {
#endif

typedef s64 OSTime;
typedef u32 OSTick;

#define OSDiffTick(tick1, tick0) ((s32)(tick1) - (s32)(tick0))

// Time base frequency = 1/4 bus clock
#define OS_TIME_SPEED (OS_BUS_CLOCK / 4)

// OS time -> Real time
#define OS_TICKS_TO_SEC(x) ((x) / (OS_TIME_SPEED))
#define OS_TICKS_TO_MSEC(x) ((x) / (OS_TIME_SPEED / 1000))
#define OS_TICKS_TO_USEC(x) (((x)*8) / (OS_TIME_SPEED / 125000))
#define OS_TICKS_TO_NSEC(x) (((x)*8000) / (OS_TIME_SPEED / 125000))
#define OS_TICKS_TO_USEC(x) (((x) * 8) / (OS_TIME_SPEED / 125000))
#define OS_TICKS_TO_NSEC(x) (((x) * 8000) / (OS_TIME_SPEED / 125000))

// Real time -> OS time
#define OS_SEC_TO_TICKS(x) ((x) * (OS_TIME_SPEED))
Expand Down
Loading
Loading