LM32: First of many LM32 source files
This commit is contained in:
parent
6a78c0f113
commit
62b394d06f
|
@ -0,0 +1,173 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* arch/misoc/src/common/lm32.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
|
||||||
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
* Ramtin Amin <keytwo@gmail.com>
|
||||||
|
*
|
||||||
|
* 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_LM32_H
|
||||||
|
#define __ARCH_MISOC_SRC_COMMON_LM32_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#ifndef __ASSEMBLY__
|
||||||
|
# include <nuttx/compiler.h>
|
||||||
|
# include <sys/types.h>
|
||||||
|
# include <stdint.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* This is the value used to mark the stack for subsequent stack monitoring
|
||||||
|
* logic.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define STACK_COLOR 0xdeadbeef
|
||||||
|
#define INTSTACK_COLOR 0xdeadbeef
|
||||||
|
#define HEAP_COLOR 'h'
|
||||||
|
|
||||||
|
/* In the RISC_V model, the state is copied from the stack to the TCB, but
|
||||||
|
* only a referenced is passed to get the state from the TCB.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define up_savestate(regs) lm32_copystate(regs, (uint32_t*)g_current_regs)
|
||||||
|
#define up_restorestate(regs) (g_current_regs = regs)
|
||||||
|
|
||||||
|
/* Determine which (if any) console driver to use. If a console is enabled
|
||||||
|
* and no other console device is specified, then a serial console is
|
||||||
|
* assumed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !defined(CONFIG_DEV_CONSOLE) || CONFIG_NFILE_DESCRIPTORS <= 0
|
||||||
|
# undef USE_SERIALDRIVER
|
||||||
|
# undef USE_EARLYSERIALINIT
|
||||||
|
# undef CONFIG_DEV_LOWCONSOLE
|
||||||
|
# undef CONFIG_RAMLOG_CONSOLE
|
||||||
|
#else
|
||||||
|
# if defined(CONFIG_RAMLOG_CONSOLE)
|
||||||
|
# undef USE_SERIALDRIVER
|
||||||
|
# undef USE_EARLYSERIALINIT
|
||||||
|
# undef CONFIG_DEV_LOWCONSOLE
|
||||||
|
# elif defined(CONFIG_DEV_LOWCONSOLE)
|
||||||
|
# undef USE_SERIALDRIVER
|
||||||
|
# undef USE_EARLYSERIALINIT
|
||||||
|
# else
|
||||||
|
# define USE_SERIALDRIVER 1
|
||||||
|
# define USE_EARLYSERIALINIT 1
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Low-level register access */
|
||||||
|
|
||||||
|
#define getreg8(a) (*(volatile uint8_t *)(a))
|
||||||
|
#define putreg8(v,a) (*(volatile uint8_t *)(a) = (v))
|
||||||
|
#define getreg16(a) (*(volatile uint16_t *)(a))
|
||||||
|
#define putreg16(v,a) (*(volatile uint16_t *)(a) = (v))
|
||||||
|
#define getreg32(a) (*(volatile uint32_t *)(a))
|
||||||
|
#define putreg32(v,a) (*(volatile uint32_t *)(a) = (v))
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
extern volatile uint32_t *g_current_regs;
|
||||||
|
|
||||||
|
extern uint32_t g_idle_topstack;
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Inline Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __ASSEMBLY__
|
||||||
|
|
||||||
|
/* Low level initialization provided by board-level logic ******************/
|
||||||
|
|
||||||
|
void lm32_board_initialize(void);
|
||||||
|
|
||||||
|
/* Memory allocation ********************************************************/
|
||||||
|
|
||||||
|
#if CONFIG_MM_REGIONS > 1
|
||||||
|
void lm32_add_region(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Context switching ********************************************************/
|
||||||
|
|
||||||
|
void lm32_copystate(uint32_t *dest, uint32_t *src);
|
||||||
|
|
||||||
|
/* IRQ initialization *******************************************************/
|
||||||
|
|
||||||
|
void lm32_irq_initialize(void);
|
||||||
|
|
||||||
|
/* System timer *************************************************************/
|
||||||
|
|
||||||
|
void lm32_timer_initialize(void);
|
||||||
|
int lm32_timerisr(int irq, void *context);
|
||||||
|
|
||||||
|
/* Software interrupts ******************************************************/
|
||||||
|
|
||||||
|
uint32_t lm32_swint(int irq, FAR void *context);
|
||||||
|
|
||||||
|
/* Signal handling **********************************************************/
|
||||||
|
|
||||||
|
void lm32_sigdeliver(void);
|
||||||
|
|
||||||
|
/* Atomic modification of registers *****************************************/
|
||||||
|
|
||||||
|
void modifyreg8(unsigned int addr, uint8_t clearbits, uint8_t setbits);
|
||||||
|
void modifyreg16(unsigned int addr, uint16_t clearbits, uint16_t setbits);
|
||||||
|
void modifyreg32(unsigned int addr, uint32_t clearbits, uint32_t setbits);
|
||||||
|
|
||||||
|
/* Debug ********************************************************************/
|
||||||
|
|
||||||
|
void lm32_dumpstate(void);
|
||||||
|
|
||||||
|
#undef EXTERN
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif /* __ASSEMBLY__ */
|
||||||
|
|
||||||
|
#endif /* __ARCH_MISOC_SRC_COMMON_LM32_H */
|
|
@ -0,0 +1,104 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* arch/misoc/src/common/lm32_allocateheap.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
|
||||||
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
* Ramtin Amin <keytwo@gmail.com>
|
||||||
|
*
|
||||||
|
* 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 <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/arch.h>
|
||||||
|
#include <nuttx/board.h>
|
||||||
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
|
#include "lm32.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_allocate_heap
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This function will be called to dynamically set aside the heap region.
|
||||||
|
*
|
||||||
|
* For the kernel build (CONFIG_BUILD_KERNEL=y) with both kernel- and
|
||||||
|
* user-space heaps (CONFIG_MM_KERNEL_HEAP=y), this function provides the
|
||||||
|
* size of the unprotected, user-space heap.
|
||||||
|
*
|
||||||
|
* If a protected kernel-space heap is provided, the kernel heap must be
|
||||||
|
* allocated (and protected) by an analogous up_allocate_kheap().
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void up_allocate_heap(FAR void **heap_start, size_t *heap_size)
|
||||||
|
{
|
||||||
|
board_autoled_on(LED_HEAPALLOCATE);
|
||||||
|
*heap_start = (FAR void *)g_idle_topstack;
|
||||||
|
*heap_size = CONFIG_RAM_END - g_idle_topstack;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: lm32_add_region
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Memory may be added in non-contiguous chunks. Additional chunks are
|
||||||
|
* added by calling this function.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if CONFIG_MM_REGIONS > 1
|
||||||
|
void lm32_add_region(void)
|
||||||
|
{
|
||||||
|
#warning Missing logic
|
||||||
|
}
|
||||||
|
#endif
|
Loading…
Reference in New Issue