Exemple #1
0
static void
dec_550_cons_init()
{
	struct ctb *ctb;
	struct cia_config *ccp;
	extern struct cia_config cia_configuration;

	ccp = &cia_configuration;
	cia_init(ccp, 0);

	ctb = (struct ctb *)(((caddr_t)hwrpb) + hwrpb->rpb_ctb_off);

	switch (ctb->ctb_term_type) {
	case 2: 
		/* serial console ... */
		/* XXX */
		{
			/*
			 * Delay to allow PROM putchars to complete.
			 * FIFO depth * character time,
			 * character time = (1000000 / (defaultrate / 10))
			 */
			DELAY(160000000 / comcnrate);

			if(comcnattach(ccp->cc_iot, 0x3f8, comcnrate,
			    COM_FREQ,
			    (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8))
				panic("can't init serial console");

			break;
		}

	case 3:
#if NPCKBD > 0
		/* display console ... */
		/* XXX */
		(void) pckbc_cnattach(ccp->cc_iot, IO_KBD, KBCMDP,
		    PCKBC_KBD_SLOT);

		if (CTB_TURBOSLOT_TYPE(ctb->ctb_turboslot) ==
		    CTB_TURBOSLOT_TYPE_ISA)
			isa_display_console(ccp->cc_iot, ccp->cc_memt);
		else
			pci_display_console(ccp->cc_iot, ccp->cc_memt,
			    &ccp->cc_pc, CTB_TURBOSLOT_BUS(ctb->ctb_turboslot),
			    CTB_TURBOSLOT_SLOT(ctb->ctb_turboslot), 0);
#else
		panic("not configured to use display && keyboard console");
#endif
		break;

	default:
		printf("ctb->ctb_term_type = 0x%lx\n", ctb->ctb_term_type);
		printf("ctb->ctb_turboslot = 0x%lx\n", ctb->ctb_turboslot);

		panic("consinit: unknown console type %ld\n",
		    ctb->ctb_term_type);
	}
}
Exemple #2
0
		/* XXX Don't know the system variations, yet. */
		platform.model = alpha_unknown_sysname();
	}

	platform.iobus = "cia";
	platform.cons_init = dec_eb164_cons_init;
	platform.pci_intr_init = eb164_intr_init;
	platform.pci_intr_map = NULL;
	platform.pci_intr_disable = eb164_intr_disable;
	platform.pci_intr_enable = eb164_intr_enable;
}

