Match Libultra (#120)

* Matched perspective, contquery, contreaddata, recvmesg and sendmesg

* Fixed libultra compilation flags

* Matched viblack

* Matched virepeatline, visetmode, visetspecial and viswapbuf

* Matched cartrominit, dpsetstat, sptask, sptaskyield, visetevent, createthread, gettime, setthreadpri, settime, settimer and starthread

* Fixed bss bs

* Matched even more libultra stuff

* Matched even more

* __osRdbSend

* Decompiled most of the functions of libultra <3

* Matched last functions

* Added a separation to libultra macros

* Removed ARRLEN from controller.h

* Fix libultra warnings

---------

Co-authored-by: Alejandro Javier Asenjo Nitti <alejandro.asenjo88@gmail.com>
This commit is contained in:
Lywx 2024-02-14 09:24:31 -06:00 committed by GitHub
parent ff2627c1ca
commit 902dc0b829
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
138 changed files with 10087 additions and 1430 deletions

View file

@ -196,9 +196,9 @@ WARNINGS := -fullwarn -verbose -woff 624,649,838,712,516,513,596,564,594,
ASFLAGS := -march=vr4300 -32 -G0
COMMON_DEFINES := -D_MIPS_SZLONG=32
GBI_DEFINES := -DF3DEX_GBI
RELEASE_DEFINES := -DNDEBUG -D_FINALROM
RELEASE_DEFINES := -DNDEBUG
AS_DEFINES := -DMIPSEB -D_LANGUAGE_ASSEMBLY -D_ULTRA64
C_DEFINES := -DLANGUAGE_C -D_LANGUAGE_C -DBUILD_VERSION=VERSION_H
C_DEFINES := -DLANGUAGE_C -D_LANGUAGE_C -DBUILD_VERSION=VERSION_H ${RELEASE_DEFINES}
ENDIAN := -EB
OPTFLAGS := -O2 -g3
@ -254,41 +254,130 @@ build/src/main/sys_audio_1EB50.o: OPTFLAGS := -O1 -g0
build/src/main/sys_sprintf.o: OPTFLAGS := -O2 -g0
build/src/main/sys_math64.o: OPTFLAGS := -O2 -g0
build/src/libultra/debug/kdebugserver.o: OPTFLAGS := -O1 -g0
build/src/libultra/gu/sqrtf.o: OPTFLAGS := -O3 -g0
build/src/libultra/gu/ortho.o: OPTFLAGS := -O3 -g0
build/src/libultra/gu/lookat.o: OPTFLAGS := -O3 -g0
build/src/libultra/gu/perspective.o: OPTFLAGS := -O3 -g0
build/src/libultra/gu/sinf.o: OPTFLAGS := -O3 -g0
build/src/libultra/gu/cosf.o: OPTFLAGS := -O3 -g0
build/src/libultra/gu/mtxutil.o: OPTFLAGS := -O3 -g0
build/src/libultra/io/pidma.o: OPTFLAGS := -O1 -g0
build/src/libultra/host/readhost.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/crc.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/contramwrite.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/cartrominit.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/contquery.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/contramread.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/devmgr.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/epidma.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/epirawdma.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/epirawwrite.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/epirawread.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/leodiskinit.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/leointerrupt.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/pigetcmdq.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/conteepread.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/conteepwrite.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/conteepprobe.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/contreaddata.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/dpsetstat.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/aisetnextbuf.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/pimgr.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/pidma.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/pirawdma.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/pfsisplug.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/spsetpc.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/motor.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/controller.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/ai.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/vi.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/aigetlen.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/aisetfreq.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/pfsgetstatus.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/si.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/siacs.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/sp.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/sirawdma.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/sirawread.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/sirawwrite.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/sprawwrite.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/sprawread.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/sprawdma.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/spgetstat.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/sptaskyielded.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/sptaskyield.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/sptask.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/spsetstat.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/pirawread.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/piacs.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/viblack.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/vimgr.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/vigetcurrcontext.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/virepeatline.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/visetmode.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/visetspecial.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/visetevent.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/viswapbuf.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/viswapcontext.o: OPTFLAGS := -O1 -g0
build/src/libultra/libc/ldiv.o: OPTFLAGS := -O2 -g0
build/src/libultra/libc/string.o: OPTFLAGS := -O2 -g0
build/src/libultra/libc/xlitob.o: OPTFLAGS := -O2 -g0
build/src/libultra/libc/xldtob.o: OPTFLAGS := -O3 -g0
build/src/libultra/libc/xprintf.o: OPTFLAGS := -O3 -g0
build/src/libultra/libc/ll.o: OPTFLAGS := -O1 -g0
build/src/libultra/libc/ll.o: MIPS_VERSION := -mips3 -32
build/src/libultra/os/createmesgqueue.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/createthread.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/setglobalintmask.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/gettime.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/initialize.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/jammesg.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/destroythread.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/getactivequeue.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/recvmesg.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/rdbsend.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/resetglobalintmask.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/sendmesg.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/startthread.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/stopthread.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/setthreadpri.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/settimer.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/settime.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/seteventmesg.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/initrdb.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/thread.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/timerintr.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/timerintr.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/getthreadpri.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/virtualtophysical.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/yieldthread.o: OPTFLAGS := -O1 -g0
build/src/libultra/rmon/rmoncmds.o: OPTFLAGS := -O1 -g0
build/src/libultra/rmon/rmonmain.o: OPTFLAGS := -O1 -g0
build/src/libultra/rmon/rmonmem.o: OPTFLAGS := -O1 -g0
build/src/libultra/rmon/rmonbrk.o: OPTFLAGS := -O1 -g0
build/src/libultra/rmon/rmontask.o: OPTFLAGS := -O1 -g0
build/src/libultra/rmon/rmonregs.o: OPTFLAGS := -O1 -g0
build/src/libultra/rmon/rmonmisc.o: OPTFLAGS := -O1 -g0
build/src/libultra/rmon/rmonmisc.o: OPTFLAGS := -O1 -G0
build/src/libultra/rmon/rmonsio.o: OPTFLAGS := -O1 -g0
# cc & asm-processor
CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(IDO) -- $(AS) $(ASFLAGS) --
build/src/libultra/gu/sqrtf.o: CC := $(IDO)
build/src/libultra/gu/sinf.o: CC := $(IDO)
build/src/libultra/gu/lookat.o: CC := $(IDO)
build/src/libultra/gu/ortho.o: CC := $(IDO)
build/src/libultra/libc/ll.o: CC := $(IDO)
build/src/libultra/gu/perspective.o: CC := $(IDO)
build/src/libultra/gu/mtxutil.o: CC := $(IDO)
build/src/libultra/gu/cosf.o: CC := $(IDO)
build/src/libultra/libc/xprintf.o: CC := $(IDO)
build/src/libultra/libc/xldtob.o: CC := $(IDO)
#build/src/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(IDO) -- $(AS) $(ASFLAGS) --

12
include/PR/assert.h Normal file
View file

@ -0,0 +1,12 @@
#ifndef __ASSERT_H__
#define __ASSERT_H__
#ifdef NDEBUG
#undef assert
#define assert(EX) ((void)0)
#else
extern void __assert(const char *, const char *, int);
#define assert(EX) ((EX)?((void)0):__assert("EX", __FILE__, __LINE__))
#endif /* NDEBUG */
#endif /* !__ASSERT_H__ */

View file

@ -1,12 +1,12 @@
#ifndef _CONTROLLER_H
#define _CONTROLLER_H
#include "macros.h"
#include "PR/ultratypes.h"
#include "PR/os_internal.h"
#include "PR/os_version.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

42
include/PR/guint.h Normal file
View file

@ -0,0 +1,42 @@
/**************************************************************************
* *
* Copyright (C) 1994, Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
**************************************************************************/
#include "PR/mbi.h"
#include "PR/gu.h"
typedef union
{
struct
{
unsigned int hi;
unsigned int lo;
} word;
double d;
} du;
typedef union
{
unsigned int i;
float f;
} fu;
#ifndef __GL_GL_H__
typedef float Matrix[4][4];
#endif
#define ROUND(d) (int)(((d) >= 0.0) ? ((d) + 0.5) : ((d) - 0.5))
#define ABS(d) ((d) > 0) ? (d) : -(d)
extern float __libm_qnan_f;

File diff suppressed because it is too large Load diff

92
include/PR/os_ai.h Normal file
View file

@ -0,0 +1,92 @@
/*====================================================================
* os_ai.h
*
* Copyright 1995, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo. (Originated by SGI)
$RCSfile: os_ai.h,v $
$Revision: 1.1 $
$Date: 1998/10/09 08:01:04 $
*---------------------------------------------------------------------*/
#ifndef _OS_AI_H_
#define _OS_AI_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
#endif
#include <PR/ultratypes.h>
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Type definitions
*
*/
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
/**************************************************************************
*
* Global definitions
*
*/
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Macro definitions
*
*/
/**************************************************************************
*
* Extern variables
*
*/
/**************************************************************************
*
* Function prototypes
*
*/
/* Audio interface (Ai) */
extern u32 osAiGetStatus(void);
extern u32 osAiGetLength(void);
extern s32 osAiSetFrequency(u32);
extern s32 osAiSetNextBuffer(void *, u32);
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
#ifdef _LANGUAGE_C_PLUS_PLUS
}
#endif
#endif /* !_OS_AI_H_ */

96
include/PR/os_cache.h Normal file
View file

@ -0,0 +1,96 @@
/*====================================================================
* os_cache.h
*
* Copyright 1995, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo. (Originated by SGI)
$RCSfile: os_cache.h,v $
$Revision: 1.1 $
$Date: 1998/10/09 08:01:04 $
*---------------------------------------------------------------------*/
#ifndef _OS_CACHE_H_
#define _OS_CACHE_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
#endif
#include <PR/ultratypes.h>
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Type definitions
*
*/
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
/**************************************************************************
*
* Global definitions
*
*/
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Macro definitions
*
*/
#define OS_DCACHE_ROUNDUP_ADDR(x) (void *)(((((u32)(x)+0xf)/0x10)*0x10))
#define OS_DCACHE_ROUNDUP_SIZE(x) (u32)(((((u32)(x)+0xf)/0x10)*0x10))
/**************************************************************************
*
* Extern variables
*
*/
/**************************************************************************
*
* Function prototypes
*
*/
/* Cache operations and macros */
extern void osInvalDCache(void *, s32);
extern void osInvalICache(void *, s32);
extern void osWritebackDCache(void *, s32);
extern void osWritebackDCacheAll(void);
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
#ifdef _LANGUAGE_C_PLUS_PLUS
}
#endif
#endif /* !_OS_CACHE_H_ */

208
include/PR/os_cont.h Normal file
View file

@ -0,0 +1,208 @@
/*====================================================================
* os_cont.h
*
* Copyright 1995, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo. (Originated by SGI)
$RCSfile: os_cont.h,v $
$Revision: 1.1 $
$Date: 1998/10/09 08:01:05 $
*---------------------------------------------------------------------*/
#ifndef _OS_CONT_H_
#define _OS_CONT_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
#endif
#include <PR/ultratypes.h>
#include "os_message.h"
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Type definitions
*
*/
/*
* Structure for controllers
*/
typedef struct {
u16 type; /* Controller Type */
u8 status; /* Controller status */
u8 errno;
}OSContStatus;
typedef struct {
u16 button;
s8 stick_x; /* -80 <= stick_x <= 80 */
s8 stick_y; /* -80 <= stick_y <= 80 */
u8 errno;
} OSContPad;
typedef struct {
void *address; /* Ram pad Address: 11 bits */
u8 databuffer[32]; /* address of the data buffer */
u8 addressCrc; /* CRC code for address */
u8 dataCrc; /* CRC code for data */
u8 errno;
} OSContRamIo;
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
/**************************************************************************
*
* Global definitions
*
*/
/*
* Controllers number
*/
#ifndef _HW_VERSION_1
#define MAXCONTROLLERS 4
#else
#define MAXCONTROLLERS 6
#endif
/* controller errors */
#define CONT_NO_RESPONSE_ERROR 0x8
#define CONT_OVERRUN_ERROR 0x4
#define CONT_RANGE_ERROR -1
#ifdef _HW_VERSION_1
#define CONT_FRAME_ERROR 0x2
#define CONT_COLLISION_ERROR 0x1
#endif
/* Controller type */
#define CONT_ABSOLUTE 0x0001
#define CONT_RELATIVE 0x0002
#define CONT_JOYPORT 0x0004
#define CONT_EEPROM 0x8000
#define CONT_EEP16K 0x4000
#define CONT_TYPE_MASK 0x1f07
#define CONT_TYPE_NORMAL 0x0005
#define CONT_TYPE_MOUSE 0x0002
#define CONT_TYPE_VOICE 0x0100
/* Controller status */
#define CONT_CARD_ON 0x01
#define CONT_CARD_PULL 0x02
#define CONT_ADDR_CRC_ER 0x04
#define CONT_EEPROM_BUSY 0x80
/* Buttons */
#define CONT_A 0x8000
#define CONT_B 0x4000
#define CONT_G 0x2000
#define CONT_START 0x1000
#define CONT_UP 0x0800
#define CONT_DOWN 0x0400
#define CONT_LEFT 0x0200
#define CONT_RIGHT 0x0100
#define CONT_L 0x0020
#define CONT_R 0x0010
#define CONT_E 0x0008
#define CONT_D 0x0004
#define CONT_C 0x0002
#define CONT_F 0x0001
/* Nintendo's official button names */
#define A_BUTTON CONT_A
#define B_BUTTON CONT_B
#define L_TRIG CONT_L
#define R_TRIG CONT_R
#define Z_TRIG CONT_G
#define START_BUTTON CONT_START
#define U_JPAD CONT_UP
#define L_JPAD CONT_LEFT
#define R_JPAD CONT_RIGHT
#define D_JPAD CONT_DOWN
#define U_CBUTTONS CONT_E
#define L_CBUTTONS CONT_C
#define R_CBUTTONS CONT_F
#define D_CBUTTONS CONT_D
/* Controller error number */
#define CONT_ERR_NO_CONTROLLER PFS_ERR_NOPACK /* 1 */
#define CONT_ERR_CONTRFAIL CONT_OVERRUN_ERROR /* 4 */
#define CONT_ERR_INVALID PFS_ERR_INVALID /* 5 */
#define CONT_ERR_DEVICE PFS_ERR_DEVICE /* 11 */
#define CONT_ERR_NOT_READY 12
#define CONT_ERR_VOICE_MEMORY 13
#define CONT_ERR_VOICE_WORD 14
#define CONT_ERR_VOICE_NO_RESPONSE 15
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Macro definitions
*
*/
/**************************************************************************
*
* Extern variables
*
*/
/**************************************************************************
*
* Function prototypes
*
*/
/* Controller interface */
extern s32 osContInit(OSMesgQueue *, u8 *, OSContStatus *);
extern s32 osContReset(OSMesgQueue *, OSContStatus *);
extern s32 osContStartQuery(OSMesgQueue *);
extern s32 osContStartReadData(OSMesgQueue *);
#ifndef _HW_VERSION_1
extern s32 osContSetCh(u8);
#endif
extern void osContGetQuery(OSContStatus *);
extern void osContGetReadData(OSContPad *);
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
#ifdef _LANGUAGE_C_PLUS_PLUS
}
#endif
#endif /* !_OS_CONT_H_ */

111
include/PR/os_convert.h Normal file
View file

@ -0,0 +1,111 @@
/*====================================================================
* os_convert.h
*
* Copyright 1995, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo. (Originated by SGI)
$RCSfile: os_convert.h,v $
$Revision: 1.2 $
$Date: 1999/04/21 02:53:11 $
*---------------------------------------------------------------------*/
#ifndef _OS_CONVERT_H_
#define _OS_CONVERT_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
#endif
#include <PR/ultratypes.h>
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Type definitions
*
*/
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
/**************************************************************************
*
* Global definitions
*
*/
#define OS_CLOCK_RATE 62500000LL
#define OS_CPU_COUNTER (OS_CLOCK_RATE*3/4)
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Macro definitions
*
*/
#define OS_NSEC_TO_CYCLES(n) (((u64)(n)*(OS_CPU_COUNTER/15625000LL))/(1000000000LL/15625000LL))
#define OS_USEC_TO_CYCLES(n) (((u64)(n)*(OS_CPU_COUNTER/15625LL))/(1000000LL/15625LL))
#define OS_CYCLES_TO_NSEC(c) (((u64)(c)*(1000000000LL/15625000LL))/(OS_CPU_COUNTER/15625000LL))
#define OS_CYCLES_TO_USEC(c) (((u64)(c)*(1000000LL/15625LL))/(OS_CPU_COUNTER/15625LL))
/* OS_K?_TO_PHYSICAL macro bug fix for CodeWarrior */
#ifndef __MWERKS__
#define OS_K0_TO_PHYSICAL(x) (u32)(((char *)(x)-0x80000000))
#define OS_K1_TO_PHYSICAL(x) (u32)(((char *)(x)-0xa0000000))
#else
#define OS_K0_TO_PHYSICAL(x) ((char *)(x)-0x80000000)
#define OS_K1_TO_PHYSICAL(x) ((char *)(x)-0xa0000000)
#endif
#define OS_PHYSICAL_TO_K0(x) (void *)(((u32)(x)+0x80000000))
#define OS_PHYSICAL_TO_K1(x) (void *)(((u32)(x)+0xa0000000))
/**************************************************************************
*
* Extern variables
*
*/
/**************************************************************************
*
* Function prototypes
*
*/
/* Address translation routines and macros */
extern u32 osVirtualToPhysical(void *);
extern void * osPhysicalToVirtual(u32);
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
#ifdef _LANGUAGE_C_PLUS_PLUS
}
#endif
#endif /* !_OS_CONVERT_H_ */

117
include/PR/os_debug.h Normal file
View file

@ -0,0 +1,117 @@
/*====================================================================
* os_debug.h
*
* Copyright 1995, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo. (Originated by SGI)
$RCSfile: os_debug.h,v $
$Revision: 1.4 $
$Date: 1999/06/30 03:04:08 $
*---------------------------------------------------------------------*/
#ifndef _OS_DEBUG_H_
#define _OS_DEBUG_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
#endif
#include <PR/ultratypes.h>
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Type definitions
*
*/
/*
* Structure for Profiler
*/
typedef struct {
u16 *histo_base; /* histogram base */
u32 histo_size; /* histogram size */
u32 *text_start; /* start of text segment */
u32 *text_end; /* end of text segment */
} OSProf;
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
/**************************************************************************
*
* Global definitions
*
*/
/*
* Profiler constants
*/
#define PROF_MIN_INTERVAL 50 /* microseconds */
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Macro definitions
*
*/
/**************************************************************************
*
* Extern variables
*
*/
/**************************************************************************
*
* Function prototypes
*
*/
/* Profiler Interface */
extern void osProfileInit(OSProf *, u32 profcnt);
extern void osProfileStart(u32);
extern void osProfileFlush(void);
extern void osProfileStop(void);
/* Thread Profiler Interface */
extern void osThreadProfileClear(OSId);
extern void osThreadProfileInit(void);
extern void osThreadProfileStart(void);
extern void osThreadProfileStop(void);
extern u32 osThreadProfileReadCount(OSId);
extern u32 osThreadProfileReadCountTh(OSThread*);
extern OSTime osThreadProfileReadTime(OSId);
extern OSTime osThreadProfileReadTimeTh(OSThread*);
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
#ifdef _LANGUAGE_C_PLUS_PLUS
}
#endif
#endif /* !_OS_DEBUG_H_ */

107
include/PR/os_eeprom.h Normal file
View file

@ -0,0 +1,107 @@
/*====================================================================
* os_eeprom.h
*
* Copyright 1995, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo. (Originated by SGI)
$RCSfile: os_eeprom.h,v $
$Revision: 1.1 $
$Date: 1998/10/09 08:01:06 $
*---------------------------------------------------------------------*/
#ifndef _OS_EEPROM_H_
#define _OS_EEPROM_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
#endif
#include <PR/ultratypes.h>
#include "PR/os_message.h"
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Type definitions
*
*/
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
/**************************************************************************
*
* Global definitions
*
*/
/* EEPROM TYPE */
#define EEPROM_TYPE_4K 0x01
#define EEPROM_TYPE_16K 0x02
/* definition for EEPROM */
#define EEPROM_MAXBLOCKS 64
#define EEP16K_MAXBLOCKS 256
#define EEPROM_BLOCK_SIZE 8
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Macro definitions
*
*/
/**************************************************************************
*
* Extern variables
*
*/
/**************************************************************************
*
* Function prototypes
*
*/
/* EEPROM interface */
extern s32 osEepromProbe(OSMesgQueue *);
extern s32 osEepromRead(OSMesgQueue *, u8, u8 *);
extern s32 osEepromWrite(OSMesgQueue *, u8, u8 *);
extern s32 osEepromLongRead(OSMesgQueue *, u8, u8 *, int);
extern s32 osEepromLongWrite(OSMesgQueue *, u8, u8 *, int);
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
#ifdef _LANGUAGE_C_PLUS_PLUS
}
#endif
#endif /* !_OS_EEPROM_H_ */

86
include/PR/os_error.h Normal file
View file

@ -0,0 +1,86 @@
/*====================================================================
* os_error.h
*
* Copyright 1995, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo. (Originated by SGI)
$RCSfile: os_error.h,v $
$Revision: 1.1 $
$Date: 1998/10/09 08:01:06 $
*---------------------------------------------------------------------*/
#ifndef _OS_ERROR_H_
#define _OS_ERROR_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
#endif
#include <PR/ultratypes.h>
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Type definitions
*
*/
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
/**************************************************************************
*
* Global definitions
*
*/
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Macro definitions
*
*/
/**************************************************************************
*
* Extern variables
*
*/
/**************************************************************************
*
* Function prototypes
*
*/
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
#ifdef _LANGUAGE_C_PLUS_PLUS
}
#endif
#endif /* !_OS_ERROR_H_ */

86
include/PR/os_exception.h Normal file
View file

@ -0,0 +1,86 @@
/*====================================================================
* os_exception.h
*
* Copyright 1995, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo. (Originated by SGI)
$RCSfile: os_exception.h,v $
$Revision: 1.1 $
$Date: 1998/10/09 08:01:07 $
*---------------------------------------------------------------------*/
#ifndef _OS_EXCEPTION_H_
#define _OS_EXCEPTION_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
#endif
#include "PR/ultratypes.h"
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
typedef u32 OSIntMask;
typedef u32 OSHWIntr;
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
/* Flags for debugging purpose */
#define OS_FLAG_CPU_BREAK 1 /* Break exception has occurred */
#define OS_FLAG_FAULT 2 /* CPU fault has occurred */
/* Interrupt masks */
#define OS_IM_NONE 0x00000001
#define OS_IM_RCP 0x00000401
#define OS_IM_SW1 0x00000501
#define OS_IM_SW2 0x00000601
#define OS_IM_CART 0x00000c01
#define OS_IM_PRENMI 0x00001401
#define OS_IM_RDBWRITE 0x00002401
#define OS_IM_RDBREAD 0x00004401
#define OS_IM_COUNTER 0x00008401
#define OS_IM_CPU 0x0000ff01
#define OS_IM_SP 0x00010401
#define OS_IM_SI 0x00020401
#define OS_IM_AI 0x00040401
#define OS_IM_VI 0x00080401
#define OS_IM_PI 0x00100401
#define OS_IM_DP 0x00200401
#define OS_IM_ALL 0x003fff01
#define RCP_IMASK 0x003f0000
#define RCP_IMASKSHIFT 16
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/* Interrupt operations */
extern OSIntMask osGetIntMask(void);
extern OSIntMask osSetIntMask(OSIntMask);
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
#ifdef _LANGUAGE_C_PLUS_PLUS
}
#endif
#endif /* !_OS_EXCEPTION_H_ */

77
include/PR/os_flash.h Normal file
View file

