示例#1
0
void show_mem()
{
    FILE *file = fopen("debug.txt", "a");
	fprintf(file, "m1(%.4f) m2(%.4f)\r\n",
            ((float)((char*)SYS_GetArena1Hi()-(char*)SYS_GetArena1Lo()))/0x100000,
            ((float)((char*)SYS_GetArena2Hi()-(char*)SYS_GetArena2Lo()))/0x100000);
    fclose(file);
}
示例#2
0
void CMEM2Alloc::init(unsigned int size)
{
	m_baseAddress = (SBlock *) std::max(((u32)SYS_GetArena2Lo() + 31) & ~31, IOS_RELOAD_AREA);
	m_endAddress = (SBlock *) ((char *)m_baseAddress + std::min(size * 0x100000, SYS_GetArena2Size() & ~31));
	if (m_endAddress > (SBlock *) 0x93300000) //rest is reserved for usb/usb2/network and other stuff... (0xE0000 bytes)
		m_endAddress = (SBlock *) 0x93300000;
	SYS_SetArena2Lo(m_endAddress);
	LWP_MutexInit(&m_mutex, 0);
}
示例#3
0
void CMEM2Alloc::cleanup(void)
{
	LWP_MutexDestroy(m_mutex);
	m_mutex = 0;
	m_first = 0;
	// Try to release the range we took through SYS functions
	if (SYS_GetArena2Lo() == m_endAddress)
		SYS_SetArena2Lo(m_baseAddress);
	m_baseAddress = 0;
	m_endAddress = 0;
}
示例#4
0
void wii_memstats(void) {
	static u32 min_free = UINT_MAX;
	static u32 temp_free;
	static u32 level;

	_CPU_ISR_Disable(level);
#ifdef GAMECUBE
	temp_free = (u32) SYS_GetArenaHi() - (u32) SYS_GetArenaLo();
#else
	temp_free = (u32) SYS_GetArena1Hi() - (u32) SYS_GetArena1Lo() +
				(u32) SYS_GetArena2Hi() - (u32) SYS_GetArena2Lo();
#endif
	_CPU_ISR_Restore(level);

	if (temp_free < min_free) {
		min_free = temp_free;
		fprintf(stderr, "free: %8u\n", min_free);
	}
}
示例#5
0
s32 USBStorage_Initialize()
{
	u32 level;

	if(__inited)
		return IPC_OK;

	_CPU_ISR_Disable(level);
	LWP_InitQueue(&__usbstorage_waitq);
	if(!arena_ptr) {
		arena_ptr = (u8*)ROUNDDOWN32(((u32)SYS_GetArena2Hi() - HEAP_SIZE));
		if((u32)arena_ptr < (u32)SYS_GetArena2Lo()) {
			_CPU_ISR_Restore(level);
			return IPC_ENOMEM;
		}
		SYS_SetArena2Hi(arena_ptr);
	}
	__lwp_heap_init(&__heap, arena_ptr, HEAP_SIZE, 32);
	__inited = true;
	_CPU_ISR_Restore(level);
	return IPC_OK;
}
示例#6
0
		static void* main_thread_function(void*)
		{
			u32 level, real_heap_size;

			// hope the parms are all set by now
			COM_InitArgv(parms_number, parms_array);

			_CPU_ISR_Disable(level);
			heap = (char *)align32(SYS_GetArena2Lo());
			real_heap_size = heap_size - ((u32)heap - (u32)SYS_GetArena2Lo());
			if ((u32)heap + real_heap_size > (u32)SYS_GetArena2Hi())
			{
				_CPU_ISR_Restore(level);
				Sys_Error("heap + real_heap_size > (u32)SYS_GetArena2Hi()");
			}	
			else
			{
				SYS_SetArena2Lo(heap + real_heap_size);
				_CPU_ISR_Restore(level);
			}

			VIDEO_SetBlack(TRUE);

			// Initialise the Host module.
			quakeparms_t parms;
			memset(&parms, 0, sizeof(parms));
			parms.argc		= com_argc;
			parms.argv		= com_argv;
			parms.basedir	= QUAKE_WII_BASEDIR;
			parms.memsize	= real_heap_size;
			parms.membase	= heap;
			if (parms.membase == 0)
			{
				Sys_Error("Heap allocation failed");
			}
			memset(parms.membase, 0, parms.memsize);
			Host_Init(&parms);

#if TIME_DEMO
			Cbuf_AddText("map start\n");
			Cbuf_AddText("wait\n");
			Cbuf_AddText("timedemo demo1\n");
#endif
#if TEST_CONNECTION
			Cbuf_AddText("connect 192.168.0.2");
#endif

			SYS_SetResetCallback(reset_system);
			SYS_SetPowerCallback(shutdown_system);

			VIDEO_SetBlack(FALSE);

			// Run the main loop.
			u64 last_time = gettime();
			for (;;)
			{
				if (want_to_reset)
					Sys_Reset();
				if (want_to_shutdown)
					Sys_Shutdown();

				// Get the frame time in ticks.
				const u64		current_time	= gettime();
				const u64		time_delta		= current_time - last_time;
				const double	seconds	= time_delta * (0.001f / TB_TIMER_CLOCK);
				last_time = current_time;

				// Run the frame.
				Host_Frame(seconds);
			};

			// Quit (this code is never reached).
			Sys_Quit();
			return 0;
		}