bsp/raspberrypi: New BSP

This commit is contained in:
Alan Cudmore
2013-03-23 19:13:07 +01:00
committed by Sebastian Huber
parent f2a1ba5002
commit c32b1efa43
21 changed files with 1532 additions and 0 deletions

View File

@@ -24,6 +24,8 @@ AC_DEFUN([RTEMS_CHECK_BSPDIR],
AC_CONFIG_SUBDIRS([lpc32xx]);;
nds )
AC_CONFIG_SUBDIRS([nds]);;
raspberrypi )
AC_CONFIG_SUBDIRS([raspberrypi]);;
rtl22xx )
AC_CONFIG_SUBDIRS([rtl22xx]);;
smdk2410 )

View File

@@ -0,0 +1,154 @@
##
#
# @file
#
# @brief Makefile of LibBSP for the raspberrypi board.
#
ACLOCAL_AMFLAGS = -I ../../../../aclocal
include $(top_srcdir)/../../../../automake/compile.am
include_bspdir = $(includedir)/bsp
include_libcpudir = $(includedir)/libcpu
dist_project_lib_DATA = bsp_specs
###############################################################################
# Header #
###############################################################################
include_HEADERS = include/bsp.h
include_HEADERS += ../../shared/include/tm27.h
nodist_include_HEADERS = ../../shared/include/coverhd.h \
include/bspopts.h
nodist_include_bsp_HEADERS = ../../shared/include/bootcard.h
include_bsp_HEADERS =
include_bsp_HEADERS += ../../shared/include/utility.h
include_bsp_HEADERS += ../../shared/include/irq-generic.h
include_bsp_HEADERS += ../../shared/include/irq-info.h
include_bsp_HEADERS += ../../shared/include/stackalloc.h
include_bsp_HEADERS += ../../shared/include/uart-output-char.h
include_bsp_HEADERS += ../../shared/tod.h
include_bsp_HEADERS += ../shared/include/linker-symbols.h
include_bsp_HEADERS += ../shared/include/start.h
include_bsp_HEADERS += ../shared/lpc/include/lpc-timer.h
include_bsp_HEADERS += ../shared/lpc/include/lpc-dma.h
include_bsp_HEADERS += include/irq.h
include_bsp_HEADERS += include/mmu.h
include_bsp_HEADERS += include/usart.h
include_bsp_HEADERS += include/raspberrypi.h
include_libcpu_HEADERS = ../../../libcpu/arm/shared/include/cache_.h \
../../../libcpu/arm/shared/include/arm-cp15.h
###############################################################################
# Data #
###############################################################################
noinst_LIBRARIES = libbspstart.a
libbspstart_a_SOURCES = ../shared/start/start.S
project_lib_DATA = start.$(OBJEXT)
project_lib_DATA += startup/linkcmds
project_lib_DATA += ../shared/startup/linkcmds.base
EXTRA_DIST = startup/linkcmds
###############################################################################
# LibBSP #
###############################################################################
noinst_LIBRARIES += libbsp.a
libbsp_a_SOURCES =
libbsp_a_CPPFLAGS =
libbsp_a_LIBADD =
# Shared
libbsp_a_SOURCES += ../../shared/bootcard.c
libbsp_a_SOURCES += ../../shared/bspclean.c
libbsp_a_SOURCES += ../../shared/bspgetworkarea.c
libbsp_a_SOURCES += ../../shared/bsplibc.c
libbsp_a_SOURCES += ../../shared/bsppost.c
libbsp_a_SOURCES += ../../shared/bsppredriverhook.c
libbsp_a_SOURCES += ../../shared/bsppretaskinghook.c
libbsp_a_SOURCES += ../../shared/gnatinstallhandler.c
libbsp_a_SOURCES += ../../shared/sbrk.c
libbsp_a_SOURCES += ../../shared/src/stackalloc.c
libbsp_a_SOURCES += ../shared/abort/simple_abort.c
libbsp_a_SOURCES += ../shared/startup/bsp-start-memcpy.S
# Startup
libbsp_a_SOURCES += startup/bspreset.c
libbsp_a_SOURCES += startup/bspstart.c
# IRQ
libbsp_a_SOURCES += ../../shared/src/irq-default-handler.c
libbsp_a_SOURCES += ../../shared/src/irq-generic.c
libbsp_a_SOURCES += ../../shared/src/irq-info.c
libbsp_a_SOURCES += ../../shared/src/irq-legacy.c
libbsp_a_SOURCES += ../../shared/src/irq-server.c
libbsp_a_SOURCES += ../../shared/src/irq-shell.c
libbsp_a_SOURCES += irq/irq.c
# Console
libbsp_a_SOURCES += ../../shared/console.c
libbsp_a_SOURCES += ../../shared/console_control.c
libbsp_a_SOURCES += ../../shared/console_read.c
libbsp_a_SOURCES += ../../shared/console_select.c
libbsp_a_SOURCES += ../../shared/console_write.c
libbsp_a_SOURCES += console/console-config.c
libbsp_a_SOURCES += console/usart.c
# clock
libbsp_a_SOURCES += clock/clockdrv.c ../../../shared/clockdrv_shell.h
# Timer
libbsp_a_SOURCES += misc/timer.c
# RTC
# SSP
# I2C
# Cache
libbsp_a_SOURCES += ../../../libcpu/shared/src/cache_manager.c
libbsp_a_SOURCES += ../../../libcpu/arm/shared/include/cache_.h
libbsp_a_CPPFLAGS += -I$(srcdir)/../../../libcpu/arm/shared/include
# Start hooks
libbsp_a_SOURCES += startup/bspstarthooks.c
###############################################################################
# Network #
###############################################################################
#if HAS_NETWORKING
#
#noinst_PROGRAMS = network.rel
#
#network_rel_SOURCES = ../shared/lpc/network/lpc-ethernet.c
#network_rel_CPPFLAGS = $(AM_CPPFLAGS) -D__INSIDE_RTEMS_BSD_TCPIP_STACK__ -D__BSD_VISIBLE
#network_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
#
#
#libbsp_a_LIBADD += network.rel
#
#endif
###############################################################################
# Special Rules #
###############################################################################
DISTCLEANFILES = include/bspopts.h
include $(srcdir)/preinstall.am
include $(top_srcdir)/../../../../automake/local.am

