mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-02-13 07:36:52 +00:00
(libogc) Retract
This commit is contained in:
parent
f22799fb00
commit
bdbf452fe9
9
gx/libogc/.gitignore
vendored
9
gx/libogc/.gitignore
vendored
@ -1,9 +0,0 @@
|
||||
cube
|
||||
deps
|
||||
include
|
||||
lib
|
||||
wii
|
||||
gc/ogc/libversion.h
|
||||
*.bz2
|
||||
docs
|
||||
warn.log
|
@ -1,270 +0,0 @@
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
ifeq ($(strip $(DEVKITPRO)),)
|
||||
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro")
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(DEVKITPPC)),)
|
||||
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
|
||||
endif
|
||||
|
||||
export PATH := $(DEVKITPPC)/bin:$(PATH)
|
||||
|
||||
export LIBOGC_MAJOR := 1
|
||||
export LIBOGC_MINOR := 8
|
||||
export LIBOGC_PATCH := 12
|
||||
|
||||
include $(DEVKITPPC)/base_rules
|
||||
|
||||
BUILD := build
|
||||
|
||||
DATESTRING := $(shell date +%Y%m%d)
|
||||
VERSTRING := $(LIBOGC_MAJOR).$(LIBOGC_MINOR).$(LIBOGC_PATCH)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(PLATFORM)),)
|
||||
#---------------------------------------------------------------------------------
|
||||
export BASEDIR := $(CURDIR)
|
||||
export LWIPDIR := $(BASEDIR)/lwip
|
||||
export OGCDIR := $(BASEDIR)/libogc
|
||||
export DBDIR := $(BASEDIR)/libdb
|
||||
export DIDIR := $(BASEDIR)/libdi
|
||||
export BTEDIR := $(BASEDIR)/lwbt
|
||||
export WIIUSEDIR := $(BASEDIR)/wiiuse
|
||||
export LIBWIIKEYB := $(BASEDIR)/libwiikeyboard
|
||||
export STUBSDIR := $(BASEDIR)/lockstubs
|
||||
export DEPS := $(BASEDIR)/deps
|
||||
export LIBS := $(BASEDIR)/lib
|
||||
|
||||
export INCDIR := $(BASEDIR)/include
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export LIBDIR := $(LIBS)/$(PLATFORM)
|
||||
export DEPSDIR := $(DEPS)/$(PLATFORM)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
BBALIB := $(LIBDIR)/libbba
|
||||
OGCLIB := $(LIBDIR)/libogc
|
||||
DBLIB := $(LIBDIR)/libdb
|
||||
DILIB := $(LIBDIR)/libdi
|
||||
BTELIB := $(LIBDIR)/libbte
|
||||
WIIUSELIB := $(LIBDIR)/libwiiuse
|
||||
WIIKEYBLIB := $(LIBDIR)/libwiikeyboard
|
||||
STUBSLIB := $(LIBDIR)/libgclibstubs
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
DEFINCS := -I$(BASEDIR) -I$(BASEDIR)/gc
|
||||
INCLUDES := $(DEFINCS) -I$(BASEDIR)/gc/netif -I$(BASEDIR)/gc/ipv4 \
|
||||
-I$(BASEDIR)/gc/ogc -I$(BASEDIR)/gc/ogc/machine \
|
||||
-I$(BASEDIR)/gc/bte \
|
||||
-I$(BASEDIR)/gc/sdcard -I$(BASEDIR)/gc/wiiuse \
|
||||
-I$(BASEDIR)/gc/di
|
||||
|
||||
MACHDEP := -DBIGENDIAN -DGEKKO -mcpu=750 -meabi -msdata=eabi -mhard-float -fmodulo-sched -ffunction-sections -fdata-sections
|
||||
|
||||
|
||||
ifeq ($(PLATFORM),wii)
|
||||
MACHDEP += -DHW_RVL
|
||||
endif
|
||||
|
||||
ifeq ($(PLATFORM),cube)
|
||||
MACHDEP += -DHW_DOL
|
||||
endif
|
||||
|
||||
CFLAGS := -DLIBOGC_INTERNAL -g -Os -mregnames -Wall $(MACHDEP) -fno-strict-aliasing $(INCLUDES)
|
||||
ASFLAGS := $(MACHDEP) -mregnames -D_LANGUAGE_ASSEMBLY $(INCLUDES)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
VPATH := $(LWIPDIR) \
|
||||
$(LWIPDIR)/arch/gc \
|
||||
$(LWIPDIR)/arch/gc/netif \
|
||||
$(LWIPDIR)/core \
|
||||
$(LWIPDIR)/core/ipv4 \
|
||||
$(LWIPDIR)/netif \
|
||||
$(OGCDIR) \
|
||||
$(DBDIR) \
|
||||
$(DBDIR)/uIP \
|
||||
$(DIDIR) \
|
||||
$(BTEDIR) \
|
||||
$(WIIUSEDIR) \
|
||||
$(SDCARDDIR) \
|
||||
$(LIBWIIKEYB) \
|
||||
$(STUBSDIR)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
LWIPOBJ := network.o netio.o gcif.o \
|
||||
inet.o mem.o dhcp.o raw.o \
|
||||
memp.o netif.o pbuf.o stats.o \
|
||||
sys.o tcp.o tcp_in.o tcp_out.o \
|
||||
udp.o icmp.o ip.o ip_frag.o \
|
||||
ip_addr.o etharp.o loopif.o
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
OGCOBJ := \
|
||||
console.o lwp_priority.o lwp_queue.o lwp_threadq.o lwp_threads.o lwp_sema.o \
|
||||
lwp_messages.o lwp.o lwp_handler.o lwp_stack.o lwp_mutex.o \
|
||||
lwp_watchdog.o lwp_wkspace.o lwp_objmgr.o lwp_heap.o sys_state.o \
|
||||
exception_handler.o exception.o irq.o irq_handler.o semaphore.o \
|
||||
video_asm.o video.o pad.o dvd.o exi.o mutex.o arqueue.o arqmgr.o \
|
||||
cache_asm.o system.o system_asm.o cond.o \
|
||||
gx.o gu.o gu_psasm.o audio.o cache.o decrementer.o \
|
||||
message.o card.o aram.o depackrnc.o decrementer_handler.o \
|
||||
depackrnc1.o dsp.o si.o tpl.o ipc.o ogc_crt0.o \
|
||||
console_font_8x16.o timesupp.o lock_supp.o newlibc.o usbgecko.o usbmouse.o \
|
||||
sbrk.o malloc_lock.o kprintf.o stm.o ios.o es.o isfs.o usb.o network_common.o \
|
||||
sdgecko_io.o sdgecko_buf.o gcsd.o argv.o network_wii.o wiisd.o conf.o usbstorage.o \
|
||||
texconv.o wiilaunch.o
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
DBOBJ := uip_ip.o uip_tcp.o uip_pbuf.o uip_netif.o uip_arp.o uip_arch.o \
|
||||
uip_icmp.o memb.o memr.o bba.o tcpip.o debug.o debug_handler.o \
|
||||
debug_supp.o geckousb.o
|
||||
#---------------------------------------------------------------------------------
|
||||
DIOBJ := di.o
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
BTEOBJ := bte.o hci.o l2cap.o btmemb.o btmemr.o btpbuf.o physbusif.o
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
WIIUSEOBJ := classic.o dynamics.o events.o guitar_hero_3.o io.o io_wii.o ir.o \
|
||||
nunchuk.o wiiboard.o wiiuse.o speaker.o wpad.o motion_plus.o
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
WIIKEYBLIBOBJ := usbkeyboard.o keyboard.o ukbdmap.o wskbdutil.o
|
||||
|
||||
|
||||
|
||||
all: wii cube
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
wii: gc/ogc/libversion.h
|
||||
#---------------------------------------------------------------------------------
|
||||
@[ -d $(INCDIR) ] || mkdir -p $(INCDIR)
|
||||
@[ -d $(LIBS)/wii ] || mkdir -p $(LIBS)/wii
|
||||
@[ -d $(DEPS)/wii ] || mkdir -p $(DEPS)/wii
|
||||
@[ -d wii ] || mkdir -p wii
|
||||
@$(MAKE) PLATFORM=wii libs -C wii -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
cube: gc/ogc/libversion.h
|
||||
#---------------------------------------------------------------------------------
|
||||
@[ -d $(INCDIR) ] || mkdir -p $(INCDIR)
|
||||
@[ -d $(LIBS)/cube ] || mkdir -p $(LIBS)/cube
|
||||
@[ -d $(DEPS)/cube ] || mkdir -p $(DEPS)/cube
|
||||
@[ -d cube ] || mkdir -p cube
|
||||
@$(MAKE) PLATFORM=cube libs -C cube -f $(CURDIR)/Makefile
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
gc/ogc/libversion.h : Makefile
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo "#ifndef __LIBVERSION_H__" > $@
|
||||
@echo "#define __LIBVERSION_H__" >> $@
|
||||
@echo >> $@
|
||||
@echo "#define _V_MAJOR_ $(LIBOGC_MAJOR)" >> $@
|
||||
@echo "#define _V_MINOR_ $(LIBOGC_MINOR)" >> $@
|
||||
@echo "#define _V_PATCH_ $(LIBOGC_PATCH)" >> $@
|
||||
@echo >> $@
|
||||
@echo "#define _V_DATE_ __DATE__" >> $@
|
||||
@echo "#define _V_TIME_ __TIME__" >> $@
|
||||
@echo >> $@
|
||||
@echo '#define _V_STRING "libOGC Release '$(LIBOGC_MAJOR).$(LIBOGC_MINOR).$(LIBOGC_PATCH)'"' >> $@
|
||||
@echo >> $@
|
||||
@echo "#endif // __LIBVERSION_H__" >> $@
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
$(BBALIB).a: $(LWIPOBJ)
|
||||
#---------------------------------------------------------------------------------
|
||||
$(OGCLIB).a: $(OGCOBJ)
|
||||
#---------------------------------------------------------------------------------
|
||||
$(MP3LIB).a: $(MP3OBJ)
|
||||
#---------------------------------------------------------------------------------
|
||||
$(DBLIB).a: $(DBOBJ)
|
||||
#---------------------------------------------------------------------------------
|
||||
$(DILIB).a: $(DIOBJ)
|
||||
#---------------------------------------------------------------------------------
|
||||
$(WIIKEYBLIB).a: $(WIIKEYBLIBOBJ)
|
||||
#---------------------------------------------------------------------------------
|
||||
$(BTELIB).a: $(BTEOBJ)
|
||||
#---------------------------------------------------------------------------------
|
||||
$(WIIUSELIB).a: $(WIIUSEOBJ)
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
.PHONY: libs wii cube install-headers install dist docs
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
install-headers:
|
||||
#---------------------------------------------------------------------------------
|
||||
@mkdir -p $(INCDIR)
|
||||
@mkdir -p $(INCDIR)/ogc/machine
|
||||
@mkdir -p $(INCDIR)/bte
|
||||
@mkdir -p $(INCDIR)/wiiuse
|
||||
@mkdir -p $(INCDIR)/sdcard
|
||||
@mkdir -p $(INCDIR)/di
|
||||
@mkdir -p $(INCDIR)/wiikeyboard
|
||||
@cp ./gc/*.h $(INCDIR)
|
||||
@cp ./gc/ogc/*.h $(INCDIR)/ogc
|
||||
@cp ./gc/ogc/machine/*.h $(INCDIR)/ogc/machine
|
||||
@cp ./gc/bte/*.h $(INCDIR)/bte
|
||||
@cp ./gc/wiiuse/*.h $(INCDIR)/wiiuse
|
||||
@cp ./gc/sdcard/*.h $(INCDIR)/sdcard
|
||||
@cp ./gc/di/*.h $(INCDIR)/di
|
||||
@cp ./gc/wiikeyboard/*.h $(INCDIR)/wiikeyboard
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
install: install-headers
|
||||
#---------------------------------------------------------------------------------
|
||||
@mkdir -p $(DEVKITPRO)/libogc
|
||||
@cp -frv include $(DEVKITPRO)/libogc
|
||||
@cp -frv lib $(DEVKITPRO)/libogc
|
||||
@cp -frv libogc_license.txt $(DEVKITPRO)/libogc
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
dist: install-headers
|
||||
#---------------------------------------------------------------------------------
|
||||
@tar --exclude=*CVS* --exclude=.svn --exclude=wii --exclude=cube --exclude=*deps* \
|
||||
--exclude=*.bz2 --exclude=*include* --exclude=*lib/* --exclude=*docs/*\
|
||||
-cvjf libogc-src-$(VERSTRING).tar.bz2 *
|
||||
@tar -cvjf libogc-$(VERSTRING).tar.bz2 include lib libogc_license.txt
|
||||
|
||||
|
||||
LIBRARIES := $(OGCLIB).a $(DBLIB).a
|
||||
|
||||
ifeq ($(PLATFORM),cube)
|
||||
LIBRARIES += $(BBALIB).a
|
||||
endif
|
||||
ifeq ($(PLATFORM),wii)
|
||||
LIBRARIES += $(BTELIB).a $(WIIUSELIB).a $(DILIB).a $(WIIKEYBLIB).a
|
||||
endif
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
libs: $(LIBRARIES)
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
#---------------------------------------------------------------------------------
|
||||
rm -fr wii cube
|
||||
rm -fr $(DEPS)
|
||||
rm -fr $(LIBS)
|
||||
rm -fr $(INCDIR)
|
||||
rm -f *.map
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
docs: install-headers
|
||||
#---------------------------------------------------------------------------------
|
||||
doxygen libogc.dox
|
||||
|
||||
-include $(DEPSDIR)/*.d
|
@ -1,61 +0,0 @@
|
||||
#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
|
@ -1,383 +0,0 @@
|
||||
/* 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
|
||||
|
@ -1,79 +0,0 @@
|
||||
/*
|
||||
* 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__ */
|
@ -1,154 +0,0 @@
|
||||
#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
|
||||
|
@ -1,43 +0,0 @@
|
||||
#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
|
@ -1,133 +0,0 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
di.h -- Drive Interface library
|
||||
|
||||
Team Twiizers
|
||||
Copyright (C) 2008
|
||||
|
||||
Erant
|
||||
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.
|
||||
|
||||
-------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
All buffers in this document need to be 32-byte aligned!
|
||||
*/
|
||||
|
||||
#ifndef __DI_H__
|
||||
#define __DI_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <ogc/ipc.h>
|
||||
#include <ogc/disc_io.h>
|
||||
|
||||
#define DVD_IDENTIFY 0x12
|
||||
#define DVD_READ_DISCID 0x70
|
||||
#define DVD_LOW_READ 0x71
|
||||
#define DVD_WAITFORCOVERCLOSE 0x79
|
||||
#define DVD_READ_PHYSICAL 0x80
|
||||
#define DVD_READ_COPYRIGHT 0x81
|
||||
#define DVD_READ_DISCKEY 0x82
|
||||
#define DVD_GETCOVER 0x88
|
||||
#define DVD_RESET 0x8A
|
||||
#define DVD_OPEN_PARTITION 0x8B
|
||||
#define DVD_CLOSE_PARTITION 0x8C
|
||||
#define DVD_READ_UNENCRYPTED 0x8D
|
||||
#define DVD_REPORTKEY 0xA4
|
||||
#define DVD_READ 0xD0
|
||||
#define DVD_READ_CONFIG 0xD1
|
||||
#define DVD_READ_BCA 0xDA
|
||||
#define DVD_GET_ERROR 0xE0
|
||||
#define DVD_SET_MOTOR 0xE3
|
||||
|
||||
#define DVD_READY 0x1
|
||||
#define DVD_INIT 0x2
|
||||
#define DVD_UNKNOWN 0x4
|
||||
#define DVD_NO_DISC 0x8
|
||||
#define DVD_IOS_ERROR 0x10
|
||||
#define DVD_D0 0x20
|
||||
#define DVD_A8 0x40
|
||||
|
||||
#define DVD_COVER_DISC_INSERTED 0x02
|
||||
|
||||
#define LIBDI_MAX_RETRIES 16
|
||||
|
||||
#define DEVICE_TYPE_WII_DVD (('W'<<24)|('D'<<16)|('V'<<8)|'D')
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct{
|
||||
uint16_t rev;
|
||||
uint16_t dev_code;
|
||||
uint32_t rel_date;
|
||||
}DI_DriveID;
|
||||
|
||||
typedef int(*di_callback)(uint32_t status, uint32_t error);
|
||||
typedef int(*read_func)(void*,uint32_t,uint32_t);
|
||||
typedef int(*read_func_async)(void*,uint32_t,uint32_t,ipccallback);
|
||||
|
||||
extern int di_fd;
|
||||
extern const DISC_INTERFACE __io_wiidvd;
|
||||
|
||||
int DI_Init();
|
||||
void DI_LoadDVDX(bool load);
|
||||
void DI_UseCache(bool use);
|
||||
void DI_SetInitCallback(di_callback cb);
|
||||
void DI_Mount();
|
||||
void DI_Close();
|
||||
int DI_GetStatus();
|
||||
|
||||
int DI_Identify(DI_DriveID* id);
|
||||
int DI_CheckDVDSupport();
|
||||
int DI_ReadDiscID(u64 *id);
|
||||
int DI_GetError(uint32_t* error);
|
||||
int DI_GetCoverRegister(uint32_t* status);
|
||||
int DI_Reset();
|
||||
|
||||
int DI_StopMotor();
|
||||
int DI_Eject();
|
||||
int DI_KillDrive();
|
||||
|
||||
int DI_ReadDVD(void* buf, uint32_t len, uint32_t lba);
|
||||
int DI_ReadDVDAsync(void* buf, uint32_t len, uint32_t lba, ipccallback ipc_cb);
|
||||
|
||||
int DI_Read(void *buf, u32 size, u32 offset);
|
||||
int DI_UnencryptedRead(void *buf, u32 size, u32 offset);
|
||||
|
||||
int DI_ReadDVDConfig(uint32_t* val, uint32_t flag);
|
||||
int DI_ReadDVDCopyright(uint32_t* copyright);
|
||||
int DI_ReadDVDDiscKey(void *buf);
|
||||
int DI_ReadDVDPhysical(void *buf);
|
||||
int DI_Read_BCA(void *buf);
|
||||
int DI_ReportKey(int keytype, uint32_t lba, void* buf);
|
||||
|
||||
int DI_OpenPartition(u32 offset);
|
||||
int DI_ClosePartition(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -1,150 +0,0 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
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
|
@ -1,44 +0,0 @@
|
||||
#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
|
@ -1,110 +0,0 @@
|
||||
#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 */
|
@ -1,12 +0,0 @@
|
||||
#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 */
|
||||
|
@ -1,112 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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 lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __LWIP_ICMP_H__
|
||||
#define __LWIP_ICMP_H__
|
||||
|
||||
#include "lwip/arch.h"
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/pbuf.h"
|
||||
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/netif.h"
|
||||
|
||||
#define ICMP_ER 0 /* echo reply */
|
||||
#define ICMP_DUR 3 /* destination unreachable */
|
||||
#define ICMP_SQ 4 /* source quench */
|
||||
#define ICMP_RD 5 /* redirect */
|
||||
#define ICMP_ECHO 8 /* echo */
|
||||
#define ICMP_TE 11 /* time exceeded */
|
||||
#define ICMP_PP 12 /* parameter problem */
|
||||
#define ICMP_TS 13 /* timestamp */
|
||||
#define ICMP_TSR 14 /* timestamp reply */
|
||||
#define ICMP_IRQ 15 /* information request */
|
||||
#define ICMP_IR 16 /* information reply */
|
||||
|
||||
enum icmp_dur_type {
|
||||
ICMP_DUR_NET = 0, /* net unreachable */
|
||||
ICMP_DUR_HOST = 1, /* host unreachable */
|
||||
ICMP_DUR_PROTO = 2, /* protocol unreachable */
|
||||
ICMP_DUR_PORT = 3, /* port unreachable */
|
||||
ICMP_DUR_FRAG = 4, /* fragmentation needed and DF set */
|
||||
ICMP_DUR_SR = 5 /* source route failed */
|
||||
};
|
||||
|
||||
enum icmp_te_type {
|
||||
ICMP_TE_TTL = 0, /* time to live exceeded in transit */
|
||||
ICMP_TE_FRAG = 1 /* fragment reassembly time exceeded */
|
||||
};
|
||||
|
||||
void icmp_input(struct pbuf *p, struct netif *inp);
|
||||
|
||||
void icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t);
|
||||
void icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t);
|
||||
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct icmp_echo_hdr {
|
||||
PACK_STRUCT_FIELD(u16_t _type_code);
|
||||
PACK_STRUCT_FIELD(u16_t chksum);
|
||||
PACK_STRUCT_FIELD(u16_t id);
|
||||
PACK_STRUCT_FIELD(u16_t seqno);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
|
||||
PACK_STRUCT_BEGIN
|
||||
struct icmp_dur_hdr {
|
||||
PACK_STRUCT_FIELD(u16_t _type_code);
|
||||
PACK_STRUCT_FIELD(u16_t chksum);
|
||||
PACK_STRUCT_FIELD(u32_t unused);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
|
||||
PACK_STRUCT_BEGIN
|
||||
struct icmp_te_hdr {
|
||||
PACK_STRUCT_FIELD(u16_t _type_code);
|
||||
PACK_STRUCT_FIELD(u16_t chksum);
|
||||
PACK_STRUCT_FIELD(u32_t unused);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
#define ICMPH_TYPE(hdr) (ntohs((hdr)->_type_code) >> 8)
|
||||
#define ICMPH_CODE(hdr) (ntohs((hdr)->_type_code) & 0xff)
|
||||
|
||||
#define ICMPH_TYPE_SET(hdr, type) ((hdr)->_type_code = htons(ICMPH_CODE(hdr) | ((type) << 8)))
|
||||
#define ICMPH_CODE_SET(hdr, code) ((hdr)->_type_code = htons((code) | (ICMPH_TYPE(hdr) << 8)))
|
||||
|
||||
#endif /* __LWIP_ICMP_H__ */
|
||||
|
@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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 lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __LWIP_INET_H__
|
||||
#define __LWIP_INET_H__
|
||||
|
||||
#include "lwip/arch.h"
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
|
||||
u16_t inet_chksum(void *dataptr, u16_t len);
|
||||
#if 0 /* optimized routine */
|
||||
u16_t inet_chksum4(u8_t *dataptr, u16_t len);
|
||||
#endif
|
||||
u16_t inet_chksum_pbuf(struct pbuf *p);
|
||||
u16_t inet_chksum_pseudo(struct pbuf *p,
|
||||
struct ip_addr *src, struct ip_addr *dest,
|
||||
u8_t proto, u16_t proto_len);
|
||||
|
||||
u32_t inet_addr(const char *cp);
|
||||
s8_t inet_aton(const char *cp, struct in_addr *addr);
|
||||
char *inet_ntoa(struct in_addr addr); /* returns ptr to static buffer; not reentrant! */
|
||||
|
||||
#ifdef htons
|
||||
#undef htons
|
||||
#endif /* htons */
|
||||
#ifdef htonl
|
||||
#undef htonl
|
||||
#endif /* htonl */
|
||||
#ifdef ntohs
|
||||
#undef ntohs
|
||||
#endif /* ntohs */
|
||||
#ifdef ntohl
|
||||
#undef ntohl
|
||||
#endif /* ntohl */
|
||||
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
#define htons(x) (x)
|
||||
#define ntohs(x) (x)
|
||||
#define htonl(x) (x)
|
||||
#define ntohl(x) (x)
|
||||
#else
|
||||
#ifdef LWIP_PREFIX_BYTEORDER_FUNCS
|
||||
/* workaround for naming collisions on some platforms */
|
||||
#define htons lwip_htons
|
||||
#define ntohs lwip_ntohs
|
||||
#define htonl lwip_htonl
|
||||
#define ntohl lwip_ntohl
|
||||
#endif
|
||||
u16_t htons(u16_t x);
|
||||
u16_t ntohs(u16_t x);
|
||||
u32_t htonl(u32_t x);
|
||||
u32_t ntohl(u32_t x);
|
||||
#endif
|
||||
|
||||
#endif /* __LWIP_INET_H__ */
|
||||
|
@ -1,154 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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 lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __LWIP_IP_H__
|
||||
#define __LWIP_IP_H__
|
||||
|
||||
#include "lwip/arch.h"
|
||||
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
|
||||
#include "lwip/err.h"
|
||||
|
||||
|
||||
void ip_init(void);
|
||||
struct netif *ip_route(struct ip_addr *dest);
|
||||
err_t ip_input(struct pbuf *p, struct netif *inp);
|
||||
err_t ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
||||
u8_t ttl, u8_t tos, u8_t proto);
|
||||
err_t ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
||||
u8_t ttl, u8_t tos, u8_t proto,
|
||||
struct netif *netif);
|
||||
|
||||
#define IP_HLEN 20
|
||||
|
||||
#define IP_PROTO_ICMP 1
|
||||
#define IP_PROTO_UDP 17
|
||||
#define IP_PROTO_UDPLITE 170
|
||||
#define IP_PROTO_TCP 6
|
||||
|
||||
/* This is passed as the destination address to ip_output_if (not
|
||||
to ip_output), meaning that an IP header already is constructed
|
||||
in the pbuf. This is used when TCP retransmits. */
|
||||
#ifdef IP_HDRINCL
|
||||
#undef IP_HDRINCL
|
||||
#endif /* IP_HDRINCL */
|
||||
#define IP_HDRINCL NULL
|
||||
|
||||
|
||||
/* This is the common part of all PCB types. It needs to be at the
|
||||
beginning of a PCB type definition. It is located here so that
|
||||
changes to this common part are made in one location instead of
|
||||
having to change all PCB structs. */
|
||||
#define IP_PCB struct ip_addr local_ip; \
|
||||
struct ip_addr remote_ip; \
|
||||
/* Socket options */ \
|
||||
u16_t so_options; \
|
||||
/* Type Of Service */ \
|
||||
u8_t tos; \
|
||||
/* Time To Live */ \
|
||||
u8_t ttl
|
||||
|
||||
/*
|
||||
* Option flags per-socket. These are the same like SO_XXX.
|
||||
*/
|
||||
#define SOF_DEBUG (u16_t)0x0001U /* turn on debugging info recording */
|
||||
#define SOF_ACCEPTCONN (u16_t)0x0002U /* socket has had listen() */
|
||||
#define SOF_REUSEADDR (u16_t)0x0004U /* allow local address reuse */
|
||||
#define SOF_KEEPALIVE (u16_t)0x0008U /* keep connections alive */
|
||||
#define SOF_DONTROUTE (u16_t)0x0010U /* just use interface addresses */
|
||||
#define SOF_BROADCAST (u16_t)0x0020U /* permit sending of broadcast msgs */
|
||||
#define SOF_USELOOPBACK (u16_t)0x0040U /* bypass hardware when possible */
|
||||
#define SOF_LINGER (u16_t)0x0080U /* linger on close if data present */
|
||||
#define SOF_OOBINLINE (u16_t)0x0100U /* leave received OOB data in line */
|
||||
#define SOF_REUSEPORT (u16_t)0x0200U /* allow local address & port reuse */
|
||||
|
||||
|
||||
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct ip_hdr {
|
||||
/* version / header length / type of service */
|
||||
PACK_STRUCT_FIELD(u16_t _v_hl_tos);
|
||||
/* total length */
|
||||
PACK_STRUCT_FIELD(u16_t _len);
|
||||
/* identification */
|
||||
PACK_STRUCT_FIELD(u16_t _id);
|
||||
/* fragment offset field */
|
||||
PACK_STRUCT_FIELD(u16_t _offset);
|
||||
#define IP_RF 0x8000 /* reserved fragment flag */
|
||||
#define IP_DF 0x4000 /* dont fragment flag */
|
||||
#define IP_MF 0x2000 /* more fragments flag */
|
||||
#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
|
||||
/* time to live / protocol*/
|
||||
PACK_STRUCT_FIELD(u16_t _ttl_proto);
|
||||
/* checksum */
|
||||
PACK_STRUCT_FIELD(u16_t _chksum);
|
||||
/* source and destination IP addresses */
|
||||
PACK_STRUCT_FIELD(struct ip_addr src);
|
||||
PACK_STRUCT_FIELD(struct ip_addr dest);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
#define IPH_V(hdr) (ntohs((hdr)->_v_hl_tos) >> 12)
|
||||
#define IPH_HL(hdr) ((ntohs((hdr)->_v_hl_tos) >> 8) & 0x0f)
|
||||
#define IPH_TOS(hdr) (ntohs((hdr)->_v_hl_tos) & 0xff)
|
||||
#define IPH_LEN(hdr) ((hdr)->_len)
|
||||
#define IPH_ID(hdr) ((hdr)->_id)
|
||||
#define IPH_OFFSET(hdr) ((hdr)->_offset)
|
||||
#define IPH_TTL(hdr) (ntohs((hdr)->_ttl_proto) >> 8)
|
||||
#define IPH_PROTO(hdr) (ntohs((hdr)->_ttl_proto) & 0xff)
|
||||
#define IPH_CHKSUM(hdr) ((hdr)->_chksum)
|
||||
|
||||
#define IPH_VHLTOS_SET(hdr, v, hl, tos) (hdr)->_v_hl_tos = (htons(((v) << 12) | ((hl) << 8) | (tos)))
|
||||
#define IPH_LEN_SET(hdr, len) (hdr)->_len = (len)
|
||||
#define IPH_ID_SET(hdr, id) (hdr)->_id = (id)
|
||||
#define IPH_OFFSET_SET(hdr, off) (hdr)->_offset = (off)
|
||||
#define IPH_TTL_SET(hdr, ttl) (hdr)->_ttl_proto = (htons(IPH_PROTO(hdr) | ((ttl) << 8)))
|
||||
#define IPH_PROTO_SET(hdr, proto) (hdr)->_ttl_proto = (htons((proto) | (IPH_TTL(hdr) << 8)))
|
||||
#define IPH_CHKSUM_SET(hdr, chksum) (hdr)->_chksum = (chksum)
|
||||
|
||||
#if IP_DEBUG
|
||||
void ip_debug_print(struct pbuf *p);
|
||||
#else
|
||||
#define ip_debug_print(p)
|
||||
#endif /* IP_DEBUG */
|
||||
|
||||
#endif /* __LWIP_IP_H__ */
|
||||
|
||||
|
@ -1,162 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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 lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __LWIP_IP_ADDR_H__
|
||||
#define __LWIP_IP_ADDR_H__
|
||||
|
||||
#include "lwip/arch.h"
|
||||
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct ip_addr {
|
||||
PACK_STRUCT_FIELD(u32_t addr);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct ip_addr2 {
|
||||
PACK_STRUCT_FIELD(u16_t addrw[2]);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/* For compatibility with BSD code */
|
||||
#ifndef HAVE_IN_ADDR
|
||||
#define HAVE_IN_ADDR
|
||||
struct in_addr {
|
||||
u32_t s_addr;
|
||||
};
|
||||
#endif
|
||||
|
||||
struct netif;
|
||||
|
||||
extern const struct ip_addr ip_addr_any;
|
||||
extern const struct ip_addr ip_addr_broadcast;
|
||||
|
||||
/** IP_ADDR_ can be used as a fixed IP address
|
||||
* for the wildcard and the broadcast address
|
||||
*/
|
||||
#define IP_ADDR_ANY ((struct ip_addr *)&ip_addr_any)
|
||||
#define IP_ADDR_BROADCAST ((struct ip_addr *)&ip_addr_broadcast)
|
||||
|
||||
#define INADDR_NONE ((u32_t) 0xffffffff) /* 255.255.255.255 */
|
||||
#define INADDR_LOOPBACK ((u32_t) 0x7f000001) /* 127.0.0.1 */
|
||||
|
||||
/* Definitions of the bits in an Internet address integer.
|
||||
|
||||
On subnets, host and network parts are found according to
|
||||
the subnet mask, not these masks. */
|
||||
|
||||
#define IN_CLASSA(a) ((((u32_t)(a)) & 0x80000000) == 0)
|
||||
#define IN_CLASSA_NET 0xff000000
|
||||
#define IN_CLASSA_NSHIFT 24
|
||||
#define IN_CLASSA_HOST (0xffffffff & ~IN_CLASSA_NET)
|
||||
#define IN_CLASSA_MAX 128
|
||||
|
||||
#define IN_CLASSB(a) ((((u32_t)(a)) & 0xc0000000) == 0x80000000)
|
||||
#define IN_CLASSB_NET 0xffff0000
|
||||
#define IN_CLASSB_NSHIFT 16
|
||||
#define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET)
|
||||
#define IN_CLASSB_MAX 65536
|
||||
|
||||
#define IN_CLASSC(a) ((((u32_t)(a)) & 0xe0000000) == 0xc0000000)
|
||||
#define IN_CLASSC_NET 0xffffff00
|
||||
#define IN_CLASSC_NSHIFT 8
|
||||
#define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET)
|
||||
|
||||
#define IN_CLASSD(a) (((u32_t)(a) & 0xf0000000) == 0xe0000000)
|
||||
#define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */
|
||||
#define IN_CLASSD_NSHIFT 28 /* net and host fields, but */
|
||||
#define IN_CLASSD_HOST 0x0fffffff /* routing needn't know. */
|
||||
#define IN_MULTICAST(a) IN_CLASSD(a)
|
||||
|
||||
#define IN_EXPERIMENTAL(a) (((u32_t)(a) & 0xf0000000) == 0xf0000000)
|
||||
#define IN_BADCLASS(a) (((u32_t)(a) & 0xf0000000) == 0xf0000000)
|
||||
|
||||
#define IN_LOOPBACKNET 127 /* official! */
|
||||
|
||||
|
||||
#define IP4_ADDR(ipaddr, a,b,c,d) (ipaddr)->addr = htonl(((u32_t)(a & 0xff) << 24) | ((u32_t)(b & 0xff) << 16) | \
|
||||
((u32_t)(c & 0xff) << 8) | (u32_t)(d & 0xff))
|
||||
|
||||
#define ip_addr_set(dest, src) (dest)->addr = \
|
||||
((src) == NULL? 0:\
|
||||
(src)->addr)
|
||||
/**
|
||||
* Determine if two address are on the same network.
|
||||
*
|
||||
* @arg addr1 IP address 1
|
||||
* @arg addr2 IP address 2
|
||||
* @arg mask network identifier mask
|
||||
* @return !0 if the network identifiers of both address match
|
||||
*/
|
||||
#define ip_addr_netcmp(addr1, addr2, mask) (((addr1)->addr & \
|
||||
(mask)->addr) == \
|
||||
((addr2)->addr & \
|
||||
(mask)->addr))
|
||||
#define ip_addr_cmp(addr1, addr2) ((addr1)->addr == (addr2)->addr)
|
||||
|
||||
#define ip_addr_isany(addr1) ((addr1) == NULL || (addr1)->addr == 0)
|
||||
|
||||
u8_t ip_addr_isbroadcast(struct ip_addr *, struct netif *);
|
||||
|
||||
#define ip_addr_ismulticast(addr1) (((addr1)->addr & ntohl(0xf0000000)) == ntohl(0xe0000000))
|
||||
|
||||
|
||||
#define ip_addr_debug_print(debug, ipaddr) LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F, \
|
||||
ipaddr?(u16_t)(ntohl((ipaddr)->addr) >> 24) & 0xff:0, \
|
||||
ipaddr?(u16_t)(ntohl((ipaddr)->addr) >> 16) & 0xff:0, \
|
||||
ipaddr?(u16_t)(ntohl((ipaddr)->addr) >> 8) & 0xff:0, \
|
||||
ipaddr?(u16_t)ntohl((ipaddr)->addr) & 0xff:0U))
|
||||
|
||||
/* cast to unsigned int, as it is used as argument to printf functions
|
||||
* which expect integer arguments. CSi: use cc.h formatters (conversion chars)! */
|
||||
#define ip4_addr1(ipaddr) ((u16_t)(ntohl((ipaddr)->addr) >> 24) & 0xff)
|
||||
#define ip4_addr2(ipaddr) ((u16_t)(ntohl((ipaddr)->addr) >> 16) & 0xff)
|
||||
#define ip4_addr3(ipaddr) ((u16_t)(ntohl((ipaddr)->addr) >> 8) & 0xff)
|
||||
#define ip4_addr4(ipaddr) ((u16_t)(ntohl((ipaddr)->addr)) & 0xff)
|
||||
#endif /* __LWIP_IP_ADDR_H__ */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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 lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Jani Monoses <jani@iv.ro>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __LWIP_IP_FRAG_H__
|
||||
#define __LWIP_IP_FRAG_H__
|
||||
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
|
||||
void ip_reass_tmr(void);
|
||||
struct pbuf * ip_reass(struct pbuf *p);
|
||||
err_t ip_frag(struct pbuf *p, struct netif *netif, struct ip_addr *dest);
|
||||
|
||||
#endif /* __LWIP_IP_FRAG_H__ */
|
||||
|
||||
|
@ -1,27 +0,0 @@
|
||||
/****************************************************************************
|
||||
* 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
|
@ -1,101 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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 lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __LWIP_API_H__
|
||||
#define __LWIP_API_H__
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/sys.h"
|
||||
|
||||
#include "lwip/ip.h"
|
||||
|
||||
#include "lwip/raw.h"
|
||||
#include "lwip/udp.h"
|
||||
#include "lwip/tcp.h"
|
||||
|
||||
#include "lwip/err.h"
|
||||
|
||||
#define NETCONN_NOCOPY 0x00
|
||||
#define NETCONN_COPY 0x01
|
||||
|
||||
enum netconn_type {
|
||||
NETCONN_TCP,
|
||||
NETCONN_UDP,
|
||||
NETCONN_UDPLITE,
|
||||
NETCONN_UDPNOCHKSUM,
|
||||
NETCONN_RAW
|
||||
};
|
||||
|
||||
enum netconn_state {
|
||||
NETCONN_NONE,
|
||||
NETCONN_WRITE,
|
||||
NETCONN_ACCEPT,
|
||||
NETCONN_RECV,
|
||||
NETCONN_CONNECT,
|
||||
NETCONN_CLOSE
|
||||
};
|
||||
|
||||
enum netconn_evt {
|
||||
NETCONN_EVTRCVPLUS,
|
||||
NETCONN_EVTRCVMINUS,
|
||||
NETCONN_EVTSENDPLUS,
|
||||
NETCONN_EVTSENDMINUS
|
||||
};
|
||||
|
||||
struct netbuf {
|
||||
struct pbuf *p, *ptr;
|
||||
struct ip_addr *fromaddr;
|
||||
u16_t fromport;
|
||||
err_t err;
|
||||
};
|
||||
|
||||
struct netconn {
|
||||
enum netconn_type type;
|
||||
enum netconn_state state;
|
||||
union {
|
||||
struct tcp_pcb *tcp;
|
||||
struct udp_pcb *udp;
|
||||
struct raw_pcb *raw;
|
||||
} pcb;
|
||||
err_t err;
|
||||
sys_sem sem;
|
||||
sys_mbox mbox;
|
||||
sys_mbox recvmbox;
|
||||
sys_mbox acceptmbox;
|
||||
u16 recvavail;
|
||||
s32 socket;
|
||||
void (*callback)(struct netconn *,enum netconn_evt,u32);
|
||||
};
|
||||
|
||||
#endif /* __LWIP_API_H__ */
|
||||
|
||||
|
@ -1,86 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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 lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __LWIP_API_MSG_H__
|
||||
#define __LWIP_API_MSG_H__
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/sys.h"
|
||||
|
||||
#include "lwip/ip.h"
|
||||
|
||||
#include "lwip/udp.h"
|
||||
#include "lwip/tcp.h"
|
||||
|
||||
#include "lwip/api.h"
|
||||
|
||||
enum apimsg_type {
|
||||
APIMSG_NEWCONN,
|
||||
APIMSG_DELCONN,
|
||||
APIMSG_BIND,
|
||||
APIMSG_CONNECT,
|
||||
APIMSG_DISCONNECT,
|
||||
APIMSG_LISTEN,
|
||||
APIMSG_ACCEPT,
|
||||
APIMSG_SEND,
|
||||
APIMSG_RECV,
|
||||
APIMSG_WRITE,
|
||||
APIMSG_CLOSE,
|
||||
APIMSG_MAX
|
||||
};
|
||||
|
||||
struct apimsg_msg {
|
||||
struct netconn *conn;
|
||||
enum netconn_type type;
|
||||
union {
|
||||
struct pbuf *p;
|
||||
struct {
|
||||
struct ip_addr *ipaddr;
|
||||
u16 port;
|
||||
} bc;
|
||||
struct {
|
||||
void *dataptr;
|
||||
u32 len;
|
||||
u8 copy;
|
||||
} w;
|
||||
sys_mbox mbox;
|
||||
u16 len;
|
||||
} msg;
|
||||
};
|
||||
|
||||
struct api_msg {
|
||||
enum apimsg_type type;
|
||||
struct apimsg_msg msg;
|
||||
};
|
||||
|
||||
#endif /* __LWIP_API_MSG_H__ */
|
||||
|
@ -1,216 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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 lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __LWIP_ARCH_H__
|
||||
#define __LWIP_ARCH_H__
|
||||
|
||||
#ifndef LITTLE_ENDIAN
|
||||
#define LITTLE_ENDIAN 1234
|
||||
#endif
|
||||
|
||||
#ifndef BIG_ENDIAN
|
||||
#define BIG_ENDIAN 4321
|
||||
#endif
|
||||
|
||||
#include "arch/cc.h"
|
||||
|
||||
#ifndef PACK_STRUCT_BEGIN
|
||||
#define PACK_STRUCT_BEGIN
|
||||
#endif /* PACK_STRUCT_BEGIN */
|
||||
|
||||
#ifndef PACK_STRUCT_END
|
||||
#define PACK_STRUCT_END
|
||||
#endif /* PACK_STRUCT_END */
|
||||
|
||||
#ifndef PACK_STRUCT_FIELD
|
||||
#define PACK_STRUCT_FIELD(x) x
|
||||
#endif /* PACK_STRUCT_FIELD */
|
||||
|
||||
|
||||
|
||||
#ifdef LWIP_PROVIDE_ERRNO
|
||||
|
||||
#define EPERM 1 /* Operation not permitted */
|
||||
#define ENOENT 2 /* No such file or directory */
|
||||
#define ESRCH 3 /* No such process */
|
||||
#define EINTR 4 /* Interrupted system call */
|
||||
#define EIO 5 /* I/O error */
|
||||
#define ENXIO 6 /* No such device or address */
|
||||
#define E2BIG 7 /* Arg list too long */
|
||||
#define ENOEXEC 8 /* Exec format error */
|
||||
#define EBADF 9 /* Bad file number */
|
||||
#define ECHILD 10 /* No child processes */
|
||||
#define EAGAIN 11 /* Try again */
|
||||
#define ENOMEM 12 /* Out of memory */
|
||||
#define EACCES 13 /* Permission denied */
|
||||
#define EFAULT 14 /* Bad address */
|
||||
#define ENOTBLK 15 /* Block device required */
|
||||
#define EBUSY 16 /* Device or resource busy */
|
||||
#define EEXIST 17 /* File exists */
|
||||
#define EXDEV 18 /* Cross-device link */
|
||||
#define ENODEV 19 /* No such device */
|
||||
#define ENOTDIR 20 /* Not a directory */
|
||||
#define EISDIR 21 /* Is a directory */
|
||||
#define EINVAL 22 /* Invalid argument */
|
||||
#define ENFILE 23 /* File table overflow */
|
||||
#define EMFILE 24 /* Too many open files */
|
||||
#define ENOTTY 25 /* Not a typewriter */
|
||||
#define ETXTBSY 26 /* Text file busy */
|
||||
#define EFBIG 27 /* File too large */
|
||||
#define ENOSPC 28 /* No space left on device */
|
||||
#define ESPIPE 29 /* Illegal seek */
|
||||
#define EROFS 30 /* Read-only file system */
|
||||
#define EMLINK 31 /* Too many links */
|
||||
#define EPIPE 32 /* Broken pipe */
|
||||
#define EDOM 33 /* Math argument out of domain of func */
|
||||
#define ERANGE 34 /* Math result not representable */
|
||||
#define EDEADLK 35 /* Resource deadlock would occur */
|
||||
#define ENAMETOOLONG 36 /* File name too long */
|
||||
#define ENOLCK 37 /* No record locks available */
|
||||
#define ENOSYS 38 /* Function not implemented */
|
||||
#define ENOTEMPTY 39 /* Directory not empty */
|
||||
#define ELOOP 40 /* Too many symbolic links encountered */
|
||||
#define EWOULDBLOCK EAGAIN /* Operation would block */
|
||||
#define ENOMSG 42 /* No message of desired type */
|
||||
#define EIDRM 43 /* Identifier removed */
|
||||
#define ECHRNG 44 /* Channel number out of range */
|
||||
#define EL2NSYNC 45 /* Level 2 not synchronized */
|
||||
#define EL3HLT 46 /* Level 3 halted */
|
||||
#define EL3RST 47 /* Level 3 reset */
|
||||
#define ELNRNG 48 /* Link number out of range */
|
||||
#define EUNATCH 49 /* Protocol driver not attached */
|
||||
#define ENOCSI 50 /* No CSI structure available */
|
||||
#define EL2HLT 51 /* Level 2 halted */
|
||||
#define EBADE 52 /* Invalid exchange */
|
||||
#define EBADR 53 /* Invalid request descriptor */
|
||||
#define EXFULL 54 /* Exchange full */
|
||||
#define ENOANO 55 /* No anode */
|
||||
#define EBADRQC 56 /* Invalid request code */
|
||||
#define EBADSLT 57 /* Invalid slot */
|
||||
|
||||
#define EDEADLOCK EDEADLK
|
||||
|
||||
#define EBFONT 59 /* Bad font file format */
|
||||
#define ENOSTR 60 /* Device not a stream */
|
||||
#define ENODATA 61 /* No data available */
|
||||
#define ETIME 62 /* Timer expired */
|
||||
#define ENOSR 63 /* Out of streams resources */
|
||||
#define ENONET 64 /* Machine is not on the network */
|
||||
#define ENOPKG 65 /* Package not installed */
|
||||
#define EREMOTE 66 /* Object is remote */
|
||||
#define ENOLINK 67 /* Link has been severed */
|
||||
#define EADV 68 /* Advertise error */
|
||||
#define ESRMNT 69 /* Srmount error */
|
||||
#define ECOMM 70 /* Communication error on send */
|
||||
#define EPROTO 71 /* Protocol error */
|
||||
#define EMULTIHOP 72 /* Multihop attempted */
|
||||
#define EDOTDOT 73 /* RFS specific error */
|
||||
#define EBADMSG 74 /* Not a data message */
|
||||
#define EOVERFLOW 75 /* Value too large for defined data type */
|
||||
#define ENOTUNIQ 76 /* Name not unique on network */
|
||||
#define EBADFD 77 /* File descriptor in bad state */
|
||||
#define EREMCHG 78 /* Remote address changed */
|
||||
#define ELIBACC 79 /* Can not access a needed shared library */
|
||||
#define ELIBBAD 80 /* Accessing a corrupted shared library */
|
||||
#define ELIBSCN 81 /* .lib section in a.out corrupted */
|
||||
#define ELIBMAX 82 /* Attempting to link in too many shared libraries */
|
||||
#define ELIBEXEC 83 /* Cannot exec a shared library directly */
|
||||
#define EILSEQ 84 /* Illegal byte sequence */
|
||||
#define ERESTART 85 /* Interrupted system call should be restarted */
|
||||
#define ESTRPIPE 86 /* Streams pipe error */
|
||||
#define EUSERS 87 /* Too many users */
|
||||
#define ENOTSOCK 88 /* Socket operation on non-socket */
|
||||
#define EDESTADDRREQ 89 /* Destination address required */
|
||||
#define EMSGSIZE 90 /* Message too long */
|
||||
#define EPROTOTYPE 91 /* Protocol wrong type for socket */
|
||||
#define ENOPROTOOPT 92 /* Protocol not available */
|
||||
#define EPROTONOSUPPORT 93 /* Protocol not supported */
|
||||
#define ESOCKTNOSUPPORT 94 /* Socket type not supported */
|
||||
#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
|
||||
#define EPFNOSUPPORT 96 /* Protocol family not supported */
|
||||
#define EAFNOSUPPORT 97 /* Address family not supported by protocol */
|
||||
#define EADDRINUSE 98 /* Address already in use */
|
||||
#define EADDRNOTAVAIL 99 /* Cannot assign requested address */
|
||||
#define ENETDOWN 100 /* Network is down */
|
||||
#define ENETUNREACH 101 /* Network is unreachable */
|
||||
#define ENETRESET 102 /* Network dropped connection because of reset */
|
||||
#define ECONNABORTED 103 /* Software caused connection abort */
|
||||
#define ECONNRESET 104 /* Connection reset by peer */
|
||||
#define ENOBUFS 105 /* No buffer space available */
|
||||
#define EISCONN 106 /* Transport endpoint is already connected */
|
||||
#define ENOTCONN 107 /* Transport endpoint is not connected */
|
||||
#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */
|
||||
#define ETOOMANYREFS 109 /* Too many references: cannot splice */
|
||||
#define ETIMEDOUT 110 /* Connection timed out */
|
||||
#define ECONNREFUSED 111 /* Connection refused */
|
||||
#define EHOSTDOWN 112 /* Host is down */
|
||||
#define EHOSTUNREACH 113 /* No route to host */
|
||||
#define EALREADY 114 /* Operation already in progress */
|
||||
#define EINPROGRESS 115 /* Operation now in progress */
|
||||
#define ESTALE 116 /* Stale NFS file handle */
|
||||
#define EUCLEAN 117 /* Structure needs cleaning */
|
||||
#define ENOTNAM 118 /* Not a XENIX named type file */
|
||||
#define ENAVAIL 119 /* No XENIX semaphores available */
|
||||
#define EISNAM 120 /* Is a named type file */
|
||||
#define EREMOTEIO 121 /* Remote I/O error */
|
||||
#define EDQUOT 122 /* Quota exceeded */
|
||||
|
||||
#define ENOMEDIUM 123 /* No medium found */
|
||||
#define EMEDIUMTYPE 124 /* Wrong medium type */
|
||||
|
||||
|
||||
#define ENSROK 0 /* DNS server returned answer with no data */
|
||||
#define ENSRNODATA 160 /* DNS server returned answer with no data */
|
||||
#define ENSRFORMERR 161 /* DNS server claims query was misformatted */
|
||||
#define ENSRSERVFAIL 162 /* DNS server returned general failure */
|
||||
#define ENSRNOTFOUND 163 /* Domain name not found */
|
||||
#define ENSRNOTIMP 164 /* DNS server does not implement requested operation */
|
||||
#define ENSRREFUSED 165 /* DNS server refused query */
|
||||
#define ENSRBADQUERY 166 /* Misformatted DNS query */
|
||||
#define ENSRBADNAME 167 /* Misformatted domain name */
|
||||
#define ENSRBADFAMILY 168 /* Unsupported address family */
|
||||
#define ENSRBADRESP 169 /* Misformatted DNS reply */
|
||||
#define ENSRCONNREFUSED 170 /* Could not contact DNS servers */
|
||||
#define ENSRTIMEOUT 171 /* Timeout while contacting DNS servers */
|
||||
#define ENSROF 172 /* End of file */
|
||||
#define ENSRFILE 173 /* Error reading file */
|
||||
#define ENSRNOMEM 174 /* Out of memory */
|
||||
#define ENSRDESTRUCTION 175 /* Application terminated lookup */
|
||||
#define ENSRQUERYDOMAINTOOLONG 176 /* Domain name is too long */
|
||||
#define ENSRCNAMELOOP 177 /* Domain name is too long */
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_PROVIDE_ERRNO */
|
||||
|
||||
#endif /* __LWIP_ARCH_H__ */
|
@ -1,90 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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 lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __LWIP_DEBUG_H__
|
||||
#define __LWIP_DEBUG_H__
|
||||
|
||||
#include "arch/cc.h"
|
||||
|
||||
/** lower two bits indicate debug level
|
||||
* - 0 off
|
||||
* - 1 warning
|
||||
* - 2 serious
|
||||
* - 3 severe
|
||||
*/
|
||||
|
||||
#define DBG_LEVEL_OFF 0
|
||||
#define DBG_LEVEL_WARNING 1 /* bad checksums, dropped packets, ... */
|
||||
#define DBG_LEVEL_SERIOUS 2 /* memory allocation failures, ... */
|
||||
#define DBG_LEVEL_SEVERE 3 /* */
|
||||
#define DBG_MASK_LEVEL 3
|
||||
|
||||
/** flag for LWIP_DEBUGF to enable that debug message */
|
||||
#define DBG_ON 0x80U
|
||||
/** flag for LWIP_DEBUGF to disable that debug message */
|
||||
#define DBG_OFF 0x00U
|
||||
|
||||
/** flag for LWIP_DEBUGF indicating a tracing message (to follow program flow) */
|
||||
#define DBG_TRACE 0x40U
|
||||
/** flag for LWIP_DEBUGF indicating a state debug message (to follow module states) */
|
||||
#define DBG_STATE 0x20U
|
||||
/** flag for LWIP_DEBUGF indicating newly added code, not thoroughly tested yet */
|
||||
#define DBG_FRESH 0x10U
|
||||
/** flag for LWIP_DEBUGF to halt after printing this debug message */
|
||||
#define DBG_HALT 0x08U
|
||||
|
||||
#ifdef LWIP_DEBUG
|
||||
# ifndef LWIP_NOASSERT
|
||||
# define LWIP_ASSERT(x,y) do { if(!(y)) LWIP_PLATFORM_ASSERT(x); } while(0)
|
||||
# else
|
||||
# define LWIP_ASSERT(x,y)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_DEBUG
|
||||
/** print debug message only if debug message type is enabled...
|
||||
* AND is of correct type AND is at least DBG_LEVEL
|
||||
*/
|
||||
# define LWIP_DEBUGF(debug,x) do { if (((debug) & DBG_ON) && ((debug) & DBG_TYPES_ON) && ((int)((debug) & DBG_MASK_LEVEL) >= DBG_MIN_LEVEL)) { LWIP_PLATFORM_DIAG(x); if ((debug) & DBG_HALT) while(1); } } while(0)
|
||||
# define LWIP_ERROR(x) do { LWIP_PLATFORM_DIAG(x); } while(0)
|
||||
#else /* LWIP_DEBUG */
|
||||
# define LWIP_ASSERT(x,y)
|
||||
# define LWIP_DEBUGF(debug,x)
|
||||
# define LWIP_ERROR(x)
|
||||
#endif /* LWIP_DEBUG */
|
||||
|
||||
#endif /* __LWIP_DEBUG_H__ */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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 lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __LWIP_DEF_H__
|
||||
#define __LWIP_DEF_H__
|
||||
|
||||
/* this might define NULL already */
|
||||
#include "arch/cc.h"
|
||||
|
||||
#define LWIP_MAX(x , y) (x) > (y) ? (x) : (y)
|
||||
#define LWIP_MIN(x , y) (x) < (y) ? (x) : (y)
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __LWIP_DEF_H__ */
|
||||
|
@ -1,223 +0,0 @@
|
||||
/** @file
|
||||
*/
|
||||
|
||||
#ifndef __LWIP_DHCP_H__
|
||||
#define __LWIP_DHCP_H__
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/udp.h"
|
||||
|
||||
/** period (in seconds) of the application calling dhcp_coarse_tmr() */
|
||||
#define DHCP_COARSE_TIMER_SECS 60
|
||||
/** period (in milliseconds) of the application calling dhcp_fine_tmr() */
|
||||
#define DHCP_FINE_TIMER_MSECS 500
|
||||
|
||||
struct dhcp
|
||||
{
|
||||
/** current DHCP state machine state */
|
||||
u8_t state;
|
||||
/** retries of current request */
|
||||
u8_t tries;
|
||||
/** transaction identifier of last sent request */
|
||||
u32_t xid;
|
||||
/** our connection to the DHCP server */
|
||||
struct udp_pcb *pcb;
|
||||
/** (first) pbuf of incoming msg */
|
||||
struct pbuf *p;
|
||||
/** incoming msg */
|
||||
struct dhcp_msg *msg_in;
|
||||
/** incoming msg options */
|
||||
struct dhcp_msg *options_in;
|
||||
/** ingoing msg options length */
|
||||
u16_t options_in_len;
|
||||
|
||||
struct pbuf *p_out; /* pbuf of outcoming msg */
|
||||
struct dhcp_msg *msg_out; /* outgoing msg */
|
||||
u16_t options_out_len; /* outgoing msg options length */
|
||||
u16_t request_timeout; /* #ticks with period DHCP_FINE_TIMER_SECS for request timeout */
|
||||
u16_t t1_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for renewal time */
|
||||
u16_t t2_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for rebind time */
|
||||
struct ip_addr server_ip_addr; /* dhcp server address that offered this lease */
|
||||
struct ip_addr offered_ip_addr;
|
||||
struct ip_addr offered_sn_mask;
|
||||
struct ip_addr offered_gw_addr;
|
||||
struct ip_addr offered_bc_addr;
|
||||
#define DHCP_MAX_DNS 2
|
||||
u32_t dns_count; /* actual number of DNS servers obtained */
|
||||
struct ip_addr offered_dns_addr[DHCP_MAX_DNS]; /* DNS server addresses */
|
||||
|
||||
u32_t offered_t0_lease; /* lease period (in seconds) */
|
||||
u32_t offered_t1_renew; /* recommended renew time (usually 50% of lease period) */
|
||||
u32_t offered_t2_rebind; /* recommended rebind time (usually 66% of lease period) */
|
||||
/** Patch #1308
|
||||
* TODO: See dhcp.c "TODO"s
|
||||
*/
|
||||
#if 0
|
||||
struct ip_addr offered_si_addr;
|
||||
u8_t *boot_file_name;
|
||||
#endif
|
||||
};
|
||||
|
||||
/* MUST be compiled with "pack structs" or equivalent! */
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
/** minimum set of fields of any DHCP message */
|
||||
struct dhcp_msg
|
||||
{
|
||||
PACK_STRUCT_FIELD(u8_t op);
|
||||
PACK_STRUCT_FIELD(u8_t htype);
|
||||
PACK_STRUCT_FIELD(u8_t hlen);
|
||||
PACK_STRUCT_FIELD(u8_t hops);
|
||||
PACK_STRUCT_FIELD(u32_t xid);
|
||||
PACK_STRUCT_FIELD(u16_t secs);
|
||||
PACK_STRUCT_FIELD(u16_t flags);
|
||||
PACK_STRUCT_FIELD(struct ip_addr ciaddr);
|
||||
PACK_STRUCT_FIELD(struct ip_addr yiaddr);
|
||||
PACK_STRUCT_FIELD(struct ip_addr siaddr);
|
||||
PACK_STRUCT_FIELD(struct ip_addr giaddr);
|
||||
#define DHCP_CHADDR_LEN 16U
|
||||
PACK_STRUCT_FIELD(u8_t chaddr[DHCP_CHADDR_LEN]);
|
||||
#define DHCP_SNAME_LEN 64U
|
||||
PACK_STRUCT_FIELD(u8_t sname[DHCP_SNAME_LEN]);
|
||||
#define DHCP_FILE_LEN 128U
|
||||
PACK_STRUCT_FIELD(u8_t file[DHCP_FILE_LEN]);
|
||||
PACK_STRUCT_FIELD(u32_t cookie);
|
||||
#define DHCP_MIN_OPTIONS_LEN 68U
|
||||
/** make sure user does not configure this too small */
|
||||
#if ((defined(DHCP_OPTIONS_LEN)) && (DHCP_OPTIONS_LEN < DHCP_MIN_OPTIONS_LEN))
|
||||
# undef DHCP_OPTIONS_LEN
|
||||
#endif
|
||||
/** allow this to be configured in lwipopts.h, but not too small */
|
||||
#if (!defined(DHCP_OPTIONS_LEN))
|
||||
/** set this to be sufficient for your options in outgoing DHCP msgs */
|
||||
# define DHCP_OPTIONS_LEN DHCP_MIN_OPTIONS_LEN
|
||||
#endif
|
||||
PACK_STRUCT_FIELD(u8_t options[DHCP_OPTIONS_LEN]);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/** start DHCP configuration */
|
||||
err_t dhcp_start(struct netif *netif);
|
||||
/** enforce early lease renewal (not needed normally)*/
|
||||
err_t dhcp_renew(struct netif *netif);
|
||||
/** release the DHCP lease, usually called before dhcp_stop()*/
|
||||
err_t dhcp_release(struct netif *netif);
|
||||
/** stop DHCP configuration */
|
||||
void dhcp_stop(struct netif *netif);
|
||||
/** inform server of our manual IP address */
|
||||
void dhcp_inform(struct netif *netif);
|
||||
|
||||
/** if enabled, check whether the offered IP address is not in use, using ARP */
|
||||
#if DHCP_DOES_ARP_CHECK
|
||||
void dhcp_arp_reply(struct netif *netif, struct ip_addr *addr);
|
||||
#endif
|
||||
|
||||
/** to be called every minute */
|
||||
void dhcp_coarse_tmr(void);
|
||||
/** to be called every half second */
|
||||
void dhcp_fine_tmr(void);
|
||||
|
||||
/** DHCP message item offsets and length */
|
||||
#define DHCP_MSG_OFS (UDP_DATA_OFS)
|
||||
#define DHCP_OP_OFS (DHCP_MSG_OFS + 0)
|
||||
#define DHCP_HTYPE_OFS (DHCP_MSG_OFS + 1)
|
||||
#define DHCP_HLEN_OFS (DHCP_MSG_OFS + 2)
|
||||
#define DHCP_HOPS_OFS (DHCP_MSG_OFS + 3)
|
||||
#define DHCP_XID_OFS (DHCP_MSG_OFS + 4)
|
||||
#define DHCP_SECS_OFS (DHCP_MSG_OFS + 8)
|
||||
#define DHCP_FLAGS_OFS (DHCP_MSG_OFS + 10)
|
||||
#define DHCP_CIADDR_OFS (DHCP_MSG_OFS + 12)
|
||||
#define DHCP_YIADDR_OFS (DHCP_MSG_OFS + 16)
|
||||
#define DHCP_SIADDR_OFS (DHCP_MSG_OFS + 20)
|
||||
#define DHCP_GIADDR_OFS (DHCP_MSG_OFS + 24)
|
||||
#define DHCP_CHADDR_OFS (DHCP_MSG_OFS + 28)
|
||||
#define DHCP_SNAME_OFS (DHCP_MSG_OFS + 44)
|
||||
#define DHCP_FILE_OFS (DHCP_MSG_OFS + 108)
|
||||
#define DHCP_MSG_LEN 236
|
||||
|
||||
#define DHCP_COOKIE_OFS (DHCP_MSG_OFS + DHCP_MSG_LEN)
|
||||
#define DHCP_OPTIONS_OFS (DHCP_MSG_OFS + DHCP_MSG_LEN + 4)
|
||||
|
||||
#define DHCP_CLIENT_PORT 68
|
||||
#define DHCP_SERVER_PORT 67
|
||||
|
||||
/** DHCP client states */
|
||||
#define DHCP_REQUESTING 1
|
||||
#define DHCP_INIT 2
|
||||
#define DHCP_REBOOTING 3
|
||||
#define DHCP_REBINDING 4
|
||||
#define DHCP_RENEWING 5
|
||||
#define DHCP_SELECTING 6
|
||||
#define DHCP_INFORMING 7
|
||||
#define DHCP_CHECKING 8
|
||||
#define DHCP_PERMANENT 9
|
||||
#define DHCP_BOUND 10
|
||||
/** not yet implemented #define DHCP_RELEASING 11 */
|
||||
#define DHCP_BACKING_OFF 12
|
||||
#define DHCP_OFF 13
|
||||
|
||||
#define DHCP_BOOTREQUEST 1
|
||||
#define DHCP_BOOTREPLY 2
|
||||
|
||||
#define DHCP_DISCOVER 1
|
||||
#define DHCP_OFFER 2
|
||||
#define DHCP_REQUEST 3
|
||||
#define DHCP_DECLINE 4
|
||||
#define DHCP_ACK 5
|
||||
#define DHCP_NAK 6
|
||||
#define DHCP_RELEASE 7
|
||||
#define DHCP_INFORM 8
|
||||
|
||||
#define DHCP_HTYPE_ETH 1
|
||||
|
||||
#define DHCP_HLEN_ETH 6
|
||||
|
||||
#define DHCP_BROADCAST_FLAG 15
|
||||
#define DHCP_BROADCAST_MASK (1 << DHCP_FLAG_BROADCAST)
|
||||
|
||||
/** BootP options */
|
||||
#define DHCP_OPTION_PAD 0
|
||||
#define DHCP_OPTION_SUBNET_MASK 1 /* RFC 2132 3.3 */
|
||||
#define DHCP_OPTION_ROUTER 3
|
||||
#define DHCP_OPTION_DNS_SERVER 6
|
||||
#define DHCP_OPTION_HOSTNAME 12
|
||||
#define DHCP_OPTION_IP_TTL 23
|
||||
#define DHCP_OPTION_MTU 26
|
||||
#define DHCP_OPTION_BROADCAST 28
|
||||
#define DHCP_OPTION_TCP_TTL 37
|
||||
#define DHCP_OPTION_END 255
|
||||
|
||||
/** DHCP options */
|
||||
#define DHCP_OPTION_REQUESTED_IP 50 /* RFC 2132 9.1, requested IP address */
|
||||
#define DHCP_OPTION_LEASE_TIME 51 /* RFC 2132 9.2, time in seconds, in 4 bytes */
|
||||
#define DHCP_OPTION_OVERLOAD 52 /* RFC2132 9.3, use file and/or sname field for options */
|
||||
|
||||
#define DHCP_OPTION_MESSAGE_TYPE 53 /* RFC 2132 9.6, important for DHCP */
|
||||
#define DHCP_OPTION_MESSAGE_TYPE_LEN 1
|
||||
|
||||
|
||||
#define DHCP_OPTION_SERVER_ID 54 /* RFC 2132 9.7, server IP address */
|
||||
#define DHCP_OPTION_PARAMETER_REQUEST_LIST 55 /* RFC 2132 9.8, requested option types */
|
||||
|
||||
#define DHCP_OPTION_MAX_MSG_SIZE 57 /* RFC 2132 9.10, message size accepted >= 576 */
|
||||
#define DHCP_OPTION_MAX_MSG_SIZE_LEN 2
|
||||
|
||||
#define DHCP_OPTION_T1 58 /* T1 renewal time */
|
||||
#define DHCP_OPTION_T2 59 /* T2 rebinding time */
|
||||
#define DHCP_OPTION_CLIENT_ID 61
|
||||
#define DHCP_OPTION_TFTP_SERVERNAME 66
|
||||
#define DHCP_OPTION_BOOTFILE 67
|
||||
|
||||
/** possible combinations of overloading the file and sname fields with options */
|
||||
#define DHCP_OVERLOAD_NONE 0
|
||||
#define DHCP_OVERLOAD_FILE 1
|
||||
#define DHCP_OVERLOAD_SNAME 2
|
||||
#define DHCP_OVERLOAD_SNAME_FILE 3
|
||||
|
||||
#endif /*__LWIP_DHCP_H__*/
|
@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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 lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __LWIP_ERR_H__
|
||||
#define __LWIP_ERR_H__
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#include "arch/cc.h"
|
||||
|
||||
typedef s8_t err_t;
|
||||
|
||||
/* Definitions for error constants. */
|
||||
|
||||
#define ERR_OK 0 /* No error, everything OK. */
|
||||
#define ERR_MEM -1 /* Out of memory error. */
|
||||
#define ERR_BUF -2 /* Buffer error. */
|
||||
|
||||
|
||||
#define ERR_ABRT -3 /* Connection aborted. */
|
||||
#define ERR_RST -4 /* Connection reset. */
|
||||
#define ERR_CLSD -5 /* Connection closed. */
|
||||
#define ERR_CONN -6 /* Not connected. */
|
||||
|
||||
#define ERR_VAL -7 /* Illegal value. */
|
||||
|
||||
#define ERR_ARG -8 /* Illegal argument. */
|
||||
|
||||
#define ERR_RTE -9 /* Routing problem. */
|
||||
|
||||
#define ERR_USE -10 /* Address in use. */
|
||||
|
||||
#define ERR_IF -11 /* Low-level netif error */
|
||||
#define ERR_ISCONN -12 /* Already connected. */
|
||||
|
||||
|
||||
#ifdef LWIP_DEBUG
|
||||
extern char *lwip_strerr(err_t err);
|
||||
#else
|
||||
#define lwip_strerr(x) ""
|
||||
#endif /* LWIP_DEBUG */
|
||||
#endif /* __LWIP_ERR_H__ */
|
@ -1,218 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
|
||||
* 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 lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __LWIPOPTS_H__
|
||||
#define __LWIPOPTS_H__
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define BYTE_ORDER BIG_ENDIAN
|
||||
#define NO_SYS 1
|
||||
#define LWIP_CALLBACK_API 1
|
||||
#undef LWIP_EVENT_API
|
||||
#define TCPIP_THREAD_PRIO 125
|
||||
#define SYS_LIGHTWEIGHT_PROT 1
|
||||
|
||||
/* ---------- Memory options ---------- */
|
||||
/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which
|
||||
lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2
|
||||
byte alignment -> define MEM_ALIGNMENT to 2. */
|
||||
#define MEM_ALIGNMENT 4
|
||||
|
||||
/* MEM_SIZE: the size of the heap memory. If the application will send
|
||||
a lot of data that needs to be copied, this should be set high. */
|
||||
#define MEM_SIZE (192*1024)
|
||||
|
||||
/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
|
||||
sends a lot of data out of ROM (or other static memory), this
|
||||
should be set high. */
|
||||
#define MEMP_NUM_PBUF 128
|
||||
/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
|
||||
per active UDP "connection". */
|
||||
#define MEMP_NUM_UDP_PCB 16
|
||||
/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
|
||||
connections. */
|
||||
#define MEMP_NUM_TCP_PCB 16
|
||||
/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
|
||||
connections. */
|
||||
#define MEMP_NUM_TCP_PCB_LISTEN 8
|
||||
/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
|
||||
segments. */
|
||||
#define MEMP_NUM_TCP_SEG 128
|
||||
|
||||
/* The following four are used only with the sequential API and can be
|
||||
set to 0 if the application only will use the raw API. */
|
||||
/* MEMP_NUM_NETBUF: the number of struct netbufs. */
|
||||
#define MEMP_NUM_NETBUF 16
|
||||
/* MEMP_NUM_NETCONN: the number of struct netconns. */
|
||||
#define MEMP_NUM_NETCONN 16
|
||||
/* MEMP_NUM_APIMSG: the number of struct api_msg, used for
|
||||
communication between the TCP/IP stack and the sequential
|
||||
programs. */
|
||||
#define MEMP_NUM_API_MSG 128
|
||||
/* MEMP_NUM_TCPIPMSG: the number of struct tcpip_msg, which is used
|
||||
for sequential API communication and incoming packets. Used in
|
||||
src/api/tcpip.c. */
|
||||
#define MEMP_NUM_TCPIP_MSG 128
|
||||
/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
|
||||
timeouts. */
|
||||
#define MEMP_NUM_SYS_TIMEOUT 0
|
||||
|
||||
/* ---------- Pbuf options ---------- */
|
||||
/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
|
||||
#define PBUF_POOL_SIZE 128 //128
|
||||
|
||||
/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
|
||||
#define PBUF_POOL_BUFSIZE 1600
|
||||
|
||||
/* PBUF_LINK_HLEN: the number of bytes that should be allocated for a
|
||||
link level header. */
|
||||
#define PBUF_LINK_HLEN 16
|
||||
|
||||
/* ---------- TCP options ---------- */
|
||||
#define LWIP_TCP 1
|
||||
#define TCP_TTL 255
|
||||
|
||||
/* Controls if TCP should queue segments that arrive out of
|
||||
order. Define to 0 if your device is low on memory. */
|
||||
#define TCP_QUEUE_OOSEQ 1
|
||||
|
||||
/* TCP Maximum segment size. */
|
||||
#define TCP_MSS 1460
|
||||
|
||||
/* TCP sender buffer space (bytes). */
|
||||
#define TCP_SND_BUF (36*TCP_MSS)
|
||||
|
||||
/* TCP sender buffer space (pbufs). This must be at least = 2 *
|
||||
TCP_SND_BUF/TCP_MSS for things to work. */
|
||||
#define TCP_SND_QUEUELEN (36*TCP_SND_BUF/TCP_MSS)
|
||||
|
||||
/* TCP receive window. */
|
||||
#define TCP_WND (36*TCP_MSS)
|
||||
|
||||
/* Maximum number of retransmissions of data segments. */
|
||||
#define TCP_MAXRTX 12
|
||||
|
||||
/* Maximum number of retransmissions of SYN segments. */
|
||||
#define TCP_SYNMAXRTX 4
|
||||
|
||||
/* ---------- ARP options ---------- */
|
||||
/**
|
||||
* - If enabled, cache entries are generated for every kind of ARP traffic or
|
||||
* broadcast IP traffic. This enhances behaviour for sending to a dynamic set
|
||||
* of hosts, for example if acting as a gateway.
|
||||
* - If disabled, cache entries are generated only for IP destination addresses
|
||||
* in use by lwIP or applications. This enhances performance if sending to a small,
|
||||
* reasonably static number of hosts. Typically for embedded devices.
|
||||
*/
|
||||
|
||||
/* ---------- IP options ---------- */
|
||||
/* Define IP_FORWARD to 1 if you wish to have the ability to forward
|
||||
IP packets across network interfaces. If you are going to run lwIP
|
||||
on a device with only one network interface, define this to 0. */
|
||||
#define IP_FORWARD 0
|
||||
|
||||
/* If defined to 1, IP options are allowed (but not parsed). If
|
||||
defined to 0, all packets with IP options are dropped. */
|
||||
#define IP_OPTIONS 1
|
||||
|
||||
/* ---------- ICMP options ---------- */
|
||||
#define ICMP_TTL 255
|
||||
|
||||
|
||||
/* ---------- DHCP options ---------- */
|
||||
/* Define LWIP_DHCP to 1 if you want DHCP configuration of
|
||||
interfaces. DHCP is not implemented in lwIP 0.5.1, however, so
|
||||
turning this on does currently not work. */
|
||||
#define LWIP_DHCP 1
|
||||
|
||||
/* 1 if you want to do an ARP check on the offered address
|
||||
(recommended). */
|
||||
#define DHCP_DOES_ARP_CHECK 1
|
||||
|
||||
/* ---------- UDP options ---------- */
|
||||
#define LWIP_UDP 1
|
||||
#define UDP_TTL 255
|
||||
|
||||
#define LWIP_STATS 0
|
||||
/* ---------- Statistics options ---------- */
|
||||
/*#define STATS*/
|
||||
#if LWIP_STATS
|
||||
#define LINK_STATS 0
|
||||
#define IP_STATS 0
|
||||
#define ICMP_STATS 0
|
||||
#define UDP_STATS 0
|
||||
#define TCP_STATS 0
|
||||
#define MEM_STATS 0
|
||||
#define MEMP_STATS 0
|
||||
#define PBUF_STATS 0
|
||||
#define SYS_STATS 0
|
||||
#define RAW_STATS 0
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_DEBUG
|
||||
#define DBG_TYPES_ON -1
|
||||
#define DEMO_DEBUG DBG_OFF
|
||||
#define ETHARP_DEBUG DBG_OFF
|
||||
#define NETIF_DEBUG DBG_OFF
|
||||
#define PBUF_DEBUG DBG_OFF
|
||||
#define API_LIB_DEBUG DBG_OFF
|
||||
#define API_MSG_DEBUG DBG_ON
|
||||
#define SOCKETS_DEBUG DBG_OFF
|
||||
#define ICMP_DEBUG DBG_OFF
|
||||
#define INET_DEBUG DBG_OFF
|
||||
#define IP_DEBUG DBG_OFF
|
||||
#define IP_REASS_DEBUG DBG_OFF
|
||||
#define MEM_DEBUG DBG_OFF
|
||||
#define MEMP_DEBUG DBG_OFF
|
||||
#define SYS_DEBUG DBG_OFF
|
||||
#define RAW_DEBUG DBG_OFF
|
||||
#define TCP_DEBUG DBG_OFF
|
||||
#define TCP_INPUT_DEBUG DBG_OFF
|
||||
#define TCP_FR_DEBUG DBG_OFF
|
||||
#define TCP_RTO_DEBUG DBG_OFF
|
||||
#define TCP_REXMIT_DEBUG DBG_OFF
|
||||
#define TCP_CWND_DEBUG DBG_OFF
|
||||
#define TCP_WND_DEBUG DBG_OFF
|
||||
#define TCP_OUTPUT_DEBUG DBG_OFF
|
||||
#define TCP_RST_DEBUG DBG_OFF
|
||||
#define TCP_QLEN_DEBUG DBG_OFF
|
||||
#define UDP_DEBUG DBG_OFF
|
||||
#define TCPIP_DEBUG DBG_OFF
|
||||
#define PPP_DEBUG DBG_OFF
|
||||
#define SLIP_DEBUG DBG_OFF
|
||||
#define DHCP_DEBUG DBG_OFF
|
||||
|
||||
#define DBG_MIN_LEVEL DBG_LEVEL_OFF
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __LWIPOPTS_H__ */
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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 lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __LWIP_MEM_H__
|
||||
#define __LWIP_MEM_H__
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/arch.h"
|
||||
|
||||
#if MEM_SIZE > 64000l
|
||||
typedef u32_t mem_size_t;
|
||||
#else
|
||||
typedef u16_t mem_size_t;
|
||||
#endif /* MEM_SIZE > 64000 */
|
||||
|
||||
|
||||
void mem_init(void);
|
||||
|
||||
void *mem_malloc(mem_size_t size);
|
||||
void mem_free(void *mem);
|
||||
void *mem_realloc(void *mem, mem_size_t size);
|
||||
void *mem_reallocm(void *mem, mem_size_t size);
|
||||
|
||||
#ifndef MEM_ALIGN_SIZE
|
||||
#define MEM_ALIGN_SIZE(size) (((size) + MEM_ALIGNMENT - 1) & ~(MEM_ALIGNMENT-1))
|
||||
#endif
|
||||
|
||||
#ifndef MEM_ALIGN
|
||||
#define MEM_ALIGN(addr) ((void *)(((mem_ptr_t)(addr) + MEM_ALIGNMENT - 1) & ~(mem_ptr_t)(MEM_ALIGNMENT-1)))
|
||||
#endif
|
||||
|
||||
#endif /* __LWIP_MEM_H__ */
|
||||
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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 lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __LWIP_MEMP_H__
|
||||
#define __LWIP_MEMP_H__
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
typedef enum {
|
||||
MEMP_PBUF,
|
||||
MEMP_RAW_PCB,
|
||||
MEMP_UDP_PCB,
|
||||
MEMP_TCP_PCB,
|
||||
MEMP_TCP_PCB_LISTEN,
|
||||
MEMP_TCP_SEG,
|
||||
|
||||
MEMP_NETBUF,
|
||||
MEMP_NETCONN,
|
||||
MEMP_API_MSG,
|
||||
MEMP_TCPIP_MSG,
|
||||
|
||||
MEMP_SYS_TIMEOUT,
|
||||
|
||||
MEMP_MAX
|
||||
} memp_t;
|
||||
|
||||
void memp_init(void);
|
||||
|
||||
void *memp_malloc(memp_t type);
|
||||
void *memp_realloc(memp_t fromtype, memp_t totype, void *mem);
|
||||
void memp_free(memp_t type, void *mem);
|
||||
|
||||
#endif /* __LWIP_MEMP_H__ */
|
||||
|
@ -1,150 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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 lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __LWIP_NETIF_H__
|
||||
#define __LWIP_NETIF_H__
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#include "lwip/err.h"
|
||||
|
||||
#include "lwip/ip_addr.h"
|
||||
|
||||
#include "lwip/inet.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#if LWIP_DHCP
|
||||
# include "lwip/dhcp.h"
|
||||
#endif
|
||||
|
||||
/** must be the maximum of all used hardware address lengths
|
||||
across all types of interfaces in use */
|
||||
#define NETIF_MAX_HWADDR_LEN 6U
|
||||
|
||||
/** TODO: define the use (where, when, whom) of netif flags */
|
||||
|
||||
/** whether the network interface is 'up'. this is
|
||||
* a software flag used to control whether this network
|
||||
* interface is enabled and processes traffic.
|
||||
*/
|
||||
#define NETIF_FLAG_UP 0x1U
|
||||
/** if set, the netif has broadcast capability */
|
||||
#define NETIF_FLAG_BROADCAST 0x2U
|
||||
/** if set, the netif is one end of a point-to-point connection */
|
||||
#define NETIF_FLAG_POINTTOPOINT 0x4U
|
||||
/** if set, the interface is configured using DHCP */
|
||||
#define NETIF_FLAG_DHCP 0x08U
|
||||
/** if set, the interface has an active link
|
||||
* (set by the network interface driver) */
|
||||
#define NETIF_FLAG_LINK_UP 0x10U
|
||||
|
||||
/** Generic data structure used for all lwIP network interfaces.
|
||||
* The following fields should be filled in by the initialization
|
||||
* function for the device driver: hwaddr_len, hwaddr[], mtu, flags */
|
||||
|
||||
struct netif {
|
||||
/** pointer to next in linked list */
|
||||
struct netif *next;
|
||||
|
||||
/** IP address configuration in network byte order */
|
||||
struct ip_addr ip_addr;
|
||||
struct ip_addr netmask;
|
||||
struct ip_addr gw;
|
||||
|
||||
/** This function is called by the network device driver
|
||||
* to pass a packet up the TCP/IP stack. */
|
||||
err_t (* input)(struct pbuf *p, struct netif *inp);
|
||||
/** This function is called by the IP module when it wants
|
||||
* to send a packet on the interface. This function typically
|
||||
* first resolves the hardware address, then sends the packet. */
|
||||
err_t (* output)(struct netif *netif, struct pbuf *p,
|
||||
struct ip_addr *ipaddr);
|
||||
/** This function is called by the ARP module when it wants
|
||||
* to send a packet on the interface. This function outputs
|
||||
* the pbuf as-is on the link medium. */
|
||||
err_t (* linkoutput)(struct netif *netif, struct pbuf *p);
|
||||
/** This field can be set by the device driver and could point
|
||||
* to state information for the device. */
|
||||
void *state;
|
||||
#if LWIP_DHCP
|
||||
/** the DHCP client state information for this netif */
|
||||
struct dhcp *dhcp;
|
||||
#endif
|
||||
/** number of bytes used in hwaddr */
|
||||
u8_t hwaddr_len;
|
||||
/** link level hardware address of this interface */
|
||||
u8_t hwaddr[NETIF_MAX_HWADDR_LEN];
|
||||
/** maximum transfer unit (in bytes) */
|
||||
u16_t mtu;
|
||||
/** flags (see NETIF_FLAG_ above) */
|
||||
u8_t flags;
|
||||
/** link type */
|
||||
u8_t link_type;
|
||||
/** descriptive abbreviation */
|
||||
char name[2];
|
||||
/** number of this interface */
|
||||
u8_t num;
|
||||
};
|
||||
|
||||
/** The list of network interfaces. */
|
||||
extern struct netif *netif_list;
|
||||
/** The default network interface. */
|
||||
extern struct netif *netif_default;
|
||||
|
||||
/* netif_init() must be called first. */
|
||||
void netif_init(void);
|
||||
|
||||
struct netif *netif_add(struct netif *netif, struct ip_addr *ipaddr, struct ip_addr *netmask,
|
||||
struct ip_addr *gw,
|
||||
void *state,
|
||||
err_t (* init)(struct netif *netif),
|
||||
err_t (* input)(struct pbuf *p, struct netif *netif));
|
||||
|
||||
void
|
||||
netif_set_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask,
|
||||
struct ip_addr *gw);
|
||||
void netif_remove(struct netif * netif);
|
||||
|
||||
/* Returns a network interface given its name. The name is of the form
|
||||
"et0", where the first two letters are the "name" field in the
|
||||
netif structure, and the digit is in the num field in the same
|
||||
structure. */
|
||||
struct netif *netif_find(char *name);
|
||||
|
||||
void netif_set_default(struct netif *netif);
|
||||
|
||||
void netif_set_ipaddr(struct netif *netif, struct ip_addr *ipaddr);
|
||||
void netif_set_netmask(struct netif *netif, struct ip_addr *netmast);
|
||||
void netif_set_gw(struct netif *netif, struct ip_addr *gw);
|
||||
void netif_set_up(struct netif *netif);
|
||||
void netif_set_down(struct netif *netif);
|
||||
u8_t netif_is_up(struct netif *netif);
|
||||
|
||||
#endif /* __LWIP_NETIF_H__ */
|
@ -1,669 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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 lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __LWIP_OPT_H__
|
||||
#define __LWIP_OPT_H__
|
||||
|
||||
/* Include user defined options first */
|
||||
#include "lwipopts.h"
|
||||
#include "lwip/debug.h"
|
||||
|
||||
/* Define default values for unconfigured parameters. */
|
||||
|
||||
/* Platform specific locking */
|
||||
|
||||
/*
|
||||
* enable SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection
|
||||
* for certain critical regions during buffer allocation, deallocation and memory
|
||||
* allocation and deallocation.
|
||||
*/
|
||||
#ifndef SYS_LIGHTWEIGHT_PROT
|
||||
#define SYS_LIGHTWEIGHT_PROT 0
|
||||
#endif
|
||||
|
||||
#ifndef NO_SYS
|
||||
#define NO_SYS 0
|
||||
#endif
|
||||
/* ---------- Memory options ---------- */
|
||||
/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which
|
||||
lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2
|
||||
byte alignment -> define MEM_ALIGNMENT to 2. */
|
||||
|
||||
#ifndef MEM_ALIGNMENT
|
||||
#define MEM_ALIGNMENT 1
|
||||
#endif
|
||||
|
||||
/* MEM_SIZE: the size of the heap memory. If the application will send
|
||||
a lot of data that needs to be copied, this should be set high. */
|
||||
#ifndef MEM_SIZE
|
||||
#define MEM_SIZE 1600
|
||||
#endif
|
||||
|
||||
#ifndef MEMP_SANITY_CHECK
|
||||
#define MEMP_SANITY_CHECK 0
|
||||
#endif
|
||||
|
||||
/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
|
||||
sends a lot of data out of ROM (or other static memory), this
|
||||
should be set high. */
|
||||
#ifndef MEMP_NUM_PBUF
|
||||
#define MEMP_NUM_PBUF 16
|
||||
#endif
|
||||
|
||||
/* Number of raw connection PCBs */
|
||||
#ifndef MEMP_NUM_RAW_PCB
|
||||
#define MEMP_NUM_RAW_PCB 4
|
||||
#endif
|
||||
|
||||
/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
|
||||
per active UDP "connection". */
|
||||
#ifndef MEMP_NUM_UDP_PCB
|
||||
#define MEMP_NUM_UDP_PCB 4
|
||||
#endif
|
||||
/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
|
||||
connections. */
|
||||
#ifndef MEMP_NUM_TCP_PCB
|
||||
#define MEMP_NUM_TCP_PCB 5
|
||||
#endif
|
||||
/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
|
||||
connections. */
|
||||
#ifndef MEMP_NUM_TCP_PCB_LISTEN
|
||||
#define MEMP_NUM_TCP_PCB_LISTEN 8
|
||||
#endif
|
||||
/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
|
||||
segments. */
|
||||
#ifndef MEMP_NUM_TCP_SEG
|
||||
#define MEMP_NUM_TCP_SEG 16
|
||||
#endif
|
||||
/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
|
||||
timeouts. */
|
||||
#ifndef MEMP_NUM_SYS_TIMEOUT
|
||||
#define MEMP_NUM_SYS_TIMEOUT 3
|
||||
#endif
|
||||
|
||||
/* The following four are used only with the sequential API and can be
|
||||
set to 0 if the application only will use the raw API. */
|
||||
/* MEMP_NUM_NETBUF: the number of struct netbufs. */
|
||||
#ifndef MEMP_NUM_NETBUF
|
||||
#define MEMP_NUM_NETBUF 2
|
||||
#endif
|
||||
/* MEMP_NUM_NETCONN: the number of struct netconns. */
|
||||
#ifndef MEMP_NUM_NETCONN
|
||||
#define MEMP_NUM_NETCONN 4
|
||||
#endif
|
||||
/* MEMP_NUM_APIMSG: the number of struct api_msg, used for
|
||||
communication between the TCP/IP stack and the sequential
|
||||
programs. */
|
||||
#ifndef MEMP_NUM_API_MSG
|
||||
#define MEMP_NUM_API_MSG 8
|
||||
#endif
|
||||
/* MEMP_NUM_TCPIPMSG: the number of struct tcpip_msg, which is used
|
||||
for sequential API communication and incoming packets. Used in
|
||||
src/api/tcpip.c. */
|
||||
#ifndef MEMP_NUM_TCPIP_MSG
|
||||
#define MEMP_NUM_TCPIP_MSG 8
|
||||
#endif
|
||||
|
||||
/* ---------- Pbuf options ---------- */
|
||||
/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
|
||||
|
||||
#ifndef PBUF_POOL_SIZE
|
||||
#define PBUF_POOL_SIZE 16
|
||||
#endif
|
||||
|
||||
/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
|
||||
|
||||
#ifndef PBUF_POOL_BUFSIZE
|
||||
#define PBUF_POOL_BUFSIZE 128
|
||||
#endif
|
||||
|
||||
/* PBUF_LINK_HLEN: the number of bytes that should be allocated for a
|
||||
link level header. Defaults to 14 for Ethernet. */
|
||||
|
||||
#ifndef PBUF_LINK_HLEN
|
||||
#define PBUF_LINK_HLEN 14
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* ---------- ARP options ---------- */
|
||||
|
||||
/** Number of active hardware address, IP address pairs cached */
|
||||
#ifndef ARP_TABLE_SIZE
|
||||
#define ARP_TABLE_SIZE 10
|
||||
#endif
|
||||
|
||||
/**
|
||||
* If enabled, outgoing packets are queued during hardware address
|
||||
* resolution.
|
||||
*
|
||||
* This feature has not stabilized yet. Single-packet queueing is
|
||||
* believed to be stable, multi-packet queueing is believed to
|
||||
* clash with the TCP segment queueing.
|
||||
*
|
||||
* As multi-packet-queueing is currently disabled, enabling this
|
||||
* _should_ work, but we need your testing feedback on lwip-users.
|
||||
*
|
||||
*/
|
||||
#ifndef ARP_QUEUEING
|
||||
#define ARP_QUEUEING 1
|
||||
#endif
|
||||
|
||||
/* This option is deprecated */
|
||||
#ifdef ETHARP_QUEUE_FIRST
|
||||
#error ETHARP_QUEUE_FIRST option is deprecated. Remove it from your lwipopts.h.
|
||||
#endif
|
||||
|
||||
/* This option is removed to comply with the ARP standard */
|
||||
#ifdef ETHARP_ALWAYS_INSERT
|
||||
#error ETHARP_ALWAYS_INSERT option is deprecated. Remove it from your lwipopts.h.
|
||||
#endif
|
||||
|
||||
/* ---------- IP options ---------- */
|
||||
/* Define IP_FORWARD to 1 if you wish to have the ability to forward
|
||||
IP packets across network interfaces. If you are going to run lwIP
|
||||
on a device with only one network interface, define this to 0. */
|
||||
#ifndef IP_FORWARD
|
||||
#define IP_FORWARD 0
|
||||
#endif
|
||||
|
||||
/* If defined to 1, IP options are allowed (but not parsed). If
|
||||
defined to 0, all packets with IP options are dropped. */
|
||||
#ifndef IP_OPTIONS
|
||||
#define IP_OPTIONS 1
|
||||
#endif
|
||||
|
||||
/** IP reassembly and segmentation. Even if they both deal with IP
|
||||
* fragments, note that these are orthogonal, one dealing with incoming
|
||||
* packets, the other with outgoing packets
|
||||
*/
|
||||
|
||||
/** Reassemble incoming fragmented IP packets */
|
||||
#ifndef IP_REASSEMBLY
|
||||
#define IP_REASSEMBLY 1
|
||||
#endif
|
||||
|
||||
/** Fragment outgoing IP packets if their size exceeds MTU */
|
||||
#ifndef IP_FRAG
|
||||
#define IP_FRAG 1
|
||||
#endif
|
||||
|
||||
/* ---------- ICMP options ---------- */
|
||||
|
||||
#ifndef ICMP_TTL
|
||||
#define ICMP_TTL 255
|
||||
#endif
|
||||
|
||||
/* ---------- RAW options ---------- */
|
||||
|
||||
#ifndef LWIP_RAW
|
||||
#define LWIP_RAW 1
|
||||
#endif
|
||||
|
||||
#ifndef RAW_TTL
|
||||
#define RAW_TTL 255
|
||||
#endif
|
||||
|
||||
/* ---------- DHCP options ---------- */
|
||||
|
||||
#ifndef LWIP_DHCP
|
||||
#define LWIP_DHCP 0
|
||||
#endif
|
||||
|
||||
/* 1 if you want to do an ARP check on the offered address
|
||||
(recommended). */
|
||||
#ifndef DHCP_DOES_ARP_CHECK
|
||||
#define DHCP_DOES_ARP_CHECK 1
|
||||
#endif
|
||||
|
||||
/* ---------- UDP options ---------- */
|
||||
#ifndef LWIP_UDP
|
||||
#define LWIP_UDP 1
|
||||
#endif
|
||||
|
||||
#ifndef UDP_TTL
|
||||
#define UDP_TTL 255
|
||||
#endif
|
||||
|
||||
/* ---------- TCP options ---------- */
|
||||
#ifndef LWIP_TCP
|
||||
#define LWIP_TCP 1
|
||||
#endif
|
||||
|
||||
#ifndef TCP_TTL
|
||||
#define TCP_TTL 255
|
||||
#endif
|
||||
|
||||
#ifndef TCP_WND
|
||||
#define TCP_WND 2048
|
||||
#endif
|
||||
|
||||
#ifndef TCP_MAXRTX
|
||||
#define TCP_MAXRTX 12
|
||||
#endif
|
||||
|
||||
#ifndef TCP_SYNMAXRTX
|
||||
#define TCP_SYNMAXRTX 6
|
||||
#endif
|
||||
|
||||
|
||||
/* Controls if TCP should queue segments that arrive out of
|
||||
order. Define to 0 if your device is low on memory. */
|
||||
#ifndef TCP_QUEUE_OOSEQ
|
||||
#define TCP_QUEUE_OOSEQ 1
|
||||
#endif
|
||||
|
||||
/* TCP Maximum segment size. */
|
||||
#ifndef TCP_MSS
|
||||
#define TCP_MSS 128 /* A *very* conservative default. */
|
||||
#endif
|
||||
|
||||
/* TCP sender buffer space (bytes). */
|
||||
#ifndef TCP_SND_BUF
|
||||
#define TCP_SND_BUF 256
|
||||
#endif
|
||||
|
||||
/* TCP sender buffer space (pbufs). This must be at least = 2 *
|
||||
TCP_SND_BUF/TCP_MSS for things to work. */
|
||||
#ifndef TCP_SND_QUEUELEN
|
||||
#define TCP_SND_QUEUELEN 4 * TCP_SND_BUF/TCP_MSS
|
||||
#endif
|
||||
|
||||
|
||||
/* Maximum number of retransmissions of data segments. */
|
||||
|
||||
/* Maximum number of retransmissions of SYN segments. */
|
||||
|
||||
/* TCP writable space (bytes). This must be less than or equal
|
||||
to TCP_SND_BUF. It is the amount of space which must be
|
||||
available in the tcp snd_buf for select to return writable */
|
||||
#ifndef TCP_SNDLOWAT
|
||||
#define TCP_SNDLOWAT TCP_SND_BUF/2
|
||||
#endif
|
||||
|
||||
/* Support loop interface (127.0.0.1) */
|
||||
#ifndef LWIP_HAVE_LOOPIF
|
||||
#define LWIP_HAVE_LOOPIF 1
|
||||
#endif
|
||||
|
||||
#ifndef LWIP_EVENT_API
|
||||
#define LWIP_EVENT_API 0
|
||||
#define LWIP_CALLBACK_API 1
|
||||
#else
|
||||
#define LWIP_EVENT_API 1
|
||||
#define LWIP_CALLBACK_API 0
|
||||
#endif
|
||||
|
||||
#ifndef LWIP_COMPAT_SOCKETS
|
||||
#define LWIP_COMPAT_SOCKETS 1
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef TCPIP_THREAD_PRIO
|
||||
#define TCPIP_THREAD_PRIO 1
|
||||
#endif
|
||||
|
||||
#ifndef SLIPIF_THREAD_PRIO
|
||||
#define SLIPIF_THREAD_PRIO 1
|
||||
#endif
|
||||
|
||||
#ifndef PPP_THREAD_PRIO
|
||||
#define PPP_THREAD_PRIO 1
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_THREAD_PRIO
|
||||
#define DEFAULT_THREAD_PRIO 1
|
||||
#endif
|
||||
|
||||
|
||||
/* ---------- Socket Options ---------- */
|
||||
/* Enable SO_REUSEADDR and SO_REUSEPORT options */
|
||||
#ifndef SO_REUSE
|
||||
# define SO_REUSE 0
|
||||
#endif
|
||||
|
||||
|
||||
/* ---------- Statistics options ---------- */
|
||||
#ifndef LWIP_STATS
|
||||
#define LWIP_STATS 1
|
||||
#endif
|
||||
|
||||
#if LWIP_STATS
|
||||
|
||||
#ifndef LWIP_STATS_DISPLAY
|
||||
#define LWIP_STATS_DISPLAY 0
|
||||
#endif
|
||||
|
||||
#ifndef LINK_STATS
|
||||
#define LINK_STATS 1
|
||||
#endif
|
||||
|
||||
#ifndef IP_STATS
|
||||
#define IP_STATS 1
|
||||
#endif
|
||||
|
||||
#ifndef IPFRAG_STATS
|
||||
#define IPFRAG_STATS 1
|
||||
#endif
|
||||
|
||||
#ifndef ICMP_STATS
|
||||
#define ICMP_STATS 1
|
||||
#endif
|
||||
|
||||
#ifndef UDP_STATS
|
||||
#define UDP_STATS 1
|
||||
#endif
|
||||
|
||||
#ifndef TCP_STATS
|
||||
#define TCP_STATS 1
|
||||
#endif
|
||||
|
||||
#ifndef MEM_STATS
|
||||
#define MEM_STATS 1
|
||||
#endif
|
||||
|
||||
#ifndef MEMP_STATS
|
||||
#define MEMP_STATS 1
|
||||
#endif
|
||||
|
||||
#ifndef PBUF_STATS
|
||||
#define PBUF_STATS 1
|
||||
#endif
|
||||
|
||||
#ifndef SYS_STATS
|
||||
#define SYS_STATS 1
|
||||
#endif
|
||||
|
||||
#ifndef RAW_STATS
|
||||
#define RAW_STATS 0
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#define LINK_STATS 0
|
||||
#define IP_STATS 0
|
||||
#define IPFRAG_STATS 0
|
||||
#define ICMP_STATS 0
|
||||
#define UDP_STATS 0
|
||||
#define TCP_STATS 0
|
||||
#define MEM_STATS 0
|
||||
#define MEMP_STATS 0
|
||||
#define PBUF_STATS 0
|
||||
#define SYS_STATS 0
|
||||
#define RAW_STATS 0
|
||||
#define LWIP_STATS_DISPLAY 0
|
||||
|
||||
#endif /* LWIP_STATS */
|
||||
|
||||
/* ---------- PPP options ---------- */
|
||||
|
||||
#ifndef PPP_SUPPORT
|
||||
#define PPP_SUPPORT 0 /* Set for PPP */
|
||||
#endif
|
||||
|
||||
#if PPP_SUPPORT
|
||||
|
||||
#define NUM_PPP 1 /* Max PPP sessions. */
|
||||
|
||||
|
||||
|
||||
#ifndef PAP_SUPPORT
|
||||
#define PAP_SUPPORT 0 /* Set for PAP. */
|
||||
#endif
|
||||
|
||||
#ifndef CHAP_SUPPORT
|
||||
#define CHAP_SUPPORT 0 /* Set for CHAP. */
|
||||
#endif
|
||||
|
||||
#define MSCHAP_SUPPORT 0 /* Set for MSCHAP (NOT FUNCTIONAL!) */
|
||||
#define CBCP_SUPPORT 0 /* Set for CBCP (NOT FUNCTIONAL!) */
|
||||
#define CCP_SUPPORT 0 /* Set for CCP (NOT FUNCTIONAL!) */
|
||||
|
||||
#ifndef VJ_SUPPORT
|
||||
#define VJ_SUPPORT 0 /* Set for VJ header compression. */
|
||||
#endif
|
||||
|
||||
#ifndef MD5_SUPPORT
|
||||
#define MD5_SUPPORT 0 /* Set for MD5 (see also CHAP) */
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Timeouts.
|
||||
*/
|
||||
#define FSM_DEFTIMEOUT 6 /* Timeout time in seconds */
|
||||
#define FSM_DEFMAXTERMREQS 2 /* Maximum Terminate-Request transmissions */
|
||||
#define FSM_DEFMAXCONFREQS 10 /* Maximum Configure-Request transmissions */
|
||||
#define FSM_DEFMAXNAKLOOPS 5 /* Maximum number of nak loops */
|
||||
|
||||
#define UPAP_DEFTIMEOUT 6 /* Timeout (seconds) for retransmitting req */
|
||||
#define UPAP_DEFREQTIME 30 /* Time to wait for auth-req from peer */
|
||||
|
||||
#define CHAP_DEFTIMEOUT 6 /* Timeout time in seconds */
|
||||
#define CHAP_DEFTRANSMITS 10 /* max # times to send challenge */
|
||||
|
||||
|
||||
/* Interval in seconds between keepalive echo requests, 0 to disable. */
|
||||
#if 1
|
||||
#define LCP_ECHOINTERVAL 0
|
||||
#else
|
||||
#define LCP_ECHOINTERVAL 10
|
||||
#endif
|
||||
|
||||
/* Number of unanswered echo requests before failure. */
|
||||
#define LCP_MAXECHOFAILS 3
|
||||
|
||||
/* Max Xmit idle time (in jiffies) before resend flag char. */
|
||||
#define PPP_MAXIDLEFLAG 100
|
||||
|
||||
/*
|
||||
* Packet sizes
|
||||
*
|
||||
* Note - lcp shouldn't be allowed to negotiate stuff outside these
|
||||
* limits. See lcp.h in the pppd directory.
|
||||
* (XXX - these constants should simply be shared by lcp.c instead
|
||||
* of living in lcp.h)
|
||||
*/
|
||||
#define PPP_MTU 1500 /* Default MTU (size of Info field) */
|
||||
#if 0
|
||||
#define PPP_MAXMTU 65535 - (PPP_HDRLEN + PPP_FCSLEN)
|
||||
#else
|
||||
#define PPP_MAXMTU 1500 /* Largest MTU we allow */
|
||||
#endif
|
||||
#define PPP_MINMTU 64
|
||||
#define PPP_MRU 1500 /* default MRU = max length of info field */
|
||||
#define PPP_MAXMRU 1500 /* Largest MRU we allow */
|
||||
#define PPP_DEFMRU 296 /* Try for this */
|
||||
#define PPP_MINMRU 128 /* No MRUs below this */
|
||||
|
||||
|
||||
#define MAXNAMELEN 256 /* max length of hostname or name for auth */
|
||||
#define MAXSECRETLEN 256 /* max length of password or secret */
|
||||
|
||||
#endif /* PPP_SUPPORT */
|
||||
|
||||
/* checksum options - set to zero for hardware checksum support */
|
||||
|
||||
#ifndef CHECKSUM_GEN_IP
|
||||
#define CHECKSUM_GEN_IP 1
|
||||
#endif
|
||||
|
||||
#ifndef CHECKSUM_GEN_UDP
|
||||
#define CHECKSUM_GEN_UDP 1
|
||||
#endif
|
||||
|
||||
#ifndef CHECKSUM_GEN_TCP
|
||||
#define CHECKSUM_GEN_TCP 1
|
||||
#endif
|
||||
|
||||
#ifndef CHECKSUM_CHECK_IP
|
||||
#define CHECKSUM_CHECK_IP 1
|
||||
#endif
|
||||
|
||||
#ifndef CHECKSUM_CHECK_UDP
|
||||
#define CHECKSUM_CHECK_UDP 1
|
||||
#endif
|
||||
|
||||
#ifndef CHECKSUM_CHECK_TCP
|
||||
#define CHECKSUM_CHECK_TCP 1
|
||||
#endif
|
||||
|
||||
/* Debugging options all default to off */
|
||||
|
||||
#ifndef DBG_TYPES_ON
|
||||
#define DBG_TYPES_ON 0
|
||||
#endif
|
||||
|
||||
#ifndef ETHARP_DEBUG
|
||||
#define ETHARP_DEBUG DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifndef NETIF_DEBUG
|
||||
#define NETIF_DEBUG DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifndef PBUF_DEBUG
|
||||
#define PBUF_DEBUG DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifndef API_LIB_DEBUG
|
||||
#define API_LIB_DEBUG DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifndef API_MSG_DEBUG
|
||||
#define API_MSG_DEBUG DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifndef SOCKETS_DEBUG
|
||||
#define SOCKETS_DEBUG DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifndef ICMP_DEBUG
|
||||
#define ICMP_DEBUG DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifndef INET_DEBUG
|
||||
#define INET_DEBUG DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifndef IP_DEBUG
|
||||
#define IP_DEBUG DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifndef IP_REASS_DEBUG
|
||||
#define IP_REASS_DEBUG DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifndef RAW_DEBUG
|
||||
#define RAW_DEBUG DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifndef MEM_DEBUG
|
||||
#define MEM_DEBUG DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifndef MEMP_DEBUG
|
||||
#define MEMP_DEBUG DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifndef SYS_DEBUG
|
||||
#define SYS_DEBUG DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifndef TCP_DEBUG
|
||||
#define TCP_DEBUG DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifndef TCP_INPUT_DEBUG
|
||||
#define TCP_INPUT_DEBUG DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifndef TCP_FR_DEBUG
|
||||
#define TCP_FR_DEBUG DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifndef TCP_RTO_DEBUG
|
||||
#define TCP_RTO_DEBUG DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifndef TCP_REXMIT_DEBUG
|
||||
#define TCP_REXMIT_DEBUG DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifndef TCP_CWND_DEBUG
|
||||
#define TCP_CWND_DEBUG DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifndef TCP_WND_DEBUG
|
||||
#define TCP_WND_DEBUG DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifndef TCP_OUTPUT_DEBUG
|
||||
#define TCP_OUTPUT_DEBUG DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifndef TCP_RST_DEBUG
|
||||
#define TCP_RST_DEBUG DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifndef TCP_QLEN_DEBUG
|
||||
#define TCP_QLEN_DEBUG DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifndef UDP_DEBUG
|
||||
#define UDP_DEBUG DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifndef TCPIP_DEBUG
|
||||
#define TCPIP_DEBUG DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifndef PPP_DEBUG
|
||||
#define PPP_DEBUG DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifndef SLIP_DEBUG
|
||||
#define SLIP_DEBUG DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifndef DHCP_DEBUG
|
||||
#define DHCP_DEBUG DBG_OFF
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef DBG_MIN_LEVEL
|
||||
#define DBG_MIN_LEVEL DBG_LEVEL_OFF
|
||||
#endif
|
||||
|
||||
#endif /* __LWIP_OPT_H__ */
|
||||
|
||||
|
||||
|
@ -1,113 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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 lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __LWIP_PBUF_H__
|
||||
#define __LWIP_PBUF_H__
|
||||
|
||||
#include "arch/cc.h"
|
||||
|
||||
|
||||
#define PBUF_TRANSPORT_HLEN 20
|
||||
#define PBUF_IP_HLEN 20
|
||||
|
||||
typedef enum {
|
||||
PBUF_TRANSPORT,
|
||||
PBUF_IP,
|
||||
PBUF_LINK,
|
||||
PBUF_RAW
|
||||
} pbuf_layer;
|
||||
|
||||
typedef enum {
|
||||
PBUF_RAM,
|
||||
PBUF_ROM,
|
||||
PBUF_REF,
|
||||
PBUF_POOL
|
||||
} pbuf_flag;
|
||||
|
||||
/* Definitions for the pbuf flag field. These are NOT the flags that
|
||||
* are passed to pbuf_alloc(). */
|
||||
#define PBUF_FLAG_RAM 0x00U /* Flags that pbuf data is stored in RAM */
|
||||
#define PBUF_FLAG_ROM 0x01U /* Flags that pbuf data is stored in ROM */
|
||||
#define PBUF_FLAG_POOL 0x02U /* Flags that the pbuf comes from the pbuf pool */
|
||||
#define PBUF_FLAG_REF 0x04U /* Flags thet the pbuf payload refers to RAM */
|
||||
|
||||
/** indicates this packet was broadcast on the link */
|
||||
#define PBUF_FLAG_LINK_BROADCAST 0x80U
|
||||
|
||||
struct pbuf {
|
||||
/** next pbuf in singly linked pbuf chain */
|
||||
struct pbuf *next;
|
||||
|
||||
/** pointer to the actual data in the buffer */
|
||||
void *payload;
|
||||
|
||||
/**
|
||||
* total length of this buffer and all next buffers in chain
|
||||
* belonging to the same packet.
|
||||
*
|
||||
* For non-queue packet chains this is the invariant:
|
||||
* p->tot_len == p->len + (p->next? p->next->tot_len: 0)
|
||||
*/
|
||||
u16_t tot_len;
|
||||
|
||||
/** length of this buffer */
|
||||
u16_t len;
|
||||
|
||||
/** flags telling the type of pbuf, see PBUF_FLAG_ */
|
||||
u16_t flags;
|
||||
|
||||
/**
|
||||
* the reference count always equals the number of pointers
|
||||
* that refer to this pbuf. This can be pointers from an application,
|
||||
* the stack itself, or pbuf->next pointers from a chain.
|
||||
*/
|
||||
u16_t ref;
|
||||
|
||||
};
|
||||
|
||||
void pbuf_init(void);
|
||||
|
||||
struct pbuf *pbuf_alloc(pbuf_layer l, u16_t size, pbuf_flag flag);
|
||||
void pbuf_realloc(struct pbuf *p, u16_t size);
|
||||
u8_t pbuf_header(struct pbuf *p, s16_t header_size);
|
||||
void pbuf_ref(struct pbuf *p);
|
||||
void pbuf_ref_chain(struct pbuf *p);
|
||||
u8_t pbuf_free(struct pbuf *p);
|
||||
u8_t pbuf_clen(struct pbuf *p);
|
||||
void pbuf_cat(struct pbuf *h, struct pbuf *t);
|
||||
void pbuf_chain(struct pbuf *h, struct pbuf *t);
|
||||
struct pbuf *pbuf_take(struct pbuf *f);
|
||||
struct pbuf *pbuf_dechain(struct pbuf *p);
|
||||
void pbuf_queue(struct pbuf *p, struct pbuf *n);
|
||||
struct pbuf * pbuf_dequeue(struct pbuf *p);
|
||||
|
||||
#endif /* __LWIP_PBUF_H__ */
|
@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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 lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __LWIP_RAW_H__
|
||||
#define __LWIP_RAW_H__
|
||||
|
||||
#include "lwip/arch.h"
|
||||
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/inet.h"
|
||||
#include "lwip/ip.h"
|
||||
|
||||
struct raw_pcb {
|
||||
/* Common members of all PCB types */
|
||||
IP_PCB;
|
||||
|
||||
struct raw_pcb *next;
|
||||
|
||||
u16_t protocol;
|
||||
|
||||
u8_t (* recv)(void *arg, struct raw_pcb *pcb, struct pbuf *p,
|
||||
struct ip_addr *addr);
|
||||
void *recv_arg;
|
||||
};
|
||||
|
||||
/* The following functions is the application layer interface to the
|
||||
RAW code. */
|
||||
struct raw_pcb * raw_new (u16_t proto);
|
||||
void raw_remove (struct raw_pcb *pcb);
|
||||
err_t raw_bind (struct raw_pcb *pcb, struct ip_addr *ipaddr);
|
||||
err_t raw_connect (struct raw_pcb *pcb, struct ip_addr *ipaddr);
|
||||
|
||||
void raw_recv (struct raw_pcb *pcb,
|
||||
u8_t (* recv)(void *arg, struct raw_pcb *pcb,
|
||||
struct pbuf *p,
|
||||
struct ip_addr *addr),
|
||||
void *recv_arg);
|
||||
err_t raw_sendto (struct raw_pcb *pcb, struct pbuf *p, struct ip_addr *ipaddr);
|
||||
err_t raw_send (struct raw_pcb *pcb, struct pbuf *p);
|
||||
|
||||
/* The following functions are the lower layer interface to RAW. */
|
||||
u8_t raw_input (struct pbuf *p, struct netif *inp);
|
||||
void raw_init (void);
|
||||
|
||||
|
||||
#endif /* __LWIP_RAW_H__ */
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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 lwIP TCP/IP stack.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This is the interface to the platform specific serial IO module
|
||||
* It needs to be implemented by those platforms which need SLIP or PPP
|
||||
*/
|
||||
|
||||
#include "arch/cc.h"
|
||||
|
||||
#ifndef __sio_fd_t_defined
|
||||
typedef void * sio_fd_t;
|
||||
#endif
|
||||
|
||||
#ifndef sio_open
|
||||
sio_fd_t sio_open(u8_t);
|
||||
#endif
|
||||
|
||||
#ifndef sio_send
|
||||
void sio_send(u8_t, sio_fd_t);
|
||||
#endif
|
||||
|
||||
#ifndef sio_recv
|
||||
u8_t sio_recv(sio_fd_t);
|
||||
#endif
|
||||
|
||||
#ifndef sio_read
|
||||
u32_t sio_read(sio_fd_t, u8_t *, u32_t);
|
||||
#endif
|
||||
|
||||
#ifndef sio_write
|
||||
u32_t sio_write(sio_fd_t, u8_t *, u32_t);
|
||||
#endif
|
||||
|
||||
#ifndef sio_read_abort
|
||||
void sio_read_abort(sio_fd_t);
|
||||
#endif
|
@ -1,178 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Leon Woestenberg <leon.woestenberg@axon.tv>
|
||||
* Copyright (c) 2001, 2002 Axon Digital Design B.V., The Netherlands.
|
||||
* 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 lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Leon Woestenberg <leon.woestenberg@axon.tv>
|
||||
*
|
||||
*/
|
||||
#ifndef __LWIP_SNMP_H__
|
||||
#define __LWIP_SNMP_H__
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
/* SNMP support available? */
|
||||
#if defined(LWIP_SNMP) && (LWIP_SNMP > 0)
|
||||
|
||||
/* network interface */
|
||||
void snmp_add_ifinoctets(unsigned long value);
|
||||
void snmp_inc_ifinucastpkts(void);
|
||||
void snmp_inc_ifinnucastpkts(void);
|
||||
void snmp_inc_ifindiscards(void);
|
||||
void snmp_add_ifoutoctets(unsigned long value);
|
||||
void snmp_inc_ifoutucastpkts(void);
|
||||
void snmp_inc_ifoutnucastpkts(void);
|
||||
void snmp_inc_ifoutdiscards(void);
|
||||
|
||||
/* IP */
|
||||
void snmp_inc_ipinreceives(void);
|
||||
void snmp_inc_ipindelivers(void);
|
||||
void snmp_inc_ipindiscards(void);
|
||||
void snmp_inc_ipoutdiscards(void);
|
||||
void snmp_inc_ipoutrequests(void);
|
||||
void snmp_inc_ipunknownprotos(void);
|
||||
void snmp_inc_ipnoroutes(void);
|
||||
void snmp_inc_ipforwdatagrams(void);
|
||||
|
||||
/* ICMP */
|
||||
void snmp_inc_icmpinmsgs(void);
|
||||
void snmp_inc_icmpinerrors(void);
|
||||
void snmp_inc_icmpindestunreachs(void);
|
||||
void snmp_inc_icmpintimeexcds(void);
|
||||
void snmp_inc_icmpinparmprobs(void);
|
||||
void snmp_inc_icmpinsrcquenchs(void);
|
||||
void snmp_inc_icmpinredirects(void);
|
||||
void snmp_inc_icmpinechos(void);
|
||||
void snmp_inc_icmpinechoreps(void);
|
||||
void snmp_inc_icmpintimestamps(void);
|
||||
void snmp_inc_icmpintimestampreps(void);
|
||||
void snmp_inc_icmpinaddrmasks(void);
|
||||
void snmp_inc_icmpinaddrmaskreps(void);
|
||||
void snmp_inc_icmpoutmsgs(void);
|
||||
void snmp_inc_icmpouterrors(void);
|
||||
void snmp_inc_icmpoutdestunreachs(void);
|
||||
void snmp_inc_icmpouttimeexcds(void);
|
||||
void snmp_inc_icmpoutparmprobs(void);
|
||||
void snmp_inc_icmpoutsrcquenchs(void);
|
||||
void snmp_inc_icmpoutredirects(void);
|
||||
void snmp_inc_icmpoutechos(void);
|
||||
void snmp_inc_icmpoutechoreps(void);
|
||||
void snmp_inc_icmpouttimestamps(void);
|
||||
void snmp_inc_icmpouttimestampreps(void);
|
||||
void snmp_inc_icmpoutaddrmasks(void);
|
||||
void snmp_inc_icmpoutaddrmaskreps(void);
|
||||
|
||||
/* TCP */
|
||||
void snmp_inc_tcpactiveopens(void);
|
||||
void snmp_inc_tcppassiveopens(void);
|
||||
void snmp_inc_tcpattemptfails(void);
|
||||
void snmp_inc_tcpestabresets(void);
|
||||
void snmp_inc_tcpcurrestab(void);
|
||||
void snmp_inc_tcpinsegs(void);
|
||||
void snmp_inc_tcpoutsegs(void);
|
||||
void snmp_inc_tcpretranssegs(void);
|
||||
void snmp_inc_tcpinerrs(void);
|
||||
void snmp_inc_tcpoutrsts(void);
|
||||
|
||||
/* UDP */
|
||||
void snmp_inc_udpindatagrams(void);
|
||||
void snmp_inc_udpnoports(void);
|
||||
void snmp_inc_udpinerrors(void);
|
||||
void snmp_inc_udpoutdatagrams(void);
|
||||
|
||||
/* LWIP_SNMP support not available */
|
||||
/* define everything to be empty */
|
||||
#else
|
||||
|
||||
/* network interface */
|
||||
#define snmp_add_ifinoctets(value)
|
||||
#define snmp_inc_ifinucastpkts()
|
||||
#define snmp_inc_ifinnucastpkts()
|
||||
#define snmp_inc_ifindiscards()
|
||||
#define snmp_add_ifoutoctets(value)
|
||||
#define snmp_inc_ifoutucastpkts()
|
||||
#define snmp_inc_ifoutnucastpkts()
|
||||
#define snmp_inc_ifoutdiscards()
|
||||
|
||||
/* IP */
|
||||
#define snmp_inc_ipinreceives()
|
||||
#define snmp_inc_ipindelivers()
|
||||
#define snmp_inc_ipindiscards()
|
||||
#define snmp_inc_ipoutdiscards()
|
||||
#define snmp_inc_ipoutrequests()
|
||||
#define snmp_inc_ipunknownprotos()
|
||||
#define snmp_inc_ipnoroutes()
|
||||
#define snmp_inc_ipforwdatagrams()
|
||||
|
||||
/* ICMP */
|
||||
#define snmp_inc_icmpinmsgs()
|
||||
#define snmp_inc_icmpinerrors()
|
||||
#define snmp_inc_icmpindestunreachs()
|
||||
#define snmp_inc_icmpintimeexcds()
|
||||
#define snmp_inc_icmpinparmprobs()
|
||||
#define snmp_inc_icmpinsrcquenchs()
|
||||
#define snmp_inc_icmpinredirects()
|
||||
#define snmp_inc_icmpinechos()
|
||||
#define snmp_inc_icmpinechoreps()
|
||||
#define snmp_inc_icmpintimestamps()
|
||||
#define snmp_inc_icmpintimestampreps()
|
||||
#define snmp_inc_icmpinaddrmasks()
|
||||
#define snmp_inc_icmpinaddrmaskreps()
|
||||
#define snmp_inc_icmpoutmsgs()
|
||||
#define snmp_inc_icmpouterrors()
|
||||
#define snmp_inc_icmpoutdestunreachs()
|
||||
#define snmp_inc_icmpouttimeexcds()
|
||||
#define snmp_inc_icmpoutparmprobs()
|
||||
#define snmp_inc_icmpoutsrcquenchs()
|
||||
#define snmp_inc_icmpoutredirects()
|
||||
#define snmp_inc_icmpoutechos()
|
||||
#define snmp_inc_icmpoutechoreps()
|
||||
#define snmp_inc_icmpouttimestamps()
|
||||
#define snmp_inc_icmpouttimestampreps()
|
||||
#define snmp_inc_icmpoutaddrmasks()
|
||||
#define snmp_inc_icmpoutaddrmaskreps()
|
||||
/* TCP */
|
||||
#define snmp_inc_tcpactiveopens()
|
||||
#define snmp_inc_tcppassiveopens()
|
||||
#define snmp_inc_tcpattemptfails()
|
||||
#define snmp_inc_tcpestabresets()
|
||||
#define snmp_inc_tcpcurrestab()
|
||||
#define snmp_inc_tcpinsegs()
|
||||
#define snmp_inc_tcpoutsegs()
|
||||
#define snmp_inc_tcpretranssegs()
|
||||
#define snmp_inc_tcpinerrs()
|
||||
#define snmp_inc_tcpoutrsts()
|
||||
|
||||
/* UDP */
|
||||
#define snmp_inc_udpindatagrams()
|
||||
#define snmp_inc_udpnoports()
|
||||
#define snmp_inc_udpinerrors()
|
||||
#define snmp_inc_udpoutdatagrams()
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* __LWIP_SNMP_H__ */
|
@ -1,271 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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 lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __LWIP_SOCKETS_H__
|
||||
#define __LWIP_SOCKETS_H__
|
||||
#include "lwip/ip_addr.h"
|
||||
|
||||
struct sockaddr_in {
|
||||
u8_t sin_len;
|
||||
u8_t sin_family;
|
||||
u16_t sin_port;
|
||||
struct in_addr sin_addr;
|
||||
char sin_zero[8];
|
||||
};
|
||||
|
||||
struct sockaddr {
|
||||
u8_t sa_len;
|
||||
u8_t sa_family;
|
||||
char sa_data[14];
|
||||
};
|
||||
|
||||
#ifndef socklen_t
|
||||
# define socklen_t int
|
||||
#endif
|
||||
|
||||
|
||||
#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 0xfff /* 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 {
|
||||
unsigned char fd_bits [(FD_SETSIZE+7)/8];
|
||||
} fd_set;
|
||||
|
||||
/*
|
||||
* only define this in sockets.c so it does not interfere
|
||||
* with other projects namespaces where timeval is present
|
||||
*/
|
||||
#ifndef LWIP_TIMEVAL_PRIVATE
|
||||
#define LWIP_TIMEVAL_PRIVATE 1
|
||||
#endif
|
||||
|
||||
#if LWIP_TIMEVAL_PRIVATE
|
||||
struct timeval {
|
||||
long tv_sec; /* seconds */
|
||||
long tv_usec; /* and microseconds */
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
int lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
|
||||
int lwip_bind(int s, struct sockaddr *name, socklen_t namelen);
|
||||
int lwip_shutdown(int s, int how);
|
||||
int lwip_getpeername (int s, struct sockaddr *name, socklen_t *namelen);
|
||||
int lwip_getsockname (int s, struct sockaddr *name, socklen_t *namelen);
|
||||
int lwip_getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen);
|
||||
int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen);
|
||||
int lwip_close(int s);
|
||||
int lwip_connect(int s, struct sockaddr *name, socklen_t namelen);
|
||||
int lwip_listen(int s, int backlog);
|
||||
int lwip_recv(int s, void *mem, int len, unsigned int flags);
|
||||
int lwip_read(int s, void *mem, int len);
|
||||
int lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
|
||||
struct sockaddr *from, socklen_t *fromlen);
|
||||
int lwip_send(int s, void *dataptr, int size, unsigned int flags);
|
||||
int lwip_sendto(int s, void *dataptr, int size, unsigned int flags,
|
||||
struct sockaddr *to, socklen_t tolen);
|
||||
int lwip_socket(int domain, int type, int protocol);
|
||||
int lwip_write(int s, void *dataptr, int size);
|
||||
int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
|
||||
struct timeval *timeout);
|
||||
int lwip_ioctl(int s, long cmd, void *argp);
|
||||
|
||||
#if LWIP_COMPAT_SOCKETS
|
||||
#define accept(a,b,c) lwip_accept(a,b,c)
|
||||
#define bind(a,b,c) lwip_bind(a,b,c)
|
||||
#define shutdown(a,b) lwip_shutdown(a,b)
|
||||
#define close(s) lwip_close(s)
|
||||
#define connect(a,b,c) lwip_connect(a,b,c)
|
||||
#define getsockname(a,b,c) lwip_getsockname(a,b,c)
|
||||
#define getpeername(a,b,c) lwip_getpeername(a,b,c)
|
||||
#define setsockopt(a,b,c,d,e) lwip_setsockopt(a,b,c,d,e)
|
||||
#define getsockopt(a,b,c,d,e) lwip_getsockopt(a,b,c,d,e)
|
||||
#define listen(a,b) lwip_listen(a,b)
|
||||
#define recv(a,b,c,d) lwip_recv(a,b,c,d)
|
||||
#define read(a,b,c) lwip_read(a,b,c)
|
||||
#define recvfrom(a,b,c,d,e,f) lwip_recvfrom(a,b,c,d,e,f)
|
||||
#define send(a,b,c,d) lwip_send(a,b,c,d)
|
||||
#define sendto(a,b,c,d,e,f) lwip_sendto(a,b,c,d,e,f)
|
||||
#define socket(a,b,c) lwip_socket(a,b,c)
|
||||
#define write(a,b,c) lwip_write(a,b,c)
|
||||
#define select(a,b,c,d,e) lwip_select(a,b,c,d,e)
|
||||
#define ioctlsocket(a,b,c) lwip_ioctl(a,b,c)
|
||||
#endif /* LWIP_COMPAT_SOCKETS */
|
||||
|
||||
#endif /* __LWIP_SOCKETS_H__ */
|
||||
|
@ -1,158 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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 lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __LWIP_STATS_H__
|
||||
#define __LWIP_STATS_H__
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "arch/cc.h"
|
||||
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/memp.h"
|
||||
|
||||
#if LWIP_STATS
|
||||
|
||||
struct stats_proto {
|
||||
u16_t xmit; /* Transmitted packets. */
|
||||
u16_t rexmit; /* Retransmitted packets. */
|
||||
u16_t recv; /* Received packets. */
|
||||
u16_t fw; /* Forwarded packets. */
|
||||
u16_t drop; /* Dropped packets. */
|
||||
u16_t chkerr; /* Checksum error. */
|
||||
u16_t lenerr; /* Invalid length error. */
|
||||
u16_t memerr; /* Out of memory error. */
|
||||
u16_t rterr; /* Routing error. */
|
||||
u16_t proterr; /* Protocol error. */
|
||||
u16_t opterr; /* Error in options. */
|
||||
u16_t err; /* Misc error. */
|
||||
u16_t cachehit;
|
||||
};
|
||||
|
||||
struct stats_mem {
|
||||
mem_size_t avail;
|
||||
mem_size_t used;
|
||||
mem_size_t max;
|
||||
mem_size_t err;
|
||||
};
|
||||
|
||||
struct stats_pbuf {
|
||||
u16_t avail;
|
||||
u16_t used;
|
||||
u16_t max;
|
||||
u16_t err;
|
||||
|
||||
u16_t alloc_locked;
|
||||
u16_t refresh_locked;
|
||||
};
|
||||
|
||||
struct stats_syselem {
|
||||
u16_t used;
|
||||
u16_t max;
|
||||
u16_t err;
|
||||
};
|
||||
|
||||
struct stats_sys {
|
||||
struct stats_syselem sem;
|
||||
struct stats_syselem mbox;
|
||||
};
|
||||
|
||||
struct stats_ {
|
||||
struct stats_proto link;
|
||||
struct stats_proto ip_frag;
|
||||
struct stats_proto ip;
|
||||
struct stats_proto icmp;
|
||||
struct stats_proto udp;
|
||||
struct stats_proto tcp;
|
||||
struct stats_pbuf pbuf;
|
||||
struct stats_mem mem;
|
||||
struct stats_mem memp[MEMP_MAX];
|
||||
struct stats_sys sys;
|
||||
};
|
||||
|
||||
extern struct stats_ lwip_stats;
|
||||
|
||||
|
||||
void stats_init(void);
|
||||
|
||||
#define STATS_INC(x) ++lwip_stats.x
|
||||
#else
|
||||
#define stats_init()
|
||||
#define STATS_INC(x)
|
||||
#endif /* LWIP_STATS */
|
||||
|
||||
#if TCP_STATS
|
||||
#define TCP_STATS_INC(x) STATS_INC(x)
|
||||
#else
|
||||
#define TCP_STATS_INC(x)
|
||||
#endif
|
||||
|
||||
#if UDP_STATS
|
||||
#define UDP_STATS_INC(x) STATS_INC(x)
|
||||
#else
|
||||
#define UDP_STATS_INC(x)
|
||||
#endif
|
||||
|
||||
#if ICMP_STATS
|
||||
#define ICMP_STATS_INC(x) STATS_INC(x)
|
||||
#else
|
||||
#define ICMP_STATS_INC(x)
|
||||
#endif
|
||||
|
||||
#if IP_STATS
|
||||
#define IP_STATS_INC(x) STATS_INC(x)
|
||||
#else
|
||||
#define IP_STATS_INC(x)
|
||||
#endif
|
||||
|
||||
#if IPFRAG_STATS
|
||||
#define IPFRAG_STATS_INC(x) STATS_INC(x)
|
||||
#else
|
||||
#define IPFRAG_STATS_INC(x)
|
||||
#endif
|
||||
|
||||
#if LINK_STATS
|
||||
#define LINK_STATS_INC(x) STATS_INC(x)
|
||||
#else
|
||||
#define LINK_STATS_INC(x)
|
||||
#endif
|
||||
|
||||
/* Display of statistics */
|
||||
#if LWIP_STATS_DISPLAY
|
||||
void stats_display(void);
|
||||
#else
|
||||
#define stats_display()
|
||||
#endif
|
||||
|
||||
#endif /* __LWIP_STATS_H__ */
|
||||
|
||||
|
||||
|
||||
|
@ -1,183 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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 lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __LWIP_SYS_H__
|
||||
#define __LWIP_SYS_H__
|
||||
|
||||
#include "arch/cc.h"
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
|
||||
#if NO_SYS
|
||||
|
||||
/* For a totally minimal and standalone system, we provide null
|
||||
definitions of the sys_ functions. */
|
||||
#include "arch/sys_arch.h"
|
||||
|
||||
struct sys_timeout {u8_t dummy;};
|
||||
|
||||
#define sys_init()
|
||||
#define sys_timeout(m,h,a)
|
||||
#define sys_untimeout(m,a)
|
||||
#define sys_sem_new(c) c
|
||||
#define sys_sem_signal(s)
|
||||
#define sys_sem_wait(s)
|
||||
#define sys_sem_free(s)
|
||||
#define sys_mbox_new() 0
|
||||
#define sys_mbox_fetch(m,d)
|
||||
#define sys_mbox_post(m,d)
|
||||
#define sys_mbox_free(m)
|
||||
|
||||
#define sys_thread_new(t,a,p)
|
||||
|
||||
#else /* NO_SYS */
|
||||
|
||||
#include "arch/sys_arch.h"
|
||||
|
||||
/** Return code for timeouts from sys_arch_mbox_fetch and sys_arch_sem_wait */
|
||||
#define SYS_ARCH_TIMEOUT 0xffffffff
|
||||
|
||||
typedef void (* sys_timeout_handler)(void *arg);
|
||||
|
||||
struct sys_timeout {
|
||||
struct sys_timeout *next;
|
||||
u32_t time;
|
||||
sys_timeout_handler h;
|
||||
void *arg;
|
||||
};
|
||||
|
||||
struct sys_timeouts {
|
||||
struct sys_timeout *next;
|
||||
};
|
||||
|
||||
/* sys_init() must be called before anthing else. */
|
||||
void sys_init(void);
|
||||
|
||||
/*
|
||||
* sys_timeout():
|
||||
*
|
||||
* Schedule a timeout a specified amount of milliseconds in the
|
||||
* future. When the timeout occurs, the specified timeout handler will
|
||||
* be called. The handler will be passed the "arg" argument when
|
||||
* called.
|
||||
*
|
||||
*/
|
||||
void sys_timeout(u32_t msecs, sys_timeout_handler h, void *arg);
|
||||
void sys_untimeout(sys_timeout_handler h, void *arg);
|
||||
struct sys_timeouts *sys_arch_timeouts(void);
|
||||
|
||||
/* Semaphore functions. */
|
||||
sys_sem_t sys_sem_new(u8_t count);
|
||||
void sys_sem_signal(sys_sem_t sem);
|
||||
u32_t sys_arch_sem_wait(sys_sem_t sem, u32_t timeout);
|
||||
void sys_sem_free(sys_sem_t sem);
|
||||
void sys_sem_wait(sys_sem_t sem);
|
||||
int sys_sem_wait_timeout(sys_sem_t sem, u32_t timeout);
|
||||
|
||||
/* Time functions. */
|
||||
#ifndef sys_msleep
|
||||
void sys_msleep(u32_t ms); /* only has a (close to) 1 jiffy resolution. */
|
||||
#endif
|
||||
#ifndef sys_jiffies
|
||||
u32_t sys_jiffies(void); /* since power up. */
|
||||
#endif
|
||||
|
||||
/* Mailbox functions. */
|
||||
sys_mbox_t sys_mbox_new(void);
|
||||
void sys_mbox_post(sys_mbox_t mbox, void *msg);
|
||||
u32_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u32_t timeout);
|
||||
void sys_mbox_free(sys_mbox_t mbox);
|
||||
void sys_mbox_fetch(sys_mbox_t mbox, void **msg);
|
||||
|
||||
|
||||
/* Thread functions. */
|
||||
sys_thread_t sys_thread_new(void (* thread)(void *arg), void *arg, int prio);
|
||||
|
||||
/* The following functions are used only in Unix code, and
|
||||
can be omitted when porting the stack. */
|
||||
/* Returns the current time in microseconds. */
|
||||
unsigned long sys_now(void);
|
||||
|
||||
#endif /* NO_SYS */
|
||||
|
||||
/* Critical Region Protection */
|
||||
/* These functions must be implemented in the sys_arch.c file.
|
||||
In some implementations they can provide a more light-weight protection
|
||||
mechanism than using semaphores. Otherwise semaphores can be used for
|
||||
implementation */
|
||||
#ifndef SYS_ARCH_PROTECT
|
||||
/** SYS_LIGHTWEIGHT_PROT
|
||||
* define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection
|
||||
* for certain critical regions during buffer allocation, deallocation and memory
|
||||
* allocation and deallocation.
|
||||
*/
|
||||
#if SYS_LIGHTWEIGHT_PROT
|
||||
|
||||
/** SYS_ARCH_DECL_PROTECT
|
||||
* declare a protection variable. This macro will default to defining a variable of
|
||||
* type sys_prot_t. If a particular port needs a different implementation, then
|
||||
* this macro may be defined in sys_arch.h.
|
||||
*/
|
||||
#define SYS_ARCH_DECL_PROTECT(lev) sys_prot_t lev
|
||||
/** SYS_ARCH_PROTECT
|
||||
* Perform a "fast" protect. This could be implemented by
|
||||
* disabling interrupts for an embedded system or by using a semaphore or
|
||||
* mutex. The implementation should allow calling SYS_ARCH_PROTECT when
|
||||
* already protected. The old protection level is returned in the variable
|
||||
* "lev". This macro will default to calling the sys_arch_protect() function
|
||||
* which should be implemented in sys_arch.c. If a particular port needs a
|
||||
* different implementation, then this macro may be defined in sys_arch.h
|
||||
*/
|
||||
#define SYS_ARCH_PROTECT(lev) lev = sys_arch_protect()
|
||||
/** SYS_ARCH_UNPROTECT
|
||||
* Perform a "fast" set of the protection level to "lev". This could be
|
||||
* implemented by setting the interrupt level to "lev" within the MACRO or by
|
||||
* using a semaphore or mutex. This macro will default to calling the
|
||||
* sys_arch_unprotect() function which should be implemented in
|
||||
* sys_arch.c. If a particular port needs a different implementation, then
|
||||
* this macro may be defined in sys_arch.h
|
||||
*/
|
||||
#define SYS_ARCH_UNPROTECT(lev) sys_arch_unprotect(lev)
|
||||
sys_prot_t sys_arch_protect(void);
|
||||
void sys_arch_unprotect(sys_prot_t pval);
|
||||
|
||||
#else
|
||||
|
||||
#define SYS_ARCH_DECL_PROTECT(lev)
|
||||
#define SYS_ARCH_PROTECT(lev)
|
||||
#define SYS_ARCH_UNPROTECT(lev)
|
||||
|
||||
#endif /* SYS_LIGHTWEIGHT_PROT */
|
||||
|
||||
#endif /* SYS_ARCH_PROTECT */
|
||||
|
||||
#endif /* __LWIP_SYS_H__ */
|
@ -1,533 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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 lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __LWIP_TCP_H__
|
||||
#define __LWIP_TCP_H__
|
||||
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/mem.h"
|
||||
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/ip.h"
|
||||
#include "lwip/icmp.h"
|
||||
|
||||
#include "lwip/err.h"
|
||||
|
||||
struct tcp_pcb;
|
||||
|
||||
/* Functions for interfacing with TCP: */
|
||||
|
||||
/* Lower layer interface to TCP: */
|
||||
void tcp_init (void); /* Must be called first to
|
||||
initialize TCP. */
|
||||
void tcp_tmr (void); /* Must be called every
|
||||
TCP_TMR_INTERVAL
|
||||
ms. (Typically 250 ms). */
|
||||
/* Application program's interface: */
|
||||
struct tcp_pcb * tcp_new (void);
|
||||
struct tcp_pcb * tcp_alloc (u8_t prio);
|
||||
|
||||
void tcp_arg (struct tcp_pcb *pcb, void *arg);
|
||||
void tcp_accept (struct tcp_pcb *pcb,
|
||||
err_t (* accept)(void *arg, struct tcp_pcb *newpcb,
|
||||
err_t err));
|
||||
void tcp_recv (struct tcp_pcb *pcb,
|
||||
err_t (* recv)(void *arg, struct tcp_pcb *tpcb,
|
||||
struct pbuf *p, err_t err));
|
||||
void tcp_sent (struct tcp_pcb *pcb,
|
||||
err_t (* sent)(void *arg, struct tcp_pcb *tpcb,
|
||||
u16_t len));
|
||||
void tcp_poll (struct tcp_pcb *pcb,
|
||||
err_t (* poll)(void *arg, struct tcp_pcb *tpcb),
|
||||
u8_t interval);
|
||||
void tcp_err (struct tcp_pcb *pcb,
|
||||
void (* err)(void *arg, err_t err));
|
||||
|
||||
#define tcp_mss(pcb) ((pcb)->mss)
|
||||
#define tcp_sndbuf(pcb) ((pcb)->snd_buf)
|
||||
|
||||
void tcp_recved (struct tcp_pcb *pcb, u16_t len);
|
||||
err_t tcp_bind (struct tcp_pcb *pcb, struct ip_addr *ipaddr,
|
||||
u16_t port);
|
||||
err_t tcp_connect (struct tcp_pcb *pcb, struct ip_addr *ipaddr,
|
||||
u16_t port, err_t (* connected)(void *arg,
|
||||
struct tcp_pcb *tpcb,
|
||||
err_t err));
|
||||
struct tcp_pcb * tcp_listen (struct tcp_pcb *pcb);
|
||||
void tcp_abort (struct tcp_pcb *pcb);
|
||||
err_t tcp_close (struct tcp_pcb *pcb);
|
||||
err_t tcp_write (struct tcp_pcb *pcb, const void *dataptr, u16_t len,
|
||||
u8_t copy);
|
||||
|
||||
void tcp_setprio (struct tcp_pcb *pcb, u8_t prio);
|
||||
|
||||
#define TCP_PRIO_MIN 1
|
||||
#define TCP_PRIO_NORMAL 64
|
||||
#define TCP_PRIO_MAX 127
|
||||
|
||||
/* It is also possible to call these two functions at the right
|
||||
intervals (instead of calling tcp_tmr()). */
|
||||
void tcp_slowtmr (void);
|
||||
void tcp_fasttmr (void);
|
||||
|
||||
|
||||
/* Only used by IP to pass a TCP segment to TCP: */
|
||||
void tcp_input (struct pbuf *p, struct netif *inp);
|
||||
/* Used within the TCP code only: */
|
||||
err_t tcp_output (struct tcp_pcb *pcb);
|
||||
void tcp_rexmit (struct tcp_pcb *pcb);
|
||||
void tcp_rexmit_rto (struct tcp_pcb *pcb);
|
||||
|
||||
|
||||
|
||||
#define TCP_SEQ_LT(a,b) ((s32_t)((a)-(b)) < 0)
|
||||
#define TCP_SEQ_LEQ(a,b) ((s32_t)((a)-(b)) <= 0)
|
||||
#define TCP_SEQ_GT(a,b) ((s32_t)((a)-(b)) > 0)
|
||||
#define TCP_SEQ_GEQ(a,b) ((s32_t)((a)-(b)) >= 0)
|
||||
/* is b<=a<=c? */
|
||||
#if 0 /* see bug #10548 */
|
||||
#define TCP_SEQ_BETWEEN(a,b,c) ((c)-(b) >= (a)-(b))
|
||||
#endif
|
||||
#define TCP_SEQ_BETWEEN(a,b,c) (TCP_SEQ_GEQ(a,b) && TCP_SEQ_LEQ(a,c))
|
||||
#define TCP_FIN 0x01U
|
||||
#define TCP_SYN 0x02U
|
||||
#define TCP_RST 0x04U
|
||||
#define TCP_PSH 0x08U
|
||||
#define TCP_ACK 0x10U
|
||||
#define TCP_URG 0x20U
|
||||
#define TCP_ECE 0x40U
|
||||
#define TCP_CWR 0x80U
|
||||
|
||||
#define TCP_FLAGS 0x3fU
|
||||
|
||||
/* Length of the TCP header, excluding options. */
|
||||
#define TCP_HLEN 20
|
||||
|
||||
#ifndef TCP_TMR_INTERVAL
|
||||
#define TCP_TMR_INTERVAL 250 /* The TCP timer interval in
|
||||
milliseconds. */
|
||||
#endif /* TCP_TMR_INTERVAL */
|
||||
|
||||
#ifndef TCP_FAST_INTERVAL
|
||||
#define TCP_FAST_INTERVAL TCP_TMR_INTERVAL /* the fine grained timeout in
|
||||
milliseconds */
|
||||
#endif /* TCP_FAST_INTERVAL */
|
||||
|
||||
#ifndef TCP_SLOW_INTERVAL
|
||||
#define TCP_SLOW_INTERVAL (2*TCP_TMR_INTERVAL) /* the coarse grained timeout in
|
||||
milliseconds */
|
||||
#endif /* TCP_SLOW_INTERVAL */
|
||||
|
||||
#define TCP_FIN_WAIT_TIMEOUT 20000 /* milliseconds */
|
||||
#define TCP_SYN_RCVD_TIMEOUT 20000 /* milliseconds */
|
||||
|
||||
#define TCP_OOSEQ_TIMEOUT 6 /* x RTO */
|
||||
|
||||
#define TCP_MSL 60000 /* The maximum segment lifetime in microseconds */
|
||||
|
||||
/*
|
||||
* User-settable options (used with setsockopt).
|
||||
*/
|
||||
#define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */
|
||||
#define TCP_KEEPALIVE 0x02 /* send KEEPALIVE probes when idle for pcb->keepalive miliseconds */
|
||||
|
||||
/* Keepalive values */
|
||||
#define TCP_KEEPDEFAULT 7200000 /* KEEPALIVE timer in miliseconds */
|
||||
#define TCP_KEEPINTVL 75000 /* Time between KEEPALIVE probes in miliseconds */
|
||||
#define TCP_KEEPCNT 9 /* Counter for KEEPALIVE probes */
|
||||
#define TCP_MAXIDLE TCP_KEEPCNT * TCP_KEEPINTVL /* Maximum KEEPALIVE probe time */
|
||||
|
||||
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct tcp_hdr {
|
||||
PACK_STRUCT_FIELD(u16_t src);
|
||||
PACK_STRUCT_FIELD(u16_t dest);
|
||||
PACK_STRUCT_FIELD(u32_t seqno);
|
||||
PACK_STRUCT_FIELD(u32_t ackno);
|
||||
PACK_STRUCT_FIELD(u16_t _hdrlen_rsvd_flags);
|
||||
PACK_STRUCT_FIELD(u16_t wnd);
|
||||
PACK_STRUCT_FIELD(u16_t chksum);
|
||||
PACK_STRUCT_FIELD(u16_t urgp);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
#define TCPH_OFFSET(phdr) (ntohs((phdr)->_hdrlen_rsvd_flags) >> 8)
|
||||
#define TCPH_HDRLEN(phdr) (ntohs((phdr)->_hdrlen_rsvd_flags) >> 12)
|
||||
#define TCPH_FLAGS(phdr) (ntohs((phdr)->_hdrlen_rsvd_flags) & TCP_FLAGS)
|
||||
|
||||
#define TCPH_OFFSET_SET(phdr, offset) (phdr)->_hdrlen_rsvd_flags = htons(((offset) << 8) | TCPH_FLAGS(phdr))
|
||||
#define TCPH_HDRLEN_SET(phdr, len) (phdr)->_hdrlen_rsvd_flags = htons(((len) << 12) | TCPH_FLAGS(phdr))
|
||||
#define TCPH_FLAGS_SET(phdr, flags) (phdr)->_hdrlen_rsvd_flags = htons((ntohs((phdr)->_hdrlen_rsvd_flags) & ~TCP_FLAGS) | (flags))
|
||||
#define TCPH_SET_FLAG(phdr, flags ) (phdr)->_hdrlen_rsvd_flags = htons(ntohs((phdr)->_hdrlen_rsvd_flags) | (flags))
|
||||
#define TCPH_UNSET_FLAG(phdr, flags) (phdr)->_hdrlen_rsvd_flags = htons(ntohs((phdr)->_hdrlen_rsvd_flags) | (TCPH_FLAGS(phdr) & ~(flags)) )
|
||||
|
||||
#define TCP_TCPLEN(seg) ((seg)->len + ((TCPH_FLAGS((seg)->tcphdr) & TCP_FIN || \
|
||||
TCPH_FLAGS((seg)->tcphdr) & TCP_SYN)? 1: 0))
|
||||
|
||||
enum tcp_state {
|
||||
CLOSED = 0,
|
||||
LISTEN = 1,
|
||||
SYN_SENT = 2,
|
||||
SYN_RCVD = 3,
|
||||
ESTABLISHED = 4,
|
||||
FIN_WAIT_1 = 5,
|
||||
FIN_WAIT_2 = 6,
|
||||
CLOSE_WAIT = 7,
|
||||
CLOSING = 8,
|
||||
LAST_ACK = 9,
|
||||
TIME_WAIT = 10
|
||||
};
|
||||
|
||||
/* the TCP protocol control block */
|
||||
struct tcp_pcb {
|
||||
/** common PCB members */
|
||||
IP_PCB;
|
||||
/** protocol specific PCB members */
|
||||
struct tcp_pcb *next; /* for the linked list */
|
||||
enum tcp_state state; /* TCP state */
|
||||
u8_t prio;
|
||||
void *callback_arg;
|
||||
|
||||
u16_t local_port;
|
||||
u16_t remote_port;
|
||||
|
||||
u8_t flags;
|
||||
#define TF_ACK_DELAY (u8_t)0x01U /* Delayed ACK. */
|
||||
#define TF_ACK_NOW (u8_t)0x02U /* Immediate ACK. */
|
||||
#define TF_INFR (u8_t)0x04U /* In fast recovery. */
|
||||
#define TF_RESET (u8_t)0x08U /* Connection was reset. */
|
||||
#define TF_CLOSED (u8_t)0x10U /* Connection was sucessfully closed. */
|
||||
#define TF_GOT_FIN (u8_t)0x20U /* Connection was closed by the remote end. */
|
||||
#define TF_NODELAY (u8_t)0x40U /* Disable Nagle algorithm */
|
||||
|
||||
/* receiver variables */
|
||||
u32_t rcv_nxt; /* next seqno expected */
|
||||
u16_t rcv_wnd; /* receiver window */
|
||||
|
||||
/* Timers */
|
||||
u32_t tmr;
|
||||
u8_t polltmr, pollinterval;
|
||||
|
||||
/* Retransmission timer. */
|
||||
u16_t rtime;
|
||||
|
||||
u16_t mss; /* maximum segment size */
|
||||
|
||||
/* RTT (round trip time) estimation variables */
|
||||
u32_t rttest; /* RTT estimate in 500ms ticks */
|
||||
u32_t rtseq; /* sequence number being timed */
|
||||
s16_t sa, sv; /* @todo document this */
|
||||
|
||||
u16_t rto; /* retransmission time-out */
|
||||
u8_t nrtx; /* number of retransmissions */
|
||||
|
||||
/* fast retransmit/recovery */
|
||||
u32_t lastack; /* Highest acknowledged seqno. */
|
||||
u8_t dupacks;
|
||||
|
||||
/* congestion avoidance/control variables */
|
||||
u16_t cwnd;
|
||||
u16_t ssthresh;
|
||||
|
||||
/* sender variables */
|
||||
u32_t snd_nxt, /* next seqno to be sent */
|
||||
snd_max, /* Highest seqno sent. */
|
||||
snd_wnd, /* sender window */
|
||||
snd_wl1, snd_wl2, /* Sequence and acknowledgement numbers of last
|
||||
window update. */
|
||||
snd_lbb; /* Sequence number of next byte to be buffered. */
|
||||
|
||||
u16_t acked;
|
||||
|
||||
u16_t snd_buf; /* Available buffer space for sending (in bytes). */
|
||||
u16_t snd_queuelen; /* Available buffer space for sending (in tcp_segs). */
|
||||
|
||||
|
||||
/* These are ordered by sequence number: */
|
||||
struct tcp_seg *unsent; /* Unsent (queued) segments. */
|
||||
struct tcp_seg *unacked; /* Sent but unacknowledged segments. */
|
||||
#if TCP_QUEUE_OOSEQ
|
||||
struct tcp_seg *ooseq; /* Received out of sequence segments. */
|
||||
#endif /* TCP_QUEUE_OOSEQ */
|
||||
|
||||
#if LWIP_CALLBACK_API
|
||||
/* Function to be called when more send buffer space is available. */
|
||||
err_t (* sent)(void *arg, struct tcp_pcb *pcb, u16_t space);
|
||||
|
||||
/* Function to be called when (in-sequence) data has arrived. */
|
||||
err_t (* recv)(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err);
|
||||
|
||||
/* Function to be called when a connection has been set up. */
|
||||
err_t (* connected)(void *arg, struct tcp_pcb *pcb, err_t err);
|
||||
|
||||
/* Function to call when a listener has been connected. */
|
||||
err_t (* accept)(void *arg, struct tcp_pcb *newpcb, err_t err);
|
||||
|
||||
/* Function which is called periodically. */
|
||||
err_t (* poll)(void *arg, struct tcp_pcb *pcb);
|
||||
|
||||
/* Function to be called whenever a fatal error occurs. */
|
||||
void (* errf)(void *arg, err_t err);
|
||||
#endif /* LWIP_CALLBACK_API */
|
||||
|
||||
/* idle time before KEEPALIVE is sent */
|
||||
u32_t keepalive;
|
||||
|
||||
/* KEEPALIVE counter */
|
||||
u8_t keep_cnt;
|
||||
};
|
||||
|
||||
struct tcp_pcb_listen {
|
||||
/* Common members of all PCB types */
|
||||
IP_PCB;
|
||||
|
||||
/* Protocol specific PCB members */
|
||||
struct tcp_pcb_listen *next; /* for the linked list */
|
||||
|
||||
/* Even if state is obviously LISTEN this is here for
|
||||
* field compatibility with tpc_pcb to which it is cast sometimes
|
||||
* Until a cleaner solution emerges this is here.FIXME
|
||||
*/
|
||||
enum tcp_state state; /* TCP state */
|
||||
|
||||
u8_t prio;
|
||||
void *callback_arg;
|
||||
|
||||
u16_t local_port;
|
||||
|
||||
#if LWIP_CALLBACK_API
|
||||
/* Function to call when a listener has been connected. */
|
||||
err_t (* accept)(void *arg, struct tcp_pcb *newpcb, err_t err);
|
||||
#endif /* LWIP_CALLBACK_API */
|
||||
};
|
||||
|
||||
#if LWIP_EVENT_API
|
||||
|
||||
enum lwip_event {
|
||||
LWIP_EVENT_ACCEPT,
|
||||
LWIP_EVENT_SENT,
|
||||
LWIP_EVENT_RECV,
|
||||
LWIP_EVENT_CONNECTED,
|
||||
LWIP_EVENT_POLL,
|
||||
LWIP_EVENT_ERR
|
||||
};
|
||||
|
||||
err_t lwip_tcp_event(void *arg, struct tcp_pcb *pcb,
|
||||
enum lwip_event,
|
||||
struct pbuf *p,
|
||||
u16_t size,
|
||||
err_t err);
|
||||
|
||||
#define TCP_EVENT_ACCEPT(pcb,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
|
||||
LWIP_EVENT_ACCEPT, NULL, 0, err)
|
||||
#define TCP_EVENT_SENT(pcb,space,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
|
||||
LWIP_EVENT_SENT, NULL, space, ERR_OK)
|
||||
#define TCP_EVENT_RECV(pcb,p,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
|
||||
LWIP_EVENT_RECV, (p), 0, (err))
|
||||
#define TCP_EVENT_CONNECTED(pcb,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
|
||||
LWIP_EVENT_CONNECTED, NULL, 0, (err))
|
||||
#define TCP_EVENT_POLL(pcb,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
|
||||
LWIP_EVENT_POLL, NULL, 0, ERR_OK)
|
||||
#define TCP_EVENT_ERR(errf,arg,err) lwip_tcp_event((arg), NULL, \
|
||||
LWIP_EVENT_ERR, NULL, 0, (err))
|
||||
#else /* LWIP_EVENT_API */
|
||||
#define TCP_EVENT_ACCEPT(pcb,err,ret) \
|
||||
if((pcb)->accept != NULL) \
|
||||
(ret = (pcb)->accept((pcb)->callback_arg,(pcb),(err)))
|
||||
#define TCP_EVENT_SENT(pcb,space,ret) \
|
||||
if((pcb)->sent != NULL) \
|
||||
(ret = (pcb)->sent((pcb)->callback_arg,(pcb),(space)))
|
||||
#define TCP_EVENT_RECV(pcb,p,err,ret) \
|
||||
if((pcb)->recv != NULL) \
|
||||
{ ret = (pcb)->recv((pcb)->callback_arg,(pcb),(p),(err)); } else { \
|
||||
if (p) pbuf_free(p); }
|
||||
#define TCP_EVENT_CONNECTED(pcb,err,ret) \
|
||||
if((pcb)->connected != NULL) \
|
||||
(ret = (pcb)->connected((pcb)->callback_arg,(pcb),(err)))
|
||||
#define TCP_EVENT_POLL(pcb,ret) \
|
||||
if((pcb)->poll != NULL) \
|
||||
(ret = (pcb)->poll((pcb)->callback_arg,(pcb)))
|
||||
#define TCP_EVENT_ERR(errf,arg,err) \
|
||||
if((errf) != NULL) \
|
||||
(errf)((arg),(err))
|
||||
#endif /* LWIP_EVENT_API */
|
||||
|
||||
/* This structure represents a TCP segment on the unsent and unacked queues */
|
||||
struct tcp_seg {
|
||||
struct tcp_seg *next; /* used when putting segements on a queue */
|
||||
struct pbuf *p; /* buffer containing data + TCP header */
|
||||
void *dataptr; /* pointer to the TCP data in the pbuf */
|
||||
u16_t len; /* the TCP length of this segment */
|
||||
struct tcp_hdr *tcphdr; /* the TCP header */
|
||||
};
|
||||
|
||||
/* Internal functions and global variables: */
|
||||
struct tcp_pcb *tcp_pcb_copy(struct tcp_pcb *pcb);
|
||||
void tcp_pcb_purge(struct tcp_pcb *pcb);
|
||||
void tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb);
|
||||
|
||||
u8_t tcp_segs_free(struct tcp_seg *seg);
|
||||
u8_t tcp_seg_free(struct tcp_seg *seg);
|
||||
struct tcp_seg *tcp_seg_copy(struct tcp_seg *seg);
|
||||
|
||||
#define tcp_ack(pcb) if((pcb)->flags & TF_ACK_DELAY) { \
|
||||
(pcb)->flags &= ~TF_ACK_DELAY; \
|
||||
(pcb)->flags |= TF_ACK_NOW; \
|
||||
tcp_output(pcb); \
|
||||
} else { \
|
||||
(pcb)->flags |= TF_ACK_DELAY; \
|
||||
}
|
||||
|
||||
#define tcp_ack_now(pcb) (pcb)->flags |= TF_ACK_NOW; \
|
||||
tcp_output(pcb)
|
||||
|
||||
err_t tcp_send_ctrl(struct tcp_pcb *pcb, u8_t flags);
|
||||
err_t tcp_enqueue(struct tcp_pcb *pcb, void *dataptr, u16_t len,
|
||||
u8_t flags, u8_t copy,
|
||||
u8_t *optdata, u8_t optlen);
|
||||
|
||||
void tcp_rexmit_seg(struct tcp_pcb *pcb, struct tcp_seg *seg);
|
||||
|
||||
void tcp_rst(u32_t seqno, u32_t ackno,
|
||||
struct ip_addr *local_ip, struct ip_addr *remote_ip,
|
||||
u16_t local_port, u16_t remote_port);
|
||||
|
||||
u32_t tcp_next_iss(void);
|
||||
|
||||
void tcp_keepalive(struct tcp_pcb *pcb);
|
||||
|
||||
extern struct tcp_pcb *tcp_input_pcb;
|
||||
extern u32_t tcp_ticks;
|
||||
|
||||
#if TCP_DEBUG || TCP_INPUT_DEBUG || TCP_OUTPUT_DEBUG
|
||||
void tcp_debug_print(struct tcp_hdr *tcphdr);
|
||||
void tcp_debug_print_flags(u8_t flags);
|
||||
void tcp_debug_print_state(enum tcp_state s);
|
||||
void tcp_debug_print_pcbs(void);
|
||||
s16_t tcp_pcbs_sane(void);
|
||||
#else
|
||||
# define tcp_debug_print(tcphdr)
|
||||
# define tcp_debug_print_flags(flags)
|
||||
# define tcp_debug_print_state(s)
|
||||
# define tcp_debug_print_pcbs()
|
||||
# define tcp_pcbs_sane() 1
|
||||
#endif /* TCP_DEBUG */
|
||||
/*
|
||||
#if NO_SYS
|
||||
#define tcp_timer_needed()
|
||||
#else
|
||||
void tcp_timer_needed(void);
|
||||
#endif
|
||||
*/
|
||||
void tcp_timer_needed(void);
|
||||
|
||||
/* The TCP PCB lists. */
|
||||
union tcp_listen_pcbs_t { /* List of all TCP PCBs in LISTEN state. */
|
||||
struct tcp_pcb_listen *listen_pcbs;
|
||||
struct tcp_pcb *pcbs;
|
||||
};
|
||||
extern union tcp_listen_pcbs_t tcp_listen_pcbs;
|
||||
extern struct tcp_pcb *tcp_active_pcbs; /* List of all TCP PCBs that are in a
|
||||
state in which they accept or send
|
||||
data. */
|
||||
extern struct tcp_pcb *tcp_tw_pcbs; /* List of all TCP PCBs in TIME-WAIT. */
|
||||
|
||||
extern struct tcp_pcb *tcp_tmp_pcb; /* Only used for temporary storage. */
|
||||
|
||||
/* Axioms about the above lists:
|
||||
1) Every TCP PCB that is not CLOSED is in one of the lists.
|
||||
2) A PCB is only in one of the lists.
|
||||
3) All PCBs in the tcp_listen_pcbs list is in LISTEN state.
|
||||
4) All PCBs in the tcp_tw_pcbs list is in TIME-WAIT state.
|
||||
*/
|
||||
|
||||
/* Define two macros, TCP_REG and TCP_RMV that registers a TCP PCB
|
||||
with a PCB list or removes a PCB from a list, respectively. */
|
||||
#if 0
|
||||
#define TCP_REG(pcbs, npcb) do {\
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("TCP_REG %p local port %d\n", npcb, npcb->local_port)); \
|
||||
for(tcp_tmp_pcb = *pcbs; \
|
||||
tcp_tmp_pcb != NULL; \
|
||||
tcp_tmp_pcb = tcp_tmp_pcb->next) { \
|
||||
LWIP_ASSERT("TCP_REG: already registered\n", tcp_tmp_pcb != npcb); \
|
||||
} \
|
||||
LWIP_ASSERT("TCP_REG: pcb->state != CLOSED", npcb->state != CLOSED); \
|
||||
npcb->next = *pcbs; \
|
||||
LWIP_ASSERT("TCP_REG: npcb->next != npcb", npcb->next != npcb); \
|
||||
*(pcbs) = npcb; \
|
||||
LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \
|
||||
tcp_timer_needed(); \
|
||||
} while(0)
|
||||
#define TCP_RMV(pcbs, npcb) do { \
|
||||
LWIP_ASSERT("TCP_RMV: pcbs != NULL", *pcbs != NULL); \
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removing %p from %p\n", npcb, *pcbs)); \
|
||||
if(*pcbs == npcb) { \
|
||||
*pcbs = (*pcbs)->next; \
|
||||
} else for(tcp_tmp_pcb = *pcbs; tcp_tmp_pcb != NULL; tcp_tmp_pcb = tcp_tmp_pcb->next) { \
|
||||
if(tcp_tmp_pcb->next != NULL && tcp_tmp_pcb->next == npcb) { \
|
||||
tcp_tmp_pcb->next = npcb->next; \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
npcb->next = NULL; \
|
||||
LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removed %p from %p\n", npcb, *pcbs)); \
|
||||
} while(0)
|
||||
|
||||
#else /* LWIP_DEBUG */
|
||||
#define TCP_REG(pcbs, npcb) do { \
|
||||
npcb->next = *pcbs; \
|
||||
*(pcbs) = npcb; \
|
||||
tcp_timer_needed(); \
|
||||
} while(0)
|
||||
#define TCP_RMV(pcbs, npcb) do { \
|
||||
if(*(pcbs) == npcb) { \
|
||||
(*(pcbs)) = (*pcbs)->next; \
|
||||
} else for(tcp_tmp_pcb = *pcbs; tcp_tmp_pcb != NULL; tcp_tmp_pcb = tcp_tmp_pcb->next) { \
|
||||
if(tcp_tmp_pcb->next != NULL && tcp_tmp_pcb->next == npcb) { \
|
||||
tcp_tmp_pcb->next = npcb->next; \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
npcb->next = NULL; \
|
||||
} while(0)
|
||||
#endif /* LWIP_DEBUG */
|
||||
#endif /* __LWIP_TCP_H__ */
|
||||
|
||||
|
||||
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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 lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __LWIP_TCPIP_H__
|
||||
#define __LWIP_TCPIP_H__
|
||||
|
||||
#include "lwip/api_msg.h"
|
||||
#include "lwip/pbuf.h"
|
||||
|
||||
enum netmsq_type {
|
||||
NETMSG_API,
|
||||
NETMSG_INPUT,
|
||||
NETMSG_CALLBACK
|
||||
};
|
||||
|
||||
struct net_msg {
|
||||
enum netmsq_type type;
|
||||
union {
|
||||
struct api_msg *apimsg;
|
||||
struct {
|
||||
struct pbuf *p;
|
||||
struct netif *net;
|
||||
} inp;
|
||||
struct {
|
||||
void (*f)(void *);
|
||||
void *ctx;
|
||||
} cb;
|
||||
} msg;
|
||||
};
|
||||
|
||||
#endif /* __LWIP_TCPIP_H__ */
|
@ -1,104 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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 lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __LWIP_UDP_H__
|
||||
#define __LWIP_UDP_H__
|
||||
|
||||
#include "lwip/arch.h"
|
||||
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/inet.h"
|
||||
#include "lwip/ip.h"
|
||||
|
||||
#define UDP_HLEN 8
|
||||
|
||||
struct udp_hdr {
|
||||
PACK_STRUCT_FIELD(u16_t src);
|
||||
PACK_STRUCT_FIELD(u16_t dest); /* src/dest UDP ports */
|
||||
PACK_STRUCT_FIELD(u16_t len);
|
||||
PACK_STRUCT_FIELD(u16_t chksum);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
|
||||
#define UDP_FLAGS_NOCHKSUM 0x01U
|
||||
#define UDP_FLAGS_UDPLITE 0x02U
|
||||
#define UDP_FLAGS_CONNECTED 0x04U
|
||||
|
||||
struct udp_pcb {
|
||||
/* Common members of all PCB types */
|
||||
IP_PCB;
|
||||
|
||||
/* Protocol specific PCB members */
|
||||
|
||||
struct udp_pcb *next;
|
||||
|
||||
u8_t flags;
|
||||
u16_t local_port, remote_port;
|
||||
|
||||
u16_t chksum_len;
|
||||
|
||||
void (* recv)(void *arg, struct udp_pcb *pcb, struct pbuf *p,
|
||||
struct ip_addr *addr, u16_t port);
|
||||
void *recv_arg;
|
||||
};
|
||||
|
||||
/* The following functions is the application layer interface to the
|
||||
UDP code. */
|
||||
struct udp_pcb * udp_new (void);
|
||||
void udp_remove (struct udp_pcb *pcb);
|
||||
err_t udp_bind (struct udp_pcb *pcb, struct ip_addr *ipaddr,
|
||||
u16_t port);
|
||||
err_t udp_connect (struct udp_pcb *pcb, struct ip_addr *ipaddr,
|
||||
u16_t port);
|
||||
void udp_disconnect (struct udp_pcb *pcb);
|
||||
void udp_recv (struct udp_pcb *pcb,
|
||||
void (* recv)(void *arg, struct udp_pcb *upcb,
|
||||
struct pbuf *p,
|
||||
struct ip_addr *addr,
|
||||
u16_t port),
|
||||
void *recv_arg);
|
||||
err_t udp_sendto (struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *dst_ip, u16_t dst_port);
|
||||
err_t udp_send (struct udp_pcb *pcb, struct pbuf *p);
|
||||
|
||||
#define udp_flags(pcb) ((pcb)->flags)
|
||||
#define udp_setflags(pcb, f) ((pcb)->flags = (f))
|
||||
|
||||
/* The following functions are the lower layer interface to UDP. */
|
||||
void udp_input (struct pbuf *p, struct netif *inp);
|
||||
void udp_init (void);
|
||||
|
||||
#if UDP_DEBUG
|
||||
void udp_debug_print(struct udp_hdr *udphdr);
|
||||
#else
|
||||
#define udp_debug_print(udphdr)
|
||||
#endif
|
||||
#endif /* __LWIP_UDP_H__ */
|
||||
|
||||
|
@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science.
|
||||
* 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. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE 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 INSTITUTE 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __ARCH_CC_H__
|
||||
#define __ARCH_CC_H__
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <gctypes.h>
|
||||
#include "asm.h"
|
||||
#include "processor.h"
|
||||
|
||||
typedef u8 u8_t;
|
||||
typedef s8 s8_t;
|
||||
typedef u16 u16_t;
|
||||
typedef s16 s16_t;
|
||||
typedef u32 u32_t;
|
||||
typedef s32 s32_t;
|
||||
typedef u32 mem_ptr_t;
|
||||
|
||||
|
||||
#define PACK_STRUCT_FIELD(x) x
|
||||
#define PACK_STRUCT_STRUCT __attribute__((packed))
|
||||
#define PACK_STRUCT_BEGIN
|
||||
#define PACK_STRUCT_END
|
||||
|
||||
#define LWIP_PLATFORM_ASSERT(x) { printf(x); while (1); }
|
||||
#define LWIP_PLATFORM_DIAG(x) printf x
|
||||
|
||||
#define SYS_ARCH_DECL_PROTECT(lev) u32 lev
|
||||
#define SYS_ARCH_PROTECT(lev) _CPU_ISR_Disable(lev)
|
||||
#define SYS_ARCH_UNPROTECT(lev) _CPU_ISR_Restore(lev)
|
||||
|
||||
/* Define (sn)printf formatters for these lwIP types */
|
||||
#define U16_F "hu"
|
||||
#define S16_F "hd"
|
||||
#define X16_F "hx"
|
||||
#define U32_F "u"
|
||||
#define S32_F "d"
|
||||
#define X32_F "x"
|
||||
|
||||
|
||||
#endif /* __ARCH_CC_H__ */
|
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science.
|
||||
* 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. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE 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 INSTITUTE 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __CPU_H__
|
||||
#define __CPU_H__
|
||||
|
||||
#define BYTE_ORDER BIG_ENDIAN
|
||||
|
||||
#endif /* __CPU_H__ */
|
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science.
|
||||
* 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. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE 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 INSTITUTE 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __ARCH_INIT_H__
|
||||
#define __ARCH_INIT_H__
|
||||
|
||||
#define TCPIP_INIT_DONE(arg) tcpip_init_done(arg)
|
||||
|
||||
void tcpip_init_done(void *);
|
||||
int wait_for_tcpip_init(void);
|
||||
|
||||
#endif /* __ARCH_INIT_H__ */
|
||||
|
||||
|
||||
|
||||
|
@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science.
|
||||
* 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. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE 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 INSTITUTE 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __LIB_H__
|
||||
#define __LIB_H__
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define bcopy(s, d, l) memcpy(d, s, l)
|
||||
#define bzero(d, l) memset(d, 0, l)
|
||||
|
||||
#endif /* __LIB_H__ */
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science.
|
||||
* 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. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE 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 INSTITUTE 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __PERF_H__
|
||||
#define __PERF_H__
|
||||
|
||||
#define PERF_START /* null definition */
|
||||
#define PERF_STOP(x) /* null definition */
|
||||
|
||||
#endif /* __PERF_H__ */
|
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science.
|
||||
* 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. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE 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 INSTITUTE 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.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __SYS_GC_H__
|
||||
#define __SYS_GC_H__
|
||||
|
||||
#include <lwp.h>
|
||||
#include <message.h>
|
||||
#include <mutex.h>
|
||||
#include <cond.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
#define SYS_MBOX_NULL MQ_BOX_NULL
|
||||
#define SYS_SEM_NULL LWP_SEM_NULL
|
||||
|
||||
typedef sem_t sys_sem;
|
||||
typedef sem_t *sys_sem_t;
|
||||
|
||||
typedef mqbox_t sys_mbox;
|
||||
typedef mqbox_t *sys_mbox_t;
|
||||
|
||||
typedef lwp_t sys_thread;
|
||||
typedef lwp_t* sys_thread_t;
|
||||
|
||||
#endif /* __SYS_C64_H__ */
|
@ -1,126 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
|
||||
* Copyright (c) 2003-2004 Leon Woestenberg <leon.woestenberg@axon.tv>
|
||||
* Copyright (c) 2003-2004 Axon Digital Design B.V., The Netherlands.
|
||||
* 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 lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __NETIF_ETHARP_H__
|
||||
#define __NETIF_ETHARP_H__
|
||||
|
||||
#ifndef ETH_PAD_SIZE
|
||||
#define ETH_PAD_SIZE 0
|
||||
#endif
|
||||
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/ip.h"
|
||||
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct eth_addr {
|
||||
PACK_STRUCT_FIELD(u8_t addr[6]);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct eth_hdr {
|
||||
#if ETH_PAD_SIZE
|
||||
PACK_STRUCT_FIELD(u8_t padding[ETH_PAD_SIZE]);
|
||||
#endif
|
||||
PACK_STRUCT_FIELD(struct eth_addr dest);
|
||||
PACK_STRUCT_FIELD(struct eth_addr src);
|
||||
PACK_STRUCT_FIELD(u16_t type);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
/** the ARP message */
|
||||
struct etharp_hdr {
|
||||
PACK_STRUCT_FIELD(struct eth_hdr ethhdr);
|
||||
PACK_STRUCT_FIELD(u16_t hwtype);
|
||||
PACK_STRUCT_FIELD(u16_t proto);
|
||||
PACK_STRUCT_FIELD(u16_t _hwlen_protolen);
|
||||
PACK_STRUCT_FIELD(u16_t opcode);
|
||||
PACK_STRUCT_FIELD(struct eth_addr shwaddr);
|
||||
PACK_STRUCT_FIELD(struct ip_addr2 sipaddr);
|
||||
PACK_STRUCT_FIELD(struct eth_addr dhwaddr);
|
||||
PACK_STRUCT_FIELD(struct ip_addr2 dipaddr);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
struct ethip_hdr {
|
||||
PACK_STRUCT_FIELD(struct eth_hdr eth);
|
||||
PACK_STRUCT_FIELD(struct ip_hdr ip);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
/** 5 seconds period */
|
||||
#define ARP_TMR_INTERVAL 5000
|
||||
|
||||
#define ETHTYPE_ARP 0x0806
|
||||
#define ETHTYPE_IP 0x0800
|
||||
|
||||
void etharp_init(void);
|
||||
void etharp_tmr(void);
|
||||
void etharp_ip_input(struct netif *netif, struct pbuf *p);
|
||||
void etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr,
|
||||
struct pbuf *p);
|
||||
err_t etharp_output(struct netif *netif, struct ip_addr *ipaddr,
|
||||
struct pbuf *q);
|
||||
err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q);
|
||||
err_t etharp_request(struct netif *netif, struct ip_addr *ipaddr);
|
||||
|
||||
#endif /* __NETIF_ARP_H__ */
|
@ -1,45 +0,0 @@
|
||||
#ifndef __GCIF_H__
|
||||
#define __GCIF_H__
|
||||
|
||||
#include <lwip/netif.h>
|
||||
|
||||
#define ERR_NODATA -12
|
||||
#define ERR_ALLREAD -13
|
||||
#define ERR_TXERROR -14
|
||||
#define ERR_RXERROR -14
|
||||
#define ERR_NODEV -16
|
||||
#define ERR_PKTSIZE -17
|
||||
#define ERR_TXPENDING -18
|
||||
|
||||
#define cpu_to_be16(x) (x)
|
||||
#define cpu_to_be32(x) (x)
|
||||
extern inline u16 cpu_to_le16(u16 x) { return (x<<8) | (x>>8);}
|
||||
extern 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)))
|
||||
|
||||
extern inline void cpu_to_le16s(u16 *a) {*a = cpu_to_le16(*a);}
|
||||
extern inline void cpu_to_le32s(u32 *a) {*a = cpu_to_le32(*a);}
|
||||
extern inline void cpu_to_be16s(u16 *a) {*a = cpu_to_be16(*a);}
|
||||
extern 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)
|
||||
|
||||
typedef void* dev_s;
|
||||
|
||||
dev_s bba_create(struct netif *);
|
||||
err_t bba_init(struct netif *);
|
||||
void bba_process(struct pbuf *p,struct netif *dev);
|
||||
|
||||
#endif
|
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* 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 lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __NETIF_LOOPIF_H__
|
||||
#define __NETIF_LOOPIF_H__
|
||||
|
||||
#include "lwip/netif.h"
|
||||
|
||||
err_t loopif_init(struct netif *netif);
|
||||
|
||||
#endif /* __NETIF_LOOPIF_H__ */
|
@ -1,287 +0,0 @@
|
||||
#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);
|
||||
s32 if_configex(struct in_addr *local_ip,struct in_addr *netmask,struct in_addr *gateway,bool use_dhcp);
|
||||
|
||||
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
|
@ -1,272 +0,0 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
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__
|
@ -1,113 +0,0 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
|
||||
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
|
@ -1,115 +0,0 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
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
|
@ -1,319 +0,0 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
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
|
@ -1,326 +0,0 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
|
||||
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
|
@ -1,605 +0,0 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
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.
|
||||
\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.
|
||||
\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
|
@ -1,239 +0,0 @@
|
||||
#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
|
@ -1,28 +0,0 @@
|
||||
#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 */
|
@ -1,115 +0,0 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
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
|
@ -1,183 +0,0 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
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
|
@ -1,81 +0,0 @@
|
||||
#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
|
@ -1,51 +0,0 @@
|
||||
#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
|
@ -1,68 +0,0 @@
|
||||
/*
|
||||
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
|
@ -1,228 +0,0 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
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
|
@ -1,369 +0,0 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
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
|
@ -1,309 +0,0 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
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
|
@ -1,325 +0,0 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
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
|
@ -1,499 +0,0 @@
|
||||
#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
|
File diff suppressed because it is too large
Load Diff
@ -1,78 +0,0 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
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
|
@ -1,65 +0,0 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
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
|
@ -1,103 +0,0 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
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
|
@ -1,189 +0,0 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
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
|
@ -1,70 +0,0 @@
|
||||
#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
|
@ -1,204 +0,0 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
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
|
@ -1,19 +0,0 @@
|
||||
#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
|
@ -1,59 +0,0 @@
|
||||
#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
|
@ -1,79 +0,0 @@
|
||||
#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
|
@ -1,76 +0,0 @@
|
||||
#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
|
@ -1,49 +0,0 @@
|
||||
#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
|
@ -1,33 +0,0 @@
|
||||
#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
|
@ -1,41 +0,0 @@
|
||||
#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
|
@ -1,44 +0,0 @@
|
||||
#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
|
@ -1,27 +0,0 @@
|
||||
#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
|
@ -1,48 +0,0 @@
|
||||
#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
|
@ -1,39 +0,0 @@
|
||||
#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
|
@ -1,107 +0,0 @@
|
||||
#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
|
@ -1,38 +0,0 @@
|
||||
#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
|
@ -1,107 +0,0 @@
|
||||
#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
|
@ -1,23 +0,0 @@
|
||||
#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
|
@ -1,338 +0,0 @@
|
||||
#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__
|
@ -1,251 +0,0 @@
|
||||
#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
|
@ -1,191 +0,0 @@
|
||||
#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
|
@ -1,123 +0,0 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
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
|
@ -1,103 +0,0 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
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
|
@ -1,97 +0,0 @@
|
||||
#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
|
@ -1,96 +0,0 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
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
|
@ -1,95 +0,0 @@
|
||||
#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
|
@ -1,66 +0,0 @@
|
||||
/*-------------------------------------------------------------
|
||||
|
||||
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
|
@ -1,27 +0,0 @@
|
||||
#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
|
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