Exemple #1
0
int _main( int argc, char *argv[] )
{
    int fres=0;
    s32 ret=0;
    struct IPCMessage *CMessage=NULL;

    thread_set_priority( 0, 0x58 );

#ifdef DEBUG
    dbgprintf("$IOSVersion: FFS-SD: %s %s 64M DEBUG$\n", __DATE__, __TIME__ );
#else
    dbgprintf("$IOSVersion: FFS-SD: %s %s 64M Release$\n", __DATE__, __TIME__ );
#endif

    //dbgprintf("FFS:Heap Init...");
    HeapID = heap_create(Heap, sizeof Heap);
    QueueSpace = heap_alloc(HeapID, 0x20);
    //dbgprintf("ok\n");

    QueueID = RegisterDevices();
    if( QueueID < 0 )
    {
        ThreadCancel( 0, 0x77 );
    }

    sdhc_init();

    //dbgprintf("FFS:Mounting SD...\n");
    fres = f_mount(0, &fatfs);
    //dbgprintf("FFS:f_mount():%d\n", fres);

    if(fres != FR_OK)
    {
        //dbgprintf("FFS:Error %d while trying to mount SD\n", fres);
        ThreadCancel( 0, 0x77 );
    }

    //dbgprintf("FFS:Clean up...");

    //clean up folders
    FS_Delete("/tmp");
    FS_Delete("/import");

    f_mkdir("/tmp");
    f_mkdir("/import");

    thread_set_priority( 0, 0x0B );

    //dbgprintf("ok\n");

    while (1)
    {
        ret = mqueue_recv(QueueID, (void *)&CMessage, 0);
        if( ret != 0 )
        {
            //dbgprintf("FFS:mqueue_recv(%d) FAILED:%d\n", QueueID, ret);
            continue;
        }

        //dbgprintf("FFS:Cmd:%d\n", CMessage->command );

        switch( CMessage->command )
        {
        case IOS_OPEN:
        {
            ret = FS_Open( CMessage->open.device, CMessage->open.mode );
#ifdef DEBUG
            if( ret != FS_NO_DEVICE )
                dbgprintf("FFS:IOS_Open(\"%s\", %d):%d\n", CMessage->open.device, CMessage->open.mode, ret );
#endif
            mqueue_ack( (void *)CMessage, ret);

        }
        break;

        case IOS_CLOSE:
        {
#ifdef DEBUG
            dbgprintf("FFS:IOS_Close(%d):", CMessage->fd);
#endif
            ret = FS_Close( CMessage->fd );
#ifdef DEBUG
            dbgprintf("%d\n", ret );
#endif
            mqueue_ack( (void *)CMessage, ret);
        }
        break;

        case IOS_READ:
        {

#ifdef DEBUG
            dbgprintf("FFS:IOS_Read(%d, 0x%p, %u):", CMessage->fd, CMessage->read.data, CMessage->read.length );
#endif
            ret = FS_Read( CMessage->fd, CMessage->read.data, CMessage->read.length );

#ifdef DEBUG
            dbgprintf("%d\n", ret );
#endif
            mqueue_ack( (void *)CMessage, ret );

        }
        break;
        case IOS_WRITE:
        {
#ifdef DEBUG
            dbgprintf("FFS:IOS_Write(%d, 0x%p, %u)", CMessage->fd, CMessage->write.data, CMessage->write.length );
#endif
            ret = FS_Write( CMessage->fd, CMessage->write.data, CMessage->write.length );

#ifdef DEBUG
            dbgprintf(":%d\n", ret );
#endif
            mqueue_ack( (void *)CMessage, ret );
        }
        break;
        case IOS_SEEK:
        {
#ifdef DEBUG
            dbgprintf("FFS:IOS_Seek(%d, %x, %d):", CMessage->fd, CMessage->seek.offset, CMessage->seek.origin );
#endif
            ret = FS_Seek( CMessage->fd, CMessage->seek.offset, CMessage->seek.origin );

#ifdef DEBUG
            dbgprintf("%d\n", ret );
#endif
            mqueue_ack( (void *)CMessage, ret );

        }
        break;

        case IOS_IOCTL:
            FFS_Ioctl(CMessage);
            break;

        case IOS_IOCTLV:
            FFS_Ioctlv(CMessage);
            break;
#ifdef EDEBUG
        default:
            dbgprintf("FFS:unimplemented/invalid msg: %08x\n", CMessage->command);
            mqueue_ack( (void *)CMessage, -1017);
#endif
        }
    }

    return 0;
}
Exemple #2
0
static int sslsd_probe(struct platform_device *dev)
{
	struct mmc_host	*mmc;
	sslsd_host		*host;
	int				ret;
	int				irq;
	struct resource	*r;
	sd_clk = sd_clk * 1000000;

#if IO_MAP == 1
	r = platform_get_resource(dev, IORESOURCE_MEM, 0);
	irq = platform_get_resource(dev, IORESOURCE_IRQ, 0)->start;
#else
	r = _rc;
	irq = _rc[1].start;
#endif
	if (!r || irq == NO_IRQ)
	{
		printk("sslsd: probe err - resource\n");
		return -ENXIO;
	}

	mmc = mmc_alloc_host(sizeof(sslsd_host), &dev->dev);
	if (!mmc) 
	{
		printk("sslsd: probe err - alloc host\n");
		return -ENOMEM;
	}

	host = mmc_priv(mmc);
#if IO_MAP == 1
//	r = request_mem_region(r->start, 0x100, DRV_NAME);
	host->hw.r = (uint32_t)ioremap_nocache(r->start, r->end - r->start + 1);
	if (!host->hw.r)
	{
		printk("sslsd: probe err - ioremap\n");
		ret = -EBUSY;
		goto l_region;
	}
#else
	host->hw.r = r->start;
#endif
	host->hw.r += 0x100;

	if (!clk)
	{
		printk("sslsd: probe info - clk not passed it assuming 25MHz\n");
		clk = 25000000;
	}
	if (!tout)
	{
		tout = clk;
	}

	host->hw.evt = sslsd_evt;
	host->hw.baseclk = clk / 100000;
	host->hw.toutclk = tout / 1000;
	host->hw.ctx = host;
	ret = sdhc_init(&host->hw);
	if (ret)
	{
		printk("sslsd: probe err - sdhc_init\n");
		ret = -ENODEV;
		goto l_host;
	}

#if SD_DMA
	if (!host->hw.fdma)
	{
		printk("sslsd: probe warn - no dma support\n");
	}
	else
	{
#if IO_MAP == 3
		ebm_mem = ebm_malloc(0x1000);
#endif
	}
#endif

	mmc->ops = &sslsd_ops;
	mmc->f_min = 100000;
//	mmc->f_max = host->hw.fhspeed ? 50000000 : 25000000;
	mmc->f_max = host->hw.fhspeed ? 50000000 : sd_clk;
	mmc->ocr_avail = host->hw.ocr;
	mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_MULTIWRITE | MMC_CAP_SDIO_IRQ;
	if (host->hw.fhspeed)
	{
		mmc->caps |= MMC_CAP_SD_HIGHSPEED;
	}
#ifdef SD_1BIT
	mmc->caps &= ~MMC_CAP_4_BIT_DATA;
#endif
	mmc->max_hw_segs = 64;
	mmc->max_phys_segs = 64;
	mmc->max_seg_size = mmc->max_req_size = 512 * 1024;
	mmc->max_blk_size = 1 << (9 + host->hw.maxblksz);
	mmc->max_blk_count = 65535;

//mmc->max_hw_segs = mmc->max_phys_segs = 1;
//printk("sslsd: segs=%d blks=%d blksz=%d caps=%X\n", 
//mmc->max_hw_segs, mmc->max_blk_count, mmc->max_blk_size, mmc->caps);

	host->mmc = mmc;
	host->res = r;
	host->irq = irq;

	sdhc_irq = irq;

//printk("sslsd: probe info - req_irq %d\n", irq);
	ret = request_irq(irq, sslsd_irq, IRQF_DISABLED, DRV_NAME, host);
	if (ret)
	{
		printk("sslsd: probe err - req_irq %d err %d\n", irq, ret);
		goto l_init;
	}

	/* tout timer */
	init_timer(&host->timer);
	host->timer.data = (unsigned long)host;
	host->timer.function = sslsd_tout;

	platform_set_drvdata(dev, mmc);

	mmc_add_host(mmc);

	/* build sysfs */ 
{
	int error = sysfs_create_group(&dev->dev.kobj, &sslsd_attr_group);
	if (error)
	{
		printk("register sysfs for power is failure %d\n", error);
	}
}

	return 0;

l_init:
	sdhc_exit(&host->hw);
l_region:
#if IO_MAP == 1
//	release_resource(r);
	iounmap((void *)(host->hw.r - 0x100));
#endif
l_host:
	mmc_free_host(mmc);
	return ret;
}
Exemple #3
0
u32 _main(void *base)
{
	FRESULT fres;
	int res;
	u32 vector;
	(void)base;

	gecko_init();
	gecko_printf("mini %s loading\n", git_version);

	gecko_printf("Initializing exceptions...\n");
	exception_initialize();
	gecko_printf("Configuring caches and MMU...\n");
	mem_initialize();

	gecko_printf("IOSflags: %08x %08x %08x\n",
		read32(0xffffff00), read32(0xffffff04), read32(0xffffff08));
	gecko_printf("          %08x %08x %08x\n",
		read32(0xffffff0c), read32(0xffffff10), read32(0xffffff14));

	irq_initialize();
	irq_enable(IRQ_TIMER);
//	irq_enable(IRQ_GPIO1B);
	irq_enable(IRQ_GPIO1);
	irq_enable(IRQ_RESET);
	gecko_timer_initialize();
	gecko_printf("Interrupts initialized\n");

	crypto_initialize();
	gecko_printf("crypto support initialized\n");

	nand_initialize();
	gecko_printf("NAND initialized.\n");

	boot2_init();

	gecko_printf("Initializing IPC...\n");
	ipc_initialize();

	gecko_printf("Initializing SDHC...\n");
	sdhc_init();

	gecko_printf("Mounting SD...\n");
	fres = f_mount(0, &fatfs);

	//if (read32(0x0d800190) & 2)
	//{
	//	gecko_printf("GameCube compatibility mode detected...\n");
		vector = boot2_run(1, 2);
	//	goto shutdown;
	//}

	//if(fres != FR_OK)
	//{
	//	gecko_printf("Error %d while trying to mount SD\n", fres);
	//	panic2(0, PANIC_MOUNT);
	//}

	//gecko_printf("Trying to boot:" PPC_BOOT_FILE "\n");

	//res = powerpc_boot_file(PPC_BOOT_FILE);
	//if(res < 0) {
	//	gecko_printf("Failed to boot PPC: %d\n", res);
	//	gecko_printf("Continuing anyway\n");
	//}

	//gecko_printf("Going into IPC mainloop...\n");
	//vector = ipc_process_slow();
	//gecko_printf("IPC mainloop done!\n");
	gecko_printf("Shutting down IPC...\n");
	ipc_shutdown();

shutdown:
	gecko_printf("Shutting down interrupts...\n");
	irq_shutdown();
	gecko_printf("Shutting down caches and MMU...\n");
	mem_shutdown();

	gecko_printf("Vectoring to 0x%08x...\n", vector);
	return vector;
}