2008-08-15 Allan Hessenflow <allanh@kallisti.com>

* ChangeLog, Makefile.am, README, bsp_specs, configure.ac,
	preinstall.am, console/console.c, include/bsp.h,
	network/networkconfig.c, start/start.S, startup/bspstart.c,
	startup/linkcmds: New files.
This commit is contained in:
Joel Sherrill
2008-08-15 20:21:00 +00:00
parent 8f45d1de30
commit 61f8fb0e3d
12 changed files with 1069 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
2008-08-15 Allan Hessenflow <allanh@kallisti.com>
* ChangeLog, Makefile.am, README, bsp_specs, configure.ac,
preinstall.am, console/console.c, include/bsp.h,
network/networkconfig.c, start/start.S, startup/bspstart.c,
startup/linkcmds: New files.

View File

@@ -0,0 +1,69 @@
##
## $Id$
##
ACLOCAL_AMFLAGS = -I ../../../../aclocal
include $(top_srcdir)/../../../../automake/compile.am
include $(top_srcdir)/../../bsp.am
dist_project_lib_DATA = bsp_specs
include_HEADERS = include/bsp.h
include_HEADERS += ../../shared/include/tm27.h
nodist_include_HEADERS = include/bspopts.h
DISTCLEANFILES = include/bspopts.h
noinst_PROGRAMS =
include_HEADERS += ../../shared/include/coverhd.h
EXTRA_DIST = start/start.S
start.$(OBJEXT): start/start.S
$(CPPASCOMPILE) -DASM -o $@ -c $<
project_lib_DATA = start.$(OBJEXT)
dist_project_lib_DATA += startup/linkcmds
noinst_PROGRAMS += startup.rel
startup_rel_SOURCES = ../../shared/bsplibc.c ../../shared/bsppost.c \
../../shared/bsppredriverhook.c startup/bspstart.c \
../../shared/bspclean.c ../../shared/sbrk.c ../../shared/setvec.c \
../../shared/bootcard.c ../../shared/gnatinstallhandler.c
startup_rel_CPPFLAGS = $(AM_CPPFLAGS)
startup_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
noinst_PROGRAMS += console.rel
console_rel_SOURCES = console/console.c
console_rel_CPPFLAGS = $(AM_CPPFLAGS)
console_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
if HAS_NETWORKING
networkconfig_CPPFLAGS = -D__INSIDE_RTEMS_BSD_TCPIP_STACK__
noinst_PROGRAMS += networkconfig.rel
networkconfig_rel_SOURCES = network/networkconfig.c
networkconfig_rel_CPPFLAGS = $(AM_CPPFLAGS) $(networkconfig_CPPFLAGS)
networkconfig_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
endif
noinst_LIBRARIES = libbsp.a
libbsp_a_SOURCES =
libbsp_a_LIBADD = startup.rel console.rel
if HAS_NETWORKING
libbsp_a_LIBADD += networkconfig.rel
libbsp_a_LIBADD += ../../../libcpu/@RTEMS_CPU@/network.rel
endif
libbsp_a_LIBADD += ../../../libcpu/@RTEMS_CPU@/mmu.rel
libbsp_a_LIBADD += ../../../libcpu/@RTEMS_CPU@/interrupt.rel
libbsp_a_LIBADD += ../../../libcpu/@RTEMS_CPU@/cache.rel
libbsp_a_LIBADD += ../../../libcpu/@RTEMS_CPU@/uart.rel
libbsp_a_LIBADD += ../../../libcpu/@RTEMS_CPU@/clock.rel
libbsp_a_LIBADD += ../../../libcpu/@RTEMS_CPU@/rtc.rel
libbsp_a_LIBADD += ../../../libcpu/@RTEMS_CPU@/timer.rel
EXTRA_DIST += times
include $(srcdir)/preinstall.am
include $(top_srcdir)/../../../../automake/local.am

View File

