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

Re: [MiNT] [PATCH] Use FireTOS exported Pure C patcher



On 28/02/2013 10:36, David Gálvez wrote:
I tested also Resource Master, that I think it's compiled also with Pure C.

Resource Master is indeed a good testcase. I found it in the official FreeMiNT setup for the FireBee. Without any patch, it hangs at startup.

There was a big bug in the patch. get_toscookie() returns 0 on success, so the internal patcher was still used with new FireTOS (while it probably crashed with old FireTOS).

Please commit the attached patch.
I tested it with the new FireTOS beta from 03/02/2013, it works fine.

However, even if I double checked that the FireTOS exported routine was really called, I didn't see any change from the internal FreeMiNT routine. I even wrote testcases for move.b -(sp) and Line A (posted on the ACP mailing list), both fails with any patcher. This demonstrate how limited is the patch solution. Anyway, it's up to FireTOS to improve the patcher, now.

BTW: Is there still a problem with shel_write()?

--
Vincent Rivière
--- freemint-1.18.orig/sys/memory.c	2013-02-08 00:18:13.281250000 +0100
+++ freemint-1.18/sys/memory.c	2013-03-02 17:22:58.398323000 +0100
@@ -13,6 +13,7 @@
 
 # include "memory.h"
 # include "global.h"
+# include "cookie.h"
 
 # include "libkern/libkern.h"
 # include "mint/basepage.h"
@@ -1622,7 +1623,18 @@
 		 * emulated via illegal instruction handler on ColdFire,
 		 * so they require to be dynamically patched.
 		 */
-		patch_memset_purec(b);
+		static void (*coldfire_purec_patcher)(BASEPAGE*) = NULL;
+
+		if (coldfire_purec_patcher == NULL)
+		{
+			ulong pexe = NULL;
+			if (get_toscookie(0x50455845L, &pexe) == 0 && pexe != NULL)
+				coldfire_purec_patcher = (void (*)(BASEPAGE*))pexe;  // Patcher exported from FireTOS.
+			else
+				coldfire_purec_patcher = patch_memset_purec; // Fallback to internal MiNT patcher.
+		}
+
+		coldfire_purec_patcher(b);
 	}
 #endif