/*---------------------------------------------------------------------------* Project: RevolutionDWC Demos File: ./common/src/d_net_connect.c Copyright 2005-2008 Nintendo. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. *---------------------------------------------------------------------------*/ #include "include/d_net_connect.h" #include "include/common.h" #include #include #include #include #include extern void* AllocFunc( DWCAllocType name, u32 size, int align ); extern void FreeFunc( DWCAllocType name, void* ptr, u32 size ); static struct { u32 total; u32 max; } s_memusage = {0,0}; /*-------------------------------------------------------------------------* Name: _Alloc Description: Memory allocation *-------------------------------------------------------------------------*/ static void* _Alloc(u32 i_name, s32 i_size) { s_memusage.total += i_size; if ( s_memusage.max < s_memusage.total ) s_memusage.max = s_memusage.total; return AllocFunc( (DWCAllocType)i_name, (u32)i_size, 32 ); } /*-------------------------------------------------------------------------* Name: _Free Description: Memory deallocation *-------------------------------------------------------------------------*/ static void _Free(u32 i_name, void* o_memory_p, s32 i_size) { s_memusage.total -= i_size; FreeFunc( (DWCAllocType)i_name, o_memory_p, (u32)i_size ); } /*-------------------------------------------------------------------------* Name: dNetConnect_Start Description: Communication settings *-------------------------------------------------------------------------*/ BOOL dNetConnect_Start() { s32 rc; /* Start the SO library */ OSReport( "SOInit() " ); { SOLibraryConfig soLibConfig; (void)memset(&soLibConfig, 0, sizeof(soLibConfig)); soLibConfig.alloc = _Alloc; soLibConfig.free = _Free; rc = SOInit(&soLibConfig); if ( rc != SO_SUCCESS ) { OSReport( "failed (%d)\n", rc ); return FALSE; } } OSReport( "success\n" ); /* Start the SO library */ OSReport( "SOStartup() " ); rc = SOStartup(); if ( rc != SO_SUCCESS ) { OSReport( "failed (%d)\n", rc ); return FALSE; } OSReport( "success\n" ); return TRUE; } /*-------------------------------------------------------------------------* Name: dNetConnect_Finish Description: End communication *-------------------------------------------------------------------------*/ void dNetConnect_Finish() { (void)SOCleanup(); (void)SOFinish(); OSReport( "-------------------------------\n" ); OSReport( "SO memory usage MAX:%d\n", s_memusage.max ); OSReport( "-------------------------------\n" ); }