URL
https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk
Subversion Repositories openrisc_2011-10-31
Compare Revisions
- This comparison shows the changes necessary to convert path
/openrisc/tags/or1ksim/or1ksim-0.3.0/testbench/support
- from Rev 19 to Rev 21
- ↔ Reverse comparison
Rev 19 → Rev 21
/int.h
0,0 → 1,15
|
/* Number of interrupt handlers */ |
#define MAX_INT_HANDLERS 32 |
|
/* Handler entry */ |
struct ihnd { |
void (*handler)(void *); |
void *arg; |
}; |
|
/* Add interrupt handler */ |
int int_add(unsigned long vect, void (* handler)(void *), void *arg); |
|
/* Initialize routine */ |
int int_init(); |
int.h
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: support.h
===================================================================
--- support.h (nonexistent)
+++ support.h (revision 21)
@@ -0,0 +1,65 @@
+/* Support file for or32 tests. This file should is included
+ in each test. It calls main() function and add support for
+ basic functions */
+
+#ifndef SUPPORT_H
+#define SUPPORT_H
+
+#include
+#include
+#include
+
+#if OR1K
+//#include <_ansi.h>
+
+/* Register access macros */
+#define REG8(add) *((volatile unsigned char *)(add))
+#define REG16(add) *((volatile unsigned short *)(add))
+#define REG32(add) *((volatile unsigned long *)(add))
+
+void printf(const char *fmt, ...);
+
+/* For writing into SPR. */
+void mtspr(unsigned long spr, unsigned long value);
+
+/* For reading SPR. */
+unsigned long mfspr(unsigned long spr);
+
+#else /* OR1K */
+
+#include
+
+#endif /* OR1K */
+
+/* Function to be called at entry point - not defined here. */
+int main ();
+
+/* Prints out a value */
+void report(unsigned long value);
+
+/* return value by making a syscall */
+extern void exit (int i) __attribute__ ((__noreturn__));
+
+/* memcpy clone */
+extern void *memcpy (void *__restrict __dest,
+ __const void *__restrict __src, size_t __n);
+
+/* Timer functions */
+extern void start_timer(int);
+extern unsigned int read_timer(int);
+
+extern unsigned long excpt_buserr;
+extern unsigned long excpt_dpfault;
+extern unsigned long excpt_ipfault;
+extern unsigned long excpt_tick;
+extern unsigned long excpt_align;
+extern unsigned long excpt_illinsn;
+extern unsigned long excpt_int;
+extern unsigned long excpt_dtlbmiss;
+extern unsigned long excpt_itlbmiss;
+extern unsigned long excpt_range;
+extern unsigned long excpt_syscall;
+extern unsigned long excpt_break;
+extern unsigned long excpt_trap;
+
+#endif
support.h
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: Makefile.am
===================================================================
--- Makefile.am (nonexistent)
+++ Makefile.am (revision 21)
@@ -0,0 +1,29 @@
+# Makefile -- Makefile for cpu architecture independent simulation
+# Copyright (C) 1999 Damjan Lampret, lampret@opencores.org
+#
+# This file is part of OpenRISC 1000 Architectural Simulator.
+#
+# This program 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 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+
+##if OR1K_EXCEPT
+##OR1K_SUPPORT_S = except.S
+##else
+##OR1K_SUPPORT_S =
+##endif
+
+noinst_LIBRARIES = libsupport.a
+libsupport_a_SOURCES = support.c support.h int.c int.h
+## EXTRA_libsupport_a_SOURCES = except.S
Makefile.am
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: int.c
===================================================================
--- int.c (nonexistent)
+++ int.c (revision 21)
@@ -0,0 +1,79 @@
+/* This file is part of test microkernel for OpenRISC 1000. */
+/* (C) 2001 Simon Srot, srot@opencores.org */
+
+#include "support.h"
+#include "spr_defs.h"
+#include "int.h"
+
+#ifdef OR1K
+
+/* Interrupt handlers table */
+struct ihnd int_handlers[MAX_INT_HANDLERS];
+
+/* Initialize routine */
+int int_init()
+{
+ int i;
+
+ for(i = 0; i < MAX_INT_HANDLERS; i++) {
+ int_handlers[i].handler = 0;
+ int_handlers[i].arg = 0;
+ }
+
+ return 0;
+}
+
+/* Add interrupt handler */
+int int_add(unsigned long vect, void (* handler)(void *), void *arg)
+{
+ if(vect >= MAX_INT_HANDLERS)
+ return -1;
+
+ int_handlers[vect].handler = handler;
+ int_handlers[vect].arg = arg;
+
+ mtspr(SPR_PICMR, mfspr(SPR_PICMR) | (0x00000001L << vect));
+
+ return 0;
+}
+
+/* Disable interrupt */
+int int_disable(unsigned long vect)
+{
+ if(vect >= MAX_INT_HANDLERS)
+ return -1;
+
+ mtspr(SPR_PICMR, mfspr(SPR_PICMR) & ~(0x00000001L << vect));
+
+ return 0;
+}
+
+/* Enable interrupt */
+int int_enable(unsigned long vect)
+{
+ if(vect >= MAX_INT_HANDLERS)
+ return -1;
+
+ mtspr(SPR_PICMR, mfspr(SPR_PICMR) | (0x00000001L << vect));
+
+ return 0;
+}
+
+/* Main interrupt handler */
+void int_main()
+{
+ unsigned long picsr = mfspr(SPR_PICSR);
+ unsigned long i = 0;
+
+ mtspr(SPR_PICSR, 0);
+
+ while(i < 32) {
+ if((picsr & (0x01L << i)) && (int_handlers[i].handler != 0)) {
+ (*int_handlers[i].handler)(int_handlers[i].arg);
+ mtspr(SPR_PICSR, mfspr(SPR_PICSR) & ~(0x00000001L << i));
+ }
+ i++;
+ }
+}
+
+#endif
int.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: .cvsignore
===================================================================
--- .cvsignore (nonexistent)
+++ .cvsignore (revision 21)
@@ -0,0 +1,2 @@
+Makefile
+.deps
Index: support.c
===================================================================
--- support.c (nonexistent)
+++ support.c (revision 21)
@@ -0,0 +1,132 @@
+/* Support */
+
+#include "spr_defs.h"
+#include "support.h"
+#include "int.h"
+
+#if OR1K
+void excpt_dummy();
+void int_main();
+
+unsigned long excpt_buserr = (unsigned long) excpt_dummy;
+unsigned long excpt_dpfault = (unsigned long) excpt_dummy;
+unsigned long excpt_ipfault = (unsigned long) excpt_dummy;
+unsigned long excpt_tick = (unsigned long) excpt_dummy;
+unsigned long excpt_align = (unsigned long) excpt_dummy;
+unsigned long excpt_illinsn = (unsigned long) excpt_dummy;
+unsigned long excpt_int = (unsigned long) int_main;
+unsigned long excpt_dtlbmiss = (unsigned long) excpt_dummy;
+unsigned long excpt_itlbmiss = (unsigned long) excpt_dummy;
+unsigned long excpt_range = (unsigned long) excpt_dummy;
+unsigned long excpt_syscall = (unsigned long) excpt_dummy;
+unsigned long excpt_break = (unsigned long) excpt_dummy;
+unsigned long excpt_trap = (unsigned long) excpt_dummy;
+
+
+/* Start function, called by reset exception handler. */
+void reset ()
+{
+ int i = main();
+ exit (i);
+}
+
+/* return value by making a syscall */
+void exit (int i)
+{
+ __asm__ __volatile__ ("l.add r3,r0,%0\n\t"
+ "l.nop %1": : "r" (i), "K" (NOP_EXIT));
+ while (1);
+}
+
+/* activate printf support in simulator */
+void printf(const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ __asm__ __volatile__ ("l.addi\tr3,%0,0\n\t"
+ "l.addi\tr4,%1,0\n\t"
+ "l.nop %2"
+ : : "r" (fmt), "r" (args), "K" (NOP_PRINTF)
+ : "r3", "r4");
+}
+
+/* print long */
+void report(unsigned long value)
+{
+ __asm__ __volatile__ ("l.addi\tr3,%0,0\n\t"
+ "l.nop %1": : "r" (value), "K" (NOP_REPORT));
+}
+
+/* just to satisfy linker */
+void __main()
+{
+}
+
+/* start_TIMER */
+void start_timer(int x)
+{
+}
+
+/* read_TIMER */
+/* Returns a value since started in uS */
+unsigned int read_timer(int x)
+{
+ unsigned long count = 0;
+
+ /* Read the Time Stamp Counter */
+/* asm("simrdtsc %0" :"=r" (count)); */
+ /*asm("l.sys 201"); */
+ return count;
+}
+
+/* For writing into SPR. */
+void mtspr(unsigned long spr, unsigned long value)
+{
+ __asm__ __volatile__ ("l.mtspr\t\t%0,%1,0": : "r" (spr), "r" (value));
+}
+
+/* For reading SPR. */
+unsigned long mfspr(unsigned long spr)
+{
+ unsigned long value;
+ __asm__ __volatile__ ("l.mfspr\t\t%0,%1,0" : "=r" (value) : "r" (spr));
+ return value;
+}
+
+#else
+void report(unsigned long value)
+{
+ printf("report(0x%x);\n", (unsigned) value);
+}
+
+/* start_TIMER */
+void start_timer(int tmrnum)
+{
+}
+
+/* read_TIMER */
+/* Returns a value since started in uS */
+unsigned int read_timer(int tmrnum)
+{
+ struct timeval tv;
+ struct timezone tz;
+
+ gettimeofday(&tv, &tz);
+
+ return(tv.tv_sec*1000000+tv.tv_usec);
+}
+
+#endif
+
+void *memcpy (void *__restrict dstvoid,
+ __const void *__restrict srcvoid, size_t length)
+{
+ char *dst = dstvoid;
+ const char *src = (const char *) srcvoid;
+
+ while (length--)
+ *dst++ = *src++;
+ return dst;
+}
+
+void excpt_dummy() {}
support.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property