View File

@@ -0,0 +1,65 @@
BSP for the Raspberry Pi ARM board
This is a basic port that should work on either Model A or Model B.
It currently supports the following devices:
o Console using the PL011 UART0
The console driver only works with polled mode right now,
the interrupt code is there, but it does not work yet.
The console driver is currently hardcoded at 115k 8N1
o Clock uses the internal ARM timer
The Raspberry Pi can be overclocked through the config.txt file, this
would affect the duration of the clock tick.
o Benchmark timer reads the lower 32 bit GPU timer register
To run an RTEMS binary, it must be stripped and loaded on the SD card along with
the following files:
bootcode.bin
config.txt
loader.bin
start.elf
kernel.img ( the RTEMS binary, you can change the name in config.txt )
These files can be obtained from a Linux installation image, or from here:
https://github.com/raspberrypi/firmware
I used an old 256MB SD card to boot RTEMS.
Much more information about the SD card file and bootloader can be found here:
http://elinux.org/RPi_Hub
http://www.raspberrypi.org
The linker script is set up for 128MB, so it can be used with a GPU/ARM split
of 128/128.
The bootloader that is used on the SD card determines the split of RAM between the
ARM and the GPU. It might make sense to adjust the GPU/ARM memory split to give
more memory to RTEMS, especially on a 512MB board.
To do:
It would be nice to get support in the BSP for the following:
o SD card
o USB and USB 10/100 network chip on Model B
o SPI
o GPIO
o ARM MMU
o Graphics console
o Sound
Credits and links:
There is a wealth of code and information to reference on the raspberrypi.org bare metal forums:
http://www.raspberrypi.org/phpBB3/viewforum.php?f=72
I found information about how to program the timers, interrupts, and UART 0
from the examples provided by:
David Welch:
https://github.com/dwelch67/raspberrypi
The readme file at his github repository has valuable information about connecting a UART cable, JTAG etc.
Steve Bate:
http://www.stevebate.net/chibios-rpi/GettingStarted.html
Steve provided a port of the Chibios RTOS to the raspberry Pi
James Walmsley:
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=72&t=22423
James ported FreeRTOS to the raspberry Pi.

View File

@@ -0,0 +1,13 @@
%rename endfile old_endfile
%rename startfile old_startfile
%rename link old_link
*startfile:
%{!qrtems: %(old_startfile)} \
%{!nostdlib: %{qrtems: start.o%s crti.o%s crtbegin.o%s -e _start}}
*link:
%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}
*endfile:
%{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }

View File

@@ -0,0 +1,91 @@
/*
* BCM2835 Clock driver
*
* Copyright (c) 2013 Alan Cudmore
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
*
* http://www.rtems.com/license/LICENSE
*
*/
#include <rtems.h>
#include <bsp.h>
#include <bsp/irq.h>
#include <bsp/raspberrypi.h>
/* This is defined in ../../../shared/clockdrv_shell.h */
void Clock_isr(rtems_irq_hdl_param arg);
static void raspberrypi_clock_at_tick(void)
{
BCM2835_REG(BCM2835_TIMER_CLI) = 0;
}
static void raspberrypi_clock_handler_install(void)
{
rtems_status_code sc = RTEMS_SUCCESSFUL;
sc = rtems_interrupt_handler_install(
BCM2835_IRQ_ID_TIMER_0,
"Clock",
RTEMS_INTERRUPT_UNIQUE,
(rtems_interrupt_handler) Clock_isr,
NULL
);
if (sc != RTEMS_SUCCESSFUL) {
rtems_fatal_error_occurred(0xdeadbeef);
}
}
static void raspberrypi_clock_initialize(void)
{
BCM2835_REG(BCM2835_TIMER_CTL) = 0x003E0000;
BCM2835_REG(BCM2835_TIMER_LOD) = 10000 - 1;
BCM2835_REG(BCM2835_TIMER_RLD) = 10000 - 1;
BCM2835_REG(BCM2835_TIMER_DIV) = BCM2835_TIMER_PRESCALE;
BCM2835_REG(BCM2835_TIMER_CLI) = 0;
BCM2835_REG(BCM2835_TIMER_CTL) = 0x003E00A2;
}
static void raspberrypi_clock_cleanup(void)
{
rtems_status_code sc = RTEMS_SUCCESSFUL;
/* Remove interrupt handler */
sc = rtems_interrupt_handler_remove(
BCM2835_IRQ_ID_TIMER_0,
(rtems_interrupt_handler) Clock_isr,
NULL
);
if (sc != RTEMS_SUCCESSFUL) {
rtems_fatal_error_occurred(0xdeadbeef);
}
}
/*
* Return the nanoseconds since last tick
*/
static uint32_t raspberrypi_clock_nanoseconds_since_last_tick(void)
{
return 0;
}
#define Clock_driver_support_at_tick() raspberrypi_clock_at_tick()
#define Clock_driver_support_initialize_hardware() raspberrypi_clock_initialize()
#define Clock_driver_support_install_isr(isr, old_isr) \
do { \
raspberrypi_clock_handler_install(); \
old_isr = NULL; \
} while (0)
#define Clock_driver_support_shutdown_hardware() raspberrypi_clock_cleanup()
#define Clock_driver_nanoseconds_since_last_tick \
raspberrypi_clock_nanoseconds_since_last_tick
#include "../../../shared/clockdrv_shell.h"

View File