@ -0,0 +1,77 @@
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo.
$RCSfile: os_flash.h,v $
$Revision: 1.1 $
$Date: 2000/06/15 06:24:55 $
*---------------------------------------------------------------------*/
#ifndef _OS_FLASH_H_
#define _OS_FLASH_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
#endif
#include "PR/ultratypes.h"
#include "PR/os_pi.h"
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/*
* defines for FLASH
*/
#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_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
/* 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_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);
extern OSPiHandle *osFlashInit(void);
extern void osFlashReadStatus(u8 *flash_status);
extern void osFlashReadId(u32 *flash_type, u32 *flash_maker);
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);
extern s32 osFlashWriteArray(u32 page_num);
extern s32 osFlashReadArray(OSIoMesg *mb, s32 priority, u32 page_num,
void *dramAddr, u32 n_pages, OSMesgQueue *mq);
extern void osFlashChange(u32 flash_num);
extern void osFlashAllEraseThrough(void);
extern void osFlashSectorEraseThrough(u32 page_num);
extern s32 osFlashCheckEraseEnd(void);
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
#ifdef _LANGUAGE_C_PLUS_PLUS
}
#endif
#endif /* !_OS_FLASH_H_ */

107
include/PR/os_gbpak.h Normal file
View file

@ -0,0 +1,107 @@
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo.
$RCSfile: os_gbpak.h,v $
$Revision: 1.1 $
$Date: 1998/10/09 08:01:07 $
*---------------------------------------------------------------------*/
#ifndef _OS_GBPAK_H_
#define _OS_GBPAK_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
#endif
#include <PR/ultratypes.h>
#include "os_message.h"
#include "os_pfs.h"
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Type definitions
*
*/
typedef struct {
u16 fixed1;
u16 start_address;
u8 nintendo_chr[0x30];
u8 game_title[16];
u16 company_code;
u8 body_code;
u8 cart_type;
u8 rom_size;
u8 ram_size;
u8 country_code;
u8 fixed2;
u8 version;
u8 isum;
u16 sum;
} OSGbpakId;
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
/**************************************************************************
*
* Global definitions
*
*/
/* definition for 64GB-PAK */
#define OS_GBPAK_POWER 0x01
#define OS_GBPAK_RSTB_DETECTION 0x04
#define OS_GBPAK_RSTB_STATUS 0x08
#define OS_GBPAK_GBCART_PULL 0x40
#define OS_GBPAK_GBCART_ON 0x80
#define OS_GBPAK_POWER_OFF 0x00 /* power of 64GB-PAK */
#define OS_GBPAK_POWER_ON 0x01
#define OS_GBPAK_ROM_ID_SIZE 0x50 /* ID size of GB cartridge */
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Macro definitions
*
*/
/**************************************************************************
*
* Extern variables
*
*/
/**************************************************************************
*
* Function prototypes
*
*/
/* 64GB-PAK */
extern s32 osGbpakInit(OSMesgQueue *, OSPfs *, int);
extern s32 osGbpakPower(OSPfs *, s32);
extern s32 osGbpakGetStatus(OSPfs *, u8 *);
extern s32 osGbpakReadWrite(OSPfs *, u16, u16, u8 *, u16);
extern s32 osGbpakReadId(OSPfs *, OSGbpakId *, u8 *);
extern s32 osGbpakCheckConnector(OSPfs *, u8 *);
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
#ifdef _LANGUAGE_C_PLUS_PLUS
}
#endif
#endif /* !_OS_GBPAK_H_ */

86
include/PR/os_gio.h Normal file
View file

@ -0,0 +1,86 @@
/*====================================================================
* os_gio.h
*
* Copyright 1995, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo. (Originated by SGI)
$RCSfile: os_gio.h,v $
$Revision: 1.1 $
$Date: 1998/10/09 08:01:08 $
*---------------------------------------------------------------------*/
#ifndef _OS_GIO_H_
#define _OS_GIO_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
#endif
#include <PR/ultratypes.h>
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Type definitions
*
*/
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
/**************************************************************************
*
* Global definitions
*
*/
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Macro definitions
*
*/
/**************************************************************************
*
* Extern variables
*
*/
/**************************************************************************
*
* Function prototypes
*
*/
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
#ifdef _LANGUAGE_C_PLUS_PLUS
}
#endif
#endif /* !_OS_GIO_H_ */

166
include/PR/os_host.h Normal file
View file

@ -0,0 +1,166 @@
/*====================================================================
* os_host.h
*
* Copyright 1995, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo. (Originated by SGI)
$RCSfile: os_host.h,v $
$Revision: 1.3 $
$Date: 1999/06/24 09:23:06 $
*---------------------------------------------------------------------*/
#ifndef _OS_HOST_H_
#define _OS_HOST_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
#endif
#include <PR/ultratypes.h>
#include <PR/os_version.h>
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Type definitions
*
*/
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
/**************************************************************************
*
* Global definitions
*
*/
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Macro definitions
*
*/
extern void __osInitialize_common(void);
#if defined(_FINALROM)
#define osInitialize() __osInitialize_common()
#else
/* PARTNER-N64 */
#if defined(PTN64)
extern void __osInitialize_kmc(void);
#define osReadHost osReadHost_pt
#define osWriteHost osWriteHost_pt
#define osInitialize() \
{ \
__osInitialize_common(); \
__osInitialize_kmc(); \
}
/* MONEGI SMART PACK A */
#elif defined(MWN64)
extern void __osInitialize_msp(void);
#define osReadHost osReadHost_pt
#define osWriteHost osWriteHost_pt
#define osInitialize() \
{ \
__osInitialize_common(); \
__osInitialize_msp(); \
}
/* IS-Viewer(for Debugger) */
#elif defined(ISV64)
extern void __osInitialize_isv(void);
#define osInitialize() \
{ \
__osInitialize_common(); \
__osInitialize_isv(); \
}
/* Emulation board for INDY */
#elif defined(EMU64)
extern void __osInitialize_emu(void);
#define osInitialize() \
{ \
__osInitialize_common(); \
__osInitialize_emu(); \
}
#else
/* Default (auto detect) */
extern void __osInitialize_autodetect(void);
extern void __osInitialize_msp(void);
extern void __osInitialize_kmc(void);
extern void __osInitialize_isv(void);
extern void __osInitialize_emu(void);
#define osInitialize() \
{ \
__osInitialize_common(); \
__osInitialize_autodetect(); \
}
#endif
#endif /* _FINAL_ROM */
#if BUILD_VERSION < VERSION_K
#undef osInitialize
#endif
/**************************************************************************
*
* Extern variables
*
*/
/**************************************************************************
*
* Function prototypes
*
*/
/* Game <> Host data transfer functions */
extern s32 osTestHost(void);
extern void osReadHost(void *, u32);
extern void osWriteHost(void *, u32);
extern void osAckRamromRead(void);
extern void osAckRamromWrite(void);
/* RDB port operations */
extern void osInitRdb(u8 *sendBuf, u32 sendSize);
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
#ifdef _LANGUAGE_C_PLUS_PLUS
}
#endif
#endif /* !_OS_HOST_H_ */

View file

@ -26,6 +26,7 @@ extern "C" {
#endif
#include <PR/os.h>
#include "PR/os_version.h"
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)

100
include/PR/os_libc.h Normal file
View file

@ -0,0 +1,100 @@
/*====================================================================
* os_libc.h
*
* Copyright 1995, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo. (Originated by SGI)
$RCSfile: os_libc.h,v $
$Revision: 1.3 $
$Date: 1999/07/13 01:43:47 $
*---------------------------------------------------------------------*/
#ifndef _OS_LIBC_H_
#define _OS_LIBC_H_
#include "os_pfs.h"
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
#endif
#include <PR/ultratypes.h>
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Type definitions
*
*/
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
/**************************************************************************
*
* Global definitions
*
*/
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Macro definitions
*
*/
/**************************************************************************
*
* Extern variables
*
*/
/**************************************************************************
*
* Function prototypes
*
*/
/* byte string operations */
extern void bcopy(const void *, void *, int);
extern int bcmp(const void *, const void *, int);
extern void bzero(void *, int);
/* Printf */
extern int sprintf(char *s, const char *fmt, ...);
extern void osSyncPrintf(const char *fmt, ...);
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
#ifdef _LANGUAGE_C_PLUS_PLUS
}
#endif
#endif /* !_OS_LIBC_H_ */

162
include/PR/os_message.h Normal file
View file

@ -0,0 +1,162 @@
/*====================================================================
* os_message.h
*
* Copyright 1995, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo. (Originated by SGI)
$RCSfile: os_message.h,v $
$Revision: 1.1 $
$Date: 1998/10/09 08:01:15 $
*---------------------------------------------------------------------*/
#ifndef _OS_MESSAGE_H_
#define _OS_MESSAGE_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
#endif
#include "PR/ultratypes.h"
#include "PR/os_thread.h"
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Type definitions
*
*/
typedef u32 OSEvent;
/*
* Structure for message
*/
typedef void *OSMesg;
/*
* Structure for message queue
*/
typedef struct OSMesgQueue_s {
OSThread *mtqueue; /* Queue to store threads blocked on empty mailboxes (receive) */
OSThread *fullqueue; /* Queue to store threads blocked on full mailboxes (send) */
s32 validCount; /* Contains number of valid message */
s32 first; /* Points to first valid message */
s32 msgCount; /* Contains total # of messages */
OSMesg *msg; /* Points to message buffer array */
} OSMesgQueue;
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
/**************************************************************************
*
* Global definitions
*
*/
/* Events */
#ifdef _FINALROM
#define OS_NUM_EVENTS 15
#else
#define OS_NUM_EVENTS 23
#endif
#define OS_EVENT_SW1 0 /* CPU SW1 interrupt */
#define OS_EVENT_SW2 1 /* CPU SW2 interrupt */
#define OS_EVENT_CART 2 /* Cartridge interrupt: used by rmon */
#define OS_EVENT_COUNTER 3 /* Counter int: used by VI/Timer Mgr */
#define OS_EVENT_SP 4 /* SP task done interrupt */
#define OS_EVENT_SI 5 /* SI (controller) interrupt */
#define OS_EVENT_AI 6 /* AI interrupt */
#define OS_EVENT_VI 7 /* VI interrupt: used by VI/Timer Mgr */
#define OS_EVENT_PI 8 /* PI interrupt: used by PI Manager */
#define OS_EVENT_DP 9 /* DP full sync interrupt */
#define OS_EVENT_CPU_BREAK 10 /* CPU breakpoint: used by rmon */
#define OS_EVENT_SP_BREAK 11 /* SP breakpoint: used by rmon */
#define OS_EVENT_FAULT 12 /* CPU fault event: used by rmon */
#define OS_EVENT_THREADSTATUS 13 /* CPU thread status: used by rmon */
#define OS_EVENT_PRENMI 14 /* Pre NMI interrupt */
#ifndef _FINALROM
#define OS_EVENT_RDB_READ_DONE 15 /* RDB read ok event: used by rmon */
#define OS_EVENT_RDB_LOG_DONE 16 /* read of log data complete */
#define OS_EVENT_RDB_DATA_DONE 17 /* read of hostio data complete */
#define OS_EVENT_RDB_REQ_RAMROM 18 /* host needs ramrom access */
#define OS_EVENT_RDB_FREE_RAMROM 19 /* host is done with ramrom access */
#define OS_EVENT_RDB_DBG_DONE 20
#define OS_EVENT_RDB_FLUSH_PROF 21
#define OS_EVENT_RDB_ACK_PROF 22
#endif
/* Flags to turn blocking on/off when sending/receiving message */
#define OS_MESG_NOBLOCK 0
#define OS_MESG_BLOCK 1
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Macro definitions
*
*/
/* Get count of valid messages in queue */
#define MQ_GET_COUNT(mq) ((mq)->validCount)
/* Figure out if message queue is empty or full */
#define MQ_IS_EMPTY(mq) (MQ_GET_COUNT(mq) == 0)
#define MQ_IS_FULL(mq) (MQ_GET_COUNT(mq) >= (mq)->msgCount)
/**************************************************************************
*
* Extern variables
*
*/
/**************************************************************************
*
* Function prototypes
*
*/
/* Message operations */
extern void osCreateMesgQueue(OSMesgQueue *, OSMesg *, s32);
extern s32 osSendMesg(OSMesgQueue *, OSMesg, s32);
extern s32 osJamMesg(OSMesgQueue *, OSMesg, s32);
extern s32 osRecvMesg(OSMesgQueue *, OSMesg *, s32);
/* Event operations */
extern void osSetEventMesg(OSEvent, OSMesgQueue *, OSMesg);
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
#ifdef _LANGUAGE_C_PLUS_PLUS
}
#endif
#endif /* !_OS_MESSAGE_H_ */

84
include/PR/os_motor.h Normal file
View file

@ -0,0 +1,84 @@
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo.
$RCSfile: os_motor.h,v $
$Revision: 1.1 $
$Date: 1998/10/09 08:01:15 $
*---------------------------------------------------------------------*/
#ifndef _OS_MOTOR_H_
#define _OS_MOTOR_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
#endif
#include <PR/ultratypes.h>
#include "PR/os_message.h"
#include "PR/os_pfs.h"
#include "PR/os_version.h"
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Type definitions
*
*/
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
/**************************************************************************
*
* Global definitions
*
*/
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Macro definitions
*
*/
/**************************************************************************
*
* Extern variables
*
*/
/**************************************************************************
*
* Function prototypes
*
*/
/* Rumble PAK interface */
extern s32 osMotorInit(OSMesgQueue *, OSPfs *, int);
#if BUILD_VERSION >= VERSION_J
#define MOTOR_START 1
#define MOTOR_STOP 0
#define osMotorStart(x) __osMotorAccess((x), MOTOR_START)
#define osMotorStop(x) __osMotorAccess((x), MOTOR_STOP)
extern s32 __osMotorAccess(OSPfs *, s32);
#else
extern s32 osMotorStop(OSPfs *);
extern s32 osMotorStart(OSPfs *);
#endif
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
#ifdef _LANGUAGE_C_PLUS_PLUS
}
#endif
#endif /* !_OS_MOTOR_H_ */

200
include/PR/os_pfs.h Normal file
View file

@ -0,0 +1,200 @@
/*====================================================================
* os_pfs.h
*
* Copyright 1995, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo. (Originated by SGI)
$RCSfile: os_pfs.h,v $
$Revision: 1.1 $
$Date: 1998/10/09 08:01:16 $
*---------------------------------------------------------------------*/
#ifndef _OS_PFS_H_
#define _OS_PFS_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
#endif
#include <PR/ultratypes.h>
#include "PR/os_message.h"
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Type definitions
*
*/
/*
* Structure for file system
*/
typedef struct {
int status;
OSMesgQueue *queue;
int channel;
u8 id[32];
u8 label[32];
int version;
int dir_size;
int inode_table; /* block location */
int minode_table; /* mirrioring inode_table */
int dir_table; /* block location */
int inode_start_page; /* page # */
u8 banks;
u8 activebank;
} OSPfs;
typedef struct {
u32 file_size; /* bytes */
u32 game_code;
u16 company_code;
char ext_name[4];
char game_name[16];
} OSPfsState;
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
/**************************************************************************
*
* Global definitions
*
*/
/* 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
/* File System flag */
#define PFS_READ 0
#define PFS_WRITE 1
#define PFS_CREATE 2
/* File System status */
#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 */
/* 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)
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Macro definitions
*
*/
/**************************************************************************
*
* Extern variables
*
*/
/**************************************************************************
*
* Function prototypes
*
*/
/* file system interface */
extern s32 osPfsInitPak(OSMesgQueue *, OSPfs *, int);
extern s32 osPfsRepairId(OSPfs *);
extern s32 osPfsInit(OSMesgQueue *, OSPfs *, int);
extern s32 osPfsReFormat(OSPfs *, OSMesgQueue *, int);
extern s32 osPfsChecker(OSPfs *);
extern s32 osPfsAllocateFile(OSPfs *, u16, u32, u8 *, u8 *, int, s32 *);
extern s32 osPfsFindFile(OSPfs *, u16, u32, u8 *, u8 *, s32 *);
extern s32 osPfsDeleteFile(OSPfs *, u16, u32, u8 *, u8 *);
extern s32 osPfsReadWriteFile(OSPfs *, s32, u8, int, int, u8 *);
extern s32 osPfsFileState(OSPfs *, s32, OSPfsState *);
extern s32 osPfsGetLabel(OSPfs *, u8 *, int *);
extern s32 osPfsSetLabel(OSPfs *, u8 *);
extern s32 osPfsIsPlug(OSMesgQueue *, u8 *);
extern s32 osPfsFreeBlocks(OSPfs *, s32 *);
extern s32 osPfsNumFiles(OSPfs *, s32 *, s32 *);
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
#ifdef _LANGUAGE_C_PLUS_PLUS
}
#endif
#endif /* !_OS_PFS_H_ */

221
include/PR/os_pi.h Normal file
View file

@ -0,0 +1,221 @@
/*====================================================================
* os_pi.h
*
* Copyright 1995, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo. (Originated by SGI)
$RCSfile: os_pi.h,v $
$Revision: 1.1 $
$Date: 1998/10/09 08:01:16 $
*---------------------------------------------------------------------*/
#ifndef _OS_PI_H_
#define _OS_PI_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
#endif
#include "PR/ultratypes.h"
#include "PR/os_thread.h"
#include "PR/os_message.h"
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Type definitions
*
*/
/*
* Structure for Enhanced PI interface
*/
/*
* OSTranxInfo is set up for Leo Disk DMA. This info will be maintained
* by exception handler. This is how the PIMGR and the ISR communicate.
*/
typedef struct {
u32 errStatus; /* error status */
void *dramAddr; /* RDRAM buffer address (DMA) */
void *C2Addr; /* C2 buffer address */
u32 sectorSize; /* size of transfering sector */
u32 C1ErrNum; /* total # of C1 errors */
u32 C1ErrSector[4]; /* error sectors */
} __OSBlockInfo;
typedef struct {
u32 cmdType; /* for disk only */
u16 transferMode; /* Block, Track, or sector? */
u16 blockNum; /* which block is transfering */
s32 sectorNum; /* which sector is transfering */
u32 devAddr; /* Device buffer address */
u32 bmCtlShadow; /* asic bm_ctl(510) register shadow ram */
u32 seqCtlShadow; /* asic seq_ctl(518) register shadow ram */
__OSBlockInfo block[2]; /* bolck transfer info */
} __OSTranxInfo;
typedef struct OSPiHandle_s {
struct OSPiHandle_s *next; /* point to next handle on the table */
u8 type; /* DEVICE_TYPE_BULK for disk */
u8 latency; /* domain latency */
u8 pageSize; /* domain page size */
u8 relDuration; /* domain release duration */
u8 pulse; /* domain pulse width */
u8 domain; /* which domain */
u32 baseAddress; /* Domain address */
u32 speed; /* for roms only */
/* The following are "private" elements" */
__OSTranxInfo transferInfo; /* for disk only */
} OSPiHandle;
typedef struct {
u8 type;
u32 address;
} OSPiInfo;
/*
* Structure for I/O message block
*/
typedef struct {
u16 type; /* Message type */
u8 pri; /* Message priority (High or Normal) */
u8 status; /* Return status */
OSMesgQueue *retQueue; /* Return message queue to notify I/O completion */
} OSIoMesgHdr;
typedef struct {
OSIoMesgHdr hdr; /* Message header */
void *dramAddr; /* RDRAM buffer address (DMA) */
u32 devAddr; /* Device buffer address (DMA) */
u32 size; /* DMA transfer size in bytes */
OSPiHandle *piHandle; /* PI device handle */
} OSIoMesg;
/*
* Structure for device manager block
*/
typedef struct {
s32 active; /* Status flag */
OSThread *thread; /* Calling thread */
OSMesgQueue *cmdQueue; /* Command queue */
OSMesgQueue *evtQueue; /* Event queue */
OSMesgQueue *acsQueue; /* Access queue */
/* Raw DMA routine */
s32 (*dma)(s32, u32, void *, u32);
s32 (*edma)(OSPiHandle *, s32, u32, void *, u32);
} OSDevMgr;
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
/**************************************************************************
*
* Global definitions
*
*/
/* Flags to indicate direction of data transfer */
#define OS_READ 0 /* device -> RDRAM */
#define OS_WRITE 1 /* device <- RDRAM */
#define OS_OTHERS 2 /* for Leo disk only */
/*
* I/O message types
*/
#define OS_MESG_TYPE_BASE (10)
#define OS_MESG_TYPE_LOOPBACK (OS_MESG_TYPE_BASE + 0)
#define OS_MESG_TYPE_DMAREAD (OS_MESG_TYPE_BASE + 1)
#define OS_MESG_TYPE_DMAWRITE (OS_MESG_TYPE_BASE + 2)
#define OS_MESG_TYPE_VRETRACE (OS_MESG_TYPE_BASE + 3)
#define OS_MESG_TYPE_COUNTER (OS_MESG_TYPE_BASE + 4)
#define OS_MESG_TYPE_EDMAREAD (OS_MESG_TYPE_BASE + 5)
#define OS_MESG_TYPE_EDMAWRITE (OS_MESG_TYPE_BASE + 6)
/*
* I/O message priority
*/
#define OS_MESG_PRI_NORMAL 0
#define OS_MESG_PRI_HIGH 1
/*
* PI/EPI
*/
#define PI_DOMAIN1 0
#define PI_DOMAIN2 1
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Macro definitions
*
*/
/**************************************************************************
*
* Extern variables
*
*/
extern OSPiHandle *__osPiTable; /* The head of OSPiHandle link list */
/**************************************************************************
*
* Function prototypes
*
*/
extern u32 osPiGetStatus(void);
extern s32 osPiGetDeviceType(void);
extern s32 osPiWriteIo(u32, u32);
extern s32 osPiReadIo(u32, u32 *);
extern s32 osPiStartDma(OSIoMesg *, s32, s32, u32, void *, u32, OSMesgQueue *);
extern void osCreatePiManager(OSPri, OSMesgQueue *, OSMesg *, s32);
/* Enhanced PI interface */
extern OSPiHandle *osCartRomInit(void);
extern OSPiHandle *osLeoDiskInit(void);
extern OSPiHandle *osDriveRomInit(void);
extern s32 osEPiDeviceType(OSPiHandle *, OSPiInfo *);
extern s32 osEPiWriteIo(OSPiHandle *, u32 , u32 );
extern s32 osEPiReadIo(OSPiHandle *, u32 , u32 *);
extern s32 osEPiStartDma(OSPiHandle *, OSIoMesg *, s32);
extern s32 osEPiLinkHandle(OSPiHandle *);
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
#ifdef _LANGUAGE_C_PLUS_PLUS
}
#endif
#endif /* !_OS_PI_H_ */

92
include/PR/os_rdp.h Normal file
View file

@ -0,0 +1,92 @@
/*====================================================================
* os_rdp.h
*
* Copyright 1995, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo. (Originated by SGI)
$RCSfile: os_rdp.h,v $
$Revision: 1.1 $
$Date: 1998/10/09 08:01:16 $
*---------------------------------------------------------------------*/
#ifndef _OS_RDP_H_
#define _OS_RDP_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
#endif
#include <PR/ultratypes.h>
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Type definitions
*
*/
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
/**************************************************************************
*
* Global definitions
*
*/
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Macro definitions
*
*/
/**************************************************************************
*
* Extern variables
*
*/
/**************************************************************************
*
* Function prototypes
*
*/
/* Display processor interface (Dp) */
extern u32 osDpGetStatus(void);
extern void osDpSetStatus(u32);
extern void osDpGetCounters(u32 *);
extern s32 osDpSetNextBuffer(void *, u64);
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
#ifdef _LANGUAGE_C_PLUS_PLUS
}
#endif
#endif /* !_OS_RDP_H_ */

90
include/PR/os_reg.h Normal file
View file

