about summary refs log tree commit diff
path: root/sysdeps/standalone/i386/force_cpu386
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/standalone/i386/force_cpu386')
-rw-r--r--sysdeps/standalone/i386/force_cpu386/Dist1
-rw-r--r--sysdeps/standalone/i386/force_cpu386/Makefile24
-rw-r--r--sysdeps/standalone/i386/force_cpu386/_exit.c47
-rw-r--r--sysdeps/standalone/i386/force_cpu386/brdinit.c44
-rw-r--r--sysdeps/standalone/i386/force_cpu386/console.c163
-rw-r--r--sysdeps/standalone/i386/force_cpu386/strtsupp.S89
-rw-r--r--sysdeps/standalone/i386/force_cpu386/target.ld59
7 files changed, 427 insertions, 0 deletions
diff --git a/sysdeps/standalone/i386/force_cpu386/Dist b/sysdeps/standalone/i386/force_cpu386/Dist
new file mode 100644
index 0000000000..8b7b09e10a
--- /dev/null
+++ b/sysdeps/standalone/i386/force_cpu386/Dist
@@ -0,0 +1 @@
+target.ld
diff --git a/sysdeps/standalone/i386/force_cpu386/Makefile b/sysdeps/standalone/i386/force_cpu386/Makefile
new file mode 100644
index 0000000000..8483724ee3
--- /dev/null
+++ b/sysdeps/standalone/i386/force_cpu386/Makefile
@@ -0,0 +1,24 @@
+# Copyright (C) 1994 Free Software Foundation, Inc.
+# Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+#   On-Line Applications Research Corporation.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public License
+# as published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Library General Public License for more details.
+
+# You should have received a copy of the GNU Library General Public
+# License along with the GNU C Library; see the file COPYING.LIB.  If
+# not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+# Cambridge, MA 02139, USA.
+
+ifeq (bare,$(subdir))
+install-others += $(libdir)/force_cpu386.ld
+$(libdir)/force_cpu386.ld: $(sysdep_dir)/standalone/i386/target.ld
+	$(do-install)
+endif
diff --git a/sysdeps/standalone/i386/force_cpu386/_exit.c b/sysdeps/standalone/i386/force_cpu386/_exit.c
new file mode 100644
index 0000000000..011bb8bda9
--- /dev/null
+++ b/sysdeps/standalone/i386/force_cpu386/_exit.c
@@ -0,0 +1,47 @@
+/* Copyright (C) 1991 Free Software Foundation, Inc.
+   Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+     On-Line Applications Research Corporation.
+ 
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+#include <ansidecl.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+/* This returns control to FORCEbug. */
+
+void DEFUN_VOID(Bsp_cleanup);
+
+/* The function `_exit' should take a status argument and simply
+   terminate program execution, using the low-order 8 bits of the
+   given integer as status.  */
+
+__NORETURN void
+DEFUN(_exit, (status), int status)
+{
+  /* status is ignored */
+  Bsp_cleanup();
+}
+
+#ifdef	 HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(_exit);
+
+#endif	/* GNU stabs.  */
diff --git a/sysdeps/standalone/i386/force_cpu386/brdinit.c b/sysdeps/standalone/i386/force_cpu386/brdinit.c
new file mode 100644
index 0000000000..0d27218121
--- /dev/null
+++ b/sysdeps/standalone/i386/force_cpu386/brdinit.c
@@ -0,0 +1,44 @@
+/* Copyright (C) 1994 Free Software Foundation, Inc.
+   Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+     On-Line Applications Research Corporation.
+ 
+This file is part of the GNU C Library.
+ 
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+ 
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+ 
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+#include <ansidecl.h>
+#include <standalone.h>
+#include "i386.h"
+
+/*  _Board_Initialize()
+
+This routine initializes the FORCE CPU386 board.  */
+
+void DEFUN_VOID(_Console_Initialize);
+
+void 
+DEFUN_VOID(_Board_Initialize)
+{
+  /*
+   *  FORCE documentation incorrectly states that the bus request
+   *  level is initialized to 3.  It is actually initialized by
+   *  FORCEbug to 0.
+   */
+ 
+  outport_byte( 0x00, 0x3f );      /* resets VMEbus request level */
+ 
+  _Console_Initialize();
+}
diff --git a/sysdeps/standalone/i386/force_cpu386/console.c b/sysdeps/standalone/i386/force_cpu386/console.c
new file mode 100644
index 0000000000..5d56f768ea
--- /dev/null
+++ b/sysdeps/standalone/i386/force_cpu386/console.c
@@ -0,0 +1,163 @@
+/* Copyright (C) 1994 Free Software Foundation, Inc.
+   Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+     On-Line Applications Research Corporation.
+ 
+This file is part of the GNU C Library.
+ 
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+ 
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+ 
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+#include <ansidecl.h>
+#include <standalone.h>
+#include "i386.h"
+
+/* Console IO routines for a FORCE CPU386 board. */
+
+/* Force CPU/386 specific IO addressing
+ *
+ * The following determines whether Port B or the Console should
+ * be used for console I/O.  Setting ONE (and only ONE) of these to 1
+ * enables I/O on that port.
+ * 
+ *     PORT A - DUSCC MC68562 Channel A  (*** not supported here ***)
+ *     PORT B - DUSCC MC68562 Channel B
+ *     PORT C - MFP MC68901 Channel      (*** FORCEbug console ***)
+ */
+
+#define PORTB         1               /* use port b as console */
+#define PORTC         0               /* use console port as console */
+
+#if ( PORTB == 1 )
+#define TX_STATUS     0x1b6           /* DUSCC General Status Register */
+#define RX_STATUS     0x1b6           /* DUSCC General Status Register */
+#define TX_BUFFER     0x1e0           /* DUSCC Transmitter Channel B */
+#define RX_BUFFER     0x1e8           /* DUSCC Receiver Channel B */
+#define Is_tx_ready( _status ) ( (_status) & 0x20 )
+#define Is_rx_ready( _status ) ( (_status) & 0x10 )
+#endif
+ 
+#if ( PORTC == 1 )
+#define TX_STATUS     0x12c           /* MFP Transmit Status Register */
+#define RX_STATUS     0x12a           /* MFP Receive Status Register */
+#define TX_BUFFER     0x12e           /* MFP Transmitter Channel  */
+#define RX_BUFFER     0x12e           /* MFP Receiver Channel  */
+#define Is_tx_ready( _status ) ( (_status) & 0x80 )
+#define Is_rx_ready( _status ) ( (_status) & 0x80 )
+#endif
+   
+/* _Console_Initialize
+
+On the Force board the console require some initialization. */
+
+void
+DEFUN_VOID(_Console_Initialize)
+{
+  register unsigned8 ignored;
+
+  /* FORCE technical support mentioned that it may be necessary to
+     read the DUSCC RX_BUFFER port four times to remove all junk.
+     This code is a little more paranoid.  */
+ 
+  inport_byte( RX_BUFFER, ignored );
+  inport_byte( RX_BUFFER, ignored );
+  inport_byte( RX_BUFFER, ignored );
+  inport_byte( RX_BUFFER, ignored );
+  inport_byte( RX_BUFFER, ignored );
+}
+
+/* Miscellaneous support for console IO */
+
+static inline int _Force386_is_rx_ready()
+{
+  register unsigned8 status;
+
+  inport_byte( RX_STATUS, status );
+
+  if ( Is_rx_ready( status ) ) return 1;
+  else                         return 0;
+}
+ 
+static inline int _Force386_is_tx_ready()
+{
+  register unsigned8 status;
+
+  inport_byte( TX_STATUS, status );
+
+  if ( Is_tx_ready( status ) ) return 1;
+  else                         return 0;
+}
+
+
+static inline int _Force386_read_data()
+{
+  register unsigned8 ch;
+
+#if ( PORTB == 1 )
+    /* Force example code resets the Channel B Receiver here.
+     * It appears to cause XON's to be lost.
+     */  
+
+     /* outport_byte( RX_STATUS, 0x10 );  */
+#endif
+
+  inport_byte( RX_BUFFER, ch );
+
+  return ch;
+}
+
+/* _Console_Putc
+
+This routine transmits a character.  It supports XON/XOFF flow control.  */
+
+#define XON             0x11            /* control-Q */
+#define XOFF            0x13            /* control-S */
+
+int
+DEFUN( _Console_Putc, (ch), char ch )
+{
+  register unsigned8 inch;
+
+  while ( !_Force386_is_tx_ready() );
+
+  while ( _Force386_is_rx_ready() == 1 ) {      /* must be an XOFF */
+    inch = _Force386_read_data();
+    if ( inch == XOFF )
+      do {
+        while ( _Force386_is_rx_ready() == 0 );
+        inch = _Force386_read_data();
+      } while ( inch != XON );
+  }
+ 
+  outport_byte( TX_BUFFER, ch );
+  return( 0 );
+}
+
+/* _Console_Getc
+
+This routine reads a character from the UART and returns it. */
+
+int
+DEFUN( _Console_Getc, (poll), int poll )
+{
+  if ( poll ) {
+    if ( !_Force386_is_rx_ready() )
+      return -1;
+    else
+      return _Force386_read_data();
+  } else {
+    while ( !_Force386_is_rx_ready() );
+    return _Force386_read_data();
+  }
+}
diff --git a/sysdeps/standalone/i386/force_cpu386/strtsupp.S b/sysdeps/standalone/i386/force_cpu386/strtsupp.S
new file mode 100644
index 0000000000..6b78a8c343
--- /dev/null
+++ b/sysdeps/standalone/i386/force_cpu386/strtsupp.S
@@ -0,0 +1,89 @@
+/* Copyright (C) 1994 Free Software Foundation, Inc.
+   Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+     On-Line Applications Research Corporation.
+ 
+This file is part of the GNU C Library.
+ 
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+ 
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+ 
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+/*  This file assists the board independent startup code by
+ *  loading the proper segment register values.  The values
+ *  loaded are dependent on the FORCEBUG.  
+ *
+ *  NOTE:  No stack has been established when this routine
+ *         is invoked.  It returns by jumping back to the start code.
+ *
+ */
+
+/*
+ *  FORCEBUG loads us into a virtual address space which 
+ *  really starts at PHYSICAL_ADDRESS_BASE.  
+ *  
+ */
+
+.set PHYSICAL_ADDRESS_BASE,    0x00002000
+
+/*
+ *  At reset time, FORCEBUG normally has the segment selectors preloaded.   
+ *  If a human resets the instruction pointer, this will not have occurred.
+ *  However, no guarantee can be made of the other registers if cs:ip was 
+ *  modified to restart the program.  Because of this, the BSP reloads all 
+ *  segment registers (except cs) with the values they have following 
+ *  a reset.  
+ */
+
+
+.set RESET_SS, 0x40        # initial value of stack segment register
+.set RESET_DS, 0x40        # initial value of data segment register
+.set RESET_ES, 0x40        # initial value of extra segment register
+.set RESET_FS, 0x40        # initial value of "f" segment register
+.set RESET_GS, 0x30        # initial value of "g" segment register 
+
+
+#define LOAD_SEGMENTS(_value,_segreg) \
+        movw      $_value##,%ax ;  \
+        movw      %ax,##_segreg
+
+    
+        .global  _load_segments
+
+        .global   _establish_stack
+
+_load_segments:
+
+        LOAD_SEGMENTS( RESET_SS, %ss )
+        LOAD_SEGMENTS( RESET_DS, %ds )
+        LOAD_SEGMENTS( RESET_ES, %es )
+        LOAD_SEGMENTS( RESET_FS, %fs )
+        LOAD_SEGMENTS( RESET_GS, %gs )
+
+        jmp     _establish_stack        # return to the bsp entry code
+
+        .global  _return_to_monitor
+_return_to_monitor:
+
+        movb    $0,%al
+        int     $0x20                   # restart FORCEbug
+        jmp     start                   # FORCEbug does not reset PC
+
+        .data
+
+        .global _Do_Load_IDT
+_Do_Load_IDT:   .byte 1
+
+        .global _Do_Load_GDT
+_Do_Load_GDT:   .byte 0
+
diff --git a/sysdeps/standalone/i386/force_cpu386/target.ld b/sysdeps/standalone/i386/force_cpu386/target.ld
new file mode 100644
index 0000000000..056da10d55
--- /dev/null
+++ b/sysdeps/standalone/i386/force_cpu386/target.ld
@@ -0,0 +1,59 @@
+/* Copyright (C) 1994 Free Software Foundation, Inc.
+   Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+     On-Line Applications Research Corporation.
+ 
+This file is part of the GNU C Library.
+ 
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+ 
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+ 
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+/* This file contains directives for the GNU linker which are specific
+to the FORCE CPU386 board.  */
+
+MEMORY 
+        {
+        ram : org = 0x0, l = 1M
+        }
+
+/* This value is also when the space is allocated.  If you change
+this one, change the other one!!! */
+
+heap_size = 0x20000;
+
+SECTIONS
+{
+        .text 0x0 : 
+        {
+            _text_start = ABSOLUTE(.) ;
+            *(.text)
+            _etext = ALIGN( 0x10 ) ;
+        }
+        .data ADDR( .text ) + SIZEOF( .text ): 
+        {
+            _data_start = . ;
+            *(.data)
+            _edata = ALIGN( 0x10 ) ;
+        }
+        .bss ADDR( .data ) + SIZEOF( .data ): 
+        {
+            _bss_start = . ;
+            *(.bss)
+            *(COMMON)
+            heap_memory = .;
+            . += 0x20000;
+            _end = . ;
+            __end = . ;
+        }
+}