mirror of
https://github.com/zestydevy/dinosaur-planet.git
synced 2024-11-23 05:19:43 +00:00
Some libultra progress (#89)
* Remove D_FINALROM define + clean up splat.yaml * Match osInitialize * Match __createSpeedParam * Match guPerspectiveF * Match __osContRamRead * Match __osContRamWrite * Match __osContAddressCrc and __osContDataCrc * Match osEPiRawStartDma * Match osEPiRawReadIo and osEPiRawWriteIo * Match osEPiReadIo and osEPiWriteIo * Update EPI_SYNC macro * Match motor.c * Match __osPfsSelectBank * Match pimgr.c * Match osInitRdb and __osRdbSend * Match osWriteHost and osReadHost
This commit is contained in:
parent
2388f299bb
commit
7785901486
@ -18,9 +18,9 @@
|
|||||||
* File: rcp.h
|
* File: rcp.h
|
||||||
*
|
*
|
||||||
* This file contains register and bit definitions for RCP memory map.
|
* This file contains register and bit definitions for RCP memory map.
|
||||||
* $Revision: 1.20 $
|
* $Revision: 1.22 $
|
||||||
* $Date: 1997/07/23 08:35:21 $
|
* $Date: 1999/05/20 03:01:49 $
|
||||||
* $Source: /disk6/Master/cvsmdev2/PR/include/rcp.h,v $
|
* $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/rcp.h,v $
|
||||||
*
|
*
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
@ -161,6 +161,9 @@ The Indy development board use cartridge domain 1:
|
|||||||
#define DEVICE_TYPE_BULK 1 /* ROM bulk */
|
#define DEVICE_TYPE_BULK 1 /* ROM bulk */
|
||||||
#define DEVICE_TYPE_64DD 2 /* 64 Disk Drive */
|
#define DEVICE_TYPE_64DD 2 /* 64 Disk Drive */
|
||||||
#define DEVICE_TYPE_SRAM 3 /* SRAM */
|
#define DEVICE_TYPE_SRAM 3 /* SRAM */
|
||||||
|
/* 4-6 are reserved */
|
||||||
|
#define DEVICE_TYPE_INIT 7 /* initial value */
|
||||||
|
/* 8-14 are reserved */
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* SP Memory
|
* SP Memory
|
||||||
|
@ -8,6 +8,24 @@
|
|||||||
#define ARRLEN(x) ((s32)(sizeof(x) / sizeof(x[0])))
|
#define ARRLEN(x) ((s32)(sizeof(x) / sizeof(x[0])))
|
||||||
#define CHNL_ERR(format) ((format.rxsize & CHNL_ERR_MASK) >> 4)
|
#define CHNL_ERR(format) ((format.rxsize & CHNL_ERR_MASK) >> 4)
|
||||||
|
|
||||||
|
#define CONT_REQUEST 0
|
||||||
|
#define CONT_READ 1
|
||||||
|
#define CONT_RAM_READ 2
|
||||||
|
#define CONT_RAM_WRITE 3
|
||||||
|
#define CONT_EEPROM_READ 4
|
||||||
|
#define CONT_EEPROM_WRITE 5
|
||||||
|
#define CONT_SETCH 254
|
||||||
|
#define CONT_RESET 255
|
||||||
|
#define CONT_ETC CONT_SETCH
|
||||||
|
|
||||||
|
#define CON_ERR_MASK 0xc0
|
||||||
|
|
||||||
|
#ifndef _HW_VERSION_1
|
||||||
|
#define CONT_FORMAT 1
|
||||||
|
#define CHANNEL_RESET 0xfd
|
||||||
|
#define FORMAT_END 0xfe
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
/* 0x0 */ u32 ramarray[15];
|
/* 0x0 */ u32 ramarray[15];
|
||||||
@ -53,7 +71,8 @@ typedef struct
|
|||||||
/* 0x1 */ u8 txsize;
|
/* 0x1 */ u8 txsize;
|
||||||
/* 0x2 */ u8 rxsize;
|
/* 0x2 */ u8 rxsize;
|
||||||
/* 0x3 */ u8 cmd;
|
/* 0x3 */ u8 cmd;
|
||||||
/* 0x4 */ u16 address;
|
/* 0x4 */ u8 address_hi;
|
||||||
|
/* 0x5 */ u8 address_lo;
|
||||||
/* 0x6 */ u8 data[BLOCKSIZE];
|
/* 0x6 */ u8 data[BLOCKSIZE];
|
||||||
/* 0x26 */ u8 datacrc;
|
/* 0x26 */ u8 datacrc;
|
||||||
} __OSContRamReadFormat;
|
} __OSContRamReadFormat;
|
||||||
@ -155,7 +174,7 @@ s32 __osCheckPackId(OSPfs *pfs, __OSPackId *temp);
|
|||||||
s32 __osGetId(OSPfs *pfs);
|
s32 __osGetId(OSPfs *pfs);
|
||||||
s32 __osCheckId(OSPfs *pfs);
|
s32 __osCheckId(OSPfs *pfs);
|
||||||
s32 __osPfsRWInode(OSPfs *pfs, __OSInode *inode, u8 flag, u8 bank);
|
s32 __osPfsRWInode(OSPfs *pfs, __OSInode *inode, u8 flag, u8 bank);
|
||||||
s32 __osPfsSelectBank(OSPfs *pfs);
|
s32 __osPfsSelectBank(OSPfs *pfs, u8 bank);
|
||||||
s32 __osPfsDeclearPage(OSPfs *pfs, __OSInode *inode, int file_size_in_pages, int *first_page, u8 bank, int *decleared, int *last_page);
|
s32 __osPfsDeclearPage(OSPfs *pfs, __OSInode *inode, int file_size_in_pages, int *first_page, u8 bank, int *decleared, int *last_page);
|
||||||
s32 __osPfsReleasePages(OSPfs *pfs, __OSInode *inode, u8 start_page, u16 *sum, u8 bank, __OSInodeUnit *last_page, int flag);
|
s32 __osPfsReleasePages(OSPfs *pfs, __OSInode *inode, u8 start_page, u16 *sum, u8 bank, __OSInodeUnit *last_page, int flag);
|
||||||
s32 __osBlockSum(OSPfs *pfs, u8 page_no, u16 *sum, u8 bank);
|
s32 __osBlockSum(OSPfs *pfs, u8 page_no, u16 *sum, u8 bank);
|
||||||
|
@ -95,8 +95,8 @@
|
|||||||
|
|
||||||
extern OSDevMgr __osPiDevMgr;
|
extern OSDevMgr __osPiDevMgr;
|
||||||
extern OSPiHandle *__osCurrentHandle[2];
|
extern OSPiHandle *__osCurrentHandle[2];
|
||||||
extern OSPiHandle CartRomHandle;
|
extern OSPiHandle __CartRomHandle;
|
||||||
extern OSPiHandle LeoDiskHandle;
|
extern OSPiHandle __LeoDiskHandle;
|
||||||
extern OSMesgQueue __osPiAccessQueue;
|
extern OSMesgQueue __osPiAccessQueue;
|
||||||
extern u32 __osPiAccessQueueEnabled;
|
extern u32 __osPiAccessQueueEnabled;
|
||||||
|
|
||||||
@ -118,29 +118,34 @@ OSMesgQueue *osPiGetCmdQueue(void);
|
|||||||
if (cHandle->var != pihandle->var) \
|
if (cHandle->var != pihandle->var) \
|
||||||
IO_WRITE(reg, pihandle->var);
|
IO_WRITE(reg, pihandle->var);
|
||||||
|
|
||||||
#define EPI_SYNC(pihandle, stat, domain) \
|
#define EPI_SYNC(pihandle, stat, domain) \
|
||||||
\
|
\
|
||||||
WAIT_ON_IOBUSY(stat) \
|
WAIT_ON_IOBUSY(stat) \
|
||||||
\
|
\
|
||||||
domain = pihandle->domain; \
|
domain = pihandle->domain; \
|
||||||
if (__osCurrentHandle[domain] != pihandle) \
|
if (__osCurrentHandle[domain]->type != pihandle->type) \
|
||||||
{ \
|
{ \
|
||||||
OSPiHandle *cHandle = __osCurrentHandle[domain]; \
|
OSPiHandle *cHandle = __osCurrentHandle[domain]; \
|
||||||
if (domain == PI_DOMAIN1) \
|
if (domain == PI_DOMAIN1) \
|
||||||
{ \
|
{ \
|
||||||
UPDATE_REG(PI_BSD_DOM1_LAT_REG, latency); \
|
UPDATE_REG(PI_BSD_DOM1_LAT_REG, latency) \
|
||||||
UPDATE_REG(PI_BSD_DOM1_PGS_REG, pageSize); \
|
UPDATE_REG(PI_BSD_DOM1_PGS_REG, pageSize) \
|
||||||
UPDATE_REG(PI_BSD_DOM1_RLS_REG, relDuration); \
|
UPDATE_REG(PI_BSD_DOM1_RLS_REG, relDuration) \
|
||||||
UPDATE_REG(PI_BSD_DOM1_PWD_REG, pulse); \
|
UPDATE_REG(PI_BSD_DOM1_PWD_REG, pulse) \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
{ \
|
{ \
|
||||||
UPDATE_REG(PI_BSD_DOM2_LAT_REG, latency); \
|
UPDATE_REG(PI_BSD_DOM2_LAT_REG, latency) \
|
||||||
UPDATE_REG(PI_BSD_DOM2_PGS_REG, pageSize); \
|
UPDATE_REG(PI_BSD_DOM2_PGS_REG, pageSize) \
|
||||||
UPDATE_REG(PI_BSD_DOM2_RLS_REG, relDuration); \
|
UPDATE_REG(PI_BSD_DOM2_RLS_REG, relDuration) \
|
||||||
UPDATE_REG(PI_BSD_DOM2_PWD_REG, pulse); \
|
UPDATE_REG(PI_BSD_DOM2_PWD_REG, pulse) \
|
||||||
} \
|
} \
|
||||||
__osCurrentHandle[domain] = pihandle; \
|
\
|
||||||
|
cHandle->type = pihandle->type; \
|
||||||
|
cHandle->latency = pihandle->latency; \
|
||||||
|
cHandle->pageSize = pihandle->pageSize; \
|
||||||
|
cHandle->relDuration = pihandle->relDuration; \
|
||||||
|
cHandle->pulse = pihandle->pulse; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // _LIBULTRA_IO_PIINT_H
|
#endif // _LIBULTRA_IO_PIINT_H
|
||||||
|
18
include/libultra/os/rdbint.h
Normal file
18
include/libultra/os/rdbint.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/**
|
||||||
|
* Internal libultra remote debug (RDB) code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _LIBULTRA_OS_RDBINT_H
|
||||||
|
#define _LIBULTRA_OS_RDBINT_H
|
||||||
|
|
||||||
|
#include <PR/ultratypes.h>
|
||||||
|
#include <PR/rdb.h>
|
||||||
|
|
||||||
|
extern rdbPacket *__osRdb_IP6_Data;
|
||||||
|
extern u32 __osRdb_IP6_Size;
|
||||||
|
extern u32 __osRdb_IP6_Ct;
|
||||||
|
extern u32 __osRdb_IP6_CurWrite;
|
||||||
|
extern u32 __osRdb_IP6_CurSend;
|
||||||
|
extern u32 __osRdb_IP6_Empty;
|
||||||
|
|
||||||
|
#endif //_LIBULTRA_OS_RDBINT_H
|
75
splat.yaml
75
splat.yaml
@ -130,7 +130,7 @@ segments:
|
|||||||
- [0x7CED0, c, segment_7CED0]
|
- [0x7CED0, c, segment_7CED0]
|
||||||
- [0x7CEF0, c, segment_7CEF0]
|
- [0x7CEF0, c, segment_7CEF0]
|
||||||
- [0x7D100, asm, libc/bcopy]
|
- [0x7D100, asm, libc/bcopy]
|
||||||
- [0x7D410, c, libultra/os/initialize]
|
- [0x7D410, c, libultra/os/O1/initialize]
|
||||||
- [0x7D940, c, libultra/os/O1/startthread]
|
- [0x7D940, c, libultra/os/O1/startthread]
|
||||||
- [0x7DA90, c, libultra/os/O1/setthreadpri]
|
- [0x7DA90, c, libultra/os/O1/setthreadpri]
|
||||||
- [0x7DB70, bin] # bunch of nops
|
- [0x7DB70, bin] # bunch of nops
|
||||||
@ -154,8 +154,8 @@ segments:
|
|||||||
- [0x7EBB0, asm, libultra/os/writebackdcacheall]
|
- [0x7EBB0, asm, libultra/os/writebackdcacheall]
|
||||||
- [0x7EBE0, c, libultra/io/O1/pidma]
|
- [0x7EBE0, c, libultra/io/O1/pidma]
|
||||||
- [0x7ECF0, c, libultra/os/O1/settime]
|
- [0x7ECF0, c, libultra/os/O1/settime]
|
||||||
- [0x7ED20, c, libultra/io/motor]
|
- [0x7ED20, c, libultra/io/g0/motor]
|
||||||
- [0x7F0F0, c, libultra/io/pimgr]
|
- [0x7F0F0, c, libultra/io/g0/pimgr]
|
||||||
- [0x7F390, c, libultra/io/O1/viblack]
|
- [0x7F390, c, libultra/io/O1/viblack]
|
||||||
- [0x7F400, c, libultra/io/O1/viswapbuf]
|
- [0x7F400, c, libultra/io/O1/viswapbuf]
|
||||||
- [0x7F450, c, libultra/os/O1/getactivequeue]
|
- [0x7F450, c, libultra/os/O1/getactivequeue]
|
||||||
@ -185,13 +185,13 @@ segments:
|
|||||||
- [0x80C50, c, libultra/os/O1/thread]
|
- [0x80C50, c, libultra/os/O1/thread]
|
||||||
- [0x80C90, asm, libultra/os/exceptasm]
|
- [0x80C90, asm, libultra/os/exceptasm]
|
||||||
- [0x81A00, c, libultra/io/O1/epilinkhandle]
|
- [0x81A00, c, libultra/io/O1/epilinkhandle]
|
||||||
- [0x81A50, c, libultra/io/epiwrite]
|
- [0x81A50, c, libultra/io/g0/epiwrite]
|
||||||
- [0x81AA0, c, libultra/io/epiread]
|
- [0x81AA0, c, libultra/io/g0/epiread]
|
||||||
- [0x81AF0, asm, libultra/os/writebackdcache]
|
- [0x81AF0, asm, libultra/os/writebackdcache]
|
||||||
- [0x81B70, c, libultra/io/O1/epidma]
|
- [0x81B70, c, libultra/io/O1/epidma]
|
||||||
- [0x81C50, c, libultra/libc/g0/string]
|
- [0x81C50, c, libultra/libc/g0/string]
|
||||||
- [0x81CF0, c, libultra/os/writehost]
|
- [0x81CF0, c, libultra/os/O1/writehost]
|
||||||
- [0x81EA0, c, libultra/os/readhost]
|
- [0x81EA0, c, libultra/os/O1/readhost]
|
||||||
- [0x81F70, c, libultra/libc/syncprintf]
|
- [0x81F70, c, libultra/libc/syncprintf]
|
||||||
- [0x82240, asm, libultra/os/setsr]
|
- [0x82240, asm, libultra/os/setsr]
|
||||||
- [0x82250, asm, libultra/os/getsr]
|
- [0x82250, asm, libultra/os/getsr]
|
||||||
@ -206,14 +206,14 @@ segments:
|
|||||||
- [0x82570, c, libultra/io/O1/ai]
|
- [0x82570, c, libultra/io/O1/ai]
|
||||||
- [0x825A0, c, libultra/os/O1/jammesg]
|
- [0x825A0, c, libultra/os/O1/jammesg]
|
||||||
- [0x826F0, c, libultra/io/O1/pigetcmdq]
|
- [0x826F0, c, libultra/io/O1/pigetcmdq]
|
||||||
- [0x82720, c, libultra/io/crc]
|
- [0x82720, c, libultra/io/g0/crc]
|
||||||
- [0x82890, c, libultra/io/pfsselectbank]
|
- [0x82890, c, libultra/io/g0/pfsselectbank]
|
||||||
- [0x82910, c, libultra/io/contramread]
|
- [0x82910, c, libultra/io/g0/contramread]
|
||||||
- [0x82B40, c, libultra/io/O1/piacs]
|
- [0x82B40, c, libultra/io/O1/piacs]
|
||||||
- [0x82C00, c, libultra/io/g0/pirawdma]
|
- [0x82C00, c, libultra/io/g0/pirawdma]
|
||||||
- [0x82CD0, c, libultra/io/epirawdma]
|
- [0x82CD0, c, libultra/io/g0/epirawdma]
|
||||||
- [0x82EB0, c, libultra/io/g0/devmgr]
|
- [0x82EB0, c, libultra/io/g0/devmgr]
|
||||||
- [0x832C0, c, libultra/os/rdbsend]
|
- [0x832C0, c, libultra/os/O1/rdbsend]
|
||||||
- [0x83580, c, libultra/io/O1/spsetpc]
|
- [0x83580, c, libultra/io/O1/spsetpc]
|
||||||
- [0x835C0, c, libultra/io/g0/sprawdma]
|
- [0x835C0, c, libultra/io/g0/sprawdma]
|
||||||
- [0x83650, c, libultra/io/O1/sp]
|
- [0x83650, c, libultra/io/O1/sp]
|
||||||
@ -222,13 +222,13 @@ segments:
|
|||||||
- [0x836C0, asm, libultra/os/setcompare]
|
- [0x836C0, asm, libultra/os/setcompare]
|
||||||
- [0x836D0, c, segment_836D0]
|
- [0x836D0, c, segment_836D0]
|
||||||
- [0x839E0, c, segment_839E0]
|
- [0x839E0, c, segment_839E0]
|
||||||
- [0x83BE0, c, libultra/os/initrdb]
|
- [0x83BE0, c, libultra/os/O1/initrdb]
|
||||||
- [0x83C70, c, libultra/os/O1/destroythread]
|
- [0x83C70, c, libultra/os/O1/destroythread]
|
||||||
- [0x83D80, c, libultra/io/epirawwrite]
|
- [0x83D80, c, libultra/io/g0/epirawwrite]
|
||||||
- [0x83EE0, c, libultra/io/epirawread]
|
- [0x83EE0, c, libultra/io/g0/epirawread]
|
||||||
- [0x84040, c, libultra/libc/xprintf]
|
- [0x84040, c, libultra/libc/xprintf]
|
||||||
- [0x84D00, c, libultra/io/O1/si]
|
- [0x84D00, c, libultra/io/O1/si]
|
||||||
- [0x84D30, c, libultra/io/contramwrite]
|
- [0x84D30, c, libultra/io/g0/contramwrite]
|
||||||
- [0x84F80, c, libultra/io/O1/pfsisplug]
|
- [0x84F80, c, libultra/io/O1/pfsisplug]
|
||||||
- [0x852C0, c, libultra/io/g0/pfsgetstatus]
|
- [0x852C0, c, libultra/io/g0/pfsgetstatus]
|
||||||
- [0x854F0, c, libultra/os/O1/resetglobalintmask]
|
- [0x854F0, c, libultra/os/O1/resetglobalintmask]
|
||||||
@ -248,61 +248,50 @@ segments:
|
|||||||
- [0x8A210, c, libultra/io/g0/sprawwrite]
|
- [0x8A210, c, libultra/io/g0/sprawwrite]
|
||||||
- [0x8A260, c, libultra/io/g0/sprawread]
|
- [0x8A260, c, libultra/io/g0/sprawread]
|
||||||
- [0x8A2B0, c, segment_8A2B0]
|
- [0x8A2B0, c, segment_8A2B0]
|
||||||
# data/rodata for this section
|
|
||||||
|
# data
|
||||||
- [0x8A350, bin]
|
- [0x8A350, bin]
|
||||||
|
|
||||||
- [0x92370, .data, crash]
|
- [0x92370, .data, crash]
|
||||||
|
|
||||||
- [0x92380, bin]
|
- [0x92380, bin]
|
||||||
|
|
||||||
- [0x93CB8, .data, libultra/io/vimgr]
|
- [0x93CB8, .data, libultra/io/vimgr]
|
||||||
|
|
||||||
- [0x93CD0, bin]
|
- [0x93CD0, bin]
|
||||||
|
- [0x97840, .data, libultra/os/O1/initialize]
|
||||||
|
- [0x97858, bin]
|
||||||
- [0x97870, .data, libultra/io/O1/controller]
|
- [0x97870, .data, libultra/io/O1/controller]
|
||||||
|
|
||||||
- [0x97878, bin]
|
- [0x97878, bin]
|
||||||
|
|
||||||
- [0x97880, .data, libultra/io/O1/siacs]
|
- [0x97880, .data, libultra/io/O1/siacs]
|
||||||
|
|
||||||
- [0x97888, bin]
|
- [0x97888, bin]
|
||||||
|
|
||||||
- [0x97890, .data, libultra/io/O1/aisetnextbuf]
|
- [0x97890, .data, libultra/io/O1/aisetnextbuf]
|
||||||
|
|
||||||
- [0x97898, bin]
|
- [0x97898, bin]
|
||||||
|
- [0x978A0, .data, libultra/io/g0/pimgr]
|
||||||
|
- [0x978C8, bin]
|
||||||
- [0x98A50, .data, libultra/os/O1/timerintr]
|
- [0x98A50, .data, libultra/os/O1/timerintr]
|
||||||
|
|
||||||
- [0x98A58, bin]
|
- [0x98A58, bin]
|
||||||
|
|
||||||
- [0x98A60, .data, libultra/io/O1/vi]
|
- [0x98A60, .data, libultra/io/O1/vi]
|
||||||
|
|
||||||
- [0x98AC8, bin]
|
- [0x98AC8, bin]
|
||||||
|
|
||||||
- [0x98AD0, .data, libultra/os/O1/thread]
|
- [0x98AD0, .data, libultra/os/O1/thread]
|
||||||
|
|
||||||
- [0x98AE8, bin]
|
- [0x98AE8, bin]
|
||||||
|
- [0x98B38, .data, libultra/os/O1/writehost]
|
||||||
|
- [0x98B40, .data, libultra/os/O1/readhost]
|
||||||
|
- [0x98B48, bin]
|
||||||
|
- [0x98B60, .data, libultra/io/g0/contramread]
|
||||||
|
- [0x98B68, bin]
|
||||||
- [0x98B70, .data, libultra/io/O1/piacs]
|
- [0x98B70, .data, libultra/io/O1/piacs]
|
||||||
|
|
||||||
- [0x98B78, bin]
|
- [0x98B78, bin]
|
||||||
|
- [0x98B80, .data, libultra/os/O1/rdbsend]
|
||||||
|
- [0x98B88, bin]
|
||||||
|
|
||||||
|
# rodata
|
||||||
- [0x99CA0, .rodata, queue]
|
- [0x99CA0, .rodata, queue]
|
||||||
|
|
||||||
- [0x99D10, .rodata, main]
|
- [0x99D10, .rodata, main]
|
||||||
|
|
||||||
- [0x99DB0, bin]
|
- [0x99DB0, bin]
|
||||||
|
|
||||||
- [0x9AF48, .rodata, scheduler]
|
- [0x9AF48, .rodata, scheduler]
|
||||||
|
|
||||||
- [0x9AF68, bin]
|
- [0x9AF68, bin]
|
||||||
|
|
||||||
- [0x9B8C0, .rodata, video]
|
- [0x9B8C0, .rodata, video]
|
||||||
|
|
||||||
- [0x9B8D8, bin]
|
- [0x9B8D8, bin]
|
||||||
|
- [0x9B980, .rodata, libultra/gu/perspective]
|
||||||
|
- [0x9B988, bin]
|
||||||
- [0xA3450, .rodata, libultra/io/g0/devmgr]
|
- [0xA3450, .rodata, libultra/io/g0/devmgr]
|
||||||
|
|
||||||
- [0xA3470, bin]
|
- [0xA3470, bin]
|
||||||
|
|
||||||
- [0xA4550, bin, ucode]
|
- [0xA4550, bin, ucode]
|
||||||
|
@ -1,7 +1,42 @@
|
|||||||
#include <PR/ultratypes.h>
|
#include <PR/ultratypes.h>
|
||||||
#include "libultra/gu/guint.h"
|
#include "libultra/gu/guint.h"
|
||||||
|
|
||||||
#pragma GLOBAL_ASM("asm/nonmatchings/libultra/gu/perspective/guPerspectiveF.s")
|
f32 fcos16_precise(s16 theta);
|
||||||
|
f32 fsin16_precise(s16 theta);
|
||||||
|
|
||||||
|
void guPerspectiveF(float mf[4][4], u16 *perspNorm, float fovy, float aspect, float near, float far, float scale)
|
||||||
|
{
|
||||||
|
float cot;
|
||||||
|
int i, j;
|
||||||
|
int unused;
|
||||||
|
|
||||||
|
guMtxIdentF(mf);
|
||||||
|
|
||||||
|
//fovy *= 3.1415926f / 180.0f;
|
||||||
|
//cot = fcos16_precise (fovy/2) / fsin16_precise (fovy/2);
|
||||||
|
cot = fcos16_precise (fovy*91.022003173828125f) / fsin16_precise (fovy*91.022003173828125f);
|
||||||
|
|
||||||
|
mf[0][0] = cot / aspect;
|
||||||
|
mf[1][1] = cot;
|
||||||
|
mf[2][2] = (near + far) / (near - far);
|
||||||
|
mf[2][3] = -1;
|
||||||
|
mf[3][2] = (2.0f * near * far) / (near - far);
|
||||||
|
mf[3][3] = 0;
|
||||||
|
|
||||||
|
for (i=0; i<4; i++)
|
||||||
|
for (j=0; j<4; j++)
|
||||||
|
mf[i][j] *= scale;
|
||||||
|
|
||||||
|
if (perspNorm != (u16 *) NULL) {
|
||||||
|
if (near+far<=2.0f) {
|
||||||
|
*perspNorm = (u16) 0xFFFF;
|
||||||
|
} else {
|
||||||
|
*perspNorm = (u16) ((2.0f*65536.0f)/(near+far));
|
||||||
|
if (*perspNorm<=0)
|
||||||
|
*perspNorm = (u16) 0x0001;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void guPerspective(Mtx *m, u16 *perspNorm, float fovy, float aspect, float near, float far, float scale)
|
void guPerspective(Mtx *m, u16 *perspNorm, float fovy, float aspect, float near, float far, float scale)
|
||||||
{
|
{
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
#include "common.h"
|
|
||||||
|
|
||||||
#pragma GLOBAL_ASM("asm/nonmatchings/libultra/io/contramread/__osContRamRead.s")
|
|
@ -1,3 +0,0 @@
|
|||||||
#include "common.h"
|
|
||||||
|
|
||||||
#pragma GLOBAL_ASM("asm/nonmatchings/libultra/io/contramwrite/__osContRamWrite.s")
|
|
@ -1,5 +0,0 @@
|
|||||||
#include "common.h"
|
|
||||||
|
|
||||||
#pragma GLOBAL_ASM("asm/nonmatchings/libultra/io/crc/__osContAddressCrc.s")
|
|
||||||
|
|
||||||
#pragma GLOBAL_ASM("asm/nonmatchings/libultra/io/crc/__osContDataCrc.s")
|
|
@ -1,3 +0,0 @@
|
|||||||
#include "common.h"
|
|
||||||
|
|
||||||
#pragma GLOBAL_ASM("asm/nonmatchings/libultra/io/epirawdma/osEPiRawStartDma.s")
|
|
@ -1,3 +0,0 @@
|
|||||||
#include "common.h"
|
|
||||||
|
|
||||||
#pragma GLOBAL_ASM("asm/nonmatchings/libultra/io/epirawread/osEPiRawReadIo.s")
|
|
@ -1,3 +0,0 @@
|
|||||||
#include "common.h"
|
|
||||||
|
|
||||||
#pragma GLOBAL_ASM("asm/nonmatchings/libultra/io/epirawwrite/osEPiRawWriteIo.s")
|
|
@ -1,3 +0,0 @@
|
|||||||
#include "common.h"
|
|
||||||
|
|
||||||
#pragma GLOBAL_ASM("asm/nonmatchings/libultra/io/epiread/osEPiReadIo.s")
|
|
@ -1,3 +0,0 @@
|
|||||||
#include "common.h"
|
|
||||||
|
|
||||||
#pragma GLOBAL_ASM("asm/nonmatchings/libultra/io/epiwrite/osEPiWriteIo.s")
|
|
85
src/libultra/io/g0/contramread.c
Normal file
85
src/libultra/io/g0/contramread.c
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
#include <PR/os_internal.h>
|
||||||
|
#include <PR/rcp.h>
|
||||||
|
#include <libultra/io/controller.h>
|
||||||
|
#include <libultra/io/siint.h>
|
||||||
|
|
||||||
|
int __osPfsLastChannel = -1;
|
||||||
|
|
||||||
|
s32 __osContRamRead(OSMesgQueue *mq, int channel, u16 address, u8 *buffer) {
|
||||||
|
s32 ret;
|
||||||
|
int i;
|
||||||
|
__OSContRamReadFormat *pifPtr;
|
||||||
|
s32 retry;
|
||||||
|
|
||||||
|
// make 3 attempts at a read
|
||||||
|
retry = 2;
|
||||||
|
|
||||||
|
// acquire lock for SI access
|
||||||
|
__osSiGetAccess();
|
||||||
|
|
||||||
|
do {
|
||||||
|
// get pointer into PIF ram
|
||||||
|
pifPtr = (__OSContRamReadFormat *)&__osPfsPifRam;
|
||||||
|
|
||||||
|
// skip format update if the previous command was a read on the same channel
|
||||||
|
if ((__osContLastCmd != CONT_RAM_READ) || (channel != __osPfsLastChannel)) {
|
||||||
|
__osContLastCmd = CONT_RAM_READ;
|
||||||
|
__osPfsLastChannel = channel;
|
||||||
|
|
||||||
|
// ???
|
||||||
|
for (i = 0; i < channel; i++) (*((u8*)pifPtr) = 0, pifPtr = (__OSContRamReadFormat*)((u8*)pifPtr + 1));
|
||||||
|
|
||||||
|
// set up read format
|
||||||
|
__osPfsPifRam.pifstatus = CONT_FORMAT;
|
||||||
|
|
||||||
|
pifPtr->dummy = 0xFF;
|
||||||
|
pifPtr->txsize = 3;
|
||||||
|
pifPtr->rxsize = 0x21;
|
||||||
|
pifPtr->cmd = CONT_RAM_READ;
|
||||||
|
pifPtr->datacrc = 0xFF;
|
||||||
|
|
||||||
|
((u8*)pifPtr)[sizeof(__OSContRamReadFormat)] = FORMAT_END;
|
||||||
|
} else {
|
||||||
|
// ???
|
||||||
|
pifPtr = (__OSContRamReadFormat *)(&((u8 *)&__osPfsPifRam)[channel]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ???
|
||||||
|
pifPtr->address_hi = (u8)(address >> 3);
|
||||||
|
pifPtr->address_lo = (u8)(__osContAddressCrc(address) | (address << 5));
|
||||||
|
|
||||||
|
// DMA PIF data
|
||||||
|
__osSiRawStartDma(OS_WRITE, &__osPfsPifRam);
|
||||||
|
osRecvMesg(mq, (OSMesg *)NULL, OS_MESG_BLOCK);
|
||||||
|
|
||||||
|
__osSiRawStartDma(OS_READ, &__osPfsPifRam);
|
||||||
|
osRecvMesg(mq, (OSMesg *)NULL, OS_MESG_BLOCK);
|
||||||
|
|
||||||
|
// check for error
|
||||||
|
ret = (s32)(pifPtr->rxsize & CON_ERR_MASK) >> 4;
|
||||||
|
|
||||||
|
if (ret == 0) {
|
||||||
|
// validate CRC
|
||||||
|
if (pifPtr->datacrc != __osContDataCrc(pifPtr->data)) {
|
||||||
|
// CRC failed, retry if status is 0
|
||||||
|
ret = __osPfsGetStatus(mq, channel);
|
||||||
|
if (ret != 0) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
ret = PFS_ERR_CONTRFAIL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// success, copy data to given buffer
|
||||||
|
bcopy(pifPtr->data, buffer, BLOCKSIZE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// failed
|
||||||
|
ret = PFS_ERR_NOPACK;
|
||||||
|
}
|
||||||
|
} while (ret == PFS_ERR_CONTRFAIL && retry-- >= 0);
|
||||||
|
|
||||||
|
// release SI access lock
|
||||||
|
__osSiRelAccess();
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
92
src/libultra/io/g0/contramwrite.c
Normal file
92
src/libultra/io/g0/contramwrite.c
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
#include <PR/os_internal.h>
|
||||||
|
#include <PR/rcp.h>
|
||||||
|
#include <libultra/io/controller.h>
|
||||||
|
#include <libultra/io/siint.h>
|
||||||
|
|
||||||
|
extern int __osPfsLastChannel;
|
||||||
|
|
||||||
|
s32 __osContRamWrite(OSMesgQueue *mq, int channel, u16 address, u8 *buffer, int force) {
|
||||||
|
s32 ret;
|
||||||
|
int i;
|
||||||
|
__OSContRamReadFormat *pifPtr;
|
||||||
|
s32 retry;
|
||||||
|
u8 crc;
|
||||||
|
|
||||||
|
// make 3 attempts at a write
|
||||||
|
retry = 2;
|
||||||
|
|
||||||
|
// skip if not forcing and address is [1,6] (protected region?)
|
||||||
|
if ((force != 1) && (address < 7) && (address != 0)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// acquire lock for SI access
|
||||||
|
__osSiGetAccess();
|
||||||
|
|
||||||
|
do {
|
||||||
|
// get pointer into PIF ram
|
||||||
|
pifPtr = (__OSContRamReadFormat *)&__osPfsPifRam;
|
||||||
|
|
||||||
|
// skip format update if the previous command was a write on the same channel
|
||||||
|
if ((__osContLastCmd != CONT_RAM_WRITE) || (channel != __osPfsLastChannel)) {
|
||||||
|
__osContLastCmd = CONT_RAM_WRITE;
|
||||||
|
__osPfsLastChannel = channel;
|
||||||
|
|
||||||
|
// ???
|
||||||
|
for (i = 0; i < channel; i++) (*((u8*)pifPtr) = 0, pifPtr = (__OSContRamReadFormat*)((u8*)pifPtr + 1));
|
||||||
|
|
||||||
|
// set up read format
|
||||||
|
__osPfsPifRam.pifstatus = CONT_FORMAT;
|
||||||
|
|
||||||
|
pifPtr->dummy = 0xFF;
|
||||||
|
pifPtr->txsize = 0x23;
|
||||||
|
pifPtr->rxsize = 1;
|
||||||
|
pifPtr->cmd = CONT_RAM_WRITE;
|
||||||
|
pifPtr->datacrc = 0xFF;
|
||||||
|
|
||||||
|
((u8*)pifPtr)[sizeof(__OSContRamReadFormat)] = FORMAT_END;
|
||||||
|
} else {
|
||||||
|
// ???
|
||||||
|
pifPtr = (__OSContRamReadFormat *)(&((u8 *)&__osPfsPifRam)[channel]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ???
|
||||||
|
pifPtr->address_hi = (u8)(address >> 3);
|
||||||
|
pifPtr->address_lo = (u8)(__osContAddressCrc(address) | (address << 5));
|
||||||
|
|
||||||
|
// copy given data to PIF data
|
||||||
|
bcopy(buffer, pifPtr->data, BLOCKSIZE);
|
||||||
|
|
||||||
|
// DMA PIF data
|
||||||
|
__osSiRawStartDma(OS_WRITE, &__osPfsPifRam);
|
||||||
|
crc = __osContDataCrc(buffer); // calculate CRC of sent data
|
||||||
|
osRecvMesg(mq, (OSMesg *)NULL, OS_MESG_BLOCK);
|
||||||
|
|
||||||
|
__osSiRawStartDma(OS_READ, &__osPfsPifRam);
|
||||||
|
osRecvMesg(mq, (OSMesg *)NULL, OS_MESG_BLOCK);
|
||||||
|
|
||||||
|
// check for error
|
||||||
|
ret = (s32)(pifPtr->rxsize & CON_ERR_MASK) >> 4;
|
||||||
|
|
||||||
|
if (ret == 0) {
|
||||||
|
// validate CRC
|
||||||
|
if (crc != pifPtr->datacrc) {
|
||||||
|
// CRC failed, retry if status is 0
|
||||||
|
ret = __osPfsGetStatus(mq, channel);
|
||||||
|
if (ret != 0) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
ret = PFS_ERR_CONTRFAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// failed
|
||||||
|
ret = PFS_ERR_NOPACK;
|
||||||
|
}
|
||||||
|
} while (ret == PFS_ERR_CONTRFAIL && retry-- >= 0);
|
||||||
|
|
||||||
|
// release SI access lock
|
||||||
|
__osSiRelAccess();
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
69
src/libultra/io/g0/crc.c
Normal file
69
src/libultra/io/g0/crc.c
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
#include <PR/ultratypes.h>
|
||||||
|
|
||||||
|
u8 __osContAddressCrc(u16 addr) {
|
||||||
|
u32 i;
|
||||||
|
s32 temp;
|
||||||
|
|
||||||
|
temp = 0;
|
||||||
|
i = 0x400;
|
||||||
|
|
||||||
|
do {
|
||||||
|
temp = temp * 2;
|
||||||
|
|
||||||
|
if (((u32)addr & i) != 0) {
|
||||||
|
if ((temp & 0x20) != 0) {
|
||||||
|
temp = temp ^ 0x14;
|
||||||
|
} else {
|
||||||
|
temp = temp + 1;
|
||||||
|
}
|
||||||
|
} else if ((temp & 0x20) != 0) {
|
||||||
|
temp = temp ^ 0x15;
|
||||||
|
}
|
||||||
|
|
||||||
|
i = i / 2;
|
||||||
|
} while (i != 0);
|
||||||
|
|
||||||
|
for (i = 0; i < 5; ++i) {
|
||||||
|
temp = temp * 2;
|
||||||
|
|
||||||
|
if ((temp & 0x20) != 0) {
|
||||||
|
temp = temp ^ 0x15;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return temp & 0x1F;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 __osContDataCrc(u8 *data) {
|
||||||
|
u32 j;
|
||||||
|
s32 temp;
|
||||||
|
u32 i;
|
||||||
|
|
||||||
|
temp = 0;
|
||||||
|
|
||||||
|
for (i = 32; i != 0; data++, i--) {
|
||||||
|
for (j = 0x80; j != 0; j >>= 1) {
|
||||||
|
temp = temp * 2;
|
||||||
|
|
||||||
|
if ((*data & j) != 0) {
|
||||||
|
if ((temp & 0x100) != 0) {
|
||||||
|
temp = temp ^ 0x84;
|
||||||
|
} else {
|
||||||
|
temp = temp + 1;
|
||||||
|
}
|
||||||
|
} else if ((temp & 0x100) != 0) {
|
||||||
|
temp = temp ^ 0x85;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
temp = temp * 2;
|
||||||
|
|
||||||
|
if ((temp & 0x100) != 0) {
|
||||||
|
temp = temp ^ 0x85;
|
||||||
|
}
|
||||||
|
} while (++i < 8);
|
||||||
|
|
||||||
|
return temp;
|
||||||
|
}
|
25
src/libultra/io/g0/epirawdma.c
Normal file
25
src/libultra/io/g0/epirawdma.c
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#include <libultra/io/piint.h>
|
||||||
|
|
||||||
|
s32 osEPiRawStartDma(OSPiHandle *pihandle, s32 direction, u32 devAddr, void *dramAddr, u32 size) {
|
||||||
|
u32 stat;
|
||||||
|
u8 domain;
|
||||||
|
|
||||||
|
EPI_SYNC(pihandle, stat, domain)
|
||||||
|
|
||||||
|
IO_WRITE(PI_DRAM_ADDR_REG, osVirtualToPhysical(dramAddr));
|
||||||
|
IO_WRITE(PI_CART_ADDR_REG, K1_TO_PHYS(pihandle->baseAddress | devAddr));
|
||||||
|
|
||||||
|
switch (direction)
|
||||||
|
{
|
||||||
|
case OS_READ:
|
||||||
|
IO_WRITE(PI_WR_LEN_REG, size - 1);
|
||||||
|
break;
|
||||||
|
case OS_WRITE:
|
||||||
|
IO_WRITE(PI_RD_LEN_REG, size - 1);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
12
src/libultra/io/g0/epirawread.c
Normal file
12
src/libultra/io/g0/epirawread.c
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#include <libultra/io/piint.h>
|
||||||
|
|
||||||
|
s32 osEPiRawReadIo(OSPiHandle *pihandle, u32 devAddr, u32 *data) {
|
||||||
|
u32 stat;
|
||||||
|
u8 domain;
|
||||||
|
|
||||||
|
EPI_SYNC(pihandle, stat, domain)
|
||||||
|
|
||||||
|
*data = *((u32 *)PHYS_TO_K1(pihandle->baseAddress | devAddr));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
12
src/libultra/io/g0/epirawwrite.c
Normal file
12
src/libultra/io/g0/epirawwrite.c
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#include <libultra/io/piint.h>
|
||||||
|
|
||||||
|
s32 osEPiRawWriteIo(OSPiHandle *pihandle, u32 devAddr, u32 data) {
|
||||||
|
u32 stat;
|
||||||
|
u8 domain;
|
||||||
|
|
||||||
|
EPI_SYNC(pihandle, stat, domain)
|
||||||
|
|
||||||
|
*((u32 *)PHYS_TO_K1(pihandle->baseAddress | devAddr)) = data;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
11
src/libultra/io/g0/epiread.c
Normal file
11
src/libultra/io/g0/epiread.c
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#include <libultra/io/piint.h>
|
||||||
|
|
||||||
|
s32 osEPiReadIo(OSPiHandle *pihandle, u32 devAddr, u32 *data) {
|
||||||
|
s32 ret;
|
||||||
|
|
||||||
|
__osPiGetAccess();
|
||||||
|
ret = osEPiRawReadIo(pihandle, devAddr, data);
|
||||||
|
__osPiRelAccess();
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
11
src/libultra/io/g0/epiwrite.c
Normal file
11
src/libultra/io/g0/epiwrite.c
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#include <libultra/io/piint.h>
|
||||||
|
|
||||||
|
s32 osEPiWriteIo(OSPiHandle *pihandle, u32 devAddr, u32 data) {
|
||||||
|
s32 ret;
|
||||||
|
|
||||||
|
__osPiGetAccess();
|
||||||
|
ret = osEPiRawWriteIo(pihandle, devAddr, data);
|
||||||
|
__osPiRelAccess();
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
138
src/libultra/io/g0/motor.c
Normal file
138
src/libultra/io/g0/motor.c
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
#include <PR/os_internal.h>
|
||||||
|
#include <libultra/io/controller.h>
|
||||||
|
|
||||||
|
OSPifRam gMotorData[MAXCONTROLLERS];
|
||||||
|
|
||||||
|
s32 __osMotorAccess(OSPfs *pfs, s32 param2) {
|
||||||
|
s32 i;
|
||||||
|
s32 ret;
|
||||||
|
__OSContRamReadFormat *ptr;
|
||||||
|
|
||||||
|
ptr = (__OSContRamReadFormat *)&gMotorData[pfs->channel];
|
||||||
|
|
||||||
|
if ((pfs->status & 8) == 0) {
|
||||||
|
return PFS_ERR_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
__osSiGetAccess();
|
||||||
|
|
||||||
|
gMotorData[pfs->channel].pifstatus = CONT_FORMAT;
|
||||||
|
|
||||||
|
ptr = (__OSContRamReadFormat *)((u8 *)ptr + pfs->channel);
|
||||||
|
|
||||||
|
for (i = 0; i < BLOCKSIZE; i++) {
|
||||||
|
ptr->data[i] = (u8)param2;
|
||||||
|
}
|
||||||
|
|
||||||
|
__osContLastCmd = CONT_ETC;
|
||||||
|
|
||||||
|
__osSiRawStartDma(OS_WRITE, &gMotorData[pfs->channel]);
|
||||||
|
osRecvMesg(pfs->queue, (OSMesg *)NULL, OS_MESG_BLOCK);
|
||||||
|
|
||||||
|
__osSiRawStartDma(OS_READ, &gMotorData[pfs->channel]);
|
||||||
|
osRecvMesg(pfs->queue, (OSMesg *)NULL, OS_MESG_BLOCK);
|
||||||
|
|
||||||
|
ret = (s32)(ptr->rxsize & CON_ERR_MASK);
|
||||||
|
|
||||||
|
if (ret == 0) {
|
||||||
|
if (param2 == 0) {
|
||||||
|
if (ptr->datacrc != 0) {
|
||||||
|
ret = PFS_ERR_CONTRFAIL;
|
||||||
|
}
|
||||||
|
} else if (ptr->datacrc != 0xEB) {
|
||||||
|
ret = PFS_ERR_CONTRFAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
__osSiRelAccess();
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void __osMakeMotorData(s32 channel, OSPifRam *mdata) {
|
||||||
|
u8 *ptr;
|
||||||
|
__OSContRamReadFormat ramreadformat;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
ptr = (u8 *)mdata->ramarray;
|
||||||
|
|
||||||
|
ramreadformat.dummy = CONT_CMD_NOP;
|
||||||
|
ramreadformat.txsize = CONT_CMD_WRITE_MEMPACK_TX;
|
||||||
|
ramreadformat.rxsize = CONT_CMD_WRITE_MEMPACK_RX;
|
||||||
|
ramreadformat.cmd = CONT_CMD_WRITE_MEMPACK;
|
||||||
|
ramreadformat.address_hi = 0xC0;
|
||||||
|
ramreadformat.address_lo = 0xC000 | __osContAddressCrc(0x600);
|
||||||
|
|
||||||
|
if (channel != 0)
|
||||||
|
{
|
||||||
|
for (i = 0; i < channel; i++)
|
||||||
|
{
|
||||||
|
*ptr++ = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*(__OSContRamReadFormat *)ptr = ramreadformat;
|
||||||
|
|
||||||
|
ptr += sizeof(__OSContRamReadFormat);
|
||||||
|
ptr[0] = CONT_CMD_END;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 osMotorInit(OSMesgQueue *mq, OSPfs *pfs, int channel) {
|
||||||
|
s32 ret;
|
||||||
|
u8 data[BLOCKSIZE];
|
||||||
|
|
||||||
|
pfs->queue = mq;
|
||||||
|
pfs->channel = channel;
|
||||||
|
pfs->activebank = 0xFF;
|
||||||
|
pfs->status = 0;
|
||||||
|
|
||||||
|
ret = __osPfsSelectBank(pfs, 0xfe);
|
||||||
|
|
||||||
|
if (ret == PFS_ERR_NEW_PACK) {
|
||||||
|
ret = __osPfsSelectBank(pfs, 0x80);
|
||||||
|
}
|
||||||
|
if (ret != 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = __osContRamRead(mq, channel, 1024, data);
|
||||||
|
|
||||||
|
if (ret == PFS_ERR_NEW_PACK) {
|
||||||
|
ret = PFS_ERR_CONTRFAIL;
|
||||||
|
}
|
||||||
|
if (ret != 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
if (data[BLOCKSIZE - 1] == 0xFE) {
|
||||||
|
return PFS_ERR_DEVICE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = __osPfsSelectBank(pfs, 0x80);
|
||||||
|
|
||||||
|
if (ret == PFS_ERR_NEW_PACK) {
|
||||||
|
ret = PFS_ERR_CONTRFAIL;
|
||||||
|
}
|
||||||
|
if (ret != 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = __osContRamRead(mq, channel, 1024, data);
|
||||||
|
|
||||||
|
if (ret == PFS_ERR_NEW_PACK) {
|
||||||
|
ret = PFS_ERR_CONTRFAIL;
|
||||||
|
}
|
||||||
|
if (ret != 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
if (data[BLOCKSIZE - 1] != 0x80) {
|
||||||
|
return PFS_ERR_DEVICE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((pfs->status & 8) == 0) {
|
||||||
|
__osMakeMotorData(channel, &gMotorData[channel]);
|
||||||
|
}
|
||||||
|
|
||||||
|
pfs->status = 8;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
19
src/libultra/io/g0/pfsselectbank.c
Normal file
19
src/libultra/io/g0/pfsselectbank.c
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#include <libultra/io/controller.h>
|
||||||
|
|
||||||
|
s32 __osPfsSelectBank(OSPfs *pfs, u8 bank) {
|
||||||
|
u8 data[BLOCKSIZE];
|
||||||
|
int i;
|
||||||
|
s32 ret;
|
||||||
|
|
||||||
|
for (i = 0; i < BLOCKSIZE; i++) {
|
||||||
|
data[i] = bank;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = __osContRamWrite(pfs->queue, pfs->channel, 1024, &data, FALSE);
|
||||||
|
|
||||||
|
if (ret == 0) {
|
||||||
|
pfs->activebank = bank;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
82
src/libultra/io/g0/pimgr.c
Normal file
82
src/libultra/io/g0/pimgr.c
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
#include <PR/os_internal.h>
|
||||||
|
#include <PR/rdb.h>
|
||||||
|
#include <libultra/io/piint.h>
|
||||||
|
|
||||||
|
OSDevMgr __osPiDevMgr = {0};
|
||||||
|
OSPiHandle *__osPiTable = NULL;
|
||||||
|
OSPiHandle *__osCurrentHandle[2] = {&__CartRomHandle, &__LeoDiskHandle};
|
||||||
|
// below are supposed to be static in .bss
|
||||||
|
OSThread piThread;
|
||||||
|
char piThreadStack[OS_PIM_STACKSIZE];
|
||||||
|
OSThread piRamRomThread;
|
||||||
|
char piRamRomThreadStack[1024];
|
||||||
|
OSMesgQueue gPiReqRamRomQueue;
|
||||||
|
OSMesg gPiReqRamRomQueueBuffer[1];
|
||||||
|
OSMesgQueue gPiFreeRamRomQueue;
|
||||||
|
OSMesg gPiFreeRamRomQueueBuffer[1];
|
||||||
|
OSMesgQueue piEventQueue;
|
||||||
|
OSMesg piEventBuf[1];
|
||||||
|
|
||||||
|
static void pi_ramrom_thread_main(void *arg);
|
||||||
|
|
||||||
|
void osCreatePiManager(OSPri pri, OSMesgQueue *cmdQ, OSMesg *cmdBuf, s32 cmdMsgCnt)
|
||||||
|
{
|
||||||
|
u32 savedMask;
|
||||||
|
OSPri oldPri;
|
||||||
|
OSPri myPri;
|
||||||
|
if (!__osPiDevMgr.active)
|
||||||
|
{
|
||||||
|
osCreateMesgQueue(cmdQ, cmdBuf, cmdMsgCnt);
|
||||||
|
osCreateMesgQueue(&piEventQueue, (OSMesg*)&piEventBuf, 1);
|
||||||
|
if (!__osPiAccessQueueEnabled)
|
||||||
|
__osPiCreateAccessQueue();
|
||||||
|
osSetEventMesg(OS_EVENT_PI, &piEventQueue, (OSMesg)0x22222222);
|
||||||
|
oldPri = -1;
|
||||||
|
myPri = osGetThreadPri(NULL);
|
||||||
|
if (myPri < pri)
|
||||||
|
{
|
||||||
|
oldPri = myPri;
|
||||||
|
osSetThreadPri(NULL, pri);
|
||||||
|
}
|
||||||
|
savedMask = __osDisableInt();
|
||||||
|
__osPiDevMgr.active = 1;
|
||||||
|
__osPiDevMgr.thread = &piThread;
|
||||||
|
__osPiDevMgr.cmdQueue = cmdQ;
|
||||||
|
__osPiDevMgr.evtQueue = &piEventQueue;
|
||||||
|
__osPiDevMgr.acsQueue = &__osPiAccessQueue;
|
||||||
|
__osPiDevMgr.dma = osPiRawStartDma;
|
||||||
|
__osPiDevMgr.edma = osEPiRawStartDma;
|
||||||
|
osCreateThread(&piThread, 0, __osDevMgrMain, &__osPiDevMgr, &piThreadStack[OS_PIM_STACKSIZE], pri);
|
||||||
|
osStartThread(&piThread);
|
||||||
|
osCreateThread(&piRamRomThread, 0, pi_ramrom_thread_main, NULL, &piRamRomThreadStack[1024], pri - 1);
|
||||||
|
osStartThread(&piRamRomThread);
|
||||||
|
__osRestoreInt(savedMask);
|
||||||
|
if (oldPri != -1)
|
||||||
|
{
|
||||||
|
osSetThreadPri(NULL, oldPri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pi_ramrom_thread_main(void *arg) {
|
||||||
|
s32 sent;
|
||||||
|
u8 buf[1];
|
||||||
|
|
||||||
|
osCreateMesgQueue(&gPiReqRamRomQueue, gPiReqRamRomQueueBuffer, 1);
|
||||||
|
osCreateMesgQueue(&gPiFreeRamRomQueue, gPiFreeRamRomQueueBuffer, 1);
|
||||||
|
osSetEventMesg(OS_EVENT_RDB_REQ_RAMROM, &gPiReqRamRomQueue, NULL);
|
||||||
|
osSetEventMesg(OS_EVENT_RDB_FREE_RAMROM, &gPiFreeRamRomQueue, NULL);
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
osRecvMesg(&gPiReqRamRomQueue, NULL, OS_MESG_BLOCK);
|
||||||
|
__osPiGetAccess();
|
||||||
|
|
||||||
|
sent = 0;
|
||||||
|
while (sent == 0) {
|
||||||
|
sent += __osRdbSend(buf, 1, RDB_TYPE_GtoH_RAMROM);
|
||||||
|
}
|
||||||
|
|
||||||
|
osRecvMesg(&gPiFreeRamRomQueue, NULL, OS_MESG_BLOCK);
|
||||||
|
__osPiRelAccess();
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +0,0 @@
|
|||||||
#include "common.h"
|
|
||||||
|
|
||||||
#pragma GLOBAL_ASM("asm/nonmatchings/libultra/io/motor/__osMotorAccess.s")
|
|
||||||
|
|
||||||
#pragma GLOBAL_ASM("asm/nonmatchings/libultra/io/motor/__osMakeMotorData.s")
|
|
||||||
|
|
||||||
#pragma GLOBAL_ASM("asm/nonmatchings/libultra/io/motor/osMotorInit.s")
|
|
@ -1,3 +0,0 @@
|
|||||||
#include "common.h"
|
|
||||||
|
|
||||||
#pragma GLOBAL_ASM("asm/nonmatchings/libultra/io/pfsselectbank/__osPfsSelectBank.s")
|
|
@ -1,5 +0,0 @@
|
|||||||
#include "common.h"
|
|
||||||
|
|
||||||
#pragma GLOBAL_ASM("asm/nonmatchings/libultra/io/pimgr/osCreatePiManager.s")
|
|
||||||
|
|
||||||
#pragma GLOBAL_ASM("asm/nonmatchings/libultra/io/pimgr/pimgr_text_01B0.s")
|
|
171
src/libultra/os/O1/initialize.c
Normal file
171
src/libultra/os/O1/initialize.c
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
#include <PR/os.h>
|
||||||
|
#include <PR/os_internal.h>
|
||||||
|
#include <PR/R4300.h>
|
||||||
|
#include <PR/rcp.h>
|
||||||
|
#include <libultra/io/piint.h>
|
||||||
|
|
||||||
|
#define PIF_COMMAND_BYTE (PIF_RAM_START+0x3c)
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
/* 0x0 */ unsigned int inst1;
|
||||||
|
/* 0x4 */ unsigned int inst2;
|
||||||
|
/* 0x8 */ unsigned int inst3;
|
||||||
|
/* 0xC */ unsigned int inst4;
|
||||||
|
} __osExceptionVector;
|
||||||
|
|
||||||
|
typedef int (*some_p64_func)(int, int);
|
||||||
|
|
||||||
|
extern __osExceptionVector __osExceptionPreamble;
|
||||||
|
extern u32 __ptExceptionPreamble[];
|
||||||
|
|
||||||
|
OSTime osClockRate = OS_CLOCK_RATE;
|
||||||
|
s32 osViClock = VI_NTSC_CLOCK;
|
||||||
|
u32 __osShutdown = 0;
|
||||||
|
u32 __OSGlobalIntMask = OS_IM_ALL;
|
||||||
|
s32 gP64Enabled;
|
||||||
|
|
||||||
|
void __createSpeedParam();
|
||||||
|
|
||||||
|
void osInitialize() {
|
||||||
|
u32 pifdata;
|
||||||
|
u32 clock; // unused
|
||||||
|
some_p64_func p64Func;
|
||||||
|
u32 *ptPreamblePtr;
|
||||||
|
u32 *eVecPtr;
|
||||||
|
u32 p64Struct_Dst;
|
||||||
|
u32 *p64Struct;
|
||||||
|
u32 *p64Status;
|
||||||
|
u32 *p64Src;
|
||||||
|
u32 *p64Dst;
|
||||||
|
u32 p64WordsLeft;
|
||||||
|
|
||||||
|
clock = 0;
|
||||||
|
|
||||||
|
// enable fpu
|
||||||
|
__osSetSR(__osGetSR() | SR_CU1);
|
||||||
|
// flush denorm to zero, enable invalid operation
|
||||||
|
__osSetFpcCsr(FPCSR_FS | FPCSR_EV);
|
||||||
|
|
||||||
|
// terminate boot process
|
||||||
|
while (__osSiRawReadIo(PIF_COMMAND_BYTE, &pifdata));
|
||||||
|
while (__osSiRawWriteIo(PIF_COMMAND_BYTE, pifdata | 8));
|
||||||
|
|
||||||
|
// copy exception preamble to exception vectors
|
||||||
|
*(__osExceptionVector *)UT_VEC = __osExceptionPreamble;
|
||||||
|
*(__osExceptionVector *)XUT_VEC = __osExceptionPreamble;
|
||||||
|
*(__osExceptionVector *)ECC_VEC = __osExceptionPreamble;
|
||||||
|
*(__osExceptionVector *)E_VEC = __osExceptionPreamble;
|
||||||
|
|
||||||
|
// flush exception vectors from cache
|
||||||
|
osWritebackDCache((void *)UT_VEC, E_VEC - UT_VEC + sizeof(__osExceptionVector));
|
||||||
|
osInvalICache((void *)UT_VEC, E_VEC - UT_VEC + sizeof(__osExceptionVector));
|
||||||
|
|
||||||
|
// create speed structures for EPI
|
||||||
|
__createSpeedParam();
|
||||||
|
|
||||||
|
// map TLB for remote debug port
|
||||||
|
osUnmapTLBAll();
|
||||||
|
osMapTLBRdb();
|
||||||
|
|
||||||
|
// bus clock -> cpu counter speed
|
||||||
|
osClockRate = osClockRate * 3 / 4;
|
||||||
|
|
||||||
|
if (osResetType == 0) {
|
||||||
|
// cold reset, clear post-NMI buffer
|
||||||
|
bzero(osAppNMIBuffer, OS_APP_NMI_BUFSIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set up correct video clock
|
||||||
|
if (osTvType == OS_TV_PAL) {
|
||||||
|
osViClock = VI_PAL_CLOCK;
|
||||||
|
} else if (osTvType == OS_TV_MPAL) {
|
||||||
|
osViClock = VI_MPAL_CLOCK;
|
||||||
|
} else {
|
||||||
|
osViClock = VI_NTSC_CLOCK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// halt if pre-NMI (IP5, aka. INT2, maps to pre-NMI)
|
||||||
|
if (__osGetCause() & CAUSE_IP5) {
|
||||||
|
while (1) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// enable audio DMA
|
||||||
|
IO_WRITE(AI_CONTROL_REG, AI_CONTROL_DMA_ON);
|
||||||
|
// set up audio default rates
|
||||||
|
IO_WRITE(AI_DACRATE_REG, AI_MAX_DAC_RATE - 1);
|
||||||
|
IO_WRITE(AI_BITRATE_REG, AI_MAX_BIT_RATE - 1);
|
||||||
|
|
||||||
|
// partner-64 stuff
|
||||||
|
// note: not 100% sure what the below is doing, some comments may be wrong
|
||||||
|
if (gP64Enabled == 0) {
|
||||||
|
p64Status = (u32 *)0xBFF08004;
|
||||||
|
p64Struct = (u32 *)0xBFF00000;
|
||||||
|
|
||||||
|
if (*p64Struct != 0x4B4D4300) {
|
||||||
|
// already initialized/no partner-64 hooked up?
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy partner exception preamble to exception vector
|
||||||
|
ptPreamblePtr = (u32 *)__ptExceptionPreamble;
|
||||||
|
eVecPtr = (u32 *)E_VEC;
|
||||||
|
|
||||||
|
*(eVecPtr++) = *(ptPreamblePtr++);
|
||||||
|
*(eVecPtr++) = *(ptPreamblePtr++);
|
||||||
|
*(eVecPtr++) = *(ptPreamblePtr++);
|
||||||
|
ptPreamblePtr += 2; // exclude two instructions (these are nops in the partner preamble)
|
||||||
|
eVecPtr += 2;
|
||||||
|
*(eVecPtr++) = *(ptPreamblePtr++);
|
||||||
|
*(eVecPtr++) = *(ptPreamblePtr++);
|
||||||
|
*(eVecPtr++) = *(ptPreamblePtr++);
|
||||||
|
|
||||||
|
// flush exception vector from cache
|
||||||
|
osWritebackDCache((void *)E_VEC, 0x24);
|
||||||
|
osInvalICache((void *)E_VEC, 0x24);
|
||||||
|
|
||||||
|
// mark partner mode as enabled
|
||||||
|
gP64Enabled = 1;
|
||||||
|
|
||||||
|
// check some status bit
|
||||||
|
if ((*p64Status & 0x10) == 0) {
|
||||||
|
p64Struct_Dst = *(p64Struct + 1);
|
||||||
|
|
||||||
|
if (p64Struct_Dst != 0xBFF00000) {
|
||||||
|
// copy 8192 bytes of something
|
||||||
|
p64Dst = (u32 *)(p64Struct_Dst | 0x20000000);
|
||||||
|
p64WordsLeft = 2048;
|
||||||
|
p64Src = (u32 *)0xBFF00000;
|
||||||
|
|
||||||
|
while (p64WordsLeft != 0) {
|
||||||
|
*(p64Dst++) = *(p64Src++);
|
||||||
|
p64WordsLeft--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// call some func with the same value used above for skipping all this
|
||||||
|
p64Func = (some_p64_func)(p64Struct_Dst + 8);
|
||||||
|
(*p64Func)(0x4B4D4300, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void func_8007CC9C() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up PI handles for EPI
|
||||||
|
* @see __osCurrentHandle
|
||||||
|
*/
|
||||||
|
void __createSpeedParam() {
|
||||||
|
__CartRomHandle.type = DEVICE_TYPE_INIT;
|
||||||
|
__CartRomHandle.latency = (u8)IO_READ(PI_BSD_DOM1_LAT_REG);
|
||||||
|
__CartRomHandle.pulse = (u8)IO_READ(PI_BSD_DOM1_PWD_REG);
|
||||||
|
__CartRomHandle.pageSize = (u8)IO_READ(PI_BSD_DOM1_PGS_REG);
|
||||||
|
__CartRomHandle.relDuration = (u8)IO_READ(PI_BSD_DOM1_RLS_REG);
|
||||||
|
|
||||||
|
__LeoDiskHandle.type = DEVICE_TYPE_INIT;
|
||||||
|
__LeoDiskHandle.latency = (u8)IO_READ(PI_BSD_DOM2_LAT_REG);
|
||||||
|
__LeoDiskHandle.pulse = (u8)IO_READ(PI_BSD_DOM2_PWD_REG);
|
||||||
|
__LeoDiskHandle.pageSize = (u8)IO_READ(PI_BSD_DOM2_PGS_REG);
|
||||||
|
__LeoDiskHandle.relDuration = (u8)IO_READ(PI_BSD_DOM2_RLS_REG);
|
||||||
|
}
|
32
src/libultra/os/O1/initrdb.c
Normal file
32
src/libultra/os/O1/initrdb.c
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#include <PR/os_internal.h>
|
||||||
|
#include <PR/rdb.h>
|
||||||
|
#include <PR/ultratypes.h>
|
||||||
|
#include <libultra/os/rdbint.h>
|
||||||
|
|
||||||
|
rdbPacket *__osRdb_IP6_Data;
|
||||||
|
u32 __osRdb_IP6_Size;
|
||||||
|
u32 __osRdb_IP6_Ct;
|
||||||
|
u32 __osRdb_IP6_CurWrite;
|
||||||
|
u32 __osRdb_IP6_CurSend;
|
||||||
|
|
||||||
|
void osInitRdb(u8 *sendBuf, u32 sendSize) {
|
||||||
|
s32 savedMask;
|
||||||
|
|
||||||
|
sendSize = sendSize / 4;
|
||||||
|
|
||||||
|
// 4-byte align sendBuf address
|
||||||
|
if (((u32)sendBuf & 3) != 0) {
|
||||||
|
sendBuf = (u8 *)((u32)sendBuf & 3) + 4;
|
||||||
|
sendSize = sendSize - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
savedMask = __osDisableInt();
|
||||||
|
|
||||||
|
__osRdb_IP6_Data = (rdbPacket *)sendBuf;
|
||||||
|
__osRdb_IP6_Size = sendSize;
|
||||||
|
__osRdb_IP6_Ct = 0;
|
||||||
|
__osRdb_IP6_CurWrite = 0;
|
||||||
|
__osRdb_IP6_CurSend = 0;
|
||||||
|
|
||||||
|
__osRestoreInt(savedMask);
|
||||||
|
}
|
74
src/libultra/os/O1/rdbsend.c
Normal file
74
src/libultra/os/O1/rdbsend.c
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
#include <PR/os_internal.h>
|
||||||
|
#include <PR/rdb.h>
|
||||||
|
#include <PR/R4300.h>
|
||||||
|
#include <PR/ultratypes.h>
|
||||||
|
#include <libultra/os/rdbint.h>
|
||||||
|
|
||||||
|
u32 __osRdb_IP6_Empty = 1;
|
||||||
|
|
||||||
|
u32 __osRdbSend(u8 *buf, u32 size, u32 type) {
|
||||||
|
rdbPacket *pktPtr;
|
||||||
|
rdbPacket pkt;
|
||||||
|
u32 pktLength;
|
||||||
|
s32 i;
|
||||||
|
s32 k;
|
||||||
|
s32 wasEmpty;
|
||||||
|
u32 savedMask;
|
||||||
|
u32 sent;
|
||||||
|
|
||||||
|
k = 0;
|
||||||
|
wasEmpty = 0;
|
||||||
|
sent = 0;
|
||||||
|
|
||||||
|
savedMask = __osDisableInt();
|
||||||
|
|
||||||
|
if (__osRdb_IP6_Empty) {
|
||||||
|
__osRdb_IP6_Empty = FALSE;
|
||||||
|
|
||||||
|
pkt.type = type;
|
||||||
|
|
||||||
|
pktLength = size < 3 ? size : 3;
|
||||||
|
|
||||||
|
pkt.length = pktLength;
|
||||||
|
i = 0;
|
||||||
|
|
||||||
|
while (i < pktLength) {
|
||||||
|
pkt.buf[i++] = buf[k++];
|
||||||
|
}
|
||||||
|
|
||||||
|
size -= pktLength;
|
||||||
|
sent = pktLength;
|
||||||
|
wasEmpty = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (size != 0 && __osRdb_IP6_Ct < __osRdb_IP6_Size) {
|
||||||
|
pktLength = size < 3 ? size : 3;
|
||||||
|
|
||||||
|
pktPtr = &__osRdb_IP6_Data[__osRdb_IP6_CurWrite];
|
||||||
|
pktPtr->type = type;
|
||||||
|
pktPtr->length = pktLength;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (i < pktLength) {
|
||||||
|
pktPtr->buf[i++] = buf[k++];
|
||||||
|
}
|
||||||
|
|
||||||
|
__osRdb_IP6_CurWrite += 1;
|
||||||
|
|
||||||
|
if (__osRdb_IP6_CurWrite >= __osRdb_IP6_Size) {
|
||||||
|
__osRdb_IP6_CurWrite = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
__osRdb_IP6_Ct += 1;
|
||||||
|
size -= pktLength;
|
||||||
|
sent += pktLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wasEmpty != 0) {
|
||||||
|
*((u32 *)RDB_BASE_REG) = *((u32 *)&pkt);
|
||||||
|
}
|
||||||
|
|
||||||
|
__osRestoreInt(savedMask);
|
||||||
|
|
||||||
|
return sent;
|
||||||
|
}
|
34
src/libultra/os/O1/readhost.c
Normal file
34
src/libultra/os/O1/readhost.c
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#include <PR/os_internal.h>
|
||||||
|
#include <PR/rdb.h>
|
||||||
|
#include <PR/R4300.h>
|
||||||
|
#include <PR/ultratypes.h>
|
||||||
|
#include <libultra/os/rdbint.h>
|
||||||
|
|
||||||
|
s32 gReadHostInitialized = 0;
|
||||||
|
OSMesgQueue gReadHostQueue;
|
||||||
|
OSMesg gReadHostQueueBuffer[1];
|
||||||
|
|
||||||
|
u8 *__osRdb_Read_Data_Buf;
|
||||||
|
u32 __osRdb_Read_Data_Ct;
|
||||||
|
|
||||||
|
void osReadHost(void *dramAddr, u32 nbytes) {
|
||||||
|
u8 buf[1];
|
||||||
|
s32 sent;
|
||||||
|
|
||||||
|
sent = 0;
|
||||||
|
|
||||||
|
if (!gReadHostInitialized) {
|
||||||
|
osCreateMesgQueue(&gReadHostQueue, gReadHostQueueBuffer, 1);
|
||||||
|
osSetEventMesg(OS_EVENT_RDB_READ_DONE, &gReadHostQueue, NULL);
|
||||||
|
gReadHostInitialized = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
__osRdb_Read_Data_Buf = dramAddr;
|
||||||
|
__osRdb_Read_Data_Ct = nbytes;
|
||||||
|
|
||||||
|
while (sent == 0) {
|
||||||
|
sent += __osRdbSend(buf, 1, RDB_TYPE_GtoH_READY_FOR_DATA);
|
||||||
|
}
|
||||||
|
|
||||||
|
osRecvMesg(&gReadHostQueue, NULL, OS_MESG_BLOCK);
|
||||||
|
}
|
53
src/libultra/os/O1/writehost.c
Normal file
53
src/libultra/os/O1/writehost.c
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
#include <PR/os_internal.h>
|
||||||
|
#include <PR/rdb.h>
|
||||||
|
#include <PR/R4300.h>
|
||||||
|
#include <PR/ultratypes.h>
|
||||||
|
#include <libultra/os/rdbint.h>
|
||||||
|
|
||||||
|
s32 gWriteHostInitialized = 0;
|
||||||
|
OSMesgQueue gWriteHostQueue;
|
||||||
|
OSMesg gWriteHostQueueBuffer[1];
|
||||||
|
|
||||||
|
void osWriteHost(void *dramAddr, u32 nbytes) {
|
||||||
|
u8 *dramPtr;
|
||||||
|
u32 sent;
|
||||||
|
u8 sizePacket[3];
|
||||||
|
u32 size;
|
||||||
|
|
||||||
|
dramPtr = (u8 *)dramAddr;
|
||||||
|
|
||||||
|
if (!gWriteHostInitialized) {
|
||||||
|
osCreateMesgQueue(&gWriteHostQueue, gWriteHostQueueBuffer, 1);
|
||||||
|
osSetEventMesg(OS_EVENT_RDB_DATA_DONE, &gWriteHostQueue, NULL);
|
||||||
|
gWriteHostInitialized = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (nbytes != 0) {
|
||||||
|
if (nbytes < RDB_DATA_MAX_BLOCK_SIZE) {
|
||||||
|
size = nbytes;
|
||||||
|
} else {
|
||||||
|
size = RDB_DATA_MAX_BLOCK_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
sizePacket[0] = (u8)((size & 0xFF0000) >> 16);
|
||||||
|
sizePacket[1] = (u8)((size & 0xFF00) >> 8);
|
||||||
|
sizePacket[2] = (u8)(size & 0xFF);
|
||||||
|
|
||||||
|
sent = 0;
|
||||||
|
|
||||||
|
while (sent < 3) {
|
||||||
|
sent += __osRdbSend(&sizePacket[sent], 3 - sent, RDB_TYPE_GtoH_DATA_CT);
|
||||||
|
}
|
||||||
|
|
||||||
|
sent = 0;
|
||||||
|
|
||||||
|
while (sent < size) {
|
||||||
|
sent += __osRdbSend(&dramPtr[sent], size - sent, RDB_TYPE_GtoH_DATA);
|
||||||
|
}
|
||||||
|
|
||||||
|
nbytes -= size;
|
||||||
|
dramPtr += size;
|
||||||
|
|
||||||
|
osRecvMesg(&gWriteHostQueue, NULL, OS_MESG_BLOCK);
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +0,0 @@
|
|||||||
#include "common.h"
|
|
||||||
|
|
||||||
#pragma GLOBAL_ASM("asm/nonmatchings/libultra/os/initialize/osInitialize.s")
|
|
||||||
|
|
||||||
void func_8007CC9C() {}
|
|
||||||
|
|
||||||
#pragma GLOBAL_ASM("asm/nonmatchings/libultra/os/initialize/__createSpeedParam.s")
|
|
@ -1,3 +0,0 @@
|
|||||||
#include "common.h"
|
|
||||||
|
|
||||||
#pragma GLOBAL_ASM("asm/nonmatchings/libultra/os/initrdb/osInitRdb.s")
|
|
@ -1,3 +0,0 @@
|
|||||||
#include "common.h"
|
|
||||||
|
|
||||||
#pragma GLOBAL_ASM("asm/nonmatchings/libultra/os/rdbsend/__osRdbSend.s")
|
|
@ -1,3 +0,0 @@
|
|||||||
#include "common.h"
|
|
||||||
|
|
||||||
#pragma GLOBAL_ASM("asm/nonmatchings/libultra/os/readhost/osReadHost.s")
|
|
@ -1,3 +0,0 @@
|
|||||||
#include "common.h"
|
|
||||||
|
|
||||||
#pragma GLOBAL_ASM("asm/nonmatchings/libultra/os/writehost/osWriteHost.s")
|
|
@ -421,7 +421,7 @@ _seqpVoiceHandler = 0x800729a0; // type:func
|
|||||||
alCSeqSetLoc = 0x8007b178; // type:func
|
alCSeqSetLoc = 0x8007b178; // type:func
|
||||||
alCSeqGetLoc = 0x8007b22c; // type:func
|
alCSeqGetLoc = 0x8007b22c; // type:func
|
||||||
__osMotorAccess = 0x8007e120; // type:func
|
__osMotorAccess = 0x8007e120; // type:func
|
||||||
pimgr_text_01B0 = 0x8007e6a0; // type:func
|
pi_ramrom_thread_main = 0x8007e6a0; // type:func
|
||||||
__ll_mod = 0x8007eee8; // type:func
|
__ll_mod = 0x8007eee8; // type:func
|
||||||
guMtxIdent = 0x8007ff68; // type:func
|
guMtxIdent = 0x8007ff68; // type:func
|
||||||
rmonPrintf = 0x80081370; // type:func
|
rmonPrintf = 0x80081370; // type:func
|
||||||
@ -476,10 +476,10 @@ __ll_lshift = 0x8007ed94; // type:func
|
|||||||
__ll_rem = 0x8007EDC0; // type:func
|
__ll_rem = 0x8007EDC0; // type:func
|
||||||
MusFxBankNumberOfEffects = 0x8007fa30; // type:data
|
MusFxBankNumberOfEffects = 0x8007fa30; // type:data
|
||||||
guMtxL2F = 0x8007ff98; // type:func
|
guMtxL2F = 0x8007ff98; // type:func
|
||||||
__osExceptionPreamble = 0x80080090; // type:data size:0x10
|
__osExceptionPreamble = 0x80080090; // type:func size:0x10
|
||||||
__ptExceptionPreamble = 0x800800a0; // type:data size:0x10
|
__ptExceptionPreamble = 0x800800a0; // type:func size:0x20
|
||||||
__ptException = 0x800800c0; // type:data
|
__ptException = 0x800800c0; // type:func
|
||||||
__osException = 0x80080164; // type:data
|
__osException = 0x80080164; // type:func
|
||||||
spin = 0x80087818; // type:data
|
spin = 0x80087818; // type:data
|
||||||
gspF3DEX2_xbusTextStart = 0x8008b160; // type:data
|
gspF3DEX2_xbusTextStart = 0x8008b160; // type:data
|
||||||
SHORT_8008c524 = 0x8008c524; // type:data size:0x2
|
SHORT_8008c524 = 0x8008c524; // type:data size:0x2
|
||||||
@ -508,8 +508,8 @@ __osViNext = 0x80097ec4; // type:data size:0x4
|
|||||||
__osRunQueue = 0x80097ed8; // type:data size:0x4
|
__osRunQueue = 0x80097ed8; // type:data size:0x4
|
||||||
__osActiveQueue = 0x80097edc; // type:data size:0x4
|
__osActiveQueue = 0x80097edc; // type:data size:0x4
|
||||||
__osRunningThread = 0x80097ee0; // type:data size:0x4
|
__osRunningThread = 0x80097ee0; // type:data size:0x4
|
||||||
writehost_data_0000 = 0x80097f30; // type:data size:0x4
|
gWriteHostInitialized = 0x80097f30; // type:data size:0x4
|
||||||
readhost_data_0000 = 0x80097f40; // type:data size:0x4
|
gReadHostInitialized = 0x80097f40; // type:data size:0x4
|
||||||
__osPfsLastChannel = 0x80097f60; // type:data size:0x4
|
__osPfsLastChannel = 0x80097f60; // type:data size:0x4
|
||||||
__osPiAccessQueueEnabled = 0x80097f70; // type:data size:0x4
|
__osPiAccessQueueEnabled = 0x80097f70; // type:data size:0x4
|
||||||
__osRdb_IP6_Empty = 0x80097f80; // type:data size:0x4
|
__osRdb_IP6_Empty = 0x80097f80; // type:data size:0x4
|
||||||
@ -543,7 +543,7 @@ rmonmem_rodata_0098 = 0x800a2a68; // type:data
|
|||||||
rmonmem_rodata_00A0 = 0x800a2a70; // type:data
|
rmonmem_rodata_00A0 = 0x800a2a70; // type:data
|
||||||
rmonbrk_rodata_0180 = 0x800a2d70; // type:data size:0x4
|
rmonbrk_rodata_0180 = 0x800a2d70; // type:data size:0x4
|
||||||
player_bss_0048 = 0x800a7d40; // type:data
|
player_bss_0048 = 0x800a7d40; // type:data
|
||||||
__kmc_pt_mode = 0x800cd320; // type:data size:0x4
|
gP64Enabled = 0x800cd320; // type:data size:0x4
|
||||||
__osEventStateTab = 0x800cd330; // type:data size:0xc0
|
__osEventStateTab = 0x800cd330; // type:data size:0xc0
|
||||||
__osContPifRam = 0x800cd3f0; // type:data size:0x40
|
__osContPifRam = 0x800cd3f0; // type:data size:0x40
|
||||||
__osContLastCmd = 0x800cd430; // type:data size:0x1
|
__osContLastCmd = 0x800cd430; // type:data size:0x1
|
||||||
@ -552,12 +552,15 @@ __osEepromTimerQ = 0x800cd458; // type:data size:0x18
|
|||||||
__osEepromTimerMsg = 0x800cd470; // type:data size:0x4
|
__osEepromTimerMsg = 0x800cd470; // type:data size:0x4
|
||||||
siAccessBuf = 0x800cd480; // type:data
|
siAccessBuf = 0x800cd480; // type:data
|
||||||
__osSiAccessQueue = 0x800cd488; // type:data
|
__osSiAccessQueue = 0x800cd488; // type:data
|
||||||
motor_bss_0000 = 0x800cd4a0; // type:data size:0x100
|
gMotorData = 0x800cd4a0; // type:data size:0x100
|
||||||
pimgr_bss_00F0 = 0x800cd690; // type:data size:0x1b0
|
piThread = 0x800cd690; // type:data size:0x1b0
|
||||||
pimgr_bss_12A0 = 0x800ce840; // type:data size:0x1b0
|
piRamRomThread = 0x800ce840; // type:data size:0x1b0
|
||||||
pimgr_bss_1850 = 0x800cedf0; // type:data size:0x18
|
piEventQueue = 0x800cee30; // type:data size:0x18
|
||||||
pimgr_bss_1890 = 0x800cee30; // type:data size:0x18
|
piEventBuf = 0x800cee48; // type:data size:0x4
|
||||||
pimgr_bss_18A8 = 0x800cee48; // type:data size:0x4
|
gPiReqRamRomQueue = 0x800CEDF0;
|
||||||
|
gPiReqRamRomQueueBuffer = 0x800CEE08;
|
||||||
|
gPiFreeRamRomQueue = 0x800CEE10;
|
||||||
|
gPiFreeRamRomQueueBuffer = 0x800CEE28;
|
||||||
__osCurrentTime = 0x800ceeb0; // type:data size:0x4
|
__osCurrentTime = 0x800ceeb0; // type:data size:0x4
|
||||||
__osBaseCounter = 0x800ceeb8; // type:data size:0x4
|
__osBaseCounter = 0x800ceeb8; // type:data size:0x4
|
||||||
__osViIntrCount = 0x800ceebc; // type:data size:0x4
|
__osViIntrCount = 0x800ceebc; // type:data size:0x4
|
||||||
@ -566,10 +569,10 @@ __osProfTimerQ = 0x800ceec8; // type:data
|
|||||||
__osProfileList = 0x800ceee0; // type:data
|
__osProfileList = 0x800ceee0; // type:data
|
||||||
__osProfileListEnd = 0x800ceee4; // type:data
|
__osProfileListEnd = 0x800ceee4; // type:data
|
||||||
__osProfileOverflowBin = 0x800ceee8; // type:data
|
__osProfileOverflowBin = 0x800ceee8; // type:data
|
||||||
writehost_bss_0000 = 0x800ceef0; // type:data size:0x18
|
gWriteHostQueue = 0x800ceef0; // type:data size:0x18
|
||||||
writehost_bss_0018 = 0x800cef08; // type:data size:0x4
|
gWriteHostQueueBuffer = 0x800cef08; // type:data size:0x4
|
||||||
readhost_bss_0000 = 0x800cef10; // type:data
|
gReadHostQueue = 0x800cef10; // type:data
|
||||||
readhost_bss_0018 = 0x800cef28; // type:data
|
gReadHostQueueBuffer = 0x800cef28; // type:data
|
||||||
__osRdb_Read_Data_Buf = 0x800cef2c; // type:data size:0x4
|
__osRdb_Read_Data_Buf = 0x800cef2c; // type:data size:0x4
|
||||||
__osRdb_Read_Data_Ct = 0x800cef30; // type:data size:0x4
|
__osRdb_Read_Data_Ct = 0x800cef30; // type:data size:0x4
|
||||||
__osPiAccessQueue = 0x800cef48; // type:data size:0x18
|
__osPiAccessQueue = 0x800cef48; // type:data size:0x18
|
||||||
@ -790,8 +793,8 @@ gametext_error_message = 0xb1ff0c61; // type:data
|
|||||||
intro_text = 0xb1fee51e; // type:data
|
intro_text = 0xb1fee51e; // type:data
|
||||||
sample_text = 0xb1fedf1e; // type:data
|
sample_text = 0xb1fedf1e; // type:data
|
||||||
ossceduler_stack = 0x800b09c0; // type:data size:0x1
|
ossceduler_stack = 0x800b09c0; // type:data size:0x1
|
||||||
LeoDiskHandle = 0x800cd618; // type:data size:0x74
|
__CartRomHandle = 0x800cd5a0; // type:data size:0x74
|
||||||
CartRomHandle = 0x800cd5a0; // type:data size:0x74
|
__LeoDiskHandle = 0x800cd618; // type:data size:0x74
|
||||||
gMenuJoyXSign = 0x800a7fc4; // type:data size:0x4
|
gMenuJoyXSign = 0x800a7fc4; // type:data size:0x4
|
||||||
gMenuJoyYSign = 0x800a7fc8; // type:data size:0x4
|
gMenuJoyYSign = 0x800a7fc8; // type:data size:0x4
|
||||||
romfunc_increase_manaMax = 0xb3936414; // type:func
|
romfunc_increase_manaMax = 0xb3936414; // type:func
|
||||||
@ -810,7 +813,7 @@ romfunc_copying_button_press = 0xb3831ba8; // type:func
|
|||||||
romfunc_player_movement = 0xb391a76c; // type:func
|
romfunc_player_movement = 0xb391a76c; // type:func
|
||||||
romfunc_enabling_magic = 0xb3a702d8; // type:func
|
romfunc_enabling_magic = 0xb3a702d8; // type:func
|
||||||
romfunc_incrementing_timers = 0xb38c5730; // type:func
|
romfunc_incrementing_timers = 0xb38c5730; // type:func
|
||||||
osClockRate = 0x8009d884; // type:data
|
osClockRate = 0x80096c40; // type:data
|
||||||
romfunc_zero_speed = 0xb39235f0; // type:func
|
romfunc_zero_speed = 0xb39235f0; // type:func
|
||||||
romfunc_mod_player_HPMax = 0xb3936378; // type:func
|
romfunc_mod_player_HPMax = 0xb3936378; // type:func
|
||||||
Vec3_Int_array = 0x800b51e8; // type:data size:0x30
|
Vec3_Int_array = 0x800b51e8; // type:data size:0x30
|
||||||
|
@ -93,7 +93,7 @@ class BuildNinjaWriter:
|
|||||||
|
|
||||||
self.writer.variable("CC_DEFINES", " ".join([
|
self.writer.variable("CC_DEFINES", " ".join([
|
||||||
"-D_LANGUAGE_C",
|
"-D_LANGUAGE_C",
|
||||||
"-D_FINALROM",
|
#"-D_FINALROM",
|
||||||
"-D_MIPS_SZLONG=32",
|
"-D_MIPS_SZLONG=32",
|
||||||
"-DF3DEX_GBI_2",
|
"-DF3DEX_GBI_2",
|
||||||
]))
|
]))
|
||||||
|
@ -39,6 +39,8 @@ gStrDITask = 0x8009a03c;
|
|||||||
gStrDIBenchmarkTest = 0x8009a048;
|
gStrDIBenchmarkTest = 0x8009a048;
|
||||||
gStrUnknownTaskType = 0x8009a060;
|
gStrUnknownTaskType = 0x8009a060;
|
||||||
__osBaseTimer = 0x800cee90;
|
__osBaseTimer = 0x800cee90;
|
||||||
|
piThreadStack = 0x800CD840;
|
||||||
|
piRamRomThreadStack = 0x800CE9F0;
|
||||||
|
|
||||||
__fstAddress = 0xA4970;
|
__fstAddress = 0xA4970;
|
||||||
__file1Address = 0xA4AA0;
|
__file1Address = 0xA4AA0;
|
Loading…
Reference in New Issue
Block a user