summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1996-05-01 15:25:33 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1996-05-01 15:25:33 +0000
commit996a9cb4e2a7d2d9ae43b8e3eb531a81ccefe690 (patch)
tree4d342614395f1c4fc7c3128a92212cef2e31e69c /c/src/lib/libbsp
parentUpdates from Eric Norum to use the mcpu32 flags and fix comments. (diff)
downloadrtems-996a9cb4e2a7d2d9ae43b8e3eb531a81ccefe690.tar.bz2
Updates from Eric Norum.
Diffstat (limited to 'c/src/lib/libbsp')
-rw-r--r--c/src/lib/libbsp/m68k/gen68360/README5
-rw-r--r--c/src/lib/libbsp/m68k/gen68360/include/bsp.h2
-rw-r--r--c/src/lib/libbsp/m68k/gen68360/start/start360.s46
-rw-r--r--c/src/lib/libbsp/m68k/gen68360/start360/start360.s46
-rw-r--r--c/src/lib/libbsp/m68k/gen68360/startup/init68360.c39
-rw-r--r--c/src/lib/libbsp/m68k/gen68360/startup/linkcmds125
-rw-r--r--c/src/lib/libbsp/m68k/gen68360/startup/linkcmds.prom111
7 files changed, 268 insertions, 106 deletions
diff --git a/c/src/lib/libbsp/m68k/gen68360/README b/c/src/lib/libbsp/m68k/gen68360/README
index 4e953bd143..cbbc295fab 100644
--- a/c/src/lib/libbsp/m68k/gen68360/README
+++ b/c/src/lib/libbsp/m68k/gen68360/README
@@ -4,9 +4,8 @@
#
# This package requires a version of GCC that has been modified
-# to support the `-m68360' argument. I have submitted the required changes
-# to the GCC maintainers. Should they choose to use a different argument
-# (-mcpu32 perhaps) this board support package will have to be changed.
+# to support the `-mcpu32' argument. I have submitted the required
+# changes to the GCC maintainers.
#
#
diff --git a/c/src/lib/libbsp/m68k/gen68360/include/bsp.h b/c/src/lib/libbsp/m68k/gen68360/include/bsp.h
index 4525e78141..508501e6e8 100644
--- a/c/src/lib/libbsp/m68k/gen68360/include/bsp.h
+++ b/c/src/lib/libbsp/m68k/gen68360/include/bsp.h
@@ -118,6 +118,8 @@ extern m68k_isr_entry M68Kvec[]; /* vector table address */
void bsp_cleanup( void );
+void M360ExecuteRISC( rtems_unsigned16 command );
+
m68k_isr_entry set_vector(
rtems_isr_entry handler,
rtems_vector_number vector,
diff --git a/c/src/lib/libbsp/m68k/gen68360/start/start360.s b/c/src/lib/libbsp/m68k/gen68360/start/start360.s
index b546e72406..2c4ed13066 100644
--- a/c/src/lib/libbsp/m68k/gen68360/start/start360.s
+++ b/c/src/lib/libbsp/m68k/gen68360/start/start360.s
@@ -298,11 +298,11 @@ uhoh: nop | Leave spot for breakpoint
bra.s uhoh | Stuck forever
/*
- * Place the low-order 3 octets of the board's
- * ethernet address at a `well-known' location.
+ * Place the low-order 3 octets of the board's ethernet address at
+ * a `well-known' fixed location relative to the beginning of ROM.
*/
.align 2
-| .long ETHERNET_ADDRESS | 08: Low-order 3 octets
+ .long ETHERNET_ADDRESS | Low-order 3 octets of ethernet address
/*
* Initial PC
@@ -347,24 +347,36 @@ start:
*/
jmp SYM(_Init68360) | Start C code (which never returns)
-
/*
- * Clear BSS, set up real stack, initialize heap, start C program
- * Assume that BSS size is a multiple of 4.
- * FIXME: The zero-loop should be changed to put the CPU into loop-mode.
- * FIXME: PROM-based systems will have to copy data segment to RAM here
+ * Copy DATA segment, clear BSS segment, set up real stack,
+ * initialize heap, start C program.
+ * Assume that DATA and BSS sizes are multiples of 4.
*/
- PUBLIC (_ClearBSSAndStart)
-SYM(_ClearBSSAndStart):
- movel #clear_start,a0
- movel #clear_end,a1
- clrl d0
- bras ZEROLOOPTEST
+ PUBLIC (_CopyDataClearBSSAndStart)
+SYM(_CopyDataClearBSSAndStart):
+ lea copy_start,a0 | Get start of DATA in RAM
+ lea SYM(etext),a2 | Get start of DATA in ROM
+ cmpl a0,a2 | Are they the same?
+ beq.s NOCOPY | Yes, no copy necessary
+ lea copy_end,a1 | Get end of DATA in RAM
+ bra.s COPYLOOPTEST | Branch into copy loop
+COPYLOOP:
+ movel a2@+,a0@+ | Copy word from ROM to RAM
+COPYLOOPTEST:
+ cmpl a1,a0 | Done?
+ bcs.s COPYLOOP | No, skip
+NOCOPY:
+
+ lea clear_start,a0 | Get start of BSS
+ lea clear_end,a1 | Get end of BSS
+ clrl d0 | Value to set
+ bra.s ZEROLOOPTEST | Branch into clear loop
ZEROLOOP:
- movel d0,a0@+
+ movel d0,a0@+ | Clear a word
ZEROLOOPTEST:
- cmpl a1,a0
- bcs ZEROLOOP
+ cmpl a1,a0 | Done?
+ bcs.s ZEROLOOP | No, skip
+
movel #stack_init,a7 | set master stack pointer
movel d0,a7@- | environp
movel d0,a7@- | argv
diff --git a/c/src/lib/libbsp/m68k/gen68360/start360/start360.s b/c/src/lib/libbsp/m68k/gen68360/start360/start360.s
index b546e72406..2c4ed13066 100644
--- a/c/src/lib/libbsp/m68k/gen68360/start360/start360.s
+++ b/c/src/lib/libbsp/m68k/gen68360/start360/start360.s
@@ -298,11 +298,11 @@ uhoh: nop | Leave spot for breakpoint
bra.s uhoh | Stuck forever
/*
- * Place the low-order 3 octets of the board's
- * ethernet address at a `well-known' location.
+ * Place the low-order 3 octets of the board's ethernet address at
+ * a `well-known' fixed location relative to the beginning of ROM.
*/
.align 2
-| .long ETHERNET_ADDRESS | 08: Low-order 3 octets
+ .long ETHERNET_ADDRESS | Low-order 3 octets of ethernet address
/*
* Initial PC
@@ -347,24 +347,36 @@ start:
*/
jmp SYM(_Init68360) | Start C code (which never returns)
-
/*
- * Clear BSS, set up real stack, initialize heap, start C program
- * Assume that BSS size is a multiple of 4.
- * FIXME: The zero-loop should be changed to put the CPU into loop-mode.
- * FIXME: PROM-based systems will have to copy data segment to RAM here
+ * Copy DATA segment, clear BSS segment, set up real stack,
+ * initialize heap, start C program.
+ * Assume that DATA and BSS sizes are multiples of 4.
*/
- PUBLIC (_ClearBSSAndStart)
-SYM(_ClearBSSAndStart):
- movel #clear_start,a0
- movel #clear_end,a1
- clrl d0
- bras ZEROLOOPTEST
+ PUBLIC (_CopyDataClearBSSAndStart)
+SYM(_CopyDataClearBSSAndStart):
+ lea copy_start,a0 | Get start of DATA in RAM
+ lea SYM(etext),a2 | Get start of DATA in ROM
+ cmpl a0,a2 | Are they the same?
+ beq.s NOCOPY | Yes, no copy necessary
+ lea copy_end,a1 | Get end of DATA in RAM
+ bra.s COPYLOOPTEST | Branch into copy loop
+COPYLOOP:
+ movel a2@+,a0@+ | Copy word from ROM to RAM
+COPYLOOPTEST:
+ cmpl a1,a0 | Done?
+ bcs.s COPYLOOP | No, skip
+NOCOPY:
+
+ lea clear_start,a0 | Get start of BSS
+ lea clear_end,a1 | Get end of BSS
+ clrl d0 | Value to set
+ bra.s ZEROLOOPTEST | Branch into clear loop
ZEROLOOP:
- movel d0,a0@+
+ movel d0,a0@+ | Clear a word
ZEROLOOPTEST:
- cmpl a1,a0
- bcs ZEROLOOP
+ cmpl a1,a0 | Done?
+ bcs.s ZEROLOOP | No, skip
+
movel #stack_init,a7 | set master stack pointer
movel d0,a7@- | environp
movel d0,a7@- | argv
diff --git a/c/src/lib/libbsp/m68k/gen68360/startup/init68360.c b/c/src/lib/libbsp/m68k/gen68360/startup/init68360.c
index a061a027e0..d0764453a8 100644
--- a/c/src/lib/libbsp/m68k/gen68360/startup/init68360.c
+++ b/c/src/lib/libbsp/m68k/gen68360/startup/init68360.c
@@ -1,5 +1,5 @@
/*
- * Initialize 68360 hardware
+ * MC68360 support routines
*
* W. Eric Norum
* Saskatchewan Accelerator Laboratory
@@ -12,15 +12,33 @@
#include <rtems.h>
#include <bsp.h>
-#include "m68360.h"
+#include <m68360.h>
-void
-_Init68360 (void)
+/*
+ * Send a command to the CPM RISC processer
+ */
+
+void M360ExecuteRISC(rtems_unsigned16 command)
+{
+ rtems_unsigned16 sr;
+
+ m68k_disable_interrupts (sr);
+ while (m360.cr & M360_CR_FLG)
+ continue;
+ m360.cr = command | M360_CR_FLG;
+ m68k_enable_interrupts (sr);
+}
+
+/*
+ * Initialize MC68360
+ */
+
+void _Init68360 (void)
{
int i;
extern void *_RomBase, *_RamBase;
m68k_isr_entry *vbr;
- extern void _ClearBSSAndStart (void);
+ extern void _CopyDataClearBSSAndStart (void);
/*
* Step 6: Is this a power-up reset?
@@ -64,7 +82,7 @@ _Init68360 (void)
*((long *)((char *)&m360 + 0xE00 + i)) = 0;
*((long *)((char *)&m360 + 0xF00 + i)) = 0;
}
- m360.cr = M360_CR_RST | M360_CR_FLG;
+ M360ExecuteRISC (M360_CR_RST);
/*
* Step 10: Write PEPAR
@@ -129,11 +147,10 @@ _Init68360 (void)
/*
* Step 13: Copy the exception vector table to system RAM
*/
-
- m68k_get_vbr( vbr );
+ m68k_get_vbr (vbr);
for (i = 0; i < 256; ++i)
M68Kvec[i] = vbr[i];
- m68k_set_vbr( M68Kvec );
+ m68k_set_vbr (M68Kvec);
/*
* Step 14: More system initialization
@@ -167,7 +184,7 @@ _Init68360 (void)
m360.mcr = 0x4C7F;
/*
- * Clear BSS, switch stacks and call main()
+ * Copy data, clear BSS, switch stacks and call main()
*/
- _ClearBSSAndStart ();
+ _CopyDataClearBSSAndStart ();
}
diff --git a/c/src/lib/libbsp/m68k/gen68360/startup/linkcmds b/c/src/lib/libbsp/m68k/gen68360/startup/linkcmds
index 74d5855fe8..c322eef82b 100644
--- a/c/src/lib/libbsp/m68k/gen68360/startup/linkcmds
+++ b/c/src/lib/libbsp/m68k/gen68360/startup/linkcmds
@@ -13,84 +13,93 @@
* Declare on-board memory
*/
MEMORY {
- ram : ORIGIN = 0x00000000, LENGTH = 4M
- rom : ORIGIN = 0xFF000000, LENGTH = 1M
- dpram : ORIGIN = 0xFE000000, LENGTH = 8k
+ ram : ORIGIN = 0x00000000, LENGTH = 4M
+ rom : ORIGIN = 0xFF000000, LENGTH = 1M
+ dpram : ORIGIN = 0xFE000000, LENGTH = 8k
}
/*
* Declare some sizes
+ * XXX: The assignment of ". += XyzSize;" fails in older gld's if the
+ * number used there is not constant. If this happens to you, edit
+ * the lines marked below to use a constant value.
*/
+HeapSize = DEFINED(HeapSize) ? HeapSize : 0x10000;
+StackSize = DEFINED(StackSize) ? StackSize : 0x1000;
/*
- * XXX: The assignment of ". += XyzSize;" fails in older gld's if the
- * number used there is not constant so the calculated sizes are
- * ignored below and the default number is used instead.
+ * Declare low-order three octets of Ethernet address
*/
-
-HeapSize = DEFINED(HeapSize) ? HeapSize : 0x10000;
-StackSize = DEFINED(StackSize) ? StackSize : 0x1000;
+ETHERNET_ADDRESS = DEFINED(ETHERNET_ADDRESS) ? ETHERNET_ADDRESS : 0xDEAD12;
/*
* Load objects
*/
SECTIONS {
+ /*
+ * Boot PROM
+ */
+ rom : {
+ _RomBase = .;
+ __RomBase = .;
+ } >rom
+
+ /*
+ * Dynamic RAM
+ */
+ ram : {
+ _RamBase = .;
+ __RamBase = .;
+ } >ram
+
+ /*
+ * Text, data and bss segments
+ */
.text : {
- _RamBase = .;
- __RamBase = .;
- CREATE_OBJECT_SYMBOLS
- *(.text)
- . = ALIGN (16);
- _etext = .;
+ CREATE_OBJECT_SYMBOLS
+ *(.text)
+ . = ALIGN (16);
+ etext = .;
+ _etext = .;
} >ram
.data : {
- *(.data)
- . = ALIGN (16);
- _edata = .;
+ copy_start = .;
+ *(.data)
+ . = ALIGN (16);
+ _edata = .;
+ copy_end = .;
} >ram
.bss : {
- M68Kvec = .;
- _M68Kvec = .;
- . += (256 * 4);
- clear_start = .;
- *(.bss)
- *(COMMON)
- . = ALIGN (16);
- _end = .;
-
- _HeapStart = .;
- __HeapStart = .;
- /* XXX: Temporary to get around a gld bug
- *
- * . += HeapSize;
- * . += StackSize;
- */
- . += 0x10000; /* XXX */
- . += 0x1000; /* XXX */
+ M68Kvec = .;
+ _M68Kvec = .;
+ . += (256 * 4);
+ clear_start = .;
+ *(.bss)
+ *(COMMON)
+ . = ALIGN (16);
+ _end = .;
- . = ALIGN (16);
- stack_init = .;
- clear_end = .;
+ _HeapStart = .;
+ __HeapStart = .;
+ /* . += HeapSize; */ /* XXX -- Old gld can't handle this */
+ /* . += StackSize; */ /* XXX -- Old gld can't handle this */
+ . += 0x10000; /* HeapSize for old gld */
+ . += 0x1000; /* StackSize for old gld */
+ . = ALIGN (16);
+ stack_init = .;
+ clear_end = .;
- _WorkspaceBase = .;
- __WorkspaceBase = .;
- } >ram
-
- /*
- * On-chip memory/peripherals
- */
- dpram : {
- m360 = .;
- _m360 = .;
- . += (8 * 1024);
+ _WorkspaceBase = .;
+ __WorkspaceBase = .;
+ } >ram
- } >dpram
+ /*
+ * On-chip memory/peripherals
+ */
+ dpram : {
+ m360 = .;
+ _m360 = .;
+ . += (8 * 1024);
- /*
- * Boot PROM
- */
- rom : {
- _RomBase = .;
- __RomBase = .;
- } >rom
+ } >dpram
}
diff --git a/c/src/lib/libbsp/m68k/gen68360/startup/linkcmds.prom b/c/src/lib/libbsp/m68k/gen68360/startup/linkcmds.prom
new file mode 100644
index 0000000000..ef1c3ee6e2
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/gen68360/startup/linkcmds.prom
@@ -0,0 +1,111 @@
+/*
+ * This file contains GNU linker directives for a generic MC68360 board.
+ * These linker directives are for producing a PROM version..
+ * To create the PROM image from the linkter output you must use objcopy
+ * (--adjust-section-vma) to place the data segment at the end of the text
+ * segment in the PROM. The start-up code takes care of copying this region
+ * to RAM.
+ *
+ * Saskatchewan Accelerator Laboratory
+ * University of Saskatchewan
+ * Saskatoon, Saskatchewan, CANADA
+ * eric@skatter.usask.ca
+ *
+ * $Id$
+ */
+
+/*
+ * a.out format doesn't handle prom images very well
+ */
+OUTPUT_FORMAT(coff-m68k)
+
+/*
+ * Declare on-board memory
+ */
+MEMORY {
+ ram : ORIGIN = 0x00000000, LENGTH = 4M
+ rom : ORIGIN = 0xFF000000, LENGTH = 1M
+ dpram : ORIGIN = 0xFE000000, LENGTH = 8k
+}
+
+/*
+ * Declare some sizes
+ */
+HeapSize = DEFINED(HeapSize) ? HeapSize : 0x10000;
+StackSize = DEFINED(StackSize) ? StackSize : 0x1000;
+
+/*
+ * Declare low-order three octets of Ethernet address
+ */
+ETHERNET_ADDRESS = DEFINED(ETHERNET_ADDRESS) ? ETHERNET_ADDRESS : 0xDEAD12;
+
+/*
+ * Load objects
+ */
+SECTIONS {
+ /*
+ * Boot PROM
+ */
+ rom : {
+ _RomBase = .;
+ __RomBase = .;
+ } >rom
+
+ /*
+ * Dynamic RAM
+ */
+ ram : {
+ _RamBase = .;
+ __RamBase = .;
+ } >ram
+
+ /*
+ * Text, data and bss segments
+ */
+ .text : {
+ CREATE_OBJECT_SYMBOLS
+ *(.text)
+ . = ALIGN (16);
+ etext = .;
+ _etext = .;
+ } >rom
+ .data : {
+ copy_start = .;
+ *(.data)
+ . = ALIGN (16);
+ _edata = .;
+ copy_end = .;
+ } >ram
+ .bss : {
+ M68Kvec = .;
+ _M68Kvec = .;
+ . += (256 * 4);
+ clear_start = .;
+ *(.bss)
+ *(COMMON)
+ . = ALIGN (16);
+ _end = .;
+
+ _HeapStart = .;
+ __HeapStart = .;
+ . += HeapSize;
+ . += StackSize;
+ . = ALIGN (16);
+ stack_init = .;
+ clear_end = .;
+
+ _WorkspaceBase = .;
+ __WorkspaceBase = .;
+ } >ram
+
+ /*
+ * On-chip memory/peripherals
+ */
+ dpram : {
+ m360 = .;
+ _m360 = .;
+ . += (8 * 1024);
+
+ } >dpram
+
+}