diff options
| author | Derek Hensley <hensley.derek58@gmail.com> | 2025-02-21 16:03:51 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-21 17:03:51 -0700 |
| commit | 8c6ae625aef6d07741cd8925f422f43ae24b198c (patch) | |
| tree | 741fafdf5cf11006a23a9019451082c269fe4922 /lib/ultralib/include | |
| parent | f013a028f42a1b11134bc5f22f28e9f48236b6f0 (diff) | |
Ultralib Update (#233)
* git subrepo pull (merge) lib/ultralib
subrepo:
subdir: "lib/ultralib"
merged: "74f0eee"
upstream:
origin: "git@github.com:decompals/ultralib.git"
branch: "main"
commit: "2717d45"
git-subrepo:
version: "0.4.9"
origin: "https://github.com/ingydotnet/git-subrepo"
commit: "cce3d93"
* New ultralib fixes
* Update some includes in tools
* git subrepo commit (merge) lib/ultralib
subrepo:
subdir: "lib/ultralib"
merged: "3a702eaf"
upstream:
origin: "git@github.com:decompals/ultralib.git"
branch: "main"
commit: "48f9f908"
git-subrepo:
version: "0.4.9"
origin: "git@github.com:ingydotnet/git-subrepo.git"
commit: "ea10886"
* Update warnings file
Diffstat (limited to 'lib/ultralib/include')
34 files changed, 1101 insertions, 19 deletions
diff --git a/lib/ultralib/include/PR/os_libc.h b/lib/ultralib/include/PR/os_libc.h index 35d0e8e..98624ad 100644 --- a/lib/ultralib/include/PR/os_libc.h +++ b/lib/ultralib/include/PR/os_libc.h @@ -80,10 +80,15 @@ extern "C" { /* byte string operations */ - +#ifndef MODERN_CC extern void bcopy(const void *, void *, int); extern int bcmp(const void *, const void *, int); extern void bzero(void *, int); +#else +extern void bcopy(const void *, void *, size_t); +extern int bcmp(const void *, const void *, size_t); +extern void bzero(void *, size_t); +#endif /* Printf */ diff --git a/lib/ultralib/include/PR/rcp.h b/lib/ultralib/include/PR/rcp.h index 47c4b34..2ae8f30 100644 --- a/lib/ultralib/include/PR/rcp.h +++ b/lib/ultralib/include/PR/rcp.h @@ -560,10 +560,11 @@ #define VI_CTRL_DIVOT_ON 0x00010 /* 4: default = on */ #define VI_CTRL_SERRATE_ON 0x00040 /* 6: on if interlaced */ #define VI_CTRL_ANTIALIAS_MASK 0x00300 /* [9:8] anti-alias mode */ -#define VI_CTRL_ANTIALIAS_MODE_1 0x00100 /* Bit [9:8] anti-alias mode */ -#define VI_CTRL_ANTIALIAS_MODE_2 0x00200 /* Bit [9:8] anti-alias mode */ -#define VI_CTRL_ANTIALIAS_MODE_3 0x00300 /* Bit [9:8] anti-alias mode */ -#define VI_CTRL_PIXEL_ADV_MASK 0x01000 /* [15:12] pixel advance mode? */ +#define VI_CTRL_ANTIALIAS_MODE_0 0x00000 /* Bit [9:8] anti-alias mode: AA enabled, resampling enabled, always fetch extra lines */ +#define VI_CTRL_ANTIALIAS_MODE_1 0x00100 /* Bit [9:8] anti-alias mode: AA enabled, resampling enabled, fetch extra lines as-needed */ +#define VI_CTRL_ANTIALIAS_MODE_2 0x00200 /* Bit [9:8] anti-alias mode: AA disabled, resampling enabled, operate as if everything is covered */ +#define VI_CTRL_ANTIALIAS_MODE_3 0x00300 /* Bit [9:8] anti-alias mode: AA disabled, resampling disabled, replicate pixels */ +#define VI_CTRL_PIXEL_ADV_MASK 0x0F000 /* [15:12] pixel advance mode? */ #define VI_CTRL_PIXEL_ADV_1 0x01000 /* Bit [15:12] pixel advance mode? */ #define VI_CTRL_PIXEL_ADV_2 0x02000 /* Bit [15:12] pixel advance mode? */ #define VI_CTRL_PIXEL_ADV_3 0x03000 /* Bit [15:12] pixel advance mode? */ diff --git a/lib/ultralib/include/PRinternal/controller.h b/lib/ultralib/include/PRinternal/controller.h new file mode 100644 index 0000000..e77b38e --- /dev/null +++ b/lib/ultralib/include/PRinternal/controller.h @@ -0,0 +1,289 @@ +#ifndef _CONTROLLER_H +#define _CONTROLLER_H + +#include "PR/os_internal.h" +#include "PR/os_version.h" +#include "PR/rcp.h" + +#include "PRinternal/macros.h" + +#define CHNL_ERR(format) (((format).rxsize & CHNL_ERR_MASK) >> 4) + +typedef struct +{ + /* 0x0 */ u32 ramarray[15]; + /* 0x3C */ u32 pifstatus; +} OSPifRam ALIGNED(0x10); + +typedef struct +{ + /* 0x0 */ u8 dummy; + /* 0x1 */ u8 txsize; + /* 0x2 */ u8 rxsize; + /* 0x3 */ u8 cmd; + /* 0x4 */ u16 button; + /* 0x6 */ s8 stick_x; + /* 0x7 */ s8 stick_y; +} __OSContReadFormat; + +typedef struct +{ + /* 0x0 */ u8 dummy; + /* 0x1 */ u8 txsize; + /* 0x2 */ u8 rxsize; + /* 0x3 */ u8 cmd; + /* 0x4 */ u8 typeh; + /* 0x5 */ u8 typel; + /* 0x6 */ u8 status; + /* 0x7 */ u8 dummy1; +} __OSContRequesFormat; + +typedef struct +{ + /* 0x0 */ u8 txsize; + /* 0x1 */ u8 rxsize; + /* 0x2 */ u8 cmd; + /* 0x3 */ u8 typeh; + /* 0x4 */ u8 typel; + /* 0x5 */ u8 status; +} __OSContRequesFormatShort; + +typedef struct +{ + /* 0x0 */ u8 dummy; + /* 0x1 */ u8 txsize; + /* 0x2 */ u8 rxsize; + /* 0x3 */ u8 cmd; +#if BUILD_VERSION >= VERSION_J + /* 0x4 */ u8 addrh; + /* 0x5 */ u8 addrl; +#else + /* 0x4 */ u16 address; +#endif + /* 0x6 */ u8 data[BLOCKSIZE]; + /* 0x26 */ u8 datacrc; +} __OSContRamReadFormat; + +typedef union { + /* 0x0 */ struct + { + /* 0x0 */ u8 bank; + /* 0x1 */ u8 page; + } inode_t; + /* 0x0 */ u16 ipage; +} __OSInodeUnit; + +typedef struct +{ + /* 0x0 */ u32 game_code; + /* 0x4 */ u16 company_code; + /* 0x6 */ __OSInodeUnit start_page; + /* 0x8 */ u8 status; + /* 0x9 */ s8 reserved; + /* 0xA */ u16 data_sum; + /* 0xC */ u8 ext_name[PFS_FILE_EXT_LEN]; + /* 0x10 */ u8 game_name[PFS_FILE_NAME_LEN]; +} __OSDir; + +typedef struct +{ + /* 0x0 */ __OSInodeUnit inode_page[128]; +} __OSInode; + +typedef struct +{ + /* 0x0 */ u32 repaired; + /* 0x4 */ u32 random; + /* 0x8 */ u64 serial_mid; + /* 0x10 */ u64 serial_low; + /* 0x18 */ u16 deviceid; + /* 0x1A */ u8 banks; + /* 0x1B */ u8 version; + /* 0x1C */ u16 checksum; + /* 0x1E */ u16 inverted_checksum; +} __OSPackId; + +typedef struct +{ + /* 0x0 */ u8 txsize; + /* 0x1 */ u8 rxsize; + /* 0x2 */ u8 cmd; + /* 0x3 */ u8 address; + /* 0x4 */ u8 data[EEPROM_BLOCK_SIZE]; +} __OSContEepromFormat; + +// Joybus commands +//from: http://en64.shoutwiki.com/wiki/SI_Registers_Detailed#CONT_CMD_Usage +#define CONT_CMD_REQUEST_STATUS 0 +#define CONT_CMD_READ_BUTTON 1 +#define CONT_CMD_READ_PAK 2 +#define CONT_CMD_WRITE_PAK 3 +#define CONT_CMD_READ_EEPROM 4 +#define CONT_CMD_WRITE_EEPROM 5 +#define CONT_CMD_READ36_VOICE 9 +#define CONT_CMD_WRITE20_VOICE 10 +#define CONT_CMD_READ2_VOICE 11 +#define CONT_CMD_WRITE4_VOICE 12 +#define CONT_CMD_SWRITE_VOICE 13 +#define CONT_CMD_CHANNEL_RESET 0xFD +#define CONT_CMD_RESET 0xFF + +// Bytes transmitted for each joybus command +#define CONT_CMD_REQUEST_STATUS_TX 1 +#define CONT_CMD_READ_BUTTON_TX 1 +#define CONT_CMD_READ_PAK_TX 3 +#define CONT_CMD_WRITE_PAK_TX 35 +#define CONT_CMD_READ_EEPROM_TX 2 +#define CONT_CMD_WRITE_EEPROM_TX 10 +#define CONT_CMD_READ36_VOICE_TX 3 +#define CONT_CMD_WRITE20_VOICE_TX 23 +#define CONT_CMD_READ2_VOICE_TX 3 +#define CONT_CMD_WRITE4_VOICE_TX 7 +#define CONT_CMD_SWRITE_VOICE_TX 3 +#define CONT_CMD_RESET_TX 1 + +// Bytes received for each joybus command +#define CONT_CMD_REQUEST_STATUS_RX 3 +#define CONT_CMD_READ_BUTTON_RX 4 +#define CONT_CMD_READ_PAK_RX 33 +#define CONT_CMD_WRITE_PAK_RX 1 +#define CONT_CMD_READ_EEPROM_RX 8 +#define CONT_CMD_WRITE_EEPROM_RX 1 +#define CONT_CMD_READ36_VOICE_RX 37 +#define CONT_CMD_WRITE20_VOICE_RX 1 +#define CONT_CMD_READ2_VOICE_RX 3 +#define CONT_CMD_WRITE4_VOICE_RX 1 +#define CONT_CMD_SWRITE_VOICE_RX 1 +#define CONT_CMD_RESET_RX 3 + +#define CONT_CMD_NOP 0xff +#define CONT_CMD_END 0xfe //indicates end of a command +#define CONT_CMD_EXE 1 //set pif ram status byte to this to do a command + +#define DIR_STATUS_EMPTY 0 +#define DIR_STATUS_UNKNOWN 1 +#define DIR_STATUS_OCCUPIED 2 + +// Controller accessory addresses +// https://github.com/joeldipops/TransferBoy/blob/master/docs/TransferPakReference.md + +// Accesory detection +#define CONT_ADDR_DETECT 0x8000 +// Rumble +#define CONT_ADDR_RUMBLE 0xC000 +// Controller Pak +// Transfer Pak +#define CONT_ADDR_GB_POWER 0x8000 // Same as the detection address, but semantically different +#define CONT_ADDR_GB_BANK 0xA000 +#define CONT_ADDR_GB_STATUS 0xB000 + +// Addresses sent to controller accessories are in blocks, not bytes +#define CONT_BLOCKS(x) ((x) / BLOCKSIZE) + +// Block addresses of the above +#define CONT_BLOCK_DETECT CONT_BLOCKS(CONT_ADDR_DETECT) +#define CONT_BLOCK_RUMBLE CONT_BLOCKS(CONT_ADDR_RUMBLE) +#define CONT_BLOCK_GB_POWER CONT_BLOCKS(CONT_ADDR_GB_POWER) +#define CONT_BLOCK_GB_BANK CONT_BLOCKS(CONT_ADDR_GB_BANK) +#define CONT_BLOCK_GB_STATUS CONT_BLOCKS(CONT_ADDR_GB_STATUS) + + +// Transfer pak + +#define GB_POWER_ON 0x84 +#define GB_POWER_OFF 0xFE + + +typedef struct +{ + /* 0x0 */ __OSInode inode; + /* 0x100 */ u8 bank; + /* 0x101 */ u8 map[PFS_INODE_DIST_MAP]; +} __OSInodeCache; + +extern s32 __osEepStatus(OSMesgQueue *, OSContStatus *); +u16 __osSumcalc(u8 *ptr, int length); +s32 __osIdCheckSum(u16 *ptr, u16 *csum, u16 *icsum); +s32 __osRepairPackId(OSPfs *pfs, __OSPackId *badid, __OSPackId *newid); +s32 __osCheckPackId(OSPfs *pfs, __OSPackId *temp); +s32 __osGetId(OSPfs *pfs); +s32 __osCheckId(OSPfs *pfs); +s32 __osPfsRWInode(OSPfs *pfs, __OSInode *inode, u8 flag, u8 bank); +#if BUILD_VERSION >= VERSION_J +s32 __osPfsSelectBank(OSPfs *pfs, u8 bank); +#else +s32 __osPfsSelectBank(OSPfs *pfs); +#endif +s32 __osPfsDeclearPage(OSPfs *pfs, __OSInode *inode, int file_size_in_pages, int *first_page, u8 bank, int *decleared, int *last_page); +#if BUILD_VERSION >= VERSION_J +s32 __osPfsReleasePages(OSPfs *pfs, __OSInode *inode, u8 start_page, u8 bank, __OSInodeUnit *last_page); +#else +s32 __osPfsReleasePages(OSPfs *pfs, __OSInode *inode, u8 start_page, u16 *sum, u8 bank, __OSInodeUnit *last_page, int flag); +#endif +s32 __osBlockSum(OSPfs *pfs, u8 page_no, u16 *sum, u8 bank); +s32 __osContRamRead(OSMesgQueue *mq, int channel, u16 address, u8 *buffer); +s32 __osContRamWrite(OSMesgQueue *mq, int channel, u16 address, u8 *buffer, int force); +void __osContGetInitData(u8 *pattern, OSContStatus *data); +void __osPackRequestData(u8 cmd); +void __osPfsRequestData(u8 cmd); +void __osPfsGetInitData(u8* pattern, OSContStatus* data); +u8 __osContAddressCrc(u16 addr); +u8 __osContDataCrc(u8 *data); +s32 __osPfsGetStatus(OSMesgQueue *queue, int channel); + +extern u8 __osContLastCmd; +extern OSTimer __osEepromTimer; +extern OSMesg __osEepromTimerMsg; +extern OSMesgQueue __osEepromTimerQ; +extern OSPifRam __osEepPifRam; +extern OSPifRam __osContPifRam; +extern OSPifRam __osPfsPifRam; +extern u8 __osMaxControllers; + +//some version of this almost certainly existed since there's plenty of times where it's used right before a return 0 +#define ERRCK(fn) \ + ret = fn; \ + if (ret != 0) \ + return ret + +#if BUILD_VERSION >= VERSION_J + +#define SELECT_BANK(pfs, bank) \ + __osPfsSelectBank((pfs), (bank)) + +#define SET_ACTIVEBANK_TO_ZERO() \ + if (pfs->activebank != 0) \ + { \ + ERRCK(__osPfsSelectBank(pfs, 0)); \ + } (void)0 + +#else + +#define SELECT_BANK(pfs, bank) \ + (pfs->activebank = (bank), __osPfsSelectBank((pfs))) + +#define SET_ACTIVEBANK_TO_ZERO() \ + if (pfs->activebank != 0) \ + { \ + pfs->activebank = 0; \ + ERRCK(__osPfsSelectBank(pfs)); \ + } (void)0 + +#endif + +#define PFS_CHECK_ID() \ + if (__osCheckId(pfs) == PFS_ERR_NEW_PACK) \ + return PFS_ERR_NEW_PACK + +#define PFS_CHECK_STATUS() \ + if ((pfs->status & PFS_INITIALIZED) == 0) \ + return PFS_ERR_INVALID + +#define PFS_GET_STATUS() \ + __osSiGetAccess(); \ + ret = __osPfsGetStatus(queue, channel); \ + __osSiRelAccess(); \ + if (ret != 0) \ + return ret + +#endif diff --git a/lib/ultralib/include/PRinternal/controller_gbpak.h b/lib/ultralib/include/PRinternal/controller_gbpak.h new file mode 100644 index 0000000..db98bd4 --- /dev/null +++ b/lib/ultralib/include/PRinternal/controller_gbpak.h @@ -0,0 +1,8 @@ +#ifndef _CONTROLLER_GBPAK_H +#define _CONTROLLER_GBPAK_H + +extern OSTimer __osGbpakTimer; +extern OSMesg __osGbpakTimerMsg; +extern OSMesgQueue __osGbpakTimerQ; + +#endif diff --git a/lib/ultralib/include/PRinternal/controller_voice.h b/lib/ultralib/include/PRinternal/controller_voice.h new file mode 100644 index 0000000..1b9dee6 --- /dev/null +++ b/lib/ultralib/include/PRinternal/controller_voice.h @@ -0,0 +1,59 @@ +#ifndef CONTROLLER_VOICE_H +#define CONTROLLER_VOICE_H + +#include "PR/ultratypes.h" + +typedef struct { + /* 0x0 */ u8 dummy; + /* 0x1 */ u8 txsize; + /* 0x2 */ u8 rxsize; + /* 0x3 */ u8 cmd; + /* 0x4 */ u8 addrh; + /* 0x5 */ u8 addrl; + /* 0x6 */ u8 data[2]; + /* 0x8 */ u8 datacrc; +} __OSVoiceRead2Format; + +typedef struct { + /* 0x0 */ u8 dummy; + /* 0x1 */ u8 txsize; + /* 0x2 */ u8 rxsize; + /* 0x3 */ u8 cmd; + /* 0x4 */ u8 addrh; + /* 0x5 */ u8 addrl; + /* 0x6 */ u8 data[36]; + /* 0x2A */ u8 datacrc; +} __OSVoiceRead36Format; + +typedef struct { + /* 0x0 */ u8 dummy; + /* 0x1 */ u8 txsize; + /* 0x2 */ u8 rxsize; + /* 0x3 */ u8 cmd; + /* 0x4 */ u8 addrh; + /* 0x5 */ u8 addrl; + /* 0x6 */ u8 data[4]; + /* 0xA */ u8 datacrc; +} __OSVoiceWrite4Format; + +typedef struct { + /* 0x0 */ u8 dummy; + /* 0x1 */ u8 txsize; + /* 0x2 */ u8 rxsize; + /* 0x3 */ u8 cmd; + /* 0x4 */ u8 addrh; + /* 0x5 */ u8 addrl; + /* 0x6 */ u8 data[20]; + /* 0x1A */ u8 datacrc; +} __OSVoiceWrite20Format; + +typedef struct { + /* 0x0 */ u8 txsize; + /* 0x1 */ u8 rxsize; + /* 0x2 */ u8 cmd; + /* 0x3 */ u8 data; + /* 0x4 */ u8 scrc; + /* 0x5 */ u8 datacrc; +} __OSVoiceSWriteFormat; + +#endif // CONTROLLER_VOICE_H diff --git a/lib/ultralib/include/dbgdefs.h b/lib/ultralib/include/PRinternal/dbgdefs.h index f7ead71..f7ead71 100644 --- a/lib/ultralib/include/dbgdefs.h +++ b/lib/ultralib/include/PRinternal/dbgdefs.h diff --git a/lib/ultralib/include/dbgproto.h b/lib/ultralib/include/PRinternal/dbgproto.h index 2eabf9a..e4d3656 100644 --- a/lib/ultralib/include/dbgproto.h +++ b/lib/ultralib/include/PRinternal/dbgproto.h @@ -1,7 +1,7 @@ #ifndef _DBGPROTO_H__ #define _DBGPROTO_H__ -#include "dbgdefs.h" +#include "PRinternal/dbgdefs.h" #define KK_REV 2 diff --git a/lib/ultralib/include/macros.h b/lib/ultralib/include/PRinternal/macros.h index 3057fc8..c84c7ad 100644 --- a/lib/ultralib/include/macros.h +++ b/lib/ultralib/include/PRinternal/macros.h @@ -13,4 +13,12 @@ #define __attribute__(x) #endif +#define ALIGN8(val) (((val) + 7) & ~7) + +#define STACK(stack, size) \ + u64 stack[ALIGN8(size) / sizeof(u64)] + +#define STACK_START(stack) \ + ((u8*)(stack) + sizeof(stack)) + #endif diff --git a/lib/ultralib/include/PRinternal/osint.h b/lib/ultralib/include/PRinternal/osint.h new file mode 100644 index 0000000..b73b609 --- /dev/null +++ b/lib/ultralib/include/PRinternal/osint.h @@ -0,0 +1,58 @@ +#ifndef _OSINT_H +#define _OSINT_H +#include "PR/os_internal.h" +typedef struct __OSEventState +{ + OSMesgQueue *messageQueue; + OSMesg message; +} __OSEventState; +extern struct __osThreadTail +{ + OSThread *next; + OSPri priority; +} __osThreadTail; + +//maybe should be in exceptasm.h? +extern void __osEnqueueAndYield(OSThread **); +extern void __osDequeueThread(OSThread **, OSThread *); +extern void __osEnqueueThread(OSThread **, OSThread *); +extern OSThread *__osPopThread(OSThread **); +extern void __osDispatchThread(void); +extern void __osCleanupThread(void); + +extern void __osSetTimerIntr(OSTime); +extern OSTime __osInsertTimer(OSTimer *); +extern void __osTimerInterrupt(void); +extern u32 __osProbeTLB(void *); +extern int __osSpDeviceBusy(void); + +extern OSThread *__osRunningThread; +extern OSThread *__osActiveQueue; +extern OSThread *__osFaultedThread; +extern OSThread *__osRunQueue; + +extern OSTimer *__osTimerList; +extern OSTimer __osBaseTimer; +extern OSTime __osCurrentTime; +extern u32 __osBaseCounter; +extern u32 __osViIntrCount; +extern u32 __osTimerCounter; +extern u32 __osShutdown; + +extern OSMesgQueue __osProfTimerQ; +extern OSProf *__osProfileList; +extern OSProf *__osProfileListEnd; +extern u32 __osProfileOverflowBin; + +extern __OSEventState __osEventStateTab[]; + + +extern void __osTimerServicesInit(void); +extern s32 __osAiDeviceBusy(void); +extern int __osDpDeviceBusy(void); + +#ifndef _FINALROM +extern void* __printfunc; +#endif + +#endif diff --git a/lib/ultralib/include/PRinternal/piint.h b/lib/ultralib/include/PRinternal/piint.h new file mode 100644 index 0000000..50a0858 --- /dev/null +++ b/lib/ultralib/include/PRinternal/piint.h @@ -0,0 +1,197 @@ +#ifndef _PIINT_H_ +#define _PIINT_H_ + +#include "PR/os_internal.h" +#include "PR/rcp.h" + +//https://github.com/LuigiBlood/64dd/wiki/Memory-Map + +#define LEO_BASE_REG 0x05000000 + +#define LEO_CMD (LEO_BASE_REG + 0x508) +#define LEO_STATUS (LEO_BASE_REG + 0x508) + +#define LEO_BM_CTL (LEO_BASE_REG + 0x510) +#define LEO_BM_STATUS (LEO_BASE_REG + 0x510) + +#define LEO_SEQ_CTL (LEO_BASE_REG + 0x518) +#define LEO_SEQ_STATUS (LEO_BASE_REG + 0x518) + +#define LEO_C2_BUFF (LEO_BASE_REG + 0x000) //C2 Sector Buffer +#define LEO_SECTOR_BUFF (LEO_BASE_REG + 0x400) //Data Sector Buffer +#define LEO_DATA (LEO_BASE_REG + 0x500) //Data +#define LEO_MISC_REG (LEO_BASE_REG + 0x504) //Misc Register +#define LEO_CUR_TK (LEO_BASE_REG + 0x50C) //Current Track +#define LEO_ERR_SECTOR (LEO_BASE_REG + 0x514) //Sector Error Status +#define LEO_CUR_SECTOR (LEO_BASE_REG + 0x51C) //Current Sector +#define LEO_HARD_RESET (LEO_BASE_REG + 0x520) //Hard Reset +#define LEO_C1_S0 (LEO_BASE_REG + 0x524) //C1 +#define LEO_HOST_SECBYTE (LEO_BASE_REG + 0x528) //Sector Size (in bytes) +#define LEO_C1_S2 (LEO_BASE_REG + 0x52C) //C1 +#define LEO_SEC_BYTE (LEO_BASE_REG + 0x530) //Sectors per Block, Full Size +#define LEO_C1_S4 (LEO_BASE_REG + 0x534) //C1 +#define LEO_C1_S6 (LEO_BASE_REG + 0x538) //C1 +#define LEO_CUR_ADDR (LEO_BASE_REG + 0x53C) //Current Address? +#define LEO_ID_REG (LEO_BASE_REG + 0x540) //ID +#define LEO_TEST_REG (LEO_BASE_REG + 0x544) //Test Read +#define LEO_TEST_PIN_SEL (LEO_BASE_REG + 0x548) //Test Write +#define LEO_RAM_ADDR (LEO_BASE_REG + 0x580) //Microsequencer RAM + +#define LEO_STATUS_PRESENCE_MASK 0xFFFF + +#define LEO_STATUS_DATA_REQUEST 0x40000000 +#define LEO_STATUS_C2_TRANSFER 0x10000000 +#define LEO_STATUS_BUFFER_MANAGER_ERROR 0x08000000 +#define LEO_STATUS_BUFFER_MANAGER_INTERRUPT 0x04000000 +#define LEO_STATUS_MECHANIC_INTERRUPT 0x02000000 +#define LEO_STATUS_DISK_PRESENT 0x01000000 +#define LEO_STATUS_BUSY_STATE 0x00800000 +#define LEO_STATUS_RESET_STATE 0x00400000 +#define LEO_STATUS_MOTOR_NOT_SPINNING 0x00100000 +#define LEO_STATUS_HEAD_RETRACTED 0x00080000 +#define LEO_STATUS_WRITE_PROTECT_ERROR 0x00040000 +#define LEO_STATUS_MECHANIC_ERROR 0x00020000 +#define LEO_STATUS_DISK_CHANGE 0x00010000 + +#define LEO_STATUS_MODE_MASK (LEO_STATUS_MOTOR_NOT_SPINNING | LEO_STATUS_HEAD_RETRACTED) +#define LEO_STATUS_MODE_SLEEP (LEO_STATUS_MOTOR_NOT_SPINNING | LEO_STATUS_HEAD_RETRACTED) +#define LEO_STATUS_MODE_STANDBY (LEO_STATUS_HEAD_RETRACTED) +#define LEO_STATUS_MODE_ACTIVE 0 + +#define LEO_CUR_TK_INDEX_LOCK 0x60000000 + +#define LEO_BM_STATUS_RUNNING 0x80000000 //Running +#define LEO_BM_STATUS_ERROR 0x04000000 //Error +#define LEO_BM_STATUS_MICRO 0x02000000 //Micro Status? +#define LEO_BM_STATUS_BLOCK 0x01000000 //Block Transfer +#define LEO_BM_STATUS_C1CORRECTION 0x00800000 //C1 Correction +#define LEO_BM_STATUS_C1DOUBLE 0x00400000 //C1 Double +#define LEO_BM_STATUS_C1SINGLE 0x00200000 //C1 Single +#define LEO_BM_STATUS_C1ERROR 0x00010000 //C1 Error + +#define LEO_BM_CTL_START 0x80000000 //Start Buffer Manager +#define LEO_BM_CTL_MODE 0x40000000 //Buffer Manager Mode +#define LEO_BM_CTL_IMASK 0x20000000 //BM Interrupt Mask +#define LEO_BM_CTL_RESET 0x10000000 //Buffer Manager Reset +#define LEO_BM_CTL_DISABLE_OR 0x08000000 //Disable OR Check? +#define LEO_BM_CTL_DISABLE_C1 0x04000000 //Disable C1 Correction +#define LEO_BM_CTL_BLOCK 0x02000000 //Block Transfer +#define LEO_BM_CTL_CLR_MECHANIC_INTR 0x01000000 //Mechanic Interrupt Reset + +#define LEO_BM_CTL_CONTROL_MASK 0xFF000000 +#define LEO_BM_CTL_SECTOR_MASK 0x00FF0000 +#define LEO_BM_CTL_SECTOR_SHIFT 16 + +#define LEO_CMD_TYPE_0 0 //TODO: name +#define LEO_CMD_TYPE_1 1 //TODO: name +#define LEO_CMD_TYPE_2 2 //TODO: name + +#define LEO_ERROR_GOOD 0 +#define LEO_ERROR_4 4 //maybe busy? +#define LEO_ERROR_22 22 // +#define LEO_ERROR_23 23 //unrecovered read error? +#define LEO_ERROR_24 24 //no reference position found? +#define LEO_ERROR_29 29 // + +extern OSDevMgr __osPiDevMgr; +extern OSPiHandle *__osCurrentHandle[]; +extern OSPiHandle CartRomHandle; +extern OSPiHandle LeoDiskHandle; +extern OSMesgQueue __osPiAccessQueue; +extern u32 __osPiAccessQueueEnabled; + +// These symbols were all renamed in 2.0J. +#if BUILD_VERSION < VERSION_J +#define __osEPiRawStartDma osEPiRawStartDma +#define __osEPiRawReadIo osEPiRawReadIo +#define __osEPiRawWriteIo osEPiRawWriteIo +#define __osPiRawStartDma osPiRawStartDma +#define __osPiRawWriteIo osPiRawWriteIo +#define __osPiRawReadIo osPiRawReadIo +#endif + +int __osPiDeviceBusy(void); +void __osDevMgrMain(void *); +void __osPiCreateAccessQueue(void); +void __osPiRelAccess(void); +void __osPiGetAccess(void); +s32 __osPiRawStartDma(s32, u32 , void *, u32 ); +s32 __osPiRawWriteIo(u32, u32); +s32 __osPiRawReadIo(u32, u32 *); +s32 __osEPiRawWriteIo(OSPiHandle *, u32 , u32); +s32 __osEPiRawReadIo(OSPiHandle *, u32 , u32 *); +s32 __osEPiRawStartDma(OSPiHandle *, s32 , u32 , void *, u32 ); +OSMesgQueue *osPiGetCmdQueue(void); + +#define WAIT_ON_IOBUSY(stat) \ + { \ + stat = IO_READ(PI_STATUS_REG); \ + while (stat & (PI_STATUS_IO_BUSY | PI_STATUS_DMA_BUSY)) \ + stat = IO_READ(PI_STATUS_REG); \ + } (void)0 + +#define UPDATE_REG(pihandle, reg, var) \ + if (cHandle->var != pihandle->var) \ + IO_WRITE(reg, pihandle->var) + +#if BUILD_VERSION >= VERSION_J + +#define EPI_SYNC(pihandle, stat, domain) \ + \ + WAIT_ON_IOBUSY(stat); \ + \ + domain = pihandle->domain; \ + if (__osCurrentHandle[domain]->type != pihandle->type) \ + { \ + OSPiHandle *cHandle = __osCurrentHandle[domain]; \ + if (domain == PI_DOMAIN1) \ + { \ + UPDATE_REG(pihandle, PI_BSD_DOM1_LAT_REG, latency); \ + UPDATE_REG(pihandle, PI_BSD_DOM1_PGS_REG, pageSize); \ + UPDATE_REG(pihandle, PI_BSD_DOM1_RLS_REG, relDuration); \ + UPDATE_REG(pihandle, PI_BSD_DOM1_PWD_REG, pulse); \ + } \ + else \ + { \ + UPDATE_REG(pihandle, PI_BSD_DOM2_LAT_REG, latency); \ + UPDATE_REG(pihandle, PI_BSD_DOM2_PGS_REG, pageSize); \ + UPDATE_REG(pihandle, PI_BSD_DOM2_RLS_REG, relDuration); \ + UPDATE_REG(pihandle, PI_BSD_DOM2_PWD_REG, pulse); \ + } \ + cHandle->type = pihandle->type; \ + cHandle->latency = pihandle->latency; \ + cHandle->pageSize = pihandle->pageSize; \ + cHandle->relDuration = pihandle->relDuration; \ + cHandle->pulse = pihandle->pulse; \ + }(void)0 + +#else + +#define EPI_SYNC(pihandle, stat, domain) \ + \ + WAIT_ON_IOBUSY(stat); \ + \ + domain = pihandle->domain; \ + if (__osCurrentHandle[domain] != pihandle) \ + { \ + OSPiHandle *cHandle = __osCurrentHandle[domain]; \ + if (domain == PI_DOMAIN1) \ + { \ + UPDATE_REG(pihandle, PI_BSD_DOM1_LAT_REG, latency); \ + UPDATE_REG(pihandle, PI_BSD_DOM1_PGS_REG, pageSize); \ + UPDATE_REG(pihandle, PI_BSD_DOM1_RLS_REG, relDuration); \ + UPDATE_REG(pihandle, PI_BSD_DOM1_PWD_REG, pulse); \ + } \ + else \ + { \ + UPDATE_REG(pihandle, PI_BSD_DOM2_LAT_REG, latency); \ + UPDATE_REG(pihandle, PI_BSD_DOM2_PGS_REG, pageSize); \ + UPDATE_REG(pihandle, PI_BSD_DOM2_RLS_REG, relDuration); \ + UPDATE_REG(pihandle, PI_BSD_DOM2_PWD_REG, pulse); \ + } \ + __osCurrentHandle[domain] = pihandle; \ + }(void)0 + +#endif + +#endif diff --git a/lib/ultralib/include/PRinternal/rmonint.h b/lib/ultralib/include/PRinternal/rmonint.h new file mode 100644 index 0000000..714a63f --- /dev/null +++ b/lib/ultralib/include/PRinternal/rmonint.h @@ -0,0 +1,169 @@ +#ifndef _RMONINT_H +#define _RMONINT_H + +#include "PRinternal/dbgproto.h" +#include "PR/os_internal.h" + +/* mips */ + +#define MIPS_LWC2_OPCODE 50 +#define MIPS_SWC2_OPCODE 58 + +#define MIPS_LW_OPCODE 35 +#define MIPS_SW_OPCODE 43 + +#define MIPS_BREAK_OPCODE 0xD +#define MIPS_BREAK_MASK 0xFC00003F + +#define MIPS_BREAK(code) \ + ((((code) & 0xFFFFF) << 6) | MIPS_BREAK_OPCODE) + +/* R4300 General Purpose Register Indices */ +#define GREG_IDX_ZERO 0 +#define GREG_IDX_AT 1 +#define GREG_IDX_T9 25 +#define GREG_IDX_K0 26 +#define GREG_IDX_GP 28 +#define GREG_IDX_RA 31 +#define GREG_IDX_LO 32 +#define GREG_IDX_HI 33 +#define GREG_IDX_CAUSE 34 +#define GREG_IDX_PC 35 +#define GREG_IDX_SR 36 + +/* RSP Scalar Register Indices */ +#define SREG_IDX_ZERO 0 +#define SREG_IDX_RA 31 +#define SREG_IDX_DRAM_ADDR (32 + 0) +#define SREG_IDX_MEM_ADDR (32 + 1) +#define SREG_IDX_RD_LEN (32 + 2) +#define SREG_IDX_PC (32 + 3) +#define SREG_IDX_WR_LEN (32 + 4) +#define SREG_IDX_STATUS (32 + 5) +#define SREG_IDX_DMA_FULL (32 + 6) +#define SREG_IDX_DMA_BUSY (32 + 7) + +/* RSP Vector Register Properties */ +#define VREG_NUM 32 +#define VREG_SIZE 0x10 + +/* rmon */ + +#define RMON_MESG_CPU_BREAK 2 +#define RMON_MESG_SP_BREAK 4 +#define RMON_MESG_FAULT 8 + +#define RMON_CPU 0 +#define RMON_RSP 1 + +/* "thread id" for rsp */ +#define RMON_TID_RSP 1000 +/* "thread priority" for rsp */ +#define RMON_PRI_RSP 42 + +/* "thread id" for no thread running */ +#define RMON_TID_NOTHREAD 1003 + +#define RMON_PID_CPU 1002 +#define RMON_PID_RSP 1001 + +/* Largest serviceable read/write memory request */ +#define RMON_MAX_XFER_SIZE 1024 + +/* rmonmain */ + +void __rmonSendHeader(KKHeader* const block, u32 blockSize, u32 type); +void __rmonSendReply(KKHeader* const block, u32 blockSize, u32 replyType); +void __rmonSendData(char* const block, unsigned int blockSize); + +extern int __rmonActive; + +/* rmonmisc */ + +void __rmonInit(void); +void __rmonPanic(void); + +extern OSMesgQueue __rmonMQ; + +/* rmonmem */ + +void __rmonWriteWordTo(u32* addr, u32 val); +u32 __rmonReadWordAt(u32* addr); +void __rmonMemcpy(u8* dest, u8* srce, u32 count); +void __rmonCopyWords(u32* dest, u32* srce, u32 count); + +extern u8 __rmonUtilityBuffer[]; + +/* rmonsio */ + +void __rmonSendFault(OSThread* thread); +void __rmonIOflush(void); +void __rmonIOputw(u32 word); +void __rmonIOhandler(void); + +extern void* __osRdb_DbgRead_Buf; +extern u8 rmonRdbReadBuf[]; + +/* rmonrcp */ + +int __rmonRCPrunning(void); +void __rmonIdleRCP(void); +void __rmonStepRCP(void); +void __rmonRunRCP(void); + +/* rmonbrk */ + +u32 __rmonGetBranchTarget(int method, int thread, char* addr); +int __rmonSetSingleStep(int thread, u32* instptr); +void __rmonGetExceptionStatus(KKStatusEvent* reply); +void __rmonHitBreak(void); +void __rmonHitSpBreak(void); +void __rmonHitCpuFault(void); + +extern u8 __rmonRcpAtBreak; + +/* rmonregs */ + +u32 __rmonGetRegisterContents(int method, int threadNumber, int regNumber); + +/* rmontask */ + +void __rmonMaskIdleThreadInts(void); +OSThread* __rmonGetTCB(int threadNumber); +int __rmonStopUserThreads(int whichThread); +int __rmonGetThreadStatus(int method, int id, KKStatusEvent* reply); + +/* rmoncmds */ + +int __rmonExecute(KKHeader* request); + +/* commands */ + +typedef int (*FUNPTR)(); + +int __rmonLoadProgram(KKHeader* req); +int __rmonListProcesses(KKHeader* req); +int __rmonGetExeName(KKHeader* req); +int __rmonListThreads(KKHeader* req); +int __rmonThreadStatus(KKHeader* req); +int __rmonStopThread(KKHeader* req); +int __rmonRunThread(KKHeader* req); +int __rmonSetFault(KKHeader* req); +int __rmonGetRegionCount(KKHeader* req); +int __rmonGetRegions(KKHeader* req); +int __rmonGetGRegisters(KKHeader* req); +int __rmonSetGRegisters(KKHeader* req); +int __rmonGetFRegisters(KKHeader* req); +int __rmonSetFRegisters(KKHeader* req); +int __rmonReadMem(KKHeader* req); +int __rmonWriteMem(KKHeader* req); +int __rmonSetBreak(KKHeader* req); +int __rmonClearBreak(KKHeader* req); +int __rmonListBreak(KKHeader* req); +int __rmonSetComm(KKHeader* req); +int __rmonGetSRegs(KKHeader* req); +int __rmonSetSRegs(KKHeader* req); +int __rmonGetVRegs(KKHeader* req); +int __rmonSetVRegs(KKHeader* req); + +#endif diff --git a/lib/ultralib/include/PRinternal/siint.h b/lib/ultralib/include/PRinternal/siint.h new file mode 100644 index 0000000..636a87f --- /dev/null +++ b/lib/ultralib/include/PRinternal/siint.h @@ -0,0 +1,15 @@ +#ifndef _SIINT_H +#define _SIINT_H + +#include "PR/os_internal.h" +#include "PR/rcp.h" + +extern s32 __osEepromRead16K; +extern u8 __osPfsInodeCacheBank; + +void __osSiGetAccess(void); +void __osSiRelAccess(void); +int __osSiDeviceBusy(void); +void __osSiCreateAccessQueue(void); + +#endif diff --git a/lib/ultralib/include/PRinternal/viint.h b/lib/ultralib/include/PRinternal/viint.h new file mode 100644 index 0000000..b3c3943 --- /dev/null +++ b/lib/ultralib/include/PRinternal/viint.h @@ -0,0 +1,67 @@ +#ifndef _VIINT_H +#define _VIINT_H +#include "PR/os_internal.h" + +#define OS_TV_TYPE_PAL 0 +#define OS_TV_TYPE_NTSC 1 +#define OS_TV_TYPE_MPAL 2 + +#define VI_STATE_MODE_UPDATED 0x01 +#define VI_STATE_XSCALE_UPDATED 0x02 +#define VI_STATE_YSCALE_UPDATED 0x04 +#define VI_STATE_CTRL_UPDATED 0x08 // related to control regs changing +#define VI_STATE_BUFFER_UPDATED 0x10 // swap buffer +#define VI_STATE_BLACK 0x20 // probably related to a black screen +#define VI_STATE_REPEATLINE 0x40 // repeat line? +#define VI_STATE_FADE 0x80 // fade + +#define VI_SCALE_MASK 0xfff //see rcp scale_x/scale_y +#define VI_2_10_FPART_MASK 0x3ff +#define VI_SUBPIXEL_SH 0x10 + +#define BURST(hsync_width, color_width, vsync_width, color_start) \ + (((u32)(hsync_width) & 0xFF) | (((u32)(color_width) & 0xFF) << 8) | (((u32)(vsync_width) & 0xF) << 16) | (((u32)(color_start) & 0xFFFF) << 20)) +#define WIDTH(v) (v) +#define VSYNC(v) (v) +#define HSYNC(duration, leap) (((u32)(leap) << 16) | ((u32)(duration) & 0xFFFF)) +#define LEAP(upper, lower) (((u32)(upper) << 16) | ((u32)(lower) & 0xFFFF)) +#define START(start, end) (((u32)(start) << 16) | ((u32)(end) & 0xFFFF)) + +#define FTOFIX(val, i, f) ((u32)((val) * (f32)(1 << (f))) & ((1 << ((i) + (f))) - 1)) + +#define F210(val) FTOFIX(val, 2, 10) +#define SCALE(scaleup, off) (F210((1.0f / (f32)(scaleup))) | (F210((f32)(off)) << 16)) + +#define VCURRENT(v) v //seemingly unused +#define ORIGIN(v) v +#define VINTR(v) v +#define HSTART START + +typedef struct +{ + /* 0x0 */ f32 factor; + /* 0x4 */ u16 offset; + /* 0x8 */ u32 scale; +} __OSViScale; + +typedef struct +{ + /* 0x0 */ u16 state; + /* 0x2 */ u16 retraceCount; + /* 0x4 */ void *framep; + /* 0x8 */ OSViMode *modep; + /* 0xC */ u32 control; + /* 0x10 */ OSMesgQueue *msgq; + /* 0x14 */ OSMesg msg; + /* 0x18 */ __OSViScale x; + /* 0x24 */ __OSViScale y; +} __OSViContext; // 0x30 bytes + +void __osViSwapContext(void); +extern __OSViContext *__osViCurr; +extern __OSViContext *__osViNext; +extern u32 __additional_scanline; +__OSViContext *__osViGetCurrentContext(void); +void __osViInit(void); +extern OSDevMgr __osViDevMgr; +#endif diff --git a/lib/ultralib/include/gcc/math.h b/lib/ultralib/include/compiler/gcc/math.h index 3e93ceb..3e93ceb 100644 --- a/lib/ultralib/include/gcc/math.h +++ b/lib/ultralib/include/compiler/gcc/math.h diff --git a/lib/ultralib/include/gcc/memory.h b/lib/ultralib/include/compiler/gcc/memory.h index edfff5e..edfff5e 100644 --- a/lib/ultralib/include/gcc/memory.h +++ b/lib/ultralib/include/compiler/gcc/memory.h diff --git a/lib/ultralib/include/gcc/sgidefs.h b/lib/ultralib/include/compiler/gcc/sgidefs.h index 56567e8..56567e8 100644 --- a/lib/ultralib/include/gcc/sgidefs.h +++ b/lib/ultralib/include/compiler/gcc/sgidefs.h diff --git a/lib/ultralib/include/gcc/stdarg.h b/lib/ultralib/include/compiler/gcc/stdarg.h index af337f6..af337f6 100644 --- a/lib/ultralib/include/gcc/stdarg.h +++ b/lib/ultralib/include/compiler/gcc/stdarg.h diff --git a/lib/ultralib/include/gcc/stdio.h b/lib/ultralib/include/compiler/gcc/stdio.h index 3e93ceb..3e93ceb 100644 --- a/lib/ultralib/include/gcc/stdio.h +++ b/lib/ultralib/include/compiler/gcc/stdio.h diff --git a/lib/ultralib/include/gcc/stdlib.h b/lib/ultralib/include/compiler/gcc/stdlib.h index 98f8a2e..98f8a2e 100644 --- a/lib/ultralib/include/gcc/stdlib.h +++ b/lib/ultralib/include/compiler/gcc/stdlib.h diff --git a/lib/ultralib/include/gcc/string.h b/lib/ultralib/include/compiler/gcc/string.h index d82e1f1..d82e1f1 100644 --- a/lib/ultralib/include/gcc/string.h +++ b/lib/ultralib/include/compiler/gcc/string.h diff --git a/lib/ultralib/include/ido/math.h b/lib/ultralib/include/compiler/ido/math.h index 3e93ceb..3e93ceb 100644 --- a/lib/ultralib/include/ido/math.h +++ b/lib/ultralib/include/compiler/ido/math.h diff --git a/lib/ultralib/include/ido/memory.h b/lib/ultralib/include/compiler/ido/memory.h index edfff5e..edfff5e 100644 --- a/lib/ultralib/include/ido/memory.h +++ b/lib/ultralib/include/compiler/ido/memory.h diff --git a/lib/ultralib/include/ido/stdarg.h b/lib/ultralib/include/compiler/ido/stdarg.h index 62f68e0..62f68e0 100644 --- a/lib/ultralib/include/ido/stdarg.h +++ b/lib/ultralib/include/compiler/ido/stdarg.h diff --git a/lib/ultralib/include/ido/stdio.h b/lib/ultralib/include/compiler/ido/stdio.h index 3e93ceb..3e93ceb 100644 --- a/lib/ultralib/include/ido/stdio.h +++ b/lib/ultralib/include/compiler/ido/stdio.h diff --git a/lib/ultralib/include/ido/stdlib.h b/lib/ultralib/include/compiler/ido/stdlib.h index 98f8a2e..98f8a2e 100644 --- a/lib/ultralib/include/ido/stdlib.h +++ b/lib/ultralib/include/compiler/ido/stdlib.h diff --git a/lib/ultralib/include/ido/string.h b/lib/ultralib/include/compiler/ido/string.h index d82e1f1..d82e1f1 100644 --- a/lib/ultralib/include/ido/string.h +++ b/lib/ultralib/include/compiler/ido/string.h diff --git a/lib/ultralib/include/compiler/modern_gcc/math.h b/lib/ultralib/include/compiler/modern_gcc/math.h new file mode 100644 index 0000000..3e93ceb --- /dev/null +++ b/lib/ultralib/include/compiler/modern_gcc/math.h @@ -0,0 +1 @@ +// Nothing needed here diff --git a/lib/ultralib/include/compiler/modern_gcc/memory.h b/lib/ultralib/include/compiler/modern_gcc/memory.h new file mode 100644 index 0000000..edfff5e --- /dev/null +++ b/lib/ultralib/include/compiler/modern_gcc/memory.h @@ -0,0 +1,23 @@ +#ifndef _MEMORY_H +#define _MEMORY_H +/* + memory.h +*/ + +#ifndef _SIZE_T_DEF +#define _SIZE_T_DEF +typedef unsigned size_t; +#endif + +void *memccpy(void *,void *,int,size_t); +void *memchr(void *,int,size_t); +int memcmp(const void *,const void *,size_t); +void *memcpy(void *,const void *,size_t); +int memicmp(void *,void *,size_t); +void *memmove(void *,void *,size_t); +void *memset(void *,int,size_t); + +void movmem(void *,void *,unsigned); +void setmem(void *,unsigned,int); + +#endif diff --git a/lib/ultralib/include/compiler/modern_gcc/sgidefs.h b/lib/ultralib/include/compiler/modern_gcc/sgidefs.h new file mode 100644 index 0000000..56567e8 --- /dev/null +++ b/lib/ultralib/include/compiler/modern_gcc/sgidefs.h @@ -0,0 +1,44 @@ +/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ralf Baechle <ralf@gnu.org>. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _SGIDEFS_H +#define _SGIDEFS_H 1 + +/* + * Definitions for the ISA level + */ +#define _MIPS_ISA_MIPS1 1 +#define _MIPS_ISA_MIPS2 2 +#define _MIPS_ISA_MIPS3 3 +#define _MIPS_ISA_MIPS4 4 +#define _MIPS_ISA_MIPS5 5 + +/* + * Subprogram calling convention + * + * At the moment only _MIPS_SIM_ABI32 is in use. This will change rsn. + * Until GCC 2.8.0 is released don't rely on this definitions because the + * 64bit code is essentially using the 32bit interface model just with + * 64bit registers. + */ +#define _MIPS_SIM_ABI32 1 +#define _MIPS_SIM_NABI32 2 +#define _MIPS_SIM_ABI64 3 + +#endif /* sgidefs.h */ diff --git a/lib/ultralib/include/compiler/modern_gcc/stdarg.h b/lib/ultralib/include/compiler/modern_gcc/stdarg.h new file mode 100644 index 0000000..1f36b0a --- /dev/null +++ b/lib/ultralib/include/compiler/modern_gcc/stdarg.h @@ -0,0 +1,9 @@ +#ifndef _STDARG_H +#define _STDARG_H + +#define va_list __builtin_va_list +#define va_start __builtin_va_start +#define va_arg __builtin_va_arg +#define va_end __builtin_va_end + +#endif diff --git a/lib/ultralib/include/compiler/modern_gcc/stdio.h b/lib/ultralib/include/compiler/modern_gcc/stdio.h new file mode 100644 index 0000000..3e93ceb --- /dev/null +++ b/lib/ultralib/include/compiler/modern_gcc/stdio.h @@ -0,0 +1 @@ +// Nothing needed here diff --git a/lib/ultralib/include/compiler/modern_gcc/stdlib.h b/lib/ultralib/include/compiler/modern_gcc/stdlib.h new file mode 100644 index 0000000..98f8a2e --- /dev/null +++ b/lib/ultralib/include/compiler/modern_gcc/stdlib.h @@ -0,0 +1,81 @@ +#ifndef _STDLIB_H +#define _STDLIB_H +/* + stdlib.h +*/ + +#ifndef _SIZE_T_DEF +#define _SIZE_T_DEF +typedef unsigned size_t; +#endif + +#ifndef _DIV_T_DEF +#define _DIV_T_DEF +typedef struct DIV_T { + int quot; + int rem; +} div_t; +#endif + +#ifndef _LDIV_T_DEF +#define _LDIV_T_DEF +typedef struct LDIV_T { + long quot; + long rem; +} ldiv_t; +#endif + +#ifndef _LLDIV_T_DEF +#define _LLDIV_T_DEF +typedef struct lldiv_t +{ + long long quot; + long long rem; +} lldiv_t; +#endif + +#ifndef NULL +#define NULL 0 +#endif + +#define _max(a,b) (((a) > (b)) ? (a) : (b)) +#define _min(a,b) (((a) < (b)) ? (a) : (b)) + +#define RAND_MAX 32767 + +int rand(void); +void srand(unsigned); + +int abs(int); +long labs(long); + +div_t div(int,int); +ldiv_t ldiv(long,long); +lldiv_t lldiv(long long, long long); + +int atoi(const char *); +long atol(const char *); + +long strtol(const char *,char **,int); +unsigned long strtoul(const char *,char **,int); + +char *itoa(int,char *,int); +char *ltoa(long,char *,int); +char *ultoa(unsigned long,char *,int); + +double atof(const char *); +double strtod(const char *,char **); + +void qsort(void *,size_t,size_t,int (*)(const void *,const void *)); +void *bsearch(const void *,const void *,size_t,size_t,int (*)(const void *,const void *)); + +void *malloc(size_t); +void *calloc(size_t,size_t); +void *realloc(void *,size_t); +void free(void *); + +void exit(int); + +void abort(void); + +#endif diff --git a/lib/ultralib/include/compiler/modern_gcc/string.h b/lib/ultralib/include/compiler/modern_gcc/string.h new file mode 100644 index 0000000..d82e1f1 --- /dev/null +++ b/lib/ultralib/include/compiler/modern_gcc/string.h @@ -0,0 +1,42 @@ +#ifndef _STRING_H +#define _STRING_H +/* + string.h +*/ + +#ifndef _SIZE_T_DEF +#define _SIZE_T_DEF +typedef unsigned size_t; +#endif + +#include "memory.h" + +char *stpcpy(char *,const char *); +char *strcat(char *,const char *); +char *strchr(const char *,int); +int strcmp(const char *,const char *); +char *strcpy(char *,const char *); +size_t strcspn(const char *,const char *); +char *strdup(const char *); +char *strerror(int); +int stricmp(const char *,const char *); +size_t strlen(const char *); +char *strlwr(char *); +char *strncat(char *,const char *,size_t); +int strncmp(const char *,const char *,size_t); +char *strncpy(char *,const char *,size_t); +int strnicmp(const char *,const char *,size_t); +char *strnset(char *,int,size_t); +char *strpbrk(const char *,const char *); +char *strrchr(const char *,int); +char *strrev(char *); +char *strset(char *,int); +size_t strspn(const char *,const char *); +char *strstr(const char *,const char *); +char *strtok(char *,const char *); +char *strupr(char *); + +#define strcmpi(s1,s2) stricmp(s1,s2) +#define strncmpi(s1,s2,n) strnicmp(s1,s2,n) + +#endif diff --git a/lib/ultralib/include/sys/asm.h b/lib/ultralib/include/sys/asm.h index 97f8fb2..60e6ccd 100644 --- a/lib/ultralib/include/sys/asm.h +++ b/lib/ultralib/include/sys/asm.h @@ -83,32 +83,37 @@ extern "C" { #endif +#define NOP \ + .set noreorder ;\ + nop ;\ + .set reorder -#define STAY1(stmnt) \ +#define CACHE(op, reg) \ .set noreorder ;\ - stmnt ;\ + cache op, reg ;\ .set reorder -#define STAY2(stmnt, arg1) \ - .set noreorder ;\ - stmnt, arg1 ;\ +#define MFC0(reg, op) \ + .set noreorder ;\ + mfc0 reg, op ;\ .set reorder -#define STAY3(stmnt, arg1, arg2) \ - .set noreorder ;\ - stmnt, arg1, arg2 ;\ +#define MTC0(reg, op) \ + .set noreorder ;\ + mtc0 reg, op ;\ .set reorder -#define NOP \ - .set noreorder ;\ - nop ;\ +#define CFC1(reg, op) \ + .set noreorder ;\ + cfc1 reg, op ;\ .set reorder -#define CACHE(op, reg) \ +#define CTC1(reg, op) \ .set noreorder ;\ - cache op, reg ;\ + ctc1 reg, op ;\ .set reorder + #ifdef __cplusplus } #endif |
