m68k/mrm332: changes required to get the mrm332 bsp working again.

Changed console driver to use interrupts instead of polling.
Change to avoid overwriting CPU32Bug interrupt vector when setting up the Sci interrupt handler.
Fixed type for boolean flag in bsp.h.
Changed mrm332.h to use 25Mhz clock.
Fixes to mrm332.cfg to use correct mcpu32 value for RTEMS_CPU_MODEL instead of m68332 which is no longer supported.
Added -mcpu=cpu32 to compiler options.
Removed broken ROM linker script and replaced broken RAM linker script with working ROM linker script.
Removed no longer required file except_vect_332_ROM.S.
Enabled 0xbeefbeef magic string in start.S to allow MRM version of CPU32Bug to auto run RTEMS.
Removed old code from start.S
Changed compiler optimization flag to optimize for size.
This commit is contained in:
James Fitzsimons
2014-03-24 22:32:10 +13:00
committed by Gedare Bloom
parent 8c26e79867
commit 89aa1ec87d
12 changed files with 275 additions and 869 deletions

View File

@@ -22,7 +22,7 @@ noinst_LIBRARIES = libbspstart.a
libbspstart_a_SOURCES = start/start.S
project_lib_DATA = start.$(OBJEXT)
dist_project_lib_DATA += startup/linkcmds startup/linkcmds_ROM
dist_project_lib_DATA += startup/linkcmds
noinst_LIBRARIES += libbsp.a
libbsp_a_SOURCES =
@@ -33,8 +33,7 @@ libbsp_a_SOURCES += startup/start_c.c ../../shared/bsplibc.c \
../../shared/bootcard.c ../../shared/sbrk.c \
../../shared/bspclean.c \
../../shared/setvec.c ../../shared/bsppretaskinghook.c \
../../shared/bspgetworkarea.c ../../shared/gnatinstallhandler.c \
startup/except_vect_332_ROM.S
../../shared/bspgetworkarea.c ../../shared/gnatinstallhandler.c
# clock
libbsp_a_SOURCES += clock/ckinit.c
# console

View File

@@ -42,7 +42,7 @@ rtems_device_driver console_open(
/* SCI internal uart */
status = rtems_termios_open( major, minor, arg, SciGetTermiosHandlers( TRUE ) );
status = rtems_termios_open( major, minor, arg, SciGetTermiosHandlers( FALSE ) );
return status;
}

View File

