--- /dev/null
+/***************************************************************************\r
+ * Copyright (C) 2007 by Pavel Chromy *\r
+ * chromy@asix.cz *\r
+ * *\r
+ * This program is free software; you can redistribute it and/or modify *\r
+ * it under the terms of the GNU General Public License as published by *\r
+ * the Free Software Foundation; either version 2 of the License, or *\r
+ * (at your option) any later version. *\r
+ * *\r
+ * This program is distributed in the hope that it will be useful, *\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *\r
+ * GNU General Public License for more details. *\r
+ * *\r
+ * You should have received a copy of the GNU General Public License *\r
+ * along with this program; if not, write to the *\r
+ * Free Software Foundation, Inc., *\r
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *\r
+ ***************************************************************************/\r
+#include "dcc.h"\r
+\r
+\r
+/* debug channel read (debugger->MCU) */\r
+uint32 dcc_rd(void)\r
+{\r
+ volatile uint32 dcc_reg;\r
+\r
+ do {\r
+ asm volatile ("mrc p14, 0, %0, C0, C0" : "=r" (dcc_reg) : );\r
+ } while ((dcc_reg&1)==0);\r
+\r
+ asm volatile ("mrc p14, 0, %0, C1, C0" : "=r" (dcc_reg) : );\r
+ return dcc_reg;\r
+}\r
+\r
+\r
+/* debug channel write (MCU->debugger) */\r
+int dcc_wr(uint32 data)\r
+{\r
+ volatile uint32 dcc_reg;\r
+\r
+ do {\r
+ asm volatile ("mrc p14, 0, %0, C0, C0" : "=r" (dcc_reg) : );\r
+ /* operation controled by master, cancel operation\r
+ upon reception of data for immediate response */\r
+ if (dcc_reg&1) return -1;\r
+ } while (dcc_reg&2);\r
+\r
+ asm volatile ("mcr p14, 0, %0, C1, C0" : : "r" (data));\r
+ return 0;\r
+}\r