This allows the use of these functions in other modules without linking
against libbase.
---
 software/include/base/irq.h |   48 +++++++++++++++++++++++++++++------
 software/libbase/Makefile   |    2 +-
 software/libbase/irq.S      |   58 -------------------------------------------
 3 files changed, 41 insertions(+), 67 deletions(-)
 delete mode 100644 software/libbase/irq.S

diff --git a/software/include/base/irq.h b/software/include/base/irq.h
index 307426c..0332448 100644
--- a/software/include/base/irq.h
+++ b/software/include/base/irq.h
@@ -18,13 +18,45 @@
 #ifndef __IRQ_H
 #define __IRQ_H
 
-void irq_enable(unsigned int en);
-void irq_setmask(unsigned int mask);
-unsigned int irq_getmask();
-unsigned int irq_pending();
-void irq_ack(unsigned int mask);
-
-unsigned int irq_getie();
-void irq_setie(unsigned int ie);
+static inline void irq_enable(unsigned int en)
+{
+       __asm__ __volatile__("wcsr IE, %0" : : "r" (en));
+}
+
+static inline unsigned int irq_getmask()
+{
+       unsigned int mask;
+       __asm__ __volatile__("rcsr %0, IM" : "=r" (mask));
+       return mask;
+}
+
+static inline void irq_setmask(unsigned int mask)
+{
+       __asm__ __volatile__("wcsr IM, %0" : : "r" (mask));
+}
+
+static inline unsigned int irq_pending()
+{
+       unsigned int pending;
+       __asm__ __volatile__("rcsr %0, IP" : "=r" (pending));
+       return pending;
+}
+
+static inline void irq_ack(unsigned int mask)
+{
+       __asm__ __volatile__("wcsr IP, %0" : : "r" (mask));
+}
+
+static inline unsigned int irq_getie()
+{
+       unsigned int ie;
+       __asm__ __volatile__("rcsr %0, IE" : "=r" (ie));
+       return ie;
+}
+
+static inline void irq_setie(unsigned int ie)
+{
+       __asm__ __volatile__("wcsr IE, %0" : : "r" (ie));
+}
 
 #endif /* __IRQ_H */
diff --git a/software/libbase/Makefile b/software/libbase/Makefile
index 6072ed9..d85f7f3 100644
--- a/software/libbase/Makefile
+++ b/software/libbase/Makefile
@@ -1,7 +1,7 @@
 MMDIR=../..
 include $(MMDIR)/software/include.mak
 
-OBJECTS_ALL=divsi3.o libc.o crc16.o crc32.o console.o blockdev.o fatfs.o 
system.o board.o irq.o uart.o
+OBJECTS_ALL=divsi3.o libc.o crc16.o crc32.o console.o blockdev.o fatfs.o 
system.o board.o uart.o
 OBJECTS=$(OBJECTS_ALL) softfloat.o softfloat-glue.o vsnprintf.o atof.o malloc.o
 OBJECTS_LIGHT=$(OBJECTS_ALL) vsnprintf-nofloat.o
 
diff --git a/software/libbase/irq.S b/software/libbase/irq.S
deleted file mode 100644
index 0fa19c5..0000000
--- a/software/libbase/irq.S
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Milkymist VJ SoC (Software)
- * Copyright (C) 2007, 2008, 2009 Sebastien Bourdeauducq
- *
- * 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, version 3 of the License.
- *
- * 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, see <http://www.gnu.org/licenses/>.
- */
-
-.section .text, "ax", @progbits
-.global irq_enable, irq_isenabled, irq_setmask, irq_getmask, irq_pending
-.global irq_ack, irq_getie, irq_setie
-
-/* Parameter: 1=enable, 0=disable */
-irq_enable:
-       wcsr    IE, r1
-       ret
-
-/* Parameter: the mask */
-irq_setmask:
-       wcsr    IM, r1
-       ret
-
-/* No parameter */
-/* Return value: the mask */
-irq_getmask:
-       rcsr    r1, IM
-       ret
-
-/* No parameter */
-/* Return value: pending IRQs */
-irq_pending:
-       rcsr    r1, IP
-       ret
-
-/* Parameter: the mask */
-irq_ack:
-       wcsr    IP, r1
-       ret
-
-/* No parameter */
-/* Return value: IE */
-irq_getie:
-       rcsr    r1, IE
-       ret
-
-/* Parameter: IE */
-irq_setie:
-       wcsr    IE, r1
-       ret
-- 
1.7.2.3

_______________________________________________
http://lists.milkymist.org/listinfo.cgi/devel-milkymist.org
IRC: #milkymist@Freenode
Twitter: www.twitter.com/milkymistvj
Ideas? http://milkymist.uservoice.com

Reply via email to