diff --git a/arch/misoc/Kconfig b/arch/misoc/Kconfig index 74a2a7649b0..5cfbf0268c8 100644 --- a/arch/misoc/Kconfig +++ b/arch/misoc/Kconfig @@ -62,7 +62,6 @@ config MISOC_UART_TX_BUF_SIZE ---help--- Size of TX buffers for MISOC UARTs -source arch/misoc/src/common/Kconfig ifdef ARCH_CHIP_LM32 source arch/misoc/src/lm32/Kconfig endif diff --git a/arch/misoc/src/common/Kconfig b/arch/misoc/src/common/Kconfig deleted file mode 100644 index 6cd8cd81750..00000000000 --- a/arch/misoc/src/common/Kconfig +++ /dev/null @@ -1,8 +0,0 @@ -# -# For a description of the syntax of this configuration file, -# see the file kconfig-language.txt in the NuttX tools repository. -# - -if ARCH_MISOC - -endif # ARCH_MISOC diff --git a/arch/misoc/src/common/hw/common.h b/arch/misoc/src/common/hw/common.h new file mode 100644 index 00000000000..a6a7a92159f --- /dev/null +++ b/arch/misoc/src/common/hw/common.h @@ -0,0 +1,49 @@ +/**************************************************************************** + * arch/misoc/src/common/hw/common.h + * + * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Author: Ramtin Amin + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __ARCH_MISOC_SRC_COMMON_HW_COMMON_H +#define __ARCH_MISOC_SRC_COMMON_HW_COMMON_H + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifdef __ASSEMBLER__ +# define MMPTR(x) x +#else +# define MMPTR(x) (*((volatile unsigned int *)(x))) +#endif + +#endif /* __ARCH_MISOC_SRC_COMMON_HW_COMMON_H */ diff --git a/arch/misoc/src/common/hw/ethmac_mem.h b/arch/misoc/src/common/hw/ethmac_mem.h new file mode 100644 index 00000000000..61964809126 --- /dev/null +++ b/arch/misoc/src/common/hw/ethmac_mem.h @@ -0,0 +1,54 @@ +/**************************************************************************** + * arch/misoc/src/common/hw/emac_mem.h + * + * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Author: Ramtin Amin + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __ARCH_MISOC_SRC_COMMON_HW_EMAC_MEM_H +#define __ARCH_MISOC_SRC_COMMON_HW_EMAC_MEM_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define ETHMAC_RX0_BASE ETHMAC_BASE +#define ETHMAC_RX1_BASE (ETHMAC_BASE+0x0800) +#define ETHMAC_TX0_BASE (ETHMAC_BASE+0x1000) +#define ETHMAC_TX1_BASE (ETHMAC_BASE+0x1800) + +#endif /* __ARCH_MISOC_SRC_COMMON_HW_EMAC_MEM_H */ diff --git a/arch/misoc/src/common/hw/flags.h b/arch/misoc/src/common/hw/flags.h new file mode 100644 index 00000000000..7ed2f4bf427 --- /dev/null +++ b/arch/misoc/src/common/hw/flags.h @@ -0,0 +1,79 @@ +/**************************************************************************** + * arch/misoc/src/common/hw/emac_mem.h + * + * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Author: Ramtin Amin + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __ARCH_MISOC_SRC_COMMON_HW_FLAGS_H +#define __ARCH_MISOC_SRC_COMMON_HW_FLAGS_H + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define UART_EV_TX 0x1 +#define UART_EV_RX 0x2 + +#define DFII_CONTROL_SEL 0x01 +#define DFII_CONTROL_CKE 0x02 +#define DFII_CONTROL_ODT 0x04 +#define DFII_CONTROL_RESET_N 0x08 + +#define DFII_COMMAND_CS 0x01 +#define DFII_COMMAND_WE 0x02 +#define DFII_COMMAND_CAS 0x04 +#define DFII_COMMAND_RAS 0x08 +#define DFII_COMMAND_WRDATA 0x10 +#define DFII_COMMAND_RDDATA 0x20 + +#define ETHMAC_EV_SRAM_WRITER 0x1 +#define ETHMAC_EV_SRAM_READER 0x1 + +#define CLKGEN_STATUS_BUSY 0x1 +#define CLKGEN_STATUS_PROGDONE 0x2 +#define CLKGEN_STATUS_LOCKED 0x4 + +#define DVISAMPLER_TOO_LATE 0x1 +#define DVISAMPLER_TOO_EARLY 0x2 + +#define DVISAMPLER_DELAY_MASTER_CAL 0x01 +#define DVISAMPLER_DELAY_MASTER_RST 0x02 +#define DVISAMPLER_DELAY_SLAVE_CAL 0x04 +#define DVISAMPLER_DELAY_SLAVE_RST 0x08 +#define DVISAMPLER_DELAY_INC 0x10 +#define DVISAMPLER_DELAY_DEC 0x20 + +#define DVISAMPLER_SLOT_EMPTY 0 +#define DVISAMPLER_SLOT_LOADED 1 +#define DVISAMPLER_SLOT_PENDING 2 + +#endif /* __ARCH_MISOC_SRC_COMMON_HW_FLAGS_H */ diff --git a/arch/misoc/src/common/misoc_isr.c b/arch/misoc/src/common/misoc_isr.c deleted file mode 100644 index 96c726b17c2..00000000000 --- a/arch/misoc/src/common/misoc_isr.c +++ /dev/null @@ -1,20 +0,0 @@ -#include - -void uart_isr(); -void uart_isr() -{ - -} - -void isr(void); -void isr(void) -{ - unsigned int irqs; - - irqs = irq_pending() & irq_getmask(); - - if (irqs & (1 << UART_INTERRUPT)) - { - uart_isr(); - } -} diff --git a/arch/misoc/src/common/misoc_uart.c b/arch/misoc/src/common/misoc_uart.c index 7a36e78199c..77410f5071d 100644 --- a/arch/misoc/src/common/misoc_uart.c +++ b/arch/misoc/src/common/misoc_uart.c @@ -1,3 +1,42 @@ +/**************************************************************************** + * arch/misoc/src/common/misoc_uart.c + * + * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Author: Ramtin Amin + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + #include #include #include @@ -20,11 +59,15 @@ #include #include "hw/flags.h" -#include "misoc_irqasm.h" +#include "chip.h" #include "misoc_uart.h" #include "lm32.h" +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + /* Buffer sizes must be a power of 2 so that modulos can be computed * with logical AND. */ @@ -32,91 +75,140 @@ #define UART_RINGBUFFER_SIZE_RX 128 #define UART_RINGBUFFER_MASK_RX (UART_RINGBUFFER_SIZE_RX-1) +#define UART_RINGBUFFER_SIZE_TX 128 +#define UART_RINGBUFFER_MASK_TX (UART_RINGBUFFER_SIZE_TX-1) + +/**************************************************************************** + * Private Data + ****************************************************************************/ + static char rx_buf[UART_RINGBUFFER_SIZE_RX]; static volatile unsigned int rx_produce; static unsigned int rx_consume; -#define UART_RINGBUFFER_SIZE_TX 128 -#define UART_RINGBUFFER_MASK_TX (UART_RINGBUFFER_SIZE_TX-1) - static char tx_buf[UART_RINGBUFFER_SIZE_TX]; static unsigned int tx_produce; static volatile unsigned int tx_consume; -static int uart_interrupt(int irq, void *context); - +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: uart_interrupt + ****************************************************************************/ + static int uart_interrupt(int irq, void *context) { unsigned int stat, rx_produce_next; stat = uart_ev_pending_read(); - if(stat & UART_EV_RX) { - while(!uart_rxempty_read()) { - rx_produce_next = (rx_produce + 1) & UART_RINGBUFFER_MASK_RX; - if(rx_produce_next != rx_consume) { - rx_buf[rx_produce] = uart_rxtx_read(); - rx_produce = rx_produce_next; - } - uart_ev_pending_write(UART_EV_RX); - } - } + if ((stat & UART_EV_RX) != 0) + { + while (!uart_rxempty_read()) + { + rx_produce_next = (rx_produce + 1) & UART_RINGBUFFER_MASK_RX; + if (rx_produce_next != rx_consume) + { + rx_buf[rx_produce] = uart_rxtx_read(); + rx_produce = rx_produce_next; + } - if(stat & UART_EV_TX) { - uart_ev_pending_write(UART_EV_TX); - while((tx_consume != tx_produce) && !uart_txfull_read()) { - uart_rxtx_write(tx_buf[tx_consume]); - tx_consume = (tx_consume + 1) & UART_RINGBUFFER_MASK_TX; + uart_ev_pending_write(UART_EV_RX); + } + } + + if ((stat & UART_EV_TX) != 0) + { + uart_ev_pending_write(UART_EV_TX); + while ((tx_consume != tx_produce) && !uart_txfull_read()) + { + uart_rxtx_write(tx_buf[tx_consume]); + tx_consume = (tx_consume + 1) & UART_RINGBUFFER_MASK_TX; + } } - } return OK; } -/* Do not use in interrupt handlers! */ +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: uart_read + * + * Do not use in interrupt handlers! + * + ****************************************************************************/ + char uart_read(void) { char c; - if(irq_getie()) { - while(rx_consume == rx_produce); - } else if (rx_consume == rx_produce) { - return 0; - } + if (irq_getie()) + { + while (rx_consume == rx_produce); + } + else if (rx_consume == rx_produce) + { + return 0; + } c = rx_buf[rx_consume]; rx_consume = (rx_consume + 1) & UART_RINGBUFFER_MASK_RX; return c; } +/**************************************************************************** + * Name: uart_read_nonblock + ****************************************************************************/ + int uart_read_nonblock(void) { return (rx_consume != rx_produce); } +/**************************************************************************** + * Name: up_putc + ****************************************************************************/ + int up_putc(int ch) { unsigned int oldmask; unsigned int tx_produce_next = (tx_produce + 1) & UART_RINGBUFFER_MASK_TX; - if(irq_getie()) { - while(tx_produce_next == tx_consume); - } else if(tx_produce_next == tx_consume) { - return ch; - } + if (irq_getie()) + { + while (tx_produce_next == tx_consume); + } + else if (tx_produce_next == tx_consume) + { + return ch; + } oldmask = irq_getmask(); irq_setmask(oldmask & ~(1 << UART_INTERRUPT)); - if((tx_consume != tx_produce) || uart_txfull_read()) { - tx_buf[tx_produce] = ch; - tx_produce = tx_produce_next; - } else { - uart_rxtx_write(ch); - } + + if ((tx_consume != tx_produce) || uart_txfull_read()) + { + tx_buf[tx_produce] = ch; + tx_produce = tx_produce_next; + } + else + { + uart_rxtx_write(ch); + } + irq_setmask(oldmask); return ch; } +/**************************************************************************** + * Name: uart_init + ****************************************************************************/ + void uart_init(void) { rx_produce = 0; @@ -132,10 +224,11 @@ void uart_init(void) irq_attach(1 << UART_INTERRUPT, uart_interrupt); } +/**************************************************************************** + * Name: uart_sync + ****************************************************************************/ + void uart_sync(void) { - while(tx_consume != tx_produce); + while (tx_consume != tx_produce); } - - - diff --git a/arch/misoc/src/common/misoc_uart.h b/arch/misoc/src/common/misoc_uart.h new file mode 100644 index 00000000000..74fcc7c0acf --- /dev/null +++ b/arch/misoc/src/common/misoc_uart.h @@ -0,0 +1,60 @@ +/**************************************************************************** + * arch/misoc/src/common/misoc_uart.c + * + * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Author: Ramtin Amin + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __ARCH_MISOC_SRC_COMMON_MISOC_UART_H +#define __ARCH_MISOC_SRC_COMMON_MISOC_UART_H 1 + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifdef __cplusplus +extern "C" +{ +#endif + +void uart_init(void); +void uart_isr(void); +void uart_sync(void); + +void uart_write(char c); +char uart_read(void); +int uart_read_nonblock(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __ARCH_MISOC_SRC_COMMON_MISOC_UART_H */ diff --git a/arch/misoc/src/lm32/Make.defs b/arch/misoc/src/lm32/Make.defs index 1c12e0c5270..1a0ce75de24 100644 --- a/arch/misoc/src/lm32/Make.defs +++ b/arch/misoc/src/lm32/Make.defs @@ -45,5 +45,5 @@ CHIP_CSRCS = lm32_allocateheap.c lm32_assert.c lm32_blocktask.c CHIP_CSRCS += lm32_copystate.c lm32_createstack.c lm32_doirq.c lm32_dumpstate.c CHIP_CSRCS += lm32_dumpstate.c lm32_exit.c lm32_idle.c lm32_initialize.c CHIP_CSRCS += lm32_initialstate.c lm32_interruptcontext.c lm32_irq.c -CHIP_CSRCS += lm32_releasepending.c lm32_releasestack.c lm32_stackframe.c -CHIP_CSRCS += lm32_swint.c lm32_unblocktask.c +CHIP_CSRCS += lm32_isr.c lm32_releasepending.c lm32_releasestack.c +CHIP_CSRCS += lm32_stackframe.c lm32_swint.c lm32_unblocktask.c diff --git a/arch/misoc/src/lm32/chip.h b/arch/misoc/src/lm32/chip.h new file mode 100644 index 00000000000..0683bd5a282 --- /dev/null +++ b/arch/misoc/src/lm32/chip.h @@ -0,0 +1,92 @@ +/**************************************************************************** + * arch/misoc/src/lm32/chip.h + * + * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Author: Ramtin Amin + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __ARCH_MISOC_SRC_LM32_CHIP_H +#define __ARCH_MISOC_SRC_LM32_CHIP_H 1 + +/**************************************************************************** + * Inline Functions + ****************************************************************************/ + +#ifdef __cplusplus +extern "C" +{ +#endif + +static inline unsigned int irq_getie(void) +{ + 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)); +} + +static inline unsigned int irq_getmask(void) +{ + + 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(void) +{ + + unsigned int pending; + __asm__ __volatile__("rcsr %0, IP" : "=r" (pending)); + return pending; +} + +#ifdef __cplusplus +} +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +void uart_isr(void); +void isr(void); + +#endif /* __ARCH_MISOC_SRC_LM32_CHIP_H */ diff --git a/arch/misoc/src/lm32/lm32_irq.c b/arch/misoc/src/lm32/lm32_irq.c index b99bb443b43..2e01b511fd1 100644 --- a/arch/misoc/src/lm32/lm32_irq.c +++ b/arch/misoc/src/lm32/lm32_irq.c @@ -46,7 +46,7 @@ #include #include -#include "misoc_irqasm.h" +#include "chip_irqasm.h" #include "lm32.h" /**************************************************************************** diff --git a/arch/misoc/src/lm32/lm32_isr.c b/arch/misoc/src/lm32/lm32_isr.c new file mode 100644 index 00000000000..539614d3179 --- /dev/null +++ b/arch/misoc/src/lm32/lm32_isr.c @@ -0,0 +1,61 @@ +/**************************************************************************** + * arch/misoc/src/lm32/lm32_isr.c + * + * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Author: Ramtin Amin + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include "chip_irqasm.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +void uart_isr() +{ +} + +void isr(void) +{ + unsigned int irqs; + + irqs = irq_pending() & irq_getmask(); + + if (irqs & (1 << UART_INTERRUPT)) + { + uart_isr(); + } +}