[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MiNT] patch:XaAES:virtual_wk



This patch introduces one new feature and 5 small fixes

----------------------------------------------------------------------------------
 If a physical workstation is already open at startup, it is used.
This is tested by trying to open a virtual workstation. If this succeeds this virtual
workstation is used and no phyiscal is opened, P_handle gets assigned
the value of the virtual handle for now.

 Temporary workaround in case vq_extnd reports invalid planes.

 Better test and error-message if xaaes.rsc has wrong version

 If cannot start, error-message is displayed after wk was closed

 Reverted previous change in waking up loader

 Does not join loader-group any more
----------------------------------------------------------------------------------


diff -u -B -I '$Id' src.cvs/k_init.c src.km/k_init.c
--- src.cvs/k_init.c	2010-01-04 23:31:11.000000000 +0100
+++ src.km/k_init.c	2010-01-13 22:36:39.203125000 +0100
@@ -77,7 +77,7 @@
 
 struct xa_module_api xam_api;
 
- STATIC char *xaaes_sysfile(const char *);
+STATIC char *xaaes_sysfile(const char *);
 
 static OBSPEC * _cdecl
 api_object_get_spec(OBJECT *ob)
@@ -570,7 +571,20 @@
 			BLOG((false, "could not determine fvdi version"));
 #endif
 	}
+	/* try to open virtual wk - necessary when physical wk is already open
+	 * ? how to know if physical wk is open and its handle without AES?
+	 */
+	if( C.fvdi_version == 0 /*&& cfg.videomode == 0*/ )
+	{
+		v->handle = 0;
+		C.P_handle = 0;
+		set_wrkin(work_in, cfg.videomode);
+		BLOG((0,"1st v_opnvwk" ));
+		v_opnvwk(work_in, &v->handle, work_out);
+		BLOG((0,"->%d, wh=%d/%d %d colors", v->handle, work_out[0], work_out[1], work_out[13]));
 
+	}
+	if ( v->handle <= 0 )
 	{
 		short mode = 1;
 		long vdo, r;
@@ -579,7 +593,9 @@
 		if (r != 0)
 			vdo = 0;
 
-		if (cfg.videomode)
+		BLOG((0,"k_init:vdo=%ld vm=%lx video=%d", vdo, vm, cfg.videomode ));
+
+		if ( cfg.videomode)
 		{
 #ifndef ST_ONLY
 			if ((vm & 0x80000000) && mvdi_api.dispatch)
@@ -711,8 +727,9 @@
 			sc = s_system(S_CTRLCACHE, -1L, 0L);
 			s_system(S_CTRLCACHE, sc & ~3, cm);
 			set_wrkin(work_in, mode);
-			BLOG((0,"k_init: v_opnwk()" ));
+			BLOG((0,"k_init: v_opnwk() mode=%d", mode ));
 			v_opnwk(work_in, &(C.P_handle), work_out);
+			BLOG((0,"k_init: v_opnwk() handle=%d", C.P_handle ));
 			s_system(S_CTRLCACHE, sc, cm);
 		}
 #else
@@ -731,16 +748,17 @@
 		 * We need to get rid of the cursor
 		 */
 		v_exit_cur(C.P_handle);
-	}
 
-	get_syspalette(C.P_handle, screen.palette);
+		get_syspalette(C.P_handle, screen.palette);
 // 	set_defaultpalette(C.P_handle);
