Beispiel #1
0
void timer_exit(Vwk * vwk)
{
    WORD old_sr;

    old_sr = set_sr(0x2700);            // disable interrupts
    Setexc(0x100, (long)tim_chain);     // set etv_timer to tick_int
    set_sr(old_sr);                     // enable interrupts
}
Beispiel #2
0
void timer_init(Vwk * vwk)
{
    WORD old_sr;

    in_proc = 0;                        // no vblanks in process

    /* Now initialize the lower level things */
    tim_addr = do_nothing_int;          // tick points to rts

    old_sr = set_sr(0x2700);            // disable interrupts
    tim_chain = (void(*)(int))          // save old vector
        Setexc(0x100, (long)tick_int);  // set etv_timer to tick_int
    set_sr(old_sr);                     // enable interrupts

}
Beispiel #3
0
void _vex_timv(Vwk * vwk)
{
    WORD old_sr;
    LONG * pointer;

    pointer = (LONG*) &CONTRL[9];

    old_sr = set_sr(0x2700);

    *pointer = (LONG) tim_addr;
    tim_addr = (void (*)(int)) *--pointer;

    set_sr(old_sr);

    INTOUT[0] = (WORD)Tickcal();        /* ms between timer C calls */
}
Beispiel #4
0
void secondary_init_irq(void)
{
	__this_cpu_write(cached_irq_mask,
			XCHAL_INTTYPE_MASK_EXTERN_EDGE |
			XCHAL_INTTYPE_MASK_EXTERN_LEVEL);
	set_sr(XCHAL_INTTYPE_MASK_EXTERN_EDGE |
			XCHAL_INTTYPE_MASK_EXTERN_LEVEL, intenable);
}
Beispiel #5
0
static void xtensa_mx_irq_unmask(struct irq_data *d)
{
	unsigned int mask = 1u << d->hwirq;

	if (mask & (XCHAL_INTTYPE_MASK_EXTERN_EDGE |
				XCHAL_INTTYPE_MASK_EXTERN_LEVEL)) {
		set_er(1u << (xtensa_get_ext_irq_no(d->hwirq) -
					HW_IRQ_MX_BASE), MIENGSET);
	} else {
		mask |= __this_cpu_read(cached_irq_mask);
		__this_cpu_write(cached_irq_mask, mask);
		set_sr(mask, intenable);
	}
}
Beispiel #6
0
LONG bconin2(void)
{
    WORD old_sr;
    ULONG value;

    while (!bconstat2()) {
#if USE_STOP_INSN_TO_FREE_HOST_CPU
        stop_until_interrupt();
#endif
    }
    /* disable interrupts */
    old_sr = set_sr(0x2700);

    ikbdiorec.head += 4;
    if (ikbdiorec.head >= ikbdiorec.size) {
        ikbdiorec.head = 0;
    }
    value = *(ULONG_ALIAS *) (ikbdiorec.buf + ikbdiorec.head);

    /* restore interrupts */
    set_sr(old_sr);
    return value;
}
Beispiel #7
0
static int xtensa_mx_irq_retrigger(struct irq_data *d)
{
	set_sr(1 << d->hwirq, intset);
	return 1;
}
Beispiel #8
0
static void xtensa_mx_irq_ack(struct irq_data *d)
{
	set_sr(1 << d->hwirq, intclear);
}
Beispiel #9
0
// Constructor for this base class: do initialization, etc.
tt_audio_base::tt_audio_base(void)
{
	set_sr(global_sr);						// Init the local sr to the global sr
	set_vectorsize(global_vectorsize);		// Init the local vs to the global vs
	init();
}
Beispiel #10
0
/*
 * Given a config_control_t structure, configure and initialize
 * the emulator.
 * This is the first function you should call if you're writing an
 * interface to Shoebill.
 */