@@ -351,8 +351,8 @@ rtems_isr SciIsr( rtems_vector_number vector )
if ( (*SCSR) & SCI_ERROR_OVERRUN ) SciErrorsOverrun ++;
/* see if it was a transmit interrupt */
if ( (*SCSR) & SCI_XMTR_AVAILABLE ) /* data reg empty, xmt complete */
/* data reg empty, xmt complete */
if ( ( *SCCR1 & SCI_ENABLE_INT_TX ) && ( (*SCSR) & SCI_XMTR_AVAILABLE ) )
{
SciDisableTransmitInterrupts();
@@ -554,12 +554,17 @@ int SciInterruptOpen(
SciSetDataBits(SCI_8_DATA_BITS); /* set data bits to 8 */
/* Install our interrupt handler into RTEMS, where does 66 come from? */
/* Install our interrupt handler into RTEMS. */
/* 68 is an unused user-defined vector. Note that the vector must be */
/* even - it sets the low bit for SPI interrupts, and clears it for */
/* SCI interrupts. Also note that vector 66 is used by CPU32bug on */
/* the mrm332. */
rtems_interrupt_catch( SciIsr, 66, &old_vector );
rtems_interrupt_catch( SciIsr, 68, &old_vector );
*QIVR = 66;
*QIVR &= 0xf8;
*QSMCR = (*QSMCR & ~IARB) | 1; // Is 1 a good value for qsm iarb?
*QIVR = 68;
*QILR &= 0xf8;
*QILR |= 0x06 & 0x07;
SciEnableTransmitter(); /* enable the transmitter */
@@ -1382,7 +1387,7 @@ void SciWriteCharWait(uint8_t c)
{
/* poll the fifo, waiting for room for another character */
while ( ( *SCSR & SCI_XMTR_AVAILABLE ) == 0 )
while ( ( *SCSR & SCI_XMTR_AVAILABLE ) != SCI_XMTR_AVAILABLE )
{
/* Either we are writing to the fifo faster than
* the uart can clock bytes out onto the cable,

View File

@@ -42,7 +42,7 @@ extern char _copy_start[];
extern char _edata[];
extern char _clear_start[];
extern char end[];
extern char _copy_data_from_rom[];
extern bool _copy_data_from_rom;
/* constants */

View File

@@ -27,6 +27,8 @@
/* System Clock definitions */
#define XTAL 32768.0 /* crystal frequency in Hz */
/* Specify the CPU frequency. Do not specify a faster clock than your */
/* CPU is rated for! */
#if 0
/* Default MRM clock rate (8.388688 MHz) set by CPU32: */
#define MRM_W 0 /* system clock parameters */
@@ -34,18 +36,19 @@
#define MRM_Y 0x3f
#endif
#if 1
#if 0
/* 16.77722 MHz: */
#define MRM_W 1 /* system clock parameters */
#define MRM_X 1
#define MRM_Y 0x0f
#endif
#if 0
#if 1
/* 25.16582 MHz: */
#define MRM_W 1 /* system clock parameters */
#define MRM_X 1
#define MRM_Y 0x17
#define SET_EDIV
#endif
#define SYS_CLOCK (XTAL*4.0*(MRM_Y+1)*(1 << (2*MRM_W+MRM_X)))

View File

@@ -5,41 +5,15 @@
include $(RTEMS_ROOT)/make/custom/default.cfg
RTEMS_CPU=m68k
RTEMS_CPU_MODEL=m68332
RTEMS_CPU_MODEL=mcpu32
# This contains the compiler options necessary to select the CPU model
# and (hopefully) optimize for it.
CPU_CFLAGS = -mcpu=cpu32
# optimize flag: typically -O2
CFLAGS_OPTIMIZE_V = -O2 -g -fomit-frame-pointer
# using optimise for size due to small memory on target board.
CFLAGS_OPTIMIZE_V = -Os -g -fomit-frame-pointer
ifeq ($(MRM_IN_ROM),yes)
# Build a rommable image - move the .data section after the .text section
# in the image.
CPU_CFLAGS += -qnolinkcmds -T $(exec_prefix)/mrm332/lib/linkcmds_ROM
endif
ifeq ($(MRM_IN_ROM),yes)
define bsp-post-link
$(OBJCOPY) --adjust-section-vma \
.data=`m68k-rtems-objdump --section-headers $(basename $@).pxe | \
awk 'function h2d(x) { x=toupper(x); digits=length(x); s=0 ; \
for (p=digits; p>0; p--) \
s += (16^(p-1)) * ( index("0123456789ABCDEF",\
substr(x,1+digits-p,1)) -1 );\
return s } ;\
/\.text/ { base = $$4 ; size = $$3 };\
END { printf("0x%x", h2d(base) + h2d(size)) }'\
` $(basename $@).pxe $(basename $@)$(EXEEXT)
$(OBJCOPY) -O srec $(basename $@)$(EXEEXT) $(basename $@).srec
sed -e 's/.$$//' -e '/^S0/d' $(basename $@).srec | \
$(PACKHEX) > $(basename $@)$(DOWNEXT)
$(NM) -g -n $(basename $@).pxe > $(basename $@).pnum
rm -f $(basename $@).srec $(basename $@).srec
$(default-bsp-post-link)
endef
else
define bsp-post-link
$(OBJCOPY) -O srec $(basename $@)$(EXEEXT) $(basename $@).srec
sed -e 's/.$$//' -e '/^S0/d' $(basename $@).srec | \
@@ -47,4 +21,4 @@ define bsp-post-link
rm -f $(basename $@).srec
$(default-bsp-post-link)
endef
endif

View File

@@ -69,7 +69,3 @@ $(PROJECT_LIB)/linkcmds: startup/linkcmds $(PROJECT_LIB)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_LIB)/linkcmds
PREINSTALL_FILES += $(PROJECT_LIB)/linkcmds
$(PROJECT_LIB)/linkcmds_ROM: startup/linkcmds_ROM $(PROJECT_LIB)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_LIB)/linkcmds_ROM
PREINSTALL_FILES += $(PROJECT_LIB)/linkcmds_ROM

View File

@@ -22,7 +22,7 @@ BEGIN_CODE
/* Put the header necessary for the modified CPU32bug to automatically
start up rtems: */
#if 0
#if 1
.long 0xbeefbeef ;
#endif
.long 0 ;
@@ -31,11 +31,16 @@ BEGIN_CODE
.global start
start:
oriw #0x0700,sr
movel #end, d0
addl #_StackSize,d0
oriw #0x0700,sr /* Mask off interupts */
// Set VBR to CPU32Bug vector table address
movel #0x0,d0 /* Use the initial vectors until we get going */
movecl d0,vbr
movel #end, d0 /* Next 3 instructions set stack pointer */
addl #_StackSize,d0 /* sp = end + _StackSize from linker script */
movel d0,sp
movel d0,a6
movel d0,a6
/* include in ram_init.S */
/*
@@ -46,6 +51,13 @@ BEGIN_CODE
/* Module Configuration Register */
/* see section(s) 3.1.3-3.1.6 of the SIM Reference Manual */
/* SIMCR etc and SAM macro all defined in sim.h found at */
/* /cpukit/score/cpu/m68k/rtems/m68k/sim.h */
/* The code below does the following: */
/* - Sets Freeze Software Enable */
/* - Turns off Show Cycle Enable */
/* - Sets the location of SIM module mapping */
/* - Sets the SIM Interrupt Arbitration Field */
lea SIMCR, a0
movew #FRZSW,d0
oriw #SAM(0,8,SHEN),d0
@@ -57,106 +69,3 @@ BEGIN_CODE
END_CODE
#if 0
/* Synthesizer Control Register */
/* see section(s) 4.8 */
/* end include in ram_init.S */
*SYNCR = (unsigned short int)
( SAM(MRM_W,15,VCO) | SAM(0x0,14,PRESCALE) | SAM(MRM_Y,8,COUNTER) );
while (! (*SYNCR & SLOCK)); /* protect from clock overshoot */
/* include in ram_init.S */
*SYNCR = (unsigned short int)
( SAM(MRM_W,15,VCO) | SAM(MRM_X,14,PRESCALE) | SAM(MRM_Y,8,COUNTER) );
/* System Protection Control Register */
/* !!! can only write to once after reset !!! */
/* see section 3.8.4 of the SIM Reference Manual */
*SYPCR = (unsigned char)( HME | BME );
/* Periodic Interrupr Control Register */
/* see section 3.8.2 of the SIM Reference Manual */
*PICR = (unsigned short int)
( SAM(0,8,PIRQL) | SAM(MRM_PIV,0,PIV) );
/* ^^^ zero disables interrupt, don't enable here or ram_init will
be wrong. It's enabled below. */
/* Periodic Interrupt Timer Register */
/* see section 3.8.3 of the SIM Reference Manual */
*PITR = (unsigned short int)( SAM(0x09,0,PITM) );
/* 1.098mS interrupt, assuming 32.768 KHz input clock */
/* Port C Data */
/* load values before enabled */
*PORTC = (unsigned char) 0x0;
/* Port E and F Data Register */
/* see section 9 of the SIM Reference Manual */
*PORTE0 = (unsigned char) 0;
*PORTF0 = (unsigned char) 0;
/* Port E and F Data Direction Register */
/* see section 9 of the SIM Reference Manual */
*DDRE = (unsigned char) 0xff;
*DDRF = (unsigned char) 0xfd;
/* Port E and F Pin Assignment Register */
/* see section 9 of the SIM Reference Manual */
*PEPAR = (unsigned char) 0;
*PFPAR = (unsigned char) 0;
/* end of SIM initalization code */
/* end include in ram_init.S */
/*
* Initialize RAM by copying the .data section out of ROM (if
* needed) and "zero-ing" the .bss section.
*/
{
register char *src = _etext;
register char *dst = _copy_start;
if (_copy_data_from_rom)
/* ROM has data at end of text; copy it. */
while (dst < _edata)
*dst++ = *src++;
/* Zero bss */
for (dst = _clear_start; dst< end; dst++)
{
*dst = 0;
}
}
/*
* Initialize vector table.
*/
{
rtems_isr_entry *monitors_vector_table;
m68k_get_vbr(monitors_vector_table);
M68Kvec[ 4 ] = monitors_vector_table[ 4 ]; /* breakpoints vector */
M68Kvec[ 9 ] = monitors_vector_table[ 9 ]; /* trace vector */
M68Kvec[ 31 ] = monitors_vector_table[ 31 ]; /* level 7 interrupt */
M68Kvec[ 47 ] = monitors_vector_table[ 47 ]; /* system call vector */
M68Kvec[ 66 ] = monitors_vector_table[ 66 ]; /* user defined */
m68k_set_vbr(&M68Kvec);
}
/*
* Initalize the board.
*/
Spurious_Initialize();
console_init();
/*
* Execute main with arguments argc and agrv.
*/
boot_card((void*)0);
reboot();
}
#endif

View File

@@ -1,289 +0,0 @@
/* Exception Vector definitions follow */
/* !!! Warning !!! This table is not tested, and
the user must make sure it is complete. */
/* If we use TRAP #15 for reboot, note that group 0 and 1 exceptions
will have priority. */
/* This is the "magic word" that CPU32bug uses to indicate that
there is a bootable image here. */
.long 0xBEEFBEEF
/* Vector 0: RESET: Initial SSP */
.long _RamEnd
/* Vector 1: RESET: Initial PC */
.long start
/* default action for undefined vectors is to re-boot */
/* Note group 0 and 1 exception (like trace) have priority
over other exceptions (like trap #15) that may call this. */
/* Vectors 2-255 */
.long reboot /* exception vector: 2 */
.long reboot /* exception vector: 3 */
.long reboot /* exception vector: 4 */
.long reboot /* exception vector: 5 */
.long reboot /* exception vector: 6 */
.long reboot /* exception vector: 7 */
.long reboot /* exception vector: 8 */
.long reboot /* exception vector: 9 */
.long reboot /* exception vector: 10 */
.long reboot /* exception vector: 11 */
.long reboot /* exception vector: 12 */
.long reboot /* exception vector: 13 */
.long reboot /* exception vector: 14 */
.long reboot /* exception vector: 15 */
.long reboot /* exception vector: 16 */
.long reboot /* exception vector: 17 */
.long reboot /* exception vector: 18 */
.long reboot /* exception vector: 19 */
.long reboot /* exception vector: 20 */
.long reboot /* exception vector: 21 */
.long reboot /* exception vector: 22 */
.long reboot /* exception vector: 23 */
.long reboot /* exception vector: 24 */
.long reboot /* exception vector: 25 */
.long reboot /* exception vector: 26 */
.long reboot /* exception vector: 27 */
.long reboot /* exception vector: 28 */
.long reboot /* exception vector: 29 */
.long reboot /* exception vector: 30 */
.long reboot /* exception vector: 31 */
.long reboot /* exception vector: 32 */
.long reboot /* exception vector: 33 */
.long reboot /* exception vector: 34 */
.long reboot /* exception vector: 35 */
.long reboot /* exception vector: 36 */
.long reboot /* exception vector: 37 */
.long reboot /* exception vector: 38 */
.long reboot /* exception vector: 39 */
.long reboot /* exception vector: 40 */
.long reboot /* exception vector: 41 */
.long reboot /* exception vector: 42 */
.long reboot /* exception vector: 43 */
.long reboot /* exception vector: 44 */
.long reboot /* exception vector: 45 */
.long reboot /* exception vector: 46 */
.long _reboot /* the reboot trap: 47 */
.long reboot /* exception vector: 48 */
.long reboot /* exception vector: 49 */
.long reboot /* exception vector: 50 */
.long reboot /* exception vector: 51 */
.long reboot /* exception vector: 52 */
.long reboot /* exception vector: 53 */
.long reboot /* exception vector: 54 */
.long reboot /* exception vector: 55 */
.long reboot /* exception vector: 56 */
.long reboot /* exception vector: 57 */
.long reboot /* exception vector: 58 */
.long reboot /* exception vector: 59 */
.long reboot /* exception vector: 60 */
.long reboot /* exception vector: 61 */
.long reboot /* exception vector: 62 */
.long reboot /* exception vector: 63 */
.long reboot /* exception vector: 64 */
.long reboot /* exception vector: 65 */
.long reboot /* exception vector: 66 */
.long reboot /* exception vector: 67 */
.long reboot /* exception vector: 68 */
.long reboot /* exception vector: 69 */
.long reboot /* exception vector: 70 */
.long reboot /* exception vector: 71 */
.long reboot /* exception vector: 72 */
.long reboot /* exception vector: 73 */
.long reboot /* exception vector: 74 */
.long reboot /* exception vector: 75 */
.long reboot /* exception vector: 76 */
.long reboot /* exception vector: 77 */
.long reboot /* exception vector: 78 */
.long reboot /* exception vector: 79 */
.long reboot /* exception vector: 80 */
.long reboot /* exception vector: 81 */
.long reboot /* exception vector: 82 */
.long reboot /* exception vector: 83 */
.long reboot /* exception vector: 84 */
.long reboot /* exception vector: 85 */
.long reboot /* exception vector: 86 */
.long reboot /* exception vector: 87 */
.long reboot /* exception vector: 88 */
.long reboot /* exception vector: 89 */
.long reboot /* exception vector: 90 */
.long reboot /* exception vector: 91 */
.long reboot /* exception vector: 92 */
.long reboot /* exception vector: 93 */
.long reboot /* exception vector: 94 */
.long reboot /* exception vector: 95 */
.long reboot /* exception vector: 96 */
.long reboot /* exception vector: 97 */
.long reboot /* exception vector: 98 */
.long reboot /* exception vector: 99 */
.long reboot /* exception vector: 100 */
.long reboot /* exception vector: 101 */
.long reboot /* exception vector: 102 */
.long reboot /* exception vector: 103 */
.long reboot /* exception vector: 104 */
.long reboot /* exception vector: 105 */
.long reboot /* exception vector: 106 */
.long reboot /* exception vector: 107 */
.long reboot /* exception vector: 108 */
.long reboot /* exception vector: 109 */
.long reboot /* exception vector: 110 */
.long reboot /* exception vector: 111 */
.long reboot /* exception vector: 112 */
.long reboot /* exception vector: 113 */
.long reboot /* exception vector: 114 */
.long reboot /* exception vector: 115 */
.long reboot /* exception vector: 116 */
.long reboot /* exception vector: 117 */
.long reboot /* exception vector: 118 */
.long reboot /* exception vector: 119 */
.long reboot /* exception vector: 120 */
.long reboot /* exception vector: 121 */
.long reboot /* exception vector: 122 */
.long reboot /* exception vector: 123 */
.long reboot /* exception vector: 124 */
.long reboot /* exception vector: 125 */
.long reboot /* exception vector: 126 */
.long reboot /* exception vector: 127 */
.long reboot /* exception vector: 128 */
.long reboot /* exception vector: 129 */
.long reboot /* exception vector: 130 */
.long reboot /* exception vector: 131 */
.long reboot /* exception vector: 132 */
.long reboot /* exception vector: 133 */
.long reboot /* exception vector: 134 */
.long reboot /* exception vector: 135 */
.long reboot /* exception vector: 136 */
.long reboot /* exception vector: 137 */
.long reboot /* exception vector: 138 */
.long reboot /* exception vector: 139 */
.long reboot /* exception vector: 140 */
.long reboot /* exception vector: 141 */
.long reboot /* exception vector: 142 */
.long reboot /* exception vector: 143 */
.long reboot /* exception vector: 144 */
.long reboot /* exception vector: 145 */
.long reboot /* exception vector: 146 */
.long reboot /* exception vector: 147 */
.long reboot /* exception vector: 148 */
.long reboot /* exception vector: 149 */
.long reboot /* exception vector: 150 */
.long reboot /* exception vector: 151 */
.long reboot /* exception vector: 152 */
.long reboot /* exception vector: 153 */
.long reboot /* exception vector: 154 */
.long reboot /* exception vector: 155 */
.long reboot /* exception vector: 156 */
.long reboot /* exception vector: 157 */
.long reboot /* exception vector: 158 */
.long reboot /* exception vector: 159 */
.long reboot /* exception vector: 160 */
.long reboot /* exception vector: 161 */
.long reboot /* exception vector: 162 */
.long reboot /* exception vector: 163 */
.long reboot /* exception vector: 164 */
.long reboot /* exception vector: 165 */
.long reboot /* exception vector: 166 */
.long reboot /* exception vector: 167 */
.long reboot /* exception vector: 168 */
.long reboot /* exception vector: 169 */
.long reboot /* exception vector: 170 */
.long reboot /* exception vector: 171 */
.long reboot /* exception vector: 172 */
.long reboot /* exception vector: 173 */
.long reboot /* exception vector: 174 */
.long reboot /* exception vector: 175 */
.long reboot /* exception vector: 176 */
.long reboot /* exception vector: 177 */
.long reboot /* exception vector: 178 */
.long reboot /* exception vector: 179 */
.long reboot /* exception vector: 180 */
.long reboot /* exception vector: 181 */
.long reboot /* exception vector: 182 */
.long reboot /* exception vector: 183 */
.long reboot /* exception vector: 184 */
.long reboot /* exception vector: 185 */
.long reboot /* exception vector: 186 */
.long reboot /* exception vector: 187 */
.long reboot /* exception vector: 188 */
.long reboot /* exception vector: 189 */
.long reboot /* exception vector: 190 */
.long reboot /* exception vector: 191 */
.long reboot /* exception vector: 192 */
.long reboot /* exception vector: 193 */
.long reboot /* exception vector: 194 */
.long reboot /* exception vector: 195 */
.long reboot /* exception vector: 196 */
.long reboot /* exception vector: 197 */
.long reboot /* exception vector: 198 */
.long reboot /* exception vector: 199 */
.long reboot /* exception vector: 200 */
.long reboot /* exception vector: 201 */
.long reboot /* exception vector: 202 */
.long reboot /* exception vector: 203 */
.long reboot /* exception vector: 204 */
.long reboot /* exception vector: 205 */
.long reboot /* exception vector: 206 */
.long reboot /* exception vector: 207 */
.long reboot /* exception vector: 208 */
.long reboot /* exception vector: 209 */
.long reboot /* exception vector: 210 */
.long reboot /* exception vector: 211 */
.long reboot /* exception vector: 212 */
.long reboot /* exception vector: 213 */
.long reboot /* exception vector: 214 */
.long reboot /* exception vector: 215 */
.long reboot /* exception vector: 216 */
.long reboot /* exception vector: 217 */
.long reboot /* exception vector: 218 */
.long reboot /* exception vector: 219 */
.long reboot /* exception vector: 220 */
.long reboot /* exception vector: 221 */
.long reboot /* exception vector: 222 */
.long reboot /* exception vector: 223 */
.long reboot /* exception vector: 224 */
.long reboot /* exception vector: 225 */
.long reboot /* exception vector: 226 */
.long reboot /* exception vector: 227 */
.long reboot /* exception vector: 228 */
.long reboot /* exception vector: 229 */
.long reboot /* exception vector: 230 */
.long reboot /* exception vector: 231 */
.long reboot /* exception vector: 232 */
.long reboot /* exception vector: 233 */
.long reboot /* exception vector: 234 */
.long reboot /* exception vector: 235 */
.long reboot /* exception vector: 236 */
.long reboot /* exception vector: 237 */
.long reboot /* exception vector: 238 */
.long reboot /* exception vector: 239 */
.long reboot /* exception vector: 240 */
.long reboot /* exception vector: 241 */
.long reboot /* exception vector: 242 */
.long reboot /* exception vector: 243 */
.long reboot /* exception vector: 244 */
.long reboot /* exception vector: 245 */
.long reboot /* exception vector: 246 */
.long reboot /* exception vector: 247 */
.long reboot /* exception vector: 248 */
.long reboot /* exception vector: 249 */
.long reboot /* exception vector: 250 */
.long reboot /* exception vector: 251 */
.long reboot /* exception vector: 252 */
.long reboot /* exception vector: 253 */
.long reboot /* exception vector: 254 */
.long reboot /* exception vector: 255 */
_reboot:
move #0x2700,%sr /* mask interrupts */
movea.l (0x0).w,%a7 /* load stack */
movea.l (0x4).w,%a0 /* jmp to location of reset vector */
jmp (%a0)
reboot:
trap #15 /* use trap exception to enter supervisor
state. Trace mode ( and other group 0
and 1 exceptions) *could* screw this up if
not vectored to reboot or did not return. */

View File

@@ -5,20 +5,26 @@ OUTPUT_ARCH(m68k)
__DYNAMIC = 0;
/*
* The memory map looks like this:
* ROM:
* +--------------------+ <- low memory
* | .text |
* | etext |
* | ctor list | the ctor and dtor lists are for
* | dtor list | C++ support
* | _endtext |
* +--------------------+
* | temporary .data | .data is moved to RAM by crt0
* | |
* +--------------------+ <- high memory
*
*
* RAM:
* +--------------------+ <- low memory
* | .data | initialized data goes here
* | _sdata |
* | _edata |
* +--------------------+
* | .bss |
* | _clear_start| start of bss, cleared by crt0
* | __bss_start | start of bss, cleared by crt0
* | _end | start of heap, used by sbrk()
* +--------------------+
* | heap space |
@@ -31,150 +37,170 @@ __DYNAMIC = 0;
/*
* Declare some sizes.
*/
RamBase = DEFINED(RamBase) ? RamBase : 0x10000;
RamSize = DEFINED(RamSize) ? RamSize : 0x70000;
RomBase = DEFINED(RomBase) ? RomBase : 0x90000;
RamBase = DEFINED(RamBase) ? RamBase : 0x03000;
RamSize = DEFINED(RamSize) ? RamSize : 0x7d000;
_RamEnd = RamBase + RamSize;
HeapSize = DEFINED(HeapSize) ? HeapSize : 0x0;
_StackSize = DEFINED(_StackSize) ? _StackSize : 0x2000;
MEMORY
{
ram : ORIGIN = 0x10000, LENGTH = 0x70000
rom : ORIGIN = 0x90000, LENGTH = 0x70000
ram : ORIGIN = 0x03000, LENGTH = 0x7d000
}
_copy_data_from_rom = 0;
_copy_data_from_rom = 1;
HeapSize = DEFINED(HeapSize) ? HeapSize : 0x0;
_StackSize = DEFINED(_StackSize) ? _StackSize : 0x2000;
/*
* stick everything in ram (of course)
*
*/
SECTIONS
{
ram : {
. = .;
} >ram
.text :
{
. = .;
text_start = .;
_text_start = .;
*(.text*)
. = ALIGN (16);
/*
* Text, data and bss segments
*/
.text : {
*(.text*)
/*
* C++ constructors/destructors
*/
*(.gnu.linkonce.t.*)
/*
* C++ constructors/destructors
*/
*(.gnu.linkonce.t.*)
/*
* Initialization and finalization code.
*
* Various files can provide initialization and finalization
* functions. crtbegin.o and crtend.o are two instances. The
* body of these functions are in .init and .fini sections. We
* accumulate the bodies here, and prepend function prologues
* from crti.o and function epilogues from crtn.o. crti.o must
* be linked first; crtn.o must be linked last. Because these
* are wildcards, it doesn't matter if the user does not
* actually link against crti.o and crtn.o; the linker won't
* look for a file to match a wildcard. The wildcard also
* means that it doesn't matter which directory crti.o and
* crtn.o are in.
*/
PROVIDE (_init = .);
*crti.o(.init)
*(.init)
*crtn.o(.init)
PROVIDE (_fini = .);
*crti.o(.fini)
*(.fini)
*crtn.o(.fini)
/*
* Initialization and finalization code.
*
* Various files can provide initialization and finalization
* functions. crtbegin.o and crtend.o are two instances. The
* body of these functions are in .init and .fini sections. We
* accumulate the bodies here, and prepend function prologues
* from crti.o and function epilogues from crtn.o. crti.o must
* be linked first; crtn.o must be linked last. Because these
* are wildcards, it doesn't matter if the user does not
* actually link against crti.o and crtn.o; the linker won't
* look for a file to match a wildcard. The wildcard also
* means that it doesn't matter which directory crti.o and
* crtn.o are in.
*/
PROVIDE (_init = .);
*crti.o(.init)
*(.init)
*crtn.o(.init)
PROVIDE (_fini = .);
*crti.o(.fini)
*(.fini)
*crtn.o(.fini)
/*
* Special FreeBSD sysctl sections.
*/
. = ALIGN (16);
__start_set_sysctl_set = .;
*(set_sysctl_*);
__stop_set_sysctl_set = ABSOLUTE(.);
*(set_domain_*);
*(set_pseudo_*);
/*
* Special FreeBSD sysctl sections.
*/
. = ALIGN (16);
__start_set_sysctl_set = .;
*(set_sysctl_*);
__stop_set_sysctl_set = ABSOLUTE(.);
*(set_domain_*);
*(set_pseudo_*);
/*
* C++ constructors/destructors
*
* gcc uses crtbegin.o to find the start of the constructors
* and destructors 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. The
* constructor and destructor list are terminated in
* crtend.o. The same comments apply to it.
*/
. = ALIGN (16);
*crtbegin.o(.ctors)
*(.ctors)
*crtend.o(.ctors)
*crtbegin.o(.dtors)
*(.dtors)
*crtend.o(.dtors)
/*
* C++ constructors/destructors
*
* gcc uses crtbegin.o to find the start of the constructors
* and destructors 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. The
* constructor and destructor list are terminated in
* crtend.o. The same comments apply to it.
*/
. = ALIGN (16);
*crtbegin.o(.ctors)
*(.ctors)
*crtend.o(.ctors)
*crtbegin.o(.dtors)
*(.dtors)
*crtend.o(.dtors)
/*
* Exception frame info
*/
. = ALIGN (16);
*(.eh_frame)
/*
* Exception frame info
*/
. = ALIGN (16);
*(.eh_frame)
/*
* Read-only data
*/
. = ALIGN (16);
_rodata_start = . ;
*(.rodata*)
*(.gnu.linkonce.r*)
/*
* Read-only data
*/
. = ALIGN (16);
_rodata_start = .;
*(.rodata*)
*(.gnu.linkonce.r*)
. = ALIGN (16);
PROVIDE (_etext = .);
_endtext = .;
__data_start_rom = .;
} > rom
.tdata : {
_TLS_Data_begin = .;
*(.tdata .tdata.* .gnu.linkonce.td.*)
_TLS_Data_end = .;
} > rom
.tbss : {
_TLS_BSS_begin = .;
*(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon)
_TLS_BSS_end = .;
} > rom
_TLS_Data_size = _TLS_Data_end - _TLS_Data_begin;
_TLS_BSS_size = _TLS_BSS_end - _TLS_BSS_begin;
_TLS_Size = _TLS_BSS_end - _TLS_Data_begin;
_TLS_Alignment = ALIGNOF (.tdata);
.gcc_exc :
AT ( ADDR(.tdata) + SIZEOF( .tdata ) )
{
*(.gcc_exc)
} > ram
.data : AT(__data_start_rom)
{
PROVIDE (_copy_start = .);
*(.data*)
*(.gnu.linkonce.d*)
*(.gcc_except_table*)
*(.jcr)
. = ALIGN (16);
PROVIDE (_edata = .);
PROVIDE (_copy_end = .);
} > ram
.shbss :
{
*(.shbss)
} > ram
.bss :
{
M68Kvec = .;
. += (256 * 4);
_clear_start = .;
*(.dynbss)
*(.bss* .gnu.linkonce.b.*)
*(COMMON)
. = ALIGN (16);
PROVIDE (end = .);
. += _StackSize;
. = ALIGN (16);
_stack_init = .;
_clear_end = .;
. = ALIGN (16);
PROVIDE (_etext = .);
} >ram
.tdata : {
_TLS_Data_begin = .;
*(.tdata .tdata.* .gnu.linkonce.td.*)
_TLS_Data_end = .;
} >ram
.tbss : {
_TLS_BSS_begin = .;
*(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon)
_TLS_BSS_end = .;
} >ram
_TLS_Data_size = _TLS_Data_end - _TLS_Data_begin;
_TLS_BSS_size = _TLS_BSS_end - _TLS_BSS_begin;
_TLS_Size = _TLS_BSS_end - _TLS_Data_begin;
_TLS_Alignment = ALIGNOF (.tdata);
.data : {
PROVIDE (_copy_start = .);
*(.data*)
*(.gnu.linkonce.d*)
*(.gcc_except_table*)
*(.jcr)
. = ALIGN (16);
PROVIDE (_edata = .);
PROVIDE (_copy_end = .);
} >ram
.bss : {
_clear_start = .;
*(.dynbss)
*(.bss* .gnu.linkonce.b.*)
*(COMMON)
. = ALIGN (16);
PROVIDE (end = .);
. += _StackSize;
. = ALIGN (16);
_stack_init = .;
_clear_end = .;
WorkAreaBase = .;
} >ram
WorkAreaBase = .;
} > ram
.stab . (NOLOAD) :
{
[ .stab ]
}
.stabstr . (NOLOAD) :
{
[ .stabstr ]
}
}

View File

@@ -1,212 +0,0 @@
/* linkcmds
*/
OUTPUT_ARCH(m68k)
STARTUP(except_vect_332_ROM.o)
__DYNAMIC = 0;
/*
* ROM:
* +--------------------+ <- low memory
* | .text |
* | etext |
* | ctor list | the ctor and dtor lists are for
* | dtor list | C++ support
* | _endtext |
* | temporary .data | .data is moved to RAM by crt0
* | |
* +--------------------+ <- high memory
*
*
* RAM:
* +--------------------+ <- low memory
* | .data | initialized data goes here
* | _sdata |
* | _edata |
* +--------------------+
* | .bss |
* | __bss_start | start of bss, cleared by crt0
* | _end | start of heap, used by sbrk()
* +--------------------+
* | heap space |
* | _ENDHEAP |
* | stack space |
* | __stack | top of stack
* +--------------------+ <- high memory
*/
MEMORY
{
rom : ORIGIN = 0x90000, LENGTH = 0x70000
ram : ORIGIN = 0x03000, LENGTH = 0x7d000
}
RamBase = DEFINED(RamBase) ? RamBase : 0x003000;
RamSize = DEFINED(RamSize) ? RamSize : 0x7d000;
_RamEnd = RamBase + RamSize;
__end_of_ram = 0x080000;
_copy_data_from_rom = 1;
HeapSize = DEFINED(HeapSize) ? HeapSize : 0x0;
_StackSize = DEFINED(_StackSize) ? _StackSize : 0x2000;
/*
*
*/
SECTIONS
{
.text :
{
. = .;
CREATE_OBJECT_SYMBOLS
text_start = .;
_text_start = .;
*(.text*)
. = ALIGN (16);
/*
* Initialization and finalization code.
*
* Various files can provide initialization and finalization
* functions. crtbegin.o and crtend.o are two instances. The
* body of these functions are in .init and .fini sections. We
* accumulate the bodies here, and prepend function prologues
* from crti.o and function epilogues from crtn.o. crti.o must
* be linked first; crtn.o must be linked last. Because these
* are wildcards, it doesn't matter if the user does not
* actually link against crti.o and crtn.o; the linker won't
* look for a file to match a wildcard. The wildcard also
* means that it doesn't matter which directory crti.o and
* crtn.o are in.
*/
PROVIDE (_init = .);
*crti.o(.init)
*(.init)
*crtn.o(.init)
PROVIDE (_fini = .);
*crti.o(.fini)
*(.fini)
*crtn.o(.fini)
/*
* Special FreeBSD sysctl sections.
*/
. = ALIGN (16);
__start_set_sysctl_set = .;
*(set_sysctl_*);
__stop_set_sysctl_set = ABSOLUTE(.);
*(set_domain_*);
*(set_pseudo_*);
/*
* C++ constructors/destructors
*
* gcc uses crtbegin.o to find the start of the constructors
* and destructors 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. The
* constructor and destructor list are terminated in
* crtend.o. The same comments apply to it.
*/
. = ALIGN (16);
*crtbegin.o(.ctors)
*(.ctors)
*crtend.o(.ctors)
*crtbegin.o(.dtors)
*(.dtors)
*crtend.o(.dtors)
*(.eh_frame)
. = ALIGN (16);
/*
* Read-only data
*/
. = ALIGN (16);
_rodata_start = . ;
*(.rodata*)
*(.gnu.linkonce.r*)
etext = ALIGN(0x10);
__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__ = .;
*(.lit)
*(.shdata)
_etext = .;
_endtext = .;
} > rom
.tdata : {
_TLS_Data_begin = .;
*(.tdata .tdata.* .gnu.linkonce.td.*)
_TLS_Data_end = .;
} > rom
.tbss : {
_TLS_BSS_begin = .;
*(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon)
_TLS_BSS_end = .;
} > rom
_TLS_Data_size = _TLS_Data_end - _TLS_Data_begin;
_TLS_BSS_size = _TLS_BSS_end - _TLS_BSS_begin;
_TLS_Size = _TLS_BSS_end - _TLS_Data_begin;
_TLS_Alignment = ALIGNOF (.tdata);
.gcc_exc :
AT ( ADDR(.tdata) + SIZEOF( .tdata ) )
{
*(.gcc_exc)
} > ram
.data :
{
data_start = .;
_data_start = .;
_copy_start = .;
_sdata = . ;
*(.data)
*(.gnu.linkonce.d*)
*(.gcc_except_table*)
*(.jcr)
CONSTRUCTORS
edata = ALIGN(0x10);
_edata = .;
} > ram
.shbss :
{
*(.shbss)
} > ram
.bss :
{
__bss_start = ALIGN(0x8);
bss_start = .;
_bss_start = .;
_clear_start = .;
*(.shbss)
*(.dynbss)
*(.bss* .gnu.linkonce.b.*)
*(COMMON)
. = ALIGN (16);
end = .;
_end = ALIGN(0x8);
__end = ALIGN(0x8);
WorkAreaBase = . + _StackSize;
} > ram
.stab . (NOLOAD) :
{
[ .stab ]
}
.stabstr . (NOLOAD) :
{
[ .stabstr ]
}
}

View File

@@ -14,14 +14,11 @@
*
*/
#include <bsp.h>
#include <bsp/bootcard.h>
#include <mrm332.h>
#include <rtems/m68k/sim.h>
#define __START_C__
#include "bsp.h"
#include <bsp/bootcard.h>
rtems_isr_entry M68Kvec[256];
rtems_isr_entry vectors[256];
/*
* This prototype really should have the noreturn attribute but
@@ -32,99 +29,97 @@ void start_c(void);
void start_c(void) {
/* Synthesizer Control Register */
/* see section(s) 4.8 */
/* end include in ram_init.S */
*SYNCR = (unsigned short int)
( SAM(MRM_W,15,VCO) | SAM(0x0,14,PRESCALE) | SAM(MRM_Y,8,COUNTER) );
while (! (*SYNCR & SLOCK)); /* protect from clock overshoot */
/* include in ram_init.S */
*SYNCR = (unsigned short int)
( SAM(MRM_W,15,VCO) | SAM(MRM_X,14,PRESCALE) | SAM(MRM_Y,8,COUNTER) );
#ifdef SET_EDIV
#define OPTIONAL_EDIV EDIV
#else
#define OPTIONAL_EDIV 0
#endif
/* System Protection Control Register */
/* !!! can only write to once after reset !!! */
/* see section 3.8.4 of the SIM Reference Manual */
*SYPCR = (unsigned char)( HME | BME );
/* Synthesizer Control Register */
/* see section(s) 4.8 */
/* end include in ram_init.S */
*SYNCR = (unsigned short int) (SAM(MRM_W, 15, VCO) | SAM(0x0, 14, PRESCALE)
| SAM(MRM_Y, 8, COUNTER) | OPTIONAL_EDIV);
while (!(*SYNCR & SLOCK))
; /* protect from clock overshoot */
/* include in ram_init.S */
*SYNCR = (unsigned short int) (SAM(MRM_W, 15, VCO) | SAM(MRM_X, 14,
PRESCALE) | SAM(MRM_Y, 8, COUNTER) | OPTIONAL_EDIV);
/* Periodic Interrupr Control Register */
/* see section 3.8.2 of the SIM Reference Manual */
*PICR = (unsigned short int)
( SAM(0,8,PIRQL) | SAM(MRM_PIV,0,PIV) );
/* ^^^ zero disables interrupt, don't enable here or ram_init will
/* System Protection Control Register */
/* !!! can only write to once after reset !!! */
/* see section 3.8.4 of the SIM Reference Manual */
*SYPCR = (unsigned char) (HME | BME);
/* Periodic Interrupr Control Register */
/* see section 3.8.2 of the SIM Reference Manual */
*PICR = (unsigned short int) (SAM(0, 8, PIRQL) | SAM(MRM_PIV, 0, PIV));
/* ^^^ zero disables interrupt, don't enable here or ram_init will
be wrong. It's enabled below. */
/* Periodic Interrupt Timer Register */
/* see section 3.8.3 of the SIM Reference Manual */
*PITR = (unsigned short int)( SAM(0x09,0,PITM) );
/* 1.098mS interrupt, assuming 32.768 KHz input clock */
/* Periodic Interrupt Timer Register */
/* see section 3.8.3 of the SIM Reference Manual */
*PITR = (unsigned short int) (SAM(0x09, 0, PITM));
/* 1.098mS interrupt, assuming 32.768 KHz input clock */
/* Port C Data */
/* load values before enabled */
*PORTC = (unsigned char) 0x0;
/* Port C Data */
/* load values before enabled */
*PORTC = (unsigned char) 0x0;
/* Port E and F Data Register */
/* see section 9 of the SIM Reference Manual */
*PORTE0 = (unsigned char) 0;
*PORTF0 = (unsigned char) 0;
/* Port E and F Data Register */
/* see section 9 of the SIM Reference Manual */
*PORTE0 = (unsigned char) 0;
*PORTF0 = (unsigned char) 0;
/* Port E and F Data Direction Register */
/* see section 9 of the SIM Reference Manual */
*DDRE = (unsigned char) 0xff;
*DDRF = (unsigned char) 0xfd;
/* Port E and F Data Direction Register */
/* see section 9 of the SIM Reference Manual */
*DDRE = (unsigned char) 0xff;
*DDRF = (unsigned char) 0xfd;
/* Port E and F Pin Assignment Register */
/* see section 9 of the SIM Reference Manual */
*PEPAR = (unsigned char) 0;
*PFPAR = (unsigned char) 0;
/* Port E and F Pin Assignment Register. Set up Port E and F as I/O */
/* see section 9 of the SIM Reference Manual */
*PEPAR = (unsigned char) 0;
*PFPAR = (unsigned char) 0;
/* end of SIM initalization code */
/* end include in ram_init.S */
/* end of SIM initalization code */
/* end include in ram_init.S */
/*
* Initialize RAM by copying the .data section out of ROM (if
* needed) and "zero-ing" the .bss section.
*/
{
register char *src = _etext;
register char *dst = _copy_start;
/*
* Initialize RAM by copying the .data section out of ROM (if
* needed) and "zero-ing" the .bss section.
*/
{
register char *src = _etext;
register char *dst = _copy_start;
if (_copy_data_from_rom)
/* ROM has data at end of text; copy it. */
while (dst < _edata)
*dst++ = *src++;
if (_copy_data_from_rom) {
/* ROM has data at end of text; copy it. */
while (dst < _edata)
*dst++ = *src++;
}
/* Zero bss */
for (dst = _clear_start; dst < end; dst++) {
*dst = 0;
}
}
/* Zero bss */
for (dst = _clear_start; dst< end; dst++)
{
*dst = 0;
}
}
/*
* Initialize vector table.
*/
{
rtems_isr_entry *monitors_vector_table;
/*
* Initialize vector table.
*/
{
rtems_isr_entry *monitors_vector_table;
m68k_get_vbr(monitors_vector_table);
m68k_get_vbr(monitors_vector_table);
M68Kvec[4] = monitors_vector_table[4]; /* breakpoints vector */
M68Kvec[9] = monitors_vector_table[9]; /* trace vector */
M68Kvec[31] = monitors_vector_table[31]; /* level 7 interrupt */
M68Kvec[47] = monitors_vector_table[47]; /* system call vector */
M68Kvec[66] = monitors_vector_table[66]; /* user defined */
M68Kvec[ 4 ] = monitors_vector_table[ 4 ]; /* breakpoints vector */
M68Kvec[ 9 ] = monitors_vector_table[ 9 ]; /* trace vector */
M68Kvec[ 31 ] = monitors_vector_table[ 31 ]; /* level 7 interrupt */
M68Kvec[ 47 ] = monitors_vector_table[ 47 ]; /* system call vector */
M68Kvec[ 66 ] = monitors_vector_table[ 66 ]; /* user defined */
m68k_set_vbr(&M68Kvec);
}
m68k_set_vbr(&M68Kvec);
}
/*
* Initalize the board.
*/
/* Spurious should be called in the predriver hook */
/* Spurious_Initialize(); */
/*console_init(); */
/*
* Execute main with arguments argc and agrv.