@@ -0,0 +1,31 @@
##
#
# @file
#
# @brief Configure script of LibBSP for the Raspberry Pi boards.
#
AC_PREREQ([2.68])
AC_INIT([rtems-c-src-lib-libbsp-arm-raspberrypi],[_RTEMS_VERSION],[http://www.rtems.org/bugzilla])
AC_CONFIG_SRCDIR([bsp_specs])
RTEMS_TOP(../../../../../..)
RTEMS_CANONICAL_TARGET_CPU
AM_INIT_AUTOMAKE([no-define nostdinc foreign 1.12.2])
RTEMS_BSP_CONFIGURE
RTEMS_PROG_CC_FOR_TARGET
RTEMS_CANONICALIZE_TOOLS
RTEMS_PROG_CCAS
RTEMS_CHECK_NETWORKING
AM_CONDITIONAL(HAS_NETWORKING,test "$HAS_NETWORKING" = "yes")
RTEMS_BSPOPTS_SET([BSP_START_RESET_VECTOR],[*],[])
RTEMS_BSPOPTS_HELP([BSP_START_RESET_VECTOR],[reset vector address for BSP start])
RTEMS_BSP_CLEANUP_OPTIONS(0, 0)
RTEMS_BSP_LINKCMDS
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

View File

@@ -0,0 +1,53 @@
/*
* Copyright (c) 2013 Alan Cudmore
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
*
* http://www.rtems.com/license/LICENSE
*
*/
#include <rtems/bspIo.h>
#include <libchip/serial.h>
#include <bspopts.h>
#include <bsp/irq.h>
#include <bsp/usart.h>
#include <bsp/raspberrypi.h>
console_tbl Console_Configuration_Ports [] = {
{
.sDeviceName = "/dev/ttyS0",
.deviceType = SERIAL_CUSTOM,
.pDeviceFns = &bcm2835_usart_fns,
.deviceProbe = NULL,
.pDeviceFlow = NULL,
.ulCtrlPort1 = BCM2835_UART0_BASE,
.ulCtrlPort2 = 0,
.ulClock = USART0_DEFAULT_BAUD,
.ulIntVector = BCM2835_IRQ_ID_UART
}
};
#define PORT_COUNT \
(sizeof(Console_Configuration_Ports) \
/ sizeof(Console_Configuration_Ports [0]))
unsigned long Console_Configuration_Count = PORT_COUNT;
static void output_char(char c)
{
const console_fns *con =
Console_Configuration_Ports [Console_Port_Minor].pDeviceFns;
if (c == '\n') {
con->deviceWritePolled((int) Console_Port_Minor, '\r');
}
con->deviceWritePolled((int) Console_Port_Minor, c);
}
BSP_output_char_function_type BSP_output_char = output_char;
BSP_polling_getchar_function_type BSP_poll_char = NULL;

View File

@@ -0,0 +1,160 @@
/*
* Copyright (c) 2013 Alan Cudmore
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
*
* http://www.rtems.com/license/LICENSE
*
*/
#include <libchip/sersupp.h>
#include <bsp.h>
#include <bsp/irq.h>
#include <bsp/usart.h>
#include <bsp/raspberrypi.h>
static void usart_delay(uint32_t n)
{
volatile uint32_t i = 0;
for(i = 0; i < n; i++);
}
static rtems_vector_number usart_get_irq_number(const console_tbl *ct)
{
return ct->ulIntVector;
}
static uint32_t usart_get_baud(const console_tbl *ct)
{
return ct->ulClock;
}
static void usart_set_baud(int minor, int baud)
{
/*
** Nothing for now
*/
return;
}
static void usart_initialize(int minor)
{
unsigned int gpio_reg;
/*
** Program GPIO pins for UART 0
*/
gpio_reg = BCM2835_REG(BCM2835_GPIO_GPFSEL1);
gpio_reg &= ~(7<<12); /* gpio14 */
gpio_reg |= (4<<12); /* alt0 */
gpio_reg &= ~(7<<15); /* gpio15 */
gpio_reg |= (4<<15); /* alt0 */
BCM2835_REG(BCM2835_GPIO_GPFSEL1) = gpio_reg;
BCM2835_REG(BCM2835_GPIO_GPPUD) = 0;
usart_delay(150);
BCM2835_REG(BCM2835_GPIO_GPPUDCLK0) = (1<<14)|(1<<15);
usart_delay(150);
BCM2835_REG(BCM2835_GPIO_GPPUDCLK0) = 0;
/*
** Init the PL011 UART
*/
BCM2835_REG(BCM2835_UART0_CR) = 0;
BCM2835_REG(BCM2835_UART0_ICR) = 0x7FF;
BCM2835_REG(BCM2835_UART0_IMSC) = 0;
BCM2835_REG(BCM2835_UART0_IBRD) = 1;
BCM2835_REG(BCM2835_UART0_FBRD) = 40;
BCM2835_REG(BCM2835_UART0_LCRH) = 0x70;
BCM2835_REG(BCM2835_UART0_RSRECR) = 0;
BCM2835_REG(BCM2835_UART0_CR) = 0x301;
BCM2835_REG(BCM2835_UART0_IMSC) = BCM2835_UART0_IMSC_RX;
usart_set_baud(minor, 115000);
}
static int usart_first_open(int major, int minor, void *arg)
{
rtems_libio_open_close_args_t *oc = (rtems_libio_open_close_args_t *) arg;
struct rtems_termios_tty *tty = (struct rtems_termios_tty *) oc->iop->data1;
const console_tbl *ct = Console_Port_Tbl [minor];
console_data *cd = &Console_Port_Data [minor];
cd->termios_data = tty;
rtems_termios_set_initial_baud(tty, ct->ulClock);
return 0;
}
static int usart_last_close(int major, int minor, void *arg)
{
return 0;
}
static int usart_read_polled(int minor)
{
if (minor == 0)
{
if(((BCM2835_REG(BCM2835_UART0_FR)) & BCM2835_UART0_FR_RXFE) == 0)
{
return((BCM2835_REG(BCM2835_UART0_DR)) & 0xFF );
}
else
{
return -1;
}
}
else
{
printk("Unknown console minor number: %d\n", minor);
return -1;
}
}
static void usart_write_polled(int minor, char c)
{
while (1)
{
if ((BCM2835_REG(BCM2835_UART0_FR) & BCM2835_UART0_FR_TXFF) == 0) break;
}
BCM2835_REG(BCM2835_UART0_DR) = c;
}
static ssize_t usart_write_support_polled(
int minor,
const char *s,
size_t n
)
{
ssize_t i = 0;
for (i = 0; i < n; ++i)
{
usart_write_polled(minor, s [i]);
}
return n;
}
static int usart_set_attributes(int minor, const struct termios *term)
{
return -1;
}
const console_fns bcm2835_usart_fns = {
.deviceProbe = libchip_serial_default_probe,
.deviceFirstOpen = usart_first_open,
.deviceLastClose = usart_last_close,
.deviceRead = usart_read_polled,
.deviceWrite = usart_write_support_polled,
.deviceInitialize = usart_initialize,
.deviceWritePolled = usart_write_polled,
.deviceSetAttributes = usart_set_attributes,
.deviceOutputUsesInterrupts = false
};

View File

@@ -0,0 +1,38 @@
/**
* @file
*
* @ingroup raspberrypi
*
* @brief Global BSP definitions.
*/
/*
* Copyright (c) 2013 Alan Cudmore
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
*
* http://www.rtems.com/license/LICENSE
*
*/
#ifndef LIBBSP_ARM_RASPBERRYPI_BSP_H
#define LIBBSP_ARM_RASPBERRYPI_BSP_H
#include <bspopts.h>
#include <rtems.h>
#include <rtems/console.h>
#include <rtems/clockdrv.h>
#include <bsp/raspberrypi.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define BSP_FEATURE_IRQ_EXTENSION
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* LIBBSP_ARM_RASPBERRYPI_BSP_H */

View File

@@ -0,0 +1,62 @@
/**
* @file
*
* @ingroup bsp_interrupt
*
* @brief Interrupt definitions.
*/
/*
* Copyright (c) 2013 Alan Cudmore
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
*
* http://www.rtems.com/license/LICENSE
*
*/
#ifndef LIBBSP_ARM_RASBPERRYPI_IRQ_H
#define LIBBSP_ARM_RASPBERRYPI_IRQ_H
#ifndef ASM
#include <rtems.h>
#include <rtems/irq.h>
#include <rtems/irq-extension.h>
#define BCM2835_INTC_TOTAL_IRQ 64 + 8
#define BCM2835_IRQ_ID_AUX 29
#define BCM2835_IRQ_ID_SPI_SLAVE 43
#define BCM2835_IRQ_ID_PWA0 45
#define BCM2835_IRQ_ID_PWA1 46
#define BCM2835_IRQ_ID_SMI 48
#define BCM2835_IRQ_ID_GPIO_0 49
#define BCM2835_IRQ_ID_GPIO_1 50
#define BCM2835_IRQ_ID_GPIO_2 51
#define BCM2835_IRQ_ID_GPIO_3 52
#define BCM2835_IRQ_ID_I2C 53
#define BCM2835_IRQ_ID_SPI 54
#define BCM2835_IRQ_ID_PCM 55
#define BCM2835_IRQ_ID_UART 57
#define BCM2835_IRQ_ID_TIMER_0 64
#define BCM2835_IRQ_ID_MAILBOX_0 65
#define BCM2835_IRQ_ID_DOORBELL_0 66
#define BCM2835_IRQ_ID_DOORBELL_1 67
#define BCM2835_IRQ_ID_GPU0_HALTED 68
#define BSP_INTERRUPT_VECTOR_MIN (0)
#define BSP_INTERRUPT_VECTOR_MAX (BCM2835_INTC_TOTAL_IRQ - 1)
#define BSP_IRQ_COUNT (BCM2835_INTC_TOTAL_IRQ)
void raspberrypi_set_exception_handler(Arm_symbolic_exception_name exception,
void (*handler)(void));
#endif /* ASM */
#endif /* LIBBSP_ARM_RASPBERRYPI_IRQ_H */

View File

@@ -0,0 +1,68 @@
/**
* @file
*
* @ingroup rapberrypi_mmu
*
* @brief MMU API.
*/
/*
* Copyright (c) 2013 Alan Cudmore.
* based on work by:
* Copyright (c) 2009
* embedded brains GmbH
* Obere Lagerstr. 30
* D-82178 Puchheim
* Germany
* <rtems@embedded-brains.de>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
*
* http://www.rtems.com/license/LICENSE
*
*/
#ifndef LIBBSP_ARM_RASPBERRYPI_MMU_H
#define LIBBSP_ARM_RASPBERRYPI_MMU_H
#include <libcpu/arm-cp15.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/**
* @defgroup raspberrypi_mmu MMU Support
*
* @ingroup raspberrypi
*
* @brief MMU support.
*
* @{
*/
#define RASPBERRYPI_MMU_CLIENT_DOMAIN 15U
#define RASPBERRYPI_MMU_READ_ONLY \
((RASPBERRYPI_MMU_CLIENT_DOMAIN << ARM_MMU_SECT_DOMAIN_SHIFT) \
| ARM_MMU_SECT_DEFAULT)
#define RASPBERRYPI_MMU_READ_ONLY_CACHED \
(RASPBERRYPI_MMU_READ_ONLY | ARM_MMU_SECT_C | ARM_MMU_SECT_B)
#define RASPBERRYPI_MMU_READ_WRITE \
((RASPBERRYPI_MMU_CLIENT_DOMAIN << ARM_MMU_SECT_DOMAIN_SHIFT) \
| ARM_MMU_SECT_AP_0 \
| ARM_MMU_SECT_DEFAULT)
#define RASPBERRYPI_MMU_READ_WRITE_CACHED \
(RASPBERRYPI_MMU_READ_WRITE | ARM_MMU_SECT_C | ARM_MMU_SECT_B)
/** @} */
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* LIBBSP_ARM_RASPBERRYPI_MMU_H */

View File

@@ -0,0 +1,194 @@
/*
* raspberrypi.h
*
* Copyright (c) 2013 Alan Cudmore.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
*
* http://www.rtems.com/license/LICENSE
*
*/
#ifndef LIBBSP_ARM_RASPBERRYPI_RASPBERRYPI_H
#define LIBBSP_ARM_RASPBERRYPI_RASPBERRYPI_H
#include <stdint.h>
#include <bsp/utility.h>
/**
* @defgroup raspberrypi_reg Register Definitions
*
* @ingroup raspberrypi
*
* @brief Register definitions.
*
* @{
*/
/**
* @name Register Macros
*
* @{
*/
#define BCM2835_REG(x) (*(volatile uint32_t *)(x))
#define BCM2835_BIT(n) (1 << (n))
/** @} */
/**
* @name Internal ARM Timer Registers
*
* @{
*/
#define BCM2835_CLOCK_FREQ 250000000
#define BCM2835_TIMER_BASE (0x2000B400)
#define BCM2835_TIMER_LOD (BCM2835_TIMER_BASE+0x00)
#define BCM2835_TIMER_VAL (BCM2835_TIMER_BASE+0x04)
#define BCM2835_TIMER_CTL (BCM2835_TIMER_BASE+0x08)
#define BCM2835_TIMER_CLI (BCM2835_TIMER_BASE+0x0C)
#define BCM2835_TIMER_RIS (BCM2835_TIMER_BASE+0x10)
#define BCM2835_TIMER_MIS (BCM2835_TIMER_BASE+0x14)
#define BCM2835_TIMER_RLD (BCM2835_TIMER_BASE+0x18)
#define BCM2835_TIMER_DIV (BCM2835_TIMER_BASE+0x1C)
#define BCM2835_TIMER_CNT (BCM2835_TIMER_BASE+0x20)
#define BCM2835_TIMER_PRESCALE 0xF9
/** @} */
/**
* @name GPIO Registers
*
* @{
*/
#define BCM2835_GPIO_REGS_BASE (0x20200000)
#define BCM2835_GPIO_GPFSEL1 (BCM2835_GPIO_REGS_BASE+0x04)
#define BCM2835_GPIO_GPSET0 (BCM2835_GPIO_REGS_BASE+0x1C)
#define BCM2835_GPIO_GPCLR0 (BCM2835_GPIO_REGS_BASE+0x28)
#define BCM2835_GPIO_GPPUD (BCM2835_GPIO_REGS_BASE+0x94)
#define BCM2835_GPIO_GPPUDCLK0 (BCM2835_GPIO_REGS_BASE+0x98)
/** @} */
/**
* @name AUX Registers
*
* @{
*/
#define BCM2835_AUX_BASE (0x20215000)
#define AUX_ENABLES (BCM2835_AUX_BASE+0x04)
#define AUX_MU_IO_REG (BCM2835_AUX_BASE+0x40)
#define AUX_MU_IER_REG (BCM2835_AUX_BASE+0x44)
#define AUX_MU_IIR_REG (BCM2835_AUX_BASE+0x48)
#define AUX_MU_LCR_REG (BCM2835_AUX_BASE+0x4C)
#define AUX_MU_MCR_REG (BCM2835_AUX_BASE+0x50)
#define AUX_MU_LSR_REG (BCM2835_AUX_BASE+0x54)
#define AUX_MU_MSR_REG (BCM2835_AUX_BASE+0x58)
#define AUX_MU_SCRATCH (BCM2835_AUX_BASE+0x5C)
#define AUX_MU_CNTL_REG (BCM2835_AUX_BASE+0x60)
#define AUX_MU_STAT_REG (BCM2835_AUX_BASE+0x64)
#define AUX_MU_BAUD_REG (BCM2835_AUX_BASE+0x68)
/** @} */
/**
* @name UART 0 (PL011) Registers
*
* @{
*/
#define BCM2835_UART0_BASE (0x20201000)
#define BCM2835_UART0_DR (BCM2835_UART0_BASE+0x00)
#define BCM2835_UART0_RSRECR (BCM2835_UART0_BASE+0x04)
#define BCM2835_UART0_FR (BCM2835_UART0_BASE+0x18)
#define BCM2835_UART0_ILPR (BCM2835_UART0_BASE+0x20)
#define BCM2835_UART0_IBRD (BCM2835_UART0_BASE+0x24)
#define BCM2835_UART0_FBRD (BCM2835_UART0_BASE+0x28)
#define BCM2835_UART0_LCRH (BCM2835_UART0_BASE+0x2C)
#define BCM2835_UART0_CR (BCM2835_UART0_BASE+0x30)
#define BCM2835_UART0_IFLS (BCM2835_UART0_BASE+0x34)
#define BCM2835_UART0_IMSC (BCM2835_UART0_BASE+0x38)
#define BCM2835_UART0_RIS (BCM2835_UART0_BASE+0x3C)
#define BCM2835_UART0_MIS (BCM2835_UART0_BASE+0x40)
#define BCM2835_UART0_ICR (BCM2835_UART0_BASE+0x44)
#define BCM2835_UART0_DMACR (BCM2835_UART0_BASE+0x48)
#define BCM2835_UART0_ITCR (BCM2835_UART0_BASE+0x80)
#define BCM2835_UART0_ITIP (BCM2835_UART0_BASE+0x84)
#define BCM2835_UART0_ITOP (BCM2835_UART0_BASE+0x88)
#define BCM2835_UART0_TDR (BCM2835_UART0_BASE+0x8C)
#define BCM2835_UART0_MIS_RX 0x10
#define BCM2835_UART0_MIS_TX 0x20
#define BCM2835_UART0_IMSC_RX 0x10
#define BCM2835_UART0_IMSC_TX 0x20
#define BCM2835_UART0_FR_RXFE 0x10
#define BCM2835_UART0_FR_TXFF 0x20
#define BCM2835_UART0_ICR_RX 0x10
#define BCM2835_UART0_ICR_TX 0x20
/** @} */
/**
* @name IRQ Registers
*
* @{
*/
#define BCM2835_BASE_INTC (0x2000B200)
#define BCM2835_IRQ_BASIC (BCM2835_BASE_INTC + 0x00)
#define BCM2835_IRQ_PENDING1 (BCM2835_BASE_INTC + 0x04)
#define BCM2835_IRQ_PENDING2 (BCM2835_BASE_INTC + 0x08)
#define BCM2835_IRQ_FIQ_CTRL (BCM2835_BASE_INTC + 0x0C)
#define BCM2835_IRQ_ENABLE1 (BCM2835_BASE_INTC + 0x10)
#define BCM2835_IRQ_ENABLE2 (BCM2835_BASE_INTC + 0x14)
#define BCM2835_IRQ_ENABLE_BASIC (BCM2835_BASE_INTC + 0x18)
#define BCM2835_IRQ_DISABLE1 (BCM2835_BASE_INTC + 0x1C)
#define BCM2835_IRQ_DISABLE2 (BCM2835_BASE_INTC + 0x20)
#define BCM2835_IRQ_DISABLE_BASIC (BCM2835_BASE_INTC + 0x24)
/** @} */
/**
* @name GPU Timer Registers
*
* @{
*/
/**
* NOTE: The GPU uses Compare registers 0 and 2 for
* it's own RTOS. 1 and 3 are available for use in
* RTEMS.
*/
#define BCM2835_GPU_TIMER_BASE (0x20003000)
#define BCM2835_GPU_TIMER_CS (BCM2835_TIMER_BASE+0x00)
#define BCM2835_GPU_TIMER_CLO (BCM2835_TIMER_BASE+0x04)
#define BCM2835_GPU_TIMER_CHI (BCM2835_TIMER_BASE+0x08)
#define BCM2835_GPU_TIMER_C0 (BCM2835_TIMER_BASE+0x0C)
#define BCM2835_GPU_TIMER_C1 (BCM2835_TIMER_BASE+0x10)
#define BCM2835_GPU_TIMER_C2 (BCM2835_TIMER_BASE+0x14)
#define BCM2835_GPU_TIMER_C3 (BCM2835_TIMER_BASE+0x18)
/** @} */
/** @} */
#endif /* LIBBSP_ARM_RASPBERRYPI_RASPBERRYPI_H */

View File

@@ -0,0 +1,26 @@
/*
* Copyright (c) 2013 Alan Cudmore.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE
*/
#ifndef LIBBSP_ARM_RASPBERRYPI_USART_H
#define LIBBSP_ARM_RASPBERRYPI_USART_H
#include <libchip/serial.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define USART0_DEFAULT_BAUD 115000
extern const console_fns bcm2835_usart_fns;
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* LIBBSP_ARM_RASPBERRYPI_USART_H */

View File

@@ -0,0 +1,124 @@
/**
* @file
*
* @ingroup bsp_interrupt
*
* @brief Interrupt support.
*/
/*
* Copyright (c) 2009
* embedded brains GmbH
* Obere Lagerstr. 30
* D-82178 Puchheim
* Germany
* <rtems@embedded-brains.de>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*/
#include <rtems/score/armv4.h>
#include <bsp.h>
#include <bsp/irq.h>
#include <bsp/irq-generic.h>
#include <bsp/raspberrypi.h>
#include <bsp/linker-symbols.h>
#include <bsp/mmu.h>
/*
** This sets the main exception vectors
*/
void raspberrypi_set_exception_handler(
Arm_symbolic_exception_name exception,
void (*handler)(void)
)
{
if ((unsigned) exception < MAX_EXCEPTIONS)
{
uint32_t *table = (uint32_t *) bsp_section_vector_begin + MAX_EXCEPTIONS;
table [exception] = (uint32_t) handler;
}
}
/*
** Determine the source of the interrupt and dispatch the correct handler.
*/
void bsp_interrupt_dispatch(void)
{
rtems_vector_number vector = 255;
/* ARM timer */
if (BCM2835_REG(BCM2835_IRQ_BASIC) && 0x1)
{
vector = BCM2835_IRQ_ID_TIMER_0;
}
/* UART 0 */
else if ( BCM2835_REG(BCM2835_IRQ_BASIC) && BCM2835_BIT(19))
{
vector = BCM2835_IRQ_ID_UART;
}
if ( vector < 255 )
{
bsp_interrupt_handler_dispatch(vector);
}
}
rtems_status_code bsp_interrupt_vector_enable(rtems_vector_number vector)
{
rtems_interrupt_level level;
rtems_interrupt_disable(level);
/* ARM Timer */
if ( vector == BCM2835_IRQ_ID_TIMER_0 )
{
BCM2835_REG(BCM2835_IRQ_ENABLE_BASIC) = 0x1;
}
/* UART 0 */
else if ( vector == BCM2835_IRQ_ID_UART )
{
BCM2835_REG(BCM2835_IRQ_ENABLE2) = BCM2835_BIT(25);
}
rtems_interrupt_enable(level);
return RTEMS_SUCCESSFUL;
}
rtems_status_code bsp_interrupt_vector_disable(rtems_vector_number vector)
{
rtems_interrupt_level level;
rtems_interrupt_disable(level);
if ( vector == BCM2835_IRQ_ID_TIMER_0 )
{
BCM2835_REG(BCM2835_IRQ_DISABLE_BASIC) = 0x1;
}
else if ( vector == BCM2835_IRQ_ID_UART )
{
BCM2835_REG(BCM2835_IRQ_DISABLE2) = BCM2835_BIT(25);
}
rtems_interrupt_enable(level);
return RTEMS_SUCCESSFUL;
}
void bsp_interrupt_handler_default(rtems_vector_number vector)
{
printk("spurious interrupt: %u\n", vector);
}
rtems_status_code bsp_interrupt_facility_initialize(void)
{
raspberrypi_set_exception_handler(ARM_EXCEPTION_IRQ, _ARMV4_Exception_interrupt);
return RTEMS_SUCCESSFUL;
}

View File

@@ -0,0 +1,22 @@
#
# Config file for RASPBERRYPI
#
# $Id: $
#
include $(RTEMS_ROOT)/make/custom/default.cfg
RTEMS_CPU = arm
CPU_CFLAGS = -mcpu=arm1176jzf-s
CFLAGS_OPTIMIZE_V = -O2 -g
# This defines the operations performed on the linked executable.
# is currently required.
define bsp-post-link
$(OBJCOPY) -O binary --strip-all \
$(basename $@).exe $(basename $@)$(DOWNEXT)
$(SIZE) $(basename $@).exe
endef

View File

@@ -0,0 +1,49 @@
/**
* @file
*
* @ingroup raspberrypi
*
* @brief Benchmark timer support.
*/
/*
* Copyright (c) 2013 by Alan Cudmore
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
*
* http://www.rtems.com/license/LICENSE
*
*/
#include <rtems.h>
#include <rtems/timerdrv.h>
#include <bsp/raspberrypi.h>
static bool benchmark_timer_find_average_overhead = false;
static uint64_t benchmark_timer_base;
void benchmark_timer_initialize(void)
{
benchmark_timer_base = BCM2835_REG(BCM2835_GPU_TIMER_CLO);
}
uint32_t benchmark_timer_read(void)
{
uint32_t delta = BCM2835_REG(BCM2835_GPU_TIMER_CLO) - benchmark_timer_base;
if (benchmark_timer_find_average_overhead)
{
return delta;
}
else
{
return BCM2835_REG(BCM2835_GPU_TIMER_CLO);
}
}
void benchmark_timer_disable_subtracting_average_overhead(bool find_average_overhead)
{
benchmark_timer_find_average_overhead = find_average_overhead;
}

View File

@@ -0,0 +1,140 @@
## Automatically generated by ampolish3 - Do not edit
if AMPOLISH3
$(srcdir)/preinstall.am: Makefile.am
$(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am
endif
PREINSTALL_DIRS =
DISTCLEANFILES += $(PREINSTALL_DIRS)
all-local: $(TMPINSTALL_FILES)
TMPINSTALL_FILES =
CLEANFILES = $(TMPINSTALL_FILES)
all-am: $(PREINSTALL_FILES)
PREINSTALL_FILES =
CLEANFILES += $(PREINSTALL_FILES)
$(PROJECT_LIB)/$(dirstamp):
@$(MKDIR_P) $(PROJECT_LIB)
@: > $(PROJECT_LIB)/$(dirstamp)
PREINSTALL_DIRS += $(PROJECT_LIB)/$(dirstamp)
$(PROJECT_INCLUDE)/$(dirstamp):
@$(MKDIR_P) $(PROJECT_INCLUDE)
@: > $(PROJECT_INCLUDE)/$(dirstamp)
PREINSTALL_DIRS += $(PROJECT_INCLUDE)/$(dirstamp)
$(PROJECT_INCLUDE)/bsp/$(dirstamp):
@$(MKDIR_P) $(PROJECT_INCLUDE)/bsp
@: > $(PROJECT_INCLUDE)/bsp/$(dirstamp)
PREINSTALL_DIRS += $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(PROJECT_INCLUDE)/libcpu/$(dirstamp):
@$(MKDIR_P) $(PROJECT_INCLUDE)/libcpu
@: > $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
PREINSTALL_DIRS += $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
$(PROJECT_LIB)/bsp_specs: bsp_specs $(PROJECT_LIB)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_LIB)/bsp_specs
PREINSTALL_FILES += $(PROJECT_LIB)/bsp_specs
$(PROJECT_INCLUDE)/bsp.h: include/bsp.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp.h
$(PROJECT_INCLUDE)/tm27.h: ../../shared/include/tm27.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/tm27.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/tm27.h
$(PROJECT_INCLUDE)/coverhd.h: ../../shared/include/coverhd.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/coverhd.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/coverhd.h
$(PROJECT_INCLUDE)/bspopts.h: include/bspopts.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bspopts.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bspopts.h
$(PROJECT_INCLUDE)/bsp/bootcard.h: ../../shared/include/bootcard.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/bootcard.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/bootcard.h
$(PROJECT_INCLUDE)/bsp/utility.h: ../../shared/include/utility.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/utility.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/utility.h
$(PROJECT_INCLUDE)/bsp/irq-generic.h: ../../shared/include/irq-generic.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq-generic.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq-generic.h
$(PROJECT_INCLUDE)/bsp/irq-info.h: ../../shared/include/irq-info.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq-info.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq-info.h
$(PROJECT_INCLUDE)/bsp/stackalloc.h: ../../shared/include/stackalloc.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/stackalloc.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/stackalloc.h
$(PROJECT_INCLUDE)/bsp/uart-output-char.h: ../../shared/include/uart-output-char.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/uart-output-char.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/uart-output-char.h
$(PROJECT_INCLUDE)/bsp/tod.h: ../../shared/tod.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/tod.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/tod.h
$(PROJECT_INCLUDE)/bsp/linker-symbols.h: ../shared/include/linker-symbols.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/linker-symbols.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/linker-symbols.h
$(PROJECT_INCLUDE)/bsp/start.h: ../shared/include/start.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/start.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/start.h
$(PROJECT_INCLUDE)/bsp/lpc-timer.h: ../shared/lpc/include/lpc-timer.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/lpc-timer.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/lpc-timer.h
$(PROJECT_INCLUDE)/bsp/lpc-dma.h: ../shared/lpc/include/lpc-dma.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/lpc-dma.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/lpc-dma.h
$(PROJECT_INCLUDE)/bsp/irq.h: include/irq.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq.h
$(PROJECT_INCLUDE)/bsp/mmu.h: include/mmu.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/mmu.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/mmu.h
$(PROJECT_INCLUDE)/bsp/usart.h: include/usart.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/usart.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/usart.h
$(PROJECT_INCLUDE)/bsp/raspberrypi.h: include/raspberrypi.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/raspberrypi.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/raspberrypi.h
$(PROJECT_INCLUDE)/libcpu/cache_.h: ../../../libcpu/arm/shared/include/cache_.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/cache_.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/cache_.h
$(PROJECT_INCLUDE)/libcpu/arm-cp15.h: ../../../libcpu/arm/shared/include/arm-cp15.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/arm-cp15.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/arm-cp15.h
$(PROJECT_LIB)/start.$(OBJEXT): start.$(OBJEXT) $(PROJECT_LIB)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_LIB)/start.$(OBJEXT)
TMPINSTALL_FILES += $(PROJECT_LIB)/start.$(OBJEXT)
$(PROJECT_LIB)/linkcmds: startup/linkcmds $(PROJECT_LIB)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_LIB)/linkcmds
TMPINSTALL_FILES += $(PROJECT_LIB)/linkcmds
$(PROJECT_LIB)/linkcmds.base: ../shared/startup/linkcmds.base $(PROJECT_LIB)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_LIB)/linkcmds.base
TMPINSTALL_FILES += $(PROJECT_LIB)/linkcmds.base

