summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/i386/i386ex/startup
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1996-10-15 20:57:04 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1996-10-15 20:57:04 +0000
commit752cd8fb98f1c65b9f482bdbebeef0bd14d98856 (patch)
tree0defcc0e4f536c41e46d2d8e4dc5d34e25900cf4 /c/src/lib/libbsp/i386/i386ex/startup
parentpatches to erc32.h to correct handling of timer mirror from Jiri Gaisler. (diff)
downloadrtems-752cd8fb98f1c65b9f482bdbebeef0bd14d98856.tar.bz2
initial version from Erik
Diffstat (limited to 'c/src/lib/libbsp/i386/i386ex/startup')
-rw-r--r--c/src/lib/libbsp/i386/i386ex/startup/README25
-rw-r--r--c/src/lib/libbsp/i386/i386ex/startup/bspstart.c160
-rw-r--r--c/src/lib/libbsp/i386/i386ex/startup/linkcmds106
-rw-r--r--c/src/lib/libbsp/i386/i386ex/startup/setvec.c59
4 files changed, 350 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/i386/i386ex/startup/README b/c/src/lib/libbsp/i386/i386ex/startup/README
new file mode 100644
index 0000000000..44f8d1d63c
--- /dev/null
+++ b/c/src/lib/libbsp/i386/i386ex/startup/README
@@ -0,0 +1,25 @@
+
+
+ The doit shell file cd's to $H, which refers to the directory
+that contains the hello world test. The console is a raw com port.
+Certain test programs behave differently with different com port speeds.
+To test the programs, it is required that you hook up a terminal
+( or minicom or procomm it doesn't really matter ) to the comm port of
+the target hardware. You must ensure that the baud rate, parity etc
+is set properly. This is done on the target hardware within interns.s .
+( Set your terminal emulator to match. ) Currently, the settings
+are 9600,8,n,1 .
+
+The format and layout of the file interns.s is taken from the
+intel ApBuilder software, freely distributed by Intel. Some
+easy macros ( SetExRegByte and SetExRegWord ) are basically lifted
+from the Intel macros. Similarly for the names of the IO ports.
+
+This "port" begain with the forceCPU bsp. Hence I am sure that
+there is some real trash that is not appropriate. For example
+the act of copying the Interrupt Descriptor tables and Global
+descriptor tables "into our space". ( in start.s I think )
+
+Erik
+
+ \ No newline at end of file
diff --git a/c/src/lib/libbsp/i386/i386ex/startup/bspstart.c b/c/src/lib/libbsp/i386/i386ex/startup/bspstart.c
new file mode 100644
index 0000000000..c6e0947988
--- /dev/null
+++ b/c/src/lib/libbsp/i386/i386ex/startup/bspstart.c
@@ -0,0 +1,160 @@
+/* bsp_start()
+ *
+ * This routine starts the application. It includes application,
+ * board, and monitor specific initialization and configuration.
+ * The generic CPU dependent initialization has been performed
+ * before this routine is invoked.
+ *
+ * INPUT: NONE
+ *
+ * OUTPUT: NONE
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#include <rtems.h>
+#include <bsp.h>
+#include <libcsupport.h>
+
+#include <stackchk.h>
+
+#include <stdio.h>
+extern void outbyte(char);
+
+/*
+ * The original table from the application and our copy of it with
+ * some changes.
+ */
+
+extern rtems_configuration_table Configuration;
+rtems_configuration_table BSP_Configuration;
+
+rtems_cpu_table Cpu_table;
+
+/* Initialize whatever libc we are using
+ * called from postdriver hook
+ */
+
+void bsp_libc_init()
+{
+ extern int end;
+ rtems_unsigned32 heap_start;
+
+ heap_start = (rtems_unsigned32) &end;
+ if (heap_start & (CPU_ALIGNMENT-1))
+ heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
+
+ RTEMS_Malloc_Initialize((void *) heap_start, 64 * 1024, 0);
+
+ /*
+ * Set up for the libc handling.
+ */
+
+ if (BSP_Configuration.ticks_per_timeslice > 0)
+ libc_init(1); /* reentrant if possible */
+ else
+ libc_init(0); /* non-reentrant */
+
+ /*
+ * Initialize the stack bounds checker
+ */
+
+#ifdef STACK_CHECKER_ON
+ Stack_check_Initialize();
+#endif
+
+}
+extern char inbyte(void);
+extern void outbyte(char);
+
+int bsp_start(
+ int argc,
+ char **argv,
+ char **environp
+)
+{
+#ifdef PRINTON
+
+ outbyte('a');
+ outbyte('b');
+ outbyte('c');
+ outbyte ('S');
+
+#endif
+
+ /*
+ * we do not use the pretasking_hook.
+ */
+
+ Cpu_table.pretasking_hook = NULL;
+
+ Cpu_table.predriver_hook = bsp_libc_init; /* RTEMS resources available */
+
+ Cpu_table.postdriver_hook = NULL; /* Call our main() for constructors */
+
+ Cpu_table.idle_task = NULL; /* do not override system IDLE task */
+
+ Cpu_table.do_zero_of_workspace = TRUE;
+
+ Cpu_table.interrupt_table_segment = get_ds();
+
+ Cpu_table.interrupt_table_offset = (void *)Interrupt_descriptor_table;
+
+ Cpu_table.interrupt_stack_size = 4096;
+
+ Cpu_table.extra_system_initialization_stack = 0;
+
+ /*
+ * Copy the table
+ */
+
+ BSP_Configuration = Configuration;
+
+ BSP_Configuration.work_space_start = (void *)
+ RAM_END - BSP_Configuration.work_space_size;
+
+
+
+#ifdef SPRINTON
+ sprintf( x_buffer, "ram end : %u, work_space_size: %d\n",
+ RAM_END , BSP_Configuration.work_space_size );
+ do {
+ outbyte ( x_buffer[i] );
+ } while ( x_buffer[i++] != '\n');
+#endif
+
+ /*
+ * Add 1 region for Malloc in libc_low
+ */
+
+ BSP_Configuration.maximum_regions++;
+
+ /*
+ * Add 1 extension for newlib libc
+ */
+
+#ifdef RTEMS_NEWLIB
+ BSP_Configuration.maximum_extensions++;
+#endif
+
+ /*
+ * Add another extension if using the stack checker
+ */
+
+#ifdef STACK_CHECKER_ON
+ BSP_Configuration.maximum_extensions++;
+#endif
+
+ rtems_initialize_executive( &BSP_Configuration, &Cpu_table );
+ /* does not return */
+ /* no cleanup necessary for Force CPU-386 */
+ for (;;); /* was return 0 to go to the debug monitor */
+}
diff --git a/c/src/lib/libbsp/i386/i386ex/startup/linkcmds b/c/src/lib/libbsp/i386/i386ex/startup/linkcmds
new file mode 100644
index 0000000000..d8fe66f8bf
--- /dev/null
+++ b/c/src/lib/libbsp/i386/i386ex/startup/linkcmds
@@ -0,0 +1,106 @@
+/*
+ * This file contains directives for the GNU linker which are specific
+ * to the Intel 386ex evaluation board.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * linkcmds,v 1.0 1995/11/30 16:52:02 Erik Ivanenko
+ */
+
+
+ ENTRY(reset) ;
+SECTIONS
+{
+ _rom_ints = 0x3fb0000;
+ .ints 0x0100 :
+ AT ( _rom_ints ) /* was 0x3fb3300 */
+ {
+ _sints = .;
+ *(.ints);
+ _eints = ALIGN (0x010);
+ }
+ _cs4_ints_segment = 0x0010 ;
+ _cs4_ints_offset = 0x0000 ;
+ _cs6_t_ints_segment = 0xF000 ; /* was 0xF000 */
+ _cs6_t_ints_offset = 0x0000 ; /* was 0x3300 */
+ _cs6_t_ints_size = _eints - _sints ;
+
+ _rom_gdt = _rom_ints + _cs6_t_ints_size;
+ .gdt 0x1000 :
+ AT ( _rom_gdt )
+ {
+ _sgdt = .;
+ *(.gdt);
+ _egdt = ALIGN (0x10);
+ }
+ _cs4_gdt_segment = 0x0100 ; /* evaluates to 0x1000 */
+ _cs4_gdt_offset = 0x0000 ;
+ _cs6_t_gdt_segment = 0xF000;
+ _cs6_t_gdt_offset = _cs6_t_ints_size; /* was 0x0 */
+ _cs6_t_gdt_size = _egdt - _sgdt;
+
+ _rom_idt = _rom_gdt + _cs6_t_gdt_size + _cs6_t_ints_size ;
+ .idt 0x1200 :
+ AT ( _rom_idt )
+ {
+ _sidt = .;
+ *(.idt);
+ _eidt = ALIGN (0x10);
+ }
+ _cs4_idt_segment = 0x0120;
+ _cs4_idt_offset = 0x0000 ;
+ _cs6_t_idt_segment = 0xF000 ;
+ _cs6_t_idt_offset = _cs6_t_ints_size + _cs6_t_gdt_size ; /* was 0x1000 */
+ _cs6_t_idt_size = _eidt - _sidt;
+
+ _rom_data_start = _rom_idt + _cs6_t_idt_size ;
+ .data :
+ AT ( _rom_data_start ) /* was 0x3fd0000 */
+ {
+ _sdata = .;
+ *(.data);
+ _edata = ALIGN( 0x10 ) ;
+ }
+ _data_start = ADDR(.data) ;
+ _data_size = _edata - _sdata ;
+ _edata = _data_start + _data_size ;
+
+ .bss :
+ {
+ _bss_start = .;
+ *(.bss);
+ *(COMMON);
+ _ebss = ALIGN(0x10);
+ end = _ebss;
+ _end = end;
+ __end = end;
+ }
+ _bss_size = _ebss - _bss_start ;
+
+
+ .text ( 0x3f80000 ):
+ {
+ _text_start = . ;
+ *(.text ) ;
+ _etext = ALIGN( 0x10 );
+ }
+
+ .initial 0x3ff1000:
+ {
+ *(.initial);
+ }
+
+ .reset 0x3fffff0:
+ {
+ *(.reset);
+ }
+}
+
+
+
diff --git a/c/src/lib/libbsp/i386/i386ex/startup/setvec.c b/c/src/lib/libbsp/i386/i386ex/startup/setvec.c
new file mode 100644
index 0000000000..e8195c0733
--- /dev/null
+++ b/c/src/lib/libbsp/i386/i386ex/startup/setvec.c
@@ -0,0 +1,59 @@
+/* set_vector
+ *
+ * This routine installs an interrupt vector on the Force CPU-386.
+ *
+ * INPUT:
+ * handler - interrupt handler entry point
+ * vector - vector number
+ * type - 0 indicates raw hardware connect
+ * 1 indicates RTEMS interrupt connect
+ *
+ * RETURNS:
+ * address of previous interrupt handler
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#include <rtems.h>
+#include <bsp.h>
+
+i386_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 */
+)
+{
+ i386_isr_entry previous_isr;
+ i386_IDT_slot idt;
+
+ if ( type )
+ rtems_interrupt_catch( handler, vector, (rtems_isr_entry *) &previous_isr );
+ else {
+ /* get the address of the old handler */
+
+ idt = Interrupt_descriptor_table[ vector ];
+
+ previous_isr = (i386_isr_entry)
+ ((idt.offset_16_31 << 16) | idt.offset_0_15);
+
+ /* build the IDT entry */
+ idt.offset_0_15 = ((rtems_unsigned32) handler) & 0xffff;
+ idt.segment_selector = get_cs();
+ idt.reserved = 0x00;
+ idt.p_dpl = 0x8e; /* present, ISR */
+ idt.offset_16_31 = ((rtems_unsigned32) handler) >> 16;
+
+ /* install the IDT entry */
+ Interrupt_descriptor_table[ vector ] = idt;
+ }
+ return previous_isr;
+}
+