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

Re: [MiNT] Xaloader patch, take #42



On 1 mar 2010, at 22.22, Miro Kropacek wrote:

Btw Pep, in case you aren't tired:

 #define DEFAULT        "xaaes.km"
 #define DEFAULT_68000  "xaaes000.km"
+#define DEFAULT_68000  "xaaes000.km"
#defining it only once is enough I think :P

No, I have no pride left whatsoever :) Yet another diff appended. 


--
MiKRO / Mystic Bytes
http://mikro.atari.org


--- ../xaloader.old/xaloader.c Fri Jul 13 23:33:02 2007
+++ xaloader.c Mon Mar  1 22:34:02 2010
@@ -10,6 +10,10 @@
 
 #define DEFAULT        "xaaes.km"
 #define DEFAULT_68000  "xaaes000.km"
+#define DEFAULT_68020  "xaaes020.km"
+#define DEFAULT_68030  "xaaes030.km"
+#define DEFAULT_68040  "xaaes040.km"
+#define DEFAULT_68060  "xaaes060.km"
 
 static void
 my_strlcpy(char *dst, const char *src, size_t n)
@@ -57,7 +61,9 @@
 }
 
 /*
- * - without an argument try to load xaaes.km from sysdir
+ * - without an argument:
+ *   - try to load xaaes.km from sysdir
+ *   - if xaaes.km is not available, try to load module based on CPU type
  * - with argument:
  *   - without a path separator try to load this from sysdir
  *   - with path separator go to this dir and load the module
@@ -141,15 +147,43 @@
  else
  {
  long cpu;
-
- name = DEFAULT;
-
+ char temp[384];
+
  /* if the system have a 68000 CPU we use the 68000 compiled
- * module
+ * module by default
  */
  r = Ssystem(S_GETCOOKIE, C__CPU, &cpu);
  if (r == 0 && cpu < 20)
  name = DEFAULT_68000;
+ else
+ name = DEFAULT;
+
+ my_strlcpy(temp, path, sizeof(path));
+ r = Dsetpath(temp);
+ r = Dgetpath(temp, 0);
+
+ my_strlcat(temp, "\\", sizeof(temp));
+ my_strlcat(temp, name, sizeof(temp));
+
+ fh = Fopen(temp, O_RDONLY);
+ if (fh < 0)
+ {
+ /* default kernel module not available, select module based on CPU type */
+ r = Ssystem(S_GETCOOKIE, C__CPU, &cpu);
+ if(r == 0)
+ {
+ switch(cpu)
+ {
+ case 20: name = DEFAULT_68020; break;
+ case 30: name = DEFAULT_68030; break;
+ case 40: name = DEFAULT_68040; break;
+ case 60: name = DEFAULT_68060; break;
+
+ default: break;
+ }
+ }
+ }
+ Fclose((int)fh);
  }
 
  /* change to the XaAES module directory */