uint32_t shoebill_initialize(shoebill_control_t *control)
{
    uint32_t i, j, pc = 0xffffffff;
    coff_file *coff = NULL;
    scsi_device_t disks[8];
    uint8_t *rom_data = NULL;
    uint32_t rom_size = 0;
    
    memset(&disks[0], 0, 8 * sizeof(scsi_device_t));
    memset(&shoe, 0, sizeof(global_shoebill_context_t));
    
    fpu_setup_jump_table();
    
    // Try to load the ROM
    if (control->rom_path == NULL) {
        sprintf(control->error_msg, "No rom file specified\n");
        goto fail;
    }
    else if (!_load_rom(control, &rom_data, &rom_size))
            goto fail;
    
    // Try to open the disk images
    if (!_open_disk_images(control, disks))
        goto fail;

    // Try to load the A/UX kernel
    if (control->aux_kernel_path == NULL) {
        sprintf(control->error_msg, "No A/UX kernel specified\n");
        goto fail;
    }
    coff = coff_parser(control->aux_kernel_path);
    
    if (coff == NULL) {
        sprintf(control->error_msg, "Can't open that A/UX kernel [%s]\n",
                control->aux_kernel_path);
        goto fail;
    }
    shoe.coff = coff;
    
    
    // Allocate and configure the rom and memory space
    
    /*if (control->ram_size > (256 * 1024 * 1024)) {
        // I think A/UX will go insane if you give it >256MB of memory
        sprintf(control->error_msg, "%u bytes is too much memory\n", control->ram_size);
        goto fail;
    }
    else */if (control->ram_size < (1024*1024)) {
        sprintf(control->error_msg, "%u bytes is too little ram\n", control->ram_size);
        goto fail;
    }
    
    shoe.physical_rom_size = rom_size;
    shoe.physical_rom_base = valloc(rom_size);
    memcpy(shoe.physical_rom_base, rom_data, rom_size);
    free(rom_data);
    rom_data = NULL;
    
    shoe.physical_mem_size = control->ram_size;
    shoe.physical_mem_base = valloc(control->ram_size);
    memset(shoe.physical_mem_base, 0, shoe.physical_mem_size);
    
    // Initialize Macintosh lomem variables that A/UX actually cares about
    
    #define AUX_LOMEM_OFFSET 0x50000
    _init_macintosh_lomem_globals(AUX_LOMEM_OFFSET);
    
    // Initialize A/UX's kernel_info structure
    
    _init_kernel_info(control, disks, AUX_LOMEM_OFFSET);
    
    // Load A/UX kernel COFF segments into memory (returns PC, the entry point into the kernel)
    
    if (!_load_aux_kernel(control, coff, &pc))
        goto fail;
    
    // HACK:
//    for (i=0; i<0x4000; i++) {
//        uint8_t c = pget(AUX_LOMEM_OFFSET + i, 1);
//        pset(i, 1, c);
//    }
    
    /*
     * Load it all into the internal global shoebill state
     * (Can't fail after this point)
     */
    
    // FIXME: Don't do this! Rewrite the via timers!
    gettimeofday(&shoe.start_time, NULL);
    shoe.total_ticks = 0;
    
    // Put the adb chip in state 3 (idle)
    shoe.adb.state = 3;
    pthread_mutex_init(&shoe.adb.lock, NULL);
    
    set_sr(0x2000);
    shoe.pc = pc;
    memcpy(shoe.scsi_devices, disks, 8 * sizeof(scsi_device_t));
    
    pthread_mutex_init(&shoe.cpu_thread_lock, NULL);
    pthread_mutex_init(&shoe.via_clock_thread_lock, NULL);
    
    pthread_mutex_lock(&shoe.cpu_thread_lock);
    pthread_mutex_lock(&shoe.via_clock_thread_lock);
    
    pthread_create(&control->cpu_thread_pid, NULL, _cpu_thread, NULL);
    // pthread_create(&control->cpu_thread_pid, NULL, debug_cpu_thread, NULL);
    pthread_create(&control->via_thread_pid, NULL, via_clock_thread, NULL);
    
    return 1;
    
fail:
    if (rom_data) free(rom_data);
    
    for (i=0; i<7; i++)
        if (disks[i].f) fclose(disks[i].f);
    
    if (shoe.physical_rom_base) free(shoe.physical_rom_base);
    if (shoe.physical_mem_base) free(shoe.physical_mem_base);
    
    // No way to free *coff yet
    return 0;
}
Beispiel #11
0
static void bios_init(void)
{
    KDEBUG(("bios_init()\n"));

    /* initialize Native Features, if available
     * do it as soon as possible so that kprintf can make use of them
     */
#if DETECT_NATIVE_FEATURES
    KDEBUG(("natfeat_init()\n"));
    natfeat_init();
#endif
#if STONX_NATIVE_PRINT
    KDEBUG(("stonx_kprintf_init()\n"));
    stonx_kprintf_init();
#endif
#if CONF_WITH_UAE
    KDEBUG(("amiga_uaelib_init()\n"));
    amiga_uaelib_init();
#endif

    /* Initialize the processor */
    KDEBUG(("processor_init()\n"));
    processor_init();   /* Set CPU type, longframe and FPU type */
    KDEBUG(("vecs_init()\n"));
    vecs_init();        /* setup all exception vectors (above) */
    KDEBUG(("init_delay()\n"));
    init_delay();       /* set 'reasonable' default values for delay */

    /* Detect optional hardware (video, sound, etc.) */
    KDEBUG(("machine_detect()\n"));
    machine_detect();   /* detect hardware */
    KDEBUG(("machine_init()\n"));
    machine_init();     /* initialise machine-specific stuff */

    /* Initialize the screen */
    KDEBUG(("screen_init()\n"));
    screen_init();      /* detect monitor type, ... */

    /* Initialize the BIOS memory management */
    KDEBUG(("bmem_init()\n"));
    bmem_init();        /* this must be done after screen_init() */

    KDEBUG(("cookie_init()\n"));
    cookie_init();      /* sets a cookie jar */
    KDEBUG(("fill_cookie_jar()\n"));
    fill_cookie_jar();  /* detect hardware features and fill the cookie jar */

    /* Set up the BIOS console output */
    KDEBUG(("linea_init()\n"));
    linea_init();       /* initialize screen related line-a variables */
    font_init();        /* initialize font ring (requires cookie_akp) */
    font_set_default(-1);/* set default font */
    vt52_init();        /* initialize the vt52 console */

    /* Now kcprintf() will also send debug info to the screen */
    KDEBUG(("after vt52_init()\n"));

    /* misc. variables */
    dumpflg = -1;
    sysbase = (LONG) os_entry;
    savptr = (LONG) trap_save_area;
    etv_timer = (void(*)(int)) just_rts;
    etv_critic = default_etv_critic;
    etv_term = just_rts;

    /* setup VBL queue */
    nvbls = 8;
    vblqueue = vbl_list;
    {
        int i;
        for(i = 0 ; i < 8 ; i++) {
            vbl_list[i] = 0;
        }
    }

#if CONF_WITH_MFP
    KDEBUG(("mfp_init()\n"));
    mfp_init();
#endif

#if CONF_WITH_TT_MFP
    if (has_tt_mfp)
    {
        KDEBUG(("tt_mfp_init()\n"));
        tt_mfp_init();
    }
#endif

    /* Initialize the system 200 Hz timer */
    KDEBUG(("init_system_timer()\n"));
    init_system_timer();

    /* Initialize the RS-232 port(s) */
    KDEBUG(("chardev_init()\n"));
    chardev_init();     /* Initialize low-memory bios vectors */
    boot_status |= CHARDEV_AVAILABLE;   /* track progress */
    KDEBUG(("init_serport()\n"));
    init_serport();
    boot_status |= RS232_AVAILABLE;     /* track progress */
#if CONF_WITH_SCC
    if (has_scc)
        boot_status |= SCC_AVAILABLE;   /* track progress */
#endif

    /* The sound init must be done before allowing MFC interrupts,
     * because of dosound stuff in the timer C interrupt routine.
     */
#if CONF_WITH_DMASOUND
    KDEBUG(("dmasound_init()\n"));
    dmasound_init();
#endif
    KDEBUG(("snd_init()\n"));
    snd_init();         /* Reset Soundchip, deselect floppies */

    /* Init the two ACIA devices (MIDI and KBD). The three actions below can
     * be done in any order provided they happen before allowing MFP
     * interrupts.
     */
    KDEBUG(("kbd_init()\n"));
    kbd_init();         /* init keyboard, disable mouse and joystick */
    KDEBUG(("midi_init()\n"));
    midi_init();        /* init MIDI acia so that kbd acia irq works */
    KDEBUG(("init_acia_vecs()\n"));
    init_acia_vecs();   /* Init the ACIA interrupt vector and related stuff */
    KDEBUG(("after init_acia_vecs()\n"));
    boot_status |= MIDI_AVAILABLE;  /* track progress */

    /* Now we can enable the interrupts.
     * We need a timer for DMA timeouts in floppy and harddisk initialisation.
     * The VBL processing will be enabled later with the vblsem semaphore.
     */
#if CONF_WITH_ATARI_VIDEO
    /* Keep the HBL disabled */
    set_sr(0x2300);
#else
    set_sr(0x2000);
#endif

    KDEBUG(("calibrate_delay()\n"));
    calibrate_delay();  /* determine values for delay() function */
                        /*  - requires interrupts to be enabled  */
    KDEBUG(("blkdev_init()\n"));
    blkdev_init();      /* floppy and harddisk initialisation */
    KDEBUG(("after blkdev_init()\n"));

    /* initialize BIOS components */

    KDEBUG(("parport_init()\n"));
    parport_init();     /* parallel port */
    //mouse_init();     /* init mouse driver */
    KDEBUG(("clock_init()\n"));
    clock_init();       /* init clock */
    KDEBUG(("after clock_init()\n"));

#if CONF_WITH_NLS
    KDEBUG(("nls_init()\n"));
    nls_init();         /* init native language support */
    nls_set_lang(get_lang_name());
#endif

    /* set start of user interface */
#if WITH_AES
    exec_os = ui_start;
#elif WITH_CLI
    exec_os = coma_start;
#else
    exec_os = NULL;
#endif

    KDEBUG(("osinit()\n"));
    osinit();                   /* initialize BDOS */
    KDEBUG(("after osinit()\n"));
    boot_status |= DOS_AVAILABLE;   /* track progress */

    /* Enable VBL processing */
    vblsem = 1;

#if CONF_WITH_CARTRIDGE
    {
        WORD save_hz = v_hz_rez, save_vt = v_vt_rez, save_pl = v_planes;

        /* Run all boot applications from the application cartridge.
         * Beware: Hatari features a special cartridge which is used
         * for GEMDOS drive emulation. It will hack drvbits and hook Pexec().
         * It will also hack Line A variables to enable extended VDI video modes.
         */
        KDEBUG(("run_cartridge_applications(3)\n"));
        run_cartridge_applications(3); /* Type "Execute prior to bootdisk" */
        KDEBUG(("after run_cartridge_applications()\n"));

        if ((v_hz_rez != save_hz) || (v_vt_rez != save_vt) || (v_planes != save_pl))
        {
            set_rez_hacked();
            font_set_default(-1);   /* set default font */
            vt52_init();            /* initialize the vt52 console */
        }
    }
#endif

#if CONF_WITH_ALT_RAM

#if CONF_WITH_FASTRAM
    /* add TT-RAM that was detected in memory.S */
    if (ramtop != NULL)
    {
        KDEBUG(("xmaddalt()\n"));
        xmaddalt(FASTRAM_START, ramtop - FASTRAM_START);
    }
#endif

#if CONF_WITH_MONSTER
    /* Add MonSTer alt-RAM detected in machine.c */
    if (has_monster)
    {
        /* Dummy read from MonSTer register to initiate write sequence. */
        unsigned short monster_reg = *(volatile unsigned short *)MONSTER_REG;

        /* Only enable 6Mb when on a Mega STE due to address conflict with
           VME bus. Todo: This should be made configurable. */
        if (has_vme)
            monster_reg = 6;
        else
            monster_reg = 8;

        /* Register write sequence: read - write - write */
        *(volatile unsigned short *)MONSTER_REG = monster_reg;
        *(volatile unsigned short *)MONSTER_REG = monster_reg;
        KDEBUG(("xmaddalt()\n"));
        xmaddalt((UBYTE *)0x400000L, monster_reg*0x100000L);
    }
#endif

#ifdef MACHINE_AMIGA
    KDEBUG(("amiga_add_alt_ram()\n"));
    amiga_add_alt_ram();
#endif

#endif /* CONF_WITH_ALT_RAM */

    KDEBUG(("bios_init() end\n"));
}
Beispiel #12
0
static void xtensa_irq_unmask(struct irq_data *d)
{
	cached_irq_mask |= 1 << d->hwirq;
	set_sr(cached_irq_mask, intenable);
}