@@ -0,0 +1,41 @@
#
# $Id$
#
BSP NAME: bf537Stamp
BOARD: ADZS-BF537-STAMP
CPU FAMILY: Blackfin
CPU: Blackfin 537
MODE: 32 bit mode
DEBUG MONITOR: ICEBear
SIMULATOR: Skyeye
PERIPHERALS
===========
TIMERS: internal
RESOLUTION: 1 milisecond
SERIAL PORTS: internal UART (polled/interrupt)
REAL-TIME CLOCK: internal
DMA: internal
VIDEO: none
SCSI: none
NETWORKING: internal
DRIVER INFORMATION
==================
CLOCK DRIVER: internal
TIMER DRIVER: internal
STDIO
=====
PORT: Console port 0
ELECTRICAL: RS-232
BAUD: 57600
BITS PER CHARACTER: 8
PARITY: None
STOP BITS: 1
NOTES
=====

View File

@@ -0,0 +1,10 @@
%rename endfile old_endfile
%rename startfile old_startfile
%rename link old_link
*startfile:
%{!qrtems: %(old_startfile)} \
%{!nostdlib: %{qrtems: start.o%s}}
*link:
%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N -e __start}

View File

@@ -0,0 +1,29 @@
## Process this file with autoconf to produce a configure script.
##
## $Id$
##
AC_PREREQ(2.60)
AC_INIT([rtems-c-src-lib-libbsp-bfin-bf537Stamp],[_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.10])
RTEMS_BSP_CONFIGURE
RTEMS_PROG_CC_FOR_TARGET([-ansi -fasm])
RTEMS_CANONICALIZE_TOOLS
RTEMS_PROG_CCAS
RTEMS_CHECK_NETWORKING
AM_CONDITIONAL(HAS_NETWORKING,test "$HAS_NETWORKING" = "yes")
## bsp-specific options
RTEMS_BSPOPTS_SET([CONSOLE_USE_INTERRUPTS],[*],[0])
RTEMS_BSPOPTS_HELP([CONSOLE_USE_INTERRUPTS],
[The console driver can operate in either polled or interrupt mode.])
# Explicitly list all Makefiles here
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

View File

@@ -0,0 +1,132 @@
/* Console driver for bf537Stamp
*
* Copyright (c) 2008 Kallisti Labs, Los Gatos, CA, USA
* written by Allan Hessenflow <allanh@kallisti.com>
*
* 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.
*
* $Id$
*/
#include <rtems.h>
#include <rtems/libio.h>
#include <bsp.h>
#include <rtems/bspIo.h>
#include <libcpu/bf537.h>
#include <libcpu/interrupt.h>
#include <libcpu/uart.h>
/*
#undef CONSOLE_USE_INTERRUPTS
#define CONSOLE_USE_INTERRUPTS 1
*/
static bfin_uart_channel_t channels[] = {
{"/dev/console",
(char *) UART0_BASE_ADDRESS,
CONSOLE_USE_INTERRUPTS,
#ifdef CONSOLE_FORCE_BAUD
CONSOLE_FORCE_BAUD,
#else
0,
#endif
NULL,
0},
{"/dev/tty1",
(char *) UART1_BASE_ADDRESS,
CONSOLE_USE_INTERRUPTS,
0,
NULL,
0}
};
static bfin_uart_config_t config = {
SCLK,
sizeof(channels) / sizeof(channels[0]),
channels
};
#if CONSOLE_USE_INTERRUPTS
static bfin_isr_t bfinUARTISRs[] = {
{SIC_DMA8_UART0_RX_VECTOR, bfin_uart_isr, 0, 0, NULL},
{SIC_DMA10_UART1_RX_VECTOR, bfin_uart_isr, 0, 0, NULL},
{SIC_DMA9_UART0_TX_VECTOR, bfin_uart_isr, 0, 0, NULL},
{SIC_DMA11_UART1_TX_VECTOR, bfin_uart_isr, 0, 0, NULL}
};
#endif
static void bf537Stamp_BSP_output_char(char c) {
bfin_uart_poll_write(0, c);
}
static char bf537Stamp_BSP_poll_char(void) {
return bfin_uart_poll_read(0);
}
BSP_output_char_function_type BSP_output_char = bf537Stamp_BSP_output_char;
BSP_polling_getchar_function_type BSP_poll_char = bf537Stamp_BSP_poll_char;
rtems_device_driver console_initialize(rtems_device_major_number major,
rtems_device_minor_number minor,
void *arg) {
rtems_status_code status;
#if CONSOLE_USE_INTERRUPTS
int i;
#endif
status = bfin_uart_initialize(major, &config);
#if CONSOLE_USE_INTERRUPTS
for (i = 0; i < sizeof(bfinUARTISRs) / sizeof(bfinUARTISRs[0]); i++) {
bfin_interrupt_register(&bfinUARTISRs[i]);
bfin_interrupt_enable(&bfinUARTISRs[i], TRUE);
}
#endif
if (status != RTEMS_SUCCESSFUL)
rtems_fatal_error_occurred(status);
return RTEMS_SUCCESSFUL;
}
rtems_device_driver console_open(rtems_device_major_number major,
rtems_device_minor_number minor,
void *arg) {
return bfin_uart_open(major, minor, arg);
}
rtems_device_driver console_close(rtems_device_major_number major,
rtems_device_minor_number minor,
void *arg) {
return rtems_termios_close(arg);
}
rtems_device_driver console_read(rtems_device_major_number major,
rtems_device_minor_number minor,
void *arg) {
return rtems_termios_read(arg);
}
rtems_device_driver console_write(rtems_device_major_number major,
rtems_device_minor_number minor,
void *arg) {
return rtems_termios_write(arg);
}
rtems_device_driver console_control(rtems_device_major_number major,
rtems_device_minor_number minor,
void *arg) {
return rtems_termios_ioctl(arg);
}

