mirror of
https://github.com/pmret/papermario.git
synced 2024-11-11 21:42:32 +01:00
Match libultra iQue ver (#1111)
* match libultra ique pt 1 * add sgidefs.h to include/gcc * recvmesg match + _getcount * add elfpatch.py for those compiled with -mips3 * pt 2 * os/setthreadpri(.data) -> os/thread * os thread matches * os timer matches * pt 4 (erm... 3?) * vitbl * os pi matches * pt. uhmmmm, i've lost track... * os pfs matches * replace elfpatch.py * pt. just forget it... * outsource from ultralib ique branch * . * . 2 * final blow * add egcs compiler to Jenkinsfile * fix errors from CI * minor changes as requested
This commit is contained in:
parent
b22883da65
commit
b171712e0e
2
Jenkinsfile
vendored
2
Jenkinsfile
vendored
@ -15,6 +15,8 @@ pipeline {
|
||||
sh 'curl -L "https://github.com/decompals/ido-static-recomp/releases/download/v0.2/ido-5.3-recomp-ubuntu-latest.tar.gz" | tar zx -C tools/build/cc/ido5.3'
|
||||
sh 'curl -L "https://github.com/decompals/mips-gcc-2.7.2/releases/download/main/gcc-2.7.2-linux.tar.gz" | tar zx -C tools/build/cc/gcc2.7.2'
|
||||
sh 'curl -L "https://github.com/decompals/mips-binutils-2.6/releases/download/main/binutils-2.6-linux.tar.gz" | tar zx -C tools/build/cc/gcc2.7.2'
|
||||
sh 'curl -L "https://github.com/decompals/mips-binutils-egcs-2.9.5/releases/latest/download/mips-binutils-egcs-2.9.5-linux.tar.gz" | tar zx -C tools/build/cc/egcs'
|
||||
sh 'curl -L "https://github.com/decompals/mips-gcc-egcs-2.91.66/releases/latest/download/mips-gcc-egcs-2.91.66-linux.tar.gz" | tar zx -C tools/build/cc/egcs'
|
||||
sh 'pip install -U -r requirements.txt'
|
||||
sh 'cargo install pigment64'
|
||||
sh './configure'
|
||||
|
115
include/PR/bcp.h
Normal file
115
include/PR/bcp.h
Normal file
@ -0,0 +1,115 @@
|
||||
#ifndef _BCP_H_
|
||||
#define _BCP_H_
|
||||
#ifdef BBPLAYER
|
||||
|
||||
#include "rcp.h"
|
||||
|
||||
/**
|
||||
* MIPS Interface (MI) Additional Registers
|
||||
*/
|
||||
|
||||
//! MI_SK_EXCEPTION_REG ?
|
||||
#define MI_14_REG (MI_BASE_REG + 0x14)
|
||||
|
||||
|
||||
|
||||
//! ?
|
||||
#define MI_30_REG (MI_BASE_REG + 0x30)
|
||||
|
||||
|
||||
|
||||
//! ?
|
||||
#define MI_38_REG (MI_BASE_REG + 0x38)
|
||||
|
||||
|
||||
|
||||
//! MI_HW_INTR_MASK_REG ?
|
||||
#define MI_3C_REG (MI_BASE_REG + 0x3C)
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Peripheral Interface (PI) Additional Registers
|
||||
*/
|
||||
|
||||
//! PI_ATB_UPPER_REG ?
|
||||
#define PI_40_REG (PI_BASE_REG + 0x40)
|
||||
|
||||
|
||||
|
||||
//! ?
|
||||
#define PI_44_REG (PI_BASE_REG + 0x44)
|
||||
|
||||
|
||||
|
||||
//! PI_CARD_CNT_REG ?
|
||||
#define PI_48_REG (PI_BASE_REG + 0x48)
|
||||
|
||||
|
||||
|
||||
//! ?
|
||||
#define PI_4C_REG (PI_BASE_REG + 0x4C)
|
||||
|
||||
|
||||
|
||||
//! PI_AES_CNT_REG ?
|
||||
#define PI_50_REG (PI_BASE_REG + 0x50)
|
||||
|
||||
|
||||
|
||||
//! PI_ALLOWED_IO_REG ?
|
||||
#define PI_54_REG (PI_BASE_REG + 0x54)
|
||||
|
||||
|
||||
|
||||
//! ?
|
||||
#define PI_58_REG (PI_BASE_REG + 0x58)
|
||||
|
||||
|
||||
|
||||
//! ?
|
||||
#define PI_5C_REG (PI_BASE_REG + 0x5C)
|
||||
|
||||
|
||||
|
||||
//! PI_MISC_REG ?
|
||||
#define PI_60_REG (PI_BASE_REG + 0x60)
|
||||
|
||||
|
||||
|
||||
//! ?
|
||||
#define PI_64_REG (PI_BASE_REG + 0x64)
|
||||
|
||||
|
||||
|
||||
//! PI_CARD_BLK_OFFSET_REG ?
|
||||
#define PI_70_REG (PI_BASE_REG + 0x70)
|
||||
|
||||
|
||||
|
||||
//! PI_EX_DMA_BUF ?
|
||||
#define PI_10000_REG(i) (PI_BASE_REG + 0x10000 + (i))
|
||||
|
||||
|
||||
|
||||
//! PI_ATB_LOWER_REG ?
|
||||
#define PI_10500_REG(i) (PI_BASE_REG + 0x10500 + (i) * 4)
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Serial Interface (SI) Additional Registers
|
||||
*/
|
||||
|
||||
//! ?
|
||||
#define SI_0C_REG (SI_BASE_REG + 0x0C)
|
||||
|
||||
|
||||
|
||||
//! ?
|
||||
#define SI_1C_REG (SI_BASE_REG + 0x1C)
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
@ -1,17 +1,21 @@
|
||||
#ifndef _CONTROLLER_H
|
||||
#define _CONTROLLER_H
|
||||
|
||||
#include "os_internal.h"
|
||||
#include "rcp.h"
|
||||
|
||||
//should go somewhere else but
|
||||
#define CHNL_ERR(format) ((format.rxsize & CHNL_ERR_MASK) >> 4)
|
||||
#define ARRLEN(x) ((s32)(sizeof(x) / sizeof(x[0])))
|
||||
#define CHNL_ERR(format) (((format).rxsize & CHNL_ERR_MASK) >> 4)
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
/* 0x0 */ u32 ramarray[15];
|
||||
/* 0x3C */ u32 pifstatus;
|
||||
} OSPifRam;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
/* 0x0 */ u8 dummy;
|
||||
/* 0x1 */ u8 txsize;
|
||||
/* 0x2 */ u8 rxsize;
|
||||
@ -103,70 +107,93 @@ typedef struct
|
||||
/* 0x4 */ u8 data[EEPROM_BLOCK_SIZE];
|
||||
} __OSContEepromFormat;
|
||||
|
||||
#define PFS_ONE_PAGE 8
|
||||
#define PFS_PAGE_SIZE (BLOCKSIZE*PFS_ONE_PAGE)
|
||||
|
||||
#define PFS_INODE_SIZE_PER_PAGE 128
|
||||
|
||||
#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_WRITTEN 2
|
||||
|
||||
#define PFS_EOF 1
|
||||
#define PFS_PAGE_NOT_EXIST 2
|
||||
#define PFS_PAGE_NOT_USED 3
|
||||
|
||||
#define PFS_FORCE 1
|
||||
|
||||
#define PFS_ID_BANK_256K 0
|
||||
|
||||
// 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_MEMPACK 2
|
||||
#define CONT_CMD_WRITE_MEMPACK 3
|
||||
#define CONT_CMD_READ_EEPROM 4
|
||||
#define CONT_CMD_WRITE_EEPROM 5
|
||||
#define CONT_CMD_RESET 0xff
|
||||
#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
|
||||
|
||||
#define CONT_CMD_REQUEST_STATUS_TX 1
|
||||
#define CONT_CMD_READ_BUTTON_TX 1
|
||||
#define CONT_CMD_READ_MEMPACK_TX 3
|
||||
#define CONT_CMD_WRITE_MEMPACK_TX 35
|
||||
#define CONT_CMD_READ_EEPROM_TX 2
|
||||
#define CONT_CMD_WRITE_EEPROM_TX 10
|
||||
#define CONT_CMD_RESET_TX 1
|
||||
// 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
|
||||
|
||||
#define CONT_CMD_REQUEST_STATUS_RX 3
|
||||
#define CONT_CMD_READ_BUTTON_RX 4
|
||||
#define CONT_CMD_READ_MEMPACK_RX 33
|
||||
#define CONT_CMD_WRITE_MEMPACK_RX 1
|
||||
#define CONT_CMD_READ_EEPROM_RX 8
|
||||
#define CONT_CMD_WRITE_EEPROM_RX 1
|
||||
#define CONT_CMD_RESET_RX 3
|
||||
// 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 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
|
||||
#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
|
||||
|
||||
#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)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* 0x0 */ __OSInode inode;
|
||||
/* 0x100 */ u8 bank;
|
||||
/* 0x101 */ u8 map[256];
|
||||
/* 0x101 */ u8 map[PFS_INODE_DIST_MAP];
|
||||
} __OSInodeCache;
|
||||
|
||||
extern s32 __osEepStatus(OSMesgQueue *, OSContStatus *);
|
||||
@ -178,6 +205,8 @@ s32 __osGetId(OSPfs *pfs);
|
||||
s32 __osCheckId(OSPfs *pfs);
|
||||
s32 __osPfsRWInode(OSPfs *pfs, __OSInode *inode, u8 flag, u8 bank);
|
||||
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 __osPfsReleasePages(OSPfs *pfs, __OSInode *inode, u8 start_page, u8 bank, __OSInodeUnit *last_page);
|
||||
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);
|
||||
@ -202,26 +231,27 @@ extern u8 __osMaxControllers;
|
||||
#define ERRCK(fn) \
|
||||
ret = fn; \
|
||||
if (ret != 0) \
|
||||
return ret;
|
||||
return ret
|
||||
|
||||
#define SET_ACTIVEBANK_TO_ZERO \
|
||||
if (pfs->activebank != 0) \
|
||||
{ \
|
||||
ERRCK(__osPfsSelectBank(pfs, 0)) \
|
||||
}
|
||||
ERRCK(__osPfsSelectBank(pfs, 0)); \
|
||||
} (void)0
|
||||
|
||||
#define PFS_CHECK_ID \
|
||||
if (__osCheckId(pfs) == PFS_ERR_NEW_PACK) \
|
||||
return PFS_ERR_NEW_PACK;
|
||||
#endif
|
||||
return PFS_ERR_NEW_PACK
|
||||
|
||||
#define PFS_CHECK_STATUS \
|
||||
if ((pfs->status & PFS_INITIALIZED) == 0) \
|
||||
return PFS_ERR_INVALID;
|
||||
return PFS_ERR_INVALID
|
||||
|
||||
#define PFS_GET_STATUS \
|
||||
__osSiGetAccess(); \
|
||||
ret = __osPfsGetStatus(queue, channel); \
|
||||
__osSiRelAccess(); \
|
||||
if (ret != 0) \
|
||||
return ret;
|
||||
return ret
|
||||
|
||||
#endif
|
||||
|
@ -7,45 +7,51 @@
|
||||
*---------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _OS_FLASH_H_
|
||||
#define _OS_FLASH_H_
|
||||
#define _OS_FLASH_H_
|
||||
|
||||
#ifdef _LANGUAGE_C_PLUS_PLUS
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <PR/ultratypes.h>
|
||||
#include "ultratypes.h"
|
||||
#include "os_pi.h"
|
||||
|
||||
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
|
||||
|
||||
/*
|
||||
* defines for FLASH
|
||||
*/
|
||||
#define FLASH_START_ADDR 0x08000000
|
||||
#define FLASH_START_ADDR 0x08000000
|
||||
|
||||
#define FLASH_SIZE 0x20000
|
||||
#define FLASH_LATENCY 0x5
|
||||
#define FLASH_PULSE 0x0c
|
||||
#define FLASH_PAGE_SIZE 0xf
|
||||
#define FLASH_REL_DURATION 0x2
|
||||
#define DEVICE_TYPE_FLASH 8
|
||||
#define FLASH_SIZE 0x20000
|
||||
|
||||
#define FLASH_VERSION_MX_PROTO_A 0x00c20000
|
||||
#define FLASH_VERSION_MX_A 0x00c20001
|
||||
#define FLASH_VERSION_MX_C 0x00c2001e
|
||||
#define FLASH_VERSION_MX_B_AND_D 0x00c2001d
|
||||
#define FLASH_VERSION_MEI 0x003200f1
|
||||
#define FLASH_LATENCY 0x5
|
||||
#define FLASH_PULSE 0x0c
|
||||
#define FLASH_PAGE_SIZE 0xf
|
||||
#define FLASH_REL_DURATION 0x2
|
||||
#define DEVICE_TYPE_FLASH 8
|
||||
|
||||
#define FLASH_VERSION_MX_PROTO_A 0x00c20000
|
||||
#define FLASH_VERSION_MX_A 0x00c20001
|
||||
#define FLASH_VERSION_MX_C 0x00c2001e
|
||||
#define FLASH_VERSION_MX_B_AND_D 0x00c2001d
|
||||
#define FLASH_VERSION_MEI 0x003200f1
|
||||
|
||||
#define OLD_FLASH 0
|
||||
#define NEW_FLASH 1
|
||||
/* OLD_FLASH is MX_PROTO_A, MX_A and MX_C */
|
||||
#define OLD_FLASH 0
|
||||
/* NEW_FLASH is MX_B_AND_D and MATSUSHITA flash */
|
||||
#define NEW_FLASH 1
|
||||
|
||||
#define FLASH_STATUS_ERASE_BUSY 2
|
||||
#define FLASH_STATUS_ERASE_ERROR -1
|
||||
#define FLASH_STATUS_ERASE_OK 0
|
||||
#define FLASH_STATUS_ERASE_BUSY 2
|
||||
#define FLASH_STATUS_ERASE_OK 0
|
||||
#define FLASH_STATUS_ERASE_ERROR -1
|
||||
|
||||
#define FLASH_STATUS_WRITE_BUSY 1
|
||||
#define FLASH_STATUS_WRITE_OK 0
|
||||
#define FLASH_STATUS_WRITE_ERROR -1
|
||||
|
||||
extern OSPiHandle *osFlashReInit(u8 latency, u8 pulse,
|
||||
u8 page_size, u8 rel_duration, u32 start);
|
||||
u8 page_size, u8 rel_duration, u32 start);
|
||||
extern OSPiHandle *osFlashInit(void);
|
||||
extern void osFlashReadStatus(u8 *flash_status);
|
||||
extern void osFlashReadId(u32 *flash_type, u32 *flash_maker);
|
||||
@ -53,10 +59,10 @@ extern void osFlashClearStatus(void);
|
||||
extern s32 osFlashAllErase(void);
|
||||
extern s32 osFlashSectorErase(u32 page_num);
|
||||
extern s32 osFlashWriteBuffer(OSIoMesg *mb, s32 priority,
|
||||
void *dramAddr, OSMesgQueue *mq);
|
||||
void *dramAddr, OSMesgQueue *mq);
|
||||
extern s32 osFlashWriteArray(u32 page_num);
|
||||
extern s32 osFlashReadArray(OSIoMesg *mb, s32 priority, u32 page_num,
|
||||
void *dramAddr, u32 n_pages, OSMesgQueue *mq);
|
||||
void *dramAddr, u32 n_pages, OSMesgQueue *mq);
|
||||
extern void osFlashChange(u32 flash_num);
|
||||
extern void osFlashAllEraseThrough(void);
|
||||
extern void osFlashSectorEraseThrough(u32 page_num);
|
||||
|
40
include/PR/os_internal_flash.h
Normal file
40
include/PR/os_internal_flash.h
Normal file
@ -0,0 +1,40 @@
|
||||
#ifndef _OS_INTERNAL_FLASH_H_
|
||||
#define _OS_INTERNAL_FLASH_H_
|
||||
|
||||
#include "os_message.h"
|
||||
#include "os_flash.h"
|
||||
|
||||
#define FLASH_BLOCK_SIZE 128
|
||||
|
||||
/**
|
||||
* Flash commands
|
||||
*/
|
||||
#define FLASH_CMD_REG 0x10000
|
||||
|
||||
/* set whole chip erase mode */
|
||||
#define FLASH_CMD_CHIP_ERASE 0x3C000000
|
||||
/* set sector erase mode */
|
||||
#define FLASH_CMD_SECTOR_ERASE 0x4B000000
|
||||
/* do erasure */
|
||||
#define FLASH_CMD_EXECUTE_ERASE 0x78000000
|
||||
/* program selected page */
|
||||
#define FLASH_CMD_PROGRAM_PAGE 0xA5000000
|
||||
/* set page program mode */
|
||||
#define FLASH_CMD_PAGE_PROGRAM 0xB4000000
|
||||
/* set status mode */
|
||||
#define FLASH_CMD_STATUS 0xD2000000
|
||||
/* set silicon id mode */
|
||||
#define FLASH_CMD_ID 0xE1000000
|
||||
/* set read mode */
|
||||
#define FLASH_CMD_READ_ARRAY 0xF0000000
|
||||
|
||||
extern OSIoMesg __osFlashMsg;
|
||||
extern OSMesgQueue __osFlashMessageQ;
|
||||
extern OSPiHandle __osFlashHandler;
|
||||
extern OSMesg __osFlashMsgBuf[1];
|
||||
extern s32 __osFlashVersion;
|
||||
extern u32 __osFlashID[4];
|
||||
|
||||
u32 __osFlashGetAddr(u32 page_num);
|
||||
|
||||
#endif
|
@ -1,3 +1,4 @@
|
||||
|
||||
/*====================================================================
|
||||
* os_pfs.h
|
||||
*
|
||||
@ -81,16 +82,18 @@ typedef struct {
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* File System size */
|
||||
#define OS_PFS_VERSION 0x0200
|
||||
#define OS_PFS_VERSION_HI (OS_PFS_VERSION >> 8)
|
||||
#define OS_PFS_VERSION_LO (OS_PFS_VERSION & 255)
|
||||
|
||||
#define PFS_INODE_SIZE_PER_PAGE 128
|
||||
#define PFS_FILE_NAME_LEN 16
|
||||
#define PFS_FILE_EXT_LEN 4
|
||||
#define BLOCKSIZE 32 /* bytes */
|
||||
#define PFS_ONE_PAGE 8 /* blocks */
|
||||
#define PFS_MAX_BANKS 62
|
||||
#define BLOCKSIZE 32 /* bytes */
|
||||
#define PFS_ONE_PAGE 8 /* blocks */
|
||||
#define PFS_MAX_BANKS 62
|
||||
|
||||
/* File System flag */
|
||||
|
||||
@ -99,28 +102,32 @@ typedef struct {
|
||||
#define PFS_CREATE 2
|
||||
|
||||
/* File System status */
|
||||
#define PFS_INITIALIZED 0x1
|
||||
#define PFS_CORRUPTED 0x2 /* File system was corrupted */
|
||||
#define PFS_ID_BROKEN 0x4
|
||||
#define PFS_MOTOR_INITIALIZED 0x8
|
||||
#define PFS_GBPAK_INITIALIZED 0x10
|
||||
#define PFS_INITIALIZED 0x1
|
||||
#define PFS_CORRUPTED 0x2
|
||||
#define PFS_ID_BROKEN 0x4
|
||||
#define PFS_MOTOR_INITIALIZED 0x8
|
||||
#define PFS_GBPAK_INITIALIZED 0x10
|
||||
|
||||
/* Definition for page usage */
|
||||
#define PFS_EOF 1
|
||||
#define PFS_PAGE_NOT_EXIST 2
|
||||
#define PFS_PAGE_NOT_USED 3
|
||||
|
||||
/* File System error number */
|
||||
|
||||
#define PFS_ERR_NOPACK 1 /* no memory card is plugged or */
|
||||
#define PFS_ERR_NEW_PACK 2 /* ram pack has been changed to a */
|
||||
/* different one */
|
||||
#define PFS_ERR_INCONSISTENT 3 /* need to run Pfschecker */
|
||||
#define PFS_ERR_CONTRFAIL CONT_OVERRUN_ERROR
|
||||
#define PFS_ERR_INVALID 5 /* invalid parameter or file not exist*/
|
||||
#define PFS_ERR_BAD_DATA 6 /* the data read from pack are bad*/
|
||||
#define PFS_DATA_FULL 7 /* no free pages on ram pack */
|
||||
#define PFS_DIR_FULL 8 /* no free directories on ram pack*/
|
||||
#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 */
|
||||
#define PFS_ERR_NOPACK 1 /* no memory card is plugged or */
|
||||
#define PFS_ERR_NEW_PACK 2 /* ram pack has been changed to a different one */
|
||||
#define PFS_ERR_INCONSISTENT 3 /* need to run Pfschecker*/
|
||||
#define PFS_ERR_CONTRFAIL CONT_OVERRUN_ERROR
|
||||
#define PFS_ERR_INVALID 5 /* invalid parameter or file not exist*/
|
||||
#define PFS_ERR_BAD_DATA 6 /* the data read from pack are bad*/
|
||||
#define PFS_DATA_FULL 7 /* no free pages on ram pack*/
|
||||
#define PFS_DIR_FULL 8 /* no free directories on ram pack*/
|
||||
#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
|
||||
|
@ -114,9 +114,11 @@ s32 __osEPiRawStartDma(OSPiHandle *, s32 , u32 , void *, u32 );
|
||||
OSMesgQueue *osPiGetCmdQueue(void);
|
||||
|
||||
#define WAIT_ON_IOBUSY(stat) \
|
||||
while (stat = IO_READ(PI_STATUS_REG), stat & (PI_STATUS_IO_BUSY | PI_STATUS_DMA_BUSY)) \
|
||||
; \
|
||||
(void)0
|
||||
{ \
|
||||
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) \
|
||||
|
970
include/PR/rcp.h
970
include/PR/rcp.h
File diff suppressed because it is too large
Load Diff
@ -1,10 +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
|
||||
|
@ -1,257 +0,0 @@
|
||||
#ifndef _CONTROLLER_H
|
||||
#define _CONTROLLER_H
|
||||
|
||||
#include "PR/os_internal.h"
|
||||
#include "PR/rcp.h"
|
||||
|
||||
//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;
|
||||
/* 0x4 */ u8 addrh;
|
||||
/* 0x5 */ u8 addrl;
|
||||
/* 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);
|
||||
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 __osPfsReleasePages(OSPfs *pfs, __OSInode *inode, u8 start_page, u8 bank, __OSInodeUnit *last_page);
|
||||
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;
|
||||
|
||||
#define SET_ACTIVEBANK_TO_ZERO \
|
||||
if (pfs->activebank != 0) \
|
||||
{ \
|
||||
ERRCK(__osPfsSelectBank(pfs, 0)) \
|
||||
}
|
||||
|
||||
#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
|
44
include/gcc/sgidefs.h
Normal file
44
include/gcc/sgidefs.h
Normal file
@ -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 */
|
@ -40,7 +40,7 @@ typedef char * __gnuc_va_list;
|
||||
|
||||
/* Get definitions for _MIPS_SIM_ABI64 etc. */
|
||||
#ifdef _MIPS_SIM
|
||||
#include <sgidefs.h>
|
||||
#include "gcc/sgidefs.h"
|
||||
#endif
|
||||
|
||||
#ifdef _STDARG_H
|
||||
|
@ -26,7 +26,14 @@
|
||||
#define TRANSPARENT_UNION
|
||||
#endif
|
||||
|
||||
#define ALIGNED(x) __attribute__((aligned(x)))
|
||||
#ifndef BBPLAYER
|
||||
# define ALIGNED(x) __attribute__((aligned(x)))
|
||||
# define BBALIGNED(x) ALIGNED(x)
|
||||
#else
|
||||
# define ALIGNED(x)
|
||||
# define BBALIGNED(x) __attribute__((aligned(x)))
|
||||
#endif
|
||||
|
||||
#define ALIGN16(val) (((val) + 0xF) & ~0xF)
|
||||
#define ALIGN8(val) (((val) + 0x7) & ~0x7)
|
||||
|
||||
|
@ -86,7 +86,7 @@ enum {
|
||||
|
||||
/* Get definitions for _MIPS_SIM_ABI64 etc. */
|
||||
#ifdef _MIPS_SIM
|
||||
#include <sgidefs.h>
|
||||
#include "gcc/sgidefs.h"
|
||||
#endif
|
||||
|
||||
#ifdef _STDARG_H
|
||||
|
@ -24,5 +24,9 @@ curl -L "https://github.com/pmret/binutils-papermario/releases/download/master/l
|
||||
curl -L "https://github.com/decompals/mips-gcc-2.7.2/releases/download/main/gcc-2.7.2-linux.tar.gz" | tar zx -C tools/build/cc/gcc2.7.2
|
||||
curl -L "https://github.com/decompals/mips-binutils-2.6/releases/download/main/binutils-2.6-linux.tar.gz" | tar zx -C tools/build/cc/gcc2.7.2
|
||||
|
||||
# EGCS
|
||||
curl -L "https://github.com/decompals/mips-binutils-egcs-2.9.5/releases/latest/download/mips-binutils-egcs-2.9.5-linux.tar.gz" | tar zx -C tools/build/cc/egcs
|
||||
curl -L "https://github.com/decompals/mips-gcc-egcs-2.91.66/releases/latest/download/mips-gcc-egcs-2.91.66-linux.tar.gz" | tar zx -C tools/build/cc/egcs
|
||||
|
||||
echo "Downloading IDO 5.3 for Linux"
|
||||
curl -L "https://github.com/decompals/ido-static-recomp/releases/download/v0.2/ido-5.3-recomp-ubuntu-latest.tar.gz" | tar zx -C tools/build/cc/ido5.3
|
||||
|
35
src/os/_getcount.c
Normal file
35
src/os/_getcount.c
Normal file
@ -0,0 +1,35 @@
|
||||
#include "ultra64.h"
|
||||
#include "macros.h"
|
||||
#include "PR/os_internal.h"
|
||||
|
||||
#ifdef BBPLAYER
|
||||
u32 __osBbLastRCount;
|
||||
u32 __osBbRCountWraps;
|
||||
u32 __osBbLastVCount;
|
||||
u32 __osBbVCountWraps;
|
||||
|
||||
u32 osGetCount(void) {
|
||||
u32 count;
|
||||
u32 mask;
|
||||
|
||||
mask = __osDisableInt();
|
||||
|
||||
__asm__("mfc0 %0, $9" : "=r"(count));
|
||||
|
||||
if (count < __osBbLastRCount) {
|
||||
__osBbRCountWraps++;
|
||||
}
|
||||
__osBbLastRCount = count;
|
||||
|
||||
count = (((u64)__osBbRCountWraps << 32) | count) * 125ull / 192ull;
|
||||
|
||||
if (count < __osBbLastVCount) {
|
||||
__osBbVCountWraps++;
|
||||
}
|
||||
__osBbLastVCount = count;
|
||||
|
||||
__osRestoreInt(mask);
|
||||
|
||||
return count;
|
||||
}
|
||||
#endif
|
18
src/os/_setcompare.c
Normal file
18
src/os/_setcompare.c
Normal file
@ -0,0 +1,18 @@
|
||||
#include "PR/os_internal.h"
|
||||
|
||||
extern u32 __osBbLastRCount;
|
||||
extern u32 __osBbRCountWraps;
|
||||
extern u32 __osBbLastVCount;
|
||||
extern u32 __osBbVCountWraps;
|
||||
|
||||
void __osSetCompare(u32 v) {
|
||||
if (v != 0) {
|
||||
u32 mask = __osDisableInt();
|
||||
u32 wraps = (v < __osBbLastVCount) ? __osBbVCountWraps + 1 : __osBbVCountWraps;
|
||||
|
||||
v = (((u64)wraps << 32) | v) * 192ull / 125ull;
|
||||
|
||||
__osRestoreInt(mask);
|
||||
}
|
||||
__asm__ ("mtc0 %0, $11" :: "r"(v));
|
||||
}
|
@ -31,9 +31,7 @@ OSPiHandle *osCartRomInit(void)
|
||||
|
||||
bzero(&__CartRomHandle.transferInfo, sizeof(__OSTranxInfo));
|
||||
|
||||
while (stat = IO_READ(PI_STATUS_REG), stat & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) {
|
||||
;
|
||||
}
|
||||
WAIT_ON_IOBUSY(stat);
|
||||
|
||||
latency = IO_READ(PI_BSD_DOM1_LAT_REG);
|
||||
pageSize = IO_READ(PI_BSD_DOM1_PGS_REG);
|
||||
|
48
src/os/common.c
Normal file
48
src/os/common.c
Normal file
@ -0,0 +1,48 @@
|
||||
#include "ultra64.h"
|
||||
|
||||
void* memset(void* dest, int ch, size_t n) {
|
||||
unsigned char* p = dest;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
p[i] = ch;
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
// these functions below should be separate in libultra_rom, however they aren't aligned in proper
|
||||
|
||||
int memcmp(const void* str1, const void* str2, size_t n) {
|
||||
const unsigned char* s1 = str1;
|
||||
const unsigned char* s2 = str2;
|
||||
unsigned char u1, u2;
|
||||
|
||||
while (n-- > 0) {
|
||||
u2 = *s2++;
|
||||
u1 = *s1++;
|
||||
if (u1 != u2) {
|
||||
return u1 - u2;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// n should be size_t but can't be
|
||||
int strncmp(const char* str1, const char* str2, int n) {
|
||||
int i;
|
||||
|
||||
for (i = 0; (*str1 == *str2) && (i < n); i++) {
|
||||
if (*str1 == 0) {
|
||||
if (*str2 == 0) {
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (*str2 == 0) {
|
||||
break;
|
||||
}
|
||||
str1++;
|
||||
str2++;
|
||||
}
|
||||
return (i != n) ? *str1 - *str2 : 0;
|
||||
}
|
175
src/os/contpfs.c
175
src/os/contpfs.c
@ -1,90 +1,94 @@
|
||||
#include "PR/controller.h"
|
||||
#include "macros.h"
|
||||
#include "PR/os_internal.h"
|
||||
#include "PR/controller.h"
|
||||
#include "PR/rmon.h"
|
||||
|
||||
extern __OSInode __osPfsInodeCache;
|
||||
|
||||
__OSInode __osPfsInodeCache ALIGNED(8);
|
||||
s32 __osPfsInodeCacheChannel = -1;
|
||||
u8 __osPfsInodeCacheBank = 250;
|
||||
|
||||
u16 __osSumcalc(u8 *ptr, int length) {
|
||||
u16 __osSumcalc(u8* ptr, int length) {
|
||||
int i;
|
||||
s32 sum;
|
||||
u8* tmp;
|
||||
sum = 0;
|
||||
tmp = ptr;
|
||||
u32 sum = 0;
|
||||
u8* tmp = ptr;
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
sum += *tmp++;
|
||||
}
|
||||
return sum;
|
||||
|
||||
return sum & 0xFFFF;
|
||||
}
|
||||
|
||||
s32 __osIdCheckSum(u16 *ptr, u16 *csum, u16 *icsum) {
|
||||
u16 data;
|
||||
s32 __osIdCheckSum(u16* ptr, u16* csum, u16* icsum) {
|
||||
u16 data = 0;
|
||||
u32 j;
|
||||
data = 0;
|
||||
*icsum = 0;
|
||||
*csum = *icsum;
|
||||
for (j = 0; j < 28; j += 2) {
|
||||
data = *(u16 *)((u8 *)ptr + j);
|
||||
|
||||
*csum = *icsum = 0;
|
||||
|
||||
for (j = 0; j < ((sizeof(__OSPackId) - sizeof(u32)) / sizeof(u8)); j += 2) {
|
||||
data = *(u16*)((u32)ptr + j);
|
||||
*csum += data;
|
||||
*icsum += ~data;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
s32 __osRepairPackId(OSPfs *pfs, __OSPackId *badid, __OSPackId *newid) {
|
||||
s32 ret;
|
||||
|
||||
s32 __osRepairPackId(OSPfs* pfs, __OSPackId* badid, __OSPackId* newid) {
|
||||
s32 ret = 0;
|
||||
u8 temp[BLOCKSIZE];
|
||||
u8 comp[BLOCKSIZE];
|
||||
u8 mask;
|
||||
u8 mask = 0;
|
||||
int i;
|
||||
int j;
|
||||
int j = 0;
|
||||
u16 index[4];
|
||||
|
||||
//ret = 0;
|
||||
//mask = 0;
|
||||
|
||||
newid->repaired = -1;
|
||||
newid->random = osGetCount();
|
||||
newid->serial_mid = badid->serial_mid;
|
||||
newid->serial_low = badid->serial_low;
|
||||
j = 0;
|
||||
|
||||
SET_ACTIVEBANK_TO_ZERO;
|
||||
|
||||
do {
|
||||
ERRCK(__osPfsSelectBank(pfs, j))
|
||||
ERRCK(__osPfsSelectBank(pfs, j));
|
||||
ERRCK(__osContRamRead(pfs->queue, pfs->channel, 0, temp));
|
||||
|
||||
temp[0] = j | 0x80;
|
||||
for (i = 1; i < ARRAY_COUNT(temp); i++) {
|
||||
|
||||
for (i = 1; i < BLOCKSIZE; i++) {
|
||||
temp[i] = ~temp[i];
|
||||
}
|
||||
|
||||
ERRCK(__osContRamWrite(pfs->queue, pfs->channel, 0, temp, FALSE));
|
||||
ERRCK(__osContRamRead(pfs->queue, pfs->channel, 0, comp));
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(temp); i++) {
|
||||
for (i = 0; i < BLOCKSIZE; i++) {
|
||||
if (comp[i] != temp[i]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i != ARRAY_COUNT(temp)) {
|
||||
|
||||
if (i != BLOCKSIZE) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (j > 0) {
|
||||
ERRCK(__osPfsSelectBank(pfs, 0));
|
||||
ERRCK(__osContRamRead(pfs->queue, pfs->channel, 0, (u8*)temp));
|
||||
if (temp[0] != 128) {
|
||||
break; //TODO: remove magic constant
|
||||
|
||||
if (temp[0] != 0x80) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
j++;
|
||||
} while (j < PFS_MAX_BANKS);
|
||||
|
||||
SET_ACTIVEBANK_TO_ZERO;
|
||||
if (j > 0) {
|
||||
mask = 1;
|
||||
} else {
|
||||
mask = 0;
|
||||
}
|
||||
|
||||
mask = (j > 0) ? 1 : 0;
|
||||
|
||||
newid->deviceid = (badid->deviceid & (u16)~1) | mask;
|
||||
newid->banks = j;
|
||||
newid->version = badid->version;
|
||||
@ -93,65 +97,71 @@ s32 __osRepairPackId(OSPfs *pfs, __OSPackId *badid, __OSPackId *newid) {
|
||||
index[1] = PFS_ID_1AREA;
|
||||
index[2] = PFS_ID_2AREA;
|
||||
index[3] = PFS_ID_3AREA;
|
||||
for (i = 0; i < ARRAY_COUNT(index); i++) {
|
||||
|
||||
for (i = 0; i < ARRLEN(index); i++) {
|
||||
ERRCK(__osContRamWrite(pfs->queue, pfs->channel, index[i], (u8*)newid, TRUE));
|
||||
}
|
||||
ERRCK(__osContRamRead(pfs->queue, pfs->channel, 1, (u8*)temp));
|
||||
for (i = 0; i < ARRAY_COUNT(temp); i++) {
|
||||
if (temp[i] != ((u8 *)newid)[i]) {
|
||||
|
||||
ERRCK(__osContRamRead(pfs->queue, pfs->channel, PFS_ID_0AREA, (u8*)temp));
|
||||
|
||||
for (i = 0; i < BLOCKSIZE; i++) {
|
||||
if (temp[i] != ((u8*)newid)[i]) {
|
||||
return PFS_ERR_DEVICE;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 __osCheckPackId(OSPfs *pfs, __OSPackId *temp) {
|
||||
s32 __osCheckPackId(OSPfs* pfs, __OSPackId* temp) {
|
||||
u16 index[4];
|
||||
s32 ret;
|
||||
s32 ret = 0;
|
||||
u16 sum;
|
||||
u16 isum;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
ret = 0;
|
||||
SET_ACTIVEBANK_TO_ZERO;
|
||||
index[0] = PFS_ID_0AREA;
|
||||
index[1] = PFS_ID_1AREA;
|
||||
index[2] = PFS_ID_2AREA;
|
||||
index[3] = PFS_ID_3AREA;
|
||||
for (i = 1; i < ARRAY_COUNT(index); i++) {
|
||||
for (i = 1; i < ARRLEN(index); i++) {
|
||||
ERRCK(__osContRamRead(pfs->queue, pfs->channel, index[i], (u8*)temp));
|
||||
__osIdCheckSum((u16 *)temp, &sum, &isum);
|
||||
if (temp->checksum == sum && temp->inverted_checksum == isum)
|
||||
__osIdCheckSum((u16*)temp, &sum, &isum);
|
||||
if (temp->checksum == sum && temp->inverted_checksum == isum) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == ARRAY_COUNT(index)) {
|
||||
|
||||
if (i == ARRLEN(index)) {
|
||||
return PFS_ERR_ID_FATAL;
|
||||
}
|
||||
|
||||
for (j = 0; j < ARRAY_COUNT(index); j++) {
|
||||
for (j = 0; j < ARRLEN(index); j++) {
|
||||
if (j != i) {
|
||||
ERRCK(__osContRamWrite(pfs->queue, pfs->channel, index[j], (u8*)temp, TRUE));
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 __osGetId(OSPfs *pfs) {
|
||||
int k;
|
||||
s32 __osGetId(OSPfs* pfs) {
|
||||
u16 sum;
|
||||
u16 isum;
|
||||
u8 temp[BLOCKSIZE];
|
||||
__OSPackId newid;
|
||||
s32 ret;
|
||||
__OSPackId *id;
|
||||
__OSPackId* id;
|
||||
|
||||
SET_ACTIVEBANK_TO_ZERO;
|
||||
ERRCK(__osContRamRead(pfs->queue, pfs->channel, 1, (u8*)temp));
|
||||
ERRCK(__osContRamRead(pfs->queue, pfs->channel, PFS_ID_0AREA, (u8*)temp));
|
||||
__osIdCheckSum((u16*)temp, &sum, &isum);
|
||||
id = (__OSPackId*)temp;
|
||||
|
||||
if (id->checksum != sum || id->inverted_checksum != isum) {
|
||||
ret = __osCheckPackId(pfs, id);
|
||||
|
||||
if (ret == PFS_ERR_ID_FATAL) {
|
||||
ERRCK(__osRepairPackId(pfs, id, &newid));
|
||||
id = &newid;
|
||||
@ -159,45 +169,51 @@ s32 __osGetId(OSPfs *pfs) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
if ((id->deviceid & 1) == 0) { //TODO: remove magic constant
|
||||
|
||||
if ((id->deviceid & 1) == 0) {
|
||||
ERRCK(__osRepairPackId(pfs, id, &newid));
|
||||
id = &newid;
|
||||
|
||||
if ((id->deviceid & 1) == 0) {
|
||||
return PFS_ERR_DEVICE;
|
||||
}
|
||||
}
|
||||
bcopy(id, pfs->id, ARRAY_COUNT(pfs->id));
|
||||
|
||||
bcopy(id, pfs->id, BLOCKSIZE);
|
||||
pfs->version = id->version;
|
||||
pfs->banks = id->banks;
|
||||
pfs->inode_start_page = pfs->banks * 2 + 3; //TODO: loads of magic constants..
|
||||
pfs->inode_start_page = 1 + DEF_DIR_PAGES + (2 * pfs->banks);
|
||||
pfs->dir_size = 16;
|
||||
pfs->inode_table = 8;
|
||||
pfs->minode_table = (pfs->banks + 1) * PFS_ONE_PAGE;
|
||||
pfs->inode_table = PFS_ONE_PAGE;
|
||||
pfs->minode_table = (1 + pfs->banks) * PFS_ONE_PAGE;
|
||||
pfs->dir_table = pfs->minode_table + pfs->banks * PFS_ONE_PAGE;
|
||||
ERRCK(__osContRamRead(pfs->queue, pfs->channel, 7, pfs->label));
|
||||
ERRCK(__osContRamRead(pfs->queue, pfs->channel, PFS_LABEL_AREA, pfs->label));
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 __osCheckId(OSPfs *pfs) {
|
||||
s32 __osCheckId(OSPfs* pfs) {
|
||||
u8 temp[BLOCKSIZE];
|
||||
s32 ret;
|
||||
|
||||
if (pfs->activebank != 0) {
|
||||
ret = __osPfsSelectBank(pfs, 0);
|
||||
|
||||
if (ret == PFS_ERR_NEW_PACK) {
|
||||
ret = __osPfsSelectBank(pfs, 0);
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
ret = __osContRamRead(pfs->queue, pfs->channel, 1, temp);
|
||||
|
||||
ret = __osContRamRead(pfs->queue, pfs->channel, PFS_ID_0AREA, (u8*)temp);
|
||||
|
||||
if (ret != 0) {
|
||||
if (ret != PFS_ERR_NEW_PACK) {
|
||||
return ret;
|
||||
} else {
|
||||
ERRCK(__osContRamRead(pfs->queue, pfs->channel, 1, temp));
|
||||
}
|
||||
ERRCK(__osContRamRead(pfs->queue, pfs->channel, PFS_ID_0AREA, (u8*)temp));
|
||||
}
|
||||
|
||||
if (bcmp(pfs->id, temp, BLOCKSIZE) != 0) {
|
||||
@ -207,62 +223,67 @@ s32 __osCheckId(OSPfs *pfs) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 __osPfsRWInode(OSPfs *pfs, __OSInode *inode, u8 flag, u8 bank) {
|
||||
s32 __osPfsRWInode(OSPfs* pfs, __OSInode* inode, u8 flag, u8 bank) {
|
||||
u8 sum;
|
||||
int j;
|
||||
s32 ret;
|
||||
int offset;
|
||||
u8 *addr;
|
||||
u8* addr;
|
||||
|
||||
if (flag == PFS_READ && bank == __osPfsInodeCacheBank && pfs->channel == __osPfsInodeCacheChannel) {
|
||||
if (flag == PFS_READ && bank == __osPfsInodeCacheBank && (pfs->channel == __osPfsInodeCacheChannel)) {
|
||||
bcopy(&__osPfsInodeCache, inode, sizeof(__OSInode));
|
||||
return 0;
|
||||
}
|
||||
|
||||
SET_ACTIVEBANK_TO_ZERO;
|
||||
|
||||
if (bank > 0) {
|
||||
offset = 1;
|
||||
} else {
|
||||
offset = pfs->inode_start_page;
|
||||
}
|
||||
offset = (bank > 0) ? 1 : pfs->inode_start_page;
|
||||
|
||||
if (flag == PFS_WRITE) {
|
||||
inode->inode_page[0].inode_t.page = __osSumcalc((u8*)&inode->inode_page[offset], (128 - offset) * 2);
|
||||
inode->inode_page[0].inode_t.page =
|
||||
__osSumcalc((u8*)&inode->inode_page[offset], (PFS_INODE_SIZE_PER_PAGE - offset) * 2);
|
||||
}
|
||||
|
||||
for (j = 0; j < PFS_ONE_PAGE; j++) {
|
||||
addr = ((u8 *)inode->inode_page + j * 32);
|
||||
addr = ((u8*)inode->inode_page + j * BLOCKSIZE);
|
||||
|
||||
if (flag == PFS_WRITE) {
|
||||
ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->inode_table + bank * PFS_ONE_PAGE + j, addr, FALSE);
|
||||
ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->minode_table + bank * PFS_ONE_PAGE + j, addr, FALSE);
|
||||
} else {
|
||||
ret = __osContRamRead(pfs->queue, pfs->channel, pfs->inode_table + bank * 8 + j, addr);
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (flag == PFS_READ) {
|
||||
sum = __osSumcalc((u8*)&inode->inode_page[offset], (128 - offset) * 2);
|
||||
sum = __osSumcalc((u8*)&inode->inode_page[offset], (PFS_INODE_SIZE_PER_PAGE - offset) * 2);
|
||||
if (sum != inode->inode_page[0].inode_t.page) {
|
||||
for (j = 0; j < PFS_ONE_PAGE; j++) {
|
||||
addr = ((u8 *)inode->inode_page + j * 32);
|
||||
addr = ((u8*)inode->inode_page + j * BLOCKSIZE);
|
||||
ret = __osContRamRead(pfs->queue, pfs->channel, pfs->minode_table + bank * PFS_ONE_PAGE + j, addr);
|
||||
}
|
||||
sum = __osSumcalc((u8*)&inode->inode_page[offset], (128 - offset) * 2);
|
||||
|
||||
sum = __osSumcalc((u8*)&inode->inode_page[offset], (PFS_INODE_SIZE_PER_PAGE - offset) * 2);
|
||||
|
||||
if (sum != inode->inode_page[0].inode_t.page) {
|
||||
return PFS_ERR_INCONSISTENT;
|
||||
}
|
||||
|
||||
for (j = 0; j < PFS_ONE_PAGE; j++) {
|
||||
addr = ((u8 *)inode->inode_page + j * 32);
|
||||
ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->inode_table + bank * PFS_ONE_PAGE + j, addr, FALSE);
|
||||
addr = ((u8*)inode->inode_page + j * BLOCKSIZE);
|
||||
ret =
|
||||
__osContRamWrite(pfs->queue, pfs->channel, pfs->inode_table + bank * PFS_ONE_PAGE + j, addr, FALSE);
|
||||
}
|
||||
< |