@ -0,0 +1,90 @@
/*====================================================================
* os_reg.h
*
* Copyright 1995, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo. (Originated by SGI)
$RCSfile: os_reg.h,v $
$Revision: 1.1 $
$Date: 1998/10/09 08:01:17 $
*---------------------------------------------------------------------*/
#ifndef _OS_REG_H_
#define _OS_REG_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
#endif
#include <PR/ultratypes.h>
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Type definitions
*
*/
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
/**************************************************************************
*
* Global definitions
*
*/
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Macro definitions
*
*/
/**************************************************************************
*
* Extern variables
*
*/
/**************************************************************************
*
* Function prototypes
*
*/
/* Miscellaneous operations */
extern u32 osGetCount(void);
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
#ifdef _LANGUAGE_C_PLUS_PLUS
}
#endif
#endif /* !_OS_REG_H_ */

86
include/PR/os_rsp.h Normal file
View file

@ -0,0 +1,86 @@
/*====================================================================
* os_rsp.h
*
* Copyright 1995, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo. (Originated by SGI)
$RCSfile: os_rsp.h,v $
$Revision: 1.1 $
$Date: 1998/10/09 08:01:17 $
*---------------------------------------------------------------------*/
#ifndef _OS_RSP_H_
#define _OS_RSP_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
#endif
#include <PR/ultratypes.h>
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Type definitions
*
*/
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
/**************************************************************************
*
* Global definitions
*
*/
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Macro definitions
*
*/
/**************************************************************************
*
* Extern variables
*
*/
/**************************************************************************
*
* Function prototypes
*
*/
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
#ifdef _LANGUAGE_C_PLUS_PLUS
}
#endif
#endif /* !_OS_RSP_H_ */

86
include/PR/os_si.h Normal file
View file

@ -0,0 +1,86 @@
/*====================================================================
* os_si.h
*
* Copyright 1995, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo. (Originated by SGI)
$RCSfile: os_si.h,v $
$Revision: 1.1 $
$Date: 1998/10/09 08:01:18 $
*---------------------------------------------------------------------*/
#ifndef _OS_SI_H_
#define _OS_SI_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
#endif
#include <PR/ultratypes.h>
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Type definitions
*
*/
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
/**************************************************************************
*
* Global definitions
*
*/
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Macro definitions
*
*/
/**************************************************************************
*
* Extern variables
*
*/
/**************************************************************************
*
* Function prototypes
*
*/
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
#ifdef _LANGUAGE_C_PLUS_PLUS
}
#endif
#endif /* !_OS_SI_H_ */

118
include/PR/os_system.h Normal file
View file

@ -0,0 +1,118 @@
/*====================================================================
* os_system.h
*
* Copyright 1995, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo. (Originated by SGI)
$RCSfile: os_system.h,v $
$Revision: 1.1 $
$Date: 1998/10/09 08:01:18 $
*---------------------------------------------------------------------*/
#ifndef _OS_SYSTEM_H_
#define _OS_SYSTEM_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
#endif
#include <PR/ultratypes.h>
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Type definitions
*
*/
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
/**************************************************************************
*
* Global definitions
*
*/
/*
* Values for osTvType
*/
#define OS_TV_PAL 0
#define OS_TV_NTSC 1
#define OS_TV_MPAL 2
/*
* Size of buffer the retains contents after NMI
*/
#define OS_APP_NMI_BUFSIZE 64
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Macro definitions
*
*/
/**************************************************************************
*
* Extern variables
*
*/
extern s32 osRomType; /* Bulk or cartridge ROM. 0=cartridge 1=bulk */
extern void *osRomBase; /* Rom base address of the game image */
extern s32 osTvType; /* 0 = PAL, 1 = NTSC, 2 = MPAL */
extern s32 osResetType; /* 0 = cold reset, 1 = NMI */
extern s32 osCicId;
extern s32 osVersion;
extern u32 osMemSize; /* Memory Size */
extern s32 osAppNMIBuffer[];
extern u64 osClockRate;
extern OSIntMask __OSGlobalIntMask; /* global interrupt mask */
/**************************************************************************
*
* Function prototypes
*
*/
extern void osInitialize(void);
extern void osExit(void);
extern u32 osGetMemSize(void);
/* pre-NMI */
extern s32 osAfterPreNMI(void);
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
#ifdef _LANGUAGE_C_PLUS_PLUS
}
#endif
#endif /* !_OS_SYSTEM_H_ */

161
include/PR/os_thread.h Normal file
View file

@ -0,0 +1,161 @@
/*====================================================================
* os_thread.h
*
* Copyright 1995, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo. (Originated by SGI)
$RCSfile: os_thread.h,v $
$Revision: 1.3 $
$Date: 1999/06/15 12:39:40 $
*---------------------------------------------------------------------*/
#ifndef _OS_THREAD_H_
#define _OS_THREAD_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
#endif
#include <PR/ultratypes.h>
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Type definitions
*
*/
typedef s32 OSPri;
typedef s32 OSId;
typedef union {
struct {
f32 f_odd;
f32 f_even;
} f;
f64 d;
} __OSfp;
typedef struct {
u64 at, v0, v1, a0, a1, a2, a3;
u64 t0, t1, t2, t3, t4, t5, t6, t7;
u64 s0, s1, s2, s3, s4, s5, s6, s7;
u64 t8, t9;
u64 gp, sp, s8, ra;
u64 lo, hi;
u32 sr, pc, cause, badvaddr, rcp;
u32 fpcsr;
__OSfp fp0, fp2, fp4, fp6, fp8, fp10, fp12, fp14;
__OSfp fp16, fp18, fp20, fp22, fp24, fp26, fp28, fp30;
} __OSThreadContext;
typedef struct {
u32 flag;
u32 count;
u64 time;
} __OSThreadprofile_s;
typedef struct OSThread_s {
struct OSThread_s *next; /* run/mesg queue link */
OSPri priority; /* run/mesg queue priority */
struct OSThread_s **queue; /* queue thread is on */
struct OSThread_s *tlnext; /* all threads queue link */
u16 state; /* OS_STATE_* */
u16 flags; /* flags for rmon */
OSId id; /* id for debugging */
int fp; /* thread has used fp unit */
__OSThreadprofile_s *thprof; /* workarea for thread profiler */
__OSThreadContext context; /* register/interrupt mask */
} OSThread;
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
/**************************************************************************
*
* Global definitions
*
*/
/* Thread states */
#define OS_STATE_STOPPED (1 << 0)
#define OS_STATE_RUNNABLE (1 << 1)
#define OS_STATE_RUNNING (1 << 2)
#define OS_STATE_WAITING (1 << 3)
/* Recommended thread priorities for the system threads */
#define OS_PRIORITY_MAX 255
#define OS_PRIORITY_VIMGR 254
#define OS_PRIORITY_RMON 250
#define OS_PRIORITY_RMONSPIN 200
#define OS_PRIORITY_PIMGR 150
#define OS_PRIORITY_SIMGR 140
#define OS_PRIORITY_APPMAX 127
#define OS_PRIORITY_IDLE 0 /* Must be 0 */
/* For thread profiler */
#define THPROF_IDMAX 64
#define THPROF_STACKSIZE 256
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Macro definitions
*
*/
/**************************************************************************
*
* Extern variables
*
*/
/**************************************************************************
*
* Function prototypes
*
*/
/* Thread operations */
extern void osCreateThread(OSThread *, OSId, void (*)(void *), void *, void *, OSPri);
extern void osDestroyThread(OSThread *);
extern void osYieldThread(void);
extern void osStartThread(OSThread *);
extern void osStopThread(OSThread *);
extern OSId osGetThreadId(OSThread *);
extern void osSetThreadPri(OSThread *, OSPri);
extern OSPri osGetThreadPri(OSThread *);
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
#ifdef _LANGUAGE_C_PLUS_PLUS
}
#endif
#endif /* !_OS_THREAD_H_ */

114
include/PR/os_time.h Normal file
View file

@ -0,0 +1,114 @@
/*====================================================================
* os_time.h
*
* Copyright 1995, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo. (Originated by SGI)
$RCSfile: os_time.h,v $
$Revision: 1.1 $
$Date: 1998/10/09 08:01:19 $
*---------------------------------------------------------------------*/
#ifndef _OS_TIME_H_
#define _OS_TIME_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
#endif
#include <PR/ultratypes.h>
#include "PR/os_message.h"
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Type definitions
*
*/
/*
* Structure for time value
*/
typedef u64 OSTime;
/*
* Structure for interval timer
*/
typedef struct OSTimer_s {
struct OSTimer_s *next; /* point to next timer in list */
struct OSTimer_s *prev; /* point to previous timer in list */
OSTime interval; /* duration set by user */
OSTime value; /* time remaining before */
/* timer fires */
OSMesgQueue *mq; /* Message Queue */
OSMesg msg; /* Message to send */
} OSTimer;
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
/**************************************************************************
*
* Global definitions
*
*/
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Macro definitions
*
*/
/**************************************************************************
*
* Extern variables
*
*/
/**************************************************************************
*
* Function prototypes
*
*/
/* Timer interface */
extern OSTime osGetTime(void);
extern void osSetTime(OSTime);
extern int osSetTimer(OSTimer *, OSTime, OSTime,
OSMesgQueue *, OSMesg);
extern int osStopTimer(OSTimer *);
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
#ifdef _LANGUAGE_C_PLUS_PLUS
}
#endif
#endif /* !_OS_TIME_H_ */

107
include/PR/os_tlb.h Normal file
View file

@ -0,0 +1,107 @@
/*====================================================================
* os_tlb.h
*
* Copyright 1995, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo. (Originated by SGI)
$RCSfile: os_tlb.h,v $
$Revision: 1.1 $
$Date: 1998/10/09 08:01:20 $
*---------------------------------------------------------------------*/
#ifndef _OS_TLB_H_
#define _OS_TLB_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
#endif
#include <PR/ultratypes.h>
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Type definitions
*
*/
typedef u32 OSPageMask;
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
/**************************************************************************
*
* Global definitions
*
*/
/*
* Page size argument for TLB routines
*/
#define OS_PM_4K 0x0000000
#define OS_PM_16K 0x0006000
#define OS_PM_64K 0x001e000
#define OS_PM_256K 0x007e000
#define OS_PM_1M 0x01fe000
#define OS_PM_4M 0x07fe000
#define OS_PM_16M 0x1ffe000
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Macro definitions
*
*/
/**************************************************************************
*
* Extern variables
*
*/
/**************************************************************************
*
* Function prototypes
*
*/
/* TLB management routines */
extern void osMapTLB(s32, OSPageMask, void *, u32, u32, s32);
extern void osMapTLBRdb(void);
extern void osUnmapTLB(s32);
extern void osUnmapTLBAll(void);
extern void osSetTLBASID(s32);
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
#ifdef _LANGUAGE_C_PLUS_PLUS
}
#endif
#endif /* !_OS_TLB_H_ */

298
include/PR/os_vi.h Normal file
View file

@ -0,0 +1,298 @@
/*====================================================================
* os_vi.h
*
* Copyright 1995, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo. (Originated by SGI)
$RCSfile: os_vi.h,v $
$Revision: 1.1 $
$Date: 1998/10/09 08:01:20 $
*---------------------------------------------------------------------*/
#ifndef _OS_VI_H_
#define _OS_VI_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
#endif
#include <PR/ultratypes.h>
#include "PR/os_thread.h"
#include "PR/os_message.h"
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Type definitions
*
*/
/*
* Structure to store VI register values that remain the same between 2 fields
*/
typedef struct {
u32 ctrl;
u32 width;
u32 burst;
u32 vSync;
u32 hSync;
u32 leap;
u32 hStart;
u32 xScale;
u32 vCurrent;
} OSViCommonRegs;
/*
* Structure to store VI register values that change between fields
*/
typedef struct {
u32 origin;
u32 yScale;
u32 vStart;
u32 vBurst;
u32 vIntr;
} OSViFieldRegs;
/*
* Structure for VI mode
*/
typedef struct {
u8 type; /* Mode type */
OSViCommonRegs comRegs; /* Common registers for both fields */
OSViFieldRegs fldRegs[2]; /* Registers for Field 1 & 2 */
} OSViMode;
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
/**************************************************************************
*
* Global definitions
*
*/
/*
* Video Interface (VI) mode type
*/
#define OS_VI_NTSC_LPN1 0 /* NTSC */
#define OS_VI_NTSC_LPF1 1
#define OS_VI_NTSC_LAN1 2
#define OS_VI_NTSC_LAF1 3
#define OS_VI_NTSC_LPN2 4
#define OS_VI_NTSC_LPF2 5
#define OS_VI_NTSC_LAN2 6
#define OS_VI_NTSC_LAF2 7
#define OS_VI_NTSC_HPN1 8
#define OS_VI_NTSC_HPF1 9
#define OS_VI_NTSC_HAN1 10
#define OS_VI_NTSC_HAF1 11
#define OS_VI_NTSC_HPN2 12
#define OS_VI_NTSC_HPF2 13
#define OS_VI_PAL_LPN1 14 /* PAL */
#define OS_VI_PAL_LPF1 15
#define OS_VI_PAL_LAN1 16
#define OS_VI_PAL_LAF1 17
#define OS_VI_PAL_LPN2 18
#define OS_VI_PAL_LPF2 19
#define OS_VI_PAL_LAN2 20
#define OS_VI_PAL_LAF2 21
#define OS_VI_PAL_HPN1 22
#define OS_VI_PAL_HPF1 23
#define OS_VI_PAL_HAN1 24
#define OS_VI_PAL_HAF1 25
#define OS_VI_PAL_HPN2 26
#define OS_VI_PAL_HPF2 27
#define OS_VI_MPAL_LPN1 28 /* MPAL - mainly Brazil */
#define OS_VI_MPAL_LPF1 29
#define OS_VI_MPAL_LAN1 30
#define OS_VI_MPAL_LAF1 31
#define OS_VI_MPAL_LPN2 32
#define OS_VI_MPAL_LPF2 33
#define OS_VI_MPAL_LAN2 34
#define OS_VI_MPAL_LAF2 35
#define OS_VI_MPAL_HPN1 36
#define OS_VI_MPAL_HPF1 37
#define OS_VI_MPAL_HAN1 38
#define OS_VI_MPAL_HAF1 39
#define OS_VI_MPAL_HPN2 40
#define OS_VI_MPAL_HPF2 41
#define OS_VI_FPAL_LPN1 42 /* FPAL - Full screen PAL */
#define OS_VI_FPAL_LPF1 43
#define OS_VI_FPAL_LAN1 44
#define OS_VI_FPAL_LAF1 45
#define OS_VI_FPAL_LPN2 46
#define OS_VI_FPAL_LPF2 47
#define OS_VI_FPAL_LAN2 48
#define OS_VI_FPAL_LAF2 49
#define OS_VI_FPAL_HPN1 50
#define OS_VI_FPAL_HPF1 51
#define OS_VI_FPAL_HAN1 52
#define OS_VI_FPAL_HAF1 53
#define OS_VI_FPAL_HPN2 54
#define OS_VI_FPAL_HPF2 55
/*
* Video Interface (VI) special features
*/
#define OS_VI_GAMMA_ON 0x0001
#define OS_VI_GAMMA_OFF 0x0002
#define OS_VI_GAMMA_DITHER_ON 0x0004
#define OS_VI_GAMMA_DITHER_OFF 0x0008
#define OS_VI_DIVOT_ON 0x0010
#define OS_VI_DIVOT_OFF 0x0020
#define OS_VI_DITHER_FILTER_ON 0x0040
#define OS_VI_DITHER_FILTER_OFF 0x0080
/*
* Video Interface (VI) mode attribute bit
*/
#define OS_VI_BIT_NONINTERLACE 0x0001 /* lo-res */
#define OS_VI_BIT_INTERLACE 0x0002 /* lo-res */
#define OS_VI_BIT_NORMALINTERLACE 0x0004 /* hi-res */
#define OS_VI_BIT_DEFLICKINTERLACE 0x0008 /* hi-res */
#define OS_VI_BIT_ANTIALIAS 0x0010
#define OS_VI_BIT_POINTSAMPLE 0x0020
#define OS_VI_BIT_16PIXEL 0x0040
#define OS_VI_BIT_32PIXEL 0x0080
#define OS_VI_BIT_LORES 0x0100
#define OS_VI_BIT_HIRES 0x0200
#define OS_VI_BIT_NTSC 0x0400
#define OS_VI_BIT_PAL 0x0800
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Macro definitions
*
*/
/**************************************************************************
*
* Extern variables
*
*/
extern OSViMode osViModeTable[]; /* Global VI mode table */
extern OSViMode osViModeNtscLpn1; /* Individual VI NTSC modes */
extern OSViMode osViModeNtscLpf1;
extern OSViMode osViModeNtscLan1;
extern OSViMode osViModeNtscLaf1;
extern OSViMode osViModeNtscLpn2;
extern OSViMode osViModeNtscLpf2;
extern OSViMode osViModeNtscLan2;
extern OSViMode osViModeNtscLaf2;
extern OSViMode osViModeNtscHpn1;
extern OSViMode osViModeNtscHpf1;
extern OSViMode osViModeNtscHan1;
extern OSViMode osViModeNtscHaf1;
extern OSViMode osViModeNtscHpn2;
extern OSViMode osViModeNtscHpf2;
extern OSViMode osViModePalLpn1; /* Individual VI PAL modes */
extern OSViMode osViModePalLpf1;
extern OSViMode osViModePalLan1;
extern OSViMode osViModePalLaf1;
extern OSViMode osViModePalLpn2;
extern OSViMode osViModePalLpf2;
extern OSViMode osViModePalLan2;
extern OSViMode osViModePalLaf2;
extern OSViMode osViModePalHpn1;
extern OSViMode osViModePalHpf1;
extern OSViMode osViModePalHan1;
extern OSViMode osViModePalHaf1;
extern OSViMode osViModePalHpn2;
extern OSViMode osViModePalHpf2;
extern OSViMode osViModeMpalLpn1; /* Individual VI MPAL modes */
extern OSViMode osViModeMpalLpf1;
extern OSViMode osViModeMpalLan1;
extern OSViMode osViModeMpalLaf1;
extern OSViMode osViModeMpalLpn2;
extern OSViMode osViModeMpalLpf2;
extern OSViMode osViModeMpalLan2;
extern OSViMode osViModeMpalLaf2;
extern OSViMode osViModeMpalHpn1;
extern OSViMode osViModeMpalHpf1;
extern OSViMode osViModeMpalHan1;
extern OSViMode osViModeMpalHaf1;
extern OSViMode osViModeMpalHpn2;
extern OSViMode osViModeMpalHpf2;
extern OSViMode osViModeFpalLpn1; /* Individual VI FPAL modes */
extern OSViMode osViModeFpalLpf1;
extern OSViMode osViModeFpalLan1;
extern OSViMode osViModeFpalLaf1;
extern OSViMode osViModeFpalLpn2;
extern OSViMode osViModeFpalLpf2;
extern OSViMode osViModeFpalLan2;
extern OSViMode osViModeFpalLaf2;
extern OSViMode osViModeFpalHpn1;
extern OSViMode osViModeFpalHpf1;
extern OSViMode osViModeFpalHan1;
extern OSViMode osViModeFpalHaf1;
extern OSViMode osViModeFpalHpn2;
extern OSViMode osViModeFpalHpf2;
/**************************************************************************
*
* Function prototypes
*
*/
/* Video interface (Vi) */
extern u32 osViGetStatus(void);
extern u32 osViGetCurrentMode(void);
extern u32 osViGetCurrentLine(void);
extern u32 osViGetCurrentField(void);
extern void *osViGetCurrentFramebuffer(void);
extern void *osViGetNextFramebuffer(void);
extern void osViSetXScale(f32);
extern void osViSetYScale(f32);
extern void osViExtendVStart(u32);
extern void osViSetSpecialFeatures(u32);
extern void osViSetMode(OSViMode *);
extern void osViSetEvent(OSMesgQueue *, OSMesg, u32);
extern void osViSwapBuffer(void *);
extern void osViBlack(u8);
extern void osViFade(u8, u16);
extern void osViRepeatLine(u8);
extern void osCreateViManager(OSPri);
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
#ifdef _LANGUAGE_C_PLUS_PLUS
}
#endif
#endif /* !_OS_VI_H_ */

108
include/PR/os_voice.h Normal file
View file

@ -0,0 +1,108 @@
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo.
$RCSfile: os_voice.h,v $
$Revision: 1.2 $
$Date: 1999/07/13 08:36:42 $
*---------------------------------------------------------------------*/
#ifndef _OS_VOICE_H_
#define _OS_VOICE_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
#endif
#include <PR/ultratypes.h>
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Type definitions
*
*/
typedef struct { /* Voice Recognition System */
OSMesgQueue *__mq; /* SI Message Queue */
int __channel; /* Controller Port # */
s32 __mode;
u8 cmd_status; /* Command Status */
} OSVoiceHandle;
typedef struct { /* Voice Recognition System */
u16 warning;
u16 answer_num; /* 0...5 */
u16 voice_level;
u16 voice_sn;
u16 voice_time;
u16 answer[5];
u16 distance[5];
} OSVoiceData;
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
/**************************************************************************
*
* Global definitions
*
*/
/* definition for Voice Recognition System */
#define VOICE_WARN_TOO_SMALL 0x0400
#define VOICE_WARN_TOO_LARGE 0x0800
#define VOICE_WARN_NOT_FIT 0x4000
#define VOICE_WARN_TOO_NOISY 0x8000
#define VOICE_STATUS_READY 0
#define VOICE_STATUS_START 1
#define VOICE_STATUS_CANCEL 3
#define VOICE_STATUS_BUSY 5
#define VOICE_STATUS_END 7
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Macro definitions
*
*/
/**************************************************************************
*
* Extern variables
*
*/
/**************************************************************************
*
* Function prototypes
*
*/
/* Voice Recognition System */
extern s32 osVoiceInit(OSMesgQueue *, OSVoiceHandle *, int);
extern s32 osVoiceCheckWord(u8 *data);
extern s32 osVoiceClearDictionary(OSVoiceHandle *, u8);
extern s32 osVoiceControlGain(OSVoiceHandle *, s32, s32);
extern s32 osVoiceSetWord(OSVoiceHandle *, u8 *);
extern s32 osVoiceStartReadData(OSVoiceHandle *);
extern s32 osVoiceStopReadData(OSVoiceHandle *);
extern s32 osVoiceGetReadData(OSVoiceHandle *, OSVoiceData *);
extern s32 osVoiceMaskDictionary(OSVoiceHandle *, u8 *, int);
extern void osVoiceCountSyllables(u8 *, u32 *);
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
#ifdef _LANGUAGE_C_PLUS_PLUS
}
#endif
#endif /* !_OS_VOICE_H_ */

View file

@ -584,14 +584,21 @@ The Indy development board use cartridge domain 1:
/*
* Patterns to interpret VI_CONTROL_REG
*/
#define VI_CTRL_TYPE_16 0x00002 /* Bit [1:0] pixel size: 16 bit */
#define VI_CTRL_TYPE_32 0x00003 /* Bit [1:0] pixel size: 32 bit */
#define VI_CTRL_GAMMA_DITHER_ON 0x00004 /* Bit 2: default = on */
#define VI_CTRL_GAMMA_ON 0x00008 /* Bit 3: default = on */
#define VI_CTRL_DIVOT_ON 0x00010 /* Bit 4: default = on */
#define VI_CTRL_SERRATE_ON 0x00040 /* Bit 6: on if interlaced */
#define VI_CTRL_ANTIALIAS_MASK 0x00300 /* Bit [9:8] anti-alias mode */
#define VI_CTRL_DITHER_FILTER_ON 0x10000 /* Bit 16: dither-filter mode */
#define VI_CTRL_TYPE_16 0x00002 /* [1:0] pixel size: 16 bit */
#define VI_CTRL_TYPE_32 0x00003 /* [1:0] pixel size: 32 bit */
#define VI_CTRL_GAMMA_DITHER_ON 0x00004 /* 2: default = on */
#define VI_CTRL_GAMMA_ON 0x00008 /* 3: default = on */
#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_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? */
#define VI_CTRL_DITHER_FILTER_ON 0x10000 /* 16: dither-filter mode */
/*
* Possible video clocks (NTSC or PAL)
@ -879,4 +886,3 @@ The Indy development board use cartridge domain 1:
#endif
#endif /* _RCP_H_ */

