Example #1
0
void arch_pre_mm_init(void)
{
	pm_init();

	if (config.cpu_active == 1) {
		interrupt_init();
		bios_init();
		
		/* PIC */
		i8259_init();
	}
}
Example #2
0
void emu_init(int argc, char **argv)
{
	char memory_file[1024];
	FILE *fp;

	if (argc == 2) {
		strcpy(memory_file, argv[1]);
	} else {
		strcpy(memory_file, "memory/start.bin");
	}

	/* Load the memory */
	fp = fopen(memory_file, "rb");
	if (fp == NULL) {
		fprintf(stderr, "[EMU] Failed to load memory file '%s'\n", memory_file);
		exit(1);
	}

	{
		/* Check the header */
		uint8 values[5];
		fread(values, sizeof(uint8), 5, fp);
		if (values[0] != 'E' || values[1] != 'M' || values[2] != 'U' || values[3] != 0x17) {
			fprintf(stderr, "[EMU] Not a valid memory file\n");
			exit(1);
		}
		if (values[4] != 4) {
			fprintf(stderr, "[EMU] Memory file is of wrong version and can't be loaded\n");
			exit(1);
		}
	}

	{
		/* Load the registers */
		uint16 values[20];
		fread(values, sizeof(uint16), 20, fp);
		emu_cs        = values[0];
		emu_ip        = values[1];
		emu_ax        = values[2];
		emu_bx        = values[3];
		emu_cx        = values[4];
		emu_dx        = values[5];
		emu_si        = values[6];
		emu_di        = values[7];
		emu_bp        = values[8];
		emu_sp        = values[9];
		emu_ds        = values[10];
		emu_es        = values[11];
		emu_ss        = values[12];
		emu_flags_all = values[13];
		emu_deep      = values[14];
		emu_last_cs   = values[15];
		emu_last_ip   = values[16];
		emu_last_crc  = values[17];
		emu_last_length = values[18];
		emu_overlay   = (uint8)values[19];
	}

	/* Load the memory */
	fread(emu_memory, 1024 * 1024, 1, fp);

	/* Correct for the type we emulate */
#if EMULATE_386
	emu_flags.iopl = 3;
	emu_flags.nt   = 1;
	emu_flags.res4 = 0;
#elif EMULATE_286
	emu_flags.iopl = 0;
	emu_flags.nt   = 0;
	emu_flags.res4 = 0;
#else
	emu_flags.iopl = 3;
	emu_flags.nt   = 1;
	emu_flags.res4 = 1;
#endif
	emu_flags.res1 = 1;

	bios_init();
}
Example #3
0
int init_module(void)
{
	return bios_init();
}
Example #4
0
void biosmain(void)
{
    BOOL show_initinfo;         /* TRUE if welcome screen must be displayed */
    BYTE *p;

    bios_init();                /* Initialize the BIOS */

    trap1( 0x30 );              /* initial test, if BDOS works: Sversion() */

    if (!HAS_RTC)
        trap1( 0x2b, os_dosdate);  /* set initial date in GEMDOS format: Tsetdate() */

    /* Steem needs this to initialize its GEMDOS hard disk emulation.
     * This may change drvbits. See Steem sources:
     * File steem/code/emulator.cpp, function intercept_bios(). */
    Drvmap();

    /*
     * if it's not the first boot, we use the existing bootdev.
     * this allows a boot device that was selected via the welcome
     * screen to persist across warm boots.
     */
    if (first_boot)
        bootdev = blkdev_avail(DEFAULT_BOOTDEV) ? DEFAULT_BOOTDEV : FLOPPY_BOOTDEV;

#if INITINFO_DURATION == 0
    show_initinfo = FALSE;
#elif ALWAYS_SHOW_INITINFO
    show_initinfo = TRUE;
#else
    show_initinfo = first_boot;
#endif

    if (show_initinfo)
        bootdev = initinfo();   /* show the welcome screen */

    KDEBUG(("bootdev = %d\n", bootdev));

    /* boot eventually from a block device (floppy or harddisk) */
    blkdev_boot();

    defdrv = bootdev;
    trap1( 0x0e , defdrv );    /* Set boot drive: Dsetdrv(defdrv) */

#if ENABLE_RESET_RESIDENT
    run_reset_resident();       /* see comments above */
#endif

    /*
     * build default environment, just a PATH= string
     */
    strcpy(default_env,PATH_ENV);
    p = default_env + sizeof(PATH_ENV); /* point to first byte of path string */
    strcpy(p,DEF_PATH);
    *p = 'A' + defdrv;                  /* fix up drive letter */
    p += sizeof(DEF_PATH);
    *p = '\0';                          /* terminate with double nul */

#if WITH_CLI
    if (early_cli) {            /* run an early console */
        PD *pd = (PD *) trap1_pexec(PE_BASEPAGE, "", "", default_env);
        pd->p_tbase = (LONG) coma_start;
        pd->p_tlen = pd->p_dlen = pd->p_blen = 0;
        trap1_pexec(PE_GOTHENFREE, "", pd, "");
    }
#endif

    autoexec();                 /* autoexec PRGs from AUTO folder */

    /* clear commandline */

    if(cmdload != 0) {
        /* Pexec a program called COMMAND.PRG */
        trap1_pexec(PE_LOADGO, "COMMAND.PRG", "", default_env);
    } else if (exec_os) {
        /* start the default (ROM) shell */
        PD *pd;
        pd = (PD *) trap1_pexec(PE_BASEPAGE, "", "", default_env);
        pd->p_tbase = (LONG) exec_os;
        pd->p_tlen = pd->p_dlen = pd->p_blen = 0;
        trap1_pexec(PE_GO, "", pd, "");
    }

#if CONF_WITH_SHUTDOWN
        /* try to shutdown the machine / close the emulator */
        shutdown();
#endif

    /* hide cursor */
    cprintf("\033f");

    kcprintf(_("System halted!\n"));
    halt();
}