1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-05-11 11:33:48 +00:00
oot/src/libultra/io/epirawwrite.c
Tharo efe485f017
Improve rcp.h, remove HW_REG macro (#1425)
* Real rcp.h

* Correction to comment in initialize.c

* Try fix R4300.h

* Adjust rcp.h formatting, remove defines in other headers that are now in rcp.h

* Suggested changes, document a bug in the modified osAiSetNextBuffer

* More rcp.h formatting changes
2022-11-13 02:16:01 -05:00

58 lines
1.8 KiB
C

#include "global.h"
s32 __osEPiRawWriteIo(OSPiHandle* handle, u32 devAddr, u32 data) {
s32 status;
OSPiHandle* curHandle;
status = IO_READ(PI_STATUS_REG);
while (status & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) {
status = IO_READ(PI_STATUS_REG);
}
if (__osCurrentHandle[handle->domain]->type != handle->type) {
curHandle = __osCurrentHandle[handle->domain];
if (handle->domain == 0) {
if (curHandle->latency != handle->latency) {
IO_WRITE(PI_BSD_DOM1_LAT_REG, handle->latency);
}
if (curHandle->pageSize != handle->pageSize) {
IO_WRITE(PI_BSD_DOM1_PGS_REG, handle->pageSize);
}
if (curHandle->relDuration != handle->relDuration) {
IO_WRITE(PI_BSD_DOM1_RLS_REG, handle->relDuration);
}
if (curHandle->pulse != handle->pulse) {
IO_WRITE(PI_BSD_DOM1_PWD_REG, handle->pulse);
}
} else {
if (curHandle->latency != handle->latency) {
IO_WRITE(PI_BSD_DOM2_LAT_REG, handle->latency);
}
if (curHandle->pageSize != handle->pageSize) {
IO_WRITE(PI_BSD_DOM2_PGS_REG, handle->pageSize);
}
if (curHandle->relDuration != handle->relDuration) {
IO_WRITE(PI_BSD_DOM2_RLS_REG, handle->relDuration);
}
if (curHandle->pulse != handle->pulse) {
IO_WRITE(PI_BSD_DOM2_PWD_REG, handle->pulse);
}
}
curHandle->type = handle->type;
curHandle->latency = handle->latency;
curHandle->pageSize = handle->pageSize;
curHandle->relDuration = handle->relDuration;
curHandle->pulse = handle->pulse;
}
IO_WRITE(handle->baseAddress | devAddr, data);
return 0;
}