View File

@@ -0,0 +1,139 @@
/* bsp.h
*
* This include file contains all board IO definitions for bf537Stamp.
*
* Copyright (c) 2006 by Atos Automacao Industrial Ltda.
* written by Alain Schaefer <alain.schaefer@easc.ch>
* and Antonio Giovanini <antonio@atos.com.br>
*
* 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.
*
* $Id$
*/
#ifndef _BSP_H
#define _BSP_H
#ifdef __cplusplus
extern "C" {
#endif
#include <bspopts.h>
#include <rtems.h>
#include <rtems/console.h>
#include <rtems/clockdrv.h>
#include <libcpu/bf537.h>
#include <libcpu/memoryRegs.h>
/* #define CLOCK_DRIVER_USE_FAST_IDLE */
/* configure data cache to use 16K of each SRAM bank when enabled */
#define BSP_DATA_CACHE_CONFIG (3 << DMEM_CONTROL_DMC_SHIFT)
/*
* PLL and clock setup values:
*/
/*
* PLL configuration for bf533Stamp
*
* XTL = 27 MHz
* CLKIN = 13 MHz
* VCO = 391 MHz
* CCLK = 391 MHz
* SCLK = 130 MHz
*/
#define PLL_CSEL 0x0000 /* CCLK = VCO */
#define PLL_SSEL 0x0003 /* SCLK = CCLK/3 */
#define PLL_MSEL 0x3A00 /* VCO = 29xCLKIN */
#define PLL_DF 0x0001 /* CLKIN = XTL/2 */
#define CCLK 500000000 /* CORE CLOCK */
#define SCLK 100000000 /* SYSTEM CLOCK */
#define CONSOLE_FORCE_BAUD 57600
/*
* Blackfin environment memory map
*/
#define L1_DATA_SRAM_A 0xff800000L
#define FIFOLENGTH 0x100
/*
* confdefs.h overrides for this BSP:
* - number of termios serial ports (defaults to 1)
*/
#define CONFIGURE_NUMBER_OF_TERMIOS_PORTS 2
/*
* Simple spin delay in microsecond units for device drivers.
* This is very dependent on the clock speed of the target.
*/
#define rtems_bsp_delay( microseconds ) \
{ \
}
/* Constants */
#define RAM_START 0
#define RAM_END 0x4000000
/* miscellaneous stuff assumed to exist */
/*
* Device Driver Table Entries
*/
/*
* NOTE: Use the standard Console driver entry
*/
/*
* NOTE: Use the standard Clock driver entry
*/
/* functions */
/*
* Helper Function to use the EzKits LEDS.
* Can be used by the Application.
*/
void setLED(uint8_t value);
/*
* Helper Function to use the EzKits LEDS
*/
uint8_t getLED(void);
rtems_isr_entry set_vector( /* returns old vector */
rtems_isr_entry handler, /* isr routine */
rtems_vector_number vector, /* vector number */
int type /* RTEMS or RAW intr */
);
/*
* Network driver configuration
*/
struct rtems_bsdnet_ifconfig;
extern int bf537Stamp_network_driver_attach(struct rtems_bsdnet_ifconfig *, int);
#define RTEMS_BSP_NETWORK_DRIVER_NAME "eth1"
#define RTEMS_BSP_NETWORK_DRIVER_ATTACH bf537Stamp_network_driver_attach
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,71 @@
/* networkconfig.c
*
* This file contains the network driver attach function and configuration
* for the bf537Stamp.
*
* Copyright (c) 2008 Kallisti Labs, Los Gatos, CA, USA
* written by Allan Hessenflow <allanh@kallisti.com>
*
* 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.
*
* $Id$
*/
#include <bsp.h>
#include <rtems/rtems_bsdnet.h>
#include <libcpu/interrupt.h>
#include <libcpu/ethernet.h>
static bfin_ethernet_configuration_t ethConfig = {
SCLK,
(void *) EMAC_BASE_ADDRESS,
(void *) DMA1_BASE_ADDRESS, /* ethernet receive */
(void *) DMA2_BASE_ADDRESS, /* ethernet transmit */
16, /* receive descriptors */
16, /* transmit descriptors */
mii, /* phy type */
1 /* phy address */
};
static bfin_isr_t ethISRs[] = {
/* careful - shared with a bunch of things */
/*
{SIC_MAC_ERROR_VECTOR,
bfin_ethernet_mac_isr,
0,
0,
NULL},
*/
/* careful - shared with porth irqa */
{SIC_DMA1_MAC_RX_VECTOR,
bfin_ethernet_rxdma_isr,
0,
0,
NULL},
/* careful - shared with porth irqb */
{SIC_DMA2_MAC_TX_VECTOR,
bfin_ethernet_txdma_isr,
0,
0,
NULL}
};
int bf537Stamp_network_driver_attach(struct rtems_bsdnet_ifconfig *config,
int attaching) {
int result;
int i;
result = bfin_ethernet_driver_attach(config, attaching, &ethConfig);
for (i = 0; i < sizeof(ethISRs) / sizeof(ethISRs[0]); i++) {
bfin_interrupt_register(&ethISRs[i]);
bfin_interrupt_enable(&ethISRs[i], TRUE);
}
return result;
}

View File

@@ -0,0 +1,58 @@
## 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_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)/bspopts.h: include/bspopts.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bspopts.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bspopts.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_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
PREINSTALL_FILES += $(PROJECT_LIB)/linkcmds

View File

@@ -0,0 +1,102 @@
/*
* $Id$
*/
#include <libcpu/bf537.h>
#include <libcpu/sicRegs.h>
#include <libcpu/cecRegs.h>
#include <libcpu/coreTimerRegs.h>
#ifndef LO
#define LO(con32) ((con32) & 0xFFFF)
#endif
#ifndef HI
#define HI(con32) (((con32) >> 16) & 0xFFFF)
#endif
.section .init
.globl __init
.type __init,@function
__init:
.section .fini
.globl __fini
.type __fini,@function
__fini:
.section .start
.align 4
.global __start
__start:
cli r0;
/* setup an initial stack */
sp.h = 0xFFB0;
sp.l = 0x0F00;
/* disable timer interrupts */
p0.h = HI(TCNTL);
p0.l = LO(TCNTL);
r0 = 0;
[p0] = r0;
/* disable all interrupts routed through sic */
p0.h = HI(SIC_IMASK);
p0.l = LO(SIC_IMASK);
[p0] = r0;
/* this is so we can stay in supervisor mode and still be able to
accept interrupts later. */
p0.h = start;
p0.l = start;
p1.h = HI(CEC_EVT15);
p1.l = LO(CEC_EVT15);
[p1] = p0;
r0 = 0x8000 (z);
sti r0;
raise 15;
p0.h = wait;
p0.l = wait;
reti = p0;
rti;
/* wait for event 15 */
wait:
jump wait;
start:
[--sp] = reti; /* allow us to process interrupts later */
/* mask interrupts for now */
cli r0;
p0.h = _bss_start;
p0.l = _bss_start;
p1.h = _end;
p1.l = _end;
r0 = p0;
r1 = p1;
r1 = r1 - r0;
p1 = r1;
r0 = 0;
/* Set _bss_start until _end to zero */
lsetup(loop1,loop2) lc0 = p1;
loop1: b[p0] = r0;
loop2: p0 +=1;
p0.h = _boot_card;
p0.l = _boot_card;
call (p0);
p0.h = _exit;
p0.l = _exit;
jump (p0);

View File

@@ -0,0 +1,241 @@
/* bspstart.c for bf537Stamp
*
* This routine starts the application. It includes application,
* board, and monitor specific initialization and configuration.
* The generic CPU dependent initialization has been performed
* before this routine is invoked.
*
* Copyright (c) 2006 by Atos Automacao Industrial Ltda.
* written by Alain Schaefer <alain.schaefer@easc.ch>
* and Antonio Giovanini <antonio@atos.com.br>
*
* 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.
*
* $Id$
*/
#include <string.h>
#include <rtems/libio.h>
#include <rtems/libcsupport.h>
#include <libcpu/bf537.h>
#include <libcpu/gpioRegs.h>
#include <libcpu/mmu.h>
#include <libcpu/interrupt.h>
#include <bsp.h>
#if 0
static bfin_mmu_region_t mmuRegions[] = {
};
#endif
/*
* Use the shared implementations of the following routines
*/
void bsp_postdriver_hook(void);
void bsp_libc_init(void *, uint32_t, int);
void Init_RTC(void);
static void initPLL(void);
static void initEBIU(void);
static void initGPIO(void);
/*
* Function: bsp_pretasking_hook
* Created: 95/03/10
*
* Description:
* BSP pretasking hook. Called just before drivers are initialized.
* Used to setup libc and install any BSP extensions.
*
* NOTES:
* Must not use libc (to do io) from here, since drivers are
* not yet initialized.
*
*/
void bsp_pretasking_hook(void) {
extern int HeapBase;
extern int RamBase;
extern int RamSize;
unsigned long heapSize;
void *heapStart;
bfin_interrupt_init();
heapStart = &HeapBase;
heapSize = (unsigned long) &RamBase;
heapSize += (unsigned long) &RamSize;
heapSize -= (unsigned long) &HeapBase;
bsp_libc_init(heapStart, heapSize, 0);
}
/*
* bsp_start
*
* This routine does the bulk of the system initialization.
*/
void bsp_start(void) {
extern void *_WorkspaceBase;
/* BSP Hardware Initialization*/
/*bfin_mmu_init(sizeof(mmuRegions) / sizeof(mmuRegions[0]), mmuRegions);*/
Init_RTC(); /* Blackfin Real Time Clock initialization */
initPLL(); /* PLL initialization */
initEBIU(); /* EBIU initialization */
initGPIO(); /* GPIO initialization */
/*
* Allocate the memory for the RTEMS Work Space. This can come from
* a variety of places: hard coded address, malloc'ed from outside
* RTEMS world (e.g. simulator or primitive memory manager), or (as
* typically done by stock BSPs) by subtracting the required amount
* of work space from the last physical address on the CPU board.
*/
/*
* Need to "allocate" the memory for the RTEMS Workspace and
* tell the RTEMS configuration where it is. This memory is
* not malloc'ed. It is just "pulled from the air".
*/
Configuration.work_space_start = (void *) &_WorkspaceBase;
}
/*
* initPLL
*
* Routine to initialize the PLL. The BF537 Stamp uses a 27 Mhz XTAL. BISON
* See "../bf537Stamp/include/bsp.h" for more information.
*/
static void initPLL(void) {
#ifdef BISON
unsigned int n;
/* Configure PLL registers */
*((uint16_t*)PLL_LOCKCNT) = 0x1000;
*((uint16_t*)PLL_DIV) = PLL_CSEL|PLL_SSEL;
*((uint16_t*)PLL_CTL) = PLL_MSEL|PLL_DF;
/* Commands to set PLL values */
asm("cli r0;");
asm("idle;");
asm("sti r0;");
/* Delay for PLL stabilization */
for (n=0; n<200; n++) {}
#endif
}
/*
* initEBIU
*
* Configure extern memory
*/
static void initEBIU(void) {
#ifdef BISON
/* Configure FLASH */
*((uint32_t*)EBIU_AMBCTL0) = 0x7bb07bb0L;
*((uint32_t*)EBIU_AMBCTL1) = 0x7bb07bb0L;
*((uint16_t*)EBIU_AMGCTL) = 0x000f;
/* Configure SDRAM
*((uint32_t*)EBIU_SDGCTL) = 0x0091998d;
*((uint16_t*)EBIU_SDBCTL) = 0x0013;
*((uint16_t*)EBIU_SDRRC) = 0x0817;
*/
#endif
}
/*
* initGPIO
*
* Enable LEDs port
*/
static void initGPIO(void) {
*(uint16_t volatile *) PORT_MUX = 0;
/* port f bits 0, 1: uart0 tx, rx */
/* bits 2 - 5: buttons */
/* bits 6 - 11: leds */
*(uint16_t volatile *) PORTF_FER = 0x0003;
*(uint16_t volatile *) (PORTFIO_BASE_ADDRESS + PORTIO_OFFSET) = 0x0000;
*(uint16_t volatile *) (PORTFIO_BASE_ADDRESS + PORTIO_INEN_OFFSET) = 0x003c;
*(uint16_t volatile *) (PORTFIO_BASE_ADDRESS + PORTIO_POLAR_OFFSET) = 0x0000;
*(uint16_t volatile *) (PORTFIO_BASE_ADDRESS + PORTIO_EDGE_OFFSET) = 0x0000;
*(uint16_t volatile *) (PORTFIO_BASE_ADDRESS + PORTIO_BOTH_OFFSET) = 0x0000;
*(uint16_t volatile *) (PORTFIO_BASE_ADDRESS + PORTIO_MASKA_OFFSET) = 0x0000;
*(uint16_t volatile *) (PORTFIO_BASE_ADDRESS + PORTIO_MASKB_OFFSET) = 0x0000;
*(uint16_t volatile *) (PORTFIO_BASE_ADDRESS + PORTIO_DIR_OFFSET) = 0x0fc0;
*(uint16_t volatile *) PORTG_FER = 0x0000;
*(uint16_t volatile *) (PORTGIO_BASE_ADDRESS + PORTIO_OFFSET) = 0x0000;
*(uint16_t volatile *) (PORTGIO_BASE_ADDRESS + PORTIO_INEN_OFFSET) = 0x0000;
*(uint16_t volatile *) (PORTGIO_BASE_ADDRESS + PORTIO_POLAR_OFFSET) = 0x0000;
*(uint16_t volatile *) (PORTGIO_BASE_ADDRESS + PORTIO_EDGE_OFFSET) = 0x0000;
*(uint16_t volatile *) (PORTGIO_BASE_ADDRESS + PORTIO_BOTH_OFFSET) = 0x0000;
*(uint16_t volatile *) (PORTGIO_BASE_ADDRESS + PORTIO_MASKA_OFFSET) = 0x0000;
*(uint16_t volatile *) (PORTGIO_BASE_ADDRESS + PORTIO_MASKB_OFFSET) = 0x0000;
*(uint16_t volatile *) (PORTGIO_BASE_ADDRESS + PORTIO_DIR_OFFSET) = 0x0000;
/* port h bits 0 - 15: ethernet */
*(uint16_t volatile *) PORTH_FER = 0xffff;
*(uint16_t volatile *) (PORTHIO_BASE_ADDRESS + PORTIO_OFFSET) = 0x0000;
*(uint16_t volatile *) (PORTHIO_BASE_ADDRESS + PORTIO_INEN_OFFSET) = 0x0000;
*(uint16_t volatile *) (PORTHIO_BASE_ADDRESS + PORTIO_POLAR_OFFSET) = 0x0000;
*(uint16_t volatile *) (PORTHIO_BASE_ADDRESS + PORTIO_EDGE_OFFSET) = 0x0000;
*(uint16_t volatile *) (PORTHIO_BASE_ADDRESS + PORTIO_BOTH_OFFSET) = 0x0000;
*(uint16_t volatile *) (PORTHIO_BASE_ADDRESS + PORTIO_MASKA_OFFSET) = 0x0000;
*(uint16_t volatile *) (PORTHIO_BASE_ADDRESS + PORTIO_MASKB_OFFSET) = 0x0000;
*(uint16_t volatile *) (PORTHIO_BASE_ADDRESS + PORTIO_DIR_OFFSET) = 0x0000;
}
/*
* Helper Function to use the EzKits LEDS.
* Can be used by the Application.
*/
void setLEDs(uint8_t value) {
*(uint16_t volatile *) (PORTFIO_BASE_ADDRESS + PORTIO_CLEAR_OFFSET) =
(uint16_t) (~value & 0x3f) << 6;
*(uint16_t volatile *) (PORTFIO_BASE_ADDRESS + PORTIO_SET_OFFSET) =
(uint16_t) (value & 0x3f) << 6;
}
/*
* Helper Function to use the EzKits LEDS
*/
uint8_t getLEDs(void) {
uint16_t r;
r = *(uint16_t volatile *) (PORTFIO_BASE_ADDRESS + PORTIO_OFFSET);
return (uint8_t) ((r >> 6) & 0x3f);
}
uint8_t getButtons(void) {
uint16_t r;
r = *(uint16_t volatile *) (PORTFIO_BASE_ADDRESS + PORTIO_OFFSET);
return (uint8_t) ((r >> 2) & 0x0f);
}

View File

@@ -0,0 +1,170 @@
/*
* $Id$
*/
OUTPUT_FORMAT("elf32-bfin", "elf32-bfin",
"elf32-bfin")
OUTPUT_ARCH(bfin)
ENTRY(__start)
/*
* Declare some sizes.
*/
_RamBase = DEFINED(_RamBase) ? _RamBase : 0x0;
_RamSize = DEFINED(_RamSize) ? _RamSize : 0x04000000;
/*_HeapSize = DEFINED(_HeapSize) ? _HeapSize : 0x0200000;*/
_StackSize = DEFINED(_StackSize) ? _StackSize : 0x1000;
MEMORY
{
sdram(rwx) : ORIGIN = 0x00001000, LENGTH = 0x03fff000
/*
l1code(rwx) : ORIGIN = 0xffa08000, LENGTH = 0x00008000
l1data(rwx) : ORIGIN = 0xff804000, LENGTH = 0x00004000
*/
}
SECTIONS
{
/*
.l1code :
{
*/
/*jump.o (.text)*/
/*
} > l1code
*/
.init :
{
*(.start)
KEEP (*(.init))
} > sdram /*=0*/
.text :
{
CREATE_OBJECT_SYMBOLS
*(.text)
*(.rodata*)
*(.gnu.linkonce.r*)
/*
* Special FreeBSD sysctl sections.
*/
. = ALIGN (16);
___start_set_sysctl_set = .;
*(set_sysctl_*);
___stop_set_sysctl_set = ABSOLUTE(.);
*(set_domain_*);
*(set_pseudo_*);
_etext = .;
___CTOR_LIST__ = .;
LONG((___CTOR_END__ - ___CTOR_LIST__) / 4 - 2)
*(.ctors)
LONG(0)
___CTOR_END__ = .;
___DTOR_LIST__ = .;
LONG((___DTOR_END__ - ___DTOR_LIST__) / 4 - 2)
*(.dtors)
LONG(0)
___DTOR_END__ = .;
} > sdram
.fini :
{
KEEP (*(.fini))
} > sdram /*=0*/
.data :
{
*(.data)
*(.jcr)
*(.gnu.linkonce.d*)
CONSTRUCTORS
_edata = .;
} > sdram
.eh_frame : { *(.eh_frame) } > sdram
.data1 : { *(.data1) } > sdram
.eh_frame : { *(.eh_frame) } > sdram
.gcc_except_table : { *(.gcc_except_table*) } > sdram
.rodata :
{
*(.rodata)
*(.rodata.*)
*(.gnu.linkonce.r*)
} > sdram
.bss :
{
_bss_start = .;
_clear_start = .;
*(.bss)
*(.gnu.linkonce.b.*)
*(COMMON)
. = ALIGN (64);
_stack_init = .;
. += _StackSize;
_clear_end = .;
_WorkspaceBase = .;
. += 512K; /* reserve some memory for workspace */
_HeapBase = .;
/*
. += _HeapSize;
*/
_end = .;
__end = .;
} > sdram
/* Debugging stuff follows */
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
/*.stack 0x80000 : { _stack = .; *(.stack) }*/
/* These must appear regardless of . */
}
__RamBase = _RamBase;
__RamSize = _RamSize;
__HeapBase = _HeapBase;
/*__HeapSize = _HeapSize;*/
__WorkspaceBase = _WorkspaceBase;
__edata = _edata;
__etext = _etext;