You've already forked hackerlibultra
mirror of
https://github.com/HackerN64/hackerlibultra.git
synced 2026-01-21 10:37:53 -08:00
Matched RSP (os/sp), region (rg), and libc C files (#11)
This commit is contained in:
5
Makefile
5
Makefile
@@ -14,7 +14,8 @@ AS := tools/kmc-gcc-wrapper/as
|
||||
CC := tools/kmc-gcc-wrapper/gcc
|
||||
AR_OLD := tools/ar
|
||||
|
||||
CFLAGS := -D_LANGUAGE_C -D_MIPS_SZLONG=32 -D_FINALROM -w -nostdinc -c -G 0 -mgp32 -mfp32 -mips3
|
||||
CFLAGS := -w -nostdinc -c -G 0 -mgp32 -mfp32 -mips3
|
||||
CPPFLAGS := -D_LANGUAGE_C -D_MIPS_SZLONG=32 -D_FINALROM -D__USE_ISOC99 -DNDEBUG -DF3DEX_GBI_2 -I $(WORKING_DIR)/include -I $(WORKING_DIR)/include/gcc
|
||||
OPTFLAGS := -O3
|
||||
|
||||
SRC_DIRS := $(shell find src -type d)
|
||||
@@ -93,7 +94,7 @@ $(BUILD_DIR)/src/os/exit.marker: OPTFLAGS := -O0
|
||||
$(BUILD_DIR)/src/os/seterrorhandler.marker: OPTFLAGS := -O0
|
||||
|
||||
$(BUILD_DIR)/%.marker: %.c
|
||||
cd $(<D) && $(WORKING_DIR)/$(CC) $(CFLAGS) $(OPTFLAGS) -I $(WORKING_DIR)/include $(<F) -o $(WORKING_DIR)/$(@:.marker=.o)
|
||||
cd $(<D) && $(WORKING_DIR)/$(CC) $(CFLAGS) $(CPPFLAGS) $(OPTFLAGS) $(<F) -o $(WORKING_DIR)/$(@:.marker=.o)
|
||||
ifneq ($(NON_MATCHING),1)
|
||||
# check if this file is in the archive; patch corrupted bytes and change file timestamps to match original if so
|
||||
@$(if $(findstring $(BASE_DIR)/$(@F:.marker=.o), $(BASE_OBJS)), \
|
||||
|
||||
110
include/PR/region.h
Executable file
110
include/PR/region.h
Executable file
@@ -0,0 +1,110 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Module: region.h
|
||||
*
|
||||
* $Revision: 1.8 $
|
||||
* $Date: 1997/11/26 00:30:56 $
|
||||
* $Author: mitu $
|
||||
* $Source: /disk6/Master/cvsmdev2/PR/include/region.h,v $
|
||||
*
|
||||
* Description:
|
||||
* This file contains macros and structure definitions for the region
|
||||
* library.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
#ifndef _REGION_H_
|
||||
#define _REGION_H_
|
||||
|
||||
|
||||
#ifdef _LANGUAGE_C_PLUS_PLUS
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <PR/ultratypes.h>
|
||||
|
||||
|
||||
/***************************************
|
||||
*
|
||||
* Global defines
|
||||
*
|
||||
*/
|
||||
/* Alignment sizes */
|
||||
#define ALIGNSZ (sizeof(long long)) /* 8 bytes */
|
||||
#define ALIGNOFFST (ALIGNSZ-1)
|
||||
|
||||
/* size for storing index to free buffer */
|
||||
#define BUF_CTRL_SIZE ALIGNSZ
|
||||
|
||||
/* Max bufcount = 32K */
|
||||
#define MAX_BUFCOUNT 0x8000
|
||||
/* code for last free buffer */
|
||||
#define BUF_FREE_WO_NEXT 0x8000
|
||||
|
||||
/*
|
||||
* Global defines for alignment size (default is 8-byte alignment)
|
||||
*/
|
||||
#define OS_RG_ALIGN_2B 2 /* 2 bytes = 16-bit alignment */
|
||||
#define OS_RG_ALIGN_4B 4 /* 4 bytes = 32-bit alignment */
|
||||
#define OS_RG_ALIGN_8B 8 /* 8 bytes = 64-bit alignment */
|
||||
#define OS_RG_ALIGN_16B 16 /* 16 bytes = 128-bit alignment */
|
||||
|
||||
#define OS_RG_ALIGN_DEFAULT OS_RG_ALIGN_8B
|
||||
|
||||
|
||||
/***************************************
|
||||
*
|
||||
* Macro definitions
|
||||
*
|
||||
*/
|
||||
|
||||
/* Perform alignment on input 's' */
|
||||
#define ALIGN(s, align) (((u32)(s) + ((align)-1)) & ~((align)-1))
|
||||
|
||||
|
||||
/***************************************
|
||||
*
|
||||
* Typedefs & structure definitions
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Structure for region header/control area
|
||||
*/
|
||||
typedef struct _Region_s {
|
||||
u8 *r_startBufferAddress; /* start address to data buffer */
|
||||
u8 *r_endAddress; /* end address of region */
|
||||
s32 r_bufferSize; /* size of buffers for this region */
|
||||
s32 r_bufferCount; /* up to 32K entries; MSB is used for
|
||||
setting end-of-list/used */
|
||||
u16 r_freeList; /* point to array index of first
|
||||
available memory buffer */
|
||||
u16 r_alignSize; /* alignment size (# of bytes) */
|
||||
} OSRegion;
|
||||
|
||||
/*
|
||||
* Macro to simplify accessing region header structure
|
||||
*/
|
||||
#define RP(x) rp->r_##x
|
||||
|
||||
|
||||
/***************************************
|
||||
*
|
||||
* Function prototypes
|
||||
*
|
||||
*/
|
||||
extern void *osCreateRegion(void *, u32, u32, u32);
|
||||
extern void *osMalloc(void *);
|
||||
extern void osFree(void *, void *);
|
||||
extern s32 osGetRegionBufCount(void *);
|
||||
extern s32 osGetRegionBufSize(void *);
|
||||
|
||||
|
||||
#ifdef _LANGUAGE_C_PLUS_PLUS
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _REGION_H_ */
|
||||
|
||||
|
||||
189
include/PR/sptask.h
Normal file
189
include/PR/sptask.h
Normal file
@@ -0,0 +1,189 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* $Revision: 1.9 $
|
||||
* $Date: 1998/03/05 06:40:29 $
|
||||
* $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/sptask.h,v $
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef _SPTASK_H_
|
||||
#define _SPTASK_H_
|
||||
|
||||
#ifdef _LANGUAGE_C_PLUS_PLUS
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <PR/ultratypes.h>
|
||||
|
||||
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* Type definitions
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Task List Structure.
|
||||
*
|
||||
* Things an app might pass to the SP via the task list.
|
||||
* Not every task ucode would need/use every field, but
|
||||
*
|
||||
* - type (audio, gfx, video, ...)
|
||||
* - flags
|
||||
* - wait for DP to drain before running new task
|
||||
* - SEE BIT DEFINITIONS UNDER "Task Flags field"
|
||||
* - pointer to boot ucode
|
||||
* - size of boot ucode
|
||||
* - pointer to ucode
|
||||
* - size of ucode
|
||||
* - pointer to initial DMEM data
|
||||
* - size of initial DMEM data
|
||||
* - pointer to DRAM stack
|
||||
* - size of DRAM stack (max)
|
||||
* - pointer to output buffer
|
||||
* - pointer to store output buffer length
|
||||
* - generic data pointer (for display list, etc.)
|
||||
* - generic data length (for display list, etc.)
|
||||
* - pointer to buffer where to store saved DMEM (in yield case)
|
||||
* - size of buffer to store saved DMEM.
|
||||
*
|
||||
* IMPORTANT!!! Watch alignment issues.
|
||||
*
|
||||
* IMPORTANT!!! Watch data cache issues. The RCP may write data into the
|
||||
* dram_stack, output_buff, output_buff_size, and the yield_data_ptr areas.
|
||||
* These buffers should be cache aligned and use the entire line (16 bytes) to
|
||||
* avoid corruption by writebacks by the CPU (cache tearing).
|
||||
*
|
||||
* IMPORTANT!!! all addresses are virtual addresses. Library does
|
||||
* any necessary translation.
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
u32 type;
|
||||
u32 flags;
|
||||
|
||||
u64 *ucode_boot;
|
||||
u32 ucode_boot_size;
|
||||
|
||||
u64 *ucode;
|
||||
u32 ucode_size;
|
||||
|
||||
u64 *ucode_data;
|
||||
u32 ucode_data_size;
|
||||
|
||||
u64 *dram_stack;
|
||||
u32 dram_stack_size;
|
||||
|
||||
u64 *output_buff;
|
||||
u64 *output_buff_size;
|
||||
|
||||
u64 *data_ptr;
|
||||
u32 data_size;
|
||||
|
||||
u64 *yield_data_ptr;
|
||||
u32 yield_data_size;
|
||||
|
||||
} OSTask_t;
|
||||
|
||||
typedef union {
|
||||
OSTask_t t;
|
||||
long long int force_structure_alignment;
|
||||
} OSTask;
|
||||
|
||||
typedef u32 OSYieldResult;
|
||||
|
||||
#endif /* _LANGUAGE_C */
|
||||
|
||||
#ifdef _LANGUAGE_ASSEMBLY
|
||||
|
||||
/*
|
||||
* For the RSP ucode:
|
||||
* offsets into the task structure
|
||||
*/
|
||||
|
||||
#include <PR/sptaskoff.h>
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Task Flags field
|
||||
*/
|
||||
#define OS_TASK_YIELDED 0x0001
|
||||
#define OS_TASK_DP_WAIT 0x0002
|
||||
#define OS_TASK_LOADABLE 0x0004
|
||||
#define OS_TASK_SP_ONLY 0x0008
|
||||
#define OS_TASK_USR0 0x0010
|
||||
#define OS_TASK_USR1 0x0020
|
||||
#define OS_TASK_USR2 0x0040
|
||||
#define OS_TASK_USR3 0x0080
|
||||
|
||||
/*
|
||||
* Size of Yield buffer. The taskHdrPtr->t.yield_data_ptr must point to a
|
||||
* buffer of this size. (The size is in bytes). ONLY If the task will NEVER
|
||||
* yield it may be a null pointer. The buffer must be aligned to a 64 bit
|
||||
* boundary. The taskHdrPtr->t.yield_data_ptr must be set to point to the
|
||||
* buffer BEFORE the task is started.
|
||||
*/
|
||||
#if (defined(F3DEX_GBI)||defined(F3DLP_GBI)||defined(F3DEX_GBI_2))
|
||||
#define OS_YIELD_DATA_SIZE 0xc00
|
||||
#else
|
||||
#define OS_YIELD_DATA_SIZE 0x900
|
||||
#endif
|
||||
#define OS_YIELD_AUDIO_SIZE 0x400
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* Global definitions
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* Macro definitions
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* this macro simulates atomic action.
|
||||
*/
|
||||
#define osSpTaskStart(tp) \
|
||||
{ \
|
||||
osSpTaskLoad((tp)); \
|
||||
osSpTaskStartGo((tp)); \
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* Extern variables
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* Function prototypes
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* break this up into two steps for debugging.
|
||||
*/
|
||||
extern void osSpTaskLoad(OSTask *tp);
|
||||
extern void osSpTaskStartGo(OSTask *tp);
|
||||
|
||||
extern void osSpTaskYield(void);
|
||||
extern OSYieldResult osSpTaskYielded(OSTask *tp);
|
||||
|
||||
#endif /* _LANGUAGE_C */
|
||||
|
||||
#ifdef _LANGUAGE_C_PLUS_PLUS
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !_SPTASK_H */
|
||||
12
include/assert.h
Normal file
12
include/assert.h
Normal 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__ */
|
||||
23
include/gcc/memory.h
Normal file
23
include/gcc/memory.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef _MEMORY_H
|
||||
#define _MEMORY_H
|
||||
/*
|
||||
memory.h
|
||||
*/
|
||||
|
||||
#ifndef _SIZE_T_DEF
|
||||
#define _SIZE_T_DEF
|
||||
typedef unsigned size_t;
|
||||
#endif
|
||||
|
||||
void *memccpy(void *,void *,int,size_t);
|
||||
void *memchr(void *,int,size_t);
|
||||
int memcmp(const void *,const void *,size_t);
|
||||
void *memcpy(void *,const void *,size_t);
|
||||
int memicmp(void *,void *,size_t);
|
||||
void *memmove(void *,void *,size_t);
|
||||
void *memset(void *,int,size_t);
|
||||
|
||||
void movmem(void *,void *,unsigned);
|
||||
void setmem(void *,unsigned,int);
|
||||
|
||||
#endif
|
||||
121
include/gcc/stdarg.h
Executable file
121
include/gcc/stdarg.h
Executable file
@@ -0,0 +1,121 @@
|
||||
#ifndef _STDARG_H
|
||||
#define _STDARG_H
|
||||
/* ---------------------------------------- */
|
||||
/* VARARGS for MIPS/GNU CC */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* ---------------------------------------- */
|
||||
|
||||
/* These macros implement varargs for GNU C--either traditional or ANSU. */
|
||||
|
||||
/* Define __gnuc_va_list. */
|
||||
|
||||
#ifndef __GNUC_VA_LIST
|
||||
#define __GNUC_VA_LIST
|
||||
typedef char * __gnuc_va_list;
|
||||
#endif /* not __GNUC_VA_LIST */
|
||||
|
||||
/* If this is for internal libc use, don't define anything but
|
||||
__gnuc_va_list. */
|
||||
#if defined (_STDARG_H) || defined (_VARARGS_H)
|
||||
|
||||
/* In GCC version 2, we want an ellipsis at the end of the declaration
|
||||
of the argument list. GCC version 1 can't parse it. */
|
||||
|
||||
#if __GNUC__ > 1
|
||||
#define __va_ellipsis ...
|
||||
#else
|
||||
#define __va_ellipsis
|
||||
#endif
|
||||
|
||||
#if __mips>=3
|
||||
#define __va_rounded_size(__TYPE) \
|
||||
(((sizeof (__TYPE) + 8 - 1) / 8) * 8)
|
||||
#else
|
||||
#define __va_rounded_size(__TYPE) \
|
||||
(((sizeof (__TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
|
||||
#endif
|
||||
|
||||
/* Get definitions for _MIPS_SIM_ABI64 etc. */
|
||||
#ifdef _MIPS_SIM
|
||||
#include <sgidefs.h>
|
||||
#endif
|
||||
|
||||
#ifdef _STDARG_H
|
||||
#if defined(_MIPS_SIM) && (_MIPS_SIM == _MIPS_SIM_ABI64)
|
||||
#define va_start(__AP, __LASTARG) \
|
||||
(__AP = __builtin_next_arg (__LASTARG) - 64 \
|
||||
+ (__builtin_args_info (2) > 8 ? 64 : __builtin_args_info(2) * 8))
|
||||
#else
|
||||
#define va_start(__AP, __LASTARG) \
|
||||
(__AP = (__gnuc_va_list) __builtin_next_arg (__LASTARG))
|
||||
#endif
|
||||
|
||||
#else
|
||||
#define va_alist __builtin_va_alist
|
||||
#if __mips>=3
|
||||
/* This assumes that `long long int' is always a 64 bit type. */
|
||||
#define va_dcl long long int __builtin_va_alist; __va_ellipsis
|
||||
#else
|
||||
#define va_dcl int __builtin_va_alist; __va_ellipsis
|
||||
#endif
|
||||
/* Need alternate code for _MIPS_SIM_ABI64, but don't use that symbol
|
||||
because it may not be defined. */
|
||||
#if defined(_MIPS_SIM) && (_MIPS_SIM == _MIPS_SIM_ABI64)
|
||||
#define va_start(__AP) \
|
||||
(__AP = __builtin_next_arg () - 64 \
|
||||
+ (__builtin_args_info (2) > 8 ? 64 : __builtin_args_info(2) * 8))
|
||||
#else
|
||||
#define va_start(__AP) __AP = (char *) &__builtin_va_alist
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef va_end
|
||||
void va_end (__gnuc_va_list); /* Defined in libgcc.a */
|
||||
#endif
|
||||
#define va_end(__AP) ((void)0)
|
||||
|
||||
/* We cast to void * and then to TYPE * because this avoids
|
||||
a warning about increasing the alignment requirement. */
|
||||
/* The __mips>=3 cases are reversed from the 32 bit cases, because the standard
|
||||
32 bit calling convention left-aligns all parameters smaller than a word,
|
||||
whereas the __mips>=3 calling convention does not (and hence they are
|
||||
right aligned). */
|
||||
#if __mips>=3
|
||||
#ifdef __MIPSEB__
|
||||
#define va_arg(__AP, __type) \
|
||||
((__type *) (void *) (__AP = (char *) ((((__PTRDIFF_TYPE__)__AP + 8 - 1) & -8) \
|
||||
+ __va_rounded_size (__type))))[-1]
|
||||
#else
|
||||
#define va_arg(__AP, __type) \
|
||||
((__AP = (char *) ((((__PTRDIFF_TYPE__)__AP + 8 - 1) & -8) \
|
||||
+ __va_rounded_size (__type))), \
|
||||
*(__type *) (void *) (__AP - __va_rounded_size (__type)))
|
||||
#endif
|
||||
|
||||
#else /* not __mips>=3 */
|
||||
|
||||
#ifdef __MIPSEB__
|
||||
/* For big-endian machines. */
|
||||
#define va_arg(__AP, __type) \
|
||||
((__AP = (char *) ((__alignof__ (__type) > 4 \
|
||||
? ((int)__AP + 8 - 1) & -8 \
|
||||
: ((int)__AP + 4 - 1) & -4) \
|
||||
+ __va_rounded_size (__type))), \
|
||||
*(__type *) (void *) (__AP - __va_rounded_size (__type)))
|
||||
#else
|
||||
/* For little-endian machines. */
|
||||
#define va_arg(__AP, __type) \
|
||||
((__type *) (void *) (__AP = (char *) ((__alignof__(__type) > 4 \
|
||||
? ((int)__AP + 8 - 1) & -8 \
|
||||
: ((int)__AP + 4 - 1) & -4) \
|
||||
+ __va_rounded_size(__type))))[-1]
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef __gnuc_va_list va_list;
|
||||
|
||||
#endif /* defined (_STDARG_H) || defined (_VARARGS_H) */
|
||||
#endif
|
||||
81
include/gcc/stdlib.h
Normal file
81
include/gcc/stdlib.h
Normal file
@@ -0,0 +1,81 @@
|
||||
#ifndef _STDLIB_H
|
||||
#define _STDLIB_H
|
||||
/*
|
||||
stdlib.h
|
||||
*/
|
||||
|
||||
#ifndef _SIZE_T_DEF
|
||||
#define _SIZE_T_DEF
|
||||
typedef unsigned size_t;
|
||||
#endif
|
||||
|
||||
#ifndef _DIV_T_DEF
|
||||
#define _DIV_T_DEF
|
||||
typedef struct DIV_T {
|
||||
int quot;
|
||||
int rem;
|
||||
} div_t;
|
||||
#endif
|
||||
|
||||
#ifndef _LDIV_T_DEF
|
||||
#define _LDIV_T_DEF
|
||||
typedef struct LDIV_T {
|
||||
long quot;
|
||||
long rem;
|
||||
} ldiv_t;
|
||||
#endif
|
||||
|
||||
#ifndef _LLDIV_T_DEF
|
||||
#define _LLDIV_T_DEF
|
||||
typedef struct lldiv_t
|
||||
{
|
||||
long long quot;
|
||||
long long rem;
|
||||
} lldiv_t;
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#define _max(a,b) (((a) > (b)) ? (a) : (b))
|
||||
#define _min(a,b) (((a) < (b)) ? (a) : (b))
|
||||
|
||||
#define RAND_MAX 32767
|
||||
|
||||
int rand(void);
|
||||
void srand(unsigned);
|
||||
|
||||
int abs(int);
|
||||
long labs(long);
|
||||
|
||||
div_t div(int,int);
|
||||
ldiv_t ldiv(long,long);
|
||||
lldiv_t lldiv(long long, long long);
|
||||
|
||||
int atoi(const char *);
|
||||
long atol(const char *);
|
||||
|
||||
long strtol(const char *,char **,int);
|
||||
unsigned long strtoul(const char *,char **,int);
|
||||
|
||||
char *itoa(int,char *,int);
|
||||
char *ltoa(long,char *,int);
|
||||
char *ultoa(unsigned long,char *,int);
|
||||
|
||||
double atof(const char *);
|
||||
double strtod(const char *,char **);
|
||||
|
||||
void qsort(void *,size_t,size_t,int (*)(const void *,const void *));
|
||||
void *bsearch(const void *,const void *,size_t,size_t,int (*)(const void *,const void *));
|
||||
|
||||
void *malloc(size_t);
|
||||
void *calloc(size_t,size_t);
|
||||
void *realloc(void *,size_t);
|
||||
void free(void *);
|
||||
|
||||
void exit(int);
|
||||
|
||||
void abort(void);
|
||||
|
||||
#endif
|
||||
42
include/gcc/string.h
Executable file
42
include/gcc/string.h
Executable file
@@ -0,0 +1,42 @@
|
||||
#ifndef _STRING_H
|
||||
#define _STRING_H
|
||||
/*
|
||||
string.h
|
||||
*/
|
||||
|
||||
#ifndef _SIZE_T_DEF
|
||||
#define _SIZE_T_DEF
|
||||
typedef unsigned size_t;
|
||||
#endif
|
||||
|
||||
#include "memory.h"
|
||||
|
||||
char *stpcpy(char *,const char *);
|
||||
char *strcat(char *,const char *);
|
||||
char *strchr(const char *,int);
|
||||
int strcmp(const char *,const char *);
|
||||
char *strcpy(char *,const char *);
|
||||
size_t strcspn(const char *,const char *);
|
||||
char *strdup(const char *);
|
||||
char *strerror(int);
|
||||
int stricmp(const char *,const char *);
|
||||
size_t strlen(const char *);
|
||||
char *strlwr(char *);
|
||||
char *strncat(char *,const char *,size_t);
|
||||
int strncmp(const char *,const char *,size_t);
|
||||
char *strncpy(char *,const char *,size_t);
|
||||
int strnicmp(const char *,const char *,size_t);
|
||||
char *strnset(char *,int,size_t);
|
||||
char *strpbrk(const char *,const char *);
|
||||
char *strrchr(const char *,int);
|
||||
char *strrev(char *);
|
||||
char *strset(char *,int);
|
||||
size_t strspn(const char *,const char *);
|
||||
char *strstr(const char *,const char *);
|
||||
char *strtok(char *,const char *);
|
||||
char *strupr(char *);
|
||||
|
||||
#define strcmpi(s1,s2) stricmp(s1,s2)
|
||||
#define strncmpi(s1,s2,n) strnicmp(s1,s2,n)
|
||||
|
||||
#endif
|
||||
17
src/io/sp.c
Executable file
17
src/io/sp.c
Executable file
@@ -0,0 +1,17 @@
|
||||
#include "PR/os_internal.h"
|
||||
#include "PR/rcp.h"
|
||||
#include "PR/sptask.h"
|
||||
#include "../os/osint.h"
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
9
src/io/spgetstat.c
Executable file
9
src/io/spgetstat.c
Executable file
@@ -0,0 +1,9 @@
|
||||
#include "PR/os_internal.h"
|
||||
#include "PR/rcp.h"
|
||||
|
||||
// TODO: this comes from a header
|
||||
#ident "$Revision: 1.17 $"
|
||||
|
||||
u32 __osSpGetStatus() {
|
||||
return IO_READ(SP_STATUS_REG);
|
||||
}
|
||||
30
src/io/sprawdma.c
Executable file
30
src/io/sprawdma.c
Executable file
@@ -0,0 +1,30 @@
|
||||
#include "PR/os_internal.h"
|
||||
#include "PR/rcp.h"
|
||||
#include "../os/osint.h"
|
||||
#include "assert.h"
|
||||
|
||||
// TODO: this comes from a header
|
||||
#ident "$Revision: 1.17 $"
|
||||
|
||||
s32 __osSpRawStartDma(s32 direction, u32 devAddr, void *dramAddr, u32 size) {
|
||||
// These asserts are present in debug builds, but the line numbers won't match as-is
|
||||
// TODO Add an assert spoofing macro that lets you specify a line number
|
||||
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;
|
||||
}
|
||||
16
src/io/sprawread.c
Executable file
16
src/io/sprawread.c
Executable file
@@ -0,0 +1,16 @@
|
||||
#include "PR/os_internal.h"
|
||||
#include "PR/rcp.h"
|
||||
#include "../os/osint.h"
|
||||
|
||||
// TODO: this comes from a header
|
||||
#ident "$Revision: 1.17 $"
|
||||
|
||||
s32 __osSpRawReadIo(u32 devAddr, u32 *data) {
|
||||
if (__osSpDeviceBusy()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
*data = IO_READ(devAddr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
15
src/io/sprawwrite.c
Executable file
15
src/io/sprawwrite.c
Executable file
@@ -0,0 +1,15 @@
|
||||
#include "PR/os_internal.h"
|
||||
#include "PR/rcp.h"
|
||||
#include "../os/osint.h"
|
||||
|
||||
// TODO: this comes from a header
|
||||
#ident "$Revision: 1.17 $"
|
||||
|
||||
s32 __osSpRawWriteIo(u32 devAddr, u32 data) {
|
||||
if (__osSpDeviceBusy()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
IO_WRITE(devAddr, data);
|
||||
return 0;
|
||||
}
|
||||
9
src/io/spsetstat.c
Executable file
9
src/io/spsetstat.c
Executable file
@@ -0,0 +1,9 @@
|
||||
#include "PR/os_internal.h"
|
||||
#include "PR/rcp.h"
|
||||
|
||||
// TODO: this comes from a header
|
||||
#ident "$Revision: 1.17 $"
|
||||
|
||||
void __osSpSetStatus(u32 data) {
|
||||
IO_WRITE(SP_STATUS_REG, data);
|
||||
}
|
||||
63
src/io/sptask.c
Executable file
63
src/io/sptask.c
Executable file
@@ -0,0 +1,63 @@
|
||||
#include "PR/os_internal.h"
|
||||
#include "PR/sptask.h"
|
||||
#include "PR/rcp.h"
|
||||
#include "../os/osint.h"
|
||||
|
||||
#define _osVirtualToPhysical(ptr) \
|
||||
if (ptr != NULL) \
|
||||
{ \
|
||||
ptr = (void *)osVirtualToPhysical(ptr); \
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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);
|
||||
}
|
||||
6
src/io/sptaskyield.c
Executable file
6
src/io/sptaskyield.c
Executable file
@@ -0,0 +1,6 @@
|
||||
#include "PR/os_internal.h"
|
||||
#include "PR/rcp.h"
|
||||
|
||||
void osSpTaskYield(void) {
|
||||
__osSpSetStatus(SP_SET_YIELD);
|
||||
}
|
||||
18
src/io/sptaskyielded.c
Executable file
18
src/io/sptaskyielded.c
Executable file
@@ -0,0 +1,18 @@
|
||||
#include "PR/os_internal.h"
|
||||
#include "PR/sptask.h"
|
||||
#include "PR/rcp.h"
|
||||
|
||||
OSYieldResult osSpTaskYielded(OSTask *tp) {
|
||||
u32 status;
|
||||
OSYieldResult result;
|
||||
|
||||
status = __osSpGetStatus();
|
||||
result = status >> 8;
|
||||
result &= 1;
|
||||
|
||||
if (status & SP_STATUS_YIELD) {
|
||||
tp->t.flags = ~(OS_TASK_DP_WAIT) & (tp->t.flags | result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -8,7 +8,7 @@ void osViSetMode(OSViMode *modep) {
|
||||
register u32 saveMask = __osDisableInt();
|
||||
|
||||
__osViNext->modep = modep;
|
||||
__osViNext->state = VI_STATE_01;
|
||||
__osViNext->state = VI_STATE_MODE_UPDATED;
|
||||
__osViNext->control = __osViNext->modep->comRegs.ctrl;
|
||||
__osRestoreInt(saveMask);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ void osViSetSpecialFeatures(u32 func) {
|
||||
__osViNext->control |= __osViNext->modep->comRegs.ctrl & VI_CTRL_ANTIALIAS_MASK;
|
||||
}
|
||||
|
||||
__osViNext->state |= VI_STATE_08;
|
||||
__osViNext->state |= VI_STATE_CTRL_UPDATED;
|
||||
|
||||
__osRestoreInt(saveMask);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,6 @@ void osViSwapBuffer(void* frameBufPtr) {
|
||||
u32 saveMask = __osDisableInt();
|
||||
|
||||
__osViNext->framep = frameBufPtr;
|
||||
__osViNext->state |= VI_STATE_10;
|
||||
__osViNext->state |= VI_STATE_BUFFER_UPDATED;
|
||||
__osRestoreInt(saveMask);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user