View file

@ -186,7 +186,7 @@ typedef u32 OSYieldResult;
/*
* break this up into two steps for debugging.
*/
extern void osSpTaskLoad(OSTask *tp);
extern void osSpTaskLoad(OSTask *intp);
extern void osSpTaskStartGo(OSTask *tp);
extern void osSpTaskYield(void);

71
include/PR/viint.h Normal file
View file

@ -0,0 +1,71 @@
#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_CTRL_ANTIALIAS_MODE_3 0x00300 /* Bit [9:8] anti-alias mode */
#define VI_CTRL_ANTIALIAS_MODE_2 0x00200 /* Bit [9:8] anti-alias mode */
#define VI_CTRL_ANTIALIAS_MODE_1 0x00100 /* Bit [9:8] anti-alias mode */
#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

View file

@ -1,38 +1,37 @@
#ifndef PR_XSTDIO_H
#define PR_XSTDIO_H
#include "ultratypes.h"
#ifndef _XSTDIO_H
#define _XSTDIO_H
#include "PR/ultratypes.h"
#include "libc/stdlib.h"
#include "libc/stdarg.h"
typedef struct {
/* 0x0 */ union {
/* 0x0 */ s64 ll;
/* 0x0 */ f64 ld;
/* 0x0 */ long long ll;
/* 0x0 */ double ld;
} v;
/* 0x8 */ char* s;
/* 0xC */ s32 n0;
/* 0x10 */ s32 nz0;
/* 0x14 */ s32 n1;
/* 0x18 */ s32 nz1;
/* 0x1C */ s32 n2;
/* 0x20 */ s32 nz2;
/* 0x24 */ s32 prec;
/* 0x28 */ s32 width;
/* 0x8 */ unsigned char* s;
/* 0xC */ int n0;
/* 0x10 */ int nz0;
/* 0x14 */ int n1;
/* 0x18 */ int nz1;
/* 0x1C */ int n2;
/* 0x20 */ int nz2;
/* 0x24 */ int prec;
/* 0x28 */ int width;
/* 0x2C */ size_t nchar;
/* 0x30 */ u32 flags;
/* 0x34 */ u8 qual;
/* 0x30 */ unsigned int flags;
/* 0x34 */ char qual;
} _Pft;
typedef void* (*PrintCallback)(void*, const char*, size_t);
#define FLAGS_SPACE 1
#define FLAGS_PLUS 2
#define FLAGS_MINUS 4
#define FLAGS_HASH 8
#define FLAGS_ZERO 16
typedef char *outfun(char*,const char*,size_t);
s32 _Printf(PrintCallback pfn, void* arg, const char* fmt, va_list ap);
void _Litob(_Pft* args, u8 type);
void _Ldtob(_Pft* args, u8 type);
int _Printf(outfun prout, char *arg, const char *fmt, va_list args);
void _Litob(_Pft *args, char type);
void _Ldtob(_Pft* px, char code);
#endif

View file

@ -31,10 +31,23 @@
#define CYCLES_TO_USEC(c) (((u64)(c)*(1000000LL/15625LL))/(osClockRate/15625LL))
#define CYCLES_TO_MSEC(c) ((s32)CYCLES_TO_USEC(c)/1000)
/*
* Macros for libultra
*/
#if defined(__sgi)
#define PRINTF
#else
#define PRINTF(...)
#endif
#define ALIGNED(x) __attribute__((aligned(x)))
#define ARRLEN(x) ((s32)(sizeof(x) / sizeof(x[0])))
#define STUBBED_PRINTF(x) ((void)(x))
#define UNUSED __attribute__((unused))
#ifndef __GNUC__
#define __attribute__(x)
#endif
#endif // MACROS_H

View file

@ -139,7 +139,7 @@ int __rmonExecute(KKHeader* request);
/* commands */
typedef int (*FUNPTR)();
typedef int (*FUNPTR)(KKHeader*);
int __rmonLoadProgram(KKHeader* req);
int __rmonListProcesses(KKHeader* req);

View file

@ -1,11 +1,92 @@
#include "common.h"
#include "PR/os_internal.h"
#include "PR/rcp.h"
#include "PR/rdb.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/debug/kdebugserver/string_to_u32.s")
// not included in final rom, but __osThreadSave is here for some reason
OSThread __osThreadSave;
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/debug/kdebugserver/send_packet.s")
extern OSThread* __osRunningThread;
extern u32 __osRdb_IP6_Empty;
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/debug/kdebugserver/clear_IP6.s")
static u8 buffer[12];
static u32 numChars = 0;
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/debug/kdebugserver/send.s")
static u32 string_to_u32(u8* s) {
u32 k;
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/debug/kdebugserver/kdebugserver.s")
k = ((s[0] & 0xFF) << 0x18);
k |= ((s[1] & 0xFF) << 0x10);
k |= ((s[2] & 0xFF) << 0x8);
k |= (s[3] & 0xFF);
return k;
}
static void send_packet(u8* s, u32 n) {
rdbPacket packet;
u32 i;
packet.type = 0xC;
packet.length = n;
for (i = 0; i < n; i++) {
packet.buf[i] = s[i];
}
*(vu32*) RDB_BASE_REG = *(u32*) &packet;
}
static void clear_IP6(void) {
while (!(__osGetCause() & CAUSE_IP6)) {
;
}
*(vu32*) RDB_READ_INTR_REG = 0;
while (__osGetCause() & CAUSE_IP6) {
;
}
}
static void send(u8* s, u32 n) {
u32 ct;
u32 i = 0;
u32 getLastIP6;
if (!__osRdb_IP6_Empty) {
clear_IP6();
getLastIP6 = FALSE;
} else {
getLastIP6 = TRUE;
}
while (n != 0) {
ct = (n < 3) ? n : 3;
send_packet(s + i, ct);
n -= ct;
i += ct;
if (n != 0) {
clear_IP6();
}
}
if (getLastIP6) {
clear_IP6();
}
}
void kdebugserver(rdbPacket packet) {
u32 i;
u32 length;
u8* addr;
for (i = 0; i < 3; i++) {
buffer[numChars++] = packet.buf[i];
}
if (buffer[0] == 2) {
send((char*) &__osRunningThread->context, sizeof(__OSThreadContext));
numChars = 0;
} else if (numChars >= 9 && buffer[0] == 1) {
addr = string_to_u32(&buffer[1]);
length = string_to_u32(&buffer[5]);
send(addr, length);
numChars = 0;
}
}

View file

@ -1,5 +1,125 @@
#include "common.h"
/**************************************************************************
* *
* Copyright (C) 1994, Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
**************************************************************************/
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/gu/cosf/__cosf.s")
#include "PR/ultratypes.h"
#include "PR/guint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/gu/cosf/D_800C9390.s")
/* ====================================================================
* ====================================================================
*
* Module: fcos.c
* $Revision: 1.3 $
* $Date: 1998/10/09 06:10:53 $
* $Author: has $
* $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/libultra/monegi/gu/cosf.c,v $
*
* Revision history:
* 09-Jun-93 - Original Version
*
* Description: source code for fcos function
*
* ====================================================================
* ====================================================================
*/
#pragma weak fcos = __cosf
#pragma weak cosf = __cosf
#define fcos __cosf
/* coefficients for polynomial approximation of cos on +/- pi/2 */
static const du P[] = {
{ 0x3ff00000, 0x00000000 }, { 0xbfc55554, 0xbc83656d }, { 0x3f8110ed, 0x3804c2a0 },
{ 0xbf29f6ff, 0xeea56814 }, { 0x3ec5dbdf, 0x0e314bfe },
};
static const du rpi = { 0x3fd45f30, 0x6dc9c883 };
static const du pihi = { 0x400921fb, 0x50000000 };
static const du pilo = { 0x3e6110b4, 0x611a6263 };
static const fu zero = { 0x00000000 };
/* ====================================================================
*
* FunctionName fcos
*
* Description computes cosine of arg
*
* ====================================================================
*/
float fcos(float x) {
float absx;
double dx, xsq, poly;
double dn;
int n;
double result;
int ix, xpt;
ix = *(int*) &x;
xpt = (ix >> 22);
xpt &= 0x1ff;
/* xpt is exponent(x) + 1 bit of mantissa */
if (xpt < 0x136) {
/* |x| < 2^28 */
/* use the standard algorithm from Cody and Waite, doing
the computations in double precision
*/
absx = ABS(x);
dx = absx;
dn = dx * rpi.d + 0.5;
n = ROUND(dn);
dn = n;
dn -= 0.5;
dx = dx - dn * pihi.d;
dx = dx - dn * pilo.d; /* dx = x - (n - 0.5)*pi */
xsq = dx * dx;
poly = ((P[4].d * xsq + P[3].d) * xsq + P[2].d) * xsq + P[1].d;
result = dx + (dx * xsq) * poly;
/* negate result if n is odd */
if ((n & 1) == 0) {
return ((float) result);
}
return (-(float) result);
}
if (x != x) {
/* x is a NaN; return a quiet NaN */
#ifdef _IP_NAN_SETS_ERRNO
*__errnoaddr = EDOM;
#endif
return (__libm_qnan_f);
}
/* just give up and return 0.0 */
return (zero.f);
}

View file

@ -1,9 +1,76 @@
#include "common.h"
/**************************************************************************
* *
* Copyright (C) 1994, Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
**************************************************************************/
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/gu/mtxutil/guMtxF2L.s")
#include "PR/ultratypes.h"
#include "PR/guint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/gu/mtxutil/guMtxIdentF.s")
void guMtxF2L(float mf[4][4], Mtx* m) {
int i, j;
int e1, e2;
int *ai, *af;
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/gu/mtxutil/guMtxIdent.s")
ai = (int*) &m->m[0][0];
af = (int*) &m->m[2][0];
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/gu/mtxutil/guMtxL2F.s")
for (i = 0; i < 4; i++) {
for (j = 0; j < 2; j++) {
e1 = FTOFIX32(mf[i][j * 2]);
e2 = FTOFIX32(mf[i][j * 2 + 1]);
*(ai++) = (e1 & 0xffff0000) | ((e2 >> 16) & 0xffff);
*(af++) = ((e1 << 16) & 0xffff0000) | (e2 & 0xffff);
}
}
}
// This function seems to use the SM64 version of the guMtxF2L function
void guMtxL2F(float mf[4][4], Mtx* m) {
int r, c;
u32 tmp1;
u32 tmp2;
u32* m1;
u32* m2;
s32 stmp1, stmp2;
m1 = (u32*) &m->m[0][0];
m2 = (u32*) &m->m[2][0];
for (r = 0; r < 4; r++) {
for (c = 0; c < 2; c++) {
tmp1 = (*m1 & 0xffff0000) | ((*m2 >> 0x10) & 0xffff);
tmp2 = ((*m1++ << 0x10) & 0xffff0000) | (*m2++ & 0xffff);
stmp1 = *(s32*) &tmp1;
stmp2 = *(s32*) &tmp2;
mf[r][c * 2 + 0] = stmp1 / 65536.0f;
mf[r][c * 2 + 1] = stmp2 / 65536.0f;
}
}
}
void guMtxIdentF(float mf[4][4]) {
int i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
if (i == j) {
mf[i][j] = 1.0;
} else {
mf[i][j] = 0.0;
}
}
}
}
void guMtxIdent(Mtx* m) {
float mf[4][4];
guMtxIdentF(mf);
guMtxF2L(mf, m);
}

View file

@ -1,5 +1,59 @@
#include "common.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/gu/perspective/guPerspectiveF.s")
/**************************************************************************
* *
* Copyright (C) 1994, Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
**************************************************************************/
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/gu/perspective/guPerspective.s")
#include "PR/ultratypes.h"
#include "PR/guint.h"
extern f32 __cosf(f32);
extern f32 __sinf(f32);
void guPerspectiveF(float mf[4][4], u16* perspNorm, float fovy, float aspect, float near, float far, float scale) {
float cot;
int i, j;
guMtxIdentF(mf);
fovy *= 3.1415926 / 180.0;
cot = __cosf(fovy / 2) / __sinf(fovy / 2);
mf[0][0] = cot / aspect;
mf[1][1] = cot;
mf[2][2] = (near + far) / (near - far);
mf[2][3] = -1;
mf[3][2] = (2 * near * far) / (near - far);
mf[3][3] = 0;
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
mf[i][j] *= scale;
}
}
if (perspNorm != (u16*) NULL) {
if (near + far <= 2.0) {
*perspNorm = (u16) 0xFFFF;
} else {
*perspNorm = (u16) ((2.0 * 65536.0) / (near + far));
if (*perspNorm <= 0) {
*perspNorm = (u16) 0x0001;
}
}
}
}
void guPerspective(Mtx* m, u16* perspNorm, float fovy, float aspect, float near, float far, float scale) {
Matrix mf;
guPerspectiveF(mf, perspNorm, fovy, aspect, near, far, scale);
guMtxF2L(mf, m);
}

View file

@ -1,5 +1,142 @@
#include "common.h"
/**************************************************************************
* *
* Copyright (C) 1994, Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
**************************************************************************/
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/gu/sinf/__sinf.s")
#include "PR/ultratypes.h"
#include "PR/guint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/gu/sinf/D_800C9340.s")
/* ====================================================================
* ====================================================================
*
* Module: fsin.c
* $Revision: 1.3 $
* $Date: 1998/10/09 06:14:51 $
* $Author: has $
* $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/libultra/monegi/gu/sinf.c,v $
*
* Revision history:
* 09-Jun-93 - Original Version
*
* Description: source code for fsin function
*
* ====================================================================
* ====================================================================
*/
#pragma weak fsin = __sinf
#pragma weak sinf = __sinf
#define fsin __sinf
/* coefficients for polynomial approximation of sin on +/- pi/2 */
static const du P[] = {
{ 0x3ff00000, 0x00000000 }, { 0xbfc55554, 0xbc83656d }, { 0x3f8110ed, 0x3804c2a0 },
{ 0xbf29f6ff, 0xeea56814 }, { 0x3ec5dbdf, 0x0e314bfe },
};
static const du rpi = { 0x3fd45f30, 0x6dc9c883 };
static const du pihi = { 0x400921fb, 0x50000000 };
static const du pilo = { 0x3e6110b4, 0x611a6263 };
static const fu zero = { 0x00000000 };
/* ====================================================================
*
* FunctionName fsin
*
* Description computes sine of arg
*
* ====================================================================
*/
float fsin(float x) {
double dx, xsq, poly;
double dn;
int n;
double result;
int ix, xpt;
ix = *(int*) &x;
xpt = (ix >> 22);
xpt &= 0x1ff;
/* xpt is exponent(x) + 1 bit of mantissa */
if (xpt < 0xff) {
/* |x| < 1.5 */
dx = x;
if (xpt >= 0xe6) {
/* |x| >= 2^(-12) */
/* compute sin(x) with a standard polynomial approximation */
xsq = dx * dx;
poly = ((P[4].d * xsq + P[3].d) * xsq + P[2].d) * xsq + P[1].d;
result = dx + (dx * xsq) * poly;
return ((float) result);
}
return (x);
}
if (xpt < 0x136) {
/* |x| < 2^28 */
dx = x;
/* reduce argument to +/- pi/2 */
dn = dx * rpi.d;
n = ROUND(dn);
dn = n;
dx = dx - dn * pihi.d;
dx = dx - dn * pilo.d; /* dx = x - n*pi */
/* compute sin(dx) as before, negating result if n is odd
*/
xsq = dx * dx;
poly = ((P[4].d * xsq + P[3].d) * xsq + P[2].d) * xsq + P[1].d;
result = dx + (dx * xsq) * poly;
if ((n & 1) == 0) {
return ((float) result);
}
return (-(float) result);
}
if (x != x) {
/* x is a NaN; return a quiet NaN */
#ifdef _IP_NAN_SETS_ERRNO
*__errnoaddr = EDOM;
#endif
return (__libm_qnan_f);
}
/* just give up and return 0.0 */
return (zero.f);
}

View file

@ -1,3 +1,36 @@
#include "common.h"
#ifndef _FINALROM
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/host/readhost/osReadHost.s")
#include "PR/os_internal.h"
#include "PR/rdb.h"
#include "macros.h"
static int readHostInitialized = FALSE;
static OSMesgQueue readHostMesgQueue ALIGNED(8);
static OSMesg readHostMesgBuf[1];
u32 __osRdb_Read_Data_Buf;
u32 __osRdb_Read_Data_Ct;
void osReadHost(void* dramAddr, u32 nbytes) {
char tstr[4];
u32 sent = 0;
if (!readHostInitialized) {
osCreateMesgQueue(&readHostMesgQueue, readHostMesgBuf, ARRLEN(readHostMesgBuf));
osSetEventMesg(OS_EVENT_RDB_READ_DONE, &readHostMesgQueue, NULL);
readHostInitialized = TRUE;
}
__osRdb_Read_Data_Buf = dramAddr;
__osRdb_Read_Data_Ct = nbytes;
while (sent == 0) {
sent += __osRdbSend(tstr, 1, RDB_TYPE_GtoH_READY_FOR_DATA);
}
osRecvMesg(&readHostMesgQueue, NULL, OS_MESG_BLOCK);
return;
}
#endif

View file

