forked from Imagelibrary/rtems
2004-07-15 Jay Monkman
* .cvsignore, ChangeLog, Makefile.am, README, bsp_specs, configure.ac, times, console/uarts.c, include/.cvsignore, include/bsp.h, include/tm27.h, network/.cvsignore, network/network.c, start/.cvsignore, start/start.S, startup/.cvsignore, startup/bspstart.c, startup/exit.c, startup/linkcmds, startup/memmap.c: New files.
This commit is contained in:
14
c/src/lib/libbsp/arm/csb337/.cvsignore
Normal file
14
c/src/lib/libbsp/arm/csb337/.cvsignore
Normal file
@@ -0,0 +1,14 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
autom4te.cache
|
||||
config.cache
|
||||
config.guess
|
||||
config.log
|
||||
config.status
|
||||
config.sub
|
||||
configure
|
||||
depcomp
|
||||
install-sh
|
||||
missing
|
||||
mkinstalldirs
|
||||
9
c/src/lib/libbsp/arm/csb337/ChangeLog
Normal file
9
c/src/lib/libbsp/arm/csb337/ChangeLog
Normal file
@@ -0,0 +1,9 @@
|
||||
2004-07-15 Jay Monkman
|
||||
|
||||
* .cvsignore, ChangeLog, Makefile.am, README, bsp_specs, configure.ac,
|
||||
times, console/uarts.c, include/.cvsignore, include/bsp.h,
|
||||
include/tm27.h, network/.cvsignore, network/network.c,
|
||||
start/.cvsignore, start/start.S, startup/.cvsignore,
|
||||
startup/bspstart.c, startup/exit.c, startup/linkcmds,
|
||||
startup/memmap.c: New files.
|
||||
|
||||
151
c/src/lib/libbsp/arm/csb337/Makefile.am
Normal file
151
c/src/lib/libbsp/arm/csb337/Makefile.am
Normal file
@@ -0,0 +1,151 @@
|
||||
##
|
||||
## $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 += include/tm27.h
|
||||
nodist_include_HEADERS = include/bspopts.h
|
||||
|
||||
EXTRA_PROGRAMS =
|
||||
CLEANFILES =
|
||||
noinst_DATA =
|
||||
|
||||
nodist_include_HEADERS += ../../shared/include/coverhd.h
|
||||
|
||||
EXTRA_DIST = start/start.S
|
||||
start$(LIB_VARIANT).$(OBJEXT): start/start.S
|
||||
$(CPPASCOMPILE) -DASM -o $@ -c $<
|
||||
project_lib_DATA = start$(LIB_VARIANT).$(OBJEXT)
|
||||
|
||||
dist_project_lib_DATA += startup/linkcmds
|
||||
|
||||
EXTRA_PROGRAMS += startup.rel
|
||||
CLEANFILES += startup.rel
|
||||
startup_rel_SOURCES = ../../shared/bsplibc.c ../../shared/bsppost.c \
|
||||
startup/bspstart.c startup/exit.c \
|
||||
startup/memmap.c \
|
||||
../../shared/bootcard.c \
|
||||
../../shared/main.c ../../shared/sbrk.c \
|
||||
../../shared/gnatinstallhandler.c
|
||||
startup_rel_CPPFLAGS = $(AM_CPPFLAGS) $(CFLAGS_OPTIMIZE_V)
|
||||
startup_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
|
||||
|
||||
EXTRA_PROGRAMS += startup_g.rel
|
||||
CLEANFILES += startup_g.rel
|
||||
startup_g_rel_SOURCES = $(startup_rel_SOURCES)
|
||||
startup_g_rel_CPPFLAGS = $(AM_CPPFLAGS) $(CFLAGS_DEBUG_V)
|
||||
startup_g_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
|
||||
|
||||
noinst_DATA += startup$(LIB_VARIANT).rel
|
||||
|
||||
EXTRA_PROGRAMS += console.rel
|
||||
CLEANFILES += console.rel
|
||||
console_rel_SOURCES = console/uarts.c ../../shared/console.c
|
||||
console_rel_CPPFLAGS = $(AM_CPPFLAGS) $(CFLAGS_OPTIMIZE_V)
|
||||
console_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
|
||||
|
||||
EXTRA_PROGRAMS += console_g.rel
|
||||
CLEANFILES += console_g.rel
|
||||
console_g_rel_SOURCES = $(console_rel_SOURCES)
|
||||
console_g_rel_CPPFLAGS = $(AM_CPPFLAGS) $(CFLAGS_DEBUG_V)
|
||||
console_g_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
|
||||
|
||||
noinst_DATA += console$(LIB_VARIANT).rel
|
||||
|
||||
if HAS_NETWORKING
|
||||
network_CPPFLAGS = -D__INSIDE_RTEMS_BSD_TCPIP_STACK__
|
||||
EXTRA_PROGRAMS += network.rel
|
||||
CLEANFILES += network.rel
|
||||
network_rel_SOURCES = network/network.c
|
||||
network_rel_CPPFLAGS = $(AM_CPPFLAGS) $(CFLAGS_OPTIMIZE_V) \
|
||||
$(network_CPPFLAGS)
|
||||
network_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
|
||||
|
||||
EXTRA_PROGRAMS += network_g.rel
|
||||
CLEANFILES += network_g.rel
|
||||
network_g_rel_SOURCES = $(network_rel_SOURCES)
|
||||
network_g_rel_CPPFLAGS = $(AM_CPPFLAGS) $(CFLAGS_DEBUG_V) \
|
||||
$(network_CPPFLAGS)
|
||||
network_g_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
|
||||
|
||||
noinst_DATA += network$(LIB_VARIANT).rel
|
||||
endif
|
||||
|
||||
EXTRA_LIBRARIES = libbsp.a
|
||||
CLEANFILES += libbsp.a
|
||||
libbsp_a_SOURCES =
|
||||
libbsp_a_LIBADD = startup$(LIB_VARIANT).rel console$(LIB_VARIANT).rel
|
||||
if HAS_NETWORKING
|
||||
libbsp_a_LIBADD += network$(LIB_VARIANT).rel
|
||||
endif
|
||||
libbsp_a_LIBADD += \
|
||||
../../../libcpu/@RTEMS_CPU@/shared/arm920$(LIB_VARIANT).rel \
|
||||
../../../libcpu/@RTEMS_CPU@/@RTEMS_CPU_MODEL@/clock$(LIB_VARIANT).rel \
|
||||
../../../libcpu/@RTEMS_CPU@/@RTEMS_CPU_MODEL@/dbgu$(LIB_VARIANT).rel \
|
||||
../../../libcpu/@RTEMS_CPU@/@RTEMS_CPU_MODEL@/timer$(LIB_VARIANT).rel \
|
||||
../../../libcpu/@RTEMS_CPU@/@RTEMS_CPU_MODEL@/pmc$(LIB_VARIANT).rel \
|
||||
../../../libcpu/@RTEMS_CPU@/@RTEMS_CPU_MODEL@/irq$(LIB_VARIANT).rel
|
||||
|
||||
EXTRA_LIBRARIES += libbsp_g.a
|
||||
CLEANFILES += libbsp_g.a
|
||||
libbsp_g_a_SOURCES = $(libbsp_a_SOURCES)
|
||||
libbsp_g_a_LIBADD = $(libbsp_a_LIBADD)
|
||||
|
||||
noinst_DATA += libbsp$(LIB_VARIANT).a
|
||||
|
||||
all-local: $(PREINSTALL_FILES) $(TMPINSTALL_FILES)
|
||||
|
||||
PREINSTALL_DIRS =
|
||||
PREINSTALL_FILES =
|
||||
TMPINSTALL_FILES =
|
||||
|
||||
$(PROJECT_INCLUDE)/$(dirstamp):
|
||||
@$(mkdir_p) $(PROJECT_INCLUDE)
|
||||
@: > $(PROJECT_INCLUDE)/$(dirstamp)
|
||||
PREINSTALL_DIRS += $(PROJECT_INCLUDE)/$(dirstamp)
|
||||
|
||||
$(PROJECT_LIB)/$(dirstamp):
|
||||
@$(mkdir_p) $(PROJECT_LIB)
|
||||
@: > $(PROJECT_LIB)/$(dirstamp)
|
||||
PREINSTALL_DIRS += $(PROJECT_LIB)/$(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: 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$(LIB_VARIANT).$(OBJEXT): start$(LIB_VARIANT).$(OBJEXT) $(PROJECT_LIB)/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_LIB)/start$(LIB_VARIANT).$(OBJEXT)
|
||||
TMPINSTALL_FILES += $(PROJECT_LIB)/start$(LIB_VARIANT).$(OBJEXT)
|
||||
|
||||
$(PROJECT_LIB)/linkcmds: startup/linkcmds $(PROJECT_LIB)/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_LIB)/linkcmds
|
||||
PREINSTALL_FILES += $(PROJECT_LIB)/linkcmds
|
||||
|
||||
CLEANFILES += $(PREINSTALL_FILES)
|
||||
DISTCLEANFILES = $(PREINSTALL_DIRS)
|
||||
CLEANFILES += $(TMPINSTALL_FILES)
|
||||
|
||||
include $(top_srcdir)/../../../../automake/local.am
|
||||
7
c/src/lib/libbsp/arm/csb337/README
Normal file
7
c/src/lib/libbsp/arm/csb337/README
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
This is the BSP for Cogent Computer System's CSB337, a single board
|
||||
computer using the Atmel AT91RM9200 CPU.
|
||||
|
||||
23
c/src/lib/libbsp/arm/csb337/bsp_specs
Normal file
23
c/src/lib/libbsp/arm/csb337/bsp_specs
Normal file
@@ -0,0 +1,23 @@
|
||||
%rename cpp old_cpp
|
||||
%rename lib old_lib
|
||||
%rename endfile old_endfile
|
||||
%rename startfile old_startfile
|
||||
%rename link old_link
|
||||
|
||||
*cpp:
|
||||
%(old_cpp) %{qrtems: -D__embedded__ -DUSE_ENHANCED_INTR_API} -Asystem(embedded)
|
||||
|
||||
*lib:
|
||||
%{!qrtems: %(old_lib)} %{qrtems: --start-group \
|
||||
%{!qrtems_debug: -lrtemsbsp -lrtemscpu} %{qrtems_debug: -lrtemsbsp_g -lrtemscpu_g} \
|
||||
-lc -lgcc --end-group \
|
||||
%{!qnolinkcmds: -T linkcmds%s}}
|
||||
|
||||
*startfile:
|
||||
%{!qrtems: %(old_startfile)} %{qrtems: \
|
||||
%{!qrtems_debug: start.o%s crtbegin.o%s} \
|
||||
%{qrtems_debug: start_g.o%s crtbegin.o%s}}
|
||||
|
||||
*link:
|
||||
%{!qrtems: %(old_link)} %{qrtems: -Qy -dp -Bstatic -N -e _start}
|
||||
|
||||
24
c/src/lib/libbsp/arm/csb337/configure.ac
Normal file
24
c/src/lib/libbsp/arm/csb337/configure.ac
Normal file
@@ -0,0 +1,24 @@
|
||||
## Process this file with autoconf to produce a configure script.
|
||||
##
|
||||
## configure.ac,v 1.5 2003/03/11 09:39:07 ralf Exp
|
||||
|
||||
AC_PREREQ(2.57)
|
||||
AC_INIT([rtems-c-src-lib-libbsp-arm-csb337],[_RTEMS_VERSION],[rtems-bugs@OARcorp.com])
|
||||
AC_CONFIG_SRCDIR([bsp_specs])
|
||||
RTEMS_TOP(../../../../../..)
|
||||
|
||||
RTEMS_CANONICAL_TARGET_CPU
|
||||
AM_INIT_AUTOMAKE([no-define foreign 1.8])
|
||||
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")
|
||||
|
||||
# Explicitly list all Makefiles here
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
AC_OUTPUT
|
||||
|
||||
72
c/src/lib/libbsp/arm/csb337/console/uarts.c
Normal file
72
c/src/lib/libbsp/arm/csb337/console/uarts.c
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Console driver for CSB337
|
||||
*
|
||||
* This driver uses the shared console driver in
|
||||
* ...../libbsp/shared/console.c
|
||||
*
|
||||
* Copyright (c) 2003 by Cogent Computer Systems
|
||||
* Written by Jay Monkman <jtm@lopingdog.com>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
*
|
||||
* http://www.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
#include <bsp.h>
|
||||
#include <rtems/libio.h>
|
||||
#include <termios.h>
|
||||
#include <rtems/bspIo.h>
|
||||
|
||||
#include <at91rm9200.h>
|
||||
#include <at91rm9200_dbgu.h>
|
||||
#include <libchip/serial.h>
|
||||
#include <libchip/sersupp.h>
|
||||
|
||||
/* How many serial ports? */
|
||||
#define NUM_DEVS 1
|
||||
|
||||
/* These are used by code in console.c */
|
||||
unsigned long Console_Port_Count = NUM_DEVS;
|
||||
console_data Console_Port_Data[NUM_DEVS];
|
||||
|
||||
/* rtems console uses the following minor number */
|
||||
rtems_device_minor_number Console_Port_Minor = 0;
|
||||
extern console_fns dbgu_fns;
|
||||
|
||||
/*
|
||||
* There's one item in array for each UART.
|
||||
*
|
||||
* Some of these fields are marked "NOT USED". They are not used
|
||||
* by console.c, but may be used by drivers in libchip
|
||||
*
|
||||
* when we add other types of UARTS we will need to move this
|
||||
* structure to a generic uart.c file with only this in it
|
||||
*/
|
||||
console_tbl Console_Port_Tbl[] = {
|
||||
{
|
||||
"/dev/console", /* sDeviceName */
|
||||
SERIAL_CUSTOM, /* deviceType */
|
||||
&dbgu_fns, /* pDeviceFns */
|
||||
NULL, /* deviceProbe */
|
||||
NULL, /* pDeviceFlow */
|
||||
0, /* ulMargin - NOT USED */
|
||||
0, /* ulHysteresis - NOT USED */
|
||||
NULL, /* pDeviceParams */
|
||||
DBGU_BASE, /* ulCtrlPort1 - Pointer to DBGU regs */
|
||||
0, /* ulCtrlPort2 - NOT USED */
|
||||
0, /* ulDataPort - NOT USED */
|
||||
NULL, /* getRegister - NOT USED */
|
||||
NULL, /* setRegister - NOT USED */
|
||||
NULL, /* getData - NOT USED */
|
||||
NULL, /* setData - NOT USED */
|
||||
0, /* ulClock - NOT USED */
|
||||
0 /* ulIntVector - NOT USED */
|
||||
}};
|
||||
|
||||
|
||||
console_tbl *BSP_get_uart_from_minor(int minor)
|
||||
{
|
||||
return &Console_Port_Tbl[minor];
|
||||
}
|
||||
7
c/src/lib/libbsp/arm/csb337/include/.cvsignore
Normal file
7
c/src/lib/libbsp/arm/csb337/include/.cvsignore
Normal file
@@ -0,0 +1,7 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
coverhd.h
|
||||
bspopts.h
|
||||
bspopts.h.in
|
||||
stamp-h
|
||||
stamp-h.in
|
||||
65
c/src/lib/libbsp/arm/csb337/include/bsp.h
Normal file
65
c/src/lib/libbsp/arm/csb337/include/bsp.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* CSB337 BSP header file
|
||||
*
|
||||
* Copyright (c) 2004 by Cogent Computer Systems
|
||||
* Writtent by Jay Monkman <jtm@lopingdog.com>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
*
|
||||
* http://www.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
*
|
||||
* $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 <libchip/serial.h>
|
||||
|
||||
|
||||
/* What is the input clock freq in hertz? */
|
||||
#define BSP_MAIN_FREQ 3686400 /* 3.6864 MHz */
|
||||
#define BSP_SLCK_FREQ 32768 /* 32.768 KHz */
|
||||
|
||||
/* What is the last interrupt? */
|
||||
#define BSP_MAX_INT AT91RM9200_MAX_INT
|
||||
|
||||
console_tbl *BSP_get_uart_from_minor(int minor);
|
||||
static inline int32_t BSP_get_baud(void) {return 38400;}
|
||||
|
||||
/* How many serial ports? */
|
||||
#define CONFIGURE_NUMBER_OF_TERMIOS_PORTS 1
|
||||
|
||||
/* How big should the interrupt stack be? */
|
||||
#define CONFIGURE_INTERRUPT_STACK_MEMORY (16 * 1024)
|
||||
|
||||
extern rtems_configuration_table BSP_Configuration;
|
||||
|
||||
#define ST_PIMR_PIV 33 /* 33 ticks of the 32.768Khz clock ~= 1msec
|
||||
|
||||
/*
|
||||
* Network driver configuration
|
||||
*/
|
||||
extern struct rtems_bsdnet_ifconfig *config;
|
||||
|
||||
/* Change these to match your board */
|
||||
int rtems_at91rm9200_emac_attach(struct rtems_bsdnet_ifconfig *config, int attaching);
|
||||
#define RTEMS_BSP_NETWORK_DRIVER_NAME "eth0"
|
||||
#define RTEMS_BSP_NETWORK_DRIVER_ATTACH rtems_at91rm9200_emac_attach
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __BSP_H__ */
|
||||
|
||||
32
c/src/lib/libbsp/arm/csb337/include/tm27.h
Normal file
32
c/src/lib/libbsp/arm/csb337/include/tm27.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* tm27.h
|
||||
*
|
||||
* 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 _RTEMS_TMTEST27
|
||||
#error "This is an RTEMS internal file you must not include directly."
|
||||
#endif
|
||||
|
||||
#ifndef __tm27_h
|
||||
#define __tm27_h
|
||||
|
||||
/*
|
||||
* Define the interrupt mechanism for Time Test 27
|
||||
*/
|
||||
|
||||
#define MUST_WAIT_FOR_INTERRUPT 0
|
||||
|
||||
#define Install_tm27_vector( handler ) /* empty */
|
||||
|
||||
#define Cause_tm27_intr() /* empty */
|
||||
|
||||
#define Clear_tm27_intr() /* empty */
|
||||
|
||||
#define Lower_tm27_intr() /* empty */
|
||||
|
||||
#endif
|
||||
14
c/src/lib/libbsp/arm/csb337/network/.cvsignore
Normal file
14
c/src/lib/libbsp/arm/csb337/network/.cvsignore
Normal file
@@ -0,0 +1,14 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
autom4te.cache
|
||||
config.cache
|
||||
config.guess
|
||||
config.log
|
||||
config.status
|
||||
config.sub
|
||||
configure
|
||||
depcomp
|
||||
install-sh
|
||||
missing
|
||||
mkinstalldirs
|
||||
665
c/src/lib/libbsp/arm/csb337/network/network.c
Normal file
665
c/src/lib/libbsp/arm/csb337/network/network.c
Normal file
@@ -0,0 +1,665 @@
|
||||
/*
|
||||
* AT91RM9200 ethernet driver
|
||||
*
|
||||
* Copyright (c) 2003 by Cogent Computer Systems
|
||||
* Written by Mike Kelly <mike@cogcomp.com>
|
||||
* and Jay Monkman <jtm@lopingdog.com>
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/rtems_bsdnet.h>
|
||||
#include <at91rm9200.h>
|
||||
#include <at91rm9200_emac.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <rtems/error.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sockio.h>
|
||||
|
||||
#include <net/if.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/if_ether.h>
|
||||
|
||||
#include <irq.h>
|
||||
|
||||
|
||||
/* interrupt stuff */
|
||||
#define EMAC_INT_PRIORITY 0 /* lowest priority */
|
||||
|
||||
/* RTEMS event used by interrupt handler to start receive daemon. */
|
||||
#define START_RECEIVE_EVENT RTEMS_EVENT_1
|
||||
|
||||
/* RTEMS event used to start transmit daemon. */
|
||||
#define START_TRANSMIT_EVENT RTEMS_EVENT_2
|
||||
|
||||
rtems_isr at91rm9200_emac_isr(rtems_vector_number vector);
|
||||
static void at91rm9200_emac_isr_on(const rtems_irq_connect_data *unused);
|
||||
static void at91rm9200_emac_isr_off(const rtems_irq_connect_data *unused);
|
||||
static int at91rm9200_emac_isr_is_on(const rtems_irq_connect_data *irq);
|
||||
|
||||
/* Replace the first value with the clock's interrupt name. */
|
||||
rtems_irq_connect_data at91rm9200_emac_isr_data = {
|
||||
AT91RM9200_INT_EMAC,
|
||||
(rtems_irq_hdl)at91rm9200_emac_isr,
|
||||
at91rm9200_emac_isr_on,
|
||||
at91rm9200_emac_isr_off,
|
||||
at91rm9200_emac_isr_is_on,
|
||||
3, /* unused for ARM */
|
||||
0 }; /* unused for ARM */
|
||||
|
||||
|
||||
/* use the values defined in linkcmds for our use of SRAM */
|
||||
extern void * at91rm9200_emac_rxbuf_hdrs;
|
||||
extern void * at91rm9200_emac_txbuf;
|
||||
extern void * at91rm9200_emac_rxbufs;
|
||||
|
||||
/* Set up EMAC hardware */
|
||||
/* Number of Receive and Transmit Buffers and Buffer Descriptors */
|
||||
#define NUM_RXBDS 8
|
||||
#define NUM_TXBDS 1
|
||||
#define RX_BUFFER_SIZE 0x600
|
||||
|
||||
/* use internal SRAM for buffers and descriptors
|
||||
* also insure that the receive descriptors
|
||||
* start on a 64byte boundary
|
||||
* Receive Buffer Descriptor Header
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned long address;
|
||||
unsigned long status;
|
||||
} RXBUF_HDR;
|
||||
|
||||
RXBUF_HDR *rxbuf_hdrs;
|
||||
unsigned char *txbuf;
|
||||
unsigned char *rxbuf;
|
||||
|
||||
int delay_cnt;
|
||||
|
||||
/*
|
||||
* Hardware-specific storage
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/*
|
||||
* Connection to networking code
|
||||
* This entry *must* be the first in the sonic_softc structure.
|
||||
*/
|
||||
struct arpcom arpcom;
|
||||
|
||||
/*
|
||||
* Interrupt vector
|
||||
*/
|
||||
rtems_vector_number vector;
|
||||
|
||||
/*
|
||||
* Indicates configuration
|
||||
*/
|
||||
int acceptBroadcast;
|
||||
|
||||
/*
|
||||
* Task waiting for interrupts
|
||||
*/
|
||||
rtems_id rxDaemonTid;
|
||||
rtems_id txDaemonTid;
|
||||
|
||||
/*
|
||||
* current receive header
|
||||
*/
|
||||
int rx_buf_idx;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Statistics
|
||||
*/
|
||||
unsigned long Interrupts;
|
||||
unsigned long rxInterrupts;
|
||||
unsigned long rxMissed;
|
||||
unsigned long rxGiant;
|
||||
unsigned long rxNonOctet;
|
||||
unsigned long rxBadCRC;
|
||||
unsigned long rxCollision;
|
||||
|
||||
unsigned long txInterrupts;
|
||||
unsigned long txSingleCollision;
|
||||
unsigned long txMultipleCollision;
|
||||
unsigned long txCollision;
|
||||
unsigned long txDeferred;
|
||||
unsigned long txUnderrun;
|
||||
unsigned long txLateCollision;
|
||||
unsigned long txExcessiveCollision;
|
||||
unsigned long txExcessiveDeferral;
|
||||
unsigned long txLostCarrier;
|
||||
unsigned long txRawWait;
|
||||
} at91rm9200_emac_softc_t;
|
||||
|
||||
static at91rm9200_emac_softc_t softc;
|
||||
|
||||
|
||||
/* The AT91RM9200 ethernet fifos are very undersized. Therefore
|
||||
* we use the internal SRAM to hold 4 receive packets and one
|
||||
* transmit packet. Note that the AT91RM9200 can only queue
|
||||
* one transmit packet at a time.
|
||||
*/
|
||||
|
||||
/* function prototypes */
|
||||
int rtems_at91rm9200_emac_attach (struct rtems_bsdnet_ifconfig *config,
|
||||
void *chip);
|
||||
void at91rm9200_emac_init(void *arg);
|
||||
void at91rm9200_emac_init_hw(at91rm9200_emac_softc_t *sc);
|
||||
void at91rm9200_emac_start(struct ifnet *ifp);
|
||||
void at91rm9200_emac_stop (at91rm9200_emac_softc_t *sc);
|
||||
void at91rm9200_emac_txDaemon (void *arg);
|
||||
void at91rm9200_emac_sendpacket (struct ifnet *ifp, struct mbuf *m);
|
||||
void at91rm9200_emac_rxDaemon(void *arg);
|
||||
void at91rm9200_emac_stats (at91rm9200_emac_softc_t *sc);
|
||||
static int at91rm9200_emac_ioctl (struct ifnet *ifp,
|
||||
int command,
|
||||
caddr_t data);
|
||||
|
||||
|
||||
int rtems_at91rm9200_emac_attach (
|
||||
struct rtems_bsdnet_ifconfig *config,
|
||||
void *chip /* only one ethernet, so no chip number */
|
||||
)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
int mtu;
|
||||
int unitnumber;
|
||||
char *unitname;
|
||||
|
||||
/* an array of receive buffer descriptors */
|
||||
rxbuf_hdrs = (RXBUF_HDR *)&at91rm9200_emac_rxbuf_hdrs;
|
||||
|
||||
/* one transmit buffer, 1536 bytes maximum */
|
||||
txbuf = (char *)&at91rm9200_emac_txbuf;
|
||||
|
||||
/* receive buffers starting address */
|
||||
rxbuf = (char *)&at91rm9200_emac_rxbufs;
|
||||
/*
|
||||
* Parse driver name
|
||||
*/
|
||||
if ((unitnumber = rtems_bsdnet_parse_driver_name (config, &unitname)) < 0)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* Is driver free?
|
||||
*/
|
||||
if (unitnumber != 0) {
|
||||
printf ("Bad AT91RM9200 EMAC unit number.\n");
|
||||
return 0;
|
||||
}
|
||||
ifp = &softc.arpcom.ac_if;
|
||||
if (ifp->if_softc != NULL) {
|
||||
printf ("Driver already in use.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* zero out the control structure
|
||||
*/
|
||||
|
||||
memset( &softc, 0, sizeof(softc) );
|
||||
|
||||
|
||||
/* get the MAC address from the chip */
|
||||
softc.arpcom.ac_enaddr[0] = (EMAC_REG(EMAC_SA1L) >> 0) & 0xff;
|
||||
softc.arpcom.ac_enaddr[1] = (EMAC_REG(EMAC_SA1L) >> 8) & 0xff;
|
||||
softc.arpcom.ac_enaddr[2] = (EMAC_REG(EMAC_SA1L) >> 16) & 0xff;
|
||||
softc.arpcom.ac_enaddr[3] = (EMAC_REG(EMAC_SA1L) >> 24) & 0xff;
|
||||
softc.arpcom.ac_enaddr[4] = (EMAC_REG(EMAC_SA1H) >> 0) & 0xff;
|
||||
softc.arpcom.ac_enaddr[5] = (EMAC_REG(EMAC_SA1H) >> 8) & 0xff;
|
||||
|
||||
if (config->mtu) {
|
||||
mtu = config->mtu;
|
||||
} else {
|
||||
mtu = ETHERMTU;
|
||||
}
|
||||
|
||||
softc.acceptBroadcast = !config->ignore_broadcast;
|
||||
|
||||
/*
|
||||
* Set up network interface values
|
||||
*/
|
||||
ifp->if_softc = &softc;
|
||||
ifp->if_unit = unitnumber;
|
||||
ifp->if_name = unitname;
|
||||
ifp->if_mtu = mtu;
|
||||
ifp->if_init = at91rm9200_emac_init;
|
||||
ifp->if_ioctl = at91rm9200_emac_ioctl;
|
||||
ifp->if_start = at91rm9200_emac_start;
|
||||
ifp->if_output = ether_output;
|
||||
ifp->if_flags = IFF_BROADCAST;
|
||||
if (ifp->if_snd.ifq_maxlen == 0) {
|
||||
ifp->if_snd.ifq_maxlen = ifqmaxlen;
|
||||
}
|
||||
|
||||
softc.rx_buf_idx = 0;
|
||||
|
||||
/*
|
||||
* Attach the interface
|
||||
*/
|
||||
if_attach (ifp);
|
||||
ether_ifattach (ifp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void at91rm9200_emac_init(void *arg)
|
||||
{
|
||||
at91rm9200_emac_softc_t *sc = arg;
|
||||
struct ifnet *ifp = &sc->arpcom.ac_if;
|
||||
|
||||
/*
|
||||
*This is for stuff that only gets done once (at91rm9200_emac_init()
|
||||
* gets called multiple times
|
||||
*/
|
||||
if (sc->txDaemonTid == 0) {
|
||||
/* Set up EMAC hardware */
|
||||
at91rm9200_emac_init_hw(sc);
|
||||
|
||||
/* Start driver tasks */
|
||||
sc->rxDaemonTid = rtems_bsdnet_newproc("ENrx",
|
||||
4096,
|
||||
at91rm9200_emac_rxDaemon,
|
||||
sc);
|
||||
sc->txDaemonTid = rtems_bsdnet_newproc("ENtx",
|
||||
4096,
|
||||
at91rm9200_emac_txDaemon,
|
||||
sc);
|
||||
} /* if txDaemonTid */
|
||||
|
||||
/* set our priority in the AIC */
|
||||
AIC_SMR_REG(AIC_SMR_EMAC) = AIC_SMR_PRIOR(EMAC_INT_PRIORITY);
|
||||
|
||||
/* install the interrupt handler */
|
||||
BSP_install_rtems_irq_handler(&at91rm9200_emac_isr_data);
|
||||
|
||||
/* EMAC doesn't support promiscuous, so ignore requests */
|
||||
if (ifp->if_flags & IFF_PROMISC) {
|
||||
printf ("Warning - AT91RM9200 Ethernet driver"
|
||||
" doesn't support Promiscuous Mode!\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Tell the world that we're running.
|
||||
*/
|
||||
ifp->if_flags |= IFF_RUNNING;
|
||||
|
||||
/* Enable TX/RX and clear the statistics counters */
|
||||
EMAC_REG(EMAC_CTL) = (EMAC_CTL_TE | EMAC_CTL_RE | EMAC_CTL_CSR);
|
||||
|
||||
/* clear any pending interrupts */
|
||||
EMAC_REG(EMAC_TSR) = 0xffffffff;
|
||||
EMAC_REG(EMAC_RSR) = 0xffffffff;
|
||||
|
||||
} /* at91rm9200_emac_init() */
|
||||
|
||||
void at91rm9200_emac_init_hw(at91rm9200_emac_softc_t *sc)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* initialize our receive buffer descriptors */
|
||||
for (i = 0; i < NUM_RXBDS-1; i++) {
|
||||
rxbuf_hdrs[i].address = (unsigned long)(&rxbuf[i * RX_BUFFER_SIZE]);
|
||||
rxbuf_hdrs[i].status = 0x00000000;
|
||||
}
|
||||
|
||||
/* last one needs the wrapbit set as well */
|
||||
rxbuf_hdrs[i].address = ((unsigned long)(&rxbuf[i * RX_BUFFER_SIZE]) |
|
||||
RXBUF_ADD_WRAP);
|
||||
rxbuf_hdrs[i].status = 0x00000000;
|
||||
|
||||
/* point to our receive buffer queue */
|
||||
EMAC_REG(EMAC_RBQP) = (unsigned long)rxbuf_hdrs;
|
||||
|
||||
/* clear any left over status bits */
|
||||
EMAC_REG(EMAC_RSR) &= ~(EMAC_RSR_OVR | EMAC_RSR_REC | EMAC_RSR_BNA);
|
||||
|
||||
/* set the MII clock divder to MCK/64 */
|
||||
EMAC_REG(EMAC_CFG) = (EMAC_CFG_CLK_64 | EMAC_CFG_BIG | EMAC_CFG_FD);
|
||||
|
||||
/* enable the MII interface */
|
||||
EMAC_REG(EMAC_CTL) = EMAC_CTL_MPE;
|
||||
|
||||
/* Set PHY LED2 to combined Link/Activity and enable pulse stretching */
|
||||
EMAC_REG(EMAC_MAN) = (0x01 << 30 | /* Start of Frame Delimiter */
|
||||
0x01 << 28 | /* Operation, 0x01 = Write */
|
||||
0x00 << 23 | /* Phy Number */
|
||||
0x14 << 18 | /* Phy Register */
|
||||
0x02 << 16 | /* must be 0x02 */
|
||||
0x0D0A); /* Write data (0x0000 if read) */
|
||||
|
||||
} /* at91rm9200_emac_init_hw() */
|
||||
|
||||
void at91rm9200_emac_start(struct ifnet *ifp)
|
||||
{
|
||||
at91rm9200_emac_softc_t *sc = ifp->if_softc;
|
||||
|
||||
rtems_event_send(sc->txDaemonTid, START_TRANSMIT_EVENT);
|
||||
ifp->if_flags |= IFF_OACTIVE;
|
||||
}
|
||||
|
||||
void at91rm9200_emac_stop (at91rm9200_emac_softc_t *sc)
|
||||
{
|
||||
struct ifnet *ifp = &sc->arpcom.ac_if;
|
||||
|
||||
ifp->if_flags &= ~IFF_RUNNING;
|
||||
|
||||
/*
|
||||
* Stop the transmitter and receiver.
|
||||
*/
|
||||
EMAC_REG(EMAC_CTL) &= ~(EMAC_CTL_TE | EMAC_CTL_RE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Driver transmit daemon
|
||||
*/
|
||||
void at91rm9200_emac_txDaemon (void *arg)
|
||||
{
|
||||
at91rm9200_emac_softc_t *sc = (at91rm9200_emac_softc_t *)arg;
|
||||
struct ifnet *ifp = &sc->arpcom.ac_if;
|
||||
struct mbuf *m;
|
||||
rtems_event_set events;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
/* turn on TX interrupt, then wait for one */
|
||||
EMAC_REG(EMAC_IER) = EMAC_INT_TCOM; /* Transmit complete */
|
||||
|
||||
rtems_bsdnet_event_receive(
|
||||
START_TRANSMIT_EVENT,
|
||||
RTEMS_EVENT_ANY | RTEMS_WAIT,
|
||||
RTEMS_NO_TIMEOUT,
|
||||
&events);
|
||||
|
||||
/* Send packets till queue is empty */
|
||||
for (;;)
|
||||
{
|
||||
/* Get the next mbuf chain to transmit. */
|
||||
IF_DEQUEUE(&ifp->if_snd, m);
|
||||
if (!m)
|
||||
break;
|
||||
at91rm9200_emac_sendpacket (ifp, m);
|
||||
}
|
||||
ifp->if_flags &= ~IFF_OACTIVE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Send packet */
|
||||
void at91rm9200_emac_sendpacket (struct ifnet *ifp, struct mbuf *m)
|
||||
{
|
||||
struct mbuf *l = NULL;
|
||||
unsigned int pkt_offset = 0;
|
||||
delay_cnt = 0;
|
||||
/* printf("at91rm9200_emac_sendpacket %p\n", m); */
|
||||
|
||||
/* Wait for EMAC Transmit Queue to become available. */
|
||||
while (((EMAC_REG(EMAC_TSR) & EMAC_TSR_COMP) == 0) &&
|
||||
((EMAC_REG(EMAC_TSR) & EMAC_TSR_TXIDLE) == 0))
|
||||
|
||||
{
|
||||
delay_cnt++;
|
||||
/* sleep(0); make sure we don't hog the cpu */
|
||||
continue;
|
||||
}
|
||||
|
||||
/* copy the mbuf chain into the transmit buffer */
|
||||
l = m;
|
||||
while (l != NULL) {
|
||||
memcpy(((char *)txbuf + pkt_offset), /* offset into pkt for mbuf */
|
||||
(char *)mtod(l, void *), /* cast to void */
|
||||
l->m_len); /* length of this mbuf */
|
||||
|
||||
pkt_offset += l->m_len; /* update offset */
|
||||
l = l->m_next; /* get next mbuf, if any */
|
||||
}
|
||||
|
||||
/* free the mbuf chain we just copied */
|
||||
m_freem(m);
|
||||
|
||||
/* clear any pending status */
|
||||
EMAC_REG(EMAC_TSR) = (EMAC_TSR_OVR | EMAC_TSR_COL | EMAC_TSR_RLE
|
||||
| EMAC_TSR_COMP | EMAC_TSR_UND);
|
||||
|
||||
/* tell the EMAC about our buffer */
|
||||
EMAC_REG(EMAC_TAR) = (unsigned long)txbuf;
|
||||
EMAC_REG(EMAC_TCR) = (unsigned long)pkt_offset;
|
||||
} /* at91rm9200_emac_sendpacket () */
|
||||
|
||||
|
||||
/* SONIC reader task */
|
||||
void at91rm9200_emac_rxDaemon(void *arg)
|
||||
{
|
||||
at91rm9200_emac_softc_t *sc = (at91rm9200_emac_softc_t *)arg;
|
||||
struct ifnet *ifp = &sc->arpcom.ac_if;
|
||||
struct mbuf *m;
|
||||
struct ether_header *eh;
|
||||
rtems_event_set events;
|
||||
int pktlen;
|
||||
|
||||
/* Input packet handling loop */
|
||||
for (;;) {
|
||||
/* turn on RX interrupts, then wait for one */
|
||||
EMAC_REG(EMAC_IER) = (EMAC_INT_RCOM | /* Receive complete */
|
||||
EMAC_INT_RBNA | /* Receive buf not available */
|
||||
EMAC_INT_ROVR); /* Receive overrun */
|
||||
|
||||
rtems_bsdnet_event_receive(
|
||||
START_RECEIVE_EVENT,
|
||||
RTEMS_EVENT_ANY | RTEMS_WAIT,
|
||||
RTEMS_NO_TIMEOUT,
|
||||
&events);
|
||||
|
||||
if (EMAC_REG(EMAC_RSR) & EMAC_RSR_BNA) {
|
||||
printf("1: EMAC_BNA\n");
|
||||
}
|
||||
|
||||
if (EMAC_REG(EMAC_RSR) & EMAC_RSR_OVR) {
|
||||
printf("1: EMAC_OVR\n");
|
||||
}
|
||||
|
||||
/* clear the receive status as we do not use it anyway */
|
||||
EMAC_REG(EMAC_RSR) = (EMAC_RSR_REC | EMAC_RSR_OVR | EMAC_RSR_BNA);
|
||||
|
||||
/* scan the buffer descriptors looking for any with data in them */
|
||||
while (rxbuf_hdrs[sc->rx_buf_idx].address & RXBUF_ADD_OWNED) {
|
||||
pktlen = rxbuf_hdrs[sc->rx_buf_idx].status & RXBUF_STAT_LEN_MASK;
|
||||
|
||||
/* get an mbuf this packet */
|
||||
MGETHDR(m, M_WAIT, MT_DATA);
|
||||
|
||||
/* now get a cluster pointed to by the mbuf */
|
||||
/* since an mbuf by itself is too small */
|
||||
MCLGET(m, M_WAIT);
|
||||
|
||||
/* set the type of mbuf to ifp (ethernet I/F) */
|
||||
m->m_pkthdr.rcvif = ifp;
|
||||
m->m_nextpkt = 0;
|
||||
|
||||
/* copy the packet into the cluster pointed to by the mbuf */
|
||||
memcpy((char *)m->m_ext.ext_buf,
|
||||
(char *)(rxbuf_hdrs[sc->rx_buf_idx].address & 0xfffffffc),
|
||||
pktlen);
|
||||
|
||||
/* Release the buffer ASAP back to the EMAC */
|
||||
rxbuf_hdrs[sc->rx_buf_idx].address &= ~RXBUF_ADD_OWNED;
|
||||
|
||||
/* set the length of the mbuf */
|
||||
m->m_len = pktlen - (sizeof(struct ether_header) + 4);
|
||||
m->m_pkthdr.len = m->m_len;
|
||||
|
||||
/* strip off the ethernet header from the mbuf */
|
||||
/* but save the pointer to it */
|
||||
eh = mtod (m, struct ether_header *);
|
||||
m->m_data += sizeof(struct ether_header);
|
||||
|
||||
/* increment the buffer index */
|
||||
sc->rx_buf_idx++;
|
||||
if (sc->rx_buf_idx >= NUM_RXBDS) {
|
||||
sc->rx_buf_idx = 0;
|
||||
}
|
||||
|
||||
/* give all this stuff to the stack */
|
||||
ether_input(ifp, eh, m);
|
||||
|
||||
} /* while ADD_OWNED = 0 */
|
||||
|
||||
if (EMAC_REG(EMAC_RSR) & EMAC_RSR_BNA) {
|
||||
printf("2:EMAC_BNA\n");
|
||||
}
|
||||
if (EMAC_REG(EMAC_RSR) & EMAC_RSR_OVR) {
|
||||
printf("2:EMAC_OVR\n");
|
||||
}
|
||||
|
||||
|
||||
} /* for (;;) */
|
||||
} /* at91rm9200_emac_rxDaemon() */
|
||||
|
||||
|
||||
/* Show interface statistics */
|
||||
void at91rm9200_emac_stats (at91rm9200_emac_softc_t *sc)
|
||||
{
|
||||
printf (" Total Interrupts:%-8lu", sc->Interrupts);
|
||||
printf (" Rx Interrupts:%-8lu", sc->rxInterrupts);
|
||||
printf (" Giant:%-8lu", sc->rxGiant);
|
||||
printf (" Non-octet:%-8lu\n", sc->rxNonOctet);
|
||||
printf (" Bad CRC:%-8lu", sc->rxBadCRC);
|
||||
printf (" Collision:%-8lu", sc->rxCollision);
|
||||
printf (" Missed:%-8lu\n", sc->rxMissed);
|
||||
|
||||
printf ( " Tx Interrupts:%-8lu", sc->txInterrupts);
|
||||
printf ( " Deferred:%-8lu", sc->txDeferred);
|
||||
printf (" Lost Carrier:%-8lu\n", sc->txLostCarrier);
|
||||
printf ( "Single Collisions:%-8lu", sc->txSingleCollision);
|
||||
printf ( "Multiple Collisions:%-8lu", sc->txMultipleCollision);
|
||||
printf ("Excessive Collisions:%-8lu\n", sc->txExcessiveCollision);
|
||||
printf ( " Total Collisions:%-8lu", sc->txCollision);
|
||||
printf ( " Late Collision:%-8lu", sc->txLateCollision);
|
||||
printf (" Underrun:%-8lu\n", sc->txUnderrun);
|
||||
printf ( " Raw output wait:%-8lu\n", sc->txRawWait);
|
||||
}
|
||||
|
||||
|
||||
/* Enables at91rm9200_emac interrupts. */
|
||||
static void at91rm9200_emac_isr_on(const rtems_irq_connect_data *unused)
|
||||
{
|
||||
/* Enable various TX/RX interrupts */
|
||||
EMAC_REG(EMAC_IER) = (EMAC_INT_RCOM | /* Receive complete */
|
||||
EMAC_INT_RBNA | /* Receive buffer not available */
|
||||
EMAC_INT_TCOM | /* Transmit complete */
|
||||
EMAC_INT_ROVR | /* Receive overrun */
|
||||
EMAC_INT_ABT); /* Abort on DMA transfer */
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Disables at91rm9200_emac interrupts */
|
||||
static void at91rm9200_emac_isr_off(const rtems_irq_connect_data *unused)
|
||||
{
|
||||
/* disable all various TX/RX interrupts */
|
||||
EMAC_REG(EMAC_IDR) = 0xffffffff;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Tests to see if at91rm9200_emac interrupts are enabled, and
|
||||
* returns non-0 if so.
|
||||
* If interrupt is not enabled, returns 0.
|
||||
*/
|
||||
static int at91rm9200_emac_isr_is_on(const rtems_irq_connect_data *irq)
|
||||
{
|
||||
return EMAC_REG(EMAC_IMR); /* any interrupts enabled? */
|
||||
}
|
||||
|
||||
/* Driver ioctl handler */
|
||||
static int
|
||||
at91rm9200_emac_ioctl (struct ifnet *ifp, int command, caddr_t data)
|
||||
{
|
||||
at91rm9200_emac_softc_t *sc = ifp->if_softc;
|
||||
int error = 0;
|
||||
|
||||
switch (command) {
|
||||
case SIOCGIFADDR:
|
||||
case SIOCSIFADDR:
|
||||
ether_ioctl (ifp, command, data);
|
||||
break;
|
||||
|
||||
case SIOCSIFFLAGS:
|
||||
switch (ifp->if_flags & (IFF_UP | IFF_RUNNING))
|
||||
{
|
||||
case IFF_RUNNING:
|
||||
at91rm9200_emac_stop (sc);
|
||||
break;
|
||||
|
||||
case IFF_UP:
|
||||
at91rm9200_emac_init (sc);
|
||||
break;
|
||||
|
||||
case IFF_UP | IFF_RUNNING:
|
||||
at91rm9200_emac_stop (sc);
|
||||
at91rm9200_emac_init (sc);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
} /* switch (if_flags) */
|
||||
break;
|
||||
|
||||
case SIO_RTEMS_SHOW_STATS:
|
||||
at91rm9200_emac_stats (sc);
|
||||
break;
|
||||
|
||||
/*
|
||||
* FIXME: All sorts of multicast commands need to be added here!
|
||||
*/
|
||||
default:
|
||||
error = EINVAL;
|
||||
break;
|
||||
} /* switch (command) */
|
||||
return error;
|
||||
}
|
||||
|
||||
/* interrupt handler */
|
||||
rtems_isr at91rm9200_emac_isr (rtems_vector_number v)
|
||||
{
|
||||
unsigned long status32;
|
||||
|
||||
/* get the ISR status and determine RX or TX */
|
||||
status32 = EMAC_REG(EMAC_ISR);
|
||||
|
||||
if (status32 & EMAC_INT_ABT) {
|
||||
EMAC_REG(EMAC_IDR) = EMAC_INT_ABT; /* disable it */
|
||||
rtems_panic("AT91RM9200 Ethernet MAC has received an Abort.\n");
|
||||
}
|
||||
|
||||
if (status32 & (EMAC_INT_RCOM | /* Receive complete */
|
||||
EMAC_INT_RBNA | /* Receive buffer not available */
|
||||
EMAC_INT_ROVR)) { /* Receive overrun */
|
||||
|
||||
/* disable the RX interrupts */
|
||||
EMAC_REG(EMAC_IDR) = (EMAC_INT_RCOM | /* Receive complete */
|
||||
EMAC_INT_RBNA | /* Receive buf not available */
|
||||
EMAC_INT_ROVR); /* Receive overrun */
|
||||
|
||||
rtems_event_send (softc.rxDaemonTid, START_RECEIVE_EVENT);
|
||||
}
|
||||
|
||||
if (status32 & EMAC_INT_TCOM) { /* Transmit buffer register empty */
|
||||
|
||||
/* disable the TX interrupts */
|
||||
EMAC_REG(EMAC_IDR) = EMAC_INT_TCOM;
|
||||
|
||||
rtems_event_send (softc.txDaemonTid, START_TRANSMIT_EVENT);
|
||||
}
|
||||
}
|
||||
|
||||
14
c/src/lib/libbsp/arm/csb337/start/.cvsignore
Normal file
14
c/src/lib/libbsp/arm/csb337/start/.cvsignore
Normal file
@@ -0,0 +1,14 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
autom4te.cache
|
||||
config.cache
|
||||
config.guess
|
||||
config.log
|
||||
config.status
|
||||
config.sub
|
||||
configure
|
||||
depcomp
|
||||
install-sh
|
||||
missing
|
||||
mkinstalldirs
|
||||
147
c/src/lib/libbsp/arm/csb337/start/start.S
Normal file
147
c/src/lib/libbsp/arm/csb337/start/start.S
Normal file
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Cogent CSB337 startup code
|
||||
*
|
||||
* Copyright (c) 2004 by Jay Monkman <jtm@lopingdog.com>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
*
|
||||
* http://www.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
|
||||
/* Some standard definitions...*/
|
||||
.equ PSR_MODE_USR, 0x10
|
||||
.equ PSR_MODE_FIQ, 0x11
|
||||
.equ PSR_MODE_IRQ, 0x12
|
||||
.equ PSR_MODE_SVC, 0x13
|
||||
.equ PSR_MODE_ABT, 0x17
|
||||
.equ PSR_MODE_UNDEF, 0x1B
|
||||
.equ PSR_MODE_SYS, 0x1F
|
||||
|
||||
.equ PSR_I, 0x80
|
||||
.equ PSR_F, 0x40
|
||||
.equ PSR_T, 0x20
|
||||
|
||||
.text
|
||||
.globl _start
|
||||
_start:
|
||||
/*
|
||||
* Since I don't plan to return to the bootloader,
|
||||
* I don't have to save the registers.
|
||||
*
|
||||
* I'll just set the CPSR for SVC mode, interrupts
|
||||
* off, and ARM instructions.
|
||||
*/
|
||||
mov r0, #(PSR_MODE_SVC | PSR_I | PSR_F)
|
||||
msr cpsr, r0
|
||||
|
||||
/* zero the bss */
|
||||
ldr r1, =_bss_end_
|
||||
ldr r0, =_bss_start_
|
||||
|
||||
_bss_init:
|
||||
mov r2, #0
|
||||
cmp r0, r1
|
||||
strlot r2, [r0], #4
|
||||
blo _bss_init /* loop while r0 < r1 */
|
||||
|
||||
|
||||
/* --- Initialize stack pointer registers */
|
||||
/* Enter IRQ mode and set up the IRQ stack pointer */
|
||||
mov r0, #(PSR_MODE_IRQ | PSR_I | PSR_F) /* No interrupts */
|
||||
msr cpsr, r0
|
||||
ldr r1, =_irq_stack_size
|
||||
ldr sp, =_irq_stack
|
||||
add sp, sp, r1
|
||||
|
||||
/* Enter FIQ mode and set up the FIQ stack pointer */
|
||||
mov r0, #(PSR_MODE_FIQ | PSR_I | PSR_F) /* No interrupts */
|
||||
msr cpsr, r0
|
||||
ldr r1, =_fiq_stack_size
|
||||
ldr sp, =_fiq_stack
|
||||
add sp, sp, r1
|
||||
|
||||
/* Enter ABT mode and set up the ABT stack pointer */
|
||||
mov r0, #(PSR_MODE_ABT | PSR_I | PSR_F) /* No interrupts */
|
||||
msr cpsr, r0
|
||||
ldr r1, =_abt_stack_size
|
||||
ldr sp, =_abt_stack
|
||||
add sp, sp, r1
|
||||
|
||||
/* Set up the SVC stack pointer last and stay in SVC mode */
|
||||
mov r0, #(PSR_MODE_SVC | PSR_I | PSR_F) /* No interrupts */
|
||||
msr cpsr, r0
|
||||
ldr r1, =_svc_stack_size
|
||||
ldr sp, =_svc_stack
|
||||
add sp, sp, r1
|
||||
sub sp, sp, #0x64
|
||||
|
||||
/*
|
||||
* Initialize the MMU. After we return, the MMU is enabled,
|
||||
* and memory may be remapped. I hope we don't remap this
|
||||
* memory away.
|
||||
*/
|
||||
ldr r0, =mem_map
|
||||
bl mmu_init
|
||||
|
||||
/*
|
||||
* Initialize the exception vectors. This includes the
|
||||
* exceptions vectors (0x00000000-0x0000001c), and the
|
||||
* pointers to the exception handlers (0x00000020-0x0000003c).
|
||||
*/
|
||||
mov r0, #0
|
||||
adr r1, vector_block
|
||||
ldmia r1!, {r2-r9}
|
||||
stmia r0!, {r2-r9}
|
||||
ldmia r1!, {r2-r9}
|
||||
stmia r0!, {r2-r9}
|
||||
|
||||
/* Now we are prepared to start the BSP's C code */
|
||||
bl boot_card
|
||||
|
||||
/*
|
||||
* Theoretically, we could return to what started us up,
|
||||
* but we'd have to have saved the registers and stacks.
|
||||
* Instead, we'll just reset.
|
||||
*/
|
||||
bl bsp_reset
|
||||
|
||||
/* We shouldn't get here. If we do, hang */
|
||||
_hang: b _hang
|
||||
|
||||
|
||||
/*
|
||||
* This is the exception vector table and the pointers to
|
||||
* the functions that handle the exceptions. It's a total
|
||||
* of 16 words (64 bytes)
|
||||
*/
|
||||
vector_block:
|
||||
ldr pc, Reset_Handler
|
||||
ldr pc, Undefined_Handler
|
||||
ldr pc, SWI_Handler
|
||||
ldr pc, Prefetch_Handler
|
||||
ldr pc, Abort_Handler
|
||||
nop
|
||||
ldr pc, IRQ_Handler
|
||||
ldr pc, FIQ_Handler
|
||||
|
||||
Reset_Handler: b bsp_reset
|
||||
Undefined_Handler: b Undefined_Handler
|
||||
SWI_Handler: b SWI_Handler
|
||||
Prefetch_Handler: b Prefetch_Handler
|
||||
Abort_Handler: b Abort_Handler
|
||||
nop
|
||||
IRQ_Handler: b IRQ_Handler
|
||||
FIQ_Handler: b FIQ_Handler
|
||||
|
||||
.globl Reset_Handler
|
||||
.globl Undefined_Handler
|
||||
.globl SWI_Handler
|
||||
.globl Prefetch_Handler
|
||||
.globl Abort_Handler
|
||||
.globl IRQ_Handler
|
||||
.globl FIQ_Handler
|
||||
14
c/src/lib/libbsp/arm/csb337/startup/.cvsignore
Normal file
14
c/src/lib/libbsp/arm/csb337/startup/.cvsignore
Normal file
@@ -0,0 +1,14 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
autom4te.cache
|
||||
config.cache
|
||||
config.guess
|
||||
config.log
|
||||
config.status
|
||||
config.sub
|
||||
configure
|
||||
depcomp
|
||||
install-sh
|
||||
missing
|
||||
mkinstalldirs
|
||||
206
c/src/lib/libbsp/arm/csb337/startup/bspstart.c
Normal file
206
c/src/lib/libbsp/arm/csb337/startup/bspstart.c
Normal file
@@ -0,0 +1,206 @@
|
||||
/*
|
||||
* Cogent CSB337 - AT91RM9200 Startup code
|
||||
*
|
||||
* Copyright (c) 2004 by Cogent Computer Systems
|
||||
* Written by Jay Monkman <jtm@lopingdog.com>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
*
|
||||
* http://www.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
#include <bsp.h>
|
||||
#include <rtems/libcsupport.h>
|
||||
#include <rtems/libio.h>
|
||||
#include <at91rm9200.h>
|
||||
#include <at91rm9200_pmc.h>
|
||||
#include <at91rm9200_emac.h>
|
||||
|
||||
/* Global Variables */
|
||||
extern void *_flash_size;
|
||||
extern void *_flash_base;
|
||||
extern void *_sdram_size;
|
||||
extern void *_sdram_base;
|
||||
extern void *_bss_free_start;
|
||||
|
||||
unsigned long free_mem_start;
|
||||
unsigned long free_mem_end;
|
||||
|
||||
rtems_configuration_table BSP_Configuration;
|
||||
rtems_cpu_table Cpu_table;
|
||||
char *rtems_progname = "RTEMS";
|
||||
|
||||
/* Function prototypes */
|
||||
extern void rtems_irq_mngt_init(void);
|
||||
void bsp_libc_init( void *, unsigned32, int );
|
||||
void bsp_postdriver_hook(void);
|
||||
static void fix_mac_addr();
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* NAME: bsp_pretasking_hook - Function to setup system before startup */
|
||||
/* */
|
||||
/* DESCRIPTION: */
|
||||
/* This function is called before drivers are initialized and used */
|
||||
/* to setup libc and BSP extensions. */
|
||||
/* */
|
||||
/* RESTRICTIONS/LIMITATIONS: */
|
||||
/* Since this function is setting up libc, it cannot use and libc */
|
||||
/* functions. */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
void bsp_pretasking_hook(void)
|
||||
{
|
||||
unsigned32 heap_start;
|
||||
unsigned32 heap_size;
|
||||
|
||||
/*
|
||||
* Set up the heap.
|
||||
*/
|
||||
heap_start = free_mem_start;
|
||||
heap_size = free_mem_end - free_mem_start;
|
||||
|
||||
/* call rtems lib init - malloc stuff */
|
||||
bsp_libc_init((void *)heap_start, heap_size, 0);
|
||||
|
||||
#ifdef RTEMS_DEBUG
|
||||
|
||||
rtems_debug_enable(RTEMS_DEBUG_ALL_MASK);
|
||||
|
||||
#endif /* RTEMS_DEBUG */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* NAME: bsp_start_default - BSP initialization function */
|
||||
/* */
|
||||
/* DESCRIPTION: */
|
||||
/* This function is called before RTEMS is initialized and used */
|
||||
/* adjust the kernel's configuration. */
|
||||
/* */
|
||||
/* This function also configures the CPU's memory protection unit. */
|
||||
/* */
|
||||
/* RESTRICTIONS/LIMITATIONS: */
|
||||
/* Since RTEMS is not configured, no RTEMS functions can be called. */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
void bsp_start_default( void )
|
||||
{
|
||||
/* disable interrupts */
|
||||
AIC_CTL_REG(AIC_IDCR) = 0xffffffff;
|
||||
|
||||
/*
|
||||
* Some versions of the bootloader have the MAC address
|
||||
* reversed. This fixes it, if necessary.
|
||||
*/
|
||||
fix_mac_addr();
|
||||
|
||||
/* tell RTEMS about the hooks we are using */
|
||||
Cpu_table.pretasking_hook = bsp_pretasking_hook;
|
||||
Cpu_table.postdriver_hook = bsp_postdriver_hook;
|
||||
|
||||
/* tell RTEMS to clear the workspace */
|
||||
Cpu_table.do_zero_of_workspace = TRUE;
|
||||
|
||||
/* Place RTEMS workspace at beginning of free memory. */
|
||||
BSP_Configuration.work_space_start = (void *)&_bss_free_start;
|
||||
|
||||
free_mem_start = ((unsigned32)&_bss_free_start +
|
||||
BSP_Configuration.work_space_size);
|
||||
|
||||
free_mem_end = ((unsigned32)&_sdram_base + (unsigned32)&_sdram_size);
|
||||
|
||||
|
||||
/*
|
||||
* Init rtems exceptions management
|
||||
*/
|
||||
rtems_exception_init_mngt();
|
||||
|
||||
/*
|
||||
* Init rtems interrupt management
|
||||
*/
|
||||
rtems_irq_mngt_init();
|
||||
|
||||
/*
|
||||
* The following information is very useful when debugging.
|
||||
*/
|
||||
#if 0
|
||||
printk( "work_space_size = 0x%x\n\r",
|
||||
BSP_Configuration.work_space_size );
|
||||
printk( "maximum_extensions = 0x%x\n\r",
|
||||
BSP_Configuration.maximum_extensions );
|
||||
printk( "microseconds_per_tick = 0x%x\n\r",
|
||||
BSP_Configuration.microseconds_per_tick );
|
||||
printk( "ticks_per_timeslice = 0x%x\n\r",
|
||||
BSP_Configuration.ticks_per_timeslice );
|
||||
printk( "maximum_devices = 0x%x\n\r",
|
||||
BSP_Configuration.maximum_devices );
|
||||
printk( "number_of_device_drivers = 0x%x\n\r",
|
||||
BSP_Configuration.number_of_device_drivers );
|
||||
printk( "Device_driver_table = 0x%x\n\r",
|
||||
BSP_Configuration.Device_driver_table );
|
||||
printk( "work_space_start = 0x%x\n\r",
|
||||
BSP_Configuration.work_space_start );
|
||||
printk( "work_space_size = 0x%x\n\r",
|
||||
BSP_Configuration.work_space_size );
|
||||
#endif
|
||||
} /* bsp_start */
|
||||
|
||||
/*
|
||||
* Some versions of the bootloader shipped with the CSB337
|
||||
* reverse the MAC address. This function tests for that,
|
||||
* and fixes the MAC address.
|
||||
*/
|
||||
static void fix_mac_addr()
|
||||
{
|
||||
uint8_t addr[6];
|
||||
|
||||
/* Read the MAC address */
|
||||
addr[0] = (EMAC_REG(EMAC_SA1L) >> 0) & 0xff;
|
||||
addr[1] = (EMAC_REG(EMAC_SA1L) >> 8) & 0xff;
|
||||
addr[2] = (EMAC_REG(EMAC_SA1L) >> 16) & 0xff;
|
||||
addr[3] = (EMAC_REG(EMAC_SA1L) >> 24) & 0xff;
|
||||
addr[4] = (EMAC_REG(EMAC_SA1H) >> 0) & 0xff;
|
||||
addr[5] = (EMAC_REG(EMAC_SA1H) >> 8) & 0xff;
|
||||
|
||||
/* Check which 3 bytes have Cogent's OUI */
|
||||
if ((addr[5] == 0x00) && (addr[4] == 0x23) && (addr[3] == 0x31)) {
|
||||
EMAC_REG(EMAC_SA1L) = ((addr[5] << 0) |
|
||||
(addr[4] << 8) |
|
||||
(addr[3] << 16) |
|
||||
(addr[2] << 24));
|
||||
|
||||
EMAC_REG(EMAC_SA1H) = ((addr[1] << 0) |
|
||||
(addr[0] << 8));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* By making this a weak alias for bsp_start_default, a brave soul
|
||||
* can override the actual bsp_start routine used.
|
||||
*/
|
||||
void bsp_start (void) __attribute__ ((weak, alias("bsp_start_default")));
|
||||
|
||||
/**
|
||||
* Reset the system.
|
||||
*
|
||||
* This functions enables the watchdog and waits for it to
|
||||
* fire, thus resetting the system.
|
||||
*/
|
||||
void bsp_reset(void)
|
||||
{
|
||||
rtems_interrupt_level level;
|
||||
|
||||
_CPU_ISR_Disable(level);
|
||||
|
||||
/* Enable the watchdog timer, then wait for the world to end. */
|
||||
ST_REG(ST_WDMR) = ST_WDMR_RSTEN | 1;
|
||||
|
||||
while(1);
|
||||
}
|
||||
37
c/src/lib/libbsp/arm/csb337/startup/exit.c
Normal file
37
c/src/lib/libbsp/arm/csb337/startup/exit.c
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Cogent CSB337 Shutdown code
|
||||
*
|
||||
* Copyright (c) 2004 by Jay Monkman <jtm@lopingdog.com>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
*
|
||||
* http://www.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <bsp.h>
|
||||
#include <rtems/bspIo.h>
|
||||
#include <rtems/libio.h>
|
||||
|
||||
int dbgu_poll_read(int);
|
||||
|
||||
void rtemsReboot (void)
|
||||
{
|
||||
asm volatile ("b _start");
|
||||
}
|
||||
|
||||
void bsp_cleanup(void)
|
||||
{
|
||||
static char line[]="\nEXECUTIVE SHUTDOWN! Any key to reboot...";
|
||||
/*
|
||||
* AT this point, the console driver is disconnected => we must
|
||||
* use polled output/input. This is exactly what printk
|
||||
* does.
|
||||
*/
|
||||
printk("\n");
|
||||
printk(line);
|
||||
while (dbgu_poll_read(0) < 0) continue;
|
||||
}
|
||||
227
c/src/lib/libbsp/arm/csb337/startup/linkcmds
Normal file
227
c/src/lib/libbsp/arm/csb337/startup/linkcmds
Normal file
@@ -0,0 +1,227 @@
|
||||
/*
|
||||
* Cogent CSB337 Linker script
|
||||
*
|
||||
* Copyright (c) 2004 by Jay Monkman <jtm@lopingdog.com>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
*
|
||||
* http://www.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm",
|
||||
"elf32-littlearm")
|
||||
OUTPUT_ARCH(arm)
|
||||
ENTRY(_start)
|
||||
|
||||
MEMORY
|
||||
{
|
||||
sdram : ORIGIN = 0x20100000, LENGTH = 15M
|
||||
sram : ORIGIN = 0x00200000, LENGTH = 16K
|
||||
}
|
||||
|
||||
/*
|
||||
* Declare some sizes.
|
||||
*/
|
||||
_sdram_base = DEFINED(_sdram_base) ? _sdram_base : 0x20100000;
|
||||
_sdram_size = DEFINED(_sdram_size) ? _sdram_size : 15M;
|
||||
|
||||
|
||||
_sram_base = DEFINED(_sram_base) ? _sram_base : 0x00000000;
|
||||
_sram_size = DEFINED(_sram_size) ? _sram_size : 16K;
|
||||
|
||||
_irq_stack_size = DEFINED(_irq_stack_size) ? _irq_stack_size : 0x1000;
|
||||
_fiq_stack_size = DEFINED(_fiq_stack_size) ? _fiq_stack_size : 0x400;
|
||||
_abt_stack_size = DEFINED(_abt_stack_size) ? _abt_stack_size : 0x100;
|
||||
_svc_stack_size = DEFINED(_svc_stack_size) ? _svc_stack_size : 0x1000;
|
||||
|
||||
|
||||
|
||||
/* Do we need any of these for elf?
|
||||
__DYNAMIC = 0; */
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.base :
|
||||
{
|
||||
_sram_base = .;
|
||||
|
||||
/* reserve room for the vectors and function pointers */
|
||||
arm_exception_table = .;
|
||||
. += 64;
|
||||
|
||||
/* 256 byte aligned rx buffer header array */
|
||||
. = ALIGN (0x100);
|
||||
at91rm9200_emac_rxbuf_hdrs = .;
|
||||
|
||||
/* 1 transmit buffer, 0x600 size */
|
||||
. += (0x100);
|
||||
at91rm9200_emac_txbuf = .;
|
||||
. += (0x600);
|
||||
|
||||
/* 4 receive buffers, 0x600 each */
|
||||
at91rm9200_emac_rxbufs = .;
|
||||
. += (0x600 * 8);
|
||||
|
||||
} > sram
|
||||
|
||||
.init :
|
||||
{
|
||||
KEEP (*(.init))
|
||||
} > sdram /*=0*/
|
||||
|
||||
.text :
|
||||
{
|
||||
_text_start = .;
|
||||
CREATE_OBJECT_SYMBOLS
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
|
||||
/*
|
||||
* Special FreeBSD sysctl sections.
|
||||
*/
|
||||
. = ALIGN (16);
|
||||
__start_set_sysctl_set = .;
|
||||
*(set_sysctl_*);
|
||||
__stop_set_sysctl_set = ABSOLUTE(.);
|
||||
*(set_domain_*);
|
||||
*(set_pseudo_*);
|
||||
|
||||
/* .gnu.warning sections are handled specially by elf32.em. */
|
||||
*(.gnu.warning)
|
||||
*(.gnu.linkonce.t*)
|
||||
*(.glue_7)
|
||||
*(.glue_7t)
|
||||
|
||||
/* I think these come from the ld docs: */
|
||||
___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__ = .;
|
||||
|
||||
_etext = .;
|
||||
PROVIDE (etext = .);
|
||||
} > sdram
|
||||
|
||||
.fini :
|
||||
{
|
||||
KEEP (*(.fini))
|
||||
} > sdram /*=0*/
|
||||
|
||||
.data :
|
||||
{
|
||||
*(.data)
|
||||
*(.data.*)
|
||||
*(.gnu.linkonce.d*)
|
||||
*(.jcr)
|
||||
SORT(CONSTRUCTORS)
|
||||
_edata = .;
|
||||
} > sdram
|
||||
|
||||
.eh_frame : { *(.eh_frame) } > RAM
|
||||
.data1 : { *(.data1) } > RAM
|
||||
.eh_frame : { *(.eh_frame) } > RAM
|
||||
.gcc_except_table : { *(.gcc_except_table) } > RAM
|
||||
|
||||
.rodata :
|
||||
{
|
||||
*(.rodata)
|
||||
*(.rodata.*)
|
||||
*(.gnu.linkonce.r*)
|
||||
} > sdram
|
||||
|
||||
.bss :
|
||||
{
|
||||
_bss_start_ = .;
|
||||
_clear_start = .;
|
||||
*(.bss)
|
||||
*(.bss.*)
|
||||
*(COMMON)
|
||||
. = ALIGN(64);
|
||||
_clear_end = .;
|
||||
|
||||
. = ALIGN (256);
|
||||
_abt_stack = .;
|
||||
. += _abt_stack_size;
|
||||
|
||||
. = ALIGN (256);
|
||||
_irq_stack = .;
|
||||
. += _irq_stack_size;
|
||||
|
||||
. = ALIGN (256);
|
||||
_fiq_stack = .;
|
||||
. += _fiq_stack_size;
|
||||
|
||||
. = ALIGN (256);
|
||||
_svc_stack = .;
|
||||
. += _svc_stack_size;
|
||||
|
||||
_bss_end_ = .;
|
||||
_end = .;
|
||||
__end = .;
|
||||
|
||||
/*
|
||||
* Ideally, the MMU's translation table would be in SRAM. But we need
|
||||
* 16K which is the size of SRAM. If we do the mapping right, the TLB
|
||||
* should be big enough that to hold all the translations that matter,
|
||||
* so keeping the table in SDRAM won't be a problem.
|
||||
*/
|
||||
. = ALIGN (16 * 1024);
|
||||
_ttbl_base = .;
|
||||
. += (16 * 1024);
|
||||
|
||||
|
||||
. = ALIGN (1024);
|
||||
_bss_free_start = .;
|
||||
|
||||
} > 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 . */
|
||||
}
|
||||
|
||||
29
c/src/lib/libbsp/arm/csb337/startup/memmap.c
Normal file
29
c/src/lib/libbsp/arm/csb337/startup/memmap.c
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* CSB337 Memory Map
|
||||
*
|
||||
* Copyright (c) 2004 by Cogent Computer Systems
|
||||
* Written by Jay Monkman <jtm@lopingdog.com>
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
#include <rtems.h>
|
||||
#include <libcpu/mmu.h>
|
||||
|
||||
/* Remember, the ARM920 has 64 TLBs. If you have more 1MB sections than
|
||||
* that, you'll have TLB lookups, which could hurt performance.
|
||||
*/
|
||||
mmu_sect_map_t mem_map[] = {
|
||||
/* <phys addr> <virt addr> <size> <flags> */
|
||||
{0x00200000, 0x00000000, 1, MMU_CACHE_NONE}, /* SRAM */
|
||||
{0x00200000, 0x00200000, 1, MMU_CACHE_NONE}, /* SRAM */
|
||||
{0x10000000, 0x10000000, 8, MMU_CACHE_NONE}, /* FLASH */
|
||||
{0x20000000, 0x20000000, 32, MMU_CACHE_WTHROUGH}, /* SDRAM */
|
||||
{0x30000000, 0x30000000, 1, MMU_CACHE_NONE}, /* video */
|
||||
{0x40000000, 0x40000000, 1, MMU_CACHE_NONE}, /* Expansion CS0 */
|
||||
{0x50000000, 0x50000000, 1, MMU_CACHE_NONE}, /* CF CE 1 */
|
||||
{0x60000000, 0x60000000, 1, MMU_CACHE_NONE}, /* CF CE 1 */
|
||||
{0x70000000, 0x70000000, 1, MMU_CACHE_NONE}, /* CF CE 2 */
|
||||
{0x80000000, 0x80000000, 1, MMU_CACHE_NONE}, /* Expansion CS0 */
|
||||
{0xfff00000, 0xfff00000, 1, MMU_CACHE_NONE}, /* Internal regs */
|
||||
{0x00000000, 0x00000000, 0, 0} /* The end */
|
||||
};
|
||||
189
c/src/lib/libbsp/arm/csb337/times
Normal file
189
c/src/lib/libbsp/arm/csb337/times
Normal file
@@ -0,0 +1,189 @@
|
||||
#
|
||||
# Timing Test Suite Results for the Cogent CSB337 AT91RM9200 based SBC.
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
Board: Cogent CSB337
|
||||
CPU: AT91RM200 - ARM920T
|
||||
Clock Speed: 184 MHz
|
||||
Memory Configuration: SDRAM, 32 bits wide
|
||||
|
||||
Times Reported in: nanoseconds
|
||||
Timer Source: TC0, using timer_clock2 - 173 ns resolution
|
||||
|
||||
All tests were compiled with VARIANT=DEBUG
|
||||
|
||||
|
||||
cache state: none I only both
|
||||
== =================================================================== ======= ======= =======
|
||||
1 rtems_semaphore_create 25258 24220 14878
|
||||
1 rtems_semaphore_delete 25604 25777 15570
|
||||
1 rtems_semaphore_obtain: available 8227 8227 2876
|
||||
1 rtems_semaphore_obtain: not available -- NO_WAIT 8228 8228 2876
|
||||
1 rtems_semaphore_release: no waiting tasks 14718 14718 5947
|
||||
|
||||
2 rtems_semaphore_obtain: not available -- caller blocks 42779 42803 19163
|
||||
|
||||
3 rtems_semaphore_release: task readied -- preempts caller 32518 32522 15196
|
||||
|
||||
4 rtems_task_restart: blocked task -- preempts caller 76466 75255 42731
|
||||
4 rtems_task_restart: ready task -- preempts caller 71276 71622 35638
|
||||
4 rtems_semaphore_release: task readied -- returns to caller 21202 21218 9188
|
||||
4 rtems_task_create 76725 76753 34138
|
||||
4 rtems_task_start 30470 30468 12108
|
||||
4 rtems_task_restart: suspended task -- returns to caller 35973 35937 14440
|
||||
4 rtems_task_delete: suspended task 65546 65528 30141
|
||||
4 rtems_task_restart: ready task -- returns to caller 37046 37087 14654
|
||||
4 rtems_task_restart: blocked task -- returns to caller 43506 43549 18857
|
||||
4 rtems_task_delete: blocked task 68155 68110 31268
|
||||
|
||||
5 rtems_task_suspend: calling task 34020 33985 14128
|
||||
5 rtems_task_resume: task readied -- preempts caller 27956 27942 11641
|
||||
|
||||
6 rtems_task_restart: calling task 45360 45360 14846
|
||||
6 rtems_task_suspend: returns to caller 15398 15393 6722
|
||||
6 rtems_task_resume: task readied -- returns to caller 17206 17211 6544
|
||||
6 rtems_task_delete: ready task 68696 68681 31434
|
||||
|
||||
7 rtems_task_restart: suspended task -- preempts caller 54129 54104 22877
|
||||
|
||||
8 rtems_task_set_priority: obtain current priority 10869 10867 4267
|
||||
8 rtems_task_set_priority: returns to caller 25368 25351 8487
|
||||
8 rtems_task_mode: obtain current mode 5835 5830 2501
|
||||
8 rtems_task_mode: no reschedule 5998 5995 2645
|
||||
8 rtems_task_mode: reschedule -- returns to caller 12110 11764 6055
|
||||
8 rtems_task_mode: reschedule -- preempts caller 33043 34773 18338
|
||||
8 rtems_task_set_note 11869 11871 4356
|
||||
8 rtems_task_get_note 12092 12087 4397
|
||||
8 rtems_clock_set 33141 33145 10160
|
||||
8 rtems_clock_get 2920 2921 811
|
||||
|
||||
9 rtems_message_queue_create 74390 75601 46883
|
||||
9 rtems_message_queue_send: no waiting tasks 20387 20387 8702
|
||||
9 rtems_message_queue_urgent: no waiting tasks 20379 20379 8632
|
||||
9 rtems_message_queue_receive: available 22941 22941 8487
|
||||
9 rtems_message_queue_flush: no messages flushed 13459 13455 5932
|
||||
9 rtems_message_queue_flush: messages flushed 15808 15794 6802
|
||||
9 rtems_message_queue_delete 32351 33043 20414
|
||||
|
||||
10 rtems_message_queue_receive: not available -- NO_WAIT 14282 14296 4859
|
||||
10 rtems_message_queue_receive: not available -- caller blocks 43862 43794 19374
|
||||
|
||||
11 rtems_message_queue_send: task readied -- preempts caller 35025 35054 16997
|
||||
|
||||
12 rtems_message_queue_send: task readied -- returns to caller 24213 24194 11113
|
||||
|
||||
13 rtems_message_queue_urgent: task readied -- preempts caller 35004 24190 17099
|
||||
|
||||
14 rtems_message_queue_urgent: task readied -- returns to caller 24190 35042 11087
|
||||
|
||||
15 rtems_event_receive: obtain current events 1847 1849 560
|
||||
15 rtems_event_receive: not available -- NO_WAIT 10207 10210 3541
|
||||
15 rtems_event_receive: not available -- caller blocks 36305 36444 16165
|
||||
15 rtems_event_send: no task readied 10879 10871 4055
|
||||
15 rtems_event_receive: available 14359 14705 7439
|
||||
15 rtems_event_send: task readied -- returns to caller 20730 20727 9674
|
||||
|
||||
16 rtems_event_send: task readied -- preempts caller 33179 33210 15246
|
||||
|
||||
17 rtems_task_set_priority: preempts caller 44149 44232 18573
|
||||
|
||||
18 rtems_task_delete: calling task 85693 85685 38982
|
||||
|
||||
19 rtems_signal_catch 11418 11764 6401
|
||||
19 rtems_signal_send: returns to caller 20414 20414 14705
|
||||
19 rtems_signal_send: signal to self 33043 33043 23182
|
||||
19 exit ASR overhead: returns to calling task 18684 18857 11591
|
||||
19 exit ASR overhead: returns to preempting task 27680 26988 13321
|
||||
|
||||
20 rtems_partition_create 30621 31486 20587
|
||||
20 rtems_region_create 47921 46710 29410
|
||||
20 rtems_partition_get_buffer: available 16435 16781 12283
|
||||
20 rtems_partition_get_buffer: not available 13840 13494 6228
|
||||
20 rtems_partition_return_buffer 18338 18684 10207
|
||||
20 rtems_partition_delete 19203 21279 10380
|
||||
20 rtems_region_get_segment: available 36849 36676 16608
|
||||
20 rtems_region_get_segment: not available -- NO_WAIT 35984 35119 17819
|
||||
20 rtems_region_return_segment: no waiting tasks 34254 34254 15916
|
||||
20 rtems_region_get_segment: not available -- caller blocks 76639 76639 42385
|
||||
20 rtems_region_return_segment: task readied -- preempts caller 71968 73006 37714
|
||||
20 rtems_region_return_segment: task readied -- returns to caller 58128 57263 24220
|
||||
20 rtems_region_delete 37368 38060 22144
|
||||
20 rtems_io_initialize 3807 3788 1332
|
||||
20 rtems_io_open 2565 2560 854
|
||||
20 rtems_io_close 2565 2558 863
|
||||
20 rtems_io_read 2560 2550 852
|
||||
20 rtems_io_write 2638 2638 908
|
||||
20 rtems_io_control 2556 2556 854
|
||||
|
||||
21 rtems_task_ident 88425 88427 41471
|
||||
21 rtems_message_queue_ident 85875 85887 40243
|
||||
21 rtems_semaphore_ident 98762 98763 46357
|
||||
21 rtems_partition_ident 85825 85816 40255
|
||||
21 rtems_region_ident 87409 87413 41071
|
||||
21 rtems_port_ident 85567 85551 40167
|
||||
21 rtems_timer_ident 85801 85795 40289
|
||||
21 rtems_rate_monotonic_ident 85787 85780 40315
|
||||
|
||||
22 rtems_message_queue_broadcast: task readied -- returns to caller 39271 38752 26469
|
||||
22 rtems_message_queue_broadcast: no waiting tasks 15305 15308 6406
|
||||
22 rtems_message_queue_broadcast: task readied -- preempts caller 43077 43250 22144
|
||||
|
||||
23 rtems_timer_create 11144 11151 4421
|
||||
23 rtems_timer_fire_after: inactive 22863 22848 7918
|
||||
23 rtems_timer_fire_after: active 25072 25074 8092
|
||||
23 rtems_timer_cancel: active 13078 13073 4392
|
||||
23 rtems_timer_cancel: inactive 10834 10841 3710
|
||||
23 rtems_timer_reset: inactive 22254 22242 7096
|
||||
23 rtems_timer_reset: active 24450 24446 7608
|
||||
23 rtems_timer_fire_when: inactive 33001 33008 10186
|
||||
23 rtems_timer_fire_when: active 33004 33025 10148
|
||||
23 rtems_timer_delete: active 17280 17289 5580
|
||||
23 rtems_timer_delete: inactive 15102 15099 5006
|
||||
23 rtems_task_wake_when 51777 51825 20185
|
||||
|
||||
24 rtems_task_wake_after: yield -- returns to caller 8205 8208 2932
|
||||
24 rtems_task_wake_after: yields -- preempts caller 27998 28006 11879
|
||||
|
||||
25 rtems_clock_tick 14878 14878 11764
|
||||
|
||||
26 _ISR_Disable 4325 4325 3806
|
||||
26 _ISR_Flash 3633 3633 2768
|
||||
26 _ISR_Enable 3806 3806 2595
|
||||
26 _Thread_Disable_dispatch 4325 4498 2941
|
||||
26 _Thread_Enable_dispatch 8131 7958 4325
|
||||
26 _Thread_Set_state 14705 15051 6055
|
||||
26 _Thread_Disptach (NO FP) 24047 25258 13840
|
||||
26 context switch: no floating point contexts 16781 17127 11418
|
||||
26 context switch: self 4671 4671 3287
|
||||
26 context switch: to another task 5363 5536 3806
|
||||
26 fp context switch: restore 1st FP task - NA NA NA
|
||||
26 fp context switch: save idle, restore initialized - NA NA NA
|
||||
26 fp context switch: save idle, restore idle - NA NA NA
|
||||
26 fp context switch: save initialized, restore initialized - NA NA NA
|
||||
26 _Thread_Resume 14705 14705 10034
|
||||
26 _Thread_Unblock 13840 14186 8304
|
||||
26 _Thread_Ready 13148 13148 5190
|
||||
26 _Thread_Get 4909 4916 2003
|
||||
26 _Semaphore_Get 3430 3427 1055
|
||||
26 _Thread_Get: invalid id 1809 1807 998
|
||||
|
||||
27 interrupt entry overhead: returns to interrupted task 0 0 0
|
||||
27 interrupt exit overhead: returns to interrupted task 0 0 0
|
||||
27 interrupt entry overhead: returns to nested interrupt 0 0 0
|
||||
27 interrupt exit overhead: returns to nested interrupt 0 0 0
|
||||
|
||||
28 rtems_port_create 19722 20414 12283
|
||||
28 rtems_port_external_to_internal 10392 10393 3361
|
||||
28 rtems_port_internal_to_external 10397 10390 3325
|
||||
28 rtems_port_delete 18511 19376 10726
|
||||
|
||||
29 rtems_rate_monotonic_create 20414 20241 12629
|
||||
29 rtems_rate_monotonic_period: initiate period -- returns to caller 32178 32351 21106
|
||||
29 rtems_rate_monotonic_period: obtain status 15051 14532 6920
|
||||
29 rtems_rate_monotonic_cancel 21971 22317 12283
|
||||
29 rtems_rate_monotonic_delete: inactive 22490 21971 11591
|
||||
29 rtems_rate_monotonic_delete: active 22490 21452 8131
|
||||
29 rtems_rate_monotonic_period: conclude periods -- caller blocks 29652 29750 12897
|
||||
|
||||
Reference in New Issue
Block a user