[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r7306 - in usrp2/trunk/fpga/opencores/aemb/sw: CVS c c
From: |
matt |
Subject: |
[Commit-gnuradio] r7306 - in usrp2/trunk/fpga/opencores/aemb/sw: CVS c c/CVS |
Date: |
Sun, 30 Dec 2007 01:03:16 -0700 (MST) |
Author: matt
Date: 2007-12-30 01:03:07 -0700 (Sun, 30 Dec 2007)
New Revision: 7306
Modified:
usrp2/trunk/fpga/opencores/aemb/sw/CVS/Entries
usrp2/trunk/fpga/opencores/aemb/sw/c/CVS/Entries
usrp2/trunk/fpga/opencores/aemb/sw/c/aeMB_testbench.c
usrp2/trunk/fpga/opencores/aemb/sw/c/libaemb.h
Log:
catching up with Shawn
Modified: usrp2/trunk/fpga/opencores/aemb/sw/CVS/Entries
===================================================================
--- usrp2/trunk/fpga/opencores/aemb/sw/CVS/Entries 2007-12-30 07:59:55 UTC
(rev 7305)
+++ usrp2/trunk/fpga/opencores/aemb/sw/CVS/Entries 2007-12-30 08:03:07 UTC
(rev 7306)
@@ -1,2 +1,2 @@
D/c////
-/gccrom/1.12/Wed Dec 12 03:12:13 2007//
+/gccrom/1.12/Wed Dec 12 20:18:00 2007//
Modified: usrp2/trunk/fpga/opencores/aemb/sw/c/CVS/Entries
===================================================================
--- usrp2/trunk/fpga/opencores/aemb/sw/c/CVS/Entries 2007-12-30 07:59:55 UTC
(rev 7305)
+++ usrp2/trunk/fpga/opencores/aemb/sw/c/CVS/Entries 2007-12-30 08:03:07 UTC
(rev 7306)
@@ -1,3 +1,3 @@
-/aeMB_testbench.c/1.13/Wed Dec 12 03:12:13 2007//
-/libaemb.h/1.1/Tue Dec 11 00:44:04 2007//
+/aeMB_testbench.c/1.14/Sun Dec 30 08:00:31 2007//
+/libaemb.h/1.3/Sun Dec 30 08:00:32 2007//
D
Modified: usrp2/trunk/fpga/opencores/aemb/sw/c/aeMB_testbench.c
===================================================================
--- usrp2/trunk/fpga/opencores/aemb/sw/c/aeMB_testbench.c 2007-12-30
07:59:55 UTC (rev 7305)
+++ usrp2/trunk/fpga/opencores/aemb/sw/c/aeMB_testbench.c 2007-12-30
08:03:07 UTC (rev 7306)
@@ -1,72 +1,28 @@
-/*
- * $Id: aeMB_testbench.c,v 1.13 2007/12/11 00:44:31 sybreon Exp $
- *
- * AEMB Function Verification C Testbench
- * Copyright (C) 2004-2007 Shawn Tan Ser Ngiap <address@hidden>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- *
- * DESCRIPTION
- * It tests a whole gamut of operations and is tightly linked to the
- * ae68_testbench.v testbench module for verification.
- *
- * HISTORY
- * $Log: aeMB_testbench.c,v $
- * Revision 1.13 2007/12/11 00:44:31 sybreon
- * Modified for AEMB2
- *
- * Revision 1.12 2007/11/18 19:41:45 sybreon
- * Minor simulation fixes.
- *
- * Revision 1.11 2007/11/14 23:41:06 sybreon
- * Fixed minor interrupt test typo.
- *
- * Revision 1.10 2007/11/14 22:12:02 sybreon
- * Added interrupt test routine.
- *
- * Revision 1.9 2007/11/09 20:51:53 sybreon
- * Added GET/PUT support through a FSL bus.
- *
- * Revision 1.8 2007/11/03 08:40:18 sybreon
- * Minor code cleanup.
- *
- * Revision 1.7 2007/11/02 18:32:19 sybreon
- * Enable MSR_IE with software.
- *
- * Revision 1.6 2007/04/30 15:57:10 sybreon
- * Removed byte acrobatics.
- *
- * Revision 1.5 2007/04/27 15:17:59 sybreon
- * Added code documentation.
- * Added new tests that test floating point, modulo arithmetic and
multiplication/division.
- *
- * Revision 1.4 2007/04/25 22:15:05 sybreon
- * Added support for 8-bit and 16-bit data types.
- *
- * Revision 1.3 2007/04/04 14:09:04 sybreon
- * Added initial interrupt/exception support.
- *
- * Revision 1.2 2007/04/04 06:07:45 sybreon
- * Fixed C code bug which passes the test
- *
- * Revision 1.1 2007/03/09 17:41:57 sybreon
- * initial import
- *
- */
+/* $Id: aeMB_testbench.c,v 1.14 2007/12/28 21:44:04 sybreon Exp $
+**
+** AEMB Function Verification C Testbench
+** Copyright (C) 2004-2007 Shawn Tan Ser Ngiap <address@hidden>
+**
+** This file is part of AEMB.
+**
+** AEMB is free software: you can redistribute it and/or modify it
+** under the terms of the GNU General Public License as published by
+** the Free Software Foundation, either version 3 of the License, or
+** (at your option) any later version.
+**
+** AEMB is distributed in the hope that it will be useful, but WITHOUT
+** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+** or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+** License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with AEMB. If not, see <http://www.gnu.org/licenses/>.
+*/
+#include <malloc.h>
+#include <errno.h>
+#include <reent.h>
+
#include "libaemb.h"
/**
@@ -98,7 +54,8 @@
int int_test ()
{
// Delay loop until hardware interrupt triggers
- for (volatile int i=0; i < 999; i++) {
+ volatile int i;
+ for (i=0; i < 999; i++) {
if (service == 0) return 0;
};
@@ -307,6 +264,27 @@
return 0;
}
+// static int errnum;
+/*
+int *__errno ()
+{
+ return &_REENT->_errno;
+ // return &errnum;
+}
+*/
+
+int malloc_test()
+{
+ void *alloc;
+
+ alloc = (void *)malloc(256); // allocate 32 bytes
+
+ if (alloc == NULL)
+ return -1;
+ else
+ return (int) alloc;
+}
+
/**
MAIN TEST PROGRAMME
@@ -322,12 +300,24 @@
// Number of each test to run
int max = 10;
+ // lock T0 if it's multi-threaded
+ /*
+ if ((aemb_isthreaded() == 0) && (aemb_isthread1() != 0)) {
+ while (1) {
+ asm volatile ("nop;");
+ }
+ }
+ */
+
// Enable Global Interrupts
aemb_enable_interrupt();
// INT TEST
//if (int_test() == -1) { *mpi = 0x4641494C; }
+ // TEST MALLOC
+ if (malloc_test() == -1) { *mpi = 0x4641494C; }
+
// FSL TEST
//if (fsl_test() == -1) { *mpi = 0x4641494C; }
@@ -346,3 +336,50 @@
// ALL PASSED
return 0;
}
+
+/*
+ HISTORY
+ $Log: aeMB_testbench.c,v $
+ Revision 1.14 2007/12/28 21:44:04 sybreon
+ Added malloc() test
+
+ Revision 1.13 2007/12/11 00:44:31 sybreon
+ Modified for AEMB2
+
+ Revision 1.12 2007/11/18 19:41:45 sybreon
+ Minor simulation fixes.
+
+ Revision 1.11 2007/11/14 23:41:06 sybreon
+ Fixed minor interrupt test typo.
+
+ Revision 1.10 2007/11/14 22:12:02 sybreon
+ Added interrupt test routine.
+
+ Revision 1.9 2007/11/09 20:51:53 sybreon
+ Added GET/PUT support through a FSL bus.
+
+ Revision 1.8 2007/11/03 08:40:18 sybreon
+ Minor code cleanup.
+
+ Revision 1.7 2007/11/02 18:32:19 sybreon
+ Enable MSR_IE with software.
+
+ Revision 1.6 2007/04/30 15:57:10 sybreon
+ Removed byte acrobatics.
+
+ Revision 1.5 2007/04/27 15:17:59 sybreon
+ Added code documentation.
+ Added new tests that test floating point, modulo arithmetic and
multiplication/division.
+
+ Revision 1.4 2007/04/25 22:15:05 sybreon
+ Added support for 8-bit and 16-bit data types.
+
+ Revision 1.3 2007/04/04 14:09:04 sybreon
+ Added initial interrupt/exception support.
+
+ Revision 1.2 2007/04/04 06:07:45 sybreon
+ Fixed C code bug which passes the test
+
+ Revision 1.1 2007/03/09 17:41:57 sybreon
+ initial import
+*/
Modified: usrp2/trunk/fpga/opencores/aemb/sw/c/libaemb.h
===================================================================
--- usrp2/trunk/fpga/opencores/aemb/sw/c/libaemb.h 2007-12-30 07:59:55 UTC
(rev 7305)
+++ usrp2/trunk/fpga/opencores/aemb/sw/c/libaemb.h 2007-12-30 08:03:07 UTC
(rev 7306)
@@ -1,4 +1,4 @@
-/* $Id: libaemb.h,v 1.1 2007/12/11 00:44:04 sybreon Exp $
+/* $Id: libaemb.h,v 1.3 2007/12/16 03:26:37 sybreon Exp $
**
** AEMB2 CUSTOM LIBRARY
**
@@ -23,16 +23,31 @@
#ifndef LIBAEMB_H
#define LIBAEMB_H
-#define AEMB_TXE 0x10000000
-#define AEMB_TX0 0x20000000
-#define AEMB_TX1 0x40000000
-#define AEMB_BIP 0x00000008
+#define AEMB_TXE 0x0100
+#define AEMB_TXP 0x0400
+#define AEMB_TX0 0x0300
+#define AEMB_TX1 0x0700
+#define AEMB_MSK 0x0F00
-void aemb_reboot () asm ("_program_init");
+#define AEMB_BIP 0x0008
+#define AEMB_CCC 0x0004
+#define AEMB_ITE 0x0002
+#define AEMB_BLE 0x0001
+
+
+// Linker symbols
+extern void* _STACK_SIZE;
+extern void* _stack_end;
+
+
+void aemb_hook_init () asm ("_program_init");
+void aemb_hook_clean () asm ("_program_clean");
+
inline void aemb_enable_interrupt ();
inline void aemb_disable_interrupt ();
inline int aemb_isthread1();
inline int aemb_isthread0();
+inline int aemb_isthreaded();
/*!
* Assembly macro to enable MSR_IE
@@ -64,97 +79,140 @@
/*!
* Bootstrap Hook Override
-
-* It re-sizes the stack, allocates half to each thread and reboots.
*/
-void aemb_reboot ()
+void aemb_hook_init ()
{
- asm volatile (// Checks for TXE & BIP flags
- "mfs r4, rmsr;"
- "andi r3, r4, 0x10000008;"
- "andi r6, r4, 0x40000000;"
- "xori r18, r3, 0x10000000;"
- "beqi r18, 20;"
- "andi r4, r4, -9;"
- "mts rmsr, r4;"
+ int msr, tmp;
+ int stk_end, stk_siz;
- // Returns when TXE=0 || BIP=1
- "rtsd r15, 8;"
- "nop;"
+ /*
+ // Check to see if hardware threads are enabled
+ if (((msr & AEMB_TXE) != AEMB_TXE) ||
+ // Check to see if second thread is started
+ ((msr & AEMB_TX1) == AEMB_TX1)) return;
+ */
+ //return;
+ asm volatile ("mfs %0, rmsr;"
+ // Check for BIP
+ "andi %1, %0, %5;"
+ "xori %1, %1, %5;"
+ "beqi %1, 44;"
- // Calculate new stack
- "addik r3, r0, _STACK_SIZE;"
- "addik r5, r0, _stack;"
- "beqid r6, 12;"
- "sra r3, r3;"
- "rsubk r5, r3, r5;"
- "addik r5, r5, -16;"
+ // Check for TXE
+ "andi %1, %0, %2;"
+ "xori %1, %1, %2;"
+ "bnei %1, 36;"
- // Re-allocate stack
- "or r1, r0, r5;"
- "ori r4, r4, 8;"
- "mts rmsr, r4;"
+ // Check for TX1
+ "andi %1, %0, %3;"
+ "xori %1, %1, %3;"
+ "beqi %1, 20;"
+
+ // reallocate stack pointer for T0
+ "ori %1, r0, %4;"
+ "sra %1, %1;"
+ "rsubk r1, %1, r1;"
- // Reboot
- "brlid r15, _crtinit;"
+ // reboot the machine
+ //"brki r0, _crtinit;"
+ "brid 0;"
"nop;"
- "brai exit;"
- );
+
+ // clear BIP
+ "andni %1, %0, %5;"
+ "mts rmsr, %1;"
+
+ :"=r"(msr), "=r"(tmp)
+ :"i"(AEMB_TXE), "i"(AEMB_TX1), "i"(&_STACK_SIZE), "i"(AEMB_BIP)
+ );
+
}
-/*
-void aemb_reboot ()
-{
+/*!
+ Undo the changes made by programme init
+*/
+
+void aemb_hook_clean ()
+{
+ int msr, tmp;
int stk_end, stk_siz;
- int msr, tmp;
-
- asm volatile ("mfs %0, rmsr;":"=r"(msr));
-
- if ((msr & AEMB_BIP) || !(msr & AEMB_TXE))
- {
- msr &= ~AEMB_BIP;
- asm volatile ("mts rmsr, %0;"::"r"(msr));
- }
- else
- {
- asm ("la %0, r0, _stack;" : "=r"(stk_end));
- asm ("la %0, r0, _STACK_SIZE;" : "=r"(stk_siz));
- if (msr & AEMB_TX1) stk_end -= (stk_siz >> 1);
+ /*
+ // Check to see if hardware threads are enabled
+ if (((msr & AEMB_TXE) != AEMB_TXE) ||
+ // Check to see if second thread is started
+ ((msr & AEMB_TX1) == AEMB_TX1)) return;
+ */
+ return;
+ asm volatile ("mfs %0, rmsr;"
+ "andi %1, %0, %2;"
+ "xori %1, %1, %2;"
+ "bnei %1, 28;"
+ "andi %1, %0, %3;"
+ "xori %1, %1, %3;"
+ "beqi %1, 16;"
+
+ // reallocate stack pointer for T0
+ "ori %1, r0, %4;"
+ "sra %1, %1;"
+ "addk r1, %1, r1;"
- stk_end -= 16;
+ :"=r"(msr), "=r"(tmp)
+ :"i"(AEMB_TXE), "i"(AEMB_TX1), "i"(&_STACK_SIZE)
+ );
- asm ("or r1, r0, %0;" :: "r"(stk_end));
+
+}
- msr |= AEMB_BIP;
- asm volatile ("mts rmsr, %0;"::"r"(msr));
+/* Checks if it's T1, and returns 0 if true */
- asm ("brlid r15, _crtinit;"
- "nop;"
- "brai exit;"
- );
- }
-}
-*/
-
int aemb_isthread1 ()
{
- int msr;
- asm volatile ("mfs %0, rmsr;":"=r"(msr));
- return (msr & AEMB_TX1);
+ int msr, tmp, res;
+ asm volatile ("mfs %0, rmsr;"
+ "andi %1, %0, %3;"
+ "xori %1, %1, %3;"
+ :"=r"(msr), "=r"(tmp)
+ :"i"(AEMB_TXE), "i"(AEMB_TXP)
+ );
+ return tmp;
}
+/* Checks if it's T0, and returns 0 if true */
+
int aemb_isthread0 ()
{
- int msr;
- asm volatile ("mfs %0, rmsr;":"=r"(msr));
- return (msr & AEMB_TX0);
+ int msr, tmp, res;
+ asm volatile ("mfs %0, rmsr;"
+ "andi %1, %0, %3;"
+ "xori %1, %1, %2;"
+ :"=r"(msr), "=r"(tmp)
+ :"i"(AEMB_TXP), "i"(AEMB_MSK)
+ );
+ return tmp;
}
+/* Checks if TXE is available, and returns 0 if true */
+
+int aemb_isthreaded ()
+{
+ int msr, tmp, res;
+ asm volatile ("mfs %0, rmsr;"
+ "andi %1, %0, %2;"
+ "xori %1, %1, %2;"
+ :"=r"(msr), "=r"(tmp)
+ :"i"(AEMB_TXE), "i"(AEMB_MSK)
+ );
+ return tmp;
+}
+
#endif
/* $Log: libaemb.h,v $
+/* Revision 1.3 2007/12/16 03:26:37 sybreon
+/* Made T0 loop.
+/*
/* Revision 1.1 2007/12/11 00:44:04 sybreon
/* initial import
/* */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r7306 - in usrp2/trunk/fpga/opencores/aemb/sw: CVS c c/CVS,
matt <=