@ -1,6 +1,8 @@
#include "global.h"
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
#include "PR/rcp.h"
#include "osint.h"
#ifdef IMPORT_DATA_PENDING
s32 osAiSetNextBuffer(void* bufPtr, u32 size) {
static u8 hdwrBugFlag = FALSE;
char* bptr;
@ -45,6 +47,3 @@ s32 osAiSetNextBuffer(void* bufPtr, u32 size) {
IO_WRITE(AI_LEN_REG, size);
return 0;
}
#else
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/aisetnextbuf/osAiSetNextBuffer.s")
#endif

View file

@ -1,3 +1,99 @@
#include "common.h"
#include "macros.h"
#include "PR/os_version.h"
#include "PR/os_internal.h"
#include "PR/R4300.h"
#include "PR/rcp.h"
#include "piint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/cartrominit/osCartRomInit.s")
#if BUILD_VERSION >= VERSION_J
OSPiHandle __CartRomHandle ALIGNED(8);
OSPiHandle* osCartRomInit(void) {
u32 value = 0;
u32 saveMask;
static int first = 1;
register u32 stat;
u32 latency;
u32 pulse;
u32 pageSize;
u32 relDuration;
__osPiGetAccess();
if (!first) {
__osPiRelAccess();
return &__CartRomHandle;
}
first = 0;
__CartRomHandle.type = DEVICE_TYPE_CART;
__CartRomHandle.baseAddress = PHYS_TO_K1(PI_DOM1_ADDR2);
__CartRomHandle.domain = PI_DOMAIN1;
__CartRomHandle.speed = 0;
bzero(&__CartRomHandle.transferInfo, sizeof(__OSTranxInfo));
WAIT_ON_IOBUSY(stat);
latency = IO_READ(PI_BSD_DOM1_LAT_REG);
pageSize = IO_READ(PI_BSD_DOM1_PGS_REG);
relDuration = IO_READ(PI_BSD_DOM1_RLS_REG);
pulse = IO_READ(PI_BSD_DOM1_PWD_REG);
IO_WRITE(PI_BSD_DOM1_LAT_REG, 0xFF);
IO_WRITE(PI_BSD_DOM1_PGS_REG, 0);
IO_WRITE(PI_BSD_DOM1_RLS_REG, 3);
IO_WRITE(PI_BSD_DOM1_PWD_REG, 0xFF);
value = IO_READ(__CartRomHandle.baseAddress);
__CartRomHandle.latency = value & 0xFF;
__CartRomHandle.pageSize = (value >> 0x10) & 0xF;
__CartRomHandle.relDuration = (value >> 0x14) & 0xF;
__CartRomHandle.pulse = (value >> 8) & 0xFF;
IO_WRITE(PI_BSD_DOM1_LAT_REG, latency);
IO_WRITE(PI_BSD_DOM1_PGS_REG, pageSize);
IO_WRITE(PI_BSD_DOM1_RLS_REG, relDuration);
IO_WRITE(PI_BSD_DOM1_PWD_REG, pulse);
saveMask = __osDisableInt();
__CartRomHandle.next = __osPiTable;
__osPiTable = &__CartRomHandle;
__osRestoreInt(saveMask);
__osPiRelAccess();
return &__CartRomHandle;
}
#else
OSPiHandle CartRomHandle ALIGNED(8);
OSPiHandle* osCartRomInit(void) {
u32 domain = 0;
u32 saveMask;
if (CartRomHandle.baseAddress == PHYS_TO_K1(PI_DOM1_ADDR2)) {
return &CartRomHandle;
}
CartRomHandle.type = DEVICE_TYPE_CART;
CartRomHandle.baseAddress = PHYS_TO_K1(PI_DOM1_ADDR2);
osPiRawReadIo(NULL, &domain);
CartRomHandle.latency = domain & 0xff;
CartRomHandle.pulse = (domain >> 8) & 0xff;
CartRomHandle.pageSize = (domain >> 0x10) & 0xf;
CartRomHandle.relDuration = (domain >> 0x14) & 0xf;
CartRomHandle.domain = PI_DOMAIN1;
#if BUILD_VERSION > VERSION_I
CartRomHandle.speed = 0;
#endif
bzero(&CartRomHandle.transferInfo, sizeof(__OSTranxInfo));
saveMask = __osDisableInt();
CartRomHandle.next = __osPiTable;
__osPiTable = &CartRomHandle;
__osRestoreInt(saveMask);
return &CartRomHandle;
}
#endif

View file

@ -1,3 +1,19 @@
#include "common.h"
#include "PR/controller.h"
#include "siint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/conteepprobe/osEepromProbe.s")
s32 osEepromProbe(OSMesgQueue* mq) {
s32 status = 0;
OSContStatus sdata;
__osSiGetAccess();
status = __osEepStatus(mq, &sdata);
if (status == 0 && (sdata.type & 0x8000) != 0) {
status = 1;
} else {
status = 0;
}
__osSiRelAccess();
return status;
}

View file

@ -1,5 +1,86 @@
#include "common.h"
#include "macros.h"
#include "PR/rcp.h"
#include "PR/controller.h"
#include "siint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/conteepread/osEepromRead.s")
OSPifRam __osEepPifRam ALIGNED(16);
#if BUILD_VERSION >= VERSION_L
s32 __osEepromRead16K;
#endif
void __osPackEepReadData(u8 address);
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/conteepread/__osPackEepReadData.s")
s32 osEepromRead(OSMesgQueue* mq, u8 address, u8* buffer) {
s32 ret = 0;
int i = 0;
u8* ptr = (u8*) &__osEepPifRam;
OSContStatus sdata;
__OSContEepromFormat eepromformat;
if (address > 0x40) {
return -1;
}
__osSiGetAccess();
ret = __osEepStatus(mq, &sdata);
if (ret != 0 || sdata.type != 0x8000) {
return 8;
}
while (sdata.status & 0x80) {
__osEepStatus(mq, &sdata);
}
__osPackEepReadData(address);
ret = __osSiRawStartDma(OS_WRITE, &__osEepPifRam);
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
for (i = 0; i < 0x10; i++) {
__osEepPifRam.ramarray[i] = 0xFF;
}
__osEepPifRam.pifstatus = 0;
ret = __osSiRawStartDma(OS_READ, &__osEepPifRam);
__osContLastCmd = 4;
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
for (i = 0; i < 4; i++) {
ptr++;
}
eepromformat = *(__OSContEepromFormat*) ptr;
ret = CHNL_ERR(eepromformat);
if (ret == 0) {
for (i = 0; i < 8; i++) {
*buffer++ = eepromformat.data[i];
}
}
__osSiRelAccess();
return ret;
}
void __osPackEepReadData(u8 address) {
u8* ptr = (u8*) &__osEepPifRam.ramarray;
__OSContEepromFormat eepromformat;
int i;
#if BUILD_VERSION < VERSION_J
for (i = 0; i < ARRLEN(__osEepPifRam.ramarray) + 1; i++) {
__osEepPifRam.ramarray[i] = CONT_CMD_NOP;
}
#endif
__osEepPifRam.pifstatus = CONT_CMD_EXE;
eepromformat.txsize = CONT_CMD_READ_EEPROM_TX;
eepromformat.rxsize = CONT_CMD_READ_EEPROM_RX;
eepromformat.cmd = CONT_CMD_READ_EEPROM;
eepromformat.address = address;
#if BUILD_VERSION < VERSION_J
for (i = 0; i < ARRLEN(eepromformat.data); i++) {
eepromformat.data[i] = 0;
}
#endif
for (i = 0; i < MAXCONTROLLERS; i++) {
*ptr++ = 0;
}
*(__OSContEepromFormat*) (ptr) = eepromformat;
ptr += sizeof(__OSContEepromFormat);
ptr[0] = CONT_CMD_END;
}

View file

@ -1,7 +1,142 @@
#include "common.h"
#include "PR/os_internal.h"
#include "PR/rcp.h"
#include "PR/controller.h"
#include "siint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/conteepwrite/osEepromWrite.s")
void __osPackEepWriteData(u8 address, u8* buffer);
s32 osEepromWrite(OSMesgQueue* mq, u8 address, u8* buffer) {
s32 ret = 0;
int i;
u8* ptr = (u8*) &__osEepPifRam.ramarray;
__OSContEepromFormat eepromformat;
OSContStatus sdata;
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/conteepwrite/__osPackEepWriteData.s")
if (address > 0x40) {
return -1;
}
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/conteepwrite/__osEepStatus.s")
__osSiGetAccess();
ret = __osEepStatus(mq, &sdata);
if (ret != 0 || sdata.type != 0x8000) {
return 8;
}
while (sdata.status & 0x80) {
__osEepStatus(mq, &sdata);
}
__osPackEepWriteData(address, buffer);
ret = __osSiRawStartDma(OS_WRITE, &__osEepPifRam);
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
for (i = 0; i < 0x10; i++) {
__osEepPifRam.ramarray[i] = 255;
}
__osEepPifRam.pifstatus = 0;
ret = __osSiRawStartDma(OS_READ, &__osEepPifRam);
__osContLastCmd = 5;
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
for (i = 0; i < 4; i++) {
ptr++;
}
eepromformat = *(__OSContEepromFormat*) ptr;
ret = CHNL_ERR(eepromformat);
__osSiRelAccess();
return ret;
}
void __osPackEepWriteData(u8 address, u8* buffer) {
u8* ptr = (u8*) &__osEepPifRam.ramarray;
__OSContEepromFormat eepromformat;
int i;
#if BUILD_VERSION < VERSION_J
for (i = 0; i < ARRLEN(__osEepPifRam.ramarray) + 1; i++) {
__osEepPifRam.ramarray[i] = CONT_CMD_NOP;
}
#endif
__osEepPifRam.pifstatus = CONT_CMD_EXE;
eepromformat.txsize = CONT_CMD_WRITE_EEPROM_TX;
eepromformat.rxsize = CONT_CMD_WRITE_EEPROM_RX;
eepromformat.cmd = CONT_CMD_WRITE_EEPROM;
eepromformat.address = address;
for (i = 0; i < ARRLEN(eepromformat.data); i++) {
eepromformat.data[i] = *buffer++;
}
for (i = 0; i < MAXCONTROLLERS; i++) {
*ptr++ = 0;
}
*(__OSContEepromFormat*) (ptr) = eepromformat;
ptr += sizeof(__OSContEepromFormat);
ptr[0] = CONT_CMD_END;
}
s32 __osEepStatus(OSMesgQueue* mq, OSContStatus* data) {
s32 ret = 0;
int i;
u8* ptr = (u8*) __osEepPifRam.ramarray;
__OSContRequesFormat requestformat;
for (i = 0; i < ARRLEN(__osEepPifRam.ramarray) + 1; i++) {
__osEepPifRam.ramarray[i] = 0;
}
__osEepPifRam.pifstatus = CONT_CMD_EXE;
ptr = (u8*) __osEepPifRam.ramarray;
for (i = 0; i < MAXCONTROLLERS; i++) {
*ptr++ = CONT_CMD_REQUEST_STATUS;
}
requestformat.dummy = CONT_CMD_NOP;
requestformat.txsize = CONT_CMD_REQUEST_STATUS_TX;
requestformat.rxsize = CONT_CMD_REQUEST_STATUS_RX;
requestformat.cmd = CONT_CMD_REQUEST_STATUS;
requestformat.typeh = CONT_CMD_NOP;
requestformat.typel = CONT_CMD_NOP;
requestformat.status = CONT_CMD_NOP;
requestformat.dummy1 = CONT_CMD_NOP;
*(__OSContRequesFormat*) ptr = requestformat;
ptr += sizeof(__OSContRequesFormat);
*ptr = CONT_CMD_END;
ret = __osSiRawStartDma(OS_WRITE, &__osEepPifRam);
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
#if BUILD_VERSION >= VERSION_J
__osContLastCmd = CONT_CMD_END;
#else
__osContLastCmd = CONT_CMD_WRITE_EEPROM; // seems to be 5 in 2.0H
#endif
ret = __osSiRawStartDma(OS_READ, &__osEepPifRam);
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
if (ret != 0) {
return ret;
}
ptr = (u8*) &__osEepPifRam;
for (i = 0; i < MAXCONTROLLERS; i++) {
*ptr++ = 0;
}
requestformat = *(__OSContRequesFormat*) ptr;
data->errno = CHNL_ERR(requestformat);
data->type = (requestformat.typel << 8) | requestformat.typeh;
data->status = requestformat.status;
if (data->errno != 0) {
return data->errno;
}
return 0;
}

View file

@ -1,5 +1,25 @@
#include "common.h"
#include "PR/os_internal.h"
#include "PR/controller.h"
#include "siint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/contquery/osContStartQuery.s")
s32 osContStartQuery(OSMesgQueue* mq) {
s32 ret = 0;
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/contquery/osContGetQuery.s")
__osSiGetAccess();
if (__osContLastCmd != CONT_CMD_REQUEST_STATUS) {
__osPackRequestData(CONT_CMD_REQUEST_STATUS);
ret = __osSiRawStartDma(OS_WRITE, __osContPifRam.ramarray);
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
}
ret = __osSiRawStartDma(OS_READ, __osContPifRam.ramarray);
__osContLastCmd = CONT_CMD_REQUEST_STATUS;
__osSiRelAccess();
return ret;
}
void osContGetQuery(OSContStatus* data) {
u8 pattern;
__osContGetInitData(&pattern, data);
}

View file

@ -1,5 +1,170 @@
#include "common.h"
#include "PR/os_internal.h"
#include "PR/rcp.h"
#include "PR/controller.h"
#include "siint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/contramread/__osContRamRead.s")
#define READFORMAT(ptr) ((__OSContRamReadFormat*) (ptr))
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/contramread/__osPackRamReadData.s")
#if BUILD_VERSION >= VERSION_J
s32 __osPfsLastChannel = -1;
s32 __osContRamRead(OSMesgQueue* mq, int channel, u16 address, u8* buffer) {
s32 ret = 0;
s32 i;
u8* ptr;
s32 retry = 2;
__osSiGetAccess();
do {
ptr = (u8*) &__osPfsPifRam;
if (__osContLastCmd != CONT_CMD_READ_PAK || (u32) __osPfsLastChannel != channel) {
__osContLastCmd = CONT_CMD_READ_PAK;
__osPfsLastChannel = channel;
for (i = 0; i < channel; i++) {
*ptr++ = CONT_CMD_REQUEST_STATUS;
}
__osPfsPifRam.pifstatus = CONT_CMD_EXE;
READFORMAT(ptr)->dummy = CONT_CMD_NOP;
READFORMAT(ptr)->txsize = CONT_CMD_READ_PAK_TX;
READFORMAT(ptr)->rxsize = CONT_CMD_READ_PAK_RX;
READFORMAT(ptr)->cmd = CONT_CMD_READ_PAK;
READFORMAT(ptr)->datacrc = 0xFF;
ptr[sizeof(__OSContRamReadFormat)] = CONT_CMD_END;
} else {
ptr += channel;
}
#if BUILD_VERSION >= VERSION_J
READFORMAT(ptr)->addrh = address >> 3;
READFORMAT(ptr)->addrl = (u8) ((address << 5) | __osContAddressCrc(address));
#else
READFORMAT(ptr)->address = (address << 0x5) | __osContAddressCrc(address);
#endif
ret = __osSiRawStartDma(OS_WRITE, &__osPfsPifRam);
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam);
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
ret = CHNL_ERR(*READFORMAT(ptr));
if (!ret) {
if (__osContDataCrc(READFORMAT(ptr)->data) != READFORMAT(ptr)->datacrc) {
ret = __osPfsGetStatus(mq, channel);
if (ret) {
break;
} else {
ret = PFS_ERR_CONTRFAIL;
}
} else {
bcopy(READFORMAT(ptr)->data, buffer, BLOCKSIZE);
}
} else {
ret = PFS_ERR_NOPACK;
}
} while ((ret == PFS_ERR_CONTRFAIL) && (retry-- >= 0));
__osSiRelAccess();
return ret;
}
#else
static void __osPackRamReadData(int channel, u16 address);
s32 __osContRamRead(OSMesgQueue* mq, int channel, u16 address, u8* buffer) {
s32 ret = 0;
int i;
u8* ptr = (u8*) &__osPfsPifRam;
__OSContRamReadFormat ramreadformat;
int retry = 2;
__osSiGetAccess();
__osContLastCmd = CONT_CMD_READ_PAK;
__osPackRamReadData(channel, address);
ret = __osSiRawStartDma(OS_WRITE, &__osPfsPifRam);
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
do {
ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam);
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
ptr = (u8*) &__osPfsPifRam;
if (channel != 0) {
for (i = 0; i < channel; i++) {
ptr++;
}
}
ramreadformat = *READFORMAT(ptr);
ret = CHNL_ERR(ramreadformat);
if (ret == 0) {
u8 c = __osContDataCrc((u8*) &ramreadformat.data);
if (c != ramreadformat.datacrc) {
ret = __osPfsGetStatus(mq, channel);
if (ret != 0) {
__osSiRelAccess();
return ret;
}
ret = PFS_ERR_CONTRFAIL;
} else {
for (i = 0; i < ARRLEN(ramreadformat.data); i++) {
*buffer++ = ramreadformat.data[i];
}
}
} else {
ret = PFS_ERR_NOPACK;
}
} while ((ret == PFS_ERR_CONTRFAIL) && retry-- >= 0);
__osSiRelAccess();
return ret;
}
static void __osPackRamReadData(int channel, u16 address) {
u8* ptr;
__OSContRamReadFormat ramreadformat;
int i;
ptr = (u8*) __osPfsPifRam.ramarray;
#if BUILD_VERSION < VERSION_I
for (i = 0; i < 16; i++) {
__osPfsPifRam.ramarray[i] = 0;
}
#endif
__osPfsPifRam.pifstatus = CONT_CMD_EXE;
ramreadformat.dummy = CONT_CMD_NOP;
ramreadformat.txsize = CONT_CMD_READ_PAK_TX;
ramreadformat.rxsize = CONT_CMD_READ_PAK_RX;
ramreadformat.cmd = CONT_CMD_READ_PAK;
ramreadformat.address = (address << 0x5) | __osContAddressCrc(address);
ramreadformat.datacrc = CONT_CMD_NOP;
for (i = 0; i < ARRLEN(ramreadformat.data); i++) {
ramreadformat.data[i] = CONT_CMD_NOP;
}
if (channel != 0) {
for (i = 0; i < channel; i++) {
*ptr++ = CONT_CMD_REQUEST_STATUS;
}
}
*(__OSContRamReadFormat*) ptr = ramreadformat;
ptr += sizeof(__OSContRamReadFormat);
ptr[0] = CONT_CMD_END;
}
#endif

View file

@ -1,5 +1,176 @@
#include "common.h"
#include "PR/os_internal.h"
#include "PR/rcp.h"
#include "PR/controller.h"
#include "siint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/contramwrite/__osContRamWrite.s")
extern s32 __osPfsLastChannel;
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/contramwrite/__osPackRamWriteData.s")
#define READFORMAT(ptr) ((__OSContRamReadFormat*) (ptr))
#if BUILD_VERSION >= VERSION_J
s32 __osContRamWrite(OSMesgQueue* mq, int channel, u16 address, u8* buffer, int force) {
s32 ret = 0;
s32 i;
u8* ptr;
s32 retry = 2;
u8 crc;
if ((force != TRUE) && (address < PFS_LABEL_AREA) && (address != 0)) {
return 0;
}
__osSiGetAccess();
do {
ptr = (u8*) __osPfsPifRam.ramarray;
if (__osContLastCmd != CONT_CMD_WRITE_PAK || (u32) __osPfsLastChannel != channel) {
__osContLastCmd = CONT_CMD_WRITE_PAK;
__osPfsLastChannel = channel;
for (i = 0; i < channel; i++) {
*ptr++ = CONT_CMD_REQUEST_STATUS;
}
__osPfsPifRam.pifstatus = CONT_CMD_EXE;
READFORMAT(ptr)->dummy = CONT_CMD_NOP;
READFORMAT(ptr)->txsize = CONT_CMD_WRITE_PAK_TX;
READFORMAT(ptr)->rxsize = CONT_CMD_WRITE_PAK_RX;
READFORMAT(ptr)->cmd = CONT_CMD_WRITE_PAK;
READFORMAT(ptr)->datacrc = 0xFF;
ptr[sizeof(__OSContRamReadFormat)] = CONT_CMD_END;
} else {
ptr += channel;
}
#if BUILD_VERSION >= VERSION_J
READFORMAT(ptr)->addrh = address >> 3;
READFORMAT(ptr)->addrl = ((address << 5) | __osContAddressCrc(address));
#else
READFORMAT(ptr)->address = (address << 0x5) | __osContAddressCrc(address);
#endif
bcopy(buffer, READFORMAT(ptr)->data, BLOCKSIZE);
ret = __osSiRawStartDma(OS_WRITE, &__osPfsPifRam);
crc = __osContDataCrc(buffer);
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam);
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
ret = CHNL_ERR(*READFORMAT(ptr));
if (!ret) {
if (crc != READFORMAT(ptr)->datacrc) {
if ((ret = __osPfsGetStatus(mq, channel))) {
break;
} else {
ret = PFS_ERR_CONTRFAIL;
}
}
} else {
ret = PFS_ERR_NOPACK;
}
} while ((ret == PFS_ERR_CONTRFAIL) && (retry-- >= 0));
__osSiRelAccess();
return ret;
}
#else
static void __osPackRamWriteData(int channel, u16 address, u8* buffer);
s32 __osContRamWrite(OSMesgQueue* mq, int channel, u16 address, u8* buffer, int force) {
s32 ret = 0;
s32 i;
u8* ptr = (u8*) &__osPfsPifRam;
__OSContRamReadFormat ramreadformat;
s32 retry = 2;
u8 crc;
if ((force != TRUE) && (address < PFS_LABEL_AREA) && (address != 0)) {
return 0;
}
__osSiGetAccess();
__osContLastCmd = CONT_CMD_WRITE_PAK;
__osPackRamWriteData(channel, address, buffer);
ret = __osSiRawStartDma(OS_WRITE, &__osPfsPifRam);
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
do {
ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam);
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
ptr = (u8*) &__osPfsPifRam;
if (channel != 0) {
for (i = 0; i < channel; i++) {
ptr++;
}
}
ramreadformat = *READFORMAT(ptr);
ret = CHNL_ERR(ramreadformat);
if (ret == 0) {
if (__osContDataCrc(buffer) != ramreadformat.datacrc) {
ret = __osPfsGetStatus(mq, channel);
if (ret != 0) {
__osSiRelAccess();
return ret;
}
ret = PFS_ERR_CONTRFAIL;
}
} else {
ret = PFS_ERR_NOPACK;
}
} while ((ret == PFS_ERR_CONTRFAIL) && retry-- >= 0);
__osSiRelAccess();
return ret;
}
static void __osPackRamWriteData(int channel, u16 address, u8* buffer) {
u8* ptr;
__OSContRamReadFormat ramreadformat;
int i;
ptr = (u8*) __osPfsPifRam.ramarray;
#if BUILD_VERSION < VERSION_I
for (i = 0; i < 16; i++) {
__osPfsPifRam.ramarray[i] = 0;
}
#endif
__osPfsPifRam.pifstatus = CONT_CMD_EXE;
ramreadformat.dummy = CONT_CMD_NOP;
ramreadformat.txsize = CONT_CMD_WRITE_PAK_TX;
ramreadformat.rxsize = CONT_CMD_WRITE_PAK_RX;
ramreadformat.cmd = CONT_CMD_WRITE_PAK;
ramreadformat.address = (address << 0x5) | __osContAddressCrc(address);
ramreadformat.datacrc = CONT_CMD_NOP;
for (i = 0; i < ARRLEN(ramreadformat.data); i++) {
ramreadformat.data[i] = *buffer++;
}
if (channel != 0) {
for (i = 0; i < channel; i++) {
*ptr++ = CONT_CMD_REQUEST_STATUS;
}
}
*(__OSContRamReadFormat*) ptr = ramreadformat;
ptr += sizeof(__OSContRamReadFormat);
ptr[0] = CONT_CMD_END;
}
#endif

View file

@ -1,7 +1,74 @@
#include "common.h"
#include "PR/os_internal.h"
#include "PR/controller.h"
#include "siint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/contreaddata/osContStartReadData.s")
static void __osPackReadData(void);
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/contreaddata/osContGetReadData.s")
s32 osContStartReadData(OSMesgQueue* mq) {
s32 ret = 0;
s32 i;
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/contreaddata/__osPackReadData.s")
__osSiGetAccess();
if (__osContLastCmd != CONT_CMD_READ_BUTTON) {
__osPackReadData();
ret = __osSiRawStartDma(OS_WRITE, __osContPifRam.ramarray);
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
}
for (i = 0; i <= ARRLEN(__osContPifRam.ramarray); i++) {
__osContPifRam.ramarray[i] = 0xFF;
}
__osContPifRam.pifstatus = 0;
ret = __osSiRawStartDma(OS_READ, __osContPifRam.ramarray);
__osContLastCmd = CONT_CMD_READ_BUTTON;
__osSiRelAccess();
return ret;
}
void osContGetReadData(OSContPad* data) {
u8* ptr = (u8*) __osContPifRam.ramarray;
__OSContReadFormat readformat;
int i;
for (i = 0; i < __osMaxControllers; i++, ptr += sizeof(__OSContReadFormat), data++) {
readformat = *(__OSContReadFormat*) ptr;
data->errno = CHNL_ERR(readformat);
if (data->errno != 0) {
continue;
}
data->button = readformat.button;
data->stick_x = readformat.stick_x;
data->stick_y = readformat.stick_y;
}
}
static void __osPackReadData(void) {
u8* ptr = (u8*) __osContPifRam.ramarray;
__OSContReadFormat readformat;
int i;
for (i = 0; i <= ARRLEN(__osContPifRam.ramarray); i++) {
__osContPifRam.ramarray[i] = 0;
}
__osContPifRam.pifstatus = CONT_CMD_EXE;
readformat.dummy = CONT_CMD_NOP;
readformat.txsize = CONT_CMD_READ_BUTTON_TX;
readformat.rxsize = CONT_CMD_READ_BUTTON_RX;
readformat.cmd = CONT_CMD_READ_BUTTON;
readformat.button = 0xFFFF;
readformat.stick_x = -1;
readformat.stick_y = -1;
for (i = 0; i < __osMaxControllers; i++) {
*(__OSContReadFormat*) ptr = readformat;
ptr += sizeof(__OSContReadFormat);
}
*ptr = CONT_CMD_END;
}

View file

@ -2,7 +2,15 @@
#include "PR/controller.h"
#include "siint.h"
extern s32 __osContinitialized;
OSPifRam __osContPifRam ALIGNED(16);
u8 __osContLastCmd;
u8 __osMaxControllers;
OSTimer __osEepromTimer;
OSMesgQueue __osEepromTimerQ ALIGNED(8);
OSMesg __osEepromTimerMsg;
s32 __osContinitialized = 0;
#define USEC_TO_CYCLES_OLD(n, clock) ((n) * (u64) (clock) / 1000000)

View file

@ -1,5 +1,114 @@
#include "common.h"
#include "PR/os_internal.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/crc/__osContAddressCrc.s")
#if BUILD_VERSION >= VERSION_J
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/crc/__osContDataCrc.s")
u8 __osContAddressCrc(u16 addr) {
u32 temp = 0;
u32 i = 0x400;
do {
temp <<= 1;
if ((u32) addr & i) {
if (temp & 0x20) {
temp ^= 0x14;
} else {
++temp;
}
} else if (temp & 0x20) {
temp ^= 0x15;
}
i >>= 1;
} while (i != 0);
i = 5;
do {
temp <<= 1;
if (temp & 0x20) {
temp ^= 0x15;
}
} while (--i != 0);
return temp & 0x1F;
}
u8 __osContDataCrc(u8* data) {
u32 temp = 0;
u32 i;
u32 j;
for (i = 0x20; i; --i) {
for (j = 0x80; j; j >>= 1) {
temp <<= 1;
if ((*data & j) != 0) {
if ((temp & 0x100) != 0) {
temp ^= 0x84;
} else {
++temp;
}
} else if (temp & 0x100) {
temp ^= 0x85;
}
}
data++;
}
do {
temp <<= 1;
if (temp & 0x100) {
temp ^= 0x85;
}
} while (++i < 8U);
return temp;
}
#else
u8 __osContAddressCrc(u16 addr) {
u8 temp = 0;
u8 temp2;
int i;
for (i = 0; i < 16; i++) {
temp2 = (temp & 0x10) ? 0x15 : 0;
temp <<= 1;
temp |= (u8) ((addr & 0x400) ? 1 : 0);
addr <<= 1;
temp ^= temp2;
}
return temp & 0x1f;
}
u8 __osContDataCrc(u8* data) {
u8 temp = 0;
u8 temp2;
int i;
int j;
for (i = 0; i <= 32; i++) {
for (j = 7; j > -1; j--) {
temp2 = (temp & 0x80) ? 0x85 : 0;
temp <<= 1;
if (i == 32) {
temp &= -1;
} else {
temp |= ((*data & (1 << j)) ? 1 : 0);
}
temp ^= temp2;
}
data++;
}
return temp;
}
#endif

View file