-	/*
-	 * Open us a virtual workstation for XaAES to play with
-	 */
-	v->handle = C.P_handle;
-	set_wrkin(work_in, 1);
-	v_opnvwk(work_in, &v->handle, work_out);
+		/*
+		 * Open us a virtual workstation for XaAES to play with
+		 */
+		//v->handle = C.P_handle;
+
+		set_wrkin(work_in, 1);
+		v_opnvwk(work_in, &v->handle, work_out);
+	}
 
 	if (v->handle == 0)
 	{
@@ -752,6 +770,8 @@
 	/*
 	 * Setup the screen parameters
 	 */
+	if( C.P_handle == 0 )
+		C.P_handle = v->handle;	/* why is phys-handle used at all? */
 	screen.r.x = screen.r.y = 0;
 	screen.r.w = work_out[0] + 1;
 	screen.r.h = work_out[1] + 1;
@@ -759,7 +779,7 @@
 	screen.display_type = D_LOCAL;
 	v->screen = screen.r;
 	C.Aes->vdi_settings = v;
-	vs_clip(C.P_handle, 1, (short *)&screen.r);
+	vs_clip(/*C.P_*/v->handle, 1, (short *)&screen.r);
 	(*v->api->set_clip)(v, &screen.r);
 
 	(*v->api->f_perimeter)(v, 0);
@@ -774,8 +794,20 @@
 	vq_extnd(v->handle, 1, work_out);	/* Get extended information */
 	screen.planes = work_out[4];		/* number of planes in the screen */
 
-	//BLOG((0,"lookup-support:%d", work_out[5] ));
+	BLOG((0,"lookup-support:%d, planes:%d", work_out[5], work_out[4] ));
 
+	/* WARNING: This is halfway nonsense! */
+	if( screen.planes > 32 || screen.planes < 1 )
+	{
+		BLOG((1,"planes wrong: %d", screen.planes ));
+		screen.planes = screen.colours >> 8;
+		BLOG((1,"planes now: %d", screen.planes ));
+		if( screen.planes > 32 || screen.planes < 1 )
+		{
+			BLOG((1,"planes still wrong: %d", screen.planes ));
+			return 1;
+		}
+	}
 // 	if (screen.planes > 8)
 // 		set_defaultpalette(v->handle);
 // 	get_syspalette(C.P_handle, screen.palette);
@@ -861,18 +893,20 @@
 	}
 // 	set_syspalette(C.P_handle, screen.palette);
 // 	set_syscolor();
-
+#define RSCFILE_VERSION	"0.0.9"
 	/*
 	 * Version check the aessys resouce
 	 */
 	{
 		OBJECT *about = ResourceTree(C.Aes_rsc, ABOUT_XAAES);
+		int gt = 0;
 
 		if ((ob_count_objs(about, 0, -1) < RSC_VERSION)   ||
 		     about[RSC_VERSION].ob_type != G_TEXT     ||
-		    (strcmp(object_get_tedinfo(about + RSC_VERSION, NULL)->te_ptext, "0.0.9")))
+		    ( gt = strcmp(object_get_tedinfo(about + RSC_VERSION, NULL)->te_ptext, RSCFILE_VERSION)))
 		{
-			display(/*00000004*/"ERROR: Outdated AESSYS resource file (%s) - update to recent version!", cfg.rsc_name);
+			char *s = gt > 0 ? "too new" : gt < 0 ? "too old" : "wrong";
+			display("ERROR: %s resource file (%s) - use version "RSCFILE_VERSION"!", s, cfg.rsc_name);
 // 			display("       also make sure you read CHANGES.txt!!");
 			return -1;
 		}
@@ -886,17 +920,18 @@
 
 	if (!(*C.Aes->objcr_module->init_module)(&xam_api, &screen, cfg.gradients))
 	{
-		BLOG((false, "object render returned NULL"));
+		BLOG((true, "object render returned NULL"));
 		return -1;
 	}
 	if (init_client_objcrend(C.Aes))
-	{	BLOG((false, "Opening object theme failed"));
+	{
+		BLOG((true, "Opening object theme failed"));
 		return -1;
 	}
 
 	if (!(C.Aes->wtheme_handle = (*C.Aes->xmwt->init_module)(&xam_api, &screen, (char *)&cfg.widg_name, cfg.gradients)))
 	{
-		display("Window widget module returned NULL");
+		BLOG((true,"Window widget module returned NULL"));
 		return -1;
 	}
 
diff -u -B -I '$Id' src.cvs/k_main.c src.km/k_main.c
--- src.cvs/k_main.c	2010-01-04 23:31:11.000000000 +0100
+++ src.km/k_main.c	2010-01-13 22:28:26.015625000 +0100
@@ -925,7 +925,7 @@
 	}
 }
 
-static void k_exit(void);
+static void k_exit(int);
 static void restore_sigs(void);
 static void setup_common(void);
 
@@ -943,7 +943,7 @@
 fatal(void)
 {
 	KERNEL_DEBUG("AESSYS: fatal error, trying to clean up");
-	k_exit();
+	k_exit(0);
 }
 #endif
 
