Libultra headers and some decomp (#14)

* lib is ultra

* it just keeps going

* math names

* format
This commit is contained in:
petrie911
2023-10-29 18:19:30 -03:00
committed by GitHub
parent 854cadfa16
commit 4311c670c3
32 changed files with 1185 additions and 262 deletions
+263 -24
View File
@@ -1,21 +1,119 @@
#ifndef PR_CONTROLLER_H
#define PR_CONTROLLER_H
#ifndef _CONTROLLER_H
#define _CONTROLLER_H
#include "global.h"
#include "PR/os.h"
#include "PR/os_internal.h"
#include "PR/os_version.h"
#include "PR/rcp.h"
typedef struct {
/* 0x00 */ u8 align;
/* 0x01 */ u8 txsize;
/* 0x02 */ u8 rxsize;
/* 0x03 */ u8 poll;
/* 0x04 */ u8 typeh;
/* 0x05 */ u8 typel;
/* 0x06 */ u8 status;
/* 0x07 */ u8 align1;
} __OSContRequestHeader; // size = 0x8
//should go somewhere else but
#define ARRLEN(x) ((s32)(sizeof(x) / sizeof(x[0])))
#define CHNL_ERR(format) (((format).rxsize & CHNL_ERR_MASK) >> 4)
typedef struct
{
/* 0x0 */ u32 ramarray[15];
/* 0x3C */ u32 pifstatus;
} OSPifRam;
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
@@ -30,22 +128,163 @@ typedef struct {
#define CONT_CMD_CHANNEL_RESET 0xFD
#define CONT_CMD_RESET 0xFF
#define UNK(n) 500000 * (u64)(n) / 1000000
// 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
{
u32 ramarray[15];
u32 pifstatus;
} OSPifRam;
/* 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 u32 __osContinitialized;
extern u8 __osMaxControllers;
extern u8 __osContLastCmd;
extern OSPifRam __osContPifRam;
extern OSMesgQueue __osEepromTimerQ;
extern OSTimer __osEepromTimer;
extern OSMesg __osEepromTimerMsg;
extern OSMesgQueue __osEepromTimerQ;
extern OSPifRam __osEepPifRam;
extern OSPifRam __osContPifRam;
extern OSPifRam __osPfsPifRam;
extern u8 __osMaxControllers;
void __osPackRequestData(u8 poll);
void __osContGetInitData(u8* pattern, OSContStatus* data);
//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
+22
View File
@@ -641,6 +641,28 @@ typedef struct {
#define PFS_ERR_EXIST 9 /* file exists */
#define PFS_ERR_ID_FATAL 10 /* dead ram pack */
#define PFS_ERR_DEVICE 11 /* wrong device type*/
#define PFS_ERR_NO_GBCART 12 /* no gb cartridge (64GB-PAK) */
#define PFS_ERR_NEW_GBCART 13 /* gb cartridge may be changed */
/* Definition for bank */
#define PFS_ID_BANK_256K 0
#define PFS_ID_BANK_1M 4
#define PFS_BANKS_256K 1
#define PFS_WRITTEN 2
#define DEF_DIR_PAGES 2
#define PFS_ID_0AREA 1
#define PFS_ID_1AREA 3
#define PFS_ID_2AREA 4
#define PFS_ID_3AREA 6
#define PFS_LABEL_AREA 7
#define PFS_ID_PAGE PFS_ONE_PAGE * 0
#define PFS_BANK_LAPPED_BY 8 /* => u8 */
#define PFS_SECTOR_PER_BANK 32
#define PFS_INODE_DIST_MAP (PFS_BANK_LAPPED_BY * PFS_SECTOR_PER_BANK)
#define PFS_SECTOR_SIZE (PFS_INODE_SIZE_PER_PAGE/PFS_SECTOR_PER_BANK)
/* definition for EEPROM */
+28
View File
@@ -0,0 +1,28 @@
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo.
$RCSfile: os_version.h,v $
$Revision: 1.2 $
$Date: 1999/06/17 01:33:01 $
*---------------------------------------------------------------------*/
#ifndef _OS_VERSION_H_
#define _OS_VERSION_H_
#define VERSION_D 1
#define VERSION_E 2
#define VERSION_F 3
#define VERSION_G 4
#define VERSION_H 5
#define VERSION_I 6
#define VERSION_J 7
#define VERSION_K 8
#define VERSION_L 9
#define BUILD_VERSION VERSION_H
#define OS_MAJOR_VERSION BUILD_VERSION_STRING /* major version */
#define OS_MINOR_VERSION 0 /* patch level */
#endif /* !_OS_VERSION_H_ */
+47 -10
View File
@@ -3,22 +3,23 @@
#include "structs.h"
f32 func_80004E20(f32 arg0, f32 arg1);
void func_80004E4C(void);
f32 Math_ModF(f32 value, f32 mod);
void Rand_Init(void);
f32 Rand_ZeroOne(void);
void func_80004FC8(s32 arg0, s32 arg1, s32 arg2);
f32 func_80004FE8(void);
f32 func_80005100(f32 arg0, f32 arg1);
f32 func_80005320(f32 arg0, f32 arg1);
f32 func_800055DC(f32 arg0, s32 arg1);
void func_80005604(s32* arg0, s32* arg1, s32 arg2, s32 arg3, s32 arg4);
void func_80005E90(Matrix*, float, char);
void Rand_SetSeed(s32 seed1, s32 seed2, s32 seed3);
f32 Rand_ZeroOneSeeded(void);
f32 Math_Atan2F(f32 y, f32 x);
f32 Math_Atan2F_XY(f32 x, f32 y);
f32 Math_Atan2F_XYAlt(f32 x, f32 y);
f32 Math_PowF(f32 base, s32 exp);
void Math_MinMax(s32* min, s32* max, s32 val1, s32 val2, s32 val3);
void func_80005680(Matrix*, Matrix*);
void func_80005708(Matrix** mtx);
void func_80005740(Matrix** mtx);
void func_80005B00(Matrix*, f32, f32, f32, u8);
void func_80005C34(Matrix*, f32, f32, f32, s32);
void func_80005E90(Matrix*, float, char);
void func_80006A20(Matrix*, Vec3f*, Vec3f*);
void func_80006EB8(Gfx**);
void func_80006F20(void);
@@ -40,12 +41,48 @@ void func_8001DC6C(s32, s32);
s32 func_8001EF10(void);
f32 func_8001FBE8(f32);
s32 vsprintf(char* dst, char* fmt, va_list args);
f32 func_8001FE60(f32);
f64 func_8001FE6C(f64);
s32 func_8001FE78(f32);
s32 func_8001FE88(f64);
f32 func_8001FE98(f32);
f64 func_8001FEA4(f64);
s32 func_8001FEB0(f32);
s32 func_8001FEC0(f64);
f32 func_8001FED0(f32);
f64 func_8001FEDC(f64);
s32 func_8001FEE8(f32);
s32 func_8001FEF8(f64);
f32 func_8001FF08(f32);
f64 func_8001FF14(f64);
s32 func_8001FF20(f32);
s32 func_8001FF30(f64);
f32 func_8001FF40(f32);
f64 func_8001FF5C(f64);
s32 func_8001FF7C(f32);
s32 func_8001FF9C(f64);
f32 func_8001FAE4(f32);
f32 func_8001FB04(f32);
f64 func_8001FB24(f64);
f32 func_8001FB58(f32);
f32 func_8001FB88(f32);
f32 func_8001FBA8(f32);
f32 func_8001FBC8(f32);
f32 Math_FAtanF(f32);
f32 Math_FAtan2F(f32, f32);
f32 Math_FAsinF(f32);
f32 Math_FAcosF(f32);
void func_800227A0(s32, OSMesgQueue*, OSMesg*, s32);
s32 func_80022B60(void);
f32 __sinf(f32);
f32 __cosf(f32);
s64 __ull_div(s64, s64);
s64 __ll_mul(s64, s64);
s64 __ll_rshift(s64, s64);
+2
View File
@@ -1,7 +1,9 @@
#ifndef GLOBAL_H
#define GLOBAL_H
#include "PR/xstdio.h"
#include "PR/os_internal.h"
#include "PR/controller.h"
#include "libultra/ultra64.h"
#include "libc/math.h"
#include "libc/stdarg.h"
+58
View File
@@ -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
+198
View File
@@ -0,0 +1,198 @@
#ifndef _PIINT_H_
#define _PIINT_H_
#include "PR/os_internal.h"
#include "PR/os_version.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
+15
View File
@@ -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