@ -1,3 +1,108 @@
#include "common.h"
#include "PR/os_internal.h"
#include "PR/rcp.h"
#include "piint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/devmgr/__osDevMgrMain.s")
void __osDevMgrMain(void* args) {
OSIoMesg* mb;
OSMesg em;
OSMesg dummy;
s32 ret;
OSDevMgr* dm;
s32 messageSend = 0;
dm = (OSDevMgr*) args;
mb = NULL;
ret = 0;
while (TRUE) {
osRecvMesg(dm->cmdQueue, (OSMesg) &mb, OS_MESG_BLOCK);
if (mb->piHandle != NULL && mb->piHandle->type == DEVICE_TYPE_64DD &&
(mb->piHandle->transferInfo.cmdType == LEO_CMD_TYPE_0 ||
mb->piHandle->transferInfo.cmdType == LEO_CMD_TYPE_1)) {
__OSBlockInfo* blockInfo;
__OSTranxInfo* info;
info = &mb->piHandle->transferInfo;
blockInfo = &info->block[info->blockNum];
info->sectorNum = -1;
if (info->transferMode != LEO_SECTOR_MODE) {
blockInfo->dramAddr = (void*) ((u32) blockInfo->dramAddr - blockInfo->sectorSize);
}
if (info->transferMode == LEO_TRACK_MODE && mb->piHandle->transferInfo.cmdType == LEO_CMD_TYPE_0) {
messageSend = 1;
} else {
messageSend = 0;
}
osRecvMesg(dm->acsQueue, &dummy, OS_MESG_BLOCK);
__osResetGlobalIntMask(OS_IM_PI);
__osEPiRawWriteIo(mb->piHandle, LEO_BM_CTL, (info->bmCtlShadow | 0x80000000));
readblock1:
osRecvMesg(dm->evtQueue, &em, OS_MESG_BLOCK);
info = &mb->piHandle->transferInfo;
blockInfo = &info->block[info->blockNum];
if (blockInfo->errStatus == LEO_ERROR_29) {
u32 stat;
__osEPiRawWriteIo(mb->piHandle, LEO_BM_CTL, info->bmCtlShadow | LEO_BM_CTL_RESET);
__osEPiRawWriteIo(mb->piHandle, LEO_BM_CTL, info->bmCtlShadow);
__osEPiRawReadIo(mb->piHandle, LEO_STATUS, &stat);
if (stat & LEO_STATUS_MECHANIC_INTERRUPT) {
__osEPiRawWriteIo(mb->piHandle, LEO_BM_CTL, info->bmCtlShadow | LEO_BM_CTL_CLR_MECHANIC_INTR);
}
blockInfo->errStatus = LEO_ERROR_4;
IO_WRITE(PI_STATUS_REG, PI_CLR_INTR);
__osSetGlobalIntMask(OS_IM_PI | SR_IBIT4);
}
osSendMesg(mb->hdr.retQueue, mb, OS_MESG_NOBLOCK);
if (messageSend == 1 && mb->piHandle->transferInfo.block[0].errStatus == LEO_ERROR_GOOD) {
messageSend = 0;
goto readblock1;
}
osSendMesg(dm->acsQueue, NULL, OS_MESG_NOBLOCK);
if (mb->piHandle->transferInfo.blockNum == 1) {
osYieldThread();
}
} else {
switch (mb->hdr.type) {
case OS_MESG_TYPE_DMAREAD:
osRecvMesg(dm->acsQueue, &dummy, OS_MESG_BLOCK);
ret = dm->dma(OS_READ, mb->devAddr, mb->dramAddr, mb->size);
break;
case OS_MESG_TYPE_DMAWRITE:
osRecvMesg(dm->acsQueue, &dummy, OS_MESG_BLOCK);
ret = dm->dma(OS_WRITE, mb->devAddr, mb->dramAddr, mb->size);
break;
case OS_MESG_TYPE_EDMAREAD:
osRecvMesg(dm->acsQueue, &dummy, OS_MESG_BLOCK);
ret = dm->edma(mb->piHandle, OS_READ, mb->devAddr, mb->dramAddr, mb->size);
break;
case OS_MESG_TYPE_EDMAWRITE:
osRecvMesg(dm->acsQueue, &dummy, OS_MESG_BLOCK);
ret = dm->edma(mb->piHandle, OS_WRITE, mb->devAddr, mb->dramAddr, mb->size);
break;
case OS_MESG_TYPE_LOOPBACK:
osSendMesg(mb->hdr.retQueue, mb, OS_MESG_NOBLOCK);
ret = -1;
break;
default:
ret = -1;
break;
}
if (ret == 0) {
osRecvMesg(dm->evtQueue, &em, OS_MESG_BLOCK);
osSendMesg(mb->hdr.retQueue, mb, OS_MESG_NOBLOCK);
osSendMesg(dm->acsQueue, NULL, OS_MESG_NOBLOCK);
}
}
}
}

View file

@ -1,3 +1,9 @@
#include "common.h"
#include "PR/os_internal.h"
#include "PR/rcp.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/dpsetstat/osDpSetStatus.s")
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
void osDpSetStatus(u32 data) {
IO_WRITE(DPC_STATUS_REG, data);
}

View file

@ -1,3 +1,61 @@
#include "common.h"
#include "piint.h"
#include "PR/ultraerror.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/epidma/osEPiStartDma.s")
s32 osEPiStartDma(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) {
register s32 ret;
if (!__osPiDevMgr.active) {
#ifdef _DEBUG
__osError(ERR_OSPISTARTDMA_PIMGR, 0);
#endif
return -1;
}
#ifdef _DEBUG
if ((mb->hdr.pri != OS_MESG_PRI_NORMAL) && (mb->hdr.pri != OS_MESG_PRI_HIGH)) {
__osError(ERR_OSPISTARTDMA_PRI, 1, mb->hdr.pri);
return -1;
}
if ((direction != OS_READ) && (direction != OS_WRITE)) {
__osError(ERR_OSPISTARTDMA_DIR, 1, direction);
return -1;
}
if (mb->devAddr & 0x1) {
__osError(ERR_OSPISTARTDMA_DEVADDR, 1, mb->devAddr);
return -1;
}
if ((u32) mb->dramAddr & 0x7) {
__osError(ERR_OSPISTARTDMA_ADDR, 1, mb->dramAddr);
return -1;
}
if (mb->size & 0x1) {
__osError(ERR_OSPISTARTDMA_SIZE, 1, mb->size);
return -1;
}
if ((mb->size == 0) || (mb->size > (16 * 1024 * 1024))) {
__osError(ERR_OSPISTARTDMA_RANGE, 1, mb->size);
return -1;
}
#endif
mb->piHandle = pihandle;
if (direction == OS_READ) {
mb->hdr.type = OS_MESG_TYPE_EDMAREAD;
} else {
mb->hdr.type = OS_MESG_TYPE_EDMAWRITE;
}
if (mb->hdr.pri == OS_MESG_PRI_HIGH) {
ret = osJamMesg(osPiGetCmdQueue(), (OSMesg) mb, OS_MESG_NOBLOCK);
} else {
ret = osSendMesg(osPiGetCmdQueue(), (OSMesg) mb, OS_MESG_NOBLOCK);
}
return ret;
}

View file

@ -1,3 +1,53 @@
#include "common.h"
#include "piint.h"
#include "PR/ultraerror.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/epirawdma/osEPiRawStartDma.s")
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
s32 __osEPiRawStartDma(OSPiHandle* pihandle, s32 direction, u32 devAddr, void* dramAddr, u32 size) {
u32 stat;
u32 domain;
#ifdef _DEBUG
if ((direction != OS_READ) && (direction != OS_WRITE)) {
__osError(ERR_OSPIRAWSTARTDMA_DIR, 1, direction);
return -1;
}
if (devAddr & 0x1) {
__osError(ERR_OSPIRAWSTARTDMA_DEVADDR, 1, devAddr);
return -1;
}
if ((u32) dramAddr & 0x7) {
__osError(ERR_OSPIRAWSTARTDMA_ADDR, 1, dramAddr);
return -1;
}
if (size & 0x1) {
__osError(ERR_OSPIRAWSTARTDMA_SIZE, 1, size);
return -1;
}
if ((size == 0) || (size > (16 * 1024 * 1024))) {
__osError(ERR_OSPIRAWSTARTDMA_RANGE, 1, size);
return -1;
}
#endif
EPI_SYNC(pihandle, stat, domain);
IO_WRITE(PI_DRAM_ADDR_REG, osVirtualToPhysical(dramAddr));
IO_WRITE(PI_CART_ADDR_REG, K1_TO_PHYS(pihandle->baseAddress | devAddr));
switch (direction) {
case OS_READ:
IO_WRITE(PI_WR_LEN_REG, size - 1);
break;
case OS_WRITE:
IO_WRITE(PI_RD_LEN_REG, size - 1);
break;
default:
return -1;
}
return 0;
}

View file

@ -1,3 +1,29 @@
#include "common.h"
#include "piint.h"
#include "PR/ultraerror.h"
#include "PR/assert.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/epirawread/osEPiRawReadIo.s")
// Adjust line numbers to match assert
#if BUILD_VERSION < VERSION_J
#line 28
#endif
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
s32 __osEPiRawReadIo(OSPiHandle* pihandle, u32 devAddr, u32* data) {
register u32 stat;
register u32 domain;
#ifdef _DEBUG
if (devAddr & 0x3) {
__osError(ERR_OSPIRAWREADIO, 1, devAddr);
return -1;
}
#endif
assert(data != NULL);
WAIT_ON_IOBUSY(stat);
*data = IO_READ(pihandle->baseAddress | devAddr);
return 0;
}

View file

@ -1,3 +1,22 @@
#include "common.h"
#include "piint.h"
#include "PR/ultraerror.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/epirawwrite/osEPiRawWriteIo.s")
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
s32 __osEPiRawWriteIo(OSPiHandle* pihandle, u32 devAddr, u32 data) {
register u32 stat;
register u32 domain;
#ifdef _DEBUG
if (devAddr & 0x3) {
__osError(ERR_OSPIRAWWRITEIO, 1, devAddr);
return -1;
}
#endif
WAIT_ON_IOBUSY(stat);
IO_WRITE(pihandle->baseAddress | devAddr, data);
return 0;
}

View file

@ -1,3 +1,38 @@
#include "common.h"
// This file was removed in 2.0J
#include "PR/os_internal.h"
#include "PR/os_libc.h"
#include "PR/rcp.h"
#include "macros.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/leodiskinit/osLeoDiskInit.s")
OSPiHandle LeoDiskHandle ALIGNED(8);
OSPiHandle* __osDiskHandle;
OSPiHandle* osLeoDiskInit() {
u32 saveMask;
LeoDiskHandle.type = DEVICE_TYPE_64DD;
LeoDiskHandle.baseAddress = PHYS_TO_K1(PI_DOM2_ADDR1);
LeoDiskHandle.latency = 3;
LeoDiskHandle.pulse = 6;
LeoDiskHandle.pageSize = 6;
LeoDiskHandle.relDuration = 2;
LeoDiskHandle.domain = PI_DOMAIN2;
IO_WRITE(PI_BSD_DOM2_LAT_REG, LeoDiskHandle.latency);
IO_WRITE(PI_BSD_DOM2_PWD_REG, LeoDiskHandle.pulse);
IO_WRITE(PI_BSD_DOM2_PGS_REG, LeoDiskHandle.pageSize);
IO_WRITE(PI_BSD_DOM2_RLS_REG, LeoDiskHandle.relDuration);
#if BUILD_VERSION >= VERSION_I
LeoDiskHandle.speed = 0;
#endif
bzero(&LeoDiskHandle.transferInfo, sizeof(__OSTranxInfo));
saveMask = __osDisableInt();
LeoDiskHandle.next = __osPiTable;
__osPiTable = &LeoDiskHandle;
__osDiskHandle = &LeoDiskHandle;
__osRestoreInt(saveMask);
return &LeoDiskHandle;
}

View file

@ -1,7 +1,195 @@
#include "common.h"
#include "PR/os_internal.h"
#include "PR/rcp.h"
#include "osint.h"
#include "piint.h"
#include "macros.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/leointerrupt/__osLeoInterrupt.s")
extern OSPiHandle* __osDiskHandle;
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/leointerrupt/__osLeoAbnormalResume.s")
u8 leoDiskStack[OS_PIM_STACKSIZE] ALIGNED(16);
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/leointerrupt/__osLeoResume.s")
static void __osLeoAbnormalResume(void);
static void __osLeoResume(void);
s32 __osLeoInterrupt() {
u32 stat = 0;
volatile u32 pi_stat;
u32 bm_stat;
__OSTranxInfo* info = &__osDiskHandle->transferInfo;
__OSBlockInfo* blockInfo = &info->block[info->blockNum];
pi_stat = IO_READ(PI_STATUS_REG);
if (pi_stat & PI_STATUS_DMA_BUSY) {
__OSGlobalIntMask = __OSGlobalIntMask & ~SR_IBIT4; // cart interrupt
blockInfo->errStatus = LEO_ERROR_29;
__osLeoResume();
return 1;
}
WAIT_ON_IOBUSY(pi_stat);
stat = IO_READ(LEO_STATUS);
if (stat & LEO_STATUS_MECHANIC_INTERRUPT) {
WAIT_ON_IOBUSY(pi_stat);
IO_WRITE(LEO_BM_CTL, info->bmCtlShadow | LEO_BM_CTL_CLR_MECHANIC_INTR);
blockInfo->errStatus = LEO_ERROR_GOOD;
return 0;
}
if (info->cmdType == LEO_CMD_TYPE_2) {
return 1;
}
if (stat & LEO_STATUS_BUFFER_MANAGER_ERROR) {
WAIT_ON_IOBUSY(pi_stat);
stat = IO_READ(LEO_STATUS);
blockInfo->errStatus = LEO_ERROR_22;
__osLeoResume();
IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR);
__OSGlobalIntMask |= OS_IM_PI;
return 1;
}
if (info->cmdType == LEO_CMD_TYPE_1) {
if ((stat & LEO_STATUS_DATA_REQUEST) == 0) {
if (info->sectorNum + 1 != info->transferMode * 85) {
blockInfo->errStatus = LEO_ERROR_24;
__osLeoAbnormalResume();
return 1;
}
IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR);
__OSGlobalIntMask |= OS_IM_PI;
blockInfo->errStatus = LEO_ERROR_GOOD;
__osLeoResume();
return 1;
} else {
blockInfo->dramAddr = (void*) ((u32) blockInfo->dramAddr + blockInfo->sectorSize);
info->sectorNum++;
osEPiRawStartDma(__osDiskHandle, OS_WRITE, LEO_SECTOR_BUFF, blockInfo->dramAddr, blockInfo->sectorSize);
return 1;
}
} else if (info->cmdType == LEO_CMD_TYPE_0) {
if (info->transferMode == LEO_SECTOR_MODE) {
if (info->sectorNum > (s32) blockInfo->C1ErrNum + 17) {
blockInfo->errStatus = LEO_ERROR_GOOD;
__osLeoAbnormalResume();
return 1;
}
if ((stat & LEO_STATUS_DATA_REQUEST) == 0) {
blockInfo->errStatus = LEO_ERROR_23;
__osLeoAbnormalResume();
return 1;
}
} else {
blockInfo->dramAddr = (void*) ((u32) blockInfo->dramAddr + blockInfo->sectorSize);
}
bm_stat = IO_READ(LEO_BM_STATUS);
if ((bm_stat & LEO_BM_STATUS_C1SINGLE && bm_stat & LEO_BM_STATUS_C1DOUBLE) || bm_stat & LEO_BM_STATUS_MICRO) {
if (blockInfo->C1ErrNum > 3) {
if (info->transferMode != LEO_SECTOR_MODE || info->sectorNum > 0x52) {
blockInfo->errStatus = LEO_ERROR_23;
__osLeoAbnormalResume();
return 1;
}
} else {
int errNum = blockInfo->C1ErrNum;
blockInfo->C1ErrSector[errNum] = info->sectorNum + 1;
}
blockInfo->C1ErrNum++;
}
if (stat & LEO_STATUS_C2_TRANSFER) {
if (info->sectorNum + 1 != 88) {
blockInfo->errStatus = LEO_ERROR_24;
__osLeoAbnormalResume();
}
if (info->transferMode == LEO_TRACK_MODE && info->blockNum == 0) {
info->blockNum = 1;
info->sectorNum = -1;
info->block[1].dramAddr = (void*) ((u32) info->block[1].dramAddr - info->block[1].sectorSize);
blockInfo->errStatus = LEO_ERROR_22;
} else {
IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR);
__OSGlobalIntMask |= OS_IM_PI;
info->cmdType = LEO_CMD_TYPE_2;
blockInfo->errStatus = LEO_ERROR_GOOD;
}
osEPiRawStartDma(__osDiskHandle, OS_READ, LEO_C2_BUFF, blockInfo->C2Addr, blockInfo->sectorSize * 4);
return 1;
}
if (info->sectorNum == -1 && info->transferMode == LEO_TRACK_MODE && info->blockNum == 1) {
__OSBlockInfo* bptr = &info->block[0];
if (bptr->C1ErrNum == 0) {
if (((u32*) bptr->C2Addr)[0] | ((u32*) bptr->C2Addr)[1] | ((u32*) bptr->C2Addr)[2] |
((u32*) bptr->C2Addr)[3]) {
bptr->errStatus = LEO_ERROR_24;
__osLeoAbnormalResume();
return 1;
}
}
bptr->errStatus = 0;
__osLeoResume();
}
info->sectorNum++;
if (stat & LEO_STATUS_DATA_REQUEST) {
if (info->sectorNum > 0x54) {
blockInfo->errStatus = LEO_ERROR_24;
__osLeoAbnormalResume();
return 1;
}
osEPiRawStartDma(__osDiskHandle, 0, LEO_SECTOR_BUFF, blockInfo->dramAddr, blockInfo->sectorSize);
blockInfo->errStatus = LEO_ERROR_GOOD;
return 1;
} else if (info->sectorNum <= 0x54) {
blockInfo->errStatus = LEO_ERROR_24;
__osLeoAbnormalResume();
return 1;
}
return 1;
} else {
blockInfo->errStatus = LEO_ERROR_4;
__osLeoAbnormalResume();
return 1;
}
}
static void __osLeoAbnormalResume(void) {
__OSTranxInfo* info = &__osDiskHandle->transferInfo;
u32 pi_stat;
WAIT_ON_IOBUSY(pi_stat);
IO_WRITE(LEO_BM_CTL, info->bmCtlShadow | LEO_BM_CTL_RESET);
WAIT_ON_IOBUSY(pi_stat);
IO_WRITE(LEO_BM_CTL, info->bmCtlShadow);
__osLeoResume();
IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR);
__OSGlobalIntMask |= OS_IM_PI;
}
static void __osLeoResume(void) {
__OSEventState* es = &__osEventStateTab[OS_EVENT_PI];
OSMesgQueue* mq = es->messageQueue;
s32 last;
if (mq == NULL || MQ_IS_FULL(mq)) {
return;
}
last = (mq->first + mq->validCount) % mq->msgCount;
mq->msg[last] = es->message;
mq->validCount++;
if (mq->mtqueue->next != NULL) {
__osEnqueueThread(&__osRunQueue, __osPopThread(&mq->mtqueue));
}
}

View file

@ -1,10 +1,10 @@
#include "global.h"
#include "siint.h"
extern OSPifRam _MotorStopData[MAXCONTROLLERS];
extern OSPifRam _MotorStartData[MAXCONTROLLERS];
extern u8 _motorstopbuf[0x20];
extern u8 _motorstartbuf[0x20];
OSPifRam _MotorStopData[MAXCONTROLLERS] ALIGNED(8);
OSPifRam _MotorStartData[MAXCONTROLLERS] ALIGNED(8);
u8 _motorstopbuf[32] ALIGNED(8);
u8 _motorstartbuf[32] ALIGNED(8);
s32 osMotorStop(OSPfs* pfs) {
s32 i;

View file

@ -1,3 +1,28 @@
#include "common.h"
#include "PR/os_internal.h"
#include "PR/controller.h"
#include "siint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/pfsgetstatus/__osPfsGetStatus.s")
s32 __osPfsGetStatus(OSMesgQueue* queue, int channel) {
s32 ret = 0;
OSMesg dummy;
u8 pattern;
OSContStatus status[4];
__osPfsRequestData(0);
ret = __osSiRawStartDma(1, &__osPfsPifRam);
osRecvMesg(queue, &dummy, 1);
ret = __osSiRawStartDma(0, &__osPfsPifRam);
osRecvMesg(queue, &dummy, 1);
__osPfsGetInitData(&pattern, status);
if (status[channel].status & CONT_CARD_ON && status[channel].status & CONT_CARD_PULL) {
return 2;
}
if (status[channel].errno || !(status[channel].status & CONT_CARD_ON)) {
return 1;
}
if (status[channel].status & CONT_ADDR_CRC_ER) {
return 4;
}
return ret;
}

View file

@ -1,7 +1,105 @@
#include "common.h"
#include "macros.h"
#include "PR/os_internal.h"
#include "PR/controller.h"
#include "siint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/pfsisplug/osPfsIsPlug.s")
OSPifRam __osPfsPifRam ALIGNED(16);
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/pfsisplug/__osPfsRequestData.s")
s32 osPfsIsPlug(OSMesgQueue* mq, u8* pattern) {
s32 ret = 0;
OSMesg msg;
u8 bitpattern;
OSContStatus contData[MAXCONTROLLERS];
s32 channel;
u8 bits = 0;
s32 crcErrorCount = 3;
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/pfsisplug/__osPfsGetInitData.s")
__osSiGetAccess();
do {
__osPfsRequestData(CONT_CMD_REQUEST_STATUS);
ret = __osSiRawStartDma(OS_WRITE, &__osPfsPifRam);
osRecvMesg(mq, &msg, OS_MESG_BLOCK);
ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam);
osRecvMesg(mq, &msg, OS_MESG_BLOCK);
__osPfsGetInitData(&bitpattern, &contData[0]);
for (channel = 0; channel < __osMaxControllers; channel++) {
if ((contData[channel].status & CONT_ADDR_CRC_ER) == 0) {
crcErrorCount--;
break;
}
}
if (channel == __osMaxControllers) {
crcErrorCount = 0;
}
} while (crcErrorCount > 0);
for (channel = 0; channel < __osMaxControllers; channel++) {
if ((contData[channel].errno == 0) && ((contData[channel].status & CONT_CARD_ON) != 0)) {
bits |= (1 << channel);
}
}
__osSiRelAccess();
*pattern = bits;
return ret;
}
void __osPfsRequestData(u8 cmd) {
u8* ptr;
__OSContRequesFormat requestformat;
int i;
__osContLastCmd = cmd;
#if BUILD_VERSION < VERSION_I
for (i = 0; i < 16; i++) {
__osPfsPifRam.ramarray[i] = 0;
}
__osPfsPifRam.pifstatus = CONT_CMD_EXE;
#endif
ptr = (u8*) &__osPfsPifRam;
requestformat.dummy = CONT_CMD_NOP;
requestformat.txsize = CONT_CMD_REQUEST_STATUS_TX;
requestformat.rxsize = CONT_CMD_REQUEST_STATUS_RX;
requestformat.cmd = cmd;
requestformat.typeh = CONT_CMD_NOP;
requestformat.typel = CONT_CMD_NOP;
requestformat.status = CONT_CMD_NOP;
requestformat.dummy1 = CONT_CMD_NOP;
for (i = 0; i < __osMaxControllers; i++) {
*((__OSContRequesFormat*) ptr) = requestformat;
ptr += sizeof(__OSContRequesFormat);
}
*ptr = CONT_CMD_END;
}
void __osPfsGetInitData(u8* pattern, OSContStatus* data) {
u8* ptr;
__OSContRequesFormat requestformat;
int i;
u8 bits = 0;
ptr = (u8*) &__osPfsPifRam;
for (i = 0; i < __osMaxControllers; i++, ptr += sizeof(requestformat), data++) {
requestformat = *((__OSContRequesFormat*) ptr);
data->errno = CHNL_ERR(requestformat);
if (data->errno != 0) {
continue;
}
data->type = ((requestformat.typel << 8) | requestformat.typeh);
data->status = requestformat.status;
bits |= (1 << i);
}
*pattern = bits;
}

View file

