[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r6539 - gnuradio/branches/developers/matt/u2f/firmware
From: |
eb |
Subject: |
[Commit-gnuradio] r6539 - gnuradio/branches/developers/matt/u2f/firmware |
Date: |
Tue, 25 Sep 2007 19:52:24 -0600 (MDT) |
Author: eb
Date: 2007-09-25 19:52:23 -0600 (Tue, 25 Sep 2007)
New Revision: 6539
Added:
gnuradio/branches/developers/matt/u2f/firmware/pic.c
gnuradio/branches/developers/matt/u2f/firmware/pic.h
Modified:
gnuradio/branches/developers/matt/u2f/firmware/Makefile
gnuradio/branches/developers/matt/u2f/firmware/memory_map.h
gnuradio/branches/developers/matt/u2f/firmware/timer_test.c
Log:
work-in-progress
Modified: gnuradio/branches/developers/matt/u2f/firmware/Makefile
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/Makefile 2007-09-26
01:50:30 UTC (rev 6538)
+++ gnuradio/branches/developers/matt/u2f/firmware/Makefile 2007-09-26
01:52:23 UTC (rev 6539)
@@ -3,6 +3,7 @@
AR = mb-ar
# CFLAGS = -Wall -O2 -g -mxl-gp-opt -mxl-soft-div -mxl-soft-mul -msoft-float
+#CFLAGS = -std=gnu99 -Wall -O2 -g -mxl-soft-div -mxl-soft-mul -msoft-float
CFLAGS = -Wall -O2 -g -mxl-soft-div -mxl-soft-mul -msoft-float
LINKER_SCRIPT = microblaze.ld
LDFLAGS = -Wl,-T$(LINKER_SCRIPT)
@@ -28,6 +29,7 @@
buffer_pool.o \
eth_driver.o \
eth_mac.o \
+ pic.o \
sim_io.o \
spi.o \
u2_init.o
Modified: gnuradio/branches/developers/matt/u2f/firmware/memory_map.h
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/memory_map.h 2007-09-26
01:50:30 UTC (rev 6538)
+++ gnuradio/branches/developers/matt/u2f/firmware/memory_map.h 2007-09-26
01:52:23 UTC (rev 6539)
@@ -181,10 +181,31 @@
#define dsp_rx_regs ((dsp_rx_regs_t *) DSP_RX_BASE)
///////////////////////////////////////////////////
-// Interrupt Controller, Slave 8
+// Simple Programmable Interrupt Controller, Slave 8
#define PIC_BASE 0xE000
+// Interrupt request lines
+// Bit numbers (LSB == 0) that correpond to interrupts into PIC
+
+#define IRQ_BUFFER 0 // buffer manager
+#define IRQ_TIMER 1
+#define IRQ_SPI 2
+#define IRQ_I2C 3
+#define IRQ_PHY 4 // ethernet PHY
+#define IRQ_RSRVD_5 5
+#define IRQ_RSRVD_6 6
+#define IRQ_RSRVD_7 7
+
+#define IRQ_TO_MASK(x) (1 << (x))
+
+#define PIC_BUFFER_INT IRQ_TO_MASK(IRQ_BUFFER)
+#define PIC_TIMER_INT IRQ_TO_MASK(IRQ_TIMER)
+#define PIC_SPI_INT IRQ_TO_MASK(IRQ_SPI)
+#define PIC_I2C_INT IRQ_TO_MASK(IRQ_I2C)
+#define PIC_PHY_INT IRQ_TO_MASK(IRQ_PHY)
+
+
typedef struct {
volatile int edge_enable;
volatile int polarity; // mask: 1 -> rising edge
@@ -194,14 +215,6 @@
#define pic_regs ((pic_regs_t *) PIC_BASE)
-#define PIC_PHY_INT 0x10 // ethernet PHY interrupt
-#define PIC_I2C_INT 0x08
-#define PIC_SPI_INT 0x04
-#define PIC_TIMER_INT 0x02
-#define PIC_BUFFER_INT 0x01
-
-#define PIC_ALL_INTS (PIC_BUFFER_INT | PIC_TIMER_INT | TIMER_SPI_INT |
PIC_I2C_INT | PIC_PHY_INT)
-
///////////////////////////////////////////////////
// Timer, Slave 9
Added: gnuradio/branches/developers/matt/u2f/firmware/pic.c
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/pic.c
(rev 0)
+++ gnuradio/branches/developers/matt/u2f/firmware/pic.c 2007-09-26
01:52:23 UTC (rev 6539)
@@ -0,0 +1,116 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "pic.h"
+#include "sim_io.h"
+#include "memory_map.h"
+
+
+#define NVECTORS 8
+
+/*
+ * Our secondary interrupt vector.
+ */
+irq_handler_t pic_vector[NVECTORS] = {
+ nop_handler,
+ nop_handler,
+ nop_handler,
+ nop_handler,
+ nop_handler,
+ nop_handler,
+ nop_handler,
+ nop_handler
+};
+
+#if 0
+static inline int
+irq_to_mask(int irq)
+{
+ static int table[8] = {
+ IRQ_TO_MASK(0),
+ IRQ_TO_MASK(1),
+ IRQ_TO_MASK(2),
+ IRQ_TO_MASK(3),
+ IRQ_TO_MASK(4),
+ IRQ_TO_MASK(5),
+ IRQ_TO_MASK(6),
+ IRQ_TO_MASK(7)
+ };
+
+ return table[irq & 0x7];
+}
+#endif
+
+void
+pic_init(void)
+{
+ // FIXME assume processor interrupts are enabled here.
+ // uP is level triggered
+
+ pic_regs->mask = ~0; // mask all interrupts
+ pic_regs->edge_enable = PIC_TIMER_INT | PIC_PHY_INT;
+ pic_regs->polarity = ~0 & ~PIC_PHY_INT; // rising edge
+ pic_regs->pending = ~0; // clear all pending ints
+}
+
+/*
+ * This magic gets pic_interrupt_handler wired into the
+ * system interrupt handler with the appropriate prologue and
+ * epilogue.
+ */
+void pic_interrupt_handler() __attribute__ ((interrupt_handler));
+
+void pic_interrupt_handler()
+{
+ sim_puts("PIC_handler: ");
+
+ // pending and not masked interrupts
+ int live = pic_regs->pending & ~pic_regs->mask;
+
+ // handle the first one set
+
+ int i;
+ int mask;
+ for (i=0, mask=1; i < NVECTORS; i++, mask <<= 1){
+ if (mask & live){ // handle this one
+ sim_puthex_nl(i);
+ (*pic_vector[i])(i);
+ pic_regs->pending = mask; // clear pending interrupt
+ return;
+ }
+ }
+}
+
+void
+pic_register_handler(unsigned irq, irq_handler_t handler)
+{
+ if (irq >= NVECTORS)
+ return;
+ pic_vector[irq] = handler;
+
+ pic_regs->mask &= ~IRQ_TO_MASK(irq);
+}
+
+void
+nop_handler(unsigned irq)
+{
+ // nop
+}
Property changes on: gnuradio/branches/developers/matt/u2f/firmware/pic.c
___________________________________________________________________
Name: svn:eol-style
+ native
Added: gnuradio/branches/developers/matt/u2f/firmware/pic.h
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/pic.h
(rev 0)
+++ gnuradio/branches/developers/matt/u2f/firmware/pic.h 2007-09-26
01:52:23 UTC (rev 6539)
@@ -0,0 +1,37 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_PIC_H
+#define INCLUDED_PIC_H
+
+typedef void (*irq_handler_t)(unsigned irq);
+
+void pic_init(void);
+void pic_register_handler(unsigned irq, irq_handler_t handler);
+
+void nop_handler(unsigned irq); // default handler does nothing
+
+// FIXME inline assembler
+int pic_disable_interrupts();
+int pic_enable_interrupts();
+void pic_restore_interrupts(int prev_status);
+
+
+#endif /* INCLUDED_PIC_H */
Property changes on: gnuradio/branches/developers/matt/u2f/firmware/pic.h
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: gnuradio/branches/developers/matt/u2f/firmware/timer_test.c
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/timer_test.c 2007-09-26
01:50:30 UTC (rev 6538)
+++ gnuradio/branches/developers/matt/u2f/firmware/timer_test.c 2007-09-26
01:52:23 UTC (rev 6539)
@@ -3,6 +3,7 @@
#include "spi.h"
#include "sim_io.h"
#include "buffer_pool.h"
+#include "pic.h"
// Globals
#define EMPTY 0
@@ -16,16 +17,14 @@
int buffer_state[4];
-#define DELTA_T 500 // 500 us (10ns per tick)
+#define DELTA_T 500 // 5 us (10ns per tick)
-/* FIXME figure out magic that ties this into the vector */
-
-void int_handler_func () __attribute__ ((interrupt_handler));
-void int_handler_func () {
+void
+timer_handler(unsigned irq)
+{
int t = timer_regs->time;
timer_regs->time = t + DELTA_T;
- pic_regs->pending = PIC_TIMER_INT;
sim_puts("Tick:");
sim_puthex_nl(t);
@@ -37,29 +36,19 @@
int t;
sim_puts("Start INIT\n");
-
u2_init();
sim_puts("Setting up interrupt controller\n");
+ pic_init();
- // setup interrupt controller
-
- // FIXME assume processor interrupts are enabled here.
- // uP is level triggered
-
- pic_regs->edge_enable = PIC_TIMER_INT | PIC_PHY_INT;
- pic_regs->polarity = PIC_TIMER_INT | PIC_PHY_INT; // rising edge
- pic_regs->mask = ~0; // mask all interrupts
- pic_regs->pending = ~0; // clear all pending ints
-
// setup timer
sim_puts("Setting up timer\n");
+ pic_register_handler(IRQ_TIMER, timer_handler);
+
t = timer_regs->time;
timer_regs->time = t + DELTA_T;
- pic_regs->mask &= ~PIC_TIMER_INT;
-
while(1){
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r6539 - gnuradio/branches/developers/matt/u2f/firmware,
eb <=