1
0
mirror of https://github.com/zeldaret/oot.git synced 2024-09-23 05:45:03 +00:00
oot/src/libultra_boot_O2/__osEPiRawWriteIo.c
Random 174af7384d
libultra cleanup (#215)
* cleanup libultra

* fixes

- use quotes instead of <> for includes
- add macros for zelda specific thread priorities
- fix Makefile
- properly format the remaining pfs structs

* fix button macros + add CHECK_BTN_ANY/CHECK_BTN_ALL

* remove ULTRA_ABS

* fix includes

* update z_player.c/z_lib.c + run format.sh

* merge upstream/master

* fix include in En_Goroiwa

* fix includes
2020-10-03 11:22:44 -04:00

58 lines
1.8 KiB
C

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