@ -1,7 +1,25 @@
#include "common.h"
#include "macros.h"
#include "PR/os_internal.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/piacs/__osPiCreateAccessQueue.s")
#define PI_Q_BUF_LEN 1
u32 __osPiAccessQueueEnabled = 0;
OSMesg piAccessBuf[PI_Q_BUF_LEN];
OSMesgQueue __osPiAccessQueue ALIGNED(8);
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/piacs/__osPiGetAccess.s")
void __osPiCreateAccessQueue(void) {
__osPiAccessQueueEnabled = 1;
osCreateMesgQueue(&__osPiAccessQueue, piAccessBuf, PI_Q_BUF_LEN);
osSendMesg(&__osPiAccessQueue, NULL, OS_MESG_NOBLOCK);
}
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/piacs/__osPiRelAccess.s")
void __osPiGetAccess(void) {
OSMesg dummyMesg;
if (!__osPiAccessQueueEnabled) {
__osPiCreateAccessQueue();
}
osRecvMesg(&__osPiAccessQueue, &dummyMesg, OS_MESG_BLOCK);
}
void __osPiRelAccess(void) {
osSendMesg(&__osPiAccessQueue, NULL, OS_MESG_NOBLOCK);
}

View file

@ -1,3 +1,10 @@
#include "common.h"
#include "PR/os_internal.h"
#include "piint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/pigetcmdq/osPiGetCmdQueue.s")
OSMesgQueue* osPiGetCmdQueue(void) {
if (!__osPiDevMgr.active) {
return NULL;
} else {
return __osPiDevMgr.cmdQueue;
}
}

View file

@ -2,16 +2,33 @@
#include "piint.h"
#include "PR/rdb.h"
void ramromMain(void* arg);
extern OSMesg piEventBuf[];
extern OSMesgQueue piEventQueue;
extern OSThread piThread;
extern char piThreadStack[];
extern OSThread ramromThread;
extern char ramromThreadStack[];
OSThread piThread ALIGNED(8);
char piThreadStack[OS_PIM_STACKSIZE] ALIGNED(16);
#ifndef _FINALROM
static OSThread ramromThread ALIGNED(8);
static char ramromThreadStack[1024] ALIGNED(16);
static OSMesgQueue getRamromQ ALIGNED(8);
static OSMesg getRamromBuf[1];
static OSMesgQueue freeRamromQ ALIGNED(8);
static OSMesg freeRamromBuf[1];
static void ramromMain(void*);
#endif
OSMesgQueue piEventQueue ALIGNED(8);
OSMesg piEventBuf[1];
#ifdef IMPORT_DATA_PENDING
OSDevMgr __osPiDevMgr = { 0 };
OSPiHandle* __osPiTable = NULL;
#if BUILD_VERSION >= VERSION_J
OSPiHandle __Dom1SpeedParam ALIGNED(8);
OSPiHandle __Dom2SpeedParam ALIGNED(8);
OSPiHandle* __osCurrentHandle[2] ALIGNED(8) = { &__Dom1SpeedParam, &__Dom2SpeedParam };
#else
extern OSPiHandle CartRomHandle;
extern OSPiHandle LeoDiskHandle;
OSPiHandle* __osCurrentHandle[2] ALIGNED(8) = { &CartRomHandle, &LeoDiskHandle };
#endif
void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgCnt) {
u32 savedMask;
@ -56,9 +73,6 @@ void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgC
osSetThreadPri(NULL, oldPri);
}
}
#else
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/pimgr/osCreatePiManager.s")
#endif
extern OSMesg freeRamromBuf[];
extern OSMesgQueue freeRamromQ;

View file

@ -1,3 +1,53 @@
#include "common.h"
#include "piint.h"
#include "PR/ultraerror.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/pirawdma/osPiRawStartDma.s")
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
s32 __osPiRawStartDma(s32 direction, u32 devAddr, void* dramAddr, u32 size) {
register u32 stat;
#ifdef _DEBUG
if ((direction != OS_READ) && (direction != OS_WRITE)) {
__osError(ERR_OSPIRAWSTARTDMA_DIR, 1, direction);
return -1;
}
if (devAddr & 0x1) {
__osError(ERR_OSPIRAWSTARTDMA_DEVADDR, 1, devAddr);
return -1;
}
if ((u32) dramAddr & 0x7) {
__osError(ERR_OSPIRAWSTARTDMA_ADDR, 1, dramAddr);
return -1;
}
if (size & 0x1) {
__osError(ERR_OSPIRAWSTARTDMA_SIZE, 1, size);
return -1;
}
if ((size == 0) || (size > (16 * 1024 * 1024))) {
__osError(ERR_OSPIRAWSTARTDMA_RANGE, 1, size);
return -1;
}
#endif
WAIT_ON_IOBUSY(stat);
IO_WRITE(PI_DRAM_ADDR_REG, osVirtualToPhysical(dramAddr));
IO_WRITE(PI_CART_ADDR_REG, K1_TO_PHYS((u32) osRomBase | devAddr));
switch (direction) {
case OS_READ:
IO_WRITE(PI_WR_LEN_REG, size - 1);
break;
case OS_WRITE:
IO_WRITE(PI_RD_LEN_REG, size - 1);
break;
default:
return -1;
}
return 0;
}

View file

@ -1,3 +1,29 @@
#include "global.h"
#include "PR/assert.h"
#include "PR/ultraerror.h"
#include "piint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/pirawread/osPiRawReadIo.s")
// Adjust line numbers to match assert
#if BUILD_VERSION < VERSION_J
#line 46
#endif
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
s32 __osPiRawReadIo(u32 devAddr, u32* data) {
register u32 stat;
#ifdef _DEBUG
if (devAddr & 0x3) {
__osError(ERR_OSPIRAWREADIO, 1, devAddr);
return -1;
}
#endif
assert(data != NULL);
WAIT_ON_IOBUSY(stat);
*data = IO_READ((u32) osRomBase | devAddr);
return 0;
}

View file

@ -1,3 +1,15 @@
#include "common.h"
#include "PR/os_internal.h"
#include "siint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/si/__osSiDeviceBusy.s")
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
int __osSiDeviceBusy() {
register u32 stat = IO_READ(SI_STATUS_REG);
if (stat & (SI_STATUS_DMA_BUSY | SI_STATUS_RD_BUSY)) {
return TRUE;
} else {
return FALSE;
}
}

View file

@ -1,7 +1,25 @@
#include "common.h"
#include "macros.h"
#include "PR/os_internal.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/siacs/__osSiCreateAccessQueue.s")
#define SI_Q_BUF_LEN 1
OSMesg siAccessBuf[SI_Q_BUF_LEN] ALIGNED(8);
OSMesgQueue __osSiAccessQueue ALIGNED(8);
u32 __osSiAccessQueueEnabled = 0;
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/siacs/__osSiGetAccess.s")
void __osSiCreateAccessQueue(void) {
__osSiAccessQueueEnabled = 1;
osCreateMesgQueue(&__osSiAccessQueue, siAccessBuf, SI_Q_BUF_LEN);
osSendMesg(&__osSiAccessQueue, NULL, OS_MESG_NOBLOCK);
}
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/siacs/__osSiRelAccess.s")
void __osSiGetAccess(void) {
OSMesg dummyMesg;
if (!__osSiAccessQueueEnabled) {
__osSiCreateAccessQueue();
}
osRecvMesg(&__osSiAccessQueue, &dummyMesg, OS_MESG_BLOCK);
}
void __osSiRelAccess(void) {
osSendMesg(&__osSiAccessQueue, NULL, OS_MESG_NOBLOCK);
}

View file

@ -1,3 +1,43 @@
#include "common.h"
#include "PR/os_internal.h"
#include "PR/assert.h"
#include "siint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/sirawdma/__osSiRawStartDma.s")
// Adjust line numbers to match assert
#if BUILD_VERSION < VERSION_J
#line 49
#endif
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
s32 __osSiRawStartDma(s32 direction, void* dramAddr) {
assert(((u32) dramAddr & 0x3) == 0);
#if BUILD_VERSION >= VERSION_J
if (IO_READ(SI_STATUS_REG) & (SI_STATUS_DMA_BUSY | SI_STATUS_RD_BUSY)) {
return -1;
}
#else
if (__osSiDeviceBusy()) {
return -1;
}
#endif
if (direction == OS_WRITE) {
osWritebackDCache(dramAddr, 64);
}
IO_WRITE(SI_DRAM_ADDR_REG, osVirtualToPhysical(dramAddr));
if (direction == OS_READ) {
IO_WRITE(SI_PIF_ADDR_RD64B_REG, PIF_RAM_START);
} else {
IO_WRITE(SI_PIF_ADDR_WR64B_REG, PIF_RAM_START);
}
if (direction == OS_READ) {
osInvalDCache(dramAddr, 64);
}
return 0;
}

View file

@ -1,3 +1,23 @@
#include "common.h"
#include "PR/os_internal.h"
#include "PR/assert.h"
#include "siint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/sirawread/__osSiRawReadIo.s")
// Adjust line numbers to match assert
#if BUILD_VERSION < VERSION_J
#line 45
#endif
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
s32 __osSiRawReadIo(u32 devAddr, u32* data) {
assert((devAddr & 0x3) == 0);
assert(data != NULL);
if (__osSiDeviceBusy()) {
return -1;
}
*data = IO_READ(devAddr);
return 0;
}

View file

@ -1,3 +1,22 @@
#include "common.h"
#include "PR/os_internal.h"
#include "PR/assert.h"
#include "siint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/sirawwrite/__osSiRawWriteIo.s")
// Adjust line numbers to match assert
#if BUILD_VERSION < VERSION_J
#line 46
#endif
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
s32 __osSiRawWriteIo(u32 devAddr, u32 data) {
assert((devAddr & 0x3) == 0);
if (__osSiDeviceBusy()) {
return -1;
}
IO_WRITE(devAddr, data);
return 0;
}

View file

@ -1,3 +1,17 @@
#include "common.h"
#include "PR/os_internal.h"
#include "PR/rcp.h"
#include "PR/sptask.h"
#include "osint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/sp/__osSpDeviceBusy.s")
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
int __osSpDeviceBusy() {
register u32 stat = IO_READ(SP_STATUS_REG);
if (stat & (SP_STATUS_DMA_BUSY | SP_STATUS_DMA_FULL | SP_STATUS_IO_FULL)) {
return TRUE;
} else {
return FALSE;
}
}

View file

@ -1,3 +1,9 @@
#include "common.h"
#include "PR/os_internal.h"
#include "PR/rcp.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/spgetstat/__osSpGetStatus.s")
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
u32 __osSpGetStatus() {
return IO_READ(SP_STATUS_REG);
}

View file

@ -1,3 +1,33 @@
#include "common.h"
#include "PR/os_internal.h"
#include "PR/assert.h"
#include "PR/rcp.h"
#include "osint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/sprawdma/__osSpRawStartDma.s")
// Adjust line numbers to match assert
#if BUILD_VERSION < VERSION_J
#line 52
#endif
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
s32 __osSpRawStartDma(s32 direction, u32 devAddr, void* dramAddr, u32 size) {
assert(((u32) devAddr & 0x7) == 0);
assert(((u32) dramAddr & 0x7) == 0);
assert(((u32) size & 0x7) == 0);
if (__osSpDeviceBusy()) {
return -1;
}
IO_WRITE(SP_MEM_ADDR_REG, devAddr);
IO_WRITE(SP_DRAM_ADDR_REG, osVirtualToPhysical(dramAddr));
if (direction == OS_READ) {
IO_WRITE(SP_WR_LEN_REG, size - 1);
} else {
IO_WRITE(SP_RD_LEN_REG, size - 1);
}
return 0;
}

View file

@ -1,3 +1,24 @@
#include "common.h"
#include "PR/os_internal.h"
#include "PR/rcp.h"
#include "PR/assert.h"
#include "osint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/sprawread/__osSpRawReadIo.s")
// Adjust line numbers to match assert
#if BUILD_VERSION < VERSION_J
#line 45
#endif
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
s32 __osSpRawReadIo(u32 devAddr, u32* data) {
assert((devAddr & 0x3) == 0);
assert(data != NULL);
if (__osSpDeviceBusy()) {
return -1;
}
*data = IO_READ(devAddr);
return 0;
}

View file

@ -1,3 +1,23 @@
#include "common.h"
#include "PR/os_internal.h"
#include "PR/rcp.h"
#include "PR/assert.h"
#include "osint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/sprawwrite/__osSpRawWriteIo.s")
// Adjust line numbers to match assert
#if BUILD_VERSION < VERSION_J
#line 45
#endif
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
s32 __osSpRawWriteIo(u32 devAddr, u32 data) {
assert((devAddr & 0x3) == 0);
if (__osSpDeviceBusy()) {
return -1;
}
IO_WRITE(devAddr, data);
return 0;
}

View file

@ -1,3 +1,15 @@
#include "common.h"
#include "PR/rcp.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/spsetpc/__osSpSetPc.s")
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
s32 __osSpSetPc(u32 pc) {
register u32 status = IO_READ(SP_STATUS_REG);
if (!(status & SP_STATUS_HALT)) {
return -1;
}
IO_WRITE(SP_PC_REG, pc);
return 0;
}

View file

@ -1,3 +1,9 @@
#include "common.h"
#include "PR/os_internal.h"
#include "PR/rcp.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/spsetstat/__osSpSetStatus.s")
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
void __osSpSetStatus(u32 data) {
IO_WRITE(SP_STATUS_REG, data);
}

View file

@ -1,7 +1,82 @@
#include "common.h"
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
#include "PR/sptask.h"
#include "PR/rcp.h"
#include "osint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/sptask/_VirtualToPhysicalTask.s")
#if BUILD_VERSION < VERSION_J
#ident "$Revision: 1.4 $"
#endif
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/sptask/osSpTaskLoad.s")
#define _osVirtualToPhysical(ptr) \
if (ptr != NULL) { \
ptr = (void*) osVirtualToPhysical(ptr); \
}
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/sptask/osSpTaskStartGo.s")
static OSTask tmp_task;
static OSTask* _VirtualToPhysicalTask(OSTask* intp) {
OSTask* tp;
tp = &tmp_task;
bcopy(intp, tp, sizeof(OSTask));
_osVirtualToPhysical(tp->t.ucode);
_osVirtualToPhysical(tp->t.ucode_data);
_osVirtualToPhysical(tp->t.dram_stack);
_osVirtualToPhysical(tp->t.output_buff);
_osVirtualToPhysical(tp->t.output_buff_size);
_osVirtualToPhysical(tp->t.data_ptr);
_osVirtualToPhysical(tp->t.yield_data_ptr);
return tp;
}
void osSpTaskLoad(OSTask* intp) {
OSTask* tp;
#ifdef _DEBUG
if ((intp->t.dram_stack != 0x0) && ((u32) intp->t.dram_stack & 0xf)) {
__osError(ERR_OSSPTASKLOAD_DRAM, 1, intp->t.dram_stack);
return;
}
if ((intp->t.output_buff != 0x0) && ((u32) intp->t.output_buff & 0xf)) {
__osError(ERR_OSSPTASKLOAD_OUT, 1, intp->t.output_buff);
return;
}
if ((intp->t.output_buff_size != 0x0) && ((u32) intp->t.output_buff_size & 0xf)) {
__osError(ERR_OSSPTASKLOAD_OUTSIZE, 1, intp->t.output_buff_size);
return;
}
if ((intp->t.yield_data_ptr != 0x0) && ((u32) intp->t.yield_data_ptr & 0xf)) {
__osError(ERR_OSSPTASKLOAD_YIELD, 1, intp->t.yield_data_ptr);
return;
}
#endif
tp = _VirtualToPhysicalTask(intp);
if (tp->t.flags & OS_TASK_YIELDED) {
tp->t.ucode_data = tp->t.yield_data_ptr;
tp->t.ucode_data_size = tp->t.yield_data_size;
intp->t.flags &= ~OS_TASK_YIELDED;
if (tp->t.flags & OS_TASK_LOADABLE) {
tp->t.ucode = (u64*) IO_READ((u32) intp->t.yield_data_ptr + OS_YIELD_DATA_SIZE - 4);
}
}
osWritebackDCache(tp, sizeof(OSTask));
__osSpSetStatus(SP_CLR_YIELD | SP_CLR_YIELDED | SP_CLR_TASKDONE | SP_SET_INTR_BREAK);
while (__osSpSetPc(SP_IMEM_START) == -1) {}
while (__osSpRawStartDma(1, (SP_IMEM_START - sizeof(*tp)), tp, sizeof(OSTask)) == -1) {}
while (__osSpDeviceBusy()) {}
while (__osSpRawStartDma(1, SP_IMEM_START, tp->t.ucode_boot, tp->t.ucode_boot_size) == -1) {}
}
void osSpTaskStartGo(OSTask* tp) {
while (__osSpDeviceBusy()) {}
__osSpSetStatus(SP_SET_INTR_BREAK | SP_CLR_SSTEP | SP_CLR_BROKE | SP_CLR_HALT);
}

View file

@ -1,3 +1,6 @@
#include "common.h"
#include "PR/os_internal.h"
#include "PR/rcp.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/sptaskyield/osSpTaskYield.s")
void osSpTaskYield(void) {
__osSpSetStatus(SP_SET_YIELD);
}

View file

@ -1,3 +1,18 @@
#include "common.h"
#include "PR/os_internal.h"
#include "PR/sptask.h"
#include "PR/rcp.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/sptaskyielded/osSpTaskYielded.s")
OSYieldResult osSpTaskYielded(OSTask* tp) {
u32 status;
OSYieldResult result;
status = __osSpGetStatus();
result = (status & SP_STATUS_YIELDED) ? OS_TASK_YIELDED : 0;
if (status & SP_STATUS_YIELD) {
tp->t.flags |= result;
tp->t.flags &= ~(OS_TASK_DP_WAIT);
}
return result;
}

View file

@ -1,3 +1,39 @@
#include "common.h"
#include "macros.h"
#include "PR/os_internal.h"
#include "PR/R4300.h"
#include "PR/rcp.h"
#include "PR/viint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/vi/__osViInit.s")
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
static __OSViContext vi[2] ALIGNED(8) = { 0 };
__OSViContext* __osViCurr = &vi[0];
__OSViContext* __osViNext = &vi[1];
void __osViInit(void) {
bzero(vi, sizeof(vi));
__osViCurr = &vi[0];
__osViNext = &vi[1];
__osViNext->retraceCount = 1;
__osViCurr->retraceCount = 1;
__osViNext->framep = (void*) K0BASE;
__osViCurr->framep = (void*) K0BASE;
if (osTvType == OS_TV_TYPE_PAL) {
__osViNext->modep = &osViModePalLan1;
} else if (osTvType == OS_TV_TYPE_MPAL) {
__osViNext->modep = &osViModeMpalLan1;
} else {
__osViNext->modep = &osViModeNtscLan1;
}
__osViNext->state = VI_STATE_BLACK;
__osViNext->control = __osViNext->modep->comRegs.ctrl;
while (IO_READ(VI_CURRENT_REG) > 10) { // wait for vsync?
}
IO_WRITE(VI_CONTROL_REG, 0); // pixel size blank (no data, no sync)
__osViSwapContext();
}

View file

@ -1,3 +1,17 @@
#include "common.h"
#include "PR/os_internal.h"
#include "PR/viint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/viblack/osViBlack.s")
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
void osViBlack(u8 active) {
register u32 saveMask = __osDisableInt();
if (active) {
__osViNext->state |= VI_STATE_BLACK;
} else {
__osViNext->state &= ~VI_STATE_BLACK;
}
__osRestoreInt(saveMask);
}

View file

@ -1,3 +1,9 @@
#include "common.h"
#include "PR/os_internal.h"
#include "PR/viint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/vigetcurrcontext/__osViGetCurrentContext.s")
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
__OSViContext* __osViGetCurrentContext(void) {
return __osViCurr;
}

View file

@ -1,5 +1,126 @@
#include "common.h"
#include "macros.h"
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
#include "PR/rcp.h"
#include "PR/viint.h"
#include "osint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/vimgr/osCreateViManager.s")
OSDevMgr __osViDevMgr = { 0 };
#if BUILD_VERSION >= VERSION_J
u32 __additional_scanline = 0;
#endif
static OSThread viThread;
static unsigned char viThreadStack[OS_VIM_STACKSIZE] ALIGNED(16);
static OSMesgQueue viEventQueue ALIGNED(8);
static OSMesg viEventBuf[5] ALIGNED(8);
static OSIoMesg viRetraceMsg ALIGNED(8);
static OSIoMesg viCounterMsg ALIGNED(8);
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/vimgr/viMgrMain.s")
static void viMgrMain(void* arg);
void osCreateViManager(OSPri pri) {
u32 savedMask;
OSPri oldPri;
OSPri myPri;
#ifdef _DEBUG
if ((pri < OS_PRIORITY_IDLE) || (pri > OS_PRIORITY_MAX)) {
__osError(ERR_OSCREATEVIMANAGER, 1, pri);
return;
}
#endif
if (__osViDevMgr.active) {
return;
}
__osTimerServicesInit();
#if BUILD_VERSION >= VERSION_J
__additional_scanline = 0;
#endif
osCreateMesgQueue(&viEventQueue, viEventBuf, ARRLEN(viEventBuf));
viRetraceMsg.hdr.type = OS_MESG_TYPE_VRETRACE;
viRetraceMsg.hdr.pri = OS_MESG_PRI_NORMAL;
viRetraceMsg.hdr.retQueue = NULL;
viCounterMsg.hdr.type = OS_MESG_TYPE_COUNTER;
viCounterMsg.hdr.pri = OS_MESG_PRI_NORMAL;
viCounterMsg.hdr.retQueue = NULL;
osSetEventMesg(OS_EVENT_VI, &viEventQueue, &viRetraceMsg);
osSetEventMesg(OS_EVENT_COUNTER, &viEventQueue, &viCounterMsg);
oldPri = -1;
myPri = osGetThreadPri(NULL);
if (myPri < pri) {
oldPri = myPri;
osSetThreadPri(NULL, pri);
}
savedMask = __osDisableInt();
__osViDevMgr.active = TRUE;
__osViDevMgr.thread = &viThread;
__osViDevMgr.cmdQueue = &viEventQueue;
__osViDevMgr.evtQueue = &viEventQueue;
__osViDevMgr.acsQueue = NULL;
__osViDevMgr.dma = NULL;
__osViDevMgr.edma = NULL;
osCreateThread(&viThread, 0, viMgrMain, &__osViDevMgr, &viThreadStack[OS_VIM_STACKSIZE], pri);
__osViInit();
osStartThread(&viThread);
__osRestoreInt(savedMask);
if (oldPri != -1) {
osSetThreadPri(NULL, oldPri);
}
}
static void viMgrMain(void* arg) {
__OSViContext* vc;
OSDevMgr* dm;
OSIoMesg* mb;
static u16 retrace;
s32 first;
u32 count;
mb = NULL;
first = 0;
vc = __osViGetCurrentContext();
retrace = vc->retraceCount;
if (retrace == 0) {
retrace = 1;
}
dm = (OSDevMgr*) arg;
while (TRUE) {
osRecvMesg(dm->evtQueue, (OSMesg) &mb, OS_MESG_BLOCK);
switch (mb->hdr.type) {
case OS_MESG_TYPE_VRETRACE:
__osViSwapContext();
retrace--;
if (retrace == 0) {
vc = __osViGetCurrentContext();
if (vc->msgq != NULL) {
osSendMesg(vc->msgq, vc->msg, OS_MESG_NOBLOCK);
}
retrace = vc->retraceCount;
}
__osViIntrCount++;
if (first) {
count = osGetCount();
__osCurrentTime = count;
first = 0;
}
count = __osBaseCounter;
__osBaseCounter = osGetCount();
count = __osBaseCounter - count;
__osCurrentTime = __osCurrentTime + count;
break;
case OS_MESG_TYPE_COUNTER:
__osTimerInterrupt();
break;
default:
break;
}
}
}

View file

@ -1,3 +1,17 @@
#include "common.h"
#include "PR/os_internal.h"
#include "PR/viint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/virepeatline/osViRepeatLine.s")
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
void osViRepeatLine(u8 active) {
register u32 saveMask = __osDisableInt();
if (active) {
__osViNext->state |= VI_STATE_REPEATLINE;
} else {
__osViNext->state &= ~VI_STATE_REPEATLINE;
}
__osRestoreInt(saveMask);
}

View file

