mirror of
https://github.com/libretro/RetroArch
synced 2025-04-15 14:42:27 +00:00
(GX) Start adding internal libogc
This commit is contained in:
parent
61473d8f15
commit
de638b66b5
@ -82,7 +82,7 @@ else ifeq ($(platform), ps3-cobra)
|
||||
|
||||
# NGC/Wii - libogc
|
||||
else ifeq ($(libogc_platform), 1)
|
||||
EXTERNAL_LIBOGC=1
|
||||
EXTERNAL_LIBOGC=0
|
||||
CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
|
||||
CXX = $(DEVKITPPC)/bin/powerpc-eabi-g++$(EXE_EXT)
|
||||
LD = $(DEVKITPPC)/bin/powerpc-eabi-ld$(EXE_EXT)
|
||||
@ -93,6 +93,8 @@ EXTERNAL_LIBOGC=1
|
||||
INCLUDE += -I. -I$(DEVKITPRO)/libogc/include -Ideps/libz -Iwii/libogc/include
|
||||
|
||||
ifeq ($(EXTERNAL_LIBOGC), 1)
|
||||
CFLAGS += -DEXTERNAL_LIBOGC
|
||||
CXXFLAGS += -DEXTERNAL_LIBOGC
|
||||
|
||||
ifeq ($(platform), ngc)
|
||||
LIBDIRS += -L$(DEVKITPRO)/libogc/lib/cube
|
||||
@ -101,6 +103,8 @@ LIBDIRS += -L$(DEVKITPRO)/libogc/lib/wii
|
||||
endif
|
||||
|
||||
else
|
||||
CFLAGS += -DINTERNAL_LIBOGC
|
||||
CXXFLAGS += -DINTERNAL_LIBOGC
|
||||
|
||||
ifeq ($(platform), ngc)
|
||||
LIBDIRS += -Lwii/libogc/libs/cube
|
||||
@ -130,7 +134,10 @@ ifeq ($(BIG_STACK), 1)
|
||||
LDFLAGS += -T bootstrap/gx/rvl.ld
|
||||
endif
|
||||
endif
|
||||
LIBS += -lfat -logc
|
||||
LIBS += -logc
|
||||
ifeq ($(EXTERNAL_LIBOGC), 1)
|
||||
LIBS += -lfat
|
||||
endif
|
||||
|
||||
ifeq ($(platform), wii)
|
||||
LIBS += -lwiiuse -lbte
|
||||
|
@ -6,7 +6,7 @@
|
||||
DEBUG = 0
|
||||
HAVE_LOGGER = 0
|
||||
HAVE_FILE_LOGGER = 0
|
||||
EXTERNAL_LIBOGC = 1
|
||||
EXTERNAL_LIBOGC = 0
|
||||
|
||||
# system platform
|
||||
system_platform = unix
|
||||
@ -43,7 +43,11 @@ endif
|
||||
MACHDEP := -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float
|
||||
CFLAGS += -Wall -std=gnu99 $(MACHDEP) $(INCLUDE)
|
||||
LDFLAGS := $(MACHDEP) -Wl,-Map,$(notdir $(ELF_TARGET)).map
|
||||
LIBS := -lfat -lwiiuse -logc -lbte
|
||||
LIBS := -lwiiuse -logc -lbte
|
||||
|
||||
ifeq ($(EXTERNAL_LIBOGC), 1)
|
||||
LIBS += -lfat
|
||||
endif
|
||||
|
||||
APP_BOOTER_DIR = wii/app_booter
|
||||
|
||||
@ -67,6 +71,20 @@ OBJ = frontend/frontend_salamander.o \
|
||||
verbosity.o \
|
||||
$(APP_BOOTER_DIR)/app_booter.binobj
|
||||
|
||||
ifeq ($(EXTERNAL_LIBOGC), 1)
|
||||
else
|
||||
OBJ += wii/libogc/libfat/cache.o \
|
||||
wii/libogc/libfat/directory.o \
|
||||
wii/libogc/libfat/disc.o \
|
||||
wii/libogc/libfat/fatdir.o \
|
||||
wii/libogc/libfat/fatfile.o \
|
||||
wii/libogc/libfat/file_allocation_table.o \
|
||||
wii/libogc/libfat/filetime.o \
|
||||
wii/libogc/libfat/libfat.o \
|
||||
wii/libogc/libfat/lock.o \
|
||||
wii/libogc/libfat/partition.o
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_LOGGER), 1)
|
||||
CFLAGS += -DHAVE_LOGGER
|
||||
CFLAGS += -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT)
|
||||
|
@ -45,6 +45,21 @@ CONSOLE EXTENSIONS
|
||||
#include "../memory/ngc/ssaram.c"
|
||||
#endif
|
||||
|
||||
#ifdef INTERNAL_LIBOGC
|
||||
#ifdef HW_RVL
|
||||
#include "../wii/libogc/libfat/cache.c"
|
||||
#include "../wii/libogc/libfat/directory.c"
|
||||
#include "../wii/libogc/libfat/disc.c"
|
||||
#include "../wii/libogc/libfat/fatdir.c"
|
||||
#include "../wii/libogc/libfat/fatfile.c"
|
||||
#include "../wii/libogc/libfat/file_allocation_table.c"
|
||||
#include "../wii/libogc/libfat/filetime.c"
|
||||
#include "../wii/libogc/libfat/libfat.c"
|
||||
#include "../wii/libogc/libfat/lock.c"
|
||||
#include "../wii/libogc/libfat/partition.c"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*============================================================
|
||||
|
@ -14,7 +14,7 @@ else ifneq ($(findstring MINGW,$(shell uname -a)),)
|
||||
system_platform = win
|
||||
endif
|
||||
|
||||
EXTERNAL_LIBOGC = 1
|
||||
EXTERNAL_LIBOGC = 0
|
||||
CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
|
||||
LD = $(DEVKITPPC)/bin/powerpc-eabi-ld$(EXE_EXT)
|
||||
OBJCOPY = $(DEVKITPPC)/bin/powerpc-eabi-objcopy$(EXE_EXT)
|
||||
|
61
wii/libogc/include/aesndlib.h
Normal file
61
wii/libogc/include/aesndlib.h
Normal file
@ -0,0 +1,61 @@
|
||||
#ifndef __AESNDLIB_H__
|
||||
#define __AESNDLIB_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#define MAX_VOICES 32
|
||||
#define SND_BUFFERSIZE 384 // output 2ms sound data at 48KHz
|
||||
#define DSP_STREAMBUFFER_SIZE 1152 // input 2ms sound data at max. 144KHz
|
||||
|
||||
#if defined(HW_DOL)
|
||||
#define DSP_DEFAULT_FREQ 48044
|
||||
#elif defined(HW_RVL)
|
||||
#define DSP_DEFAULT_FREQ 48000
|
||||
#endif
|
||||
|
||||
#define VOICE_STATE_STOPPED 0
|
||||
#define VOICE_STATE_RUNNING 1
|
||||
#define VOICE_STATE_STREAM 2
|
||||
|
||||
#define VOICE_MONO8 0x00000000
|
||||
#define VOICE_STEREO8 0x00000001
|
||||
#define VOICE_MONO16 0x00000002
|
||||
#define VOICE_STEREO16 0x00000003
|
||||
|
||||
#define VOICE_FREQ32KHZ 32000
|
||||
#define VOICE_FREQ48KHZ 48000
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct aesndpb_t AESNDPB;
|
||||
|
||||
typedef void (*AESNDVoiceCallback)(AESNDPB *pb,u32 state);
|
||||
typedef void (*AESNDAudioCallback)(void *audio_buffer,u32 len);
|
||||
|
||||
void AESND_Init();
|
||||
void AESND_Reset();
|
||||
void AESND_Pause(bool pause);
|
||||
u32 AESND_GetDSPProcessTime();
|
||||
f32 AESND_GetDSPProcessUsage();
|
||||
AESNDAudioCallback AESND_RegisterAudioCallback(AESNDAudioCallback cb);
|
||||
|
||||
AESNDPB* AESND_AllocateVoice(AESNDVoiceCallback cb);
|
||||
void AESND_FreeVoice(AESNDPB *pb);
|
||||
void AESND_SetVoiceStop(AESNDPB *pb,bool stop);
|
||||
void AESND_SetVoiceMute(AESNDPB *pb,bool mute);
|
||||
void AESND_SetVoiceLoop(AESNDPB *pb,bool loop);
|
||||
void AESND_SetVoiceFormat(AESNDPB *pb,u32 format);
|
||||
void AESND_SetVoiceStream(AESNDPB *pb,bool stream);
|
||||
void AESND_SetVoiceFrequency(AESNDPB *pb,u32 freq);
|
||||
void AESND_SetVoiceVolume(AESNDPB *pb,u16 volume_l,u16 volume_r);
|
||||
void AESND_SetVoiceBuffer(AESNDPB *pb,const void *buffer,u32 len);
|
||||
void AESND_PlayVoice(AESNDPB *pb,u32 format,const void *buffer,u32 len,u32 freq,u32 delay,bool looped);
|
||||
AESNDVoiceCallback AESND_RegisterVoiceCallback(AESNDPB *pb,AESNDVoiceCallback cb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
383
wii/libogc/include/asndlib.h
Normal file
383
wii/libogc/include/asndlib.h
Normal file
@ -0,0 +1,383 @@
|
||||
/* ASNDLIB -> accelerated sound lib using the DSP
|
||||
|
||||
Copyright (c) 2008 Hermes <www.entuwii.net>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are
|
||||
permitted provided that the following conditions are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright notice, this list of
|
||||
conditions and the following disclaimer.
|
||||
- Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
- The names of the contributors may not be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __ASNDLIB_H__
|
||||
#define __ASNDLIB_H__
|
||||
|
||||
#define __SNDLIB_H__
|
||||
|
||||
/*!
|
||||
* \file asndlib.h
|
||||
* \brief ASND library
|
||||
*
|
||||
*/
|
||||
|
||||
#define ASND_LIB 0x100
|
||||
#define SND_LIB (ASND_LIB+2)
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*! \addtogroup sndretvals SND return values
|
||||
* @{
|
||||
*/
|
||||
#define SND_OK 0
|
||||
#define SND_INVALID -1
|
||||
#define SND_ISNOTASONGVOICE -2
|
||||
#define SND_BUSY 1
|
||||
/*! @} */
|
||||
|
||||
/*! \addtogroup sndiavretvals SND_IsActiveVoice additional return values
|
||||
* @{
|
||||
*/
|
||||
#define SND_UNUSED 0 /*!< This voice is available for use. */
|
||||
#define SND_WORKING 1 /*!< This voice is currently in progress. */
|
||||
#define SND_WAITING 2 /*!< This voice is currently in progress and waiting to one SND_AddVoice() function (the voice handler is called continuously) */
|
||||
/*! @} */
|
||||
|
||||
/*! \addtogroup sndsetvoiceformats Voice format
|
||||
* @{
|
||||
*/
|
||||
#define VOICE_MONO_8BIT 0
|
||||
#define VOICE_MONO_16BIT 1
|
||||
#define VOICE_MONO_16BIT_BE 1
|
||||
#define VOICE_STEREO_8BIT 2
|
||||
#define VOICE_STEREO_16BIT 3
|
||||
#define VOICE_STEREO_16BIT_BE 3
|
||||
#define VOICE_MONO_8BIT_U 4
|
||||
#define VOICE_MONO_16BIT_LE 5
|
||||
#define VOICE_STEREO_8BIT_U 6
|
||||
#define VOICE_STEREO_16BIT_LE 7
|
||||
/*! @} */
|
||||
|
||||
/*! \addtogroup voicevol Voice volume
|
||||
* @{
|
||||
*/
|
||||
#define MIN_VOLUME 0
|
||||
#define MID_VOLUME 127
|
||||
#define MAX_VOLUME 255
|
||||
/*! @} */
|
||||
|
||||
/*! \addtogroup pitchrange Pitch Range
|
||||
* @{
|
||||
*/
|
||||
#define MIN_PITCH 1 /*!< 1Hz */
|
||||
#define F44100HZ_PITCH 44100 /*!< 44100Hz */
|
||||
#define MAX_PITCH 144000 /*!< 144000Hz (more process time for pitch>48000) */
|
||||
#define INIT_RATE_48000
|
||||
/*! @} */
|
||||
|
||||
/*! \addtogroup notecode Note codification
|
||||
* @{
|
||||
*/
|
||||
enum
|
||||
{
|
||||
NOTE_DO=0,
|
||||
NOTE_DOs,
|
||||
NOTE_REb=NOTE_DOs,
|
||||
NOTE_RE,
|
||||
NOTE_REs,
|
||||
NOTE_MIb=NOTE_REs,
|
||||
NOTE_MI,
|
||||
NOTE_FA,
|
||||
NOTE_FAs,
|
||||
NOTE_SOLb=NOTE_FAs,
|
||||
NOTE_SOL,
|
||||
NOTE_SOLs,
|
||||
NOTE_LAb=NOTE_SOLs,
|
||||
NOTE_LA,
|
||||
NOTE_LAs,
|
||||
NOTE_SIb=NOTE_LAs,
|
||||
NOTE_SI
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
NOTE_C=0,
|
||||
NOTE_Cs,
|
||||
NOTE_Db=NOTE_Cs,
|
||||
NOTE_D,
|
||||
NOTE_Ds,
|
||||
NOTE_Eb=NOTE_Ds,
|
||||
NOTE_E,
|
||||
NOTE_F,
|
||||
NOTE_Fs,
|
||||
NOTE_Gb=NOTE_Fs,
|
||||
NOTE_G,
|
||||
NOTE_Gs,
|
||||
NOTE_Ab=NOTE_Gs,
|
||||
NOTE_A,
|
||||
NOTE_As,
|
||||
NOTE_Bb=NOTE_As,
|
||||
NOTE_B
|
||||
};
|
||||
|
||||
#define NOTE(note,octave) (note+(octave<<3)+(octave<<2)) /*!< Final note codification. Used in Note2Freq(). */
|
||||
/*! @} */
|
||||
|
||||
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
/*! \addtogroup sndlibcompat SNDLIB compatibility macros
|
||||
* \details These defines are for compatability with SNDLIB functions.
|
||||
* @{
|
||||
*/
|
||||
#define Note2Freq ANote2Freq
|
||||
#define SND_Init ASND_Init
|
||||
#define SND_End ASND_End
|
||||
#define SND_Pause ASND_Pause
|
||||
#define SND_Is_Paused ASND_Is_Paused
|
||||
#define SND_GetTime ASND_GetTime
|
||||
#define SND_GetSampleCounter ASND_GetSampleCounter
|
||||
#define SND_GetSamplesPerTick ASND_GetSamplesPerTick
|
||||
#define SND_SetTime ASND_SetTime
|
||||
#define SND_SetCallback ASND_SetCallback
|
||||
#define SND_GetAudioRate ASND_GetAudioRate
|
||||
#define SND_SetVoice ASND_SetVoice
|
||||
#define SND_AddVoice ASND_AddVoice
|
||||
#define SND_StopVoice ASND_StopVoice
|
||||
#define SND_PauseVoice ASND_PauseVoice
|
||||
#define SND_StatusVoice ASND_StatusVoice
|
||||
#define SND_GetFirstUnusedVoice ASND_GetFirstUnusedVoice
|
||||
#define SND_ChangePitchVoice ASND_ChangePitchVoice
|
||||
#define SND_ChangeVolumeVoice ASND_ChangeVolumeVoice
|
||||
#define SND_ChangeVolumeVoice ASND_ChangeVolumeVoice
|
||||
#define SND_GetTickCounterVoice ASND_GetTickCounterVoice
|
||||
#define SND_GetTimerVoice ASND_GetTimerVoice
|
||||
#define SND_TestPointer ASND_TestPointer
|
||||
/*! @} */
|
||||
|
||||
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
/** \brief Callback type for ASND_SetVoice(). */
|
||||
typedef void (*ASNDVoiceCallback)(s32 voice);
|
||||
|
||||
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
/** \brief Initializes the SND lib and fixes the hardware sample rate.
|
||||
* \param[in] note \ref notecode to play. for example: NOTE(C,4) for note C and octave 4.
|
||||
* \param[in] freq_base Frequency base of the sample. For example 8000Hz.
|
||||
* \param[in] note_base \ref notecode of the sample. For example: NOTE(L, 3) for note L and octave 3 (LA 3).
|
||||
* \return Frequency, in Hz. */
|
||||
int ANote2Freq(int note, int freq_base,int note_base);
|
||||
|
||||
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
/*! \addtogroup General sound functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*! \brief Initializes the ASND lib and fixes the hardware sample rate to 48000.
|
||||
* \return None. */
|
||||
void ASND_Init();
|
||||
|
||||
/*! \brief De-initializes the ASND lib.
|
||||
* \return None. */
|
||||
void ASND_End();
|
||||
|
||||
/*! \brief Used to pause (or unpause) the sound.
|
||||
* \note The sound starts paused when ASND_Init() is called.
|
||||
* \param[in] paused If 1, sound is paused; sound can be unpaused with 0.
|
||||
* \return None. */
|
||||
void ASND_Pause(s32 paused);
|
||||
|
||||
/*! \brief Returns sound paused status.
|
||||
* \return 1 if paused, 0 if unpaused. */
|
||||
s32 ASND_Is_Paused();
|
||||
|
||||
/*! \brief Returns the global time.
|
||||
* \details The time is updated from the IRQ.
|
||||
* \return The current time, in milliseconds. */
|
||||
u32 ASND_GetTime();
|
||||
|
||||
/*! \brief Retrieves the global sample counter.
|
||||
* \details This counter is updated from the IRQ in steps of ASND_GetSamplesPerTick().
|
||||
* \note You can use this to implement one timer with high precision.
|
||||
* \return Current sample. */
|
||||
u32 ASND_GetSampleCounter();
|
||||
|
||||
/*! \brief Retrieves the samples sent from the IRQ in one tick.
|
||||
* \return Samples per tick. */
|
||||
u32 ASND_GetSamplesPerTick();
|
||||
|
||||
/*! \brief Set the global time.
|
||||
* \details This time is updated from the IRQ.
|
||||
* \param[in] time Fix the current time, in milliseconds.
|
||||
* \return None. */
|
||||
void ASND_SetTime(u32 time);
|
||||
|
||||
/*! \brief Sets a global callback for general purposes.
|
||||
* \details This callback is called from the IRQ.
|
||||
* \param[in] callback Callback function to assign.
|
||||
* \return None. */
|
||||
void ASND_SetCallback(void (*callback)());
|
||||
|
||||
/*! \brief Returns the current audio rate.
|
||||
* \note This function is implemented for compatibility with SNDLIB.
|
||||
* \return Audio rate (48000). */
|
||||
s32 ASND_GetAudioRate();
|
||||
|
||||
/*! @} */
|
||||
|
||||
/*! \addtogroup voicefuncs Voice functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
// NOTE: I'm keeping this description around because I couldn't fully understand it; if someone else knows exactly what it's doing, they can come around
|
||||
// and make sure the description is correct.
|
||||
/* callback: can be NULL or one callback function is used to implement a double buffer use. When the second buffer is empty, the callback is called sending
|
||||
the voice number as parameter. You can use "void callback(s32 voice)" function to call ASND_AddVoice() and add one voice to the second buffer.
|
||||
NOTE: When callback is fixed the voice never stops and it turn in SND_WAITING status if success one timeout condition.
|
||||
*/
|
||||
|
||||
/*! \brief Sets a PCM voice to play.
|
||||
* \details This function stops one previous voice. Use ASND_StatusVoice() to test the status condition.
|
||||
* \note The voices are played in 16-bit stereo, regardless of the source format.<br><br>
|
||||
*
|
||||
* \note \a callback is used to implement a double buffer. When the second buffer is empty, the callback function is called with the voice number
|
||||
* as an argument. You can use <tt>void <i>callback</i> (s32 voice)</tt> to call ASND_AddVoice() and add one voice to the second buffer. When the callback
|
||||
* is non-NULL the, the voice never stops and returns SND_WAITING if successful on timeout condition.
|
||||
* \param[in] voice Voice slot to use for this sound; valid values are 0 to (MAX_SND_VOICES-1).
|
||||
* \param[in] format \ref sndsetvoiceformats to use for this sound.
|
||||
* \param[in] pitch Frequency to use, in Hz.
|
||||
* \param[in] delay Delay to wait before playing this voice; value is in milliseconds.
|
||||
* \param[in] snd Buffer containing samples to play back; the buffer <b>must</b> be aligned and padded to 32 bytes!
|
||||
* \param[in] size_snd Size of the buffer samples, in bytes.
|
||||
* \param[in] volume_l \ref voicevol of the left channel; value can be 0 - 255 inclusive.
|
||||
* \param[in] volume_r \ref voicevol of the right channel; value can be 0 - 255 inclusive.
|
||||
* \param[in] callback Optional callback function to use; set to NULL for no callback. See the note above for details.
|
||||
* \return SND_OK or SND_INVALID. */
|
||||
s32 ASND_SetVoice(s32 voice, s32 format, s32 pitch,s32 delay, void *snd, s32 size_snd, s32 volume_l, s32 volume_r, ASNDVoiceCallback callback);
|
||||
|
||||
/*! \brief Sets a PCM voice to play infinitely.
|
||||
* \note See ASND_SetVoice() for a detailed description, as it is largely identical. */
|
||||
s32 ASND_SetInfiniteVoice(s32 voice, s32 format, s32 pitch,s32 delay, void *snd, s32 size_snd, s32 volume_l, s32 volume_r);
|
||||
|
||||
/*! \brief Adds a PCM voice to play from the second buffer.
|
||||
* \note This function requires a call to ASND_SetVoice() and its subsequent return value to be a status other than SND_UNUSED prior to calling this one.
|
||||
* \param[in] voice Voice slot to attach this buffer to; value must be 0 to (MAX_SND_VOICES-1).
|
||||
* \param[in] snd Buffer containing the samples; it <b>must</b> be aligned and padded to 32 bytes AND have the same sample format as the first buffer.
|
||||
* \param[in] size_snd Size of the buffer samples, in bytes.
|
||||
* \return SND_OK or SND_INVALID; it may also return SND_BUSY if the second buffer is not empty and the voice cannot be added. */
|
||||
s32 ASND_AddVoice(s32 voice, void *snd, s32 size_snd);
|
||||
|
||||
/*! \brief Stops the selected voice.
|
||||
* \details If the voice is used in song mode, you need to assign the samples with ASND_SetSongSampleVoice() again. In this case, use ANS_PauseSongVoice()
|
||||
* to stop the voice without loss of samples.
|
||||
* \param[in] voice Voice to stop, from 0 to (MAX_SND_VOICES-1).
|
||||
* \return SND_OK or SND_INVALID. */
|
||||
s32 ASND_StopVoice(s32 voice);
|
||||
|
||||
/*! \brief Pauses the selected voice.
|
||||
* \param[in] voice Voice to pause, from 0 to (MAX_SND_VOICES-1).
|
||||
* \return SND_OK or SND_INVALID. */
|
||||
s32 ASND_PauseVoice(s32 voice, s32 pause);
|
||||
|
||||
/*! \brief Returns the status of the selected voice.
|
||||
* \param[in] voice Voice slot to get the status from, from 0 to (MAX_SND_VOICES-1).
|
||||
* \return SND_INVALID if invalid, else a value from \ref sndiavretvals. */
|
||||
s32 ASND_StatusVoice(s32 voice);
|
||||
|
||||
/*! \brief Returns the first unused voice.
|
||||
* \note Voice 0 is the last possible voice that can be returned. The idea is that this voice is reserved for a MOD/OGG/MP3/etc. player. With this in mind,
|
||||
* you can use this function to determine that the rest of the voices are working if the return value is < 1.
|
||||
* \return SND_INVALID or the first free voice from 0 to (MAX_SND_VOICES-1). */
|
||||
s32 ASND_GetFirstUnusedVoice();
|
||||
|
||||
/*! \brief Changes the voice pitch in real-time.
|
||||
* \details This function can be used to create audio effects such as Doppler effect emulation.
|
||||
* \param[in] voice Voice to change the pitch of, from 0 to (MAX_SND_VOICES-1).
|
||||
* \return SND_OK or SND_INVALID. */
|
||||
s32 ASND_ChangePitchVoice(s32 voice, s32 pitch);
|
||||
|
||||
/*! \brief Changes the voice volume in real-time.
|
||||
* \details This function can be used to create audio effects like distance attenuation.
|
||||
* \param[in] voice Voice to change the volume of, from 0 to (MAX_SND_VOICES-1).
|
||||
* \param[in] volume_l \ref voicevol to set the left channel to, from 0 to 255.
|
||||
* \param[in] volume_r \ref voicevol to set the right channel to, from 0 to 255.
|
||||
* \return SND_OK or SND_INVALID. */
|
||||
s32 ASND_ChangeVolumeVoice(s32 voice, s32 volume_l, s32 volume_r);
|
||||
|
||||
/*! \brief Returns the voice tick counter.
|
||||
* \details This value represents the number of ticks since this voice started to play, sans delay time. It uses the same resolution as the internal
|
||||
* sound buffer. For example, if the lib is initialized with INIT_RATE_48000, a return value of 24000 is equal to 0.5 seconds. This value can be used, for
|
||||
* example, to synchronize audio and video.
|
||||
* \note This function does not return error codes.
|
||||
* \param[in] voice Voice to retrieve the counter value from, from 0 to (MAX_SND_VOICES-1).
|
||||
* \return Number of ticks since this voice started playing. */
|
||||
u32 ASND_GetTickCounterVoice(s32 voice);
|
||||
|
||||
/*! \brief Returns the voice playback time.
|
||||
* \details This value represents the time, in milliseconds, since this voice started playing, sans delay time. This value can be used, for example, to
|
||||
* synchronize audio and video.
|
||||
* \note This function does not return error codes.
|
||||
* \param[in] voice Voice to retrieve the time value from, from 0 to (MAX_SND_VOICES-1).
|
||||
* \return Amount of time since this voice has started playing. */
|
||||
u32 ASND_GetTimerVoice(s32 voice);
|
||||
|
||||
/*! \brief Tests if \a pointer is in use by \a voice as a buffer.
|
||||
* \param[in] voice Voice to test, from 0 to (MAX_SND_VOICES-1).
|
||||
* \param[in] pointer Address to test. This must be the same pointer sent to ASND_AddVoice() or ASND_SetVoice().
|
||||
* \return SND_INVALID if invalid
|
||||
* \return 0 if the pointer is unused
|
||||
* \return 1 if the pointer used as a buffer. */
|
||||
s32 ASND_TestPointer(s32 voice, void *pointer);
|
||||
|
||||
/*! \brief Tests to determine if the \a voice is ready to receive a new buffer sample with ASND_AddVoice().
|
||||
* \details You can use this function to block a reader when double buffering is used. It works similarly to ASND_TestPointer() without needing to pass a
|
||||
* pointer.
|
||||
* \param[in] voice Voice to test, from 0 to (MAX_SND_VOICES-1).
|
||||
* \return SND_INVALID
|
||||
* \return 0 if voice is NOT ready to receive a new voice.
|
||||
* \return 1 if voice is ready to receive a new voice with ASND_AddVoice(). */
|
||||
s32 ASND_TestVoiceBufferReady(s32 voice);
|
||||
|
||||
/*! @} */
|
||||
|
||||
/*! \addtogroup dspfuncs DSP functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*! \brief Returns the DSP usage.
|
||||
* \details The value is a percentage of DSP usage.
|
||||
* \return DSP usage, in percent. */
|
||||
u32 ASND_GetDSP_PercentUse();
|
||||
|
||||
u32 ASND_GetDSP_ProcessTime();
|
||||
|
||||
/*! @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
79
wii/libogc/include/bte/bd_addr.h
Normal file
79
wii/libogc/include/bte/bd_addr.h
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (c) 2003 EISLAB, Lulea University of Technology.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwBT Bluetooth stack.
|
||||
*
|
||||
* Author: Conny Ohult <conny@sm.luth.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __BD_ADDR_H__
|
||||
#define __BD_ADDR_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
struct bd_addr {
|
||||
u8 addr[6];
|
||||
};
|
||||
|
||||
#define BD_ADDR_LEN 6
|
||||
|
||||
#define BD_ADDR_ANY (&(struct bd_addr){{0,0,0,0,0,0}})
|
||||
#define BD_ADDR_LOCAL (&(struct bd_addr){{0,0,0,0xff,0xff,0xff}})
|
||||
|
||||
#define BD_ADDR(bdaddr, a, b, c, d, e, f) do{ \
|
||||
(bdaddr)->addr[0] = a; \
|
||||
(bdaddr)->addr[1] = b; \
|
||||
(bdaddr)->addr[2] = c; \
|
||||
(bdaddr)->addr[3] = d; \
|
||||
(bdaddr)->addr[4] = e; \
|
||||
(bdaddr)->addr[5] = f; }while(0)
|
||||
//TODO: USE memcmp????
|
||||
#define bd_addr_cmp(addr1, addr2) (((addr1)->addr[0] == (addr2)->addr[0]) && \
|
||||
((addr1)->addr[1] == (addr2)->addr[1]) && \
|
||||
((addr1)->addr[2] == (addr2)->addr[2]) && \
|
||||
((addr1)->addr[3] == (addr2)->addr[3]) && \
|
||||
((addr1)->addr[4] == (addr2)->addr[4]) && \
|
||||
((addr1)->addr[5] == (addr2)->addr[5]))
|
||||
//TODO: USE memcpy????
|
||||
#define bd_addr_set(addr1, addr2) do { \
|
||||
(addr1)->addr[0] = (addr2)->addr[0]; \
|
||||
(addr1)->addr[1] = (addr2)->addr[1]; \
|
||||
(addr1)->addr[2] = (addr2)->addr[2]; \
|
||||
(addr1)->addr[3] = (addr2)->addr[3]; \
|
||||
(addr1)->addr[4] = (addr2)->addr[4]; \
|
||||
(addr1)->addr[5] = (addr2)->addr[5]; }while(0)
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __BD_ADDR_H__ */
|
154
wii/libogc/include/bte/bte.h
Normal file
154
wii/libogc/include/bte/bte.h
Normal file
@ -0,0 +1,154 @@
|
||||
#ifndef __BTE_H__
|
||||
#define __BTE_H__
|
||||
|
||||
#include <gccore.h>
|
||||
#include "bd_addr.h"
|
||||
|
||||
#define ERR_OK 0
|
||||
#define ERR_MEM -1
|
||||
#define ERR_BUF -2
|
||||
#define ERR_ABRT -3
|
||||
#define ERR_RST -4
|
||||
#define ERR_CLSD -5
|
||||
#define ERR_CONN -6
|
||||
#define ERR_VAL -7
|
||||
#define ERR_ARG -8
|
||||
#define ERR_RTE -9
|
||||
#define ERR_USE -10
|
||||
#define ERR_IF -11
|
||||
#define ERR_PKTSIZE -17
|
||||
|
||||
#define HIDP_STATE_READY 0x00
|
||||
#define HIDP_STATE_LISTEN 0x01
|
||||
#define HIDP_STATE_CONNECTING 0x02
|
||||
#define HIDP_STATE_CONNECTED 0x04
|
||||
|
||||
#define HIDP_CONTROL_CHANNEL 0x11
|
||||
#define HIDP_DATA_CHANNEL 0x13
|
||||
|
||||
#define HIDP_HDR_TRANS_MASK 0xf0
|
||||
#define HIDP_HDR_PARAM_MASK 0x0f
|
||||
|
||||
#define HIDP_TRANS_HANDSHAKE 0x00
|
||||
#define HIDP_TRANS_HIDCONTROL 0x10
|
||||
#define HIDP_TRANS_GETREPORT 0x40
|
||||
#define HIDP_TRANS_SETREPORT 0x50
|
||||
#define HIDP_TRANS_GETPROTOCOL 0x60
|
||||
#define HIDP_TRANS_SETPROTOCOL 0x70
|
||||
#define HIDP_TRANS_GETIDLE 0x80
|
||||
#define HIDP_TRANS_SETIDLE 0x90
|
||||
#define HIDP_TRANS_DATA 0xa0
|
||||
#define HIDP_TRANS_DATAC 0xb0
|
||||
|
||||
#define HIDP_HSHK_SUCCESSFULL 0x00
|
||||
#define HIDP_HSHK_NOTREADY 0x01
|
||||
#define HIDP_HSHK_INV_REPORTID 0x02
|
||||
#define HIDP_HSHK_NOTSUPPORTED 0x03
|
||||
#define HIDP_HSHK_IVALIDPARAM 0x04
|
||||
#define HIDP_HSHK_UNKNOWNERROR 0x0e
|
||||
#define HIDP_HSHK_FATALERROR 0x0f
|
||||
|
||||
#define HIDP_CTRL_NOP 0x00
|
||||
#define HIDP_CTRL_HARDRESET 0x01
|
||||
#define HIDP_CTRL_SOFTRESET 0x02
|
||||
#define HIDP_CTRL_SUSPEND 0x03
|
||||
#define HIDP_CTRL_RESUME 0x04
|
||||
#define HIDP_CTRL_VC_UNPLUG 0x05
|
||||
|
||||
/* HIDP data transaction headers */
|
||||
#define HIDP_DATA_RTYPE_MASK 0x03
|
||||
#define HIDP_DATA_RSRVD_MASK 0x0c
|
||||
#define HIDP_DATA_RTYPE_OTHER 0x00
|
||||
#define HIDP_DATA_RTYPE_INPUT 0x01
|
||||
#define HIDP_DATA_RTYPE_OUPUT 0x02
|
||||
#define HIDP_DATA_RTYPE_FEATURE 0x03
|
||||
|
||||
#define HIDP_PROTO_BOOT 0x00
|
||||
#define HIDP_PROTO_REPORT 0x01
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
struct l2cap_pcb;
|
||||
struct ctrl_req_t;
|
||||
|
||||
struct inquiry_info
|
||||
{
|
||||
struct bd_addr bdaddr;
|
||||
u8 cod[3];
|
||||
};
|
||||
|
||||
struct inquiry_info_ex
|
||||
{
|
||||
struct bd_addr bdaddr;
|
||||
u8 cod[3];
|
||||
u8 psrm;
|
||||
u8 psm;
|
||||
u16 co;
|
||||
};
|
||||
|
||||
struct linkkey_info
|
||||
{
|
||||
struct bd_addr bdaddr;
|
||||
u8 key[16];
|
||||
};
|
||||
|
||||
struct bte_pcb
|
||||
{
|
||||
u8 err;
|
||||
u32 state;
|
||||
void *cbarg;
|
||||
|
||||
struct ctrl_req_t *ctrl_req_head;
|
||||
struct ctrl_req_t *ctrl_req_tail;
|
||||
|
||||
lwpq_t cmdq;
|
||||
|
||||
struct bd_addr bdaddr;
|
||||
|
||||
struct l2cap_pcb *ctl_pcb;
|
||||
struct l2cap_pcb *data_pcb;
|
||||
|
||||
|
||||
s32 (*recv)(void *arg,void *buffer,u16 len);
|
||||
s32 (*conn_cfm)(void *arg,struct bte_pcb *pcb,u8 err);
|
||||
s32 (*disconn_cfm)(void *arg,struct bte_pcb *pcb,u8 err);
|
||||
};
|
||||
|
||||
typedef s32 (*btecallback)(s32 result,void *userdata);
|
||||
|
||||
void BTE_Init();
|
||||
void BTE_Shutdown();
|
||||
s32 BTE_InitCore(btecallback cb);
|
||||
s32 BTE_ApplyPatch(btecallback cb);
|
||||
s32 BTE_InitSub(btecallback cb);
|
||||
s32 BTE_ReadStoredLinkKey(struct linkkey_info *keys,u8 max_cnt,btecallback cb);
|
||||
s32 BTE_ReadBdAddr(struct bd_addr *bdaddr, btecallback cb);
|
||||
void (*BTE_SetDisconnectCallback(void (*callback)(struct bd_addr *bdaddr,u8 reason)))(struct bd_addr *bdaddr,u8 reason);
|
||||
|
||||
struct bte_pcb* bte_new();
|
||||
void bte_arg(struct bte_pcb *pcb,void *arg);
|
||||
void bte_received(struct bte_pcb *pcb, s32 (*recv)(void *arg,void *buffer,u16 len));
|
||||
void bte_disconnected(struct bte_pcb *pcb,s32 (disconn_cfm)(void *arg,struct bte_pcb *pcb,u8 err));
|
||||
|
||||
s32 bte_registerdeviceasync(struct bte_pcb *pcb,struct bd_addr *bdaddr,s32 (*conn_cfm)(void *arg,struct bte_pcb *pcb,u8 err));
|
||||
|
||||
s32 bte_disconnect(struct bte_pcb *pcb);
|
||||
|
||||
//s32 bte_listen(struct bte_pcb *pcb,struct bd_addr *bdaddr,u8 psm);
|
||||
//s32 bte_accept(struct bte_pcb *pcb,s32 (*recv)(void *arg,void *buffer,u16 len));
|
||||
s32 bte_inquiry(struct inquiry_info *info,u8 max_cnt,u8 flush);
|
||||
s32 bte_inquiry_ex(struct inquiry_info_ex *info,u8 max_cnt,u8 flush);
|
||||
//s32 bte_connect(struct bte_pcb *pcb,struct bd_addr *bdaddr,u8 psm,s32 (*recv)(void *arg,void *buffer,u16 len));
|
||||
//s32 bte_connect_ex(struct bte_pcb *pcb,struct inquiry_info_ex *info,u8 psm,s32 (*recv)(void *arg,void *buffer,u16 len));
|
||||
s32 bte_senddata(struct bte_pcb *pcb,void *message,u16 len);
|
||||
s32 bte_sendmessage(struct bte_pcb *pcb,void *message,u16 len);
|
||||
s32 bte_sendmessageasync(struct bte_pcb *pcb,void *message,u16 len,s32 (*sent)(void *arg,struct bte_pcb *pcb,u8 err));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
43
wii/libogc/include/debug.h
Normal file
43
wii/libogc/include/debug.h
Normal file
@ -0,0 +1,43 @@
|
||||
#ifndef __DEBUG_H__
|
||||
#define __DEBUG_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#define GDBSTUB_DEVICE_USB 0 /*!< device type: USBGecko */
|
||||
#define GDBSTUB_DEVICE_TCP 1 /*!< device type: BBA-TCP */
|
||||
|
||||
#define GDBSTUB_DEF_CHANNEL 0 /*!< default EXI channel. channel can be 0 or 1. Note: Used for device type USBGecko */
|
||||
#define GDBSTUB_DEF_TCPPORT 2828 /*!< default TCP port. Note: Used for device type TCP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const char *tcp_localip;
|
||||
extern const char *tcp_netmask;
|
||||
extern const char *tcp_gateway;
|
||||
|
||||
|
||||
/*!\fn void _break()
|
||||
* \brief Stub function to insert the hardware break instruction. This function is used to enter the debug stub and to
|
||||
* connect with the host. The developer is free to insert this function at any position in project's source code.
|
||||
*
|
||||
* \return none.
|
||||
*/
|
||||
void _break();
|
||||
|
||||
|
||||
/*!\fn void DEBUG_Init(s32 device_type,s32 channel_port)
|
||||
* \brief Performs the initialization of the debug stub.
|
||||
* \param[in] device_type type of device to use. can be either USB or TCP.
|
||||
* \param[in] channel_port depending on the used device this can be either the EXI channel or the TCP port.
|
||||
*
|
||||
* \return none.
|
||||
*/
|
||||
void DEBUG_Init(s32 device_type,s32 channel_port);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
122
wii/libogc/include/fat.h
Normal file
122
wii/libogc/include/fat.h
Normal file
@ -0,0 +1,122 @@
|
||||
/*
|
||||
fat.h
|
||||
Simple functionality for startup, mounting and unmounting of FAT-based devices.
|
||||
|
||||
Copyright (c) 2006 - 2012
|
||||
Michael "Chishm" Chisholm
|
||||
Dave "WinterMute" Murphy
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
3. The name of the author may not be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _LIBFAT_H
|
||||
#define _LIBFAT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "libfatversion.h"
|
||||
|
||||
// When compiling for NDS, make sure NDS is defined
|
||||
#ifndef NDS
|
||||
#if defined ARM9 || defined ARM7
|
||||
#define NDS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(__gamecube__) || defined (__wii__)
|
||||
# include <ogc/disc_io.h>
|
||||
#else
|
||||
# ifdef NDS
|
||||
# include <nds/disc_io.h>
|
||||
# else
|
||||
# include <disc_io.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
Initialise any inserted block-devices.
|
||||
Add the fat device driver to the devoptab, making it available for standard file functions.
|
||||
cacheSize: The number of pages to allocate for each inserted block-device
|
||||
setAsDefaultDevice: if true, make this the default device driver for file operations
|
||||
*/
|
||||
extern bool fatInit (uint32_t cacheSize, bool setAsDefaultDevice);
|
||||
|
||||
/*
|
||||
Calls fatInit with setAsDefaultDevice = true and cacheSize optimised for the host system.
|
||||
*/
|
||||
extern bool fatInitDefault (void);
|
||||
|
||||
/*
|
||||
Mount the device pointed to by interface, and set up a devoptab entry for it as "name:".
|
||||
You can then access the filesystem using "name:/".
|
||||
This will mount the active partition or the first valid partition on the disc,
|
||||
and will use a cache size optimized for the host system.
|
||||
*/
|
||||
extern bool fatMountSimple (const char* name, const DISC_INTERFACE* interface);
|
||||
|
||||
/*
|
||||
Mount the device pointed to by interface, and set up a devoptab entry for it as "name:".
|
||||
You can then access the filesystem using "name:/".
|
||||
If startSector = 0, it will mount the active partition of the first valid partition on
|
||||
the disc. Otherwise it will try to mount the partition starting at startSector.
|
||||
cacheSize specifies the number of pages to allocate for the cache.
|
||||
This will not startup the disc, so you need to call interface->startup(); first.
|
||||
*/
|
||||
extern bool fatMount (const char* name, const DISC_INTERFACE* interface, sec_t startSector, uint32_t cacheSize, uint32_t SectorsPerPage);
|
||||
|
||||
/*
|
||||
Unmount the partition specified by name.
|
||||
If there are open files, it will attempt to synchronise them to disc.
|
||||
*/
|
||||
extern void fatUnmount (const char* name);
|
||||
|
||||
/*
|
||||
Get Volume Label
|
||||
*/
|
||||
extern void fatGetVolumeLabel (const char* name, char *label);
|
||||
|
||||
// File attributes
|
||||
#define ATTR_ARCHIVE 0x20 // Archive
|
||||
#define ATTR_DIRECTORY 0x10 // Directory
|
||||
#define ATTR_VOLUME 0x08 // Volume
|
||||
#define ATTR_SYSTEM 0x04 // System
|
||||
#define ATTR_HIDDEN 0x02 // Hidden
|
||||
#define ATTR_READONLY 0x01 // Read only
|
||||
|
||||
/*
|
||||
Methods to modify DOS File Attributes
|
||||
*/
|
||||
int FAT_getAttr(const char *file);
|
||||
int FAT_setAttr(const char *file, uint8_t attr );
|
||||
|
||||
#define LIBFAT_FEOS_MULTICWD
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _LIBFAT_H
|
150
wii/libogc/include/gccore.h
Normal file
150
wii/libogc/include/gccore.h
Normal file
@ -0,0 +1,150 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
gccore.h -- GC core header
|
||||
|
||||
Copyright (C) 2004
|
||||
Michael Wiedenbauer (shagkur)
|
||||
Dave Murphy (WinterMute)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __GCCORE_H__
|
||||
#define __GCCORE_H__
|
||||
|
||||
/*! \file gccore.h
|
||||
\brief Core header which includes all subsequent subsystem headers
|
||||
|
||||
*/
|
||||
|
||||
#include "ogc/dsp.h"
|
||||
#include "ogc/aram.h"
|
||||
#include "ogc/arqueue.h"
|
||||
#include "ogc/arqmgr.h"
|
||||
#include "ogc/audio.h"
|
||||
#include "ogc/cache.h"
|
||||
#include "ogc/card.h"
|
||||
#include "ogc/cast.h"
|
||||
#include "ogc/color.h"
|
||||
#include "ogc/consol.h"
|
||||
#include "ogc/dvd.h"
|
||||
#include "ogc/exi.h"
|
||||
#include "ogc/gu.h"
|
||||
#include "ogc/gx.h"
|
||||
#include "ogc/si.h"
|
||||
#include "ogc/gx_struct.h"
|
||||
#include "ogc/irq.h"
|
||||
#include "ogc/lwp.h"
|
||||
#include "ogc/mutex.h"
|
||||
#include "ogc/message.h"
|
||||
#include "ogc/semaphore.h"
|
||||
#include "ogc/pad.h"
|
||||
#include "ogc/tpl.h"
|
||||
#include "ogc/system.h"
|
||||
#include "ogc/video.h"
|
||||
#include "ogc/usbgecko.h"
|
||||
#include "ogc/video_types.h"
|
||||
#include "ogc/texconv.h"
|
||||
|
||||
#if defined(HW_RVL)
|
||||
#include "ogc/ipc.h"
|
||||
#include "ogc/es.h"
|
||||
#include "ogc/stm.h"
|
||||
#include "ogc/ios.h"
|
||||
#include "ogc/usb.h"
|
||||
#include "ogc/isfs.h"
|
||||
#include "ogc/conf.h"
|
||||
#include "ogc/usbstorage.h"
|
||||
|
||||
#include "ogc/wiilaunch.h"
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Error returns
|
||||
*/
|
||||
#define RNC_FILE_IS_NOT_RNC -1
|
||||
#define RNC_HUF_DECODE_ERROR -2
|
||||
#define RNC_FILE_SIZE_MISMATCH -3
|
||||
#define RNC_PACKED_CRC_ERROR -4
|
||||
#define RNC_UNPACKED_CRC_ERROR -5
|
||||
|
||||
#ifndef ATTRIBUTE_ALIGN
|
||||
# define ATTRIBUTE_ALIGN(v) __attribute__((aligned(v)))
|
||||
#endif
|
||||
#ifndef ATTRIBUTE_PACKED
|
||||
# define ATTRIBUTE_PACKED __attribute__((packed))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
/*!
|
||||
* \mainpage
|
||||
*
|
||||
* - \subpage intro
|
||||
* - \subpage api_doc
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
* \page intro Introduction
|
||||
* Welcome to the libOGC reference documentation.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \page api_doc Detailed API description
|
||||
*
|
||||
* - \ref aram.h "ARAM subsystem"
|
||||
* - \ref arqmgr.h "ARAM queue management subsystem"
|
||||
* - \ref audio.h "AUDIO subsystem"
|
||||
* - \ref asndlib.h "ASND library"
|
||||
* - \ref exi.h "EXI subsystem"
|
||||
* - \ref irq.h "IRQ subsystem"
|
||||
* - \ref dsp.h "DSP subsystem"
|
||||
* - \ref dvd.h "DVD subsystem"
|
||||
* - \ref gx.h "GX subsystem"
|
||||
* - \ref gu.h "gu/Matrix subsystem"
|
||||
* - \ref video.h "VIDEO subsystem"
|
||||
* - \ref cache.h "Cache subsystem"
|
||||
* - \ref card.h "Memory card subsystem"
|
||||
* - \ref consol.h "Console subsystem"
|
||||
* - \ref system.h "OS functions and initialization"
|
||||
* - \ref lwp.h "Thread subsystem I"
|
||||
* - \ref message.h "Thread subsystem II"
|
||||
* - \ref mutex.h "Thread subsystem III"
|
||||
* - \ref semaphore.h "Thread subsystem IV"
|
||||
* - \ref cond.h "Thread subsystem V"
|
||||
*/
|
||||
|
||||
s32 depackrnc1_ulen(void *packed);
|
||||
s32 depackrnc1(void *packed,void *unpacked);
|
||||
|
||||
void depackrnc2(void *packed,void *unpacked);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
44
wii/libogc/include/gcmodplay.h
Normal file
44
wii/libogc/include/gcmodplay.h
Normal file
@ -0,0 +1,44 @@
|
||||
#ifndef __GCMODPLAY_H__
|
||||
#define __GCMODPLAY_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
#include "modplay/modplay.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct _modsndbuf {
|
||||
u32 freq;
|
||||
u16 fmt;
|
||||
u32 chans;
|
||||
f32 samples;
|
||||
void *usr_data;
|
||||
void (*callback)(void *,u8 *,u32);
|
||||
} MODSNDBUF;
|
||||
|
||||
typedef struct _modplay {
|
||||
MOD mod;
|
||||
BOOL playing,paused;
|
||||
BOOL bits,stereo,manual_polling;
|
||||
u32 playfreq,numSFXChans;
|
||||
MODSNDBUF soundBuf;
|
||||
} MODPlay;
|
||||
|
||||
void MODPlay_Init(MODPlay *mod);
|
||||
s32 MODPlay_SetFrequency(MODPlay *mod,u32 freq);
|
||||
void MODPlay_SetStereo(MODPlay *mod,BOOL stereo);
|
||||
s32 MODPlay_SetMOD(MODPlay *mod,const void *mem);
|
||||
void MODPlay_Unload(MODPlay *mod);
|
||||
s32 MODPlay_AllocSFXChannels(MODPlay *mod,u32 sfxchans);
|
||||
s32 MODPlay_Start(MODPlay *mod);
|
||||
s32 MODPlay_Stop(MODPlay *mod);
|
||||
s32 MODPlay_TriggerNote(MODPlay *mod,u32 chan,u8 inst,u16 freq,u8 vol);
|
||||
s32 MODPlay_Pause(MODPlay *mod,BOOL);
|
||||
void MODPlay_SetVolume(MODPlay * mod, s32 musicvolume, s32 sfxvolume);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
110
wii/libogc/include/gctypes.h
Normal file
110
wii/libogc/include/gctypes.h
Normal file
@ -0,0 +1,110 @@
|
||||
#ifndef __GCTYPES_H__
|
||||
#define __GCTYPES_H__
|
||||
|
||||
/*! \file gctypes.h
|
||||
\brief Data type definitions
|
||||
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*+----------------------------------------------------------------------------------------------+*/
|
||||
typedef uint8_t u8; ///< 8bit unsigned integer
|
||||
typedef uint16_t u16; ///< 16bit unsigned integer
|
||||
typedef uint32_t u32; ///< 32bit unsigned integer
|
||||
typedef uint64_t u64; ///< 64bit unsigned integer
|
||||
/*+----------------------------------------------------------------------------------------------+*/
|
||||
typedef int8_t s8; ///< 8bit signed integer
|
||||
typedef int16_t s16; ///< 16bit signed integer
|
||||
typedef int32_t s32; ///< 32bit signed integer
|
||||
typedef int64_t s64; ///< 64bit signed integer
|
||||
/*+----------------------------------------------------------------------------------------------+*/
|
||||
typedef volatile u8 vu8; ///< 8bit unsigned volatile integer
|
||||
typedef volatile u16 vu16; ///< 16bit unsigned volatile integer
|
||||
typedef volatile u32 vu32; ///< 32bit unsigned volatile integer
|
||||
typedef volatile u64 vu64; ///< 64bit unsigned volatile integer
|
||||
/*+----------------------------------------------------------------------------------------------+*/
|
||||
typedef volatile s8 vs8; ///< 8bit signed volatile integer
|
||||
typedef volatile s16 vs16; ///< 16bit signed volatile integer
|
||||
typedef volatile s32 vs32; ///< 32bit signed volatile integer
|
||||
typedef volatile s64 vs64; ///< 64bit signed volatile integer
|
||||
/*+----------------------------------------------------------------------------------------------+*/
|
||||
// fixed point math typedefs
|
||||
typedef s16 sfp16; ///< signed 8:8 fixed point
|
||||
typedef s32 sfp32; ///< signed 20:8 fixed point
|
||||
typedef u16 ufp16; ///< unsigned 8:8 fixed point
|
||||
typedef u32 ufp32; ///< unsigned 24:8 fixed point
|
||||
/*+----------------------------------------------------------------------------------------------+*/
|
||||
typedef float f32;
|
||||
typedef double f64;
|
||||
/*+----------------------------------------------------------------------------------------------+*/
|
||||
typedef volatile float vf32;
|
||||
typedef volatile double vf64;
|
||||
/*+----------------------------------------------------------------------------------------------+*/
|
||||
|
||||
|
||||
typedef unsigned int BOOL;
|
||||
/*+----------------------------------------------------------------------------------------------+*/
|
||||
// alias type typedefs
|
||||
#define FIXED s32 ///< Alias type for sfp32
|
||||
/*+----------------------------------------------------------------------------------------------+*/
|
||||
#ifndef TRUE
|
||||
#define TRUE 1 ///< True
|
||||
#endif
|
||||
/*+----------------------------------------------------------------------------------------------+*/
|
||||
#ifndef FALSE
|
||||
#define FALSE 0 ///< False
|
||||
#endif
|
||||
/*+----------------------------------------------------------------------------------------------+*/
|
||||
#ifndef NULL
|
||||
#define NULL 0 ///< Pointer to 0
|
||||
#endif
|
||||
/*+----------------------------------------------------------------------------------------------+*/
|
||||
#ifndef LITTLE_ENDIAN
|
||||
#define LITTLE_ENDIAN 3412
|
||||
#endif /* LITTLE_ENDIAN */
|
||||
/*+----------------------------------------------------------------------------------------------+*/
|
||||
#ifndef BIG_ENDIAN
|
||||
#define BIG_ENDIAN 1234
|
||||
#endif /* BIGE_ENDIAN */
|
||||
/*+----------------------------------------------------------------------------------------------+*/
|
||||
#ifndef BYTE_ORDER
|
||||
#define BYTE_ORDER BIG_ENDIAN
|
||||
#endif /* BYTE_ORDER */
|
||||
/*+----------------------------------------------------------------------------------------------+*/
|
||||
|
||||
|
||||
//! argv structure
|
||||
/*! \struct __argv
|
||||
|
||||
structure used to set up argc/argv
|
||||
|
||||
*/
|
||||
struct __argv {
|
||||
int argvMagic; //!< argv magic number, set to 0x5f617267 ('_arg') if valid
|
||||
char *commandLine; //!< base address of command line, set of null terminated strings
|
||||
int length;//!< total length of command line
|
||||
int argc;
|
||||
char **argv;
|
||||
char **endARGV;
|
||||
};
|
||||
|
||||
//! Default location for the system argv structure.
|
||||
extern struct __argv *__system_argv;
|
||||
|
||||
// argv struct magic number
|
||||
#define ARGV_MAGIC 0x5f617267
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* TYPES_H */
|
||||
|
||||
|
||||
/* END OF FILE */
|
12
wii/libogc/include/gcutil.h
Normal file
12
wii/libogc/include/gcutil.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef __GCUTIL_H__
|
||||
#define __GCUTIL_H__
|
||||
|
||||
#ifndef ATTRIBUTE_ALIGN
|
||||
# define ATTRIBUTE_ALIGN(v) __attribute__((aligned(v)))
|
||||
#endif
|
||||
#ifndef ATTRIBUTE_PACKED
|
||||
# define ATTRIBUTE_PACKED __attribute__((packed))
|
||||
#endif
|
||||
|
||||
#endif /* _GCUTIL_H */
|
||||
|
27
wii/libogc/include/iso9660.h
Normal file
27
wii/libogc/include/iso9660.h
Normal file
@ -0,0 +1,27 @@
|
||||
/****************************************************************************
|
||||
* ISO9660 devoptab
|
||||
*
|
||||
* Copyright (C) 2008-2010
|
||||
* tipoloski, clava, shagkur, Tantric, joedj
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ISO9660_H__
|
||||
#define __ISO9660_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#define ISO_MAXPATHLEN 128
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
bool ISO9660_Mount(const char* name, const DISC_INTERFACE* disc_interface);
|
||||
bool ISO9660_Unmount(const char* name);
|
||||
const char *ISO9660_GetVolumeLabel(const char *name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
10
wii/libogc/include/libfatversion.h
Normal file
10
wii/libogc/include/libfatversion.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef __LIBFATVERSION_H__
|
||||
#define __LIBFATVERSION_H__
|
||||
|
||||
#define _LIBFAT_MAJOR_ 1
|
||||
#define _LIBFAT_MINOR_ 1
|
||||
#define _LIBFAT_PATCH_ 1
|
||||
|
||||
#define _LIBFAT_STRING "libFAT Release 1.1.1"
|
||||
|
||||
#endif // __LIBFATVERSION_H__
|
287
wii/libogc/include/network.h
Normal file
287
wii/libogc/include/network.h
Normal file
@ -0,0 +1,287 @@
|
||||
#ifndef __NETWORK_H__
|
||||
#define __NETWORK_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define INVALID_SOCKET (~0)
|
||||
#define SOCKET_ERROR (-1)
|
||||
|
||||
#define SOCK_STREAM 1
|
||||
#define SOCK_DGRAM 2
|
||||
#define SOCK_RAW 3
|
||||
|
||||
/*
|
||||
* Option flags per-socket.
|
||||
*/
|
||||
#define SO_DEBUG 0x0001 /* turn on debugging info recording */
|
||||
#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
|
||||
#define SO_REUSEADDR 0x0004 /* allow local address reuse */
|
||||
#define SO_KEEPALIVE 0x0008 /* keep connections alive */
|
||||
#define SO_DONTROUTE 0x0010 /* just use interface addresses */
|
||||
#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
|
||||
#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
|
||||
#define SO_LINGER 0x0080 /* linger on close if data present */
|
||||
#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
|
||||
#define SO_REUSEPORT 0x0200 /* allow local address & port reuse */
|
||||
|
||||
#define SO_DONTLINGER (int)(~SO_LINGER)
|
||||
|
||||
/*
|
||||
* Additional options, not kept in so_options.
|
||||
*/
|
||||
#define SO_SNDBUF 0x1001 /* send buffer size */
|
||||
#define SO_RCVBUF 0x1002 /* receive buffer size */
|
||||
#define SO_SNDLOWAT 0x1003 /* send low-water mark */
|
||||
#define SO_RCVLOWAT 0x1004 /* receive low-water mark */
|
||||
#define SO_SNDTIMEO 0x1005 /* send timeout */
|
||||
#define SO_RCVTIMEO 0x1006 /* receive timeout */
|
||||
#define SO_ERROR 0x1007 /* get error status and clear */
|
||||
#define SO_TYPE 0x1008 /* get socket type */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Structure used for manipulating linger option.
|
||||
*/
|
||||
struct linger {
|
||||
int l_onoff; /* option on/off */
|
||||
int l_linger; /* linger time */
|
||||
};
|
||||
|
||||
/*
|
||||
* Level number for (get/set)sockopt() to apply to socket itself.
|
||||
*/
|
||||
#define SOL_SOCKET 0xffff /* options for socket level */
|
||||
|
||||
#define AF_UNSPEC 0
|
||||
#define AF_INET 2
|
||||
#define PF_INET AF_INET
|
||||
#define PF_UNSPEC AF_UNSPEC
|
||||
|
||||
#define IPPROTO_IP 0
|
||||
#define IPPROTO_TCP 6
|
||||
#define IPPROTO_UDP 17
|
||||
|
||||
#define INADDR_ANY 0
|
||||
#define INADDR_BROADCAST 0xffffffff
|
||||
|
||||
/* Flags we can use with send and recv. */
|
||||
#define MSG_DONTWAIT 0x40 /* Nonblocking i/o for this operation only */
|
||||
|
||||
/*
|
||||
* Options for level IPPROTO_IP
|
||||
*/
|
||||
#define IP_TOS 1
|
||||
#define IP_TTL 2
|
||||
|
||||
|
||||
#define IPTOS_TOS_MASK 0x1E
|
||||
#define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK)
|
||||
#define IPTOS_LOWDELAY 0x10
|
||||
#define IPTOS_THROUGHPUT 0x08
|
||||
#define IPTOS_RELIABILITY 0x04
|
||||
#define IPTOS_LOWCOST 0x02
|
||||
#define IPTOS_MINCOST IPTOS_LOWCOST
|
||||
|
||||
/*
|
||||
* Definitions for IP precedence (also in ip_tos) (hopefully unused)
|
||||
*/
|
||||
#define IPTOS_PREC_MASK 0xe0
|
||||
#define IPTOS_PREC(tos) ((tos) & IPTOS_PREC_MASK)
|
||||
#define IPTOS_PREC_NETCONTROL 0xe0
|
||||
#define IPTOS_PREC_INTERNETCONTROL 0xc0
|
||||
#define IPTOS_PREC_CRITIC_ECP 0xa0
|
||||
#define IPTOS_PREC_FLASHOVERRIDE 0x80
|
||||
#define IPTOS_PREC_FLASH 0x60
|
||||
#define IPTOS_PREC_IMMEDIATE 0x40
|
||||
#define IPTOS_PREC_PRIORITY 0x20
|
||||
#define IPTOS_PREC_ROUTINE 0x00
|
||||
|
||||
|
||||
/*
|
||||
* Commands for ioctlsocket(), taken from the BSD file fcntl.h.
|
||||
*
|
||||
*
|
||||
* Ioctl's have the command encoded in the lower word,
|
||||
* and the size of any in or out parameters in the upper
|
||||
* word. The high 2 bits of the upper word are used
|
||||
* to encode the in/out status of the parameter; for now
|
||||
* we restrict parameters to at most 128 bytes.
|
||||
*/
|
||||
#if !defined(FIONREAD) || !defined(FIONBIO)
|
||||
#define IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */
|
||||
#define IOC_VOID 0x20000000 /* no parameters */
|
||||
#define IOC_OUT 0x40000000 /* copy out parameters */
|
||||
#define IOC_IN 0x80000000 /* copy in parameters */
|
||||
#define IOC_INOUT (IOC_IN|IOC_OUT)
|
||||
/* 0x20000000 distinguishes new &
|
||||
old ioctl's */
|
||||
#define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
|
||||
|
||||
#define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
|
||||
|
||||
#define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
|
||||
#endif
|
||||
|
||||
#ifndef FIONREAD
|
||||
#define FIONREAD _IOR('f', 127, unsigned long) /* get # bytes to read */
|
||||
#endif
|
||||
#ifndef FIONBIO
|
||||
#define FIONBIO _IOW('f', 126, unsigned long) /* set/clear non-blocking i/o */
|
||||
#endif
|
||||
|
||||
/* Socket I/O Controls */
|
||||
#ifndef SIOCSHIWAT
|
||||
#define SIOCSHIWAT _IOW('s', 0, unsigned long) /* set high watermark */
|
||||
#define SIOCGHIWAT _IOR('s', 1, unsigned long) /* get high watermark */
|
||||
#define SIOCSLOWAT _IOW('s', 2, unsigned long) /* set low watermark */
|
||||
#define SIOCGLOWAT _IOR('s', 3, unsigned long) /* get low watermark */
|
||||
#define SIOCATMARK _IOR('s', 7, unsigned long) /* at oob mark? */
|
||||
#endif
|
||||
|
||||
#ifndef O_NONBLOCK
|
||||
#define O_NONBLOCK 04000U
|
||||
#endif
|
||||
|
||||
#ifndef FD_SET
|
||||
#undef FD_SETSIZE
|
||||
#define FD_SETSIZE 16
|
||||
#define FD_SET(n, p) ((p)->fd_bits[(n)/8] |= (1 << ((n) & 7)))
|
||||
#define FD_CLR(n, p) ((p)->fd_bits[(n)/8] &= ~(1 << ((n) & 7)))
|
||||
#define FD_ISSET(n,p) ((p)->fd_bits[(n)/8] & (1 << ((n) & 7)))
|
||||
#define FD_ZERO(p) memset((void*)(p),0,sizeof(*(p)))
|
||||
|
||||
typedef struct fd_set {
|
||||
u8 fd_bits [(FD_SETSIZE+7)/8];
|
||||
} fd_set;
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef TCP_NODELAY
|
||||
#define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */
|
||||
#endif
|
||||
#ifndef TCP_KEEPALIVE
|
||||
#define TCP_KEEPALIVE 0x02 /* send KEEPALIVE probes when idle for pcb->keepalive miliseconds */
|
||||
#endif
|
||||
|
||||
#ifndef socklen_t
|
||||
#define socklen_t u32
|
||||
#endif
|
||||
|
||||
#ifndef htons
|
||||
#define htons(x) (x)
|
||||
#endif
|
||||
#ifndef ntohs
|
||||
#define ntohs(x) (x)
|
||||
#endif
|
||||
#ifndef htonl
|
||||
#define htonl(x) (x)
|
||||
#endif
|
||||
#ifndef ntohl
|
||||
#define ntohl(x) (x)
|
||||
#endif
|
||||
|
||||
#ifndef h_addr
|
||||
#define h_addr h_addr_list[0]
|
||||
#endif
|
||||
|
||||
#ifndef IP4_ADDR
|
||||
#define IP4_ADDR(ipaddr, a,b,c,d) (ipaddr)->s_addr = htonl(((u32)(a&0xff)<<24)|((u32)(b&0xff)<<16)|((u32)(c&0xff)<<8)|(u32)(d&0xff))
|
||||
#define ip4_addr1(ipaddr) ((u32)(ntohl((ipaddr)->s_addr) >> 24) & 0xff)
|
||||
#define ip4_addr2(ipaddr) ((u32)(ntohl((ipaddr)->s_addr) >> 16) & 0xff)
|
||||
#define ip4_addr3(ipaddr) ((u32)(ntohl((ipaddr)->s_addr) >> 8) & 0xff)
|
||||
#define ip4_addr4(ipaddr) ((u32)(ntohl((ipaddr)->s_addr)) & 0xff)
|
||||
#endif
|
||||
|
||||
#define POLLIN 0x0001
|
||||
#define POLLPRI 0x0002
|
||||
#define POLLOUT 0x0004
|
||||
#define POLLERR 0x0008
|
||||
#define POLLHUP 0x0010
|
||||
#define POLLNVAL 0x0020
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_IN_ADDR
|
||||
#define HAVE_IN_ADDR
|
||||
struct in_addr {
|
||||
u32 s_addr;
|
||||
};
|
||||
#endif
|
||||
|
||||
struct sockaddr_in {
|
||||
u8 sin_len;
|
||||
u8 sin_family;
|
||||
u16 sin_port;
|
||||
struct in_addr sin_addr;
|
||||
s8 sin_zero[8];
|
||||
};
|
||||
|
||||
struct sockaddr {
|
||||
u8 sa_len;
|
||||
u8 sa_family;
|
||||
s8 sa_data[14];
|
||||
};
|
||||
|
||||
struct hostent {
|
||||
char *h_name; /* official name of host */
|
||||
char **h_aliases; /* alias list */
|
||||
u16 h_addrtype; /* host address type */
|
||||
u16 h_length; /* length of address */
|
||||
char **h_addr_list; /* list of addresses from name server */
|
||||
};
|
||||
|
||||
struct pollsd {
|
||||
s32 socket;
|
||||
u32 events;
|
||||
u32 revents;
|
||||
};
|
||||
|
||||
u32 inet_addr(const char *cp);
|
||||
s8 inet_aton(const char *cp, struct in_addr *addr);
|
||||
char *inet_ntoa(struct in_addr addr); /* returns ptr to static buffer; not reentrant! */
|
||||
|
||||
s32 if_config( char *local_ip, char *netmask, char *gateway,bool use_dhcp, int max_retries);
|
||||
s32 if_configex(struct in_addr *local_ip, struct in_addr *netmask, struct in_addr *gateway, bool use_dhcp, int max_retries);
|
||||
|
||||
s32 net_init();
|
||||
#ifdef HW_RVL
|
||||
typedef s32 (*netcallback)(s32 result, void *usrdata);
|
||||
s32 net_init_async(netcallback cb, void *usrdata);
|
||||
s32 net_get_status(void);
|
||||
void net_wc24cleanup();
|
||||
s32 net_get_mac_address(void *mac_buf);
|
||||
#endif
|
||||
void net_deinit();
|
||||
|
||||
u32 net_gethostip();
|
||||
s32 net_socket(u32 domain,u32 type,u32 protocol);
|
||||
s32 net_bind(s32 s,struct sockaddr *name,socklen_t namelen);
|
||||
s32 net_listen(s32 s,u32 backlog);
|
||||
s32 net_accept(s32 s,struct sockaddr *addr,socklen_t *addrlen);
|
||||
s32 net_connect(s32 s,struct sockaddr *,socklen_t);
|
||||
s32 net_write(s32 s,const void *data,s32 size);
|
||||
s32 net_send(s32 s,const void *data,s32 size,u32 flags);
|
||||
s32 net_sendto(s32 s,const void *data,s32 len,u32 flags,struct sockaddr *to,socklen_t tolen);
|
||||
s32 net_recv(s32 s,void *mem,s32 len,u32 flags);
|
||||
s32 net_recvfrom(s32 s,void *mem,s32 len,u32 flags,struct sockaddr *from,socklen_t *fromlen);
|
||||
s32 net_read(s32 s,void *mem,s32 len);
|
||||
s32 net_close(s32 s);
|
||||
s32 net_select(s32 maxfdp1,fd_set *readset,fd_set *writeset,fd_set *exceptset,struct timeval *timeout);
|
||||
s32 net_setsockopt(s32 s,u32 level,u32 optname,const void *optval,socklen_t optlen);
|
||||
s32 net_ioctl(s32 s, u32 cmd, void *argp);
|
||||
s32 net_fcntl(s32 s, u32 cmd, u32 flags);
|
||||
s32 net_poll(struct pollsd *sds,s32 nsds,s32 timeout);
|
||||
s32 net_shutdown(s32 s, u32 how);
|
||||
|
||||
struct hostent * net_gethostbyname(const char *addrString);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
272
wii/libogc/include/ogc/aram.h
Normal file
272
wii/libogc/include/ogc/aram.h
Normal file
@ -0,0 +1,272 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
aram.h -- ARAM subsystem
|
||||
|
||||
Copyright (C) 2004
|
||||
Michael Wiedenbauer (shagkur)
|
||||
Dave Murphy (WinterMute)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __ARAM_H__
|
||||
#define __ARAM_H__
|
||||
|
||||
/*!
|
||||
* \file aram.h
|
||||
* \brief ARAM subsystem
|
||||
*
|
||||
*/
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
|
||||
/*!
|
||||
* \addtogroup dmamode ARAM DMA transfer direction
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define AR_MRAMTOARAM 0 /*!< direction: MRAM -> ARAM (write) */
|
||||
#define AR_ARAMTOMRAM 1 /*!< direction: ARAM -> MRAM (read) */
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* \addtogroup memmode ARAM memory access modes
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define AR_ARAMINTALL 0 /*!< use all the internal ARAM memory */
|
||||
#define AR_ARAMINTUSER 1 /*!< use only the internal user space of the ARAM memory */
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
/*!
|
||||
* \typedef void (*ARCallback)(void)
|
||||
* \brief function pointer typedef for the user's ARAM interrupt callback
|
||||
*
|
||||
* \param none
|
||||
*/
|
||||
typedef void (*ARCallback)(void);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn ARCallback AR_RegisterCallback(ARCallback callback)
|
||||
* \brief Register the given function as a DMA callback
|
||||
*
|
||||
* Any existing callback is replaced unconditionally
|
||||
*
|
||||
* \param[in] callback to be invoked upon completion of DMA transaction
|
||||
*
|
||||
* \return pointer to the previously registered callback and NULL respectively
|
||||
*/
|
||||
ARCallback AR_RegisterCallback(ARCallback callback);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn u32 AR_GetDMAStatus()
|
||||
* \brief Get current status of DMA
|
||||
*
|
||||
* \return zero if DMA is idle, non-zero if a DMA is in progress
|
||||
*/
|
||||
u32 AR_GetDMAStatus();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn u32 AR_Init(u32 *stack_idx_array,u32 num_entries)
|
||||
* \brief Initializes ARAM subsystem.
|
||||
*
|
||||
* Following tasks are performed:
|
||||
*
|
||||
* - Disables ARAM DMA
|
||||
* - Sets DMA callback to NULL
|
||||
* - Initializes ARAM controller
|
||||
* - Determines size of ARAM memory
|
||||
* - Initializes the ARAM stack based memory allocation system<br>
|
||||
*
|
||||
* The parameter u32 *stack_idx_array points to an array of u32 integers. The parameter u32 num_entries specifies the number of entries in this array.<br>
|
||||
* The user application is responsible for determining how many ARAM blocks the device driver can allocate.<br>
|
||||
*
|
||||
* As an example, consider:
|
||||
* \code
|
||||
* #define MAX_NUM_BLOCKS 10
|
||||
*
|
||||
* u32 aram_blocks[MAX_NUM_BLOCKS];
|
||||
* ...
|
||||
* void func(void)
|
||||
* {
|
||||
* AR_Init(aram_blocks, MAX_NUM_BLOCKS);
|
||||
* }
|
||||
* \endcode
|
||||
*
|
||||
* Here, we are telling AR that the application will allocate, at most, 10 blocks (of arbitrary size), and that AR should store addresses for those blocks in the array aram_blocks. Note that the array is simply storage supplied by the application so that AR can track the number and size of memory blocks allocated by AR_Alloc().
|
||||
* AR_Free()also uses this array to release blocks.<br>
|
||||
* If you do not wish to use AR_Alloc() and AR_Free() and would rather manage ARAM usage within your application, then call AR_Init() like so:<br>
|
||||
*
|
||||
* AR_Init(NULL, 0);<br>
|
||||
*
|
||||
* The AR_Init() function also calculates the total size of the ARAM aggregate. Note that this procedure is <b><i>destructive</i></b> - i.e., any data stored in ARAM will be corrupted.<br>
|
||||
* AR_Init()may be invoked multiple times. This function checks the state of an initialization flag; if asserted, this function will simply exit on subsequent calls. To perform another initialization of the ARAM driver, call AR_Reset() before invoking AR_Init() again.
|
||||
*
|
||||
* \param[in] stack_idx_array pointer to an array of u32 integer
|
||||
* \param[in] num_entries number of entries in the specified array
|
||||
*
|
||||
* \return base address of the "user" ARAM area. As of this writing, the operating system reserves the bottom 16 KB of ARAM. Therefore, AR_Init() returns 0x04000 to indicate the starting location of the ARAM user area.
|
||||
*/
|
||||
u32 AR_Init(u32 *stack_idx_array,u32 num_entries);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void AR_StartDMA(u32 dir,u32 memaddr,u32 aramaddr,u32 len)
|
||||
* \brief Initiates a DMA between main memory and ARAM.
|
||||
*
|
||||
* This function:
|
||||
*
|
||||
* - Does <b><i>not</i></b> perform boundery-checking on addresses and lengths.
|
||||
* - Will assert failure if a DMA is allready in progress.
|
||||
* - Is provided for debugging purpose. Application programmers must use the ARQ API in order to access ARAM.
|
||||
*
|
||||
* \param[in] dir specifies the \ref dmamode "direction" of transfer.
|
||||
* \param[in] memaddr specifies main memory address for the transfer
|
||||
* \param[in] aramaddr specifies the ARAM address for the transfer. <b><i>NOTE:</i></b> Addresses are 27bits wide and refer to bytes
|
||||
* \param[in] len specifies the length of the block to transfer. <b><i>NOTE:</i></b> Must be in bytes and a multiple of 32
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void AR_StartDMA(u32 dir,u32 memaddr,u32 aramaddr,u32 len);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn u32 AR_Alloc(u32 len)
|
||||
* \brief Allocate a block of memory from ARAM having <i>len</i> bytes.
|
||||
*
|
||||
* The <i>len</i> parameter <b><i>must</i></b> be a multiple of 32
|
||||
*
|
||||
* \param[in] len length of the specified block of memory in ARAM
|
||||
*
|
||||
* \return address of the block if successful, otherwise NULL
|
||||
*/
|
||||
u32 AR_Alloc(u32 len);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn u32 AR_Free(u32 *len)
|
||||
* \brief Free a block from ARAM
|
||||
*
|
||||
* \param[out] len pointer to receive the length of the free'd ARAM block. This is optional and can be NULL.
|
||||
*
|
||||
* \return ARAM current baseaddress after free'ing the block
|
||||
*/
|
||||
u32 AR_Free(u32 *len);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void AR_Clear(u32 flag)
|
||||
* \brief Clear ARAM memory
|
||||
*
|
||||
* \param[in] flag specifies the region of ARAM to clear
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void AR_Clear(u32 flag);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn BOOL AR_CheckInit()
|
||||
* \brief Get the ARAM subsystem initialization flag
|
||||
*
|
||||
* \return TRUE if the ARAM subsystem has been initialized(via AR_Init())<br>
|
||||
* FALSE if the ARAM subsystem has not been initialized, or has been reset(via AR_Reset())
|
||||
*/
|
||||
BOOL AR_CheckInit();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void AR_Reset()
|
||||
* \brief Clears the ARAM subsystem initialization flag.
|
||||
*
|
||||
* Calling AR_Init() after this function will cause a "real" initialization of ARAM
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void AR_Reset();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn u32 AR_GetSize()
|
||||
* \brief Get the total size - in bytes - of ARAM as calculated during AR_Init()
|
||||
*
|
||||
* \return size of the specified ARAM block
|
||||
*/
|
||||
u32 AR_GetSize();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn u32 AR_GetBaseAddress()
|
||||
* \brief Get the baseaddress of ARAM memory
|
||||
*
|
||||
* \return ARAM memory baseaddress
|
||||
*/
|
||||
u32 AR_GetBaseAddress();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn u32 AR_GetInternalSize()
|
||||
* \brief Get the size of the internal ARAM memory
|
||||
*
|
||||
* \return ARAM internal memory size
|
||||
*/
|
||||
u32 AR_GetInternalSize();
|
||||
|
||||
|
||||
/*!
|
||||
* \def AR_StartDMARead(maddr,araddr,tlen)
|
||||
* \brief Wraps the DMA read operation done by AR_StartDMA()
|
||||
*/
|
||||
#define AR_StartDMARead(maddr,araddr,tlen) \
|
||||
AR_StartDMA(AR_ARAMTOMRAM,maddr,araddr,tlen);
|
||||
|
||||
|
||||
/*!
|
||||
* \def AR_StartDMAWrite(maddr,araddr,tlen)
|
||||
* \brief Wraps the DMA write operation done by AR_StartDMA()
|
||||
*/
|
||||
#define AR_StartDMAWrite(maddr,araddr,tlen) \
|
||||
AR_StartDMA(AR_MRAMTOARAM,maddr,araddr,tlen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif //__ARAM_H__
|
113
wii/libogc/include/ogc/arqmgr.h
Normal file
113
wii/libogc/include/ogc/arqmgr.h
Normal file
@ -0,0 +1,113 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
|
||||
arqmgr.h -- ARAM task queue management
|
||||
|
||||
Copyright (C) 2004
|
||||
Michael Wiedenbauer (shagkur)
|
||||
Dave Murphy (WinterMute)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __ARQMGR_H__
|
||||
#define __ARQMGR_H__
|
||||
|
||||
|
||||
/*!
|
||||
* \file arqmgr.h
|
||||
* \brief ARAM queue managemnt subsystem
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
/*!
|
||||
* \typedef void (*ARQMCallback)()
|
||||
* \brief function pointer typedef for the user's callback when ARAM operation has completed
|
||||
* \param none
|
||||
*/
|
||||
typedef void (*ARQMCallback)(s32 result);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void ARQM_Init(u32 arambase,s32 len)
|
||||
* \brief Initialize the ARAM queue management system
|
||||
*
|
||||
* \param[in] arambase ARAM startaddress to take for the queue stack
|
||||
* \param[in] len maximum amount of memory to be reserved from the ARAM for the queue management
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void ARQM_Init(u32 arambase,s32 len);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn u32 ARQM_PushData(void *buff,s32 len)
|
||||
* \brief Push the data onto the ARAM queue
|
||||
*
|
||||
* \param[in] buff startaddress of buffer to be pushed onto the queue. <b><i>NOTE:</i></b> Must be 32-bytealigned.
|
||||
* \param[in] len length of data to be pushed onto the queue.
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
u32 ARQM_PushData(void *buffer,s32 len);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn u32 ARQM_GetZeroBuffer()
|
||||
* \brief Returns ARAM address of 'zero buffer'
|
||||
*
|
||||
* \return See description
|
||||
*/
|
||||
u32 ARQM_GetZeroBuffer();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn u32 ARQM_GetStackPointer()
|
||||
* \brief Return the ARAM address of the next free stack pointer
|
||||
*
|
||||
* \return See description
|
||||
*/
|
||||
u32 ARQM_GetStackPointer();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn u32 ARQM_GetFreeSize()
|
||||
* \brief Return Returns remaining number of bytes on stack
|
||||
*
|
||||
* \return See description
|
||||
*/
|
||||
u32 ARQM_GetFreeSize();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
115
wii/libogc/include/ogc/arqueue.h
Normal file
115
wii/libogc/include/ogc/arqueue.h
Normal file
@ -0,0 +1,115 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
arqueue.h -- ARAM task request queue implementation
|
||||
|
||||
Copyright (C) 2004
|
||||
Michael Wiedenbauer (shagkur)
|
||||
Dave Murphy (WinterMute)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __ARQUEUE_H__
|
||||
#define __ARQUEUE_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
#include <ogc/lwp_queue.h>
|
||||
#include "aram.h"
|
||||
|
||||
#define ARQ_MRAMTOARAM AR_MRAMTOARAM
|
||||
#define ARQ_ARAMTOMRAM AR_ARAMTOMRAM
|
||||
|
||||
#define ARQ_DEF_CHUNK_SIZE 4096
|
||||
|
||||
#define ARQ_PRIO_LO 0
|
||||
#define ARQ_PRIO_HI 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
enum {
|
||||
ARQ_TASK_READY = 0,
|
||||
ARQ_TASK_RUNNING,
|
||||
ARQ_TASK_FINISHED
|
||||
};
|
||||
|
||||
typedef struct _arq_request ARQRequest;
|
||||
typedef void (*ARQCallback)(ARQRequest *);
|
||||
|
||||
struct _arq_request {
|
||||
lwp_node node;
|
||||
u32 owner,dir,prio,state;
|
||||
u32 aram_addr,mram_addr,len;
|
||||
ARQCallback callback;
|
||||
};
|
||||
|
||||
void ARQ_Init();
|
||||
void ARQ_Reset();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void ARQ_PostRequest(ARQRequest *req,u32 owner,u32 dir,u32 prio,u32 aram_addr,u32 mram_addr,u32 len)
|
||||
* \brief Enqueue a ARAM DMA transfer request.
|
||||
*
|
||||
* \param[in] req structure to hold ARAM DMA request informations.
|
||||
* \param[in] owner unique owner id.
|
||||
* \param[in] dir direction of ARAM DMA transfer.
|
||||
* \param[in] prio priority of request.
|
||||
* \param[in] aram_addr startaddress of buffer to be pushed onto the queue. <b><i>NOTE:</i></b> Must be 32-bytealigned.
|
||||
* \param[in] mram_addr length of data to be pushed onto the queue.
|
||||
* \param[in] len startaddress of buffer to be pushed onto the queue. <b><i>NOTE:</i></b> Must be 32-bytealigned.
|
||||
* \param[in] cb length of data to be pushed onto the queue.
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void ARQ_PostRequest(ARQRequest *req,u32 owner,u32 dir,u32 prio,u32 aram_addr,u32 mram_addr,u32 len);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void ARQ_PostRequestAsync(ARQRequest *req,u32 owner,u32 dir,u32 prio,u32 aram_addr,u32 mram_addr,u32 len,ARQCallback cb)
|
||||
* \brief Enqueue a ARAM DMA transfer request.
|
||||
*
|
||||
* \param[in] req structure to hold ARAM DMA request informations.
|
||||
* \param[in] owner unique owner id.
|
||||
* \param[in] dir direction of ARAM DMA transfer.
|
||||
* \param[in] prio priority of request.
|
||||
* \param[in] aram_addr startaddress of buffer to be pushed onto the queue. <b><i>NOTE:</i></b> Must be 32-bytealigned.
|
||||
* \param[in] mram_addr length of data to be pushed onto the queue.
|
||||
* \param[in] len startaddress of buffer to be pushed onto the queue. <b><i>NOTE:</i></b> Must be 32-bytealigned.
|
||||
* \param[in] cb length of data to be pushed onto the queue.
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void ARQ_PostRequestAsync(ARQRequest *req,u32 owner,u32 dir,u32 prio,u32 aram_addr,u32 mram_addr,u32 len,ARQCallback cb);
|
||||
void ARQ_RemoveRequest(ARQRequest *req);
|
||||
void ARQ_SetChunkSize(u32 size);
|
||||
u32 ARQ_GetChunkSize();
|
||||
void ARQ_FlushQueue();
|
||||
u32 ARQ_RemoveOwnerRequest(u32 owner);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
319
wii/libogc/include/ogc/audio.h
Normal file
319
wii/libogc/include/ogc/audio.h
Normal file
@ -0,0 +1,319 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
audio.h -- Audio subsystem
|
||||
|
||||
Copyright (C) 2004
|
||||
Michael Wiedenbauer (shagkur)
|
||||
Dave Murphy (WinterMute)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __AUDIO_H__
|
||||
#define __AUDIO_H__
|
||||
|
||||
/*! \file audio.h
|
||||
\brief AUDIO subsystem
|
||||
|
||||
*/
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
/*!
|
||||
* \addtogroup ai_stream_mode AI streaming modes
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define AI_STREAM_STOP 0x00000000 /*!< Stop streaming audio playback */
|
||||
#define AI_STREAM_START 0x00000001 /*!< Start streaming audio playback */
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* \addtogroup ai_sample_rates AI sampling rates
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define AI_SAMPLERATE_32KHZ 0x00000000 /*!< AI sampling rate at 32kHz */
|
||||
#define AI_SAMPLERATE_48KHZ 0x00000001 /*!< AI sampling rate at 48kHz */
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*!
|
||||
* \typedef void (*AIDCallback)(void)
|
||||
* \brief function pointer typedef for the user's Audio DMA interrupt callback
|
||||
*
|
||||
* \param none
|
||||
*/
|
||||
typedef void (*AIDCallback)(void);
|
||||
|
||||
|
||||
/*!
|
||||
* \typedef void (*AISCallback)(u32 smp_cnt)
|
||||
* \brief function pointer typedef for the user's Audio Streaming interrupt callback
|
||||
*
|
||||
* \param smp_cnt AI sample count
|
||||
*/
|
||||
typedef void (*AISCallback)(u32 smp_cnt);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn AISCallback AUDIO_RegisterStreamCallback(AISCallback callback)
|
||||
* \brief Register a user callback function for the AUDIO streaming interface
|
||||
*
|
||||
* \param[in] callback pointer to the function which to call when AIS interrupt has triggered.
|
||||
*
|
||||
* \return pointer to old callback function or NULL respectively.
|
||||
*/
|
||||
AISCallback AUDIO_RegisterStreamCallback(AISCallback callback);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void AUDIO_Init(u8 *stack)
|
||||
* \brief Initialize the AUDIO subsystem
|
||||
*
|
||||
* \param[in] stack pointer to a memory area to work as stack when calling the callbacks. May be NULL
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void AUDIO_Init(u8 *stack);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void AUDIO_SetStreamVolLeft(u8 vol)
|
||||
* \brief Set streaming volume on the left channel.
|
||||
*
|
||||
* \param[in] vol level of volume 0<= vol <=255
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void AUDIO_SetStreamVolLeft(u8 vol);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn u8 AUDIO_GetStreamVolLeft()
|
||||
* \brief Get streaming volume of the left channel.
|
||||
*
|
||||
* \return level of volume.
|
||||
*/
|
||||
u8 AUDIO_GetStreamVolLeft();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void AUDIO_SetStreamVolRight(u8 vol)
|
||||
* \brief set streaming volume of the right channel.
|
||||
*
|
||||
* \param[in] vol level of volume 0<= vol <=255
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void AUDIO_SetStreamVolRight(u8 vol);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn u8 AUDIO_GetStreamVolRight()
|
||||
* \brief Get streaming volume of the right channel.
|
||||
*
|
||||
* \return level of volume.
|
||||
*/
|
||||
u8 AUDIO_GetStreamVolRight();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void AUDIO_SetStreamSampleRate(u32 rate)
|
||||
* \brief Set streaming sample rate
|
||||
*
|
||||
* \param[in] rate streaming \ref ai_sample_rates "sample rate"
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void AUDIO_SetStreamSampleRate(u32 rate);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn u32 AUDIO_GetStreamSampleRate()
|
||||
* \brief Get streaming sample rate
|
||||
*
|
||||
* \return \ref ai_sample_rates "sample rate"
|
||||
*/
|
||||
u32 AUDIO_GetStreamSampleRate();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn AIDCallback AUDIO_RegisterDMACallback(AIDCallback callback)
|
||||
* \brief Register a user callback function for the audio DMA interface.
|
||||
*
|
||||
* This callback will be called whenever the audio DMA requests new data.<br>
|
||||
* Internally the DMA buffers are double buffered.
|
||||
*
|
||||
* \param[in] callback pointer to the function which to call when AID interrupt has triggered.
|
||||
*
|
||||
* \return pointer to old callback function or NULL respectively.
|
||||
*/
|
||||
AIDCallback AUDIO_RegisterDMACallback(AIDCallback callback);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void AUDIO_InitDMA(u32 startaddr,u32 len)
|
||||
* \brief Initialize an audio DMA transfer
|
||||
*
|
||||
* \param[in] startaddr start address of the memory region to load into the audio DMA. <b><i>NOTE:</i></b> Has to be aligned on a 32byte boundery!
|
||||
* \param[in] len lenght of data to load into the audio DMA. <b><i>NOTE:</i></b> Should be a multiple of 32
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void AUDIO_InitDMA(u32 startaddr,u32 len);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn u16 AUDIO_GetDMAEnableFlag()
|
||||
* \brief Get the audio DMA flag
|
||||
*
|
||||
* \return state of the current DMA operation.
|
||||
*/
|
||||
u16 AUDIO_GetDMAEnableFlag();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void AUDIO_StartDMA()
|
||||
* \brief Start the audio DMA operation.
|
||||
*
|
||||
* Starts to transfer the data from main memory to the audio interface thru DMA.<br>
|
||||
* This call should follow the call to AUDIO_InitDMA() which is used to initialize DMA transfers.
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void AUDIO_StartDMA();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void AUDIO_StopDMA()
|
||||
* \brief Stop the previously started audio DMA operation.
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void AUDIO_StopDMA();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn u32 AUDIO_GetDMABytesLeft()
|
||||
* \brief Get the count of bytes, left to play, from the audio DMA interface
|
||||
*
|
||||
* \return count of bytes left to play.
|
||||
*/
|
||||
u32 AUDIO_GetDMABytesLeft();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn u32 AUDIO_GetDMALength()
|
||||
* \brief Get the DMA transfer length configured in the audio DMA interface.
|
||||
*
|
||||
* \return length of data loaded into the audio DMA interface.
|
||||
*/
|
||||
u32 AUDIO_GetDMALength();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn u32 AUDIO_GetDMAStartAddr()
|
||||
* \brief Get the main memory address for the DMA operation.
|
||||
*
|
||||
* \return start address of mainmemory loaded into the audio DMA interface.
|
||||
*/
|
||||
u32 AUDIO_GetDMAStartAddr();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void AUDIO_SetStreamTrigger(u32 cnt)
|
||||
* \brief Set the sample count for the stream trigger
|
||||
*
|
||||
* \param[in] cnt count of samples when to trigger the audio stream.
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void AUDIO_SetStreamTrigger(u32 cnt);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void AUDIO_ResetStreamSampleCnt()
|
||||
* \brief Reset the stream sample count register.
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void AUDIO_ResetStreamSampleCnt();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void AUDIO_SetDSPSampleRate(u8 rate)
|
||||
* \brief Set the sampling rate for the DSP interface
|
||||
*
|
||||
* \param[in] rate sampling rate to set for the DSP (AI_SAMPLERATE_32KHZ,AI_SAMPLERATE_48KHZ)
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void AUDIO_SetDSPSampleRate(u8 rate);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn u32 AUDIO_GetDSPSampleRate()
|
||||
* \brief Get the sampling rate for the DSP interface
|
||||
*
|
||||
* \return DSP sampling rate (AI_SAMPLERATE_32KHZ,AI_SAMPLERATE_48KHZ)
|
||||
*/
|
||||
u32 AUDIO_GetDSPSampleRate();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void AUDIO_SetStreamPlayState(u32 state)
|
||||
* \brief Set the play state for the streaming audio interface
|
||||
*
|
||||
* \param[in] state playstate of the streaming audio interface (AI_STREAM_STOP,AI_STREAM_START)
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void AUDIO_SetStreamPlayState(u32 state);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn u32 AUDIO_GetStreamPlayState()
|
||||
* \brief Get the play state from the streaming audio interface
|
||||
*
|
||||
* \return playstate (AI_STREAM_STOP,AI_STREAM_START)
|
||||
*/
|
||||
u32 AUDIO_GetStreamPlayState();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
326
wii/libogc/include/ogc/cache.h
Normal file
326
wii/libogc/include/ogc/cache.h
Normal file
@ -0,0 +1,326 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
|
||||
cache.h -- Cache interface
|
||||
|
||||
Copyright (C) 2004
|
||||
Michael Wiedenbauer (shagkur)
|
||||
Dave Murphy (WinterMute)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __CACHE_H__
|
||||
#define __CACHE_H__
|
||||
|
||||
/*! \file cache.h
|
||||
\brief Cache subsystem
|
||||
|
||||
*/
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#define LC_BASEPREFIX 0xe000
|
||||
#define LC_BASE (LC_BASEPREFIX<<16)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void DCEnable()
|
||||
* \brief Enable L1 d-cache
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void DCEnable();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void DCDisable()
|
||||
* \brief Disable L1 d-cache
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void DCDisable();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void DCFreeze()
|
||||
* \brief Current contents of the L1 d-cache are locked down and will not be cast out.
|
||||
*
|
||||
* Hits are still serviced, but misses go straight to L2 or 60x bus. Most cache operations, such as DCFlushRange(), will still execute regardless of whether the cache is frozen.<br>
|
||||
* <b><i>NOTE:</i></b> In PowerPC architecture jargon, this feature is referred to as "locking" the data cache. We use the word "freeze" to distinguish it from the locked cache and DMA features.
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void DCFreeze();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void DCUnfreeze()
|
||||
* \brief Undoes actions of DCFreeze().
|
||||
*
|
||||
* Old cache blocks will now be cast out on subsequent L1 misses.<br>
|
||||
* <b><i>NOTE:</i></b> In PowerPC architecture jargon, this feature is referred to as "locking" the data cache. We use the word "freeze" to distinguish it from the locked cache and DMA features.
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void DCUnfreeze();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void DCFlashInvalidate()
|
||||
* \brief Invalidate L1 d-cache.
|
||||
*
|
||||
* An invalidate operation is issued that marks the state of each data cache block as invalid without writing back modified cache blocks to memory.<br>
|
||||
* Cache access is blocked during this time.Bus accesses to the cache are signaled as a miss during invalidate-all operations.
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void DCFlashInvalidate();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void DCInvalidateRange(void *startaddress,u32 len)
|
||||
* \brief Invalidates a given range of the d-cache.
|
||||
*
|
||||
* If any part of the range hits in the d-cache, the corresponding block will be invalidated.
|
||||
*
|
||||
* \param[in] startaddress pointer to the startaddress of the memory range to invalidate. <b><i>NOTE:</i></b> Has to be aligned on a 32byte boundery
|
||||
* \param[in] len length of the range to invalidate. <b><i>NOTE:</i></b> Should be a multiple of 32
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void DCInvalidateRange(void *startaddress,u32 len);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void DCFlushRange(void *startaddress,u32 len)
|
||||
* \brief Flushes a given range.
|
||||
*
|
||||
* If any part of the range hits in the d-cache the corresponding block will be flushed to main memory and invalidated.<br>
|
||||
* <b><i>NOTE:</i></b> This function invokes a "sync" after flushing the range. This means the function will stall until the CPU knows that the data has been writen to main memory
|
||||
*
|
||||
* \param[in] startaddress pointer to the startaddress of the memory range to flush. <b><i>NOTE:</i></b> Has to be aligned on a 32byte boundery
|
||||
* \param[in] len length of range to be flushed. <b><i>NOTE:</i></b> Should be a multiple of 32
|
||||
*
|
||||
*\return none
|
||||
*/
|
||||
void DCFlushRange(void *startaddress,u32 len);
|
||||
|
||||
/*!
|
||||
* \fn void DCStoreRange(void *startaddress,u32 len)
|
||||
* \brief Ensures a range of memory is updated with any modified data in the cache.
|
||||
*
|
||||
* <b><i>NOTE:</i></b> This function invokes a "sync" after storing the range. This means the function will stall until the CPU knows that the data has been writen to main memory
|
||||
*
|
||||
* \param[in] startaddress pointer to the startaddress of the memory range to store. <b><i>NOTE:</i></b> Has to be aligned on a 32byte boundery
|
||||
* \param[in] len length of the range to store. <b><i>NOTE:</i></b> Should be a multiple of 32
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void DCStoreRange(void *startaddress,u32 len);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void DCFlushRangeNoSync(void *startaddress,u32 len)
|
||||
* \brief Flushes a given range.
|
||||
*
|
||||
* If any part of the range hits in the d-cache the corresponding block will be flushed to main memory and invalidated.<br>
|
||||
* <b><i>NOTE:</i></b> This routine does not perform a "sync" to ensure that the range has been flushed to memory. That is, the cache blocks are sent to the bus interface unit for storage to main memory, but by the time this function returns, you are not guaranteed that the blocks have been written to memory.
|
||||
*
|
||||
* \param[in] startaddress pointer to the startaddress of the memory range to flush. <b><i>NOTE:</i></b> Has to be aligned on a 32byte boundery
|
||||
* \param[in] len length of range to be flushed. <b><i>NOTE:</i></b> Should be a multiple of 32
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void DCFlushRangeNoSync(void *startaddress,u32 len);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void DCStoreRangeNoSync(void *startaddress,u32 len)
|
||||
* \brief Ensures a range of memory is updated with any modified data in the cache.
|
||||
*
|
||||
* <b><i>NOTE:</i></b> This routine does not perform a "sync" to ensure that the range has been flushed to memory. That is, the cache blocks are sent to the bus interface unit for storage to main memory, but by the time this function returns, you are not guaranteed that the blocks have been written to memory
|
||||
*
|
||||
* \param[in] startaddress pointer to the startaddress of the memory range to store. <b><i>NOTE:</i></b> Has to be aligned on a 32byte boundery
|
||||
* \param[in] len length of the range to store. <b><i>NOTE:</i></b> Should be a multiple of 32
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void DCStoreRangeNoSync(void *startaddress,u32 len);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void DCZeroRange(void *startaddress,u32 len)
|
||||
* \brief Loads a range of memory into cache and zeroes all the cache lines.
|
||||
*
|
||||
* \param[in] startaddress pointer to the startaddress of the memory range to load/zero. <b><i>NOTE:</i></b> Has to be aligned on a 32byte boundery
|
||||
* \param[in] len length of the range to load/zero. <b><i>NOTE:</i></b> Should be a multiple of 32
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void DCZeroRange(void *startaddress,u32 len);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void DCTouchRange(void *startaddress,u32 len)
|
||||
* \brief Loads a range of memory into cache.
|
||||
*
|
||||
* \param[in] startaddress pointer to the startaddress of the memory range to load. <b><i>NOTE:</i></b> Has to be aligned on a 32byte boundery
|
||||
* \param[in] len length of the range to load. <b><i>NOTE:</i></b> Should be a multiple of 32
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void DCTouchRange(void *startaddress,u32 len);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void ICSync()
|
||||
* \brief Performs an instruction cache synchronization.
|
||||
*
|
||||
* This ensures that all instructions preceding this instruction have completed before this instruction completes.
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void ICSync();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void ICFlashInvalidate()
|
||||
* \brief Invalidate the L1 i-cache.
|
||||
*
|
||||
* An invalidate operation is issued that marks the state of each instruction cache block as invalid without writing back modified cache blocks to memory.<br>
|
||||
* Cache access is blocked during this time. Bus accesses to the cache are signaled as a miss during invalidate-all operations.
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void ICFlashInvalidate();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void ICEnable()
|
||||
* \brief Enable L1 i-cache
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void ICEnable();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void ICDisable()
|
||||
* \brief Disable L1 i-cache
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void ICDisable();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void ICFreeze()
|
||||
* \brief Current contents of the L1 i-cache are locked down and will not be cast out.
|
||||
*
|
||||
* Hits are still serviced, but misses go straight to L2 or 60x bus.<br>
|
||||
* <b><i>NOTE:</i></b> In PowerPC architecture jargon, this feature is referred to as "locking" the data cache. We use the word "freeze" to distinguish it from the locked cache and DMA features.
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void ICFreeze();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void ICUnfreeze()
|
||||
* \brief Undoes actions of ICFreeze().
|
||||
*
|
||||
* Old cache blocks will now be cast out on subsequent L1 misses.<br>
|
||||
* <b><i>NOTE:</i></b> In PowerPC architecture jargon, this feature is referred to as "locking" the data cache. We use the word "freeze" to distinguish it from the locked cache and DMA features.
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void ICUnfreeze();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void ICBlockInvalidate(void *startaddress)
|
||||
* \brief Invalidates a block in the i-cache.
|
||||
*
|
||||
* If the block hits in the i-cache, the corresponding block will be invalidated.
|
||||
*
|
||||
* \param[in] startaddress pointer to the startaddress of the memory block to invalidate. <b><i>NOTE:</i></b> Has to be aligned on a 32byte boundery
|
||||
*
|
||||
*\return none
|
||||
*/
|
||||
void ICBlockInvalidate(void *startaddress);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void ICInvalidateRange(void *startaddress,u32 len)
|
||||
* \brief Invalidate a range in the L1 i-cache.
|
||||
*
|
||||
* If any part of the range hits in the i-cache, the corresponding block will be invalidated.
|
||||
*
|
||||
* \param[in] startaddress pointer to the startaddress of the memory range to invalidate. <b><i>NOTE:</i></b> Has to be aligned on a 32byte boundery
|
||||
* \param[in] len length of the range to invalidate. <b><i>NOTE:</i></b> Should be a multiple of 32
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void ICInvalidateRange(void *startaddress,u32 len);
|
||||
|
||||
/*!
|
||||
* \fn void L2Enhance()
|
||||
* \brief Turn on extra L2 cache features
|
||||
*
|
||||
* Sets the following bits in the HID4 register which affect the L2 cache:
|
||||
* - L2FM=01 (64-byte fetch mode)
|
||||
* - BCO=1 (dual 64-byte castout buffers)
|
||||
* - L2MUM=1 (configured as 2-deep miss-under-miss cache)
|
||||
* Since these features can't be enabled safely, any HID4 writes in the HBC stub will be removed.
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
#ifdef HW_RVL
|
||||
void L2Enhance();
|
||||
#endif
|
||||
|
||||
void LCEnable();
|
||||
void LCDisable();
|
||||
void LCLoadBlocks(void *,void *,u32);
|
||||
void LCStoreBlocks(void *,void *,u32);
|
||||
u32 LCLoadData(void *,void *,u32);
|
||||
u32 LCStoreData(void *,void *,u32);
|
||||
u32 LCQueueLength();
|
||||
u32 LCQueueWait(u32);
|
||||
void LCFlushQueue();
|
||||
void LCAlloc(void *,u32);
|
||||
void LCAllocNoInvalidate(void *,u32);
|
||||
void LCAllocOneTag(BOOL,void *);
|
||||
void LCAllocTags(BOOL,void *,u32);
|
||||
|
||||
#define LCGetBase() ((void*)LC_BASE)
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
605
wii/libogc/include/ogc/card.h
Normal file
605
wii/libogc/include/ogc/card.h
Normal file
@ -0,0 +1,605 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
card.h -- Memory card subsystem
|
||||
|
||||
Copyright (C) 2004
|
||||
Michael Wiedenbauer (shagkur)
|
||||
Dave Murphy (WinterMute)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __CARD_H__
|
||||
#define __CARD_H__
|
||||
|
||||
/*!
|
||||
\file card.h
|
||||
\brief Memory card subsystem
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
/*! \addtogroup cardsolts Memory card slots
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define CARD_SLOTA 0 /*!< memory card slot A */
|
||||
#define CARD_SLOTB 1 /*!< memory card slot B */
|
||||
|
||||
/*! @} */
|
||||
|
||||
|
||||
#define CARD_WORKAREA (5*8*1024) /*!< minimum size of the workarea passed to Mount[Async]() */
|
||||
#define CARD_READSIZE 512 /*!< minimum size of block to read from memory card */
|
||||
#define CARD_FILENAMELEN 32 /*!< maximum filename length */
|
||||
#define CARD_MAXFILES 128 /*!< maximum number of files on the memory card */
|
||||
|
||||
/*! \addtogroup card_errors Memory card error codes
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define CARD_ERROR_UNLOCKED 1 /*!< card beeing unlocked or allready unlocked. */
|
||||
#define CARD_ERROR_READY 0 /*!< card is ready. */
|
||||
#define CARD_ERROR_BUSY -1 /*!< card is busy. */
|
||||
#define CARD_ERROR_WRONGDEVICE -2 /*!< wrong device connected in slot */
|
||||
#define CARD_ERROR_NOCARD -3 /*!< no memory card in slot */
|
||||
#define CARD_ERROR_NOFILE -4 /*!< specified file not found */
|
||||
#define CARD_ERROR_IOERROR -5 /*!< internal EXI I/O error */
|
||||
#define CARD_ERROR_BROKEN -6 /*!< directory structure or file entry broken */
|
||||
#define CARD_ERROR_EXIST -7 /*!< file allready exists with the specified parameters */
|
||||
#define CARD_ERROR_NOENT -8 /*!< found no empty block to create the file */
|
||||
#define CARD_ERROR_INSSPACE -9 /*!< not enough space to write file to memory card */
|
||||
#define CARD_ERROR_NOPERM -10 /*!< not enough permissions to operate on the file */
|
||||
#define CARD_ERROR_LIMIT -11 /*!< card size limit reached */
|
||||
#define CARD_ERROR_NAMETOOLONG -12 /*!< filename too long */
|
||||
#define CARD_ERROR_ENCODING -13 /*!< font encoding PAL/SJIS mismatch*/
|
||||
#define CARD_ERROR_CANCELED -14 /*!< card operation canceled */
|
||||
#define CARD_ERROR_FATAL_ERROR -128 /*!< fatal error, non recoverable */
|
||||
|
||||
/*! @} */
|
||||
|
||||
|
||||
/* File attribute defines */
|
||||
#define CARD_ATTRIB_PUBLIC 0x04
|
||||
#define CARD_ATTRIB_NOCOPY 0x08
|
||||
#define CARD_ATTRIB_NOMOVE 0x10
|
||||
|
||||
/* Banner & Icon Attributes */
|
||||
#define CARD_BANNER_W 96
|
||||
#define CARD_BANNER_H 32
|
||||
|
||||
#define CARD_BANNER_NONE 0x00
|
||||
#define CARD_BANNER_CI 0x01
|
||||
#define CARD_BANNER_RGB 0x02
|
||||
#define CARD_BANNER_MASK 0x03
|
||||
|
||||
#define CARD_MAXICONS 8
|
||||
#define CARD_ICON_W 32
|
||||
#define CARD_ICON_H 32
|
||||
|
||||
#define CARD_ICON_NONE 0x00
|
||||
#define CARD_ICON_CI 0x01
|
||||
#define CARD_ICON_RGB 0x02
|
||||
#define CARD_ICON_MASK 0x03
|
||||
|
||||
#define CARD_ANIM_LOOP 0x00
|
||||
#define CARD_ANIM_BOUNCE 0x04
|
||||
#define CARD_ANIM_MASK 0x04
|
||||
|
||||
#define CARD_SPEED_END 0x00
|
||||
#define CARD_SPEED_FAST 0x01
|
||||
#define CARD_SPEED_MIDDLE 0x02
|
||||
#define CARD_SPEED_SLOW 0x03
|
||||
#define CARD_SPEED_MASK 0x03
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
/*! \typedef struct _card_file card_file
|
||||
\brief structure to hold the fileinformations upon open and for later use.
|
||||
\param chn CARD slot.
|
||||
\param filenum file index in the card directory structure.
|
||||
\param offset offset into the file.
|
||||
\param len length of file.
|
||||
\param iblock block index on memory card.
|
||||
*/
|
||||
typedef struct _card_file {
|
||||
s32 chn;
|
||||
s32 filenum;
|
||||
s32 offset;
|
||||
s32 len;
|
||||
u16 iblock;
|
||||
} card_file;
|
||||
|
||||
|
||||
/*! \typedef struct card_dir
|
||||
\brief structure to hold the information of a directory entry
|
||||
\param chn CARD slot.
|
||||
\param fileno file index in the card directory structure.
|
||||
\param filelen length of file.
|
||||
\param filename[CARD_FILENAMELEN] name of the file on card.
|
||||
\param gamecode[4] string identifier <=4.
|
||||
\param company[2] string identifier <=2.
|
||||
\param showall boolean flag whether to showall entries or ony those identified by card_gamecode and card_company, previously set within the call to CARD_Init()
|
||||
*/
|
||||
typedef struct _card_dir {
|
||||
s32 chn;
|
||||
u32 fileno;
|
||||
u32 filelen;
|
||||
u8 permissions;
|
||||
u8 filename[CARD_FILENAMELEN];
|
||||
u8 gamecode[4];
|
||||
u8 company[2];
|
||||
bool showall;
|
||||
} card_dir;
|
||||
|
||||
|
||||
/*! \typedef struct card_stat
|
||||
\brief structure to hold the additional statistical informations.
|
||||
\param filename[CARD_FILENAMELEN] name of the file on card.
|
||||
\param len length of file.
|
||||
\param gamecode[4] string identifier <=4.
|
||||
\param company[2] string identifier <=2.
|
||||
\param banner_fmt format of banner.
|
||||
\param icon_addr icon image address in file.
|
||||
\param icon_speed speed of an animated icon.
|
||||
\param comment_addr address in file of the comment block.
|
||||
\param offset_banner offset in file to the banner's image data.
|
||||
\param offset_banner_tlut offset in file to the banner's texture lookup table.
|
||||
\param offset_icon[CARD_MAXICONS] array of offsets in file to the icon's image data <CARD_MAXICONS.
|
||||
\param offset_icon_tlut offset in file to the icons's texture lookup table.
|
||||
\param offset_data offset to additional data.
|
||||
*/
|
||||
typedef struct _card_stat {
|
||||
u8 filename[CARD_FILENAMELEN];
|
||||
u32 len;
|
||||
u32 time; //time since 1970 in seconds
|
||||
u8 gamecode[4];
|
||||
u8 company[2];
|
||||
u8 banner_fmt;
|
||||
u32 icon_addr;
|
||||
u16 icon_fmt;
|
||||
u16 iconfmt[CARD_MAXICONS];
|
||||
u16 icon_speed;
|
||||
u16 iconspeed[CARD_MAXICONS];
|
||||
u32 comment_addr;
|
||||
u32 offset_banner;
|
||||
u32 offset_banner_tlut;
|
||||
u32 offset_icon[CARD_MAXICONS];
|
||||
u32 offset_icon_tlut[CARD_MAXICONS];
|
||||
u32 offset_data;
|
||||
} card_stat;
|
||||
|
||||
#define CARD_GetBannerFmt(stat) (((stat)->banner_fmt)&CARD_BANNER_MASK)
|
||||
#define CARD_SetBannerFmt(stat,fmt) ((stat)->banner_fmt = (u8)(((stat)->banner_fmt&~CARD_BANNER_MASK)|(fmt)))
|
||||
#define CARD_GetIconFmt(stat,n) (((stat)->icon_fmt>>(2*(n)))&CARD_ICON_MASK)
|
||||
#define CARD_SetIconFmt(stat,n,fmt) ((stat)->icon_fmt = (u16)(((stat)->icon_fmt&~(CARD_ICON_MASK<<(2*(n))))|((fmt)<<(2*(n)))))
|
||||
#define CARD_GetIconSpeed(stat,n) (((stat)->icon_speed>>(2*(n)))&~CARD_SPEED_MASK);
|
||||
#define CARD_SetIconSpeed(stat,n,speed) ((stat)->icon_speed = (u16)(((stat)->icon_fmt&~(CARD_SPEED_MASK<<(2*(n))))|((speed)<<(2*(n)))))
|
||||
#define CARD_SetIconAddr(stat,addr) ((stat)->icon_addr = (u32)(addr))
|
||||
#define CARD_SetCommentAddr(stat,addr) ((stat)->comment_addr = (u32)(addr))
|
||||
|
||||
/*! \typedef void (*cardcallback)(s32 chan,s32 result)
|
||||
\brief function pointer typedef for the user's operation callback
|
||||
\param chan CARD slot
|
||||
\param result result of operation upon call of callback.
|
||||
*/
|
||||
typedef void (*cardcallback)(s32 chan,s32 result);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_Init(const char *gamecode,const char *company)
|
||||
\brief Performs the initialization of the memory card subsystem
|
||||
\param[in] gamecode pointer to a 4byte long string to specify the vendors game code. May be NULL
|
||||
\param[in] company pointer to a 2byte long string to specify the vendors company code. May be NULL
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_Init(const char *gamecode,const char *company);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_Probe(s32 chn)
|
||||
\brief Performs a check against the desired EXI channel if a device is inserted
|
||||
\param[in] chn CARD slot
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_Probe(s32 chn);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_ProbeEx(s32 chn,s32 *mem_size,s32 *sect_size)
|
||||
\brief Performs a check against the desired EXI channel if a memory card is inserted or mounted
|
||||
\param[in] chn CARD slot
|
||||
\param[out] mem_size pointer to a integer variable, ready to take the resulting value (this param is optional and can be NULL)
|
||||
\param[out] sect_size pointer to a integer variable, ready to take the resulting value (this param is optional and can be NULL)
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_ProbeEx(s32 chn,s32 *mem_size,s32 *sect_size);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_Mount(s32 chn,void *workarea,cardcallback detach_cb)
|
||||
\brief Mounts the memory card in the slot CHN. Synchronous version.
|
||||
\param[in] chn CARD slot
|
||||
\param[in] workarea pointer to memory area to hold the cards system area. The startaddress of the workdarea should be aligned on a 32byte boundery
|
||||
\param[in] detach_cb pointer to a callback function. This callback function will be called when the card is removed from the slot.
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_Mount(s32 chn,void *workarea,cardcallback detach_cb);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_MountAsync(s32 chn,void *workarea,cardcallback detach_cb,cardcallback attach_cb)
|
||||
\brief Mounts the memory card in the slot CHN. This function returns immediately. Asynchronous version.
|
||||
\param[in] chn CARD slot
|
||||
\param[in] workarea pointer to memory area to hold the cards system area. The startaddress of the workdarea should be aligned on a 32byte boundery
|
||||
\param[in] detach_cb pointer to a callback function. This callback function will be called when the card is removed from the slot.
|
||||
\param[in] attach_cb pointer to a callback function. This callback function will be called when the mount process has finished.
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_MountAsync(s32 chn,void *workarea,cardcallback detach_cb,cardcallback attach_cb);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_Unmount(s32 chn)
|
||||
\brief Unmounts the memory card in the slot CHN and releases the EXI bus.
|
||||
\param[in] chn CARD slot
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_Unmount(s32 chn);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_Read(card_file *file,void *buffer,u32 len,u32 offset)
|
||||
\brief Reads the data from the file into the buffer from the given offset with the given length. Synchronous version
|
||||
\param[in] file pointer to the card_file structure. It holds the fileinformations to read from.
|
||||
\param[out] buffer pointer to memory area read-in the data. The startaddress of the buffer should be aligned to a 32byte boundery.
|
||||
\param[in] len length of data to read.
|
||||
\param[in] offset offset into the file to read from.
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_Read(card_file *file,void *buffer,u32 len,u32 offset);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_ReadAsync(card_file *file,void *buffer,u32 len,u32 offset,cardcallback callback)
|
||||
\brief Reads the data from the file into the buffer from the given offset with the given length. This function returns immediately. Asynchronous version
|
||||
\param[in] file pointer to the card_file structure. It holds the fileinformations to read from.
|
||||
\param[out] buffer pointer to memory area read-in the data. The startaddress of the buffer should be aligned to a 32byte boundery.
|
||||
\param[in] len length of data to read.
|
||||
\param[in] offset offset into the file to read from.
|
||||
\param[in] callback pointer to a callback function. This callback will be called when the read process has finished.
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_ReadAsync(card_file *file,void *buffer,u32 len,u32 offset,cardcallback callback);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_Open(s32 chn,const char *filename,card_file *file)
|
||||
\brief Opens the file with the given filename and fills in the fileinformations.
|
||||
\param[in] chn CARD slot
|
||||
\param[in] filename name of the file to open.
|
||||
\param[out] file pointer to the card_file structure. It receives the fileinformations for later usage.
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_Open(s32 chn,const char *filename,card_file *file);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_OpenEntry(s32 chn,card_dir *entry,card_file *file)
|
||||
\brief Opens the file with the given filename and fills in the fileinformations.
|
||||
\param[in] chn CARD slot
|
||||
\param[in] entry pointer to the directory entry to open.
|
||||
\param[out] file pointer to the card_file structure. It receives the fileinformations for later usage.
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_OpenEntry(s32 chn,card_dir *entry,card_file *file);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_Close(card_file *file)
|
||||
\brief Closes the file with the given card_file structure and releases the handle.
|
||||
\param[in] file pointer to the card_file structure to close.
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_Close(card_file *file);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_Create(s32 chn,const char *filename,u32 size,card_file *file)
|
||||
\brief Creates a new file with the given filename and fills in the fileinformations. Synchronous version.
|
||||
\param[in] chn CARD slot
|
||||
\param[in] filename name of the file to create.
|
||||
\param[in] size size of the newly created file. This must be a multiple of the memory card's sector size.
|
||||
\param[out] file pointer to the card_file structure. It receives the fileinformations for later usage.
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_Create(s32 chn,const char *filename,u32 size,card_file *file);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_CreateAsync(s32 chn,const char *filename,u32 size,card_file *file,cardcallback callback)
|
||||
\brief Creates a new file with the given filename and fills in the fileinformations. This function returns immediately. Asynchronous version.
|
||||
\param[in] chn CARD slot
|
||||
\param[in] filename name of the file to create.
|
||||
\param[in] size size of the newly created file. This must be a multiple of the memory card's sector size.
|
||||
\param[out] file pointer to the card_file structure. It receives the fileinformations for later usage.
|
||||
\param[in] callback pointer to a callback function. This callback will be called when the create process has finished.
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_CreateAsync(s32 chn,const char *filename,u32 size,card_file *file,cardcallback callback);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_CreateEntry(s32 chn,card_dir *entry,card_file *file)
|
||||
\brief Creates a new file with the given filename and fills in the fileinformations. Synchronous version.
|
||||
\param[in] chn CARD slot
|
||||
\param[in] entry pointer to the directory entry to create.
|
||||
\param[out] file pointer to the card_file structure. It receives the fileinformations for later usage.
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_CreateEntry(s32 chn,card_dir *direntry,card_file *file);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_CreateEntryAsync(s32 chn,card_dir *entry,card_file *file,cardcallback callback)
|
||||
\brief Creates a new file with the given filename and fills in the fileinformations. This function returns immediately. Asynchronous version.
|
||||
\param[in] chn CARD slot
|
||||
\param[in] entry pointer to the directory entry to create
|
||||
\param[out] file pointer to the card_file structure. It receives the fileinformations for later usage.
|
||||
\param[in] callback pointer to a callback function. This callback will be called when the create process has finished.
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_CreateEntryAsync(s32 chn,card_dir *direntry,card_file *file,cardcallback callback);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_Delete(s32 chn,const char *filename)
|
||||
\brief Deletes a file with the given filename. Synchronous version.
|
||||
\param[in] chn CARD slot
|
||||
\param[in] filename name of the file to delete.
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_Delete(s32 chn,const char *filename);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_DeleteAsync(s32 chn,const char *filename,cardcallback callback)
|
||||
\brief Deletes a file with the given filename. This function returns immediately. Asynchronous version.
|
||||
\param[in] chn CARD slot
|
||||
\param[in] filename name of the file to delete.
|
||||
\param[in] callback pointer to a callback function. This callback will be called when the delete process has finished.
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_DeleteAsync(s32 chn,const char *filename,cardcallback callback);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_DeleteEntry(s32 chn,card_dir *dir_entry)
|
||||
\brief Deletes a file with the given directory entry informations.
|
||||
\param[in] chn CARD slot
|
||||
\param[in] dir_entry pointer to the card_dir structure which holds the informations for the delete operation.
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_DeleteEntry(s32 chn,card_dir *dir_entry);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_DeleteEntryAsync(s32 chn,card_dir *dir_entry,cardcallback callback)
|
||||
\brief Deletes a file with the given directory entry informations. This function returns immediately. Asynchronous version.
|
||||
\param[in] chn CARD slot
|
||||
\param[in] dir_entry pointer to the card_dir structure which holds the informations for the delete operation.
|
||||
\param[in] callback pointer to a callback function. This callback will be called when the delete process has finished.
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_DeleteEntryAsync(s32 chn,card_dir *dir_entry,cardcallback callback);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_Write(card_file *file,void *buffer,u32 len,u32 offset)
|
||||
\brief Writes the data to the file from the buffer to the given offset with the given length. Synchronous version
|
||||
\param[in] file pointer to the card_file structure which holds the fileinformations.
|
||||
\param[in] buffer pointer to the memory area to read from. The startaddress of the buffer should be aligned on a 32byte boundery.
|
||||
\param[in] len length of data to write.
|
||||
\param[in] offset starting point in the file to start writing.
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_Write(card_file *file,void *buffer,u32 len,u32 offset);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_WriteAsync(card_file *file,void *buffer,u32 len,u32 offset,cardcallback callback)
|
||||
\brief Writes the data to the file from the buffer to the given offset with the given length. This function returns immediately. Asynchronous version
|
||||
\param[in] file pointer to the card_file structure which holds the fileinformations.
|
||||
\param[in] buffer pointer to the memory area to read from. The startaddress of the buffer should be aligned on a 32byte boundery.
|
||||
\param[in] len length of data to write.
|
||||
\param[in] offset starting point in the file to start writing.
|
||||
\param[in] callback pointer to a callback function. This callback will be called when the write process has finished.
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_WriteAsync(card_file *file,void *buffer,u32 len,u32 offset,cardcallback callback);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_GetErrorCode(s32 chn)
|
||||
\brief Returns the result code from the last operation.
|
||||
\param[in] chn CARD slot
|
||||
|
||||
\return \ref card_errors "card error codes" of last operation
|
||||
*/
|
||||
s32 CARD_GetErrorCode(s32 chn);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_FindFirst(s32 chn, card_dir *dir, bool showall)
|
||||
\brief Start to iterate thru the memory card's directory structure and returns the first directory entry.
|
||||
\param[in] chn CARD slot
|
||||
\param[out] dir pointer to card_dir structure to receive the result set.
|
||||
\param[in] showall Whether to show all files of the memory card or only those which are identified by the company and gamecode string.
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_FindFirst(s32 chn, card_dir *dir, bool showall);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_FindNext(card_dir *dir)
|
||||
\brief Returns the next directory entry from the memory cards directory structure.
|
||||
\param[out] dir pointer to card_dir structure to receive the result set.
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_FindNext(card_dir *dir);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_GetDirectory(s32 chn, card_dir *dir_entries, s32 *count, bool showall)
|
||||
\brief Returns the directory entries. size of entries is max. 128.
|
||||
\param[in] chn CARD slot
|
||||
\param[out] dir_entries pointer to card_dir structure to receive the result set.
|
||||
\param[out] count pointer to an integer to receive the counted entries.
|
||||
\param[in] showall Whether to show all files of the memory card or only those which are identified by the company and gamecode string.
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_GetDirectory(s32 chn, card_dir *dir_entries, s32 *count, bool showall);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_GetSectorSize(s32 chn,u32 *sector_size)
|
||||
\brief Returns the next directory entry from the memory cards directory structure.
|
||||
\param[in] chn CARD slot.
|
||||
\param[out] sector_size pointer to receive the result.
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_GetSectorSize(s32 chn,u32 *sector_size);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_GetBlockCount(s32 chn,u32 *block_count)
|
||||
\brief Returns the next directory entry from the memory cards directory structure.
|
||||
\param[in] chn CARD slot.
|
||||
\param[out] sector_size pointer to receive the result.
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_GetBlockCount(s32 chn,u32 *block_count);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_GetStatus(s32 chn,s32 fileno,card_stat *stats)
|
||||
\brief Get additional file statistic informations.
|
||||
\param[in] chn CARD slot.
|
||||
\param[in] fileno file index. returned by a previous call to CARD_Open().
|
||||
\param[out] stats pointer to receive the result set.
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_GetStatus(s32 chn,s32 fileno,card_stat *stats);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_SetStatus(s32 chn,s32 fileno,card_stat *stats)
|
||||
\brief Set additional file statistic informations. Synchronous version.
|
||||
\param[in] chn CARD slot.
|
||||
\param[in] fileno file index. returned by a previous call to CARD_Open().
|
||||
\param[out] stats pointer which holds the informations to set.
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_SetStatus(s32 chn,s32 fileno,card_stat *stats);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_SetStatusAsync(s32 chn,s32 fileno,card_stat *stats,cardcallback callback)
|
||||
\brief Set additional file statistic informations. This function returns immediately. Asynchronous version.
|
||||
\param[in] chn CARD slot.
|
||||
\param[in] fileno file index. returned by a previous call to CARD_Open().
|
||||
\param[out] stats pointer which holds the informations to set.
|
||||
\param[in] callback pointer to a callback function. This callback will be called when the setstatus process has finished.
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_SetStatusAsync(s32 chn,s32 fileno,card_stat *stats,cardcallback callback);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_GetAttributes(s32 chn,s32 fileno,u8 *attr)
|
||||
\brief Get additional file attributes. Synchronous version.
|
||||
\param[in] chn CARD slot.
|
||||
\param[in] fileno file index. returned by a previous call to CARD_Open().
|
||||
\param[out] attr pointer to receive attribute value.
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_GetAttributes(s32 chn,s32 fileno,u8 *attr);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_SetAttributes(s32 chn,s32 fileno,u8 attr)
|
||||
\brief Set additional file attributes. Synchronous version.
|
||||
\param[in] chn CARD slot.
|
||||
\param[in] fileno file index. returned by a previous call to CARD_Open().
|
||||
\param[in] attr attribute value to set.
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_SetAttributes(s32 chn,s32 fileno,u8 attr);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_SetAttributesAsync(s32 chn,s32 fileno,u8 attr,cardcallback callback)
|
||||
\brief Set additional file attributes. This function returns immediately. Asynchronous version.
|
||||
\param[in] chn CARD slot.
|
||||
\param[in] fileno file index. returned by a previous call to CARD_Open().
|
||||
\param[in] attr attribute value to set.
|
||||
\param[in] callback pointer to a callback function. This callback will be called when the setattributes process has finished.
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_SetAttributesAsync(s32 chn,s32 fileno,u8 attr,cardcallback callback);
|
||||
|
||||
/**
|
||||
* Not finished function
|
||||
*/
|
||||
s32 CARD_Format(s32 chn);
|
||||
/**
|
||||
* Not finished function
|
||||
*/
|
||||
s32 CARD_FormatAsync(s32 chn,cardcallback callback);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_SetCompany(const char *company)
|
||||
\brief Set additional file attributes. This function returns immediately. Asynchronous version.
|
||||
\param[in] chn CARD slot.
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_SetCompany(const char *company);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_SetGamecode(const char *gamecode)
|
||||
\brief Set additional file attributes. This function returns immediately. Asynchronous version.
|
||||
\param[in] chn CARD slot.
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_SetGamecode(const char *gamecode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
239
wii/libogc/include/ogc/cast.h
Normal file
239
wii/libogc/include/ogc/cast.h
Normal file
@ -0,0 +1,239 @@
|
||||
#ifndef __CAST_H__
|
||||
#define __CAST_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#define GQR2 914
|
||||
#define GQR3 915
|
||||
#define GQR4 916
|
||||
#define GQR5 917
|
||||
#define GQR6 918
|
||||
#define GQR7 919
|
||||
|
||||
#define GQR_TYPE_F32 0
|
||||
#define GQR_TYPE_U8 4
|
||||
#define GQR_TYPE_U16 5
|
||||
#define GQR_TYPE_S8 6
|
||||
#define GQR_TYPE_S16 7
|
||||
|
||||
#define GQR_CAST_U8 2
|
||||
#define GQR_CAST_U16 3
|
||||
#define GQR_CAST_S8 4
|
||||
#define GQR_CAST_S16 5
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef GEKKO
|
||||
|
||||
#define __set_gqr(_reg,_val) asm volatile("mtspr %0,%1" : : "i"(_reg), "b"(_val))
|
||||
|
||||
// does a default init
|
||||
static inline void CAST_Init()
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"li 3,0x0004\n\
|
||||
oris 3,3,0x0004\n\
|
||||
mtspr 914,3\n\
|
||||
li 3,0x0005\n\
|
||||
oris 3,3,0x0005\n\
|
||||
mtspr 915,3\n\
|
||||
li 3,0x0006\n\
|
||||
oris 3,3,0x0006\n\
|
||||
mtspr 916,3\n\
|
||||
li 3,0x0007\n\
|
||||
oris 3,3,0x0007\n\
|
||||
mtspr 917,3\n"
|
||||
: : : "r3"
|
||||
);
|
||||
}
|
||||
|
||||
static inline void CAST_SetGQR2(u32 type,u32 scale)
|
||||
{
|
||||
register u32 val = (((((scale)<<8)|(type))<<16)|(((scale)<<8)|(type)));
|
||||
__set_gqr(GQR2,val);
|
||||
}
|
||||
|
||||
static inline void CAST_SetGQR3(u32 type,u32 scale)
|
||||
{
|
||||
register u32 val = (((((scale)<<8)|(type))<<16)|(((scale)<<8)|(type)));
|
||||
__set_gqr(GQR3,val);
|
||||
}
|
||||
|
||||
static inline void CAST_SetGQR4(u32 type,u32 scale)
|
||||
{
|
||||
register u32 val = (((((scale)<<8)|(type))<<16)|(((scale)<<8)|(type)));
|
||||
__set_gqr(GQR4,val);
|
||||
}
|
||||
|
||||
static inline void CAST_SetGQR5(u32 type,u32 scale)
|
||||
{
|
||||
register u32 val = (((((scale)<<8)|(type))<<16)|(((scale)<<8)|(type)));
|
||||
__set_gqr(GQR5,val);
|
||||
}
|
||||
|
||||
static inline void CAST_SetGQR6(u32 type,u32 scale)
|
||||
{
|
||||
register u32 val = (((((scale)<<8)|(type))<<16)|(((scale)<<8)|(type)));
|
||||
__set_gqr(GQR6,val);
|
||||
}
|
||||
|
||||
static inline void CAST_SetGQR7(u32 type,u32 scale)
|
||||
{
|
||||
register u32 val = (((((scale)<<8)|(type))<<16)|(((scale)<<8)|(type)));
|
||||
__set_gqr(GQR7,val);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************/
|
||||
/* */
|
||||
/* cast from int to float */
|
||||
/* */
|
||||
/******************************************************************/
|
||||
|
||||
static inline f32 __castu8f32(register u8 *in)
|
||||
{
|
||||
register f32 rval;
|
||||
__asm__ __volatile__ (
|
||||
"psq_l %[rval],0(%[in]),1,2" : [rval]"=f"(rval) : [in]"r"(in)
|
||||
);
|
||||
return rval;
|
||||
}
|
||||
|
||||
static inline f32 __castu16f32(register u16 *in)
|
||||
{
|
||||
register f32 rval;
|
||||
__asm__ __volatile__ (
|
||||
"psq_l %[rval],0(%[in]),1,3" : [rval]"=f"(rval) : [in]"r"(in)
|
||||
);
|
||||
return rval;
|
||||
}
|
||||
|
||||
static inline f32 __casts8f32(register s8 *in)
|
||||
{
|
||||
register f32 rval;
|
||||
__asm__ __volatile__ (
|
||||
"psq_l %[rval],0(%[in]),1,4" : [rval]"=f"(rval) : [in]"r"(in)
|
||||
);
|
||||
return rval;
|
||||
}
|
||||
|
||||
static inline f32 __casts16f32(register s16 *in)
|
||||
{
|
||||
register f32 rval;
|
||||
__asm__ __volatile__ (
|
||||
"psq_l %[rval],0(%[in]),1,5" : [rval]"=f"(rval) : [in]"r"(in)
|
||||
);
|
||||
return rval;
|
||||
}
|
||||
|
||||
static inline void castu8f32(register u8 *in,register volatile f32 *out)
|
||||
{
|
||||
*out = __castu8f32(in);
|
||||
}
|
||||
|
||||
static inline void castu16f32(register u16 *in,register volatile f32 *out)
|
||||
{
|
||||
*out = __castu16f32(in);
|
||||
}
|
||||
|
||||
static inline void casts8f32(register s8 *in,register volatile f32 *out)
|
||||
{
|
||||
*out = __casts8f32(in);
|
||||
}
|
||||
|
||||
static inline void casts16f32(register s16 *in,register volatile f32 *out)
|
||||
{
|
||||
*out = __casts16f32(in);
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
/* */
|
||||
/* cast from float to int */
|
||||
/* */
|
||||
/******************************************************************/
|
||||
|
||||
static inline u8 __castf32u8(register f32 in)
|
||||
{
|
||||
f32 a;
|
||||
register u8 rval;
|
||||
register f32 *ptr = &a;
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"psq_st %[in],0(%[ptr]),1,2\n"
|
||||
"lbz %[out],0(%[ptr])\n"
|
||||
: [out]"=r"(rval), [ptr]"+r"(ptr) : [in]"f"(in)
|
||||
);
|
||||
return rval;
|
||||
}
|
||||
|
||||
static inline u16 __castf32u16(register f32 in)
|
||||
{
|
||||
f32 a;
|
||||
register u16 rval;
|
||||
register f32 *ptr = &a;
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"psq_st %[in],0(%[ptr]),1,3\n"
|
||||
"lhz %[out],0(%[ptr])\n"
|
||||
: [out]"=r"(rval), [ptr]"+r"(ptr) : [in]"f"(in)
|
||||
);
|
||||
return rval;
|
||||
}
|
||||
|
||||
static inline s8 __castf32s8(register f32 in)
|
||||
{
|
||||
f32 a;
|
||||
register s8 rval;
|
||||
register f32 *ptr = &a;
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"psq_st %[in],0(%[ptr]),1,4\n"
|
||||
"lbz %[out],0(%[ptr])\n"
|
||||
: [out]"=r"(rval), [ptr]"+r"(ptr) : [in]"f"(in)
|
||||
);
|
||||
return rval;
|
||||
}
|
||||
|
||||
static inline s16 __castf32s16(register f32 in)
|
||||
{
|
||||
f32 a;
|
||||
register s16 rval;
|
||||
register f32 *ptr = &a;
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"psq_st %[in],0(%[ptr]),1,5\n"
|
||||
"lha %[out],0(%[ptr])\n"
|
||||
: [out]"=r"(rval), [ptr]"+r"(ptr) : [in]"f"(in)
|
||||
);
|
||||
return rval;
|
||||
}
|
||||
|
||||
static inline void castf32u8(register f32 *in,register vu8 *out)
|
||||
{
|
||||
*out = __castf32u8(*in);
|
||||
}
|
||||
|
||||
static inline void castf32u16(register f32 *in,register vu16 *out)
|
||||
{
|
||||
*out = __castf32u16(*in);
|
||||
}
|
||||
|
||||
static inline void castf32s8(register f32 *in,register vs8 *out)
|
||||
{
|
||||
*out = __castf32s8(*in);
|
||||
}
|
||||
|
||||
static inline void castf32s16(register f32 *in,register vs16 *out)
|
||||
{
|
||||
*out = __castf32s16(*in);
|
||||
}
|
||||
|
||||
#endif //GEKKO
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
28
wii/libogc/include/ogc/color.h
Normal file
28
wii/libogc/include/ogc/color.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef __COLOR_H__
|
||||
#define __COLOR_H__
|
||||
|
||||
// luminance is stored twice, thus one of the lum. is
|
||||
// redundant, but this way we can fill the screen.
|
||||
|
||||
#define COLOR_BLACK (0x00800080)
|
||||
#define COLOR_MAROON (0x266A26C0)
|
||||
#define COLOR_GREEN (0x4B554B4A)
|
||||
#define COLOR_OLIVE (0x7140718A)
|
||||
#define COLOR_NAVY (0x0EC00E75)
|
||||
#define COLOR_PURPLE (0x34AA34B5)
|
||||
#define COLOR_TEAL (0x59955940)
|
||||
#define COLOR_GRAY (0x80808080)
|
||||
#define COLOR_SILVER (0xC080C080)
|
||||
#define COLOR_RED (0x4C544CFF)
|
||||
#define COLOR_LIME (0x952B9515)
|
||||
#define COLOR_YELLOW (0xE100E194)
|
||||
#define COLOR_BLUE (0x1DFF1D6B)
|
||||
#define COLOR_FUCHSIA (0x69D469EA)
|
||||
#define COLOR_AQUA (0xB2ABB200)
|
||||
#define COLOR_WHITE (0xFF80FF80)
|
||||
#define COLOR_MONEYGREEN (0xD076D074)
|
||||
#define COLOR_SKYBLUE (0xC399C36A)
|
||||
#define COLOR_CREAM (0xFA79FA82)
|
||||
#define COLOR_MEDGRAY (0xA082A07F)
|
||||
|
||||
#endif /* COLOR_H */
|
115
wii/libogc/include/ogc/cond.h
Normal file
115
wii/libogc/include/ogc/cond.h
Normal file
@ -0,0 +1,115 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
cond.h -- Thread subsystem V
|
||||
|
||||
Copyright (C) 2004
|
||||
Michael Wiedenbauer (shagkur)
|
||||
Dave Murphy (WinterMute)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __COND_H__
|
||||
#define __COND_H__
|
||||
|
||||
/*! \file cond.h
|
||||
\brief Thread subsystem V
|
||||
|
||||
*/
|
||||
|
||||
#include <gctypes.h>
|
||||
#include <time.h>
|
||||
|
||||
#define LWP_COND_NULL 0xffffffff
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*! \typedef u32 cond_t
|
||||
\brief typedef for the condition variable handle
|
||||
*/
|
||||
typedef u32 cond_t;
|
||||
|
||||
|
||||
/*! \fn s32 LWP_CondInit(cond_t *cond)
|
||||
\brief Initialize condition variable
|
||||
\param[out] cond pointer to the cond_t handle
|
||||
|
||||
\return 0 on success, <0 on error
|
||||
*/
|
||||
s32 LWP_CondInit(cond_t *cond);
|
||||
|
||||
|
||||
/*! \fn s32 LWP_CondWait(cond_t cond,mutex_t mutex)
|
||||
\brief Wait on condition variable.
|
||||
\param[in] cond handle to the cond_t structure
|
||||
\param[in] mutex handle to the mutex_t structure
|
||||
|
||||
\return 0 on success, <0 on error
|
||||
*/
|
||||
s32 LWP_CondWait(cond_t cond,mutex_t mutex);
|
||||
|
||||
|
||||
/*! \fn s32 LWP_CondSignal(cond_t cond)
|
||||
\brief Signal a specific thread waiting on this condition variable to wake up.
|
||||
\param[in] cond handle to the cond_t structure
|
||||
|
||||
\return 0 on success, <0 on error
|
||||
*/
|
||||
s32 LWP_CondSignal(cond_t cond);
|
||||
|
||||
|
||||
/*! \fn s32 LWP_CondBroadcast(cond_t cond)
|
||||
\brief Broadcast all threads waiting on this condition variable to wake up.
|
||||
\param[in] cond handle to the cond_t structure
|
||||
|
||||
\return 0 on success, <0 on error
|
||||
*/
|
||||
s32 LWP_CondBroadcast(cond_t cond);
|
||||
|
||||
|
||||
/*! \fn s32 LWP_CondTimedWait(cond_t cond,mutex_t mutex,const struct timespec *abstime)
|
||||
\brief Timed wait on a conditionvariable.
|
||||
\param[in] cond handle to the cond_t structure
|
||||
\param[in] mutex handle to the mutex_t structure
|
||||
\param[in] abstime pointer to a timespec structure holding the abs time for the timeout.
|
||||
|
||||
\return 0 on success, <0 on error
|
||||
*/
|
||||
s32 LWP_CondTimedWait(cond_t cond,mutex_t mutex,const struct timespec *abstime);
|
||||
|
||||
|
||||
/*! \fn s32 LWP_CondDestroy(cond_t cond)
|
||||
\brief Destroy condition variable, release all threads and handles blocked on that condition variable.
|
||||
\param[in] cond handle to the cond_t structure
|
||||
|
||||
\return 0 on success, <0 on error
|
||||
*/
|
||||
s32 LWP_CondDestroy(cond_t cond);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
183
wii/libogc/include/ogc/conf.h
Normal file
183
wii/libogc/include/ogc/conf.h
Normal file
@ -0,0 +1,183 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
conf.h -- SYSCONF support
|
||||
|
||||
Copyright (C) 2008
|
||||
Hector Martin (marcan)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
#ifndef __CONF_H__
|
||||
#define __CONF_H__
|
||||
|
||||
#if defined(HW_RVL)
|
||||
|
||||
#include <gctypes.h>
|
||||
#include <gcutil.h>
|
||||
|
||||
#define CONF_EBADFILE -0x6001
|
||||
#define CONF_ENOENT -0x6002
|
||||
#define CONF_ETOOBIG -0x6003
|
||||
#define CONF_ENOTINIT -0x6004
|
||||
#define CONF_ENOTIMPL -0x6005
|
||||
#define CONF_EBADVALUE -0x6006
|
||||
#define CONF_ENOMEM -0x6007
|
||||
#define CONF_ERR_OK 0
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
enum {
|
||||
CONF_BIGARRAY = 1,
|
||||
CONF_SMALLARRAY,
|
||||
CONF_BYTE,
|
||||
CONF_SHORT,
|
||||
CONF_LONG,
|
||||
CONF_BOOL = 7
|
||||
};
|
||||
|
||||
enum {
|
||||
CONF_VIDEO_NTSC = 0,
|
||||
CONF_VIDEO_PAL,
|
||||
CONF_VIDEO_MPAL
|
||||
};
|
||||
|
||||
enum {
|
||||
CONF_REGION_JP = 0,
|
||||
CONF_REGION_US = 1,
|
||||
CONF_REGION_EU = 2,
|
||||
CONF_REGION_KR = 4,
|
||||
CONF_REGION_CN = 5
|
||||
};
|
||||
|
||||
enum {
|
||||
CONF_AREA_JPN = 0,
|
||||
CONF_AREA_USA,
|
||||
CONF_AREA_EUR,
|
||||
CONF_AREA_AUS,
|
||||
CONF_AREA_BRA,
|
||||
CONF_AREA_TWN,
|
||||
CONF_AREA_ROC,
|
||||
CONF_AREA_KOR,
|
||||
CONF_AREA_HKG,
|
||||
CONF_AREA_ASI,
|
||||
CONF_AREA_LTN,
|
||||
CONF_AREA_SAF,
|
||||
CONF_AREA_CHN
|
||||
};
|
||||
|
||||
enum {
|
||||
CONF_SHUTDOWN_STANDBY = 0,
|
||||
CONF_SHUTDOWN_IDLE
|
||||
};
|
||||
|
||||
enum {
|
||||
CONF_LED_OFF = 0,
|
||||
CONF_LED_DIM,
|
||||
CONF_LED_BRIGHT
|
||||
};
|
||||
|
||||
enum {
|
||||
CONF_SOUND_MONO = 0,
|
||||
CONF_SOUND_STEREO,
|
||||
CONF_SOUND_SURROUND
|
||||
};
|
||||
|
||||
enum {
|
||||
CONF_LANG_JAPANESE = 0,
|
||||
CONF_LANG_ENGLISH,
|
||||
CONF_LANG_GERMAN,
|
||||
CONF_LANG_FRENCH,
|
||||
CONF_LANG_SPANISH,
|
||||
CONF_LANG_ITALIAN,
|
||||
CONF_LANG_DUTCH,
|
||||
CONF_LANG_SIMP_CHINESE,
|
||||
CONF_LANG_TRAD_CHINESE,
|
||||
CONF_LANG_KOREAN
|
||||
};
|
||||
|
||||
enum {
|
||||
CONF_ASPECT_4_3 = 0,
|
||||
CONF_ASPECT_16_9
|
||||
};
|
||||
|
||||
enum {
|
||||
CONF_SENSORBAR_BOTTOM = 0,
|
||||
CONF_SENSORBAR_TOP
|
||||
};
|
||||
|
||||
#define CONF_PAD_MAX_REGISTERED 10
|
||||
#define CONF_PAD_MAX_ACTIVE 4
|
||||
|
||||
typedef struct _conf_pad_device conf_pad_device;
|
||||
|
||||
struct _conf_pad_device {
|
||||
u8 bdaddr[6];
|
||||
char name[0x40];
|
||||
} ATTRIBUTE_PACKED;
|
||||
|
||||
typedef struct _conf_pads conf_pads;
|
||||
|
||||
struct _conf_pads {
|
||||
u8 num_registered;
|
||||
conf_pad_device registered[CONF_PAD_MAX_REGISTERED];
|
||||
conf_pad_device active[CONF_PAD_MAX_ACTIVE];
|
||||
conf_pad_device balance_board;
|
||||
conf_pad_device unknown;
|
||||
} ATTRIBUTE_PACKED;
|
||||
|
||||
s32 CONF_Init(void);
|
||||
s32 CONF_GetLength(const char *name);
|
||||
s32 CONF_GetType(const char *name);
|
||||
s32 CONF_Get(const char *name, void *buffer, u32 length);
|
||||
s32 CONF_GetShutdownMode(void);
|
||||
s32 CONF_GetIdleLedMode(void);
|
||||
s32 CONF_GetProgressiveScan(void);
|
||||
s32 CONF_GetEuRGB60(void);
|
||||
s32 CONF_GetIRSensitivity(void);
|
||||
s32 CONF_GetSensorBarPosition(void);
|
||||
s32 CONF_GetPadSpeakerVolume(void);
|
||||
s32 CONF_GetPadMotorMode(void);
|
||||
s32 CONF_GetSoundMode(void);
|
||||
s32 CONF_GetLanguage(void);
|
||||
s32 CONF_GetCounterBias(u32 *bias);
|
||||
s32 CONF_GetScreenSaverMode(void);
|
||||
s32 CONF_GetDisplayOffsetH(s8 *offset);
|
||||
s32 CONF_GetPadDevices(conf_pads *pads);
|
||||
s32 CONF_GetNickName(u8 *nickname);
|
||||
s32 CONF_GetAspectRatio(void);
|
||||
s32 CONF_GetEULA(void);
|
||||
s32 CONF_GetParentalPassword(s8 *password);
|
||||
s32 CONF_GetParentalAnswer(s8 *answer);
|
||||
s32 CONF_GetWiiConnect24(void);
|
||||
s32 CONF_GetRegion(void);
|
||||
s32 CONF_GetArea(void);
|
||||
s32 CONF_GetVideo(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
81
wii/libogc/include/ogc/consol.h
Normal file
81
wii/libogc/include/ogc/consol.h
Normal file
@ -0,0 +1,81 @@
|
||||
#ifndef __CONSOL_H__
|
||||
#define __CONSOL_H__
|
||||
|
||||
/*!
|
||||
* \file consol.h
|
||||
* \brief Console subsystem
|
||||
*
|
||||
*/
|
||||
|
||||
#include "gx_struct.h"
|
||||
|
||||
/* macros to support old function names */
|
||||
#define console_init CON_Init
|
||||
#define SYS_ConsoleInit CON_InitEx
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* \fn CON_Init(void *framebuffer,int xstart,int ystart,int xres,int yres,int stride)
|
||||
* \brief Initializes the console subsystem with given parameters
|
||||
*
|
||||
* \param[in] framebuffer pointer to the framebuffer used for drawing the characters
|
||||
* \param[in] xstart,ystart start position of the console output in pixel
|
||||
* \param[in] xres,yres size of the console in pixel
|
||||
* \param[in] stride size of one line of the framebuffer in bytes
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void CON_Init(void *framebuffer,int xstart,int ystart,int xres,int yres,int stride);
|
||||
|
||||
/*!
|
||||
* \fn s32 CON_InitEx(GXRModeObj *rmode, s32 conXOrigin,s32 conYOrigin,s32 conWidth,s32 conHeight)
|
||||
* \brief Initialize stdout console
|
||||
* \param[in] rmode pointer to the video/render mode configuration
|
||||
* \param[in] conXOrigin starting pixel in X direction of the console output on the external framebuffer
|
||||
* \param[in] conYOrigin starting pixel in Y direction of the console output on the external framebuffer
|
||||
* \param[in] conWidth width of the console output 'window' to be drawn
|
||||
* \param[in] conHeight height of the console output 'window' to be drawn
|
||||
*
|
||||
* \return 0 on success, <0 on error
|
||||
*/
|
||||
s32 CON_InitEx(GXRModeObj *rmode, s32 conXOrigin,s32 conYOrigin,s32 conWidth,s32 conHeight);
|
||||
|
||||
/*!
|
||||
* \fn CON_GetMetrics(int *cols, int *rows)
|
||||
* \brief retrieve the columns and rows of the current console
|
||||
*
|
||||
* \param[out] cols,rows number of columns and rows of the current console
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void CON_GetMetrics(int *cols, int *rows);
|
||||
|
||||
/*!
|
||||
* \fn CON_GetPosition(int *col, int *row)
|
||||
* \brief retrieve the current cursor position of the current console
|
||||
*
|
||||
* \param[out] col,row current cursor position
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void CON_GetPosition(int *cols, int *rows);
|
||||
|
||||
/*!
|
||||
* \fn CON_EnableGecko(int channel, int safe)
|
||||
* \brief Enable or disable the USB gecko console.
|
||||
*
|
||||
* \param[in] channel EXI channel, or -1 ¨to disable the gecko console
|
||||
* \param[in] safe If true, use safe mode (wait for peer)
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void CON_EnableGecko(int channel,int safe);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
51
wii/libogc/include/ogc/context.h
Normal file
51
wii/libogc/include/ogc/context.h
Normal file
@ -0,0 +1,51 @@
|
||||
#ifndef __EXCONTEXT_H__
|
||||
#define __EXCONTEXT_H__
|
||||
|
||||
#define NUM_EXCEPTIONS 15
|
||||
|
||||
#define EX_SYS_RESET 0
|
||||
#define EX_MACH_CHECK 1
|
||||
#define EX_DSI 2
|
||||
#define EX_ISI 3
|
||||
#define EX_INT 4
|
||||
#define EX_ALIGN 5
|
||||
#define EX_PRG 6
|
||||
#define EX_FP 7
|
||||
#define EX_DEC 8
|
||||
#define EX_SYS_CALL 9
|
||||
#define EX_TRACE 10
|
||||
#define EX_PERF 11
|
||||
#define EX_IABR 12
|
||||
#define EX_RESV 13
|
||||
#define EX_THERM 14
|
||||
|
||||
#ifndef _LANGUAGE_ASSEMBLY
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct _excption_frame {
|
||||
u32 EXCPT_Number;
|
||||
u32 SRR0,SRR1;
|
||||
u32 GPR[32];
|
||||
u32 GQR[8];
|
||||
u32 CR, LR, CTR, XER, MSR, DAR;
|
||||
|
||||
u16 state; //used to determine whether to restore the fpu context or not
|
||||
u16 mode; //unused
|
||||
|
||||
f64 FPR[32];
|
||||
u64 FPSCR;
|
||||
f64 PSFPR[32];
|
||||
} frame_context;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif //!_LANGUAGE_ASSEMBLY
|
||||
|
||||
#endif
|
68
wii/libogc/include/ogc/disc_io.h
Normal file
68
wii/libogc/include/ogc/disc_io.h
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
disc_io.h
|
||||
Interface template for low level disc functions.
|
||||
|
||||
Copyright (c) 2006 Michael "Chishm" Chisholm
|
||||
Based on code originally written by MightyMax
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
3. The name of the author may not be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef OGC_DISC_IO_INCLUDE
|
||||
#define OGC_DISC_IO_INCLUDE
|
||||
|
||||
#include <stdint.h>
|
||||
#include <gctypes.h>
|
||||
|
||||
|
||||
#define FEATURE_MEDIUM_CANREAD 0x00000001
|
||||
#define FEATURE_MEDIUM_CANWRITE 0x00000002
|
||||
#define FEATURE_GAMECUBE_SLOTA 0x00000010
|
||||
#define FEATURE_GAMECUBE_SLOTB 0x00000020
|
||||
#define FEATURE_GAMECUBE_DVD 0x00000040
|
||||
#define FEATURE_WII_SD 0x00000100
|
||||
#define FEATURE_WII_USB 0x00000200
|
||||
#define FEATURE_WII_DVD 0x00000400
|
||||
|
||||
typedef uint32_t sec_t;
|
||||
|
||||
typedef bool (* FN_MEDIUM_STARTUP)(void) ;
|
||||
typedef bool (* FN_MEDIUM_ISINSERTED)(void) ;
|
||||
typedef bool (* FN_MEDIUM_READSECTORS)(sec_t sector, sec_t numSectors, void* buffer) ;
|
||||
typedef bool (* FN_MEDIUM_WRITESECTORS)(sec_t sector, sec_t numSectors, const void* buffer) ;
|
||||
typedef bool (* FN_MEDIUM_CLEARSTATUS)(void) ;
|
||||
typedef bool (* FN_MEDIUM_SHUTDOWN)(void) ;
|
||||
|
||||
struct DISC_INTERFACE_STRUCT {
|
||||
unsigned long ioType ;
|
||||
unsigned long features ;
|
||||
FN_MEDIUM_STARTUP startup ;
|
||||
FN_MEDIUM_ISINSERTED isInserted ;
|
||||
FN_MEDIUM_READSECTORS readSectors ;
|
||||
FN_MEDIUM_WRITESECTORS writeSectors ;
|
||||
FN_MEDIUM_CLEARSTATUS clearStatus ;
|
||||
FN_MEDIUM_SHUTDOWN shutdown ;
|
||||
} ;
|
||||
|
||||
typedef struct DISC_INTERFACE_STRUCT DISC_INTERFACE ;
|
||||
|
||||
#endif // define OGC_DISC_IO_INCLUDE
|
228
wii/libogc/include/ogc/dsp.h
Normal file
228
wii/libogc/include/ogc/dsp.h
Normal file
@ -0,0 +1,228 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
dsp.h -- DSP subsystem
|
||||
|
||||
Copyright (C) 2004
|
||||
Michael Wiedenbauer (shagkur)
|
||||
Dave Murphy (WinterMute)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __DSP_H__
|
||||
#define __DSP_H__
|
||||
|
||||
/*! \file dsp.h
|
||||
\brief DSP subsystem
|
||||
|
||||
*/
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
/*!
|
||||
* \addtogroup dsp_taskstate DSP task states
|
||||
* \brief DSP task state indicating DSP task's current operation
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define DSPTASK_INIT 0 /*!< DSP task is initializing */
|
||||
#define DSPTASK_RUN 1 /*!< DSP task is running */
|
||||
#define DSPTASK_YIELD 2 /*!< DSP task has yield */
|
||||
#define DSPTASK_DONE 3 /*!< DSP task is done/ready */
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
* \addtogroup dsp_taskflag DSP task flags
|
||||
* \brief DSP task queue state flag indicating the task's current queue state. Multiple states are OR'd.
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define DSPTASK_CLEARALL 0x00000000 /*!< DSP task emtpy/ready */
|
||||
#define DSPTASK_ATTACH 0x00000001 /*!< DSP task attached */
|
||||
#define DSPTASK_CANCEL 0x00000002 /*!< DSP task canceled */
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
/*!
|
||||
\typedef struct _dsp_task dsptask_t
|
||||
\brief forward typdef to struct _dsp_task. This struture holds certain DSP task information for execution.
|
||||
*/
|
||||
typedef struct _dsp_task dsptask_t;
|
||||
|
||||
|
||||
/*! \typedef void (*DSPTaskCallback)(dsptask_t *task)
|
||||
\brief function pointer typedef for the user's DSP task callbacks
|
||||
\param[in] task pointer to the dsp_task structure.
|
||||
*/
|
||||
typedef void (*DSPTaskCallback)(dsptask_t *task);
|
||||
|
||||
|
||||
/*! \typedef void (*DSPCallback)(void)
|
||||
\brief function pointer typedef for the user's DSP interrupt callback
|
||||
*/
|
||||
typedef void (*DSPCallback)(void);
|
||||
|
||||
|
||||
/*! \typedef struct _dsp_task dsptask_t
|
||||
\param state current task \ref dsp_taskstate "state" set
|
||||
\param prio priority of the task
|
||||
\param flags currnet task \ref dsp_taskflag "flag(s)" set.
|
||||
\param init_vec initialization vector. depends on the DSP code to execute.
|
||||
\param resume_vec resume vector. depends on the DSP code to execute.
|
||||
\param iram_maddr main memory address of i-ram image. NOTE: Has to be aligned on a 32byte boundery!
|
||||
\param iram_len size of i-ram image. NOTE: Should be a multiple of 32
|
||||
\param iram_addr DSP i-ram address to load the image to.
|
||||
\param dram_maddr main memory address of d-ram image. NOTE: Has to be aligned on a 32byte boundery!
|
||||
\param dram_len size of d-ram image. NOTE: Should be a multiple of 32
|
||||
\param dram_addr DSP d-ram address to load the image to.
|
||||
\param init_cb pointer to the user's init callback function. Called durring task initialization.
|
||||
\param res_cb pointer to the user's resume callback function. Called when the task should resume.
|
||||
\param done_cb pointer to the user's done callback function. Called when the task has finished.
|
||||
\param req_cb pointer to the user's request callback function. Used to retrieve data from main application durring execution.
|
||||
\param next pointer to the next task in the doubly linked list.
|
||||
\param prev pointer to the previous task in the doubly linked list.
|
||||
*/
|
||||
struct _dsp_task {
|
||||
vu32 state;
|
||||
vu32 prio;
|
||||
vu32 flags;
|
||||
|
||||
void *iram_maddr;
|
||||
u32 iram_len;
|
||||
u32 iram_addr;
|
||||
|
||||
void *dram_maddr;
|
||||
u32 dram_len;
|
||||
u32 dram_addr;
|
||||
|
||||
u16 init_vec;
|
||||
u16 resume_vec;
|
||||
|
||||
DSPTaskCallback init_cb;
|
||||
DSPTaskCallback res_cb;
|
||||
DSPTaskCallback done_cb;
|
||||
DSPTaskCallback req_cb;
|
||||
|
||||
struct _dsp_task *next;
|
||||
struct _dsp_task *prev;
|
||||
};
|
||||
|
||||
|
||||
/*! \fn void DSP_Init()
|
||||
\brief Initialize DSP subsystem.
|
||||
|
||||
\return none
|
||||
*/
|
||||
void DSP_Init();
|
||||
|
||||
|
||||
/*! \fn u32 DSP_CheckMailTo()
|
||||
\brief Check if mail was sent to DSP
|
||||
|
||||
\return 1: mail sent, 0: mail on route
|
||||
*/
|
||||
u32 DSP_CheckMailTo();
|
||||
|
||||
|
||||
/*! \fn u32 DSP_CheckMailFrom()
|
||||
\brief Check for mail from DSP
|
||||
|
||||
\return 1: has mail, 0: no mail
|
||||
*/
|
||||
u32 DSP_CheckMailFrom();
|
||||
|
||||
|
||||
/*! \fn u32 DSP_ReadMailFrom()
|
||||
\brief Read mail from DSP
|
||||
|
||||
\return mail value received
|
||||
*/
|
||||
u32 DSP_ReadMailFrom();
|
||||
|
||||
|
||||
/*! \fn void DSP_AssertInt()
|
||||
\brief Asserts the processor interface interrupt
|
||||
|
||||
\return none
|
||||
*/
|
||||
void DSP_AssertInt();
|
||||
|
||||
|
||||
/*! \fn void DSP_SendMailTo(u32 mail)
|
||||
\brief Send mail to DSP
|
||||
\param[in] mail value to send
|
||||
|
||||
\return none
|
||||
*/
|
||||
void DSP_SendMailTo(u32 mail);
|
||||
|
||||
|
||||
/*! \fn u32 DSP_ReadCPUtoDSP()
|
||||
\brief Read back CPU->DSP mailbox
|
||||
|
||||
\return mail value received
|
||||
*/
|
||||
u32 DSP_ReadCPUtoDSP();
|
||||
|
||||
|
||||
/*! \fn dsptask_t* DSP_AddTask(dsptask_t *task)
|
||||
\brief Add a DSP task to the tasklist and start executing if necessary.
|
||||
\param[in] task pointer to a dsptask_t structure which holds all necessary values for DSP task execution.
|
||||
|
||||
\return current task
|
||||
*/
|
||||
dsptask_t* DSP_AddTask(dsptask_t *task);
|
||||
|
||||
dsptask_t* DSP_AssertTask(dsptask_t *task);
|
||||
|
||||
void DSP_CancelTask(dsptask_t *task);
|
||||
|
||||
void DSP_Reset();
|
||||
|
||||
void DSP_Halt();
|
||||
|
||||
void DSP_Unhalt();
|
||||
|
||||
/*! \fn DSPCallback DSP_RegisterCallback(DSPCallback usr_cb)
|
||||
\brief Register an user's interrupt callback. This may be used to handle DSP interrupts on its own. By default a system default callback is installed on DSP_Init().
|
||||
\param[in] user_cb pointer to the user's interrupt callback function.
|
||||
\
|
||||
\return pointer to old interrupt callback function.
|
||||
*/
|
||||
DSPCallback DSP_RegisterCallback(DSPCallback usr_cb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
369
wii/libogc/include/ogc/dvd.h
Normal file
369
wii/libogc/include/ogc/dvd.h
Normal file
@ -0,0 +1,369 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
dvd.h -- DVD subsystem
|
||||
|
||||
Copyright (C) 2004
|
||||
Michael Wiedenbauer (shagkur)
|
||||
Dave Murphy (WinterMute)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __DVD_H__
|
||||
#define __DVD_H__
|
||||
|
||||
/*!
|
||||
* \file dvd.h
|
||||
* \brief DVD subsystem
|
||||
*
|
||||
*/
|
||||
|
||||
#include <gctypes.h>
|
||||
#include <ogc/lwp_queue.h>
|
||||
#include <ogc/disc_io.h>
|
||||
|
||||
/*!
|
||||
* \addtogroup dvd_statecodes DVD state codes
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define DVD_STATE_FATAL_ERROR -1
|
||||
#define DVD_STATE_END 0
|
||||
#define DVD_STATE_BUSY 1
|
||||
#define DVD_STATE_WAITING 2
|
||||
#define DVD_STATE_COVER_CLOSED 3
|
||||
#define DVD_STATE_NO_DISK 4
|
||||
#define DVD_STATE_COVER_OPEN 5
|
||||
#define DVD_STATE_WRONG_DISK 6
|
||||
#define DVD_STATE_MOTOR_STOPPED 7
|
||||
#define DVD_STATE_IGNORED 8
|
||||
#define DVD_STATE_CANCELED 10
|
||||
#define DVD_STATE_RETRY 11
|
||||
|
||||
#define DVD_ERROR_OK 0
|
||||
#define DVD_ERROR_FATAL -1
|
||||
#define DVD_ERROR_IGNORED -2
|
||||
#define DVD_ERROR_CANCELED -3
|
||||
#define DVD_ERROR_COVER_CLOSED -4
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
* \addtogroup dvd_resetmode DVD reset modes
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define DVD_RESETHARD 0 /*!< Performs a hard reset. Complete new boot of FW. */
|
||||
#define DVD_RESETSOFT 1 /*!< Performs a soft reset. FW restart and drive spinup */
|
||||
#define DVD_RESETNONE 2 /*!< Only initiate DI registers */
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
* \addtogroup dvd_motorctrlmode DVD motor control modes
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define DVD_SPINMOTOR_DOWN 0x00000000 /*!< Stop DVD drive */
|
||||
#define DVD_SPINMOTOR_UP 0x00000100 /*!< Start DVD drive */
|
||||
#define DVD_SPINMOTOR_ACCEPT 0x00004000 /*!< Force DVD to accept the disk */
|
||||
#define DVD_SPINMOTOR_CHECKDISK 0x00008000 /*!< Force DVD to perform a disc check */
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
/*!
|
||||
* \typedef struct _dvddiskid dvddiskid
|
||||
* \brief forward typedef for struct _dvddiskid
|
||||
*/
|
||||
typedef struct _dvddiskid dvddiskid;
|
||||
|
||||
/*!
|
||||
* \typedef struct _dvddiskid dvddiskid
|
||||
*
|
||||
* This structure holds the game vendors copyright informations.<br>
|
||||
* Additionally it holds certain parameters for audiocontrol and<br>
|
||||
* multidisc support.
|
||||
*
|
||||
* \param gamename[4] vendors game key
|
||||
* \param company[2] vendors company key
|
||||
* \param disknum number of disc when multidisc support is used.
|
||||
* \param gamever version of game
|
||||
* \param streaming flag to control audio streaming
|
||||
* \param streambufsize size of buffer used for audio streaming
|
||||
* \param pad[22] padding
|
||||
*/
|
||||
struct _dvddiskid {
|
||||
s8 gamename[4];
|
||||
s8 company[2];
|
||||
u8 disknum;
|
||||
u8 gamever;
|
||||
u8 streaming;
|
||||
u8 streambufsize;
|
||||
u8 pad[22];
|
||||
};
|
||||
|
||||
/*!
|
||||
* \typedef struct _dvdcmdblk dvdcmdblk
|
||||
* \brief forward typedef for struct _dvdcmdblk
|
||||
*/
|
||||
typedef struct _dvdcmdblk dvdcmdblk;
|
||||
|
||||
|
||||
/*!
|
||||
* \typedef void (*dvdcbcallback)(s32 result,dvdcmdblk *block)
|
||||
* \brief function pointer typedef for the user's operations callback
|
||||
*/
|
||||
typedef void (*dvdcbcallback)(s32 result,dvdcmdblk *block);
|
||||
|
||||
|
||||
/*!
|
||||
* \typedef struct _dvdcmdblk dvdcmdblk
|
||||
*
|
||||
* This structure is used internally to control the requested operation.
|
||||
*/
|
||||
struct _dvdcmdblk {
|
||||
lwp_node node;
|
||||
u32 cmd;
|
||||
s32 state;
|
||||
s64 offset;
|
||||
u32 len;
|
||||
void *buf;
|
||||
u32 currtxsize;
|
||||
u32 txdsize;
|
||||
dvddiskid *id;
|
||||
dvdcbcallback cb;
|
||||
void *usrdata;
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
* \typedef struct _dvddrvinfo dvddrvinfo
|
||||
* \brief forward typedef for struct _dvddrvinfo
|
||||
*/
|
||||
typedef struct _dvddrvinfo dvddrvinfo;
|
||||
|
||||
|
||||
/*!
|
||||
* \typedef struct _dvddrvinfo dvddrvinfo
|
||||
*
|
||||
* This structure structure holds the drive version infromation.<br>
|
||||
* Use DVD_Inquiry() to retrieve this information.
|
||||
*
|
||||
* \param rev_leve revision level
|
||||
* \param dev_code device code
|
||||
* \param rel_date release date
|
||||
* \param pad[24] padding
|
||||
*/
|
||||
struct _dvddrvinfo {
|
||||
u16 rev_level;
|
||||
u16 dev_code;
|
||||
u32 rel_date;
|
||||
u8 pad[24];
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
* \typedef struct _dvdfileinfo dvdfileinfo
|
||||
* \brief forward typedef for struct _dvdfileinfo
|
||||
*/
|
||||
typedef struct _dvdfileinfo dvdfileinfo;
|
||||
|
||||
|
||||
/*!
|
||||
* \typedef void (*dvdcallback)(s32 result,dvdfileinfo *info)
|
||||
* \brief function pointer typedef for the user's DVD operation callback
|
||||
*
|
||||
* \param[in] result error code of last operation
|
||||
* \param[in] info pointer to user's file info strucutre
|
||||
*/
|
||||
typedef void (*dvdcallback)(s32 result,dvdfileinfo *info);
|
||||
|
||||
|
||||
/*!
|
||||
* \typedef struct _dvdfileinfo dvdfileinfo
|
||||
*
|
||||
* This structure is used internally to control the requested file operation.
|
||||
*/
|
||||
struct _dvdfileinfo {
|
||||
dvdcmdblk block;
|
||||
u32 addr;
|
||||
u32 len;
|
||||
dvdcallback cb;
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void DVD_Init()
|
||||
* \brief Initializes the DVD subsystem
|
||||
*
|
||||
* You must call this function before calling any other DVD function
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void DVD_Init();
|
||||
void DVD_Pause();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void DVD_Reset(u32 reset_mode)
|
||||
* \brief Performs a reset of the drive and FW respectively.
|
||||
*
|
||||
* \param[in] reset_mode \ref dvd_resetmode "type" of reset
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void DVD_Reset(u32 reset_mode);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn s32 DVD_Mount()
|
||||
* \brief Mounts the DVD drive.
|
||||
*
|
||||
* This is a synchronous version of DVD_MountAsync().
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
s32 DVD_Mount();
|
||||
s32 DVD_GetDriveStatus();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn s32 DVD_MountAsync(dvdcmdblk *block,dvdcbcallback cb)
|
||||
* \brief Mounts the DVD drive.
|
||||
*
|
||||
* You <b>must</b> call this function in order to access the DVD.
|
||||
*
|
||||
* Following tasks are performed:
|
||||
* - Issue a hard reset to the drive.
|
||||
* - Turn on drive's debug mode.
|
||||
* - Patch drive's FW.
|
||||
* - Enable extensions.
|
||||
* - Read disc ID
|
||||
*
|
||||
* The patch code and procedure was taken from the gc-linux DVD device driver.
|
||||
*
|
||||
* \param[in] block pointer to a dvdcmdblk structure used to process the operation
|
||||
* \param[in] cb callback to be invoked upon completion of operation
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
s32 DVD_MountAsync(dvdcmdblk *block,dvdcbcallback cb);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn s32 DVD_ControlDrive(dvdcmdblk *block,u32 cmd)
|
||||
* \brief Controls the drive's motor and behavior.
|
||||
*
|
||||
* This is a synchronous version of DVD_ControlDriveAsync().
|
||||
*
|
||||
* \param[in] block pointer to a dvdcmdblk structure used to process the operation
|
||||
* \param[in] cmd \ref dvd_motorctrlmode "command" to control the drive.
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
s32 DVD_ControlDrive(dvdcmdblk *block,u32 cmd);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn s32 DVD_ControlDriveAsync(dvdcmdblk *block,u32 cmd,dvdcbcallback cb)
|
||||
* \brief Controls the drive's motor and behavior.
|
||||
*
|
||||
* \param[in] block pointer to a dvdcmdblk structure used to process the operation
|
||||
* \param[in] cmd \ref dvd_motorctrlmode "command" to control the drive.
|
||||
* \param[in] cb callback to be invoked upon completion of operation.
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
s32 DVD_ControlDriveAsync(dvdcmdblk *block,u32 cmd,dvdcbcallback cb);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn s32 DVD_SetGCMOffset(dvdcmdblk *block,u32 offset)
|
||||
* \brief Sets the offset to the GCM. Used for multigame discs.
|
||||
*
|
||||
* This is a synchronous version of DVD_SetGCMOffsetAsync().
|
||||
*
|
||||
* \param[in] block pointer to a dvdcmdblk structure used to process the operation
|
||||
* \param[in] offset offset to the GCM on disc.
|
||||
*
|
||||
* \return \ref dvd_errorcodes "dvd error code"
|
||||
*/
|
||||
s32 DVD_SetGCMOffset(dvdcmdblk *block,s64 offset);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn s32 DVD_SetGCMOffsetAsync(dvdcmdblk *block,u32 offset,dvdcbcallback cb)
|
||||
* \brief Sets the offset to the GCM. Used for multigame discs.
|
||||
*
|
||||
* This is a synchronous version of DVD_SetGCMOffsetAsync().
|
||||
*
|
||||
* \param[in] block pointer to a dvdcmdblk structure used to process the operation
|
||||
* \param[in] offset offset to the GCM on disc.
|
||||
* \param[in] cb callback to be invoked upon completion of operation.
|
||||
*
|
||||
* \return \ref dvd_errorcodes "dvd error code"
|
||||
*/
|
||||
s32 DVD_SetGCMOffsetAsync(dvdcmdblk *block,s64 offset,dvdcbcallback cb);
|
||||
|
||||
s32 DVD_GetCmdBlockStatus(dvdcmdblk *block);
|
||||
s32 DVD_SpinUpDrive(dvdcmdblk *block);
|
||||
s32 DVD_SpinUpDriveAsync(dvdcmdblk *block,dvdcbcallback cb);
|
||||
s32 DVD_Inquiry(dvdcmdblk *block,dvddrvinfo *info);
|
||||
s32 DVD_InquiryAsync(dvdcmdblk *block,dvddrvinfo *info,dvdcbcallback cb);
|
||||
s32 DVD_ReadPrio(dvdcmdblk *block,void *buf,u32 len,s64 offset,s32 prio);
|
||||
s32 DVD_ReadAbsAsyncPrio(dvdcmdblk *block,void *buf,u32 len,s64 offset,dvdcbcallback cb,s32 prio);
|
||||
s32 DVD_ReadAbsAsyncForBS(dvdcmdblk *block,void *buf,u32 len,s64 offset,dvdcbcallback cb);
|
||||
s32 DVD_SeekPrio(dvdcmdblk *block,s64 offset,s32 prio);
|
||||
s32 DVD_SeekAbsAsyncPrio(dvdcmdblk *block,s64 offset,dvdcbcallback cb,s32 prio);
|
||||
s32 DVD_CancelAllAsync(dvdcbcallback cb);
|
||||
s32 DVD_StopStreamAtEndAsync(dvdcmdblk *block,dvdcbcallback cb);
|
||||
s32 DVD_StopStreamAtEnd(dvdcmdblk *block);
|
||||
s32 DVD_ReadDiskID(dvdcmdblk *block,dvddiskid *id,dvdcbcallback cb);
|
||||
u32 DVD_SetAutoInvalidation(u32 auto_inv);
|
||||
dvddiskid* DVD_GetCurrentDiskID();
|
||||
dvddrvinfo* DVD_GetDriveInfo();
|
||||
|
||||
#define DVD_SetUserData(block, data) ((block)->usrdata = (data))
|
||||
#define DVD_GetUserData(block) ((block)->usrdata)
|
||||
|
||||
#define DEVICE_TYPE_GAMECUBE_DVD (('G'<<24)|('D'<<16)|('V'<<8)|'D')
|
||||
extern const DISC_INTERFACE __io_gcdvd;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
309
wii/libogc/include/ogc/es.h
Normal file
309
wii/libogc/include/ogc/es.h
Normal file
@ -0,0 +1,309 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
es.h -- tik services
|
||||
|
||||
Copyright (C) 2008
|
||||
Michael Wiedenbauer (shagkur)
|
||||
Dave Murphy (WinterMute)
|
||||
Hector Martin (marcan)
|
||||
Andre Heider (dhewg)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
#ifndef __ES_H__
|
||||
#define __ES_H__
|
||||
|
||||
#if defined(HW_RVL)
|
||||
|
||||
#include <gctypes.h>
|
||||
#include <gcutil.h>
|
||||
|
||||
#define ES_EINVAL -0x1004
|
||||
#define ES_ENOMEM -0x100C
|
||||
#define ES_ENOTINIT -0x1100
|
||||
#define ES_EALIGN -0x1101
|
||||
|
||||
#define ES_SIG_RSA4096 0x10000
|
||||
#define ES_SIG_RSA2048 0x10001
|
||||
#define ES_SIG_ECDSA 0x10002
|
||||
|
||||
#define ES_CERT_RSA4096 0
|
||||
#define ES_CERT_RSA2048 1
|
||||
#define ES_CERT_ECDSA 2
|
||||
|
||||
#define ES_KEY_COMMON 4
|
||||
#define ES_KEY_SDCARD 6
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef u32 sigtype;
|
||||
typedef sigtype sig_header;
|
||||
typedef sig_header signed_blob;
|
||||
|
||||
typedef u8 sha1[20];
|
||||
typedef u8 aeskey[16];
|
||||
|
||||
typedef struct _sig_rsa2048 {
|
||||
sigtype type;
|
||||
u8 sig[256];
|
||||
u8 fill[60];
|
||||
} __attribute__((packed)) sig_rsa2048;
|
||||
|
||||
typedef struct _sig_rsa4096 {
|
||||
sigtype type;
|
||||
u8 sig[512];
|
||||
u8 fill[60];
|
||||
} __attribute__((packed)) sig_rsa4096;
|
||||
|
||||
typedef struct _sig_ecdsa {
|
||||
sigtype type;
|
||||
u8 sig[60];
|
||||
u8 fill[64];
|
||||
} __attribute__((packed)) sig_ecdsa;
|
||||
|
||||
typedef char sig_issuer[0x40];
|
||||
|
||||
typedef struct _tiklimit {
|
||||
u32 tag;
|
||||
u32 value;
|
||||
} __attribute__((packed)) tiklimit;
|
||||
|
||||
typedef struct _tikview {
|
||||
u32 view;
|
||||
u64 ticketid;
|
||||
u32 devicetype;
|
||||
u64 titleid;
|
||||
u16 access_mask;
|
||||
u8 reserved[0x3c];
|
||||
u8 cidx_mask[0x40];
|
||||
u16 padding;
|
||||
tiklimit limits[8];
|
||||
} __attribute__((packed)) tikview;
|
||||
|
||||
typedef struct _tik {
|
||||
sig_issuer issuer;
|
||||
u8 fill[63]; //TODO: not really fill
|
||||
aeskey cipher_title_key;
|
||||
u8 fill2;
|
||||
u64 ticketid;
|
||||
u32 devicetype;
|
||||
u64 titleid;
|
||||
u16 access_mask;
|
||||
u8 reserved[0x3c];
|
||||
u8 cidx_mask[0x40];
|
||||
u16 padding;
|
||||
tiklimit limits[8];
|
||||
} __attribute__((packed)) tik;
|
||||
|
||||
typedef struct _tmd_content {
|
||||
u32 cid;
|
||||
u16 index;
|
||||
u16 type;
|
||||
u64 size;
|
||||
sha1 hash;
|
||||
} __attribute__((packed)) tmd_content;
|
||||
|
||||
typedef struct _tmd {
|
||||
sig_issuer issuer; //0x140
|
||||
u8 version; //0x180
|
||||
u8 ca_crl_version; //0x181
|
||||
u8 signer_crl_version; //0x182
|
||||
u8 fill2; //0x183
|
||||
u64 sys_version; //0x184
|
||||
u64 title_id; //0x18c
|
||||
u32 title_type; //0x194
|
||||
u16 group_id; //0x198
|
||||
u16 zero; //0x19a
|
||||
u16 region; //0x19c
|
||||
u8 ratings[16]; //0x19e
|
||||
u8 reserved[12]; //0x1ae
|
||||
u8 ipc_mask[12];
|
||||
u8 reserved2[18];
|
||||
u32 access_rights;
|
||||
u16 title_version;
|
||||
u16 num_contents;
|
||||
u16 boot_index;
|
||||
u16 fill3;
|
||||
// content records follow
|
||||
// C99 flexible array
|
||||
tmd_content contents[];
|
||||
} __attribute__((packed)) tmd;
|
||||
|
||||
typedef struct _tmd_view_content
|
||||
{
|
||||
u32 cid;
|
||||
u16 index;
|
||||
u16 type;
|
||||
u64 size;
|
||||
} __attribute__((packed)) tmd_view_content;
|
||||
|
||||
typedef struct _tmdview
|
||||
{
|
||||
u8 version; // 0x0000;
|
||||
u8 filler[3];
|
||||
u64 sys_version; //0x0004
|
||||
u64 title_id; // 0x00c
|
||||
u32 title_type; //0x0014
|
||||
u16 group_id; //0x0018
|
||||
u8 reserved[0x3e]; //0x001a this is the same reserved 0x3e bytes from the tmd
|
||||
u16 title_version; //0x0058
|
||||
u16 num_contents; //0x005a
|
||||
tmd_view_content contents[]; //0x005c
|
||||
}__attribute__((packed)) tmd_view;
|
||||
|
||||
typedef struct _cert_header {
|
||||
sig_issuer issuer;
|
||||
u32 cert_type;
|
||||
char cert_name[64];
|
||||
u32 cert_id; //???
|
||||
} __attribute__((packed)) cert_header;
|
||||
|
||||
typedef struct _cert_rsa2048 {
|
||||
sig_issuer issuer;
|
||||
u32 cert_type;
|
||||
char cert_name[64];
|
||||
u32 cert_id;
|
||||
u8 modulus[256];
|
||||
u32 exponent;
|
||||
u8 pad[0x34];
|
||||
} __attribute__((packed)) cert_rsa2048;
|
||||
|
||||
typedef struct _cert_rsa4096 {
|
||||
sig_issuer issuer;
|
||||
u32 cert_type;
|
||||
char cert_name[64];
|
||||
u32 cert_id;
|
||||
u8 modulus[512];
|
||||
u32 exponent;
|
||||
u8 pad[0x34];
|
||||
} __attribute__((packed)) cert_rsa4096;
|
||||
|
||||
typedef struct _cert_ecdsa {
|
||||
sig_issuer issuer;
|
||||
u32 cert_type;
|
||||
char cert_name[64];
|
||||
u32 cert_id; // ng key id
|
||||
u8 r[30];
|
||||
u8 s[30];
|
||||
u8 pad[0x3c];
|
||||
} __attribute__((packed)) cert_ecdsa;
|
||||
|
||||
#define TMD_SIZE(x) (((x)->num_contents)*sizeof(tmd_content) + sizeof(tmd))
|
||||
// backwards compatibility
|
||||
#define TMD_CONTENTS(x) ((x)->contents)
|
||||
|
||||
//TODO: add ECC stuff
|
||||
|
||||
#define IS_VALID_SIGNATURE(x) ( \
|
||||
((*(x))==ES_SIG_RSA2048) || \
|
||||
((*(x))==ES_SIG_RSA4096) || \
|
||||
((*(x))==ES_SIG_ECDSA))
|
||||
|
||||
#define SIGNATURE_SIZE(x) (\
|
||||
((*(x))==ES_SIG_RSA2048) ? sizeof(sig_rsa2048) : ( \
|
||||
((*(x))==ES_SIG_RSA4096) ? sizeof(sig_rsa4096) : ( \
|
||||
((*(x))==ES_SIG_ECDSA) ? sizeof(sig_ecdsa) : 0 )))
|
||||
|
||||
#define SIGNATURE_SIG(x) (((u8*)x)+4)
|
||||
|
||||
#define IS_VALID_CERT(x) ( \
|
||||
(((x)->cert_type)==ES_CERT_RSA2048) || \
|
||||
(((x)->cert_type)==ES_CERT_RSA4096) || \
|
||||
(((x)->cert_type)==ES_CERT_ECDSA))
|
||||
|
||||
#define CERTIFICATE_SIZE(x) (\
|
||||
(((x)->cert_type)==ES_CERT_RSA2048) ? sizeof(cert_rsa2048) : ( \
|
||||
(((x)->cert_type)==ES_CERT_RSA4096) ? sizeof(cert_rsa4096) : ( \
|
||||
(((x)->cert_type)==ES_CERT_ECDSA) ? sizeof(cert_ecdsa) : 0 )))
|
||||
|
||||
#define SIGNATURE_PAYLOAD(x) ((void *)(((u8*)(x)) + SIGNATURE_SIZE(x)))
|
||||
|
||||
#define SIGNED_TMD_SIZE(x) ( TMD_SIZE((tmd*)SIGNATURE_PAYLOAD(x)) + SIGNATURE_SIZE(x))
|
||||
#define SIGNED_TIK_SIZE(x) ( sizeof(tik) + SIGNATURE_SIZE(x) )
|
||||
#define SIGNED_CERT_SIZE(x) ( CERTIFICATE_SIZE((cert_header*)SIGNATURE_PAYLOAD(x)) + SIGNATURE_SIZE(x))
|
||||
|
||||
#define STD_SIGNED_TIK_SIZE ( sizeof(tik) + sizeof(sig_rsa2048) )
|
||||
|
||||
#define MAX_NUM_TMD_CONTENTS 512
|
||||
|
||||
#define MAX_TMD_SIZE ( sizeof(tmd) + MAX_NUM_TMD_CONTENTS*sizeof(tmd_content) )
|
||||
#define MAX_SIGNED_TMD_SIZE ( MAX_TMD_SIZE + sizeof(sig_rsa2048) )
|
||||
|
||||
s32 __ES_Init(void);
|
||||
s32 __ES_Close(void);
|
||||
s32 __ES_Reset(void);
|
||||
s32 ES_GetTitleID(u64 *titleID);
|
||||
s32 ES_SetUID(u64 uid);
|
||||
s32 ES_GetDataDir(u64 titleID, char *filepath);
|
||||
s32 ES_GetNumTicketViews(u64 titleID, u32 *cnt);
|
||||
s32 ES_GetTicketViews(u64 titleID, tikview *views, u32 cnt);
|
||||
s32 ES_GetNumOwnedTitles(u32 *cnt);
|
||||
s32 ES_GetOwnedTitles(u64 *titles, u32 cnt);
|
||||
s32 ES_GetNumTitles(u32 *cnt);
|
||||
s32 ES_GetTitles(u64 *titles, u32 cnt);
|
||||
s32 ES_GetNumStoredTMDContents(const signed_blob *stmd, u32 tmd_size, u32 *cnt);
|
||||
s32 ES_GetStoredTMDContents(const signed_blob *stmd, u32 tmd_size, u32 *contents, u32 cnt);
|
||||
s32 ES_GetStoredTMDSize(u64 titleID, u32 *size);
|
||||
s32 ES_GetStoredTMD(u64 titleID, signed_blob *stmd, u32 size);
|
||||
s32 ES_GetTitleContentsCount(u64 titleID, u32 *num);
|
||||
s32 ES_GetTitleContents(u64 titleID, u8 *data, u32 size);
|
||||
s32 ES_GetTMDViewSize(u64 titleID, u32 *size);
|
||||
s32 ES_GetTMDView(u64 titleID, u8 *data, u32 size);
|
||||
s32 ES_GetNumSharedContents(u32 *cnt);
|
||||
s32 ES_GetSharedContents(sha1 *contents, u32 cnt);
|
||||
s32 ES_LaunchTitle(u64 titleID, const tikview *view);
|
||||
s32 ES_LaunchTitleBackground(u64 titleID, const tikview *view);
|
||||
s32 ES_Identify(const signed_blob *certificates, u32 certificates_size, const signed_blob *tmd, u32 tmd_size, const signed_blob *ticket, u32 ticket_size, u32 *keyid);
|
||||
s32 ES_AddTicket(const signed_blob *tik, u32 tik_size, const signed_blob *certificates, u32 certificates_size, const signed_blob *crl, u32 crl_size);
|
||||
s32 ES_DeleteTicket(const tikview *view);
|
||||
s32 ES_AddTitleTMD(const signed_blob *tmd, u32 tmd_size);
|
||||
s32 ES_AddTitleStart(const signed_blob *tmd, u32 tmd_size, const signed_blob *certificatess, u32 certificatess_size, const signed_blob *crl, u32 crl_size);
|
||||
s32 ES_AddContentStart(u64 titleID, u32 cid);
|
||||
s32 ES_AddContentData(s32 cid, u8 *data, u32 data_size);
|
||||
s32 ES_AddContentFinish(u32 cid);
|
||||
s32 ES_AddTitleFinish(void);
|
||||
s32 ES_AddTitleCancel(void);
|
||||
s32 ES_ImportBoot(const signed_blob *tik, u32 tik_size,const signed_blob *tik_certs, u32 tik_certs_size,const signed_blob *tmd, u32 tmd_size,const signed_blob *tmd_certs, u32 tmd_certs_size,const u8 *content, u32 content_size);
|
||||
s32 ES_OpenContent(u16 index);
|
||||
s32 ES_OpenTitleContent(u64 titleID, tikview *views, u16 index);
|
||||
s32 ES_ReadContent(s32 cfd, u8 *data, u32 data_size);
|
||||
s32 ES_SeekContent(s32 cfd, s32 where, s32 whence);
|
||||
s32 ES_CloseContent(s32 cfd);
|
||||
s32 ES_DeleteTitle(u64 titleID);
|
||||
s32 ES_DeleteTitleContent(u64 titleID);
|
||||
s32 ES_Encrypt(u32 keynum, u8 *iv, u8 *source, u32 size, u8 *dest);
|
||||
s32 ES_Decrypt(u32 keynum, u8 *iv, u8 *source, u32 size, u8 *dest);
|
||||
s32 ES_Sign(u8 *source, u32 size, u8 *sig, u8 *certs);
|
||||
s32 ES_GetDeviceCert(u8 *outbuf);
|
||||
s32 ES_GetDeviceID(u32 *device_id);
|
||||
s32 ES_GetBoot2Version(u32 *version);
|
||||
signed_blob *ES_NextCert(const signed_blob *certs);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* defined(HW_RVL) */
|
||||
|
||||
#endif
|
325
wii/libogc/include/ogc/exi.h
Normal file
325
wii/libogc/include/ogc/exi.h
Normal file
@ -0,0 +1,325 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
exi.h -- EXI subsystem
|
||||
|
||||
Copyright (C) 2004
|
||||
Michael Wiedenbauer (shagkur)
|
||||
Dave Murphy (WinterMute)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __EXI_H__
|
||||
#define __EXI_H__
|
||||
|
||||
/*!
|
||||
\file exi.h
|
||||
\brief EXI subsystem
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "gctypes.h"
|
||||
|
||||
/*!
|
||||
* \addtogroup exi_tx_mode EXI tranfer types
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define EXI_READ 0 /*!< EXI transfer type read */
|
||||
#define EXI_WRITE 1 /*!< EXI transfer type write */
|
||||
#define EXI_READWRITE 2 /*!< EXI transfer type read-write */
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
* \addtogroup exi_channels EXI channels
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define EXI_CHANNEL_0 0 /*!< EXI channel 0 (memory card slot A) */
|
||||
#define EXI_CHANNEL_1 1 /*!< EXI channel 1 (memory card slot B) */
|
||||
#define EXI_CHANNEL_2 2 /*!< EXI channel 2 (other EXI devices connected, e.g. BBA) */
|
||||
#define EXI_CHANNEL_MAX 3 /*!< _Termination */
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
* \addtogroup exi_devices EXI devices
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define EXI_DEVICE_0 0 /*!< EXI device 0 */
|
||||
#define EXI_DEVICE_1 1 /*!< EXI device 1 */
|
||||
#define EXI_DEVICE_2 2 /*!< EXI device 2 */
|
||||
#define EXI_DEVICE_MAX 3 /*!< _Termination */
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
* \addtogroup exi_speed EXI device frequencies
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define EXI_SPEED1MHZ 0 /*!< EXI device frequency 1MHz */
|
||||
#define EXI_SPEED2MHZ 1 /*!< EXI device frequency 2MHz */
|
||||
#define EXI_SPEED4MHZ 2 /*!< EXI device frequency 4MHz */
|
||||
#define EXI_SPEED8MHZ 3 /*!< EXI device frequency 8MHz */
|
||||
#define EXI_SPEED16MHZ 4 /*!< EXI device frequency 16MHz */
|
||||
#define EXI_SPEED32MHZ 5 /*!< EXI device frequency 32MHz */
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
* \addtogroup exi_flags EXI device operation flags
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define EXI_FLAG_DMA 0x0001 /*!< EXI DMA mode transfer in progress */
|
||||
#define EXI_FLAG_IMM 0x0002 /*!< EXI immediate mode transfer in progress */
|
||||
#define EXI_FLAG_SELECT 0x0004 /*!< EXI channel and device selected */
|
||||
#define EXI_FLAG_ATTACH 0x0008 /*!< EXI device on selected channel and device attached */
|
||||
#define EXI_FLAG_LOCKED 0x0010 /*!< EXI channel and device locked for device operations */
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
* \addtogroup exi_mcident EXI memory card identifier
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define EXI_MEMCARD59 0x00000004 /*!< Nintendo memory card: 64/ 4/ 0.5 (blocks/Mbits/MB). 3rd party vendors do have the same identification */
|
||||
#define EXI_MEMCARD123 0x00000008 /*!< Nintendo memory card: 128/ 8/ 1.0 (blocks/Mbits/MB). 3rd party vendors do have the same identification */
|
||||
#define EXI_MEMCARD251 0x00000010 /*!< Nintendo memory card: 256/ 16/ 2.0 (blocks/Mbits/MB). 3rd party vendors do have the same identification */
|
||||
#define EXI_MEMCARD507 0x00000020 /*!< Nintendo memory card: 512/ 32/ 4.0 (blocks/Mbits/MB). 3rd party vendors do have the same identification */
|
||||
#define EXI_MEMCARD1019 0x00000040 /*!< Nintendo memory card: 1024/ 64/ 8.0 (blocks/Mbits/MB). 3rd party vendors do have the same identification */
|
||||
#define EXI_MEMCARD2043 0x00000080 /*!< Nintendo memory card: 2048/128/16.0 (blocks/Mbits/MB). 3rd party vendors do have the same identification */
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*! \typedef s32 (*EXICallback)(s32 chn,s32 dev)
|
||||
\brief function pointer typedef for the user's EXI callback
|
||||
\param chn EXI channel
|
||||
\param dev EXI device
|
||||
*/
|
||||
typedef s32 (*EXICallback)(s32 chn,s32 dev);
|
||||
|
||||
|
||||
/*! \fn s32 EXI_ProbeEx(s32 nChn)
|
||||
\brief Performs an extended probe of the EXI channel
|
||||
\param[in] nChn EXI channel to probe
|
||||
|
||||
\return 1 on success, <=0 on error
|
||||
*/
|
||||
s32 EXI_ProbeEx(s32 nChn);
|
||||
|
||||
|
||||
/*! \fn s32 EXI_Probe(s32 nChn)
|
||||
\brief Probes the EXI channel
|
||||
\param[in] nChn EXI channel to probe
|
||||
|
||||
\return 1 on success, <=0 on error
|
||||
*/
|
||||
s32 EXI_Probe(s32 nChn);
|
||||
|
||||
|
||||
/*! \fn s32 EXI_Lock(s32 nChn,s32 nDev,EXICallback unlockCB)
|
||||
\brief Try to lock the desired EXI channel on the given device.
|
||||
\param[in] nChn EXI channel to lock
|
||||
\param[in] nDev EXI device to lock
|
||||
\param[in] unlockCB pointer to callback to call when EXI_Unlock() is called. Thus allowing us a small way of mutual exclusion.
|
||||
|
||||
\return 1 on success, <=0 on error
|
||||
*/
|
||||
s32 EXI_Lock(s32 nChn,s32 nDev,EXICallback unlockCB);
|
||||
|
||||
|
||||
/*! \fn s32 EXI_Unlock(s32 nChn)
|
||||
\brief Unlock the desired EXI channel.
|
||||
\param[in] nChn EXI channel to unlock
|
||||
|
||||
\return 1 on success, <=0 on error
|
||||
*/
|
||||
s32 EXI_Unlock(s32 nChn);
|
||||
|
||||
|
||||
/*! \fn s32 EXI_Select(s32 nChn,s32 nDev,s32 nFrq)
|
||||
\brief Selects the spedified EXI channel on the given device with the given frequency
|
||||
\param[in] nChn EXI channel to select
|
||||
\param[in] nDev EXI device to select
|
||||
\param[in] nFrq EXI frequency to select
|
||||
|
||||
\return 1 on success, <=0 on error
|
||||
*/
|
||||
s32 EXI_Select(s32 nChn,s32 nDev,s32 nFrq);
|
||||
|
||||
|
||||
/*! \fn s32 EXI_SelectSD(s32 nChn,s32 nDev,s32 nFrq)
|
||||
\brief Performs a special select, for SD cards or adapters respectively, on the given device with the given frequence
|
||||
\param[in] nChn EXI channel to select
|
||||
\param[in] nDev EXI device to select
|
||||
\param[in] nFrq EXI frequency to select
|
||||
|
||||
\return 1 on success, <=0 on error
|
||||
*/
|
||||
s32 EXI_SelectSD(s32 nChn,s32 nDev,s32 nFrq);
|
||||
|
||||
|
||||
/*! \fn s32 EXI_Deselect(s32 nChn)
|
||||
\brief Deselects the EXI channel.
|
||||
\param[in] nChn EXI channel to deselect
|
||||
|
||||
\return 1 on success, <=0 on error
|
||||
*/
|
||||
s32 EXI_Deselect(s32 nChn);
|
||||
|
||||
|
||||
/*! \fn s32 EXI_Sync(s32 nChn)
|
||||
\brief Synchronize or finish respectively the last EXI transfer.
|
||||
\param[in] nChn EXI channel to select
|
||||
|
||||
\return 1 on success, <=0 on error
|
||||
*/
|
||||
s32 EXI_Sync(s32 nChn);
|
||||
|
||||
|
||||
/*! \fn s32 EXI_Imm(s32 nChn,void *pData,u32 nLen,u32 nMode,EXICallback tc_cb)
|
||||
\brief Initializes an immediate mode EXI transfer.
|
||||
\param[in] nChn EXI channel to select
|
||||
\param[in,out] pData pointer to a buffer to read/copy from/to data.
|
||||
\param[in] nLen lenght of data to transfer <=4.
|
||||
\param[in] nMode direction of transferoperation(EXI_READ,EXI_WRITE,EXI_READWRITE)
|
||||
\param[in] tc_cb pointer to a callback to call when transfer has completed. May be NULL.
|
||||
|
||||
\return 1 on success, <=0 on error
|
||||
*/
|
||||
s32 EXI_Imm(s32 nChn,void *pData,u32 nLen,u32 nMode,EXICallback tc_cb);
|
||||
|
||||
|
||||
/*! \fn s32 EXI_ImmEx(s32 nChn,void *pData,u32 nLen,u32 nMode)
|
||||
\brief Initializes an extended immediate mode EXI transfer.
|
||||
\param[in] nChn EXI channel to select
|
||||
\param[in,out] pData pointer to a buffer to read/copy from/to data.
|
||||
\param[in] nLen lenght of data to transfer.
|
||||
\param[in] nMode direction of transferoperation(EXI_READ,EXI_WRITE,EXI_READWRITE)
|
||||
|
||||
\return 1 on success, <=0 on error
|
||||
*/
|
||||
s32 EXI_ImmEx(s32 nChn,void *pData,u32 nLen,u32 nMode);
|
||||
|
||||
|
||||
/*! \fn s32 EXI_Dma(s32 nChn,void *pData,u32 nLen,u32 nMode,EXICallback tc_cb)
|
||||
\brief Initializes a DMA mode EXI transfer.
|
||||
\param[in] nChn EXI channel to select
|
||||
\param[in,out] pData pointer to a buffer to read/copy from/to data.
|
||||
\param[in] nLen lenght of data to transfer.
|
||||
\param[in] nMode direction of transferoperation(EXI_READ,EXI_WRITE,EXI_READWRITE)
|
||||
\param[in] tc_cb pointer to a callback to call when transfer has completed. May be NULL.
|
||||
|
||||
\return 1 on success, <=0 on error
|
||||
*/
|
||||
s32 EXI_Dma(s32 nChn,void *pData,u32 nLen,u32 nMode,EXICallback tc_cb);
|
||||
|
||||
|
||||
/*! \fn s32 EXI_GetState(s32 nChn)
|
||||
\brief Get the EXI state
|
||||
\param[in] nChn EXI channel to select
|
||||
|
||||
\return EXI channels state flag.
|
||||
*/
|
||||
s32 EXI_GetState(s32 nChn);
|
||||
|
||||
|
||||
/*! \fn s32 EXI_GetID(s32 nChn,s32 nDev,u32 *nId)
|
||||
\brief Get the ID of the connected EXI device on the given channel
|
||||
\param[in] nChn EXI channel to select
|
||||
\param[in] nDev EXI device to select
|
||||
\param[out] nId EXI device ID to return.
|
||||
|
||||
\return 1 on success, <=0 on error
|
||||
*/
|
||||
s32 EXI_GetID(s32 nChn,s32 nDev,u32 *nId);
|
||||
|
||||
|
||||
/*! \fn s32 EXI_Attach(s32 nChn,EXICallback ext_cb)
|
||||
\brief Attach the device on the given channel
|
||||
\param[in] nChn EXI channel to select
|
||||
\param[in] ext_cb pointer to callback to call when device is physically removed.
|
||||
|
||||
\return 1 on success, <=0 on error
|
||||
*/
|
||||
s32 EXI_Attach(s32 nChn,EXICallback ext_cb);
|
||||
|
||||
|
||||
/*! \fn s32 EXI_Detach(s32 nChn)
|
||||
\brief Detach the device on the given channel
|
||||
\param[in] nChn EXI channel to select
|
||||
|
||||
\return 1 on success, <=0 on error
|
||||
*/
|
||||
s32 EXI_Detach(s32 nChn);
|
||||
|
||||
|
||||
/*! \fn void EXI_ProbeReset()
|
||||
\brief Resets certain internal flags and counters and performs a probe on all 3 channels.
|
||||
|
||||
\return nothing
|
||||
*/
|
||||
void EXI_ProbeReset();
|
||||
|
||||
|
||||
/*! \fn EXICallback EXI_RegisterEXICallback(s32 nChn,EXICallback exi_cb)
|
||||
\brief Register a callback function in the EXI driver for the EXI interrupt.
|
||||
\param[in] nChn EXI channel to select
|
||||
\param[in] exi_cb pointer to the function which to call when EXI interrupt has triggered.
|
||||
|
||||
\return old callback function pointer or NULL
|
||||
*/
|
||||
EXICallback EXI_RegisterEXICallback(s32 nChn,EXICallback exi_cb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
499
wii/libogc/include/ogc/gu.h
Normal file
499
wii/libogc/include/ogc/gu.h
Normal file
@ -0,0 +1,499 @@
|
||||
#ifndef __GU_H__
|
||||
#define __GU_H__
|
||||
|
||||
/*!
|
||||
* \file gu.h
|
||||
* \brief GU/Matrix subsystem
|
||||
*
|
||||
* \details The GU/Matrix subsystem is used for many matrix- , vector- and quaternion-related operations.
|
||||
*
|
||||
* The matrix functions are coupled tightly with GX (GX will take Mtx for many of its own matrix-related functions, for example).
|
||||
* This library supports 3x3, 3x4, 4x3 and 4x4 matrices.
|
||||
*
|
||||
* This library has functions for manipulating vectors as well; some of its functions are for transforming matrices using vectors.
|
||||
*
|
||||
* It also includes functions for using and converting between quaternions. Although quaternions are not used natively in libogc,
|
||||
* they work well with rotation functions as they aren't susceptible to "gimbal lock". You can use the appropriate functions to
|
||||
* freely convert between quaternions and matrices.
|
||||
*
|
||||
* \note Many of the functions come in two flavors: C and "paired single". Both perform the same exact operations, but with a key
|
||||
* difference: the C versions are written in pure C and are slightly more accurate, while the PS versions are hand-written
|
||||
* assembly routines utilizing the Gekko's "paired-single" extension, which is much faster for almost every operation but slightly
|
||||
* less accurate. When building for the GameCube or Wii (which is probably always), the library is configured to automatically use
|
||||
* the paired-single tuned versions, as the speed difference is worth the accuracy hit. If you want to use the C routine and take
|
||||
* the performance hit instead, prefix the function with "c_". You are not limited to using only one or the other collection; you
|
||||
* can use both in your code if you wish.
|
||||
*
|
||||
* \warning Some functions (notably guFrustum() and related) take a 4x4 matrix, while the rest work only on 4x3 matrices. Make sure
|
||||
* you are passing the correct matrix type to each function, as passing the wrong one can create subtle bugs.
|
||||
*/
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#ifdef GEKKO
|
||||
#define MTX_USE_PS
|
||||
#undef MTX_USE_C
|
||||
#endif
|
||||
|
||||
#ifndef GEKKO
|
||||
#define MTX_USE_C
|
||||
#undef MTX_USE_PS
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||
#endif
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||
#endif
|
||||
|
||||
#define M_PI 3.14159265358979323846
|
||||
#define M_DTOR (3.14159265358979323846/180.0)
|
||||
|
||||
#define FTOFIX32(x) (s32)((x) * (f32)0x00010000)
|
||||
#define FIX32TOF(x) ((f32)(x) * (1.0f / (f32)0x00010000))
|
||||
#define FTOFRAC8(x) ((s32) MIN(((x) * (128.0f)), 127.0f) & 0xff)
|
||||
|
||||
#define DegToRad(a) ( (a) * 0.01745329252f )
|
||||
#define RadToDeg(a) ( (a) * 57.29577951f )
|
||||
|
||||
/*!
|
||||
* \def guMtxRowCol(mt,row,col)
|
||||
* \brief Provides storage-safe access to elements of Mtx and Mtx44.
|
||||
*
|
||||
* \details This macro provides storage-safe access to elements of Mtx and Mtx44. Matrix storage format is transparent to the
|
||||
* programmer as long as matrices are initialized and manipulated exclusively with the matrix API. Do not initialize matrices
|
||||
* when they are first declared and do not set values by hand. To insulate code from changes to matrix storage format, you should
|
||||
* use this macro instead of directly accessing individual matrix elements.
|
||||
*
|
||||
* \note When using this function, think of the matrix in row-major format.
|
||||
*
|
||||
* \param[in] mt Matrix to be accessed.
|
||||
* \param[in] r Row index of element to access.
|
||||
* \param[in] c Column index of element to access.
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
#define guMtxRowCol(mt,row,col) (mt[row][col])
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*! \struct guVector
|
||||
* \brief 3-element vector with x, y and z components.
|
||||
*
|
||||
* \details When used in 3D transformations, it is treated as a column vector with an implied fourth 'w' coordinate of 1.
|
||||
* For example, to multiply a vector <i>vOld</i> by a matrix <i>m</i>: <i>vNew</i> = <i>m</i> x <i>vOld</i>. In code:
|
||||
*
|
||||
* \code guVecMultiply( m, &vOld, &vNew ); \endcode
|
||||
*
|
||||
* \note This is a generic structure which can be used in any situation or function that accepts an array or struct with
|
||||
* three f32 values.
|
||||
*/
|
||||
typedef struct _vecf {
|
||||
f32 x,y,z;
|
||||
} guVector;
|
||||
|
||||
/*! \struct guQuaternion
|
||||
* \brief Quaternion type consisting of an (x,y,z) vector component and a (w) scalar component.
|
||||
*
|
||||
* \details This struct is used by gu library function such as guQuatMtx(), which generates a rotation matrix from a
|
||||
* quaternion.
|
||||
*
|
||||
* \note This is a generic structure which can be used in any situation or function that accepts an array or struct with
|
||||
* four f32 values.
|
||||
*/
|
||||
typedef struct _qrtn {
|
||||
f32 x,y,z,w;
|
||||
} guQuaternion;
|
||||
|
||||
/*! \typedef f32 Mtx[3][4]
|
||||
* \brief Standard 3x4 matrix.
|
||||
* \warning Some functions take the 4x4 matrix type rather than this one, so make sure you don't mix up the two.
|
||||
*/
|
||||
typedef f32 Mtx[3][4];
|
||||
typedef f32 (*MtxP)[4];
|
||||
|
||||
/*! \typedef f32 ROMtx[4][3]
|
||||
* \brief Column-major representation of the standard Mtx structure.
|
||||
*
|
||||
* \details It is not a true transpose, as it is a 4x3 matrix. These structures are only accepted by functions that explicitly
|
||||
* require reordered matrices.
|
||||
*/
|
||||
typedef f32 ROMtx[4][3];
|
||||
typedef f32 (*ROMtxP)[3];
|
||||
|
||||
/*! \typedef f32 Mtx33[3][3]
|
||||
* \brief 3x3 matrix.
|
||||
*/
|
||||
typedef f32 Mtx33[3][3];
|
||||
typedef f32 (*Mtx33P)[3];
|
||||
|
||||
/*! \typedef f32 Mtx44[4][4]
|
||||
* \brief 4x4 matrix.
|
||||
* \warning Some functions take this instead of the 3x4 matrix, so make sure you don't mix up the two.
|
||||
*/
|
||||
typedef f32 Mtx44[4][4];
|
||||
typedef f32 (*Mtx44P)[4];
|
||||
|
||||
/*!
|
||||
* \fn void guFrustum(Mtx44 mt,f32 t,f32 b,f32 l,f32 r,f32 n,f32 f)
|
||||
* \brief Sets a 4x4 perspective projection matrix from viewing volume dimensions.
|
||||
*
|
||||
* \details This matrix is used by the GX API to transform points to screen space.
|
||||
*
|
||||
* For normal perspective projection, the axis of projection is the -z axis, so \a t = positive, \a b = -\a t, \a r =
|
||||
* positive, \a l = -\a r. \a n and \a f must both be given as positive distances.
|
||||
*
|
||||
* \note \a m negates a point's 'z' values, so pre-transformed points should have negative 'z' values in eye space in
|
||||
* order to be visible after projection.
|
||||
*
|
||||
* \param[out] mt New projection matrix.
|
||||
* \param[in] t Top edge of view volume at the near clipping plane.
|
||||
* \param[in] b Bottom edge of view volume at the near clipping plane.
|
||||
* \param[in] l Left edge of view volume at the near clipping plane.
|
||||
* \param[in] r Right edge of view volume at the near clipping plane.
|
||||
* \param[in] n Positive distance to the near clipping plane.
|
||||
* \param[in] f Positive distance to the far clipping plane.
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void guFrustum(Mtx44 mt,f32 t,f32 b,f32 l,f32 r,f32 n,f32 f);
|
||||
|
||||
/*!
|
||||
* \fn void guPerspective(Mtx44 mt,f32 fovy,f32 aspect,f32 n,f32 f)
|
||||
* \brief Sets a 4x4 perspective projection matrix from field of view and aspect ratio parameters.
|
||||
*
|
||||
* \details This matrix is used by the GX API to transform points to screen space.
|
||||
*
|
||||
* This function generates a projection matrix equivalent to that created by guFrustum() with the axis of projection
|
||||
* centered around Z. It is included to provide an alternative method of specifying view volume dimensions.
|
||||
*
|
||||
* The field of view (\a fovy) is the total field of view in degrees in the Y-Z plane. \a aspect is the ratio
|
||||
* (width/height) of the view window in screen space. \a n and \a f must both be given as positive distances.
|
||||
*
|
||||
* \note \a m negates a point's 'z' values, so pre-transformed points should have negative 'z' values in eye space in order to
|
||||
* be visible after projection.
|
||||
*
|
||||
* \param[out] mt New perspective projection matrix.
|
||||
* \param[in] fovy Total field of view in the Y-Z plane measured in degrees.
|
||||
* \param[in] aspect View window aspect ratio (width/height)
|
||||
* \param[in] n Positive distance to near clipping plane.
|
||||
* \param[in] f Positive distance to far clipping plane.
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void guPerspective(Mtx44 mt,f32 fovy,f32 aspect,f32 n,f32 f);
|
||||
|
||||
/*!
|
||||
* \fn void guOrtho(Mtx44 mt,f32 t,f32 b,f32 l,f32 r,f32 n,f32 f)
|
||||
* \brief Sets a 4x4 matrix for orthographic projection.
|
||||
*
|
||||
* \details This matrix is used by the GX API to transform points from eye space to screen space.
|
||||
*
|
||||
* For normal parallel projections, the axis of projection is the -z axis, so \a t = positive, \a b = -\a t, \a r =
|
||||
* positive, \a l = -\a r. \a n and \a f must both be given as positive distances.
|
||||
*
|
||||
* \note \a m negates \a a point's 'z' values, so pre-transformed points should have negative 'z' values in eye space in order
|
||||
* to be visible after projection.
|
||||
*
|
||||
* \param[out] mt New parallel projection matrix.
|
||||
* \param[in] t Top edge of view volume.
|
||||
* \param[in] b Bottom edge of view volume.
|
||||
* \param[in] l Left edge of view volume.
|
||||
* \param[in] r Right edge of view volume.
|
||||
* \param[in] n Positive distance to the near clipping plane.
|
||||
* \param[in] f Positive distance to the far clipping plane.
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void guOrtho(Mtx44 mt,f32 t,f32 b,f32 l,f32 r,f32 n,f32 f);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void guLightPerspective(Mtx mt,f32 fovY,f32 aspect,f32 scaleS,f32 scaleT,f32 transS,f32 transT)
|
||||
* \brief Sets a 3x4 perspective projection matrix from field of view and aspect ratio parameters, two scale values, and two
|
||||
* translation values.
|
||||
*
|
||||
* \details This matrix is used to project points into texture space and yield texture coordinates.
|
||||
*
|
||||
* This function generates a projection matrix, equivalent to that created by guLightFrustum(), with the axis of projection
|
||||
* centered around Z. This function is included to provide an alternative method of specifying texture projection volume
|
||||
* dimensions.
|
||||
*
|
||||
* The field of view (\a fovy) is the total field of view in degrees in the YZ plane. \a aspect is the ratio (width / height)
|
||||
* of the view window in screen space.
|
||||
*
|
||||
* Standard projection yields values ranging from -1.0 to 1.0 in both dimensions of the front clipping plane. Since texture
|
||||
* coordinates should usually be within the range of 0.0 to 1.0, we have added a scale and translation value for both S and T.
|
||||
* The most common way to use these values is to set all of them to 0.5 (so that points in the range of -1.0 to 1.0 are first
|
||||
* scaled by 0.5) to be in the range of -0.5 to 0.5. Then they are translated by 0.5 to be in the range of 0.0 to 1.0. Other
|
||||
* values can be used for translation and scale to yield different effects.
|
||||
*
|
||||
* \param[out] mt New projection matrix.
|
||||
* \param[in] fovy Total field of view in the YZ plane measured in degrees.
|
||||
* \param[in] aspect View window aspect ratio (width / height)
|
||||
* \param[in] scaleS Scale in the S direction for projected coordinates (usually 0.5).
|
||||
* \param[in] scaleT Scale in the T direction for projected coordinates (usually 0.5).
|
||||
* \param[in] transS Translate in the S direction for projected coordinates (usually 0.5).
|
||||
* \param[in] transT Translate in the T direction for projected coordinates (usually 0.5).
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void guLightPerspective(Mtx mt,f32 fovY,f32 aspect,f32 scaleS,f32 scaleT,f32 transS,f32 transT);
|
||||
|
||||
/*!
|
||||
* \fn void guLightOrtho(Mtx mt,f32 t,f32 b,f32 l,f32 r,f32 scaleS,f32 scaleT,f32 transS,f32 transT)
|
||||
* \brief Sets a 3x4 matrix for orthographic projection.
|
||||
*
|
||||
* \details Use this matrix to project points into texture space and yield texture coordinates.
|
||||
*
|
||||
* For normal parallel projections, the axis of projection is the -z axis, so \a t = positive, \a b = -\a t, \a r = positive,
|
||||
* \a l = -\a r.
|
||||
*
|
||||
* Standard projection yields values ranging from -1.0 to 1.0 in both dimensions of the front clipping plane. Since texture
|
||||
* coordinates should usually be within the range of 0.0 to 1.0, we have added a scale and translation value for both S and T.
|
||||
* The most common way to use these values is to set all of them to 0.5 so that points in the range of -1.0 to 1.0 are first
|
||||
* scaled by 0.5 (to be in the range of -0.5 to 0.5). Then they are translated by 0.5 to be in the range of 0.0 to 1.0. Other
|
||||
* values can be used for translation and scale to yield different effects.
|
||||
*
|
||||
* \param[out] mt New parallel projection matrix.
|
||||
* \param[in] t Top edge of view volume.
|
||||
* \param[in] b Bottom edge of view volume.
|
||||
* \param[in] l Left edge of view volume.
|
||||
* \param[in] r Right edge of view volume.
|
||||
* \param[in] scaleS Scale in the S direction for projected coordinates (usually 0.5).
|
||||
* \param[in] scaleT Scale in the T direction for projected coordinates (usually 0.5).
|
||||
* \param[in] transS Translate in the S direction for projected coordinates (usually 0.5).
|
||||
* \param[in] transT Translate in the T direction for projected coordinates (usually 0.5).
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void guLightOrtho(Mtx mt,f32 t,f32 b,f32 l,f32 r,f32 scaleS,f32 scaleT,f32 transS,f32 transT);
|
||||
|
||||
/*!
|
||||
* \fn void guLightFrustum(Mtx mt,f32 t,f32 b,f32 l,f32 r,f32 n,f32 scaleS,f32 scaleT,f32 transS,f32 transT)
|
||||
* \brief Sets a 3x4 perspective projection matrix from viewing volume dimensions, two scale values, and two translation values.
|
||||
*
|
||||
* \details This matrix is used to project points into texture space and yield texture coordinates.
|
||||
*
|
||||
* For normal perspective projection, the axis of projection is the -z axis, so \a t = positive, \a b = -\a t, \a r = positive,
|
||||
* \a l = -\a r. \a n must be given as a positive distance.
|
||||
*
|
||||
* Standard projection yields values ranging from -1.0 to 1.0 in both dimensions of the front clipping plane. Since texture
|
||||
* coordinates usually should be within the range of 0.0 to 1.0, we have added a scale and translation value for both S and T.
|
||||
* The most common usage of these values is to set all of them to 0.5 so that points in the range of -1.0 to 1.0 are first
|
||||
* scaled by 0.5 to be in the range of -0.5 to 0.5, and are then translated by 0.5 to be in the range of 0.0 to 1.0. Other
|
||||
* values can be used for translation and scale to yield different effects.
|
||||
*
|
||||
* \param[out] mt New projection matrix.
|
||||
* \param[in] t Top edge of view volume at the near clipping plane.
|
||||
* \param[in] b Bottom edge of view volume at the near clipping plane.
|
||||
* \param[in] l Left edge of view volume at the near clipping plane.
|
||||
* \param[in] r Right edge of view volume at the near clipping plane.
|
||||
* \param[in] n Positive distance to the near clipping plane.
|
||||
* \param[in] scaleS Scale in the S direction for projected coordinates (usually 0.5).
|
||||
* \param[in] scaleT Scale in the T direction for projected coordinates (usually 0.5).
|
||||
* \param[in] transS Translate in the S direction for projected coordinates (usually 0.5).
|
||||
* \param[in] transT Translate in the T direction for projected coordinates (usually 0.5).
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void guLightFrustum(Mtx mt,f32 t,f32 b,f32 l,f32 r,f32 n,f32 scaleS,f32 scaleT,f32 transS,f32 transT);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void guLookAt(Mtx mt,guVector *camPos,guVector *camUp,guVector *target)
|
||||
* \brief Sets a world-space to camera-space transformation matrix.
|
||||
*
|
||||
* \details Create the matrix \a m by specifying a camera position (\a camPos), a camera "up" direction (\a camUp), and a target
|
||||
* position (\a target).
|
||||
*
|
||||
* The camera's reference viewing direction is the -z axis. The camera's reference 'up' direction is the +y axis.
|
||||
*
|
||||
* This function is especially convenient for creating a tethered camera, aiming at an object, panning, or specifying an
|
||||
* arbitrary view.
|
||||
*
|
||||
* \param[out] mt New viewing matrix.
|
||||
* \param[in] camPos Vector giving 3D camera position in world space.
|
||||
* \param[in] camUp Vector containing camera "up" vector; does not have to be a unit vector.
|
||||
* \param[in] target Vector giving 3D target position in world space.
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void guLookAt(Mtx mt,guVector *camPos,guVector *camUp,guVector *target);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void guVecHalfAngle(guVector *a,guVector *b,guVector *half)
|
||||
* \brief Computes a vector that lies halfway between \a a and \a b.
|
||||
*
|
||||
* \details The halfway vector is useful in specular reflection calculations. It is interpreted as pointing from the reflecting
|
||||
* surface to the general viewing direction.
|
||||
*
|
||||
* \a a and \a b do not have to be unit vectors. Both of these vectors are assumed to be pointing towards the surface from the
|
||||
* light or viewer, respectively. Local copies of these vectors are negated, normalized and added head to tail.
|
||||
*
|
||||
* \a half is computed as a unit vector that points from the surface to halfway between the light and the viewing direction.
|
||||
*
|
||||
* \param[in] a Pointer to incident vector. Must point from the light source to the surface.
|
||||
* \param[in] b Pointer to viewing vector. Must point from the viewer to the surface.
|
||||
* \param[out] half Pointer to resultant half-angle unit vector; points from the surface to halfway between the light and the viewing direction.
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void guVecHalfAngle(guVector *a,guVector *b,guVector *half);
|
||||
|
||||
void c_guVecAdd(guVector *a,guVector *b,guVector *ab);
|
||||
void c_guVecSub(guVector *a,guVector *b,guVector *ab);
|
||||
void c_guVecScale(guVector *src,guVector *dst,f32 scale);
|
||||
void c_guVecNormalize(guVector *v);
|
||||
void c_guVecMultiply(Mtx mt,guVector *src,guVector *dst);
|
||||
void c_guVecCross(guVector *a,guVector *b,guVector *axb);
|
||||
void c_guVecMultiplySR(Mtx mt,guVector *src,guVector *dst);
|
||||
f32 c_guVecDotProduct(guVector *a,guVector *b);
|
||||
|
||||
#ifdef GEKKO
|
||||
void ps_guVecAdd(register guVector *a,register guVector *b,register guVector *ab);
|
||||
void ps_guVecSub(register guVector *a,register guVector *b,register guVector *ab);
|
||||
void ps_guVecScale(register guVector *src,register guVector *dst,f32 scale);
|
||||
void ps_guVecNormalize(register guVector *v);
|
||||
void ps_guVecCross(register guVector *a,register guVector *b,register guVector *axb);
|
||||
void ps_guVecMultiply(register Mtx mt,register guVector *src,register guVector *dst);
|
||||
void ps_guVecMultiplySR(register Mtx mt,register guVector *src,register guVector *dst);
|
||||
f32 ps_guVecDotProduct(register guVector *a,register guVector *b);
|
||||
#endif //GEKKO
|
||||
|
||||
void c_guQuatAdd(guQuaternion *a,guQuaternion *b,guQuaternion *ab);
|
||||
void c_guQuatSub(guQuaternion *a,guQuaternion *b,guQuaternion *ab);
|
||||
void c_guQuatMultiply(guQuaternion *a,guQuaternion *b,guQuaternion *ab);
|
||||
void c_guQuatNormalize(guQuaternion *a,guQuaternion *d);
|
||||
void c_guQuatInverse(guQuaternion *a,guQuaternion *d);
|
||||
void c_guQuatMtx(guQuaternion *a,Mtx m);
|
||||
|
||||
#ifdef GEKKO
|
||||
void ps_guQuatAdd(register guQuaternion *a,register guQuaternion *b,register guQuaternion *ab);
|
||||
void ps_guQuatSub(register guQuaternion *a,register guQuaternion *b,register guQuaternion *ab);
|
||||
void ps_guQuatMultiply(register guQuaternion *a,register guQuaternion *b,register guQuaternion *ab);
|
||||
void ps_guQuatNormalize(register guQuaternion *a,register guQuaternion *d);
|
||||
void ps_guQuatInverse(register guQuaternion *a,register guQuaternion *d);
|
||||
#endif
|
||||
|
||||
void c_guMtxIdentity(Mtx mt);
|
||||
void c_guMtxCopy(Mtx src,Mtx dst);
|
||||
void c_guMtxConcat(Mtx a,Mtx b,Mtx ab);
|
||||
void c_guMtxScale(Mtx mt,f32 xS,f32 yS,f32 zS);
|
||||
void c_guMtxScaleApply(Mtx src,Mtx dst,f32 xS,f32 yS,f32 zS);
|
||||
void c_guMtxApplyScale(Mtx src,Mtx dst,f32 xS,f32 yS,f32 zS);
|
||||
void c_guMtxTrans(Mtx mt,f32 xT,f32 yT,f32 zT);
|
||||
void c_guMtxTransApply(Mtx src,Mtx dst,f32 xT,f32 yT,f32 zT);
|
||||
void c_guMtxApplyTrans(Mtx src,Mtx dst,f32 xT,f32 yT,f32 zT);
|
||||
u32 c_guMtxInverse(Mtx src,Mtx inv);
|
||||
u32 c_guMtxInvXpose(Mtx src,Mtx xPose);
|
||||
void c_guMtxTranspose(Mtx src,Mtx xPose);
|
||||
void c_guMtxRotRad(Mtx mt,const char axis,f32 rad);
|
||||
void c_guMtxRotTrig(Mtx mt,const char axis,f32 sinA,f32 cosA);
|
||||
void c_guMtxRotAxisRad(Mtx mt,guVector *axis,f32 rad);
|
||||
void c_guMtxReflect(Mtx m,guVector *p,guVector *n);
|
||||
void c_guMtxQuat(Mtx m,guQuaternion *a);
|
||||
|
||||
#ifdef GEKKO
|
||||
void ps_guMtxIdentity(register Mtx mt);
|
||||
void ps_guMtxCopy(register Mtx src,register Mtx dst);
|
||||
void ps_guMtxConcat(register Mtx a,register Mtx b,register Mtx ab);
|
||||
void ps_guMtxTranspose(register Mtx src,register Mtx xPose);
|
||||
u32 ps_guMtxInverse(register Mtx src,register Mtx inv);
|
||||
u32 ps_guMtxInvXpose(register Mtx src,register Mtx xPose);
|
||||
void ps_guMtxScale(register Mtx mt,register f32 xS,register f32 yS,register f32 zS);
|
||||
void ps_guMtxScaleApply(register Mtx src,register Mtx dst,register f32 xS,register f32 yS,register f32 zS);
|
||||
void ps_guMtxApplyScale(register Mtx src,register Mtx dst,register f32 xS,register f32 yS,register f32 zS);
|
||||
void ps_guMtxTrans(register Mtx mt,register f32 xT,register f32 yT,register f32 zT);
|
||||
void ps_guMtxTransApply(register Mtx src,register Mtx dst,register f32 xT,register f32 yT,register f32 zT);
|
||||
void ps_guMtxApplyTrans(register Mtx src,register Mtx dst,register f32 xT,register f32 yT,register f32 zT);
|
||||
void ps_guMtxRotRad(register Mtx mt,register const char axis,register f32 rad);
|
||||
void ps_guMtxRotTrig(register Mtx mt,register const char axis,register f32 sinA,register f32 cosA);
|
||||
void ps_guMtxRotAxisRad(register Mtx mt,register guVector *axis,register f32 tmp0);
|
||||
void ps_guMtxReflect(register Mtx m,register guVector *p,register guVector *n);
|
||||
#endif //GEKKO
|
||||
|
||||
#ifdef MTX_USE_C
|
||||
|
||||
#define guVecAdd c_guVecAdd
|
||||
#define guVecSub c_guVecSub
|
||||
#define guVecScale c_guVecScale
|
||||
#define guVecNormalize c_guVecNormalize
|
||||
#define guVecMultiply c_guVecMultiply
|
||||
#define guVecCross c_guVecCross
|
||||
#define guVecMultiplySR c_guVecMultiplySR
|
||||
#define guVecDotProduct c_guVecDotProduct
|
||||
|
||||
#define guQuatAdd c_guQuatAdd
|
||||
#define guQuatSub c_guQuatSub
|
||||
#define guQuatMultiply c_guQuatMultiply
|
||||
#define guQuatNoramlize c_guQuatNormalize
|
||||
#define guQuatInverse c_guQuatInverse
|
||||
#define guQuatMtx c_guQuatMtx
|
||||
|
||||
#define guMtxIdentity c_guMtxIdentity
|
||||
#define guMtxCopy c_guMtxCopy
|
||||
#define guMtxConcat c_guMtxConcat
|
||||
#define guMtxScale c_guMtxScale
|
||||
#define guMtxScaleApply c_guMtxScaleApply
|
||||
#define guMtxApplyScale c_guMtxApplyScale
|
||||
#define guMtxTrans c_guMtxTrans
|
||||
#define guMtxTransApply c_guMtxTransApply
|
||||
#define guMtxApplyTrans c_guMtxApplyTrans
|
||||
#define guMtxInverse c_guMtxInverse
|
||||
#define guMtxTranspose c_guMtxTranspose
|
||||
#define guMtxInvXpose c_guMtxInvXpose
|
||||
#define guMtxRotRad c_guMtxRotRad
|
||||
#define guMtxRotTrig c_guMtxRotTrig
|
||||
#define guMtxRotAxisRad c_guMtxRotAxisRad
|
||||
#define guMtxReflect c_guMtxReflect
|
||||
#define guMtxQuat c_guMtxQuat
|
||||
|
||||
#else //MTX_USE_C
|
||||
|
||||
#define guVecAdd ps_guVecAdd
|
||||
#define guVecSub ps_guVecSub
|
||||
#define guVecScale ps_guVecScale
|
||||
#define guVecNormalize ps_guVecNormalize
|
||||
#define guVecMultiply ps_guVecMultiply
|
||||
#define guVecCross ps_guVecCross
|
||||
#define guVecMultiplySR ps_guVecMultiplySR
|
||||
#define guVecDotProduct ps_guVecDotProduct
|
||||
|
||||
#define guQuatAdd ps_guQuatAdd
|
||||
#define guQuatSub ps_guQuatSub
|
||||
#define guQuatMultiply ps_guQuatMultiply
|
||||
#define guQuatNormalize ps_guQuatNormalize
|
||||
#define guQuatInverse ps_guQuatInverse
|
||||
|
||||
#define guMtxIdentity ps_guMtxIdentity
|
||||
#define guMtxCopy ps_guMtxCopy
|
||||
#define guMtxConcat ps_guMtxConcat
|
||||
#define guMtxScale ps_guMtxScale
|
||||
#define guMtxScaleApply ps_guMtxScaleApply
|
||||
#define guMtxApplyScale ps_guMtxApplyScale
|
||||
#define guMtxTrans ps_guMtxTrans
|
||||
#define guMtxTransApply ps_guMtxTransApply
|
||||
#define guMtxApplyTrans ps_guMtxApplyTrans
|
||||
#define guMtxInverse ps_guMtxInverse
|
||||
#define guMtxTranspose ps_guMtxTranspose
|
||||
#define guMtxInvXpose ps_guMtxInvXpose
|
||||
#define guMtxRotRad ps_guMtxRotRad
|
||||
#define guMtxRotTrig ps_guMtxRotTrig
|
||||
#define guMtxRotAxisRad ps_guMtxRotAxisRad
|
||||
#define guMtxReflect ps_guMtxReflect
|
||||
|
||||
#endif //MTX_USE_PS
|
||||
|
||||
#define guMtxRotDeg(mt,axis,deg) guMtxRotRad(mt,axis,DegToRad(deg))
|
||||
#define guMtxRotAxisDeg(mt,axis,deg) guMtxRotAxisRad(mt,axis,DegToRad(deg))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
5256
wii/libogc/include/ogc/gx.h
Normal file
5256
wii/libogc/include/ogc/gx.h
Normal file
File diff suppressed because it is too large
Load Diff
78
wii/libogc/include/ogc/gx_struct.h
Normal file
78
wii/libogc/include/ogc/gx_struct.h
Normal file
@ -0,0 +1,78 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
gx_struct.h -- support header
|
||||
|
||||
Copyright (C) 2004
|
||||
Michael Wiedenbauer (shagkur)
|
||||
Dave Murphy (WinterMute)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __GX_STRUCT_H__
|
||||
#define __GX_STRUCT_H__
|
||||
|
||||
/*!
|
||||
\file gx_struct.h
|
||||
\brief support header
|
||||
*/
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
/*!
|
||||
\typedef struct _gx_rmodeobj GXRModeObj
|
||||
\brief structure to hold the selected video and render settings
|
||||
\param viTVMode mode and type of TV
|
||||
\param fbWidth width of external framebuffer
|
||||
\param efbHeight height of embedded framebuffer
|
||||
\param xfbHeight height of external framebuffer
|
||||
\param viXOrigin x starting point of first pixel to draw on VI
|
||||
\param viYOrigin y starting point of first pixel to draw on VI
|
||||
\param viWidth width of configured VI
|
||||
\param viHeight height of configured VI
|
||||
*/
|
||||
typedef struct _gx_rmodeobj {
|
||||
u32 viTVMode;
|
||||
u16 fbWidth;
|
||||
u16 efbHeight;
|
||||
u16 xfbHeight;
|
||||
u16 viXOrigin;
|
||||
u16 viYOrigin;
|
||||
u16 viWidth;
|
||||
u16 viHeight;
|
||||
u32 xfbMode;
|
||||
u8 field_rendering;
|
||||
u8 aa;
|
||||
u8 sample_pattern[12][2];
|
||||
u8 vfilter[7];
|
||||
} GXRModeObj;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
65
wii/libogc/include/ogc/ios.h
Normal file
65
wii/libogc/include/ogc/ios.h
Normal file
@ -0,0 +1,65 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
ios.h -- IOS control
|
||||
|
||||
Copyright (C) 2008
|
||||
Michael Wiedenbauer (shagkur)
|
||||
Dave Murphy (WinterMute)
|
||||
Hector Martin (marcan)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
#ifndef __IOS_H__
|
||||
#define __IOS_H__
|
||||
|
||||
#if defined(HW_RVL)
|
||||
|
||||
#include <gctypes.h>
|
||||
#include <gcutil.h>
|
||||
|
||||
#define IOS_EINVAL -0x3004
|
||||
#define IOS_EBADVERSION -0x3100
|
||||
#define IOS_ETOOMANYVIEWS -0x3101
|
||||
#define IOS_EMISMATCH -0x3102
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
s32 __IOS_InitializeSubsystems(void);
|
||||
s32 __IOS_ShutdownSubsystems(void);
|
||||
s32 __IOS_LoadStartupIOS(void);
|
||||
s32 __IOS_LaunchNewIOS(int version);
|
||||
s32 IOS_GetPreferredVersion(void);
|
||||
s32 IOS_ReloadIOS(int version);
|
||||
s32 IOS_GetVersion();
|
||||
s32 IOS_GetRevision();
|
||||
s32 IOS_GetRevisionMajor();
|
||||
s32 IOS_GetRevisionMinor();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
103
wii/libogc/include/ogc/ipc.h
Normal file
103
wii/libogc/include/ogc/ipc.h
Normal file
@ -0,0 +1,103 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
ipc.h -- Interprocess Communication with Starlet
|
||||
|
||||
Copyright (C) 2008
|
||||
Michael Wiedenbauer (shagkur)
|
||||
Dave Murphy (WinterMute)
|
||||
Hector Martin (marcan)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
#ifndef __IPC_H__
|
||||
#define __IPC_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#define IPC_HEAP -1
|
||||
|
||||
#define IPC_OPEN_NONE 0
|
||||
#define IPC_OPEN_READ 1
|
||||
#define IPC_OPEN_WRITE 2
|
||||
#define IPC_OPEN_RW (IPC_OPEN_READ|IPC_OPEN_WRITE)
|
||||
|
||||
#define IPC_MAXPATH_LEN 64
|
||||
|
||||
#define IPC_OK 0
|
||||
#define IPC_EINVAL -4
|
||||
#define IPC_ENOHEAP -5
|
||||
#define IPC_ENOENT -6
|
||||
#define IPC_EQUEUEFULL -8
|
||||
#define IPC_ENOMEM -22
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct _ioctlv
|
||||
{
|
||||
void *data;
|
||||
u32 len;
|
||||
} ioctlv;
|
||||
|
||||
void __IPC_Reinitialize(void);
|
||||
|
||||
typedef s32 (*ipccallback)(s32 result,void *usrdata);
|
||||
|
||||
s32 iosCreateHeap(s32 size);
|
||||
void* iosAlloc(s32 hid,s32 size);
|
||||
void iosFree(s32 hid,void *ptr);
|
||||
|
||||
void* IPC_GetBufferLo();
|
||||
void* IPC_GetBufferHi();
|
||||
void IPC_SetBufferLo(void *bufferlo);
|
||||
void IPC_SetBufferHi(void *bufferhi);
|
||||
|
||||
s32 IOS_Open(const char *filepath,u32 mode);
|
||||
s32 IOS_OpenAsync(const char *filepath,u32 mode,ipccallback ipc_cb,void *usrdata);
|
||||
|
||||
s32 IOS_Close(s32 fd);
|
||||
s32 IOS_CloseAsync(s32 fd,ipccallback ipc_cb,void *usrdata);
|
||||
|
||||
s32 IOS_Seek(s32 fd,s32 where,s32 whence);
|
||||
s32 IOS_SeekAsync(s32 fd,s32 where,s32 whence,ipccallback ipc_cb,void *usrdata);
|
||||
s32 IOS_Read(s32 fd,void *buf,s32 len);
|
||||
s32 IOS_ReadAsync(s32 fd,void *buf,s32 len,ipccallback ipc_cb,void *usrdata);
|
||||
s32 IOS_Write(s32 fd,const void *buf,s32 len);
|
||||
s32 IOS_WriteAsync(s32 fd,const void *buf,s32 len,ipccallback ipc_cb,void *usrdata);
|
||||
|
||||
s32 IOS_Ioctl(s32 fd,s32 ioctl,void *buffer_in,s32 len_in,void *buffer_io,s32 len_io);
|
||||
s32 IOS_IoctlAsync(s32 fd,s32 ioctl,void *buffer_in,s32 len_in,void *buffer_io,s32 len_io,ipccallback ipc_cb,void *usrdata);
|
||||
s32 IOS_Ioctlv(s32 fd,s32 ioctl,s32 cnt_in,s32 cnt_io,ioctlv *argv);
|
||||
s32 IOS_IoctlvAsync(s32 fd,s32 ioctl,s32 cnt_in,s32 cnt_io,ioctlv *argv,ipccallback ipc_cb,void *usrdata);
|
||||
|
||||
s32 IOS_IoctlvFormat(s32 hId,s32 fd,s32 ioctl,const char *format,...);
|
||||
s32 IOS_IoctlvFormatAsync(s32 hId,s32 fd,s32 ioctl,ipccallback usr_cb,void *usr_data,const char *format,...);
|
||||
|
||||
s32 IOS_IoctlvReboot(s32 fd,s32 ioctl,s32 cnt_in,s32 cnt_io,ioctlv *argv);
|
||||
s32 IOS_IoctlvRebootBackground(s32 fd,s32 ioctl,s32 cnt_in,s32 cnt_io,ioctlv *argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
189
wii/libogc/include/ogc/irq.h
Normal file
189
wii/libogc/include/ogc/irq.h
Normal file
@ -0,0 +1,189 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
irq.h -- Interrupt subsystem
|
||||
|
||||
Copyright (C) 2004
|
||||
Michael Wiedenbauer (shagkur)
|
||||
Dave Murphy (WinterMute)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __IRQ_H__
|
||||
#define __IRQ_H__
|
||||
|
||||
/*! \file irq.h
|
||||
\brief Interrupt subsystem
|
||||
|
||||
*/
|
||||
|
||||
#include <gctypes.h>
|
||||
#include "context.h"
|
||||
|
||||
#define IM_NONE (0xffffffff)
|
||||
#define IRQ_MEM0 0
|
||||
#define IRQ_MEM1 1
|
||||
#define IRQ_MEM2 2
|
||||
#define IRQ_MEM3 3
|
||||
#define IRQ_MEMADDRESS 4
|
||||
#define IRQ_DSP_AI 5
|
||||
#define IRQ_DSP_ARAM 6
|
||||
#define IRQ_DSP_DSP 7
|
||||
#define IRQ_AI 8
|
||||
#define IRQ_EXI0_EXI 9
|
||||
#define IRQ_EXI0_TC 10
|
||||
#define IRQ_EXI0_EXT 11
|
||||
#define IRQ_EXI1_EXI 12
|
||||
#define IRQ_EXI1_TC 13
|
||||
#define IRQ_EXI1_EXT 14
|
||||
#define IRQ_EXI2_EXI 15
|
||||
#define IRQ_EXI2_TC 16
|
||||
#define IRQ_PI_CP 17
|
||||
#define IRQ_PI_PETOKEN 18
|
||||
#define IRQ_PI_PEFINISH 19
|
||||
#define IRQ_PI_SI 20
|
||||
#define IRQ_PI_DI 21
|
||||
#define IRQ_PI_RSW 22
|
||||
#define IRQ_PI_ERROR 23
|
||||
#define IRQ_PI_VI 24
|
||||
#define IRQ_PI_DEBUG 25
|
||||
#define IRQ_PI_HSP 26
|
||||
#if defined(HW_RVL)
|
||||
#define IRQ_PI_ACR 27
|
||||
#endif
|
||||
#define IRQ_MAX 32
|
||||
|
||||
#define IRQMASK(irq) (0x80000000u>>irq)
|
||||
|
||||
#define IM_MEM0 IRQMASK(IRQ_MEM0)
|
||||
#define IM_MEM1 IRQMASK(IRQ_MEM1)
|
||||
#define IM_MEM2 IRQMASK(IRQ_MEM2)
|
||||
#define IM_MEM3 IRQMASK(IRQ_MEM3)
|
||||
#define IM_MEMADDRESS IRQMASK(IRQ_MEMADDRESS)
|
||||
#define IM_MEM (IM_MEM0|IM_MEM1|IM_MEM2|IM_MEM3|IM_MEMADDRESS)
|
||||
|
||||
#define IM_DSP_AI IRQMASK(IRQ_DSP_AI)
|
||||
#define IM_DSP_ARAM IRQMASK(IRQ_DSP_ARAM)
|
||||
#define IM_DSP_DSP IRQMASK(IRQ_DSP_DSP)
|
||||
#define IM_DSP (IM_DSP_AI|IM_DSP_ARAM|IM_DSP_DSP)
|
||||
|
||||
#define IM_AI IRQMASK(IRQ_AI)
|
||||
|
||||
#define IM_EXI0_EXI IRQMASK(IRQ_EXI0_EXI)
|
||||
#define IM_EXI0_TC IRQMASK(IRQ_EXI0_TC)
|
||||
#define IM_EXI0_EXT IRQMASK(IRQ_EXI0_EXT)
|
||||
#define IM_EXI0 (IM_EXI0_EXI|IM_EXI0_TC|IM_EXI0_EXT)
|
||||
|
||||
#define IM_EXI1_EXI IRQMASK(IRQ_EXI1_EXI)
|
||||
#define IM_EXI1_TC IRQMASK(IRQ_EXI1_TC)
|
||||
#define IM_EXI1_EXT IRQMASK(IRQ_EXI1_EXT)
|
||||
#define IM_EXI1 (IM_EXI1_EXI|IM_EXI1_TC|IM_EXI1_EXT)
|
||||
|
||||
#define IM_EXI2_EXI IRQMASK(IRQ_EXI2_EXI)
|
||||
#define IM_EXI2_TC IRQMASK(IRQ_EXI2_TC)
|
||||
#define IM_EXI2 (IM_EXI2_EXI|IM_EXI2_TC)
|
||||
#define IM_EXI (IM_EXI0|IM_EXI1|IM_EXI2)
|
||||
|
||||
#define IM_PI_CP IRQMASK(IRQ_PI_CP)
|
||||
#define IM_PI_PETOKEN IRQMASK(IRQ_PI_PETOKEN)
|
||||
#define IM_PI_PEFINISH IRQMASK(IRQ_PI_PEFINISH)
|
||||
#define IM_PI_SI IRQMASK(IRQ_PI_SI)
|
||||
#define IM_PI_DI IRQMASK(IRQ_PI_DI)
|
||||
#define IM_PI_RSW IRQMASK(IRQ_PI_RSW)
|
||||
#define IM_PI_ERROR IRQMASK(IRQ_PI_ERROR)
|
||||
#define IM_PI_VI IRQMASK(IRQ_PI_VI)
|
||||
#define IM_PI_DEBUG IRQMASK(IRQ_PI_DEBUG)
|
||||
#define IM_PI_HSP IRQMASK(IRQ_PI_HSP)
|
||||
#if defined(HW_DOL)
|
||||
#define IM_PI (IM_PI_CP|IM_PI_PETOKEN|IM_PI_PEFINISH|IM_PI_SI|IM_PI_DI|IM_PI_RSW|IM_PI_ERROR|IM_PI_VI|IM_PI_DEBUG|IM_PI_HSP)
|
||||
#elif defined(HW_RVL)
|
||||
#define IM_PI_ACR IRQMASK(IRQ_PI_ACR)
|
||||
#define IM_PI (IM_PI_CP|IM_PI_PETOKEN|IM_PI_PEFINISH|IM_PI_SI|IM_PI_DI|IM_PI_RSW|IM_PI_ERROR|IM_PI_VI|IM_PI_DEBUG|IM_PI_HSP|IM_PI_ACR)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
/*! \typedef void (*raw_irq_handler_t)(u32 irq,void *ctx)
|
||||
\brief function pointer typedef for the interrupt handler callback
|
||||
\param[in] irq interrupt number of triggered interrupt.
|
||||
\param[in] ctx pointer to the user data.
|
||||
*/
|
||||
typedef void (*raw_irq_handler_t)(u32 irq,void *ctx);
|
||||
|
||||
|
||||
/*! \fn raw_irq_handler_t IRQ_Request(u32 nIrq,raw_irq_handler_t pHndl,void *pCtx)
|
||||
\brief Register an interrupt handler.
|
||||
\param[in] nIrq interrupt number to which to register the handler
|
||||
\param[in] pHndl pointer to the handler callback function which to call when interrupt has triggered
|
||||
\param[in] pCtx pointer to user data to pass with, when handler is called
|
||||
|
||||
\return Old interrupt handler, else NULL
|
||||
*/
|
||||
raw_irq_handler_t IRQ_Request(u32 nIrq,raw_irq_handler_t pHndl,void *pCtx);
|
||||
|
||||
|
||||
/*! \fn raw_irq_handler_t IRQ_Free(u32 nIrq)
|
||||
\brief Free an interrupt handler.
|
||||
\param[in] nIrq interrupt number for which to free the handler
|
||||
|
||||
\return Old interrupt handler, else NULL
|
||||
*/
|
||||
raw_irq_handler_t IRQ_Free(u32 nIrq);
|
||||
|
||||
|
||||
/*! \fn raw_irq_handler_t IRQ_GetHandler(u32 nIrq)
|
||||
\brief Get the handler from interrupt number
|
||||
\param[in] nIrq interrupt number for which to retrieve the handler
|
||||
|
||||
\return interrupt handler, else NULL
|
||||
*/
|
||||
raw_irq_handler_t IRQ_GetHandler(u32 nIrq);
|
||||
|
||||
|
||||
/*! \fn u32 IRQ_Disable()
|
||||
\brief Disable the complete IRQ subsystem. No interrupts will be served. Multithreading kernel fully disabled.
|
||||
|
||||
\return Old state of the IRQ subsystem
|
||||
*/
|
||||
u32 IRQ_Disable(void);
|
||||
|
||||
|
||||
/*! \fn u32 IRQ_Restore(u32 level)
|
||||
\brief Restore the IRQ subsystem with the given level. This is function should be used together with IRQ_Disable()
|
||||
\param[in] level IRQ level to restore to.
|
||||
|
||||
\return none
|
||||
*/
|
||||
void IRQ_Restore(u32 level);
|
||||
|
||||
void __MaskIrq(u32 nMask);
|
||||
void __UnmaskIrq(u32 nMask);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
70
wii/libogc/include/ogc/isfs.h
Normal file
70
wii/libogc/include/ogc/isfs.h
Normal file
@ -0,0 +1,70 @@
|
||||
#ifndef __ISFS_H__
|
||||
#define __ISFS_H__
|
||||
|
||||
#if defined(HW_RVL)
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#define ISFS_MAXPATH IPC_MAXPATH_LEN
|
||||
|
||||
#define ISFS_OPEN_READ 0x01
|
||||
#define ISFS_OPEN_WRITE 0x02
|
||||
#define ISFS_OPEN_RW (ISFS_OPEN_READ | ISFS_OPEN_WRITE)
|
||||
|
||||
#define ISFS_OK 0
|
||||
#define ISFS_ENOMEM -22
|
||||
#define ISFS_EINVAL -101
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct _fstats
|
||||
{
|
||||
u32 file_length;
|
||||
u32 file_pos;
|
||||
} fstats;
|
||||
|
||||
typedef s32 (*isfscallback)(s32 result,void *usrdata);
|
||||
|
||||
s32 ISFS_Initialize();
|
||||
s32 ISFS_Deinitialize();
|
||||
|
||||
s32 ISFS_Open(const char *filepath,u8 mode);
|
||||
s32 ISFS_OpenAsync(const char *filepath,u8 mode,isfscallback cb,void *usrdata);
|
||||
s32 ISFS_Close(s32 fd);
|
||||
s32 ISFS_CloseAsync(s32 fd,isfscallback cb,void *usrdata);
|
||||
s32 ISFS_Delete(const char *filepath);
|
||||
s32 ISFS_DeleteAsync(const char *filepath,isfscallback cb,void *usrdata);
|
||||
s32 ISFS_ReadDir(const char *filepath,char *name_list,u32 *num);
|
||||
s32 ISFS_ReadDirAsync(const char *filepath,char *name_list,u32 *num,isfscallback cb,void *usrdata);
|
||||
s32 ISFS_CreateFile(const char *filepath,u8 attributes,u8 owner_perm,u8 group_perm,u8 other_perm);
|
||||
s32 ISFS_CreateFileAsync(const char *filepath,u8 attributes,u8 owner_perm,u8 group_perm,u8 other_perm,isfscallback cb,void *usrdata);
|
||||
s32 ISFS_Write(s32 fd,const void *buffer,u32 length);
|
||||
s32 ISFS_WriteAsync(s32 fd,const void *buffer,u32 length,isfscallback cb,void *usrdata);
|
||||
s32 ISFS_Read(s32 fd,void *buffer,u32 length);
|
||||
s32 ISFS_ReadAsync(s32 fd,void *buffer,u32 length,isfscallback cb,void *usrdata);
|
||||
s32 ISFS_Seek(s32 fd,s32 where,s32 whence);
|
||||
s32 ISFS_SeekAsync(s32 fd,s32 where,s32 whence,isfscallback cb,void *usrdata);
|
||||
s32 ISFS_CreateDir(const char *filepath,u8 attributes,u8 owner_perm,u8 group_perm,u8 other_perm);
|
||||
s32 ISFS_CreateDirAsync(const char *filepath,u8 attributes,u8 owner_perm,u8 group_perm,u8 other_perm,isfscallback cb,void *usrdata);
|
||||
s32 ISFS_GetStats(void *stats);
|
||||
s32 ISFS_GetStatsAsync(void *stats,isfscallback cb,void *usrdata);
|
||||
s32 ISFS_GetFileStats(s32 fd,fstats *status);
|
||||
s32 ISFS_GetFileStatsAsync(s32 fd,fstats *status,isfscallback cb,void *usrdata);
|
||||
s32 ISFS_GetAttr(const char *filepath,u32 *ownerID,u16 *groupID,u8 *attributes,u8 *ownerperm,u8 *groupperm,u8 *otherperm);
|
||||
s32 ISFS_GetAttrAsync(const char *filepath,u32 *ownerID,u16 *groupID,u8 *attributes,u8 *ownerperm,u8 *groupperm,u8 *otherperm,isfscallback cb,void *usrdata);
|
||||
s32 ISFS_Rename(const char *filepathOld,const char *filepathNew);
|
||||
s32 ISFS_RenameAsync(const char *filepathOld,const char *filepathNew,isfscallback cb,void *usrdata);
|
||||
s32 ISFS_SetAttr(const char *filepath,u32 ownerID,u16 groupID,u8 attributes,u8 ownerperm,u8 groupperm,u8 otherperm);
|
||||
s32 ISFS_SetAttrAsync(const char *filepath,u32 ownerID,u16 groupID,u8 attributes,u8 ownerperm,u8 groupperm,u8 otherperm,isfscallback cb,void *usrdata);
|
||||
s32 ISFS_GetUsage(const char* filepath, u32* usage1, u32* usage2);
|
||||
s32 ISFS_GetUsageAsync(const char* filepath, u32* usage1, u32* usage2,isfscallback cb,void *usrdata);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* defined(HW_RVL) */
|
||||
|
||||
#endif
|
13
wii/libogc/include/ogc/libversion.h
Normal file
13
wii/libogc/include/ogc/libversion.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef __LIBVERSION_H__
|
||||
#define __LIBVERSION_H__
|
||||
|
||||
#define _V_MAJOR_ 1
|
||||
#define _V_MINOR_ 8
|
||||
#define _V_PATCH_ 17
|
||||
|
||||
#define _V_DATE_ __DATE__
|
||||
#define _V_TIME_ __TIME__
|
||||
|
||||
#define _V_STRING "libOGC Release 1.8.17"
|
||||
|
||||
#endif // __LIBVERSION_H__
|
204
wii/libogc/include/ogc/lwp.h
Normal file
204
wii/libogc/include/ogc/lwp.h
Normal file
@ -0,0 +1,204 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
lwp.h -- Thread subsystem I
|
||||
|
||||
Copyright (C) 2004
|
||||
Michael Wiedenbauer (shagkur)
|
||||
Dave Murphy (WinterMute)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __LWP_H__
|
||||
#define __LWP_H__
|
||||
|
||||
/*! \file lwp.h
|
||||
\brief Thread subsystem I
|
||||
|
||||
*/
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#define LWP_CLOSED -1
|
||||
#define LWP_SUCCESSFUL 0
|
||||
#define LWP_ALREADY_SUSPENDED 1
|
||||
#define LWP_NOT_SUSPENDED 2
|
||||
|
||||
#define LWP_PRIO_IDLE 0
|
||||
#define LWP_PRIO_HIGHEST 127
|
||||
|
||||
#define LWP_THREAD_NULL 0xffffffff
|
||||
#define LWP_TQUEUE_NULL 0xffffffff
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*! \typedef u32 lwp_t
|
||||
\brief typedef for the thread context handle
|
||||
*/
|
||||
typedef u32 lwp_t;
|
||||
|
||||
|
||||
/*! \typedef u32 lwpq_t
|
||||
\brief typedef for the thread queue's context handle
|
||||
*/
|
||||
typedef u32 lwpq_t;
|
||||
|
||||
/*! \fn s32 LWP_CreateThread(lwp_t *thethread,void* (*entry)(void *),void *arg,void *stackbase,u32 stack_size,u8 prio)
|
||||
\brief Spawn a new thread with the given parameters
|
||||
\param[out] thethread pointer to a lwp_t handle
|
||||
\param[in] entry pointer to the thread's entry function.
|
||||
\param[in] arg pointer to an argument for the thread's entry function.
|
||||
\param[in] stackbase pointer to the threads stackbase address. If NULL, the stack is allocated by the thread system.
|
||||
\param[in] stack_size size of the provided stack. If 0, the default STACKSIZE of 8Kb is taken.
|
||||
\param[in] prio priority on which the newly created thread runs.
|
||||
|
||||
\return 0 on success, <0 on error
|
||||
*/
|
||||
s32 LWP_CreateThread(lwp_t *thethread,void* (*entry)(void *),void *arg,void *stackbase,u32 stack_size,u8 prio);
|
||||
|
||||
|
||||
/*! \fn s32 LWP_SuspendThread(lwp_t thethread)
|
||||
\brief Suspend the given thread.
|
||||
\param[in] thethread handle to the thread context which should be suspended.
|
||||
|
||||
\return 0 on success, <0 on error
|
||||
*/
|
||||
s32 LWP_SuspendThread(lwp_t thethread);
|
||||
|
||||
|
||||
/*! \fn s32 LWP_ResumeThread(lwp_t thethread)
|
||||
\brief Resume the given thread.
|
||||
\param[in] thethread handle to the thread context which should be resumed.
|
||||
|
||||
\return 0 on success, <0 on error
|
||||
*/
|
||||
s32 LWP_ResumeThread(lwp_t thethread);
|
||||
|
||||
|
||||
/*! \fn BOOL LWP_ThreadIsSuspended(lwp_t thethread)
|
||||
\brief Test whether the given thread is suspended or not
|
||||
\param[in] thethread handle to the thread context which should be tested.
|
||||
|
||||
\return TRUE or FALSE
|
||||
*/
|
||||
BOOL LWP_ThreadIsSuspended(lwp_t thethread);
|
||||
|
||||
|
||||
/*! \fn lwp_t LWP_GetSelf()
|
||||
\brief Return the handle to the current thread.
|
||||
|
||||
\return thread context handle
|
||||
*/
|
||||
lwp_t LWP_GetSelf();
|
||||
|
||||
|
||||
/*! \fn void LWP_SetThreadPriority(lwp_t thethread,u32 prio)
|
||||
\brief Set the priority of the given thread.
|
||||
\param[in] thethread handle to the thread context whos priority should be changed. If NULL, the current thread will be taken.
|
||||
\param[in] prio new priority to set
|
||||
|
||||
\return none
|
||||
*/
|
||||
void LWP_SetThreadPriority(lwp_t thethread,u32 prio);
|
||||
|
||||
|
||||
/*! \fn void LWP_YieldThread()
|
||||
\brief Yield the current thread to another one with higher priority or if not running at the same priority which state is runnable.
|
||||
|
||||
\return none
|
||||
*/
|
||||
void LWP_YieldThread();
|
||||
|
||||
|
||||
/*! \fn void LWP_Reschedule(u32 prio)
|
||||
\brief Reschedule all threads running at the given priority
|
||||
\param[in] prio priority level to reschedule
|
||||
|
||||
\return none
|
||||
*/
|
||||
void LWP_Reschedule(u32 prio);
|
||||
|
||||
|
||||
/*! \fn s32 LWP_JoinThread(lwp_t thethread,void **value_ptr)
|
||||
\brief Join the given thread.
|
||||
\param[in] thethread handle to the thread's context which should be joined to wait on termination.
|
||||
\param[in] value_ptr pointer-pointer to a variable to receive the return code of the terminated thread.
|
||||
|
||||
\return 0 on success, <0 on error
|
||||
*/
|
||||
s32 LWP_JoinThread(lwp_t thethread,void **value_ptr);
|
||||
|
||||
|
||||
/*! \fn void LWP_InitQueue(lwpq_t *thequeue)
|
||||
\brief Initialize the thread synchronization queue
|
||||
\param[in] thequeue pointer to a lwpq_t handle.
|
||||
|
||||
\return 0 on success, <0 on error
|
||||
*/
|
||||
s32 LWP_InitQueue(lwpq_t *thequeue);
|
||||
|
||||
|
||||
/*! \fn void LWP_CloseQueue(lwpq_t thequeue)
|
||||
\brief Close the thread synchronization queue and releas the handle
|
||||
\param[in] thequeue handle to the thread's synchronization queue
|
||||
|
||||
\return none
|
||||
*/
|
||||
void LWP_CloseQueue(lwpq_t thequeue);
|
||||
|
||||
|
||||
/*! \fn s32 LWP_ThreadSleep(lwpq_t thequeue)
|
||||
\brief Pushes the current thread onto the given thread synchronization queue and sets the thread state to blocked.
|
||||
\param[in] thequeue handle to the thread's synchronization queue to push the thread on
|
||||
|
||||
\return none
|
||||
*/
|
||||
s32 LWP_ThreadSleep(lwpq_t thequeue);
|
||||
|
||||
|
||||
/*! \fn void LWP_ThreadSignal(lwpq_t thequeue)
|
||||
\brief Signals one thread to be revmoved from the thread synchronization queue and sets it back to running state.
|
||||
\param[in] thequeue handle to the thread's synchronization queue to pop the blocked thread off
|
||||
|
||||
\return none
|
||||
*/
|
||||
void LWP_ThreadSignal(lwpq_t thequeue);
|
||||
|
||||
|
||||
/*! \fn void LWP_ThreadBroadcast(lwpq_t thequeue)
|
||||
\brief Removes all blocked threads from the thread synchronization queue and sets them back to running state.
|
||||
\param[in] thequeue handle to the thread's synchronization queue to pop the blocked threads off
|
||||
|
||||
\return none
|
||||
*/
|
||||
void LWP_ThreadBroadcast(lwpq_t thequeue);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
19
wii/libogc/include/ogc/lwp_config.h
Normal file
19
wii/libogc/include/ogc/lwp_config.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef __LWP_CONFIG_H__
|
||||
#define __LWP_CONFIG_H__
|
||||
|
||||
|
||||
#define LWP_MAX_MQUEUES 64
|
||||
|
||||
#define LWP_MAX_MUTEXES 64
|
||||
|
||||
#define LWP_MAX_THREADS 16
|
||||
|
||||
#define LWP_MAX_SEMAS 64
|
||||
|
||||
#define LWP_MAX_CONDVARS 64
|
||||
|
||||
#define LWP_MAX_TQUEUES 64
|
||||
|
||||
#define LWP_MAX_WATCHDOGS 64
|
||||
|
||||
#endif
|
59
wii/libogc/include/ogc/lwp_heap.h
Normal file
59
wii/libogc/include/ogc/lwp_heap.h
Normal file
@ -0,0 +1,59 @@
|
||||
#ifndef __LWP_HEAP_H__
|
||||
#define __LWP_HEAP_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
#include "machine/asm.h"
|
||||
|
||||
#define HEAP_BLOCK_USED 1
|
||||
#define HEAP_BLOCK_FREE 0
|
||||
|
||||
#define HEAP_DUMMY_FLAG (0+HEAP_BLOCK_USED)
|
||||
|
||||
#define HEAP_OVERHEAD (sizeof(u32)*2)
|
||||
#define HEAP_BLOCK_USED_OVERHEAD (sizeof(void*)*2)
|
||||
#define HEAP_MIN_SIZE (HEAP_OVERHEAD+sizeof(heap_block))
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _heap_block_st heap_block;
|
||||
struct _heap_block_st {
|
||||
u32 back_flag;
|
||||
u32 front_flag;
|
||||
heap_block *next;
|
||||
heap_block *prev;
|
||||
};
|
||||
|
||||
typedef struct _heap_iblock_st {
|
||||
u32 free_blocks;
|
||||
u32 free_size;
|
||||
u32 used_blocks;
|
||||
u32 used_size;
|
||||
} heap_iblock;
|
||||
|
||||
typedef struct _heap_cntrl_st {
|
||||
heap_block *start;
|
||||
heap_block *final;
|
||||
|
||||
heap_block *first;
|
||||
heap_block *perm_null;
|
||||
heap_block *last;
|
||||
u32 pg_size;
|
||||
u32 reserved;
|
||||
} heap_cntrl;
|
||||
|
||||
u32 __lwp_heap_init(heap_cntrl *theheap,void *start_addr,u32 size,u32 pg_size);
|
||||
void* __lwp_heap_allocate(heap_cntrl *theheap,u32 size);
|
||||
BOOL __lwp_heap_free(heap_cntrl *theheap,void *ptr);
|
||||
u32 __lwp_heap_getinfo(heap_cntrl *theheap,heap_iblock *theinfo);
|
||||
|
||||
#ifdef LIBOGC_INTERNAL
|
||||
#include <libogc/lwp_heap.inl>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
79
wii/libogc/include/ogc/lwp_messages.h
Normal file
79
wii/libogc/include/ogc/lwp_messages.h
Normal file
@ -0,0 +1,79 @@
|
||||
#ifndef __LWP_MESSAGES_H__
|
||||
#define __LWP_MESSAGES_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
#include <lwp_threadq.h>
|
||||
|
||||
//#define _LWPMQ_DEBUG
|
||||
|
||||
#define LWP_MQ_FIFO 0
|
||||
#define LWP_MQ_PRIORITY 1
|
||||
|
||||
#define LWP_MQ_STATUS_SUCCESSFUL 0
|
||||
#define LWP_MQ_STATUS_INVALID_SIZE 1
|
||||
#define LWP_MQ_STATUS_TOO_MANY 2
|
||||
#define LWP_MQ_STATUS_UNSATISFIED 3
|
||||
#define LWP_MQ_STATUS_UNSATISFIED_NOWAIT 4
|
||||
#define LWP_MQ_STATUS_DELETED 5
|
||||
#define LWP_MQ_STATUS_TIMEOUT 6
|
||||
#define LWP_MQ_STATUS_UNSATISFIED_WAIT 7
|
||||
|
||||
#define LWP_MQ_SEND_REQUEST INT_MAX
|
||||
#define LWP_MQ_SEND_URGENT INT_MIN
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void (*mq_notifyhandler)(void *);
|
||||
|
||||
typedef struct _mqbuffer {
|
||||
u32 size;
|
||||
u32 buffer[1];
|
||||
} mq_buffer;
|
||||
|
||||
typedef struct _mqbuffercntrl {
|
||||
lwp_node node;
|
||||
u32 prio;
|
||||
mq_buffer contents;
|
||||
} mq_buffercntrl;
|
||||
|
||||
//the following struct is extensible
|
||||
typedef struct _mqattr {
|
||||
u32 mode;
|
||||
} mq_attr;
|
||||
|
||||
typedef struct _mqcntrl {
|
||||
lwp_thrqueue wait_queue;
|
||||
mq_attr attr;
|
||||
u32 max_pendingmsgs;
|
||||
u32 num_pendingmsgs;
|
||||
u32 max_msgsize;
|
||||
lwp_queue pending_msgs;
|
||||
mq_buffer *msq_buffers;
|
||||
mq_notifyhandler notify_handler;
|
||||
void *notify_arg;
|
||||
lwp_queue inactive_msgs;
|
||||
} mq_cntrl;
|
||||
|
||||
u32 __lwpmq_initialize(mq_cntrl *mqueue,mq_attr *attrs,u32 max_pendingmsgs,u32 max_msgsize);
|
||||
void __lwpmq_close(mq_cntrl *mqueue,u32 status);
|
||||
u32 __lwpmq_seize(mq_cntrl *mqueue,u32 id,void *buffer,u32 *size,u32 wait,u64 timeout);
|
||||
u32 __lwpmq_submit(mq_cntrl *mqueue,u32 id,void *buffer,u32 size,u32 type,u32 wait,u64 timeout);
|
||||
u32 __lwpmq_broadcast(mq_cntrl *mqueue,void *buffer,u32 size,u32 id,u32 *count);
|
||||
void __lwpmq_msg_insert(mq_cntrl *mqueue,mq_buffercntrl *msg,u32 type);
|
||||
u32 __lwpmq_flush(mq_cntrl *mqueue);
|
||||
u32 __lwpmq_flush_support(mq_cntrl *mqueue);
|
||||
void __lwpmq_flush_waitthreads(mq_cntrl *mqueue);
|
||||
|
||||
#ifdef LIBOGC_INTERNAL
|
||||
#include <libogc/lwp_messages.inl>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
76
wii/libogc/include/ogc/lwp_mutex.h
Normal file
76
wii/libogc/include/ogc/lwp_mutex.h
Normal file
@ -0,0 +1,76 @@
|
||||
#ifndef __LWP_MUTEX_H__
|
||||
#define __LWP_MUTEX_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
#include <lwp_threadq.h>
|
||||
|
||||
#define LWP_MUTEX_LOCKED 0
|
||||
#define LWP_MUTEX_UNLOCKED 1
|
||||
|
||||
#define LWP_MUTEX_NEST_ACQUIRE 0
|
||||
#define LWP_MUTEX_NEST_ERROR 1
|
||||
#define LWP_MUTEX_NEST_BLOCK 2
|
||||
|
||||
#define LWP_MUTEX_FIFO 0
|
||||
#define LWP_MUTEX_PRIORITY 1
|
||||
#define LWP_MUTEX_INHERITPRIO 2
|
||||
#define LWP_MUTEX_PRIORITYCEIL 3
|
||||
|
||||
#define LWP_MUTEX_SUCCESSFUL 0
|
||||
#define LWP_MUTEX_UNSATISFIED_NOWAIT 1
|
||||
#define LWP_MUTEX_NEST_NOTALLOWED 2
|
||||
#define LWP_MUTEX_NOTOWNER 3
|
||||
#define LWP_MUTEX_DELETED 4
|
||||
#define LWP_MUTEX_TIMEOUT 5
|
||||
#define LWP_MUTEX_CEILINGVIOL 6
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _lwpmutexattr {
|
||||
u32 mode;
|
||||
u32 nest_behavior;
|
||||
u8 prioceil,onlyownerrelease;
|
||||
} lwp_mutex_attr;
|
||||
|
||||
typedef struct _lwpmutex {
|
||||
lwp_thrqueue wait_queue;
|
||||
lwp_mutex_attr atrrs;
|
||||
u32 lock,nest_cnt,blocked_cnt;
|
||||
lwp_cntrl *holder;
|
||||
} lwp_mutex;
|
||||
|
||||
void __lwp_mutex_initialize(lwp_mutex *mutex,lwp_mutex_attr *attrs,u32 init_lock);
|
||||
u32 __lwp_mutex_surrender(lwp_mutex *mutex);
|
||||
void __lwp_mutex_seize_irq_blocking(lwp_mutex *mutex,u64 timeout);
|
||||
void __lwp_mutex_flush(lwp_mutex *mutex,u32 status);
|
||||
|
||||
static __inline__ u32 __lwp_mutex_seize_irq_trylock(lwp_mutex *mutex,u32 *isr_level);
|
||||
|
||||
#define __lwp_mutex_seize(_mutex_t,_id,_wait,_timeout,_level) \
|
||||
do { \
|
||||
if(__lwp_mutex_seize_irq_trylock(_mutex_t,&_level)) { \
|
||||
if(!_wait) { \
|
||||
_CPU_ISR_Restore(_level); \
|
||||
_thr_executing->wait.ret_code = LWP_MUTEX_UNSATISFIED_NOWAIT; \
|
||||
} else { \
|
||||
__lwp_threadqueue_csenter(&(_mutex_t)->wait_queue); \
|
||||
_thr_executing->wait.queue = &(_mutex_t)->wait_queue; \
|
||||
_thr_executing->wait.id = _id; \
|
||||
__lwp_thread_dispatchdisable(); \
|
||||
_CPU_ISR_Restore(_level); \
|
||||
__lwp_mutex_seize_irq_blocking(_mutex_t,(u64)_timeout); \
|
||||
} \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#ifdef LIBOGC_INTERNAL
|
||||
#include <libogc/lwp_mutex.inl>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
49
wii/libogc/include/ogc/lwp_objmgr.h
Normal file
49
wii/libogc/include/ogc/lwp_objmgr.h
Normal file
@ -0,0 +1,49 @@
|
||||
#ifndef __LWP_OBJMGR_H__
|
||||
#define __LWP_OBJMGR_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
#include "lwp_queue.h"
|
||||
|
||||
#define LWP_OBJMASKTYPE(type) ((type)<<16)
|
||||
#define LWP_OBJMASKID(id) ((id)&0xffff)
|
||||
#define LWP_OBJTYPE(id) ((id)>>16)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _lwp_objinfo lwp_objinfo;
|
||||
|
||||
typedef struct _lwp_obj {
|
||||
lwp_node node;
|
||||
s32 id;
|
||||
lwp_objinfo *information;
|
||||
} lwp_obj;
|
||||
|
||||
struct _lwp_objinfo {
|
||||
u32 min_id;
|
||||
u32 max_id;
|
||||
u32 max_nodes;
|
||||
u32 node_size;
|
||||
lwp_obj **local_table;
|
||||
void *obj_blocks;
|
||||
lwp_queue inactives;
|
||||
u32 inactives_cnt;
|
||||
};
|
||||
|
||||
void __lwp_objmgr_initinfo(lwp_objinfo *info,u32 max_nodes,u32 node_size);
|
||||
void __lwp_objmgr_free(lwp_objinfo *info,lwp_obj *object);
|
||||
lwp_obj* __lwp_objmgr_allocate(lwp_objinfo *info);
|
||||
lwp_obj* __lwp_objmgr_get(lwp_objinfo *info,u32 id);
|
||||
lwp_obj* __lwp_objmgr_getisrdisable(lwp_objinfo *info,u32 id,u32 *p_level);
|
||||
lwp_obj* __lwp_objmgr_getnoprotection(lwp_objinfo *info,u32 id);
|
||||
|
||||
#ifdef LIBOGC_INTERNAL
|
||||
#include <libogc/lwp_objmgr.inl>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
33
wii/libogc/include/ogc/lwp_priority.h
Normal file
33
wii/libogc/include/ogc/lwp_priority.h
Normal file
@ -0,0 +1,33 @@
|
||||
#ifndef __LWP_PRIORITY_H__
|
||||
#define __LWP_PRIORITY_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
#include "machine/processor.h"
|
||||
|
||||
#define LWP_PRIO_MIN 0
|
||||
#define LWP_PRIO_MAX 255
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _priocntrl {
|
||||
u32 *minor;
|
||||
u32 ready_minor,ready_major;
|
||||
u32 block_minor,block_major;
|
||||
} prio_cntrl;
|
||||
|
||||
extern vu32 _prio_major_bitmap;
|
||||
extern u32 _prio_bitmap[];
|
||||
|
||||
void __lwp_priority_init();
|
||||
|
||||
#ifdef LIBOGC_INTERNAL
|
||||
#include <libogc/lwp_priority.inl>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
41
wii/libogc/include/ogc/lwp_queue.h
Normal file
41
wii/libogc/include/ogc/lwp_queue.h
Normal file
@ -0,0 +1,41 @@
|
||||
#ifndef __LWP_QUEUE_H__
|
||||
#define __LWP_QUEUE_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
//#define _LWPQ_DEBUG
|
||||
|
||||
#ifdef _LWPQ_DEBUG
|
||||
extern int printk(const char *fmt,...);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _lwpnode {
|
||||
struct _lwpnode *next;
|
||||
struct _lwpnode *prev;
|
||||
} lwp_node;
|
||||
|
||||
typedef struct _lwpqueue {
|
||||
lwp_node *first;
|
||||
lwp_node *perm_null;
|
||||
lwp_node *last;
|
||||
} lwp_queue;
|
||||
|
||||
void __lwp_queue_initialize(lwp_queue *,void *,u32,u32);
|
||||
lwp_node* __lwp_queue_get(lwp_queue *);
|
||||
void __lwp_queue_append(lwp_queue *,lwp_node *);
|
||||
void __lwp_queue_extract(lwp_node *);
|
||||
void __lwp_queue_insert(lwp_node *,lwp_node *);
|
||||
|
||||
#ifdef LIBOGC_INTERNAL
|
||||
#include <libogc/lwp_queue.inl>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
44
wii/libogc/include/ogc/lwp_sema.h
Normal file
44
wii/libogc/include/ogc/lwp_sema.h
Normal file
@ -0,0 +1,44 @@
|
||||
#ifndef __LWP_SEMA_H__
|
||||
#define __LWP_SEMA_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
#include <lwp_threadq.h>
|
||||
|
||||
#define LWP_SEMA_MODEFIFO 0
|
||||
#define LWP_SEMA_MODEPRIORITY 1
|
||||
|
||||
#define LWP_SEMA_SUCCESSFUL 0
|
||||
#define LWP_SEMA_UNSATISFIED_NOWAIT 1
|
||||
#define LWP_SEMA_DELETED 2
|
||||
#define LWP_SEMA_TIMEOUT 3
|
||||
#define LWP_SEMA_MAXCNT_EXCEEDED 4
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _lwpsemattr {
|
||||
u32 max_cnt;
|
||||
u32 mode;
|
||||
} lwp_semattr;
|
||||
|
||||
typedef struct _lwpsema {
|
||||
lwp_thrqueue wait_queue;
|
||||
lwp_semattr attrs;
|
||||
u32 count;
|
||||
} lwp_sema;
|
||||
|
||||
void __lwp_sema_initialize(lwp_sema *sema,lwp_semattr *attrs,u32 init_count);
|
||||
u32 __lwp_sema_surrender(lwp_sema *sema,u32 id);
|
||||
u32 __lwp_sema_seize(lwp_sema *sema,u32 id,u32 wait,u64 timeout);
|
||||
void __lwp_sema_flush(lwp_sema *sema,u32 status);
|
||||
|
||||
#ifdef LIBOGC_INTERNAL
|
||||
#include <libogc/lwp_sema.inl>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
27
wii/libogc/include/ogc/lwp_stack.h
Normal file
27
wii/libogc/include/ogc/lwp_stack.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef __LWP_STACK_H__
|
||||
#define __LWP_STACK_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
#include <lwp_threads.h>
|
||||
|
||||
#define CPU_STACK_ALIGNMENT 8
|
||||
#define CPU_MINIMUM_STACK_SIZE 1024*8
|
||||
#define CPU_MINIMUM_STACK_FRAME_SIZE 16
|
||||
#define CPU_MODES_INTERRUPT_MASK 0x00000001 /* interrupt level in mode */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
u32 __lwp_stack_allocate(lwp_cntrl *,u32);
|
||||
void __lwp_stack_free(lwp_cntrl *);
|
||||
|
||||
#ifdef LIBOGC_INTERNAL
|
||||
#include <libogc/lwp_stack.inl>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
48
wii/libogc/include/ogc/lwp_states.h
Normal file
48
wii/libogc/include/ogc/lwp_states.h
Normal file
@ -0,0 +1,48 @@
|
||||
#ifndef ___LWP_STATES_H__
|
||||
#define ___LWP_STATES_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#define LWP_STATES_READY 0x00000000
|
||||
#define LWP_STATES_DORMANT 0x00000001
|
||||
#define LWP_STATES_SUSPENDED 0x00000002
|
||||
#define LWP_STATES_TRANSIENT 0x00000004
|
||||
#define LWP_STATES_DELAYING 0x00000008
|
||||
#define LWP_STATES_WAITING_FOR_TIME 0x00000010
|
||||
#define LWP_STATES_WAITING_FOR_BUFFER 0x00000020
|
||||
#define LWP_STATES_WAITING_FOR_SEGMENT 0x00000040
|
||||
#define LWP_STATES_WAITING_FOR_MESSAGE 0x00000080
|
||||
#define LWP_STATES_WAITING_FOR_EVENT 0x00000100
|
||||
#define LWP_STATES_WAITING_FOR_MUTEX 0x00000200
|
||||
#define LWP_STATES_WAITING_FOR_SEMAPHORE 0x00000400
|
||||
#define LWP_STATES_WAITING_FOR_CONDVAR 0x00000800
|
||||
#define LWP_STATES_WAITING_FOR_JOINATEXIT 0x00001000
|
||||
#define LWP_STATES_WAITING_FOR_RPCREPLAY 0x00002000
|
||||
#define LWP_STATES_WAITING_FOR_PERIOD 0x00004000
|
||||
#define LWP_STATES_WAITING_FOR_SIGNAL 0x00008000
|
||||
#define LWP_STATES_INTERRUPTIBLE_BY_SIGNAL 0x00010000
|
||||
|
||||
#define LWP_STATES_LOCALLY_BLOCKED (LWP_STATES_WAITING_FOR_BUFFER | LWP_STATES_WAITING_FOR_SEGMENT | \
|
||||
LWP_STATES_WAITING_FOR_MESSAGE | LWP_STATES_WAITING_FOR_SEMAPHORE | \
|
||||
LWP_STATES_WAITING_FOR_MUTEX | LWP_STATES_WAITING_FOR_CONDVAR | \
|
||||
LWP_STATES_WAITING_FOR_JOINATEXIT | LWP_STATES_WAITING_FOR_SIGNAL)
|
||||
|
||||
#define LWP_STATES_WAITING_ON_THREADQ (LWP_STATES_LOCALLY_BLOCKED | LWP_STATES_WAITING_FOR_RPCREPLAY)
|
||||
|
||||
#define LWP_STATES_BLOCKED (LWP_STATES_DELAYING | LWP_STATES_WAITING_FOR_TIME | \
|
||||
LWP_STATES_WAITING_FOR_PERIOD | LWP_STATES_WAITING_FOR_EVENT | \
|
||||
LWP_STATES_WAITING_ON_THREADQ | LWP_STATES_INTERRUPTIBLE_BY_SIGNAL)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef LIBOGC_INTERNAL
|
||||
#include <libogc/lwp_states.inl>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
39
wii/libogc/include/ogc/lwp_threadq.h
Normal file
39
wii/libogc/include/ogc/lwp_threadq.h
Normal file
@ -0,0 +1,39 @@
|
||||
#ifndef __LWP_THREADQ_H__
|
||||
#define __LWP_THREADQ_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
#include <lwp_tqdata.h>
|
||||
#include <lwp_threads.h>
|
||||
#include <lwp_watchdog.h>
|
||||
|
||||
#define LWP_THREADQ_NOTIMEOUT LWP_WD_NOTIMEOUT
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
lwp_cntrl* __lwp_threadqueue_firstfifo(lwp_thrqueue *queue);
|
||||
lwp_cntrl* __lwp_threadqueue_firstpriority(lwp_thrqueue *queue);
|
||||
void __lwp_threadqueue_enqueuefifo(lwp_thrqueue *queue,lwp_cntrl *thethread,u64 timeout);
|
||||
lwp_cntrl* __lwp_threadqueue_dequeuefifo(lwp_thrqueue *queue);
|
||||
void __lwp_threadqueue_enqueuepriority(lwp_thrqueue *queue,lwp_cntrl *thethread,u64 timeout);
|
||||
lwp_cntrl* __lwp_threadqueue_dequeuepriority(lwp_thrqueue *queue);
|
||||
void __lwp_threadqueue_init(lwp_thrqueue *queue,u32 mode,u32 state,u32 timeout_state);
|
||||
lwp_cntrl* __lwp_threadqueue_first(lwp_thrqueue *queue);
|
||||
void __lwp_threadqueue_enqueue(lwp_thrqueue *queue,u64 timeout);
|
||||
lwp_cntrl* __lwp_threadqueue_dequeue(lwp_thrqueue *queue);
|
||||
void __lwp_threadqueue_flush(lwp_thrqueue *queue,u32 status);
|
||||
void __lwp_threadqueue_extract(lwp_thrqueue *queue,lwp_cntrl *thethread);
|
||||
void __lwp_threadqueue_extractfifo(lwp_thrqueue *queue,lwp_cntrl *thethread);
|
||||
void __lwp_threadqueue_extractpriority(lwp_thrqueue *queue,lwp_cntrl *thethread);
|
||||
u32 __lwp_threadqueue_extractproxy(lwp_cntrl *thethread);
|
||||
|
||||
#ifdef LIBOGC_INTERNAL
|
||||
#include <libogc/lwp_threadq.inl>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
107
wii/libogc/include/ogc/lwp_threads.h
Normal file
107
wii/libogc/include/ogc/lwp_threads.h
Normal file
@ -0,0 +1,107 @@
|
||||
#ifndef __LWP_THREADS_H__
|
||||
#define __LWP_THREADS_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
#include <stdlib.h>
|
||||
#include "lwp_states.h"
|
||||
#include "lwp_tqdata.h"
|
||||
#include "lwp_watchdog.h"
|
||||
#include "lwp_objmgr.h"
|
||||
#include "context.h"
|
||||
|
||||
//#define _LWPTHREADS_DEBUG
|
||||
#define LWP_TIMESLICE_TIMER_ID 0x00070040
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LWP_CPU_BUDGET_ALGO_NONE = 0,
|
||||
LWP_CPU_BUDGET_ALGO_TIMESLICE
|
||||
} lwp_cpu_budget_algorithms;
|
||||
|
||||
typedef struct _lwpwaitinfo {
|
||||
u32 id;
|
||||
u32 cnt;
|
||||
void *ret_arg;
|
||||
void *ret_arg_1;
|
||||
u32 option;
|
||||
u32 ret_code;
|
||||
lwp_queue block2n;
|
||||
lwp_thrqueue *queue;
|
||||
} lwp_waitinfo;
|
||||
|
||||
typedef struct _lwpcntrl {
|
||||
lwp_obj object;
|
||||
u8 cur_prio,real_prio;
|
||||
u32 suspendcnt,res_cnt;
|
||||
u32 isr_level;
|
||||
u32 cur_state;
|
||||
u32 cpu_time_budget;
|
||||
lwp_cpu_budget_algorithms budget_algo;
|
||||
bool is_preemptible;
|
||||
lwp_waitinfo wait;
|
||||
prio_cntrl priomap;
|
||||
wd_cntrl timer;
|
||||
|
||||
void* (*entry)(void *);
|
||||
void *arg;
|
||||
void *stack;
|
||||
u32 stack_size;
|
||||
u8 stack_allocated;
|
||||
lwp_queue *ready;
|
||||
lwp_thrqueue join_list;
|
||||
frame_context context; //16
|
||||
void *libc_reent;
|
||||
} lwp_cntrl, *lwp_cntrl_t;
|
||||
|
||||
extern lwp_cntrl *_thr_main;
|
||||
extern lwp_cntrl *_thr_idle;
|
||||
extern lwp_cntrl *_thr_executing;
|
||||
extern lwp_cntrl *_thr_heir;
|
||||
extern lwp_cntrl *_thr_allocated_fp;
|
||||
extern vu32 _context_switch_want;
|
||||
extern vu32 _thread_dispatch_disable_level;
|
||||
|
||||
extern wd_cntrl _lwp_wd_timeslice;
|
||||
extern void **__lwp_thr_libc_reent;
|
||||
extern lwp_queue _lwp_thr_ready[];
|
||||
|
||||
void __thread_dispatch();
|
||||
void __lwp_thread_yield();
|
||||
void __lwp_thread_closeall();
|
||||
void __lwp_thread_setstate(lwp_cntrl *,u32);
|
||||
void __lwp_thread_clearstate(lwp_cntrl *,u32);
|
||||
void __lwp_thread_changepriority(lwp_cntrl *,u32,u32);
|
||||
void __lwp_thread_setpriority(lwp_cntrl *,u32);
|
||||
void __lwp_thread_settransient(lwp_cntrl *);
|
||||
void __lwp_thread_suspend(lwp_cntrl *);
|
||||
void __lwp_thread_resume(lwp_cntrl *,u32);
|
||||
void __lwp_thread_loadenv(lwp_cntrl *);
|
||||
void __lwp_thread_ready(lwp_cntrl *);
|
||||
u32 __lwp_thread_init(lwp_cntrl *,void *,u32,u32,u32,bool);
|
||||
u32 __lwp_thread_start(lwp_cntrl *,void* (*)(void*),void *);
|
||||
void __lwp_thread_exit(void *);
|
||||
void __lwp_thread_close(lwp_cntrl *);
|
||||
void __lwp_thread_startmultitasking();
|
||||
void __lwp_thread_stopmultitasking(void (*exitfunc)());
|
||||
lwp_obj* __lwp_thread_getobject(lwp_cntrl *);
|
||||
u32 __lwp_evaluatemode();
|
||||
|
||||
u32 __lwp_isr_in_progress();
|
||||
void __lwp_thread_resettimeslice();
|
||||
void __lwp_rotate_readyqueue(u32);
|
||||
void __lwp_thread_delayended(void *);
|
||||
void __lwp_thread_tickle_timeslice(void *);
|
||||
|
||||
#ifdef LIBOGC_INTERNAL
|
||||
#include <libogc/lwp_threads.inl>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
38
wii/libogc/include/ogc/lwp_tqdata.h
Normal file
38
wii/libogc/include/ogc/lwp_tqdata.h
Normal file
@ -0,0 +1,38 @@
|
||||
#ifndef __LWP_TQDATA_H__
|
||||
#define __LWP_TQDATA_H__
|
||||
|
||||
#define LWP_THREADQ_NUM_PRIOHEADERS 4
|
||||
#define LWP_THREADQ_PRIOPERHEADER 64
|
||||
#define LWP_THREADQ_REVERSESEARCHMASK 0x20
|
||||
|
||||
#define LWP_THREADQ_SYNCHRONIZED 0
|
||||
#define LWP_THREADQ_NOTHINGHAPPEND 1
|
||||
#define LWP_THREADQ_TIMEOUT 2
|
||||
#define LWP_THREADQ_SATISFIED 3
|
||||
|
||||
#define LWP_THREADQ_MODEFIFO 0
|
||||
#define LWP_THREADQ_MODEPRIORITY 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "lwp_queue.h"
|
||||
#include "lwp_priority.h"
|
||||
|
||||
typedef struct _lwpthrqueue {
|
||||
union {
|
||||
lwp_queue fifo;
|
||||
lwp_queue priority[LWP_THREADQ_NUM_PRIOHEADERS];
|
||||
} queues;
|
||||
u32 sync_state;
|
||||
u32 mode;
|
||||
u32 state;
|
||||
u32 timeout_state;
|
||||
} lwp_thrqueue;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
107
wii/libogc/include/ogc/lwp_watchdog.h
Normal file
107
wii/libogc/include/ogc/lwp_watchdog.h
Normal file
@ -0,0 +1,107 @@
|
||||
#ifndef __LWP_WATCHDOG_H__
|
||||
#define __LWP_WATCHDOG_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
#include "lwp_queue.h"
|
||||
#include <time.h>
|
||||
|
||||
#if defined(HW_RVL)
|
||||
#define TB_BUS_CLOCK 243000000u
|
||||
#define TB_CORE_CLOCK 729000000u
|
||||
#elif defined(HW_DOL)
|
||||
#define TB_BUS_CLOCK 162000000u
|
||||
#define TB_CORE_CLOCK 486000000u
|
||||
#endif
|
||||
#define TB_TIMER_CLOCK (TB_BUS_CLOCK/4000) //4th of the bus frequency
|
||||
|
||||
#define TB_SECSPERMIN 60
|
||||
#define TB_MINSPERHR 60
|
||||
#define TB_MONSPERYR 12
|
||||
#define TB_DAYSPERYR 365
|
||||
#define TB_HRSPERDAY 24
|
||||
#define TB_SECSPERDAY (TB_SECSPERMIN*TB_MINSPERHR*TB_HRSPERDAY)
|
||||
#define TB_SECSPERNYR (365*TB_SECSPERDAY)
|
||||
|
||||
#define TB_MSPERSEC 1000
|
||||
#define TB_USPERSEC 1000000
|
||||
#define TB_NSPERSEC 1000000000
|
||||
#define TB_NSPERMS 1000000
|
||||
#define TB_NSPERUS 1000
|
||||
#define TB_USPERTICK 10000
|
||||
|
||||
#define ticks_to_cycles(ticks) ((((u64)(ticks)*(u64)((TB_CORE_CLOCK*2)/TB_TIMER_CLOCK))/2))
|
||||
#define ticks_to_secs(ticks) (((u64)(ticks)/(u64)(TB_TIMER_CLOCK*1000)))
|
||||
#define ticks_to_millisecs(ticks) (((u64)(ticks)/(u64)(TB_TIMER_CLOCK)))
|
||||
#define ticks_to_microsecs(ticks) ((((u64)(ticks)*8)/(u64)(TB_TIMER_CLOCK/125)))
|
||||
#define ticks_to_nanosecs(ticks) ((((u64)(ticks)*8000)/(u64)(TB_TIMER_CLOCK/125)))
|
||||
|
||||
#define tick_microsecs(ticks) ((((u64)(ticks)*8)%(u64)(TB_TIMER_CLOCK/125)))
|
||||
#define tick_nanosecs(ticks) ((((u64)(ticks)*8000)%(u64)(TB_TIMER_CLOCK/125)))
|
||||
|
||||
|
||||
#define secs_to_ticks(sec) ((u64)(sec)*(TB_TIMER_CLOCK*1000))
|
||||
#define millisecs_to_ticks(msec) ((u64)(msec)*(TB_TIMER_CLOCK))
|
||||
#define microsecs_to_ticks(usec) (((u64)(usec)*(TB_TIMER_CLOCK/125))/8)
|
||||
#define nanosecs_to_ticks(nsec) (((u64)(nsec)*(TB_TIMER_CLOCK/125))/8000)
|
||||
|
||||
#define diff_ticks(tick0,tick1) (((u64)(tick1)<(u64)(tick0))?((u64)-1-(u64)(tick0)+(u64)(tick1)):((u64)(tick1)-(u64)(tick0)))
|
||||
|
||||
#define LWP_WD_INACTIVE 0
|
||||
#define LWP_WD_INSERTED 1
|
||||
#define LWP_WD_ACTIVE 2
|
||||
#define LWP_WD_REMOVE 3
|
||||
|
||||
#define LWP_WD_FORWARD 0
|
||||
#define LWP_WD_BACKWARD 1
|
||||
|
||||
#define LWP_WD_NOTIMEOUT 0
|
||||
|
||||
#define LWP_WD_ABS(x) ((s64)(x)>0?(s64)(x):-((s64)(x)))
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern vu32 _wd_sync_level;
|
||||
extern vu32 _wd_sync_count;
|
||||
extern u32 _wd_ticks_since_boot;
|
||||
|
||||
extern lwp_queue _wd_ticks_queue;
|
||||
|
||||
extern u32 gettick();
|
||||
extern u64 gettime();
|
||||
extern void settime(u64);
|
||||
|
||||
u32 diff_sec(u64 start,u64 end);
|
||||
u32 diff_msec(u64 start,u64 end);
|
||||
u32 diff_usec(u64 start,u64 end);
|
||||
u32 diff_nsec(u64 start,u64 end);
|
||||
|
||||
typedef void (*wd_service_routine)(void *);
|
||||
|
||||
typedef struct _wdcntrl {
|
||||
lwp_node node;
|
||||
u64 start;
|
||||
u32 id;
|
||||
u32 state;
|
||||
u64 fire;
|
||||
wd_service_routine routine;
|
||||
void *usr_data;
|
||||
} wd_cntrl;
|
||||
|
||||
void __lwp_watchdog_init();
|
||||
void __lwp_watchdog_settimer(wd_cntrl *wd);
|
||||
void __lwp_wd_insert(lwp_queue *header,wd_cntrl *wd);
|
||||
u32 __lwp_wd_remove(lwp_queue *header,wd_cntrl *wd);
|
||||
void __lwp_wd_tickle(lwp_queue *queue);
|
||||
void __lwp_wd_adjust(lwp_queue *queue,u32 dir,s64 interval);
|
||||
|
||||
#ifdef LIBOGC_INTERNAL
|
||||
#include <libogc/lwp_watchdog.inl>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
23
wii/libogc/include/ogc/lwp_wkspace.h
Normal file
23
wii/libogc/include/ogc/lwp_wkspace.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef __LWP_WKSPACE_H__
|
||||
#define __LWP_WKSPACE_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
#include <lwp_heap.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern heap_cntrl __wkspace_heap;
|
||||
|
||||
void __lwp_wkspace_init(u32 size);
|
||||
|
||||
#ifdef LIBOGC_INTERNAL
|
||||
#include <libogc/lwp_wkspace.inl>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
338
wii/libogc/include/ogc/machine/asm.h
Normal file
338
wii/libogc/include/ogc/machine/asm.h
Normal file
@ -0,0 +1,338 @@
|
||||
#ifndef __ASM_H__
|
||||
#define __ASM_H__
|
||||
|
||||
#ifdef _LANGUAGE_ASSEMBLY
|
||||
/* Condition Register Bit Fields */
|
||||
|
||||
#define cr0 0
|
||||
#define cr1 1
|
||||
#define cr2 2
|
||||
#define cr3 3
|
||||
#define cr4 4
|
||||
#define cr5 5
|
||||
#define cr6 6
|
||||
#define cr7 7
|
||||
|
||||
|
||||
/* General Purpose Registers (GPRs) */
|
||||
|
||||
#define r0 0
|
||||
#define r1 1
|
||||
#define sp 1
|
||||
#define r2 2
|
||||
#define toc 2
|
||||
#define r3 3
|
||||
#define r4 4
|
||||
#define r5 5
|
||||
#define r6 6
|
||||
#define r7 7
|
||||
#define r8 8
|
||||
#define r9 9
|
||||
#define r10 10
|
||||
#define r11 11
|
||||
#define r12 12
|
||||
#define r13 13
|
||||
#define r14 14
|
||||
#define r15 15
|
||||
#define r16 16
|
||||
#define r17 17
|
||||
#define r18 18
|
||||
#define r19 19
|
||||
#define r20 20
|
||||
#define r21 21
|
||||
#define r22 22
|
||||
#define r23 23
|
||||
#define r24 24
|
||||
#define r25 25
|
||||
#define r26 26
|
||||
#define r27 27
|
||||
#define r28 28
|
||||
#define r29 29
|
||||
#define r30 30
|
||||
#define r31 31
|
||||
|
||||
|
||||
/* Floating Point Registers (FPRs) */
|
||||
|
||||
#define fr0 0
|
||||
#define fr1 1
|
||||
#define fr2 2
|
||||
#define fr3 3
|
||||
#define fr4 4
|
||||
#define fr5 5
|
||||
#define fr6 6
|
||||
#define fr7 7
|
||||
#define fr8 8
|
||||
#define fr9 9
|
||||
#define fr10 10
|
||||
#define fr11 11
|
||||
#define fr12 12
|
||||
#define fr13 13
|
||||
#define fr14 14
|
||||
#define fr15 15
|
||||
#define fr16 16
|
||||
#define fr17 17
|
||||
#define fr18 18
|
||||
#define fr19 19
|
||||
#define fr20 20
|
||||
#define fr21 21
|
||||
#define fr22 22
|
||||
#define fr23 23
|
||||
#define fr24 24
|
||||
#define fr25 25
|
||||
#define fr26 26
|
||||
#define fr27 27
|
||||
#define fr28 28
|
||||
#define fr29 29
|
||||
#define fr30 30
|
||||
#define fr31 31
|
||||
|
||||
#define vr0 0
|
||||
#define vr1 1
|
||||
#define vr2 2
|
||||
#define vr3 3
|
||||
#define vr4 4
|
||||
#define vr5 5
|
||||
#define vr6 6
|
||||
#define vr7 7
|
||||
#define vr8 8
|
||||
#define vr9 9
|
||||
#define vr10 10
|
||||
#define vr11 11
|
||||
#define vr12 12
|
||||
#define vr13 13
|
||||
#define vr14 14
|
||||
#define vr15 15
|
||||
#define vr16 16
|
||||
#define vr17 17
|
||||
#define vr18 18
|
||||
#define vr19 19
|
||||
#define vr20 20
|
||||
#define vr21 21
|
||||
#define vr22 22
|
||||
#define vr23 23
|
||||
#define vr24 24
|
||||
#define vr25 25
|
||||
#define vr26 26
|
||||
#define vr27 27
|
||||
#define vr28 28
|
||||
#define vr29 29
|
||||
#define vr30 30
|
||||
#define vr31 31
|
||||
|
||||
#endif //_LANGUAGE_ASSEMBLY
|
||||
|
||||
#define SPRG0 272
|
||||
#define SPRG1 273
|
||||
#define SPRG2 274
|
||||
#define SPRG3 275
|
||||
|
||||
#define PMC1 953
|
||||
#define PMC2 954
|
||||
#define PMC3 957
|
||||
#define PMC4 958
|
||||
|
||||
#define MMCR0 952
|
||||
#define MMCR1 956
|
||||
|
||||
|
||||
#define LINK_REGISTER_CALLEE_UPDATE_ROOM 4
|
||||
#define EXCEPTION_NUMBER 8
|
||||
#define SRR0_OFFSET 12
|
||||
#define SRR1_OFFSET 16
|
||||
#define GPR0_OFFSET 20
|
||||
#define GPR1_OFFSET 24
|
||||
#define GPR2_OFFSET 28
|
||||
#define GPR3_OFFSET 32
|
||||
#define GPR4_OFFSET 36
|
||||
#define GPR5_OFFSET 40
|
||||
#define GPR6_OFFSET 44
|
||||
#define GPR7_OFFSET 48
|
||||
#define GPR8_OFFSET 52
|
||||
#define GPR9_OFFSET 56
|
||||
#define GPR10_OFFSET 60
|
||||
#define GPR11_OFFSET 64
|
||||
#define GPR12_OFFSET 68
|
||||
#define GPR13_OFFSET 72
|
||||
#define GPR14_OFFSET 76
|
||||
#define GPR15_OFFSET 80
|
||||
#define GPR16_OFFSET 84
|
||||
#define GPR17_OFFSET 88
|
||||
#define GPR18_OFFSET 92
|
||||
#define GPR19_OFFSET 96
|
||||
#define GPR20_OFFSET 100
|
||||
#define GPR21_OFFSET 104
|
||||
#define GPR22_OFFSET 108
|
||||
#define GPR23_OFFSET 112
|
||||
#define GPR24_OFFSET 116
|
||||
#define GPR25_OFFSET 120
|
||||
#define GPR26_OFFSET 124
|
||||
#define GPR27_OFFSET 128
|
||||
#define GPR28_OFFSET 132
|
||||
#define GPR29_OFFSET 136
|
||||
#define GPR30_OFFSET 140
|
||||
#define GPR31_OFFSET 144
|
||||
|
||||
#define GQR0_OFFSET 148
|
||||
#define GQR1_OFFSET 152
|
||||
#define GQR2_OFFSET 156
|
||||
#define GQR3_OFFSET 160
|
||||
#define GQR4_OFFSET 164
|
||||
#define GQR5_OFFSET 168
|
||||
#define GQR6_OFFSET 172
|
||||
#define GQR7_OFFSET 176
|
||||
|
||||
#define CR_OFFSET 180
|
||||
#define LR_OFFSET 184
|
||||
#define CTR_OFFSET 188
|
||||
#define XER_OFFSET 192
|
||||
#define MSR_OFFSET 196
|
||||
#define DAR_OFFSET 200
|
||||
|
||||
#define STATE_OFFSET 204
|
||||
#define MODE_OFFSET 206
|
||||
|
||||
#define FPR0_OFFSET 208
|
||||
#define FPR1_OFFSET 216
|
||||
#define FPR2_OFFSET 224
|
||||
#define FPR3_OFFSET 232
|
||||
#define FPR4_OFFSET 240
|
||||
#define FPR5_OFFSET 248
|
||||
#define FPR6_OFFSET 256
|
||||
#define FPR7_OFFSET 264
|
||||
#define FPR8_OFFSET 272
|
||||
#define FPR9_OFFSET 280
|
||||
#define FPR10_OFFSET 288
|
||||
#define FPR11_OFFSET 296
|
||||
#define FPR12_OFFSET 304
|
||||
#define FPR13_OFFSET 312
|
||||
#define FPR14_OFFSET 320
|
||||
#define FPR15_OFFSET 328
|
||||
#define FPR16_OFFSET 336
|
||||
#define FPR17_OFFSET 344
|
||||
#define FPR18_OFFSET 352
|
||||
#define FPR19_OFFSET 360
|
||||
#define FPR20_OFFSET 368
|
||||
#define FPR21_OFFSET 376
|
||||
#define FPR22_OFFSET 384
|
||||
#define FPR23_OFFSET 392
|
||||
#define FPR24_OFFSET 400
|
||||
#define FPR25_OFFSET 408
|
||||
#define FPR26_OFFSET 416
|
||||
#define FPR27_OFFSET 424
|
||||
#define FPR28_OFFSET 432
|
||||
#define FPR29_OFFSET 440
|
||||
#define FPR30_OFFSET 448
|
||||
#define FPR31_OFFSET 456
|
||||
|
||||
#define FPSCR_OFFSET 464
|
||||
|
||||
#define PSR0_OFFSET 472
|
||||
#define PSR1_OFFSET 480
|
||||
#define PSR2_OFFSET 488
|
||||
#define PSR3_OFFSET 496
|
||||
#define PSR4_OFFSET 504
|
||||
#define PSR5_OFFSET 512
|
||||
#define PSR6_OFFSET 520
|
||||
#define PSR7_OFFSET 528
|
||||
#define PSR8_OFFSET 536
|
||||
#define PSR9_OFFSET 544
|
||||
#define PSR10_OFFSET 552
|
||||
#define PSR11_OFFSET 560
|
||||
#define PSR12_OFFSET 568
|
||||
#define PSR13_OFFSET 576
|
||||
#define PSR14_OFFSET 584
|
||||
#define PSR15_OFFSET 592
|
||||
#define PSR16_OFFSET 600
|
||||
#define PSR17_OFFSET 608
|
||||
#define PSR18_OFFSET 616
|
||||
#define PSR19_OFFSET 624
|
||||
#define PSR20_OFFSET 632
|
||||
#define PSR21_OFFSET 640
|
||||
#define PSR22_OFFSET 648
|
||||
#define PSR23_OFFSET 656
|
||||
#define PSR24_OFFSET 664
|
||||
#define PSR25_OFFSET 672
|
||||
#define PSR26_OFFSET 680
|
||||
#define PSR27_OFFSET 688
|
||||
#define PSR28_OFFSET 696
|
||||
#define PSR29_OFFSET 704
|
||||
#define PSR30_OFFSET 712
|
||||
#define PSR31_OFFSET 720
|
||||
/*
|
||||
* maintain the EABI requested 8 bytes aligment
|
||||
* As SVR4 ABI requires 16, make it 16 (as some
|
||||
* exception may need more registers to be processed...)
|
||||
*/
|
||||
#define EXCEPTION_FRAME_END 728
|
||||
|
||||
#define IBAT0U 528
|
||||
#define IBAT0L 529
|
||||
#define IBAT1U 530
|
||||
#define IBAT1L 531
|
||||
#define IBAT2U 532
|
||||
#define IBAT2L 533
|
||||
#define IBAT3U 534
|
||||
#define IBAT3L 535
|
||||
#define IBAT4U 560
|
||||
#define IBAT4L 561
|
||||
#define IBAT5U 562
|
||||
#define IBAT5L 563
|
||||
#define IBAT6U 564
|
||||
#define IBAT6L 565
|
||||
#define IBAT7U 566
|
||||
#define IBAT7L 567
|
||||
|
||||
#define DBAT0U 536
|
||||
#define DBAT0L 537
|
||||
#define DBAT1U 538
|
||||
#define DBAT1L 539
|
||||
#define DBAT2U 540
|
||||
#define DBAT2L 541
|
||||
#define DBAT3U 542
|
||||
#define DBAT3L 543
|
||||
#define DBAT4U 568
|
||||
#define DBAT4L 569
|
||||
#define DBAT5U 570
|
||||
#define DBAT5L 571
|
||||
#define DBAT6U 572
|
||||
#define DBAT6L 573
|
||||
#define DBAT7U 574
|
||||
#define DBAT7L 575
|
||||
|
||||
#define HID0 1008
|
||||
#define HID1 1009
|
||||
#define HID2 920
|
||||
#define HID4 1011
|
||||
|
||||
#define GQR0 912
|
||||
#define GQR1 913
|
||||
#define GQR2 914
|
||||
#define GQR3 915
|
||||
#define GQR4 916
|
||||
#define GQR5 917
|
||||
#define GQR6 918
|
||||
#define GQR7 919
|
||||
|
||||
#define L2CR 1017
|
||||
|
||||
#define WPAR 921
|
||||
|
||||
#define DMAU 922
|
||||
#define DMAL 923
|
||||
|
||||
#define MSR_RI 0x00000002
|
||||
#define MSR_DR 0x00000010
|
||||
#define MSR_IR 0x00000020
|
||||
#define MSR_IP 0x00000040
|
||||
#define MSR_SE 0x00000400
|
||||
#define MSR_ME 0x00001000
|
||||
#define MSR_FP 0x00002000
|
||||
#define MSR_POW 0x00004000
|
||||
#define MSR_EE 0x00008000
|
||||
|
||||
#define PPC_ALIGNMENT 8
|
||||
|
||||
#define PPC_CACHE_ALIGNMENT 32
|
||||
|
||||
#endif //__ASM_H__
|
251
wii/libogc/include/ogc/machine/processor.h
Normal file
251
wii/libogc/include/ogc/machine/processor.h
Normal file
@ -0,0 +1,251 @@
|
||||
#ifndef __PROCESSOR_H__
|
||||
#define __PROCESSOR_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
#include "asm.h"
|
||||
|
||||
#define __stringify(rn) #rn
|
||||
#define ATTRIBUTE_ALIGN(v) __attribute__((aligned(v)))
|
||||
// courtesy of Marcan
|
||||
#define STACK_ALIGN(type, name, cnt, alignment) u8 _al__##name[((sizeof(type)*(cnt)) + (alignment) + (((sizeof(type)*(cnt))%(alignment)) > 0 ? ((alignment) - ((sizeof(type)*(cnt))%(alignment))) : 0))]; \
|
||||
type *name = (type*)(((u32)(_al__##name)) + ((alignment) - (((u32)(_al__##name))&((alignment)-1))))
|
||||
|
||||
#define _sync() asm volatile("sync")
|
||||
#define _nop() asm volatile("nop")
|
||||
#define ppcsync() asm volatile("sc")
|
||||
#define ppchalt() ({ \
|
||||
asm volatile("sync"); \
|
||||
while(1) { \
|
||||
asm volatile("nop"); \
|
||||
asm volatile("li 3,0"); \
|
||||
asm volatile("nop"); \
|
||||
} \
|
||||
})
|
||||
|
||||
#define mfpvr() ({register u32 _rval; \
|
||||
asm volatile("mfpvr %0" : "=r"(_rval)); _rval;})
|
||||
|
||||
#define mfdcr(_rn) ({register u32 _rval; \
|
||||
asm volatile("mfdcr %0," __stringify(_rn) \
|
||||
: "=r" (_rval)); _rval;})
|
||||
#define mtdcr(rn, val) asm volatile("mtdcr " __stringify(rn) ",%0" : : "r" (val))
|
||||
|
||||
#define mfmsr() ({register u32 _rval; \
|
||||
asm volatile("mfmsr %0" : "=r" (_rval)); _rval;})
|
||||
#define mtmsr(val) asm volatile("mtmsr %0" : : "r" (val))
|
||||
|
||||
#define mfdec() ({register u32 _rval; \
|
||||
asm volatile("mfdec %0" : "=r" (_rval)); _rval;})
|
||||
#define mtdec(_val) asm volatile("mtdec %0" : : "r" (_val))
|
||||
|
||||
#define mfspr(_rn) \
|
||||
({ register u32 _rval = 0; \
|
||||
asm volatile("mfspr %0," __stringify(_rn) \
|
||||
: "=r" (_rval));\
|
||||
_rval; \
|
||||
})
|
||||
|
||||
#define mtspr(_rn, _val) asm volatile("mtspr " __stringify(_rn) ",%0" : : "r" (_val))
|
||||
|
||||
#define mfwpar() mfspr(WPAR)
|
||||
#define mtwpar(_val) mtspr(WPAR,_val)
|
||||
|
||||
#define mfmmcr0() mfspr(MMCR0)
|
||||
#define mtmmcr0(_val) mtspr(MMCR0,_val)
|
||||
#define mfmmcr1() mfspr(MMCR1)
|
||||
#define mtmmcr1(_val) mtspr(MMCR1,_val)
|
||||
|
||||
#define mfpmc1() mfspr(PMC1)
|
||||
#define mtpmc1(_val) mtspr(PMC1,_val)
|
||||
#define mfpmc2() mfspr(PMC2)
|
||||
#define mtpmc2(_val) mtspr(PMC2,_val)
|
||||
#define mfpmc3() mfspr(PMC3)
|
||||
#define mtpmc3(_val) mtspr(PMC3,_val)
|
||||
#define mfpmc4() mfspr(PMC4)
|
||||
#define mtpmc4(_val) mtspr(PMC4,_val)
|
||||
|
||||
#define mfhid0() mfspr(HID0)
|
||||
#define mthid0(_val) mtspr(HID0,_val)
|
||||
#define mfhid1() mfspr(HID1)
|
||||
#define mthid1(_val) mtspr(HID1,_val)
|
||||
#define mfhid2() mfspr(HID2)
|
||||
#define mthid2(_val) mtspr(HID2,_val)
|
||||
#define mfhid4() mfspr(HID4)
|
||||
#define mthid4(_val) mtspr(HID4,_val)
|
||||
|
||||
#define __lhbrx(base,index) \
|
||||
({ register u16 res; \
|
||||
__asm__ volatile ("lhbrx %0,%1,%2" : "=r"(res) : "b%"(index), "r"(base) : "memory"); \
|
||||
res; })
|
||||
|
||||
#define __lwbrx(base,index) \
|
||||
({ register u32 res; \
|
||||
__asm__ volatile ("lwbrx %0,%1,%2" : "=r"(res) : "b%"(index), "r"(base) : "memory"); \
|
||||
res; })
|
||||
|
||||
#define __sthbrx(base,index,value) \
|
||||
__asm__ volatile ("sthbrx %0,%1,%2" : : "r"(value), "b%"(index), "r"(base) : "memory")
|
||||
|
||||
#define __stwbrx(base,index,value) \
|
||||
__asm__ volatile ("stwbrx %0,%1,%2" : : "r"(value), "b%"(index), "r"(base) : "memory")
|
||||
|
||||
#define cntlzw(_val) ({register u32 _rval; \
|
||||
asm volatile("cntlzw %0, %1" : "=r"((_rval)) : "r"((_val))); _rval;})
|
||||
|
||||
#define _CPU_MSR_GET( _msr_value ) \
|
||||
do { \
|
||||
_msr_value = 0; \
|
||||
asm volatile ("mfmsr %0" : "=&r" ((_msr_value)) : "0" ((_msr_value))); \
|
||||
} while (0)
|
||||
|
||||
#define _CPU_MSR_SET( _msr_value ) \
|
||||
{ asm volatile ("mtmsr %0" : "=&r" ((_msr_value)) : "0" ((_msr_value))); }
|
||||
|
||||
#define _CPU_ISR_Enable() \
|
||||
{ register u32 _val = 0; \
|
||||
__asm__ __volatile__ ( \
|
||||
"mfmsr %0\n" \
|
||||
"ori %0,%0,0x8000\n" \
|
||||
"mtmsr %0" \
|
||||
: "=&r" ((_val)) : "0" ((_val)) \
|
||||
); \
|
||||
}
|
||||
|
||||
#define _CPU_ISR_Disable( _isr_cookie ) \
|
||||
{ register u32 _disable_mask = 0; \
|
||||
_isr_cookie = 0; \
|
||||
__asm__ __volatile__ ( \
|
||||
"mfmsr %0\n" \
|
||||
"rlwinm %1,%0,0,17,15\n" \
|
||||
"mtmsr %1\n" \
|
||||
"extrwi %0,%0,1,16" \
|
||||
: "=&r" ((_isr_cookie)), "=&r" ((_disable_mask)) \
|
||||
: "0" ((_isr_cookie)), "1" ((_disable_mask)) \
|
||||
); \
|
||||
}
|
||||
|
||||
#define _CPU_ISR_Restore( _isr_cookie ) \
|
||||
{ register u32 _enable_mask = 0; \
|
||||
__asm__ __volatile__ ( \
|
||||
" cmpwi %0,0\n" \
|
||||
" beq 1f\n" \
|
||||
" mfmsr %1\n" \
|
||||
" ori %1,%1,0x8000\n" \
|
||||
" mtmsr %1\n" \
|
||||
"1:" \
|
||||
: "=r"((_isr_cookie)),"=&r" ((_enable_mask)) \
|
||||
: "0"((_isr_cookie)),"1" ((_enable_mask)) \
|
||||
); \
|
||||
}
|
||||
|
||||
#define _CPU_ISR_Flash( _isr_cookie ) \
|
||||
{ register u32 _flash_mask = 0; \
|
||||
__asm__ __volatile__ ( \
|
||||
" cmpwi %0,0\n" \
|
||||
" beq 1f\n" \
|
||||
" mfmsr %1\n" \
|
||||
" ori %1,%1,0x8000\n" \
|
||||
" mtmsr %1\n" \
|
||||
" rlwinm %1,%1,0,17,15\n" \
|
||||
" mtmsr %1\n" \
|
||||
"1:" \
|
||||
: "=r" ((_isr_cookie)), "=&r" ((_flash_mask)) \
|
||||
: "0" ((_isr_cookie)), "1" ((_flash_mask)) \
|
||||
); \
|
||||
}
|
||||
|
||||
#define _CPU_FPR_Enable() \
|
||||
{ register u32 _val = 0; \
|
||||
asm volatile ("mfmsr %0; ori %0,%0,0x2000; mtmsr %0" : \
|
||||
"=&r" (_val) : "0" (_val));\
|
||||
}
|
||||
|
||||
#define _CPU_FPR_Disable() \
|
||||
{ register u32 _val = 0; \
|
||||
asm volatile ("mfmsr %0; rlwinm %0,%0,0,19,17; mtmsr %0" : \
|
||||
"=&r" (_val) : "0" (_val));\
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
static inline u16 bswap16(u16 val)
|
||||
{
|
||||
u16 tmp = val;
|
||||
return __lhbrx(&tmp,0);
|
||||
}
|
||||
|
||||
static inline u32 bswap32(u32 val)
|
||||
{
|
||||
u32 tmp = val;
|
||||
return __lwbrx(&tmp,0);
|
||||
}
|
||||
|
||||
static inline u64 bswap64(u64 val)
|
||||
{
|
||||
union ullc {
|
||||
u64 ull;
|
||||
u32 ul[2];
|
||||
} outv;
|
||||
u64 tmp = val;
|
||||
|
||||
outv.ul[0] = __lwbrx(&tmp,4);
|
||||
outv.ul[1] = __lwbrx(&tmp,0);
|
||||
|
||||
return outv.ull;
|
||||
}
|
||||
|
||||
// Basic I/O
|
||||
|
||||
static inline u32 read32(u32 addr)
|
||||
{
|
||||
u32 x;
|
||||
asm volatile("lwz %0,0(%1) ; sync" : "=r"(x) : "b"(0xc0000000 | addr));
|
||||
return x;
|
||||
}
|
||||
|
||||
static inline void write32(u32 addr, u32 x)
|
||||
{
|
||||
asm("stw %0,0(%1) ; eieio" : : "r"(x), "b"(0xc0000000 | addr));
|
||||
}
|
||||
|
||||
static inline void mask32(u32 addr, u32 clear, u32 set)
|
||||
{
|
||||
write32(addr, (read32(addr)&(~clear)) | set);
|
||||
}
|
||||
|
||||
static inline u16 read16(u32 addr)
|
||||
{
|
||||
u16 x;
|
||||
asm volatile("lhz %0,0(%1) ; sync" : "=r"(x) : "b"(0xc0000000 | addr));
|
||||
return x;
|
||||
}
|
||||
|
||||
static inline void write16(u32 addr, u16 x)
|
||||
{
|
||||
asm("sth %0,0(%1) ; eieio" : : "r"(x), "b"(0xc0000000 | addr));
|
||||
}
|
||||
|
||||
static inline u8 read8(u32 addr)
|
||||
{
|
||||
u8 x;
|
||||
asm volatile("lbz %0,0(%1) ; sync" : "=r"(x) : "b"(0xc0000000 | addr));
|
||||
return x;
|
||||
}
|
||||
|
||||
static inline void write8(u32 addr, u8 x)
|
||||
{
|
||||
asm("stb %0,0(%1) ; eieio" : : "r"(x), "b"(0xc0000000 | addr));
|
||||
}
|
||||
|
||||
static inline void writef32(u32 addr, f32 x)
|
||||
{
|
||||
asm("stfs %0,0(%1) ; eieio" : : "f"(x), "b"(0xc0000000 | addr));
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
191
wii/libogc/include/ogc/machine/spinlock.h
Normal file
191
wii/libogc/include/ogc/machine/spinlock.h
Normal file
@ -0,0 +1,191 @@
|
||||
#ifndef __SPINLOCK_H__
|
||||
#define __SPINLOCK_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
#include <lwp_threads.h>
|
||||
|
||||
typedef struct {
|
||||
vu32 lock;
|
||||
} spinlock_t;
|
||||
|
||||
#define SPIN_LOCK_UNLOCKED (spinlock_t){0}
|
||||
|
||||
#define spin_lock_init(x) do { *(x) = SPIN_LOCK_UNLOCKED; }while(0)
|
||||
|
||||
static __inline__ u32 _test_and_set(u32 *atomic)
|
||||
{
|
||||
register u32 ret;
|
||||
|
||||
__asm__ __volatile__ ("1: lwarx %0,0,%1\n"
|
||||
" cmpwi 0,%0,0\n"
|
||||
" bne- 2f\n"
|
||||
" stwcx. %2,0,%1\n"
|
||||
" bne- 1b\n"
|
||||
" isync\n"
|
||||
"2:" : "=&r"(ret)
|
||||
: "r"(atomic), "r"(1)
|
||||
: "cr0", "memory");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static __inline__ u32 atomic_inc(u32 *pint)
|
||||
{
|
||||
register u32 ret;
|
||||
__asm__ __volatile__(
|
||||
"1: lwarx %0,0,%1\n\
|
||||
addi %0,%0,1\n\
|
||||
stwcx. %0,0,%1\n\
|
||||
bne- 1b\n\
|
||||
isync\n"
|
||||
: "=&r"(ret) : "r"(pint)
|
||||
: "cr0", "memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static __inline__ u32 atomic_dec(u32 *pint)
|
||||
{
|
||||
register u32 ret;
|
||||
__asm__ __volatile__(
|
||||
"1: lwarx %0,0,%1\n\
|
||||
addi %0,%0,-1\n\
|
||||
stwcx. %0,0,%1\n\
|
||||
bne- 1b\n\
|
||||
isync\n"
|
||||
: "=&r"(ret) : "r"(pint)
|
||||
: "cr0", "memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static __inline__ void spin_lock(spinlock_t *lock)
|
||||
{
|
||||
register u32 tmp;
|
||||
|
||||
__asm__ __volatile__(
|
||||
"b 1f # spin_lock\n\
|
||||
2: lwzx %0,0,%1\n\
|
||||
cmpwi 0,%0,0\n\
|
||||
bne+ 2b\n\
|
||||
1: lwarx %0,0,%1\n\
|
||||
cmpwi 0,%0,0\n\
|
||||
bne- 2b\n\
|
||||
stwcx. %2,0,%1\n\
|
||||
bne- 2b\n\
|
||||
isync"
|
||||
: "=&r"(tmp)
|
||||
: "r"(lock), "r"(1)
|
||||
: "cr0", "memory");
|
||||
}
|
||||
|
||||
static __inline__ void spin_lock_irqsave(spinlock_t *lock,register u32 *p_isr_level)
|
||||
{
|
||||
register u32 level;
|
||||
register u32 tmp;
|
||||
|
||||
_CPU_ISR_Disable(level);
|
||||
|
||||
__asm__ __volatile__(
|
||||
" b 1f # spin_lock\n\
|
||||
2: lwzx %0,0,%1\n\
|
||||
cmpwi 0,%0,0\n\
|
||||
bne+ 2b\n\
|
||||
1: lwarx %0,0,%1\n\
|
||||
cmpwi 0,%0,0\n\
|
||||
bne- 2b\n\
|
||||
stwcx. %2,0,%1\n\
|
||||
bne- 2b\n\
|
||||
isync"
|
||||
: "=&r"(tmp)
|
||||
: "r"(lock), "r"(1)
|
||||
: "cr0", "memory");
|
||||
|
||||
*p_isr_level = level;
|
||||
}
|
||||
|
||||
static __inline__ void spin_unlock(spinlock_t *lock)
|
||||
{
|
||||
__asm__ __volatile__("eieio # spin_unlock": : :"memory");
|
||||
lock->lock = 0;
|
||||
}
|
||||
|
||||
static __inline__ void spin_unlock_irqrestore(spinlock_t *lock,register u32 isr_level)
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
"eieio # spin_unlock"
|
||||
: : :"memory");
|
||||
lock->lock = 0;
|
||||
|
||||
_CPU_ISR_Restore(isr_level);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
vu32 lock;
|
||||
} rwlock_t;
|
||||
|
||||
#define RW_LOCK_UNLOCKED (rwlock_t){0}
|
||||
|
||||
#define read_lock_init(lp) do { *(lp) = RW_LOCK_UNLOCKED; }while(0)
|
||||
|
||||
static __inline__ void read_lock(rwlock_t *rw)
|
||||
{
|
||||
register u32 tmp;
|
||||
|
||||
__asm__ __volatile__(
|
||||
"b 2f # read_lock\n\
|
||||
1: lwzx %0,0,%1\n\
|
||||
cmpwi 0,%0,0\n\
|
||||
blt+ 1b\n\
|
||||
2: lwarx %0,0,%1\n\
|
||||
addic. %0,%0,1\n\
|
||||
ble- 1b\n\
|
||||
stwcx. %0,0,%1\n\
|
||||
bne- 2b\n\
|
||||
isync"
|
||||
: "=&r"(tmp)
|
||||
: "r"(&rw->lock)
|
||||
: "cr0", "memory");
|
||||
}
|
||||
|
||||
static __inline__ void read_unlock(rwlock_t *rw)
|
||||
{
|
||||
register u32 tmp;
|
||||
|
||||
__asm__ __volatile__(
|
||||
"eieio # read_unlock\n\
|
||||
1: lwarx %0,0,%1\n\
|
||||
addic %0,%0,-1\n\
|
||||
stwcx. %0,0,%1\n\
|
||||
bne- 1b"
|
||||
: "=&r"(tmp)
|
||||
: "r"(&rw->lock)
|
||||
: "cr0", "memory");
|
||||
}
|
||||
|
||||
static __inline__ void write_lock(rwlock_t *rw)
|
||||
{
|
||||
register u32 tmp;
|
||||
|
||||
__asm__ __volatile__(
|
||||
"b 2f # write_lock\n\
|
||||
1: lwzx %0,0,%1\n\
|
||||
cmpwi 0,%0,0\n\
|
||||
bne+ 1b\n\
|
||||
2: lwarx %0,0,%1\n\
|
||||
cmpwi 0,%0,0\n\
|
||||
bne- 1b\n\
|
||||
stwcx. %2,0,%1\n\
|
||||
bne- 2b\n\
|
||||
isync"
|
||||
: "=&r"(tmp)
|
||||
: "r"(&rw->lock), "r"(-1)
|
||||
: "cr0", "memory");
|
||||
}
|
||||
|
||||
static __inline__ void write_unlock(rwlock_t *rw)
|
||||
{
|
||||
__asm__ __volatile__("eieio # write_unlock": : :"memory");
|
||||
rw->lock = 0;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
123
wii/libogc/include/ogc/message.h
Normal file
123
wii/libogc/include/ogc/message.h
Normal file
@ -0,0 +1,123 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
message.h -- Thread subsystem II
|
||||
|
||||
Copyright (C) 2004
|
||||
Michael Wiedenbauer (shagkur)
|
||||
Dave Murphy (WinterMute)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __MESSAGE_H__
|
||||
#define __MESSAGE_H__
|
||||
|
||||
/*! \file message.h
|
||||
\brief Thread subsystem II
|
||||
|
||||
*/
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#define MQ_BOX_NULL 0xffffffff
|
||||
|
||||
#define MQ_ERROR_SUCCESSFUL 0
|
||||
#define MQ_ERROR_TOOMANY -5
|
||||
|
||||
#define MQ_MSG_BLOCK 0
|
||||
#define MQ_MSG_NOBLOCK 1
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*! \typedef u32 mqbox_t
|
||||
\brief typedef for the message queue handle
|
||||
*/
|
||||
typedef u32 mqbox_t;
|
||||
|
||||
|
||||
/*! \typedef void* mqmsg_t
|
||||
\brief typedef for the message pointer
|
||||
*/
|
||||
typedef void* mqmsg_t;
|
||||
|
||||
|
||||
|
||||
/*! \fn u32 MQ_Init(mqbox_t *mqbox,u32 count)
|
||||
\brief Initializes a message queue
|
||||
\param[out] mqbox pointer to the mqbox_t handle.
|
||||
\param[in] count maximum number of messages the queue can hold
|
||||
|
||||
\return 0 on success, <0 on error
|
||||
*/
|
||||
s32 MQ_Init(mqbox_t *mqbox,u32 count);
|
||||
|
||||
|
||||
/*! \fn void MQ_Close(mqbox_t mqbox)
|
||||
\brief Closes the message queue and releases all memory.
|
||||
\param[in] mqbox handle to the mqbox_t structure.
|
||||
|
||||
\return none
|
||||
*/
|
||||
void MQ_Close(mqbox_t mqbox);
|
||||
|
||||
|
||||
/*! \fn BOOL MQ_Send(mqbox_t mqbox,mqmsg_t msg,u32 flags)
|
||||
\brief Sends a message to the given message queue.
|
||||
\param[in] mqbox mqbox_t handle to the message queue
|
||||
\param[in] msg message to send
|
||||
\param[in] flags message flags (MQ_MSG_BLOCK, MQ_MSG_NOBLOCK)
|
||||
|
||||
\return bool result
|
||||
*/
|
||||
BOOL MQ_Send(mqbox_t mqbox,mqmsg_t msg,u32 flags);
|
||||
|
||||
|
||||
/*! \fn BOOL MQ_Jam(mqbox_t mqbox,mqmsg_t msg,u32 flags)
|
||||
\brief Sends a message to the given message queue and jams it in front of the queue.
|
||||
\param[in] mqbox mqbox_t handle to the message queue
|
||||
\param[in] msg message to send
|
||||
\param[in] flags message flags (MQ_MSG_BLOCK, MQ_MSG_NOBLOCK)
|
||||
|
||||
\return bool result
|
||||
*/
|
||||
BOOL MQ_Jam(mqbox_t mqbox,mqmsg_t msg,u32 flags);
|
||||
|
||||
|
||||
/*! \fn BOOL MQ_Receive(mqbox_t mqbox,mqmsg_t *msg,u32 flags)
|
||||
\brief Sends a message to the given message queue.
|
||||
\param[in] mqbox mqbox_t handle to the message queue
|
||||
\param[in] msg pointer to a mqmsg_t_t-type message to receive.
|
||||
\param[in] flags message flags (MQ_MSG_BLOCK, MQ_MSG_NOBLOCK)
|
||||
|
||||
\return bool result
|
||||
*/
|
||||
BOOL MQ_Receive(mqbox_t mqbox,mqmsg_t *msg,u32 flags);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
103
wii/libogc/include/ogc/mutex.h
Normal file
103
wii/libogc/include/ogc/mutex.h
Normal file
@ -0,0 +1,103 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
mutex.h -- Thread subsystem III
|
||||
|
||||
Copyright (C) 2004
|
||||
Michael Wiedenbauer (shagkur)
|
||||
Dave Murphy (WinterMute)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __MUTEX_H__
|
||||
#define __MUTEX_H__
|
||||
|
||||
/*! \file mutex.h
|
||||
\brief Thread subsystem III
|
||||
|
||||
*/
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#define LWP_MUTEX_NULL 0xffffffff
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*! \typedef u32 mutex_t
|
||||
\brief typedef for the mutex handle
|
||||
*/
|
||||
typedef u32 mutex_t;
|
||||
|
||||
|
||||
/*! \fn s32 LWP_MutexInit(mutex_t *mutex,bool use_recursive)
|
||||
\brief Initializes a mutex lock.
|
||||
\param[out] mutex pointer to a mutex_t handle.
|
||||
\param[in] use_recursive whether to allow the thread, whithin the same context, to enter multiple times the lock or not.
|
||||
|
||||
\return 0 on success, <0 on error
|
||||
*/
|
||||
s32 LWP_MutexInit(mutex_t *mutex,bool use_recursive);
|
||||
|
||||
|
||||
/*! \fn s32 LWP_MutexDestroy(mutex_t mutex)
|
||||
\brief Close mutex lock, release all threads and handles locked on this mutex.
|
||||
\param[in] mutex handle to the mutex_t structure.
|
||||
|
||||
\return 0 on success, <0 on error
|
||||
*/
|
||||
s32 LWP_MutexDestroy(mutex_t mutex);
|
||||
|
||||
|
||||
/*! \fn s32 LWP_MutexLock(mutex_t mutex)
|
||||
\brief Enter the mutex lock.
|
||||
\param[in] mutex handle to the mutext_t structure.
|
||||
|
||||
\return 0 on success, <0 on error
|
||||
*/
|
||||
s32 LWP_MutexLock(mutex_t mutex);
|
||||
|
||||
|
||||
/*! \fn s32 LWP_MutexTryLock(mutex_t mutex)
|
||||
\brief Try to enter the mutex lock.
|
||||
\param[in] mutex handle to the mutex_t structure.
|
||||
|
||||
\return 0: on first aquire, 1: would lock
|
||||
*/
|
||||
s32 LWP_MutexTryLock(mutex_t mutex);
|
||||
|
||||
|
||||
/*! \fn s32 LWP_MutexUnlock(mutex_t mutex)
|
||||
\brief Release the mutex lock and let other threads process further on this mutex.
|
||||
\param[in] mutex handle to the mutex_t structure.
|
||||
|
||||
\return 0 on success, <0 on error
|
||||
*/
|
||||
s32 LWP_MutexUnlock(mutex_t mutex);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
97
wii/libogc/include/ogc/pad.h
Normal file
97
wii/libogc/include/ogc/pad.h
Normal file
@ -0,0 +1,97 @@
|
||||
#ifndef __PAD_H__
|
||||
#define __PAD_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#define PAD_CHAN0 0
|
||||
#define PAD_CHAN1 1
|
||||
#define PAD_CHAN2 2
|
||||
#define PAD_CHAN3 3
|
||||
#define PAD_CHANMAX 4
|
||||
|
||||
#define PAD_MOTOR_STOP 0
|
||||
#define PAD_MOTOR_RUMBLE 1
|
||||
#define PAD_MOTOR_STOP_HARD 2
|
||||
|
||||
#define PAD_ERR_NONE 0
|
||||
#define PAD_ERR_NO_CONTROLLER -1
|
||||
#define PAD_ERR_NOT_READY -2
|
||||
#define PAD_ERR_TRANSFER -3
|
||||
|
||||
#define PAD_BUTTON_LEFT 0x0001
|
||||
#define PAD_BUTTON_RIGHT 0x0002
|
||||
#define PAD_BUTTON_DOWN 0x0004
|
||||
#define PAD_BUTTON_UP 0x0008
|
||||
#define PAD_TRIGGER_Z 0x0010
|
||||
#define PAD_TRIGGER_R 0x0020
|
||||
#define PAD_TRIGGER_L 0x0040
|
||||
#define PAD_BUTTON_A 0x0100
|
||||
#define PAD_BUTTON_B 0x0200
|
||||
#define PAD_BUTTON_X 0x0400
|
||||
#define PAD_BUTTON_Y 0x0800
|
||||
#define PAD_BUTTON_MENU 0x1000
|
||||
#define PAD_BUTTON_START 0x1000
|
||||
|
||||
#define PAD_CHAN0_BIT 0x80000000
|
||||
#define PAD_CHAN1_BIT 0x40000000
|
||||
#define PAD_CHAN2_BIT 0x20000000
|
||||
#define PAD_CHAN3_BIT 0x10000000
|
||||
/*+----------------------------------------------------------------------------------------------+*/
|
||||
/*+----------------------------------------------------------------------------------------------+*/
|
||||
/*+----------------------------------------------------------------------------------------------+*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
/*+----------------------------------------------------------------------------------------------+*/
|
||||
typedef struct _padstatus {
|
||||
u16 button;
|
||||
s8 stickX;
|
||||
s8 stickY;
|
||||
s8 substickX;
|
||||
s8 substickY;
|
||||
u8 triggerL;
|
||||
u8 triggerR;
|
||||
u8 analogA;
|
||||
u8 analogB;
|
||||
s8 err;
|
||||
} PADStatus;
|
||||
|
||||
typedef void (*sampling_callback)(void);
|
||||
/*+----------------------------------------------------------------------------------------------+*/
|
||||
/*+----------------------------------------------------------------------------------------------+*/
|
||||
/*+----------------------------------------------------------------------------------------------+*/
|
||||
|
||||
u32 PAD_Init();
|
||||
u32 PAD_Sync();
|
||||
u32 PAD_Read(PADStatus *status);
|
||||
u32 PAD_Reset(u32 mask);
|
||||
u32 PAD_Recalibrate(u32 mask);
|
||||
void PAD_Clamp(PADStatus *status);
|
||||
void PAD_ControlMotor(s32 chan,u32 cmd);
|
||||
void PAD_SetSpec(u32 spec);
|
||||
|
||||
u32 PAD_ScanPads();
|
||||
|
||||
u16 PAD_ButtonsUp(int pad);
|
||||
u16 PAD_ButtonsDown(int pad);
|
||||
u16 PAD_ButtonsHeld(int pad);
|
||||
|
||||
s8 PAD_SubStickX(int pad);
|
||||
s8 PAD_SubStickY(int pad);
|
||||
|
||||
s8 PAD_StickX(int pad);
|
||||
s8 PAD_StickY(int pad);
|
||||
|
||||
u8 PAD_TriggerL(int pad);
|
||||
u8 PAD_TriggerR(int pad);
|
||||
|
||||
|
||||
sampling_callback PAD_SetSamplingCallback(sampling_callback cb);
|
||||
|
||||
/*+----------------------------------------------------------------------------------------------+*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
96
wii/libogc/include/ogc/semaphore.h
Normal file
96
wii/libogc/include/ogc/semaphore.h
Normal file
@ -0,0 +1,96 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
semaphore.h -- Thread subsystem IV
|
||||
|
||||
Copyright (C) 2004
|
||||
Michael Wiedenbauer (shagkur)
|
||||
Dave Murphy (WinterMute)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __SEMAPHORE_H__
|
||||
#define __SEMAPHORE_H__
|
||||
|
||||
/*! \file semaphore.h
|
||||
\brief Thread subsystem IV
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#define LWP_SEM_NULL 0xffffffff
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*! \typedef u32 sem_t
|
||||
\brief typedef for the semaphore handle
|
||||
*/
|
||||
typedef u32 sem_t;
|
||||
|
||||
|
||||
/*! \fn s32 LWP_SemInit(sem_t *sem,u32 start,u32 max)
|
||||
\brief Initializes a semaphore.
|
||||
\param[out] sem pointer to a sem_t handle.
|
||||
\param[in] start start count of the semaphore
|
||||
\param[in] max maximum count of the semaphore
|
||||
|
||||
\return 0 on success, <0 on error
|
||||
*/
|
||||
s32 LWP_SemInit(sem_t *sem,u32 start,u32 max);
|
||||
|
||||
|
||||
/*! \fn s32 LWP_SemDestroy(sem_t sem)
|
||||
\brief Close and destroy a semaphore, release all threads and handles locked on this semaphore.
|
||||
\param[in] sem handle to the sem_t structure.
|
||||
|
||||
\return 0 on success, <0 on error
|
||||
*/
|
||||
s32 LWP_SemDestroy(sem_t sem);
|
||||
|
||||
|
||||
/*! \fn s32 LWP_SemWait(sem_t sem)
|
||||
\brief Count down semaphore counter and enter lock if counter <=0
|
||||
\param[in] sem handle to the sem_t structure.
|
||||
|
||||
\return 0 on success, <0 on error
|
||||
*/
|
||||
s32 LWP_SemWait(sem_t sem);
|
||||
|
||||
|
||||
/*! \fn s32 LWP_SemPost(sem_t sem)
|
||||
\brief Count up semaphore counter and release lock if counter >0
|
||||
\param[in] sem handle to the sem_t structure.
|
||||
|
||||
\return 0 on success, <0 on error
|
||||
*/
|
||||
s32 LWP_SemPost(sem_t sem);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
95
wii/libogc/include/ogc/si.h
Normal file
95
wii/libogc/include/ogc/si.h
Normal file
@ -0,0 +1,95 @@
|
||||
#ifndef __SI_H__
|
||||
#define __SI_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#define SI_CHAN0 0
|
||||
#define SI_CHAN1 1
|
||||
#define SI_CHAN2 2
|
||||
#define SI_CHAN3 3
|
||||
#define SI_MAX_CHAN 4
|
||||
|
||||
#define SI_CHAN0_BIT 0x80000000
|
||||
#define SI_CHAN1_BIT 0x40000000
|
||||
#define SI_CHAN2_BIT 0x20000000
|
||||
#define SI_CHAN3_BIT 0x10000000
|
||||
#define SI_CHAN_BIT(chn) (SI_CHAN0_BIT>>(chn))
|
||||
|
||||
#define SI_ERROR_UNDER_RUN 0x0001
|
||||
#define SI_ERROR_OVER_RUN 0x0002
|
||||
#define SI_ERROR_COLLISION 0x0004
|
||||
#define SI_ERROR_NO_RESPONSE 0x0008
|
||||
#define SI_ERROR_WRST 0x0010
|
||||
#define SI_ERROR_RDST 0x0020
|
||||
#define SI_ERR_UNKNOWN 0x0040
|
||||
#define SI_ERR_BUSY 0x0080
|
||||
|
||||
//
|
||||
// CMD_TYPE_AND_STATUS response data
|
||||
//
|
||||
#define SI_TYPE_MASK 0x18000000u
|
||||
#define SI_TYPE_N64 0x00000000u
|
||||
#define SI_TYPE_DOLPHIN 0x08000000u
|
||||
#define SI_TYPE_GC SI_TYPE_DOLPHIN
|
||||
|
||||
// GameCube specific
|
||||
#define SI_GC_WIRELESS 0x80000000u
|
||||
#define SI_GC_NOMOTOR 0x20000000u // no rumble motor
|
||||
#define SI_GC_STANDARD 0x01000000u // dolphin standard controller
|
||||
|
||||
// WaveBird specific
|
||||
#define SI_WIRELESS_RECEIVED 0x40000000u // 0: no wireless unit
|
||||
#define SI_WIRELESS_IR 0x04000000u // 0: IR 1: RF
|
||||
#define SI_WIRELESS_STATE 0x02000000u // 0: variable 1: fixed
|
||||
#define SI_WIRELESS_ORIGIN 0x00200000u // 0: invalid 1: valid
|
||||
#define SI_WIRELESS_FIX_ID 0x00100000u // 0: not fixed 1: fixed
|
||||
#define SI_WIRELESS_TYPE 0x000f0000u
|
||||
#define SI_WIRELESS_LITE_MASK 0x000c0000u // 0: normal 1: lite controller
|
||||
#define SI_WIRELESS_LITE 0x00040000u // 0: normal 1: lite controller
|
||||
#define SI_WIRELESS_CONT_MASK 0x00080000u // 0: non-controller 1: non-controller
|
||||
#define SI_WIRELESS_CONT 0x00000000u
|
||||
#define SI_WIRELESS_ID 0x00c0ff00u
|
||||
#define SI_WIRELESS_TYPE_ID (SI_WIRELESS_TYPE | SI_WIRELESS_ID)
|
||||
|
||||
#define SI_N64_CONTROLLER (SI_TYPE_N64 | 0x05000000)
|
||||
#define SI_N64_MIC (SI_TYPE_N64 | 0x00010000)
|
||||
#define SI_N64_KEYBOARD (SI_TYPE_N64 | 0x00020000)
|
||||
#define SI_N64_MOUSE (SI_TYPE_N64 | 0x02000000)
|
||||
#define SI_GBA (SI_TYPE_N64 | 0x00040000)
|
||||
#define SI_GC_CONTROLLER (SI_TYPE_GC | SI_GC_STANDARD)
|
||||
#define SI_GC_RECEIVER (SI_TYPE_GC | SI_GC_WIRELESS)
|
||||
#define SI_GC_WAVEBIRD (SI_TYPE_GC | SI_GC_WIRELESS | SI_GC_STANDARD | SI_WIRELESS_STATE | SI_WIRELESS_FIX_ID)
|
||||
#define SI_GC_KEYBOARD (SI_TYPE_GC | 0x00200000)
|
||||
#define SI_GC_STEERING (SI_TYPE_GC | 0x00000000)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef void (*SICallback)(s32,u32);
|
||||
typedef void (*RDSTHandler)(u32,void*);
|
||||
|
||||
u32 SI_Sync();
|
||||
u32 SI_Busy();
|
||||
u32 SI_IsChanBusy(s32 chan);
|
||||
void SI_EnablePolling(u32 poll);
|
||||
void SI_DisablePolling(u32 poll);
|
||||
void SI_SetCommand(s32 chan,u32 cmd);
|
||||
u32 SI_GetStatus(s32 chan);
|
||||
u32 SI_GetResponse(s32 chan,void *buf);
|
||||
u32 SI_GetResponseRaw(s32 chan);
|
||||
void SI_RefreshSamplingRate();
|
||||
u32 SI_Transfer(s32 chan,void *out,u32 out_len,void *in,u32 in_len,SICallback cb,u32 us_delay);
|
||||
u32 SI_GetTypeAsync(s32 chan,SICallback cb);
|
||||
u32 SI_GetType(s32 chan);
|
||||
u32 SI_GetCommand(s32 chan);
|
||||
void SI_TransferCommands();
|
||||
u32 SI_RegisterPollingHandler(RDSTHandler handler);
|
||||
u32 SI_UnregisterPollingHandler(RDSTHandler handler);
|
||||
u32 SI_EnablePollingInterrupt(s32 enable);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
66
wii/libogc/include/ogc/stm.h
Normal file
66
wii/libogc/include/ogc/stm.h
Normal file
@ -0,0 +1,66 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
stm.h - System and miscellaneous hardware control functions
|
||||
|
||||
Copyright (C) 2008
|
||||
Michael Wiedenbauer (shagkur)
|
||||
Dave Murphy (WinterMute)
|
||||
Hector Martin (marcan)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
#ifndef __STM_H__
|
||||
#define __STM_H__
|
||||
|
||||
#if defined(HW_RVL)
|
||||
|
||||
#include <gctypes.h>
|
||||
#include <gcutil.h>
|
||||
|
||||
#define STM_EVENT_RESET 0x00020000
|
||||
#define STM_EVENT_POWER 0x00000800
|
||||
|
||||
#define STM_EINVAL -0x2004
|
||||
#define STM_ENOTINIT -0x2100
|
||||
#define STM_ENOHANDLER -0x2101
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef void (*stmcallback)(u32 event);
|
||||
|
||||
s32 __STM_Init();
|
||||
s32 __STM_Close();
|
||||
s32 STM_ShutdownToStandby();
|
||||
s32 STM_ShutdownToIdle();
|
||||
s32 STM_SetLedMode(u32 mode);
|
||||
s32 STM_RebootSystem();
|
||||
stmcallback STM_RegisterEventHandler(stmcallback newhandler);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* defined(HW_RVL) */
|
||||
|
||||
#endif
|
27
wii/libogc/include/ogc/sys_state.h
Normal file
27
wii/libogc/include/ogc/sys_state.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef __SYS_STATE_H__
|
||||
#define __SYS_STATE_H__
|
||||
|
||||
#define SYS_STATE_BEFORE_INIT 0
|
||||
#define SYS_STATE_BEFORE_MT 1
|
||||
#define SYS_STATE_BEGIN_MT 2
|
||||
#define SYS_STATE_UP 3
|
||||
#define SYS_STATE_SHUTDOWN 4
|
||||
#define SYS_STATE_FAILED 5
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern u32 _sys_state_curr;
|
||||
|
||||
#ifdef LIBOGC_INTERNAL
|
||||
#include <libogc/sys_state.inl>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
350
wii/libogc/include/ogc/system.h
Normal file
350
wii/libogc/include/ogc/system.h
Normal file
@ -0,0 +1,350 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
system.h -- OS functions and initialization
|
||||
|
||||
Copyright (C) 2004
|
||||
Michael Wiedenbauer (shagkur)
|
||||
Dave Murphy (WinterMute)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __SYSTEM_H__
|
||||
#define __SYSTEM_H__
|
||||
|
||||
|
||||
/*! \file system.h
|
||||
\brief OS functions and initialization
|
||||
|
||||
*/
|
||||
|
||||
#include <gctypes.h>
|
||||
#include <gcutil.h>
|
||||
#include <time.h>
|
||||
#include <ogc/lwp_queue.h>
|
||||
#include "gx_struct.h"
|
||||
|
||||
#define SYS_BASE_CACHED (0x80000000)
|
||||
#define SYS_BASE_UNCACHED (0xC0000000)
|
||||
|
||||
#define SYS_WD_NULL 0xffffffff
|
||||
|
||||
/*!
|
||||
* \addtogroup sys_resettypes OS reset types
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define SYS_RESTART 0 /*!< Reboot the gamecube, force, if necessary, to boot the IPL menu. Cold reset is issued */
|
||||
#define SYS_HOTRESET 1 /*!< Restart the application. Kind of softreset */
|
||||
#define SYS_SHUTDOWN 2 /*!< Shutdown the thread system, card management system etc. Leave current thread running and return to caller */
|
||||
|
||||
#define SYS_RETURNTOMENU 3 /*!< Directly load the Wii Channels menu, without actually cold-resetting the system */
|
||||
#define SYS_POWEROFF 4 /*!< Powers off the Wii, automatically choosing Standby or Idle mode depending on the user's configuration */
|
||||
#define SYS_POWEROFF_STANDBY 5 /*!< Powers off the Wii to standby (red LED, WC24 off) mode. */
|
||||
#define SYS_POWEROFF_IDLE 6 /*!< Powers off the Wii to idle (yellow LED, WC24 on) mode. */
|
||||
|
||||
/*!
|
||||
*@}
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
* \addtogroup sys_mprotchans OS memory protection channels
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define SYS_PROTECTCHAN0 0 /*!< OS memory protection channel 0 */
|
||||
#define SYS_PROTECTCHAN1 1 /*!< OS memory protection channel 1 */
|
||||
#define SYS_PROTECTCHAN2 2 /*!< OS memory protection channel 2 */
|
||||
#define SYS_PROTECTCHAN3 3 /*!< OS memory protection channel 2 */
|
||||
#define SYS_PROTECTCHANMAX 4 /*!< _Termination */
|
||||
|
||||
/*!
|
||||
*@}
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
* \addtogroup sys_mprotmodes OS memory protection modes
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define SYS_PROTECTNONE 0x00000000 /*!< Read and write operations on protected region is granted */
|
||||
#define SYS_PROTECTREAD 0x00000001 /*!< Read from protected region is permitted */
|
||||
#define SYS_PROTECTWRITE 0x00000002 /*!< Write to protected region is permitted */
|
||||
#define SYS_PROTECTRDWR (SYS_PROTECTREAD|SYS_PROTECTWRITE) /*!< Read and write operations on protected region is permitted */
|
||||
|
||||
/*!
|
||||
*@}
|
||||
*/
|
||||
|
||||
#define SYS_FONTSIZE_ANSI (288 + 131072)
|
||||
#define SYS_FONTSIZE_SJIS (3840 + 1179648)
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* \addtogroup sys_mcastmacros OS memory casting macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define MEM_VIRTUAL_TO_PHYSICAL(x) (((u32)(x)) & ~SYS_BASE_UNCACHED) /*!< Cast virtual address to physical address, e.g. 0x8xxxxxxx -> 0x0xxxxxxx */
|
||||
#define MEM_PHYSICAL_TO_K0(x) (void*)((u32)(x) + SYS_BASE_CACHED) /*!< Cast physical address to cached virtual address, e.g. 0x0xxxxxxx -> 0x8xxxxxxx */
|
||||
#define MEM_PHYSICAL_TO_K1(x) (void*)((u32)(x) + SYS_BASE_UNCACHED) /*!< Cast physical address to uncached virtual address, e.g. 0x0xxxxxxx -> 0xCxxxxxxx */
|
||||
#define MEM_K0_TO_PHYSICAL(x) (void*)((u32)(x) - SYS_BASE_CACHED) /*!< Cast physical address to cached virtual address, e.g. 0x0xxxxxxx -> 0x8xxxxxxx */
|
||||
#define MEM_K1_TO_PHYSICAL(x) (void*)((u32)(x) - SYS_BASE_UNCACHED) /*!< Cast physical address to uncached virtual address, e.g. 0x0xxxxxxx -> 0xCxxxxxxx */
|
||||
#define MEM_K0_TO_K1(x) (void*)((u32)(x) + (SYS_BASE_UNCACHED - SYS_BASE_CACHED)) /*!< Cast cached virtual address to uncached virtual address, e.g. 0x8xxxxxxx -> 0xCxxxxxxx */
|
||||
#define MEM_K1_TO_K0(x) (void*)((u32)(x) - (SYS_BASE_UNCACHED - SYS_BASE_CACHED)) /*!< Cast uncached virtual address to cached virtual address, e.g. 0xCxxxxxxx -> 0x8xxxxxxx */
|
||||
|
||||
/*!
|
||||
*@}
|
||||
*/
|
||||
|
||||
#define SYS_GetArenaLo SYS_GetArena1Lo
|
||||
#define SYS_SetArenaLo SYS_SetArena1Lo
|
||||
#define SYS_GetArenaHi SYS_GetArena1Hi
|
||||
#define SYS_SetArenaHi SYS_SetArena1Hi
|
||||
#define SYS_GetArenaSize SYS_GetArena1Size
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
/*!
|
||||
* \typedef u32 syswd_t
|
||||
* \brief handle typedef for the alarm context
|
||||
*/
|
||||
typedef u32 syswd_t;
|
||||
|
||||
|
||||
/*!
|
||||
* \typedef struct _syssram syssram
|
||||
* \brief holds the stored configuration value from the system SRAM area
|
||||
* \param checksum holds the block checksum.
|
||||
* \param checksum_in holds the inverse block checksum
|
||||
* \param ead0 unknown attribute
|
||||
* \param ead1 unknown attribute
|
||||
* \param counter_bias bias value for the realtime clock
|
||||
* \param display_offsetH pixel offset for the VI
|
||||
* \param ntd unknown attribute
|
||||
* \param lang language of system
|
||||
* \param flags device and operations flag
|
||||
*/
|
||||
typedef struct _syssram syssram;
|
||||
|
||||
struct _syssram {
|
||||
u16 checksum;
|
||||
u16 checksum_inv;
|
||||
u32 ead0;
|
||||
u32 ead1;
|
||||
u32 counter_bias;
|
||||
s8 display_offsetH;
|
||||
u8 ntd;
|
||||
u8 lang;
|
||||
u8 flags;
|
||||
} ATTRIBUTE_PACKED;
|
||||
|
||||
|
||||
/*!
|
||||
* \typedef struct _syssramex syssramex
|
||||
* \brief holds the stored configuration value from the extended SRAM area
|
||||
* \param flash_id[2][12] 96bit memorycard unlock flash ID
|
||||
* \param wirelessKbd_id Device ID of last connected wireless keyboard
|
||||
* \param wirelessPad_id[4] 16bit device ID of last connected pad.
|
||||
* \param dvderr_code last non-recoverable error from DVD interface
|
||||
* \param __padding0 padding
|
||||
* \param flashID_chksum[2] 16bit checksum of unlock flash ID
|
||||
* \param __padding1[4] padding
|
||||
*/
|
||||
typedef struct _syssramex syssramex;
|
||||
|
||||
struct _syssramex {
|
||||
u8 flash_id[2][12];
|
||||
u32 wirelessKbd_id;
|
||||
u16 wirelessPad_id[4];
|
||||
u8 dvderr_code;
|
||||
u8 __padding0;
|
||||
u16 flashID_chksum[2];
|
||||
u8 __padding1[4];
|
||||
} ATTRIBUTE_PACKED;
|
||||
|
||||
typedef void (*alarmcallback)(syswd_t alarm,void *cb_arg);
|
||||
|
||||
typedef struct _sys_fontheader sys_fontheader;
|
||||
|
||||
struct _sys_fontheader {
|
||||
u16 font_type;
|
||||
u16 first_char;
|
||||
u16 last_char;
|
||||
u16 inval_char;
|
||||
u16 asc;
|
||||
u16 desc;
|
||||
u16 width;
|
||||
u16 leading;
|
||||
u16 cell_width;
|
||||
u16 cell_height;
|
||||
u32 sheet_size;
|
||||
u16 sheet_format;
|
||||
u16 sheet_column;
|
||||
u16 sheet_row;
|
||||
u16 sheet_width;
|
||||
u16 sheet_height;
|
||||
u16 width_table;
|
||||
u32 sheet_image;
|
||||
u32 sheet_fullsize;
|
||||
u8 c0;
|
||||
u8 c1;
|
||||
u8 c2;
|
||||
u8 c3;
|
||||
} ATTRIBUTE_PACKED;
|
||||
|
||||
typedef void (*resetcallback)(void);
|
||||
typedef void (*powercallback)(void);
|
||||
typedef s32 (*resetfunction)(s32 final);
|
||||
typedef struct _sys_resetinfo sys_resetinfo;
|
||||
|
||||
struct _sys_resetinfo {
|
||||
lwp_node node;
|
||||
resetfunction func;
|
||||
u32 prio;
|
||||
};
|
||||
|
||||
/*! \fn void SYS_Init()
|
||||
\deprecated Performs basic system initialization such as EXI init etc. This function is called from within the crt0 startup code.
|
||||
|
||||
\return none
|
||||
*/
|
||||
void SYS_Init();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void* SYS_AllocateFramebuffer(GXRModeObj *rmode)
|
||||
* \brief Allocate cacheline aligned memory for the external framebuffer based on the rendermode object.
|
||||
* \param[in] rmode pointer to the video/render mode configuration
|
||||
*
|
||||
* \return pointer to the framebuffer's startaddress. <b><i>NOTE:</i></b> Address returned is aligned to a 32byte boundery!
|
||||
*/
|
||||
void* SYS_AllocateFramebuffer(GXRModeObj *rmode);
|
||||
|
||||
|
||||
void SYS_ProtectRange(u32 chan,void *addr,u32 bytes,u32 cntrl);
|
||||
void SYS_StartPMC(u32 mcr0val,u32 mcr1val);
|
||||
void SYS_DumpPMC();
|
||||
void SYS_StopPMC();
|
||||
|
||||
|
||||
/*! \fn s32 SYS_CreateAlarm(syswd_t *thealarm)
|
||||
\brief Create/initialize sysalarm structure
|
||||
\param[in] thealarm pointer to the handle to store the created alarm context identifier
|
||||
|
||||
\return 0 on succuess, non-zero on error
|
||||
*/
|
||||
s32 SYS_CreateAlarm(syswd_t *thealarm);
|
||||
|
||||
|
||||
/*! \fn s32 SYS_SetAlarm(syswd_t thealarm,const struct timespec *tp,alarmcallback cb)
|
||||
\brief Set the alarm parameters for a one-shot alarm, add to the list of alarms and start.
|
||||
\param[in] thealarm identifier to the alarm context to be initialize for a one-shot alarm
|
||||
\param[in] tp pointer to timespec structure holding the time to fire the alarm
|
||||
\param[in] cb pointer to callback which is called when the alarm fires.
|
||||
|
||||
\return 0 on succuess, non-zero on error
|
||||
*/
|
||||
s32 SYS_SetAlarm(syswd_t thealarm,const struct timespec *tp,alarmcallback cb,void *cbarg);
|
||||
|
||||
|
||||
/*! \fn s32 SYS_SetPeriodicAlarm(syswd_t thealarm,const struct timespec *tp_start,const struct timespec *tp_period,alarmcallback cb)
|
||||
\brief Set the alarm parameters for a periodioc alarm, add to the list of alarms and start. The alarm and interval persists as long as SYS_CancelAlarm() isn't called.
|
||||
\param[in] thealarm identifier to the alarm context to be initialized for a periodic alarm
|
||||
\param[in] tp_start pointer to timespec structure holding the time to fire first time the alarm
|
||||
\param[in] tp_period pointer to timespec structure holding the interval for all following alarm triggers.
|
||||
\param[in] cb pointer to callback which is called when the alarm fires.
|
||||
|
||||
\return 0 on succuess, non-zero on error
|
||||
*/
|
||||
s32 SYS_SetPeriodicAlarm(syswd_t thealarm,const struct timespec *tp_start,const struct timespec *tp_period,alarmcallback cb,void *cbarg);
|
||||
|
||||
|
||||
/*! \fn s32 SYS_RemoveAlarm(syswd_t thealarm)
|
||||
\brief Remove the given alarm context from the list of contexts and destroy it
|
||||
\param[in] thealarm identifier to the alarm context to be removed and destroyed
|
||||
|
||||
\return 0 on succuess, non-zero on error
|
||||
*/
|
||||
s32 SYS_RemoveAlarm(syswd_t thealarm);
|
||||
|
||||
|
||||
/*! \fn s32 SYS_CancelAlarm(syswd_t thealarm)
|
||||
\brief Cancel the alarm, but do not remove from the list of contexts.
|
||||
\param[in] thealarm identifier to the alram context to be canceled
|
||||
|
||||
\return 0 on succuess, non-zero on error
|
||||
*/
|
||||
s32 SYS_CancelAlarm(syswd_t thealarm);
|
||||
|
||||
|
||||
void SYS_SetWirelessID(u32 chan,u32 id);
|
||||
u32 SYS_GetWirelessID(u32 chan);
|
||||
u32 SYS_GetFontEncoding();
|
||||
u32 SYS_InitFont(sys_fontheader *font_data);
|
||||
void SYS_GetFontTexture(s32 c,void **image,s32 *xpos,s32 *ypos,s32 *width);
|
||||
void SYS_GetFontTexel(s32 c,void *image,s32 pos,s32 stride,s32 *width);
|
||||
void SYS_ResetSystem(s32 reset,u32 reset_code,s32 force_menu);
|
||||
void SYS_RegisterResetFunc(sys_resetinfo *info);
|
||||
void SYS_UnregisterResetFunc(sys_resetinfo *info);
|
||||
void SYS_SwitchFiber(u32 arg0,u32 arg1,u32 arg2,u32 arg3,u32 pc,u32 newsp);
|
||||
|
||||
void* SYS_GetArena1Lo();
|
||||
void SYS_SetArena1Lo(void *newLo);
|
||||
void* SYS_GetArena1Hi();
|
||||
void SYS_SetArena1Hi(void *newHi);
|
||||
u32 SYS_GetArena1Size();
|
||||
|
||||
resetcallback SYS_SetResetCallback(resetcallback cb);
|
||||
|
||||
u32 SYS_ResetButtonDown();
|
||||
|
||||
#if defined(HW_RVL)
|
||||
u32 SYS_GetHollywoodRevision();
|
||||
void* SYS_GetArena2Lo();
|
||||
void SYS_SetArena2Lo(void *newLo);
|
||||
void* SYS_GetArena2Hi();
|
||||
void SYS_SetArena2Hi(void *newHi);
|
||||
u32 SYS_GetArena2Size();
|
||||
powercallback SYS_SetPowerCallback(powercallback cb);
|
||||
#endif
|
||||
|
||||
/* \fn u64 SYS_Time()
|
||||
\brief Returns the current time in ticks since 2000 (proper Dolphin/Wii time)
|
||||
\return ticks since 2000
|
||||
*/
|
||||
u64 SYS_Time();
|
||||
|
||||
void kprintf(const char *str, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
51
wii/libogc/include/ogc/texconv.h
Normal file
51
wii/libogc/include/ogc/texconv.h
Normal file
@ -0,0 +1,51 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
texconv.h -- GX texture helper functions
|
||||
|
||||
Copyright (C) 2004
|
||||
Michael Wiedenbauer (shagkur)
|
||||
Dave Murphy (WinterMute)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __TEXCONV_H__
|
||||
#define __TEXTCONV_H__
|
||||
|
||||
/*!
|
||||
\file texconv.h
|
||||
\brief GX texture helper functions
|
||||
*/
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
void MakeTexture565(const void *src,void *dst,s32 width,s32 height);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
31
wii/libogc/include/ogc/tpl.h
Normal file
31
wii/libogc/include/ogc/tpl.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef __TPL_H__
|
||||
#define __TPL_H__
|
||||
|
||||
#include "gx.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef void* FHANDLE;
|
||||
|
||||
// tdf file
|
||||
typedef struct _tplfile {
|
||||
int type;
|
||||
int ntextures;
|
||||
void *texdesc;
|
||||
FHANDLE tpl_file;
|
||||
} TPLFile;
|
||||
|
||||
s32 TPL_OpenTPLFromFile(TPLFile* tdf, const char* file_name);
|
||||
s32 TPL_OpenTPLFromMemory(TPLFile* tdf, void *memory,u32 len);
|
||||
s32 TPL_GetTexture(TPLFile *tdf,s32 id,GXTexObj *texObj);
|
||||
s32 TPL_GetTextureCI(TPLFile *tdf,s32 id,GXTexObj *texObj,GXTlutObj *tlutObj,u8 tluts);
|
||||
s32 TPL_GetTextureInfo(TPLFile *tdf,s32 id,u32 *fmt,u16 *width,u16 *height);
|
||||
void TPL_CloseTPLFile(TPLFile *tdf);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
239
wii/libogc/include/ogc/usb.h
Normal file
239
wii/libogc/include/ogc/usb.h
Normal file
@ -0,0 +1,239 @@
|
||||
#ifndef __USB_H__
|
||||
#define __USB_H__
|
||||
|
||||
#if defined(HW_RVL)
|
||||
|
||||
#include <gcutil.h>
|
||||
#include <gctypes.h>
|
||||
|
||||
#define USB_MAXPATH IPC_MAXPATH_LEN
|
||||
|
||||
#define USB_OK 0
|
||||
#define USB_FAILED 1
|
||||
|
||||
#define USB_CLASS_HID 0x03
|
||||
#define USB_SUBCLASS_BOOT 0x01
|
||||
#define USB_PROTOCOL_KEYBOARD 0x01
|
||||
#define USB_PROTOCOL_MOUSE 0x02
|
||||
|
||||
#define USB_REPTYPE_INPUT 0x01
|
||||
#define USB_REPTYPE_OUTPUT 0x02
|
||||
#define USB_REPTYPE_FEATURE 0x03
|
||||
|
||||
/* Descriptor types */
|
||||
#define USB_DT_DEVICE 0x01
|
||||
#define USB_DT_CONFIG 0x02
|
||||
#define USB_DT_STRING 0x03
|
||||
#define USB_DT_INTERFACE 0x04
|
||||
#define USB_DT_ENDPOINT 0x05
|
||||
#define USB_DT_DEVICE_QUALIFIER 0x06
|
||||
#define USB_DT_OTHER_SPEED_CONFIG 0x07
|
||||
#define USB_DT_INTERFACE_POWER 0x08
|
||||
#define USB_DT_OTG 0x09
|
||||
#define USB_DT_DEBUG 0x10
|
||||
#define USB_DT_INTERFACE_ASSOCIATION 0x11
|
||||
#define USB_DT_HID 0x21
|
||||
#define USB_DT_REPORT 0x22
|
||||
#define USB_DT_PHYSICAL 0x23
|
||||
#define USB_DT_CLASS_SPECIFIC_INTERFACE 0x24
|
||||
#define USB_DT_CLASS_SPECIFIC_ENDPOINT 0x25
|
||||
#define USB_DT_HUB 0x29
|
||||
|
||||
/* Standard requests */
|
||||
#define USB_REQ_GETSTATUS 0x00
|
||||
#define USB_REQ_CLEARFEATURE 0x01
|
||||
#define USB_REQ_SETFEATURE 0x03
|
||||
#define USB_REQ_SETADDRESS 0x05
|
||||
#define USB_REQ_GETDESCRIPTOR 0x06
|
||||
#define USB_REQ_SETDESCRIPTOR 0x07
|
||||
#define USB_REQ_GETCONFIG 0x08
|
||||
#define USB_REQ_SETCONFIG 0x09
|
||||
#define USB_REQ_GETINTERFACE 0x0A
|
||||
#define USB_REQ_SETINTERFACE 0x0B
|
||||
#define USB_REQ_SYNCFRAME 0x0C
|
||||
|
||||
#define USB_REQ_GETREPORT 0x01
|
||||
#define USB_REQ_GETIDLE 0x02
|
||||
#define USB_REQ_GETPROTOCOL 0x03
|
||||
#define USB_REQ_SETREPORT 0x09
|
||||
#define USB_REQ_SETIDLE 0x0A
|
||||
#define USB_REQ_SETPROTOCOL 0x0B
|
||||
|
||||
/* Descriptor sizes per descriptor type */
|
||||
#define USB_DT_DEVICE_SIZE 18
|
||||
#define USB_DT_CONFIG_SIZE 9
|
||||
#define USB_DT_INTERFACE_SIZE 9
|
||||
#define USB_DT_ENDPOINT_SIZE 7
|
||||
#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
|
||||
#define USB_DT_HID_SIZE 9
|
||||
#define USB_DT_HUB_NONVAR_SIZE 7
|
||||
|
||||
/* control message request type bitmask */
|
||||
#define USB_CTRLTYPE_DIR_HOST2DEVICE (0<<7)
|
||||
#define USB_CTRLTYPE_DIR_DEVICE2HOST (1<<7)
|
||||
#define USB_CTRLTYPE_TYPE_STANDARD (0<<5)
|
||||
#define USB_CTRLTYPE_TYPE_CLASS (1<<5)
|
||||
#define USB_CTRLTYPE_TYPE_VENDOR (2<<5)
|
||||
#define USB_CTRLTYPE_TYPE_RESERVED (3<<5)
|
||||
#define USB_CTRLTYPE_REC_DEVICE 0
|
||||
#define USB_CTRLTYPE_REC_INTERFACE 1
|
||||
#define USB_CTRLTYPE_REC_ENDPOINT 2
|
||||
#define USB_CTRLTYPE_REC_OTHER 3
|
||||
|
||||
#define USB_REQTYPE_INTERFACE_GET (USB_CTRLTYPE_DIR_DEVICE2HOST|USB_CTRLTYPE_TYPE_CLASS|USB_CTRLTYPE_REC_INTERFACE)
|
||||
#define USB_REQTYPE_INTERFACE_SET (USB_CTRLTYPE_DIR_HOST2DEVICE|USB_CTRLTYPE_TYPE_CLASS|USB_CTRLTYPE_REC_INTERFACE)
|
||||
#define USB_REQTYPE_ENDPOINT_GET (USB_CTRLTYPE_DIR_DEVICE2HOST|USB_CTRLTYPE_TYPE_CLASS|USB_CTRLTYPE_REC_ENDPOINT)
|
||||
#define USB_REQTYPE_ENDPOINT_SET (USB_CTRLTYPE_DIR_HOST2DEVICE|USB_CTRLTYPE_TYPE_CLASS|USB_CTRLTYPE_REC_ENDPOINT)
|
||||
|
||||
#define USB_FEATURE_ENDPOINT_HALT 0
|
||||
|
||||
#define USB_ENDPOINT_INTERRUPT 0x03
|
||||
#define USB_ENDPOINT_IN 0x80
|
||||
#define USB_ENDPOINT_OUT 0x00
|
||||
|
||||
#define USB_OH0_DEVICE_ID 0x00000000 // for completion
|
||||
#define USB_OH1_DEVICE_ID 0x00200000
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct _usbendpointdesc
|
||||
{
|
||||
u8 bLength;
|
||||
u8 bDescriptorType;
|
||||
u8 bEndpointAddress;
|
||||
u8 bmAttributes;
|
||||
u16 wMaxPacketSize;
|
||||
u8 bInterval;
|
||||
} ATTRIBUTE_PACKED usb_endpointdesc;
|
||||
|
||||
typedef struct _usbinterfacedesc
|
||||
{
|
||||
u8 bLength;
|
||||
u8 bDescriptorType;
|
||||
u8 bInterfaceNumber;
|
||||
u8 bAlternateSetting;
|
||||
u8 bNumEndpoints;
|
||||
u8 bInterfaceClass;
|
||||
u8 bInterfaceSubClass;
|
||||
u8 bInterfaceProtocol;
|
||||
u8 iInterface;
|
||||
u8 *extra;
|
||||
u16 extra_size;
|
||||
struct _usbendpointdesc *endpoints;
|
||||
} ATTRIBUTE_PACKED usb_interfacedesc;
|
||||
|
||||
typedef struct _usbconfdesc
|
||||
{
|
||||
u8 bLength;
|
||||
u8 bDescriptorType;
|
||||
u16 wTotalLength;
|
||||
u8 bNumInterfaces;
|
||||
u8 bConfigurationValue;
|
||||
u8 iConfiguration;
|
||||
u8 bmAttributes;
|
||||
u8 bMaxPower;
|
||||
struct _usbinterfacedesc *interfaces;
|
||||
} ATTRIBUTE_PACKED usb_configurationdesc;
|
||||
|
||||
typedef struct _usbdevdesc
|
||||
{
|
||||
u8 bLength;
|
||||
u8 bDescriptorType;
|
||||
u16 bcdUSB;
|
||||
u8 bDeviceClass;
|
||||
u8 bDeviceSubClass;
|
||||
u8 bDeviceProtocol;
|
||||
u8 bMaxPacketSize0;
|
||||
u16 idVendor;
|
||||
u16 idProduct;
|
||||
u16 bcdDevice;
|
||||
u8 iManufacturer;
|
||||
u8 iProduct;
|
||||
u8 iSerialNumber;
|
||||
u8 bNumConfigurations;
|
||||
struct _usbconfdesc *configurations;
|
||||
} ATTRIBUTE_PACKED usb_devdesc;
|
||||
|
||||
typedef struct _usbhiddesc
|
||||
{
|
||||
u8 bLength;
|
||||
u8 bDescriptorType;
|
||||
u16 bcdHID;
|
||||
u8 bCountryCode;
|
||||
u8 bNumDescriptors;
|
||||
struct {
|
||||
u8 bDescriptorType;
|
||||
u16 wDescriptorLength;
|
||||
} ATTRIBUTE_PACKED descr[1];
|
||||
} ATTRIBUTE_PACKED usb_hiddesc;
|
||||
|
||||
typedef struct _usb_device_entry {
|
||||
s32 device_id;
|
||||
u16 vid;
|
||||
u16 pid;
|
||||
u32 token;
|
||||
} usb_device_entry;
|
||||
|
||||
typedef s32 (*usbcallback)(s32 result,void *usrdata);
|
||||
|
||||
s32 USB_Initialize();
|
||||
s32 USB_Deinitialize();
|
||||
|
||||
s32 USB_OpenDevice(s32 device_id,u16 vid,u16 pid,s32 *fd);
|
||||
s32 USB_CloseDevice(s32 *fd);
|
||||
s32 USB_CloseDeviceAsync(s32 *fd,usbcallback cb,void *usrdata);
|
||||
|
||||
s32 USB_GetDescriptors(s32 fd, usb_devdesc *udd);
|
||||
void USB_FreeDescriptors(usb_devdesc *udd);
|
||||
|
||||
s32 USB_GetGenericDescriptor(s32 fd,u8 type,u8 index,u8 interface,void *data,u32 size);
|
||||
s32 USB_GetHIDDescriptor(s32 fd,u8 interface,usb_hiddesc *uhd,u32 size);
|
||||
|
||||
s32 USB_GetDeviceDescription(s32 fd,usb_devdesc *devdesc);
|
||||
s32 USB_DeviceRemovalNotifyAsync(s32 fd,usbcallback cb,void *userdata);
|
||||
s32 USB_DeviceChangeNotifyAsync(u8 interface_class,usbcallback cb,void *userdata);
|
||||
|
||||
s32 USB_SuspendDevice(s32 fd);
|
||||
s32 USB_ResumeDevice(s32 fd);
|
||||
|
||||
s32 USB_ReadIsoMsg(s32 fd,u8 bEndpoint,u8 bPackets,u16 *rpPacketSizes,void *rpData);
|
||||
s32 USB_ReadIsoMsgAsync(s32 fd,u8 bEndpoint,u8 bPackets,u16 *rpPacketSizes,void *rpData,usbcallback cb,void *userdata);
|
||||
|
||||
s32 USB_ReadIntrMsg(s32 fd,u8 bEndpoint,u16 wLength,void *rpData);
|
||||
s32 USB_ReadIntrMsgAsync(s32 fd,u8 bEndpoint,u16 wLength,void *rpData,usbcallback cb,void *usrdata);
|
||||
|
||||
s32 USB_ReadBlkMsg(s32 fd,u8 bEndpoint,u16 wLength,void *rpData);
|
||||
s32 USB_ReadBlkMsgAsync(s32 fd,u8 bEndpoint,u16 wLength,void *rpData,usbcallback cb,void *usrdata);
|
||||
|
||||
s32 USB_ReadCtrlMsg(s32 fd,u8 bmRequestType,u8 bmRequest,u16 wValue,u16 wIndex,u16 wLength,void *rpData);
|
||||
s32 USB_ReadCtrlMsgAsync(s32 fd,u8 bmRequestType,u8 bmRequest,u16 wValue,u16 wIndex,u16 wLength,void *rpData,usbcallback cb,void *usrdata);
|
||||
|
||||
s32 USB_WriteIsoMsg(s32 fd,u8 bEndpoint,u8 bPackets,u16 *rpPacketSizes,void *rpData);
|
||||
s32 USB_WriteIsoMsgAsync(s32 fd,u8 bEndpoint,u8 bPackets,u16 *rpPacketSizes,void *rpData,usbcallback cb,void *userdata);
|
||||
|
||||
s32 USB_WriteIntrMsg(s32 fd,u8 bEndpoint,u16 wLength,void *rpData);
|
||||
s32 USB_WriteIntrMsgAsync(s32 fd,u8 bEndpoint,u16 wLength,void *rpData,usbcallback cb,void *usrdata);
|
||||
|
||||
s32 USB_WriteBlkMsg(s32 fd,u8 bEndpoint,u16 wLength,void *rpData);
|
||||
s32 USB_WriteBlkMsgAsync(s32 fd,u8 bEndpoint,u16 wLength,void *rpData,usbcallback cb,void *usrdata);
|
||||
|
||||
s32 USB_WriteCtrlMsg(s32 fd,u8 bmRequestType,u8 bmRequest,u16 wValue,u16 wIndex,u16 wLength,void *rpData);
|
||||
s32 USB_WriteCtrlMsgAsync(s32 fd,u8 bmRequestType,u8 bmRequest,u16 wValue,u16 wIndex,u16 wLength,void *rpData,usbcallback cb,void *usrdata);
|
||||
|
||||
s32 USB_GetConfiguration(s32 fd, u8 *configuration);
|
||||
s32 USB_SetConfiguration(s32 fd, u8 configuration);
|
||||
s32 USB_SetAlternativeInterface(s32 fd, u8 interface, u8 alternateSetting);
|
||||
s32 USB_ClearHalt(s32 fd, u8 endpointAddress);
|
||||
s32 USB_GetDeviceList(usb_device_entry *descr_buffer,u8 num_descr,u8 interface_class,u8 *cnt_descr);
|
||||
|
||||
s32 USB_GetAsciiString(s32 fd,u8 bIndex,u16 wLangID,u16 wLength,void *rpData);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* defined(HW_RVL) */
|
||||
|
||||
#endif
|
28
wii/libogc/include/ogc/usbgecko.h
Normal file
28
wii/libogc/include/ogc/usbgecko.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef __USBGECKO_H___
|
||||
#define __USBGECKO_H___
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
void usb_flush(s32 chn);
|
||||
int usb_isgeckoalive(s32 chn);
|
||||
int usb_recvbuffer(s32 chn,void *buffer,int size);
|
||||
int usb_sendbuffer(s32 chn,const void *buffer,int size);
|
||||
int usb_recvbuffer_safe(s32 chn,void *buffer,int size);
|
||||
int usb_sendbuffer_safe(s32 chn,const void *buffer,int size);
|
||||
int usb_recvbuffer_ex(s32 chn,void *buffer,int size, int retries);
|
||||
int usb_sendbuffer_ex(s32 chn,const void *buffer,int size, int retries);
|
||||
int usb_recvbuffer_safe_ex(s32 chn,void *buffer,int size, int retries);
|
||||
int usb_sendbuffer_safe_ex(s32 chn,const void *buffer,int size, int retries);
|
||||
int usb_flashread(s32 chn, u32 offset, void *buffer, size_t length);
|
||||
int usb_flashwrite(s32 chn, u32 offset, const void *buffer, size_t length);
|
||||
int usb_flashverify(s32 chn);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
30
wii/libogc/include/ogc/usbmouse.h
Normal file
30
wii/libogc/include/ogc/usbmouse.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef __USBMOUSE_H__
|
||||
#define __USBMOUSE_H__
|
||||
|
||||
#if defined(HW_RVL)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct {
|
||||
u8 button;
|
||||
int rx;
|
||||
int ry;
|
||||
int rz;
|
||||
} mouse_event;
|
||||
|
||||
s32 MOUSE_Init(void);
|
||||
s32 MOUSE_Deinit(void);
|
||||
|
||||
s32 MOUSE_GetEvent(mouse_event *event);
|
||||
s32 MOUSE_FlushEvents(void);
|
||||
bool MOUSE_IsConnected(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
92
wii/libogc/include/ogc/usbstorage.h
Normal file
92
wii/libogc/include/ogc/usbstorage.h
Normal file
@ -0,0 +1,92 @@
|
||||
#ifndef __USBSTORAGE_H__
|
||||
#define __USBSTORAGE_H__
|
||||
|
||||
#if defined(HW_RVL)
|
||||
|
||||
#include <gctypes.h>
|
||||
#include <ogc/mutex.h>
|
||||
#include <ogc/disc_io.h>
|
||||
#include <ogc/system.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define USBSTORAGE_OK 0
|
||||
#define USBSTORAGE_ENOINTERFACE -10000
|
||||
#define USBSTORAGE_ESENSE -10001
|
||||
#define USBSTORAGE_ESHORTWRITE -10002
|
||||
#define USBSTORAGE_ESHORTREAD -10003
|
||||
#define USBSTORAGE_ESIGNATURE -10004
|
||||
#define USBSTORAGE_ETAG -10005
|
||||
#define USBSTORAGE_ESTATUS -10006
|
||||
#define USBSTORAGE_EDATARESIDUE -10007
|
||||
#define USBSTORAGE_ETIMEDOUT -10008
|
||||
#define USBSTORAGE_EINIT -10009
|
||||
#define USBSTORAGE_PROCESSING -10010
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u8 configuration;
|
||||
u32 interface;
|
||||
u32 altInterface;
|
||||
u8 bInterfaceSubClass;
|
||||
|
||||
u8 ep_in;
|
||||
u8 ep_out;
|
||||
|
||||
u8 max_lun;
|
||||
u32 *sector_size;
|
||||
|
||||
s32 usb_fd;
|
||||
|
||||
mutex_t lock;
|
||||
syswd_t alarm;
|
||||
s32 retval;
|
||||
|
||||
u32 tag;
|
||||
u8 suspended;
|
||||
|
||||
u8 *buffer;
|
||||
} usbstorage_handle;
|
||||
|
||||
#define B_RAW_DEVICE_DATA_IN 0x01
|
||||
#define B_RAW_DEVICE_COMMAND 0
|
||||
|
||||
typedef struct {
|
||||
uint8_t command[16];
|
||||
uint8_t command_length;
|
||||
uint8_t flags;
|
||||
uint8_t scsi_status;
|
||||
void* data;
|
||||
size_t data_length;
|
||||
} raw_device_command;
|
||||
|
||||
s32 USBStorage_Initialize();
|
||||
|
||||
s32 USBStorage_Open(usbstorage_handle *dev, s32 device_id, u16 vid, u16 pid);
|
||||
s32 USBStorage_Close(usbstorage_handle *dev);
|
||||
s32 USBStorage_Reset(usbstorage_handle *dev);
|
||||
|
||||
s32 USBStorage_GetMaxLUN(usbstorage_handle *dev);
|
||||
s32 USBStorage_MountLUN(usbstorage_handle *dev, u8 lun);
|
||||
s32 USBStorage_Suspend(usbstorage_handle *dev);
|
||||
s32 USBStorage_IsDVD();
|
||||
s32 USBStorage_ioctl(int request, ...);
|
||||
|
||||
s32 USBStorage_ReadCapacity(usbstorage_handle *dev, u8 lun, u32 *sector_size, u32 *n_sectors);
|
||||
s32 USBStorage_Read(usbstorage_handle *dev, u8 lun, u32 sector, u16 n_sectors, u8 *buffer);
|
||||
s32 USBStorage_Write(usbstorage_handle *dev, u8 lun, u32 sector, u16 n_sectors, const u8 *buffer);
|
||||
s32 USBStorage_StartStop(usbstorage_handle *dev, u8 lun, u8 lo_ej, u8 start, u8 imm);
|
||||
|
||||
#define DEVICE_TYPE_WII_USB (('W'<<24)|('U'<<16)|('S'<<8)|'B')
|
||||
|
||||
extern DISC_INTERFACE __io_usbstorage;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* HW_RVL */
|
||||
|
||||
#endif /* __USBSTORAGE_H__ */
|
206
wii/libogc/include/ogc/video.h
Normal file
206
wii/libogc/include/ogc/video.h
Normal file
@ -0,0 +1,206 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
video.h -- VIDEO subsystem
|
||||
|
||||
Copyright (C) 2004
|
||||
Michael Wiedenbauer (shagkur)
|
||||
Dave Murphy (WinterMute)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __VIDEO_H__
|
||||
#define __VIDEO_H__
|
||||
|
||||
/*!
|
||||
* \file video.h
|
||||
* \brief VIDEO subsystem
|
||||
*
|
||||
*/
|
||||
|
||||
#include <gctypes.h>
|
||||
#include "gx_struct.h"
|
||||
#include "video_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
/*!
|
||||
* \typedef void (*VIRetraceCallback)(u32 retraceCnt)
|
||||
* \brief function pointer typedef for the user's retrace callback
|
||||
* \param[in] retraceCnt current retrace count
|
||||
*/
|
||||
typedef void (*VIRetraceCallback)(u32 retraceCnt);
|
||||
|
||||
typedef void (*VIPositionCallback)(u32 posX,u32 posY);
|
||||
|
||||
void* VIDEO_GetNextFramebuffer();
|
||||
void* VIDEO_GetCurrentFramebuffer();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void VIDEO_Init()
|
||||
* \brief Initializes the VIDEO subsystem. This call should be done in the early stages of your main()
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void VIDEO_Init();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void VIDEO_Flush()
|
||||
* \brief Flush the shadow registers to the drivers video registers.
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void VIDEO_Flush();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void VIDEO_SetBlack(bool black)
|
||||
* \brief Blackout the VIDEO interface.
|
||||
*
|
||||
* \param[in] black Boolean flag to determine whether to blackout the VI or not.
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void VIDEO_SetBlack(bool black);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn u32 VIDEO_GetNextField()
|
||||
* \brief Get the next field in DS mode.
|
||||
*
|
||||
* \return \ref vi_fielddef "field"
|
||||
*/
|
||||
u32 VIDEO_GetNextField();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn u32 VIDEO_GetCurrentLine()
|
||||
* \brief Get current video line
|
||||
*
|
||||
* \return linenumber
|
||||
*/
|
||||
u32 VIDEO_GetCurrentLine();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn u32 VIDEO_GetCurrentTvMode()
|
||||
* \brief Get current configured TV mode
|
||||
*
|
||||
* \return \ref vi_standardtypedef "tvmode"
|
||||
*/
|
||||
u32 VIDEO_GetCurrentTvMode();
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void VIDEO_Configure(GXRModeObj *rmode)
|
||||
* \brief Configure the VI with the given render mode object
|
||||
*
|
||||
* \param[in] rmode pointer to the video/render mode \ref gxrmode_obj "configuration".
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void VIDEO_Configure(GXRModeObj *rmode);
|
||||
|
||||
u32 VIDEO_GetFrameBufferSize(GXRModeObj *rmode);
|
||||
|
||||
/*!
|
||||
* \fn void VIDEO_ClearFrameBuffer(GXRModeObj *rmode,void *fb,u32 color)
|
||||
* \brief Clear the given framebuffer.
|
||||
*
|
||||
* \param[in] rmode pointer to a GXRModeObj, specifying the mode.
|
||||
* \param[in] fb pointer to the startaddress of the framebuffer to clear.
|
||||
* \param[in] color YUYUV value to use for clearing.
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void VIDEO_ClearFrameBuffer(GXRModeObj *rmode,void *fb,u32 color);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void VIDEO_WaitVSync(void)
|
||||
* \brief Wait on the next vertical retrace
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void VIDEO_WaitVSync(void);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void VIDEO_SetNextFramebuffer(void *fb)
|
||||
* \brief Set the framebuffer for the next VI register update.
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void VIDEO_SetNextFramebuffer(void *fb);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn void VIDEO_SetNextRightFramebuffer(void *fb)
|
||||
* \brief Set the right framebuffer for the next VI register update. This is used for 3D Gloves for instance.
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
void VIDEO_SetNextRightFramebuffer(void *fb);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn VIRetraceCallback VIDEO_SetPreRetraceCallback(VIRetraceCallback callback)
|
||||
* \brief Set the Pre-Retrace callback function. This function is called within the video interrupt handler before the VI registers will be updated.
|
||||
*
|
||||
* \param[in] callback pointer to the callback function which is called at pre-retrace.
|
||||
*
|
||||
* \return Old pre-retrace callback or NULL
|
||||
*/
|
||||
VIRetraceCallback VIDEO_SetPreRetraceCallback(VIRetraceCallback callback);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn VIRetraceCallback VIDEO_SetPostRetraceCallback(VIRetraceCallback callback)
|
||||
* \brief Set the Post-Retrace callback function. This function is called within the video interrupt handler after the VI registers are updated.
|
||||
*
|
||||
* \param[in] callback pointer to the callback function which is called at post-retrace.
|
||||
*
|
||||
* \return Old post-retrace callback or NULL
|
||||
*/
|
||||
VIRetraceCallback VIDEO_SetPostRetraceCallback(VIRetraceCallback callback);
|
||||
|
||||
|
||||
/*!
|
||||
* \fn u32 VIDEO_HaveComponentCable(void)
|
||||
* \brief Check for a component cable. This function returns 1 when a Component (YPbPr) cable is connected.
|
||||
*
|
||||
* \return 1 if a component cable is connected, 0 otherwise
|
||||
*/
|
||||
u32 VIDEO_HaveComponentCable(void);
|
||||
|
||||
GXRModeObj * VIDEO_GetPreferredMode(GXRModeObj *mode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
195
wii/libogc/include/ogc/video_types.h
Normal file
195
wii/libogc/include/ogc/video_types.h
Normal file
@ -0,0 +1,195 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
video_types.h -- support header
|
||||
|
||||
Copyright (C) 2004
|
||||
Michael Wiedenbauer (shagkur)
|
||||
Dave Murphy (WinterMute)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __VIDEO_TYPES_H__
|
||||
#define __VIDEO_TYPES_H__
|
||||
|
||||
/*!
|
||||
\file video_types.h
|
||||
\brief support header
|
||||
*/
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
/*!
|
||||
* \addtogroup vi_defines List of defines used for the VIDEO subsystem
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
#define VI_DISPLAY_PIX_SZ 2 /*!< multiplier to get real pixel size in bytes */
|
||||
|
||||
/*!
|
||||
* \addtogroup vi_modetypedef VIDEO mode types
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define VI_INTERLACE 0 /*!< Video mode INTERLACED. */
|
||||
#define VI_NON_INTERLACE 1 /*!< Video mode NON INTERLACED */
|
||||
#define VI_PROGRESSIVE 2 /*!< Video mode PROGRESSIVE. Special mode for higher quality */
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
* \addtogroup vi_standardtypedef VIDEO standard types
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define VI_NTSC 0 /*!< Video standard used in North America and Japan */
|
||||
#define VI_PAL 1 /*!< Video standard used in Europe */
|
||||
#define VI_MPAL 2 /*!< Video standard, similar to NTSC, used in Brazil */
|
||||
#define VI_DEBUG 3 /*!< Video standard, for debugging purpose, used in North America and Japan. Special decoder needed */
|
||||
#define VI_DEBUG_PAL 4 /*!< Video standard, for debugging purpose, used in Europe. Special decoder needed */
|
||||
#define VI_EURGB60 5 /*!< RGB 60Hz, 480 lines mode (same timing and aspect ratio as NTSC) used in Europe */
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#define VI_XFBMODE_SF 0
|
||||
#define VI_XFBMODE_DF 1
|
||||
|
||||
|
||||
/*!
|
||||
* \addtogroup vi_fielddef VIDEO field types
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define VI_FIELD_ABOVE 1 /*!< Upper field in DS mode */
|
||||
#define VI_FIELD_BELOW 0 /*!< Lower field in DS mode */
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
// Maximum screen space
|
||||
#define VI_MAX_WIDTH_NTSC 720
|
||||
#define VI_MAX_HEIGHT_NTSC 480
|
||||
|
||||
#define VI_MAX_WIDTH_PAL 720
|
||||
#define VI_MAX_HEIGHT_PAL 576
|
||||
|
||||
#define VI_MAX_WIDTH_MPAL 720
|
||||
#define VI_MAX_HEIGHT_MPAL 480
|
||||
|
||||
#define VI_MAX_WIDTH_EURGB60 VI_MAX_WIDTH_NTSC
|
||||
#define VI_MAX_HEIGHT_EURGB60 VI_MAX_HEIGHT_NTSC
|
||||
|
||||
#define VIDEO_PadFramebufferWidth(width) ((u16)(((u16)(width) + 15) & ~15)) /*!< macro to pad the width to a multiple of 16 */
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#define VI_TVMODE(fmt, mode) ( ((fmt) << 2) + (mode) )
|
||||
|
||||
#define VI_TVMODE_NTSC_INT VI_TVMODE(VI_NTSC, VI_INTERLACE)
|
||||
#define VI_TVMODE_NTSC_DS VI_TVMODE(VI_NTSC, VI_NON_INTERLACE)
|
||||
#define VI_TVMODE_NTSC_PROG VI_TVMODE(VI_NTSC, VI_PROGRESSIVE)
|
||||
|
||||
#define VI_TVMODE_PAL_INT VI_TVMODE(VI_PAL, VI_INTERLACE)
|
||||
#define VI_TVMODE_PAL_DS VI_TVMODE(VI_PAL, VI_NON_INTERLACE)
|
||||
#define VI_TVMODE_PAL_PROG VI_TVMODE(VI_PAL, VI_PROGRESSIVE)
|
||||
|
||||
#define VI_TVMODE_EURGB60_INT VI_TVMODE(VI_EURGB60, VI_INTERLACE)
|
||||
#define VI_TVMODE_EURGB60_DS VI_TVMODE(VI_EURGB60, VI_NON_INTERLACE)
|
||||
#define VI_TVMODE_EURGB60_PROG VI_TVMODE(VI_EURGB60, VI_PROGRESSIVE)
|
||||
|
||||
#define VI_TVMODE_MPAL_INT VI_TVMODE(VI_MPAL, VI_INTERLACE)
|
||||
#define VI_TVMODE_MPAL_DS VI_TVMODE(VI_MPAL, VI_NON_INTERLACE)
|
||||
#define VI_TVMODE_MPAL_PROG VI_TVMODE(VI_MPAL, VI_PROGRESSIVE)
|
||||
|
||||
#define VI_TVMODE_DEBUG_INT VI_TVMODE(VI_DEBUG, VI_INTERLACE)
|
||||
|
||||
#define VI_TVMODE_DEBUG_PAL_INT VI_TVMODE(VI_DEBUG_PAL, VI_INTERLACE)
|
||||
#define VI_TVMODE_DEBUG_PAL_DS VI_TVMODE(VI_DEBUG_PAL, VI_NON_INTERLACE)
|
||||
|
||||
|
||||
/*!
|
||||
* \addtogroup vi_defines List of defines used for the VIDEO subsystem
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
* \addtogroup gxrmode_obj VIDEO render modes
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern GXRModeObj TVNtsc240Ds; /*!< Video and render mode configuration for 240 lines,singlefield NTSC mode */
|
||||
extern GXRModeObj TVNtsc240DsAa; /*!< Video and render mode configuration for 240 lines,singlefield,antialiased NTSC mode */
|
||||
extern GXRModeObj TVNtsc240Int; /*!< Video and render mode configuration for 240 lines,interlaced NTSC mode */
|
||||
extern GXRModeObj TVNtsc240IntAa; /*!< Video and render mode configuration for 240 lines,interlaced,antialiased NTSC mode */
|
||||
extern GXRModeObj TVNtsc480Int; /*!< Video and render mode configuration for 480 lines,interlaced NTSC mode */
|
||||
extern GXRModeObj TVNtsc480IntDf; /*!< Video and render mode configuration for 480 lines,interlaced,doublefield NTSC mode */
|
||||
extern GXRModeObj TVNtsc480IntAa; /*!< Video and render mode configuration for 480 lines,interlaced,doublefield,antialiased NTSC mode */
|
||||
extern GXRModeObj TVNtsc480Prog; /*!< Video and render mode configuration for 480 lines,progressive,singlefield NTSC mode */
|
||||
extern GXRModeObj TVNtsc480ProgSoft;
|
||||
extern GXRModeObj TVNtsc480ProgAa;
|
||||
extern GXRModeObj TVMpal240Ds;
|
||||
extern GXRModeObj TVMpal240DsAa;
|
||||
extern GXRModeObj TVMpal480IntDf; /*!< Video and render mode configuration for 480 lines,interlaced,doublefield,antialiased MPAL mode */
|
||||
extern GXRModeObj TVMpal480IntAa;
|
||||
extern GXRModeObj TVMpal480Prog;
|
||||
extern GXRModeObj TVPal264Ds; /*!< Video and render mode configuration for 264 lines,singlefield PAL mode */
|
||||
extern GXRModeObj TVPal264DsAa; /*!< Video and render mode configuration for 264 lines,singlefield,antialiased PAL mode */
|
||||
extern GXRModeObj TVPal264Int; /*!< Video and render mode configuration for 264 lines,interlaced PAL mode */
|
||||
extern GXRModeObj TVPal264IntAa; /*!< Video and render mode configuration for 264 lines,interlaced,antialiased PAL mode */
|
||||
extern GXRModeObj TVPal524IntAa; /*!< Video and render mode configuration for 524 lines,interlaced,antialiased PAL mode */
|
||||
extern GXRModeObj TVPal528Int; /*!< Video and render mode configuration for 528 lines,interlaced,antialiased PAL mode */
|
||||
extern GXRModeObj TVPal528IntDf; /*!< Video and render mode configuration for 264 lines,interlaced,doublefield antialiased PAL mode */
|
||||
extern GXRModeObj TVPal576IntDfScale;
|
||||
extern GXRModeObj TVPal576ProgScale;
|
||||
extern GXRModeObj TVEurgb60Hz240Ds;
|
||||
extern GXRModeObj TVEurgb60Hz240DsAa;
|
||||
extern GXRModeObj TVEurgb60Hz240Int;
|
||||
extern GXRModeObj TVEurgb60Hz240IntAa;
|
||||
extern GXRModeObj TVEurgb60Hz480Int;
|
||||
extern GXRModeObj TVEurgb60Hz480IntDf;
|
||||
extern GXRModeObj TVEurgb60Hz480IntAa;
|
||||
extern GXRModeObj TVEurgb60Hz480Prog;
|
||||
extern GXRModeObj TVEurgb60Hz480ProgSoft;
|
||||
extern GXRModeObj TVEurgb60Hz480ProgAa;
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif
|
79
wii/libogc/include/ogc/wiilaunch.h
Normal file
79
wii/libogc/include/ogc/wiilaunch.h
Normal file
@ -0,0 +1,79 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
wiilaunch.h -- Wii NAND title launching and argument passing
|
||||
|
||||
Copyright (C) 2008
|
||||
Hector Martin (marcan)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
#if defined(HW_RVL)
|
||||
|
||||
#ifndef __WIILAUNCH_H__
|
||||
#define __WIILAUNCH_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
#include <gcutil.h>
|
||||
|
||||
// not initialized
|
||||
#define WII_ENOTINIT -0x9001
|
||||
// internal error
|
||||
#define WII_EINTERNAL -0x9002
|
||||
// checksum error
|
||||
#define WII_ECHECKSUM -0x9003
|
||||
// required title not installed
|
||||
#define WII_EINSTALL -0x9004
|
||||
// argument list too big
|
||||
#define WII_E2BIG -0x9005
|
||||
|
||||
// you probably shouldn't use anything not in this list, since those may change
|
||||
// these are guaranteed to exist because Nintendo hardcodes them
|
||||
// any category not on this list will cause a hang when the settings menu tries to do the animation
|
||||
// however, settings items contained in one of the following categories will work
|
||||
// nonexistent items will cause a 404
|
||||
#define SETTINGS_CALENDAR "Calendar/Calendar_index.html"
|
||||
#define SETTINGS_DISPLAY "Display/Display_index.html"
|
||||
#define SETTINGS_SOUND "Sound/Sound_index.html"
|
||||
#define SETTINGS_PARENTAL "Parental_Control/Parental_Control_index.html"
|
||||
#define SETTINGS_INTERNET "Internet/Internet_index.html"
|
||||
#define SETTINGS_WC24 "WiiConnect24/Wiiconnect24_index.html"
|
||||
#define SETTINGS_UPDATE "Update/Update_index.html"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
s32 WII_Initialize(void);
|
||||
s32 WII_ReturnToMenu(void);
|
||||
s32 WII_ReturnToSettings(void);
|
||||
s32 WII_ReturnToSettingsPage(const char *page);
|
||||
s32 WII_LaunchTitle(u64 titleID);
|
||||
s32 WII_LaunchTitleWithArgs(u64 titleID, int launchcode, ...);
|
||||
s32 WII_OpenURL(const char *url);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
41
wii/libogc/include/ogcsys.h
Normal file
41
wii/libogc/include/ogcsys.h
Normal file
@ -0,0 +1,41 @@
|
||||
#ifndef __OGCSYS_H__
|
||||
#define __OGCSYS_H__
|
||||
|
||||
#include <gccore.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined(HW_RVL)
|
||||
#define TB_BUS_CLOCK 243000000u
|
||||
#define TB_CORE_CLOCK 729000000u
|
||||
#elif defined(HW_DOL)
|
||||
#define TB_BUS_CLOCK 162000000u
|
||||
#define TB_CORE_CLOCK 486000000u
|
||||
#endif
|
||||
#define TB_TIMER_CLOCK (TB_BUS_CLOCK/4000) //4th of the bus frequency
|
||||
|
||||
#define TB_MSPERSEC 1000
|
||||
#define TB_USPERSEC 1000000
|
||||
#define TB_NSPERSEC 1000000000
|
||||
#define TB_NSPERMS 1000000
|
||||
#define TB_NSPERUS 1000
|
||||
#define TB_USPERTICK 10000
|
||||
|
||||
#define TB_SECSPERMIN 60
|
||||
#define TB_MINSPERHR 60
|
||||
#define TB_MONSPERYR 12
|
||||
#define TB_DAYSPERYR 365
|
||||
#define TB_HRSPERDAY 24
|
||||
#define TB_SECSPERDAY (TB_SECSPERMIN*TB_MINSPERHR*TB_HRSPERDAY)
|
||||
#define TB_SECSPERNYR (365*TB_SECSPERDAY)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int nanosleep(struct timespec *tb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
196
wii/libogc/include/samplerate.h
Normal file
196
wii/libogc/include/samplerate.h
Normal file
@ -0,0 +1,196 @@
|
||||
/*
|
||||
** Copyright (C) 2002-2004 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation; either version 2 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
** API documentation is available here:
|
||||
** http://www.mega-nerd.com/SRC/api.html
|
||||
*/
|
||||
|
||||
#ifndef SAMPLERATE_H
|
||||
#define SAMPLERATE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
/* Opaque data type SRC_STATE. */
|
||||
typedef struct SRC_STATE_tag SRC_STATE ;
|
||||
|
||||
/* SRC_DATA is used to pass data to src_simple() and src_process(). */
|
||||
typedef struct
|
||||
{ float *data_in, *data_out ;
|
||||
|
||||
long input_frames, output_frames ;
|
||||
long input_frames_used, output_frames_gen ;
|
||||
|
||||
int end_of_input ;
|
||||
|
||||
double src_ratio ;
|
||||
} SRC_DATA ;
|
||||
|
||||
/* SRC_CB_DATA is used with callback based API. */
|
||||
typedef struct
|
||||
{ long frames ;
|
||||
float *data_in ;
|
||||
} SRC_CB_DATA ;
|
||||
|
||||
/*
|
||||
** User supplied callback function type for use with src_callback_new()
|
||||
** and src_callback_read(). First parameter is the same pointer that was
|
||||
** passed into src_callback_new(). Second parameter is pointer to a
|
||||
** pointer. The user supplied callback function must modify *data to
|
||||
** point to the start of the user supplied float array. The user supplied
|
||||
** function must return the number of frames that **data points to.
|
||||
*/
|
||||
|
||||
typedef long (*src_callback_t) (void *cb_data, float **data) ;
|
||||
|
||||
/*
|
||||
** Standard initialisation function : return an anonymous pointer to the
|
||||
** internal state of the converter. Choose a converter from the enums below.
|
||||
** Error returned in *error.
|
||||
*/
|
||||
|
||||
SRC_STATE* src_new (int converter_type, int channels, int *error) ;
|
||||
|
||||
/*
|
||||
** Initilisation for callback based API : return an anonymous pointer to the
|
||||
** internal state of the converter. Choose a converter from the enums below.
|
||||
** The cb_data pointer can point to any data or be set to NULL. Whatever the
|
||||
** value, when processing, user supplied function "func" gets called with
|
||||
** cb_data as first parameter.
|
||||
*/
|
||||
|
||||
SRC_STATE* src_callback_new (src_callback_t func, int converter_type, int channels,
|
||||
int *error, void* cb_data) ;
|
||||
|
||||
/*
|
||||
** Cleanup all internal allocations.
|
||||
** Always returns NULL.
|
||||
*/
|
||||
|
||||
SRC_STATE* src_delete (SRC_STATE *state) ;
|
||||
|
||||
/*
|
||||
** Standard processing function.
|
||||
** Returns non zero on error.
|
||||
*/
|
||||
|
||||
int src_process (SRC_STATE *state, SRC_DATA *data) ;
|
||||
|
||||
/*
|
||||
** Callback based processing function. Read up to frames worth of data from
|
||||
** the converter int *data and return frames read or -1 on error.
|
||||
*/
|
||||
long src_callback_read (SRC_STATE *state, double src_ratio, long frames, float *data) ;
|
||||
|
||||
/*
|
||||
** Simple interface for performing a single conversion from input buffer to
|
||||
** output buffer at a fixed conversion ratio.
|
||||
** Simple interface does not require initialisation as it can only operate on
|
||||
** a single buffer worth of audio.
|
||||
*/
|
||||
|
||||
int src_simple (SRC_DATA *data, int converter_type, int channels) ;
|
||||
|
||||
/*
|
||||
** This library contains a number of different sample rate converters,
|
||||
** numbered 0 through N.
|
||||
**
|
||||
** Return a string giving either a name or a more full description of each
|
||||
** sample rate converter or NULL if no sample rate converter exists for
|
||||
** the given value. The converters are sequentially numbered from 0 to N.
|
||||
*/
|
||||
|
||||
const char *src_get_name (int converter_type) ;
|
||||
const char *src_get_description (int converter_type) ;
|
||||
const char *src_get_version (void) ;
|
||||
|
||||
/*
|
||||
** Set a new SRC ratio. This allows step responses
|
||||
** in the conversion ratio.
|
||||
** Returns non zero on error.
|
||||
*/
|
||||
|
||||
int src_set_ratio (SRC_STATE *state, double new_ratio) ;
|
||||
|
||||
/*
|
||||
** Reset the internal SRC state.
|
||||
** Does not modify the quality settings.
|
||||
** Does not free any memory allocations.
|
||||
** Returns non zero on error.
|
||||
*/
|
||||
|
||||
int src_reset (SRC_STATE *state) ;
|
||||
|
||||
/*
|
||||
** Return TRUE if ratio is a valid conversion ratio, FALSE
|
||||
** otherwise.
|
||||
*/
|
||||
|
||||
int src_is_valid_ratio (double ratio) ;
|
||||
|
||||
/*
|
||||
** Return an error number.
|
||||
*/
|
||||
|
||||
int src_error (SRC_STATE *state) ;
|
||||
|
||||
/*
|
||||
** Convert the error number into a string.
|
||||
*/
|
||||
const char* src_strerror (int error) ;
|
||||
|
||||
/*
|
||||
** The following enums can be used to set the interpolator type
|
||||
** using the function src_set_converter().
|
||||
*/
|
||||
|
||||
enum
|
||||
{
|
||||
SRC_SINC_BEST_QUALITY = 0,
|
||||
SRC_SINC_MEDIUM_QUALITY = 1,
|
||||
SRC_SINC_FASTEST = 2,
|
||||
SRC_ZERO_ORDER_HOLD = 3,
|
||||
SRC_LINEAR = 4
|
||||
} ;
|
||||
|
||||
/*
|
||||
** Extra helper functions for converting from short to float and
|
||||
** back again.
|
||||
*/
|
||||
|
||||
void src_short_to_float_array (const short *in, float *out, int len) ;
|
||||
void src_float_to_short_array (const float *in, short *out, int len) ;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* SAMPLERATE_H */
|
||||
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: 5421ef3e-c898-4ec3-8671-ea03d943ee00
|
||||
*/
|
||||
|
18
wii/libogc/include/sdcard/card_buf.h
Normal file
18
wii/libogc/include/sdcard/card_buf.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef __CARD_BUF_H__
|
||||
#define __CARD_BUF_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void sdgecko_initBufferPool();
|
||||
u8* sdgecko_allocBuffer();
|
||||
void sdgecko_freeBuffer(u8 *buf);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
65
wii/libogc/include/sdcard/card_cmn.h
Normal file
65
wii/libogc/include/sdcard/card_cmn.h
Normal file
@ -0,0 +1,65 @@
|
||||
#ifndef __CARD_CMN_H__
|
||||
#define __CARD_CMN_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#define CARDIO_ERROR_READY 0
|
||||
#define CARDIO_ERROR_BUSY -1
|
||||
#define CARDIO_ERROR_WRONGDEVICE -2
|
||||
#define CARDIO_ERROR_NOCARD -3
|
||||
#define CARDIO_ERROR_IDLE -4
|
||||
#define CARDIO_ERROR_IOERROR -5
|
||||
#define CARDIO_ERROR_IOTIMEOUT -6
|
||||
|
||||
#define CARDIO_ERROR_NOTPERMITTED -107
|
||||
#define CARDIO_ERROR_ROOTENTRY -108
|
||||
#define CARDIO_ERROR_OUTOFROOTENTRY -109
|
||||
#define CARDIO_ERROR_FILEEXIST -110
|
||||
#define CARDIO_ERROR_NOEMPTYCLUSTER -111
|
||||
#define CARDIO_ERROR_EOF -112
|
||||
#define CARDIO_ERROR_SYSTEMPARAM -113
|
||||
#define CARDIO_ERROR_FILEOPENED -114
|
||||
#define CARDIO_ERROR_FILENOTOPENED -115
|
||||
#define CARDIO_ERROR_FILENAMETOOLONG -116
|
||||
#define CARDIO_ERROR_INVALIDNAME -117
|
||||
#define CARDIO_ERROR_NOLONGNAME -118
|
||||
#define CARDIO_ERROR_INCORRECTFAT -119
|
||||
#define CARDIO_ERROR_NOTFOUND -120
|
||||
#define CARDIO_ERROR_OUTOFMEMORY -121
|
||||
#define CARDIO_ERROR_INVALIDFAT -122
|
||||
#define CARDIO_ERROR_INVALIDMBR -123
|
||||
#define CARDIO_ERROR_INVALIDPBR -124
|
||||
#define CARDIO_ERROR_NOEMPTYBLOCK -125
|
||||
#define CARDIO_ERROR_INTERNAL -126
|
||||
#define CARDIO_ERROR_INVALIDPARAM -127
|
||||
#define CARDIO_ERROR_FATALERROR -128
|
||||
|
||||
#define MAX_DRIVE 2
|
||||
#define SECTOR_SIZE 512
|
||||
|
||||
#define NOT_INITIALIZED 0
|
||||
#define INITIALIZING 1
|
||||
#define INITIALIZED 2
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct _dev_info {
|
||||
u32 CpV;
|
||||
u32 HpC;
|
||||
u32 SpH;
|
||||
u32 allS;
|
||||
u32 szS;
|
||||
u32 PBpV;
|
||||
u32 LBpV;
|
||||
u32 SpB;
|
||||
u32 PpB;
|
||||
u32 szP;
|
||||
} DEV_INFO;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
51
wii/libogc/include/sdcard/card_io.h
Normal file
51
wii/libogc/include/sdcard/card_io.h
Normal file
@ -0,0 +1,51 @@
|
||||
#ifndef __CARD_IO_H__
|
||||
#define __CARD_IO_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#define MAX_MI_NUM 1
|
||||
#define MAX_DI_NUM 5
|
||||
|
||||
#define PAGE_SIZE256 256
|
||||
#define PAGE_SIZE512 512
|
||||
|
||||
/* CID Register */
|
||||
#define MANUFACTURER_ID(drv_no) ((u8)(g_CID[drv_no][0]))
|
||||
|
||||
/* CSD Register */
|
||||
#define READ_BL_LEN(drv_no) ((u8)(g_CSD[drv_no][5]&0x0f))
|
||||
#define WRITE_BL_LEN(drv_no) ((u8)((g_CSD[drv_no][12]&0x03)<<2)|((g_CSD[drv_no][13]>>6)&0x03))
|
||||
#define C_SIZE(drv_no) ((u16)(((g_CSD[drv_no][6]&0x03)<<10)|(g_CSD[drv_no][7]<<2)|((g_CSD[drv_no][8]>>6)&0x03)))
|
||||
#define C_SIZE_MULT(drv_no) ((u8)((g_CSD[drv_no][9]&0x03)<<1)|((g_CSD[drv_no][10]>>7)&0x01))
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
extern u8 g_CSD[MAX_DRIVE][16];
|
||||
extern u8 g_CID[MAX_DRIVE][16];
|
||||
extern u8 g_mCode[MAX_MI_NUM];
|
||||
extern u16 g_dCode[MAX_MI_NUM][MAX_DI_NUM];
|
||||
|
||||
|
||||
void sdgecko_initIODefault();
|
||||
s32 sdgecko_initIO(s32 drv_no);
|
||||
s32 sdgecko_preIO(s32 drv_no);
|
||||
s32 sdgecko_readCID(s32 drv_no);
|
||||
s32 sdgecko_readCSD(s32 drv_no);
|
||||
s32 sdgecko_readStatus(s32 drv_no);
|
||||
s32 sdgecko_readSectors(s32 drv_no,u32 sector_no,u32 num_sectors,void *buf);
|
||||
s32 sdgecko_writeSector(s32 drv_no,u32 sector_no,const void *buf,u32 len);
|
||||
s32 sdgecko_writeSectors(s32 drv_no,u32 sector_no,u32 num_sectors,const void *buf);
|
||||
|
||||
s32 sdgecko_doUnmount(s32 drv_no);
|
||||
|
||||
void sdgecko_insertedCB(s32 drv_no);
|
||||
void sdgecko_ejectedCB(s32 drv_no);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
45
wii/libogc/include/sdcard/gcsd.h
Normal file
45
wii/libogc/include/sdcard/gcsd.h
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
|
||||
gcsd.h
|
||||
|
||||
Hardware routines for reading and writing to SD geckos connected
|
||||
to the memory card ports.
|
||||
|
||||
These functions are just wrappers around libsdcard's functions.
|
||||
|
||||
Copyright (c) 2008 Sven "svpe" Peter <svpe@gmx.net>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
3. The name of the author may not be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __GCSD_H__
|
||||
#define __GCSD_H__
|
||||
|
||||
#include <gccore.h>
|
||||
#include <ogc/disc_io.h>
|
||||
|
||||
#define DEVICE_TYPE_GC_SD (('G'<<24)|('C'<<16)|('S'<<8)|'D')
|
||||
|
||||
extern const DISC_INTERFACE __io_gcsda;
|
||||
extern const DISC_INTERFACE __io_gcsdb;
|
||||
|
||||
#endif
|
44
wii/libogc/include/sdcard/wiisd_io.h
Normal file
44
wii/libogc/include/sdcard/wiisd_io.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
|
||||
wii_sd.h
|
||||
|
||||
Hardware interface for libfat Wii internal SD
|
||||
|
||||
Copyright (c) 2008
|
||||
Michael Wiedenbauer (shagkur)
|
||||
Dave Murphy (WinterMute)
|
||||
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
3. The name of the author may not be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __WIISD_IO_H__
|
||||
#define __WIISD_IO_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
#include <ogc/disc_io.h>
|
||||
|
||||
#define DEVICE_TYPE_WII_SD (('W'<<24)|('I'<<16)|('S'<<8)|'D')
|
||||
|
||||
extern const DISC_INTERFACE __io_wiisd;
|
||||
|
||||
#endif
|
150
wii/libogc/include/smb.h
Normal file
150
wii/libogc/include/smb.h
Normal file
@ -0,0 +1,150 @@
|
||||
/****************************************************************************
|
||||
* TinySMB
|
||||
* Nintendo Wii/GameCube SMB implementation
|
||||
*
|
||||
* Copyright softdev
|
||||
* Modified by Tantric to utilize NTLM authentication
|
||||
* PathInfo added by rodries
|
||||
* SMB devoptab by scip, rodries
|
||||
*
|
||||
* You will find WireShark (http://www.wireshark.org/)
|
||||
* invaluable for debugging SAMBA implementations.
|
||||
*
|
||||
* Recommended Reading
|
||||
* Implementing CIFS - Christopher R Hertel
|
||||
* http://www.ubiqx.org/cifs/SMB.html
|
||||
*
|
||||
* License:
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __NBTSMB_H__
|
||||
#define __NBTSMB_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
#include <sys/statvfs.h>
|
||||
|
||||
#define SMB_MAXPATH 4096
|
||||
|
||||
/**
|
||||
* SMB Error codes
|
||||
*/
|
||||
#define SMB_SUCCESS 0
|
||||
#define SMB_ERROR -1
|
||||
#define SMB_BAD_PROTOCOL -2
|
||||
#define SMB_BAD_COMMAND -3
|
||||
#define SMB_PROTO_FAIL -4
|
||||
#define SMB_NOT_USER -5
|
||||
#define SMB_BAD_KEYLEN -6
|
||||
#define SMB_BAD_DATALEN -7
|
||||
#define SMB_BAD_LOGINDATA -8
|
||||
|
||||
/**
|
||||
* SMB File Open Function
|
||||
*/
|
||||
#define SMB_OF_OPEN 1
|
||||
#define SMB_OF_TRUNCATE 2
|
||||
#define SMB_OF_CREATE 16
|
||||
|
||||
/**
|
||||
* FileSearch
|
||||
*/
|
||||
#define SMB_SRCH_READONLY 1
|
||||
#define SMB_SRCH_HIDDEN 2
|
||||
#define SMB_SRCH_SYSTEM 4
|
||||
#define SMB_SRCH_VOLUME 8
|
||||
#define SMB_SRCH_DIRECTORY 16
|
||||
#define SMB_SRCH_ARCHIVE 32
|
||||
|
||||
/**
|
||||
* SMB File Access Modes
|
||||
*/
|
||||
#define SMB_OPEN_READING 0
|
||||
#define SMB_OPEN_WRITING 1
|
||||
#define SMB_OPEN_READWRITE 2
|
||||
#define SMB_OPEN_COMPATIBLE 0
|
||||
#define SMB_DENY_READWRITE 0x10
|
||||
#define SMB_DENY_WRITE 0x20
|
||||
#define SMB_DENY_READ 0x30
|
||||
#define SMB_DENY_NONE 0x40
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/***
|
||||
* SMB Connection Handle
|
||||
*/
|
||||
typedef u32 SMBCONN;
|
||||
|
||||
/***
|
||||
* SMB File Handle
|
||||
*/
|
||||
typedef void* SMBFILE;
|
||||
|
||||
/*** SMB_FILEENTRY
|
||||
SMB Long Filename Directory Entry
|
||||
***/
|
||||
typedef struct
|
||||
{
|
||||
u64 size;
|
||||
u64 ctime;
|
||||
u64 atime;
|
||||
u64 mtime;
|
||||
u32 attributes;
|
||||
u16 sid;
|
||||
char name[768]; //unicode
|
||||
} SMBDIRENTRY;
|
||||
|
||||
/**
|
||||
* Prototypes
|
||||
*/
|
||||
|
||||
/*** Functions to be used with stdio API ***/
|
||||
bool smbInitDevice(const char* name, const char *user, const char *password, const char *share, const char *ip);
|
||||
bool smbInit(const char *user, const char *password, const char *share, const char *ip);
|
||||
void smbClose(const char* name);
|
||||
bool smbCheckConnection(const char* name);
|
||||
void smbSetSearchFlags(unsigned short flags);
|
||||
|
||||
/*** Session ***/
|
||||
s32 SMB_Connect(SMBCONN *smbhndl, const char *user, const char *password, const char *share, const char *IP);
|
||||
void SMB_Close(SMBCONN smbhndl);
|
||||
s32 SMB_Reconnect(SMBCONN *_smbhndl, bool test_conn);
|
||||
|
||||
/*** File Find ***/
|
||||
s32 SMB_PathInfo(const char *filename, SMBDIRENTRY *sdir, SMBCONN smbhndl);
|
||||
s32 SMB_FindFirst(const char *filename, unsigned short flags, SMBDIRENTRY *sdir, SMBCONN smbhndl);
|
||||
s32 SMB_FindNext(SMBDIRENTRY *sdir,SMBCONN smbhndl);
|
||||
s32 SMB_FindClose(SMBDIRENTRY *sdir,SMBCONN smbhndl);
|
||||
|
||||
/*** File I/O ***/
|
||||
SMBFILE SMB_OpenFile(const char *filename, unsigned short access, unsigned short creation,SMBCONN smbhndl);
|
||||
void SMB_CloseFile(SMBFILE sfid);
|
||||
s32 SMB_ReadFile(char *buffer, size_t size, off_t offset, SMBFILE sfid);
|
||||
s32 SMB_WriteFile(const char *buffer, size_t size, off_t offset, SMBFILE sfid);
|
||||
s32 SMB_CreateDirectory(const char *dirname, SMBCONN smbhndl);
|
||||
s32 SMB_DeleteDirectory(const char *dirname, SMBCONN smbhndl);
|
||||
s32 SMB_DeleteFile(const char *filename, SMBCONN smbhndl);
|
||||
s32 SMB_Rename(const char *filename, const char * newname, SMBCONN smbhndl);
|
||||
s32 SMB_DiskInformation(struct statvfs *buf, SMBCONN smbhndl);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
748
wii/libogc/include/wiiuse/wiiuse.h
Normal file
748
wii/libogc/include/wiiuse/wiiuse.h
Normal file
@ -0,0 +1,748 @@
|
||||
#ifndef __WIIUSE_H__
|
||||
#define __WIIUSE_H__
|
||||
|
||||
#if defined(_WIN32)
|
||||
/* windows */
|
||||
#include <windows.h>
|
||||
#elif defined(GEKKO)
|
||||
/* wii */
|
||||
#include <bte/bte.h>
|
||||
#elif defined(__linux__)
|
||||
/* nix */
|
||||
#include <bluetooth/bluetooth.h>
|
||||
#endif
|
||||
|
||||
#ifdef WIIUSE_INTERNAL_H_INCLUDED
|
||||
#define WCONST
|
||||
#else
|
||||
#define WCONST const
|
||||
#endif
|
||||
|
||||
/* led bit masks */
|
||||
#define WIIMOTE_LED_NONE 0x00
|
||||
#define WIIMOTE_LED_1 0x10
|
||||
#define WIIMOTE_LED_2 0x20
|
||||
#define WIIMOTE_LED_3 0x40
|
||||
#define WIIMOTE_LED_4 0x80
|
||||
|
||||
/* button codes */
|
||||
#define WIIMOTE_BUTTON_TWO 0x0001
|
||||
#define WIIMOTE_BUTTON_ONE 0x0002
|
||||
#define WIIMOTE_BUTTON_B 0x0004
|
||||
#define WIIMOTE_BUTTON_A 0x0008
|
||||
#define WIIMOTE_BUTTON_MINUS 0x0010
|
||||
#define WIIMOTE_BUTTON_ZACCEL_BIT6 0x0020
|
||||
#define WIIMOTE_BUTTON_ZACCEL_BIT7 0x0040
|
||||
#define WIIMOTE_BUTTON_HOME 0x0080
|
||||
#define WIIMOTE_BUTTON_LEFT 0x0100
|
||||
#define WIIMOTE_BUTTON_RIGHT 0x0200
|
||||
#define WIIMOTE_BUTTON_DOWN 0x0400
|
||||
#define WIIMOTE_BUTTON_UP 0x0800
|
||||
#define WIIMOTE_BUTTON_PLUS 0x1000
|
||||
#define WIIMOTE_BUTTON_ZACCEL_BIT4 0x2000
|
||||
#define WIIMOTE_BUTTON_ZACCEL_BIT5 0x4000
|
||||
#define WIIMOTE_BUTTON_UNKNOWN 0x8000
|
||||
#define WIIMOTE_BUTTON_ALL 0x1F9F
|
||||
|
||||
/* nunchul button codes */
|
||||
#define NUNCHUK_BUTTON_Z 0x01
|
||||
#define NUNCHUK_BUTTON_C 0x02
|
||||
#define NUNCHUK_BUTTON_ALL 0x03
|
||||
|
||||
/* classic controller button codes */
|
||||
#define CLASSIC_CTRL_BUTTON_UP 0x0001
|
||||
#define CLASSIC_CTRL_BUTTON_LEFT 0x0002
|
||||
#define CLASSIC_CTRL_BUTTON_ZR 0x0004
|
||||
#define CLASSIC_CTRL_BUTTON_X 0x0008
|
||||
#define CLASSIC_CTRL_BUTTON_A 0x0010
|
||||
#define CLASSIC_CTRL_BUTTON_Y 0x0020
|
||||
#define CLASSIC_CTRL_BUTTON_B 0x0040
|
||||
#define CLASSIC_CTRL_BUTTON_ZL 0x0080
|
||||
#define CLASSIC_CTRL_BUTTON_FULL_R 0x0200
|
||||
#define CLASSIC_CTRL_BUTTON_PLUS 0x0400
|
||||
#define CLASSIC_CTRL_BUTTON_HOME 0x0800
|
||||
#define CLASSIC_CTRL_BUTTON_MINUS 0x1000
|
||||
#define CLASSIC_CTRL_BUTTON_FULL_L 0x2000
|
||||
#define CLASSIC_CTRL_BUTTON_DOWN 0x4000
|
||||
#define CLASSIC_CTRL_BUTTON_RIGHT 0x8000
|
||||
#define CLASSIC_CTRL_BUTTON_ALL 0xFEFF
|
||||
|
||||
/* guitar hero 3 button codes */
|
||||
#define GUITAR_HERO_3_BUTTON_STRUM_UP 0x0001
|
||||
#define GUITAR_HERO_3_BUTTON_YELLOW 0x0008
|
||||
#define GUITAR_HERO_3_BUTTON_GREEN 0x0010
|
||||
#define GUITAR_HERO_3_BUTTON_BLUE 0x0020
|
||||
#define GUITAR_HERO_3_BUTTON_RED 0x0040
|
||||
#define GUITAR_HERO_3_BUTTON_ORANGE 0x0080
|
||||
#define GUITAR_HERO_3_BUTTON_PLUS 0x0400
|
||||
#define GUITAR_HERO_3_BUTTON_MINUS 0x1000
|
||||
#define GUITAR_HERO_3_BUTTON_STRUM_DOWN 0x4000
|
||||
#define GUITAR_HERO_3_BUTTON_ALL 0xFEFF
|
||||
|
||||
/* guitar hero world tour touch bar codes */
|
||||
#define GUITAR_HERO_3_TOUCH_AVAILABLE 0x1000
|
||||
#define GUITAR_HERO_3_TOUCH_GREEN 0x1001
|
||||
#define GUITAR_HERO_3_TOUCH_RED 0x1002
|
||||
#define GUITAR_HERO_3_TOUCH_YELLOW 0x1004
|
||||
#define GUITAR_HERO_3_TOUCH_BLUE 0x1008
|
||||
#define GUITAR_HERO_3_TOUCH_ORANGE 0x1010
|
||||
|
||||
/* wiimote option flags */
|
||||
#define WIIUSE_SMOOTHING 0x01
|
||||
#define WIIUSE_CONTINUOUS 0x02
|
||||
#define WIIUSE_ACCEL_THRESH 0x04
|
||||
#define WIIUSE_IR_THRESH 0x08
|
||||
#define WIIUSE_JS_THRESH 0x10
|
||||
#define WIIUSE_INIT_FLAGS WIIUSE_SMOOTHING
|
||||
|
||||
#define WIIUSE_ORIENT_PRECISION 100.0f
|
||||
|
||||
/* expansion codes */
|
||||
#define EXP_NONE 0
|
||||
#define EXP_NUNCHUK 1
|
||||
#define EXP_CLASSIC 2
|
||||
#define EXP_GUITAR_HERO_3 3
|
||||
#define EXP_WII_BOARD 4
|
||||
#define EXP_MOTION_PLUS 5
|
||||
|
||||
/* IR correction types */
|
||||
typedef enum ir_position_t {
|
||||
WIIUSE_IR_ABOVE,
|
||||
WIIUSE_IR_BELOW
|
||||
} ir_position_t;
|
||||
|
||||
/**
|
||||
* @brief Check if a button is pressed.
|
||||
* @param dev Pointer to a wiimote_t or expansion structure.
|
||||
* @param button The button you are interested in.
|
||||
* @return 1 if the button is pressed, 0 if not.
|
||||
*/
|
||||
#define IS_PRESSED(dev, button) ((dev->btns & button) == button)
|
||||
|
||||
/**
|
||||
* @brief Check if a button is being held.
|
||||
* @param dev Pointer to a wiimote_t or expansion structure.
|
||||
* @param button The button you are interested in.
|
||||
* @return 1 if the button is held, 0 if not.
|
||||
*/
|
||||
#define IS_HELD(dev, button) ((dev->btns_held & button) == button)
|
||||
|
||||
/**
|
||||
* @brief Check if a button is released on this event. \n\n
|
||||
* This does not mean the button is not pressed, it means \n
|
||||
* this button was just now released.
|
||||
* @param dev Pointer to a wiimote_t or expansion structure.
|
||||
* @param button The button you are interested in.
|
||||
* @return 1 if the button is released, 0 if not.
|
||||
*
|
||||
*/
|
||||
#define IS_RELEASED(dev, button) ((dev->btns_released & button) == button)
|
||||
|
||||
/**
|
||||
* @brief Check if a button has just been pressed this event.
|
||||
* @param dev Pointer to a wiimote_t or expansion structure.
|
||||
* @param button The button you are interested in.
|
||||
* @return 1 if the button is pressed, 0 if not.
|
||||
*/
|
||||
#define IS_JUST_PRESSED(dev, button) (IS_PRESSED(dev, button) && !IS_HELD(dev, button))
|
||||
|
||||
/**
|
||||
* @brief Return the IR sensitivity level.
|
||||
* @param wm Pointer to a wiimote_t structure.
|
||||
* @param lvl [out] Pointer to an int that will hold the level setting.
|
||||
* If no level is set 'lvl' will be set to 0.
|
||||
*/
|
||||
#define WIIUSE_GET_IR_SENSITIVITY(dev, lvl) \
|
||||
do { \
|
||||
if ((wm->state & 0x01000) == 0x01000) *lvl = 1; \
|
||||
else if ((wm->state & 0x02000) == 0x02000) *lvl = 2; \
|
||||
else if ((wm->state & 0x04000) == 0x04000) *lvl = 3; \
|
||||
else if ((wm->state & 0x08000) == 0x08000) *lvl = 4; \
|
||||
else if ((wm->state & 0x10000) == 0x10000) *lvl = 5; \
|
||||
else *lvl = 0; \
|
||||
} while (0)
|
||||
|
||||
#define WIIUSE_USING_ACC(wm) ((wm->state & 0x00100) == 0x00100)
|
||||
#define WIIUSE_USING_EXP(wm) ((wm->state & 0x00200) == 0x00200)
|
||||
#define WIIUSE_USING_IR(wm) ((wm->state & 0x00400) == 0x00400)
|
||||
#define WIIUSE_USING_SPEAKER(wm) ((wm->state & 0x00800) == 0x00800)
|
||||
|
||||
#define WIIUSE_IS_LED_SET(wm, num) ((wm->leds & WIIMOTE_LED_##num) == WIIMOTE_LED_##num)
|
||||
|
||||
/*
|
||||
* Largest known payload is 21 bytes.
|
||||
* Add 2 for the prefix and round up to a power of 2.
|
||||
*/
|
||||
#define MAX_PAYLOAD 32
|
||||
|
||||
/*
|
||||
* This is left over from an old hack, but it may actually
|
||||
* be a useful feature to keep so it wasn't removed.
|
||||
*/
|
||||
#ifdef WIN32
|
||||
#define WIIMOTE_DEFAULT_TIMEOUT 100
|
||||
#define WIIMOTE_EXP_TIMEOUT 100
|
||||
#endif
|
||||
|
||||
typedef unsigned char ubyte;
|
||||
typedef char sbyte;
|
||||
typedef unsigned short uword;
|
||||
typedef short sword;
|
||||
typedef unsigned int uint;
|
||||
typedef char sint;
|
||||
|
||||
|
||||
struct wiimote_t;
|
||||
struct vec3b_t;
|
||||
struct orient_t;
|
||||
struct gforce_t;
|
||||
|
||||
#ifdef GEKKO
|
||||
typedef void (*wii_event_cb)(struct wiimote_t*, s32 event);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Callback that handles a read event.
|
||||
*
|
||||
* @param wm Pointer to a wiimote_t structure.
|
||||
* @param data Pointer to the filled data block.
|
||||
* @param len Length in bytes of the data block.
|
||||
*
|
||||
* @see wiiuse_init()
|
||||
*
|
||||
* A registered function of this type is called automatically by the wiiuse
|
||||
* library when the wiimote has returned the full data requested by a previous
|
||||
* call to wiiuse_read_data().
|
||||
*/
|
||||
typedef void (*wiiuse_data_cb)(struct wiimote_t* wm, ubyte* data, unsigned short len);
|
||||
|
||||
typedef enum data_req_s
|
||||
{
|
||||
REQ_READY = 0,
|
||||
REQ_SENT,
|
||||
REQ_DONE
|
||||
} data_req_s;
|
||||
|
||||
/**
|
||||
* @struct data_req_t
|
||||
* @brief Data read request structure.
|
||||
*/
|
||||
struct data_req_t {
|
||||
lwp_node node;
|
||||
ubyte data[48]; /**< buffer where read data is written */
|
||||
unsigned int len;
|
||||
data_req_s state; /**< set to 1 if not using callback and needs to be cleaned up */
|
||||
wiiuse_data_cb cb; /**< read data callback */
|
||||
struct data_req_t *next;
|
||||
};
|
||||
|
||||
typedef void (*cmd_blk_cb)(struct wiimote_t *wm,ubyte *data,uword len);
|
||||
|
||||
typedef enum cmd_blk_s
|
||||
{
|
||||
CMD_READY = 0,
|
||||
CMD_SENT,
|
||||
CMD_DONE
|
||||
} cmd_blk_s;
|
||||
|
||||
struct cmd_blk_t
|
||||
{
|
||||
lwp_node node;
|
||||
|
||||
ubyte data[48];
|
||||
uint len;
|
||||
|
||||
cmd_blk_s state;
|
||||
cmd_blk_cb cb;
|
||||
|
||||
struct cmd_blk_t *next;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @struct vec2b_t
|
||||
* @brief Unsigned x,y byte vector.
|
||||
*/
|
||||
typedef struct vec2b_t {
|
||||
ubyte x, y;
|
||||
} vec2b_t;
|
||||
|
||||
|
||||
/**
|
||||
* @struct vec3b_t
|
||||
* @brief Unsigned x,y,z byte vector.
|
||||
*/
|
||||
typedef struct vec3b_t {
|
||||
ubyte x, y, z;
|
||||
} vec3b_t;
|
||||
|
||||
/**
|
||||
* @struct vec3b_t
|
||||
* @brief Unsigned x,y,z byte vector.
|
||||
*/
|
||||
typedef struct vec3w_t {
|
||||
uword x, y, z;
|
||||
} vec3w_t;
|
||||
|
||||
|
||||
/**
|
||||
* @struct vec3f_t
|
||||
* @brief Signed x,y,z float struct.
|
||||
*/
|
||||
typedef struct vec3f_t {
|
||||
float x, y, z;
|
||||
} vec3f_t;
|
||||
|
||||
|
||||
/**
|
||||
* @struct orient_t
|
||||
* @brief Orientation struct.
|
||||
*
|
||||
* Yaw, pitch, and roll range from -180 to 180 degrees.
|
||||
*/
|
||||
typedef struct orient_t {
|
||||
float roll; /**< roll, this may be smoothed if enabled */
|
||||
float pitch; /**< pitch, this may be smoothed if enabled */
|
||||
float yaw;
|
||||
|
||||
float a_roll; /**< absolute roll, unsmoothed */
|
||||
float a_pitch; /**< absolute pitch, unsmoothed */
|
||||
} orient_t;
|
||||
|
||||
|
||||
/**
|
||||
* @struct gforce_t
|
||||
* @brief Gravity force struct.
|
||||
*/
|
||||
typedef struct gforce_t {
|
||||
float x, y, z;
|
||||
} gforce_t;
|
||||
|
||||
|
||||
/**
|
||||
* @struct accel_t
|
||||
* @brief Accelerometer struct. For any device with an accelerometer.
|
||||
*/
|
||||
typedef struct accel_t {
|
||||
struct vec3w_t cal_zero; /**< zero calibration */
|
||||
struct vec3w_t cal_g; /**< 1g difference around 0cal */
|
||||
|
||||
float st_roll; /**< last smoothed roll value */
|
||||
float st_pitch; /**< last smoothed roll pitch */
|
||||
float st_alpha; /**< alpha value for smoothing [0-1] */
|
||||
} accel_t;
|
||||
|
||||
|
||||
/**
|
||||
* @struct ir_dot_t
|
||||
* @brief A single IR source.
|
||||
*/
|
||||
typedef struct ir_dot_t {
|
||||
ubyte visible; /**< if the IR source is visible */
|
||||
|
||||
short rx; /**< raw X coordinate (0-1023) */
|
||||
short ry; /**< raw Y coordinate (0-767) */
|
||||
|
||||
ubyte size; /**< size of the IR dot (0-15) */
|
||||
} ir_dot_t;
|
||||
|
||||
|
||||
typedef struct fdot_t {
|
||||
float x,y;
|
||||
} fdot_t;
|
||||
|
||||
typedef struct sb_t {
|
||||
fdot_t dots[2];
|
||||
fdot_t acc_dots[2];
|
||||
fdot_t rot_dots[2];
|
||||
float angle;
|
||||
float off_angle;
|
||||
float score;
|
||||
} sb_t;
|
||||
|
||||
/**
|
||||
* @enum aspect_t
|
||||
* @brief Screen aspect ratio.
|
||||
*/
|
||||
typedef enum aspect_t {
|
||||
WIIUSE_ASPECT_4_3,
|
||||
WIIUSE_ASPECT_16_9
|
||||
} aspect_t;
|
||||
|
||||
|
||||
/**
|
||||
* @struct ir_t
|
||||
* @brief IR struct. Hold all data related to the IR tracking.
|
||||
*/
|
||||
typedef struct ir_t {
|
||||
struct ir_dot_t dot[4]; /**< IR dots */
|
||||
ubyte num_dots; /**< number of dots at this time */
|
||||
|
||||
int state; /**< keeps track of the IR state */
|
||||
|
||||
int raw_valid; /**< is the raw position valid? */
|
||||
sb_t sensorbar; /**< sensor bar, detected or guessed */
|
||||
float ax; /**< raw X coordinate */
|
||||
float ay; /**< raw Y coordinate */
|
||||
float distance; /**< pixel width of the sensor bar */
|
||||
float z; /**< calculated distance in meters */
|
||||
float angle; /**< angle of the wiimote to the sensor bar*/
|
||||
|
||||
int smooth_valid; /**< is the smoothed position valid? */
|
||||
float sx; /**< smoothed X coordinate */
|
||||
float sy; /**< smoothed Y coordinate */
|
||||
float error_cnt; /**< error count, for smoothing algorithm*/
|
||||
float glitch_cnt; /**< glitch count, same */
|
||||
|
||||
int valid; /**< is the bounded position valid? */
|
||||
float x; /**< bounded X coordinate */
|
||||
float y; /**< bounded Y coordinate */
|
||||
enum aspect_t aspect; /**< aspect ratio of the screen */
|
||||
enum ir_position_t pos; /**< IR sensor bar position */
|
||||
unsigned int vres[2]; /**< IR virtual screen resolution */
|
||||
int offset[2]; /**< IR XY correction offset */
|
||||
|
||||
} ir_t;
|
||||
|
||||
|
||||
/**
|
||||
* @struct joystick_t
|
||||
* @brief Joystick calibration structure.
|
||||
*
|
||||
* The angle \a ang is relative to the positive y-axis into quadrant I
|
||||
* and ranges from 0 to 360 degrees. So if the joystick is held straight
|
||||
* upwards then angle is 0 degrees. If it is held to the right it is 90,
|
||||
* down is 180, and left is 270.
|
||||
*
|
||||
* The magnitude \a mag is the distance from the center to where the
|
||||
* joystick is being held. The magnitude ranges from 0 to 1.
|
||||
* If the joystick is only slightly tilted from the center the magnitude
|
||||
* will be low, but if it is closer to the outter edge the value will
|
||||
* be higher.
|
||||
*/
|
||||
typedef struct joystick_t {
|
||||
struct vec2b_t max; /**< maximum joystick values */
|
||||
struct vec2b_t min; /**< minimum joystick values */
|
||||
struct vec2b_t center; /**< center joystick values */
|
||||
struct vec2b_t pos; /**< raw position values */
|
||||
|
||||
float ang; /**< angle the joystick is being held */
|
||||
float mag; /**< magnitude of the joystick (range 0-1) */
|
||||
} joystick_t;
|
||||
|
||||
|
||||
/**
|
||||
* @struct nunchuk_t
|
||||
* @brief Nunchuk expansion device.
|
||||
*/
|
||||
typedef struct nunchuk_t {
|
||||
struct accel_t accel_calib; /**< nunchuk accelerometer calibration */
|
||||
struct joystick_t js; /**< joystick calibration */
|
||||
|
||||
int* flags; /**< options flag (points to wiimote_t.flags) */
|
||||
|
||||
ubyte btns; /**< what buttons have just been pressed */
|
||||
ubyte btns_last; /**< what buttons have just been pressed */
|
||||
ubyte btns_held; /**< what buttons are being held down */
|
||||
ubyte btns_released; /**< what buttons were just released this */
|
||||
|
||||
struct vec3w_t accel; /**< current raw acceleration data */
|
||||
struct orient_t orient; /**< current orientation on each axis */
|
||||
struct gforce_t gforce; /**< current gravity forces on each axis */
|
||||
} nunchuk_t;
|
||||
|
||||
|
||||
/**
|
||||
* @struct classic_ctrl_t
|
||||
* @brief Classic controller expansion device.
|
||||
*/
|
||||
typedef struct classic_ctrl_t {
|
||||
short btns; /**< what buttons have just been pressed */
|
||||
short btns_last; /**< what buttons have just been pressed */
|
||||
short btns_held; /**< what buttons are being held down */
|
||||
short btns_released; /**< what buttons were just released this */
|
||||
|
||||
ubyte rs_raw;
|
||||
ubyte ls_raw;
|
||||
|
||||
float r_shoulder; /**< right shoulder button (range 0-1) */
|
||||
float l_shoulder; /**< left shoulder button (range 0-1) */
|
||||
|
||||
struct joystick_t ljs; /**< left joystick calibration */
|
||||
struct joystick_t rjs; /**< right joystick calibration */
|
||||
ubyte type; /**< original, pro, wiiu pro */
|
||||
} classic_ctrl_t;
|
||||
|
||||
|
||||
/**
|
||||
* @struct guitar_hero_3_t
|
||||
* @brief Guitar Hero 3 expansion device.
|
||||
*/
|
||||
typedef struct guitar_hero_3_t {
|
||||
short btns; /**< what buttons have just been pressed */
|
||||
short btns_last; /**< what buttons have just been pressed */
|
||||
short btns_held; /**< what buttons are being held down */
|
||||
short btns_released; /**< what buttons were just released this */
|
||||
|
||||
ubyte wb_raw;
|
||||
float whammy_bar; /**< whammy bar (range 0-1) */
|
||||
|
||||
ubyte tb_raw;
|
||||
int touch_bar; /**< touch bar */
|
||||
|
||||
struct joystick_t js; /**< joystick calibration */
|
||||
} guitar_hero_3_t;
|
||||
|
||||
/**
|
||||
* @struct wii_board_t
|
||||
* @brief Wii Balance Board expansion device.
|
||||
*/
|
||||
typedef struct wii_board_t {
|
||||
float tl; /* Interpolated */
|
||||
float tr;
|
||||
float bl;
|
||||
float br; /* End interp */
|
||||
short rtl; /* RAW */
|
||||
short rtr;
|
||||
short rbl;
|
||||
short rbr; /* /RAW */
|
||||
short ctl[3]; /* Calibration */
|
||||
short ctr[3];
|
||||
short cbl[3];
|
||||
short cbr[3]; /* /Calibration */
|
||||
float x;
|
||||
float y;
|
||||
} wii_board_t;
|
||||
|
||||
typedef struct motion_plus_t
|
||||
{
|
||||
short rx, ry, rz;
|
||||
ubyte status;
|
||||
ubyte ext;
|
||||
} motion_plus_t;
|
||||
|
||||
/**
|
||||
* @struct expansion_t
|
||||
* @brief Generic expansion device plugged into wiimote.
|
||||
*/
|
||||
typedef struct expansion_t {
|
||||
int type; /**< type of expansion attached */
|
||||
|
||||
union {
|
||||
struct nunchuk_t nunchuk;
|
||||
struct classic_ctrl_t classic;
|
||||
struct guitar_hero_3_t gh3;
|
||||
struct wii_board_t wb;
|
||||
struct motion_plus_t mp;
|
||||
};
|
||||
} expansion_t;
|
||||
|
||||
|
||||
/**
|
||||
* @enum win32_bt_stack_t
|
||||
* @brief Available bluetooth stacks for Windows.
|
||||
*/
|
||||
typedef enum win_bt_stack_t {
|
||||
WIIUSE_STACK_UNKNOWN,
|
||||
WIIUSE_STACK_MS,
|
||||
WIIUSE_STACK_BLUESOLEIL
|
||||
} win_bt_stack_t;
|
||||
|
||||
|
||||
/**
|
||||
* @struct wiimote_state_t
|
||||
* @brief Significant data from the previous event.
|
||||
*/
|
||||
typedef struct wiimote_state_t {
|
||||
unsigned short btns;
|
||||
|
||||
struct ir_t ir;
|
||||
struct vec3w_t accel;
|
||||
struct expansion_t exp;
|
||||
} wiimote_state_t;
|
||||
|
||||
|
||||
/**
|
||||
* @enum WIIUSE_EVENT_TYPE
|
||||
* @brief Events that wiiuse can generate from a poll.
|
||||
*/
|
||||
typedef enum WIIUSE_EVENT_TYPE {
|
||||
WIIUSE_NONE = 0,
|
||||
WIIUSE_EVENT,
|
||||
WIIUSE_STATUS,
|
||||
WIIUSE_CONNECT,
|
||||
WIIUSE_DISCONNECT,
|
||||
WIIUSE_UNEXPECTED_DISCONNECT,
|
||||
WIIUSE_READ_DATA,
|
||||
WIIUSE_ACK,
|
||||
WIIUSE_NUNCHUK_INSERTED,
|
||||
WIIUSE_NUNCHUK_REMOVED,
|
||||
WIIUSE_CLASSIC_CTRL_INSERTED,
|
||||
WIIUSE_CLASSIC_CTRL_REMOVED,
|
||||
WIIUSE_GUITAR_HERO_3_CTRL_INSERTED,
|
||||
WIIUSE_GUITAR_HERO_3_CTRL_REMOVED,
|
||||
WIIUSE_WII_BOARD_INSERTED,
|
||||
WIIUSE_WII_BOARD_REMOVED,
|
||||
WIIUSE_MOTION_PLUS_ACTIVATED,
|
||||
WIIUSE_MOTION_PLUS_REMOVED
|
||||
} WIIUSE_EVENT_TYPE;
|
||||
|
||||
/**
|
||||
* @struct wiimote_t
|
||||
* @brief Wiimote structure.
|
||||
*/
|
||||
typedef struct wiimote_t {
|
||||
WCONST int unid; /**< user specified id */
|
||||
|
||||
#if defined(_WIN32)
|
||||
WCONST HANDLE dev_handle; /**< HID handle */
|
||||
WCONST OVERLAPPED hid_overlap; /**< overlap handle */
|
||||
WCONST enum win_bt_stack_t stack; /**< type of bluetooth stack to use */
|
||||
WCONST int timeout; /**< read timeout */
|
||||
WCONST ubyte normal_timeout; /**< normal timeout */
|
||||
WCONST ubyte exp_timeout; /**< timeout for expansion handshake */
|
||||
#elif defined(GEKKO)
|
||||
WCONST lwp_queue cmdq;
|
||||
WCONST struct bd_addr bdaddr; /**< bt address */
|
||||
WCONST char bdaddr_str[18]; /**< readable bt address */
|
||||
WCONST struct bte_pcb *sock; /**< output socket */
|
||||
WCONST wii_event_cb event_cb; /**< event callback */
|
||||
#elif defined(unix)
|
||||
WCONST bdaddr_t bdaddr; /**< bt address */
|
||||
WCONST char bdaddr_str[18]; /**< readable bt address */
|
||||
WCONST int out_sock; /**< output socket */
|
||||
WCONST int in_sock; /**< input socket */
|
||||
#endif
|
||||
|
||||
WCONST int state; /**< various state flags */
|
||||
WCONST ubyte leds; /**< currently lit leds */
|
||||
#ifdef GEKKO
|
||||
WCONST ubyte battery_level; /**< battery level */
|
||||
#else
|
||||
WCONST float battery_level; /**< battery level */
|
||||
#endif
|
||||
|
||||
WCONST int flags; /**< options flag */
|
||||
|
||||
WCONST ubyte handshake_state; /**< the state of the connection handshake */
|
||||
WCONST ubyte expansion_state; /**< the state of the expansion handshake */
|
||||
|
||||
WCONST struct data_req_t* data_req; /**< list of data read requests */
|
||||
|
||||
WCONST struct cmd_blk_t *cmd_head;
|
||||
WCONST struct cmd_blk_t *cmd_tail;
|
||||
|
||||
WCONST struct accel_t accel_calib; /**< wiimote accelerometer calibration */
|
||||
WCONST struct expansion_t exp; /**< wiimote expansion device */
|
||||
|
||||
WCONST struct vec3w_t accel; /**< current raw acceleration data */
|
||||
WCONST struct orient_t orient; /**< current orientation on each axis */
|
||||
WCONST struct gforce_t gforce; /**< current gravity forces on each axis */
|
||||
|
||||
WCONST struct ir_t ir; /**< IR data */
|
||||
|
||||
WCONST unsigned short btns; /**< what buttons are down */
|
||||
WCONST unsigned short btns_last; /**< what buttons were down before */
|
||||
WCONST unsigned short btns_held; /**< what buttons are and were held down */
|
||||
WCONST unsigned short btns_released; /**< what buttons were just released */
|
||||
|
||||
WCONST struct wiimote_state_t lstate; /**< last saved state */
|
||||
|
||||
WCONST WIIUSE_EVENT_TYPE event; /**< type of event that occured */
|
||||
WCONST ubyte event_buf[MAX_PAYLOAD]; /**< event buffer */
|
||||
|
||||
WCONST ubyte motion_plus_id[6];
|
||||
} wiimote;
|
||||
|
||||
#if defined(GEKKO)
|
||||
/**
|
||||
* @struct wiimote_listen_t
|
||||
* @brief Wiimote listen structure.
|
||||
*/
|
||||
typedef struct wiimote_listen_t {
|
||||
WCONST struct bd_addr bdaddr;
|
||||
WCONST struct bte_pcb *sock;
|
||||
WCONST struct wiimote_t *(*assign_cb)(struct bd_addr *bdaddr);
|
||||
WCONST struct wiimote_t *wm;
|
||||
} wiimote_listen;
|
||||
#endif
|
||||
|
||||
/*****************************************
|
||||
*
|
||||
* Include API specific stuff
|
||||
*
|
||||
*****************************************/
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIIUSE_EXPORT_DECL __declspec(dllexport)
|
||||
#define WIIUSE_IMPORT_DECL __declspec(dllimport)
|
||||
#else
|
||||
#define WIIUSE_EXPORT_DECL
|
||||
#define WIIUSE_IMPORT_DECL
|
||||
#endif
|
||||
|
||||
#ifdef WIIUSE_COMPILE_LIB
|
||||
#define WIIUSE_EXPORT WIIUSE_EXPORT_DECL
|
||||
#else
|
||||
#define WIIUSE_EXPORT WIIUSE_IMPORT_DECL
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* wiiuse.c */
|
||||
WIIUSE_EXPORT extern const char* wiiuse_version();
|
||||
|
||||
#ifndef GEKKO
|
||||
WIIUSE_EXPORT extern struct wiimote_t** wiiuse_init(int wiimotes);
|
||||
#else
|
||||
WIIUSE_EXPORT extern int wiiuse_register(struct wiimote_listen_t *wml, struct bd_addr *bdaddr, struct wiimote_t *(*assign_cb)(struct bd_addr *bdaddr));
|
||||
WIIUSE_EXPORT extern struct wiimote_t** wiiuse_init(int wiimotes, wii_event_cb event_cb);
|
||||
WIIUSE_EXPORT extern void wiiuse_sensorbar_enable(int enable);
|
||||
#endif
|
||||
|
||||
WIIUSE_EXPORT extern void wiiuse_disconnected(struct wiimote_t* wm);
|
||||
WIIUSE_EXPORT extern void wiiuse_cleanup(struct wiimote_t** wm, int wiimotes);
|
||||
WIIUSE_EXPORT extern void wiiuse_rumble(struct wiimote_t* wm, int status);
|
||||
WIIUSE_EXPORT extern void wiiuse_toggle_rumble(struct wiimote_t* wm);
|
||||
WIIUSE_EXPORT extern void wiiuse_set_leds(struct wiimote_t* wm, int leds,cmd_blk_cb cb);
|
||||
WIIUSE_EXPORT extern void wiiuse_motion_sensing(struct wiimote_t* wm, int status);
|
||||
WIIUSE_EXPORT extern int wiiuse_read_data(struct wiimote_t* wm, ubyte* buffer, unsigned int offset, unsigned short len, cmd_blk_cb cb);
|
||||
WIIUSE_EXPORT extern int wiiuse_write_data(struct wiimote_t *wm,unsigned int addr,ubyte *data,ubyte len,cmd_blk_cb cb);
|
||||
WIIUSE_EXPORT extern void wiiuse_status(struct wiimote_t *wm,cmd_blk_cb cb);
|
||||
WIIUSE_EXPORT extern struct wiimote_t* wiiuse_get_by_id(struct wiimote_t** wm, int wiimotes, int unid);
|
||||
WIIUSE_EXPORT extern int wiiuse_set_flags(struct wiimote_t* wm, int enable, int disable);
|
||||
WIIUSE_EXPORT extern float wiiuse_set_smooth_alpha(struct wiimote_t* wm, float alpha);
|
||||
WIIUSE_EXPORT extern void wiiuse_set_bluetooth_stack(struct wiimote_t** wm, int wiimotes, enum win_bt_stack_t type);
|
||||
WIIUSE_EXPORT extern void wiiuse_resync(struct wiimote_t* wm);
|
||||
WIIUSE_EXPORT extern void wiiuse_set_timeout(struct wiimote_t** wm, int wiimotes, ubyte normal_timeout, ubyte exp_timeout);
|
||||
WIIUSE_EXPORT extern int wiiuse_write_streamdata(struct wiimote_t *wm,ubyte *data,ubyte len,cmd_blk_cb cb);
|
||||
|
||||
/* connect.c */
|
||||
WIIUSE_EXPORT extern int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout);
|
||||
WIIUSE_EXPORT extern int wiiuse_connect(struct wiimote_t** wm, int wiimotes);
|
||||
WIIUSE_EXPORT extern void wiiuse_disconnect(struct wiimote_t* wm);
|
||||
|
||||
/* events.c */
|
||||
WIIUSE_EXPORT extern int wiiuse_poll(struct wiimote_t** wm, int wiimotes);
|
||||
|
||||
/* ir.c */
|
||||
WIIUSE_EXPORT extern void wiiuse_set_ir_mode(struct wiimote_t *wm);
|
||||
WIIUSE_EXPORT extern void wiiuse_set_ir(struct wiimote_t* wm, int status);
|
||||
WIIUSE_EXPORT extern void wiiuse_set_ir_vres(struct wiimote_t* wm, unsigned int x, unsigned int y);
|
||||
WIIUSE_EXPORT extern void wiiuse_set_ir_position(struct wiimote_t* wm, enum ir_position_t pos);
|
||||
WIIUSE_EXPORT extern void wiiuse_set_aspect_ratio(struct wiimote_t* wm, enum aspect_t aspect);
|
||||
WIIUSE_EXPORT extern void wiiuse_set_ir_sensitivity(struct wiimote_t* wm, int level);
|
||||
|
||||
/* motion_plus.c */
|
||||
WIIUSE_EXPORT extern void wiiuse_set_motion_plus(struct wiimote_t *wm, int status);
|
||||
|
||||
/* speaker.c */
|
||||
WIIUSE_EXPORT extern void wiiuse_set_speaker(struct wiimote_t *wm, int status);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
208
wii/libogc/include/wiiuse/wpad.h
Normal file
208
wii/libogc/include/wiiuse/wpad.h
Normal file
@ -0,0 +1,208 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
wpad.h -- Wiimote Application Programmers Interface
|
||||
|
||||
Copyright (C) 2008
|
||||
Michael Wiedenbauer (shagkur)
|
||||
Dave Murphy (WinterMute)
|
||||
Hector Martin (marcan)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
#ifndef __WPAD_H__
|
||||
#define __WPAD_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
#include <wiiuse/wiiuse.h>
|
||||
|
||||
#define WPAD_MAX_IR_DOTS 4
|
||||
|
||||
enum {
|
||||
WPAD_CHAN_ALL = -1,
|
||||
WPAD_CHAN_0,
|
||||
WPAD_CHAN_1,
|
||||
WPAD_CHAN_2,
|
||||
WPAD_CHAN_3,
|
||||
WPAD_BALANCE_BOARD,
|
||||
WPAD_MAX_WIIMOTES,
|
||||
};
|
||||
|
||||
#define WPAD_BUTTON_2 0x0001
|
||||
#define WPAD_BUTTON_1 0x0002
|
||||
#define WPAD_BUTTON_B 0x0004
|
||||
#define WPAD_BUTTON_A 0x0008
|
||||
#define WPAD_BUTTON_MINUS 0x0010
|
||||
#define WPAD_BUTTON_HOME 0x0080
|
||||
#define WPAD_BUTTON_LEFT 0x0100
|
||||
#define WPAD_BUTTON_RIGHT 0x0200
|
||||
#define WPAD_BUTTON_DOWN 0x0400
|
||||
#define WPAD_BUTTON_UP 0x0800
|
||||
#define WPAD_BUTTON_PLUS 0x1000
|
||||
|
||||
#define WPAD_NUNCHUK_BUTTON_Z (0x0001<<16)
|
||||
#define WPAD_NUNCHUK_BUTTON_C (0x0002<<16)
|
||||
|
||||
#define WPAD_CLASSIC_BUTTON_UP (0x0001<<16)
|
||||
#define WPAD_CLASSIC_BUTTON_LEFT (0x0002<<16)
|
||||
#define WPAD_CLASSIC_BUTTON_ZR (0x0004<<16)
|
||||
#define WPAD_CLASSIC_BUTTON_X (0x0008<<16)
|
||||
#define WPAD_CLASSIC_BUTTON_A (0x0010<<16)
|
||||
#define WPAD_CLASSIC_BUTTON_Y (0x0020<<16)
|
||||
#define WPAD_CLASSIC_BUTTON_B (0x0040<<16)
|
||||
#define WPAD_CLASSIC_BUTTON_ZL (0x0080<<16)
|
||||
#define WPAD_CLASSIC_BUTTON_FULL_R (0x0200<<16)
|
||||
#define WPAD_CLASSIC_BUTTON_PLUS (0x0400<<16)
|
||||
#define WPAD_CLASSIC_BUTTON_HOME (0x0800<<16)
|
||||
#define WPAD_CLASSIC_BUTTON_MINUS (0x1000<<16)
|
||||
#define WPAD_CLASSIC_BUTTON_FULL_L (0x2000<<16)
|
||||
#define WPAD_CLASSIC_BUTTON_DOWN (0x4000<<16)
|
||||
#define WPAD_CLASSIC_BUTTON_RIGHT (0x8000<<16)
|
||||
|
||||
#define WPAD_GUITAR_HERO_3_BUTTON_STRUM_UP (0x0001<<16)
|
||||
#define WPAD_GUITAR_HERO_3_BUTTON_YELLOW (0x0008<<16)
|
||||
#define WPAD_GUITAR_HERO_3_BUTTON_GREEN (0x0010<<16)
|
||||
#define WPAD_GUITAR_HERO_3_BUTTON_BLUE (0x0020<<16)
|
||||
#define WPAD_GUITAR_HERO_3_BUTTON_RED (0x0040<<16)
|
||||
#define WPAD_GUITAR_HERO_3_BUTTON_ORANGE (0x0080<<16)
|
||||
#define WPAD_GUITAR_HERO_3_BUTTON_PLUS (0x0400<<16)
|
||||
#define WPAD_GUITAR_HERO_3_BUTTON_MINUS (0x1000<<16)
|
||||
#define WPAD_GUITAR_HERO_3_BUTTON_STRUM_DOWN (0x4000<<16)
|
||||
|
||||
enum {
|
||||
WPAD_EXP_NONE = 0,
|
||||
WPAD_EXP_NUNCHUK,
|
||||
WPAD_EXP_CLASSIC,
|
||||
WPAD_EXP_GUITARHERO3,
|
||||
WPAD_EXP_WIIBOARD,
|
||||
WPAD_EXP_UNKNOWN = 255
|
||||
};
|
||||
|
||||
enum {
|
||||
WPAD_FMT_BTNS = 0,
|
||||
WPAD_FMT_BTNS_ACC,
|
||||
WPAD_FMT_BTNS_ACC_IR
|
||||
};
|
||||
|
||||
enum {
|
||||
WPAD_STATE_DISABLED,
|
||||
WPAD_STATE_ENABLING,
|
||||
WPAD_STATE_ENABLED
|
||||
};
|
||||
|
||||
#define WPAD_ERR_NONE 0
|
||||
#define WPAD_ERR_NO_CONTROLLER -1
|
||||
#define WPAD_ERR_NOT_READY -2
|
||||
#define WPAD_ERR_TRANSFER -3
|
||||
#define WPAD_ERR_NONEREGISTERED -4
|
||||
#define WPAD_ERR_UNKNOWN -5
|
||||
#define WPAD_ERR_BAD_CHANNEL -6
|
||||
#define WPAD_ERR_QUEUE_EMPTY -7
|
||||
#define WPAD_ERR_BADVALUE -8
|
||||
#define WPAD_ERR_BADCONF -9
|
||||
|
||||
#define WPAD_DATA_BUTTONS 0x01
|
||||
#define WPAD_DATA_ACCEL 0x02
|
||||
#define WPAD_DATA_EXPANSION 0x04
|
||||
#define WPAD_DATA_IR 0x08
|
||||
|
||||
#define WPAD_ENC_FIRST 0x00
|
||||
#define WPAD_ENC_CONT 0x01
|
||||
|
||||
#define WPAD_THRESH_IGNORE -1
|
||||
#define WPAD_THRESH_ANY 0
|
||||
#define WPAD_THRESH_DEFAULT_BUTTONS 0
|
||||
#define WPAD_THRESH_DEFAULT_IR WPAD_THRESH_IGNORE
|
||||
#define WPAD_THRESH_DEFAULT_ACCEL 20
|
||||
#define WPAD_THRESH_DEFAULT_JOYSTICK 2
|
||||
#define WPAD_THRESH_DEFAULT_BALANCEBOARD 60
|
||||
#define WPAD_THRESH_DEFAULT_MOTION_PLUS 100
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct _wpad_data
|
||||
{
|
||||
s16 err;
|
||||
|
||||
u32 data_present;
|
||||
u8 battery_level;
|
||||
|
||||
u32 btns_h;
|
||||
u32 btns_l;
|
||||
u32 btns_d;
|
||||
u32 btns_u;
|
||||
|
||||
struct ir_t ir;
|
||||
struct vec3w_t accel;
|
||||
struct orient_t orient;
|
||||
struct gforce_t gforce;
|
||||
struct expansion_t exp;
|
||||
} WPADData;
|
||||
|
||||
typedef struct _wpad_encstatus
|
||||
{
|
||||
u8 data[32];
|
||||
}WPADEncStatus;
|
||||
|
||||
typedef void (*WPADDataCallback)(s32 chan, const WPADData *data);
|
||||
typedef void (*WPADShutdownCallback)(s32 chan);
|
||||
|
||||
s32 WPAD_Init();
|
||||
s32 WPAD_ControlSpeaker(s32 chan,s32 enable);
|
||||
s32 WPAD_ReadEvent(s32 chan, WPADData *data);
|
||||
s32 WPAD_DroppedEvents(s32 chan);
|
||||
s32 WPAD_Flush(s32 chan);
|
||||
s32 WPAD_ReadPending(s32 chan, WPADDataCallback datacb);
|
||||
s32 WPAD_SetDataFormat(s32 chan, s32 fmt);
|
||||
s32 WPAD_SetMotionPlus(s32 chan, u8 enable);
|
||||
s32 WPAD_SetVRes(s32 chan,u32 xres,u32 yres);
|
||||
s32 WPAD_GetStatus();
|
||||
s32 WPAD_Probe(s32 chan,u32 *type);
|
||||
s32 WPAD_SetEventBufs(s32 chan, WPADData *bufs, u32 cnt);
|
||||
s32 WPAD_Disconnect(s32 chan);
|
||||
s32 WPAD_IsSpeakerEnabled(s32 chan);
|
||||
s32 WPAD_SendStreamData(s32 chan,void *buf,u32 len);
|
||||
void WPAD_Shutdown();
|
||||
void WPAD_SetIdleTimeout(u32 seconds);
|
||||
void WPAD_SetPowerButtonCallback(WPADShutdownCallback cb);
|
||||
void WPAD_SetBatteryDeadCallback(WPADShutdownCallback cb);
|
||||
s32 WPAD_ScanPads();
|
||||
s32 WPAD_Rumble(s32 chan, int status);
|
||||
s32 WPAD_SetIdleThresholds(s32 chan, s32 btns, s32 ir, s32 accel, s32 js, s32 wb, s32 mp);
|
||||
void WPAD_EncodeData(WPADEncStatus *info,u32 flag,const s16 *pcmSamples,s32 numSamples,u8 *encData);
|
||||
WPADData *WPAD_Data(int chan);
|
||||
u8 WPAD_BatteryLevel(int chan);
|
||||
u32 WPAD_ButtonsUp(int chan);
|
||||
u32 WPAD_ButtonsDown(int chan);
|
||||
u32 WPAD_ButtonsHeld(int chan);
|
||||
void WPAD_IR(int chan, struct ir_t *ir);
|
||||
void WPAD_Orientation(int chan, struct orient_t *orient);
|
||||
void WPAD_GForce(int chan, struct gforce_t *gforce);
|
||||
void WPAD_Accel(int chan, struct vec3w_t *accel);
|
||||
void WPAD_Expansion(int chan, struct expansion_t *exp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
653
wii/libogc/libdb/debug.c
Normal file
653
wii/libogc/libdb/debug.c
Normal file
@ -0,0 +1,653 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include "asm.h"
|
||||
#include "processor.h"
|
||||
#include "spinlock.h"
|
||||
#include "lwp.h"
|
||||
#include "lwp_threads.h"
|
||||
#include "sys_state.h"
|
||||
#include "context.h"
|
||||
#include "cache.h"
|
||||
#include "video.h"
|
||||
#include "ogcsys.h"
|
||||
|
||||
#include "lwp_config.h"
|
||||
|
||||
#include "tcpip.h"
|
||||
#include "geckousb.h"
|
||||
#include "debug_if.h"
|
||||
#include "debug_supp.h"
|
||||
|
||||
#define GEKKO_MAX_BP 256
|
||||
|
||||
#define SP_REGNUM 1 //register no. for stackpointer
|
||||
#define PC_REGNUM 64 //register no. for programcounter (srr0)
|
||||
|
||||
#define BUFMAX 2048 //we take the same as in ppc-stub.c
|
||||
|
||||
#define BPCODE 0x7d821008
|
||||
|
||||
#define highhex(x) hexchars [((x)>>4)&0xf]
|
||||
#define lowhex(x) hexchars [(x)&0xf]
|
||||
|
||||
#if UIP_LOGGING == 1
|
||||
#include <stdio.h>
|
||||
#define UIP_LOG(m) uip_log(__FILE__,__LINE__,m)
|
||||
#else
|
||||
#define UIP_LOG(m)
|
||||
#endif /* UIP_LOGGING == 1 */
|
||||
|
||||
static s32 dbg_active = 0;
|
||||
static s32 dbg_instep = 0;
|
||||
static s32 dbg_initialized = 0;
|
||||
|
||||
static struct dbginterface *current_device = NULL;
|
||||
|
||||
static char remcomInBuffer[BUFMAX];
|
||||
static char remcomOutBuffer[BUFMAX];
|
||||
|
||||
const char hexchars[]="0123456789abcdef";
|
||||
|
||||
static struct hard_trap_info {
|
||||
u32 tt;
|
||||
u8 signo;
|
||||
} hard_trap_info[] = {
|
||||
{EX_MACH_CHECK,SIGSEGV},/* Machine Check */
|
||||
{EX_DSI,SIGSEGV}, /* Adress Error(store) DSI */
|
||||
{EX_ISI,SIGBUS}, /* Instruction Bus Error ISI */
|
||||
{EX_INT,SIGINT}, /* Interrupt */
|
||||
{EX_ALIGN,SIGBUS}, /* Alignment */
|
||||
{EX_PRG,SIGTRAP}, /* Breakpoint Trap */
|
||||
{EX_FP,SIGFPE}, /* FPU unavail */
|
||||
{EX_DEC,SIGALRM}, /* Decrementer */
|
||||
{EX_SYS_CALL,SIGSYS}, /* System Call */
|
||||
{EX_TRACE,SIGTRAP}, /* Singel-Step/Watch */
|
||||
{0xB,SIGILL}, /* Reserved */
|
||||
{EX_IABR,SIGTRAP}, /* Instruction Address Breakpoint (GEKKO) */
|
||||
{0xD,SIGFPE}, /* FP assist */
|
||||
{0,0} /* MUST be the last */
|
||||
};
|
||||
|
||||
static struct bp_entry {
|
||||
u32 *address;
|
||||
u32 instr;
|
||||
struct bp_entry *next;
|
||||
} bp_entries[GEKKO_MAX_BP];
|
||||
|
||||
static struct bp_entry *p_bpentries = NULL;
|
||||
static frame_context current_thread_registers;
|
||||
|
||||
void __breakinst();
|
||||
void c_debug_handler(frame_context *ctx);
|
||||
|
||||
extern void dbg_exceptionhandler();
|
||||
extern void __exception_sethandler(u32 nExcept, void (*pHndl)(frame_context*));
|
||||
|
||||
extern void __clr_iabr();
|
||||
extern void __enable_iabr();
|
||||
extern void __disable_iabr();
|
||||
extern void __set_iabr(void *);
|
||||
|
||||
extern const char *tcp_localip;
|
||||
extern const char *tcp_netmask;
|
||||
extern const char *tcp_gateway;
|
||||
extern u8 __text_start[],__data_start[],__bss_start[];
|
||||
extern u8 __text_fstart[],__data_fstart[],__bss_fstart[];
|
||||
|
||||
static __inline__ void bp_init()
|
||||
{
|
||||
s32 i;
|
||||
|
||||
for(i=0;i<GEKKO_MAX_BP;i++) {
|
||||
bp_entries[i].address = NULL;
|
||||
bp_entries[i].instr = 0xffffffff;
|
||||
bp_entries[i].next = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static s32 hex(char ch)
|
||||
{
|
||||
if (ch >= 'a' && ch <= 'f')
|
||||
return ch-'a'+10;
|
||||
if (ch >= '0' && ch <= '9')
|
||||
return ch-'0';
|
||||
if (ch >= 'A' && ch <= 'F')
|
||||
return ch-'A'+10;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static s32 hexToInt(char **ptr, s32 *ival)
|
||||
{
|
||||
s32 cnt;
|
||||
s32 val,nibble;
|
||||
|
||||
val = 0;
|
||||
cnt = 0;
|
||||
while(**ptr) {
|
||||
nibble = hex(**ptr);
|
||||
if(nibble<0) break;
|
||||
|
||||
val = (val<<4)|nibble;
|
||||
cnt++;
|
||||
|
||||
(*ptr)++;
|
||||
}
|
||||
*ival = val;
|
||||
return cnt;
|
||||
}
|
||||
|
||||
static s32 computeSignal(s32 excpt)
|
||||
{
|
||||
struct hard_trap_info *ht;
|
||||
for(ht = hard_trap_info;ht->tt && ht->signo;ht++) {
|
||||
if(ht->tt==excpt) return ht->signo;
|
||||
}
|
||||
return SIGHUP;
|
||||
}
|
||||
|
||||
static u32 insert_bp(void *mem)
|
||||
{
|
||||
u32 i;
|
||||
struct bp_entry *p;
|
||||
|
||||
for(i=0;i<GEKKO_MAX_BP;i++) {
|
||||
if(bp_entries[i].address == NULL) break;
|
||||
}
|
||||
if(i==GEKKO_MAX_BP) return 0;
|
||||
|
||||
p = &bp_entries[i];
|
||||
p->next = p_bpentries;
|
||||
p->address = mem;
|
||||
p_bpentries = p;
|
||||
|
||||
p->instr = *(p->address);
|
||||
*(p->address) = BPCODE;
|
||||
|
||||
DCStoreRangeNoSync((void*)((u32)mem&~0x1f),32);
|
||||
ICInvalidateRange((void*)((u32)mem&~0x1f),32);
|
||||
_sync();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static u32 remove_bp(void *mem)
|
||||
{
|
||||
struct bp_entry *e = p_bpentries;
|
||||
struct bp_entry *f = NULL;
|
||||
|
||||
if(!e) return 0;
|
||||
if(e->address==mem) {
|
||||
p_bpentries = e->next;
|
||||
f = e;
|
||||
} else {
|
||||
for(;e->next;e=e->next) {
|
||||
if(e->next->address==mem) {
|
||||
f = e->next;
|
||||
e->next = f->next;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!f) return 0;
|
||||
|
||||
*(f->address) = f->instr;
|
||||
f->instr = 0xffffffff;
|
||||
f->address = NULL;
|
||||
|
||||
DCStoreRangeNoSync((void*)((u32)mem&~0x1f),32);
|
||||
ICInvalidateRange((void*)((u32)mem&~0x1f),32);
|
||||
_sync();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static char getdbgchar()
|
||||
{
|
||||
char ch = 0;
|
||||
s32 len = 0;
|
||||
|
||||
len = current_device->read(current_device,&ch,1);
|
||||
|
||||
return (len>0)?ch:0;
|
||||
}
|
||||
|
||||
static void putdbgchar(char ch)
|
||||
{
|
||||
current_device->write(current_device,&ch,1);
|
||||
}
|
||||
|
||||
static void putdbgstr(const char *str)
|
||||
{
|
||||
current_device->write(current_device,str,strlen(str));
|
||||
}
|
||||
|
||||
static void putpacket(const char *buffer)
|
||||
{
|
||||
u8 recv;
|
||||
u8 chksum,ch;
|
||||
char *ptr;
|
||||
const char *inp;
|
||||
static char outbuf[2048];
|
||||
|
||||
do {
|
||||
inp = buffer;
|
||||
ptr = outbuf;
|
||||
|
||||
*ptr++ = '$';
|
||||
|
||||
chksum = 0;
|
||||
while((ch=*inp++)!='\0') {
|
||||
*ptr++ = ch;
|
||||
chksum += ch;
|
||||
}
|
||||
|
||||
*ptr++ = '#';
|
||||
*ptr++ = hexchars[chksum>>4];
|
||||
*ptr++ = hexchars[chksum&0x0f];
|
||||
*ptr = '\0';
|
||||
|
||||
putdbgstr(outbuf);
|
||||
|
||||
recv = getdbgchar();
|
||||
} while((recv&0x7f)!='+');
|
||||
}
|
||||
|
||||
static void getpacket(char *buffer)
|
||||
{
|
||||
char ch;
|
||||
u8 chksum,xmitsum;
|
||||
s32 i,cnt;
|
||||
|
||||
do {
|
||||
while((ch=(getdbgchar()&0x7f))!='$');
|
||||
|
||||
cnt = 0;
|
||||
chksum = 0;
|
||||
xmitsum = -1;
|
||||
|
||||
while(cnt<BUFMAX) {
|
||||
ch = getdbgchar()&0x7f;
|
||||
if(ch=='#') break;
|
||||
|
||||
chksum += ch;
|
||||
buffer[cnt] = ch;
|
||||
cnt++;
|
||||
}
|
||||
if(cnt>=BUFMAX) continue;
|
||||
|
||||
buffer[cnt] = 0;
|
||||
if(ch=='#') {
|
||||
xmitsum = hex(getdbgchar()&0x7f)<<4;
|
||||
xmitsum |= hex(getdbgchar()&0x7f);
|
||||
|
||||
if(chksum!=xmitsum) putdbgchar('-');
|
||||
else {
|
||||
putdbgchar('+');
|
||||
if(buffer[2]==':') {
|
||||
putdbgchar(buffer[0]);
|
||||
putdbgchar(buffer[1]);
|
||||
|
||||
cnt = strlen((const char*)buffer);
|
||||
for(i=3;i<=cnt;i++) buffer[i-3] = buffer[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
} while(chksum!=xmitsum);
|
||||
}
|
||||
|
||||
static void process_query(const char *inp,char *outp,s32 thread)
|
||||
{
|
||||
char *optr;
|
||||
|
||||
switch(inp[1]) {
|
||||
case 'C':
|
||||
optr = outp;
|
||||
*optr++ = 'Q';
|
||||
*optr++ = 'C';
|
||||
optr = thread2vhstr(optr,thread);
|
||||
*optr++ = 0;
|
||||
break;
|
||||
case 'P':
|
||||
{
|
||||
s32 ret,rthread,mask;
|
||||
struct gdbstub_threadinfo info;
|
||||
|
||||
ret = parseqp(inp,&mask,&rthread);
|
||||
if(!ret || mask&~0x1f) {
|
||||
strcpy(outp,"E01");
|
||||
break;
|
||||
}
|
||||
|
||||
ret = gdbstub_getthreadinfo(rthread,&info);
|
||||
if(!ret) {
|
||||
strcpy(outp,"E02");
|
||||
break;
|
||||
}
|
||||
packqq(outp,mask,rthread,&info);
|
||||
}
|
||||
break;
|
||||
case 'L':
|
||||
{
|
||||
s32 ret,athread,first,max_cnt,i,done,rthread;
|
||||
|
||||
ret = parseql(inp,&first,&max_cnt,&athread);
|
||||
if(!ret) {
|
||||
strcpy(outp,"E02");
|
||||
break;
|
||||
}
|
||||
if(max_cnt==0) {
|
||||
strcpy(outp,"E02");
|
||||
break;
|
||||
}
|
||||
if(max_cnt>QM_MAXTHREADS) max_cnt = QM_MAXTHREADS;
|
||||
|
||||
optr = reserve_qmheader(outp);
|
||||
if(first) rthread = 0;
|
||||
else rthread = athread;
|
||||
|
||||
done = 0;
|
||||
for(i=0;i<max_cnt;i++) {
|
||||
rthread = gdbstub_getnextthread(rthread);
|
||||
if(rthread<=0) {
|
||||
done = 1;
|
||||
break;
|
||||
}
|
||||
optr = packqmthread(optr,rthread);
|
||||
}
|
||||
*optr = 0;
|
||||
packqmheader(outp,i,done,athread);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static s32 gdbstub_setthreadregs(s32 thread,frame_context *frame)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static s32 gdbstub_getthreadregs(s32 thread,frame_context *frame)
|
||||
{
|
||||
lwp_cntrl *th;
|
||||
|
||||
th = gdbstub_indextoid(thread);
|
||||
if(th) {
|
||||
memcpy(frame->GPR,th->context.GPR,(32*4));
|
||||
memcpy(frame->FPR,th->context.FPR,(32*8));
|
||||
frame->SRR0 = th->context.LR;
|
||||
frame->SRR1 = th->context.MSR;
|
||||
frame->CR = th->context.CR;
|
||||
frame->LR = th->context.LR;
|
||||
frame->CTR = th->context.CTR;
|
||||
frame->XER = th->context.XER;
|
||||
frame->FPSCR = th->context.FPSCR;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void gdbstub_report_exception(frame_context *frame,s32 thread)
|
||||
{
|
||||
s32 sigval;
|
||||
char *ptr;
|
||||
|
||||
ptr = remcomOutBuffer;
|
||||
sigval = computeSignal(frame->EXCPT_Number);
|
||||
*ptr++ = 'T';
|
||||
*ptr++ = highhex(sigval);
|
||||
*ptr++ = lowhex(sigval);
|
||||
*ptr++ = highhex(SP_REGNUM);
|
||||
*ptr++ = lowhex(SP_REGNUM);
|
||||
*ptr++ = ':';
|
||||
ptr = mem2hstr(ptr,(char*)&frame->GPR[1],4);
|
||||
*ptr++ = ';';
|
||||
*ptr++ = highhex(PC_REGNUM);
|
||||
*ptr++ = lowhex(PC_REGNUM);
|
||||
*ptr++ = ':';
|
||||
ptr = mem2hstr(ptr,(char*)&frame->SRR0,4);
|
||||
*ptr++ = ';';
|
||||
|
||||
*ptr++ = 't';
|
||||
*ptr++ = 'h';
|
||||
*ptr++ = 'r';
|
||||
*ptr++ = 'e';
|
||||
*ptr++ = 'a';
|
||||
*ptr++ = 'd';
|
||||
*ptr++ = ':';
|
||||
ptr = thread2vhstr(ptr,thread);
|
||||
*ptr++ = ';';
|
||||
|
||||
*ptr++ = '\0';
|
||||
|
||||
}
|
||||
|
||||
|
||||
void c_debug_handler(frame_context *frame)
|
||||
{
|
||||
char *ptr;
|
||||
s32 addr,len;
|
||||
s32 thread,current_thread;
|
||||
s32 host_has_detached;
|
||||
frame_context *regptr;
|
||||
|
||||
thread = gdbstub_getcurrentthread();
|
||||
current_thread = thread;
|
||||
|
||||
if(current_device->open(current_device)<0) return;
|
||||
|
||||
if(dbg_active) {
|
||||
gdbstub_report_exception(frame,thread);
|
||||
putpacket(remcomOutBuffer);
|
||||
}
|
||||
|
||||
if(frame->SRR0==(u32)__breakinst) frame->SRR0 += 4;
|
||||
|
||||
host_has_detached = 0;
|
||||
while(!host_has_detached) {
|
||||
remcomOutBuffer[0]= 0;
|
||||
getpacket(remcomInBuffer);
|
||||
switch(remcomInBuffer[0]) {
|
||||
case '?':
|
||||
gdbstub_report_exception(frame,thread);
|
||||
break;
|
||||
case 'D':
|
||||
dbg_instep = 0;
|
||||
dbg_active = 0;
|
||||
frame->SRR1 &= ~MSR_SE;
|
||||
strcpy(remcomOutBuffer,"OK");
|
||||
host_has_detached = 1;
|
||||
break;
|
||||
case 'k':
|
||||
dbg_instep = 0;
|
||||
dbg_active = 0;
|
||||
frame->SRR1 &= ~MSR_SE;
|
||||
frame->SRR0 = 0x80001800;
|
||||
host_has_detached = 1;
|
||||
goto exit;
|
||||
case 'g':
|
||||
regptr = frame;
|
||||
ptr = remcomOutBuffer;
|
||||
if(current_thread!=thread) regptr = ¤t_thread_registers;
|
||||
|
||||
ptr = mem2hstr(ptr,(char*)regptr->GPR,32*4);
|
||||
ptr = mem2hstr(ptr,(char*)regptr->FPR,32*8);
|
||||
ptr = mem2hstr(ptr,(char*)®ptr->SRR0,4);
|
||||
ptr = mem2hstr(ptr,(char*)®ptr->SRR1,4);
|
||||
ptr = mem2hstr(ptr,(char*)®ptr->CR,4);
|
||||
ptr = mem2hstr(ptr,(char*)®ptr->LR,4);
|
||||
ptr = mem2hstr(ptr,(char*)®ptr->CTR,4);
|
||||
ptr = mem2hstr(ptr,(char*)®ptr->XER,4);
|
||||
ptr = mem2hstr(ptr,(char*)®ptr->FPSCR,4);
|
||||
break;
|
||||
case 'm':
|
||||
ptr = &remcomInBuffer[1];
|
||||
if(hexToInt(&ptr,&addr) && ((addr&0xC0000000)==0xC0000000 || (addr&0xC0000000)==0x80000000)
|
||||
&& *ptr++==','
|
||||
&& hexToInt(&ptr,&len) && len<=((BUFMAX - 4)/2))
|
||||
mem2hstr(remcomOutBuffer,(void*)addr,len);
|
||||
else
|
||||
strcpy(remcomOutBuffer,"E00");
|
||||
break;
|
||||
case 'q':
|
||||
process_query(remcomInBuffer,remcomOutBuffer,thread);
|
||||
break;
|
||||
case 'c':
|
||||
dbg_instep = 0;
|
||||
dbg_active = 1;
|
||||
frame->SRR1 &= ~MSR_SE;
|
||||
current_device->wait(current_device);
|
||||
goto exit;
|
||||
case 's':
|
||||
dbg_instep = 1;
|
||||
dbg_active = 1;
|
||||
frame->SRR1 |= MSR_SE;
|
||||
current_device->wait(current_device);
|
||||
goto exit;
|
||||
case 'z':
|
||||
{
|
||||
s32 ret,type;
|
||||
u32 len;
|
||||
char *addr;
|
||||
|
||||
ret = parsezbreak(remcomInBuffer,&type,&addr,&len);
|
||||
if(!ret) {
|
||||
strcpy(remcomOutBuffer,"E01");
|
||||
break;
|
||||
}
|
||||
if(type!=0) break;
|
||||
|
||||
if(len<4) {
|
||||
strcpy(remcomOutBuffer,"E02");
|
||||
break;
|
||||
}
|
||||
|
||||
ret = remove_bp(addr);
|
||||
if(!ret) {
|
||||
strcpy(remcomOutBuffer,"E03");
|
||||
break;
|
||||
}
|
||||
strcpy(remcomOutBuffer,"OK");
|
||||
}
|
||||
break;
|
||||
case 'H':
|
||||
if(remcomInBuffer[1]=='g')
|
||||
{
|
||||
s32 tmp,ret;
|
||||
|
||||
if(vhstr2thread(&remcomInBuffer[2],&tmp)==NULL) {
|
||||
strcpy(remcomOutBuffer,"E01");
|
||||
break;
|
||||
}
|
||||
if(!tmp) tmp = thread;
|
||||
if(tmp==current_thread) {
|
||||
strcpy(remcomOutBuffer,"OK");
|
||||
break;
|
||||
}
|
||||
|
||||
if(current_thread!=thread) ret = gdbstub_setthreadregs(current_thread,¤t_thread_registers);
|
||||
if(tmp!=thread) {
|
||||
ret = gdbstub_getthreadregs(tmp,¤t_thread_registers);
|
||||
if(!ret) {
|
||||
strcpy(remcomOutBuffer,"E02");
|
||||
break;
|
||||
}
|
||||
}
|
||||
current_thread= tmp;
|
||||
}
|
||||
strcpy(remcomOutBuffer,"OK");
|
||||
break;
|
||||
case 'T':
|
||||
{
|
||||
s32 tmp;
|
||||
|
||||
if(vhstr2thread(&remcomInBuffer[1],&tmp)==NULL) {
|
||||
strcpy(remcomOutBuffer,"E01");
|
||||
break;
|
||||
}
|
||||
if(gdbstub_indextoid(tmp)==NULL) strcpy(remcomOutBuffer,"E02");
|
||||
else strcpy(remcomOutBuffer,"OK");
|
||||
}
|
||||
break;
|
||||
case 'Z':
|
||||
{
|
||||
s32 ret,type;
|
||||
u32 len;
|
||||
char *addr;
|
||||
|
||||
ret = parsezbreak(remcomInBuffer,&type,&addr,&len);
|
||||
if(!ret) {
|
||||
strcpy(remcomOutBuffer,"E01");
|
||||
break;
|
||||
}
|
||||
if(type!=0) {
|
||||
strcpy(remcomOutBuffer,"E02");
|
||||
break;
|
||||
}
|
||||
if(len<4) {
|
||||
strcpy(remcomOutBuffer,"E03");
|
||||
break;
|
||||
}
|
||||
|
||||
ret = insert_bp(addr);
|
||||
if(!ret) {
|
||||
strcpy(remcomOutBuffer,"E04");
|
||||
break;
|
||||
}
|
||||
strcpy(remcomOutBuffer,"OK");
|
||||
}
|
||||
break;
|
||||
}
|
||||
putpacket(remcomOutBuffer);
|
||||
}
|
||||
current_device->close(current_device);
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
|
||||
void _break(void)
|
||||
{
|
||||
if(!dbg_initialized) return;
|
||||
__asm__ __volatile__ (".globl __breakinst\n\
|
||||
__breakinst: .long 0x7d821008");
|
||||
}
|
||||
|
||||
void DEBUG_Init(s32 device_type,s32 channel_port)
|
||||
{
|
||||
u32 level;
|
||||
struct uip_ip_addr localip,netmask,gateway;
|
||||
|
||||
UIP_LOG("DEBUG_Init()\n");
|
||||
|
||||
__lwp_thread_dispatchdisable();
|
||||
|
||||
bp_init();
|
||||
|
||||
if(device_type==GDBSTUB_DEVICE_USB) {
|
||||
current_device = usb_init(channel_port);
|
||||
} else {
|
||||
localip.addr = uip_ipaddr((const u8_t*)tcp_localip);
|
||||
netmask.addr = uip_ipaddr((const u8_t*)tcp_netmask);
|
||||
gateway.addr = uip_ipaddr((const u8_t*)tcp_gateway);
|
||||
|
||||
current_device = tcpip_init(&localip,&netmask,&gateway,(u16)channel_port);
|
||||
}
|
||||
|
||||
if(current_device!=NULL) {
|
||||
_CPU_ISR_Disable(level);
|
||||
__exception_sethandler(EX_DSI,dbg_exceptionhandler);
|
||||
__exception_sethandler(EX_PRG,dbg_exceptionhandler);
|
||||
__exception_sethandler(EX_TRACE,dbg_exceptionhandler);
|
||||
__exception_sethandler(EX_IABR,dbg_exceptionhandler);
|
||||
_CPU_ISR_Restore(level);
|
||||
|
||||
dbg_initialized = 1;
|
||||
|
||||
}
|
||||
__lwp_thread_dispatchenable();
|
||||
}
|
||||
|
169
wii/libogc/libdb/debug_handler.S
Normal file
169
wii/libogc/libdb/debug_handler.S
Normal file
@ -0,0 +1,169 @@
|
||||
#include <asm.h>
|
||||
|
||||
#define EXCEPTION_PROLOG \
|
||||
mfspr r0,912; \
|
||||
stw r0,GQR0_OFFSET(sp); \
|
||||
mfspr r0,913; \
|
||||
stw r0,GQR1_OFFSET(sp); \
|
||||
mfspr r0,914; \
|
||||
stw r0,GQR2_OFFSET(sp); \
|
||||
mfspr r0,915; \
|
||||
stw r0,GQR3_OFFSET(sp); \
|
||||
mfspr r0,916; \
|
||||
stw r0,GQR4_OFFSET(sp); \
|
||||
mfspr r0,917; \
|
||||
stw r0,GQR5_OFFSET(sp); \
|
||||
mfspr r0,918; \
|
||||
stw r0,GQR6_OFFSET(sp); \
|
||||
mfspr r0,919; \
|
||||
stw r0,GQR7_OFFSET(sp); \
|
||||
stmw r6,GPR6_OFFSET(sp)
|
||||
|
||||
#define EXCEPTION_EPILOG \
|
||||
lwz r4,GQR0_OFFSET(sp); \
|
||||
mtspr 912,r4; \
|
||||
lwz r4,GQR1_OFFSET(sp); \
|
||||
mtspr 913,r4; \
|
||||
lwz r4,GQR2_OFFSET(sp); \
|
||||
mtspr 914,r4; \
|
||||
lwz r4,GQR3_OFFSET(sp); \
|
||||
mtspr 915,r4; \
|
||||
lwz r4,GQR4_OFFSET(sp); \
|
||||
mtspr 916,r4; \
|
||||
lwz r4,GQR5_OFFSET(sp); \
|
||||
mtspr 917,r4; \
|
||||
lwz r4,GQR6_OFFSET(sp); \
|
||||
mtspr 918,r4; \
|
||||
lwz r4,GQR7_OFFSET(sp); \
|
||||
mtspr 919,r4; \
|
||||
lmw r5,GPR5_OFFSET(sp)
|
||||
|
||||
.extern c_debug_handler
|
||||
.extern _cpu_context_save_fp
|
||||
.globl dbg_exceptionhandler
|
||||
dbg_exceptionhandler:
|
||||
stwu sp,-EXCEPTION_FRAME_END(sp) //now we're able to adjust the stackpointer with it's cached address
|
||||
|
||||
EXCEPTION_PROLOG
|
||||
|
||||
mfmsr r4
|
||||
ori r4,r4,MSR_FP
|
||||
mtmsr r4
|
||||
isync
|
||||
|
||||
addi r14,sp,0
|
||||
|
||||
lis r15,__debug_nestlevel@ha
|
||||
lwz r6,__debug_nestlevel@l(r15)
|
||||
cmpwi r6,0
|
||||
bne nested
|
||||
|
||||
lis sp,__debugstack@h
|
||||
ori sp,sp,__debugstack@l
|
||||
lis r0,0
|
||||
stwu r0,-16(sp)
|
||||
|
||||
nested:
|
||||
addi r6,r6,1
|
||||
stw r6,__debug_nestlevel@l(r15)
|
||||
|
||||
addi r3,r14,0x08
|
||||
bl _cpu_context_save_fp
|
||||
bl c_debug_handler
|
||||
|
||||
lwz r6,__debug_nestlevel@l(r15)
|
||||
addi r6,r6,-1
|
||||
stw r6,__debug_nestlevel@l(r15)
|
||||
|
||||
addi sp,r14,0
|
||||
|
||||
exit:
|
||||
lwz r4,CR_OFFSET(sp)
|
||||
mtcr r4
|
||||
lwz r4,LR_OFFSET(sp)
|
||||
mtlr r4
|
||||
lwz r4,CTR_OFFSET(sp)
|
||||
mtctr r4
|
||||
lwz r4,XER_OFFSET(sp)
|
||||
mtxer r4
|
||||
|
||||
EXCEPTION_EPILOG
|
||||
|
||||
mfmsr r4
|
||||
rlwinm r4,r4,0,19,17
|
||||
mtmsr r4
|
||||
isync
|
||||
|
||||
lwz toc,GPR2_OFFSET(sp)
|
||||
lwz r0,GPR0_OFFSET(sp)
|
||||
|
||||
lwz r4,SRR0_OFFSET(sp)
|
||||
mtsrr0 r4
|
||||
lwz r4,SRR1_OFFSET(sp)
|
||||
mtsrr1 r4
|
||||
|
||||
lwz r4,GPR4_OFFSET(sp)
|
||||
lwz r3,GPR3_OFFSET(sp)
|
||||
addi sp,sp,EXCEPTION_FRAME_END
|
||||
rfi
|
||||
|
||||
.globl __set_iabr
|
||||
__set_iabr:
|
||||
mfmsr r4
|
||||
rlwinm r5,r4,0,18,16
|
||||
mtmsr r5
|
||||
clrrwi r3,r3,2
|
||||
mtspr 1010,r3
|
||||
isync
|
||||
sync
|
||||
mtmsr r4
|
||||
blr
|
||||
|
||||
.globl __enable_iabr
|
||||
__enable_iabr:
|
||||
mfmsr r4
|
||||
rlwinm r5,r4,0,18,16
|
||||
mtmsr r5
|
||||
mfspr r3,1010
|
||||
ori r3,r3,0x0003
|
||||
mtspr 1010,r3
|
||||
isync
|
||||
sync
|
||||
mtmsr r4
|
||||
blr
|
||||
|
||||
.globl __disable_iabr
|
||||
__disable_iabr:
|
||||
mfmsr r4
|
||||
rlwinm r5,r4,0,18,16
|
||||
mtmsr r5
|
||||
mfspr r3,1010
|
||||
clrrwi r3,r3,2
|
||||
mtspr 1010,r3
|
||||
isync
|
||||
sync
|
||||
mtmsr r4
|
||||
blr
|
||||
|
||||
.globl __clr_iabr
|
||||
__clr_iabr:
|
||||
mfmsr r4
|
||||
rlwinm r5,r4,0,18,16
|
||||
mtmsr r5
|
||||
mtspr 1010,0
|
||||
isync
|
||||
sync
|
||||
mtmsr r4
|
||||
blr
|
||||
|
||||
.section .bss
|
||||
|
||||
.balign 4
|
||||
__debug_nestlevel:
|
||||
.long 0
|
||||
|
||||
.balign 8
|
||||
.globl __debugstack_end,__debugstack
|
||||
__debugstack_end:
|
||||
.space 0x4000
|
||||
__debugstack:
|
20
wii/libogc/libdb/debug_if.h
Normal file
20
wii/libogc/libdb/debug_if.h
Normal file
@ -0,0 +1,20 @@
|
||||
#ifndef __DEBUG_IF_H__
|
||||
#define __DEBUG_IF_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#define GDBSTUB_DEVICE_USB 0
|
||||
#define GDBSTUB_DEVICE_TCP 1
|
||||
|
||||
struct dbginterface
|
||||
{
|
||||
s32 fhndl;
|
||||
|
||||
int (*open)(struct dbginterface *device);
|
||||
int (*close)(struct dbginterface *device);
|
||||
int (*wait)(struct dbginterface *device);
|
||||
int (*read)(struct dbginterface *device,void *buffer,int size);
|
||||
int (*write)(struct dbginterface *devicec,const void *buffer,int size);
|
||||
};
|
||||
|
||||
#endif
|
477
wii/libogc/libdb/debug_supp.c
Normal file
477
wii/libogc/libdb/debug_supp.c
Normal file
@ -0,0 +1,477 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <gccore.h>
|
||||
|
||||
#include "lwp_threads.h"
|
||||
#include "debug_supp.h"
|
||||
|
||||
extern lwp_objinfo _lwp_cond_objects;
|
||||
extern lwp_objinfo _lwp_thr_objects;
|
||||
extern lwp_objinfo _lwp_tqueue_objects;
|
||||
extern lwp_objinfo _lwp_mqbox_objects;
|
||||
extern lwp_objinfo _lwp_mutex_objects;
|
||||
extern lwp_objinfo _lwp_sema_objects;
|
||||
|
||||
extern const u8 hexchars[];
|
||||
|
||||
extern u8 __text_start[],__data_start[],__bss_start[];
|
||||
extern u8 __text_fstart[],__data_fstart[],__bss_fstart[];
|
||||
|
||||
s32 hstr2nibble(const char *buf,s32 *nibble)
|
||||
{
|
||||
s32 ch;
|
||||
|
||||
ch = *buf;
|
||||
if(ch>='0' && ch<='9') {
|
||||
*nibble = ch - '0';
|
||||
return 1;
|
||||
}
|
||||
if(ch>='a' && ch<='f') {
|
||||
*nibble = ch - 'a' + 10;
|
||||
return 1;
|
||||
}
|
||||
if(ch>='A' && ch<='F') {
|
||||
*nibble = ch - 'A' + 10;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 hstr2byte(const char *buf,s32 *bval)
|
||||
{
|
||||
s32 hnib,lnib;
|
||||
|
||||
if(!hstr2nibble(buf,&hnib) || !hstr2nibble(buf+1,&lnib)) return 0;
|
||||
|
||||
*bval = (hnib<<4)|lnib;
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* vhstr2int(const char *buf,s32 *ival)
|
||||
{
|
||||
s32 i,val,nibble;
|
||||
s32 found0,lim;
|
||||
|
||||
found0 = 0;
|
||||
for(i=0;i<8;i++,buf++) {
|
||||
if(*buf!='0') break;
|
||||
|
||||
found0 = 1;
|
||||
}
|
||||
|
||||
val = 0;
|
||||
lim = 8 - i;
|
||||
for(i=0;i<lim;i++,buf++) {
|
||||
if(!hstr2nibble(buf,&nibble)) {
|
||||
if(i==0 && !found0) return NULL;
|
||||
|
||||
*ival = val;
|
||||
return buf;
|
||||
}
|
||||
val = (val<<4)|nibble;
|
||||
}
|
||||
if(hstr2nibble(buf,&nibble)) return NULL;
|
||||
|
||||
*ival = val;
|
||||
return buf;
|
||||
}
|
||||
|
||||
const char* fhstr2int(const char *buf,s32 *ival)
|
||||
{
|
||||
s32 i,val,nibble;
|
||||
|
||||
val = 0;
|
||||
for(i=0;i<8;i++,buf++) {
|
||||
if(!hstr2nibble(buf,&nibble)) return NULL;
|
||||
|
||||
val = (val<<4)|nibble;
|
||||
}
|
||||
|
||||
*ival = val;
|
||||
return buf;
|
||||
}
|
||||
|
||||
char* int2fhstr(char *buf,s32 val)
|
||||
{
|
||||
s32 i,nibble,shift;
|
||||
|
||||
for(i=0,shift=28;i<8;i++,shift-=4,buf++) {
|
||||
nibble = (val>>shift)&0x0f;
|
||||
*buf = hexchars[nibble];
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
char* int2vhstr(char *buf,s32 val)
|
||||
{
|
||||
s32 i,nibble,shift;
|
||||
|
||||
for(i=0,shift=28;i<8;i++,shift-=4) {
|
||||
nibble = (val>>shift)&0x0f;
|
||||
if(nibble) break;
|
||||
}
|
||||
if(i==8) {
|
||||
*buf++ = '0';
|
||||
return buf;
|
||||
}
|
||||
|
||||
*buf++ = hexchars[nibble];
|
||||
for(i++,shift-=4;i<8;i++,shift-=4,buf++) {
|
||||
nibble = (val>>shift)&0x0f;
|
||||
*buf = hexchars[nibble];
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
char* mem2hstr(char *buf,const char *mem,s32 count)
|
||||
{
|
||||
s32 i;
|
||||
char ch;
|
||||
|
||||
for(i=0;i<count;i++,mem++) {
|
||||
ch = *mem;
|
||||
*buf++ = hexchars[ch>>4];
|
||||
*buf++ = hexchars[ch&0x0f];
|
||||
}
|
||||
*buf = 0;
|
||||
return buf;
|
||||
}
|
||||
char* thread2fhstr(char *buf,s32 thread)
|
||||
{
|
||||
s32 i,nibble,shift;
|
||||
|
||||
for(i=0;i<8;i++,buf++) *buf = '0';
|
||||
for(i=0,shift=28;i<8;i++,shift-=4,buf++) {
|
||||
nibble = (thread>>shift)&0x0f;
|
||||
*buf = hexchars[nibble];
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
char* thread2vhstr(char *buf,s32 thread)
|
||||
{
|
||||
s32 i,nibble,shift;
|
||||
|
||||
for(i=0,shift=28;i<8;i++,shift-=4) {
|
||||
nibble = (thread>>shift)&0x0f;
|
||||
if(nibble) break;
|
||||
}
|
||||
if(i==8) {
|
||||
*buf++ = '0';
|
||||
return buf;
|
||||
}
|
||||
|
||||
*buf++ = hexchars[nibble];
|
||||
for(i++,shift-=4;i<8;i++,shift-=4,buf++) {
|
||||
nibble = (thread>>shift)&0x0f;
|
||||
*buf = hexchars[nibble];
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
const char* fhstr2thread(const char *buf,s32 *thread)
|
||||
{
|
||||
s32 i,nibble,val;
|
||||
|
||||
for(i=0;i<8;i++,buf++)
|
||||
if(*buf!='0') return NULL;
|
||||
|
||||
val = 0;
|
||||
for(i=0;i<8;i++,buf++) {
|
||||
if(!hstr2nibble(buf,&nibble)) return NULL;
|
||||
|
||||
val = (val<<4)|nibble;
|
||||
}
|
||||
|
||||
*thread = val;
|
||||
return buf;
|
||||
}
|
||||
|
||||
const char* vhstr2thread(const char *buf,s32 *thread)
|
||||
{
|
||||
s32 i,val,nibble;
|
||||
s32 found0,lim;
|
||||
|
||||
found0 = 0;
|
||||
for(i=0;i<16;i++,buf++) {
|
||||
if(*buf!='0') break;
|
||||
|
||||
found0 = 1;
|
||||
}
|
||||
|
||||
val = 0;
|
||||
lim = 16 - i;
|
||||
for(i=0;i<lim;i++,buf++) {
|
||||
if(!hstr2nibble(buf,&nibble)) {
|
||||
if(i==0 && found0) return NULL;
|
||||
|
||||
*thread = val;
|
||||
return buf;
|
||||
}
|
||||
|
||||
val = (val<<4)|nibble;
|
||||
}
|
||||
if(hstr2nibble(buf,&nibble)) return NULL;
|
||||
|
||||
*thread = val;
|
||||
return buf;
|
||||
}
|
||||
|
||||
s32 gdbstub_idtoindex(s32 objid)
|
||||
{
|
||||
s32 min_id,max_id;
|
||||
s32 first_id;
|
||||
|
||||
if(_thr_executing==_thr_idle) return 1;
|
||||
|
||||
first_id = 1;
|
||||
min_id = _lwp_thr_objects.min_id;
|
||||
max_id = _lwp_thr_objects.max_id;
|
||||
if(objid>=min_id && objid<max_id) return first_id + (objid - min_id);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
lwp_cntrl* gdbstub_indextoid(s32 thread)
|
||||
{
|
||||
s32 min_id,max_id,first_id;
|
||||
lwp_cntrl *th;
|
||||
|
||||
if(thread<=0) return NULL;
|
||||
|
||||
if(thread==1) return _thr_idle;
|
||||
|
||||
first_id = 1;
|
||||
min_id = _lwp_thr_objects.min_id;
|
||||
max_id = _lwp_thr_objects.max_id;
|
||||
if(thread<(first_id + (max_id - min_id))) {
|
||||
th = (lwp_cntrl*)_lwp_thr_objects.local_table[thread - first_id];
|
||||
return th;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
s32 gdbstub_getcurrentthread()
|
||||
{
|
||||
return gdbstub_idtoindex(_thr_executing->object.id);
|
||||
}
|
||||
|
||||
s32 gdbstub_getnextthread(s32 athread)
|
||||
{
|
||||
s32 id,start;
|
||||
s32 first_id,min_id,max_id,lim;
|
||||
|
||||
if(athread<1) return 1;
|
||||
|
||||
first_id = 1;
|
||||
min_id = _lwp_thr_objects.min_id;
|
||||
max_id = _lwp_thr_objects.max_id;
|
||||
lim = first_id + max_id - min_id;
|
||||
if(athread<lim) {
|
||||
if(athread<first_id)
|
||||
start = first_id;
|
||||
else
|
||||
start = athread+1;
|
||||
|
||||
for(id=start;id<lim;id++)
|
||||
if(_lwp_thr_objects.local_table[id - first_id]!=NULL) return id;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 gdbstub_getoffsets(char **textaddr,char **dataaddr,char **bssaddr)
|
||||
{
|
||||
*textaddr = (char*)((u32)__text_fstart - (u32)__text_fstart);
|
||||
*dataaddr = (char*)((u32)__data_fstart - (u32)__text_fstart);
|
||||
*bssaddr = (char*)((u32)__bss_fstart - (u32)__text_fstart);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
s32 gdbstub_getthreadinfo(s32 thread,struct gdbstub_threadinfo *info)
|
||||
{
|
||||
s32 first_id,min_id,max_id;
|
||||
lwp_cntrl *th;
|
||||
char tmp_buf[20];
|
||||
|
||||
if(thread<=0) return 0;
|
||||
|
||||
if(thread==1) {
|
||||
strcpy(info->display,"idle thread");
|
||||
strcpy(info->name,"IDLE");
|
||||
info->more_display[0] = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
first_id = 1;
|
||||
min_id = _lwp_thr_objects.min_id;
|
||||
max_id = _lwp_thr_objects.max_id;
|
||||
if(thread<=(first_id + (max_id - min_id))){
|
||||
th = (lwp_cntrl*)_lwp_thr_objects.local_table[thread - first_id];
|
||||
if(th==NULL) return 0;
|
||||
|
||||
strcpy(info->display,"libogc task: control at: 0x");
|
||||
tmp_buf[0] = hexchars[(((int)th)>>28)&0x0f];
|
||||
tmp_buf[1] = hexchars[(((int)th)>>24)&0x0f];
|
||||
tmp_buf[2] = hexchars[(((int)th)>>20)&0x0f];
|
||||
tmp_buf[3] = hexchars[(((int)th)>>16)&0x0f];
|
||||
tmp_buf[4] = hexchars[(((int)th)>>12)&0x0f];
|
||||
tmp_buf[5] = hexchars[(((int)th)>>8)&0x0f];
|
||||
tmp_buf[6] = hexchars[(((int)th)>>4)&0x0f];
|
||||
tmp_buf[7] = hexchars[((int)th)&0x0f];
|
||||
tmp_buf[8] = 0;
|
||||
strcat(info->display,tmp_buf);
|
||||
|
||||
info->name[0] = 0;
|
||||
info->name[1] = 0;
|
||||
info->name[2] = 0;
|
||||
info->name[3] = 0;
|
||||
info->name[4] = 0;
|
||||
|
||||
info->more_display[0] = 0;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 parsezbreak(const char *in,s32 *type,char **addr,u32 *len)
|
||||
{
|
||||
s32 ttmp,atmp,ltmp;
|
||||
|
||||
in++;
|
||||
if(!hstr2nibble(in,&ttmp) || *(in+1)!=',') return 0;
|
||||
|
||||
in += 2;
|
||||
in = vhstr2int(in,&atmp);
|
||||
if(in==NULL || *in!=',') return 0;
|
||||
|
||||
in++;
|
||||
in = vhstr2int(in,<mp);
|
||||
if(in==NULL || ltmp<1) return 0;
|
||||
|
||||
*type = ttmp;
|
||||
*addr = (char*)atmp;
|
||||
*len = ltmp;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
s32 parseqp(const char *in,s32 *mask,s32 *thread)
|
||||
{
|
||||
const char *ptr;
|
||||
|
||||
ptr = fhstr2int(in+2,mask);
|
||||
if(ptr==NULL) return 0;
|
||||
|
||||
ptr = fhstr2thread(ptr,thread);
|
||||
if(ptr==NULL) return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void packqq(char *out,s32 mask,s32 thread,struct gdbstub_threadinfo *info)
|
||||
{
|
||||
s32 len;
|
||||
|
||||
*out++ = 'q';
|
||||
*out++ = 'Q';
|
||||
out = int2fhstr(out,mask);
|
||||
out = thread2fhstr(out,thread);
|
||||
|
||||
if(mask&0x01) {
|
||||
memcpy(out,"00000001",8);
|
||||
out += 8;
|
||||
*out++ = '1';
|
||||
*out++ = '0';
|
||||
out = thread2fhstr(out,thread);
|
||||
}
|
||||
if(mask&0x02) {
|
||||
memcpy(out,"00000002",8);
|
||||
out += 8;
|
||||
*out++ = '0';
|
||||
*out++ = '1';
|
||||
*out++ = '1';
|
||||
}
|
||||
if(mask&0x04) {
|
||||
memcpy(out,"00000004",8);
|
||||
out += 8;
|
||||
|
||||
info->display[sizeof(info->display)-1] = 0; //for god sake
|
||||
len = strlen(info->display);
|
||||
|
||||
*out++ = hexchars[(len>>4)&0x0f];
|
||||
*out++ = hexchars[len&0x0f];
|
||||
|
||||
memcpy(out,info->display,len);
|
||||
out += len;
|
||||
}
|
||||
if(mask&0x08) {
|
||||
memcpy(out,"00000008",8);
|
||||
out += 8;
|
||||
|
||||
info->display[sizeof(info->name)-1] = 0; //for god sake
|
||||
len = strlen(info->name);
|
||||
|
||||
*out++ = hexchars[(len>>4)&0x0f];
|
||||
*out++ = hexchars[len&0x0f];
|
||||
|
||||
memcpy(out,info->name,len);
|
||||
out += len;
|
||||
}
|
||||
if(mask&0x10) {
|
||||
memcpy(out,"00000010",8);
|
||||
out += 8;
|
||||
|
||||
info->display[sizeof(info->more_display)-1] = 0; //for god sake
|
||||
len = strlen(info->more_display);
|
||||
|
||||
*out++ = hexchars[(len>>4)&0x0f];
|
||||
*out++ = hexchars[len&0x0f];
|
||||
|
||||
memcpy(out,info->more_display,len);
|
||||
out += len;
|
||||
}
|
||||
*out = 0;
|
||||
}
|
||||
|
||||
s32 parseql(const char *in,s32 *first,s32 *max_cnt,s32 *athread)
|
||||
{
|
||||
const char *ptr;
|
||||
|
||||
ptr = in+2;
|
||||
if(!hstr2nibble(ptr,first)) return 0;
|
||||
|
||||
ptr++;
|
||||
if(!hstr2byte(ptr,max_cnt)) return 0;
|
||||
|
||||
ptr += 2;
|
||||
ptr = fhstr2thread(ptr,athread);
|
||||
if(ptr==NULL) return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
char* reserve_qmheader(char *out)
|
||||
{
|
||||
return (out+21);
|
||||
}
|
||||
|
||||
char* packqmthread(char *out,s32 thread)
|
||||
{
|
||||
return thread2fhstr(out,thread);
|
||||
}
|
||||
|
||||
void packqmheader(char *out,s32 count,s32 done,s32 athread)
|
||||
{
|
||||
*out++ = 'q';
|
||||
*out++ = 'M';
|
||||
*out++ = hexchars[(count>>4)&0x0f];
|
||||
*out++ = hexchars[count&0x0f];
|
||||
|
||||
if(done) *out++ = '1';
|
||||
else *out++ = '0';
|
||||
|
||||
thread2fhstr(out,athread);
|
||||
}
|
32
wii/libogc/libdb/debug_supp.h
Normal file
32
wii/libogc/libdb/debug_supp.h
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef __DEBUG_SUPP_H__
|
||||
#define __DEBUG_SUPP_H__
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#define QM_MAXTHREADS (20)
|
||||
|
||||
struct gdbstub_threadinfo {
|
||||
char display[256];
|
||||
char more_display[256];
|
||||
char name[256];
|
||||
};
|
||||
|
||||
s32 gdbstub_getcurrentthread();
|
||||
s32 hstr2nibble(const char *buf,s32 *nibble);
|
||||
char* int2vhstr(char *buf,s32 val);
|
||||
char* mem2hstr(char *buf,const char *mem,s32 count);
|
||||
char* thread2vhstr(char *buf,s32 thread);
|
||||
const char* vhstr2thread(const char *buf,s32 *thread);
|
||||
lwp_cntrl* gdbstub_indextoid(s32 thread);
|
||||
s32 gdbstub_getoffsets(char **textaddr,char **dataaddr,char **bssaddr);
|
||||
s32 parsezbreak(const char *in,s32 *type,char **addr,u32 *len);
|
||||
s32 gdbstub_getthreadinfo(s32 thread,struct gdbstub_threadinfo *info);
|
||||
s32 parseqp(const char *in,s32 *mask,s32 *thread);
|
||||
void packqq(char *out,s32 mask,s32 thread,struct gdbstub_threadinfo *info);
|
||||
char* reserve_qmheader(char *out);
|
||||
s32 parseql(const char *in,s32 *first,s32 *max_cnt,s32 *athread);
|
||||
s32 gdbstub_getnextthread(s32 athread);
|
||||
char* packqmthread(char *out,s32 thread);
|
||||
void packqmheader(char *out,s32 count,s32 done,s32 athread);
|
||||
|
||||
#endif
|
198
wii/libogc/libdb/geckousb.c
Normal file
198
wii/libogc/libdb/geckousb.c
Normal file
@ -0,0 +1,198 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <gccore.h>
|
||||
|
||||
#include "geckousb.h"
|
||||
|
||||
#define _SHIFTL(v, s, w) \
|
||||
((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))
|
||||
#define _SHIFTR(v, s, w) \
|
||||
((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))
|
||||
|
||||
static struct dbginterface usb_device;
|
||||
|
||||
static __inline__ int __send_command(s32 chn,u16 *cmd)
|
||||
{
|
||||
s32 ret;
|
||||
|
||||
ret = 0;
|
||||
if(!EXI_Select(chn,EXI_DEVICE_0,EXI_SPEED32MHZ)) ret |= 0x01;
|
||||
if(!EXI_Imm(chn,cmd,sizeof(u16),EXI_READWRITE,NULL)) ret |= 0x02;
|
||||
if(!EXI_Sync(chn)) ret |= 0x04;
|
||||
if(!EXI_Deselect(chn)) ret |= 0x08;
|
||||
|
||||
if(ret) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int __usb_sendbyte(s32 chn,char ch)
|
||||
{
|
||||
s32 ret;
|
||||
u16 val;
|
||||
|
||||
val = (0xB000|_SHIFTL(ch,4,8));
|
||||
ret = __send_command(chn,&val);
|
||||
if(ret==1 && !(val&0x0400)) ret = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int __usb_recvbyte(s32 chn,char *ch)
|
||||
{
|
||||
s32 ret;
|
||||
u16 val;
|
||||
|
||||
*ch = 0;
|
||||
val = 0xA000;
|
||||
ret = __send_command(chn,&val);
|
||||
if(ret==1 && !(val&0x0800)) ret = 0;
|
||||
else if(ret==1) *ch = (val&0xff);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int __usb_checksend(s32 chn)
|
||||
{
|
||||
s32 ret;
|
||||
u16 val;
|
||||
|
||||
val = 0xC000;
|
||||
ret = __send_command(chn,&val);
|
||||
if(ret==1 && !(val&0x0400)) ret = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int __usb_checkrecv(s32 chn)
|
||||
{
|
||||
s32 ret;
|
||||
u16 val;
|
||||
|
||||
val = 0xD000;
|
||||
ret = __send_command(chn,&val);
|
||||
if(ret==1 && !(val&0x0400)) ret = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void __usb_flush(s32 chn)
|
||||
{
|
||||
char tmp;
|
||||
|
||||
if(!EXI_Lock(chn,EXI_DEVICE_0,NULL)) return;
|
||||
|
||||
while(__usb_recvbyte(chn,&tmp));
|
||||
|
||||
EXI_Unlock(chn);
|
||||
}
|
||||
|
||||
|
||||
static int __usb_isgeckoalive(s32 chn)
|
||||
{
|
||||
s32 ret;
|
||||
u16 val;
|
||||
|
||||
if(!EXI_Lock(chn,EXI_DEVICE_0,NULL)) return 0;
|
||||
|
||||
val = 0x9000;
|
||||
ret = __send_command(chn,&val);
|
||||
if(ret==1 && !(val&0x0470)) ret = 0;
|
||||
|
||||
EXI_Unlock(chn);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int __usb_recvbuffer(s32 chn,void *buffer,int size)
|
||||
{
|
||||
s32 ret;
|
||||
s32 left = size;
|
||||
char *ptr = (char*)buffer;
|
||||
|
||||
if(!EXI_Lock(chn,EXI_DEVICE_0,NULL)) return 0;
|
||||
|
||||
while(left>0) {
|
||||
if(__usb_checkrecv(chn)) {
|
||||
ret = __usb_recvbyte(chn,ptr);
|
||||
if(ret==0) break;
|
||||
|
||||
ptr++;
|
||||
left--;
|
||||
}
|
||||
}
|
||||
|
||||
EXI_Unlock(chn);
|
||||
return (size - left);
|
||||
}
|
||||
|
||||
static int __usb_sendbuffer(s32 chn,const void *buffer,int size)
|
||||
{
|
||||
s32 ret;
|
||||
s32 left = size;
|
||||
char *ptr = (char*)buffer;
|
||||
|
||||
if(!EXI_Lock(chn,EXI_DEVICE_0,NULL)) return 0;
|
||||
|
||||
while(left>0) {
|
||||
if(__usb_checksend(chn)) {
|
||||
ret = __usb_sendbyte(chn,*ptr);
|
||||
if(ret==0) break;
|
||||
|
||||
ptr++;
|
||||
left--;
|
||||
}
|
||||
}
|
||||
|
||||
EXI_Unlock(chn);
|
||||
return (size - left);
|
||||
}
|
||||
|
||||
static int usbopen(struct dbginterface *device)
|
||||
{
|
||||
if(!__usb_isgeckoalive(device->fhndl)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int usbclose(struct dbginterface *device)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int usbwait(struct dbginterface *device)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int usbread(struct dbginterface *device,void *buffer,int size)
|
||||
{
|
||||
int ret;
|
||||
ret = __usb_recvbuffer(device->fhndl,buffer,size);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int usbwrite(struct dbginterface *device,const void *buffer,int size)
|
||||
{
|
||||
int ret;
|
||||
ret = __usb_sendbuffer(device->fhndl,buffer,size);
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct dbginterface* usb_init(s32 channel)
|
||||
{
|
||||
usb_device.fhndl = channel;
|
||||
if(__usb_isgeckoalive(channel))
|
||||
__usb_flush(channel);
|
||||
|
||||
usb_device.open = usbopen;
|
||||
usb_device.close = usbclose;
|
||||
usb_device.wait = usbwait;
|
||||
usb_device.read = usbread;
|
||||
usb_device.write = usbwrite;
|
||||
|
||||
return &usb_device;
|
||||
}
|
8
wii/libogc/libdb/geckousb.h
Normal file
8
wii/libogc/libdb/geckousb.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef __GECKOUSB_H___
|
||||
#define __GECKOUSB_H___
|
||||
|
||||
#include "debug_if.h"
|
||||
|
||||
struct dbginterface* usb_init(s32 channel);
|
||||
|
||||
#endif
|
466
wii/libogc/libdb/tcpip.c
Normal file
466
wii/libogc/libdb/tcpip.c
Normal file
@ -0,0 +1,466 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "asm.h"
|
||||
#include "processor.h"
|
||||
|
||||
#include "uIP/bba.h"
|
||||
#include "uIP/memr.h"
|
||||
#include "uIP/memb.h"
|
||||
#include "uIP/uip_ip.h"
|
||||
#include "uIP/uip_arp.h"
|
||||
#include "uIP/uip_tcp.h"
|
||||
#include "uIP/uip_pbuf.h"
|
||||
#include "uIP/uip_netif.h"
|
||||
|
||||
#include "tcpip.h"
|
||||
#include "debug_if.h"
|
||||
|
||||
#if UIP_LOGGING == 1
|
||||
#include <stdio.h>
|
||||
#define UIP_LOG(m) uip_log(__FILE__,__LINE__,m)
|
||||
#else
|
||||
#define UIP_LOG(m)
|
||||
#endif /* UIP_LOGGING == 1 */
|
||||
|
||||
#if UIP_STATISTICS == 1
|
||||
struct uip_stats uip_stat;
|
||||
#define UIP_STAT(s) s
|
||||
#else
|
||||
#define UIP_STAT(s)
|
||||
#endif /* UIP_STATISTICS == 1 */
|
||||
|
||||
const char *tcp_localip __attribute__ ((weak)) = "";
|
||||
const char *tcp_netmask __attribute__ ((weak)) = "";
|
||||
const char *tcp_gateway __attribute__ ((weak)) = "";
|
||||
|
||||
struct tcpip_sock {
|
||||
struct tcpip_sock *next;
|
||||
struct uip_tcp_pcb *pcb;
|
||||
struct uip_pbuf *lastdata;
|
||||
s32 lastoffset,recvevt,sendevt,flags;
|
||||
s32 err,socket;
|
||||
} tcpip_socks[UIP_TCPIP_SOCKS];
|
||||
|
||||
static s64 tcpip_time = 0;
|
||||
static s32 listensock = -1;
|
||||
static struct uip_netif netif;
|
||||
static struct dbginterface netif_device;
|
||||
static struct tcpip_sock *tcpip_accepted_sockets = NULL;
|
||||
|
||||
extern s64 gettime();
|
||||
extern u32 diff_msec(s64 start,s64 end);
|
||||
|
||||
static s32_t tcpip_allocsocket(struct uip_tcp_pcb *pcb)
|
||||
{
|
||||
s32_t i;
|
||||
|
||||
for(i=0;i<UIP_TCPIP_SOCKS;i++) {
|
||||
if(tcpip_socks[i].pcb==NULL) {
|
||||
tcpip_socks[i].pcb = pcb;
|
||||
tcpip_socks[i].lastdata = NULL;
|
||||
tcpip_socks[i].lastoffset = 0;
|
||||
tcpip_socks[i].recvevt = 0;
|
||||
tcpip_socks[i].sendevt = 1;
|
||||
tcpip_socks[i].flags = 0;
|
||||
tcpip_socks[i].socket = i;
|
||||
tcpip_socks[i].err = UIP_ERR_OK;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static struct tcpip_sock* tcpip_getsocket(s32_t s)
|
||||
{
|
||||
struct tcpip_sock *sock;
|
||||
|
||||
if(s<0 || s>=UIP_TCPIP_SOCKS) return NULL;
|
||||
|
||||
sock = &tcpip_socks[s];
|
||||
if(!sock->pcb) return NULL;
|
||||
|
||||
return sock;
|
||||
}
|
||||
|
||||
//device callbacks
|
||||
static int opentcpip(struct dbginterface *device)
|
||||
{
|
||||
if(listensock>=0 && (device->fhndl<0 ))
|
||||
device->fhndl = tcpip_accept(listensock);
|
||||
|
||||
if(device->fhndl<0)
|
||||
return -1;
|
||||
else
|
||||
tcpip_starttimer(device->fhndl);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int closetcpip(struct dbginterface *device)
|
||||
{
|
||||
tcpip_stoptimer(device->fhndl);
|
||||
tcpip_close(device->fhndl);
|
||||
device->fhndl = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int waittcpip(struct dbginterface *device)
|
||||
{
|
||||
tcpip_stoptimer(device->fhndl);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int readtcpip(struct dbginterface *device,void *buffer,int size)
|
||||
{
|
||||
if(device->fhndl>=0)
|
||||
return tcpip_read(device->fhndl,buffer,size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int writetcpip(struct dbginterface *device,const void *buffer,int size)
|
||||
{
|
||||
if(device->fhndl>=0)
|
||||
return tcpip_write(device->fhndl,buffer,size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void tcpip_err(void *arg,s8_t err)
|
||||
{
|
||||
// printf("tcpip_err: err_code(%d)\n",err);
|
||||
}
|
||||
|
||||
static s8_t tcpip_poll(void *arg,struct uip_tcp_pcb *pcb)
|
||||
{
|
||||
UIP_LOG("tcpip_poll()");
|
||||
return UIP_ERR_OK;
|
||||
}
|
||||
|
||||
static s8_t tcpip_sent(void *arg,struct uip_tcp_pcb *pcb,u16_t space)
|
||||
{
|
||||
// printf("tcpip_sent(%d)\n",space);
|
||||
return UIP_ERR_OK;
|
||||
}
|
||||
|
||||
//static u32 qcnt = 0;
|
||||
|
||||
static s8_t tcpip_recved(void *arg,struct uip_tcp_pcb *pcb,struct uip_pbuf *p,s8_t err)
|
||||
{
|
||||
u16_t len;
|
||||
struct tcpip_sock *sock = (struct tcpip_sock*)arg;
|
||||
|
||||
//printf("tcpip_recved(%s (%d/%d))\n",(u8_t*)p->payload,p->len,p->tot_len);
|
||||
if(!sock) {
|
||||
uip_pbuf_free(p);
|
||||
return UIP_ERR_VAL;
|
||||
}
|
||||
|
||||
if(p) {
|
||||
len = p->tot_len;
|
||||
if(sock->lastdata==NULL) {
|
||||
sock->lastdata = p;
|
||||
} else {
|
||||
/*
|
||||
qcnt++;
|
||||
printf("tcpip_recved(queuing %d)\n",qcnt);
|
||||
*/
|
||||
uip_pbuf_queue(sock->lastdata,p);
|
||||
}
|
||||
} else
|
||||
len = 1;
|
||||
|
||||
uip_tcp_recved(pcb,len);
|
||||
return UIP_ERR_OK;
|
||||
}
|
||||
|
||||
|
||||
static s8_t tcpip_accept_func(void *arg,struct uip_tcp_pcb *newpcb,s8_t err)
|
||||
{
|
||||
s32_t s;
|
||||
struct tcpip_sock *ptr,*newsock = NULL;
|
||||
struct tcpip_sock *sock = (struct tcpip_sock*)arg;
|
||||
|
||||
UIP_LOG("tcpip_accept_func()");
|
||||
if(!sock) return UIP_ERR_ABRT;
|
||||
|
||||
s = tcpip_allocsocket(newpcb);
|
||||
if(s<0) {
|
||||
uip_tcp_close(newpcb);
|
||||
return UIP_ERR_ABRT;
|
||||
}
|
||||
|
||||
newsock = tcpip_getsocket(s);
|
||||
newsock->pcb->flags |= UIP_TF_NODELAY;
|
||||
|
||||
ptr = tcpip_accepted_sockets;
|
||||
while(ptr && ptr->next) ptr = ptr->next;
|
||||
if(!ptr) tcpip_accepted_sockets = newsock;
|
||||
else ptr->next = newsock;
|
||||
|
||||
uip_tcp_arg(newpcb,newsock);
|
||||
uip_tcp_recv(newpcb,tcpip_recved);
|
||||
uip_tcp_sent(newpcb,tcpip_sent);
|
||||
uip_tcp_err(newpcb,tcpip_err);
|
||||
uip_tcp_poll(newpcb,tcpip_poll,4);
|
||||
|
||||
return UIP_ERR_OK;
|
||||
}
|
||||
|
||||
static void __tcpip_poll()
|
||||
{
|
||||
u32 diff;
|
||||
s64 now;
|
||||
|
||||
if(uip_netif_default==NULL) return;
|
||||
|
||||
uip_bba_poll(uip_netif_default);
|
||||
|
||||
if(tcpip_time && (uip_tcp_active_pcbs || uip_tcp_tw_pcbs)) {
|
||||
now = gettime();
|
||||
diff = diff_msec(tcpip_time,now);
|
||||
if(diff>=UIP_TCP_TMR_INTERVAL) {
|
||||
uip_tcp_tmr();
|
||||
tcpip_time = gettime();
|
||||
}
|
||||
} else
|
||||
tcpip_time = 0;
|
||||
}
|
||||
|
||||
void tcpip_tmr_needed()
|
||||
{
|
||||
if(!tcpip_time && (uip_tcp_active_pcbs || uip_tcp_tw_pcbs)) {
|
||||
tcpip_time = gettime();
|
||||
}
|
||||
}
|
||||
|
||||
struct dbginterface* tcpip_init(struct uip_ip_addr *localip,struct uip_ip_addr *netmask,struct uip_ip_addr *gateway,u16 port)
|
||||
{
|
||||
uipdev_s hbba;
|
||||
struct uip_netif *pnet ;
|
||||
struct sockaddr_in name;
|
||||
socklen_t namelen = sizeof(struct sockaddr);
|
||||
|
||||
memr_init();
|
||||
uip_ipinit();
|
||||
uip_pbuf_init();
|
||||
uip_netif_init();
|
||||
uip_tcp_init();
|
||||
|
||||
UIP_MEMSET(tcpip_socks,0,(UIP_TCPIP_SOCKS*sizeof(struct tcpip_sock)));
|
||||
|
||||
hbba = uip_bba_create(&netif);
|
||||
pnet = uip_netif_add(&netif,localip,netmask,gateway,hbba,uip_bba_init,uip_ipinput);
|
||||
if(pnet) {
|
||||
uip_netif_setdefault(pnet);
|
||||
|
||||
listensock = tcpip_socket();
|
||||
if(listensock<0) return NULL;
|
||||
|
||||
name.sin_addr.s_addr = INADDR_ANY;
|
||||
name.sin_port = htons(port);
|
||||
name.sin_family = AF_INET;
|
||||
|
||||
if(tcpip_bind(listensock,(struct sockaddr*)&name,&namelen)<0){
|
||||
tcpip_close(listensock);
|
||||
listensock = -1;
|
||||
return NULL;
|
||||
}
|
||||
if(tcpip_listen(listensock,1)<0) {
|
||||
tcpip_close(listensock);
|
||||
listensock = -1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
netif_device.fhndl = -1;
|
||||
netif_device.wait = waittcpip;
|
||||
netif_device.open = opentcpip;
|
||||
netif_device.close = closetcpip;
|
||||
netif_device.read = readtcpip;
|
||||
netif_device.write = writetcpip;
|
||||
|
||||
return &netif_device;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
s32_t tcpip_socket()
|
||||
{
|
||||
s32_t s;
|
||||
struct tcpip_sock *sock;
|
||||
struct uip_tcp_pcb *pcb;
|
||||
|
||||
pcb = uip_tcp_new();
|
||||
if(!pcb) return -1;
|
||||
|
||||
s = tcpip_allocsocket(pcb);
|
||||
if(s<0) {
|
||||
uip_tcp_close(pcb);
|
||||
return -1;
|
||||
}
|
||||
|
||||
sock = tcpip_getsocket(s);
|
||||
uip_tcp_arg(pcb,sock);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
s32_t tcpip_bind(s32_t s,struct sockaddr *name,socklen_t *namelen)
|
||||
{
|
||||
struct tcpip_sock *sock;
|
||||
struct uip_ip_addr local_ip;
|
||||
u16_t local_port;
|
||||
s8_t err;
|
||||
|
||||
sock = tcpip_getsocket(s);
|
||||
if(!sock) return -1;
|
||||
|
||||
local_ip.addr = ((struct sockaddr_in*)name)->sin_addr.s_addr;
|
||||
local_port = ((struct sockaddr_in*)name)->sin_port;
|
||||
|
||||
err = uip_tcp_bind(sock->pcb,&local_ip,local_port);
|
||||
|
||||
return (s32_t)err;
|
||||
}
|
||||
|
||||
s32_t tcpip_listen(s32_t s,u32_t backlog)
|
||||
{
|
||||
struct tcpip_sock *sock;
|
||||
|
||||
sock = tcpip_getsocket(s);
|
||||
if(!sock) return -1;
|
||||
|
||||
sock->pcb = uip_tcp_listen(sock->pcb);
|
||||
if(sock->pcb==NULL) return -1;
|
||||
|
||||
uip_tcp_accept(sock->pcb,tcpip_accept_func);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32_t tcpip_accept(s32_t s)
|
||||
{
|
||||
s32_t newsock = -1;
|
||||
struct tcpip_sock *sock;
|
||||
|
||||
sock = tcpip_getsocket(s);
|
||||
if(sock==NULL) return -1;
|
||||
|
||||
do {
|
||||
__tcpip_poll();
|
||||
} while(!tcpip_accepted_sockets);
|
||||
|
||||
newsock = tcpip_accepted_sockets->socket;
|
||||
tcpip_accepted_sockets = tcpip_accepted_sockets->next;
|
||||
|
||||
return newsock;
|
||||
}
|
||||
|
||||
s32_t tcpip_read(s32_t s,void *buffer,u32_t len)
|
||||
{
|
||||
u32_t off,copy;
|
||||
u8_t *ptr;
|
||||
struct uip_pbuf *p;
|
||||
struct tcpip_sock *sock;
|
||||
|
||||
sock = tcpip_getsocket(s);
|
||||
if(!sock) return -1;
|
||||
|
||||
do {
|
||||
__tcpip_poll();
|
||||
} while(sock->lastdata==NULL);
|
||||
|
||||
if(sock->lastdata) {
|
||||
off = 0;
|
||||
ptr = buffer;
|
||||
while(len>0 && sock->lastdata) {
|
||||
p = sock->lastdata;
|
||||
|
||||
if(len>p->len-sock->lastoffset) copy = (p->len-sock->lastoffset);
|
||||
else copy = len;
|
||||
|
||||
UIP_MEMCPY(ptr+off,(u8_t*)p->payload+sock->lastoffset,copy);
|
||||
|
||||
off += copy;
|
||||
len -= copy;
|
||||
sock->lastoffset += copy;
|
||||
|
||||
if(sock->lastoffset>=p->len) {
|
||||
sock->lastoffset = 0;
|
||||
sock->lastdata = uip_pbuf_dequeue(p);
|
||||
uip_pbuf_free(p);
|
||||
/*
|
||||
if(qcnt>0) {
|
||||
printf("tcpip_read(dequeuing %d)\n",--qcnt);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
return off;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
s32_t tcpip_write(s32_t s,const void *buffer,u32_t len)
|
||||
{
|
||||
s8_t err;
|
||||
u16_t snd_buf,copy;
|
||||
struct tcpip_sock *sock;
|
||||
|
||||
sock = tcpip_getsocket(s);
|
||||
if(!sock) return -1;
|
||||
|
||||
// printf("tcpip_write()\n");
|
||||
while(len>0) {
|
||||
do {
|
||||
__tcpip_poll();
|
||||
} while((snd_buf=uip_tcp_sndbuf(sock->pcb))==0);
|
||||
|
||||
if(len>snd_buf) copy = snd_buf;
|
||||
else copy = len;
|
||||
|
||||
err = uip_tcp_write(sock->pcb,buffer,copy,1);
|
||||
if(err==UIP_ERR_OK && (!sock->pcb->unacked || sock->pcb->flags&UIP_TF_NODELAY || sock->pcb->snd_queuelen>1))
|
||||
uip_tcpoutput(sock->pcb);
|
||||
|
||||
buffer = buffer+copy;
|
||||
len -= copy;
|
||||
}
|
||||
return UIP_ERR_OK;
|
||||
}
|
||||
|
||||
void tcpip_close(s32_t s)
|
||||
{
|
||||
struct tcpip_sock *sock;
|
||||
|
||||
sock = tcpip_getsocket(s);
|
||||
if(sock==NULL) return;
|
||||
|
||||
uip_tcp_close(sock->pcb);
|
||||
sock->pcb = NULL;
|
||||
}
|
||||
|
||||
// does basically only stop the tcpip timer
|
||||
void tcpip_stoptimer(s32_t s)
|
||||
{
|
||||
struct tcpip_sock *sock;
|
||||
|
||||
sock = tcpip_getsocket(s);
|
||||
if(!sock) return;
|
||||
|
||||
if(tcpip_time && sock->pcb && (uip_tcp_active_pcbs || uip_tcp_tw_pcbs)) tcpip_time = 0;
|
||||
}
|
||||
|
||||
// does basically only restart the tcpip timer
|
||||
void tcpip_starttimer(s32_t s)
|
||||
{
|
||||
struct tcpip_sock *sock;
|
||||
|
||||
sock = tcpip_getsocket(s);
|
||||
if(!sock) return;
|
||||
|
||||
if(tcpip_time==0 && sock->pcb && (uip_tcp_active_pcbs || uip_tcp_tw_pcbs)) tcpip_time = gettime();
|
||||
}
|
||||
|
53
wii/libogc/libdb/tcpip.h
Normal file
53
wii/libogc/libdb/tcpip.h
Normal file
@ -0,0 +1,53 @@
|
||||
#ifndef __TCPIP_H__
|
||||
#define __TCPIP_H__
|
||||
|
||||
#include "uIP/uip.h"
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define AF_UNSPEC 0
|
||||
#define AF_INET 2
|
||||
#define PF_INET AF_INET
|
||||
#define PF_UNSPEC AF_UNSPEC
|
||||
|
||||
#define INADDR_ANY 0
|
||||
#define INADDR_BROADCAST 0xffffffff
|
||||
|
||||
#ifndef socklen_t
|
||||
#define socklen_t u32_t
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_IN_ADDR
|
||||
#define HAVE_IN_ADDR
|
||||
struct in_addr {
|
||||
u32 s_addr;
|
||||
};
|
||||
#endif
|
||||
|
||||
struct sockaddr_in {
|
||||
u8 sin_len;
|
||||
u8 sin_family;
|
||||
u16 sin_port;
|
||||
struct in_addr sin_addr;
|
||||
s8 sin_zero[8];
|
||||
};
|
||||
|
||||
struct sockaddr {
|
||||
u8 sa_len;
|
||||
u8 sa_family;
|
||||
s8 sa_data[14];
|
||||
};
|
||||
|
||||
struct dbginterface* tcpip_init(struct uip_ip_addr *localip,struct uip_ip_addr *netmask,struct uip_ip_addr *gateway,u16 port);
|
||||
|
||||
void tcpip_close(s32_t s);
|
||||
void tcpip_starttimer(s32_t s);
|
||||
void tcpip_stoptimer(s32_t s);
|
||||
s32_t tcpip_socket();
|
||||
s32_t tcpip_listen(s32_t s,u32_t backlog);
|
||||
s32_t tcpip_bind(s32_t s,struct sockaddr *name,socklen_t *namelen);
|
||||
s32_t tcpip_accept(s32_t s);
|
||||
s32_t tcpip_read(s32_t s,void *buffer,u32_t len);
|
||||
s32_t tcpip_write(s32_t s,const void *buffer,u32_t len);
|
||||
|
||||
#endif
|
835
wii/libogc/libdb/uIP/bba.c
Normal file
835
wii/libogc/libdb/uIP/bba.c
Normal file
@ -0,0 +1,835 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "asm.h"
|
||||
#include "processor.h"
|
||||
#include "exi.h"
|
||||
#include "cache.h"
|
||||
#include "bba.h"
|
||||
#include "uip_pbuf.h"
|
||||
#include "uip_netif.h"
|
||||
#include "uip_arp.h"
|
||||
|
||||
#define IFNAME0 'e'
|
||||
#define IFNAME1 't'
|
||||
|
||||
#define BBA_MINPKTSIZE 60
|
||||
|
||||
#define BBA_CID 0x04020200
|
||||
|
||||
#define BBA_CMD_IRMASKALL 0x00
|
||||
#define BBA_CMD_IRMASKNONE 0xF8
|
||||
|
||||
#define BBA_NCRA 0x00 /* Network Control Register A, RW */
|
||||
#define BBA_NCRA_RESET (1<<0) /* RESET */
|
||||
#define BBA_NCRA_ST0 (1<<1) /* ST0, Start transmit command/status */
|
||||
#define BBA_NCRA_ST1 (1<<2) /* ST1, " */
|
||||
#define BBA_NCRA_SR (1<<3) /* SR, Start Receive */
|
||||
|
||||
#define BBA_NCRB 0x01 /* Network Control Register B, RW */
|
||||
#define BBA_NCRB_PR (1<<0) /* PR, Promiscuous Mode */
|
||||
#define BBA_NCRB_CA (1<<1) /* CA, Capture Effect Mode */
|
||||
#define BBA_NCRB_PM (1<<2) /* PM, Pass Multicast */
|
||||
#define BBA_NCRB_PB (1<<3) /* PB, Pass Bad Frame */
|
||||
#define BBA_NCRB_AB (1<<4) /* AB, Accept Broadcast */
|
||||
#define BBA_NCRB_HBD (1<<5) /* HBD, reserved */
|
||||
#define BBA_NCRB_RXINTC0 (1<<6) /* RXINTC, Receive Interrupt Counter */
|
||||
#define BBA_NCRB_RXINTC1 (1<<7) /* " */
|
||||
#define BBA_NCRB_1_PACKET_PER_INT (0<<6) /* 0 0 */
|
||||
#define BBA_NCRB_2_PACKETS_PER_INT (1<<6) /* 0 1 */
|
||||
#define BBA_NCRB_4_PACKETS_PER_INT (2<<6) /* 1 0 */
|
||||
#define BBA_NCRB_8_PACKETS_PER_INT (3<<6) /* 1 1 */
|
||||
|
||||
#define BBA_LTPS 0x04 /* Last Transmitted Packet Status, RO */
|
||||
#define BBA_LRPS 0x05 /* Last Received Packet Status, RO */
|
||||
|
||||
#define BBA_IMR 0x08 /* Interrupt Mask Register, RW, 00h */
|
||||
#define BBA_IMR_FRAGIM (1<<0) /* FRAGIM, Fragment Counter Int Mask */
|
||||
#define BBA_IMR_RIM (1<<1) /* RIM, Receive Interrupt Mask */
|
||||
#define BBA_IMR_TIM (1<<2) /* TIM, Transmit Interrupt Mask */
|
||||
#define BBA_IMR_REIM (1<<3) /* REIM, Receive Error Interrupt Mask */
|
||||
#define BBA_IMR_TEIM (1<<4) /* TEIM, Transmit Error Interrupt Mask */
|
||||
#define BBA_IMR_FIFOEIM (1<<5) /* FIFOEIM, FIFO Error Interrupt Mask */
|
||||
#define BBA_IMR_BUSEIM (1<<6) /* BUSEIM, BUS Error Interrupt Mask */
|
||||
#define BBA_IMR_RBFIM (1<<7) /* RBFIM, RX Buffer Full Interrupt Mask */
|
||||
|
||||
#define BBA_IR 0x09 /* Interrupt Register, RW, 00h */
|
||||
#define BBA_IR_FRAGI (1<<0) /* FRAGI, Fragment Counter Interrupt */
|
||||
#define BBA_IR_RI (1<<1) /* RI, Receive Interrupt */
|
||||
#define BBA_IR_TI (1<<2) /* TI, Transmit Interrupt */
|
||||
#define BBA_IR_REI (1<<3) /* REI, Receive Error Interrupt */
|
||||
#define BBA_IR_TEI (1<<4) /* TEI, Transmit Error Interrupt */
|
||||
#define BBA_IR_FIFOEI (1<<5) /* FIFOEI, FIFO Error Interrupt */
|
||||
#define BBA_IR_BUSEI (1<<6) /* BUSEI, BUS Error Interrupt */
|
||||
#define BBA_IR_RBFI (1<<7) /* RBFI, RX Buffer Full Interrupt */
|
||||
|
||||
#define BBA_BP 0x0a/*+0x0b*/ /* Boundary Page Pointer Register */
|
||||
#define BBA_TLBP 0x0c/*+0x0d*/ /* TX Low Boundary Page Pointer Register */
|
||||
#define BBA_TWP 0x0e/*+0x0f*/ /* Transmit Buffer Write Page Pointer Register */
|
||||
#define BBA_TRP 0x12/*+0x13*/ /* Transmit Buffer Read Page Pointer Register */
|
||||
#define BBA_RWP 0x16/*+0x17*/ /* Receive Buffer Write Page Pointer Register */
|
||||
#define BBA_RRP 0x18/*+0x19*/ /* Receive Buffer Read Page Pointer Register */
|
||||
#define BBA_RHBP 0x1a/*+0x1b*/ /* Receive High Boundary Page Pointer Register */
|
||||
|
||||
#define BBA_RXINTT 0x14/*+0x15*/ /* Receive Interrupt Timer Register */
|
||||
|
||||
#define BBA_NAFR_PAR0 0x20 /* Physical Address Register Byte 0 */
|
||||
#define BBA_NAFR_PAR1 0x21 /* Physical Address Register Byte 1 */
|
||||
#define BBA_NAFR_PAR2 0x22 /* Physical Address Register Byte 2 */
|
||||
#define BBA_NAFR_PAR3 0x23 /* Physical Address Register Byte 3 */
|
||||
#define BBA_NAFR_PAR4 0x24 /* Physical Address Register Byte 4 */
|
||||
#define BBA_NAFR_PAR5 0x25 /* Physical Address Register Byte 5 */
|
||||
|
||||
#define BBA_NWAYC 0x30 /* NWAY Configuration Register, RW, 84h */
|
||||
#define BBA_NWAYC_FD (1<<0) /* FD, Full Duplex Mode */
|
||||
#define BBA_NWAYC_PS100 (1<<1) /* PS100/10, Port Select 100/10 */
|
||||
#define BBA_NWAYC_ANE (1<<2) /* ANE, Autonegotiation Enable */
|
||||
#define BBA_NWAYC_ANS_RA (1<<3) /* ANS, Restart Autonegotiation */
|
||||
#define BBA_NWAYC_LTE (1<<7) /* LTE, Link Test Enable */
|
||||
|
||||
#define BBA_NWAYS 0x31
|
||||
#define BBA_NWAYS_LS10 (1<<0)
|
||||
#define BBA_NWAYS_LS100 (1<<1)
|
||||
#define BBA_NWAYS_LPNWAY (1<<2)
|
||||
#define BBA_NWAYS_ANCLPT (1<<3)
|
||||
#define BBA_NWAYS_100TXF (1<<4)
|
||||
#define BBA_NWAYS_100TXH (1<<5)
|
||||
#define BBA_NWAYS_10TXF (1<<6)
|
||||
#define BBA_NWAYS_10TXH (1<<7)
|
||||
|
||||
#define BBA_GCA 0x32 /* GMAC Configuration A Register, RW, 00h */
|
||||
#define BBA_GCA_ARXERRB (1<<3) /* ARXERRB, Accept RX packet with error */
|
||||
|
||||
#define BBA_MISC 0x3d /* MISC Control Register 1, RW, 3ch */
|
||||
#define BBA_MISC_BURSTDMA (1<<0)
|
||||
#define BBA_MISC_DISLDMA (1<<1)
|
||||
|
||||
#define BBA_TXFIFOCNT 0x3e/*0x3f*/ /* Transmit FIFO Counter Register */
|
||||
#define BBA_WRTXFIFOD 0x48/*-0x4b*/ /* Write TX FIFO Data Port Register */
|
||||
|
||||
#define BBA_MISC2 0x50 /* MISC Control Register 2, RW, 00h */
|
||||
#define BBA_MISC2_HBRLEN0 (1<<0) /* HBRLEN, Host Burst Read Length */
|
||||
#define BBA_MISC2_HBRLEN1 (1<<1) /* " */
|
||||
#define BBA_MISC2_RUNTSIZE (1<<2) /* " */
|
||||
#define BBA_MISC2_DREQBCTRL (1<<3) /* " */
|
||||
#define BBA_MISC2_RINTSEL (1<<4) /* " */
|
||||
#define BBA_MISC2_ITPSEL (3<<5) /* " */
|
||||
#define BBA_MISC2_AUTORCVR (1<<7) /* Auto RX Full Recovery */
|
||||
|
||||
#define BBA_RX_STATUS_BF (1<<0)
|
||||
#define BBA_RX_STATUS_CRC (1<<1)
|
||||
#define BBA_RX_STATUS_FAE (1<<2)
|
||||
#define BBA_RX_STATUS_FO (1<<3)
|
||||
#define BBA_RX_STATUS_RW (1<<4)
|
||||
#define BBA_RX_STATUS_MF (1<<5)
|
||||
#define BBA_RX_STATUS_RF (1<<6)
|
||||
#define BBA_RX_STATUS_RERR (1<<7)
|
||||
|
||||
#define BBA_TX_STATUS_CC0 (1<<0)
|
||||
#define BBA_TX_STATUS_CC1 (1<<1)
|
||||
#define BBA_TX_STATUS_CC2 (1<<2)
|
||||
#define BBA_TX_STATUS_CC3 (1<<3)
|
||||
#define BBA_TX_STATUS_CCMASK (0x0f)
|
||||
#define BBA_TX_STATUS_CRSLOST (1<<4)
|
||||
#define BBA_TX_STATUS_UF (1<<5)
|
||||
#define BBA_TX_STATUS_OWC (1<<6)
|
||||
#define BBA_TX_STATUS_OWN (1<<7)
|
||||
#define BBA_TX_STATUS_TERR (1<<7)
|
||||
|
||||
#define BBA_TX_MAX_PACKET_SIZE 1518 /* 14+1500+4 */
|
||||
#define BBA_RX_MAX_PACKET_SIZE 1536 /* 6 pages * 256 bytes */
|
||||
|
||||
#define BBA_INIT_TLBP 0x00
|
||||
#define BBA_INIT_BP 0x01
|
||||
#define BBA_INIT_RHBP 0x0f
|
||||
#define BBA_INIT_RWP BBA_INIT_BP
|
||||
#define BBA_INIT_RRP BBA_INIT_BP
|
||||
|
||||
#define BBA_NAPI_WEIGHT 16
|
||||
|
||||
#define RX_BUFFERS 16
|
||||
|
||||
#define cpu_to_be16(x) (x)
|
||||
#define cpu_to_be32(x) (x)
|
||||
static inline u16 cpu_to_le16(u16 x) { return (x<<8) | (x>>8);}
|
||||
static inline u32 cpu_to_le32(u32 x) { return((x>>24) | ((x>>8)&0xff00) | ((x<<8)&0xff0000) | (x<<24));}
|
||||
|
||||
#define cpu_to_le16p(addr) (cpu_to_le16(*(addr)))
|
||||
#define cpu_to_le32p(addr) (cpu_to_le32(*(addr)))
|
||||
#define cpu_to_be16p(addr) (cpu_to_be16(*(addr)))
|
||||
#define cpu_to_be32p(addr) (cpu_to_be32(*(addr)))
|
||||
|
||||
static inline void cpu_to_le16s(u16 *a) {*a = cpu_to_le16(*a);}
|
||||
static inline void cpu_to_le32s(u32 *a) {*a = cpu_to_le32(*a);}
|
||||
static inline void cpu_to_be16s(u16 *a) {*a = cpu_to_be16(*a);}
|
||||
static inline void cpu_to_be32s(u32 *a) {*a = cpu_to_be32(*a);}
|
||||
|
||||
#define le16_to_cpup(x) cpu_to_le16p(x)
|
||||
#define le32_to_cpup(x) cpu_to_le32p(x)
|
||||
#define be16_to_cpup(x) cpu_to_be16p(x)
|
||||
#define be32_to_cpup(x) cpu_to_be32p(x)
|
||||
|
||||
#define le16_to_cpus(x) cpu_to_le16s(x)
|
||||
#define le32_to_cpus(x) cpu_to_le32s(x)
|
||||
#define be16_to_cpus(x) cpu_to_be16s(x)
|
||||
#define be32_to_cpus(x) cpu_to_be32s(x)
|
||||
|
||||
struct bba_priv {
|
||||
u8 revid;
|
||||
u16 devid;
|
||||
u8 acstart;
|
||||
s8_t state;
|
||||
struct uip_eth_addr *ethaddr;
|
||||
};
|
||||
|
||||
#define X(a,b) b,a
|
||||
struct bba_descr {
|
||||
u32 X(X(next_packet_ptr:12, packet_len:12), status:8);
|
||||
} __attribute((packed));
|
||||
|
||||
#define _SHIFTL(v, s, w) \
|
||||
((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))
|
||||
#define _SHIFTR(v, s, w) \
|
||||
((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))
|
||||
|
||||
/* new functions */
|
||||
#define bba_select() EXI_Select(EXI_CHANNEL_0,EXI_DEVICE_2,EXI_SPEED32MHZ)
|
||||
#define bba_deselect() EXI_Deselect(EXI_CHANNEL_0)
|
||||
|
||||
#define bba_in12(reg) ((bba_in8(reg)&0xff)|((bba_in8((reg)+1)&0x0f)<<8))
|
||||
#define bba_out12(reg,val) do { \
|
||||
bba_out8((reg),(val)&0xff); \
|
||||
bba_out8((reg)+1,((val)&0x0f00)>>8); \
|
||||
} while(0)
|
||||
|
||||
#if UIP_LOGGING == 1
|
||||
#include <stdio.h>
|
||||
#define UIP_LOG(m) uip_log(__FILE__,__LINE__,m)
|
||||
#else
|
||||
#define UIP_LOG(m)
|
||||
#endif /* UIP_LOGGING == 1 */
|
||||
|
||||
#if UIP_STATISTICS == 1
|
||||
struct uip_stats uip_stat;
|
||||
#define UIP_STAT(s) s
|
||||
#else
|
||||
#define UIP_STAT(s)
|
||||
#endif /* UIP_STATISTICS == 1 */
|
||||
|
||||
static s64 bba_arp_tmr = 0;
|
||||
|
||||
static struct uip_pbuf *bba_recv_pbufs = NULL;
|
||||
static struct uip_netif *bba_netif = NULL;
|
||||
static struct bba_priv bba_device;
|
||||
static struct bba_descr cur_descr;
|
||||
|
||||
static void bba_cmd_ins(u32 reg,void *val,u32 len);
|
||||
static void bba_cmd_outs(u32 reg,void *val,u32 len);
|
||||
static void bba_ins(u32 reg,void *val,u32 len);
|
||||
static void bba_outs(u32 reg,void *val,u32 len);
|
||||
|
||||
static void bba_devpoll(u16 *pstatus);
|
||||
|
||||
extern void udelay(int us);
|
||||
extern u32 diff_msec(long long start,long long end);
|
||||
extern u32 diff_usec(long long start,long long end);
|
||||
extern long long gettime();
|
||||
|
||||
static __inline__ void bba_cmd_insnosel(u32 reg,void *val,u32 len)
|
||||
{
|
||||
u16 req;
|
||||
req = reg<<8;
|
||||
EXI_Imm(EXI_CHANNEL_0,&req,sizeof(req),EXI_WRITE,NULL);
|
||||
EXI_Sync(EXI_CHANNEL_0);
|
||||
EXI_ImmEx(EXI_CHANNEL_0,val,len,EXI_READ);
|
||||
}
|
||||
|
||||
static void bba_cmd_ins(u32 reg,void *val,u32 len)
|
||||
{
|
||||
bba_select();
|
||||
bba_cmd_insnosel(reg,val,len);
|
||||
bba_deselect();
|
||||
}
|
||||
|
||||
static __inline__ void bba_cmd_outsnosel(u32 reg,void *val,u32 len)
|
||||
{
|
||||
u16 req;
|
||||
req = (reg<<8)|0x4000;
|
||||
EXI_Imm(EXI_CHANNEL_0,&req,sizeof(req),EXI_WRITE,NULL);
|
||||
EXI_Sync(EXI_CHANNEL_0);
|
||||
EXI_ImmEx(EXI_CHANNEL_0,val,len,EXI_WRITE);
|
||||
}
|
||||
|
||||
static void bba_cmd_outs(u32 reg,void *val,u32 len)
|
||||
{
|
||||
bba_select();
|
||||
bba_cmd_outsnosel(reg,val,len);
|
||||
bba_deselect();
|
||||
}
|
||||
|
||||
static inline u8 bba_cmd_in8(u32 reg)
|
||||
{
|
||||
u8 val;
|
||||
bba_cmd_ins(reg,&val,sizeof(val));
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline u8 bba_cmd_in8_slow(u32 reg)
|
||||
{
|
||||
u8 val;
|
||||
bba_select();
|
||||
bba_cmd_insnosel(reg,&val,sizeof(val));
|
||||
udelay(200); //usleep doesn't work on this amount, decrementer is based on 10ms, wait is 200us
|
||||
bba_deselect();
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline void bba_cmd_out8(u32 reg,u8 val)
|
||||
{
|
||||
bba_cmd_outs(reg,&val,sizeof(val));
|
||||
}
|
||||
|
||||
static inline u8 bba_in8(u32 reg)
|
||||
{
|
||||
u8 val;
|
||||
bba_ins(reg,&val,sizeof(val));
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline void bba_out8(u32 reg,u8 val)
|
||||
{
|
||||
bba_outs(reg,&val,sizeof(val));
|
||||
}
|
||||
|
||||
static inline void bba_insnosel(u32 reg,void *val,u32 len)
|
||||
{
|
||||
u32 req;
|
||||
req = (reg<<8)|0x80000000;
|
||||
EXI_Imm(EXI_CHANNEL_0,&req,sizeof(req),EXI_WRITE,NULL);
|
||||
EXI_Sync(EXI_CHANNEL_0);
|
||||
EXI_ImmEx(EXI_CHANNEL_0,val,len,EXI_READ);
|
||||
}
|
||||
|
||||
static void bba_ins(u32 reg,void *val,u32 len)
|
||||
{
|
||||
bba_select();
|
||||
bba_insnosel(reg,val,len);
|
||||
bba_deselect();
|
||||
}
|
||||
|
||||
static inline void bba_outsnoselect(u32 reg,void *val,u32 len)
|
||||
{
|
||||
u32 req;
|
||||
req = (reg<<8)|0xC0000000;
|
||||
EXI_Imm(EXI_CHANNEL_0,&req,sizeof(req),EXI_WRITE,NULL);
|
||||
EXI_Sync(EXI_CHANNEL_0);
|
||||
EXI_ImmEx(EXI_CHANNEL_0,val,len,EXI_WRITE);
|
||||
}
|
||||
|
||||
static void bba_outs(u32 reg,void *val,u32 len)
|
||||
{
|
||||
bba_select();
|
||||
bba_outsnoselect(reg,val,len);
|
||||
bba_deselect();
|
||||
}
|
||||
|
||||
static inline void bba_insregister(u32 reg)
|
||||
{
|
||||
u32 req;
|
||||
req = (reg<<8)|0x80000000;
|
||||
EXI_Imm(EXI_CHANNEL_0,&req,sizeof(req),EXI_WRITE,NULL);
|
||||
EXI_Sync(EXI_CHANNEL_0);
|
||||
}
|
||||
|
||||
static inline void bba_insdata(void *val,u32 len)
|
||||
{
|
||||
EXI_ImmEx(EXI_CHANNEL_0,val,len,EXI_READ);
|
||||
}
|
||||
|
||||
|
||||
static inline void bba_outsregister(u32 reg)
|
||||
{
|
||||
u32 req;
|
||||
req = (reg<<8)|0xC0000000;
|
||||
EXI_Imm(EXI_CHANNEL_0,&req,sizeof(req),EXI_WRITE,NULL);
|
||||
EXI_Sync(EXI_CHANNEL_0);
|
||||
}
|
||||
|
||||
static inline void bba_outsdata(void *val,u32 len)
|
||||
{
|
||||
EXI_ImmEx(EXI_CHANNEL_0,val,len,EXI_WRITE);
|
||||
}
|
||||
|
||||
static __inline__ u32 __linkstate()
|
||||
{
|
||||
u8 nways = 0;
|
||||
|
||||
nways = bba_in8(BBA_NWAYS);
|
||||
if(nways&BBA_NWAYS_LS10 || nways&BBA_NWAYS_LS100) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static u32 __bba_getlink_state_async()
|
||||
{
|
||||
u32 ret;
|
||||
|
||||
|
||||
if(EXI_Lock(EXI_CHANNEL_0,EXI_DEVICE_2,NULL)==0) return 0;
|
||||
ret = __linkstate();
|
||||
EXI_Unlock(EXI_CHANNEL_0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static u32 __bba_read_cid()
|
||||
{
|
||||
u16 cmd = 0;
|
||||
u32 cid = 0;
|
||||
|
||||
bba_select();
|
||||
EXI_Imm(EXI_CHANNEL_0,&cmd,2,EXI_WRITE,NULL);
|
||||
EXI_Sync(EXI_CHANNEL_0);
|
||||
EXI_Imm(EXI_CHANNEL_0,&cid,4,EXI_READ,NULL);
|
||||
EXI_Sync(EXI_CHANNEL_0);
|
||||
bba_deselect();
|
||||
|
||||
return cid;
|
||||
}
|
||||
static void __bba_reset()
|
||||
{
|
||||
bba_out8(0x60,0x00);
|
||||
udelay(10000);
|
||||
bba_cmd_in8_slow(0x0F);
|
||||
udelay(10000);
|
||||
bba_out8(BBA_NCRA,BBA_NCRA_RESET);
|
||||
bba_out8(BBA_NCRA,0x00);
|
||||
}
|
||||
|
||||
static void __bba_recv_init()
|
||||
{
|
||||
bba_out8(BBA_NCRB,(BBA_NCRB_CA|BBA_NCRB_AB));
|
||||
bba_out8(BBA_MISC2,(BBA_MISC2_AUTORCVR));
|
||||
|
||||
bba_out12(BBA_TLBP, BBA_INIT_TLBP);
|
||||
bba_out12(BBA_BP,BBA_INIT_BP);
|
||||
bba_out12(BBA_RWP,BBA_INIT_RWP);
|
||||
bba_out12(BBA_RRP,BBA_INIT_RRP);
|
||||
bba_out12(BBA_RHBP,BBA_INIT_RHBP);
|
||||
|
||||
bba_out8(BBA_GCA,BBA_GCA_ARXERRB);
|
||||
bba_out8(BBA_NCRA,BBA_NCRA_SR);
|
||||
}
|
||||
|
||||
static void bba_process(struct uip_pbuf *p,struct uip_netif *dev)
|
||||
{
|
||||
struct uip_eth_hdr *ethhdr = NULL;
|
||||
struct bba_priv *priv = (struct bba_priv*)dev->state;
|
||||
const s32 ethhlen = sizeof(struct uip_eth_hdr);
|
||||
|
||||
if(p) {
|
||||
ethhdr = p->payload;
|
||||
switch(htons(ethhdr->type)) {
|
||||
case UIP_ETHTYPE_IP:
|
||||
uip_arp_ipin(dev,p);
|
||||
uip_pbuf_header(p,-(ethhlen));
|
||||
dev->input(p,dev);
|
||||
break;
|
||||
case UIP_ETHTYPE_ARP:
|
||||
uip_arp_arpin(dev,priv->ethaddr,p);
|
||||
break;
|
||||
default:
|
||||
uip_pbuf_free(p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static s8_t bba_start_rx(struct uip_netif *dev,u32 budget)
|
||||
{
|
||||
s32 size;
|
||||
u16 top,pos,rwp,rrp;
|
||||
u32 pkt_status,recvd;
|
||||
struct uip_pbuf *p,*q;
|
||||
|
||||
UIP_LOG("bba_start_rx()\n");
|
||||
|
||||
recvd = 0;
|
||||
rwp = bba_in12(BBA_RWP);
|
||||
rrp = bba_in12(BBA_RRP);
|
||||
while(recvd<budget && rrp!=rwp) {
|
||||
bba_ins(rrp<<8,(void*)(&cur_descr),sizeof(struct bba_descr));
|
||||
le32_to_cpus((u32*)((void*)(&cur_descr)));
|
||||
|
||||
size = cur_descr.packet_len - 4;
|
||||
pkt_status = cur_descr.status;
|
||||
if(size>(BBA_RX_MAX_PACKET_SIZE+4)) {
|
||||
UIP_LOG("bba_start_rx: packet dropped due to big buffer.\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if(pkt_status&(BBA_RX_STATUS_RERR|BBA_RX_STATUS_FAE)) {
|
||||
UIP_LOG("bba_start_rx: packet dropped due to receive errors.\n");
|
||||
rwp = bba_in12(BBA_RWP);
|
||||
rrp = bba_in12(BBA_RRP);
|
||||
continue;
|
||||
}
|
||||
|
||||
pos = (rrp<<8)+4;
|
||||
top = (BBA_INIT_RHBP+1)<<8;
|
||||
|
||||
p = uip_pbuf_alloc(UIP_PBUF_RAW,size,UIP_PBUF_POOL);
|
||||
if(p) {
|
||||
for(q=p;q!=NULL;q=q->next) {
|
||||
bba_select();
|
||||
bba_insregister(pos);
|
||||
if((pos+size)<top) {
|
||||
bba_insdata(q->payload,size);
|
||||
} else {
|
||||
s32 chunk = top-pos;
|
||||
|
||||
size -= chunk;
|
||||
pos = BBA_INIT_RRP<<8;
|
||||
bba_insdata(q->payload,chunk);
|
||||
bba_deselect();
|
||||
|
||||
bba_select();
|
||||
bba_insregister(pos);
|
||||
bba_insdata(q->payload+chunk,size);
|
||||
}
|
||||
bba_deselect();
|
||||
pos += size;
|
||||
}
|
||||
|
||||
EXI_Unlock(EXI_CHANNEL_0);
|
||||
bba_process(p,dev);
|
||||
EXI_Lock(EXI_CHANNEL_0,EXI_DEVICE_2,NULL);
|
||||
} else
|
||||
break;
|
||||
|
||||
recvd++;
|
||||
|
||||
bba_out12(BBA_RRP,(rrp=cur_descr.next_packet_ptr));
|
||||
rwp = bba_in12(BBA_RWP);
|
||||
}
|
||||
return UIP_ERR_OK;
|
||||
}
|
||||
|
||||
static inline void bba_interrupt(u16 *pstatus)
|
||||
{
|
||||
u8 ir,imr,status;
|
||||
|
||||
ir = bba_in8(BBA_IR);
|
||||
imr = bba_in8(BBA_IMR);
|
||||
status = ir&imr;
|
||||
|
||||
if(status&BBA_IR_FRAGI) {
|
||||
bba_out8(BBA_IR,BBA_IR_FRAGI);
|
||||
}
|
||||
if(status&BBA_IR_RI) {
|
||||
bba_start_rx(bba_netif,0x10);
|
||||
bba_out8(BBA_IR,BBA_IR_RI);
|
||||
}
|
||||
if(status&BBA_IR_REI) {
|
||||
bba_out8(BBA_IR,BBA_IR_REI);
|
||||
}
|
||||
if(status&BBA_IR_TI) {
|
||||
bba_out8(BBA_IR,BBA_IR_TI);
|
||||
}
|
||||
if(status&BBA_IR_TEI) {
|
||||
bba_out8(BBA_IR,BBA_IR_TEI);
|
||||
}
|
||||
if(status&BBA_IR_FIFOEI) {
|
||||
bba_out8(BBA_IR,BBA_IR_FIFOEI);
|
||||
}
|
||||
if(status&BBA_IR_BUSEI) {
|
||||
bba_out8(BBA_IR,BBA_IR_BUSEI);
|
||||
}
|
||||
if(status&BBA_IR_RBFI) {
|
||||
bba_start_rx(bba_netif,0x10);
|
||||
bba_out8(BBA_IR,BBA_IR_RBFI);
|
||||
}
|
||||
*pstatus |= status;
|
||||
}
|
||||
|
||||
static s8_t bba_dochallengeresponse()
|
||||
{
|
||||
u16 status;
|
||||
s32 cnt;
|
||||
|
||||
UIP_LOG("bba_dochallengeresponse()\n");
|
||||
/* as we do not have interrupts we've to poll the irqs */
|
||||
cnt = 0;
|
||||
do {
|
||||
cnt++;
|
||||
bba_devpoll(&status);
|
||||
if(status==0x1000) cnt = 0;
|
||||
} while(cnt<100 && !(status&0x0800));
|
||||
|
||||
if(cnt>=1000) return UIP_ERR_IF;
|
||||
return UIP_ERR_OK;
|
||||
}
|
||||
|
||||
static s8_t __bba_init(struct uip_netif *dev)
|
||||
{
|
||||
struct bba_priv *priv = (struct bba_priv*)dev->state;
|
||||
if(!priv) return UIP_ERR_IF;
|
||||
|
||||
__bba_reset();
|
||||
|
||||
priv->revid = bba_cmd_in8(0x01);
|
||||
|
||||
bba_cmd_outs(0x04,&priv->devid,2);
|
||||
bba_cmd_out8(0x05,priv->acstart);
|
||||
|
||||
bba_out8(0x5b, (bba_in8(0x5b)&~0x80));
|
||||
bba_out8(0x5e, 0x01);
|
||||
bba_out8(0x5c, (bba_in8(0x5c)|0x04));
|
||||
|
||||
__bba_recv_init();
|
||||
|
||||
bba_ins(BBA_NAFR_PAR0,priv->ethaddr->addr, 6);
|
||||
|
||||
bba_out8(BBA_IR,0xFF);
|
||||
bba_out8(BBA_IMR,0xFF&~BBA_IMR_FIFOEIM);
|
||||
|
||||
bba_cmd_out8(0x02,BBA_CMD_IRMASKNONE);
|
||||
|
||||
return UIP_ERR_OK;
|
||||
}
|
||||
|
||||
static s8_t bba_init_one(struct uip_netif *dev)
|
||||
{
|
||||
s32 ret;
|
||||
struct bba_priv *priv = (struct bba_priv*)dev->state;
|
||||
|
||||
if(!priv) return UIP_ERR_IF;
|
||||
|
||||
priv->revid = 0x00;
|
||||
priv->devid = 0xD107;
|
||||
priv->acstart = 0x4E;
|
||||
|
||||
ret = __bba_init(dev);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static s8_t bba_probe(struct uip_netif *dev)
|
||||
{
|
||||
s32 ret;
|
||||
u32 cid;
|
||||
|
||||
if(EXI_Lock(EXI_CHANNEL_0,EXI_DEVICE_2,NULL)==0) return -1;
|
||||
|
||||
cid = __bba_read_cid();
|
||||
if(cid!=BBA_CID) {
|
||||
EXI_Unlock(EXI_CHANNEL_0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = bba_init_one(dev);
|
||||
|
||||
EXI_Unlock(EXI_CHANNEL_0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static u32 bba_calc_response(struct uip_netif *dev,u32 val)
|
||||
{
|
||||
u8 revid_0, revid_eth_0, revid_eth_1;
|
||||
struct bba_priv *priv = (struct bba_priv*)dev->state;
|
||||
|
||||
UIP_LOG("bba_calc_response()\n");
|
||||
|
||||
revid_0 = priv->revid;
|
||||
revid_eth_0 = _SHIFTR(priv->devid,8,8);
|
||||
revid_eth_1 = priv->devid&0xff;
|
||||
|
||||
u8 i0, i1, i2, i3;
|
||||
i0 = (val & 0xff000000) >> 24;
|
||||
i1 = (val & 0x00ff0000) >> 16;
|
||||
i2 = (val & 0x0000ff00) >> 8;
|
||||
i3 = (val & 0x000000ff);
|
||||
|
||||
u8 c0, c1, c2, c3;
|
||||
c0 = ((i0 + i1 * 0xc1 + 0x18 + revid_0) ^ (i3 * i2 + 0x90)
|
||||
) & 0xff;
|
||||
c1 = ((i1 + i2 + 0x90) ^ (c0 + i0 - 0xc1)
|
||||
) & 0xff;
|
||||
c2 = ((i2 + 0xc8) ^ (c0 + ((revid_eth_0 + revid_0 * 0x23) ^ 0x19))
|
||||
) & 0xff;
|
||||
c3 = ((i0 + 0xc1) ^ (i3 + ((revid_eth_1 + 0xc8) ^ 0x90))
|
||||
) & 0xff;
|
||||
|
||||
return ((c0 << 24) | (c1 << 16) | (c2 << 8) | c3);
|
||||
}
|
||||
|
||||
static void bba_devpoll(u16 *pstatus)
|
||||
{
|
||||
u8 status;
|
||||
s64 now;
|
||||
|
||||
UIP_LOG("bba_devpoll()\n");
|
||||
|
||||
now = gettime();
|
||||
if(diff_msec(bba_arp_tmr,now)>=UIP_ARP_TMRINTERVAL) {
|
||||
uip_arp_timer();
|
||||
bba_arp_tmr = gettime();
|
||||
}
|
||||
|
||||
status = 0;
|
||||
*pstatus = 0;
|
||||
if(EXI_Lock(EXI_CHANNEL_0,EXI_DEVICE_2,NULL)==1) {
|
||||
status = bba_cmd_in8(0x03);
|
||||
if(status) {
|
||||
bba_cmd_out8(0x02,BBA_CMD_IRMASKALL);
|
||||
if(status&0x80) {
|
||||
*pstatus |= (status<<8);
|
||||
bba_interrupt(pstatus);
|
||||
bba_cmd_out8(0x03,0x80);
|
||||
bba_cmd_out8(0x02,BBA_CMD_IRMASKNONE);
|
||||
EXI_Unlock(EXI_CHANNEL_0);
|
||||
return;
|
||||
}
|
||||
if(status&0x40) {
|
||||
*pstatus |= (status<<8);
|
||||
__bba_init(bba_netif);
|
||||
bba_cmd_out8(0x03, 0x40);
|
||||
bba_cmd_out8(0x02,BBA_CMD_IRMASKNONE);
|
||||
EXI_Unlock(EXI_CHANNEL_0);
|
||||
return;
|
||||
}
|
||||
if(status&0x20) {
|
||||
*pstatus |= (status<<8);
|
||||
bba_cmd_out8(0x03, 0x20);
|
||||
bba_cmd_out8(0x02,BBA_CMD_IRMASKNONE);
|
||||
EXI_Unlock(EXI_CHANNEL_0);
|
||||
return;
|
||||
}
|
||||
if(status&0x10) {
|
||||
u32 response,challange;
|
||||
|
||||
*pstatus |= (status<<8);
|
||||
bba_cmd_out8(0x05,bba_device.acstart);
|
||||
bba_cmd_ins(0x08,&challange,sizeof(challange));
|
||||
response = bba_calc_response(bba_netif,challange);
|
||||
bba_cmd_outs(0x09,&response,sizeof(response));
|
||||
bba_cmd_out8(0x03, 0x10);
|
||||
bba_cmd_out8(0x02,BBA_CMD_IRMASKNONE);
|
||||
EXI_Unlock(EXI_CHANNEL_0);
|
||||
return;
|
||||
}
|
||||
if(status&0x08) {
|
||||
*pstatus |= (status<<8);
|
||||
bba_cmd_out8(0x03, 0x08);
|
||||
bba_cmd_out8(0x02,BBA_CMD_IRMASKNONE);
|
||||
EXI_Unlock(EXI_CHANNEL_0);
|
||||
return;
|
||||
}
|
||||
|
||||
*pstatus |= (status<<8);
|
||||
bba_interrupt(pstatus);
|
||||
bba_cmd_out8(0x02,BBA_CMD_IRMASKNONE);
|
||||
}
|
||||
EXI_Unlock(EXI_CHANNEL_0);
|
||||
}
|
||||
}
|
||||
|
||||
static s8_t __bba_start_tx(struct uip_netif *dev,struct uip_pbuf *p,struct uip_ip_addr *ipaddr)
|
||||
{
|
||||
return uip_arp_out(dev,ipaddr,p);
|
||||
}
|
||||
|
||||
static s8_t __bba_link_tx(struct uip_netif *dev,struct uip_pbuf *p)
|
||||
{
|
||||
u8 pad[60];
|
||||
u32 len;
|
||||
struct uip_pbuf *tmp;
|
||||
|
||||
if(EXI_Lock(EXI_CHANNEL_0,EXI_DEVICE_2,NULL)==0) return UIP_ERR_IF;
|
||||
|
||||
if(p->tot_len>BBA_TX_MAX_PACKET_SIZE) {
|
||||
UIP_LOG("__bba_link_tx: packet dropped due to big buffer.\n");
|
||||
EXI_Unlock(EXI_CHANNEL_0);
|
||||
return UIP_ERR_PKTSIZE;
|
||||
}
|
||||
|
||||
if(!__linkstate()) {
|
||||
EXI_Unlock(EXI_CHANNEL_0);
|
||||
return UIP_ERR_ABRT;
|
||||
}
|
||||
|
||||
while((bba_in8(BBA_NCRA)&(BBA_NCRA_ST0|BBA_NCRA_ST1)));
|
||||
|
||||
len = p->tot_len;
|
||||
bba_out12(BBA_TXFIFOCNT,len);
|
||||
|
||||
bba_select();
|
||||
bba_outsregister(BBA_WRTXFIFOD);
|
||||
for(tmp=p;tmp!=NULL;tmp=tmp->next) {
|
||||
bba_outsdata(tmp->payload,tmp->len);
|
||||
}
|
||||
if(len<BBA_MINPKTSIZE) {
|
||||
len = (BBA_MINPKTSIZE-len);
|
||||
bba_outsdata(pad,len);
|
||||
}
|
||||
bba_deselect();
|
||||
|
||||
bba_out8(BBA_NCRA,((bba_in8(BBA_NCRA)&~BBA_NCRA_ST0)|BBA_NCRA_ST1)); //&~BBA_NCRA_ST0
|
||||
EXI_Unlock(EXI_CHANNEL_0);
|
||||
return UIP_ERR_OK;
|
||||
}
|
||||
|
||||
s8_t uip_bba_init(struct uip_netif *dev)
|
||||
{
|
||||
s8_t ret;
|
||||
s32_t cnt;
|
||||
|
||||
ret = bba_probe(dev);
|
||||
if(ret<0) return ret;
|
||||
|
||||
ret = bba_dochallengeresponse();
|
||||
if(ret<0) return ret;
|
||||
|
||||
cnt = 0;
|
||||
do {
|
||||
udelay(500);
|
||||
cnt++;
|
||||
} while((ret=__bba_getlink_state_async())==0 && cnt<10000);
|
||||
if(!ret) return UIP_ERR_IF;
|
||||
|
||||
dev->flags |= UIP_NETIF_FLAG_LINK_UP;
|
||||
uip_netif_setup(dev);
|
||||
uip_arp_init();
|
||||
|
||||
bba_recv_pbufs = NULL;
|
||||
bba_arp_tmr = gettime();
|
||||
|
||||
return UIP_ERR_OK;
|
||||
}
|
||||
|
||||
uipdev_s uip_bba_create(struct uip_netif *dev)
|
||||
{
|
||||
dev->name[0] = IFNAME0;
|
||||
dev->name[1] = IFNAME1;
|
||||
|
||||
dev->output = __bba_start_tx;
|
||||
dev->linkoutput = __bba_link_tx;
|
||||
dev->mtu = 1500;
|
||||
dev->flags = UIP_NETIF_FLAG_BROADCAST;
|
||||
dev->hwaddr_len = 6;
|
||||
|
||||
bba_device.ethaddr = (struct uip_eth_addr*)dev->hwaddr;
|
||||
bba_device.state = UIP_ERR_OK;
|
||||
|
||||
bba_netif = dev;
|
||||
return &bba_device;
|
||||
}
|
||||
|
||||
void uip_bba_poll(struct uip_netif *dev)
|
||||
{
|
||||
u16 status;
|
||||
|
||||
UIP_LOG("uip_bba_poll()\n");
|
||||
|
||||
bba_devpoll(&status);
|
||||
|
||||
}
|
14
wii/libogc/libdb/uIP/bba.h
Normal file
14
wii/libogc/libdb/uIP/bba.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef __BBA_DBG_H__
|
||||
#define __BBA_DBG_H__
|
||||
|
||||
#include "uip.h"
|
||||
|
||||
struct uip_netif;
|
||||
|
||||
typedef void* uipdev_s;
|
||||
|
||||
uipdev_s uip_bba_create(struct uip_netif *dev);
|
||||
s8_t uip_bba_init(struct uip_netif *dev);
|
||||
void uip_bba_poll(struct uip_netif *dev);
|
||||
|
||||
#endif
|
48
wii/libogc/libdb/uIP/memb.c
Normal file
48
wii/libogc/libdb/uIP/memb.c
Normal file
@ -0,0 +1,48 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "uip.h"
|
||||
#include "memb.h"
|
||||
|
||||
void memb_init(struct memb_blks *blk)
|
||||
{
|
||||
UIP_MEMSET(blk->mem,0,(MEM_ALIGN_SIZE(blk->size)+sizeof(u32))*blk->num);
|
||||
}
|
||||
|
||||
void* memb_alloc(struct memb_blks *blk)
|
||||
{
|
||||
s32 i;
|
||||
u32 *ptr;
|
||||
|
||||
ptr = (u32*)blk->mem;
|
||||
for(i=0;i<blk->num;i++) {
|
||||
if(*ptr==0) {
|
||||
++(*ptr);
|
||||
return (void*)(ptr+1);
|
||||
}
|
||||
ptr = (u32*)(u8*)ptr+(MEM_ALIGN_SIZE(blk->size)+sizeof(u32));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
u8 memb_free(struct memb_blks *blk,void *ptr)
|
||||
{
|
||||
s32 i;
|
||||
u32 *ptr2,*ptr1;
|
||||
|
||||
ptr1 = ptr;
|
||||
ptr2 = (u32*)blk->mem;
|
||||
for(i=0;i<blk->num;i++) {
|
||||
if(ptr2==(ptr1 - 1)) {
|
||||
return --(*ptr2);
|
||||
}
|
||||
ptr2 = (u32*)(u8*)ptr2+(MEM_ALIGN_SIZE(blk->size)+sizeof(u32));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
u8 memb_ref(struct memb_blks *blk,void *ptr)
|
||||
{
|
||||
u32 *pref = ptr-sizeof(u32);
|
||||
return ++(*pref);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user