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

[MiNT] Patch: Firebee software poweroff



This patch enables MiNT to power off the Firebee when
Shutdown(SHUT_POWER) is called. It requires the latest (january 2012)
PIC firmware to work, but does no harm with previous versions.

Alan, please review and (hopefully!) apply this patch.

Jo Even

-----------------8<-------------------

Index: sys/cookie.h
===================================================================
RCS file: /mint/freemint/sys/cookie.h,v
retrieving revision 1.17
diff -a -u -r1.17 cookie.h
--- sys/cookie.h	11 Nov 2011 00:13:40 -0000	1.17
+++ sys/cookie.h	15 Dec 2013 18:17:26 -0000
@@ -57,6 +57,7 @@
 # define COOKIE__NET	0x5f4e4554L
 # define COOKIE__IDT	0x5f494454L
 # define COOKIE__AKP	0x5f414b50L
+# define COOKIE__CF_	0x5f43465fL // FireTOS on Firebee
 
 /* MiNT cookies (MiNT is now TOS) */
 # define COOKIE_MiNT	0x4d694e54L
Index: sys/arch/halt.c
===================================================================
RCS file: /mint/freemint/sys/arch/halt.c,v
retrieving revision 1.5
diff -a -u -r1.5 halt.c
--- sys/arch/halt.c	13 Jul 2007 21:32:49 -0000	1.5
+++ sys/arch/halt.c	15 Dec 2013 18:17:27 -0000
@@ -49,6 +49,10 @@
 
 # include "aranym.h"
 
+#define __MBAR ((volatile unsigned char*)0xff000000)
+#define MCF_PSC3_PSCTB_8BIT (*(volatile unsigned
long*)(&__MBAR[0x890c]))
+#define WRITEPIC(b) *(volatile unsigned char*)(&MCF_PSC3_PSCTB_8BIT) =
b
+
 void
 hw_poweroff(void)
 {
@@ -56,15 +60,25 @@
 	nf_shutdown();
 # else
 	/* CT60 poweroff */
-	unsigned long int dummy;
+	unsigned long int cvalue;
 
-	if (get_cookie(NULL, COOKIE_CT60, &dummy) == E_OK)
+	if (get_cookie(NULL, COOKIE_CT60, &cvalue) == E_OK)
 	{
 		/* any write to that address causes poweroff */
 		*(volatile char *) 0xFA800000L = 1;
 	
 		/* does not return */ 
 	}
+
+	/* Firebee poweroff */
+	if (get_cookie(NULL, COOKIE__CF_, &cvalue) == E_OK)
+	if (get_cookie(NULL, COOKIE__MCH, &cvalue) == E_OK && (cvalue &
FALCON))
+	{
+		WRITEPIC(0x0c); // Header
+		WRITEPIC('O');
+		WRITEPIC('F');
+		WRITEPIC('F');
+	}
 # endif
 }
 
Index: sys/cookie.h
===================================================================
RCS file: /mint/freemint/sys/cookie.h,v
retrieving revision 1.17
diff -a -u -r1.17 cookie.h
--- sys/cookie.h	11 Nov 2011 00:13:40 -0000	1.17
+++ sys/cookie.h	15 Dec 2013 18:17:26 -0000
@@ -57,6 +57,7 @@
 # define COOKIE__NET	0x5f4e4554L
 # define COOKIE__IDT	0x5f494454L
 # define COOKIE__AKP	0x5f414b50L
+# define COOKIE__CF_	0x5f43465fL // FireTOS on Firebee
 
 /* MiNT cookies (MiNT is now TOS) */
 # define COOKIE_MiNT	0x4d694e54L
Index: sys/arch/halt.c
===================================================================
RCS file: /mint/freemint/sys/arch/halt.c,v
retrieving revision 1.5
diff -a -u -r1.5 halt.c
--- sys/arch/halt.c	13 Jul 2007 21:32:49 -0000	1.5
+++ sys/arch/halt.c	15 Dec 2013 18:17:27 -0000
@@ -49,6 +49,10 @@
 
 # include "aranym.h"
 
+#define __MBAR ((volatile unsigned char*)0xff000000)
+#define MCF_PSC3_PSCTB_8BIT (*(volatile unsigned long*)(&__MBAR[0x890c]))
+#define WRITEPIC(b) *(volatile unsigned char*)(&MCF_PSC3_PSCTB_8BIT) = b
+
 void
 hw_poweroff(void)
 {
@@ -56,15 +60,25 @@
 	nf_shutdown();
 # else
 	/* CT60 poweroff */
-	unsigned long int dummy;
+	unsigned long int cvalue;
 
-	if (get_cookie(NULL, COOKIE_CT60, &dummy) == E_OK)
+	if (get_cookie(NULL, COOKIE_CT60, &cvalue) == E_OK)
 	{
 		/* any write to that address causes poweroff */
 		*(volatile char *) 0xFA800000L = 1;
 	
 		/* does not return */ 
 	}
+
+	/* Firebee poweroff */
+	if (get_cookie(NULL, COOKIE__CF_, &cvalue) == E_OK)
+	if (get_cookie(NULL, COOKIE__MCH, &cvalue) == E_OK && (cvalue & FALCON))
+	{
+		WRITEPIC(0x0c); // Header
+		WRITEPIC('O');
+		WRITEPIC('F');
+		WRITEPIC('F');
+	}
 # endif
 }