Changeset 3a4ae6c in rtems for c/src/lib/libbsp/m68k/idp


Ignore:
Timestamp:
09/11/95 19:35:39 (27 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
ced11f99
Parents:
5072b07
Message:

The word "RTEMS" almost completely removed from the core.

Configuration Table Template file added and all tests
modified to use this. All gvar.h and conftbl.h files
removed from test directories.

Configuration parameter maximum_devices added.

Core semaphore and mutex handlers added and RTEMS API Semaphore
Manager updated to reflect this.

Initialization sequence changed to invoke API specific initialization
routines. Initialization tasks table now owned by RTEMS Tasks Manager.

Added user extension for post-switch.

Utilized user extensions to implement API specific functionality
like signal dispatching.

Added extensions to the System Initialization Thread so that an
API can register a function to be invoked while the system
is being initialized. These are largely equivalent to the
pre-driver and post-driver hooks.

Added the Modules file oar-go32_p5, modified oar-go32, and modified
the file make/custom/go32.cfg to look at an environment varable which
determines what CPU model is being used.

All BSPs updated to reflect named devices and clock driver's IOCTL
used by the Shared Memory Driver. Also merged clock isr into
main file and removed ckisr.c where possible.

Updated spsize to reflect new and moved variables.

Makefiles for the executive source and include files updated to show
break down of files into Core, RTEMS API, and Neither.

Header and inline files installed into subdirectory based on whether
logically in the Core or a part of the RTEMS API.

Location:
c/src/lib/libbsp/m68k/idp
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/m68k/idp/clock/ckinit.c

    r5072b07 r3a4ae6c  
    2727#include <stdlib.h>
    2828
    29 #include <rtems.h>
    30 #include <clockdrv.h>
    3129#include <bsp.h>
     30#include <rtems/libio.h>
    3231
    3332rtems_unsigned32 Clock_isrs;        /* ISRs until next tick */
     
    4039void Disable_clock();
    4140
    42 #define TIMER_VECTOR 0x4D
    43 
    44 rtems_device_driver Clock_initialize(
    45   rtems_device_major_number major,
    46   rtems_device_minor_number minor,
    47   void *pargp,
    48   rtems_id tid,
    49   rtems_unsigned32 *rval
     41#define CLOCK_VECTOR 0x4D
     42
     43void Clock_exit( void );
     44 
     45/*
     46 * These are set by clock driver during its init
     47 */
     48 
     49rtems_device_major_number rtems_clock_major = ~0;
     50rtems_device_minor_number rtems_clock_minor;
     51 
     52
     53/*
     54 *  ISR Handler
     55 *
     56 *
     57 * ((1ms * 6.5 MHz) / 2^5) = 203.125) where 6.5 MHz is the clock rate of the
     58 * MC68230, 2^5 is the prescaler factor, and 1ms is the common interrupt
     59 * interval for the Clock_isr routine.
     60 * Therefore, 203 (decimal) is the number to program into the CPRH-L registers
     61 * of the MC68230 for countdown.  However, I have found that 193 instead of
     62 * 203 provides greater accuracy -- why?  The crystal should be more accurate
     63 * than that
     64 */
     65
     66rtems_isr Clock_isr(
     67  rtems_vector_number vector
    5068)
    5169{
    52   Install_clock( Clock_isr );
    53 }
    54 
    55 void ReInstall_clock( clock_isr )
    56 rtems_isr_entry clock_isr;
    57 {
    58   rtems_unsigned32 isrlevel = 0 ;
    59 
    60   rtems_interrupt_disable( isrlevel );
    61    (void) set_vector( clock_isr, TIMER_VECTOR, 1 );
    62   rtems_interrupt_enable( isrlevel );
    63 }
    64 
    65 /* The following was added for debugging purposes */
     70  Clock_driver_ticks += 1;
     71  /* acknowledge interrupt
     72        TSR = 1; */
     73  MC68230_WRITE (TSR, 1);
     74
     75  if ( Clock_isrs == 1 ) {
     76    rtems_clock_tick();
     77        /* Cast to an integer so that 68EC040 IDP which doesn't have an FPU doesn't
     78           have a heart attack -- if you use newlib1.6 or greater and get
     79           libgcc.a for gcc with software floating point support, this is not
     80           a problem */
     81    Clock_isrs =
     82      (int)(BSP_Configuration.microseconds_per_tick / 1000);
     83  }
     84  else
     85    Clock_isrs -= 1;
     86}
     87
    6688void Disable_clock()
    6789{
     
    78100  if ( Configuration.ticks_per_timeslice ) {
    79101/*    led_putnum('c'); * for debugging purposes */
    80     Old_ticker = (rtems_isr_entry) set_vector( clock_isr, TIMER_VECTOR, 1 );
     102    Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 );
    81103
    82104        /* Disable timer for initialization */
     
    86108           file in this directory to understand why I use the values that I do */
    87109        /* Set up the interrupt vector on the MC68230 chip:
    88                 TIVR = TIMER_VECTOR; */
    89         MC68230_WRITE (TIVR, TIMER_VECTOR);
     110                TIVR = CLOCK_VECTOR; */
     111        MC68230_WRITE (TIVR, CLOCK_VECTOR);
    90112
    91113        /* Set CPRH through CPRL to 193 (not 203) decimal for countdown--see ckisr.c
     
    109131}
    110132
     133void ReInstall_clock( clock_isr )
     134rtems_isr_entry clock_isr;
     135{
     136  rtems_unsigned32 isrlevel = 0 ;
     137
     138  rtems_interrupt_disable( isrlevel );
     139   (void) set_vector( clock_isr, CLOCK_VECTOR, 1 );
     140  rtems_interrupt_enable( isrlevel );
     141}
     142
     143/* The following was added for debugging purposes */
    111144void Clock_exit( void )
    112145{
     
    124157  }
    125158}
     159
     160rtems_device_driver Clock_initialize(
     161  rtems_device_major_number major,
     162  rtems_device_minor_number minor,
     163  void *pargp
     164)
     165{
     166  Install_clock( Clock_isr );
     167 
     168  /*
     169   * make major/minor avail to others such as shared memory driver
     170   */
     171 
     172  rtems_clock_major = major;
     173  rtems_clock_minor = minor;
     174 
     175  return RTEMS_SUCCESSFUL;
     176}
     177 
     178rtems_device_driver Clock_control(
     179  rtems_device_major_number major,
     180  rtems_device_minor_number minor,
     181  void *pargp
     182)
     183{
     184    rtems_libio_ioctl_args_t *args = pargp;
     185 
     186    if (args == 0)
     187        goto done;
     188 
     189    /*
     190     * This is hokey, but until we get a defined interface
     191     * to do this, it will just be this simple...
     192     */
     193 
     194    if (args->command == rtems_build_name('I', 'S', 'R', ' '))
     195    {
     196        Clock_isr(CLOCK_VECTOR);
     197    }
     198    else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
     199    {
     200        ReInstall_clock(args->buffer);
     201    }
     202 
     203done:
     204    return RTEMS_SUCCESSFUL;
     205}
     206
  • c/src/lib/libbsp/m68k/idp/console/console.c

    r5072b07 r3a4ae6c  
    1212#define MIDP_INIT
    1313
    14 #include "rtems.h"
    15 #include "console.h"
    16 #include "bsp.h"
    17 
    18 #include "ringbuf.h"
     14#include <bsp.h>
     15#include <rtems/libio.h>
     16
     17#include <ringbuf.h>
    1918
    2019Ring_buffer_t  Buffer[ 2 ];
    2120
    2221rtems_isr C_Receive_ISR(rtems_vector_number vector);
    23 
    2422
    2523/*  console_initialize
     
    3735  rtems_device_major_number  major,
    3836  rtems_device_minor_number  minor,
    39   void                      *arg,
    40   rtems_id                   self,
    41   rtems_unsigned32          *status
    42 )
    43 {
     37  void                      *arg
     38)
     39{
     40  rtems_status_code status;
    4441
    4542  Ring_buffer_Initialize( &Buffer[ 0 ] );
     
    4845  init_pit();
    4946
    50   *status = RTEMS_SUCCESSFUL;
     47  status = rtems_io_register_name(
     48    "/dev/console",
     49    major,
     50    (rtems_device_minor_number) 0
     51  );
     52 
     53  if (status != RTEMS_SUCCESSFUL)
     54    rtems_fatal_error_occurred(status);
     55 
     56  status = rtems_io_register_name(
     57    "/dev/tty00",
     58    major,
     59    (rtems_device_minor_number) 0
     60  );
     61 
     62  if (status != RTEMS_SUCCESSFUL)
     63    rtems_fatal_error_occurred(status);
     64 
     65  status = rtems_io_register_name(
     66    "/dev/tty01",
     67    major,
     68    (rtems_device_minor_number) 1
     69  );
     70 
     71  if (status != RTEMS_SUCCESSFUL)
     72    rtems_fatal_error_occurred(status);
     73 
     74  return RTEMS_SUCCESSFUL;
    5175}
    5276
     
    152176
    153177/*
    154  * __read  -- read bytes from the serial port. Ignore fd, since
    155  *            we only have stdin.
    156  */
    157 
    158 int __read(
    159   int fd,
    160   char *buf,
    161   int nbytes
    162 )
    163 {
    164   int i = 0;
    165   int port;
    166 
    167   /*
    168    *  Map port A to stdin, stdout, and stderr.
    169    *  Map everything else to port B.
    170    */
    171 
    172   if ( fd <= 2 ) port = 0;
    173   else           port = 1;
    174 
    175   for (i = 0; i < nbytes; i++) {
    176     *(buf + i) = inbyte( port );
    177     if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) {
    178       (*(buf + i++)) = '\n';
    179       (*(buf + i)) = 0;
     178 *  Open entry point
     179 */
     180
     181rtems_device_driver console_open(
     182  rtems_device_major_number major,
     183  rtems_device_minor_number minor,
     184  void                    * arg
     185)
     186{
     187  return RTEMS_SUCCESSFUL;
     188}
     189 
     190/*
     191 *  Close entry point
     192 */
     193
     194rtems_device_driver console_close(
     195  rtems_device_major_number major,
     196  rtems_device_minor_number minor,
     197  void                    * arg
     198)
     199{
     200  return RTEMS_SUCCESSFUL;
     201}
     202
     203/*
     204 * read bytes from the serial port. We only have stdin.
     205 */
     206
     207rtems_device_driver console_read(
     208  rtems_device_major_number major,
     209  rtems_device_minor_number minor,
     210  void                    * arg
     211)
     212{
     213  rtems_libio_rw_args_t *rw_args;
     214  char *buffer;
     215  int maximum;
     216  int count = 0;
     217 
     218  rw_args = (rtems_libio_rw_args_t *) arg;
     219
     220  buffer = rw_args->buffer;
     221  maximum = rw_args->count;
     222
     223  if ( minor > 1 )
     224    return RTEMS_INVALID_NUMBER;
     225
     226  for (count = 0; count < maximum; count++) {
     227    buffer[ count ] = inbyte( minor );
     228    if (buffer[ count ] == '\n' || buffer[ count ] == '\r') {
     229      buffer[ count++ ]  = '\n';
     230      buffer[ count ]  = 0;
    180231      break;
    181232    }
    182233  }
    183   return (i);
    184 }
    185 
    186 /*
    187  * __write -- write bytes to the serial port. Ignore fd, since
    188  *            stdout and stderr are the same. Since we have no filesystem,
    189  *            open will only return an error.
    190  */
    191 
    192 int __write(
    193   int fd,
    194   char *buf,
    195   int nbytes
    196 )
    197 {
    198   int i;
    199   int port;
    200  
    201   /*
    202    *  Map port A to stdin, stdout, and stderr.
    203    *  Map everything else to port B.
    204    */
    205  
    206   if ( fd <= 2 ) port = 0;
    207   else           port = 1;
    208  
    209   for (i = 0; i < nbytes; i++) {
    210     if (*(buf + i) == '\n') {
    211       outbyte ('\r', port );
     234
     235  rw_args->bytes_moved = count;
     236  return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED;
     237}
     238
     239/*
     240 * write bytes to the serial port. Stdout and stderr are the same.
     241 */
     242
     243rtems_device_driver console_write(
     244  rtems_device_major_number major,
     245  rtems_device_minor_number minor,
     246  void                    * arg
     247)
     248{
     249  int count;
     250  int maximum;
     251  rtems_libio_rw_args_t *rw_args;
     252  char *buffer;
     253
     254  rw_args = (rtems_libio_rw_args_t *) arg;
     255
     256  buffer = rw_args->buffer;
     257  maximum = rw_args->count;
     258
     259  if ( minor > 1 )
     260    return RTEMS_INVALID_NUMBER;
     261
     262  for (count = 0; count < maximum; count++) {
     263    if ( buffer[ count ] == '\n') {
     264      outbyte('\r', minor );
    212265    }
    213     outbyte (*(buf + i), port );
     266    outbyte( buffer[ count ], minor );
    214267  }
    215   return (nbytes);
    216 }
     268  return maximum;
     269}
     270
     271/*
     272 *  IO Control entry point
     273 */
     274
     275rtems_device_driver console_control(
     276  rtems_device_major_number major,
     277  rtems_device_minor_number minor,
     278  void                    * arg
     279)
     280{
     281  return RTEMS_SUCCESSFUL;
     282}
  • c/src/lib/libbsp/m68k/idp/include/bsp.h

    r5072b07 r3a4ae6c  
    1111#include <rtems.h>
    1212#include <console.h>
     13#include <clockdrv.h>
    1314#include <mc68230.h>
    1415#include <mc68681.h>
     
    5354#endif
    5455
     56/*
     57 *  Device Driver Table Entries
     58 */
     59
     60/*
     61 * NOTE: Use the standard Console driver entry
     62 */
     63 
     64/*
     65 * NOTE: Use the standard Clock driver entry
     66 */
     67
     68/*
     69 * How many libio files we want
     70 */
     71
     72#define BSP_LIBIO_MAX_FDS       20
     73
    5574/* miscellaneous stuff assumed to exist */
    5675
  • c/src/lib/libbsp/m68k/idp/startup/bspstart.c

    r5072b07 r3a4ae6c  
    2121 */
    2222
    23 #include <rtems.h>
    2423#include <bsp.h>
     24#include <rtems/libio.h>
     25 
    2526#include <libcsupport.h>
     27 
     28#include <string.h>
     29#include <fcntl.h>
     30 
     31#ifdef STACK_CHECKER_ON
     32#include <stackchk.h>
     33#endif
    2634
    2735unsigned char *duart_base;
     
    4250rtems_cpu_table Cpu_table;
    4351 
     52char *rtems_progname;
     53
    4454/*      Initialize whatever libc we are using
    4555 *      called from postdriver hook
     
    5767        /* Create 64 KByte memory region for RTEMS executive */
    5868    RTEMS_Malloc_Initialize((void *) heap_start, 64 * 1024, 0);
     69
     70    /*
     71     *  Init the RTEMS libio facility to provide UNIX-like system
     72     *  calls for use by newlib (ie: provide __open, __close, etc)
     73     *  Uses malloc() to get area for the iops, so must be after malloc init
     74     */
     75
     76    rtems_libio_init();
    5977 
    6078    /*
     
    7795 
    7896
    79 int bsp_start(
     97/*
     98 * After drivers are setup, register some "filenames"
     99 * and open stdin, stdout, stderr files
     100 *
     101 * Newlib will automatically associate the files with these
     102 * (it hardcodes the numbers)
     103 */
     104 
     105void
     106bsp_postdriver_hook(void)
     107{
     108  int stdin_fd, stdout_fd, stderr_fd;
     109 
     110  if ((stdin_fd = __open("/dev/console", O_RDONLY, 0)) == -1)
     111    rtems_fatal_error_occurred('STD0');
     112 
     113  if ((stdout_fd = __open("/dev/console", O_WRONLY, 0)) == -1)
     114    rtems_fatal_error_occurred('STD1');
     115 
     116  if ((stderr_fd = __open("/dev/console", O_WRONLY, 0)) == -1)
     117    rtems_fatal_error_occurred('STD2');
     118 
     119  if ((stdin_fd != 0) || (stdout_fd != 1) || (stderr_fd != 2))
     120    rtems_fatal_error_occurred('STIO');
     121}
     122
     123int main(
    80124  int argc,
    81125  char **argv,
     
    86130  int             index;
    87131
     132  if ((argc > 0) && argv && argv[0])
     133    rtems_progname = argv[0];
     134  else
     135    rtems_progname = "RTEMS";
     136
    88137  duart_base = (unsigned char *)DUART_ADDR;
    89138
     
    122171  Cpu_table.predriver_hook = bsp_libc_init;  /* RTEMS resources available */
    123172 
    124   Cpu_table.postdriver_hook = NULL;
     173  Cpu_table.postdriver_hook = bsp_postdriver_hook;
    125174 
    126175  Cpu_table.idle_task = NULL;  /* do not override system IDLE task */
     
    165214#endif
    166215 
     216  /*
     217   * Tell libio how many fd's we want and allow it to tweak config
     218   */
     219
     220  rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS);
     221
    167222/*  led_putnum('e'); * for debugging purposes only */
    168223  rtems_initialize_executive( &BSP_Configuration, &Cpu_table );/* does not return */
Note: See TracChangeset for help on using the changeset viewer.