From mint-bounce@lists.fishpool.fi Tue Jul 6 15:47:44 2010 Message-ID: <4C3387A2.6090204@freesbee.fr> Date: Tue, 06 Jul 2010 21:44:34 +0200 From: =?ISO-8859-1?Q?Vincent_Rivi=E8re?= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.2.4) Gecko/20100608 Thunderbird/3.1 MIME-Version: 1.0 To: mint@lists.fishpool.fi Subject: [MiNT] [patch] Line A for ColdFire Content-Type: multipart/mixed; boundary="------------030305050905080503070109" X-ecartis-version: Ecartis v1.0.0 Sender: mint-bounce@lists.fishpool.fi Errors-to: mint-bounce@lists.fishpool.fi X-original-sender: vincent.riviere@freesbee.fr Precedence: bulk List-help: List-unsubscribe: List-Id: X-List-ID: List-subscribe: List-owner: List-post: This is a multi-part message in MIME format. --------------030305050905080503070109 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Hello. I have tried to compile bash for ColdFire and it crashed because it uses=20 ncurses, which uses ioctl(TIOCGWINSZ), which uses... Line A. The Line A interface is problematic on ColdFire because all the opcodes=20 conflict with the MAC instructions, and do not trigger any exception. I=20 found a very simple solution: use the opcodes A92X instead of A00X. These= =20 opcodes are invalid on any ColdFire and trigger the standard Line A=20 exception. Then the OS has to keep only the 4 lower bits. EmuTOS and Fire= TOS=20 have already been patched to support this modified API on ColdFire, and i= t=20 works well. The attached patch adds support to the MiNTLib for this new Line A API fo= r=20 ColdFire. I have also included "memory" in the clobber lists to avoid any instructi= on=20 reordering by GCC. This happens sometimes when compiling for ColdFire, th= at=20 smells like a GCC bug. Alan, please commit this patch to the MiNTLib. --=20 Vincent Rivi=E8re --------------030305050905080503070109 Content-Type: text/plain; name="linea.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="linea.patch" diff -aurN -x CVS mintlib.orig/include/mint/linea.h mintlib/include/mint/linea.h --- mintlib.orig/include/mint/linea.h 2009-05-18 22:32:10.375000000 +0200 +++ mintlib/include/mint/linea.h 2010-07-06 21:09:03.171875000 +0200 @@ -757,6 +757,20 @@ /* Functions */ +#ifdef __mcoldfire__ + // On ColdFire V4e, the standard Line A opcodes + // conflict with some valid MAC instructions. + // Fortunately, the following range is always invalid + // and triggers the standard Line A exception. + // The ColdFire OS will keep only the last 4 bits + #define LINEA_OPCODE_BASE 0xa920 +#else + #define LINEA_OPCODE_BASE 0xa000 +#endif + #define ASM_LINEA3(opcode) ".word " #opcode + #define ASM_LINEA2(opcode) ASM_LINEA3(opcode) + #define ASM_LINEA(n) ASM_LINEA2(LINEA_OPCODE_BASE+n) + #ifdef __GNUC_INLINE__ #define linea0() \ @@ -767,10 +781,11 @@ \ __asm__ volatile \ ( \ - ".word 0xA000" \ + ASM_LINEA(0x0) \ : "=g"(__xaline), "=g"(__xfonts), "=g"(__xfuncs) /* outputs */ \ : /* inputs */ \ : __CLOBBER_RETURN("a0") __CLOBBER_RETURN("a1") __CLOBBER_RETURN("a2") "d0", "d1", "d2" /* clobbered regs */ \ + AND_MEMORY \ ); \ __aline = __xaline; \ __fonts = __xfonts; \ @@ -781,10 +796,11 @@ ({ \ __asm__ volatile \ ( \ - ".word 0xA001" \ + ASM_LINEA(0x1) \ : /* outputs */ \ : /* inputs */ \ : "d0", "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \ + AND_MEMORY \ ); \ }) @@ -793,10 +809,11 @@ register short retvalue __asm__ ("d0"); \ __asm__ volatile \ ( \ - ".word 0xA002" \ + ASM_LINEA(0x2) \ : "=g"(retvalue) /* outputs */ \ : /* inputs */ \ : __CLOBBER_RETURN("d0") "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \ + AND_MEMORY \ ); \ (int)retvalue; \ }) @@ -805,10 +822,11 @@ ({ \ __asm__ volatile \ ( \ - ".word 0xA003" \ + ASM_LINEA(0x3) \ : /* outputs */ \ : /* inputs */ \ : "d0", "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \ + AND_MEMORY \ ); \ }) @@ -816,10 +834,11 @@ ({ \ __asm__ volatile \ ( \ - ".word 0xA004" \ + ASM_LINEA(0x4) \ : /* outputs */ \ : /* inputs */ \ : "d0", "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \ + AND_MEMORY \ ); \ }) @@ -827,10 +846,11 @@ ({ \ __asm__ volatile \ ( \ - ".word 0xA005" \ + ASM_LINEA(0x5) \ : /* outputs */ \ : /* inputs */ \ : "d0", "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \ + AND_MEMORY \ ); \ }) @@ -838,10 +858,11 @@ ({ \ __asm__ volatile \ ( \ - ".word 0xA006" \ + ASM_LINEA(0x6) \ : /* outputs */ \ : /* inputs */ \ : "d0", "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \ + AND_MEMORY \ ); \ }) @@ -851,11 +872,12 @@ ( \ PUSH_SP("d2/a2/a6", 12) \ "movl %0,a6\n\t" \ - ".word 0xA007\n\t" \ + ASM_LINEA(0x7) "\n\t" \ POP_SP("d2/a2/a6", 12) \ : /* outputs */ \ : "r"(P) /* inputs */ \ : "d0", "d1", "a0", "a1" /* clobbered regs */ \ + AND_MEMORY \ ); \ }) @@ -863,10 +885,11 @@ ({ \ __asm__ volatile \ ( \ - ".word 0xA008" \ + ASM_LINEA(0x8) \ : /* outputs */ \ : /* inputs */ \ : "d0", "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \ + AND_MEMORY \ ); \ }) @@ -874,10 +897,11 @@ ({ \ __asm__ volatile \ ( \ - ".word 0xA009" \ + ASM_LINEA(0x9) \ : /* outputs */ \ : /* inputs */ \ : "d0", "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \ + AND_MEMORY \ ); \ }) @@ -885,10 +909,11 @@ ({ \ __asm__ volatile \ ( \ - ".word 0xA00A" \ + ASM_LINEA(0xa) \ : /* outputs */ \ : /* inputs */ \ : "d0", "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \ + AND_MEMORY \ ); \ }) @@ -896,10 +921,11 @@ ({ \ __asm__ volatile \ ( \ - ".word 0xA00B" \ + ASM_LINEA(0xb) \ : /* outputs */ \ : /* inputs */ \ : "d0", "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \ + AND_MEMORY \ ); \ }) @@ -909,11 +935,12 @@ ( \ "movl %0,a2\n\t" \ "movl a6,sp@-\n\t" \ - ".word 0xA00C\n\t" \ + ASM_LINEA(0xc) "\n\t" \ "movl sp@+,a6" \ : /* outputs */ \ : "g"(P) /* inputs */ \ : "d0", "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \ + AND_MEMORY \ ); \ }) @@ -927,11 +954,12 @@ "movl %2,a0\n\t" \ "movl %3,a2\n\t" \ "movl a6,sp@-\n\t" \ - ".word 0xA00D\n\t" \ + ASM_LINEA(0xd) "\n\t" \ "movl sp@+,a6" \ : /* outputs */ \ : "g"(x), "g"(y), "g"(sd), "g"(ss) /* inputs */ \ : "d0", "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \ + AND_MEMORY \ ); \ }) @@ -939,10 +967,11 @@ ({ \ __asm__ volatile \ ( \ - ".word 0xA00E" \ + ASM_LINEA(0xe) \ : /* outputs */ \ : /* inputs */ \ : "d0", "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \ + AND_MEMORY \ ); \ }) @@ -950,10 +979,11 @@ ({ \ __asm__ volatile \ ( \ - ".word 0xA00F" \ + ASM_LINEA(0xf) \ : /* outputs */ \ : /* inputs */ \ : "d0", "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \ + AND_MEMORY \ ); \ }) diff -aurN -x CVS mintlib.orig/mintlib/linea.c mintlib/mintlib/linea.c --- mintlib.orig/mintlib/linea.c 2009-05-18 22:32:10.406250000 +0200 +++ mintlib/mintlib/linea.c 2010-07-06 21:17:52.453125000 +0200 @@ -14,10 +14,11 @@ __asm__ volatile ( - ".word 0xA000" + ASM_LINEA(0x0) : "=g"(__xaline), "=g"(__xfonts), "=g"(__xfuncs) /* outputs */ : /* inputs */ : __CLOBBER_RETURN("a0") __CLOBBER_RETURN("a1") __CLOBBER_RETURN("a2") "d0", "d1", "d2" /* clobbered regs */ + AND_MEMORY ); __aline = __xaline; @@ -29,10 +30,11 @@ { __asm__ volatile ( - ".word 0xA001" + ASM_LINEA(0x1) : /* outputs */ : /* inputs */ : "d0", "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ + AND_MEMORY ); } @@ -42,10 +44,11 @@ __asm__ volatile ( - ".word 0xA002" + ASM_LINEA(0x2) : "=r"(retvalue) /* outputs */ : /* inputs */ : __CLOBBER_RETURN("d0") "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ + AND_MEMORY ); return (int) retvalue; @@ -55,10 +58,11 @@ { __asm__ volatile ( - ".word 0xA003" + ASM_LINEA(0x3) : /* outputs */ : /* inputs */ : "d0", "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ + AND_MEMORY ); } @@ -66,10 +70,11 @@ { __asm__ volatile ( - ".word 0xA004" + ASM_LINEA(0x4) : /* outputs */ : /* inputs */ : "d0", "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ + AND_MEMORY ); } @@ -77,10 +82,11 @@ { __asm__ volatile ( - ".word 0xA005" + ASM_LINEA(0x5) : /* outputs */ : /* inputs */ : "d0", "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ + AND_MEMORY ); } @@ -88,10 +94,11 @@ { __asm__ volatile ( - ".word 0xA006" + ASM_LINEA(0x6) : /* outputs */ : /* inputs */ : "d0", "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ + AND_MEMORY ); } @@ -101,11 +108,12 @@ ( PUSH_SP("d2/a2/a6", 12) "movl %0,a6\n\t" - ".word 0xA007\n\t" + ASM_LINEA(0x7) "\n\t" POP_SP("d2/a2/a6", 12) : /* outputs */ : "r"(P) /* inputs */ : "d0", "d1", "a0", "a1" /* clobbered regs */ + AND_MEMORY ); } @@ -113,10 +121,11 @@ { __asm__ volatile ( - ".word 0xA008" + ASM_LINEA(0x8) : /* outputs */ : /* inputs */ : "d0", "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ + AND_MEMORY ); } @@ -124,10 +133,11 @@ { __asm__ volatile ( - ".word 0xA009" + ASM_LINEA(0x9) : /* outputs */ : /* inputs */ : "d0", "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ + AND_MEMORY ); } @@ -135,10 +145,11 @@ { __asm__ volatile ( - ".word 0xA00A" + ASM_LINEA(0xa) : /* outputs */ : /* inputs */ : "d0", "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ + AND_MEMORY ); } @@ -146,10 +157,11 @@ { __asm__ volatile ( - ".word 0xA00B" + ASM_LINEA(0xb) : /* outputs */ : /* inputs */ : "d0", "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ + AND_MEMORY ); } @@ -158,10 +170,11 @@ __asm__ volatile ( "movl %0,a2\n\t" - ".word 0xA00C" + ASM_LINEA(0xc) : /* outputs */ : "r"(P) /* inputs */ : "d0", "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ + AND_MEMORY ); } @@ -173,10 +186,11 @@ "movw %1,d1\n\t" "movl %2,a0\n\t" "movl %3,a2\n\t" - ".word 0xA00D" + ASM_LINEA(0xd) : /* outputs */ : "r"((short)x), "r"((short)y), "r"(sd), "r"(ss) /* inputs */ : "d0", "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ + AND_MEMORY ); } @@ -184,10 +198,11 @@ { __asm__ volatile ( - ".word 0xA00E" + ASM_LINEA(0xe) : /* outputs */ : /* inputs */ : "d0", "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ + AND_MEMORY ); } @@ -195,9 +210,10 @@ { __asm__ volatile ( - ".word 0xA00F" + ASM_LINEA(0xf) : /* outputs */ : /* inputs */ : "d0", "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ + AND_MEMORY ); } --------------030305050905080503070109--