示例#1
0
文件: mcard.c 项目: suloku/gcmm
/****************************************************************************
 * MountCard
 *
 * Mounts the memory card in the given slot.
 * CARD_Mount is called for a maximum of 10 tries
 * Returns the result of the last attempted CARD_Mount command.
 ***************************************************************************/
int MountCard(int cslot)
{
	s32 ret = -1;
	int tries = 0;
	int isMounted;

	// Mount the card, try several times as they are tricky
	while ( (tries < 10) && (ret < 0))
	{
		/*** We already initialized the Memory Card subsystem with CARD_Init() in select_memcard_slot(). Let's reset the
		EXI subsystem, just to make sure we have no problems mounting the card ***/
		EXI_ProbeReset();
		CARD_Init (NULL, NULL);
		//Ensure we start in show all files mode
		CARD_SetCompany(NULL);
		CARD_SetGamecode(NULL);		

		/*** Mount the card ***/
		ret = CARD_Mount (cslot, SysArea, card_removed);
		if (ret >= 0) break;

		VIDEO_WaitVSync ();
		tries++;
	}
			/*** Make sure the card is really mounted ***/
	isMounted = CARD_ProbeEx(cslot, &memsize, &sectsize);
	if (memsize > 0 && sectsize > 0)//then we really mounted de card
	{
		return isMounted;
	}
	/*** If this point is reached, something went wrong ***/
	CARD_Unmount(cslot);
	return ret;
}
示例#2
0
文件: main.c 项目: suloku/dolaunch
static int initFAT(){

	int slotagecko = 0;
	int i =0;
	s32 ret, memsize, sectsize;


	for(i=0;i<10;i++){
		ret = CARD_ProbeEx(CARD_SLOTA, &memsize, &sectsize);
		//printf("Ret: %d", ret);
		if (ret == CARD_ERROR_WRONGDEVICE){
			slotagecko = 1;
			break;
		}
	}

	if (slotagecko)
	{//Memcard in SLOT B, SD gecko in SLOT A
		//This will ensure SD gecko is recognized if inserted or changed to another slot after GCMM is executed
		for(i=0;i<10;i++){
			ret = CARD_Probe(CARD_SLOTA);
			if (ret == CARD_ERROR_WRONGDEVICE)
				//printf ("SDGecko detected...\n\n");
				break;
		}
		__io_gcsda.startup();
		if (!__io_gcsda.isInserted())
		{
			//printf ("No SD Gecko inserted! Using embedded config.\n\n");
			return 0;
		}
		if (!fatMountSimple ("fat", &__io_gcsda))
		{
			//printf("Error Mounting SD fat! Using embedded config.\n\n");
			return 0;
		}
	}else //Memcard in SLOT A, SD gecko in SLOT B
	{
		//This will ensure SD gecko is recognized if inserted or changed to another slot after GCMM is executed
		for(i=0;i<10;i++){
			ret = CARD_Probe(CARD_SLOTB);
			if (ret == CARD_ERROR_WRONGDEVICE)
				break;
		}	
		__io_gcsdb.startup();
		if (!__io_gcsdb.isInserted())
		{
			//printf ("No SD Gecko inserted! Using default config.\n\n");
			return 0;
		}
		if (!fatMountSimple ("fat", &__io_gcsdb))
		{
			//printf("Error Mounting SD fat! Using default config.\n\n");
			return 0;
		}
	}

	return 1;
}
示例#3
0
int main()
{
	Initialise();

	while(1)
	{
		s32 Size;
		s32 SSize;
		u32 ID;
		s32 getIDerr;
		s32 CARDerr;
		s32 EXIerr;
		VIDEO_ClearFrameBuffer(rmode, xfb, 0);

		// Can't use printf since Dolphin overrides it
		std::cout<<"\x1b[0;0H"; // Position the cursor (at 0, 0)
		for (int channel = 0; channel < EXI_CHANNEL_MAX; ++channel)
			for (int device = 0; device < EXI_DEVICE_MAX; ++device)
			{
				if (getIDerr = EXI_GetID(channel, device, &ID) == 1)
				{
					std::cout<<"Channel "<<channel<<" Device "<<device<<"\tID = 0x"<<std::setbase(16)<<ID<<std::endl;
					if ((channel == 0 && device == 0)||(channel == 1 && device == 0))
					{
						// It's a memcard slot
						if (CARDerr = CARD_ProbeEx(channel, &Size, &SSize) >= 0)
						{
							std::cout<<"\tMemcard has a size of "<<std::setbase(10)<<Size<<" and a Sector Size of "<<std::setbase(10)<<SSize<<std::endl;
						}
						else if (CARDerr == -2)
							std::cout<<"\tNot a Memcard!"<<std::endl;
						else
							std::cout<<"\tCARD Error "<<CARDerr<<std::endl;
					}
					else
					{
						// It's not a memcard, what to do? - Just probe for now
						if (EXIerr = EXI_ProbeEx(channel)){}
						else
							std::cout<<"\tEXI Error "<<EXIerr<<std::endl;
					}
				}
				else
					std::cout<<"Channel "<<channel<<" Device "<<device<<std::endl<<"\tEXI_GetID Error "<<getIDerr<<std::endl;
			}

		VIDEO_WaitVSync();
	}
	return 0;
}
示例#4
0
s32 deviceHandler_CARD_init(file_handle* file){
	int slot = (!strncmp((const char*)initial_CARDB.name, file->name, 7));
	file->status = initialize_card(slot);
	s32 memSize = 0, sectSize = 0;
	int ret = CARD_ProbeEx(slot,&memSize,&sectSize);
	if(ret==CARD_ERROR_READY) {
		initial_CARD_info.totalSpaceInKB = (memSize<<7);
	} else {
		print_gecko("CARD_ProbeEx failed %i\r\n", ret);
	}
	initial_CARD_info.freeSpaceInKB = 0;
	
	return file->status == CARD_ERROR_READY ? 1 : 0;
}
示例#5
0
bool deviceHandler_CARD_test_b() {
	s32 memSize = 0, sectSize = 0;
	return ((initialize_card(1)==CARD_ERROR_READY) && (CARD_ProbeEx(1, &memSize,&sectSize)==CARD_ERROR_READY));
}