View File

@@ -0,0 +1,35 @@
/**
* @file
*
* @ingroup raspberrypi
*
* @brief Reset code.
*/
/*
* Copyright (c) 2013 by Alan Cudmore
* Based on work by:
* Copyright (c) 2009
* embedded brains GmbH
* Obere Lagerstr. 30
* D-82178 Puchheim
* Germany
* <rtems@embedded-brains.de>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
*
* http://www.rtems.com/license/LICENSE
*
*/
#include <rtems.h>
#include <bsp/bootcard.h>
void bsp_reset( void)
{
while (true) {
/* Do nothing */
}
}

View File

@@ -0,0 +1,29 @@
/**
* @file
*
* @ingroup raspberrypi
*
* @brief Startup code.
*/
/*
* Copyright (c) 2013 by Alan Cudmore
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
*
* http://www.rtems.com/license/LICENSE
*/
#include <bsp.h>
#include <bsp/bootcard.h>
#include <bsp/irq-generic.h>
#include <bsp/irq.h>
#include <bsp/linker-symbols.h>
#include <bsp/stackalloc.h>
#include <bsp/raspberrypi.h>
void bsp_start(void)
{
bsp_interrupt_initialize();
}

View File

@@ -0,0 +1,114 @@
/**
* @file
*
* @ingroup raspberrypi
*
* @brief Startup code.
*/
/*
* Copyright (c) 2013 by Alan Cudmore
* based on work by:
* Copyright (c) 2009
* embedded brains GmbH
* Obere Lagerstr. 30
* D-82178 Puchheim
* Germany
* <rtems@embedded-brains.de>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE
*/
#include <stdbool.h>
#include <bspopts.h>
#include <bsp/start.h>
#include <bsp/raspberrypi.h>
#include <bsp/mmu.h>
#include <bsp/linker-symbols.h>
#include <bsp/uart-output-char.h>
static void BSP_START_TEXT_SECTION clear_bss(void)
{
const int *end = (const int *) bsp_section_bss_end;
int *out = (int *) bsp_section_bss_begin;
/* Clear BSS */
while (out != end) {
*out = 0;
++out;
}
}
static void BSP_START_TEXT_SECTION raspberrypi_cache_setup(void)
{
uint32_t ctrl = 0;
/* Disable MMU and cache, basic settings */
ctrl = arm_cp15_get_control();
ctrl &= ~(ARM_CP15_CTRL_I | ARM_CP15_CTRL_R | ARM_CP15_CTRL_C
| ARM_CP15_CTRL_V | ARM_CP15_CTRL_M);
ctrl |= ARM_CP15_CTRL_S | ARM_CP15_CTRL_A;
arm_cp15_set_control(ctrl);
arm_cp15_cache_invalidate();
arm_cp15_tlb_invalidate();
}
void BSP_START_TEXT_SECTION bsp_start_hook_0(void)
{
raspberrypi_cache_setup();
}
void BSP_START_TEXT_SECTION bsp_start_hook_1(void)
{
/* Copy .text section */
arm_cp15_instruction_cache_invalidate();
bsp_start_memcpy(
(int *) bsp_section_text_begin,
(const int *) bsp_section_text_load_begin,
(size_t) bsp_section_text_size
);
/* Copy .rodata section */
arm_cp15_instruction_cache_invalidate();
bsp_start_memcpy(
(int *) bsp_section_rodata_begin,
(const int *) bsp_section_rodata_load_begin,
(size_t) bsp_section_rodata_size
);
/* Copy .data section */
arm_cp15_instruction_cache_invalidate();
bsp_start_memcpy(
(int *) bsp_section_data_begin,
(const int *) bsp_section_data_load_begin,
(size_t) bsp_section_data_size
);
/* Copy .fast_text section */
arm_cp15_instruction_cache_invalidate();
bsp_start_memcpy(
(int *) bsp_section_fast_text_begin,
(const int *) bsp_section_fast_text_load_begin,
(size_t) bsp_section_fast_text_size
);
/* Copy .fast_data section */
arm_cp15_instruction_cache_invalidate();
bsp_start_memcpy(
(int *) bsp_section_fast_data_begin,
(const int *) bsp_section_fast_data_load_begin,
(size_t) bsp_section_fast_data_size
);
/* Clear .bss section */
clear_bss();
}

