From 99648958668d3a33ee57974479b36201fe303f34 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 20 Apr 2018 10:35:35 +0200 Subject: bsps: Move startup files to bsps Adjust build support files to new directory layout. This patch is a part of the BSP source reorganization. Update #3285. --- bsps/m68k/mrm332/start/bsp_specs | 9 ++ bsps/m68k/mrm332/start/linkcmds | 212 +++++++++++++++++++++++++++++++++++++++ bsps/m68k/mrm332/start/start_c.c | 130 ++++++++++++++++++++++++ 3 files changed, 351 insertions(+) create mode 100644 bsps/m68k/mrm332/start/bsp_specs create mode 100644 bsps/m68k/mrm332/start/linkcmds create mode 100644 bsps/m68k/mrm332/start/start_c.c (limited to 'bsps/m68k/mrm332') diff --git a/bsps/m68k/mrm332/start/bsp_specs b/bsps/m68k/mrm332/start/bsp_specs new file mode 100644 index 0000000000..87638cc027 --- /dev/null +++ b/bsps/m68k/mrm332/start/bsp_specs @@ -0,0 +1,9 @@ +%rename endfile old_endfile +%rename startfile old_startfile + +*startfile: +%{!qrtems: %(old_startfile)} \ +%{!nostdlib: %{qrtems: crti.o%s crtbegin.o%s}} + +*endfile: +%{!qrtems: %(old_endfile)} %{qrtems: crtend.o%s crtn.o%s} diff --git a/bsps/m68k/mrm332/start/linkcmds b/bsps/m68k/mrm332/start/linkcmds new file mode 100644 index 0000000000..1ee7117d6b --- /dev/null +++ b/bsps/m68k/mrm332/start/linkcmds @@ -0,0 +1,212 @@ +/* linkcmds + */ + +OUTPUT_ARCH(m68k) +ENTRY(start) +STARTUP(start.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 + */ + +/* + * Declare some sizes. + */ +RomBase = DEFINED(RomBase) ? RomBase : 0x90000; +RamBase = DEFINED(RamBase) ? RamBase : 0x03000; +RamSize = DEFINED(RamSize) ? RamSize : 0x7d000; +_RamEnd = RamBase + RamSize; + +MEMORY +{ + rom : ORIGIN = 0x90000, LENGTH = 0x70000 + ram : ORIGIN = 0x03000, LENGTH = 0x7d000 +} + +_copy_data_from_rom = 1; +HeapSize = DEFINED(HeapSize) ? HeapSize : 0x0; +_StackSize = DEFINED(_StackSize) ? _StackSize : 0x2000; + + +/* + * + */ +SECTIONS +{ + .text : + { + . = .; + text_start = .; + _text_start = .; + *(.text*) + . = ALIGN (16); + + /* + * 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) + + /* + * 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) + + /* + * Exception frame info + */ + . = ALIGN (16); + *(.eh_frame) + + /* + * Read-only data + */ + . = ALIGN (16); + _rodata_start = . ; + *(.rodata*) + KEEP (*(SORT(.rtemsroset.*))) + *(.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_Data_begin = _TLS_Data_size != 0 ? _TLS_Data_begin : _TLS_BSS_begin; + _TLS_Data_end = _TLS_Data_size != 0 ? _TLS_Data_end : _TLS_BSS_begin; + _TLS_BSS_size = _TLS_BSS_end - _TLS_BSS_begin; + _TLS_Size = _TLS_BSS_end - _TLS_Data_begin; + _TLS_Alignment = MAX (ALIGNOF (.tdata), ALIGNOF (.tbss)); + .gcc_exc : + AT ( ADDR(.tdata) + SIZEOF( .tdata ) ) + { + *(.gcc_exc) + } > ram + .data : AT(__data_start_rom) + { + PROVIDE (_copy_start = .); + *(.data*) + KEEP (*(SORT(.rtemsrwset.*))) + *(.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 = .; + + WorkAreaBase = .; + } > ram + .stab . (NOLOAD) : + { + [ .stab ] + } + .stabstr . (NOLOAD) : + { + [ .stabstr ] + } +} diff --git a/bsps/m68k/mrm332/start/start_c.c b/bsps/m68k/mrm332/start/start_c.c new file mode 100644 index 0000000000..060c96b004 --- /dev/null +++ b/bsps/m68k/mrm332/start/start_c.c @@ -0,0 +1,130 @@ +/** + * @file + * + * MRM332 C Start Up Code + */ + +/* + * COPYRIGHT (c) 2000. + * Matt Cross + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + */ + +#include +#include +#include +#include +#define __START_C__ + +/* + * This prototype really should have the noreturn attribute but + * that causes a warning. Not sure how to fix that. + */ +/* void dumby_start () __attribute__ ((noreturn)); */ +void start_c(void); + +void start_c(void) { + +#ifdef SET_EDIV +#define OPTIONAL_EDIV EDIV +#else +#define OPTIONAL_EDIV 0 +#endif + + /* 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); + + /* 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. 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 */ + + /* + * 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); + } + + + /* + * Execute main with arguments argc and agrv. + */ + boot_card((void*)0); + reboot(); + +} -- cgit v1.2.3