diff options
| author | Roman971 <romanlasnier@hotmail.com> | 2020-03-22 22:19:43 +0100 |
|---|---|---|
| committer | Roman971 <romanlasnier@hotmail.com> | 2020-03-22 22:20:03 +0100 |
| commit | 8cfe7cce9f8d8abea794e67510879e751d373a87 (patch) | |
| tree | c6c46f34d3575f6dc02b98b2b5f5ad88d2b2c64e /src/libultra_boot_O2 | |
| parent | 251aea64ab3e6e8cd6f1d9ed34f514e656724777 (diff) | |
Format all src C files
Diffstat (limited to 'src/libultra_boot_O2')
34 files changed, 396 insertions, 415 deletions
diff --git a/src/libultra_boot_O2/_Ldtob.c b/src/libultra_boot_O2/_Ldtob.c index 4a72dfd33..57a49cc8c 100644 --- a/src/libultra_boot_O2/_Ldtob.c +++ b/src/libultra_boot_O2/_Ldtob.c @@ -5,8 +5,8 @@ #define BUFF_LEN 0x20 -s16 _Ldunscale(s16 *, _Pft *); -void _Genld(_Pft *, u8, u8 *, s16, s16); +s16 _Ldunscale(s16*, _Pft*); +void _Genld(_Pft*, u8, u8*, s16, s16); const double D_800122E0[] = { 10e0L, 10e1L, 10e3L, 10e7L, 10e15L, 10e31L, 10e63L, 10e127L, 10e255L }; @@ -43,9 +43,9 @@ const double D_800122E0[] = { 10e0L, 10e1L, 10e3L, 10e7L, 10e15L, 10e31L, 10e63L #define _D3 3 #endif -void _Ldtob(_Pft *args, u8 type) { +void _Ldtob(_Pft* args, u8 type) { u8 buff[BUFF_LEN]; - u8 *ptr; + u8* ptr; u32 sp70; f64 val; /* maybe struct? */ @@ -159,9 +159,9 @@ void _Ldtob(_Pft *args, u8 type) { _Genld((_Pft*)args, type, ptr, nsig, exp); } -s16 _Ldunscale(s16 *pex, _Pft *px) { +s16 _Ldunscale(s16* pex, _Pft* px) { - unsigned short *ps = (unsigned short *) px; + unsigned short* ps = (unsigned short*)px; short xchar = (ps[_D0] & _DMASK) >> _DOFF; if (xchar == _DMAX) { /* NaN or INF */ *pex = 0; @@ -179,16 +179,15 @@ s16 _Ldunscale(s16 *pex, _Pft *px) { } } -void _Genld(_Pft *px, u8 code, u8 *p, s16 nsig, s16 xexp) { +void _Genld(_Pft* px, u8 code, u8* p, s16 nsig, s16 xexp) { u8 point = '.'; if (nsig <= 0) { nsig = 1, - p = (u8 *) "0"; + p = (u8*)"0"; } - if (code == 'f' - || ((code == 'g' || code == 'G') && (-4 <= xexp) && (xexp < px->prec))) { /* 'f' format */ + if (code == 'f' || ((code == 'g' || code == 'G') && (-4 <= xexp) && (xexp < px->prec))) { /* 'f' format */ ++xexp; /* change to leading digit count */ if (code != 'f') { /* fixup for 'g' */ if (!(px->flags & FLAGS_HASH) && nsig < px->prec) { @@ -257,7 +256,7 @@ void _Genld(_Pft *px, u8 code, u8 *p, s16 nsig, s16 xexp) { px->n1 += nsig; px->nz1 = px->prec - nsig; } - p = (u8 *) &px->s[px->n1]; /* put exponent */ + p = (u8*)&px->s[px->n1]; /* put exponent */ *p++ = code; if (0 <= xexp) { *p++ = '+'; @@ -273,11 +272,10 @@ void _Genld(_Pft *px, u8 code, u8 *p, s16 nsig, s16 xexp) { } *p++ = xexp / 10 + '0', xexp %= 10; *p++ = xexp + '0'; - px->n2 = p - (u8 *) &px->s[px->n1]; + px->n2 = p - (u8*)&px->s[px->n1]; } if ((px->flags & (FLAGS_ZERO | FLAGS_MINUS)) == FLAGS_ZERO) { /* pad with leading zeros */ - int n = - px->n0 + px->n1 + px->nz1 + px->n2 + px->nz2; + int n = px->n0 + px->n1 + px->nz1 + px->n2 + px->nz2; if (n < px->width) { px->nz0 = px->width - n; diff --git a/src/libultra_boot_O2/_Litob.c b/src/libultra_boot_O2/_Litob.c index 15206217c..5b2329cd3 100644 --- a/src/libultra_boot_O2/_Litob.c +++ b/src/libultra_boot_O2/_Litob.c @@ -8,28 +8,31 @@ u8 D_8000AF70[] = "0123456789abcdef"; u8 D_8000AF84[] = "0123456789ABCDEF"; -void _Litob(_Pft *args, u8 type) { +void _Litob(_Pft* args, u8 type) { u8 buff[BUFF_LEN]; - const u8 *num_map; + const u8* num_map; s32 base; s32 buff_ind; u64 num; lldiv_t quotrem; - if (type == 'X') + if (type == 'X') { num_map = D_8000AF84; - else + } else { num_map = D_8000AF70; + } base = (type == 'o') ? 8 : ((type != 'x' && type != 'X') ? 10 : 16); buff_ind = BUFF_LEN; num = args->v.ll; - if ((type == 'd' || type == 'i') && args->v.ll < 0) + if ((type == 'd' || type == 'i') && args->v.ll < 0) { num = -num; + } - if (num != 0 || args->prec != 0) + if (num != 0 || args->prec != 0) { buff[--buff_ind] = num_map[num % base]; + } args->v.ll = num / base; @@ -43,12 +46,14 @@ void _Litob(_Pft *args, u8 type) { memcpy(args->s, buff + buff_ind, args->n1); - if (args->n1 < args->prec) + if (args->n1 < args->prec) { args->nz0 = args->prec - args->n1; + } if (args->prec < 0 && (args->flags & (FLAGS_ZERO | FLAGS_MINUS)) == FLAGS_ZERO) { buff_ind = args->width - args->n0 - args->nz0 - args->n1; - if (buff_ind > 0) + if (buff_ind > 0) { args->nz0 += buff_ind; + } } } diff --git a/src/libultra_boot_O2/_Printf.c b/src/libultra_boot_O2/_Printf.c index cbb803bbd..a5f922d56 100644 --- a/src/libultra_boot_O2/_Printf.c +++ b/src/libultra_boot_O2/_Printf.c @@ -3,38 +3,37 @@ #include <stdarg.h> #include <string.h> -#define ATOI(i, a) \ - for (i = 0; *a >= '0' && *a <= '9'; a++) \ - if (i < 999) \ +#define ATOI(i, a) \ + for (i = 0; *a >= '0' && *a <= '9'; a++) \ + if (i < 999) \ i = *a + i * 10 - '0'; -#define _PROUT(fmt, _size) \ - if (_size > 0) { \ - arg = (void*)pfn(arg, fmt, _size); \ - if (arg != 0) \ - x.nchar += _size; \ - else \ - return x.nchar; \ +#define _PROUT(fmt, _size) \ + if (_size > 0) { \ + arg = (void*)pfn(arg, fmt, _size); \ + if (arg != 0) \ + x.nchar += _size; \ + else \ + return x.nchar; \ } -#define _PAD(m, src, extracond) \ - if (extracond && m > 0) { \ - int i; \ - int j; \ - for (j = m; j > 0; j -= i) { \ - if ((u32) j > 32) \ - i = 32; \ - else \ - i = j; \ - _PROUT(src, i); \ - } \ +#define _PAD(m, src, extracond) \ + if (extracond && m > 0) { \ + int i; \ + int j; \ + for (j = m; j > 0; j -= i) { \ + if ((u32)j > 32) \ + i = 32; \ + else \ + i = j; \ + _PROUT(src, i); \ + } \ } char spaces[] = " "; char zeroes[] = "00000000000000000000000000000000"; -void _Putfld(_Pft *, va_list *, u8, u8 *); +void _Putfld(_Pft*, va_list*, u8, u8*); -s32 _Printf(char *(*pfn)(char *, const char *, size_t), char *arg, const char *fmt, va_list ap) -{ +s32 _Printf(char* (*pfn)(char*, const char*, size_t), char* arg, const char* fmt, va_list ap) { _Pft x; x.nchar = 0; while (1) { @@ -47,15 +46,15 @@ s32 _Printf(char *(*pfn)(char *, const char *, size_t), char *arg, const char *f u8 ac[0x20]; - s = (u8 *)fmt; + s = (u8*)fmt; while ((c = *s) != 0 && c != '%') { s++; } - _PROUT(fmt, s - (u8 *)fmt); + _PROUT(fmt, s - (u8*)fmt); if (c == 0) { return x.nchar; } - fmt = (char *) ++s; + fmt = (char*)++s; x.flags = 0; for (; (t = strchr(fchar, *s)) != NULL; s++) { x.flags |= fbit[t - fchar]; @@ -92,23 +91,21 @@ s32 _Printf(char *(*pfn)(char *, const char *, size_t), char *arg, const char *f s++; } _Putfld(&x, &ap, *s, ac); - x.width -= x.n0 + x.nz0 + x.n1 + x.nz1 - + x.n2 + x.nz2; + x.width -= x.n0 + x.nz0 + x.n1 + x.nz1 + x.n2 + x.nz2; _PAD(x.width, spaces, !(x.flags & FLAGS_MINUS)); - _PROUT((char *) ac, x.n0); + _PROUT((char*)ac, x.n0); _PAD(x.nz0, zeroes, 1); _PROUT(x.s, x.n1); _PAD(x.nz1, zeroes, 1); - _PROUT((char *) (&x.s[x.n1]), x.n2) + _PROUT((char*)(&x.s[x.n1]), x.n2) _PAD(x.nz2, zeroes, 1); _PAD(x.width, spaces, x.flags & FLAGS_MINUS); - fmt = (char *) s + 1; + fmt = (char*)s + 1; } } void _Putfld(_Pft* px, va_list* pap, u8 code, u8* ac) { - px->n0 = px->nz0 = px->n1 = px->nz1 = px->n2 = - px->nz2 = 0; + px->n0 = px->nz0 = px->n1 = px->nz1 = px->n2 = px->nz2 = 0; switch (code) { @@ -127,7 +124,7 @@ void _Putfld(_Pft* px, va_list* pap, u8 code, u8* ac) { } if (px->qual == 'h') { - px->v.ll = (s16) px->v.ll; + px->v.ll = (s16)px->v.ll; } if (px->v.ll < 0) { @@ -138,7 +135,7 @@ void _Putfld(_Pft* px, va_list* pap, u8 code, u8* ac) { ac[px->n0++] = ' '; } - px->s = (char *) &ac[px->n0]; + px->s = (char*)&ac[px->n0]; _Litob(px, code); break; @@ -156,9 +153,9 @@ void _Putfld(_Pft* px, va_list* pap, u8 code, u8* ac) { } if (px->qual == 'h') { - px->v.ll = (u16) px->v.ll; + px->v.ll = (u16)px->v.ll; } else if (px->qual == 0) { - px->v.ll = (u32) px->v.ll; + px->v.ll = (u32)px->v.ll; } if (px->flags & FLAGS_HASH) { @@ -168,7 +165,7 @@ void _Putfld(_Pft* px, va_list* pap, u8 code, u8* ac) { ac[px->n0++] = code; } } - px->s = (char *) &ac[px->n0]; + px->s = (char*)&ac[px->n0]; _Litob(px, code); break; @@ -189,30 +186,30 @@ void _Putfld(_Pft* px, va_list* pap, u8 code, u8* ac) { } } - px->s = (char *) &ac[px->n0]; + px->s = (char*)&ac[px->n0]; _Ldtob(px, code); break; case 'n': if (px->qual == 'h') { - *(va_arg(*pap, u16 *)) = px->nchar; + *(va_arg(*pap, u16*)) = px->nchar; } else if (px->qual == 'l') { - *va_arg(*pap, u32 *) = px->nchar; + *va_arg(*pap, u32*) = px->nchar; } else if (px->qual == 'L') { - *va_arg(*pap, u64 *) = px->nchar; + *va_arg(*pap, u64*) = px->nchar; } else { - *va_arg(*pap, u32 *) = px->nchar; + *va_arg(*pap, u32*) = px->nchar; } break; case 'p': - px->v.ll = (long) va_arg(*pap, void *); - px->s = (char *) &ac[px->n0]; + px->v.ll = (long)va_arg(*pap, void*); + px->s = (char*)&ac[px->n0]; _Litob(px, 'x'); break; case 's': - px->s = va_arg(*pap, char *); + px->s = va_arg(*pap, char*); px->n1 = strlen(px->s); if (px->prec >= 0 && px->n1 > px->prec) { px->n1 = px->prec; @@ -227,4 +224,4 @@ void _Putfld(_Pft* px, va_list* pap, u8 code, u8* ac) { ac[px->n0++] = code; break; } -}
\ No newline at end of file +} diff --git a/src/libultra_boot_O2/__osDevMgrMain.c b/src/libultra_boot_O2/__osDevMgrMain.c index b3d8cd971..9065b903c 100644 --- a/src/libultra_boot_O2/__osDevMgrMain.c +++ b/src/libultra_boot_O2/__osDevMgrMain.c @@ -1,8 +1,7 @@ #include <global.h> #include <ultra64/hardware.h> -void __osDevMgrMain(void* arg) -{ +void __osDevMgrMain(void* arg) { OSIoMesg* ioMesg; OSMesg sp70; OSMesg sp6C; @@ -16,17 +15,16 @@ void __osDevMgrMain(void* arg) arg0 = (OSMgrArgs*)arg; ioMesg = NULL; - while (true) - { + while (true) { osRecvMesg(arg0->cmdQueue, (OSMesg)&ioMesg, OS_MESG_BLOCK); - if ((ioMesg->piHandle != NULL) && (ioMesg->piHandle->type == DEVICE_TYPE_64DD) && - ((ioMesg->piHandle->transferInfo.cmdType == 0) || (ioMesg->piHandle->transferInfo.cmdType == 1))) - { + if ((ioMesg->piHandle != NULL) && (ioMesg->piHandle->type == DEVICE_TYPE_64DD) && + ((ioMesg->piHandle->transferInfo.cmdType == 0) || (ioMesg->piHandle->transferInfo.cmdType == 1))) { transfer = &ioMesg->piHandle->transferInfo; block = &transfer->block[transfer->blockNum]; transfer->sectorNum = -1; - if (transfer->transferMode != 3) + if (transfer->transferMode != 3) { block->dramAddr = (void*)((u32)block->dramAddr - block->sectorSize); + } phi_s2 = ((transfer->transferMode == 2) && (ioMesg->piHandle->transferInfo.cmdType == 0)) ? 1 : 0; @@ -34,38 +32,36 @@ void __osDevMgrMain(void* arg) __osResetGlobalIntMask(0x00100401); __osEPiRawWriteIo(ioMesg->piHandle, 0x05000510, transfer->bmCtlShadow | 0x80000000); - while (true) - { + while (true) { osRecvMesg(arg0->eventQueue, &sp70, OS_MESG_BLOCK); transfer = &ioMesg->piHandle->transferInfo; block = &transfer->block[transfer->blockNum]; - if (block->errStatus == 0x1D) - { + if (block->errStatus == 0x1D) { __osEPiRawWriteIo(ioMesg->piHandle, 0x05000510, transfer->bmCtlShadow | 0x10000000); __osEPiRawWriteIo(ioMesg->piHandle, 0x05000510, transfer->bmCtlShadow); __osEPiRawReadIo(ioMesg->piHandle, 0x05000508, &sp54); - if (sp54 & 0x02000000) + if (sp54 & 0x02000000) { __osEPiRawWriteIo(ioMesg->piHandle, 0x05000510, transfer->bmCtlShadow | 0x1000000); + } block->errStatus = 4; HW_REG(PI_STATUS_REG, u32) = PI_STATUS_CLEAR_INTR; __osSetGlobalIntMask(0x00100C01); } osSendMesg(ioMesg->hdr.retQueue, ioMesg, OS_MESG_NOBLOCK); - if ((phi_s2 != 1) || (ioMesg->piHandle->transferInfo.block[0].errStatus != 0)) + if ((phi_s2 != 1) || (ioMesg->piHandle->transferInfo.block[0].errStatus != 0)) { break; + } phi_s2 = 0; } osSendMesg(arg0->acccessQueue, 0, OS_MESG_NOBLOCK); - if (ioMesg->piHandle->transferInfo.blockNum == 1) + if (ioMesg->piHandle->transferInfo.blockNum == 1) { osYieldThread(); - } - else - { - switch (ioMesg->hdr.type) - { + } + } else { + switch (ioMesg->hdr.type) { case 11: osRecvMesg(arg0->acccessQueue, &sp6C, OS_MESG_BLOCK); phi_s0 = arg0->piDmaCallback(OS_READ, ioMesg->devAddr, ioMesg->dramAddr, ioMesg->size); @@ -76,11 +72,13 @@ void __osDevMgrMain(void* arg) break; case 15: osRecvMesg(arg0->acccessQueue, &sp6C, OS_MESG_BLOCK); - phi_s0 = arg0->epiDmaCallback(ioMesg->piHandle, OS_READ, ioMesg->devAddr, ioMesg->dramAddr, ioMesg->size); + phi_s0 = arg0->epiDmaCallback(ioMesg->piHandle, OS_READ, ioMesg->devAddr, ioMesg->dramAddr, + ioMesg->size); break; case 16: osRecvMesg(arg0->acccessQueue, &sp6C, OS_MESG_BLOCK); - phi_s0 = arg0->epiDmaCallback(ioMesg->piHandle, OS_WRITE, ioMesg->devAddr, ioMesg->dramAddr, ioMesg->size); + phi_s0 = arg0->epiDmaCallback(ioMesg->piHandle, OS_WRITE, ioMesg->devAddr, ioMesg->dramAddr, + ioMesg->size); break; case 10: osSendMesg(ioMesg->hdr.retQueue, ioMesg, OS_MESG_NOBLOCK); @@ -91,8 +89,7 @@ void __osDevMgrMain(void* arg) break; } - if (phi_s0 == 0) - { + if (phi_s0 == 0) { osRecvMesg(arg0->eventQueue, &sp70, OS_MESG_BLOCK); osSendMesg(ioMesg->hdr.retQueue, ioMesg, OS_MESG_NOBLOCK); osSendMesg(arg0->acccessQueue, NULL, OS_MESG_NOBLOCK); diff --git a/src/libultra_boot_O2/__osEPiRawReadIo.c b/src/libultra_boot_O2/__osEPiRawReadIo.c index d44881015..b1e9b88d0 100644 --- a/src/libultra_boot_O2/__osEPiRawReadIo.c +++ b/src/libultra_boot_O2/__osEPiRawReadIo.c @@ -1,45 +1,49 @@ #include <global.h> #include <ultra64/hardware.h> -s32 __osEPiRawReadIo(OSPiHandle* handle, u32 devAddr, u32* data) -{ +s32 __osEPiRawReadIo(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)) + 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) - { + if (__osCurrentHandle[handle->domain]->type != handle->type) { curHandle = __osCurrentHandle[handle->domain]; - if (handle->domain == 0) - { - if (curHandle->latency != handle->latency) + if (handle->domain == 0) { + if (curHandle->latency != handle->latency) { HW_REG(PI_BSD_DOM1_LAT_REG, u32) = handle->latency; + } - if (curHandle->pageSize != handle->pageSize) + if (curHandle->pageSize != handle->pageSize) { HW_REG(PI_BSD_DOM1_PGS_REG, u32) = handle->pageSize; + } - if (curHandle->relDuration != handle->relDuration) + if (curHandle->relDuration != handle->relDuration) { HW_REG(PI_BSD_DOM1_RLS_REG, u32) = handle->relDuration; + } - if (curHandle->pulse != handle->pulse) + if (curHandle->pulse != handle->pulse) { HW_REG(PI_BSD_DOM1_PWD_REG, u32) = handle->pulse; - } - else - { - if (curHandle->latency != handle->latency) + } + } else { + if (curHandle->latency != handle->latency) { HW_REG(PI_BSD_DOM2_LAT_REG, u32) = handle->latency; + } - if (curHandle->pageSize != handle->pageSize) + if (curHandle->pageSize != handle->pageSize) { HW_REG(PI_BSD_DOM2_PGS_REG, u32) = handle->pageSize; + } - if (curHandle->relDuration != handle->relDuration) + if (curHandle->relDuration != handle->relDuration) { HW_REG(PI_BSD_DOM2_RLS_REG, u32) = handle->relDuration; + } - if (curHandle->pulse != handle->pulse) + if (curHandle->pulse != handle->pulse) { HW_REG(PI_BSD_DOM2_PWD_REG, u32) = handle->pulse; + } } curHandle->type = handle->type; diff --git a/src/libultra_boot_O2/__osEPiRawStartDma.c b/src/libultra_boot_O2/__osEPiRawStartDma.c index dcd5f44d9..cc28a6ca9 100644 --- a/src/libultra_boot_O2/__osEPiRawStartDma.c +++ b/src/libultra_boot_O2/__osEPiRawStartDma.c @@ -1,45 +1,49 @@ #include <global.h> #include <ultra64/hardware.h> -s32 __osEPiRawStartDma(OSPiHandle* handle, s32 direction, u32 cartAddr, void* dramAddr, size_t size) -{ +s32 __osEPiRawStartDma(OSPiHandle* handle, s32 direction, u32 cartAddr, void* dramAddr, size_t size) { s32 status; OSPiHandle* curHandle; - while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY | PI_STATUS_ERROR)) + 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) - { + if (__osCurrentHandle[handle->domain]->type != handle->type) { curHandle = __osCurrentHandle[handle->domain]; - if (handle->domain == 0) - { - if (curHandle->latency != handle->latency) + if (handle->domain == 0) { + if (curHandle->latency != handle->latency) { HW_REG(PI_BSD_DOM1_LAT_REG, u32) = handle->latency; + } - if (curHandle->pageSize != handle->pageSize) + if (curHandle->pageSize != handle->pageSize) { HW_REG(PI_BSD_DOM1_PGS_REG, u32) = handle->pageSize; + } - if (curHandle->relDuration != handle->relDuration) + if (curHandle->relDuration != handle->relDuration) { HW_REG(PI_BSD_DOM1_RLS_REG, u32) = handle->relDuration; + } - if (curHandle->pulse != handle->pulse) + if (curHandle->pulse != handle->pulse) { HW_REG(PI_BSD_DOM1_PWD_REG, u32) = handle->pulse; - } - else - { - if (curHandle->latency != handle->latency) + } + } else { + if (curHandle->latency != handle->latency) { HW_REG(PI_BSD_DOM2_LAT_REG, u32) = handle->latency; + } - if (curHandle->pageSize != handle->pageSize) + if (curHandle->pageSize != handle->pageSize) { HW_REG(PI_BSD_DOM2_PGS_REG, u32) = handle->pageSize; + } - if (curHandle->relDuration != handle->relDuration) + if (curHandle->relDuration != handle->relDuration) { HW_REG(PI_BSD_DOM2_RLS_REG, u32) = handle->relDuration; + } - if (curHandle->pulse != handle->pulse) + if (curHandle->pulse != handle->pulse) { HW_REG(PI_BSD_DOM2_PWD_REG, u32) = handle->pulse; + } } curHandle->type = handle->type; @@ -52,17 +56,16 @@ s32 __osEPiRawStartDma(OSPiHandle* handle, s32 direction, u32 cartAddr, void* dr HW_REG(PI_DRAM_ADDR_REG, void*) = (void*)osVirtualToPhysical(dramAddr); HW_REG(PI_CART_ADDR_REG, void*) = (void*)((handle->baseAddress | cartAddr) & 0x1fffffff); - switch (direction) - { - case OS_READ: - HW_REG(PI_WR_LEN_REG, u32) = size - 1; - break; - case OS_WRITE: - HW_REG(PI_RD_LEN_REG, u32) = size - 1; - break; - default: - return -1; - break; + switch (direction) { + case OS_READ: + HW_REG(PI_WR_LEN_REG, u32) = size - 1; + break; + case OS_WRITE: + HW_REG(PI_RD_LEN_REG, u32) = size - 1; + break; + default: + return -1; + break; } return 0; diff --git a/src/libultra_boot_O2/__osEPiRawWriteIo.c b/src/libultra_boot_O2/__osEPiRawWriteIo.c index 517c7397a..08d817bfa 100644 --- a/src/libultra_boot_O2/__osEPiRawWriteIo.c +++ b/src/libultra_boot_O2/__osEPiRawWriteIo.c @@ -1,45 +1,49 @@ #include <global.h> #include <ultra64/hardware.h> -s32 __osEPiRawWriteIo(OSPiHandle* handle, u32 devAddr, u32 data) -{ +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)) + 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) - { + if (__osCurrentHandle[handle->domain]->type != handle->type) { curHandle = __osCurrentHandle[handle->domain]; - if (handle->domain == 0) - { - if (curHandle->latency != handle->latency) + if (handle->domain == 0) { + if (curHandle->latency != handle->latency) { HW_REG(PI_BSD_DOM1_LAT_REG, u32) = handle->latency; + } - if (curHandle->pageSize != handle->pageSize) + if (curHandle->pageSize != handle->pageSize) { HW_REG(PI_BSD_DOM1_PGS_REG, u32) = handle->pageSize; + } - if (curHandle->relDuration != handle->relDuration) + if (curHandle->relDuration != handle->relDuration) { HW_REG(PI_BSD_DOM1_RLS_REG, u32) = handle->relDuration; + } - if (curHandle->pulse != handle->pulse) + if (curHandle->pulse != handle->pulse) { HW_REG(PI_BSD_DOM1_PWD_REG, u32) = handle->pulse; - } - else - { - if (curHandle->latency != handle->latency) + } + } else { + if (curHandle->latency != handle->latency) { HW_REG(PI_BSD_DOM2_LAT_REG, u32) = handle->latency; + } - if (curHandle->pageSize != handle->pageSize) + if (curHandle->pageSize != handle->pageSize) { HW_REG(PI_BSD_DOM2_PGS_REG, u32) = handle->pageSize; + } - if (curHandle->relDuration != handle->relDuration) + if (curHandle->relDuration != handle->relDuration) { HW_REG(PI_BSD_DOM2_RLS_REG, u32) = handle->relDuration; + } - if (curHandle->pulse != handle->pulse) + if (curHandle->pulse != handle->pulse) { HW_REG(PI_BSD_DOM2_PWD_REG, u32) = handle->pulse; + } } curHandle->type = handle->type; diff --git a/src/libultra_boot_O2/__osPiRawStartDma.c b/src/libultra_boot_O2/__osPiRawStartDma.c index 0957a0ebc..589a63b3b 100644 --- a/src/libultra_boot_O2/__osPiRawStartDma.c +++ b/src/libultra_boot_O2/__osPiRawStartDma.c @@ -1,30 +1,27 @@ #include <global.h> #include <ultra64/hardware.h> -s32 __osPiRawStartDma(s32 dir, u32 cart_addr, void *dram_addr, size_t size) -{ +s32 __osPiRawStartDma(s32 dir, u32 cart_addr, void* dram_addr, size_t size) { register int status; status = HW_REG(PI_STATUS_REG, u32); - while (status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY | PI_STATUS_ERROR)) - { + while (status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY | PI_STATUS_ERROR)) { status = HW_REG(PI_STATUS_REG, u32); } - HW_REG(PI_DRAM_ADDR_REG, void *) = (void *)osVirtualToPhysical(dram_addr); + HW_REG(PI_DRAM_ADDR_REG, void*) = (void*)osVirtualToPhysical(dram_addr); - HW_REG(PI_CART_ADDR_REG, void *) = (void *)((osRomBase | cart_addr) & 0x1fffffff); + HW_REG(PI_CART_ADDR_REG, void*) = (void*)((osRomBase | cart_addr) & 0x1fffffff); - switch (dir) - { - case OS_READ: - HW_REG(PI_WR_LEN_REG, u32) = size - 1; - break; - case OS_WRITE: - HW_REG(PI_RD_LEN_REG, u32) = size - 1; - break; - default: - return -1; - break; + switch (dir) { + case OS_READ: + HW_REG(PI_WR_LEN_REG, u32) = size - 1; + break; + case OS_WRITE: + HW_REG(PI_RD_LEN_REG, u32) = size - 1; + break; + default: + return -1; + break; } return 0; -}
\ No newline at end of file +} diff --git a/src/libultra_boot_O2/__osSiDeviceBusy.c b/src/libultra_boot_O2/__osSiDeviceBusy.c index 983bd071d..8bb777745 100644 --- a/src/libultra_boot_O2/__osSiDeviceBusy.c +++ b/src/libultra_boot_O2/__osSiDeviceBusy.c @@ -1,12 +1,12 @@ #include <global.h> #include <ultra64/hardware.h> -u32 __osSiDeviceBusy() -{ +u32 __osSiDeviceBusy() { register u32 status; status = HW_REG(SI_STATUS_REG, u32); - if (status & (SI_STATUS_DMA_BUSY | SI_STATUS_IO_READ_BUSY)) + if (status & (SI_STATUS_DMA_BUSY | SI_STATUS_IO_READ_BUSY)) { return true; - else + } else { return false; + } } diff --git a/src/libultra_boot_O2/__osSiRawReadIo.c b/src/libultra_boot_O2/__osSiRawReadIo.c index c3bb394f0..fa26c8e2a 100644 --- a/src/libultra_boot_O2/__osSiRawReadIo.c +++ b/src/libultra_boot_O2/__osSiRawReadIo.c @@ -1,10 +1,10 @@ #include <global.h> #include <ultra64/hardware.h> -s32 __osSiRawReadIo(void *a0, u32 *a1) -{ - if (__osSiDeviceBusy()) +s32 __osSiRawReadIo(void* a0, u32* a1) { + if (__osSiDeviceBusy()) { return -1; + } *a1 = HW_REG((u32)a0, u32); return 0; -}
\ No newline at end of file +} diff --git a/src/libultra_boot_O2/__osSiRawWriteIo.c b/src/libultra_boot_O2/__osSiRawWriteIo.c index c7ff8eab7..7658b5a97 100644 --- a/src/libultra_boot_O2/__osSiRawWriteIo.c +++ b/src/libultra_boot_O2/__osSiRawWriteIo.c @@ -1,10 +1,10 @@ #include <global.h> #include <ultra64/hardware.h> -s32 __osSiRawWriteIo(void *a0, u32 a1) -{ - if (__osSiDeviceBusy()) +s32 __osSiRawWriteIo(void* a0, u32 a1) { + if (__osSiDeviceBusy()) { return -1; + } HW_REG((u32)a0, u32) = a1; return 0; -}
\ No newline at end of file +} diff --git a/src/libultra_boot_O2/__osViGetCurrentContext.c b/src/libultra_boot_O2/__osViGetCurrentContext.c index b629c77f7..fea88be8f 100644 --- a/src/libultra_boot_O2/__osViGetCurrentContext.c +++ b/src/libultra_boot_O2/__osViGetCurrentContext.c @@ -1,6 +1,5 @@ #include <global.h> -OSViContext* __osViGetCurrentContext() -{ +OSViContext* __osViGetCurrentContext() { return __osViCurr; } diff --git a/src/libultra_boot_O2/__osViInit.c b/src/libultra_boot_O2/__osViInit.c index a660a1de2..becce34ab 100644 --- a/src/libultra_boot_O2/__osViInit.c +++ b/src/libultra_boot_O2/__osViInit.c @@ -1,12 +1,11 @@ #include <global.h> #include <ultra64/hardware.h> -OSViContext vi[2] = {0}; +OSViContext vi[2] = { 0 }; OSViContext* __osViCurr = &vi[0]; OSViContext* __osViNext = &vi[1]; -void __osViInit() -{ +void __osViInit() { bzero(vi, sizeof(vi)); __osViCurr = &vi[0]; __osViNext = &vi[1]; @@ -15,19 +14,21 @@ void __osViInit() __osViCurr->retraceCount = 1; __osViNext->buffer = (void*)0x80000000; __osViCurr->buffer = (void*)0x80000000; - - if (osTvType == 0) + + if (osTvType == 0) { __osViNext->modep = &osViModePalLan1; - else if (osTvType == 2) + } else if (osTvType == 2) { __osViNext->modep = &osViModeMpalLan1; - else + } else { __osViNext->modep = &osViModeNtscLan1; + } __osViNext->state = 0x20; __osViNext->features = __osViNext->modep->comRegs.ctrl; - while (HW_REG(VI_CURRENT_REG, u32) > 10) + while (HW_REG(VI_CURRENT_REG, u32) > 10) { ; + } HW_REG(VI_CONTROL_REG, u32) = 0; __osViSwapContext(); diff --git a/src/libultra_boot_O2/__osViSwapContext.c b/src/libultra_boot_O2/__osViSwapContext.c index 93f8ede35..4dcc4c870 100644 --- a/src/libultra_boot_O2/__osViSwapContext.c +++ b/src/libultra_boot_O2/__osViSwapContext.c @@ -1,10 +1,9 @@ #include <global.h> #include <ultra64/hardware.h> -void __osViSwapContext() -{ - register OSViMode *s0; - register OSViContext *s1; +void __osViSwapContext() { + register OSViMode* s0; + register OSViContext* s1; u32 origin; u32 hStart; u32 vstart; diff --git a/src/libultra_boot_O2/osCartRomInit.c b/src/libultra_boot_O2/osCartRomInit.c index 5492a61f5..eef5be9fd 100644 --- a/src/libultra_boot_O2/osCartRomInit.c +++ b/src/libultra_boot_O2/osCartRomInit.c @@ -3,8 +3,7 @@ OSPiHandle __CartRomHandle; -OSPiHandle* osCartRomInit() -{ +OSPiHandle* osCartRomInit() { register u32 a; register s32 status; register u32 prevInt; @@ -17,8 +16,7 @@ OSPiHandle* osCartRomInit() __osPiGetAccess(); - if (!D_8000AF10) - { + if (!D_8000AF10) { __osPiRelAccess(); return &__CartRomHandle; } @@ -30,8 +28,9 @@ OSPiHandle* osCartRomInit() __CartRomHandle.speed = 0; bzero(&__CartRomHandle.transferInfo, sizeof(__OSTranxInfo)); - while (status = HW_REG(PI_STATUS_REG, u32), status & PI_STATUS_ERROR) + while (status = HW_REG(PI_STATUS_REG, u32), status & PI_STATUS_ERROR) { ; + } lastLatency = HW_REG(PI_BSD_DOM1_LAT_REG, u32); lastPageSize = HW_REG(PI_BSD_DOM1_PGS_REG, u32); diff --git a/src/libultra_boot_O2/osDriveRomInit.c b/src/libultra_boot_O2/osDriveRomInit.c index 2428161e8..4dd49a629 100644 --- a/src/libultra_boot_O2/osDriveRomInit.c +++ b/src/libultra_boot_O2/osDriveRomInit.c @@ -3,8 +3,7 @@ OSPiHandle __DriveRomHandle; -OSPiHandle* osDriveRomInit() -{ +OSPiHandle* osDriveRomInit() { register s32 status; register u32 a; register s32 prevInt; @@ -12,8 +11,7 @@ OSPiHandle* osDriveRomInit() __osPiGetAccess(); - if (!D_8000AC70) - { + if (!D_8000AC70) { __osPiRelAccess(); return &__DriveRomHandle; } @@ -25,8 +23,9 @@ OSPiHandle* osDriveRomInit() __DriveRomHandle.speed = 0; bzero(&__DriveRomHandle.transferInfo, sizeof(__OSTranxInfo)); - while (status = HW_REG(PI_STATUS_REG, u32), status & PI_STATUS_ERROR) + while (status = HW_REG(PI_STATUS_REG, u32), status & PI_STATUS_ERROR) { ; + } HW_REG(PI_BSD_DOM1_LAT_REG, u32) = 0xff; HW_REG(PI_BSD_DOM1_PGS_REG, u32) = 0; diff --git a/src/libultra_boot_O2/osEPiReadIo.c b/src/libultra_boot_O2/osEPiReadIo.c index 9953c8529..964330c30 100644 --- a/src/libultra_boot_O2/osEPiReadIo.c +++ b/src/libultra_boot_O2/osEPiReadIo.c @@ -1,7 +1,6 @@ #include <global.h> -s32 osEPiReadIo(OSPiHandle* handle, u32 devAddr, u32* data) -{ +s32 osEPiReadIo(OSPiHandle* handle, u32 devAddr, u32* data) { register s32 ret; __osPiGetAccess(); @@ -9,4 +8,4 @@ s32 osEPiReadIo(OSPiHandle* handle, u32 devAddr, u32* data) __osPiRelAccess(); return ret; -}
\ No newline at end of file +} diff --git a/src/libultra_boot_O2/osEPiStartDma.c b/src/libultra_boot_O2/osEPiStartDma.c index a2c2b8d5a..83fc694a3 100644 --- a/src/libultra_boot_O2/osEPiStartDma.c +++ b/src/libultra_boot_O2/osEPiStartDma.c @@ -1,21 +1,23 @@ #include <global.h> -s32 osEPiStartDma(OSPiHandle* handle, OSIoMesg* mb, s32 direction) -{ +s32 osEPiStartDma(OSPiHandle* handle, OSIoMesg* mb, s32 direction) { s32 ret; - if (!__osPiDevMgr.initialized) + if (!__osPiDevMgr.initialized) { return -1; + } mb->piHandle = handle; - if (direction == OS_READ) + if (direction == OS_READ) { mb->hdr.type = 0xf; - else + } else { mb->hdr.type = 0x10; + } - if (mb->hdr.pri == 1) + if (mb->hdr.pri == 1) { ret = osJamMesg(osPiGetCmdQueue(), (OSMesg)mb, 0); - else + } else { ret = osSendMesg(osPiGetCmdQueue(), (OSMesg)mb, 0); + } return ret; -}
\ No newline at end of file +} diff --git a/src/libultra_boot_O2/osEPiWriteIo.c b/src/libultra_boot_O2/osEPiWriteIo.c index ef1cc385f..5d4f61a2f 100644 --- a/src/libultra_boot_O2/osEPiWriteIo.c +++ b/src/libultra_boot_O2/osEPiWriteIo.c @@ -1,7 +1,6 @@ #include <global.h> -s32 osEPiWriteIo(OSPiHandle* handle, u32 devAddr, u32 data) -{ +s32 osEPiWriteIo(OSPiHandle* handle, u32 devAddr, u32 data) { register s32 ret; __osPiGetAccess(); diff --git a/src/libultra_boot_O2/osPiGetCmdQueue.c b/src/libultra_boot_O2/osPiGetCmdQueue.c index 159c42378..1f097a926 100644 --- a/src/libultra_boot_O2/osPiGetCmdQueue.c +++ b/src/libultra_boot_O2/osPiGetCmdQueue.c @@ -1,9 +1,9 @@ #include <global.h> -OSMesgQueue* osPiGetCmdQueue() -{ - if (!__osPiDevMgr.initialized) +OSMesgQueue* osPiGetCmdQueue() { + if (!__osPiDevMgr.initialized) { return NULL; + } return __osPiDevMgr.cmdQueue; } diff --git a/src/libultra_boot_O2/osViBlack.c b/src/libultra_boot_O2/osViBlack.c index 4a122496c..753619b8b 100644 --- a/src/libultra_boot_O2/osViBlack.c +++ b/src/libultra_boot_O2/osViBlack.c @@ -1,8 +1,7 @@ #include <global.h> // TODO: name magic constants -void osViBlack(u8 active) -{ +void osViBlack(u8 active) { register u32 int_disabled = __osDisableInt(); if (active) { __osViNext->state |= 0x20; diff --git a/src/libultra_boot_O2/osViGetNextFramebuffer.c b/src/libultra_boot_O2/osViGetNextFramebuffer.c index 83eaa2705..a8b642603 100644 --- a/src/libultra_boot_O2/osViGetNextFramebuffer.c +++ b/src/libultra_boot_O2/osViGetNextFramebuffer.c @@ -1,9 +1,8 @@ #include <global.h> -void* osViGetNextFramebuffer() -{ +void* osViGetNextFramebuffer() { s32 prevInt = __osDisableInt(); void* buff = __osViNext->buffer; __osRestoreInt(prevInt); return buff; -}
\ No newline at end of file +} diff --git a/src/libultra_boot_O2/osViModeFpalLan1.c b/src/libultra_boot_O2/osViModeFpalLan1.c index c620ad53d..47b36d7ad 100644 --- a/src/libultra_boot_O2/osViModeFpalLan1.c +++ b/src/libultra_boot_O2/osViModeFpalLan1.c @@ -1,33 +1,32 @@ #include <global.h> -OSViMode osViModeFpalLan1 = -{ - 0x2C, //type - { //comRegs - 0x311E, //ctrl - 0x140, //width - 0x4541E3A, //burst - 0x271, //vSync - 0x170C69, //hSync - 0xC6F0C6D, //leap - 0x800300, //hStart - 0x200, //xScale - 0 //vCurrent +OSViMode osViModeFpalLan1 = { + 0x2C, // type + { + // comRegs + 0x311E, // ctrl + 0x140, // width + 0x4541E3A, // burst + 0x271, // vSync + 0x170C69, // hSync + 0xC6F0C6D, // leap + 0x800300, // hStart + 0x200, // xScale + 0 // vCurrent }, - { //fldRegs - { - 0x280, //origin - 0x400, //yScale - 0x2F0269, //vStart - 0x9026B, //vBurst - 2, //vIntr - }, - { - 0x280, //origin - 0x400, //yScale - 0x2F0269, //vStart - 0x9026B, //vBurst - 2 //vIntr - } - } + { // fldRegs + { + 0x280, // origin + 0x400, // yScale + 0x2F0269, // vStart + 0x9026B, // vBurst + 2, // vIntr + }, + { + 0x280, // origin + 0x400, // yScale + 0x2F0269, // vStart + 0x9026B, // vBurst + 2 // vIntr + } }, }; diff --git a/src/libultra_boot_O2/osViModeMpalLan1.c b/src/libultra_boot_O2/osViModeMpalLan1.c index 805cd450b..7557468f8 100644 --- a/src/libultra_boot_O2/osViModeMpalLan1.c +++ b/src/libultra_boot_O2/osViModeMpalLan1.c @@ -1,33 +1,34 @@ #include <global.h> -OSViMode osViModeMpalLan1 = -{ - 0x1E, //type - { //comRegs - 0x311E, //ctrl - 0x140, //width - 0x4651E39, //burst - 0x20D, //vSync - 0x40C11, //hSync - 0xC190C1A, //leap - 0x6C02EC, //hStart - 0x200, //xScale - 0, //vCurrent +OSViMode osViModeMpalLan1 = { + 0x1E, // type + { + // comRegs + 0x311E, // ctrl + 0x140, // width + 0x4651E39, // burst + 0x20D, // vSync + 0x40C11, // hSync + 0xC190C1A, // leap + 0x6C02EC, // hStart + 0x200, // xScale + 0, // vCurrent }, - { //fldRegs - { //[0] - 0x280, //origin - 0x400, //yScale - 0x2501FF, //vStart - 0xE0204, //vBurst - 2, //vIntr - }, - { //[1] - 0x280, //origin - 0x400, //yScale - 0x2501FF, //vStart - 0xE0204, //vBurst - 2, //vIntr - } - } + { // fldRegs + { + // [0] + 0x280, // origin + 0x400, // yScale + 0x2501FF, // vStart + 0xE0204, // vBurst + 2, // vIntr + }, + { + // [1] + 0x280, // origin + 0x400, // yScale + 0x2501FF, // vStart + 0xE0204, // vBurst + 2, // vIntr + } }, }; diff --git a/src/libultra_boot_O2/osViModeNtscLan1.c b/src/libultra_boot_O2/osViModeNtscLan1.c index 99573758e..1026faae8 100644 --- a/src/libultra_boot_O2/osViModeNtscLan1.c +++ b/src/libultra_boot_O2/osViModeNtscLan1.c @@ -1,33 +1,34 @@ #include <global.h> -OSViMode osViModeNtscLan1 = -{ - 2, //type - { //comRegs - 0x311E, //ctrl - 0x140, //width - 0x3E52239, //burst - 0x20D, //vSync - 0xC15, //hSync - 0xC150C15, //leap - 0x6C02EC, //hStart - 0x200, //xScale - 0, //vCurrent +OSViMode osViModeNtscLan1 = { + 2, // type + { + // comRegs + 0x311E, // ctrl + 0x140, // width + 0x3E52239, // burst + 0x20D, // vSync + 0xC15, // hSync + 0xC150C15, // leap + 0x6C02EC, // hStart + 0x200, // xScale + 0, // vCurrent }, - { //fldRegs - { //[0] - 0x280, //origin - 0x400, //yScale - 0x2501FF, //vStart - 0xE0204, //vBurst - 2, //vIntr - }, - { //[1] - 0x280, //origin - 0x400, //yScale - 0x2501FF, //vStart - 0xE0204, //vBurst - 2, //vIntr - } - } + { // fldRegs + { + // [0] + 0x280, // origin + 0x400, // yScale + 0x2501FF, // vStart + 0xE0204, // vBurst + 2, // vIntr + }, + { + // [1] + 0x280, // origin + 0x400, // yScale + 0x2501FF, // vStart + 0xE0204, // vBurst + 2, // vIntr + } }, }; diff --git a/src/libultra_boot_O2/osViSetMode.c b/src/libultra_boot_O2/osViSetMode.c index 5d29da826..6b7a5e21a 100644 --- a/src/libultra_boot_O2/osViSetMode.c +++ b/src/libultra_boot_O2/osViSetMode.c @@ -1,7 +1,6 @@ #include <global.h> -void osViSetMode(OSViMode *mode) -{ +void osViSetMode(OSViMode* mode) { register u32 int_disabled = __osDisableInt(); __osViNext->modep = mode; __osViNext->state = 1; diff --git a/src/libultra_boot_O2/osViSetSpecialFeatures.c b/src/libultra_boot_O2/osViSetSpecialFeatures.c index 06d040a51..ab949ba31 100644 --- a/src/libultra_boot_O2/osViSetSpecialFeatures.c +++ b/src/libultra_boot_O2/osViSetSpecialFeatures.c @@ -1,7 +1,6 @@ #include <global.h> -void osViSetSpecialFeatures(u32 func) -{ +void osViSetSpecialFeatures(u32 func) { register u32 int_disabled = __osDisableInt(); if (func & OS_VI_GAMMA_ON) { __osViNext->features |= OS_VI_GAMMA; diff --git a/src/libultra_boot_O2/osViSetXScale.c b/src/libultra_boot_O2/osViSetXScale.c index 128b64c99..3c3103c46 100644 --- a/src/libultra_boot_O2/osViSetXScale.c +++ b/src/libultra_boot_O2/osViSetXScale.c @@ -1,7 +1,6 @@ #include <global.h> -void osViSetXScale(f32 value) -{ +void osViSetXScale(f32 value) { register u32 nomValue; register u32 saveMask; diff --git a/src/libultra_boot_O2/osViSetYScale.c b/src/libultra_boot_O2/osViSetYScale.c index bf34f28e1..91f12fed2 100644 --- a/src/libultra_boot_O2/osViSetYScale.c +++ b/src/libultra_boot_O2/osViSetYScale.c @@ -1,7 +1,6 @@ #include <global.h> -void osViSetYScale(float scale) -{ +void osViSetYScale(float scale) { register s32 prevInt; prevInt = __osDisableInt(); diff --git a/src/libultra_boot_O2/osViSwapBuffer.c b/src/libultra_boot_O2/osViSwapBuffer.c index eb6b05d31..c671a50f0 100644 --- a/src/libultra_boot_O2/osViSwapBuffer.c +++ b/src/libultra_boot_O2/osViSwapBuffer.c @@ -1,7 +1,6 @@ #include <global.h> -void osViSwapBuffer(void *vaddr) -{ +void osViSwapBuffer(void* vaddr) { u32 int_disabled = __osDisableInt(); __osViNext->buffer = vaddr; __osViNext->state |= 0x10; // TODO: figure out what this flag means diff --git a/src/libultra_boot_O2/pimgr.c b/src/libultra_boot_O2/pimgr.c index c15d7b919..581f66f48 100644 --- a/src/libultra_boot_O2/pimgr.c +++ b/src/libultra_boot_O2/pimgr.c @@ -1,6 +1,6 @@ #include <global.h> -OSMgrArgs __osPiDevMgr = {0}; +OSMgrArgs __osPiDevMgr = { 0 }; OSPiHandle __Dom1SpeedParam; OSPiHandle __Dom2SpeedParam; @@ -11,31 +11,27 @@ OSMesg piEventBuf[2]; OSThread __osThreadSave; OSPiHandle* __osPiTable = NULL; -OSPiHandle* __osCurrentHandle[] = -{ +OSPiHandle* __osCurrentHandle[] = { &__Dom1SpeedParam, &__Dom2SpeedParam, }; - -void osCreatePiManager(OSPri pri, OSMesgQueue *cmdQ, OSMesg *cmdBuf, s32 cmdMsgCnt) -{ +void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgCnt) { u32 int_disabled; OSPri newPri; OSPri currentPri; - if (!__osPiDevMgr.initialized) - { + if (!__osPiDevMgr.initialized) { osCreateMesgQueue(cmdQ, cmdBuf, cmdMsgCnt); osCreateMesgQueue(&piEventQueue, piEventBuf, 1); - if (!__osPiAccessQueueEnabled) + if (!__osPiAccessQueueEnabled) { __osPiCreateAccessQueue(); + } osSetEventMesg(OS_EVENT_PI, &piEventQueue, (OSMesg)0x22222222); newPri = -1; currentPri = osGetThreadPri(NULL); - if (currentPri < pri) - { + if (currentPri < pri) { newPri = currentPri; osSetThreadPri(NULL, pri); } @@ -49,12 +45,13 @@ void osCreatePiManager(OSPri pri, OSMesgQueue *cmdQ, OSMesg *cmdBuf, s32 cmdMsgC __osPiDevMgr.piDmaCallback = __osPiRawStartDma; __osPiDevMgr.epiDmaCallback = __osEPiRawStartDma; - osCreateThread(&piThread, 0, __osDevMgrMain, (void *)&__osPiDevMgr, piStackThread + sizeof(piStackThread), pri); + osCreateThread(&piThread, 0, __osDevMgrMain, (void*)&__osPiDevMgr, piStackThread + sizeof(piStackThread), pri); osStartThread(&piThread); __osRestoreInt(int_disabled); - if (newPri != -1) + if (newPri != -1) { osSetThreadPri(NULL, newPri); + } } } diff --git a/src/libultra_boot_O2/sprintf.c b/src/libultra_boot_O2/sprintf.c index 58510a35c..2ff0b33e0 100644 --- a/src/libultra_boot_O2/sprintf.c +++ b/src/libultra_boot_O2/sprintf.c @@ -1,26 +1,25 @@ #include <global.h> -char* proutSprintf(char* dst, const char *fmt, size_t size) -{ +char* proutSprintf(char* dst, const char* fmt, size_t size) { return (char*)memcpy(dst, fmt, size) + size; } -s32 vsprintf(char* dst, const char* fmt, va_list args) -{ +s32 vsprintf(char* dst, const char* fmt, va_list args) { s32 ret = _Printf(&proutSprintf, dst, fmt, args); - if (ret > -1) + if (ret > -1) { dst[ret] = 0; + } return ret; } -s32 sprintf(char* dst, const char* fmt, ...) -{ +s32 sprintf(char* dst, const char* fmt, ...) { s32 ret; va_list args; va_start(args, fmt); ret = _Printf(&proutSprintf, dst, fmt, args); - if (ret > -1) + if (ret > -1) { dst[ret] = 0; + } return ret; } diff --git a/src/libultra_boot_O2/string.c b/src/libultra_boot_O2/string.c index 771caf1a3..529ba37d8 100644 --- a/src/libultra_boot_O2/string.c +++ b/src/libultra_boot_O2/string.c @@ -1,33 +1,30 @@ #include <global.h> -const u8 *strchr(const u8 *str, s32 ch) -{ +const u8* strchr(const u8* str, s32 ch) { u8 c = ch; - while (*str != c) - { - if (*str == 0) + while (*str != c) { + if (*str == 0) { return NULL; + } str++; } return str; } -size_t strlen(const u8 *str) -{ - const u8 *ptr = str; - while (*ptr) +size_t strlen(const u8* str) { + const u8* ptr = str; + while (*ptr) { ptr++; + } return ptr - str; } -void *memcpy(void *dst, const void *src, size_t size) -{ - u8 *_dst = dst; - const u8 *_src = src; - while (size > 0) - { +void* memcpy(void* dst, const void* src, size_t size) { + u8* _dst = dst; + const u8* _src = src; + while (size > 0) { *_dst++ = *_src++; size--; } return dst; -}
\ No newline at end of file +} diff --git a/src/libultra_boot_O2/vimgr.c b/src/libultra_boot_O2/vimgr.c index de54494f9..d2839078e 100644 --- a/src/libultra_boot_O2/vimgr.c +++ b/src/libultra_boot_O2/vimgr.c @@ -1,7 +1,6 @@ #include <global.h> -typedef struct -{ +typedef struct { u16 unk00; u8 unk02; u32 unk04; @@ -16,18 +15,16 @@ OSMesgQueue viEventQueue; OSMesg viEventBuf[6]; viMesgStruct viRetraceMsg; viMesgStruct viCounterMsg; -OSMgrArgs __osViDevMgr = {0}; +OSMgrArgs __osViDevMgr = { 0 }; u32 __additional_scanline = 0; void viMgrMain(void*); -void osCreateViManager(OSPri pri) -{ +void osCreateViManager(OSPri pri) { u32 int_disabled; OSPri newPri; OSPri currentPri; - if (!__osViDevMgr.initialized) - { + if (!__osViDevMgr.initialized) { __osTimerServicesInit(); __additional_scanline = 0; osCreateMesgQueue(&viEventQueue, viEventBuf, 5); @@ -41,8 +38,7 @@ void osCreateViManager(OSPri pri) osSetEventMesg(OS_EVENT_COUNTER, &viEventQueue, &viCounterMsg); newPri = -1; currentPri = osGetThreadPri(NULL); - if (currentPri < pri) - { + if (currentPri < pri) { newPri = currentPri; osSetThreadPri(NULL, pri); } @@ -56,19 +52,17 @@ void osCreateViManager(OSPri pri) __osViDevMgr.piDmaCallback = NULL; __osViDevMgr.epiDmaCallback = NULL; - osCreateThread(&viThread, 0, &viMgrMain, &__osViDevMgr, viThreadStack+sizeof(viThreadStack), pri); + osCreateThread(&viThread, 0, &viMgrMain, &__osViDevMgr, viThreadStack + sizeof(viThreadStack), pri); __osViInit(); osStartThread(&viThread); __osRestoreInt(int_disabled); - if (newPri != -1) - { + if (newPri != -1) { osSetThreadPri(NULL, newPri); } } } -void viMgrMain(void* vargs) -{ +void viMgrMain(void* vargs) { OSMgrArgs* args; static u16 viRetrace; u32 addTime; @@ -77,49 +71,47 @@ void viMgrMain(void* vargs) temp = 0; mesg = NULL; - viRetrace = __osViGetCurrentContext()->retraceCount; - if (viRetrace == 0) + viRetrace = __osViGetCurrentContext()->retraceCount; + if (viRetrace == 0) { viRetrace = 1; + } args = (OSMgrArgs*)vargs; - while (1) - { + while (1) { osRecvMesg(args->eventQueue, (OSMesg)&mesg, OS_MESG_BLOCK); - switch (mesg->unk00) - { - case 13: - __osViSwapContext(); - viRetrace--; - if (!viRetrace) - { - OSViContext* ctx = __osViGetCurrentContext(); - if (ctx->mq) - osSendMesg(ctx->mq, ctx->msg, OS_MESG_NOBLOCK); - viRetrace = ctx->retraceCount; - } + switch (mesg->unk00) { + case 13: + __osViSwapContext(); + viRetrace--; + if (!viRetrace) { + OSViContext* ctx = __osViGetCurrentContext(); + if (ctx->mq) { + osSendMesg(ctx->mq, ctx->msg, OS_MESG_NOBLOCK); + } + viRetrace = ctx->retraceCount; + } - __osViIntrCount++; + __osViIntrCount++; - // block optimized out since temp is always 0, - // but it changes register allocation and ordering for __osCurrentTime - if (temp != 0) - { - addTime = osGetCount(); - __osCurrentTime = addTime; - temp = 0; - } + // block optimized out since temp is always 0, + // but it changes register allocation and ordering for __osCurrentTime + if (temp != 0) { + addTime = osGetCount(); + __osCurrentTime = addTime; + temp = 0; + } - addTime = __osBaseCounter; - __osBaseCounter = osGetCount(); - addTime = __osBaseCounter - addTime; - __osCurrentTime = __osCurrentTime + addTime; + addTime = __osBaseCounter; + __osBaseCounter = osGetCount(); + addTime = __osBaseCounter - addTime; + __osCurrentTime = __osCurrentTime + addTime; - break; + break; - case 14: - __osTimerInterrupt(); - break; + case 14: + __osTimerInterrupt(); + break; } } } |