@@ -960,7 +960,7 @@
 	BLOG((false, "%s(%d:AES:%d): sigterm received", p->name, p->pid, C.AESpid ));
 #if 1
 	BLOG((false, "(ignored)" ));
-		return;
+	return;
 #else
 	if( p->pid != C.AESpid ){
 		BLOG((false, "(ignored)" ));
@@ -1450,7 +1450,8 @@
 	setup_common();
 
 	/* join process group of loader */
-	p_setpgrp(0, loader_pgrp);
+	/* this breaks shutdown on my TT - XaAES has pgrp 0 now */
+	//p_setpgrp(0, loader_pgrp);
 
 	c_naes = NULL;
 
@@ -1740,12 +1741,7 @@
 		cancelroottimeout(C.sdt);
 	C.sdt = NULL;
 leave:
-	if (wait)
-	{
-		display(/*press_any_key*/"press any key to continue ...");
-		_c_conin();
-	}
-	k_exit();
+	k_exit(wait);
 
 	kthread_exit(0);
 }
@@ -1805,7 +1801,7 @@
 }
 
 static void
-k_exit(void)
+k_exit(int wait)
 {
 //	display("k_exit");
 	C.shutdown |= QUIT_NOW;
@@ -1836,6 +1832,11 @@
 
 // 	display("k_shutdown..");
 	k_shutdown();
+	if (wait)
+	{
+		display(/*press_any_key*/"press any key to continue ...");
+		_c_conin();
+	}
 // 	display("done");
 
 	if (c_naes)
@@ -1868,26 +1868,25 @@
 	 */
 	PRCLOSE;
 
-	BLOG((false, "Closing alert pipe"));
 	if (C.alert_pipe > 0)
 		f_close(C.alert_pipe);
-
+#if 0
 	{
 	struct proc *lp = pid2proc( loader_pid );
-	BLOG((false, "Waking up loader: pid=%ld wait_cond=%lx wait_q=%d", loader_pid, lp->wait_cond, lp->wait_q));
+	BLOG((false, "Waking up loader: pid=%ld:%lx wait_cond=%lx wait_q=%d", loader_pid, &loader_pid, lp->wait_cond, lp->wait_q));
 	/* wakeup loader */
 
-	//wake(WAIT_Q, (long)&loader_pid);
 	wake(WAIT_Q, lp->wait_cond );
 	}
-
+#else
+	wake(WAIT_Q, (long)&loader_pid);
+#endif
 	/* XXX todo -> module_exit */
 // 	display("kthread_exit...");
 
 	if (C.KBD_dev > 0)
 	{
 		long r;
-		BLOG((false, "Closing kbd dev:%ld", C.KBD_dev));
 		r = f_cntl(C.KBD_dev, (long)&KBD_dev_sg, TIOCSETN);
 		KERNEL_DEBUG("fcntl(TIOCSETN) -> %li", r);
 
diff -u -B -I '$Id' src.cvs/k_shutdown.c src.km/k_shutdown.c
--- src.cvs/k_shutdown.c	2010-01-04 23:31:11.000000000 +0100
+++ src.km/k_shutdown.c	2010-01-07 21:17:47.328125000 +0100
@@ -233,7 +233,7 @@
 	 */
 	if (v && v->handle && v->handle != C.P_handle)
 	{
-		BLOG((false, "Closing down vwk"));
+		BLOG((false, "Closing down vwk %d", v->handle));
 		v_clsvwk(v->handle);
 	}
 	/*
@@ -241,7 +241,7 @@
 	 */
 	if (C.P_handle)
 	{
-		BLOG((false, "Closing down physical vdi workstation"));
+		BLOG((false, "Closing down physical vdi workstation %d", C.P_handle));
 		vst_color(C.P_handle, G_BLACK);
 		vswr_mode(C.P_handle, MD_REPLACE);
 
@@ -261,6 +261,7 @@
 		 */
 #ifndef ST_ONLY
 		//if( C.fvdi_version == 0 )
+		if( C.P_handle > 0 && C.P_handle != v->handle )
 		{
 			unsigned long sc = 0, cm = 0;
 			int odbl;