View File

@@ -0,0 +1,62 @@
/**
* @file
*
* @ingroup raspberry_pi
*
* @brief Memory map.
*/
/**
* @defgroup raspberry_pi Memory Map
*
* @ingroup bsp_linker
*
* @brief Raspberry Pi memory map.
*
* <table>
* <tr><th>Region Name</th><th>Region Begin</th><th>Region Size</th></tr>
* <tr><td>VECTOR_RAM</td><td>0x08000000</td><td>8k</td></tr>
* <tr><td>RAM</td><td>0x80008000</td><td>128M</td></tr>
* </table>
*
* <table>
* <tr><th>Section Name</th><th>Section Runtime Region</th><th>Section Load Region</th></tr>
* <tr><td>.start</td><td>RAM</td><td></td></tr>
* <tr><td>.vector</td><td>VECTOR_RAM</td><td></td></tr>
* <tr><td>.text</td><td>RAM</td><td>RAM_EXT</td></tr>
* <tr><td>.rodata</td><td>RAM</td><td>RAM_EXT</td></tr>
* <tr><td>.data</td><td>RAM</td><td>RAM_EXT</td></tr>
* <tr><td>.fast</td><td>RAM</td><td>RAM_EXT</td></tr>
* <tr><td>.bss</td><td>RAM</td><td></td></tr>
* <tr><td>.work</td><td>RAM</td><td></td></tr>
* <tr><td>.stack</td><td>RAM</td><td></td></tr>
* </table>
*/
MEMORY {
VECTOR_RAM (AIW) : ORIGIN = 0x0 , LENGTH = 0x8000
RAM (AIW) : ORIGIN = 0x00008000, LENGTH = 128M - 0x8000
}
REGION_ALIAS ("REGION_START", RAM);
REGION_ALIAS ("REGION_VECTOR", VECTOR_RAM);
REGION_ALIAS ("REGION_TEXT", RAM);
REGION_ALIAS ("REGION_TEXT_LOAD", RAM);
REGION_ALIAS ("REGION_RODATA", RAM);
REGION_ALIAS ("REGION_RODATA_LOAD", RAM);
REGION_ALIAS ("REGION_DATA", RAM);
REGION_ALIAS ("REGION_DATA_LOAD", RAM);
REGION_ALIAS ("REGION_FAST_TEXT", RAM);
REGION_ALIAS ("REGION_FAST_TEXT_LOAD", RAM);
REGION_ALIAS ("REGION_FAST_DATA", RAM);
REGION_ALIAS ("REGION_FAST_DATA_LOAD", RAM);
REGION_ALIAS ("REGION_BSS", RAM);
REGION_ALIAS ("REGION_WORK", RAM);
REGION_ALIAS ("REGION_STACK", RAM);
bsp_stack_irq_size = DEFINED (bsp_stack_irq_size) ? bsp_stack_irq_size : 4096;
bsp_stack_abt_size = DEFINED (bsp_stack_abt_size) ? bsp_stack_abt_size : 1024;
bsp_section_robarrier_align = DEFINED (bsp_section_robarrier_align) ? bsp_section_robarrier_align : 1M;
INCLUDE linkcmds.armv4