change log for rtems (2010-08-20)
rtems-vc at rtems.org
rtems-vc at rtems.org
Fri Aug 20 22:10:18 UTC 2010
*joel*:
2010-08-20 <yann.sionneau at telecom-sudparis.eu>
Add Milkymist BSP developed as part of GSOC 2010.
* ChangeLog, Makefile.am, README, bsp_specs, configure.ac,
preinstall.am, Documentation/uart.txt, include/.cvsignore,
include/bsp.h, include/system_conf.h, include/tm27.h,
make/custom/milkymist.cfg, startup/linkcmds: New files.
A 1.1 c/src/lib/libbsp/lm32/milkymist/ChangeLog
A 1.1 c/src/lib/libbsp/lm32/milkymist/Documentation/uart.txt
A 1.1 c/src/lib/libbsp/lm32/milkymist/Makefile.am
A 1.1 c/src/lib/libbsp/lm32/milkymist/README
A 1.1 c/src/lib/libbsp/lm32/milkymist/bsp_specs
A 1.1 c/src/lib/libbsp/lm32/milkymist/configure.ac
A 1.1 c/src/lib/libbsp/lm32/milkymist/include/.cvsignore
A 1.1 c/src/lib/libbsp/lm32/milkymist/include/bsp.h
A 1.1 c/src/lib/libbsp/lm32/milkymist/include/system_conf.h
A 1.1 c/src/lib/libbsp/lm32/milkymist/include/tm27.h
A 1.1 c/src/lib/libbsp/lm32/milkymist/make/custom/milkymist.cfg
A 1.1 c/src/lib/libbsp/lm32/milkymist/preinstall.am
A 1.1 c/src/lib/libbsp/lm32/milkymist/startup/linkcmds
diff -u /dev/null rtems/c/src/lib/libbsp/lm32/milkymist/ChangeLog:1.1
--- /dev/null Fri Aug 20 17:10:15 2010
+++ rtems/c/src/lib/libbsp/lm32/milkymist/ChangeLog Fri Aug 20 16:22:27 2010
@@ -0,0 +1,9 @@
+2010-08-20 <yann.sionneau at telecom-sudparis.eu>
+
+ Add Milkymist BSP developed as part of GSOC 2010.
+ * ChangeLog, Makefile.am, README, bsp_specs, configure.ac,
+ preinstall.am, Documentation/uart.txt, include/.cvsignore,
+ include/bsp.h, include/system_conf.h, include/tm27.h,
+ make/custom/milkymist.cfg, startup/linkcmds: New files.
+
+08 / 12 / 2010 : <Yann Sionneau> Added Milkymist BSP
diff -u /dev/null rtems/c/src/lib/libbsp/lm32/milkymist/Documentation/uart.txt:1.1
--- /dev/null Fri Aug 20 17:10:15 2010
+++ rtems/c/src/lib/libbsp/lm32/milkymist/Documentation/uart.txt Fri Aug 20 16:22:27 2010
@@ -0,0 +1,31 @@
+Initialization :
+
+ set the CSR_UART_DIVISOR to the correct VALUE,
+ depending on the internal frequency of the LatticeMico32 softcore.
+
+ for the ML401 board, this value is calculated using this formula : clk_frequency/230400/16
+ clk_frequency = 100000000 Hz
+ => we must set CSR_UART_DIVISOR to 27
+
+How to send a byte to uart :
+
+void writechar(char c)
+{
+ CSR_UART_RXTX = c;
+ while(!(irq_pending() & IRQ_UARTTX));
+ irq_ack(IRQ_UARTTX);
+}
+
+How to receive a byte from uart :
+
+
+char readchar()
+{
+ char c;
+ while(!(irq_pending() & IRQ_UARTRX));
+ irq_ack(IRQ_UARTRX);
+ c = CSR_UART_RXTX;
+ return c;
+}
+
+
diff -u /dev/null rtems/c/src/lib/libbsp/lm32/milkymist/Makefile.am:1.1
--- /dev/null Fri Aug 20 17:10:15 2010
+++ rtems/c/src/lib/libbsp/lm32/milkymist/Makefile.am Fri Aug 20 16:22:27 2010
@@ -0,0 +1,69 @@
+##
+## $Id$
+##
+
+ACLOCAL_AMFLAGS = -I ../../../../aclocal
+
+include $(top_srcdir)/../../../../automake/compile.am
+
+include_bspdir = $(includedir)/bsp
+
+dist_project_lib_DATA = bsp_specs
+
+include_HEADERS = include/bsp.h
+include_HEADERS += include/tm27.h
+
+nodist_include_HEADERS = include/bspopts.h
+nodist_include_bsp_HEADERS = ../../shared/include/bootcard.h
+DISTCLEANFILES = include/bspopts.h
+
+noinst_PROGRAMS =
+
+include_HEADERS += ../../shared/include/coverhd.h
+include_HEADERS += include/system_conf.h
+
+noinst_LIBRARIES = libbspstart.a
+libbspstart_a_SOURCES = ../../lm32/shared/start/start.S
+project_lib_DATA = start.$(OBJEXT)
+
+dist_project_lib_DATA += startup/linkcmds
+
+noinst_LIBRARIES += libbsp.a
+libbsp_a_SOURCES =
+libbsp_a_LIBADD =
+
+# startup
+libbsp_a_SOURCES += ../../shared/bspclean.c ../../shared/bsplibc.c \
+ ../../shared/bsppost.c ../shared/startup/bspstart.c \
+ ../../shared/bspreset.c ../../shared/bsppretaskinghook.c \
+ ../../shared/bspgetworkarea.c ../../shared/bootcard.c \
+ ../../shared/sbrk.c ../../lm32/shared/startup/setvec.c \
+ ../../shared/gnatinstallhandler.c
+
+# clock
+
+libbsp_a_SOURCES += ../../lm32/shared/milkymist_clock/ckinit.c
+
+# console
+libbsp_a_SOURCES += ../../lm32/shared/milkymist_console/console.c \
+ ../../lm32/shared/milkymist_console/uart.c
+# timer
+libbsp_a_SOURCES += ../../lm32/shared/milkymist_timer/timer.c
+
+# framebuffer
+libbsp_a_SOURCES += ../../lm32/shared/milkymist_framebuffer/framebuffer.c
+
+# gpio
+libbsp_a_SOURCES += ../../lm32/shared/milkymist_gpio/gpio.c
+
+if HAS_NETWORKING
+noinst_PROGRAMS += network.rel
+network_rel_SOURCES = ../../lm32/shared/milkymist_networking/network.c \
+ ../../lm32/shared/milkymist_networking/mm_crc32.c
+network_rel_CPPFLAGS = $(AM_CPPFLAGS) -D__INSIDE_RTEMS_BSD_TCPIP_STACK__
+network_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
+libbsp_a_LIBADD += network.rel
+endif
+
+include $(srcdir)/preinstall.am
+include $(top_srcdir)/../../../../automake/local.am
diff -u /dev/null rtems/c/src/lib/libbsp/lm32/milkymist/README:1.1
--- /dev/null Fri Aug 20 17:10:15 2010
+++ rtems/c/src/lib/libbsp/lm32/milkymist/README Fri Aug 20 16:22:27 2010
@@ -0,0 +1,21 @@
+#
+# $Id$
+#
+
+This is a BSP written by Yann Sionneau <yann.sionneau at telecom-sudparis.eu>
+as part of Google Summer of Code 2010.
+
+This is a BSP to make RTEMS run on Milkymist One board using Milkymist SoC
+
+It provides driver for timer, uart, ethernet, framebuffer so far.
+
+Milkymist SoC is running @ 83 MHz with 128 MB of 32-bit DDR400 SDRAM
+The SoC is based on a XC6SLX45 Spartan-6 FPGA running
+the LatticeMico32 softcore.
+
+More informations available at : http://www.milkymist.org/
+
+Information about the porting can be found in Yann Sionneau's blog
+at http://sionneau.net/
+
+Milkymist is a project leaded by Sebastien Bourdeauducq (aka lekernel)
diff -u /dev/null rtems/c/src/lib/libbsp/lm32/milkymist/bsp_specs:1.1
--- /dev/null Fri Aug 20 17:10:15 2010
+++ rtems/c/src/lib/libbsp/lm32/milkymist/bsp_specs Fri Aug 20 16:22:27 2010
@@ -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_endfile)} %{qrtems: crtend.o%s crtn.o%s}
diff -u /dev/null rtems/c/src/lib/libbsp/lm32/milkymist/configure.ac:1.1
--- /dev/null Fri Aug 20 17:10:15 2010
+++ rtems/c/src/lib/libbsp/lm32/milkymist/configure.ac Fri Aug 20 16:22:27 2010
@@ -0,0 +1,34 @@
+## Process this file with autoconf to produce a configure script.
+##
+## $Id$
+
+AC_PREREQ(2.60)
+AC_INIT([rtems-c-src-lib-libbsp-lm32-milkymist],
+ [_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
+RTEMS_CANONICALIZE_TOOLS
+RTEMS_PROG_CCAS
+
+RTEMS_CHECK_NETWORKING
+AM_CONDITIONAL(HAS_NETWORKING,test "$HAS_NETWORKING" = "yes")
+
+RTEMS_BSPOPTS_SET([ON_SIMULATOR],[*],[])
+RTEMS_BSPOPTS_HELP([ON_SIMULATOR],
+[If defined, this indicates the BSP is being built to run on the lm32
+ simulator in GDB. This enables fast idle support which speeds up the
+ clock ticks while the idle task is running so time spent in the idle
+ task is minimized. This significantly reduces the wall time required
+ to execute the RTEMS test suites. It also enables a special exit and
+ alternate printk support.])
+
+RTEMS_BSP_CLEANUP_OPTIONS(0,0)
+# Explicitly list all Makefiles here
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
diff -u /dev/null rtems/c/src/lib/libbsp/lm32/milkymist/include/.cvsignore:1.1
--- /dev/null Fri Aug 20 17:10:15 2010
+++ rtems/c/src/lib/libbsp/lm32/milkymist/include/.cvsignore Fri Aug 20 16:22:27 2010
@@ -0,0 +1,4 @@
+stamp-h
+stamp-h.in
+bspopts.h
+bspopts.h.in
diff -u /dev/null rtems/c/src/lib/libbsp/lm32/milkymist/include/bsp.h:1.1
--- /dev/null Fri Aug 20 17:10:15 2010
+++ rtems/c/src/lib/libbsp/lm32/milkymist/include/bsp.h Fri Aug 20 16:22:27 2010
@@ -0,0 +1,74 @@
+/* bsp.h
+ *
+ * This include file contains all board IO definitions.
+ *
+ * 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$
+ *
+ * Yann Sionneau <yann.sionneau at telecom-sudparis.eu>, (GSoC 2010)
+ * Telecom SudParis
+ */
+
+#ifndef _BSP_H
+#define _BSP_H
+
+#include <stdint.h>
+#include <bspopts.h>
+
+#include <rtems.h>
+#include <rtems/console.h>
+#include <rtems/clockdrv.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define BSP_DIRTY_MEMORY 1
+
+#define BSP_HAS_FRAME_BUFFER 1
+
+#define GPIO_DRIVER_TABLE_ENTRY { gpio_initialize, \
+gpio_open, gpio_close, gpio_read, gpio_write, gpio_control}
+
+ /*
+ * lm32 requires certain aligment of mbuf because unaligned uint32_t
+ * accesses are not handled properly.
+ */
+
+#define CPU_U32_FIX
+
+#if defined(RTEMS_NETWORKING)
+#include <rtems/rtems_bsdnet.h>
+struct rtems_bsdnet_ifconfig;
+extern int rtems_minimac_driver_attach (struct rtems_bsdnet_ifconfig *config,
+ int attaching);
+#define RTEMS_BSP_NETWORK_DRIVER_ATTACH rtems_minimac_driver_attach
+#define RTEMS_BSP_NETWORK_DRIVER_NAME "minimac0"
+#endif
+
+ /*
+ * 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 ) \
+ { \
+ }
+
+/* functions */
+lm32_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 */
+);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff -u /dev/null rtems/c/src/lib/libbsp/lm32/milkymist/include/system_conf.h:1.1
--- /dev/null Fri Aug 20 17:10:16 2010
+++ rtems/c/src/lib/libbsp/lm32/milkymist/include/system_conf.h Fri Aug 20 16:22:27 2010
@@ -0,0 +1,56 @@
+/* system_conf.h
+ * Global System conf
+ *
+ * Milkymist port of RTEMS
+ *
+ * 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 __SYSTEM_CONFIG_H_
+#define __SYSTEM_CONFIG_H_
+
+#define CPU_FREQUENCY (83333333)
+#define UART_BAUD_RATE (115200)
+
+#define MM_TIMER1_COMPARE (0xe0001024)
+#define MM_TIMER1_COUNTER (0xe0001028)
+#define MM_TIMER1_CONTROL (0xe0001020)
+
+#define MM_TIMER0_COMPARE (0xe0001014)
+#define MM_TIMER0_COUNTER (0xe0001018)
+#define MM_TIMER0_CONTROL (0xe0001010)
+
+#define TIMER_ENABLE (0x01)
+#define TIMER_AUTORESTART (0x02)
+
+#define MM_VGA_RESET_MODE (0x01)
+#define MM_VGA_RESET (0xe0003000)
+#define MM_VGA_BASEADDRESS (0xe0003024)
+#define MM_VGA_BASEADDRESS_ACT (0xe0003028)
+
+#define MM_MINIMAC_SETUP (0xe0009000)
+#define MM_MINIMAC_STATE0 (0xe0009008)
+#define MM_MINIMAC_ADDR0 (0xe000900C)
+#define MM_MINIMAC_COUNT0 (0xe0009010)
+
+#define MM_MINIMAC_STATE1 (0xe0009014)
+#define MM_MINIMAC_ADDR1 (0xe0009018)
+#define MM_MINIMAC_COUNT1 (0xe000901C)
+
+#define MM_MINIMAC_STATE2 (0xe0009020)
+#define MM_MINIMAC_ADDR2 (0xe0009024)
+#define MM_MINIMAC_COUNT2 (0xe0009028)
+
+#define MM_MINIMAC_STATE3 (0xe000902C)
+#define MM_MINIMAC_ADDR3 (0xe0009030)
+#define MM_MINIMAC_COUNT3 (0xe0009034)
+
+#define MM_MINIMAC_TXREMAINING (0xe000903C)
+#define MM_MINIMAC_TXADR (0xe0009038)
+
+#endif /* __SYSTEM_CONFIG_H_ */
diff -u /dev/null rtems/c/src/lib/libbsp/lm32/milkymist/include/tm27.h:1.1
--- /dev/null Fri Aug 20 17:10:16 2010
+++ rtems/c/src/lib/libbsp/lm32/milkymist/include/tm27.h Fri Aug 20 16:22:27 2010
@@ -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
+
+/*
+ * Stuff for Time Test 27
+ */
+
+#define MUST_WAIT_FOR_INTERRUPT 0
+
+#define Install_tm27_vector( handler ) set_vector( (handler), 0, 1 )
+
+#define Cause_tm27_intr() /* empty */
+
+#define Clear_tm27_intr() /* empty */
+
+#define Lower_tm27_intr() /* empty */
+
+#endif
diff -u /dev/null rtems/c/src/lib/libbsp/lm32/milkymist/make/custom/milkymist.cfg:1.1
--- /dev/null Fri Aug 20 17:10:16 2010
+++ rtems/c/src/lib/libbsp/lm32/milkymist/make/custom/milkymist.cfg Fri Aug 20 16:22:27 2010
@@ -0,0 +1,28 @@
+#
+# Config file for the milkymist BSP
+#
+
+# Choices for CPU_MODEL:
+# tiny (no cache)
+# standard (instruction cache)
+# fast (instruction and data cache)
+
+RTEMS_CPU = lm32
+RTEMS_CPU_MODEL = lm32
+
+include $(RTEMS_ROOT)/make/custom/default.cfg
+
+# This contains the compiler options necessary to select the CPU model
+# and (hopefully) optimize for it.
+CPU_CFLAGS = -mbarrel-shift-enabled -mmultiply-enabled \
+ -mdivide-enabled -msign-extend-enabled
+
+# optimize flag: typically -O2
+# ATM, doesn't work with optimization levels > 0
+CFLAGS_OPTIMIZE_V = -O2 -g
+
+define bsp-post-link
+ $(OBJCOPY) -O binary --strip-all $(basename $@).exe \
+ -R entry -R exceptions $(basename $@)$(DOWNEXT)
+ $(default-bsp-post-link)
+endef
diff -u /dev/null rtems/c/src/lib/libbsp/lm32/milkymist/preinstall.am:1.1
--- /dev/null Fri Aug 20 17:10:16 2010
+++ rtems/c/src/lib/libbsp/lm32/milkymist/preinstall.am Fri Aug 20 16:22:27 2010
@@ -0,0 +1,71 @@
+## 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_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)/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)/coverhd.h: ../../shared/include/coverhd.h $(PROJECT_INCLUDE)/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/coverhd.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/coverhd.h
+
+$(PROJECT_INCLUDE)/system_conf.h: include/system_conf.h $(PROJECT_INCLUDE)/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/system_conf.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/system_conf.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
+
diff -u /dev/null rtems/c/src/lib/libbsp/lm32/milkymist/startup/linkcmds:1.1
--- /dev/null Fri Aug 20 17:10:16 2010
+++ rtems/c/src/lib/libbsp/lm32/milkymist/startup/linkcmds Fri Aug 20 16:22:27 2010
@@ -0,0 +1,290 @@
+OUTPUT_FORMAT("elf32-lm32", "elf32-lm32",
+ "elf32-lm32")
+OUTPUT_ARCH(lm32)
+ENTRY(_start)
+/* Do we need any of these for elf?
+ __DYNAMIC = 0; */
+
+/*
+ * Declare some sizes. Heap is sized at whatever ram space is left.
+ */
+RamBase = DEFINED(RamBase) ? RamBase : 0x40000000;
+RamSize = DEFINED(RamSize) ? RamSize : 64M;
+HeapSize = DEFINED(HeapSize) ? HeapSize : 2M;
+_StackSize = DEFINED(_StackSize) ? _StackSize : 0x2000;
+
+PROVIDE (__stack = 0);
+MEMORY {
+ sdram : ORIGIN = 0x40000000 , LENGTH = 64M
+}
+SECTIONS
+{
+ .boot :
+ {
+ KEEP (*(.boot))
+ } > sdram
+
+ /* Read-only sections, merged into text segment: */
+ .interp : { *(.interp) } > sdram
+ .hash : { *(.hash) } > sdram
+ .dynsym : { *(.dynsym) } > sdram
+ .dynstr : { *(.dynstr) } > sdram
+ .gnu.version : { *(.gnu.version) } > sdram
+ .gnu.version_d : { *(.gnu.version_d) } > sdram
+ .gnu.version_r : { *(.gnu.version_r) } > sdram
+ .rela.text :
+ { *(.rela.text) *(.rela.gnu.linkonce.t*) } > sdram
+ .rela.data :
+ { *(.rela.data) *(.rela.gnu.linkonce.d*) } > sdram
+ .rela.rodata :
+ { *(.rela.rodata*) *(.rela.gnu.linkonce.r*) } > sdram
+ .rela.got : { *(.rela.got) } > sdram
+ .rela.got1 : { *(.rela.got1) } > sdram
+ .rela.got2 : { *(.rela.got2) } > sdram
+ .rela.ctors : { *(.rela.ctors) } > sdram
+ .rela.dtors : { *(.rela.dtors) } > sdram
+ .rela.init : { *(.rela.init) } > sdram
+ .rela.fini : { *(.rela.fini) } > sdram
+ .rela.bss : { *(.rela.bss) } > sdram
+ .rela.plt : { *(.rela.plt) } > sdram
+ .rela.sdata : { *(.rela.sdata) } > sdram
+ .rela.sbss : { *(.rela.sbss) } > sdram
+ .rela.sdata2 : { *(.rela.sdata2) } > sdram
+ .rela.sbss2 : { *(.rela.sbss2) } > sdram
+ .rela.dyn : { *(.rela.dyn) } > sdram
+
+ .init : { KEEP(*(.init)) } > sdram
+
+ .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*)
+ } > sdram
+
+ .fini : { _fini = .; KEEP(*(.fini)) } > sdram
+
+ .rodata : { *(.rodata*) *(.gnu.linkonce.r*) } > sdram
+ .rodata1 : { *(.rodata1) } > sdram
+
+ /* Adjust the address for the data segment. We want to adjust up to
+ the same address within the page on the next page up. */
+ . = ALIGN(0x10000) + (. & (0x10000 - 1));
+ /* Ensure the __preinit_array_start label is properly aligned. We
+ could instead move the label definition inside the section, but
+ the linker would then create the section even if it turns out to
+ be empty, which isn't pretty. */
+ . = ALIGN(32 / 8);
+ PROVIDE (__preinit_array_start = .);
+ .preinit_array : { *(.preinit_array) } >sdram
+ PROVIDE (__preinit_array_end = .);
+ PROVIDE (__init_array_start = .);
+ .init_array : { *(.init_array) } >sdram
+ PROVIDE (__init_array_end = .);
+ PROVIDE (__fini_array_start = .);
+ .fini_array : { *(.fini_array) } >sdram
+ PROVIDE (__fini_array_end = .);
+
+/* _SDA2_BASE_ = __SDATA2_START__ + 0xe000; */
+ .sdata2 : { *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) } >sdram
+ .sbss2 : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)
+ /* avoid empty sdata2/sbss2 area -- __eabi would not set up r2
+ * which may be important if run-time loading is used
+ */
+ . += 1;
+ } >sdram
+ .eh_frame : { *.(eh_frame) } >sdram
+
+ /* NOTE: if the BSP uses page tables, the correctness of
+ * '_etext' (and __DATA_START__) is CRUCIAL - otherwise,
+ * an invalid mapping may result!!!
+ */
+ _etext = .;
+ PROVIDE (etext = .);
+
+ /* Adjust the address for the data segment. We want to adjust up to
+ the same address within the page on the next page up. It would
+ be more correct to do this:
+ . = ALIGN(0x40000) + (ALIGN(8) & (0x40000 - 1));
+ The current expression does not correctly handle the case of a
+ text segment ending precisely at the end of a page; it causes the
+ data segment to skip a page. The above expression does not have
+ this problem, but it will currently (2/95) cause BFD to allocate
+ a single segment, combining both text and data, for this case.
+ This will prevent the text segment from being shared among
+ multiple executions of the program; I think that is more
+ important than losing a page of the virtual address space (note
+ that no actual memory is lost; the page which is skipped can not
+ be referenced). */
+ . = ALIGN(0x1000);
+ .data ALIGN(0x1000) :
+ {
+ /* NOTE: if the BSP uses page tables, the correctness of
+ * '__DATA_START__' (and _etext) is CRUCIAL - otherwise,
+ * an invalid mapping may result!!!
+ */
+ PROVIDE(__DATA_START__ = ABSOLUTE(.) );
+ *(.data .data.* .gnu.linkonce.d*)
+ SORT(CONSTRUCTORS)
+ } > sdram
+ .data1 : { *(.data1) } > sdram
+ PROVIDE (__EXCEPT_START__ = .);
+ .gcc_except_table : {
+ *(.gcc_except_table)
+ *(.gcc_except_table.*)
+ } > sdram
+ PROVIDE (__EXCEPT_END__ = .);
+ .got1 : { *(.got1) } > sdram
+ /* Put .ctors and .dtors next to the .got2 section, so that the pointers
+ get relocated with -mrelocatable. Also put in the .fixup pointers.
+ The current compiler no longer needs this, but keep it around for 2.7.2 */
+ PROVIDE (_GOT2_START_ = .);
+ .got2 : { *(.got2) } > sdram
+ .dynamic : { *(.dynamic) } > sdram
+
+ .ctors :
+ {
+ /* gcc uses crtbegin.o to find the start of
+ the constructors, so we make sure it is
+ first. Because this is a wildcard, it
+ doesn't matter if the user does not
+ actually link against crtbegin.o; the
+ linker won't look for a file to match a
+ wildcard. The wildcard also means that it
+ doesn't matter which directory crtbegin.o
+ is in. */
+ KEEP (*crtbegin.o(.ctors))
+ /* We don't want to include the .ctor section from
+ from the crtend.o file until after the sorted ctors.
+ The .ctor section from the crtend file contains the
+ end of ctors marker and it must be last */
+ KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*(.ctors))
+ } > sdram
+ .dtors :
+ {
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*(.dtors))
+ } > sdram
+
+
+ PROVIDE (_FIXUP_START_ = .);
+ .fixup : { *(.fixup) } > sdram
+ PROVIDE (_FIXUP_END_ = .);
+ PROVIDE (_GOT2_END_ = .);
+ PROVIDE (_GOT_START_ = .);
+
+ .got : { *(.got) } > sdram
+ .got.plt : { *(.got.plt) } > sdram
+
+ PROVIDE (_GOT_END_ = .);
+
+ .jcr : { KEEP (*(.jcr)) } > sdram
+
+ /* We want the small data sections together, so single-instruction offsets
+ can access them all, and initialized data all before uninitialized, so
+ we can shorten the on-disk segment size. */
+/* _SDA_BASE_ = __SDATA_START__ + 0xe000; */
+ .sdata : { *(.sdata*) *(.gnu.linkonce.s.*) } >sdram
+ _edata = .;
+ _gp = .;
+ PROVIDE (edata = .);
+ .sbss :
+ {
+ _clear_start = .;
+ PROVIDE (__sbss_start = .);
+ *(.dynsbss)
+ *(.sbss* .gnu.linkonce.sb.*)
+ *(.scommon)
+ /* avoid empty sdata/sbss area -- __eabi would not set up r13
+ * which may be important if run-time loading is used
+ */
+ . += 1;
+ . = ALIGN(16);
+ PROVIDE (__sbss_end = .);
+ } > sdram
+ .plt : { *(.plt) } > sdram
+ .bss :
+ {
+ PROVIDE (__bss_start = .);
+ *(.dynbss)
+ *(.bss .bss* .gnu.linkonce.b*)
+ *(COMMON)
+ . = ALIGN(16);
+ _end = . ;
+ __rtems_end = . ;
+ PROVIDE (end = .);
+
+ . += _StackSize;
+ _fstack = .;
+
+ WorkAreaBase = .;
+
+ . = ALIGN (16);
+ _stack_init = .;
+ _clear_end = .;
+
+ } > sdram
+
+
+ /DISCARD/ :
+ {
+ *(.comment)
+ }
+
+
+ /* 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) }
+ /* These must appear regardless of . */
+}
*joel*:
2010-08-20 <yann.sionneau at telecom-sudparis.eu>
* acinclude.m4, configure.ac: Add Milkymist BSP developed as part of
GSOC 2010.
M 1.15 c/src/lib/libbsp/lm32/ChangeLog
M 1.2 c/src/lib/libbsp/lm32/acinclude.m4
M 1.3 c/src/lib/libbsp/lm32/configure.ac
diff -u rtems/c/src/lib/libbsp/lm32/ChangeLog:1.14 rtems/c/src/lib/libbsp/lm32/ChangeLog:1.15
--- rtems/c/src/lib/libbsp/lm32/ChangeLog:1.14 Fri May 7 14:25:08 2010
+++ rtems/c/src/lib/libbsp/lm32/ChangeLog Fri Aug 20 16:22:31 2010
@@ -1,3 +1,8 @@
+2010-08-20 <yann.sionneau at telecom-sudparis.eu>
+
+ * acinclude.m4, configure.ac: Add Milkymist BSP developed as part of
+ GSOC 2010.
+
2010-05-07 Joel Sherrill <joel.sherrill at oarcorp.com>
* shared/start/start.S: Finish merging change.
diff -u rtems/c/src/lib/libbsp/lm32/acinclude.m4:1.1 rtems/c/src/lib/libbsp/lm32/acinclude.m4:1.2
--- rtems/c/src/lib/libbsp/lm32/acinclude.m4:1.1 Thu Dec 4 16:55:13 2008
+++ rtems/c/src/lib/libbsp/lm32/acinclude.m4 Fri Aug 20 16:22:31 2010
@@ -4,6 +4,8 @@
case "$1" in
lm32_evr )
AC_CONFIG_SUBDIRS([lm32_evr]);;
+ milkymist )
+ AC_CONFIG_SUBDIRS([milkymist]);;
*)
AC_MSG_ERROR([Invalid BSP]);;
esac
diff -u rtems/c/src/lib/libbsp/lm32/configure.ac:1.2 rtems/c/src/lib/libbsp/lm32/configure.ac:1.3
--- rtems/c/src/lib/libbsp/lm32/configure.ac:1.2 Sat Nov 28 00:28:40 2009
+++ rtems/c/src/lib/libbsp/lm32/configure.ac Fri Aug 20 16:22:31 2010
@@ -4,7 +4,7 @@
AC_PREREQ(2.60)
AC_INIT([rtems-c-src-lib-libbsp-lm32],[_RTEMS_VERSION],[http://www.rtems.org/bugzilla])
-AC_CONFIG_SRCDIR([lm32_evr])
+AC_CONFIG_SRCDIR([../lm32])
RTEMS_TOP(../../../../..)
RTEMS_CANONICAL_TARGET_CPU
*joel*:
2010-08-20 <yann.sionneau at telecom-sudparis.eu>
* shared/milkymist_ac97/ac97.c, shared/milkymist_clock/ckinit.c,
shared/milkymist_clock/clock.h, shared/milkymist_console/console.c,
shared/milkymist_console/uart.c, shared/milkymist_console/uart.h,
shared/milkymist_framebuffer/framebuffer.c,
shared/milkymist_gpio/gpio.c, shared/milkymist_networking/mm_crc32.c,
shared/milkymist_networking/network.c,
shared/milkymist_networking/network.h,
shared/milkymist_timer/timer.c: New files.
M 1.16 c/src/lib/libbsp/lm32/ChangeLog
A 1.1 c/src/lib/libbsp/lm32/shared/milkymist_ac97/ac97.c
A 1.1 c/src/lib/libbsp/lm32/shared/milkymist_clock/ckinit.c
A 1.1 c/src/lib/libbsp/lm32/shared/milkymist_clock/clock.h
A 1.1 c/src/lib/libbsp/lm32/shared/milkymist_console/console.c
A 1.1 c/src/lib/libbsp/lm32/shared/milkymist_console/uart.h
A 1.1 c/src/lib/libbsp/lm32/shared/milkymist_console/uart.c
A 1.1 c/src/lib/libbsp/lm32/shared/milkymist_framebuffer/framebuffer.c
A 1.1 c/src/lib/libbsp/lm32/shared/milkymist_gpio/gpio.c
A 1.1 c/src/lib/libbsp/lm32/shared/milkymist_networking/mm_crc32.c
A 1.1 c/src/lib/libbsp/lm32/shared/milkymist_networking/network.h
A 1.1 c/src/lib/libbsp/lm32/shared/milkymist_networking/network.c
A 1.1 c/src/lib/libbsp/lm32/shared/milkymist_timer/timer.c
diff -u rtems/c/src/lib/libbsp/lm32/ChangeLog:1.15 rtems/c/src/lib/libbsp/lm32/ChangeLog:1.16
--- rtems/c/src/lib/libbsp/lm32/ChangeLog:1.15 Fri Aug 20 16:22:31 2010
+++ rtems/c/src/lib/libbsp/lm32/ChangeLog Fri Aug 20 16:23:26 2010
@@ -1,5 +1,16 @@
2010-08-20 <yann.sionneau at telecom-sudparis.eu>
+ * shared/milkymist_ac97/ac97.c, shared/milkymist_clock/ckinit.c,
+ shared/milkymist_clock/clock.h, shared/milkymist_console/console.c,
+ shared/milkymist_console/uart.c, shared/milkymist_console/uart.h,
+ shared/milkymist_framebuffer/framebuffer.c,
+ shared/milkymist_gpio/gpio.c, shared/milkymist_networking/mm_crc32.c,
+ shared/milkymist_networking/network.c,
+ shared/milkymist_networking/network.h,
+ shared/milkymist_timer/timer.c: New files.
+
+2010-08-20 <yann.sionneau at telecom-sudparis.eu>
+
* acinclude.m4, configure.ac: Add Milkymist BSP developed as part of
GSOC 2010.
diff -u /dev/null rtems/c/src/lib/libbsp/lm32/shared/milkymist_ac97/ac97.c:1.1
--- /dev/null Fri Aug 20 17:10:16 2010
+++ rtems/c/src/lib/libbsp/lm32/shared/milkymist_ac97/ac97.c Fri Aug 20 16:23:27 2010
@@ -0,0 +1,119 @@
+/* ac97.c
+ *
+ * This file is the sound driver for the Milkymist One board
+ * It does an OSS style character device in /dev/snd
+ *
+ * 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$
+ *
+ * COPYRIGHT (c) Yann Sionneau <yann.sionneau at telecom-sudparis.eu> (GSoC 2010)
+ * Telecom SudParis
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <pthread.h>
+#include <rtems.h>
+#include <bsp.h>
+#include "../include/system_conf.h"
+#include <rtems/libio.h>
+
+#define GPIO_DRIVER_TABLE_ENTRY { ac97_initialize, \
+ac97_open, ac97_close, ac97_read, ac97_write, ac97_control}
+
+#define SND_DEVICE_NAME "/dev/snd"
+
+static struct milkymist_ac97 {
+ rtems_device_minor_number minor;
+ pthread_mutex_t mutex;
+} ac97_driver;
+
+rtems_device_driver gpio_initialize(
+rtems_device_major_number major,
+rtems_device_minor_number minor,
+void *arg)
+{
+ rtems_status_code status;
+
+ printk( "ac97 driver initializing..\n" );
+
+ status = rtems_io_register_name(SND_DEVICE_NAME, major, 0);
+ if (status != RTEMS_SUCCESSFUL)
+ {
+ printk("Error registering /dev/snd ac97 device \n");
+ rtems_fatal_error_occurred( status );
+ }
+ gpio[0].minor = 0;
+ gpio[0].mutex = PTHREAD_MUTEX_INITIALIZER;
+
+ return RTEMS_SUCCESSFUL;
+}
+
+rtems_device_driver gpio_close(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *arg
+)
+{
+ if (pthread_mutex_unlock(&ac97_driver.mutex) == 0){
+ return RTEMS_SUCCESSFUL;
+ }
+ return RTEMS_UNSATISFIED;
+}
+
+rtems_device_driver gpio_open(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *arg
+)
+{
+ if (pthread_mutex_trylock(&ac97_driver.mutex) == 0){
+ return RTEMS_SUCCESSFUL;
+ }
+ return RTEMS_UNSATISFIED;
+}
+
+
+rtems_device_driver gpio_read(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *arg
+)
+{
+ rtems_libio_rw_args_t *rw_args = (rtems_libio_rw_args_t *)arg;
+
+ return RTEMS_SUCCESSFUL;
+}
+
+rtems_device_driver gpio_write(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *arg
+)
+{
+ rtems_libio_rw_args_t *rw_args = (rtems_libio_rw_args_t *)arg;
+
+ return RTEMS_SUCCESSFUL;
+}
+
+rtems_device_driver gpio_control(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *arg
+)
+{
+ rtems_libio_ioctl_args_t *args = arg;
+
+ switch( args->command ) {
+ default:
+ args->ioctl_return = 0;
+ break;
+ }
+ return RTEMS_SUCCESSFUL;
+}
+
diff -u /dev/null rtems/c/src/lib/libbsp/lm32/shared/milkymist_clock/ckinit.c:1.1
--- /dev/null Fri Aug 20 17:10:16 2010
+++ rtems/c/src/lib/libbsp/lm32/shared/milkymist_clock/ckinit.c Fri Aug 20 16:23:27 2010
@@ -0,0 +1,70 @@
+/* ckinit.c
+ *
+ * Clock device driver for Lattice Mico32 (lm32).
+ *
+ * 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$
+ *
+ * COPYRIGHT (c) Yann Sionneau <yann.sionneau at telecom-sudparis.eu> (GSoC 2010)
+ * Telecom SudParis
+ */
+
+#include <bsp.h>
+#include "../include/system_conf.h"
+#include "clock.h"
+#include "bspopts.h"
+
+#if ON_SIMULATOR
+#define CLOCK_DRIVER_USE_FAST_IDLE
+#endif
+
+static inline int clockread(unsigned int reg)
+{
+ return *((int*)(reg));
+}
+
+static inline void clockwrite(unsigned int reg, int value)
+{
+ *((int*)reg) = value;
+}
+
+/*
+ * The interrupt vector number associated with the clock tick device
+ * driver.
+ */
+
+#define TIMER0_IRQ (1)
+
+#define CLOCK_VECTOR ( TIMER0_IRQ )
+#define CLOCK_IRQMASK ( 1 << CLOCK_VECTOR )
+
+#define Clock_driver_support_at_tick() \
+ do { \
+ lm32_interrupt_ack(CLOCK_IRQMASK); \
+ } while (0)
+
+#define Clock_driver_support_install_isr(_new, _old ) \
+ do { \
+ _old = (rtems_isr_entry) set_vector( _new, CLOCK_VECTOR, 1 ); \
+ } while (0)
+
+void Clock_driver_support_initialize_hardware(void)
+{
+ clockwrite(MM_TIMER0_COMPARE, (CPU_FREQUENCY / (1000000 / rtems_configuration_get_microseconds_per_tick())));
+
+ clockwrite(MM_TIMER0_COUNTER, 0);
+ clockwrite(MM_TIMER0_CONTROL, TIMER_ENABLE | TIMER_AUTORESTART);
+ lm32_interrupt_unmask(CLOCK_IRQMASK);
+}
+
+void Clock_driver_support_shutdown_hardware(void)
+{
+ lm32_interrupt_mask(CLOCK_IRQMASK);
+ clockwrite(MM_TIMER0_CONTROL, 0);
+}
+
+#include "../../../shared/clockdrv_shell.h"
+
diff -u /dev/null rtems/c/src/lib/libbsp/lm32/shared/milkymist_clock/clock.h:1.1
--- /dev/null Fri Aug 20 17:10:17 2010
+++ rtems/c/src/lib/libbsp/lm32/shared/milkymist_clock/clock.h Fri Aug 20 16:23:27 2010
@@ -0,0 +1,18 @@
+/*
+ * This file contains definitions for LatticeMico32 Timer (Clock)
+ *
+ * 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$
+ *
+ * COPYRIGHT (c) Yann Sionneau <yann.sionneau at telecom-sudparis.eu> (GSoC 2010)
+ * Telecom SudParis
+ */
+
+#ifndef _BSPCLOCK_H
+#define _BSPCLOCK_H
+
+
+#endif /* _BSPCLOCK_H */
diff -u /dev/null rtems/c/src/lib/libbsp/lm32/shared/milkymist_console/console.c:1.1
--- /dev/null Fri Aug 20 17:10:17 2010
+++ rtems/c/src/lib/libbsp/lm32/shared/milkymist_console/console.c Fri Aug 20 16:23:27 2010
@@ -0,0 +1,226 @@
+/*
+ * Console driver for Lattice Mico32 (lm32).
+ *
+ * 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$
+ *
+ * Jukka Pietarinen <jukka.pietarinen at mrf.fi>, 2008,
+ * Micro-Research Finland Oy
+ *
+ * COPYRIGHT (c) Yann Sionneau <yann.sionneau at telecom-sudparis.eu>, GSoc 2010
+ * Telecom SudParis
+ */
+
+#define NO_BSP_INIT
+
+#include <rtems.h>
+#include <bsp.h>
+#include <rtems/libio.h>
+
+void BSP_uart_polled_write(char ch);
+int BSP_uart_polled_read( void );
+char BSP_uart_is_character_ready(char *ch);
+
+/* console_initialize
+ *
+ * This routine initializes the console IO driver.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * Return values:
+ */
+
+rtems_device_driver console_initialize(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *arg
+)
+{
+ rtems_status_code status;
+
+ printk("console_initialize\n");
+
+ status = rtems_io_register_name(
+ "/dev/console",
+ major,
+ (rtems_device_minor_number) 0
+ );
+
+ if (status != RTEMS_SUCCESSFUL)
+ rtems_fatal_error_occurred(status);
+
+ return RTEMS_SUCCESSFUL;
+}
+
+/* is_character_ready
+ *
+ * This routine returns TRUE if a character is available.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * Return values:
+ */
+
+bool is_character_ready(
+ char *ch
+)
+{
+ return BSP_uart_is_character_ready(ch);
+}
+
+/* inbyte
+ *
+ * This routine reads a character from the SOURCE.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * Return values:
+ * character read from SOURCE
+ */
+
+int inbyte( void )
+{
+ /*
+ * If polling, wait until a character is available.
+ */
+
+ return BSP_uart_polled_read();
+}
+
+/* outbyte
+ *
+ * This routine transmits a character out the SOURCE. It may support
+ * XON/XOFF flow control.
+ *
+ * Input parameters:
+ * ch - character to be transmitted
+ *
+ * Output parameters: NONE
+ */
+
+void outbyte(
+ char ch
+)
+{
+ /*
+ * If polling, wait for the transmitter to be ready.
+ * Check for flow control requests and process.
+ * Then output the character.
+ */
+
+ BSP_uart_polled_write(ch);
+}
+
+/*
+ * Open entry point
+ */
+
+rtems_device_driver console_open(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
+)
+{
+ return RTEMS_SUCCESSFUL;
+}
+
+/*
+ * Close entry point
+ */
+
+rtems_device_driver console_close(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
+)
+{
+ return RTEMS_SUCCESSFUL;
+}
+
+/*
+ * read bytes from the serial port. We only have stdin.
+ */
+
+rtems_device_driver console_read(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
+)
+{
+ rtems_libio_rw_args_t *rw_args;
+ char *buffer;
+ int maximum;
+ int count = 0;
+
+ rw_args = (rtems_libio_rw_args_t *) arg;
+
+ buffer = rw_args->buffer;
+ maximum = rw_args->count;
+
+ for (count = 0; count < maximum; count++) {
+ buffer[ count ] = inbyte();
+ if (buffer[ count ] == '\n' || buffer[ count ] == '\r') {
+ buffer[ count++ ] = '\n';
+ break;
+ }
+ }
+
+ rw_args->bytes_moved = count;
+ return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED;
+}
+
+/*
+ * write bytes to the serial port. Stdout and stderr are the same.
+ */
+
+rtems_device_driver console_write(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
+)
+{
+ int count;
+ int maximum;
+ rtems_libio_rw_args_t *rw_args;
+ char *buffer;
+
+ rw_args = (rtems_libio_rw_args_t *) arg;
+
+ buffer = rw_args->buffer;
+ maximum = rw_args->count;
+
+ for (count = 0; count < maximum; count++) {
+ if ( buffer[ count ] == '\n') {
+ outbyte('\r');
+ }
+ outbyte( buffer[ count ] );
+ }
+
+ rw_args->bytes_moved = maximum;
+ return 0;
+}
+
+/*
+ * IO Control entry point
+ */
+
+rtems_device_driver console_control(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
+)
+{
+ return RTEMS_SUCCESSFUL;
+}
+
+BSP_output_char_function_type BSP_output_char = BSP_uart_polled_write;
+BSP_polling_getchar_function_type BSP_poll_char = BSP_uart_polled_read;
diff -u /dev/null rtems/c/src/lib/libbsp/lm32/shared/milkymist_console/uart.h:1.1
--- /dev/null Fri Aug 20 17:10:17 2010
+++ rtems/c/src/lib/libbsp/lm32/shared/milkymist_console/uart.h Fri Aug 20 16:23:27 2010
@@ -0,0 +1,26 @@
+/*
+ * This file contains definitions for LatticeMico32 UART
+ *
+ * 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$
+ *
+ * COPYRIGHT (c) Yann Sionneau <yann.sionneau at telecom-sudparis.eu> (GSoC 2010)
+ * Telecom SudParis
+ */
+
+#ifndef _BSPUART_H
+#define _BSPUART_H
+
+void BSP_uart_init(int baud);
+
+#define MM_UART_RXTX (0xe0000000)
+
+#define MM_UART_DIV (0xe0000004)
+
+#define MM_IRQ_UARTTX (0x00000010) /* 4 */
+#define MM_IRQ_UARTRX (0x00000008) /* 3 */
+
+#endif /* _BSPUART_H */
diff -u /dev/null rtems/c/src/lib/libbsp/lm32/shared/milkymist_console/uart.c:1.1
--- /dev/null Fri Aug 20 17:10:17 2010
+++ rtems/c/src/lib/libbsp/lm32/shared/milkymist_console/uart.c Fri Aug 20 16:23:27 2010
@@ -0,0 +1,69 @@
+/*
+ * Uart driver for Lattice Mico32 (lm32) UART
+ *
+ * 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$
+ *
+ * COPYRIGHT (c) Yann Sionneau <yann.sionneau at telecom-sudparis.eu> (GSoC 2010)
+ * Telecom SudParis
+ */
+
+#include "../include/system_conf.h"
+#include "uart.h"
+#include <rtems/libio.h>
+
+static inline int uartread(unsigned int reg)
+{
+ return *((int*)(reg));
+}
+
+static inline void uartwrite(unsigned int reg, int value)
+{
+ *((int*)(reg)) = value;
+}
+
+void BSP_uart_init(int baud)
+{
+
+ /* Set baud rate */
+ uartwrite(MM_UART_DIV, CPU_FREQUENCY/baud/16);
+}
+
+void BSP_uart_polled_write(char ch)
+{
+ int ip;
+ /* Wait until THR is empty. */
+ uartwrite(MM_UART_RXTX, ch);
+ do {
+ lm32_read_interrupts(ip);
+ } while (! (ip & MM_IRQ_UARTTX) );
+ lm32_interrupt_ack(MM_IRQ_UARTTX);
+}
+
+char BSP_uart_polled_read( void )
+{
+ int ip;
+ /* Wait until there is a byte in RBR */
+ do {
+ lm32_read_interrupts(ip);
+ } while(! (ip & MM_IRQ_UARTRX) );
+ lm32_interrupt_ack(MM_IRQ_UARTRX);
+ return (char) uartread(MM_UART_RXTX);
+}
+
+char BSP_uart_is_character_ready(char *ch)
+{
+ int ip;
+ lm32_read_interrupts(ip);
+ if (ip & MM_IRQ_UARTRX)
+ {
+ *ch = (char) uartread(MM_UART_RXTX);
+ lm32_interrupt_ack(MM_IRQ_UARTRX);
+ return true;
+ }
+ *ch = '0';
+ return false;
+}
diff -u /dev/null rtems/c/src/lib/libbsp/lm32/shared/milkymist_framebuffer/framebuffer.c:1.1
--- /dev/null Fri Aug 20 17:10:17 2010
+++ rtems/c/src/lib/libbsp/lm32/shared/milkymist_framebuffer/framebuffer.c Fri Aug 20 16:23:27 2010
@@ -0,0 +1,244 @@
+/* framebuffer.c
+ *
+ * This file is the framebuffer driver for the Milkymist VGA IP-core
+ * This VGA Core is a part of Milkymist System-on-Chip
+ *
+ * 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$
+ *
+ * COPYRIGHT (c) Yann Sionneau <yann.sionneau at telecom-sudparis.eu> (GSoC 2010)
+ * Telecom SudParis
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <pthread.h>
+#include <rtems.h>
+#include <bsp.h>
+#include "../include/system_conf.h"
+#include <rtems/libio.h>
+#include <rtems/fb.h>
+
+#define FRAMEBUFFER_DEVICE_NAME "/dev/fb"
+
+pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+
+static unsigned short int framebufferA[640*480] __attribute__((aligned(32)));
+static unsigned short int framebufferB[640*480] __attribute__((aligned(32)));
+static unsigned short int framebufferC[640*480] __attribute__((aligned(32)));
+
+static unsigned short int *frontbuffer = framebufferA;
+static unsigned short int *backbuffer = framebufferB;
+static unsigned short int *lastbuffer = framebufferC;
+
+static inline void fb_write(unsigned int reg, int value)
+{
+ *((int*)reg) = value;
+}
+
+static inline int fb_read(unsigned int reg)
+{
+ return *((int*)(reg));
+}
+
+/* screen information for the VGA driver */
+static struct fb_var_screeninfo fb_var =
+{
+ .xres = 640,
+ .yres = 480,
+ .bits_per_pixel = 16
+};
+
+static struct fb_fix_screeninfo fb_fix =
+{
+// this is initialized at start-up
+ .smem_len = 640 * 480 * 2, /* buffer size */
+// 2 bytes per pixels
+ .type = FB_TYPE_VGA_PLANES, /* type of display */
+ .visual = FB_VISUAL_TRUECOLOR, /* color scheme used */
+ .line_length = 80 /* chars per line */
+};
+
+
+static int get_fix_screen_info( struct fb_fix_screeninfo *info )
+{
+ *info = fb_fix;
+ return 0;
+}
+
+static int get_var_screen_info( struct fb_var_screeninfo *info )
+{
+ *info = fb_var;
+ return 0;
+}
+
+
+rtems_device_driver frame_buffer_initialize(
+rtems_device_major_number major,
+rtems_device_minor_number minor,
+void *arg)
+{
+ rtems_status_code status;
+
+ printk( "frame buffer driver initializing..\n" );
+
+ fb_fix.smem_start = (volatile char *)frontbuffer;
+
+ fb_write(MM_VGA_BASEADDRESS, (unsigned int)frontbuffer);
+ fb_write(MM_VGA_RESET, (unsigned int)0);
+
+ /*
+ * Register the device
+ */
+ status = rtems_io_register_name(FRAMEBUFFER_DEVICE_NAME, major, 0);
+ if (status != RTEMS_SUCCESSFUL)
+ {
+ printk("Error registering frame buffer device!\n");
+ rtems_fatal_error_occurred( status );
+ }
+
+ printk("VGA: initialized at resolution %dx%d\n", fb_var.xres, fb_var.yres);
+ printk("VGA: framebuffers at 0x%08x 0x%08x 0x%08x\n",
+ (unsigned int)frontbuffer, (unsigned int)backbuffer,
+ (unsigned int)lastbuffer);
+
+ /*
+ * graphics hardware initialization goes here for non-console
+ * devices
+ */
+ return RTEMS_SUCCESSFUL;
+}
+
+rtems_device_driver frame_buffer_close(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *arg
+)
+{
+ if (pthread_mutex_unlock(&mutex) == 0){
+ /* restore previous state. for VGA this means return to text mode.
+ * leave out if graphics hardware has been initialized in
+ * frame_buffer_initialize() */
+ fb_write(MM_VGA_RESET, MM_VGA_RESET_MODE);
+ return RTEMS_SUCCESSFUL;
+ }
+ return RTEMS_UNSATISFIED;
+}
+
+rtems_device_driver frame_buffer_open(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *arg
+)
+{
+ if (pthread_mutex_trylock(&mutex) == 0){
+ fb_write(MM_VGA_RESET, (unsigned int)0);
+ return RTEMS_SUCCESSFUL;
+ }
+ return RTEMS_UNSATISFIED;
+}
+
+static void vga_swap_buffers(void)
+{
+ unsigned short int *p;
+
+ /*
+ * Make sure last buffer swap has been executed.
+ * Beware, DMA address registers of vgafb are incomplete
+ * (only LSBs are present) so don't compare them directly
+ * with CPU pointers.
+ */
+ while( fb_read(MM_VGA_BASEADDRESS_ACT) != fb_read(MM_VGA_BASEADDRESS) );
+
+ p = frontbuffer;
+ frontbuffer = backbuffer;
+ backbuffer = lastbuffer;
+ lastbuffer = p;
+
+ fb_fix.smem_start = (volatile char *)backbuffer;
+
+ fb_write(MM_VGA_BASEADDRESS, (unsigned int)frontbuffer);
+}
+
+rtems_device_driver frame_buffer_read(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *arg
+)
+{
+ rtems_libio_rw_args_t *rw_args = (rtems_libio_rw_args_t *)arg;
+ rw_args->bytes_moved = ((rw_args->offset + rw_args->count) > fb_fix.smem_len ) ? (fb_fix.smem_len - rw_args->offset) : rw_args->count;
+ memcpy(rw_args->buffer, (const void *) (fb_fix.smem_start + rw_args->offset), rw_args->bytes_moved);
+ return RTEMS_SUCCESSFUL;
+}
+
+rtems_device_driver frame_buffer_write(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *arg
+)
+{
+ rtems_libio_rw_args_t *rw_args = (rtems_libio_rw_args_t *)arg;
+ rw_args->bytes_moved = ((rw_args->offset + rw_args->count) > fb_fix.smem_len ) ? (fb_fix.smem_len - rw_args->offset) : rw_args->count;
+ memcpy( (void *) (fb_fix.smem_start + rw_args->offset), rw_args->buffer, rw_args->bytes_moved);
+ return RTEMS_SUCCESSFUL;
+}
+
+rtems_device_driver frame_buffer_control(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *arg
+)
+{
+ rtems_libio_ioctl_args_t *args = arg;
+
+ switch( args->command ) {
+ case FBIOGET_FSCREENINFO:
+ args->ioctl_return = get_fix_screen_info( ( struct fb_fix_screeninfo * ) args->buffer );
+ break;
+ case FBIOGET_VSCREENINFO:
+ args->ioctl_return = get_var_screen_info( ( struct fb_var_screeninfo * ) args->buffer );
+ break;
+ case FBIOPUT_VSCREENINFO:
+ /* not implemented yet */
+ args->ioctl_return = -1;
+ return RTEMS_UNSATISFIED;
+ case FBIOGETCMAP:
+ /* not implemented yet */
+ args->ioctl_return = -1;
+ return RTEMS_UNSATISFIED;
+ break;
+ case FBIOPUTCMAP:
+ /* not implemented yet */
+ args->ioctl_return = -1;
+ return RTEMS_UNSATISFIED;
+ break;
+ case FBIOSWAPBUFFERS:
+ vga_swap_buffers();
+ args->ioctl_return = 0;
+ break;
+ case FBIOSETBUFFERMODE:
+ args->ioctl_return = 0;
+ switch ( (unsigned int)args->buffer ) {
+ case FB_SINGLE_BUFFERED:
+ fb_fix.smem_start = (volatile char *)frontbuffer;
+ break;
+ case FB_TRIPLE_BUFFERED:
+ fb_fix.smem_start = (volatile char *)backbuffer;
+ break;
+ default:
+ printk("[framebuffer] : error no such buffer mode\n");
+ }
+ break;
+ default:
+ args->ioctl_return = 0;
+ break;
+ }
+ return RTEMS_SUCCESSFUL;
+}
+
diff -u /dev/null rtems/c/src/lib/libbsp/lm32/shared/milkymist_gpio/gpio.c:1.1
--- /dev/null Fri Aug 20 17:10:17 2010
+++ rtems/c/src/lib/libbsp/lm32/shared/milkymist_gpio/gpio.c Fri Aug 20 16:23:27 2010
@@ -0,0 +1,191 @@
+/* gpio.c
+ *
+ * This file is the gpio driver for the Milkymist One board
+ *
+ * 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$
+ *
+ * COPYRIGHT (c) Yann Sionneau <yann.sionneau at telecom-sudparis.eu> (GSoC 2010)
+ * Telecom SudParis
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <pthread.h>
+#include <rtems.h>
+#include <bsp.h>
+#include "../include/system_conf.h"
+#include <rtems/libio.h>
+
+#define GPIO_DRIVER_TABLE_ENTRY { gpio_initialize, \
+gpio_open, gpio_close, gpio_read, gpio_write, gpio_control}
+
+#define LED1_DEVICE_NAME "/dev/led1"
+#define LED2_DEVICE_NAME "/dev/led2"
+#define BTN1_DEVICE_NAME "/dev/btn1"
+#define BTN2_DEVICE_NAME "/dev/btn2"
+#define BTN3_DEVICE_NAME "/dev/btn3"
+
+static struct milkymist_gpio {
+ rtems_device_minor_number minor;
+ unsigned int *address;
+ unsigned int offset;
+ uint8_t readonly;
+ pthread_mutex_t mutex;
+} gpio[5];
+
+rtems_device_driver gpio_initialize(
+rtems_device_major_number major,
+rtems_device_minor_number minor,
+void *arg)
+{
+ rtems_status_code status;
+
+ printk( "gpio driver initializing..\n" );
+
+ status = rtems_io_register_name(LED1_DEVICE_NAME, major, 0);
+ if (status != RTEMS_SUCCESSFUL)
+ {
+ printk("Error registering gpio device led1\n");
+ rtems_fatal_error_occurred( status );
+ }
+ gpio[0].minor = 0;
+ gpio[0].readonly = 0;
+ gpio[0].offset = 0x00000001;
+ gpio[0].address = (unsigned int *)0xe0001004;
+ gpio[0].mutex = PTHREAD_MUTEX_INITIALIZER;
+
+ status = rtems_io_register_name(LED2_DEVICE_NAME, major, 1);
+ if (status != RTEMS_SUCCESSFUL)
+ {
+ printk("Error registering gpio device led2\n");
+ rtems_fatal_error_occurred( status );
+ }
+ gpio[1].minor = 1;
+ gpio[1].readonly = 0;
+ gpio[1].offset = 0x00000002;
+ gpio[1].address = (unsigned int *)0xe0001004;
+ gpio[1].mutex = PTHREAD_MUTEX_INITIALIZER;
+
+ status = rtems_io_register_name(BTN1_DEVICE_NAME, major, 2);
+ if (status != RTEMS_SUCCESSFUL)
+ {
+ printk("Error registering gpio device btn1\n");
+ rtems_fatal_error_occurred( status );
+ }
+ gpio[2].minor = 2;
+ gpio[2].readonly = 1;
+ gpio[2].offset = 0x00000001;
+ gpio[2].address = (unsigned int *)0xe0001000;
+ gpio[2].mutex = PTHREAD_MUTEX_INITIALIZER;
+ status = rtems_io_register_name(BTN2_DEVICE_NAME, major, 3);
+ if (status != RTEMS_SUCCESSFUL)
+ {
+ printk("Error registering gpio device btn2\n");
+ rtems_fatal_error_occurred( status );
+ }
+ gpio[3].minor = 3;
+ gpio[3].readonly = 1;
+ gpio[3].address = (unsigned int *)0xe0001000;
+ gpio[3].offset = 0x00000002;
+ gpio[3].mutex = PTHREAD_MUTEX_INITIALIZER;
+
+ status = rtems_io_register_name(BTN3_DEVICE_NAME, major, 4);
+ if (status != RTEMS_SUCCESSFUL)
+ {
+ printk("Error registering gpio device btn3\n");
+ rtems_fatal_error_occurred( status );
+ }
+
+ gpio[4].minor = 4;
+ gpio[4].readonly = 1;
+ gpio[4].offset = 0x00000004;
+ gpio[4].address = (unsigned int *)0xe0001000;
+ gpio[4].mutex = PTHREAD_MUTEX_INITIALIZER;
+
+ return RTEMS_SUCCESSFUL;
+}
+
+rtems_device_driver gpio_close(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *arg
+)
+{
+ if (pthread_mutex_unlock(&gpio[minor].mutex) == 0){
+ return RTEMS_SUCCESSFUL;
+ }
+ return RTEMS_UNSATISFIED;
+}
+
+rtems_device_driver gpio_open(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *arg
+)
+{
+ if (pthread_mutex_trylock(&gpio[minor].mutex) == 0){
+ return RTEMS_SUCCESSFUL;
+ }
+ return RTEMS_UNSATISFIED;
+}
+
+
+rtems_device_driver gpio_read(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *arg
+)
+{
+ rtems_libio_rw_args_t *rw_args = (rtems_libio_rw_args_t *)arg;
+ rw_args->bytes_moved = 1;
+
+ if ( *gpio[minor].address & gpio[minor].offset )
+ *(uint8_t *)rw_args->buffer = 1;
+ else
+ *(uint8_t *)rw_args->buffer = 0;
+
+ return RTEMS_SUCCESSFUL;
+}
+
+rtems_device_driver gpio_write(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *arg
+)
+{
+ rtems_libio_rw_args_t *rw_args = (rtems_libio_rw_args_t *)arg;
+ rw_args->bytes_moved = 1;
+
+ if (gpio[minor].readonly)
+ return RTEMS_UNSATISFIED;
+
+ if ( *(uint8_t *)rw_args->buffer )
+ *gpio[minor].address |= gpio[minor].offset;
+ else
+ *gpio[minor].address &= ~gpio[minor].offset;
+
+ return RTEMS_SUCCESSFUL;
+}
+
+rtems_device_driver gpio_control(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *arg
+)
+{
+ rtems_libio_ioctl_args_t *args = arg;
+
+ switch( args->command ) {
+ default:
+ args->ioctl_return = 0;
+ break;
+ }
+ return RTEMS_SUCCESSFUL;
+}
+
diff -u /dev/null rtems/c/src/lib/libbsp/lm32/shared/milkymist_networking/mm_crc32.c:1.1
--- /dev/null Fri Aug 20 17:10:17 2010
+++ rtems/c/src/lib/libbsp/lm32/shared/milkymist_networking/mm_crc32.c Fri Aug 20 16:23:27 2010
@@ -0,0 +1,82 @@
+/* crc32.c -- compute the CRC-32 of a data stream
+ * COPYRIGHT (C) 1995-1998 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ *
+ * $Id$
+ *
+ */
+
+const unsigned int crc_table[256] = {
+ 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
+ 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
+ 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
+ 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
+ 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
+ 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
+ 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
+ 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
+ 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
+ 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
+ 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
+ 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
+ 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
+ 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
+ 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
+ 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
+ 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
+ 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
+ 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
+ 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
+ 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
+ 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
+ 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
+ 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
+ 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
+ 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
+ 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
+ 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
+ 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
+ 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
+ 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
+ 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
+ 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
+ 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
+ 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
+ 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
+ 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
+ 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
+ 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
+ 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
+ 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
+ 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
+ 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
+ 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
+ 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
+ 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
+ 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
+ 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
+ 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
+ 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
+ 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
+ 0x2d02ef8dL
+};
+
+#define DO1(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8);
+#define DO2(buf) DO1(buf); DO1(buf);
+#define DO4(buf) DO2(buf); DO2(buf);
+#define DO8(buf) DO4(buf); DO4(buf);
+
+unsigned int mm_ether_crc32(const unsigned char *buffer, unsigned int len)
+{
+ unsigned int crc;
+ crc = 0;
+ crc = crc ^ 0xffffffffL;
+ while(len >= 8) {
+ DO8(buffer);
+ len -= 8;
+ }
+ if(len) do {
+ DO1(buffer);
+ } while(--len);
+ return crc ^ 0xffffffffL;
+}
diff -u /dev/null rtems/c/src/lib/libbsp/lm32/shared/milkymist_networking/network.h:1.1
--- /dev/null Fri Aug 20 17:10:17 2010
+++ rtems/c/src/lib/libbsp/lm32/shared/milkymist_networking/network.h Fri Aug 20 16:23:27 2010
@@ -0,0 +1,80 @@
+/* network.h
+ *
+ * RTEMS driver for Minimac ethernet IP-core of Milkymist SoC
+ *
+ * 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$
+ *
+ * COPYRIGHT (c) Yann Sionneau <yann.sionneau at telecom-sudparis.eu> (GSoC 2010)
+ * Telecom SudParis, France
+ */
+
+
+#ifndef _MM_NETWORKING_H_
+#define _MM_NETWORKING_H_
+
+#include "../include/system_conf.h"
+
+#define IRQ_ETHRX 11
+#define IRQ_ETHTX 12
+
+#define INTERRUPT_EVENT RTEMS_EVENT_1
+#define START_TRANSMIT_EVENT RTEMS_EVENT_2
+
+#define MINIMAC_STATE_EMPTY (0x0)
+#define MINIMAC_STATE_LOADED (0x1)
+#define MINIMAC_STATE_PENDING (0x2)
+
+#define MINIMAC_SETUP_RXRST (0x1)
+#define MINIMAC_SETUP_TXRST (0x2)
+
+#define NB_RX_SLOTS 4
+
+#define MM_ETHTX_IRQMASK (1 << IRQ_ETHTX)
+#define MM_ETHRX_IRQMASK (1 << IRQ_ETHRX)
+#define ETHERNET_FRAME_LENGTH 1532
+
+struct mm_packet {
+ unsigned char preamble[8];
+ char raw_data[MLEN];
+} __attribute__((aligned(4), packed));
+
+struct minimac_softc {
+
+ struct arpcom arpcom;
+ uint8_t registered;
+
+ /*
+ * Statistics
+ */
+
+ rtems_id rxDaemonTid;
+ rtems_id txDaemonTid;
+
+ unsigned long int rxInterrupts;
+ unsigned long int txInterrupts;
+ unsigned long int rxedPackets;
+ unsigned long int txFifoFull;
+ unsigned long int txErrors;
+};
+
+int rtems_minimac_driver_attach (struct rtems_bsdnet_ifconfig *, int);
+
+static void minimac_start(struct ifnet *);
+static void minimac_init(void *);
+static int minimac_ioctl(struct ifnet *, ioctl_command_t, caddr_t);
+static void minimac_stop(struct minimac_softc *);
+
+static void minimac_txDaemon(void *);
+static void minimac_rxDaemon(void *);
+static void minimac_sendpacket(struct ifnet *, struct mbuf *);
+
+static rtems_isr minimac_rx_interrupt_handler (rtems_vector_number);
+static rtems_isr minimac_tx_interrupt_handler (rtems_vector_number);
+
+static void minimac_stats(struct minimac_softc *);
+
+#endif
diff -u /dev/null rtems/c/src/lib/libbsp/lm32/shared/milkymist_networking/network.c:1.1
--- /dev/null Fri Aug 20 17:10:17 2010
+++ rtems/c/src/lib/libbsp/lm32/shared/milkymist_networking/network.c Fri Aug 20 16:23:27 2010
@@ -0,0 +1,401 @@
+/*
+ * RTEMS driver for Minimac ethernet IP-core of Milkymist SoC
+ *
+ * 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$
+ *
+ * COPYRIGHT (c) Yann Sionneau <yann.sionneau at telecom-sudparis.eu> (GSoC 2010)
+ * Telecom SudParis, France
+ */
+
+
+#include <bsp.h>
+#include "../include/system_conf.h"
+#include "bspopts.h"
+#include <stdio.h>
+#include <rtems/rtems_bsdnet.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 <rtems.h>
+#include "network.h"
+
+unsigned int mm_ether_crc32(const unsigned char *buffer, unsigned int len);
+static char rxbuff0[ETHERNET_FRAME_LENGTH] __attribute__((aligned (4)));
+static char rxbuff1[ETHERNET_FRAME_LENGTH] __attribute__((aligned (4)));
+static char rxbuff2[ETHERNET_FRAME_LENGTH] __attribute__((aligned (4)));
+static char rxbuff3[ETHERNET_FRAME_LENGTH] __attribute__((aligned (4)));
+
+static char *rxbuffs[4] = {rxbuff0, rxbuff1, rxbuff2, rxbuff3};
+
+static struct minimac_softc minimac_softc;
+
+static uint32_t rx_slot_state[4] = {MM_MINIMAC_STATE0, MM_MINIMAC_STATE1,
+ MM_MINIMAC_STATE2, MM_MINIMAC_STATE3};
+
+static uint32_t rx_slot_addr[4] = {MM_MINIMAC_ADDR0, MM_MINIMAC_ADDR1,
+ MM_MINIMAC_ADDR2, MM_MINIMAC_ADDR3};
+
+static uint32_t rx_slot_count[4] = {MM_MINIMAC_COUNT0, MM_MINIMAC_COUNT1,
+ MM_MINIMAC_COUNT2, MM_MINIMAC_COUNT3};
+#ifdef CPU_U32_FIX
+
+/*
+ * Routine to align the received packet so that the ip header
+ * is on a 32-bit boundary. Necessary for cpu's that do not
+ * allow unaligned loads and stores and when the 32-bit DMA
+ * mode is used.
+ *
+ * Transfers are done on word basis to avoid possibly slow byte
+ * and half-word writes.
+ *
+ * Copied over from sonic.c driver
+ */
+
+void ipalign(struct mbuf *m)
+{
+ unsigned int *first, *last, data;
+ unsigned int tmp = 0;
+
+ if ((((int) m->m_data) & 2) && (m->m_len)) {
+ last = (unsigned int *) ((((int) m->m_data) + m->m_len + 8) & ~3);
+ first = (unsigned int *) (((int) m->m_data) & ~3);
+ tmp = *first << 16;
+ first++;
+ do {
+ data = *first;
+ *first = tmp | (data >> 16);
+ tmp = data << 16;
+ first++;
+ } while (first <= last);
+
+ m->m_data = (caddr_t)(((int) m->m_data) + 2);
+ }
+}
+#endif
+
+static inline int minimac_read(unsigned int reg)
+{
+ return *((int*)(reg));
+}
+
+static inline void minimac_write(unsigned int reg, int value)
+{
+ *((int*)reg) = value;
+}
+
+int rtems_minimac_driver_attach (struct rtems_bsdnet_ifconfig *config,
+ int attaching)
+{
+ struct minimac_softc *sc;
+ struct ifnet *ifp;
+
+
+ if (!attaching) {
+ printk ("MINIMAC driver cannot be detached.\n");
+ return 0;
+ }
+
+ sc = &minimac_softc;
+ ifp = &(sc->arpcom.ac_if);
+
+ if (sc->registered) {
+ printk ("Driver already in use.\n");
+ return 0;
+ }
+
+ sc->registered = 1;
+
+ /*
+ * Mac address of Milkymist One board is 1 by default
+ */
+
+ sc->arpcom.ac_enaddr[0] = 0x00;
+ sc->arpcom.ac_enaddr[1] = 0x23;
+ sc->arpcom.ac_enaddr[2] = 0x8b;
+ sc->arpcom.ac_enaddr[3] = 0x47;
+ sc->arpcom.ac_enaddr[4] = 0x86;
+ sc->arpcom.ac_enaddr[5] = 0x20;
+ ifp->if_softc = sc;
+ ifp->if_mtu = ETHERMTU;
+ ifp->if_unit = 0;
+ ifp->if_name = "minimac";
+ ifp->if_init = minimac_init;
+ ifp->if_ioctl = minimac_ioctl;
+ ifp->if_start = minimac_start;
+ ifp->if_output = ether_output;
+ ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX;
+ ifp->if_snd.ifq_maxlen = ifqmaxlen;
+
+ if_attach (ifp);
+ ether_ifattach(ifp);
+ printk("[minimac] Ethernet driver attached\n");
+ return 1;
+}
+
+static void minimac_start(struct ifnet *ifp)
+{
+ struct minimac_softc *sc = ifp->if_softc;
+ rtems_event_send (sc->txDaemonTid, START_TRANSMIT_EVENT);
+ ifp->if_flags |= IFF_OACTIVE;
+// printk("[minimac] start();\n");
+}
+
+/*
+ * Initialize and start the device
+ */
+static void minimac_init (void *arg)
+{
+ struct minimac_softc *sc = arg;
+ struct ifnet *ifp = &sc->arpcom.ac_if;
+ unsigned char j;
+ if (sc->txDaemonTid == 0) {
+ sc->txDaemonTid = rtems_bsdnet_newproc ("MINIMACtx", 4096, minimac_txDaemon, sc);
+ sc->rxDaemonTid = rtems_bsdnet_newproc ("MINIMACrx", 4096, minimac_rxDaemon, sc);
+ set_vector(minimac_rx_interrupt_handler, IRQ_ETHRX, 1);
+ set_vector(minimac_tx_interrupt_handler, IRQ_ETHTX, 1);
+ lm32_interrupt_unmask(MM_ETHRX_IRQMASK);
+ lm32_interrupt_unmask(MM_ETHTX_IRQMASK);
+ }
+
+ /*
+ * Tell the world that we're running.
+ */
+ ifp->if_flags |= IFF_RUNNING;
+
+ /*
+ * Start the receiver and transmitter
+ */
+
+ lm32_interrupt_ack( MM_ETHTX_IRQMASK | MM_ETHRX_IRQMASK );
+ minimac_write(MM_MINIMAC_TXREMAINING, 0);
+
+ for (j = 0 ; j < NB_RX_SLOTS ; j++) {
+ minimac_write(rx_slot_addr[j], (unsigned int)rxbuffs[j]);
+ minimac_write(rx_slot_state[j], MINIMAC_STATE_LOADED);
+ }
+
+
+ minimac_write(MM_MINIMAC_SETUP, 0);
+ rtems_event_send(sc->rxDaemonTid, INTERRUPT_EVENT);
+}
+
+static void minimac_stop (struct minimac_softc *sc)
+{
+ struct ifnet *ifp = &sc->arpcom.ac_if;
+ unsigned char j;
+ ifp->if_flags &= ~IFF_RUNNING;
+
+ /*
+ * Shuts down receiver and transmitter
+ */
+ for (j = 0 ; j < NB_RX_SLOTS ; j++)
+ minimac_write(rx_slot_state[j], MINIMAC_STATE_EMPTY);
+ minimac_write(MM_MINIMAC_TXREMAINING, 0);
+ minimac_write(MM_MINIMAC_SETUP, MINIMAC_SETUP_RXRST | MINIMAC_SETUP_TXRST);
+}
+
+static int minimac_ioctl(struct ifnet *ifp, ioctl_command_t command, caddr_t data)
+{
+
+ struct minimac_softc *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:
+ minimac_stop (sc);
+ break;
+
+ case IFF_UP:
+ minimac_init (sc);
+ break;
+
+ case IFF_UP | IFF_RUNNING:
+ minimac_stop (sc);
+ minimac_init (sc);
+ break;
+
+ default:
+ break;
+ }
+ break;
+
+ case SIO_RTEMS_SHOW_STATS:
+ minimac_stats (sc);
+ break;
+
+ /*
+ * FIXME: All sorts of multicast commands need to be added here!
+ */
+ default:
+ error = EINVAL;
+ break;
+ }
+ return error;
+
+
+}
+
+rtems_isr minimac_rx_interrupt_handler(rtems_vector_number vector)
+{
+ unsigned int ip;
+ struct minimac_softc *sc = &minimac_softc;
+ lm32_read_interrupts(ip);
+ if (ip & MM_ETHRX_IRQMASK) {
+ lm32_interrupt_mask(MM_ETHRX_IRQMASK);
+ rtems_event_send(sc->rxDaemonTid, INTERRUPT_EVENT);
+ sc->rxInterrupts++; // update stats
+ }
+}
+
+rtems_isr minimac_tx_interrupt_handler(rtems_vector_number vector)
+{
+ int ip;
+ struct minimac_softc *sc = &minimac_softc;
+ lm32_read_interrupts(ip);
+ if (ip & MM_ETHTX_IRQMASK) {
+ lm32_interrupt_ack(MM_ETHTX_IRQMASK);
+ rtems_event_send(sc->txDaemonTid, INTERRUPT_EVENT);
+ sc->txInterrupts++; // update stats
+ }
+}
+
+
+static void minimac_rxDaemon(void *arg)
+{
+ struct ifnet *ifp = &minimac_softc.arpcom.ac_if;
+ rtems_event_set events;
+ struct minimac_softc *sc = &minimac_softc;
+ for (;;) {
+ uint32_t *buf;
+ int rxlen;
+ uint8_t j;
+ struct mbuf *m;
+ struct ether_header *eh;
+ rtems_bsdnet_event_receive( RTEMS_ALL_EVENTS,
+ RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &events);
+ if(minimac_read(MM_MINIMAC_SETUP) & MINIMAC_SETUP_RXRST ) {
+ printk("Minimac RX FIFO overflow!\n");
+ minimac_write(MM_MINIMAC_SETUP, 0);
+ lm32_interrupt_ack(MM_ETHRX_IRQMASK);
+ lm32_interrupt_unmask(MM_ETHRX_IRQMASK);
+ sc->txFifoFull++; // update stats
+ }
+
+ for (j = 0 ; j < NB_RX_SLOTS ; j++) {
+ if (minimac_read(rx_slot_state[j]) == MINIMAC_STATE_PENDING) {
+ asm volatile( /* Invalidate Level-1 data cache */
+ "wcsr DCC, r0\n"
+ "nop\n"
+ );
+ rxlen = minimac_read(rx_slot_count[j]);
+ rxlen -= 8; // we drop the preamble
+ MGETHDR(m, M_WAIT, MT_DATA);
+ MCLGET(m, M_WAIT);
+ m->m_pkthdr.rcvif = ifp;
+ buf = (uint32_t *) mtod(m, uint32_t*);
+ memcpy(buf, (uint8_t *)minimac_read(rx_slot_addr[j]) + 8, rxlen);
+ m->m_len = m->m_pkthdr.len = rxlen - sizeof(uint32_t) - sizeof(struct ether_header);
+
+ minimac_write(rx_slot_state[j], MINIMAC_STATE_EMPTY);
+ minimac_write(rx_slot_state[j], MINIMAC_STATE_LOADED);
+ eh = mtod(m, struct ether_header*);
+ m->m_data += sizeof(struct ether_header);
+#ifdef CPU_U32_FIX
+ ipalign(m);
+#endif
+ ether_input(ifp, eh, m);
+ }
+ }
+ lm32_interrupt_ack(MM_ETHRX_IRQMASK); // we ack once for all the rx interruptions
+ lm32_interrupt_unmask(MM_ETHRX_IRQMASK);
+ }
+}
+static void minimac_txDaemon(void *arg)
+{
+ struct ifnet *ifp = &minimac_softc.arpcom.ac_if;
+ rtems_event_set events;
+ struct mbuf *m;
+ int txq;
+
+ for (;;) {
+ rtems_bsdnet_event_receive (START_TRANSMIT_EVENT | INTERRUPT_EVENT, RTEMS_EVENT_ANY | RTEMS_WAIT, RTEMS_NO_TIMEOUT, &events);
+ for (;;) {
+ txq = 2048;
+
+ if (txq < ifp->if_mtu)
+ break;
+
+ IF_DEQUEUE(&ifp->if_snd, m);
+
+ if (!m)
+ break;
+ minimac_sendpacket(ifp, m);
+ m_freem(m);
+ }
+ ifp->if_flags &= ~IFF_OACTIVE;
+ }
+}
+
+static void minimac_stats(struct minimac_softc *sc)
+{
+
+}
+
+
+static void minimac_sendpacket(struct ifnet *ifp, struct mbuf *m)
+{
+ struct mbuf *nm = m;
+ struct minimac_softc *sc = &minimac_softc;
+ unsigned int len = 0;
+ struct mm_packet p;
+ unsigned int crc;
+ uint8_t i;
+ for (i = 0 ; i < 7 ; i++) // Preamble
+ p.preamble[i] = 0x55;
+ p.preamble[7] = 0xd5;
+
+ do
+ {
+ unsigned int mlen;
+ mlen = nm->m_len;
+ if (nm->m_len > 0) {
+ m_copydata(nm, 0, mlen, p.raw_data + len);
+ len += nm->m_len;
+ }
+
+ } while ( (nm = nm->m_next) != 0 );
+ for ( ; len < 60 ; len++)
+ p.raw_data[len] = 0x00; // Padding
+
+ crc = mm_ether_crc32((uint8_t *)p.raw_data, len); // CRC32
+
+ p.raw_data[len] = crc & 0xff;
+ p.raw_data[len+1] = (crc & 0xff00) >> 8;
+ p.raw_data[len+2] = (crc & 0xff0000) >> 16;
+ p.raw_data[len+3] = crc >> 24;
+
+ len += 4; // We add 4 bytes of CRC32
+
+ if (len + 8 < 64) {
+ printk("[minimac] Packet is too small !\n");
+ sc->txErrors++; // update stats
+ return;
+ }
+
+ minimac_write(MM_MINIMAC_TXADR, (unsigned int)&p);
+ minimac_write(MM_MINIMAC_TXREMAINING, (unsigned int)(len + 8));
+}
diff -u /dev/null rtems/c/src/lib/libbsp/lm32/shared/milkymist_timer/timer.c:1.1
--- /dev/null Fri Aug 20 17:10:17 2010
+++ rtems/c/src/lib/libbsp/lm32/shared/milkymist_timer/timer.c Fri Aug 20 16:23:27 2010
@@ -0,0 +1,88 @@
+/* timer.c
+ *
+ * This file manages the benchmark timer used by the RTEMS Timing
+ * Test Suite. Each measured time period is demarcated by calls to
+ * benchmark_timer_initialize() and benchmark_timer_read().
+ * benchmark_timer_read() usually returns the number of microseconds
+ * since benchmark_timer_initialize() exitted.
+ *
+ * NOTE: It is important that the timer start/stop overhead be
+ * determined when porting or modifying this code.
+ *
+ * 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$
+ *
+ * COPYRIGHT (c) Yann Sionneau <yann.sionneau at telecom-sudparis.eu> (GSoC 2010)
+ * Telecom SudParis
+ */
+
+#include <rtems.h>
+#include <bsp.h>
+#include "../include/system_conf.h"
+#include "../../shared/clock/clock.h"
+
+static inline int timerread(unsigned int reg)
+{
+ return *((int*)(reg));
+}
+
+static inline void timerwrite(unsigned int reg, int value)
+{
+ *((int*)reg) = value;
+}
+
+bool benchmark_timer_find_average_overhead;
+
+void benchmark_timer_initialize( void )
+{
+ timerwrite(MM_TIMER1_COMPARE, 0xffffffff);
+ timerwrite(MM_TIMER1_COUNTER, 0);
+ timerwrite(MM_TIMER1_CONTROL, TIMER_ENABLE);
+}
+
+/*
+ * The following controls the behavior of benchmark_timer_read().
+ *
+ * AVG_OVEREHAD is the overhead for starting and stopping the timer. It
+ * is usually deducted from the number returned.
+ *
+ * LEAST_VALID is the lowest number this routine should trust. Numbers
+ * below this are "noise" and zero is returned.
+ */
+
+#define AVG_OVERHEAD 4 /* It typically takes X.X microseconds */
+ /* (Y countdowns) to start/stop the timer. */
+ /* This value is in microseconds. */
+#define LEAST_VALID 4 /* Don't trust a clicks value lower than this */
+
+int benchmark_timer_read( void )
+{
+ uint32_t ticks;
+ uint32_t total;
+ ticks = timerread(MM_TIMER1_COUNTER);
+ if (ticks == 0xffffffff)
+ printk("Timer overflow!\n");
+
+ total = ticks / (CPU_FREQUENCY / 1000000);
+
+ if ( benchmark_timer_find_average_overhead == true )
+ return total;
+ else
+ {
+ if ( total < LEAST_VALID )
+ return 0;
+
+ return (total - AVG_OVERHEAD);
+
+ }
+}
+
+void benchmark_timer_disable_subtracting_average_overhead(
+ bool find_flag
+)
+{
+ benchmark_timer_find_average_overhead = find_flag;
+}
*joel*:
2010-08-20 <yann.sionneau at telecom-sudparis.eu>
* rtems/score/lm32.h: Add lm32_read_interrupts().
M 1.17 cpukit/score/cpu/lm32/ChangeLog
M 1.3 cpukit/score/cpu/lm32/rtems/score/lm32.h
diff -u rtems/cpukit/score/cpu/lm32/ChangeLog:1.16 rtems/cpukit/score/cpu/lm32/ChangeLog:1.17
--- rtems/cpukit/score/cpu/lm32/ChangeLog:1.16 Fri Jul 30 13:52:06 2010
+++ rtems/cpukit/score/cpu/lm32/ChangeLog Fri Aug 20 16:24:16 2010
@@ -1,3 +1,7 @@
+2010-08-20 <yann.sionneau at telecom-sudparis.eu>
+
+ * rtems/score/lm32.h: Add lm32_read_interrupts().
+
2010-07-30 Gedare Bloom <giddyup44 at yahoo.com>
PR 1599/cpukit
diff -u rtems/cpukit/score/cpu/lm32/rtems/score/lm32.h:1.2 rtems/cpukit/score/cpu/lm32/rtems/score/lm32.h:1.3
--- rtems/cpukit/score/cpu/lm32/rtems/score/lm32.h:1.2 Thu Dec 3 22:27:21 2009
+++ rtems/cpukit/score/cpu/lm32/rtems/score/lm32.h Fri Aug 20 16:24:16 2010
@@ -68,6 +68,9 @@
}
#endif
+#define lm32_read_interrupts( _ip) \
+ asm volatile ("rcsr %0, ip":"=r"(_ip));
+
#define lm32_disable_interrupts( _level ) \
do { register uint32_t ie; \
asm volatile ("rcsr %0,ie":"=r"(ie)); \
*joel*:
2010-08-20 <yann.sionneau at telecom-sudparis.eu>
* libmisc/fb/fb.h: Add constants for buffer modes.
M 1.2577 cpukit/ChangeLog
M 1.3 cpukit/libmisc/fb/fb.h
diff -u rtems/cpukit/ChangeLog:1.2576 rtems/cpukit/ChangeLog:1.2577
--- rtems/cpukit/ChangeLog:1.2576 Fri Aug 20 09:37:07 2010
+++ rtems/cpukit/ChangeLog Fri Aug 20 16:24:44 2010
@@ -1,3 +1,7 @@
+2010-08-20 <yann.sionneau at telecom-sudparis.eu>
+
+ * libmisc/fb/fb.h: Add constants for buffer modes.
+
2010-08-16 Ralf Corsépius <ralf.corsepius at rtems.org>
* posix/include/rtems/posix/aio_misc.h: Add decl for aio_request_queue.
diff -u rtems/cpukit/libmisc/fb/fb.h:1.2 rtems/cpukit/libmisc/fb/fb.h:1.3
--- rtems/cpukit/libmisc/fb/fb.h:1.2 Sun Nov 29 05:57:23 2009
+++ rtems/cpukit/libmisc/fb/fb.h Fri Aug 20 16:24:44 2010
@@ -24,7 +24,11 @@
#define FBIOGETCMAP 0x4604
#define FBIOPUTCMAP 0x4605
#define FB_EXEC_FUNCTION 0x4606
+#define FBIOSWAPBUFFERS 0x4607
+#define FBIOSETBUFFERMODE 0x4608
+#define FB_SINGLE_BUFFERED 0
+#define FB_TRIPLE_BUFFERED 1
#define FB_TYPE_PACKED_PIXELS 0 /* Packed Pixels */
#define FB_TYPE_PLANES 1 /* Non interleaved planes */
*joel*:
2010-08-20 <yann.sionneau at telecom-sudparis.eu>
* libchip/network/greth.c, libchip/network/open_eth.c: Add constants
for buffer modes.
M 1.533 c/src/ChangeLog
M 1.11 c/src/libchip/network/greth.c
M 1.19 c/src/libchip/network/open_eth.c
diff -u rtems/c/src/ChangeLog:1.532 rtems/c/src/ChangeLog:1.533
--- rtems/c/src/ChangeLog:1.532 Tue Aug 17 09:15:47 2010
+++ rtems/c/src/ChangeLog Fri Aug 20 16:26:09 2010
@@ -1,3 +1,8 @@
+2010-08-20 <yann.sionneau at telecom-sudparis.eu>
+
+ * libchip/network/greth.c, libchip/network/open_eth.c: Add constants
+ for buffer modes.
+
2010-08-17 Sebastian Huber <sebastian.huber at embedded-brains.de>
* libchip/ide/ata_internal.h: C++ compatibility.
diff -u rtems/c/src/libchip/network/greth.c:1.10 rtems/c/src/libchip/network/greth.c:1.11
--- rtems/c/src/libchip/network/greth.c:1.10 Mon May 31 08:27:07 2010
+++ rtems/c/src/libchip/network/greth.c Fri Aug 20 16:26:10 2010
@@ -44,6 +44,8 @@
#if defined(__m68k__)
extern m68k_isr_entry set_vector( rtems_isr_entry, rtems_vector_number, int );
+#elif defined(__lm32__)
+extern lm32_isr_entry set_vector( rtems_isr_entry, rtems_vector_number, int );
#else
extern rtems_isr_entry set_vector( rtems_isr_entry, rtems_vector_number, int );
#endif
diff -u rtems/c/src/libchip/network/open_eth.c:1.18 rtems/c/src/libchip/network/open_eth.c:1.19
--- rtems/c/src/libchip/network/open_eth.c:1.18 Mon May 31 07:16:43 2010
+++ rtems/c/src/libchip/network/open_eth.c Fri Aug 20 16:26:10 2010
@@ -57,6 +57,8 @@
#if defined(__m68k__)
extern m68k_isr_entry set_vector( rtems_isr_entry, rtems_vector_number, int );
+#elif defined(__lm32__)
+extern lm32_isr_entry set_vector( rtems_isr_entry, rtems_vector_number, int );
#else
extern rtems_isr_entry set_vector( rtems_isr_entry, rtems_vector_number, int );
#endif
--
Generated by Deluxe Loginfo [http://www.codewiz.org/projects/index.html#loginfo] 2.122 by Bernardo Innocenti <bernie at develer.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/vc/attachments/20100820/84a2f8ad/attachment-0001.html>
More information about the vc
mailing list