summaryrefslogtreecommitdiffstats
path: root/bsps/mips/malta
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-04-20 10:35:35 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-04-20 13:52:14 +0200
commit99648958668d3a33ee57974479b36201fe303f34 (patch)
tree6f27ea790e2823c6156e71219a4f54680263fac6 /bsps/mips/malta
parentbsps: Move start files to bsps (diff)
downloadrtems-99648958668d3a33ee57974479b36201fe303f34.tar.bz2
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.
Diffstat (limited to 'bsps/mips/malta')
-rw-r--r--bsps/mips/malta/start/bsp_specs9
-rw-r--r--bsps/mips/malta/start/bspreset.c34
-rw-r--r--bsps/mips/malta/start/bspstart.c113
-rw-r--r--bsps/mips/malta/start/inittlb.c27
-rw-r--r--bsps/mips/malta/start/linkcmds213
-rw-r--r--bsps/mips/malta/start/simple_access.c133
6 files changed, 529 insertions, 0 deletions
diff --git a/bsps/mips/malta/start/bsp_specs b/bsps/mips/malta/start/bsp_specs
new file mode 100644
index 0000000000..87638cc027
--- /dev/null
+++ b/bsps/mips/malta/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/mips/malta/start/bspreset.c b/bsps/mips/malta/start/bspreset.c
new file mode 100644
index 0000000000..6d406ea943
--- /dev/null
+++ b/bsps/mips/malta/start/bspreset.c
@@ -0,0 +1,34 @@
+/**
+ * @file
+ *
+ * This file contains the code necessary to reset the Malta board.
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2012.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * 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 <rtems.h>
+#include <bsp/bootcard.h>
+
+void bsp_reset(void)
+{
+ uint32_t *reset;
+
+ reset= (uint32_t *)0x9F000500;
+ /*
+ * Qemu understands 0x42 to reset simulated machine.
+ * We added code to recognize 0xFF to exit simulator.
+ *
+ * TBD: Qemu PC simulation has option to exit on reset.
+ * find processing of that command line option and
+ * use it to change behaviour of 0x42.
+ */
+ // *reset = 0x42;
+ *reset = 0xFF;
+}
diff --git a/bsps/mips/malta/start/bspstart.c b/bsps/mips/malta/start/bspstart.c
new file mode 100644
index 0000000000..58eee11027
--- /dev/null
+++ b/bsps/mips/malta/start/bspstart.c
@@ -0,0 +1,113 @@
+/**
+ * @file
+ *
+ * This file contains the bsp_start() method and support.
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2012.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * 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 <bsp.h>
+#include <libcpu/isr_entries.h>
+#include <bsp/bootcard.h>
+#include <rtems/pci.h>
+#include <bsp/irq-generic.h>
+#include <bsp/i8259.h>
+
+/*
+ * STRUCTURES
+ */
+
+/* Structure filled in by get_mem_info. Only the size field is
+ * actually used (to clear bss), so the others aren't even filled in.
+ */
+struct s_mem
+{
+ unsigned int size;
+ unsigned int icsize;
+ unsigned int dcsize;
+};
+
+
+/*
+ * GLOBALS
+ */
+uint32_t bsp_clicks_per_microsecond;
+
+
+/*
+ * PROTOTYPES
+ */
+void clear_cache( void *address, size_t n );
+void get_mem_info( struct s_mem *mem );
+
+/*
+ * EXTERNs
+ */
+extern int RamSize;
+
+/*
+ * bsp_start
+ *
+ * This routine does the bulk of the system initialization.
+ */
+void bsp_start( void )
+{
+ /* uint32_t board_ID = 0x420; */
+ static int j = 1;
+ int pci_init_retval;
+
+ /*
+ * Note: This is the value that works for qemu, and it was
+ * unable to be validated on the actual hardware.
+ */
+ mips_set_sr( 0x04100000 );
+
+ bsp_interrupt_initialize();
+
+ /*
+ * XXX need to figure out a real value. :)
+ * This works for the qemu simulation, but timeing may
+ * be off for the actual hardware.
+ */
+ bsp_clicks_per_microsecond = 100;
+
+ #if 1
+ while ( j != 1 ) {
+ int i;
+ printk (".");
+ for (i=0; i<1000; i++);
+ }
+ #endif
+
+ /*
+ * init PCI Bios interface...
+ */
+ pci_init_retval = pci_initialize();
+ if (pci_init_retval != PCIB_ERR_SUCCESS) {
+ printk("PCI bus: could not initialize PCI BIOS interface\n");
+ }
+
+ BSP_i8259s_init();
+
+}
+
+/*
+ * Required routine by some gcc run-times.
+ */
+void clear_cache( void *address, size_t n )
+{
+}
+
+void get_mem_info(
+ struct s_mem *mem
+)
+{
+ mem->size = (int) (&RamSize); /* Normally 128 or 256 MB */
+}
diff --git a/bsps/mips/malta/start/inittlb.c b/bsps/mips/malta/start/inittlb.c
new file mode 100644
index 0000000000..0088b98483
--- /dev/null
+++ b/bsps/mips/malta/start/inittlb.c
@@ -0,0 +1,27 @@
+/**
+ * @file
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2012.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * 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 <bsp.h>
+#include <rtems/mips/idtcpu.h>
+
+extern void resettlb( int i );
+
+void init_tlb(void);
+
+void init_tlb(void)
+{
+ int i;
+
+ for (i = 0; i < N_TLB_ENTRIES; i++ )
+ resettlb(i);
+}
diff --git a/bsps/mips/malta/start/linkcmds b/bsps/mips/malta/start/linkcmds
new file mode 100644
index 0000000000..3a71c5af8b
--- /dev/null
+++ b/bsps/mips/malta/start/linkcmds
@@ -0,0 +1,213 @@
+/*
+ * MIPS Malta Linker Script
+ */
+
+/*
+ * Declare some sizes.
+ */
+RamBase = DEFINED(RamBase) ? RamBase : 0x80000000;
+RamSize = DEFINED(RamSize) ? RamSize : 128M;
+HeapSize = DEFINED(HeapSize) ? HeapSize : 0x0;
+_StackSize = DEFINED(_StackSize) ? _StackSize : 0x2000;
+
+ENTRY(_start)
+STARTUP(start.o)
+
+SECTIONS
+{
+ . = 0x80010000;
+ .text :
+ {
+ _ftext = . ;
+ eprol = .;
+ *(.text*)
+ *(.gnu.linkonce.t*)
+ *(.mips16.fn.*)
+ *(.mips16.call.*)
+ PROVIDE (__runtime_reloc_start = .);
+ *(.rel.sdata)
+ PROVIDE (__runtime_reloc_stop = .);
+
+ *(.gcc_except_table*)
+ *(.eh_frame_hdr)
+ *(.eh_frame)
+ }
+
+ .init :
+ {
+ KEEP(*(.init))
+ }
+
+ .fini :
+ {
+ KEEP(*(.fini))
+ }
+
+ .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))
+ }
+
+ .dtors :
+ {
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*(.dtors))
+
+ etext = .;
+ _etext = .;
+ }
+
+ .rtemsroset : {
+ /* for pre rtems-libbsd FreeBSD code */
+ __start_set_sysctl_set = .;
+ *(set_sysctl_*);
+ __stop_set_sysctl_set = .;
+ *(set_domain_*);
+ *(set_pseudo_*);
+
+ KEEP (*(SORT(.rtemsroset.*)))
+
+ . = ALIGN (16);
+ _endtext = .;
+ }
+
+ .rdata : {
+ *(.rdata)
+ *(.rodata)
+ *(.rodata.*)
+ *(.gnu.linkonce.r*)
+ }
+
+ .tdata : {
+ _TLS_Data_begin = .;
+ *(.tdata .tdata.* .gnu.linkonce.td.*)
+ _TLS_Data_end = .;
+ }
+
+ .tbss : {
+ _TLS_BSS_begin = .;
+ *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon)
+ _TLS_BSS_end = .;
+ }
+
+ _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));
+
+ _fdata = ALIGN(16);
+
+ .data : {
+ *(.data)
+ *(.data.*)
+ *(.gnu.linkonce.d*)
+ SORT(CONSTRUCTORS)
+ }
+
+ .rtemsrwset : {
+ KEEP (*(SORT(.rtemsrwset.*)))
+ }
+
+ . = ALIGN(8);
+
+ .jcr : {
+ KEEP (*(.jcr))
+ }
+
+ _gp = ALIGN(16) + 0x7440;
+ __global = _gp;
+
+ .sdata : {
+ *(.sdata)
+ *(.sdata.*)
+ *(.gnu.linkonce.s*)
+ }
+ .lit8 : {
+ *(.lit8)
+ }
+ .lit4 : {
+ *(.lit4)
+ }
+
+ edata = .;
+ _edata = .;
+ _fbss = .;
+
+ .sbss : {
+ *(.sbss*)
+ *(.scommon)
+ }
+ .bss : {
+ _bss_start = . ;
+ *(.bss*)
+ *(COMMON)
+ . = ALIGN (64);
+ _stack_limit = .;
+ . += _StackSize;
+ __stack = .;
+ _stack_init = .;
+ WorkAreaBase = .;
+ _clear_end = .;
+ }
+ . = 0x88400000; /* reserve some memory for Work Area */
+ end = .;
+ _end = .;
+
+
+/* Put starting stack in SRAM (8 Kb); this size is the same as the stack from
+ the original script (when everything was in SRAM). */
+ /* __stack = 0x8000A000; */
+ /* 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) }
+}
diff --git a/bsps/mips/malta/start/simple_access.c b/bsps/mips/malta/start/simple_access.c
new file mode 100644
index 0000000000..cd15484b1c
--- /dev/null
+++ b/bsps/mips/malta/start/simple_access.c
@@ -0,0 +1,133 @@
+/**
+ * @file
+ *
+ * This file contains the code to do simple memory and io accesses.
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2012.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * 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 <rtems.h>
+#include <bsp.h>
+
+#include <bsp/pci.h>
+#include <bsp/irq.h>
+#include <rtems/bspIo.h>
+#include <rtems/endian.h>
+// #define DEBUG_ACCESSES 1
+
+#ifdef DEBUG_ACCESSES
+ #define JPRINTK(fmt, ...) printk("%s: " fmt, __FUNCTION__, ##__VA_ARGS__)
+#else
+ #define JPRINTK(fmt, ...)
+#endif
+
+/*
+ * * Simple accesses
+ * */
+void simple_out_32(uint32_t base, uint32_t addr, uint32_t val)
+{
+ volatile uint32_t *ptr;
+
+ ptr = (volatile uint32_t *) (base + addr);
+ *ptr = val;
+
+ JPRINTK( "%p data: 0x%x\n", ptr, val);
+}
+
+void simple_out_le32(uint32_t base, uint32_t addr, uint32_t val)
+{
+ volatile uint32_t *ptr;
+ uint32_t data = 0;
+
+ ptr = (volatile uint32_t *) (base + addr);
+ rtems_uint32_to_little_endian( val, (uint8_t *) &data);
+ *ptr = data;
+
+ JPRINTK( "%p data: 0x%x\n", ptr, data);
+}
+
+uint8_t simple_in_8( uint32_t base, uint32_t addr ) {
+ volatile uint8_t *ptr;
+ uint8_t val;
+
+ ptr = (volatile uint8_t *) (base + addr);
+ val = *ptr;
+ JPRINTK( "0x%x data: 0x%x\n", ptr, val);
+
+ return val;
+}
+
+int16_t simple_in_le16( uint32_t base, uint32_t addr ) {
+ volatile uint16_t *ptr;
+ uint16_t val;
+ uint16_t rval;
+
+ ptr = (volatile uint16_t *) (base + addr);
+ val = *ptr;
+ rval = rtems_uint16_from_little_endian( (uint8_t *) &val);
+ JPRINTK( "0x%x data: 0x%x raw: 0x%x\n", ptr, rval, val);
+ return rval;
+}
+
+int16_t simple_in_16( uint32_t base, uint32_t addr ) {
+ volatile uint16_t *ptr;
+ uint16_t val;
+
+ ptr = (volatile uint16_t *) (base + addr);
+ val = *ptr;
+ JPRINTK( "0x%x data: 0x%x raw: 0x%x\n", ptr, val, val);
+ return val;
+}
+
+uint32_t simple_in_le32( uint32_t base, uint32_t addr ) {
+ volatile uint32_t *ptr;
+ uint32_t val;
+ uint32_t rval;
+
+ ptr = (volatile uint32_t *) (base + addr);
+ val = *ptr;
+ rval = rtems_uint32_from_little_endian( (uint8_t *) &val);
+ JPRINTK( "0x%x data: 0x%x raw: 0x%x\n", ptr, rval, val);
+ return rval;
+}
+
+uint32_t simple_in_32( uint32_t base, uint32_t addr ) {
+ volatile uint32_t *ptr;
+ uint32_t val;
+
+ ptr = (volatile uint32_t *) (base + addr);
+ val = *ptr;
+ JPRINTK( "0x%x data: 0x%x raw: 0x%x\n", ptr, val, val);
+ return val;
+}
+
+void simple_out_8( uint32_t base, uint32_t addr, uint8_t val ) {
+ volatile uint8_t *ptr;
+
+ ptr = (volatile uint8_t *) (base | addr);
+ JPRINTK( "0x%x data: 0x%x\n", ptr, val);
+ *ptr = val;
+}
+
+void simple_out_le16( uint32_t base, uint32_t addr, uint16_t val ) {
+ volatile uint16_t *ptr;
+ uint16_t data;
+ ptr = (volatile uint16_t *) (base + addr);
+ rtems_uint16_to_little_endian( val, (uint8_t *) &data);
+ *ptr = data;
+ JPRINTK( "0x%x data: 0x%x\n", ptr, data);
+}
+
+void simple_out_16( uint32_t base, uint32_t addr, uint16_t val ) {
+ volatile uint16_t *ptr;
+ ptr = (volatile uint16_t *) (base + addr);
+ *ptr = val;
+ JPRINTK( "0x%x data: 0x%x\n", ptr, val);
+}