Beispiel #1
0
gboolean refresh(PROC_T *p){
    if(!p->entry_iseed) create_entry(p);

    switch(p->status.info){
    case 0:
	break;
    case S_RUNNING:
	break;
    case S_WAIT:
	/*waiting to start */
	gtk_entry_set_text(GTK_ENTRY(p->entry_timing),"Waiting");
	break;
    case S_START:
	/*just started. */
	gtk_entry_set_text(GTK_ENTRY(p->entry_timing),"Started");
	{
	    char lb[12];
	    char stime[80];
	    snprintf(lb,12," %5d",p->pid);
	    struct tm *tim=localtime(&(p->status.timstart));
	    strftime(stime,80,"[%F %k:%M:%S]",tim);
	    strcat(stime,lb);
	    gtk_label_set_text(GTK_LABEL(p->entry_pid), stime);
	}
	notify_user(p);
	break;
    case S_QUEUED:
	/*queued in scheduler */
	gtk_entry_set_text(GTK_ENTRY(p->entry_timing),"Queued");
	break;
    case S_FINISH:/*Finished */
	p->frac=1;
	change_button(p,GTK_STOCK_APPLY,(GCallback)delete_hbox_event);
	/*progress bar color. */
	gtk_widget_modify_bg(p->entry_timing,GTK_STATE_SELECTED,&green);
	notify_user(p);
	break;
    case S_CRASH:/*Error */
	gtk_entry_set_text(GTK_ENTRY(p->entry_timing),"Error");
	change_button(p,GTK_STOCK_CLOSE,(GCallback)delete_hbox_event);
	gtk_widget_modify_base(p->entry_timing,GTK_STATE_NORMAL,&red);
	notify_user(p);
	break;
    case S_TOKILL:/*kill command sent */
	gtk_entry_set_text(GTK_ENTRY(p->entry_timing),"Kill command sent");
	change_button(p,GTK_STOCK_CLOSE,(GCallback)delete_hbox_event);
	gtk_widget_modify_base(p->entry_timing,GTK_STATE_NORMAL,&yellow);
	break;
    case S_KILLED:
	gtk_entry_set_text(GTK_ENTRY(p->entry_timing),"Killed");
	change_button(p,GTK_STOCK_CLOSE,(GCallback)delete_hbox_event);
	gtk_widget_modify_base(p->entry_timing,GTK_STATE_NORMAL,&red);
	notify_user(p);
	break;
    default:
	warning("Unknown info\n");
    }
    update_prog(p);
    return 0;
}
Beispiel #2
0
int caps_loadimage (struct zfile *zf, int drv, int *num_tracks)
{
	static int notified;
	struct CapsImageInfo ci;
	int len, ret;
	uae_u8 *buf;
	TCHAR s1[100];
	struct CapsDateTimeExt *cdt;

	if (!caps_init ())
		return 0;
	caps_unloadimage (drv);
	zfile_fseek (zf, 0, SEEK_END);
	len = zfile_ftell (zf);
	zfile_fseek (zf, 0, SEEK_SET);
	buf = xmalloc (uae_u8, len);
	if (!buf)
		return 0;
	if (zfile_fread (buf, len, 1, zf) == 0)
		return 0;
	ret = pCAPSLockImageMemory (caps_cont[drv], buf, len, 0);
	xfree (buf);
	if (ret != imgeOk) {
		if (ret == imgeIncompatible || ret == imgeUnsupported) {
			if (!notified)
				notify_user (NUMSG_OLDCAPS);
			notified = 1;
		}
		write_log (L"caps: CAPSLockImageMemory() returned %d\n", ret);
		return 0;
	}
	caps_locked[drv] = 1;
	ret = pCAPSGetImageInfo(&ci, caps_cont[drv]);
	*num_tracks = (ci.maxcylinder - ci.mincylinder + 1) * (ci.maxhead - ci.minhead + 1);

	if (cvi.release < 4) { // pre-4.x bug workaround
		struct CapsTrackInfoT1 cit;
		cit.type = 1;
		if (pCAPSLockTrack ((PCAPSTRACKINFO)&cit, caps_cont[drv], 0, 0, caps_flags) == imgeIncompatible) {
			if (!notified)
				notify_user (NUMSG_OLDCAPS);
			notified = 1;
			caps_unloadimage (drv);
			return 0;
		}
		pCAPSUnlockAllTracks (caps_cont[drv]);
	}

	ret = pCAPSLoadImage(caps_cont[drv], caps_flags);
	cdt = &ci.crdt;
	_stprintf (s1, L"%d.%d.%d %d:%d:%d", cdt->day, cdt->month, cdt->year, cdt->hour, cdt->min, cdt->sec);
	write_log (L"caps: type:%d date:%s rel:%d rev:%d\n",
		ci.type, s1, ci.release, ci.revision);
	return 1;
}
Beispiel #3
0
int caps_init (void)
{
	static int init, noticed;
	int i;
	HMODULE h;
	TCHAR *dllname = L"CAPSImg.dll";

	if (init)
		return 1;
	h = WIN32_LoadLibrary (dllname);
	if (!h) {
		TCHAR tmp[MAX_DPATH];
		if (SUCCEEDED (SHGetFolderPath (NULL, CSIDL_PROGRAM_FILES_COMMON, NULL, 0, tmp))) {
			_tcscat (tmp, L"\\Software Preservation Society\\");
			_tcscat (tmp, dllname);
			h = LoadLibrary (tmp);
			if (!h) {
				if (noticed)
					return 0;
				notify_user (NUMSG_NOCAPS);
				noticed = 1;
				return 0;
			}
		}
	}
	if (GetProcAddress (h, "CAPSLockImageMemory") == 0 || GetProcAddress (h, "CAPSGetVersionInfo") == 0) {
		if (noticed)
			return 0;
		notify_user (NUMSG_OLDCAPS);
		noticed = 1;
		return 0;
	}
	pCAPSInit = (CAPSINIT)GetProcAddress (h, "CAPSInit");
	pCAPSAddImage = (CAPSADDIMAGE)GetProcAddress (h, "CAPSAddImage");
	pCAPSLockImageMemory = (CAPSLOCKIMAGEMEMORY)GetProcAddress (h, "CAPSLockImageMemory");
	pCAPSUnlockImage = (CAPSUNLOCKIMAGE)GetProcAddress (h, "CAPSUnlockImage");
	pCAPSLoadImage = (CAPSLOADIMAGE)GetProcAddress (h, "CAPSLoadImage");
	pCAPSGetImageInfo = (CAPSGETIMAGEINFO)GetProcAddress (h, "CAPSGetImageInfo");
	pCAPSLockTrack = (CAPSLOCKTRACK)GetProcAddress (h, "CAPSLockTrack");
	pCAPSUnlockTrack = (CAPSUNLOCKTRACK)GetProcAddress (h, "CAPSUnlockTrack");
	pCAPSUnlockAllTracks = (CAPSUNLOCKALLTRACKS)GetProcAddress (h, "CAPSUnlockAllTracks");
	pCAPSGetVersionInfo = (CAPSGETVERSIONINFO)GetProcAddress (h, "CAPSGetVersionInfo");
	init = 1;
	cvi.type = 1;
	pCAPSGetVersionInfo (&cvi, 0);
	write_log (L"CAPS: library version %d.%d (flags=%08X)\n", cvi.release, cvi.revision, cvi.flag);
	oldlib = (cvi.flag & (DI_LOCK_TRKBIT | DI_LOCK_OVLBIT)) != (DI_LOCK_TRKBIT | DI_LOCK_OVLBIT);
	if (!oldlib)
		caps_flags |= DI_LOCK_TRKBIT | DI_LOCK_OVLBIT;
	canseed = (cvi.flag & DI_LOCK_SETWSEED) != 0;
	for (i = 0; i < 4; i++)
		caps_cont[i] = pCAPSAddImage ();
	return 1;
}
Beispiel #4
0
void moduleripper (void)
{
	int size;
	uae_u8 *buf, *p;

	size = currprefs.chipmem_size;
	for (int i = 0; i < MAX_RAM_BOARDS; i++) {
		size += currprefs.fastmem[i].size;
		size += currprefs.z3fastmem[i].size;
	}
	size += currprefs.bogomem_size;
	size += currprefs.mbresmem_low_size;
	size += currprefs.mbresmem_high_size;
	buf = p = xmalloc (uae_u8, size);
	if (!buf)
		return;
	memcpy (p, chipmem_bank.baseaddr, currprefs.chipmem_size);
	p += currprefs.chipmem_size;
	for (int i = 0; i < MAX_RAM_BOARDS; i++) {
		mc (p, fastmem_bank[i].start, currprefs.fastmem[i].size);
		p += currprefs.fastmem[i].size;
	}
	mc (p, bogomem_bank.start, currprefs.bogomem_size);
	p += currprefs.bogomem_size;
	mc (p, a3000lmem_bank.start, currprefs.mbresmem_low_size);
	p += currprefs.mbresmem_low_size;
	mc (p, a3000hmem_bank.start, currprefs.mbresmem_high_size);
	p += currprefs.mbresmem_high_size;
	for (int i = 0; i < MAX_RAM_BOARDS; i++) {
		mc (p, z3fastmem_bank[i].start, currprefs.z3fastmem[i].size);
		p += currprefs.z3fastmem[i].size;
	}

	got = 0;
	canceled = 0;
#ifdef _WIN32
	__try {
#endif
		prowizard_search (buf, size);
#ifdef _WIN32
	} __except(ExceptionFilter (GetExceptionInformation (), GetExceptionCode ())) {
		write_log (_T("prowizard scan crashed\n"));
	}
#endif
	if (!got)
		notify_user (NUMSG_MODRIP_NOTFOUND);
	else if (!canceled)
		notify_user (NUMSG_MODRIP_FINISHED);
	xfree (buf);
}
Beispiel #5
0
static void state_incompatible_warn (void)
{
	static int warned;
	int dowarn = 0;
	int i;

#ifdef BSDSOCKET
	if (currprefs.socket_emu)
		dowarn = 1;
#endif
#ifdef UAESERIAL
	if (currprefs.uaeserial)
		dowarn = 1;
#endif
#ifdef SCSIEMU
	if (currprefs.scsi)
		dowarn = 1;
#endif
#ifdef CATWEASEL
	if (currprefs.catweasel)
		dowarn = 1;
#endif
#ifdef FILESYS
	for(i = 0; i < currprefs.mountitems; i++) {
		struct mountedinfo mi;
		int type = get_filesys_unitconfig (&currprefs, i, &mi);
		if (mi.ismounted && type != FILESYS_VIRTUAL && type != FILESYS_HARDFILE && type != FILESYS_HARDFILE_RDB)
			dowarn = 1;
	}
#endif
	if (!warned && dowarn) {
		warned = 1;
		notify_user (NUMSG_STATEHD);
	}
}
Beispiel #6
0
static void ersatz_failed (void)
{
    if (already_failed)
	    return;
    already_failed = 1;
    notify_user (NUMSG_KICKREPNO);
    uae_restart (-1, NULL);
}
Beispiel #7
0
int kickstart_checksum (uae_u8 *mem, int size)
{
	if (!kickstart_checksum_do (mem, size)) {
#ifndef	SINGLEFILE
		notify_user (NUMSG_KSROMCRCERROR);
#endif
		return 0;
	}
	return 1;
}
Beispiel #8
0
/* Returns true if the configuration value changed */
static int
set_configuration()
{
  notify_user(USB_EVENT_CONFIG);
  if (usb_configuration_value != LOW_BYTE(usb_setup_buffer.wValue)) {
    usb_configuration_value = LOW_BYTE(usb_setup_buffer.wValue);
    usb_arch_set_configuration(usb_configuration_value);
    usb_send_ctrl_status();
    return 1;
  } else {
    usb_send_ctrl_status();
    return 0;
  }
}
Beispiel #9
0
int decode_rom (uae_u8 *mem, int size, int mode, int real_size)
{
	if (mode == 1) {
		if (!decode_cloanto_rom_do (mem, size, real_size)) {
#ifndef SINGLEFILE
			notify_user (NUMSG_NOROMKEY);
#endif
			return 0;
		}
		return 1;
	} else if (mode == 2) {
		decode_rekick_rom_do (mem, size, real_size);
		return 1;
	}
	return 0;
}
void notify_all_users(char* caption, char* message, char* icon) {
    printf("NOTIFY: %s - %s\n", caption, message);

    FILE* ufp = PCHECKED(fopen(_PATH_UTMP, "r"));

    struct utmp utmp_entry;

    while(fread((char*) &utmp_entry, sizeof(utmp_entry), 1, ufp) == 1) {
        // we want to have a login name, we want to be a user session and we want our line to start with ':', indicating a x11 session        
        if (*utmp_entry.ut_name && *utmp_entry.ut_line && utmp_entry.ut_type == USER_PROCESS && *utmp_entry.ut_line == ':') {
            struct passwd *user_passwd = PCHECKED(getpwnam(utmp_entry.ut_name));
            notify_user(user_passwd->pw_uid, caption, message, icon);
        }
    }

    fclose(ufp);
}
static int process_job(struct job *job, int cid)
{
	int err = 0;
	job->state = STATE_PROCESSING;

	INFO("%s", job->infile);

	err = __process_job(job);
	if (err)
		INFO("__process_job return %d", err);
	job->state = err ? STATE_FAILED : STATE_SUCCESS;

	notify_user(job, err, cid);
	destroy_job(job);

	return 0;
}
Beispiel #12
0
static bool load_qemu_implementation(void)
{
#ifdef WITH_QEMU_CPU
	write_log(_T("PPC: Loading QEmu implementation\n"));
	memset(&impl, 0, sizeof(impl));

	UAE_DLHANDLE handle = uae_qemu_uae_init();
	if (!handle) {
#ifdef FSUAE
		gui_message(_T("PPC: Error loading qemu-uae plugin\n"));
#else
		notify_user (NUMSG_NO_PPC);
#endif
		return false;
	}
	write_log(_T("PPC: Loaded qemu-uae library at %p\n"), handle);

	/* Retrieve function pointers from library */

	impl.init = (ppc_cpu_init_function) uae_dlsym(handle, "ppc_cpu_init");
	//impl.free = (ppc_cpu_free_function) uae_dlsym(handle, "ppc_cpu_free");
	//impl.stop = (ppc_cpu_stop_function) uae_dlsym(handle, "ppc_cpu_stop");
	impl.external_interrupt = (qemu_uae_ppc_external_interrupt_function) uae_dlsym(handle, "qemu_uae_ppc_external_interrupt");
	impl.map_memory = (ppc_cpu_map_memory_function) uae_dlsym(handle, "ppc_cpu_map_memory");
	impl.run_continuous = (ppc_cpu_run_continuous_function) uae_dlsym(handle, "ppc_cpu_run_continuous");
	impl.check_state = (ppc_cpu_check_state_function) uae_dlsym(handle, "ppc_cpu_check_state");
	impl.set_state = (ppc_cpu_set_state_function) uae_dlsym(handle, "ppc_cpu_set_state");
	impl.reset = (ppc_cpu_reset_function) uae_dlsym(handle, "ppc_cpu_reset");
	impl.in_cpu_thread = (qemu_uae_ppc_in_cpu_thread_function) uae_dlsym(handle, "qemu_uae_ppc_in_cpu_thread");
	impl.lock = (qemu_uae_lock_function) uae_dlsym(handle, "qemu_uae_lock");

	// FIXME: not needed, handled internally by uae_dlopen_plugin
	// uae_dlopen_patch_common(handle);

	uae_patch_library_ppc(handle);
	return true;
#else
	return false;
#endif
}
Beispiel #13
0
int caps_init (void)
{
    static int init, noticed;
    int i;

    if (init)
        return 1;
#ifdef FSUAE
    UAE_DLHANDLE h = uae_dlopen_plugin(_T("capsimg"));
    // compatibility lookup for older plugin
    if (!h) {
        h = uae_dlopen_plugin(_T("libcapsimage"));
    }
#else
    UAE_DLHANDLE h = uae_dlopen_plugin(_T("CAPSImg"));
    if (!h) {
        TCHAR tmp[MAX_DPATH];
        if (SUCCEEDED (SHGetFolderPath (NULL, CSIDL_PROGRAM_FILES_COMMON, NULL, 0, tmp))) {
            _tcscat (tmp, _T("\\Software Preservation Society\\"));
            _tcscat (tmp, _T("CAPSImg.dll"));
            h = uae_dlopen(tmp);
        }
    }
#endif
    if (!h) {
        if (noticed)
            return 0;
        notify_user (NUMSG_NOCAPS);
        noticed = 1;
        return 0;
    }

    if (uae_dlsym(h, "CAPSLockImageMemory") == 0 || uae_dlsym(h, "CAPSGetVersionInfo") == 0) {
        if (noticed)
            return 0;
        notify_user (NUMSG_OLDCAPS);
        noticed = 1;
        return 0;
    }

    pCAPSInit = (CAPSINIT) uae_dlsym(h, "CAPSInit");
    pCAPSAddImage = (CAPSADDIMAGE) uae_dlsym(h, "CAPSAddImage");
    pCAPSLockImageMemory = (CAPSLOCKIMAGEMEMORY) uae_dlsym(h, "CAPSLockImageMemory");
    pCAPSUnlockImage = (CAPSUNLOCKIMAGE) uae_dlsym(h, "CAPSUnlockImage");
    pCAPSLoadImage = (CAPSLOADIMAGE) uae_dlsym(h, "CAPSLoadImage");
    pCAPSGetImageInfo = (CAPSGETIMAGEINFO) uae_dlsym(h, "CAPSGetImageInfo");
    pCAPSLockTrack = (CAPSLOCKTRACK) uae_dlsym(h, "CAPSLockTrack");
    pCAPSUnlockTrack = (CAPSUNLOCKTRACK) uae_dlsym(h, "CAPSUnlockTrack");
    pCAPSUnlockAllTracks = (CAPSUNLOCKALLTRACKS) uae_dlsym(h, "CAPSUnlockAllTracks");
    pCAPSGetVersionInfo = (CAPSGETVERSIONINFO) uae_dlsym(h, "CAPSGetVersionInfo");
    pCAPSGetInfo = (CAPSGETINFO) uae_dlsym(h, "CAPSGetInfo");
    pCAPSSetRevolution = (CAPSSETREVOLUTION) uae_dlsym(h, "CAPSSetRevolution");
    pCAPSGetImageTypeMemory = (CAPSGETIMAGETYPEMEMORY) uae_dlsym(h, "CAPSGetImageTypeMemory");

    init = 1;
    cvi.type = 1;
    pCAPSGetVersionInfo (&cvi, 0);
    write_log (_T("CAPS: library version %d.%d (flags=%08X)\n"), cvi.release, cvi.revision, cvi.flag);
    oldlib = (cvi.flag & (DI_LOCK_TRKBIT | DI_LOCK_OVLBIT)) != (DI_LOCK_TRKBIT | DI_LOCK_OVLBIT);
    if (!oldlib)
        caps_flags |= DI_LOCK_TRKBIT | DI_LOCK_OVLBIT;
    canseed = (cvi.flag & DI_LOCK_SETWSEED) != 0;
    for (i = 0; i < 4; i++)
        caps_cont[i] = pCAPSAddImage ();
    return 1;
}
Beispiel #14
0
gboolean refresh(PROC_T *p){
    if(!p->row){
	char sdate[80];
	char spid[12];
	snprintf(spid,12," %d ",p->pid);
	struct tm *tim=localtime(&p->status.timstart);
	strftime(sdate,80,"%m-%d %k:%M:%S",tim);
	char *spath=p->path;
	char *sstart=NULL, *sout=NULL, *sargs=NULL;
	if(spath){
	    const char *pos=NULL;
	    pos=strstr(spath, "/maos ");
	    if(!pos){
		pos=strstr(spath, "/skyc ");
	    }
	    if(pos){
		sstart=(char*)malloc(pos-spath+1);
		memcpy(sstart, spath, pos-spath);
		sstart[pos-spath]='\0';
		sargs=strdup(pos+1);
		char *pos2=NULL;
		for(char *tmp=sargs; (tmp=strstr(tmp, " -o ")); tmp+=4){
		    pos2=tmp;
		}
		if(pos2){
		    pos2+=4;
		    char *pos3=strchr(pos2, ' ');
		    if(!pos3) pos3=strchr(pos2, '\0');
		    if(pos3){
			sout=(char*)malloc(pos3-pos2+1);
			memcpy(sout, pos2, pos3-pos2);
			sout[pos3-pos2]='\0';
			memmove(pos2-4, pos3, strlen(pos3)+1);
		    }
		}
	    }
	}
	GtkListStore *list=lists[p->hid];
	GtkTreeIter iter;
	gtk_list_store_append(list, &iter);
	gtk_list_store_set(list,&iter,
			   COL_DATE,  sdate,
			   COL_PID,   spid,
			   COL_FULL,  spath?spath:"Unknown",
			   COL_START, sstart?sstart:" ",
			   COL_ARGS,  sargs?sargs:" ",
			   COL_OUT,   sout?sout:" ",
			   COL_ERRHI, " ",
			   COL_ERRLO, " ",
			   COL_SEED,  " ",
			   COL_SEEDP, 0,
			   COL_STEP,  " ",
			   COL_STEPP, 0,
			   -1);
	free(sstart); free(sout); free(sargs);
	GtkTreePath *tpath=gtk_tree_model_get_path(GTK_TREE_MODEL(list), &iter);
	p->row=gtk_tree_row_reference_new(GTK_TREE_MODEL(list),tpath);
	list_update_progress(p);
	gtk_tree_path_free(tpath);
	gtk_tree_view_columns_autosize(GTK_TREE_VIEW(views[p->hid]));
    }
    switch(p->status.info){
    case 0:
	break;
    case S_RUNNING:
	list_update_progress(p);
	list_modify_icon(p,icon_running);
	break;
    case S_WAIT: /*waiting to start */
	//list_modify_status(p, "Waiting");
	list_modify_reset(p);
	list_modify_icon(p,icon_waiting);
	break;
    case S_START: /*just started. */
	//list_modify_status(p, "Started");
	list_modify_reset(p);
	list_modify_icon(p,icon_running);
	notify_user(p);
	break;
    case S_QUEUED:
	//list_modify_status(p, "Queued");
	list_modify_reset(p);
	list_modify_icon(p,icon_waiting);
	break;
    case S_FINISH:/*Finished */
	list_update_progress(p);
	list_modify_icon(p, icon_finished);
	//list_modify_color(p,"#00DD00");
	notify_user(p);
	break;
    case S_CRASH:/*Error */
	//list_modify_status(p, "Error");
	list_modify_icon(p,icon_failed);
	//list_modify_color(p,"#CC0000");
	notify_user(p);
	break;
    case S_TOKILL:/*kill command sent */
	//list_modify_status(p, "Kill command sent");
	list_modify_icon(p,icon_failed);
	//list_modify_color(p,"#CCCC00");
	break;
    case S_KILLED:
	//list_modify_status(p, "Killed");
	list_modify_icon(p,icon_failed);
	//list_modify_color(p,"#CC0000");
	notify_user(p);
	break;
    case S_REMOVE:
	break;
    default:
	warning("Unknown info: %d\n",p->status.info);
    }
    if(p->status.warning){
	list_modify_color(p, "#FF0000");
    }
    return 0;
}
Beispiel #15
0
static void ersatz_init (void)
{
    int f;
    uaecptr request;
    uaecptr a;

    already_failed = 0;
    write_log ("initializing kickstart replacement\n");
    if (disk_empty (0)) {
	    already_failed = 1;
	    notify_user (NUMSG_KICKREP);
	    uae_restart (-1, NULL);
	    return;
    }

    regs.s = 0;

    /* Set some interrupt vectors */
    for (a = 8; a < 0xC0; a += 4) {
	put_long (a, 0xF8001A);
    }
    regs.isp = regs.msp = regs.usp = 0x800;
    m68k_areg(&regs, 7) = 0x80000;
    regs.intmask = 0;

    /* Build a dummy execbase */
    put_long (4, m68k_areg(&regs, 6) = 0x676);
    put_byte (0x676 + 0x129, 0);
    for (f = 1; f < 105; f++) {
	put_word (0x676 - 6*f, 0x4EF9);
	put_long (0x676 - 6*f + 2, 0xF8000C);
    }
    /* Some "supported" functions */
    put_long (0x676 - 456 + 2, 0xF80014);
    put_long (0x676 - 216 + 2, 0xF80020);
    put_long (0x676 - 198 + 2, 0xF80026);
    put_long (0x676 - 204 + 2, 0xF8002c);
    put_long (0x676 - 210 + 2, 0xF8002a);

    /* Build an IORequest */
    request = 0x800;
    put_word (request + 0x1C, 2);
    put_long (request + 0x28, 0x4000);
    put_long (request + 0x2C, 0);
    put_long (request + 0x24, 0x200 * 4);
    m68k_areg(&regs, 1) = request;
    ersatz_doio ();
    /* kickstart disk loader */
    if (get_long(0x4000) == 0x4b49434b) {
	/* a kickstart disk was found in drive 0! */
	write_log ("Loading Kickstart rom image from Kickstart disk\n");
	/* print some notes... */
	write_log ("NOTE: if UAE crashes set CPU to 68000 and/or chipmem size to 512KB!\n");

	/* read rom image from kickstart disk */
	put_word (request + 0x1C, 2);
	put_long (request + 0x28, 0xF80000);
	put_long (request + 0x2C, 0x200);
	put_long (request + 0x24, 0x200 * 512);
	m68k_areg(&regs, 1) = request;
	ersatz_doio ();

	/* read rom image once again to mirror address space.
	   not elegant, but it works... */
	put_word (request + 0x1C, 2);
	put_long (request + 0x28, 0xFC0000);
	put_long (request + 0x2C, 0x200);
	put_long (request + 0x24, 0x200 * 512);
	m68k_areg(&regs, 1) = request;
	ersatz_doio ();

	disk_eject (0);

	m68k_setpc (&regs, 0xFC0002);
	fill_prefetch_slow (&regs);
	uae_reset (0);
	ersatzkickfile = 0;
	return;
    }

    m68k_setpc (&regs, 0x400C);
    fill_prefetch_slow (&regs);

    /* Init the hardware */
    put_long (0x3000, 0xFFFFFFFEul);
    put_long (0xDFF080, 0x3000);
    put_word (0xDFF088, 0);
    put_word (0xDFF096, 0xE390);
    put_word (0xDFF09A, 0xE02C);
    put_word (0xDFF09E, 0x0000);
    put_word (0xDFF092, 0x0038);
    put_word (0xDFF094, 0x00D0);
    put_word (0xDFF08E, 0x2C81);
    put_word (0xDFF090, 0xF4C1);
    put_word (0xDFF02A, 0x8000);

    put_byte (0xBFD100, 0xF7);
    put_byte (0xBFEE01, 0);
    put_byte (0xBFEF01, 0x08);
    put_byte (0xBFDE00, 0x04);
    put_byte (0xBFDF00, 0x84);
    put_byte (0xBFDD00, 0x9F);
    put_byte (0xBFED01, 0x9F);
}
Beispiel #16
0
PROCESS_THREAD(usb_process, ev , data)
{
  PROCESS_BEGIN();
  PRINTF("USB process started\r\n");
  while(1) {
    PROCESS_WAIT_EVENT();
    if (ev == PROCESS_EVENT_EXIT) break;
    if (ev == PROCESS_EVENT_POLL) {
      unsigned int events = usb_arch_get_global_events();
      if (events) {
	if (events & USB_EVENT_RESET) {
	  submit_setup();
	  usb_configuration_value = 0;
	  notify_user(USB_EVENT_RESET);
	}
	if (events & USB_EVENT_SUSPEND) {
	  notify_user(USB_EVENT_SUSPEND);
	}
	if (events & USB_EVENT_RESUME) {
	  notify_user(USB_EVENT_RESUME);
	}
	
      }
      events = usb_get_ep_events(0);
      if (events) {
	if ((events & USB_EP_EVENT_NOTIFICATION)
	    && !(ctrl_buffer.flags & USB_BUFFER_SUBMITTED)) {
	  /* PRINTF("Endpoint 0\r\n"); */
	  if (ctrl_buffer.flags & USB_BUFFER_FAILED) {
	    /* Something went wrong with the buffer, just wait for a
	       new SETUP packet */
	    PRINTF("Discarded\r\n");
	    submit_setup();
	  } else if (ctrl_buffer.flags & USB_BUFFER_SETUP) {
	    struct USBRequestHandlerHook *hook = usb_request_handler_hooks;

	    PRINTF("Setup\r\n");
#if 0
	    {
	    unsigned int i;
	    for (i = 0; i< 8; i++) PRINTF(" %02x", ((unsigned char*)&usb_setup_buffer)[i]);
	    PRINTF("\r\n");
	    }
#endif	    
	    while(hook) {
	      const struct USBRequestHandler *handler = hook->handler;
	      /* Check if the handler matches the request */
	      if (((handler->request_type ^ usb_setup_buffer.bmRequestType)
		   & handler->request_type_mask) == 0
		  && ((handler->request ^ usb_setup_buffer.bRequest)
		      & handler->request_mask) == 0) {
		if (handler->handler_func()) break;
	      }
	      hook = hook->next;
	    }
	    if (!hook) {
	      /* No handler found */
	      usb_error_stall();
	      PRINTF("Unhandled setup: %02x %02x %04x %04x %04x\r\n",
		     usb_setup_buffer.bmRequestType, usb_setup_buffer.bRequest,
		     usb_setup_buffer.wValue, usb_setup_buffer.wIndex,
		     usb_setup_buffer.wLength);
	    }
	    /* Check if any handler stalled the pipe, if so prepare for
	       next setup */
	    if (error_stall) {
	      error_stall = 0;
	      submit_setup();
	    }
	  } else {
	    if (ctrl_buffer.id == IN_ID) {
	      /* Receive status stage */
	      PRINTF("Status OUT\r\n");
	      ctrl_buffer.flags =  USB_BUFFER_NOTIFY;
	      ctrl_buffer.next = NULL;
	      ctrl_buffer.data = NULL;
	      ctrl_buffer.left = 0;
	      ctrl_buffer.id = STATUS_OUT_ID;
	      usb_submit_recv_buffer(0,&ctrl_buffer);
	    } else if (ctrl_buffer.id == STATUS_OUT_ID) {
	      PRINTF("Status OUT done\r\n");
	      submit_setup();
	    } else if (ctrl_buffer.id == STATUS_IN_ID) {
	      PRINTF("Status IN done\r\n");
	      if (usb_flags & USB_FLAG_ADDRESS_PENDING) {
		while(usb_send_pending(0));
		usb_arch_set_address(LOW_BYTE(usb_setup_buffer.wValue));
		usb_flags &= ~USB_FLAG_ADDRESS_PENDING;
	      }
	      submit_setup();
	    } else if (ctrl_buffer.id == OUT_ID) {
	      PRINTF("OUT\r\n");
	      if (data_callback) {
		data_callback(ctrl_data, ctrl_data_len- ctrl_buffer.left);
	      } else {
		usb_send_ctrl_status();
	      }
	    }
	  }
	}
      }
    }
  }
  PROCESS_END();
}
Beispiel #17
0
static unsigned int
handle_standard_requests()
{
  switch(usb_setup_buffer.bmRequestType) {
  case 0x80: /* standard device IN requests */
    switch(usb_setup_buffer.bRequest) {
    case GET_DESCRIPTOR:
      switch (HIGH_BYTE(usb_setup_buffer.wValue)) {
      case DEVICE:
	get_device_descriptor();
	break;
      case CONFIGURATION:
	get_configuration_descriptor();
	break;
      case STRING:
	get_string_descriptor();
	break;
      default:
	/* Unknown descriptor */
	return 0;
      }
      break;
    case GET_CONFIGURATION:
      get_configuration();
      break;
    case GET_STATUS:
      get_device_status();
      break;
    case GET_INTERFACE:
      get_interface();
      break;
    default:
      return 0;
    }
    break;
  case 0x81: /* standard interface IN requests */
    switch(usb_setup_buffer.bRequest) {
    case GET_STATUS:
      get_interface_status();
      break;
#ifdef HID_ENABLED
      case GET_DESCRIPTOR:
	switch (USB_setup_buffer.wValue.byte.high) {
	case REPORT:
	  get_report_descriptor();
	  break;
	}
	break;
#endif	
    default:
      return 0;
    }
    break;
  case 0x82: /* standard endpoint IN requests */
    switch(usb_setup_buffer.bRequest) {
    case GET_STATUS:
      get_endpoint_status();
      break;
    default:
      return 0;
    }
    break;
  case 0x00: /* standard device OUT requests */
    switch(usb_setup_buffer.bRequest) {
    case SET_ADDRESS:
      PRINTF("Address: %d\r\n", LOW_BYTE(usb_setup_buffer.wValue));
      usb_flags |= USB_FLAG_ADDRESS_PENDING;
      /* The actual setting of the address is done when the status packet
	 is sent. */
      usb_send_ctrl_status();
      break;
#if SETABLE_STRING_DESCRIPTORS > 0
    case SET_DESCRIPTOR:
      if (usb_setup_buffer.wValue.byte.high == STRING) {
	set_string_descriptor();
      } else {
	return 0;
      }
      break;
#endif
    case SET_CONFIGURATION:
      if (set_configuration()) {
#if 0
	config_msg.data.config = LOW_BYTE(usb_setup_buffer.wValue);
	notify_user(&config_msg);
#endif
      }
      break;
    default:
      return 0;
    }
    break;
  case 0x01: /* standard interface OUT requests */
    switch(usb_setup_buffer.bRequest) {
    case SET_INTERFACE:
      /* Change interface here if we support more than one */
      usb_send_ctrl_status();
      break;
    default:
      return 0;
    }
    break;
  case 0x02: /* standard endpoint OUT requests */
    switch(usb_setup_buffer.bRequest) {
    case SET_FEATURE:
    case CLEAR_FEATURE:
      if (usb_setup_buffer.wValue == ENDPOINT_HALT_FEATURE) {
	usb_arch_halt_endpoint(usb_setup_buffer.wIndex, usb_setup_buffer.bRequest== SET_FEATURE);
	usb_send_ctrl_status();
      } else {
	usb_error_stall();
      }
      break;
    default:
      return 0;
    }
    break;
#ifdef HID_ENABLED
  case 0xa1: /* class specific interface IN request*/
    switch(USB_setup_buffer.bRequest) {
    case GET_HID_REPORT:
      PRINTF("Get report\r\n");
      send_ctrl_response((code u_int8_t*)&zero_byte,
			   sizeof(zero_byte));
      break;
    case GET_HID_IDLE:
      PRINTF("Get idle\r\n");
      send_ctrl_response((code u_int8_t*)&zero_byte,
			 sizeof(zero_byte));
      break;
    default:
      return 0;
      }
    break;
  case 0x21: /* class specific interface OUT request*/
    switch(USB_setup_buffer.bRequest) {
    case SET_HID_IDLE:
      PRINTF("Set idle\r\n");
      send_ctrl_status();
      break;
    default:
      return 0;
    }
    break;
#endif
  default:
    return 0;
  }
  return 1;
}