extern int comconsole; /* XXX for forcing comconsole when srm serial console is used */
static void
dec_eb164_cons_init()
{
	struct ctb *ctb;

	cia_init();

#ifdef DDB
	siogdbattach(0x2f8, 57600);
#endif

	ctb = (struct ctb *)(((caddr_t)hwrpb) + hwrpb->rpb_ctb_off);

	switch (ctb->ctb_term_type) {
	case 2: 
		/* serial console ... */
		/* XXX */
		{
			/*
			 * Delay to allow PROM putchars to complete.
			 * FIFO depth * character time,
			 * character time = (1000000 / (defaultrate / 10))
			 */
			DELAY(160000000 / comcnrate);

                        /* 
                         * force a comconsole on com1 if the SRM has a serial
			 * console
                         */
                        comconsole = 0;
			if (siocnattach(0x3f8, comcnrate))
				panic("can't init serial console");

			break;
		}

	case 3:
		/* display console ... */
		/* XXX */
#if NSC > 0
		sccnattach();
#else
		panic("not configured to use display && keyboard console");
#endif
		break;

	default:
		printf("ctb->ctb_term_type = 0x%lx\n", ctb->ctb_term_type);
		printf("ctb->ctb_turboslot = 0x%lx\n", ctb->ctb_turboslot);

		panic("consinit: unknown console type %d\n",
		    (int) ctb->ctb_term_type);
	}
}
Exemple #3
0
static void
st550_cons_init()
{
	struct ctb *ctb;

	cia_init();

#ifdef DDB
	siogdbattach(0x2f8, 57600);
#endif

	ctb = (struct ctb *)(((caddr_t)hwrpb) + hwrpb->rpb_ctb_off);

	switch (ctb->ctb_term_type) {
	case 2:
		/* serial console ... */
		/* XXX */
		/*
		 * Delay to allow PROM putchars to complete.
		 * FIFO depth * character time,
		 * character time = (1000000 / (defaultrate / 10))
		 */
		DELAY(160000000 / comcnrate);
		comconsole = 0;
		if (siocnattach(0x3f8, comcnrate))
			panic("can't init serial console");

		boothowto |= RB_SERIAL;
		break;

	case 3:
		/* display console ... */
		/* XXX */
#ifdef DEV_SC
		sccnattach();
#else
		panic("not configured to use display && keyboard console");
#endif
		break;

	default:
		printf("ctb->ctb_term_type = 0x%lx\n", ctb->ctb_term_type);
		printf("ctb->ctb_turboslot = 0x%lx\n", ctb->ctb_turboslot);

		panic("consinit: unknown console type %ld\n",
		    ctb->ctb_term_type);
	}
}
Exemple #4
0
static void
dec_eb164_cons_init()
{
	struct ctb *ctb;
	struct cia_config *ccp;
	extern struct cia_config cia_configuration;

	ccp = &cia_configuration;
	cia_init(ccp, 0);

	ctb = (struct ctb *)(((caddr_t)hwrpb) + hwrpb->rpb_ctb_off);

	switch (ctb->ctb_term_type) {
	case CTB_PRINTERPORT: 
		/* serial console ... */
		/* XXX */
		{
			/*
			 * Delay to allow PROM putchars to complete.
			 * FIFO depth * character time,
			 * character time = (1000000 / (defaultrate / 10))
			 */
			DELAY(160000000 / comcnrate);

			if(comcnattach(&ccp->cc_iot, 0x3f8, comcnrate,
			    COM_FREQ,
			    (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8))
				panic("can't init serial console");

			break;
		}

	case CTB_GRAPHICS:
#if NPCKBD > 0
		/* display console ... */
		/* XXX */
		(void) pckbc_cnattach(&ccp->cc_iot, IO_KBD, KBCMDP, 0);

		/*
		 * On at least LX164, SRM reports an isa video board
		 * as a pci slot with 0xff as the bus and slot numbers.
		 * Since these values are not plausible from a pci point
		 * of view, it is safe to check for them.
		 */
		if (CTB_TURBOSLOT_TYPE(ctb->ctb_turboslot) ==
		    CTB_TURBOSLOT_TYPE_ISA ||
		    (CTB_TURBOSLOT_BUS(ctb->ctb_turboslot) == 0xff &&
		     CTB_TURBOSLOT_SLOT(ctb->ctb_turboslot) == 0xff))
			isa_display_console(&ccp->cc_iot, &ccp->cc_memt);
		else
			pci_display_console(&ccp->cc_iot, &ccp->cc_memt,
			    &ccp->cc_pc, CTB_TURBOSLOT_BUS(ctb->ctb_turboslot),
			    CTB_TURBOSLOT_SLOT(ctb->ctb_turboslot), 0);
#else
		panic("not configured to use display && keyboard console");
#endif
		break;

	default:
		printf("ctb->ctb_term_type = 0x%lx\n", ctb->ctb_term_type);
		printf("ctb->ctb_turboslot = 0x%lx\n", ctb->ctb_turboslot);

		panic("consinit: unknown console type %ld",
		    ctb->ctb_term_type);
	}
}
void
ciaattach(device_t parent, device_t self, void *aux)
{
	struct cia_softc *sc = device_private(self);
	struct cia_config *ccp;
	struct pcibus_attach_args pba;
	char bits[64];
	const char *name;
	int pass;

	/* note that we've attached the chipset; can't have 2 CIAs. */
	ciafound = 1;
	sc->sc_dev = self;

	/*
	 * set up the chipset's info; done once at console init time
	 * (maybe), but we must do it here as well to take care of things
	 * that need to use memory allocation.
	 */
	ccp = sc->sc_ccp = &cia_configuration;
	cia_init(ccp, 1);

	if (ccp->cc_flags & CCF_ISPYXIS) {
		name = "Pyxis";
		pass = ccp->cc_rev;
	} else {
		name = "ALCOR/ALCOR2";
		pass = ccp->cc_rev + 1;
	}

	aprint_normal(": DECchip 2117x Core Logic Chipset (%s), pass %d\n",
	    name, pass);
	if (ccp->cc_cnfg) {
		snprintb(bits, sizeof(bits), CIA_CSR_CNFG_BITS, ccp->cc_cnfg);
		aprint_normal_dev(self, "extended capabilities: %s\n", bits);
	}

	switch (ccp->cc_flags & (CCF_PCI_USE_BWX|CCF_BUS_USE_BWX)) {
	case CCF_PCI_USE_BWX|CCF_BUS_USE_BWX:
		name = "PCI config and bus";
		break;
	case CCF_PCI_USE_BWX:
		name = "PCI config";
		break;
	case CCF_BUS_USE_BWX:
		name = "bus";
		break;
	default:
		name = NULL;
		break;
	}
	if (name != NULL)
		aprint_normal_dev(self, "using BWX for %s access\n", name);

#ifdef DEC_550
	if (cputype == ST_DEC_550 &&
	    (hwrpb->rpb_variation & SV_ST_MASK) < SV_ST_MIATA_1_5) {
		/*
		 * Miata 1 systems have a bug: DMA cannot cross
		 * an 8k boundary!  Make sure PCI read prefetching
		 * is disabled on these chips.  Note that secondary
		 * PCI busses don't have this problem, because of
		 * the way PPBs handle PCI read requests.
		 *
		 * In the 21174 Technical Reference Manual, this is
		 * actually documented as "Pyxis Pass 1", but apparently
		 * there are chips that report themselves as "Pass 1"
		 * which do not have the bug!  Miatas with the Cypress
		 * PCI-ISA bridge (i.e. Miata 1.5 and Miata 2) do not
		 * have the bug, so we use this check.
		 *
		 * NOTE: This bug is actually worked around in cia_dma.c,
		 * when direct-mapped DMA maps are created.
		 *
		 * XXX WE NEED TO THINK ABOUT HOW TO HANDLE THIS FOR
		 * XXX SGMAP DMA MAPPINGS!
		 */
		uint32_t ctrl;

		/* XXX no bets... */
		aprint_error_dev(self,
		    "WARNING: Pyxis pass 1 DMA bug; no bets...\n");

		ccp->cc_flags |= CCF_PYXISBUG;

		alpha_mb();
		ctrl = REGVAL(CIA_CSR_CTRL);
		ctrl &= ~(CTRL_RD_TYPE|CTRL_RL_TYPE|CTRL_RM_TYPE);
		REGVAL(CIA_CSR_CTRL) = ctrl;
		alpha_mb();
	}
#endif /* DEC_550 */

	cia_dma_init(ccp);

	switch (cputype) {
#ifdef DEC_KN20AA
	case ST_DEC_KN20AA:
		pci_kn20aa_pickintr(ccp);
		break;
#endif

#ifdef DEC_EB164
	case ST_EB164:
		pci_eb164_pickintr(ccp);
		break;
#endif

#ifdef DEC_550
	case ST_DEC_550:
		pci_550_pickintr(ccp);
		break;
#endif

#ifdef DEC_1000A
	case ST_DEC_1000A:
		pci_1000a_pickintr(ccp, &ccp->cc_iot, &ccp->cc_memt,
			&ccp->cc_pc);
		break;
#endif

#ifdef DEC_1000
	case ST_DEC_1000:
		pci_1000_pickintr(ccp, &ccp->cc_iot, &ccp->cc_memt,
			&ccp->cc_pc);
		break;
#endif

	default:
		panic("ciaattach: shouldn't be here, really...");
	}

	pba.pba_iot = &ccp->cc_iot;
	pba.pba_memt = &ccp->cc_memt;
	pba.pba_dmat =
	    alphabus_dma_get_tag(&ccp->cc_dmat_direct, ALPHA_BUS_PCI);
	pba.pba_dmat64 = NULL;
	pba.pba_pc = &ccp->cc_pc;
	pba.pba_bus = 0;
	pba.pba_bridgetag = NULL;
	pba.pba_flags = PCI_FLAGS_IO_OKAY | PCI_FLAGS_MEM_OKAY;
	if ((ccp->cc_flags & CCF_PYXISBUG) == 0)
		pba.pba_flags |= PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY |
		    PCI_FLAGS_MWI_OKAY;
	config_found_ia(self, "pcibus", &pba, pcibusprint);
}
Exemple #6
0
int main(int argc, char* argv[])
{
    toolcontext ctx;
    u8 magic[4];
    char infname[512];
    int c;
    u32 ncchoffset = ~0;
    char keysetfname[512] = "keys.xml";
    keyset tmpkeys;
    unsigned int checkkeysetfile = 0;

    memset(&ctx, 0, sizeof(toolcontext));
    ctx.actions = InfoFlag | ExtractFlag;
    ctx.filetype = FILETYPE_UNKNOWN;

    settings_init(&ctx.usersettings);
    keyset_init(&ctx.usersettings.keys);
    keyset_init(&tmpkeys);


    while (1)
    {
        int option_index;
        static struct option long_options[] =
        {
            {"extract", 0, NULL, 'x'},
            {"plain", 0, NULL, 'p'},
            {"info", 0, NULL, 'i'},
            {"exefs", 1, NULL, 0},
            {"romfs", 1, NULL, 1},
            {"exheader", 1, NULL, 2},
            {"certs", 1, NULL, 3},
            {"tik", 1, NULL, 4},
            {"tmd", 1, NULL, 5},
            {"contents", 1, NULL, 6},
            {"meta", 1, NULL, 7},
            {"exefsdir", 1, NULL, 8},
            {"keyset", 1, NULL, 'k'},
            {"ncch", 1, NULL, 'n'},
            {"verbose", 0, NULL, 'v'},
            {"verify", 0, NULL, 'y'},
            {"raw", 0, NULL, 'r'},
            {"unitsize", 1, NULL, 9},
            {"showkeys", 0, NULL, 10},
            {"commonkey", 1, NULL, 11},
            {"ncchkey", 1, NULL, 12},
            {"intype", 1, NULL, 't'},
            {"lzssout", 1, NULL, 13},
            {"firmdir", 1, NULL, 14},
            {"ncchsyskey", 1, NULL, 15},
            {"wav", 1, NULL, 16},
            {"romfsdir", 1, NULL, 17},
            {"listromfs", 0, NULL, 18},
            {"wavloops", 1, NULL, 19},
            {"logo", 1, NULL, 20},
            {NULL},
        };

        c = getopt_long(argc, argv, "ryxivpk:n:t:", long_options, &option_index);
        if (c == -1)
            break;

        switch (c)
        {
        case 'x':
            ctx.actions |= ExtractFlag;
            break;

        case 'v':
            ctx.actions |= VerboseFlag;
            break;

        case 'y':
            ctx.actions |= VerifyFlag;
            break;

        case 'p':
            ctx.actions |= PlainFlag;
            break;

        case 'r':
            ctx.actions |= RawFlag;
            break;

        case 'i':
            ctx.actions |= InfoFlag;
            break;

        case 'n':
            ncchoffset = strtoul(optarg, 0, 0);
            break;

        case 'k':
            strncpy(keysetfname, optarg, sizeof(keysetfname));
            checkkeysetfile = 1;
            break;

        case 't':
            if (!strcmp(optarg, "exheader"))
                ctx.filetype = FILETYPE_EXHEADER;
            else if (!strcmp(optarg, "ncch"))
                ctx.filetype = FILETYPE_CXI;
            else if (!strcmp(optarg, "ncsd"))
                ctx.filetype = FILETYPE_CCI;
            else if (!strcmp(optarg, "cia"))
                ctx.filetype = FILETYPE_CIA;
            else if (!strcmp(optarg, "tmd"))
                ctx.filetype = FILETYPE_TMD;
            else if (!strcmp(optarg, "lzss"))
                ctx.filetype = FILETYPE_LZSS;
            else if (!strcmp(optarg, "firm"))
                ctx.filetype = FILETYPE_FIRM;
            else if (!strcmp(optarg, "cwav"))
                ctx.filetype = FILETYPE_CWAV;
            else if (!strcmp(optarg, "romfs"))
                ctx.filetype = FILETYPE_ROMFS;
            break;

        case 0:
            settings_set_exefs_path(&ctx.usersettings, optarg);
            break;
        case 1:
            settings_set_romfs_path(&ctx.usersettings, optarg);
            break;
        case 2:
            settings_set_exheader_path(&ctx.usersettings, optarg);
            break;
        case 3:
            settings_set_certs_path(&ctx.usersettings, optarg);
            break;
        case 4:
            settings_set_tik_path(&ctx.usersettings, optarg);
            break;
        case 5:
            settings_set_tmd_path(&ctx.usersettings, optarg);
            break;
        case 6:
            settings_set_content_path(&ctx.usersettings, optarg);
            break;
        case 7:
            settings_set_content_path(&ctx.usersettings, optarg);
            break;
        case 8:
            settings_set_exefs_dir_path(&ctx.usersettings, optarg);
            break;
        case 9:
            settings_set_mediaunit_size(&ctx.usersettings, strtoul(optarg, 0, 0));
            break;
        case 10:
            ctx.actions |= ShowKeysFlag;
            break;
        case 11:
            keyset_parse_commonkey(&tmpkeys, optarg, strlen(optarg));
            break;
        case 12:
            keyset_parse_ncchkey(&tmpkeys, optarg, strlen(optarg));
            break;
        case 13:
            settings_set_lzss_path(&ctx.usersettings, optarg);
            break;
        case 14:
            settings_set_firm_dir_path(&ctx.usersettings, optarg);
            break;
        case 15:
            keyset_parse_ncchfixedsystemkey(&tmpkeys, optarg, strlen(optarg));
            break;
        case 16:
            settings_set_wav_path(&ctx.usersettings, optarg);
            break;
        case 17:
            settings_set_romfs_dir_path(&ctx.usersettings, optarg);
            break;
        case 18:
            settings_set_list_romfs_files(&ctx.usersettings, 1);
            break;
        case 19:
            settings_set_cwav_loopcount(&ctx.usersettings, strtoul(optarg, 0, 0));
            break;
        case 20:
            settings_set_logo_path(&ctx.usersettings, optarg);
            break;

        default:
            usage(argv[0]);
        }
    }

    if (optind == argc - 1)
    {
        // Exactly one extra argument - an input file
        strncpy(infname, argv[optind], sizeof(infname));
    }
    else if ( (optind < argc) || (argc == 1) )
    {
        // Too many extra args
        usage(argv[0]);
    }

    keyset_load(&ctx.usersettings.keys, keysetfname, (ctx.actions & VerboseFlag) | checkkeysetfile);
    keyset_merge(&ctx.usersettings.keys, &tmpkeys);
    if (ctx.actions & ShowKeysFlag)
        keyset_dump(&ctx.usersettings.keys);

    ctx.infile = fopen(infname, "rb");

    if (ctx.infile == 0)
    {
        fprintf(stderr, "error: could not open input file!\n");
        return -1;
    }

    fseek(ctx.infile, 0, SEEK_END);
    ctx.infilesize = ftell(ctx.infile);
    fseek(ctx.infile, 0, SEEK_SET);




    if (ctx.filetype == FILETYPE_UNKNOWN)
    {
        fseek(ctx.infile, 0x100, SEEK_SET);
        fread(&magic, 1, 4, ctx.infile);

        switch(getle32(magic))
        {
        case MAGIC_NCCH:
            ctx.filetype = FILETYPE_CXI;
            break;

        case MAGIC_NCSD:
            ctx.filetype = FILETYPE_CCI;
            break;

        default:
            break;
        }
    }

    if (ctx.filetype == FILETYPE_UNKNOWN)
    {
        fseek(ctx.infile, 0, SEEK_SET);
        fread(magic, 1, 4, ctx.infile);

        switch(getle32(magic))
        {
        case 0x2020:
            ctx.filetype = FILETYPE_CIA;
            break;

        case MAGIC_FIRM:
            ctx.filetype = FILETYPE_FIRM;
            break;

        case MAGIC_CWAV:
            ctx.filetype = FILETYPE_CWAV;
            break;

        case MAGIC_IVFC:
            ctx.filetype = FILETYPE_ROMFS; // TODO: need to determine more here.. savegames use IVFC too, but is not ROMFS.
            break;
        }
    }

    if (ctx.filetype == FILETYPE_UNKNOWN)
    {
        fprintf(stdout, "Unknown file\n");
        exit(1);
    }


    switch(ctx.filetype)
    {
    case FILETYPE_CCI:
    {
        ncsd_context ncsdctx;

        ncsd_init(&ncsdctx);
        ncsd_set_file(&ncsdctx, ctx.infile);
        ncsd_set_size(&ncsdctx, ctx.infilesize);
        ncsd_set_usersettings(&ncsdctx, &ctx.usersettings);
        ncsd_process(&ncsdctx, ctx.actions);

        break;
    }

    case FILETYPE_FIRM:
    {
        firm_context firmctx;

        firm_init(&firmctx);
        firm_set_file(&firmctx, ctx.infile);
        firm_set_size(&firmctx, ctx.infilesize);
        firm_set_usersettings(&firmctx, &ctx.usersettings);
        firm_process(&firmctx, ctx.actions);

        break;
    }

    case FILETYPE_CXI:
    {
        ncch_context ncchctx;

        ncch_init(&ncchctx);
        ncch_set_file(&ncchctx, ctx.infile);
        ncch_set_size(&ncchctx, ctx.infilesize);
        ncch_set_usersettings(&ncchctx, &ctx.usersettings);
        ncch_process(&ncchctx, ctx.actions);

        break;
    }


    case FILETYPE_CIA:
    {
        cia_context ciactx;

        cia_init(&ciactx);
        cia_set_file(&ciactx, ctx.infile);
        cia_set_size(&ciactx, ctx.infilesize);
        cia_set_usersettings(&ciactx, &ctx.usersettings);
        cia_process(&ciactx, ctx.actions);

        break;
    }

    case FILETYPE_EXHEADER:
    {
        exheader_context exheaderctx;

        exheader_init(&exheaderctx);
        exheader_set_file(&exheaderctx, ctx.infile);
        exheader_set_size(&exheaderctx, ctx.infilesize);
        settings_set_ignore_programid(&ctx.usersettings, 1);

        exheader_set_usersettings(&exheaderctx, &ctx.usersettings);
        exheader_process(&exheaderctx, ctx.actions);

        break;
    }

    case FILETYPE_TMD:
    {
        tmd_context tmdctx;

        tmd_init(&tmdctx);
        tmd_set_file(&tmdctx, ctx.infile);
        tmd_set_size(&tmdctx, ctx.infilesize);
        tmd_set_usersettings(&tmdctx, &ctx.usersettings);
        tmd_process(&tmdctx, ctx.actions);

        break;
    }

    case FILETYPE_LZSS:
    {
        lzss_context lzssctx;

        lzss_init(&lzssctx);
        lzss_set_file(&lzssctx, ctx.infile);
        lzss_set_size(&lzssctx, ctx.infilesize);
        lzss_set_usersettings(&lzssctx, &ctx.usersettings);
        lzss_process(&lzssctx, ctx.actions);

        break;
    }


    case FILETYPE_CWAV:
    {
        cwav_context cwavctx;

        cwav_init(&cwavctx);
        cwav_set_file(&cwavctx, ctx.infile);
        cwav_set_size(&cwavctx, ctx.infilesize);
        cwav_set_usersettings(&cwavctx, &ctx.usersettings);
        cwav_process(&cwavctx, ctx.actions);

        break;
    }

    case FILETYPE_ROMFS:
    {
        romfs_context romfsctx;

        romfs_init(&romfsctx);
        romfs_set_file(&romfsctx, ctx.infile);
        romfs_set_size(&romfsctx, ctx.infilesize);
        romfs_set_usersettings(&romfsctx, &ctx.usersettings);
        romfs_process(&romfsctx, ctx.actions);

        break;
    }
    }

    if (ctx.infile)
        fclose(ctx.infile);

    return 0;
}
Exemple #7
0
int action_parse(toolcontext* ctx, char* fname)
{
	u8 magic[4];

	ctx->infile = fopen(fname, "rb");

	if (ctx->infile == 0) 
	{
		fprintf(stderr, "error: could not open input file!\n");
		return -1;
	}

	fseek(ctx->infile, 0, SEEK_END);
	ctx->infilesize = ftell(ctx->infile);
	fseek(ctx->infile, 0, SEEK_SET);


	if (ctx->filetype == FILETYPE_UNKNOWN)
	{
		fseek(ctx->infile, 0x100, SEEK_SET);
		fread(&magic, 1, 4, ctx->infile);

		switch(getle32(magic))
		{
			case MAGIC_NCCH:
				ctx->filetype = FILETYPE_CXI;
			break;

			case MAGIC_NCSD:
				ctx->filetype = FILETYPE_CCI;
			break;

			default:
			break;
		}
	}

	if (ctx->filetype == FILETYPE_UNKNOWN)
	{
		fseek(ctx->infile, 0, SEEK_SET);
		fread(magic, 1, 4, ctx->infile);
		
		switch(getle32(magic))
		{
			case 0x2020:
				ctx->filetype = FILETYPE_CIA;
			break;

			case MAGIC_FIRM:
				ctx->filetype = FILETYPE_FIRM;
			break;

			case MAGIC_CWAV:
				ctx->filetype = FILETYPE_CWAV;
			break;

			case MAGIC_IVFC:
				ctx->filetype = FILETYPE_ROMFS; // TODO: need to determine more here.. savegames use IVFC too, but is not ROMFS.
			break;
		}
	}

	if (ctx->filetype == FILETYPE_UNKNOWN)
	{
		fprintf(stdout, "Unknown file\n");
		exit(1);
	}


	switch(ctx->filetype)
	{
		case FILETYPE_CCI:
		{
			ncsd_context ncsdctx;

			ncsd_init(&ncsdctx);
			ncsd_set_file(&ncsdctx, ctx->infile);
			ncsd_set_size(&ncsdctx, ctx->infilesize);
			ncsd_set_usersettings(&ncsdctx, &ctx->usersettings);
			ncsd_process(&ncsdctx, ctx->actions);
			
			break;			
		}

		case FILETYPE_FIRM:
		{
			firm_context firmctx;

			firm_init(&firmctx);
			firm_set_file(&firmctx, ctx->infile);
			firm_set_size(&firmctx, ctx->infilesize);
			firm_set_usersettings(&firmctx, &ctx->usersettings);
			firm_process(&firmctx, ctx->actions);
			
			break;			
		}
		
		case FILETYPE_CXI:
		{
			ncch_context ncchctx;

			ncch_init(&ncchctx);
			ncch_set_file(&ncchctx, ctx->infile);
			ncch_set_size(&ncchctx, ctx->infilesize);
			ncch_set_usersettings(&ncchctx, &ctx->usersettings);
			ncch_process(&ncchctx, ctx->actions);

			break;
		}
		

		case FILETYPE_CIA:
		{
			cia_context ciactx;

			cia_init(&ciactx);
			cia_set_file(&ciactx, ctx->infile);
			cia_set_size(&ciactx, ctx->infilesize);
			cia_set_usersettings(&ciactx, &ctx->usersettings);
			cia_process(&ciactx, ctx->actions);

			break;
		}

		case FILETYPE_EXHEADER:
		{
			exheader_context exheaderctx;

			exheader_init(&exheaderctx);
			exheader_set_file(&exheaderctx, ctx->infile);
			exheader_set_size(&exheaderctx, ctx->infilesize);
			settings_set_ignore_programid(&ctx->usersettings, 1);

			exheader_set_usersettings(&exheaderctx, &ctx->usersettings);
			exheader_process(&exheaderctx, ctx->actions);
	
			break;
		}

		case FILETYPE_TMD:
		{
			tmd_context tmdctx;

			tmd_init(&tmdctx);
			tmd_set_file(&tmdctx, ctx->infile);
			tmd_set_size(&tmdctx, ctx->infilesize);
			tmd_set_usersettings(&tmdctx, &ctx->usersettings);
			tmd_process(&tmdctx, ctx->actions);
	
			break;
		}

		case FILETYPE_LZSS:
		{
			lzss_context lzssctx;

			lzss_init(&lzssctx);
			lzss_set_file(&lzssctx, ctx->infile);
			lzss_set_size(&lzssctx, ctx->infilesize);
			lzss_set_usersettings(&lzssctx, &ctx->usersettings);
			lzss_process(&lzssctx, ctx->actions);
	
			break;
		}


		case FILETYPE_CWAV:
		{
			cwav_context cwavctx;

			cwav_init(&cwavctx);
			cwav_set_file(&cwavctx, ctx->infile);
			cwav_set_size(&cwavctx, ctx->infilesize);
			cwav_set_usersettings(&cwavctx, &ctx->usersettings);
			cwav_process(&cwavctx, ctx->actions);
	
			break;
		}

		case FILETYPE_EXEFS:
		{
			exefs_context exefsctx;

			exefs_init(&exefsctx);
			exefs_set_file(&exefsctx, ctx->infile);
			exefs_set_size(&exefsctx, ctx->infilesize);
			exefs_set_usersettings(&exefsctx, &ctx->usersettings);
			exefs_process(&exefsctx, ctx->actions);
	
			break;
		}

		case FILETYPE_ROMFS:
		{
			romfs_context romfsctx;

			romfs_init(&romfsctx);
			romfs_set_file(&romfsctx, ctx->infile);
			romfs_set_size(&romfsctx, ctx->infilesize);
			romfs_set_usersettings(&romfsctx, &ctx->usersettings);
			romfs_process(&romfsctx, ctx->actions);
	
			break;
		}
	}
	
	if (ctx->infile)
		fclose(ctx->infile);

	return 0;
}
Exemple #8
0
void
dec_1000a_cons_init()
{
	struct ctb *ctb;
	struct cia_config *ccp;
	struct apecs_config *acp;
	extern struct cia_config cia_configuration;
	extern struct apecs_config apecs_configuration;
	bus_space_tag_t iot, memt;
	struct alpha_pci_chipset *pcichipset;

	if(strcmp(platform.iobus, "cia") == 0) {
		ccp = &cia_configuration;
		cia_init(ccp, 0);
		iot = &ccp->cc_iot;
		memt = &ccp->cc_memt;
		pcichipset = &ccp->cc_pc;
	} else {
		acp = &apecs_configuration;
		apecs_init(acp, 0);
		iot = &acp->ac_iot;
		memt = &acp->ac_memt;
		pcichipset = &acp->ac_pc;
	}

	ctb = (struct ctb *)(((caddr_t)hwrpb) + hwrpb->rpb_ctb_off);

	switch (ctb->ctb_term_type) {
	case CTB_PRINTERPORT: 
		/* serial console ... */
		/* XXX */
		{
			/*
			 * Delay to allow PROM putchars to complete.
			 * FIFO depth * character time,
			 * character time = (1000000 / (defaultrate / 10))
			 */
			DELAY(160000000 / comcnrate);

			if(comcnattach(iot, 0x3f8, comcnrate,
			    COM_FREQ,
			    (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8))
				panic("can't init serial console");

			break;
		}

	case CTB_GRAPHICS:
#if NPCKBD > 0
		/* display console ... */
		/* XXX */
		(void) pckbc_cnattach(iot, IO_KBD, KBCMDP, PCKBC_KBD_SLOT);

		/*
		 * AlphaServer 1000s have a firmware bug whereby the
		 * built-in ISA VGA is reported incorrectly -- ctb_turboslot
		 * is mostly 0.
		 */
		switch (CTB_TURBOSLOT_TYPE(ctb->ctb_turboslot)) {
		case CTB_TURBOSLOT_TYPE_PCI:
			pci_display_console(iot, memt, pcichipset,
			    CTB_TURBOSLOT_BUS(ctb->ctb_turboslot),
			    CTB_TURBOSLOT_SLOT(ctb->ctb_turboslot), 0);
			break;

		default:
			isa_display_console(iot, memt);
			break;
		}
#else
		panic("not configured to use display && keyboard console");
#endif
		break;

	default:
		printf("ctb->ctb_term_type = 0x%lx\n", ctb->ctb_term_type);
		printf("ctb->ctb_turboslot = 0x%lx\n", ctb->ctb_turboslot);

		panic("consinit: unknown console type %ld",
		    ctb->ctb_term_type);
	}
#ifdef KGDB
	/* Attach the KGDB device. */
	alpha_kgdb_init(kgdb_devlist, iot);
#endif /* KGDB */
}