@ -1,3 +1,27 @@
#include "common.h"
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
#include "PR/assert.h"
#include "PR/viint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/visetevent/osViSetEvent.s")
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
void osViSetEvent(OSMesgQueue* mq, OSMesg m, u32 retraceCount) {
register u32 saveMask;
#ifdef _DEBUG
if (!__osViDevMgr.active) {
__osError(ERR_OSVISETEVENT, 0);
return;
}
assert(mq != NULL);
#endif
saveMask = __osDisableInt();
__osViNext->msgq = mq;
__osViNext->msg = m;
__osViNext->retraceCount = retraceCount;
__osRestoreInt(saveMask);
}

View file

@ -1,3 +1,27 @@
#include "common.h"
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
#include "PR/assert.h"
#include "PR/viint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/visetmode/osViSetMode.s")
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
void osViSetMode(OSViMode* modep) {
register u32 saveMask;
#ifdef _DEBUG
if (!__osViDevMgr.active) {
__osError(ERR_OSVISETMODE, 0);
return;
}
assert(modep != NULL);
#endif
saveMask = __osDisableInt();
__osViNext->modep = modep;
__osViNext->state = VI_STATE_MODE_UPDATED;
__osViNext->control = __osViNext->modep->comRegs.ctrl;
__osRestoreInt(saveMask);
}

View file

@ -1,3 +1,72 @@
#include "common.h"
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
#include "PR/rcp.h"
#include "PR/viint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/visetspecial/osViSetSpecialFeatures.s")
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
// This value was incorrectly calculated until being fixed in 2.0J
#if BUILD_VERSION >= VERSION_J
#define OS_VI_SPECIAL_MAX \
(OS_VI_GAMMA_ON | OS_VI_GAMMA_OFF | OS_VI_GAMMA_DITHER_ON | OS_VI_GAMMA_DITHER_OFF | OS_VI_DIVOT_ON | \
OS_VI_DIVOT_OFF | OS_VI_DITHER_FILTER_ON | OS_VI_DITHER_FILTER_OFF)
#else
#define OS_VI_SPECIAL_MAX OS_VI_DITHER_FILTER_OFF
#endif
void osViSetSpecialFeatures(u32 func) {
register u32 saveMask;
#ifdef _DEBUG
if (!__osViDevMgr.active) {
__osError(ERR_OSVISETSPECIAL_VIMGR, 0);
return;
}
if ((func < OS_VI_GAMMA_ON) || (func > OS_VI_SPECIAL_MAX)) {
__osError(ERR_OSVISETSPECIAL_VALUE, 1, func);
return;
}
#endif
saveMask = __osDisableInt();
if ((func & OS_VI_GAMMA_ON) != 0) {
__osViNext->control |= VI_CTRL_GAMMA_ON;
}
if ((func & OS_VI_GAMMA_OFF) != 0) {
__osViNext->control &= ~VI_CTRL_GAMMA_ON;
}
if ((func & OS_VI_GAMMA_DITHER_ON) != 0) {
__osViNext->control |= VI_CTRL_GAMMA_DITHER_ON;
}
if ((func & OS_VI_GAMMA_DITHER_OFF) != 0) {
__osViNext->control &= ~VI_CTRL_GAMMA_DITHER_ON;
}
if ((func & OS_VI_DIVOT_ON) != 0) {
__osViNext->control |= VI_CTRL_DIVOT_ON;
}
if ((func & OS_VI_DIVOT_OFF) != 0) {
__osViNext->control &= ~VI_CTRL_DIVOT_ON;
}
if ((func & OS_VI_DITHER_FILTER_ON) != 0) {
__osViNext->control |= VI_CTRL_DITHER_FILTER_ON;
__osViNext->control &= ~VI_CTRL_ANTIALIAS_MASK;
}
if ((func & OS_VI_DITHER_FILTER_OFF) != 0) {
__osViNext->control &= ~VI_CTRL_DITHER_FILTER_ON;
__osViNext->control |= __osViNext->modep->comRegs.ctrl & VI_CTRL_ANTIALIAS_MASK;
}
__osViNext->state |= VI_STATE_CTRL_UPDATED;
__osRestoreInt(saveMask);
}

View file

@ -1,3 +1,31 @@
#include "common.h"
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
#include "PR/assert.h"
#include "PR/viint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/viswapbuf/osViSwapBuffer.s")
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
void osViSwapBuffer(void* frameBufPtr) {
u32 saveMask;
#ifdef _DEBUG
if (!__osViDevMgr.active) {
__osError(ERR_OSVISWAPBUFFER_VIMGR, 0);
return;
}
assert(frameBufPtr != NULL);
if ((u32) frameBufPtr & 0x3f) {
__osError(ERR_OSVISWAPBUFFER_ADDR, 1, frameBufPtr);
return;
}
#endif
saveMask = __osDisableInt();
__osViNext->framep = frameBufPtr;
__osViNext->state |= VI_STATE_BUFFER_UPDATED;
__osRestoreInt(saveMask);
}

View file

@ -1,3 +1,80 @@
#include "common.h"
#include "PR/os_internal.h"
#include "PR/rcp.h"
#include "PR/viint.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/viswapcontext/__osViSwapContext.s")
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
void __osViSwapContext() {
register OSViMode* vm;
register __OSViContext* vc;
u32 origin;
u32 hStart;
#if BUILD_VERSION >= VERSION_J
u32 vStart;
#endif
u32 nomValue;
u32 field;
field = 0;
vc = __osViNext;
vm = vc->modep;
field = IO_READ(VI_CURRENT_REG) & 1; // field num
origin = osVirtualToPhysical(vc->framep) + (vm->fldRegs[field].origin);
if (vc->state & VI_STATE_XSCALE_UPDATED) {
vc->x.scale |= (vm->comRegs.xScale & ~VI_SCALE_MASK);
} else {
vc->x.scale = vm->comRegs.xScale;
}
if (vc->state & VI_STATE_YSCALE_UPDATED) {
nomValue = vm->fldRegs[field].yScale & VI_SCALE_MASK;
vc->y.scale = vc->y.factor * nomValue;
vc->y.scale |= vm->fldRegs[field].yScale & ~VI_SCALE_MASK;
} else {
vc->y.scale = vm->fldRegs[field].yScale;
}
#if BUILD_VERSION >= VERSION_J
vStart = (vm->fldRegs[field].vStart - (__additional_scanline << 0x10)) + __additional_scanline;
#endif
hStart = vm->comRegs.hStart;
if (vc->state & VI_STATE_BLACK) {
hStart = 0;
}
if (vc->state & VI_STATE_REPEATLINE) {
vc->y.scale = 0;
origin = osVirtualToPhysical(vc->framep);
}
if (vc->state & VI_STATE_FADE) {
vc->y.scale = (vc->y.offset << VI_SUBPIXEL_SH) & (VI_2_10_FPART_MASK << VI_SUBPIXEL_SH);
origin = osVirtualToPhysical(vc->framep);
}
IO_WRITE(VI_ORIGIN_REG, origin);
IO_WRITE(VI_WIDTH_REG, vm->comRegs.width);
IO_WRITE(VI_BURST_REG, vm->comRegs.burst);
IO_WRITE(VI_V_SYNC_REG, vm->comRegs.vSync);
IO_WRITE(VI_H_SYNC_REG, vm->comRegs.hSync);
IO_WRITE(VI_LEAP_REG, vm->comRegs.leap);
IO_WRITE(VI_H_START_REG, hStart);
#if BUILD_VERSION >= VERSION_J
IO_WRITE(VI_V_START_REG, vStart);
#else
IO_WRITE(VI_V_START_REG, vm->fldRegs[field].vStart);
#endif
IO_WRITE(VI_V_BURST_REG, vm->fldRegs[field].vBurst);
IO_WRITE(VI_INTR_REG, vm->fldRegs[field].vIntr);
IO_WRITE(VI_X_SCALE_REG, vc->x.scale);
IO_WRITE(VI_Y_SCALE_REG, vc->y.scale);
IO_WRITE(VI_CONTROL_REG, vc->control);
__osViNext = __osViCurr;
__osViCurr = vc;
*__osViNext = *__osViCurr;
}

View file

@ -1,9 +1,307 @@
#include "common.h"
#include "libc/stdlib.h"
#include "libc/string.h"
#include "PR/xstdio.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/libc/xldtob/_Genld.s")
// TODO: these come from headers
#ident "$Revision: 1.23 $"
#ident "$Revision: 1.34 $"
#ident "$Revision: 1.5 $"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/libc/xldtob/D_800C9580.s")
#define BUFF_LEN 0x20
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/libc/xldtob/_Ldtob.s")
static s16 _Ldunscale(s16* pex, _Pft* px);
static void _Genld(_Pft* px, char code, u8* p, s16 nsig, s16 xexp);
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/libc/xldtob/D_800C95D0.s")
static const double pows[] = { 10e0L, 10e1L, 10e3L, 10e7L, 10e15L, 10e31L, 10e63L, 10e127L, 10e255L };
// float properties
#define _D0 0
#define _DBIAS 0x3ff
#define _DLONG 1
#define _DOFF 4
#define _FBIAS 0x7e
#define _FOFF 7
#define _FRND 1
#define _LBIAS 0x3ffe
#define _LOFF 15
// integer properties
#define _C2 1
#define _CSIGN 1
#define _ILONG 0
#define _MBMAX 8
#define NAN 2
#define INF 1
#define FINITE -1
#define _DFRAC ((1 << _DOFF) - 1)
#define _DMASK (0x7fff & ~_DFRAC)
#define _DMAX ((1 << (15 - _DOFF)) - 1)
#define _DNAN (0x8000 | _DMAX << _DOFF | 1 << (_DOFF - 1))
#define _DSIGN 0x8000
#define _D1 1 // big-endian order
#define _D2 2
#define _D3 3
#define ALIGN(s, align) (((u32) (s) + ((align) -1)) & ~((align) -1))
void _Ldtob(_Pft* px, char code) {
char buff[BUFF_LEN];
char* p;
f64 ldval;
s16 err;
s16 nsig;
s16 xexp;
// char unused[0x4];
p = buff;
ldval = px->v.ld;
if (px->prec < 0) {
px->prec = 6;
} else if (px->prec == 0 && (code == 'g' || code == 'G')) {
px->prec = 1;
}
err = _Ldunscale(&xexp, px);
if (err > 0) {
memcpy(px->s, err == 2 ? "NaN" : "Inf", px->n1 = 3);
return;
} else if (err == 0) {
nsig = 0;
xexp = 0;
} else {
{
int i;
int n;
if (ldval < 0) {
ldval = -ldval;
}
// what
if ((xexp = xexp * 30103 / 100000 - 4) < 0) {
n = ALIGN(-xexp, 4), xexp = -n;
for (i = 0; n > 0; n >>= 1, i++) {
if (n & 1) {
ldval *= pows[i];
}
}
} else if (xexp > 0) {
f64 factor = 1;
xexp &= ~3;
for (n = xexp, i = 0; n > 0; n >>= 1, i++) {
if (n & 1) {
factor *= pows[i];
}
}
ldval /= factor;
}
}
{
int gen = px->prec + ((code == 'f') ? 10 + xexp : 6);
if (gen > 0x13) {
gen = 0x13;
}
for (*p++ = '0'; gen > 0 && 0 < ldval; p += 8) {
int j;
long lo = ldval;
if ((gen -= 8) > 0) {
ldval = (ldval - lo) * 1e8;
}
for (p += 8, j = 8; lo > 0 && --j >= 0;) {
ldiv_t qr;
qr = ldiv(lo, 10);
*--p = qr.rem + '0', lo = qr.quot;
}
while (--j >= 0) {
*--p = '0';
}
}
gen = p - &buff[1];
for (p = &buff[1], xexp += 7; *p == '0'; p++) {
--gen, --xexp;
}
nsig = px->prec + ((code == 'f') ? xexp + 1 : ((code == 'e' || code == 'E') ? 1 : 0));
if (gen < nsig) {
nsig = gen;
}
if (nsig > 0) {
const char drop = nsig < gen && '5' <= p[nsig] ? '9' : '0';
int n;
for (n = nsig; p[--n] == drop;) {
--nsig;
}
if (drop == '9') {
++p[n];
}
if (n < 0) {
--p, ++nsig, ++xexp;
}
}
}
}
_Genld(px, code, p, nsig, xexp);
}
s16 _Ldunscale(s16* pex, _Pft* px) {
u16* ps = (u16*) px;
s16 xchar = (ps[_D0] & _DMASK) >> _DOFF;
if (xchar == _DMAX) {
*pex = 0;
return (ps[_D0] & _DFRAC) || ps[_D1] || ps[_D2] || ps[_D3] ? 2 : 1;
} else if (xchar > 0) {
ps[_D0] = (ps[_D0] & ~_DMASK) | 0x3FF0;
*pex = xchar - 0x3FE;
return -1;
} else if (xchar < 0) {
return 2;
} else {
*pex = 0;
return 0;
}
}
void _Genld(_Pft* px, char code, u8* p, s16 nsig, s16 xexp) {
const unsigned char point = '.';
if (nsig <= 0) {
nsig = 1, p = "0";
}
if (code == 'f' || (code == 'g' || code == 'G') && xexp >= -4 && xexp < px->prec) {
xexp++;
if (code != 'f') {
if (((px->flags & 8) == 0) && nsig < px->prec) {
px->prec = nsig;
}
if ((px->prec -= xexp) < 0) {
px->prec = 0;
}
}
if (xexp <= 0) {
px->s[px->n1++] = '0';
if (px->prec > 0 || (px->flags & 8)) {
px->s[px->n1++] = point;
}
if (px->prec < -xexp) {
xexp = -px->prec;
}
px->nz1 = -xexp;
px->prec += xexp;
if (px->prec < nsig) {
nsig = px->prec;
}
memcpy(&px->s[px->n1], p, px->n2 = nsig);
px->nz2 = px->prec - nsig;
} else if (nsig < xexp) {
memcpy(&px->s[px->n1], p, nsig);
px->n1 += nsig;
px->nz1 = xexp - nsig;
if (px->prec > 0 || (px->flags & 8)) {
px->s[px->n1] = point;
px->n2++;
}
px->nz2 = px->prec;
} else {
memcpy(&px->s[px->n1], p, xexp);
px->n1 += xexp;
nsig -= xexp;
if (px->prec > 0 || (px->flags & 8)) {
px->s[px->n1++] = point;
}
if (px->prec < nsig) {
nsig = px->prec;
}
memcpy(&px->s[px->n1], &p[xexp], nsig);
px->n1 += nsig;
px->nz1 = px->prec - nsig;
}
} else {
if (code == 'g' || code == 'G') {
if (nsig < px->prec) {
px->prec = nsig;
}
if (--px->prec < 0) {
px->prec = 0;
}
code = (code == 'g') ? 'e' : 'E';
}
px->s[px->n1++] = *p++;
if (px->prec > 0 || (px->flags & 8)) {
px->s[px->n1++] = point;
}
if (px->prec > 0) {
if (px->prec < --nsig) {
nsig = px->prec;
}
memcpy(&px->s[px->n1], p, nsig);
px->n1 += nsig;
px->nz1 = px->prec - nsig;
}
p = &px->s[px->n1];
*p++ = code;
if (xexp >= 0) {
*p++ = '+';
} else {
*p++ = '-';
xexp = -xexp;
}
if (xexp >= 100) {
if (xexp >= 1000) {
*p++ = (xexp / 1000) + '0', xexp %= 1000;
}
*p++ = (xexp / 100) + '0', xexp %= 100;
}
*p++ = (xexp / 10) + '0', xexp %= 10;
*p++ = xexp + '0';
px->n2 = (size_t) p - ((size_t) px->s + px->n1);
}
if ((px->flags & 0x14) == 0x10) {
s32 n = px->n0 + px->n1 + px->nz1 + px->n2 + px->nz2;
if (n < px->width) {
px->nz0 = px->width - n;
}
}
}

View file

@ -2,40 +2,12 @@
#include "libc/string.h"
#include "libc/stdlib.h"
// typedef struct {
// /* 0x0 */ union {
// /* 0x0 */ s64 ll;
// /* 0x0 */ f64 ld;
// } v;
// /* 0x8 */ char* s;
// /* 0xC */ s32 n0;
// /* 0x10 */ s32 nz0;
// /* 0x14 */ s32 n1;
// /* 0x18 */ s32 nz1;
// /* 0x1C */ s32 n2;
// /* 0x20 */ s32 nz2;
// /* 0x24 */ s32 prec;
// /* 0x28 */ s32 width;
// /* 0x2C */ size_t nchar;
// /* 0x30 */ u32 flags;
// /* 0x34 */ u8 qual;
// } _Pft;
#define BUFF_LEN 0x18
// #define FLAGS_SPACE 1
// #define FLAGS_PLUS 2
// #define FLAGS_MINUS 4
// #define FLAGS_HASH 8
// #define FLAGS_ZERO 16
// Pending Data for import:
// u8 ldigs[] = "0123456789abcdef";
// u8 udigs[] = "0123456789ABCDEF";
static char ldigs[] = "0123456789abcdef";
static char udigs[] = "0123456789ABCDEF";
extern u8 ldigs[];
extern u8 udigs[];
void _Litob(_Pft* args, u8 type) {
void _Litob(_Pft* args, char type) {
u8 buff[BUFF_LEN];
const u8* numMap;
s32 base;

View file

@ -1,5 +1,251 @@
#include "common.h"
#include "macros.h"
#include "libc/string.h"
#include "libc/stdarg.h"
#include "PR/xstdio.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/libc/xprintf/_Putfld.s")
// TODO: these come from headers
#ident "$Revision: 1.34 $"
#ident "$Revision: 1.5 $"
#ident "$Revision: 1.23 $"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/libc/xprintf/_Printf.s")
#define isdigit(x) ((x >= '0' && x <= '9'))
#define LDSIGN(x) (((unsigned short*) &(x))[0] & 0x8000)
#define ATOI(dst, src) \
for (dst = 0; isdigit(*src); ++src) { \
if (dst < 999) \
dst = dst * 10 + *src - '0'; \
}
#define MAX_PAD ((sizeof(spaces) - 1))
#define PAD(s, n) \
if (0 < (n)) { \
int i, j = (n); \
for (; 0 < j; j -= i) { \
i = MAX_PAD < (unsigned int) j ? (int) MAX_PAD : j; \
PUT(s, i); \
} \
}
#define PUT(s, n) \
if (0 < (n)) { \
if ((arg = (*prout)(arg, s, n)) != NULL) \
x.nchar += (n); \
else \
return x.nchar; \
}
static char spaces[] = " ";
static char zeroes[] = "00000000000000000000000000000000";
static void _Putfld(_Pft* x, va_list* args, char type, char* buff);
int _Printf(outfun prout, char* arg, const char* fmt, va_list args) {
_Pft x;
x.nchar = 0;
while (TRUE) {
const char* s;
char c;
const char* t;
static const char fchar[] = { ' ', '+', '-', '#', '0', '\0' };
static const int fbit[] = { FLAGS_SPACE, FLAGS_PLUS, FLAGS_MINUS, FLAGS_HASH, FLAGS_ZERO, 0 };
char ac[32];
s = fmt;
for (c = *s; c != 0 && c != '%';) {
c = *++s;
}
PUT(fmt, s - fmt);
if (c == 0) {
return x.nchar;
}
fmt = ++s;
for (x.flags = 0; (t = strchr(fchar, *s)) != NULL; s++) {
x.flags |= fbit[t - fchar];
}
if (*s == '*') {
x.width = va_arg(args, int);
if (x.width < 0) {
x.width = -x.width;
x.flags |= FLAGS_MINUS;
}
s++;
} else
ATOI(x.width, s);
if (*s != '.') {
x.prec = -1;
} else if (*++s == '*') {
x.prec = va_arg(args, int);
++s;
} else {
for (x.prec = 0; isdigit(*s); s++) {
if (x.prec < 999) {
x.prec = x.prec * 10 + *s - '0';
}
}
}
x.qual = strchr("hlL", *s) ? *s++ : '\0';
if (x.qual == 'l' && *s == 'l') {
x.qual = 'L';
++s;
}
_Putfld(&x, &args, *s, ac);
x.width -= x.n0 + x.nz0 + x.n1 + x.nz1 + x.n2 + x.nz2;
{
if (!(x.flags & FLAGS_MINUS)) {
int i, j;
if (0 < (x.width)) {
i, j = x.width;
for (; 0 < j; j -= i) {
i = MAX_PAD < (unsigned int) j ? (int) MAX_PAD : j;
PUT(spaces, i);
}
}
}
PUT(ac, x.n0);
PAD(zeroes, x.nz0)
PUT(x.s, x.n1);
PAD(zeroes, x.nz1);
PUT(x.s + x.n1, x.n2);
PAD(zeroes, x.nz2);
if (x.flags & FLAGS_MINUS) {
PAD(spaces, x.width);
}
}
fmt = s + 1;
}
return 0;
}
static void _Putfld(_Pft* x, va_list* args, char type, char* buff) {
x->n0 = x->nz0 = x->n1 = x->nz1 = x->n2 = x->nz2 = 0;
switch (type) {
case 'c':
buff[x->n0++] = va_arg(*args, int);
break;
case 'd':
case 'i':
if (x->qual == 'l') {
x->v.ll = va_arg(*args, int);
} else if (x->qual == 'L') {
x->v.ll = va_arg(*args, s64);
} else {
x->v.ll = va_arg(*args, int);
}
if (x->qual == 'h') {
x->v.ll = (s16) x->v.ll;
}
if (x->v.ll < 0) {
buff[x->n0++] = '-';
} else if (x->flags & FLAGS_PLUS) {
buff[x->n0++] = '+';
} else if (x->flags & FLAGS_SPACE) {
buff[x->n0++] = ' ';
}
x->s = (char*) &buff[x->n0];
_Litob(x, type);
break;
case 'x':
case 'X':
case 'u':
case 'o':
if (x->qual == 'l') {
x->v.ll = va_arg(*args, int);
} else if (x->qual == 'L') {
x->v.ll = va_arg(*args, s64);
} else {
x->v.ll = va_arg(*args, int);
}
if (x->qual == 'h') {
x->v.ll = (u16) x->v.ll;
} else if (x->qual == 0) {
x->v.ll = (unsigned int) x->v.ll;
}
if (x->flags & FLAGS_HASH) {
buff[x->n0++] = '0';
if (type == 'x' || type == 'X') {
buff[x->n0++] = type;
}
}
x->s = (char*) &buff[x->n0];
_Litob(x, type);
break;
case 'e':
case 'f':
case 'g':
case 'E':
case 'G':
//... okay?
x->v.ld = x->qual == 'L' ? va_arg(*args, f64) : va_arg(*args, f64);
if (LDSIGN(x->v.ld)) {
buff[x->n0++] = '-';
} else if (x->flags & FLAGS_PLUS) {
buff[x->n0++] = '+';
} else if (x->flags & FLAGS_SPACE) {
buff[x->n0++] = ' ';
}
x->s = (char*) &buff[x->n0];
_Ldtob(x, type);
break;
case 'n':
if (x->qual == 'h') {
*(va_arg(*args, u16*)) = x->nchar;
} else if (x->qual == 'l') {
*va_arg(*args, unsigned int*) = x->nchar;
} else if (x->qual == 'L') {
*va_arg(*args, u64*) = x->nchar;
} else {
*va_arg(*args, unsigned int*) = x->nchar;
}
break;
case 'p':
x->v.ll = (long) va_arg(*args, void*);
x->s = (char*) &buff[x->n0];
_Litob(x, 'x');
break;
case 's':
x->s = va_arg(*args, char*);
x->n1 = strlen(x->s);
if (x->prec >= 0 && x->prec < x->n1) {
x->n1 = x->prec;
}
break;
case '%':
buff[x->n0++] = '%';
break;
default:
buff[x->n0++] = type;
break;
}
}

Some files were not shown because too many files have changed in this diff Show more