Changeset 3a4ae6c in rtems for c/src/lib


Ignore:
Timestamp:
Sep 11, 1995, 7:35:39 PM (26 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
Files:
66 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/include/console.h

    r5072b07 r3a4ae6c  
    2323
    2424#define CONSOLE_DRIVER_TABLE_ENTRY \
    25   { console_initialize, NULL, NULL, NULL, NULL, NULL }
     25  { console_initialize, console_open, console_close, \
     26    console_read, console_write, console_control }
    2627
    2728rtems_device_driver console_initialize(
    2829  rtems_device_major_number,
    2930  rtems_device_minor_number,
    30   void *,
    31   rtems_id,
    32   rtems_unsigned32 *
     31  void *
     32);
     33
     34rtems_device_driver console_open(
     35  rtems_device_major_number,
     36  rtems_device_minor_number,
     37  void *
     38);
     39
     40rtems_device_driver console_close(
     41  rtems_device_major_number,
     42  rtems_device_minor_number,
     43  void *
     44);
     45
     46rtems_device_driver console_read(
     47  rtems_device_major_number,
     48  rtems_device_minor_number,
     49  void *
     50);
     51
     52rtems_device_driver console_write(
     53  rtems_device_major_number,
     54  rtems_device_minor_number,
     55  void *
     56);
     57
     58rtems_device_driver console_control(
     59  rtems_device_major_number,
     60  rtems_device_minor_number,
     61  void *
    3362);
    3463
  • c/src/lib/libbsp/hppa1.1/simhppa/include/bsp.h

    r5072b07 r3a4ae6c  
    6868
    6969/*
    70  * Todo: this should be put somewhere else
    71  */
    72 
    73 #undef CLOCK_DRIVER_TABLE_ENTRY
    74 #define CLOCK_DRIVER_TABLE_ENTRY { Clock_initialize, NULL, NULL, NULL, NULL, Clock_control }
    75 rtems_device_driver Clock_control(
    76   rtems_device_major_number major,
    77   rtems_device_minor_number minor,
    78   void *pargp
    79 );
    80 
    81 /*
    8270 * We printf() to a buffer if multiprocessing, *or* if this is set.
    8371 * ref: src/lib/libbsp/hppa/simhppa/iosupp/consupp.c
     
    8573
    8674extern int use_print_buffer;
     75
     76/*
     77 *  Device Driver Table Entries
     78 */
    8779
    8880/*
     
    9385#define CONSOLE_DRIVER_TABLE_ENTRY \
    9486  { tty_initialize, tty_open, tty_close, tty_read, tty_write, tty_control }
     87
     88/*
     89 * NOTE: Use the standard Clock driver entry
     90 */
    9591
    9692/*
  • c/src/lib/libbsp/hppa1.1/simhppa/startup/bspstart.c

    r5072b07 r3a4ae6c  
    132132
    133133    /*
    134      * Init the RTEMS libio facility to provide UNIX-like system
     134     *  Init the RTEMS libio facility to provide UNIX-like system
    135135     *  calls for use by newlib (ie: provide __open, __close, etc)
    136136     *  Uses malloc() to get area for the iops, so must be after malloc init
  • c/src/lib/libbsp/i386/force386/clock/ckinit.c

    r5072b07 r3a4ae6c  
    2020
    2121#include <bsp.h>
    22 #include <clockdrv.h>
     22
     23#include <rtems/libio.h>
     24
    2325#include <stdlib.h>
    2426
     27#define CLOCK_VECTOR  0x38
     28
     29rtems_unsigned32 Clock_isrs;              /* ISRs until next tick */
     30
    2531volatile rtems_unsigned32 Clock_driver_ticks;
    26 rtems_unsigned32 Clock_isrs;              /* ISRs until next tick */
     32
    2733rtems_isr_entry  Old_ticker;
    2834
    29 rtems_device_driver Clock_initialize(
    30   rtems_device_major_number major,
    31   rtems_device_minor_number minor,
    32   void *pargp,
    33   rtems_id tid,
    34   rtems_unsigned32 *rval
     35void Clock_exit( void );
     36 
     37/*
     38 * These are set by clock driver during its init
     39 */
     40 
     41rtems_device_major_number rtems_clock_major = ~0;
     42rtems_device_major_number rtems_clock_minor = 0;
     43
     44/*
     45 *  This is the ISR handler.
     46 */
     47
     48rtems_isr Clock_isr(
     49  rtems_vector_number vector
    3550)
    3651{
    37   Install_clock( Clock_isr );
    38 }
    39 
    40 void ReInstall_clock(
    41   rtems_isr_entry clock_isr
    42 )
    43 {
    44   rtems_unsigned32 isrlevel = 0;
    45 
    46   rtems_interrupt_disable( isrlevel );
    47    (void) set_vector( clock_isr, 0x38, 1 );
    48   rtems_interrupt_enable( isrlevel );
     52  /* enable_tracing(); */
     53  Clock_driver_ticks += 1;
     54  if ( Clock_isrs == 1 ) {
     55    rtems_clock_tick();
     56    Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
     57  }
     58  else
     59    Clock_isrs -= 1;
    4960}
    5061
     
    5768
    5869  if ( BSP_Configuration.ticks_per_timeslice ) {
    59     Old_ticker = ( rtems_isr_entry ) set_vector( clock_isr, 0x38, 1 );
     70    Old_ticker = ( rtems_isr_entry ) set_vector( clock_isr, CLOCK_VECTOR, 1 );
    6071    outport_byte( TBCR, 0x14 );  /* reset it, delay mode, 50X */
    6172    outport_byte( TBDR, 0x50 );  /* 1 millisecond */
     
    6374  }
    6475  atexit( Clock_exit );
     76}
     77
     78void ReInstall_clock(
     79  rtems_isr_entry clock_isr
     80)
     81{
     82  rtems_unsigned32 isrlevel = 0;
     83
     84  rtems_interrupt_disable( isrlevel );
     85   (void) set_vector( clock_isr, CLOCK_VECTOR, 1 );
     86  rtems_interrupt_enable( isrlevel );
    6587}
    6688
     
    7496}
    7597
     98rtems_device_driver Clock_initialize(
     99  rtems_device_major_number major,
     100  rtems_device_minor_number minor,
     101  void *pargp
     102)
     103{
     104  Install_clock( Clock_isr );
     105 
     106  /*
     107   * make major/minor avail to others such as shared memory driver
     108   */
     109 
     110  rtems_clock_major = major;
     111  rtems_clock_minor = minor;
     112 
     113  return RTEMS_SUCCESSFUL;
     114}
     115 
     116rtems_device_driver Clock_control(
     117  rtems_device_major_number major,
     118  rtems_device_minor_number minor,
     119  void *pargp
     120)
     121{
     122    rtems_libio_ioctl_args_t *args = pargp;
     123 
     124    if (args == 0)
     125        goto done;
     126 
     127    /*
     128     * This is hokey, but until we get a defined interface
     129     * to do this, it will just be this simple...
     130     */
     131 
     132    if (args->command == rtems_build_name('I', 'S', 'R', ' '))
     133    {
     134        Clock_isr(CLOCK_VECTOR);
     135    }
     136    else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
     137    {
     138        ReInstall_clock(args->buffer);
     139    }
     140 
     141done:
     142    return RTEMS_SUCCESSFUL;
     143}
  • c/src/lib/libbsp/i386/force386/console/console.c

    r5072b07 r3a4ae6c  
    1515#define F386_INIT
    1616
     17#include <bsp.h>
     18#include <rtems/libio.h>
     19
    1720#include <stdlib.h>
    18 
    19 #include <rtems.h>
    20 #include "console.h"
    21 #include "bsp.h"
    2221
    2322/*  console_cleanup
     
    6261  rtems_device_major_number  major,
    6362  rtems_device_minor_number  minor,
    64   void                      *arg,
    65   rtems_id                   self,
    66   rtems_unsigned32          *status
    67 )
    68 {
    69    /*
    70     *  flush the console now and at exit.  Just in case.
    71     */
    72 
    73    console_cleanup();
    74 
    75    atexit( console_cleanup );
     63  void                      *arg
     64)
     65{
     66  rtems_status_code status;
     67
     68  /*
     69   *  flush the console now and at exit.  Just in case.
     70   */
     71
     72  console_cleanup();
     73
     74  status = rtems_io_register_name(
     75    "/dev/console",
     76    major,
     77    (rtems_device_minor_number) 0
     78  );
     79 
     80  if (status != RTEMS_SUCCESSFUL)
     81    rtems_fatal_error_occurred(status);
     82
     83  atexit( console_cleanup );
     84
     85  return RTEMS_SUCCESSFUL;
    7686}
    7787
     
    173183
    174184/*
    175  * __read  -- read bytes from the serial port. Ignore fd, since
    176  *            we only have stdin.
    177  */
    178 
    179 int __read(
    180   int fd,
    181   char *buf,
    182   int nbytes
    183 )
    184 {
    185   int i = 0;
    186 
    187   for (i = 0; i < nbytes; i++) {
    188     *(buf + i) = inbyte();
    189     if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) {
    190       (*(buf + i++)) = '\n';
    191       (*(buf + i)) = 0;
     185 *  Open entry point
     186 */
     187 
     188rtems_device_driver console_open(
     189  rtems_device_major_number major,
     190  rtems_device_minor_number minor,
     191  void                    * arg
     192)
     193{
     194  return RTEMS_SUCCESSFUL;
     195}
     196 
     197/*
     198 *  Close entry point
     199 */
     200 
     201rtems_device_driver console_close(
     202  rtems_device_major_number major,
     203  rtems_device_minor_number minor,
     204  void                    * arg
     205)
     206{
     207  return RTEMS_SUCCESSFUL;
     208}
     209
     210/*
     211 * read bytes from the serial port. We only have stdin.
     212 */
     213 
     214rtems_device_driver console_read(
     215  rtems_device_major_number major,
     216  rtems_device_minor_number minor,
     217  void                    * arg
     218)
     219{
     220  rtems_libio_rw_args_t *rw_args;
     221  char *buffer;
     222  int maximum;
     223  int count = 0;
     224 
     225  rw_args = (rtems_libio_rw_args_t *) arg;
     226 
     227  buffer = rw_args->buffer;
     228  maximum = rw_args->count;
     229 
     230  for (count = 0; count < maximum; count++) {
     231    buffer[ count ] = inbyte();
     232    if (buffer[ count ] == '\n' || buffer[ count ] == '\r') {
     233      buffer[ count++ ]  = '\n';
     234      buffer[ count ]  = 0;
    192235      break;
    193236    }
    194237  }
    195   return (i);
    196 }
    197 
    198 /*
    199  * __write -- write bytes to the serial port. Ignore fd, since
    200  *            stdout and stderr are the same. Since we have no filesystem,
    201  *            open will only return an error.
    202  */
    203 
    204 int __write(
    205   int fd,
    206   char *buf,
    207   int nbytes
    208 )
    209 {
    210   int i;
    211 
    212   for (i = 0; i < nbytes; i++) {
    213     if (*(buf + i) == '\n') {
    214       outbyte ('\r');
     238 
     239  rw_args->bytes_moved = count;
     240  return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED;
     241}
     242 
     243/*
     244 * write bytes to the serial port. Stdout and stderr are the same.
     245 */
     246 
     247rtems_device_driver console_write(
     248  rtems_device_major_number major,
     249  rtems_device_minor_number minor,
     250  void                    * arg
     251)
     252{
     253  int count;
     254  int maximum;
     255  rtems_libio_rw_args_t *rw_args;
     256  char *buffer;
     257 
     258  rw_args = (rtems_libio_rw_args_t *) arg;
     259 
     260  buffer = rw_args->buffer;
     261  maximum = rw_args->count;
     262 
     263  for (count = 0; count < maximum; count++) {
     264    if ( buffer[ count ] == '\n') {
     265      outbyte('\r');
    215266    }
    216     outbyte (*(buf + i));
    217   }
    218   return (nbytes);
    219 }
     267    outbyte( buffer[ count ] );
     268  }
     269  return maximum;
     270}
     271 
     272/*
     273 *  IO Control entry point
     274 */
     275 
     276rtems_device_driver console_control(
     277  rtems_device_major_number major,
     278  rtems_device_minor_number minor,
     279  void                    * arg
     280)
     281{
     282  return RTEMS_SUCCESSFUL;
     283}
     284
  • c/src/lib/libbsp/i386/force386/include/bsp.h

    r5072b07 r3a4ae6c  
    2323#include <rtems.h>
    2424#include <iosupp.h>
     25#include <console.h>
     26#include <clockdrv.h>
    2527
    2628/*
     
    129131#endif
    130132
     133/*
     134 *  Device Driver Table Entries
     135 */
     136
     137/*
     138 * NOTE: Use the standard Console driver entry
     139 */
     140 
     141/*
     142 * NOTE: Use the standard Clock driver entry
     143 */
     144
     145/*
     146 * How many libio files we want
     147 */
     148
     149#define BSP_LIBIO_MAX_FDS       20
     150
    131151/* miscellaneous stuff assumed to exist */
    132152
  • c/src/lib/libbsp/i386/force386/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>
    2627
     28#include <fcntl.h>
     29
     30#ifdef STACK_CHECKER_ON
    2731#include <stackchk.h>
     32#endif
    2833
    2934/*
     
    3641
    3742rtems_cpu_table Cpu_table;
     43
     44char *rtems_progname;
    3845
    3946/*      Initialize whatever libc we are using
     
    5158
    5259    RTEMS_Malloc_Initialize((void *) heap_start, 64 * 1024, 0);
     60
     61    /*
     62     *  Init the RTEMS libio facility to provide UNIX-like system
     63     *  calls for use by newlib (ie: provide __open, __close, etc)
     64     *  Uses malloc() to get area for the iops, so must be after malloc init
     65     */
     66
     67    rtems_libio_init();
    5368
    5469    /*
     
    7186}
    7287
    73 int bsp_start(
     88/*
     89 * After drivers are setup, register some "filenames"
     90 * and open stdin, stdout, stderr files
     91 *
     92 * Newlib will automatically associate the files with these
     93 * (it hardcodes the numbers)
     94 */
     95 
     96void
     97bsp_postdriver_hook(void)
     98{
     99  int stdin_fd, stdout_fd, stderr_fd;
     100 
     101  if ((stdin_fd = __open("/dev/console", O_RDONLY, 0)) == -1)
     102    rtems_fatal_error_occurred('STD0');
     103 
     104  if ((stdout_fd = __open("/dev/console", O_WRONLY, 0)) == -1)
     105    rtems_fatal_error_occurred('STD1');
     106 
     107  if ((stderr_fd = __open("/dev/console", O_WRONLY, 0)) == -1)
     108    rtems_fatal_error_occurred('STD2');
     109 
     110  if ((stdin_fd != 0) || (stdout_fd != 1) || (stderr_fd != 2))
     111    rtems_fatal_error_occurred('STIO');
     112}
     113
     114int main(
    74115  int argc,
    75116  char **argv,
     
    77118)
    78119{
     120 
     121  if ((argc > 0) && argv && argv[0])
     122    rtems_progname = argv[0];
     123  else
     124    rtems_progname = "RTEMS";
     125 
    79126  /*
    80127   *  FORCE documentation incorrectly states that the bus request
     
    93140  Cpu_table.predriver_hook = bsp_libc_init;  /* RTEMS resources available */
    94141
    95   Cpu_table.postdriver_hook = NULL;   /* Call our main() for constructors */
     142  Cpu_table.postdriver_hook = bsp_postdriver_hook;
    96143
    97144  Cpu_table.idle_task = NULL;  /* do not override system IDLE task */
     
    138185#endif
    139186
     187  /*
     188   * Tell libio how many fd's we want and allow it to tweak config
     189   */
     190
     191  rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS);
     192
    140193  rtems_initialize_executive( &BSP_Configuration, &Cpu_table );
    141194  /* does not return */
  • c/src/lib/libbsp/i386/go32/clock/ckinit.c

    r5072b07 r3a4ae6c  
    1212
    1313#include <bsp.h>
    14 #include <clockdrv.h>
     14#include <rtems/libio.h>
     15
    1516#include <stdlib.h>
    1617
    1718volatile rtems_unsigned32 Clock_driver_ticks;
    18 rtems_unsigned32 Clock_isrs_per_tick;           /* ISRs per tick */
    19 rtems_unsigned32 Clock_isrs;                    /* ISRs until next tick */
     19rtems_unsigned32 Clock_isrs_per_tick;  /* ISRs per tick */
     20rtems_unsigned32 Clock_isrs;   /* ISRs until next tick */
    2021rtems_isr_entry  Old_ticker;
     22
     23#define CLOCK_VECTOR 0x8
     24
     25void Clock_exit( void );
     26
     27/*
     28 * These are set by clock driver during its init
     29 */
     30 
     31rtems_device_major_number rtems_clock_major = ~0;
     32rtems_device_minor_number rtems_clock_minor;
     33
     34rtems_isr Clock_isr(
     35  rtems_vector_number vector
     36)
     37{
     38    /* touch interrupt controller for irq0 (0x20+0) */
     39    outport_byte( 0x20, 0x20 );
     40
     41    Clock_driver_ticks += 1;
     42
     43#if 0 && defined(pentium)
     44    {
     45      extern long long Last_RDTSC;
     46      __asm __volatile( ".byte 0x0F, 0x31" : "=A" (Last_RDTSC) );
     47    }
     48#endif
     49
     50    if ( Clock_isrs == 1 ) {
     51      rtems_clock_tick();
     52      Clock_isrs = Clock_isrs_per_tick;
     53    } else {
     54      Clock_isrs -= 1;
     55    }
     56}
     57
     58void Install_clock(
     59  rtems_isr_entry clock_isr
     60)
     61{
     62    unsigned int microseconds_per_isr;
     63
     64#if 0
     65    /* Initialize clock from on-board real time clock.  This breaks the */
     66    /* test code which assumes which assumes the application will do it. */
     67    {
     68       rtems_time_of_day Now;
     69       extern void init_rtc( void );
     70       extern long rtc_read( rtems_time_of_day * tod );
     71       init_rtc();
     72       if ( rtc_read( &Now ) >= 0 )
     73         clock_set( &Now );
     74       }
     75#endif
     76
     77    /* Start by assuming hardware counter is large enough, then */
     78    /* scale it until it actually fits.    */
     79    Clock_driver_ticks = 0;
     80    Clock_isrs_per_tick = 1;
     81
     82    if ( BSP_Configuration.microseconds_per_tick == 0 )
     83       microseconds_per_isr = 10000; /* default 10 ms */
     84    else
     85       microseconds_per_isr = BSP_Configuration.microseconds_per_tick;
     86    while ( US_TO_TICK(microseconds_per_isr) > 65535 )  {
     87      Clock_isrs_per_tick  *= 10;
     88      microseconds_per_isr /= 10;
     89    }
     90
     91    /* Initialize count in ckisr.c */
     92    Clock_isrs = Clock_isrs_per_tick;
     93
     94#if 0
     95    /* This was dropped in the last revision.  Its a nice thing to know. */
     96    TICKS_PER_SECOND = 1000000 / (Clock_isrs_per_tick * microseconds_per_isr);
     97#endif
     98
     99    if ( BSP_Configuration.ticks_per_timeslice )  {
     100      /* 105/88 approximates TIMER_TICK*1e-6 */
     101      unsigned int count = US_TO_TICK( microseconds_per_isr );
     102
     103      Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 );
     104      outport_byte( TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN );
     105      outport_byte( TIMER_CNTR0, count >> 0 & 0xff );
     106      outport_byte( TIMER_CNTR0, count >> 8 & 0xff );
     107    }
     108    atexit( Clock_exit );
     109}
     110
     111void ReInstall_clock(
     112  rtems_isr_entry clock_isr
     113)
     114{
     115  rtems_unsigned32 isrlevel = 0;
     116
     117  rtems_interrupt_disable( isrlevel );
     118   (void) set_vector( clock_isr, CLOCK_VECTOR, 1 );
     119  rtems_interrupt_enable( isrlevel );
     120}
     121
     122void Clock_exit( void )
     123{
     124  if ( BSP_Configuration.ticks_per_timeslice ) {
     125 extern void rtc_set_dos_date( void );
     126
     127 /* reset to DOS value: */
     128 outport_byte( TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN );
     129 outport_byte( TIMER_CNTR0, 0 );
     130 outport_byte( TIMER_CNTR0, 0 );
     131
     132 /* reset time-of-day */
     133 rtc_set_dos_date();
     134 
     135 /* re-enable old handler: assume it was one of ours */
     136 set_vector( (rtems_isr_entry)Old_ticker, CLOCK_VECTOR, 1 );
     137  }
     138}
    21139
    22140rtems_device_driver Clock_initialize(
    23141  rtems_device_major_number major,
    24142  rtems_device_minor_number minor,
    25   void *pargp,
    26   rtems_id tid,
    27   rtems_unsigned32 *rval
     143  void *pargp
    28144)
    29145{
    30146  Install_clock( Clock_isr );
    31 }
    32 
    33 void ReInstall_clock(
    34   rtems_isr_entry clock_isr
    35 )
    36 {
    37   rtems_unsigned32 isrlevel = 0;
    38 
    39   rtems_interrupt_disable( isrlevel );
    40    (void) set_vector( clock_isr, 0x8, 1 );
    41   rtems_interrupt_enable( isrlevel );
    42 }
    43 
    44 void Install_clock(
    45   rtems_isr_entry clock_isr
    46 )
    47 {
    48     unsigned int        microseconds_per_isr;
    49 
    50 #if 0
    51     /* Initialize clock from on-board real time clock.  This breaks the */
    52     /* test code which assumes which assumes the application will do it. */
    53     {
    54         rtems_time_of_day Now;
    55         extern void init_rtc( void );
    56         extern long rtc_read( rtems_time_of_day * tod );
    57         init_rtc();
    58         if ( rtc_read( &Now ) >= 0 )
    59             clock_set( &Now );
    60     }
    61 #endif
    62 
    63     /* Start by assuming hardware counter is large enough, then */
    64     /* scale it until it actually fits.                         */
    65     Clock_driver_ticks = 0;
    66     Clock_isrs_per_tick = 1;
    67 
    68     if ( BSP_Configuration.microseconds_per_tick == 0 )
    69         microseconds_per_isr = 10000;   /* default 10 ms */
    70     else
    71         microseconds_per_isr = BSP_Configuration.microseconds_per_tick;
    72     while ( US_TO_TICK(microseconds_per_isr) > 65535 )  {
    73         Clock_isrs_per_tick  *= 10;
    74         microseconds_per_isr /= 10;
    75     }
    76 
    77     /* Initialize count in ckisr.c */
    78     Clock_isrs = Clock_isrs_per_tick;
    79 
    80 #if 0
    81     /* This was dropped in the last revision.  Its a nice thing to know. */
    82     TICKS_PER_SECOND = 1000000 / (Clock_isrs_per_tick * microseconds_per_isr);
    83 #endif
    84 
    85     if ( BSP_Configuration.ticks_per_timeslice )  {
    86         /* 105/88 approximates TIMER_TICK*1e-6 */
    87         unsigned int count = US_TO_TICK( microseconds_per_isr );
    88 
    89         Old_ticker = (rtems_isr_entry) set_vector( clock_isr, 0x8, 1 );
    90         outport_byte( TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN );
    91         outport_byte( TIMER_CNTR0, count >> 0 & 0xff );
    92         outport_byte( TIMER_CNTR0, count >> 8 & 0xff );
    93     }
    94     atexit( Clock_exit );
    95 }
    96 
    97 void Clock_exit( void )
    98 {
    99   if ( BSP_Configuration.ticks_per_timeslice ) {
    100         extern void rtc_set_dos_date( void );
    101 
    102         /* reset to DOS value: */
    103         outport_byte( TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN );
    104         outport_byte( TIMER_CNTR0, 0 );
    105         outport_byte( TIMER_CNTR0, 0 );
    106 
    107         /* reset time-of-day */
    108         rtc_set_dos_date();
    109        
    110         /* re-enable old handler: assume it was one of ours */
    111         set_vector( (rtems_isr_entry)Old_ticker, 0x8, 1 );
    112   }
    113 }
    114 
     147 
     148  /*
     149   * make major/minor avail to others such as shared memory driver
     150   */
     151 
     152  rtems_clock_major = major;
     153  rtems_clock_minor = minor;
     154 
     155  return RTEMS_SUCCESSFUL;
     156}
     157 
     158rtems_device_driver Clock_control(
     159  rtems_device_major_number major,
     160  rtems_device_minor_number minor,
     161  void *pargp
     162)
     163{
     164    rtems_libio_ioctl_args_t *args = pargp;
     165 
     166    if (args == 0)
     167        goto done;
     168 
     169    /*
     170     * This is hokey, but until we get a defined interface
     171     * to do this, it will just be this simple...
     172     */
     173 
     174    if (args->command == rtems_build_name('I', 'S', 'R', ' '))
     175    {
     176        Clock_isr(CLOCK_VECTOR);
     177    }
     178    else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
     179    {
     180        ReInstall_clock(args->buffer);
     181    }
     182 
     183done:
     184    return RTEMS_SUCCESSFUL;
     185}
    115186
    116187#if 0 && defined(pentium)
    117 /* This can be used to get extremely accurate timing on a pentium.      */
    118 /* It isn't supported. [bryce]                                          */
     188/* This can be used to get extremely accurate timing on a pentium. */
     189/* It isn't supported. [bryce]      */
    119190#define HZ 90.0
    120191volatile long long Last_RDTSC;
    121192#define RDTSC()\
    122193  ({ long long _now; __asm __volatile (".byte 0x0F,0x31":"=A"(_now)); _now; })
     194
    123195long long Kernel_Time_ns( void )
    124196{
     
    129201    disable_intr( flags );
    130202    now = 1e9 * Clock_driver_ticks / isrs_per_second
    131               + (RDTSC() - Last_RDTSC) * (1000.0/HZ);
     203       + (RDTSC() - Last_RDTSC) * (1000.0/HZ);
    132204    enable_intr( flags );
    133205    return now;
  • c/src/lib/libbsp/i386/go32/console/console.c

    r5072b07 r3a4ae6c  
    99#include <stdlib.h>
    1010
    11 #include <rtems.h>
    12 #include "console.h"
    13 #include "bsp.h"
     11#include <bsp.h>
     12#include <rtems/libio.h>
    1413
    1514#include <dpmi.h>
     
    4342 */
    4443
    45 /* Set this if console I/O should use go32 (DOS) read/write calls.      */
    46 /* Otherwise, direct hardware accesses will be used.                    */
    47 int                     _IBMPC_Use_Go32_IO      = 0;
    48 
    49 static rtems_isr_entry  old_keyboard_isr        = NULL;
    50 extern void             _IBMPC_keyboard_isr( rtems_unsigned32 interrupt );
    51 
     44/* Set this if console I/O should use go32 (DOS) read/write calls.   */
     45/* Otherwise, direct hardware accesses will be used.                 */
     46
     47int      _IBMPC_Use_Go32_IO  = 0;
     48
     49static rtems_isr_entry  old_keyboard_isr  = NULL;
     50
     51extern void    _IBMPC_keyboard_isr( rtems_unsigned32 interrupt );
    5252
    5353rtems_device_driver console_initialize(
    5454  rtems_device_major_number  major,
    5555  rtems_device_minor_number  minor,
    56   void                      *arg,
    57   rtems_id                   self,
    58   rtems_unsigned32          *status
    59 )
    60 {
    61     if ( _IBMPC_Use_Go32_IO )  {
    62         /* Nothing.  We let DOS and go32 do all the work. */
    63     } else {
    64         /* Grap the keyboard interrupt so DOS doesn't steal our */
    65         /* keystrokes.                                          */
    66         rtems_status_code       status;
    67         status = rtems_interrupt_catch( _IBMPC_keyboard_isr, 9,
    68                                         &old_keyboard_isr );
    69         if ( status )  {
    70             int write( int, void *, int );
    71             void exit( int );
    72             char msg[] = "error initializing keyboard\n";
    73             write( 2, msg, sizeof msg - 1 );
    74             exit( 1 );
    75         }
     56  void                      *arg
     57)
     58{
     59  rtems_status_code status;
     60
     61  if ( _IBMPC_Use_Go32_IO )  {
     62    /* Nothing.  We let DOS and go32 do all the work. */
     63  } else {
     64    /* Grap the keyboard interrupt so DOS doesn't steal our */
     65    /* keystrokes.                                    */
     66    rtems_status_code  status;
     67
     68    status =
     69      rtems_interrupt_catch( _IBMPC_keyboard_isr, 9, &old_keyboard_isr );
     70
     71    if ( status )  {
     72      int write( int, void *, int );
     73      void exit( int );
     74
     75      char msg[] = "error initializing keyboard\n";
     76      write( 2, msg, sizeof msg - 1 );
     77      exit( 1 );
    7678    }
    77 
    78     atexit( console_cleanup );
     79  }
     80
     81  status = rtems_io_register_name(
     82    "/dev/console",
     83    major,
     84    (rtems_device_minor_number) 0
     85  );
     86 
     87  if (status != RTEMS_SUCCESSFUL)
     88    rtems_fatal_error_occurred(status);
     89 
     90  atexit( console_cleanup );
     91
     92  return RTEMS_SUCCESSFUL;
    7993}
    8094
     
    118132    outbyte( ch );
    119133    if ( ch == '\r' )
    120         outbyte( '\n' );
     134      outbyte( '\n' );
    121135#endif
    122136    return ch;
     
    139153
    140154/*
    141  * __read  -- read bytes from the console. Ignore fd, since
    142  *            we only have stdin.
    143  */
    144 
    145 int __read(
    146   int fd,
    147   char *buf,
    148   int nbytes
    149 )
    150 {
    151   int i = 0;
    152 
    153   for ( i = 0; i < nbytes; i++ ) {
    154     buf[i] = inbyte();
    155     if ( buf[i] == '\r' ) {
    156         /* What if this goes past the end of the buffer?  We're hosed. [bhc] */
    157         buf[i++] = '\n';
    158         buf[i] = '\0';
    159         break;
     155 *  Open entry point
     156 */
     157 
     158rtems_device_driver console_open(
     159  rtems_device_major_number major,
     160  rtems_device_minor_number minor,
     161  void                    * arg
     162)
     163{
     164  return RTEMS_SUCCESSFUL;
     165}
     166
     167/*
     168 *  Close entry point
     169 */
     170 
     171rtems_device_driver console_close(
     172  rtems_device_major_number major,
     173  rtems_device_minor_number minor,
     174  void                    * arg
     175)
     176{
     177  return RTEMS_SUCCESSFUL;
     178}
     179 
     180/*
     181 * read bytes from the serial port. We only have stdin.
     182 */
     183 
     184rtems_device_driver console_read(
     185  rtems_device_major_number major,
     186  rtems_device_minor_number minor,
     187  void                    * arg
     188)
     189{
     190  rtems_libio_rw_args_t *rw_args;
     191  char *buffer;
     192  int maximum;
     193  int count = 0;
     194 
     195  rw_args = (rtems_libio_rw_args_t *) arg;
     196 
     197  buffer = rw_args->buffer;
     198  maximum = rw_args->count;
     199 
     200  for (count = 0; count < maximum; count++) {
     201    buffer[ count ] = inbyte();
     202    if (buffer[ count ] == '\n' || buffer[ count ] == '\r') {
     203      /* What if this goes past the end of the buffer?  We're hosed. [bhc] */
     204      buffer[ count++ ]  = '\n';
     205      buffer[ count ]  = 0;
     206      break;
    160207    }
    161208  }
    162   return i;
    163 }
    164 
    165 /*
    166  * __write -- write bytes to the console. Ignore fd, since
    167  *            stdout and stderr are the same. Since we have no filesystem,
    168  *            open will only return an error.
    169  */
    170 
    171 int __write(
    172   int fd,
    173   char *buf,
    174   int nbytes
    175 )
    176 {
    177   int i;
    178 
    179   for (i = 0; i < nbytes; i++) {
    180     if (*(buf + i) == '\n') {
    181       outbyte ('\r');
     209 
     210  rw_args->bytes_moved = count;
     211  return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED;
     212}
     213 
     214/*
     215 * write bytes to the serial port. Stdout and stderr are the same.
     216 */
     217 
     218rtems_device_driver console_write(
     219  rtems_device_major_number major,
     220  rtems_device_minor_number minor,
     221  void                    * arg
     222)
     223{
     224  int count;
     225  int maximum;
     226  rtems_libio_rw_args_t *rw_args;
     227  char *buffer;
     228 
     229  rw_args = (rtems_libio_rw_args_t *) arg;
     230 
     231  buffer = rw_args->buffer;
     232  maximum = rw_args->count;
     233 
     234  for (count = 0; count < maximum; count++) {
     235    if ( buffer[ count ] == '\n') {
     236      outbyte('\r');
    182237    }
    183     outbyte (*(buf + i));
     238    outbyte( buffer[ count ] );
    184239  }
    185   return (nbytes);
    186 }
     240  return maximum;
     241}
     242 
     243/*
     244 *  IO Control entry point
     245 */
     246 
     247rtems_device_driver console_control(
     248  rtems_device_major_number major,
     249  rtems_device_minor_number minor,
     250  void                    * arg
     251)
     252{
     253  return RTEMS_SUCCESSFUL;
     254}
     255
  • c/src/lib/libbsp/i386/go32/include/bsp.h

    r5072b07 r3a4ae6c  
    2323#include <rtems.h>
    2424#include <iosupp.h>
     25#include <console.h>
     26#include <clockdrv.h>
    2527
    2628/*
     
    125127#endif
    126128
     129/*
     130 *  Device Driver Table Entries
     131 */
     132
     133/*
     134 * NOTE: Use the standard Console driver entry
     135 */
     136 
     137/*
     138 * NOTE: Use the standard Clock driver entry
     139 */
     140
     141/*
     142 * How many libio files we want
     143 */
     144
     145#define BSP_LIBIO_MAX_FDS       20
     146
    127147/* functions */
    128148
     
    134154
    135155extern rtems_configuration_table BSP_Configuration;
    136 
    137 #if 0
    138 extern i386_IDT_slot Interrupt_descriptor_table[ 256 ];
    139 extern i386_GDT_slot Global_descriptor_table[ 8192 ];
    140 BSP_EXTERN unsigned short Idt[3];  /* Interrupt Descriptor Table Address */
    141 BSP_EXTERN unsigned short Gdt[3];  /* Global Descriptor Table Address */
    142 BSP_EXTERN unsigned int   Idt_base;
    143 BSP_EXTERN unsigned int   Gdt_base;
    144 #endif
    145156
    146157/* routines */
  • c/src/lib/libbsp/i386/go32/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>
    26 
     27#include <z8036.h>
     28 
     29#include <string.h>
     30#include <fcntl.h>
     31 
     32#ifdef STACK_CHECKER_ON
    2733#include <stackchk.h>
     34#endif
    2835
    2936/*
     
    3643
    3744rtems_cpu_table Cpu_table;
     45
     46char *rtems_progname;
    3847
    3948/*      Initialize whatever libc we are using
     
    5867
    5968    /*
     69     *  Init the RTEMS libio facility to provide UNIX-like system
     70     *  calls for use by newlib (ie: provide __open, __close, etc)
     71     *  Uses malloc() to get area for the iops, so must be after malloc init
     72     */
     73
     74    rtems_libio_init();
     75
     76    /*
    6077     * Set up for the libc handling.
    6178     */
     
    7592
    7693}
    77 
    78 void bsp_start()
     94 
     95/*
     96 * After drivers are setup, register some "filenames"
     97 * and open stdin, stdout, stderr files
     98 *
     99 * Newlib will automatically associate the files with these
     100 * (it hardcodes the numbers)
     101 */
     102 
     103void
     104bsp_postdriver_hook(void)
    79105{
    80     extern void * sbrk( int );
    81 
    82     Cpu_table.pretasking_hook           = NULL;
    83     Cpu_table.predriver_hook = bsp_libc_init;  /* RTEMS resources available */
    84     Cpu_table.postdriver_hook = NULL;   /* Call our main() for constructors */
    85     Cpu_table.idle_task = NULL;  /* do not override system IDLE task */
    86     Cpu_table.do_zero_of_workspace      = TRUE;
    87     Cpu_table.interrupt_table_segment   = 0;/* get_ds(); */
    88     Cpu_table.interrupt_table_offset    = (void *)0;
    89     Cpu_table.interrupt_stack_size      = 4096;
    90     Cpu_table.extra_system_initialization_stack = 0;
    91 
    92     /*
    93      *  Copy the table
    94      */
    95     BSP_Configuration = Configuration;
    96 
    97     BSP_Configuration.work_space_start = sbrk( Configuration.work_space_size );
    98     if ( BSP_Configuration.work_space_start == 0 )  {
    99         /* Big trouble */
    100         int     write( int, void *, int );
    101         void    _exit( int );
    102         char    msg[] = "bsp_start() couldn't sbrk() RTEMS work space\n";
    103         write( 2, msg, sizeof msg - 1 );
    104         _exit( 1 );
    105     }
    106 
    107     /*
    108      * Add 1 region for Malloc in libc_low
    109      */
    110 
    111     BSP_Configuration.maximum_regions++;
    112 
    113     /*
    114      * Add 1 extension for newlib libc
    115      */
     106  int stdin_fd, stdout_fd, stderr_fd;
     107 
     108  if ((stdin_fd = __open("/dev/console", O_RDONLY, 0)) == -1)
     109    rtems_fatal_error_occurred('STD0');
     110 
     111  if ((stdout_fd = __open("/dev/console", O_WRONLY, 0)) == -1)
     112    rtems_fatal_error_occurred('STD1');
     113 
     114  if ((stderr_fd = __open("/dev/console", O_WRONLY, 0)) == -1)
     115    rtems_fatal_error_occurred('STD2');
     116 
     117  if ((stdin_fd != 0) || (stdout_fd != 1) || (stderr_fd != 2))
     118    rtems_fatal_error_occurred('STIO');
     119}
     120
     121/* This is the original command line passed from DOS */
     122char ** Go32_Argv;
     123
     124int main(
     125  int argc,
     126  char **argv,
     127  char **environp
     128)
     129{
     130  extern void * sbrk( int );
     131  extern volatile void _exit( int );
     132
     133  /* Set up arguments that we can access later */
     134  Go32_Argv = argv;
     135
     136  if ((argc > 0) && argv && argv[0])
     137    rtems_progname = argv[0];
     138  else
     139    rtems_progname = "RTEMS";
     140
     141  Cpu_table.pretasking_hook     = NULL;
     142  Cpu_table.predriver_hook = bsp_libc_init;  /* RTEMS resources available */
     143  Cpu_table.postdriver_hook = bsp_postdriver_hook;
     144  Cpu_table.idle_task = NULL;  /* do not override system IDLE task */
     145  Cpu_table.do_zero_of_workspace = TRUE;
     146  Cpu_table.interrupt_table_segment = 0;/* get_ds(); */
     147  Cpu_table.interrupt_table_offset = (void *)0;
     148  Cpu_table.interrupt_stack_size = 4096;
     149  Cpu_table.extra_system_initialization_stack = 0;
     150
     151  /*
     152   *  Copy the table
     153   */
     154  BSP_Configuration = Configuration;
     155
     156  BSP_Configuration.work_space_start = sbrk( Configuration.work_space_size );
     157  if ( BSP_Configuration.work_space_start == 0 )  {
     158    /* Big trouble */
     159    int write( int, void *, int );
     160    char msg[] = "bsp_start() couldn't sbrk() RTEMS work space\n";
     161    write( 2, msg, sizeof msg - 1 );
     162    _exit( 1 );
     163  }
     164
     165  /*
     166   * Add 1 region for Malloc in libc_low
     167   */
     168
     169  BSP_Configuration.maximum_regions++;
     170
     171  /*
     172   * Add 1 extension for newlib libc
     173   */
    116174
    117175#ifdef RTEMS_NEWLIB
    118     BSP_Configuration.maximum_extensions++;
    119 #endif
    120 
    121     /*
    122      * Add another extension if using the stack checker
    123      */
     176  BSP_Configuration.maximum_extensions++;
     177#endif
     178
     179  /*
     180   * Add another extension if using the stack checker
     181   */
    124182
    125183#ifdef STACK_CHECKER_ON
    126     BSP_Configuration.maximum_extensions++;
    127 #endif
    128 
    129     rtems_initialize_executive( &BSP_Configuration, &Cpu_table );
    130     /* does not return */
    131 
    132     /* no cleanup necessary for GO32 */
     184  BSP_Configuration.maximum_extensions++;
     185#endif
     186
     187  /*
     188   * Tell libio how many fd's we want and allow it to tweak config
     189   */
     190
     191  rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS);
     192
     193  rtems_initialize_executive( &BSP_Configuration, &Cpu_table );
     194  /* does not return */
     195
     196  /* We only return here if the executive has finished.  This happens   */
     197  /* when the task has called exit().                                   */
     198  /* At this point we call _exit() which resides in djgcc.              */
     199   
     200  for (;;)
     201          _exit( 0 );
     202
     203  /* no cleanup necessary for GO32 */
     204
     205  return 0;
    133206}
  • c/src/lib/libbsp/i960/cvme961/clock/ckinit.c

    r5072b07 r3a4ae6c  
    2121#include <stdlib.h>
    2222
    23 #include <rtems.h>
    2423#include <bsp.h>
    25 #include <clockdrv.h>
     24#include <rtems/libio.h>
     25
     26#define CLOCK_VECTOR 5
    2627
    2728rtems_unsigned32 Clock_isrs;              /* ISRs until next tick */
     
    3031                                          /* ticks since initialization */
    3132
    32 rtems_device_driver Clock_initialize(
    33   rtems_device_major_number major,
    34   rtems_device_minor_number minor,
    35   void *pargp,
    36   rtems_id id,
    37   rtems_unsigned32 *rval )
    38 {
    39   Install_clock( Clock_isr );
    40   atexit( Clock_exit );
    41 }
     33void Clock_exit( void );
     34 
     35/*
     36 * These are set by clock driver during its init
     37 */
     38 
     39rtems_device_major_number rtems_clock_major = ~0;
     40rtems_device_minor_number rtems_clock_minor;
    4241
    43 void ReInstall_clock(
    44   rtems_isr_entry clock_isr
    45 )
    46 {
    47    (void) set_vector( clock_isr, 5, 1 );
    48 }
     42
     43/* this is later in the file to avoid it being inlined */
     44rtems_isr Clock_isr( rtems_vector_number vector );
    4945
    5046void Install_clock(
     
    5854
    5955  if ( BSP_Configuration.ticks_per_timeslice ) {
    60     Old_ticker = set_vector( clock_isr, 5, 1 );
     56    Old_ticker = set_vector( clock_isr, CLOCK_VECTOR, 1 );
    6157    victimer = (volatile unsigned char *) 0xa00000c3;
    6258    *victimer = 0x12;
    6359    *victimer = 0x92;      /* 1000 HZ */
    6460  }
     61}
     62
     63void ReInstall_clock(
     64  rtems_isr_entry clock_isr
     65)
     66{
     67   (void) set_vector( clock_isr, CLOCK_VECTOR, 1 );
    6568}
    6669
     
    7679  }
    7780}
     81
     82rtems_device_driver Clock_initialize(
     83  rtems_device_major_number major,
     84  rtems_device_minor_number minor,
     85  void *pargp
     86)
     87{
     88  Install_clock( Clock_isr );
     89 
     90  atexit( Clock_exit );
     91
     92  /*
     93   * make major/minor avail to others such as shared memory driver
     94   */
     95 
     96  rtems_clock_major = major;
     97  rtems_clock_minor = minor;
     98 
     99  return RTEMS_SUCCESSFUL;
     100}
     101 
     102rtems_device_driver Clock_control(
     103  rtems_device_major_number major,
     104  rtems_device_minor_number minor,
     105  void *pargp
     106)
     107{
     108    rtems_libio_ioctl_args_t *args = pargp;
     109 
     110    if (args == 0)
     111        goto done;
     112 
     113    /*
     114     * This is hokey, but until we get a defined interface
     115     * to do this, it will just be this simple...
     116     */
     117 
     118    if (args->command == rtems_build_name('I', 'S', 'R', ' '))
     119    {
     120        Clock_isr(CLOCK_VECTOR);
     121    }
     122    else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
     123    {
     124        ReInstall_clock(args->buffer);
     125    }
     126 
     127done:
     128    return RTEMS_SUCCESSFUL;
     129}
     130
     131rtems_isr Clock_isr(
     132  rtems_vector_number vector
     133)
     134{
     135  /* enable_tracing(); */
     136  Clock_driver_ticks += 1;
     137  if ( Clock_isrs == 1 ) {
     138    rtems_clock_tick();
     139    Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
     140  }
     141  else
     142    Clock_isrs -= 1;
     143  i960_clear_intr( 5 );
     144}
     145
  • c/src/lib/libbsp/i960/cvme961/console/console.c

    r5072b07 r3a4ae6c  
    11/*
    2  *  This file contains the MVME136 console IO package.
     2 *  This file contains the CVME961 console IO package.
    33 *
    44 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
     
    1515#define C961_INIT
    1616
    17 #include <rtems.h>
    18 #include "console.h"
    19 #include "bsp.h"
     17#include <bsp.h>
     18#include <rtems/libio.h>
    2019
    2120/*  console_initialize
     
    3332  rtems_device_major_number  major,
    3433  rtems_device_minor_number  minor,
    35   void                      *arg,
    36   rtems_id                   self,
    37   rtems_unsigned32          *status
    38 )
    39 {
    40   *status = RTEMS_SUCCESSFUL;
     34  void                      *arg
     35)
     36{
     37 rtems_status_code status;
     38 
     39  status = rtems_io_register_name(
     40    "/dev/console",
     41    major,
     42    (rtems_device_minor_number) 0
     43  );
     44 
     45  if (status != RTEMS_SUCCESSFUL)
     46    rtems_fatal_error_occurred(status);
     47 
     48  return RTEMS_SUCCESSFUL;
    4149}
    4250
     
    101109
    102110/*
    103  * __read  -- read bytes from the serial port. Ignore fd, since
    104  *            we only have stdin.
    105  */
    106 
    107 int __read(
    108   int fd,
    109   char *buf,
    110   int nbytes
    111 )
    112 {
    113   int i = 0;
    114 
    115   for (i = 0; i < nbytes; i++) {
    116     *(buf + i) = inbyte();
    117     if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) {
    118       (*(buf + i++)) = '\n';
    119       (*(buf + i)) = 0;
     111 *  Open entry point
     112 */
     113 
     114rtems_device_driver console_open(
     115  rtems_device_major_number major,
     116  rtems_device_minor_number minor,
     117  void                    * arg
     118)
     119{
     120  return RTEMS_SUCCESSFUL;
     121}
     122 
     123/*
     124 *  Close entry point
     125 */
     126 
     127rtems_device_driver console_close(
     128  rtems_device_major_number major,
     129  rtems_device_minor_number minor,
     130  void                    * arg
     131)
     132{
     133  return RTEMS_SUCCESSFUL;
     134}
     135 
     136/*
     137 * read bytes from the serial port. We only have stdin.
     138 */
     139 
     140rtems_device_driver console_read(
     141  rtems_device_major_number major,
     142  rtems_device_minor_number minor,
     143  void                    * arg
     144)
     145{
     146  rtems_libio_rw_args_t *rw_args;
     147  char *buffer;
     148  int maximum;
     149  int count = 0;
     150 
     151  rw_args = (rtems_libio_rw_args_t *) arg;
     152 
     153  buffer = rw_args->buffer;
     154  maximum = rw_args->count;
     155 
     156  for (count = 0; count < maximum; count++) {
     157    buffer[ count ] = inbyte();
     158    if (buffer[ count ] == '\n' || buffer[ count ] == '\r') {
     159      buffer[ count++ ]  = '\n';
     160      buffer[ count ]  = 0;
    120161      break;
    121162    }
    122163  }
    123   return (i);
    124 }
    125 
    126 /*
    127  * __write -- write bytes to the serial port. Ignore fd, since
    128  *            stdout and stderr are the same. Since we have no filesystem,
    129  *            open will only return an error.
    130  */
    131 
    132 int __write(
    133   int fd,
    134   char *buf,
    135   int nbytes
    136 )
    137 {
    138   int i;
    139 
    140   for (i = 0; i < nbytes; i++) {
    141     if (*(buf + i) == '\n') {
    142       outbyte ('\r');
     164 
     165  rw_args->bytes_moved = count;
     166  return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED;
     167}
     168 
     169/*
     170 * write bytes to the serial port. Stdout and stderr are the same.
     171 */
     172 
     173rtems_device_driver console_write(
     174  rtems_device_major_number major,
     175  rtems_device_minor_number minor,
     176  void                    * arg
     177)
     178{
     179  int count;
     180  int maximum;
     181  rtems_libio_rw_args_t *rw_args;
     182  char *buffer;
     183 
     184  rw_args = (rtems_libio_rw_args_t *) arg;
     185 
     186  buffer = rw_args->buffer;
     187  maximum = rw_args->count;
     188 
     189  for (count = 0; count < maximum; count++) {
     190    if ( buffer[ count ] == '\n') {
     191      outbyte('\r');
    143192    }
    144     outbyte (*(buf + i));
     193    outbyte( buffer[ count ] );
    145194  }
    146   return (nbytes);
    147 }
     195  return maximum;
     196}
     197 
     198/*
     199 *  IO Control entry point
     200 */
     201 
     202rtems_device_driver console_control(
     203  rtems_device_major_number major,
     204  rtems_device_minor_number minor,
     205  void                    * arg
     206)
     207{
     208  return RTEMS_SUCCESSFUL;
     209}
     210
  • c/src/lib/libbsp/i960/cvme961/include/bsp.h

    r5072b07 r3a4ae6c  
    2525#include <rtems.h>
    2626#include <iosupp.h>
     27#include <console.h>
     28#include <clockdrv.h>
    2729
    2830/*
     
    116118BSP_EXTERN i960ca_control_table *Ctl_tbl;
    117119
     120/*
     121 *  Device Driver Table Entries
     122 */
     123
     124/*
     125 * NOTE: Use the standard Console driver entry
     126 */
     127 
     128/*
     129 * NOTE: Use the standard Clock driver entry
     130 */
     131
     132/*
     133 * How many libio files we want
     134 */
     135
     136#define BSP_LIBIO_MAX_FDS       20
     137
    118138/* functions */
    119139
  • c/src/lib/libbsp/i960/cvme961/startup/bspstart.c

    r5072b07 r3a4ae6c  
    2121 */
    2222
    23 #include <rtems.h>
    2423#include <bsp.h>
    25 #include "libcsupport.h"
    26 
    27 
    28 #include "stackchk.h"
     24#include <rtems/libio.h>
     25 
     26#include <libcsupport.h>
     27 
     28#include <string.h>
     29#include <fcntl.h>
     30 
     31#ifdef STACK_CHECKER_ON
     32#include <stackchk.h>
     33#endif
    2934
    3035/*
     
    3843
    3944rtems_cpu_table Cpu_table;
     45
     46char *rtems_progname;
    4047
    4148/*      Initialize whatever libc we are using
     
    5360
    5461    RTEMS_Malloc_Initialize((void *) heap_start, 64 * 1024, 0);
     62
     63    /*
     64     *  Init the RTEMS libio facility to provide UNIX-like system
     65     *  calls for use by newlib (ie: provide __open, __close, etc)
     66     *  Uses malloc() to get area for the iops, so must be after malloc init
     67     */
     68
     69    rtems_libio_init();
    5570
    5671    /*
     
    7186}
    7287
    73 int bsp_start(
     88/*
     89 * After drivers are setup, register some "filenames"
     90 * and open stdin, stdout, stderr files
     91 *
     92 * Newlib will automatically associate the files with these
     93 * (it hardcodes the numbers)
     94 */
     95 
     96void
     97bsp_postdriver_hook(void)
     98{
     99  int stdin_fd, stdout_fd, stderr_fd;
     100 
     101  if ((stdin_fd = __open("/dev/console", O_RDONLY, 0)) == -1)
     102    rtems_fatal_error_occurred('STD0');
     103 
     104  if ((stdout_fd = __open("/dev/console", O_WRONLY, 0)) == -1)
     105    rtems_fatal_error_occurred('STD1');
     106 
     107  if ((stderr_fd = __open("/dev/console", O_WRONLY, 0)) == -1)
     108    rtems_fatal_error_occurred('STD2');
     109 
     110  if ((stdin_fd != 0) || (stdout_fd != 1) || (stderr_fd != 2))
     111    rtems_fatal_error_occurred('STIO');
     112}
     113
     114int main(
    74115  int argc,
    75116  char **argv,
     
    77118)
    78119{
     120  if ((argc > 0) && argv && argv[0])
     121    rtems_progname = argv[0];
     122  else
     123    rtems_progname = "RTEMS";
     124
    79125  /* set node number in SQSIO4 CTL REG */
    80126
     
    111157  Cpu_table.predriver_hook = bsp_libc_init;  /* RTEMS resources available */
    112158
    113   Cpu_table.postdriver_hook = NULL;   /* Call our main() for constructors */
     159  Cpu_table.postdriver_hook = bsp_postdriver_hook;
    114160
    115161  Cpu_table.idle_task = NULL;  /* do not override system IDLE task */
     
    151197#endif
    152198
     199  /*
     200   * Tell libio how many fd's we want and allow it to tweak config
     201   */
     202
     203  rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS);
     204
    153205  BSP_Configuration.work_space_start = (void *)
    154206     (RAM_END - BSP_Configuration.work_space_size);
  • c/src/lib/libbsp/m68k/dmv152/clock/ckinit.c

    r5072b07 r3a4ae6c  
    2020
    2121#include <stdlib.h>
    22 
    23 #include <rtems.h>
     22 
    2423#include <bsp.h>
    25 #include <clockdrv.h>
     24#include <rtems/libio.h>
    2625
    2726rtems_unsigned32 Clock_isrs;        /* ISRs until next tick */
     
    3029rtems_isr_entry  Old_ticker;
    3130
    32 rtems_device_driver Clock_initialize(
    33   rtems_device_major_number major,
    34   rtems_device_minor_number minor,
    35   void *pargp,
    36   rtems_id tid,
    37   rtems_unsigned32 *rval
     31void Clock_exit( void );
     32
     33#define CLOCK_VECTOR  TIMER_VECTOR
     34 
     35/*
     36 * These are set by clock driver during its init
     37 */
     38 
     39rtems_device_major_number rtems_clock_major = ~0;
     40rtems_device_minor_number rtems_clock_minor;
     41
     42/*
     43 *  ISR Handler
     44 */
     45
     46rtems_isr Clock_isr(
     47  rtems_vector_number vector
    3848)
    3949{
    40   Install_clock( Clock_isr );
    41 }
     50  Clock_driver_ticks += 1;
    4251
    43 void ReInstall_clock(
    44   rtems_isr_entry clock_isr
    45 )
    46 {
    47   rtems_unsigned32 isrlevel = 0 ;
     52  Z8x36_WRITE( TIMER, CT1_CMD_STATUS, 0xE2 );
     53  Z8x36_WRITE( TIMER, CT1_CMD_STATUS, 0x22 );
     54  Z8x36_WRITE( TIMER, CT1_CMD_STATUS, 0xC6 );
    4855
    49   rtems_interrupt_disable( isrlevel );
    50    (void) set_vector( clock_isr, TIMER_VECTOR, 1 );
    51   rtems_interrupt_enable( isrlevel );
     56  if ( Clock_isrs == 1 ) {
     57    rtems_clock_tick();
     58    Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
     59  }
     60  else
     61    Clock_isrs -= 1;
    5262}
    5363
     
    6272
    6373  if ( BSP_Configuration.ticks_per_timeslice ) {
    64     Old_ticker = (rtems_isr_entry) set_vector( clock_isr, TIMER_VECTOR, 1 );
     74    Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 );
    6575
    6676    Z8x36_WRITE( TIMER, MASTER_CFG, 0xd4 );
     
    7080    Z8x36_WRITE( TIMER, CT1_TIME_CONST_LSB, 0xCE );
    7181    Z8x36_WRITE( TIMER, CT1_MODE_SPEC, 0x83 );
    72     Z8x36_WRITE( TIMER, CNT_TMR_VECTOR, TIMER_VECTOR );
     82    Z8x36_WRITE( TIMER, CNT_TMR_VECTOR, CLOCK_VECTOR );
    7383    Z8x36_WRITE( TIMER, CT1_CMD_STATUS, 0x20 );
    7484    Z8x36_READ ( TIMER, MASTER_INTR, data );
     
    8898}
    8999
     100void ReInstall_clock(
     101  rtems_isr_entry clock_isr
     102)
     103{
     104  rtems_unsigned32 isrlevel = 0 ;
     105
     106  rtems_interrupt_disable( isrlevel );
     107   (void) set_vector( clock_isr, CLOCK_VECTOR, 1 );
     108  rtems_interrupt_enable( isrlevel );
     109}
     110
    90111void Clock_exit( void )
    91112{
     
    100121  }
    101122}
     123
     124rtems_device_driver Clock_initialize(
     125  rtems_device_major_number major,
     126  rtems_device_minor_number minor,
     127  void *pargp
     128)
     129{
     130  Install_clock( Clock_isr );
     131 
     132  /*
     133   * make major/minor avail to others such as shared memory driver
     134   */
     135 
     136  rtems_clock_major = major;
     137  rtems_clock_minor = minor;
     138 
     139  return RTEMS_SUCCESSFUL;
     140}
     141 
     142rtems_device_driver Clock_control(
     143  rtems_device_major_number major,
     144  rtems_device_minor_number minor,
     145  void *pargp
     146)
     147{
     148    rtems_libio_ioctl_args_t *args = pargp;
     149 
     150    if (args == 0)
     151        goto done;
     152 
     153    /*
     154     * This is hokey, but until we get a defined interface
     155     * to do this, it will just be this simple...
     156     */
     157 
     158    if (args->command == rtems_build_name('I', 'S', 'R', ' '))
     159    {
     160        Clock_isr(CLOCK_VECTOR);
     161    }
     162    else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
     163    {
     164        ReInstall_clock(args->buffer);
     165    }
     166 
     167done:
     168    return RTEMS_SUCCESSFUL;
     169}
     170
  • c/src/lib/libbsp/m68k/dmv152/console/console.c

    r5072b07 r3a4ae6c  
    1515#define D152_INIT
    1616
    17 #include <rtems.h>
    18 #include "console.h"
    19 #include "bsp.h"
    20 
     17#include <bsp.h>
     18#include <rtems/libio.h>
     19 
    2120/*  console_initialize
    2221 *
     
    2928 *  Return values:
    3029 */
    31 
     30 
    3231rtems_device_driver console_initialize(
    3332  rtems_device_major_number  major,
    3433  rtems_device_minor_number  minor,
    35   void                      *arg,
    36   rtems_id                   self,
    37   rtems_unsigned32          *status
    38 )
    39 {
    40   *status = RTEMS_SUCCESSFUL;
    41 }
    42 
     34  void                      *arg
     35)
     36{
     37  rtems_status_code status;
     38 
     39  status = rtems_io_register_name(
     40    "/dev/console",
     41    major,
     42    (rtems_device_minor_number) 0
     43  );
     44 
     45  if (status != RTEMS_SUCCESSFUL)
     46    rtems_fatal_error_occurred(status);
     47 
     48  return RTEMS_SUCCESSFUL;
     49}
    4350
    4451/*  is_character_ready
     
    140147
    141148/*
    142  * __read  -- read bytes from the serial port. Ignore fd, since
    143  *            we only have stdin.
    144  */
    145 
    146 int __read(
    147   int fd,
    148   char *buf,
    149   int nbytes
    150 )
    151 {
    152   int i = 0;
    153 
    154   for (i = 0; i < nbytes; i++) {
    155     *(buf + i) = inbyte();
    156     if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) {
    157       (*(buf + i++)) = '\n';
    158       (*(buf + i)) = 0;
     149 *  Open entry point
     150 */
     151
     152rtems_device_driver console_open(
     153  rtems_device_major_number major,
     154  rtems_device_minor_number minor,
     155  void                    * arg
     156)
     157{
     158  return RTEMS_SUCCESSFUL;
     159}
     160 
     161/*
     162 *  Close entry point
     163 */
     164
     165rtems_device_driver console_close(
     166  rtems_device_major_number major,
     167  rtems_device_minor_number minor,
     168  void                    * arg
     169)
     170{
     171  return RTEMS_SUCCESSFUL;
     172}
     173
     174/*
     175 * read bytes from the serial port. We only have stdin.
     176 */
     177
     178rtems_device_driver console_read(
     179  rtems_device_major_number major,
     180  rtems_device_minor_number minor,
     181  void                    * arg
     182)
     183{
     184  rtems_libio_rw_args_t *rw_args;
     185  char *buffer;
     186  int maximum;
     187  int count = 0;
     188 
     189  rw_args = (rtems_libio_rw_args_t *) arg;
     190
     191  buffer = rw_args->buffer;
     192  maximum = rw_args->count;
     193
     194  for (count = 0; count < maximum; count++) {
     195    buffer[ count ] = inbyte();
     196    if (buffer[ count ] == '\n' || buffer[ count ] == '\r') {
     197      buffer[ count++ ]  = '\n';
     198      buffer[ count ]  = 0;
    159199      break;
    160200    }
    161201  }
    162   return (i);
    163 }
    164 
    165 /*
    166  * __write -- write bytes to the serial port. Ignore fd, since
    167  *            stdout and stderr are the same. Since we have no filesystem,
    168  *            open will only return an error.
    169  */
    170 
    171 int __write(
    172   int fd,
    173   char *buf,
    174   int nbytes
    175 )
    176 {
    177   int i;
    178 
    179   for (i = 0; i < nbytes; i++) {
    180     if (*(buf + i) == '\n') {
    181       outbyte ('\r');
     202
     203  rw_args->bytes_moved = count;
     204  return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED;
     205}
     206
     207/*
     208 * write bytes to the serial port. Stdout and stderr are the same.
     209 */
     210
     211rtems_device_driver console_write(
     212  rtems_device_major_number major,
     213  rtems_device_minor_number minor,
     214  void                    * arg
     215)
     216{
     217  int count;
     218  int maximum;
     219  rtems_libio_rw_args_t *rw_args;
     220  char *buffer;
     221
     222  rw_args = (rtems_libio_rw_args_t *) arg;
     223
     224  buffer = rw_args->buffer;
     225  maximum = rw_args->count;
     226
     227  for (count = 0; count < maximum; count++) {
     228    if ( buffer[ count ] == '\n') {
     229      outbyte('\r');
    182230    }
    183     outbyte (*(buf + i));
    184   }
    185   return (nbytes);
    186 }
     231    outbyte( buffer[ count ] );
     232  }
     233  return maximum;
     234}
     235
     236/*
     237 *  IO Control entry point
     238 */
     239
     240rtems_device_driver console_control(
     241  rtems_device_major_number major,
     242  rtems_device_minor_number minor,
     243  void                    * arg
     244)
     245{
     246  return RTEMS_SUCCESSFUL;
     247}
  • c/src/lib/libbsp/m68k/dmv152/include/bsp.h

    r5072b07 r3a4ae6c  
    2222
    2323#include <rtems.h>
     24#include <console.h>
     25#include <clockdrv.h>
    2426#include <iosupp.h>
     27#include <vmeintr.h>
    2528#include <z8530.h>
    2629#include <z8536.h>
     
    152155extern m68k_isr_entry M68Kvec[];   /* vector table address */
    153156
     157/*
     158 *  Device Driver Table Entries
     159 */
     160
     161/*
     162 * NOTE: Use the standard Console driver entry
     163 */
     164 
     165/*
     166 * NOTE: Use the standard Clock driver entry
     167 */
     168
     169/*
     170 * How many libio files we want
     171 */
     172
     173#define BSP_LIBIO_MAX_FDS       20
     174
    154175/* functions */
    155176
  • c/src/lib/libbsp/m68k/dmv152/startup/bspstart.c

    r5072b07 r3a4ae6c  
    2222 */
    2323
    24 #include <rtems.h>
    2524#include <bsp.h>
     25#include <rtems/libio.h>
     26 
    2627#include <libcsupport.h>
    27 #include <vmeintr.h>
    28 
     28 
     29#include <string.h>
     30#include <fcntl.h>
     31 
     32#ifdef STACK_CHECKER_ON
     33#include <stackchk.h>
     34#endif
    2935/*
    3036 *  The original table from the application and our copy of it with
     
    3642
    3743rtems_cpu_table Cpu_table;
     44
     45char *rtems_progname;
    3846
    3947/*      Initialize whatever libc we are using
     
    5361
    5462    /*
     63     *  Init the RTEMS libio facility to provide UNIX-like system
     64     *  calls for use by newlib (ie: provide __open, __close, etc)
     65     *  Uses malloc() to get area for the iops, so must be after malloc init
     66     */
     67
     68    rtems_libio_init();
     69
     70    /*
    5571     * Set up for the libc handling.
    5672     */
     
    7086}
    7187
    72 int bsp_start(
     88/*
     89 * After drivers are setup, register some "filenames"
     90 * and open stdin, stdout, stderr files
     91 *
     92 * Newlib will automatically associate the files with these
     93 * (it hardcodes the numbers)
     94 */
     95 
     96void
     97bsp_postdriver_hook(void)
     98{
     99  int stdin_fd, stdout_fd, stderr_fd;
     100 
     101  if ((stdin_fd = __open("/dev/console", O_RDONLY, 0)) == -1)
     102    rtems_fatal_error_occurred('STD0');
     103 
     104  if ((stdout_fd = __open("/dev/console", O_WRONLY, 0)) == -1)
     105    rtems_fatal_error_occurred('STD1');
     106 
     107  if ((stderr_fd = __open("/dev/console", O_WRONLY, 0)) == -1)
     108    rtems_fatal_error_occurred('STD2');
     109 
     110  if ((stdin_fd != 0) || (stdout_fd != 1) || (stderr_fd != 2))
     111    rtems_fatal_error_occurred('STIO');
     112}
     113
     114int main(
    73115  int argc,
    74116  char **argv,
     
    80122  void           *vbr;
    81123
     124  if ((argc > 0) && argv && argv[0])
     125    rtems_progname = argv[0];
     126  else
     127    rtems_progname = "RTEMS";
     128
    82129  monitors_vector_table = (m68k_isr_entry *)0;   /* Monitor Vectors are at 0 */
    83130  m68k_set_vbr( monitors_vector_table );
     
    116163  Cpu_table.predriver_hook = bsp_libc_init;  /* RTEMS resources available */
    117164
    118   Cpu_table.postdriver_hook = NULL;   /* Call our main() for constructors */
     165  Cpu_table.postdriver_hook = bsp_postdriver_hook;
    119166
    120167  Cpu_table.idle_task = NULL;  /* do not override system IDLE task */
     
    159206    BSP_Configuration.maximum_extensions++;
    160207#endif
     208
     209  /*
     210   * Tell libio how many fd's we want and allow it to tweak config
     211   */
     212
     213  rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS);
    161214
    162215  rtems_initialize_executive( &BSP_Configuration, &Cpu_table );
  • c/src/lib/libbsp/m68k/gen68302/clock/ckinit.c

    r5072b07 r3a4ae6c  
    2121#include <stdlib.h>                     /* for atexit() */
    2222
    23 #include <rtems.h>
    2423#include <bsp.h>
    25 #include <clockdrv.h>
     24#include <rtems/libio.h>
     25
    2626#include "m68302.h"
    2727
     28#define CLOCK_VECTOR 137
    2829
    2930#define TMR1_VAL (  RBIT_TMR_RST        /* software reset the timer */\
     
    5051rtems_unsigned32 Clock_isrs;
    5152
     53void Clock_exit( void );
     54 
     55/*
     56 * These are set by clock driver during its init
     57 */
     58 
     59rtems_device_major_number rtems_clock_major = ~0;
     60rtems_device_minor_number rtems_clock_minor;
    5261
    53 rtems_device_driver Clock_initialize(
    54   rtems_device_major_number major,
    55   rtems_device_minor_number minor,
    56   void *pargp,
    57   rtems_id tid,
    58   rtems_unsigned32 *rval
     62/*
     63 *  ISR Handler
     64 */
     65
     66rtems_isr Clock_isr(
     67  rtems_vector_number vector
    5968)
    6069{
    61   Install_clock( Clock_isr );
     70  Clock_driver_ticks += 1;
     71
     72  m302.reg.isr  = RBIT_ISR_TIMER1;      /* clear in-service bit */
     73  m302.reg.ter1 = (RBIT_TER_REF | RBIT_TER_CAP); /* clear timer intr request */
     74
     75  if ( Clock_isrs == 1 ) {
     76    rtems_clock_tick();
     77    Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
     78  }
     79  else
     80    Clock_isrs -= 1;
    6281}
    63 
    6482
    6583void Install_clock(
     
    7290
    7391  if ( BSP_Configuration.ticks_per_timeslice ) {
    74 /*  set_vector( clock_isr, 137, 1 );*/
     92/*  set_vector( clock_isr, CLOCK_VECTOR, 1 );*/
    7593
    7694    m302.reg.trr1 = TRR1_VAL;           /* set timer reference register */
     
    85103}
    86104
     105void ReInstall_clock(
     106  rtems_isr_entry clock_isr
     107)
     108{
     109  rtems_unsigned32 isrlevel;
     110 
     111  rtems_interrupt_disable( isrlevel );
     112   /* (void) set_vector( clock_isr, CLOCK_VECTOR, 1 ); */
     113  rtems_interrupt_enable( isrlevel );
     114}
    87115
    88116void Clock_exit( void )
     
    93121  }
    94122}
     123
     124rtems_device_driver Clock_initialize(
     125  rtems_device_major_number major,
     126  rtems_device_minor_number minor,
     127  void *pargp
     128)
     129{
     130  Install_clock( Clock_isr );
     131 
     132  /*
     133   * make major/minor avail to others such as shared memory driver
     134   */
     135 
     136  rtems_clock_major = major;
     137  rtems_clock_minor = minor;
     138 
     139  return RTEMS_SUCCESSFUL;
     140}
     141 
     142rtems_device_driver Clock_control(
     143  rtems_device_major_number major,
     144  rtems_device_minor_number minor,
     145  void *pargp
     146)
     147{
     148    rtems_libio_ioctl_args_t *args = pargp;
     149 
     150    if (args == 0)
     151        goto done;
     152 
     153    /*
     154     * This is hokey, but until we get a defined interface
     155     * to do this, it will just be this simple...
     156     */
     157 
     158    if (args->command == rtems_build_name('I', 'S', 'R', ' '))
     159    {
     160        Clock_isr( CLOCK_VECTOR);
     161    }
     162    else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
     163    {
     164        ReInstall_clock(args->buffer);
     165    }
     166 
     167done:
     168    return RTEMS_SUCCESSFUL;
     169}
     170
  • c/src/lib/libbsp/m68k/gen68302/console/console.c

    r5072b07 r3a4ae6c  
    1515#define GEN68302_INIT
    1616
    17 #include <rtems.h>
    18 #include "console.h"
    1917#include <bsp.h>
     18#include <rtems/libio.h>
    2019
    2120#include "m68302.h"
     
    3534  rtems_device_major_number  major,
    3635  rtems_device_minor_number  minor,
    37   void                      *arg,
    38   rtems_id                   self,
    39   rtems_unsigned32          *status
    40 )
    41 {
     36  void                      *arg
     37)
     38{
     39  rtems_status_code status;
    4240  volatile m302_dualPortRAM_t *p = &m302;
    4341
     
    8280  p->reg.scc[1].scm  = 0x01BD;
    8381
    84   *status = RTEMS_SUCCESSFUL;
    85 }
    86 
     82  status = rtems_io_register_name(
     83    "/dev/console",
     84    major,
     85    (rtems_device_minor_number) 0
     86  );
     87 
     88  if (status != RTEMS_SUCCESSFUL)
     89    rtems_fatal_error_occurred(status);
     90 
     91  return RTEMS_SUCCESSFUL;
     92
     93}
    8794
    8895/*  is_character_ready
     
    195202
    196203/*
    197  * __read  -- read bytes from the serial port. Ignore fd, since
    198  *            we only have stdin.
    199  */
    200 
    201 int __read(
    202   int fd,
    203   char *buf,
    204   int nbytes
    205 )
    206 {
    207   int i = 0;
    208 
    209   for (i = 0; i < nbytes; i++) {
    210     *(buf + i) = inbyte();
    211     if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) {
    212       (*(buf + i++)) = '\n';
    213       (*(buf + i)) = 0;
     204 *  Open entry point
     205 */
     206
     207rtems_device_driver console_open(
     208  rtems_device_major_number major,
     209  rtems_device_minor_number minor,
     210  void                    * arg
     211)
     212{
     213  return RTEMS_SUCCESSFUL;
     214}
     215 
     216/*
     217 *  Close entry point
     218 */
     219
     220rtems_device_driver console_close(
     221  rtems_device_major_number major,
     222  rtems_device_minor_number minor,
     223  void                    * arg
     224)
     225{
     226  return RTEMS_SUCCESSFUL;
     227}
     228
     229/*
     230 * read bytes from the serial port. We only have stdin.
     231 */
     232
     233rtems_device_driver console_read(
     234  rtems_device_major_number major,
     235  rtems_device_minor_number minor,
     236  void                    * arg
     237)
     238{
     239  rtems_libio_rw_args_t *rw_args;
     240  char *buffer;
     241  int maximum;
     242  int count = 0;
     243 
     244  rw_args = (rtems_libio_rw_args_t *) arg;
     245
     246  buffer = rw_args->buffer;
     247  maximum = rw_args->count;
     248
     249  for (count = 0; count < maximum; count++) {
     250    buffer[ count ] = inbyte();
     251    if (buffer[ count ] == '\n' || buffer[ count ] == '\r') {
     252      buffer[ count++ ]  = '\n';
     253      buffer[ count ]  = 0;
    214254      break;
    215255    }
    216256  }
    217   return (i);
    218 }
    219 
    220 /*
    221  * __write -- write bytes to the serial port. Ignore fd, since
    222  *            stdout and stderr are the same. Since we have no filesystem,
    223  *            open will only return an error.
    224  */
    225 
    226 int __write(
    227   int fd,
    228   char *buf,
    229   int nbytes
    230 )
    231 {
    232   int i;
    233 
    234   for (i = 0; i < nbytes; i++) {
    235     if (*(buf + i) == '\n') {
    236       outbyte ('\r');
     257
     258  rw_args->bytes_moved = count;
     259  return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED;
     260}
     261
     262/*
     263 * write bytes to the serial port. Stdout and stderr are the same.
     264 */
     265
     266rtems_device_driver console_write(
     267  rtems_device_major_number major,
     268  rtems_device_minor_number minor,
     269  void                    * arg
     270)
     271{
     272  int count;
     273  int maximum;
     274  rtems_libio_rw_args_t *rw_args;
     275  char *buffer;
     276
     277  rw_args = (rtems_libio_rw_args_t *) arg;
     278
     279  buffer = rw_args->buffer;
     280  maximum = rw_args->count;
     281
     282  for (count = 0; count < maximum; count++) {
     283    if ( buffer[ count ] == '\n') {
     284      outbyte('\r');
    237285    }
    238     outbyte (*(buf + i));
     286    outbyte( buffer[ count ] );
    239287  }
    240   return (nbytes);
    241 }
     288  return maximum;
     289}
     290
     291/*
     292 *  IO Control entry point
     293 */
     294
     295rtems_device_driver console_control(
     296  rtems_device_major_number major,
     297  rtems_device_minor_number minor,
     298  void                    * arg
     299)
     300{
     301  return RTEMS_SUCCESSFUL;
     302}
  • c/src/lib/libbsp/m68k/gen68302/include/bsp.h

    r5072b07 r3a4ae6c  
    2424
    2525#include <rtems.h>
     26#include <console.h>
    2627#include <iosupp.h>
     28#include <clockdrv.h>
    2729
    2830/*
     
    8284#endif
    8385
     86/*
     87 *  Device Driver Table Entries
     88 */
     89
     90/*
     91 * NOTE: Use the standard Console driver entry
     92 */
     93 
     94/*
     95 * NOTE: Use the standard Clock driver entry
     96 */
     97
     98/*
     99 * How many libio files we want
     100 */
     101
     102#define BSP_LIBIO_MAX_FDS       20
     103
    84104/* miscellaneous stuff assumed to exist */
    85105
  • c/src/lib/libbsp/m68k/gen68302/start/start302.s

    r5072b07 r3a4ae6c  
    228228#endif
    229229
    230         jsr     SYM (bsp_start)
     230        move.l  #0,a7@-               | environp
     231        move.l  #0,a7@-               | argv
     232        move.l  #0,a7@-               | argc
     233        jsr     SYM (main)
    231234
    232235        nop
  • c/src/lib/libbsp/m68k/gen68302/start302/start302.s

    r5072b07 r3a4ae6c  
    228228#endif
    229229
    230         jsr     SYM (bsp_start)
     230        move.l  #0,a7@-               | environp
     231        move.l  #0,a7@-               | argv
     232        move.l  #0,a7@-               | argc
     233        jsr     SYM (main)
    231234
    232235        nop
  • c/src/lib/libbsp/m68k/gen68302/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>
    26 
     27 
     28#include <string.h>
     29#include <fcntl.h>
     30 
     31#ifdef STACK_CHECKER_ON
     32#include <stackchk.h>
     33#endif
    2734
    2835/*
     
    3542
    3643rtems_cpu_table Cpu_table;
     44
     45char *rtems_progname;
    3746
    3847/*      Initialize whatever libc we are using
     
    5968
    6069    /*
     70     *  Init the RTEMS libio facility to provide UNIX-like system
     71     *  calls for use by newlib (ie: provide __open, __close, etc)
     72     *  Uses malloc() to get area for the iops, so must be after malloc init
     73     */
     74
     75    rtems_libio_init();
     76
     77    /*
    6178     * Set up for the libc handling.
    6279     */
     
    7693}
    7794
    78 
    79 int bsp_start(
     95/*
     96 * After drivers are setup, register some "filenames"
     97 * and open stdin, stdout, stderr files
     98 *
     99 * Newlib will automatically associate the files with these
     100 * (it hardcodes the numbers)
     101 */
     102 
     103void
     104bsp_postdriver_hook(void)
     105{
     106  int stdin_fd, stdout_fd, stderr_fd;
     107 
     108  if ((stdin_fd = __open("/dev/console", O_RDONLY, 0)) == -1)
     109    rtems_fatal_error_occurred('STD0');
     110 
     111  if ((stdout_fd = __open("/dev/console", O_WRONLY, 0)) == -1)
     112    rtems_fatal_error_occurred('STD1');
     113 
     114  if ((stderr_fd = __open("/dev/console", O_WRONLY, 0)) == -1)
     115    rtems_fatal_error_occurred('STD2');
     116 
     117  if ((stdin_fd != 0) || (stdout_fd != 1) || (stderr_fd != 2))
     118    rtems_fatal_error_occurred('STIO');
     119}
     120
     121int main(
    80122  int argc,
    81123  char **argv,
     
    83125)
    84126{
     127  if ((argc > 0) && argv && argv[0])
     128    rtems_progname = argv[0];
     129  else
     130    rtems_progname = "RTEMS";
     131
    85132  /*
    86133   *  Allocate the memory for the RTEMS Work Space.  This can come from
     
    91138   */
    92139#if 0
    93 a  Cpu_table.interrupt_vector_table = (mc68000_isr *) 0/*&M68Kvec*/;
     140  Cpu_table.interrupt_vector_table = (mc68000_isr *) 0/*&M68Kvec*/;
    94141#endif
    95142
     
    122169    BSP_Configuration.maximum_extensions++;
    123170#endif
     171
     172  /*
     173   * Tell libio how many fd's we want and allow it to tweak config
     174   */
     175
     176  rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS);
    124177
    125178  /*
     
    144197  Cpu_table.predriver_hook = bsp_libc_init;    /* RTEMS resources available */
    145198
    146   Cpu_table.postdriver_hook = NULL;
     199  Cpu_table.postdriver_hook = bsp_postdriver_hook;
    147200
    148201  Cpu_table.idle_task = NULL;  /* do not override system IDLE task */
  • 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 */
  • c/src/lib/libbsp/m68k/mvme136/clock/ckinit.c

    r5072b07 r3a4ae6c  
    2121#include <stdlib.h>
    2222
    23 #include <rtems.h>
    2423#include <bsp.h>
    25 #include <clockdrv.h>
     24#include <rtems/libio.h>
    2625#include <z8036.h>
    2726
     
    3635                                    /*   and trigger countdown */
    3736
     37#define TIMER        0xfffb0000
     38#define RELOAD       0x24            /* clr IP & IUS,allow countdown */
     39 
     40#define CLOCK_VECTOR 66
     41
    3842rtems_unsigned32 Clock_isrs;        /* ISRs until next tick */
    39 volatile rtems_unsigned32 Clock_driver_ticks;
    40                                     /* ticks since initialization */
     43
     44volatile rtems_unsigned32 Clock_driver_ticks; /* ticks since initialization */
     45
    4146rtems_isr_entry  Old_ticker;
    4247
    43 rtems_device_driver Clock_initialize(
    44   rtems_device_major_number major,
    45   rtems_device_minor_number minor,
    46   void *pargp,
    47   rtems_id tid,
    48   rtems_unsigned32 *rval
     48void Clock_exit( void );
     49
     50/*
     51 * These are set by clock driver during its init
     52 */
     53 
     54rtems_device_major_number rtems_clock_major = ~0;
     55rtems_device_minor_number rtems_clock_minor;
     56 
     57/*
     58 *  ISR Handler
     59 */
     60 
     61rtems_isr Clock_isr(
     62  rtems_vector_number vector
    4963)
    5064{
    51   Install_clock( Clock_isr );
    52 }
     65  Clock_driver_ticks += 1;
     66  ((volatile struct z8036_map *) TIMER)->CT1_CMD_STATUS = RELOAD;
    5367
    54 void ReInstall_clock(
    55   rtems_isr_entry clock_isr
    56 )
    57 {
    58   rtems_unsigned32 isrlevel;
    59 
    60   rtems_interrupt_disable( isrlevel );
    61    (void) set_vector( clock_isr, 66, 1 );
    62   rtems_interrupt_enable( isrlevel );
     68  if ( Clock_isrs == 1 ) {
     69    rtems_clock_tick();
     70    Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
     71  }
     72  else
     73    Clock_isrs -= 1;
    6374}
    6475
     
    7384
    7485  if ( BSP_Configuration.ticks_per_timeslice ) {
    75     Old_ticker = (rtems_isr_entry) set_vector( clock_isr, 66, 1 );
     86    Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 );
    7687    timer = (struct z8036_map *) 0xfffb0000;
    7788    timer->MASTER_INTR        = MICRVAL;
    7889    timer->CT1_MODE_SPEC      = T1MSRVAL;
    7990
    80   *((rtems_unsigned16 *)0xfffb0016) = MS_COUNT;  /* write countdown value */
    81 /*
    82     timer->CT1_TIME_CONST_MSB = (MS_COUNT >> 8);
    83     timer->CT1_TIME_CONST_LSB = (MS_COUNT &  0xff);
    84 */
     91    *((rtems_unsigned16 *)0xfffb0016) = MS_COUNT;  /* write countdown value */
     92
     93    /*
     94     *  timer->CT1_TIME_CONST_MSB = (MS_COUNT >> 8);
     95     *  timer->CT1_TIME_CONST_LSB = (MS_COUNT &  0xff);
     96     */
     97
    8598    timer->MASTER_CFG         = MCCRVAL;
    8699    timer->CT1_CMD_STATUS     = T1CSRVAL;
    87100
    88 /*
    89  * Enable interrupt via VME interrupt mask register
    90  */
     101    /*
     102     * Enable interrupt via VME interrupt mask register
     103     */
    91104    (*(rtems_unsigned8 *)0xfffb0038) &= 0xfd;
    92 
    93105
    94106    atexit( Clock_exit );
    95107  }
    96108
     109}
     110
     111void ReInstall_clock(
     112  rtems_isr_entry clock_isr
     113)
     114{
     115  rtems_unsigned32 isrlevel;
     116
     117  rtems_interrupt_disable( isrlevel );
     118   (void) set_vector( clock_isr, CLOCK_VECTOR, 1 );
     119  rtems_interrupt_enable( isrlevel );
    97120}
    98121
     
    110133  }
    111134}
     135
     136rtems_device_driver Clock_initialize(
     137  rtems_device_major_number major,
     138  rtems_device_minor_number minor,
     139  void *pargp
     140)
     141{
     142  Install_clock( Clock_isr );
     143
     144  /*
     145   * make major/minor avail to others such as shared memory driver
     146   */
     147
     148  rtems_clock_major = major;
     149  rtems_clock_minor = minor;
     150 
     151  return RTEMS_SUCCESSFUL;
     152}
     153
     154rtems_device_driver Clock_control(
     155  rtems_device_major_number major,
     156  rtems_device_minor_number minor,
     157  void *pargp
     158)
     159{
     160    rtems_libio_ioctl_args_t *args = pargp;
     161 
     162    if (args == 0)
     163        goto done;
     164 
     165    /*
     166     * This is hokey, but until we get a defined interface
     167     * to do this, it will just be this simple...
     168     */
     169 
     170    if (args->command == rtems_build_name('I', 'S', 'R', ' '))
     171    {
     172        Clock_isr(CLOCK_VECTOR);
     173    }
     174    else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
     175    {
     176        ReInstall_clock(args->buffer);
     177    }
     178 
     179done:
     180    return RTEMS_SUCCESSFUL;
     181}
     182
  • c/src/lib/libbsp/m68k/mvme136/console/console.c

    r5072b07 r3a4ae6c  
    1515#define M136_INIT
    1616
    17 #include <rtems.h>
    18 #include "console.h"
    19 #include "bsp.h"
     17#include <bsp.h>
     18#include <rtems/libio.h>
    2019
    2120/*  console_initialize
     
    3332  rtems_device_major_number  major,
    3433  rtems_device_minor_number  minor,
    35   void                      *arg,
    36   rtems_id                   self,
    37   rtems_unsigned32          *status
    38 )
    39 {
     34  void                      *arg
     35)
     36{
     37  rtems_status_code status;
     38
    4039  _Write_m681 = ( struct w_m681_info * ) M681ADDR;
    4140  _Read_m681 = ( struct r_m681_info * ) M681ADDR;
    42   *status = RTEMS_SUCCESSFUL;
     41
     42  status = rtems_io_register_name(
     43    "/dev/console",
     44    major,
     45    (rtems_device_minor_number) 0
     46  );
     47
     48  if (status != RTEMS_SUCCESSFUL)
     49    rtems_fatal_error_occurred(status);
     50 
     51  return RTEMS_SUCCESSFUL;
    4352}
    4453
     
    113122
    114123/*
    115  * __read  -- read bytes from the serial port. Ignore fd, since
    116  *            we only have stdin.
    117  */
    118 
    119 int __read(
    120   int fd,
    121   char *buf,
    122   int nbytes
    123 )
    124 {
    125   int i = 0;
    126 
    127   for (i = 0; i < nbytes; i++) {
    128     *(buf + i) = inbyte();
    129     if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) {
    130       (*(buf + i++)) = '\n';
    131       (*(buf + i)) = 0;
     124 *  Open entry point
     125 */
     126
     127rtems_device_driver console_open(
     128  rtems_device_major_number major,
     129  rtems_device_minor_number minor,
     130  void                    * arg
     131)
     132{
     133  return RTEMS_SUCCESSFUL;
     134}
     135 
     136/*
     137 *  Close entry point
     138 */
     139
     140rtems_device_driver console_close(
     141  rtems_device_major_number major,
     142  rtems_device_minor_number minor,
     143  void                    * arg
     144)
     145{
     146  return RTEMS_SUCCESSFUL;
     147}
     148
     149/*
     150 * read bytes from the serial port. We only have stdin.
     151 */
     152
     153rtems_device_driver console_read(
     154  rtems_device_major_number major,
     155  rtems_device_minor_number minor,
     156  void                    * arg
     157)
     158{
     159  rtems_libio_rw_args_t *rw_args;
     160  char *buffer;
     161  int maximum;
     162  int count = 0;
     163 
     164  rw_args = (rtems_libio_rw_args_t *) arg;
     165
     166  buffer = rw_args->buffer;
     167  maximum = rw_args->count;
     168
     169  for (count = 0; count < maximum; count++) {
     170    buffer[ count ] = inbyte();
     171    if (buffer[ count ] == '\n' || buffer[ count ] == '\r') {
     172      buffer[ count++ ]  = '\n';
     173      buffer[ count ]  = 0;
    132174      break;
    133175    }
    134176  }
    135   return (i);
    136 }
    137 
    138 /*
    139  * __write -- write bytes to the serial port. Ignore fd, since
    140  *            stdout and stderr are the same. Since we have no filesystem,
    141  *            open will only return an error.
    142  */
    143 
    144 int __write(
    145   int fd,
    146   char *buf,
    147   int nbytes
    148 )
    149 {
    150   int i;
    151 
    152   for (i = 0; i < nbytes; i++) {
    153     if (*(buf + i) == '\n') {
    154       outbyte ('\r');
     177
     178  rw_args->bytes_moved = count;
     179  return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED;
     180}
     181
     182/*
     183 * write bytes to the serial port. Stdout and stderr are the same.
     184 */
     185
     186rtems_device_driver console_write(
     187  rtems_device_major_number major,
     188  rtems_device_minor_number minor,
     189  void                    * arg
     190)
     191{
     192  int count;
     193  int maximum;
     194  rtems_libio_rw_args_t *rw_args;
     195  char *buffer;
     196
     197  rw_args = (rtems_libio_rw_args_t *) arg;
     198
     199  buffer = rw_args->buffer;
     200  maximum = rw_args->count;
     201
     202  for (count = 0; count < maximum; count++) {
     203    if ( buffer[ count ] == '\n') {
     204      outbyte('\r');
    155205    }
    156     outbyte (*(buf + i));
     206    outbyte( buffer[ count ] );
    157207  }
    158   return (nbytes);
    159 }
     208  return maximum;
     209}
     210
     211/*
     212 *  IO Control entry point
     213 */
     214
     215rtems_device_driver console_control(
     216  rtems_device_major_number major,
     217  rtems_device_minor_number minor,
     218  void                    * arg
     219)
     220{
     221  return RTEMS_SUCCESSFUL;
     222}
  • c/src/lib/libbsp/m68k/mvme136/include/bsp.h

    r5072b07 r3a4ae6c  
    2222
    2323#include <rtems.h>
     24#include <clockdrv.h>
     25#include <console.h>
    2426#include <iosupp.h>
    2527
     
    125127extern m68k_isr_entry M68Kvec[];   /* vector table address */
    126128
     129/*
     130 *  Device Driver Table Entries
     131 */
     132
     133/*
     134 * NOTE: Use the standard Console driver entry
     135 */
     136 
     137/*
     138 * NOTE: Use the standard Clock driver entry
     139 */
     140
     141/*
     142 * How many libio files we want
     143 */
     144
     145#define BSP_LIBIO_MAX_FDS       20
     146
    127147/* functions */
    128148
  • c/src/lib/libbsp/m68k/mvme136/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>
    2627#include <z8036.h>
    2728
    28 #include "stackchk.h"
     29#include <string.h>
     30#include <fcntl.h>
     31
     32#ifdef STACK_CHECKER_ON
     33#include <stackchk.h>
     34#endif
    2935
    3036/*
     
    3743
    3844rtems_cpu_table Cpu_table;
     45
     46char *rtems_progname;
    3947
    4048/*      Initialize whatever libc we are using
     
    4755    rtems_unsigned32        heap_start;
    4856
     57#ifdef RTEMS_DEBUG
     58    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
     59#endif
     60
    4961    heap_start = (rtems_unsigned32) &end;
    5062    if (heap_start & (CPU_ALIGNMENT-1))
     
    5264
    5365    RTEMS_Malloc_Initialize((void *) heap_start, 64 * 1024, 0);
     66
     67    /*
     68     *  Init the RTEMS libio facility to provide UNIX-like system
     69     *  calls for use by newlib (ie: provide __open, __close, etc)
     70     *  Uses malloc() to get area for the iops, so must be after malloc init
     71     */
     72
     73    rtems_libio_init();
    5474
    5575    /*
     
    7191}
    7292
    73 int bsp_start(
     93/*
     94 * After drivers are setup, register some "filenames"
     95 * and open stdin, stdout, stderr files
     96 *
     97 * Newlib will automatically associate the files with these
     98 * (it hardcodes the numbers)
     99 */
     100 
     101void
     102bsp_postdriver_hook(void)
     103{
     104  int stdin_fd, stdout_fd, stderr_fd;
     105
     106  if ((stdin_fd = __open("/dev/console", O_RDONLY, 0)) == -1)
     107    rtems_fatal_error_occurred('STD0');
     108 
     109  if ((stdout_fd = __open("/dev/console", O_WRONLY, 0)) == -1)
     110    rtems_fatal_error_occurred('STD1');
     111 
     112  if ((stderr_fd = __open("/dev/console", O_WRONLY, 0)) == -1)
     113    rtems_fatal_error_occurred('STD2');
     114 
     115  if ((stdin_fd != 0) || (stdout_fd != 1) || (stderr_fd != 2))
     116    rtems_fatal_error_occurred('STIO');
     117}
     118
     119
     120int main(
    74121  int argc,
    75122  char **argv,
     
    80127  int             index;
    81128
     129  if ((argc > 0) && argv && argv[0])
     130    rtems_progname = argv[0];
     131  else
     132    rtems_progname = "RTEMS";
     133
    82134  monitors_vector_table = (m68k_isr_entry *)0;   /* 135Bug Vectors are at 0 */
    83135  m68k_set_vbr( monitors_vector_table );
     
    105157  Cpu_table.predriver_hook = bsp_libc_init;  /* RTEMS resources available */
    106158
    107   Cpu_table.postdriver_hook = NULL;
     159  Cpu_table.postdriver_hook = bsp_postdriver_hook;
    108160
    109161  Cpu_table.idle_task = NULL;  /* do not override system IDLE task */
     
    148200#endif
    149201
     202  /*
     203   * Tell libio how many fd's we want and allow it to tweak config
     204   */
     205
     206  rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS);
     207
    150208  rtems_initialize_executive( &BSP_Configuration, &Cpu_table );
    151209  /* does not return */
  • c/src/lib/libbsp/m68k/mvme162/clock/ckinit.c

    r5072b07 r3a4ae6c  
    2828#include <stdlib.h>
    2929
    30 #include <rtems.h>
    3130#include <bsp.h>
    32 #include <clockdrv.h>
     31#include <rtems/libio.h>
    3332
    3433#define MS_COUNT          1000            /* T2's countdown constant (1 ms) */
     
    3938rtems_isr_entry  Old_ticker;
    4039
    41 rtems_device_driver Clock_initialize(
    42   rtems_device_major_number major,
    43   rtems_device_minor_number minor,
    44   void *pargp,
    45   rtems_id tid,
    46   rtems_unsigned32 *rval
    47 )
     40void Clock_exit( void );
     41 
     42#define CLOCK_VECTOR (VBR0 * 0x10 + 0x9)
     43/*
     44 * These are set by clock driver during its init
     45 */
     46 
     47rtems_device_major_number rtems_clock_major = ~0;
     48rtems_device_minor_number rtems_clock_minor;
     49 
     50
     51/*
     52 *  ISR Handler
     53 */
     54
     55rtems_isr Clock_isr(rtems_vector_number vector)
    4856{
    49   Install_clock( Clock_isr );
    50 }
     57  Clock_driver_ticks += 1;
     58  lcsr->timer_cnt_2 = 0;            /* clear counter */
     59  lcsr->intr_clear |= 0x02000000;
    5160
    52 void ReInstall_clock(rtems_isr_entry clock_isr)
    53 {
    54   rtems_unsigned32 isrlevel;
    55 
    56   rtems_interrupt_disable( isrlevel );
    57   (void) set_vector( clock_isr, VBR0 * 0x10 + 0x9, 1 );
    58   rtems_interrupt_enable( isrlevel );
     61  if ( Clock_isrs == 1 ) {
     62    rtems_clock_tick();
     63    Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
     64  }
     65  else
     66    Clock_isrs -= 1;
    5967}
    6068
     
    6775  if ( BSP_Configuration.ticks_per_timeslice ) {
    6876    Old_ticker =
    69       (rtems_isr_entry) set_vector( clock_isr, VBR0 * 0x10 + 0x9, 1 );
     77      (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 );
    7078    lcsr->vector_base |= MASK_INT;   /* unmask VMEchip2 interrupts */
    7179    lcsr->to_ctl = 0xE7;             /* prescaler to 1 MHz (see Appendix A1) */
     
    8088    atexit( Clock_exit );
    8189  }
     90}
    8291
     92void ReInstall_clock(rtems_isr_entry clock_isr)
     93{
     94  rtems_unsigned32 isrlevel;
     95
     96  rtems_interrupt_disable( isrlevel );
     97  (void) set_vector( clock_isr, CLOCK_VECTOR, 1 );
     98  rtems_interrupt_enable( isrlevel );
    8399}
    84100
     
    87103/* Dummy for now. See other m68k BSP's for code examples */
    88104}
     105
     106rtems_device_driver Clock_initialize(
     107  rtems_device_major_number major,
     108  rtems_device_minor_number minor,
     109  void *pargp
     110)
     111{
     112  Install_clock( Clock_isr );
     113 
     114  /*
     115   * make major/minor avail to others such as shared memory driver
     116   */
     117 
     118  rtems_clock_major = major;
     119  rtems_clock_minor = minor;
     120 
     121  return RTEMS_SUCCESSFUL;
     122}
     123 
     124rtems_device_driver Clock_control(
     125  rtems_device_major_number major,
     126  rtems_device_minor_number minor,
     127  void *pargp
     128)
     129{
     130    rtems_libio_ioctl_args_t *args = pargp;
     131 
     132    if (args == 0)
     133        goto done;
     134 
     135    /*
     136     * This is hokey, but until we get a defined interface
     137     * to do this, it will just be this simple...
     138     */
     139 
     140    if (args->command == rtems_build_name('I', 'S', 'R', ' '))
     141    {
     142        Clock_isr(CLOCK_VECTOR);
     143    }
     144    else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
     145    {
     146        ReInstall_clock(args->buffer);
     147    }
     148 
     149done:
     150    return RTEMS_SUCCESSFUL;
     151}
     152
  • c/src/lib/libbsp/m68k/mvme162/console/console.c

    r5072b07 r3a4ae6c  
    2222#define M162_INIT
    2323
    24 #include <rtems.h>
    25 #include "console.h"
    26 #include "bsp.h"
    27 #include "ringbuf.h"
     24#include <bsp.h>
     25#include <rtems/libio.h>
     26#include <ringbuf.h>
    2827
    2928Ring_buffer_t  Buffer[2];
     
    5554  rtems_device_major_number  major,
    5655  rtems_device_minor_number  minor,
    57   void                      *arg,
    58   rtems_id                   self,
    59   rtems_unsigned32          *status
     56  void                      *arg
    6057)
    6158{
    6259  int     i;
     60  rtems_status_code status;
    6361 
    6462  /*
     
    8078  mcchip->SCC_int_ctl = 0x13;     /* SCC IEN, IPL3 */
    8179
    82   *status = RTEMS_SUCCESSFUL;
     80  status = rtems_io_register_name(
     81    "/dev/console",
     82    major,
     83    (rtems_device_minor_number) 0
     84  );
     85 
     86  if (status != RTEMS_SUCCESSFUL)
     87    rtems_fatal_error_occurred(status);
     88 
     89  status = rtems_io_register_name(
     90    "/dev/tty00",
     91    major,
     92    (rtems_device_minor_number) 0
     93  );
     94 
     95  if (status != RTEMS_SUCCESSFUL)
     96    rtems_fatal_error_occurred(status);
     97 
     98  status = rtems_io_register_name(
     99    "/dev/tty01",
     100    major,
     101    (rtems_device_minor_number) 0
     102  );
     103 
     104  if (status != RTEMS_SUCCESSFUL)
     105    rtems_fatal_error_occurred(status);
     106 
     107  return RTEMS_SUCCESSFUL;
    83108}
    84109
     
    101126 */
    102127
    103 char char_wait(int port)
     128char inbyte(int port)
    104129{
    105130  unsigned char tmp_char;
     
    114139 */
    115140
    116 void char_put(int port, char ch)
     141void outbyte(int port, char ch)
    117142{
    118143  while (1) {
     
    123148
    124149/*
    125  *    Map port A (1) to stdin, stdout, and stderr.
    126  *    Map everything else to port B (0).
    127  */
    128 
    129 int __read(int fd, char *buf, int nbytes)
    130 {
    131   int i, port;
    132 
    133   if ( fd <= 2 ) port = 1;
    134   else           port = 0;
    135 
    136   for (i = 0; i < nbytes; i++) {
    137     *(buf + i) = char_wait(port);
    138     if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) {
    139       (*(buf + i++)) = '\n';
    140       (*(buf + i)) = 0;
     150 *  Open entry point
     151 */
     152
     153rtems_device_driver console_open(
     154  rtems_device_major_number major,
     155  rtems_device_minor_number minor,
     156  void                    * arg
     157)
     158{
     159  return RTEMS_SUCCESSFUL;
     160}
     161 
     162/*
     163 *  Close entry point
     164 */
     165
     166rtems_device_driver console_close(
     167  rtems_device_major_number major,
     168  rtems_device_minor_number minor,
     169  void                    * arg
     170)
     171{
     172  return RTEMS_SUCCESSFUL;
     173}
     174
     175/*
     176 * read bytes from the serial port. We only have stdin.
     177 */
     178
     179rtems_device_driver console_read(
     180  rtems_device_major_number major,
     181  rtems_device_minor_number minor,
     182  void                    * arg
     183)
     184{
     185  rtems_libio_rw_args_t *rw_args;
     186  char *buffer;
     187  int maximum;
     188  int count = 0;
     189 
     190  rw_args = (rtems_libio_rw_args_t *) arg;
     191
     192  buffer = rw_args->buffer;
     193  maximum = rw_args->count;
     194
     195  if ( minor > 1 )
     196    return RTEMS_INVALID_NUMBER;
     197
     198  for (count = 0; count < maximum; count++) {
     199    buffer[ count ] = inbyte( minor );
     200    if (buffer[ count ] == '\n' || buffer[ count ] == '\r') {
     201      buffer[ count++ ]  = '\n';
     202      buffer[ count ]  = 0;
    141203      break;
    142204    }
    143205  }
    144   return (i);
    145 }
    146 
    147 /*
    148  *  Map port A (1) to stdin, stdout, and stderr.
    149  *  Map everything else to port B (0).
    150  */
    151 
    152 int __write(int fd, char *buf, int nbytes)
    153 {
    154   int i, port;
    155  
    156   if ( fd <= 2 ) port = 1;
    157   else           port = 0;
    158  
    159   for (i = 0; i < nbytes; i++) {
    160     if (*(buf + i) == '\n') {
    161       char_put (port, '\r');
     206
     207  rw_args->bytes_moved = count;
     208  return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED;
     209}
     210
     211/*
     212 * write bytes to the serial port. Stdout and stderr are the same.
     213 */
     214
     215rtems_device_driver console_write(
     216  rtems_device_major_number major,
     217  rtems_device_minor_number minor,
     218  void                    * arg
     219)
     220{
     221  int count;
     222  int maximum;
     223  rtems_libio_rw_args_t *rw_args;
     224  char *buffer;
     225
     226  rw_args = (rtems_libio_rw_args_t *) arg;
     227
     228  buffer = rw_args->buffer;
     229  maximum = rw_args->count;
     230
     231  if ( minor > 1 )
     232    return RTEMS_INVALID_NUMBER;
     233
     234  for (count = 0; count < maximum; count++) {
     235    if ( buffer[ count ] == '\n') {
     236      outbyte('\r', minor );
    162237    }
    163     char_put (port, *(buf + i));
    164   }
    165   return (nbytes);
    166 }
     238    outbyte( buffer[ count ], minor  );
     239  }
     240  return maximum;
     241}
     242
     243/*
     244 *  IO Control entry point
     245 */
     246
     247rtems_device_driver console_control(
     248  rtems_device_major_number major,
     249  rtems_device_minor_number minor,
     250  void                    * arg
     251)
     252{
     253  return RTEMS_SUCCESSFUL;
     254}
  • c/src/lib/libbsp/m68k/mvme162/include/bsp.h

    r5072b07 r3a4ae6c  
    2929
    3030#include <rtems.h>
     31#include <clockdrv.h>
     32#include <console.h>
    3133#include <iosupp.h>
    3234
     
    249251#endif
    250252
     253/*
     254 *  Device Driver Table Entries
     255 */
     256
     257/*
     258 * NOTE: Use the standard Console driver entry
     259 */
     260 
     261/*
     262 * NOTE: Use the standard Clock driver entry
     263 */
     264
     265/*
     266 * How many libio files we want
     267 */
     268
     269#define BSP_LIBIO_MAX_FDS       20
     270
    251271/* miscellaneous stuff assumed to exist */
    252272
  • c/src/lib/libbsp/m68k/mvme162/startup/bspstart.c

    r5072b07 r3a4ae6c  
    2828 */
    2929
    30 #include <rtems.h>
    3130#include <bsp.h>
     31#include <rtems/libio.h>
     32 
    3233#include <libcsupport.h>
    33 #include <z8036.h>
     34 
     35#include <string.h>
     36#include <fcntl.h>
     37 
     38#ifdef STACK_CHECKER_ON
     39#include <stackchk.h>
     40#endif
    3441
    3542/*
     
    4249
    4350rtems_cpu_table Cpu_table;
     51
     52char *rtems_progname;
    4453
    4554/*      Initialize whatever libc we are using
     
    5968
    6069    /*
     70     *  Init the RTEMS libio facility to provide UNIX-like system
     71     *  calls for use by newlib (ie: provide __open, __close, etc)
     72     *  Uses malloc() to get area for the iops, so must be after malloc init
     73     */
     74
     75    rtems_libio_init();
     76
     77    /*
    6178     * Set up for the libc handling.
    6279     */
     
    7693}
    7794
    78 int bsp_start(
     95/*
     96 * After drivers are setup, register some "filenames"
     97 * and open stdin, stdout, stderr files
     98 *
     99 * Newlib will automatically associate the files with these
     100 * (it hardcodes the numbers)
     101 */
     102 
     103void
     104bsp_postdriver_hook(void)
     105{
     106  int stdin_fd, stdout_fd, stderr_fd;
     107 
     108  if ((stdin_fd = __open("/dev/console", O_RDONLY, 0)) == -1)
     109    rtems_fatal_error_occurred('STD0');
     110 
     111  if ((stdout_fd = __open("/dev/console", O_WRONLY, 0)) == -1)
     112    rtems_fatal_error_occurred('STD1');
     113 
     114  if ((stderr_fd = __open("/dev/console", O_WRONLY, 0)) == -1)
     115    rtems_fatal_error_occurred('STD2');
     116 
     117  if ((stdin_fd != 0) || (stdout_fd != 1) || (stderr_fd != 2))
     118    rtems_fatal_error_occurred('STIO');
     119}
     120
     121int main(
    79122  int argc,
    80123  char **argv,
     
    85128  int             index;
    86129
     130  if ((argc > 0) && argv && argv[0])
     131    rtems_progname = argv[0];
     132  else
     133    rtems_progname = "RTEMS";
     134
    87135  /*
    88136   *  162Bug Vectors are at 0xFFE00000
     
    122170  Cpu_table.predriver_hook = bsp_libc_init;  /* RTEMS resources available */
    123171
    124   Cpu_table.postdriver_hook = NULL;   /* Call our main() for constructors */
     172  Cpu_table.postdriver_hook = bsp_postdriver_hook;
    125173
    126174  Cpu_table.idle_task = NULL;  /* do not override system IDLE task */
     
    162210#endif
    163211
     212  /*
     213   * Tell libio how many fd's we want and allow it to tweak config
     214   */
     215
     216  rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS);
     217
    164218  BSP_Configuration.work_space_start = (void *)
    165219     (RAM_END - BSP_Configuration.work_space_size);
  • c/src/lib/libbsp/no_cpu/no_bsp/clock/ckinit.c

    r5072b07 r3a4ae6c  
    6161rtems_isr_entry  Old_ticker;
    6262
    63 /*
    64  *  Reinstall_clock
    65  *
    66  *  Install a clock tick handler without reprogramming the chip.  This
    67  *  is used by the polling shared memory device driver.
    68  */
    69 
    70 void ReInstall_clock(
    71   rtems_isr_entry clock_isr
    72 )
    73 {
    74   rtems_unsigned32 isrlevel = 0;
    75 
    76   /*
    77    *  Disable interrupts and install the clock ISR vector using the
    78    *  BSP dependent set_vector routine.  In the below example, the clock
    79    *  ISR is on vector 4 and is an RTEMS interrupt.
    80    */
    81 
    82   rtems_interrupt_disable( isrlevel );
    83    (void) set_vector( clock_isr, CLOCK_VECTOR, 1 );
    84   rtems_interrupt_enable( isrlevel );
     63void Clock_exit( void );
     64
     65
     66/*
     67 *  Isr Handler
     68 */
     69
     70rtems_isr Clock_isr(
     71  rtems_vector_number vector
     72)
     73{
     74/*
     75 * bump the number of clock driver ticks since initialization
     76 *
     77 * determine if it is time to announce the passing of tick as configured
     78 * to RTEMS through the rtems_clock_tick directive
     79 *
     80 * perform any timer dependent tasks
     81 */
    8582}
    8683
     
    125122
    126123/*
     124 *  Reinstall_clock
     125 *
     126 *  Install a clock tick handler without reprogramming the chip.  This
     127 *  is used by the polling shared memory device driver.
     128 */
     129
     130void ReInstall_clock(
     131  rtems_isr_entry clock_isr
     132)
     133{
     134  rtems_unsigned32 isrlevel = 0;
     135
     136  /*
     137   *  Disable interrupts and install the clock ISR vector using the
     138   *  BSP dependent set_vector routine.  In the below example, the clock
     139   *  ISR is on vector 4 and is an RTEMS interrupt.
     140   */
     141
     142  rtems_interrupt_disable( isrlevel );
     143   (void) set_vector( clock_isr, CLOCK_VECTOR, 1 );
     144  rtems_interrupt_enable( isrlevel );
     145}
     146
     147/*
    127148 *  Clean up before the application exits
    128149 */
     
    150171)
    151172{
    152   Install_clock((rtems_isr_entry) Clock_isr);
    153 
     173  Install_clock( Clock_isr );
     174 
    154175  /*
    155176   * make major/minor avail to others such as shared memory driver
    156177   */
     178 
    157179  rtems_clock_major = major;
    158     rtems_clock_minor = minor;
    159 
     180  rtems_clock_minor = minor;
     181 
    160182  return RTEMS_SUCCESSFUL;
    161183}
  • c/src/lib/libbsp/no_cpu/no_bsp/console/console.c

    r5072b07 r3a4ae6c  
    1515#define NO_BSP_INIT
    1616
    17 #include <rtems.h>
    18 #include "console.h"
    19 #include "bsp.h"
     17#include <bsp.h>
     18#include <rtems/libio.h>
    2019
    2120/*  console_initialize
     
    3332  rtems_device_major_number  major,
    3433  rtems_device_minor_number  minor,
    35   void                      *arg,
    36   rtems_id                   self,
    37   rtems_unsigned32          *status
    38 )
    39 {
    40   *status = RTEMS_SUCCESSFUL;
     34  void                      *arg
     35)
     36{
     37  rtems_status_code status;
     38 
     39  status = rtems_io_register_name(
     40    "/dev/console",
     41    major,
     42    (rtems_device_minor_number) 0
     43  );
     44 
     45  if (status != RTEMS_SUCCESSFUL)
     46    rtems_fatal_error_occurred(status);
     47 
     48  return RTEMS_SUCCESSFUL;
    4149}
    4250
     
    111119}
    112120
    113 /*
    114  * __read  -- read bytes from the serial port. Ignore fd, since
    115  *            we only have stdin.
    116  */
    117 
    118 int __read(
    119   int fd,
    120   char *buf,
    121   int nbytes
    122 )
    123 {
    124   int i = 0;
    125 
    126   for (i = 0; i < nbytes; i++) {
    127     *(buf + i) = inbyte();
    128     if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) {
    129       (*(buf + i++)) = '\n';
    130       (*(buf + i)) = 0;
     121
     122/*
     123 *  Open entry point
     124 */
     125
     126rtems_device_driver console_open(
     127  rtems_device_major_number major,
     128  rtems_device_minor_number minor,
     129  void                    * arg
     130)
     131{
     132  return RTEMS_SUCCESSFUL;
     133}
     134 
     135/*
     136 *  Close entry point
     137 */
     138
     139rtems_device_driver console_close(
     140  rtems_device_major_number major,
     141  rtems_device_minor_number minor,
     142  void                    * arg
     143)
     144{
     145  return RTEMS_SUCCESSFUL;
     146}
     147
     148/*
     149 * read bytes from the serial port. We only have stdin.
     150 */
     151
     152rtems_device_driver console_read(
     153  rtems_device_major_number major,
     154  rtems_device_minor_number minor,
     155  void                    * arg
     156)
     157{
     158  rtems_libio_rw_args_t *rw_args;
     159  char *buffer;
     160  int maximum;
     161  int count = 0;
     162 
     163  rw_args = (rtems_libio_rw_args_t *) arg;
     164
     165  buffer = rw_args->buffer;
     166  maximum = rw_args->count;
     167
     168  for (count = 0; count < maximum; count++) {
     169    buffer[ count ] = inbyte();
     170    if (buffer[ count ] == '\n' || buffer[ count ] == '\r') {
     171      buffer[ count++ ]  = '\n';
     172      buffer[ count ]  = 0;
    131173      break;
    132174    }
    133175  }
    134   return (i);
    135 }
    136 
    137 /*
    138  * __write -- write bytes to the serial port. Ignore fd, since
    139  *            stdout and stderr are the same. Since we have no filesystem,
    140  *            open will only return an error.
    141  */
    142 
    143 int __write(
    144   int fd,
    145   char *buf,
    146   int nbytes
    147 )
    148 {
    149   int i;
    150 
    151   for (i = 0; i < nbytes; i++) {
    152     if (*(buf + i) == '\n') {
    153       outbyte ('\r');
     176
     177  rw_args->bytes_moved = count;
     178  return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED;
     179}
     180
     181/*
     182 * write bytes to the serial port. Stdout and stderr are the same.
     183 */
     184
     185rtems_device_driver console_write(
     186  rtems_device_major_number major,
     187  rtems_device_minor_number minor,
     188  void                    * arg
     189)
     190{
     191  int count;
     192  int maximum;
     193  rtems_libio_rw_args_t *rw_args;
     194  char *buffer;
     195
     196  rw_args = (rtems_libio_rw_args_t *) arg;
     197
     198  buffer = rw_args->buffer;
     199  maximum = rw_args->count;
     200
     201  for (count = 0; count < maximum; count++) {
     202    if ( buffer[ count ] == '\n') {
     203      outbyte('\r');
    154204    }
    155     outbyte (*(buf + i));
     205    outbyte( buffer[ count ] );
    156206  }
    157   return (nbytes);
    158 }
     207  return maximum;
     208}
     209
     210/*
     211 *  IO Control entry point
     212 */
     213
     214rtems_device_driver console_control(
     215  rtems_device_major_number major,
     216  rtems_device_minor_number minor,
     217  void                    * arg
     218)
     219{
     220  return RTEMS_SUCCESSFUL;
     221}
  • c/src/lib/libbsp/no_cpu/no_bsp/include/bsp.h

    r5072b07 r3a4ae6c  
    2424
    2525#include <rtems.h>
     26#include <console.h>
    2627#include <clockdrv.h>
    2728
     
    7071
    7172/*
    72  * Console driver init
     73 *  Device Driver Table Entries
    7374 */
    74  
    75 rtems_device_driver console_initialize(
    76   rtems_device_major_number, rtems_device_minor_number minor, void *);
    77  
    78 #define CONSOLE_DRIVER_TABLE_ENTRY \
    79   { console_initialize, NULL, NULL, NULL, NULL, NULL }
     75
     76/*
     77 * NOTE: Use the standard Console driver entry
     78 */
    8079 
    8180/*
    8281 * NOTE: Use the standard Clock driver entry
    8382 */
     83
     84/*
     85 * How many libio files we want
     86 */
     87
     88#define BSP_LIBIO_MAX_FDS       20
    8489
    8590/* functions */
  • c/src/lib/libbsp/no_cpu/no_bsp/startup/bspstart.c

    r5072b07 r3a4ae6c  
    2121 */
    2222
    23 #include <rtems.h>
    2423#include <bsp.h>
    25 #include <shm.h>
     24#include <rtems/libio.h>
     25 
    2626#include <libcsupport.h>
     27 
     28#include <string.h>
     29#include <fcntl.h>
     30 
     31#ifdef STACK_CHECKER_ON
     32#include <stackchk.h>
     33#endif
    2734
    2835/*
     
    3643
    3744rtems_cpu_table Cpu_table;
     45
     46char *rtems_progname;
    3847
    3948/*      Initialize whatever libc we are using
     
    6069
    6170    /*
     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();
     77
     78    /*
    6279     * Set up for the libc handling.
    6380     */
     
    7794}
    7895
    79 int bsp_start(
     96/*
     97 * After drivers are setup, register some "filenames"
     98 * and open stdin, stdout, stderr files
     99 *
     100 * Newlib will automatically associate the files with these
     101 * (it hardcodes the numbers)
     102 */
     103 
     104void
     105bsp_postdriver_hook(void)
     106{
     107  int stdin_fd, stdout_fd, stderr_fd;
     108 
     109  if ((stdin_fd = __open("/dev/console", O_RDONLY, 0)) == -1)
     110    rtems_fatal_error_occurred('STD0');
     111 
     112  if ((stdout_fd = __open("/dev/console", O_WRONLY, 0)) == -1)
     113    rtems_fatal_error_occurred('STD1');
     114 
     115  if ((stderr_fd = __open("/dev/console", O_WRONLY, 0)) == -1)
     116    rtems_fatal_error_occurred('STD2');
     117 
     118  if ((stdin_fd != 0) || (stdout_fd != 1) || (stderr_fd != 2))
     119    rtems_fatal_error_occurred('STIO');
     120}
     121
     122int main(
    80123  int argc,
    81124  char **argv,
     
    83126)
    84127{
     128  if ((argc > 0) && argv && argv[0])
     129    rtems_progname = argv[0];
     130  else
     131    rtems_progname = "RTEMS";
     132
    85133  /*
    86134   *  Allocate the memory for the RTEMS Work Space.  This can come from
     
    119167#endif
    120168
     169#ifdef STACK_CHECKER_ON
     170    /*
     171     * Add 1 extension for stack checker
     172     */
     173 
     174    BSP_Configuration.maximum_extensions++;
     175#endif
     176
     177  /*
     178   * Tell libio how many fd's we want and allow it to tweak config
     179   */
     180
     181  rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS);
     182
    121183  /*
    122184   *  Need to "allocate" the memory for the RTEMS Workspace and
     
    139201  Cpu_table.predriver_hook = bsp_libc_init;    /* RTEMS resources available */
    140202
    141   Cpu_table.postdriver_hook = NULL;
     203  Cpu_table.postdriver_hook = bsp_postdriver_hook;
    142204
    143205  Cpu_table.idle_task = NULL;  /* do not override system IDLE task */
  • c/src/lib/libbsp/powerpc/papyrus/include/bsp.h

    r5072b07 r3a4ae6c  
    4444#else
    4545#include <rtems.h>
     46#include <console.h>
    4647
    4748/*
     
    9596extern rtems_cpu_table           Cpu_table;             /* owned by BSP */
    9697
     98/*
     99 *  Device Driver Table Entries
     100 */
     101
     102/*
     103 * NOTE: Use the standard Console driver entry
     104 */
     105 
     106/*
     107 * NOTE: Use the standard Clock driver entry
     108 */
     109
     110/*
     111 * How many libio files we want
     112 */
     113
     114#define BSP_LIBIO_MAX_FDS       20
     115
    97116/* functions */
    98117
  • c/src/lib/libbsp/powerpc/papyrus/startup/bspstart.c

    r5072b07 r3a4ae6c  
    3838 */
    3939
    40 #include <rtems.h>
    4140#include <bsp.h>
    42 #include <shm.h>
     41#include <rtems/libio.h>
     42 
    4343#include <libcsupport.h>
     44 
     45#include <string.h>
     46#include <fcntl.h>
     47 
     48#ifdef STACK_CHECKER_ON
     49#include <stackchk.h>
     50#endif
    4451
    4552/*
     
    5360
    5461rtems_cpu_table Cpu_table;
     62
     63char *rtems_progname;
    5564
    5665/*      Initialize whatever libc we are using
     
    7786
    7887    /*
     88     *  Init the RTEMS libio facility to provide UNIX-like system
     89     *  calls for use by newlib (ie: provide __open, __close, etc)
     90     *  Uses malloc() to get area for the iops, so must be after malloc init
     91     */
     92
     93    rtems_libio_init();
     94
     95    /*
    7996     * Set up for the libc handling.
    8097     */
     
    94111}
    95112
    96 void bsp_start(void)
     113/*
     114 * After drivers are setup, register some "filenames"
     115 * and open stdin, stdout, stderr files
     116 *
     117 * Newlib will automatically associate the files with these
     118 * (it hardcodes the numbers)
     119 */
     120 
     121void
     122bsp_postdriver_hook(void)
    97123{
     124  int stdin_fd, stdout_fd, stderr_fd;
     125 
     126  if ((stdin_fd = __open("/dev/console", O_RDONLY, 0)) == -1)
     127    rtems_fatal_error_occurred('STD0');
     128 
     129  if ((stdout_fd = __open("/dev/console", O_WRONLY, 0)) == -1)
     130    rtems_fatal_error_occurred('STD1');
     131 
     132  if ((stderr_fd = __open("/dev/console", O_WRONLY, 0)) == -1)
     133    rtems_fatal_error_occurred('STD2');
     134 
     135  if ((stdin_fd != 0) || (stdout_fd != 1) || (stderr_fd != 2))
     136    rtems_fatal_error_occurred('STIO');
     137}
     138
     139int main(
     140  int argc,
     141  char **argv,
     142  char **environp
     143)
     144{
     145  if ((argc > 0) && argv && argv[0])
     146    rtems_progname = argv[0];
     147  else
     148    rtems_progname = "RTEMS";
     149
    98150  /*
    99151   *  Allocate the memory for the RTEMS Work Space.  This can come from
     
    133185
    134186  /*
     187   * Tell libio how many fd's we want and allow it to tweak config
     188   */
     189
     190  rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS);
     191
     192  /*
    135193   *  Need to "allocate" the memory for the RTEMS Workspace and
    136194   *  tell the RTEMS configuration where it is.  This memory is
     
    155213  Cpu_table.predriver_hook = bsp_libc_init;    /* RTEMS resources available */
    156214
    157   Cpu_table.postdriver_hook = NULL;
     215  Cpu_table.postdriver_hook = bsp_postdriver_hook;
    158216
    159217  Cpu_table.idle_task = NULL;  /* do not override system IDLE task */
  • c/src/lib/libbsp/shmdr/init.c

    r5072b07 r3a4ae6c  
    44 *  driver initialization routine.
    55 *
    6  *  Input parameters:
    7  *    configuration - address of configuration table
     6 *  Input parameters:  NONE
    87 *
    98 *  Output parameters: NONE
     
    3433rtems_extensions_table MPCI_Shm_extensions;
    3534
    36 rtems_mpci_entry Shm_Initialization(
    37   rtems_configuration_table   *configuration,
    38   rtems_cpu_table             *cpu_configuration,
    39   rtems_multiprocessing_table *mp_configuration
    40 
    41 )
     35rtems_mpci_entry Shm_Initialization( void )
     36
    4237{
    4338  rtems_unsigned32         i, all_initialized;
     
    4742  rtems_unsigned32         extension_id;    /* for installation of MPCI_Fatal */
    4843  rtems_unsigned32         remaining_memory;
     44/* XXX these should use "public" methods to set their values.... */
     45  rtems_configuration_table   *configuration = _Configuration_Table;
     46  rtems_multiprocessing_table *mp_configuration = _Configuration_MP_table;
    4947
    5048  Shm_RTEMS_Configuration    = configuration;
  • c/src/lib/libbsp/shmdr/mpci.h

    r5072b07 r3a4ae6c  
    1616 */
    1717
    18 #ifndef __MPCI_h
    19 #define __MPCI_h
     18#ifndef __SHM_MPCI_h
     19#define __SHM_MPCI_h
    2020
    2121#ifdef __cplusplus
  • c/src/lib/libbsp/shmdr/shm.h

    r5072b07 r3a4ae6c  
    494494);
    495495
    496 rtems_mpci_entry Shm_Initialization(
    497   rtems_configuration_table   *configuration,
    498   rtems_cpu_table             *cpu_configuration,
    499   rtems_multiprocessing_table *mp_configuration
    500 );
     496rtems_mpci_entry Shm_Initialization( void );
    501497
    502498rtems_mpci_entry Shm_Receive_packet(
  • c/src/lib/libbsp/shmdr/shm_driver.h

    r5072b07 r3a4ae6c  
    494494);
    495495
    496 rtems_mpci_entry Shm_Initialization(
    497   rtems_configuration_table   *configuration,
    498   rtems_cpu_table             *cpu_configuration,
    499   rtems_multiprocessing_table *mp_configuration
    500 );
     496rtems_mpci_entry Shm_Initialization( void );
    501497
    502498rtems_mpci_entry Shm_Receive_packet(
  • c/src/lib/libbsp/unix/posix/console/console.c

    r5072b07 r3a4ae6c  
    33 *
    44 *  These provide UNIX-like read and write calls for the C library.
     5 *
     6 *  NOTE:  For the most part, this is just a space holder.
    57 *
    68 *  COPYRIGHT (c) 1994 by Division Incorporated
     
    3234)
    3335{
    34     return RTEMS_SUCCESSFUL;
     36  return 0;
    3537}
    3638
     39
     40/*
     41 *  Open entry point
     42 */
     43
     44rtems_device_driver console_open(
     45  rtems_device_major_number major,
     46  rtems_device_minor_number minor,
     47  void                    * arg
     48)
     49{
     50  return RTEMS_SUCCESSFUL;
     51}
     52 
     53/*
     54 *  Close entry point
     55 */
     56
     57rtems_device_driver console_close(
     58  rtems_device_major_number major,
     59  rtems_device_minor_number minor,
     60  void                    * arg
     61)
     62{
     63  return RTEMS_SUCCESSFUL;
     64}
     65
     66/*
     67 * read bytes from the serial port. We only have stdin.
     68 */
     69
     70rtems_device_driver console_read(
     71  rtems_device_major_number major,
     72  rtems_device_minor_number minor,
     73  void                    * arg
     74)
     75{
     76  return RTEMS_UNSATISFIED;
     77}
     78
     79/*
     80 * write bytes to the serial port. Stdout and stderr are the same.
     81 */
     82
     83rtems_device_driver console_write(
     84  rtems_device_major_number major,
     85  rtems_device_minor_number minor,
     86  void                    * arg
     87)
     88{
     89  return -1;
     90}
     91
     92/*
     93 *  IO Control entry point
     94 */
     95
     96rtems_device_driver console_control(
     97  rtems_device_major_number major,
     98  rtems_device_minor_number minor,
     99  void                    * arg
     100)
     101{
     102  return RTEMS_SUCCESSFUL;
     103}
  • c/src/lib/libbsp/unix/posix/include/bsp.h

    r5072b07 r3a4ae6c  
    2323#include <rtems.h>
    2424#include <clockdrv.h>
     25#include <console.h>
    2526#include <iosupp.h>
    2627#include <libcsupport.h>
     
    8182
    8283/*
    83  * Console driver init
     84 *  Device Driver Table Entries
    8485 */
    85  
    86 rtems_device_driver console_initialize(
    87   rtems_device_major_number, rtems_device_minor_number minor, void *);
    88  
    89 #define CONSOLE_DRIVER_TABLE_ENTRY \
    90   { console_initialize, NULL, NULL, NULL, NULL, NULL }
     86
     87/*
     88 * NOTE: Use the standard Console driver entry
     89 */
    9190 
    9291/*
     
    9493 */
    9594 
     95/*
     96 * How many libio files we want
     97 */
     98
     99#define BSP_LIBIO_MAX_FDS       20
     100
    96101/* functions */
    97102
  • c/src/lib/libbsp/unix/posix/startup/bspstart.c

    r5072b07 r3a4ae6c  
    3737#include <bsp.h>
    3838#include <libcsupport.h>
     39
     40#include <rtems/libio.h>
    3941
    4042#ifdef STACK_CHECKER_ON
     
    113115    RTEMS_Malloc_Initialize((void *)heap_start, Heap_size, 1024 * 1024);
    114116
     117    /*
     118     *  Init the RTEMS libio facility to provide UNIX-like system
     119     *  calls for use by newlib (ie: provide __open, __close, etc)
     120     *  Uses malloc() to get area for the iops, so must be after malloc init
     121     */
     122
     123    rtems_libio_init();
     124
    115125    libc_init(1);
    116126}
     
    159169#ifdef RTEMS_DEBUG
    160170    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
     171#endif
     172}
     173
     174/*
     175 * After drivers are setup, register some "filenames"
     176 * and open stdin, stdout, stderr files
     177 *
     178 * Newlib will automatically associate the files with these
     179 * (it hardcodes the numbers)
     180 */
     181 
     182void
     183bsp_postdriver_hook(void)
     184{
     185#if 0
     186  int stdin_fd, stdout_fd, stderr_fd;
     187 
     188  if ((stdin_fd = __open("/dev/console", O_RDONLY, 0)) == -1)
     189    rtems_fatal_error_occurred('STD0');
     190 
     191  if ((stdout_fd = __open("/dev/console", O_WRONLY, 0)) == -1)
     192    rtems_fatal_error_occurred('STD1');
     193 
     194  if ((stderr_fd = __open("/dev/console", O_WRONLY, 0)) == -1)
     195    rtems_fatal_error_occurred('STD2');
     196 
     197  if ((stdin_fd != 0) || (stdout_fd != 1) || (stderr_fd != 2))
     198    rtems_fatal_error_occurred('STIO');
    161199#endif
    162200}
     
    262300    Cpu_table.predriver_hook = NULL;
    263301
    264     Cpu_table.postdriver_hook = NULL;
     302    Cpu_table.postdriver_hook = bsp_postdriver_hook;
    265303
    266304    Cpu_table.idle_task = NULL;  /* do not override system IDLE task */
     
    302340#endif
    303341
    304     /*
    305      * Add 1 extension for MPCI_fatal
    306      */
    307 
    308     if (BSP_Configuration.User_multiprocessing_table)
    309         BSP_Configuration.maximum_extensions++;
    310 
    311     CPU_CLICKS_PER_TICK = 1;
    312 
    313     /*
    314      *  Start most of RTEMS
    315      *  main() will start the rest
    316      */
    317 
    318     bsp_isr_level = rtems_initialize_executive_early(
    319       &BSP_Configuration,
    320       &Cpu_table
    321     );
     342  /*
     343   * Tell libio how many fd's we want and allow it to tweak config
     344   */
     345
     346  rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS);
     347
     348  /*
     349   * Add 1 extension for MPCI_fatal
     350   */
     351
     352  if (BSP_Configuration.User_multiprocessing_table)
     353      BSP_Configuration.maximum_extensions++;
     354
     355  CPU_CLICKS_PER_TICK = 1;
     356
     357  /*
     358   *  Start most of RTEMS
     359   *  main() will start the rest
     360   */
     361
     362  bsp_isr_level = rtems_initialize_executive_early(
     363    &BSP_Configuration,
     364    &Cpu_table
     365  );
    322366}
  • c/src/lib/libc/error.c

    r5072b07 r3a4ae6c  
    9292    { "directive not implemented",          RTEMS_NOT_IMPLEMENTED, },
    9393    { "RTEMS inconsistency detected",       RTEMS_INTERNAL_ERROR, },
    94     { "internal multiprocessing only",      RTEMS_PROXY_BLOCKING, },
    9594    { "could not get enough memory",        RTEMS_NO_MEMORY, },
     95    { "internal multiprocessing only",      THREAD_STATUS_PROXY_BLOCKING, },
    9696    { 0, 0, 0 },
    9797};
     
    135135        local_errno = errno;
    136136
    137     if (_Configuration_Is_multiprocessing())
     137    if (_System_state_Is_multiprocessing)
    138138        fprintf(stderr, "[%d] ", _Configuration_MP_table->node);
    139139   
  • c/src/lib/libc/libio.c

    r5072b07 r3a4ae6c  
    1515
    1616#include <fcntl.h>                      /* O_RDONLY, et.al. */
     17#include <sys/fcntl.h>                      /* O_RDONLY, et.al. */
    1718#if defined(solaris2)
    1819#define O_NDELAY O_NONBLOCK
     20#elif  defined(RTEMS_NEWLIB)
     21#define O_NDELAY _FNBIO
    1922#endif
    2023#include <errno.h>
  • c/src/lib/libc/newlibc.c

    r5072b07 r3a4ae6c  
    8181
    8282
    83 rtems_extension
     83rtems_boolean
    8484libc_create_hook(rtems_tcb *current_task,
    8585                 rtems_tcb *creating_task)
    8686{
    8787    MY_task_set_note(creating_task, LIBC_NOTEPAD, 0);
     88    return TRUE;
    8889}
    8990
     
    232233        memset(&libc_extension, 0, sizeof(libc_extension));
    233234
    234         libc_extension.rtems_task_create  = libc_create_hook;
    235         libc_extension.rtems_task_start   = libc_start_hook;
    236         libc_extension.task_switch  = libc_switch_hook;
    237         libc_extension.rtems_task_delete  = libc_delete_hook;
     235        libc_extension.thread_create  = libc_create_hook;
     236        libc_extension.thread_start   = libc_start_hook;
     237        libc_extension.thread_switch  = libc_switch_hook;
     238        libc_extension.thread_delete  = libc_delete_hook;
    238239
    239240        rc = rtems_extension_create(rtems_build_name('L', 'I', 'B', 'C'),
  • c/src/lib/libc/support.c

    r5072b07 r3a4ae6c  
    1414 */
    1515
    16 #include <rtems/system.h>
    17 #include <rtems/thread.h>
     16#include <rtems.h>
    1817
    1918void MY_task_set_note(
     
    2322)
    2423{
    25   the_thread->RTEMS_API->Notepads[ notepad ] = note;
     24  RTEMS_API_Control    *api;
     25 
     26  api = the_thread->API_Extensions[ THREAD_API_RTEMS ];
     27
     28  api->Notepads[ notepad ] = note;
    2629}
    2730
     
    3235)
    3336{
    34   return the_thread->RTEMS_API->Notepads[ notepad ];
     37  RTEMS_API_Control    *api;
     38 
     39  api = the_thread->API_Extensions[ THREAD_API_RTEMS ];
     40
     41  return api->Notepads[ notepad ];
    3542}
    3643
  • c/src/lib/libcpu/powerpc/ppc403/clock/clock.c

    r5072b07 r3a4ae6c  
    3434#include <bsp.h>
    3535#include <clockdrv.h>
     36#include <rtems/libio.h>
    3637
    3738#include <stdlib.h>                     /* for atexit() */
     
    4344static rtems_boolean auto_restart;
    4445
    45 rtems_device_driver Clock_initialize(
    46   rtems_device_major_number major,
    47   rtems_device_minor_number minor,
    48   void *pargp,
    49   rtems_id tid,
    50   rtems_unsigned32 *rval
    51 )
    52 {
    53     Install_clock(Clock_isr);
    54 }
    55 
    56 
    57 void
    58 ReInstall_clock(rtems_isr_entry new_clock_isr)
    59 {
    60     rtems_isr_entry previous_isr;
    61     rtems_unsigned32 isrlevel = 0;
    62 
    63     rtems_interrupt_disable(isrlevel);
    64    
    65     rtems_interrupt_catch(new_clock_isr, PPC_IRQ_PIT,
    66                           &previous_isr);
    67 
    68     rtems_interrupt_enable(isrlevel);
    69 }
    70 
     46void Clock_exit( void );
     47 
     48/*
     49 * These are set by clock driver during its init
     50 */
     51 
     52rtems_device_major_number rtems_clock_major = ~0;
     53rtems_device_minor_number rtems_clock_minor;
     54 
    7155static INLINE rtems_unsigned32 get_itimer(void)
    7256{
     
    7660
    7761    return rc;
     62}
     63
     64/*
     65 *  ISR Handler
     66 */
     67 
     68rtems_isr
     69Clock_isr(rtems_vector_number vector)
     70{
     71    if (!auto_restart)
     72        {
     73            rtems_unsigned32 clicks_til_next_interrupt;
     74            rtems_unsigned32 itimer_value;
     75
     76            /*
     77             * setup for next interrupt; making sure the new value is reasonably
     78             * in the future.... in case we lost out on an interrupt somehow
     79             */
     80
     81            itimer_value = get_itimer();
     82            tick_time += pit_value;
     83
     84            /*
     85             * how far away is next interrupt *really*
     86             * It may be a long time; this subtraction works even if
     87             * Clock_clicks_interrupt < Clock_clicks_low_order via
     88             * the miracle of unsigned math.
     89             */
     90            clicks_til_next_interrupt = tick_time - itimer_value;
     91
     92            /*
     93             * If it is too soon then bump it up.
     94             * This should only happen if CPU_HPPA_CLICKS_PER_TICK is too small.
     95             * But setting it low is useful for debug, so...
     96             */
     97
     98            if (clicks_til_next_interrupt < 400)
     99                {
     100                    tick_time = itimer_value + 1000;
     101                    clicks_til_next_interrupt = 1000;
     102                    /* XXX: count these! this should be rare */
     103                }
     104
     105            /*
     106             * If it is too late, that means we missed the interrupt somehow.
     107             * Rather than wait 35-50s for a wrap, we just fudge it here.
     108             */
     109           
     110            if (clicks_til_next_interrupt > pit_value)
     111                {
     112                    tick_time = itimer_value + 1000;
     113                    clicks_til_next_interrupt = 1000;
     114                    /* XXX: count these! this should never happen :-) */
     115                }
     116
     117            asm volatile ("mtpit %0" :: "r" (clicks_til_next_interrupt));
     118        }
     119
     120    asm volatile ( "mttsr %0" :: "r" (0x08000000));
     121
     122    Clock_driver_ticks++;
     123
     124    rtems_clock_tick();
    78125}
    79126
     
    132179}
    133180
    134 
    135 rtems_isr
    136 Clock_isr(rtems_vector_number vector)
    137 {
    138     if (!auto_restart)
    139         {
    140             rtems_unsigned32 clicks_til_next_interrupt;
    141             rtems_unsigned32 itimer_value;
    142 
    143             /*
    144              * setup for next interrupt; making sure the new value is reasonably
    145              * in the future.... in case we lost out on an interrupt somehow
    146              */
    147 
    148             itimer_value = get_itimer();
    149             tick_time += pit_value;
    150 
    151             /*
    152              * how far away is next interrupt *really*
    153              * It may be a long time; this subtraction works even if
    154              * Clock_clicks_interrupt < Clock_clicks_low_order via
    155              * the miracle of unsigned math.
    156              */
    157             clicks_til_next_interrupt = tick_time - itimer_value;
    158 
    159             /*
    160              * If it is too soon then bump it up.
    161              * This should only happen if CPU_HPPA_CLICKS_PER_TICK is too small.
    162              * But setting it low is useful for debug, so...
    163              */
    164 
    165             if (clicks_til_next_interrupt < 400)
    166                 {
    167                     tick_time = itimer_value + 1000;
    168                     clicks_til_next_interrupt = 1000;
    169                     /* XXX: count these! this should be rare */
    170                 }
    171 
    172             /*
    173              * If it is too late, that means we missed the interrupt somehow.
    174              * Rather than wait 35-50s for a wrap, we just fudge it here.
    175              */
    176            
    177             if (clicks_til_next_interrupt > pit_value)
    178                 {
    179                     tick_time = itimer_value + 1000;
    180                     clicks_til_next_interrupt = 1000;
    181                     /* XXX: count these! this should never happen :-) */
    182                 }
    183 
    184             asm volatile ("mtpit %0" :: "r" (clicks_til_next_interrupt));
    185         }
    186 
    187     asm volatile ( "mttsr %0" :: "r" (0x08000000));
    188 
    189     Clock_driver_ticks++;
    190 
    191     rtems_clock_tick();
    192 }
     181void
     182ReInstall_clock(rtems_isr_entry new_clock_isr)
     183{
     184    rtems_isr_entry previous_isr;
     185    rtems_unsigned32 isrlevel = 0;
     186
     187    rtems_interrupt_disable(isrlevel);
     188   
     189    rtems_interrupt_catch(new_clock_isr, PPC_IRQ_PIT,
     190                          &previous_isr);
     191
     192    rtems_interrupt_enable(isrlevel);
     193}
     194
    193195
    194196/*
     
    214216}
    215217
     218rtems_device_driver Clock_initialize(
     219  rtems_device_major_number major,
     220  rtems_device_minor_number minor,
     221  void *pargp
     222)
     223{
     224  Install_clock( Clock_isr );
     225 
     226  /*
     227   * make major/minor avail to others such as shared memory driver
     228   */
     229 
     230  rtems_clock_major = major;
     231  rtems_clock_minor = minor;
     232 
     233  return RTEMS_SUCCESSFUL;
     234}
     235 
     236rtems_device_driver Clock_control(
     237  rtems_device_major_number major,
     238  rtems_device_minor_number minor,
     239  void *pargp
     240)
     241{
     242    rtems_libio_ioctl_args_t *args = pargp;
     243 
     244    if (args == 0)
     245        goto done;
     246 
     247    /*
     248     * This is hokey, but until we get a defined interface
     249     * to do this, it will just be this simple...
     250     */
     251 
     252    if (args->command == rtems_build_name('I', 'S', 'R', ' '))
     253    {
     254        Clock_isr(PPC_IRQ_PIT);
     255    }
     256    else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
     257    {
     258        ReInstall_clock(args->buffer);
     259    }
     260 
     261done:
     262    return RTEMS_SUCCESSFUL;
     263}
     264
  • c/src/lib/libcpu/powerpc/ppc403/console/console.c

    r5072b07 r3a4ae6c  
    3232#define NO_BSP_INIT
    3333
    34 #include <rtems.h>
    35 #include "console.h"
    36 #include "bsp.h"
     34#include <bsp.h>
     35#include <rtems/libio.h>
    3736
    3837extern rtems_cpu_table           Cpu_table;             /* owned by BSP */
     
    140139  rtems_device_major_number  major,
    141140  rtems_device_minor_number  minor,
    142   void                      *arg,
    143   rtems_id                   self,
    144   rtems_unsigned32          *status
    145 )
    146 {
     141  void                      *arg
     142)
     143{
     144  rtems_status_code status;
    147145  register unsigned tmp;
    148146
     
    165163  port->SPHS = (HSRDsr | HSRCts);
    166164
    167   *status = RTEMS_SUCCESSFUL;
     165  status = rtems_io_register_name(
     166    "/dev/console",
     167    major,
     168    (rtems_device_minor_number) 0
     169  );
     170 
     171  if (status != RTEMS_SUCCESSFUL)
     172    rtems_fatal_error_occurred(status);
     173 
     174  return RTEMS_SUCCESSFUL;
    168175}
    169176
     
    281288
    282289/*
    283  * __read  -- read bytes from the serial port. Ignore fd, since
    284  *            we only have stdin.
    285  */
    286 
    287 int __read(
    288   int fd,
    289   char *buf,
    290   int nbytes
    291 )
    292 {
    293   int i = 0;
    294 
    295   for (i = 0; i < nbytes; i++) {
    296     *(buf + i) = inbyte();
    297     if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) {
    298       (*(buf + i++)) = '\n';
    299       (*(buf + i)) = 0;
     290 *  Open entry point
     291 */
     292 
     293rtems_device_driver console_open(
     294  rtems_device_major_number major,
     295  rtems_device_minor_number minor,
     296  void                    * arg
     297)
     298{
     299  return RTEMS_SUCCESSFUL;
     300}
     301 
     302/*
     303 *  Close entry point
     304 */
     305 
     306rtems_device_driver console_close(
     307  rtems_device_major_number major,
     308  rtems_device_minor_number minor,
     309  void                    * arg
     310)
     311{
     312  return RTEMS_SUCCESSFUL;
     313}
     314 
     315/*
     316 * read bytes from the serial port. We only have stdin.
     317 */
     318 
     319rtems_device_driver console_read(
     320  rtems_device_major_number major,
     321  rtems_device_minor_number minor,
     322  void                    * arg
     323)
     324{
     325  rtems_libio_rw_args_t *rw_args;
     326  char *buffer;
     327  int maximum;
     328  int count = 0;
     329 
     330  rw_args = (rtems_libio_rw_args_t *) arg;
     331 
     332  buffer = rw_args->buffer;
     333  maximum = rw_args->count;
     334 
     335  for (count = 0; count < maximum; count++) {
     336    buffer[ count ] = inbyte();
     337    if (buffer[ count ] == '\n' || buffer[ count ] == '\r') {
     338      buffer[ count++ ]  = '\n';
     339      buffer[ count ]  = 0;
    300340      break;
    301341    }
    302342  }
    303   return (i);
    304 }
    305 
    306 /*
    307  * __write -- write bytes to the serial port. Ignore fd, since
    308  *            stdout and stderr are the same. Since we have no filesystem,
    309  *            open will only return an error.
    310  */
    311 
    312 int __write(
    313   int fd,
    314   char *buf,
    315   int nbytes
    316 )
    317 {
    318   int i;
    319 
    320   for (i = 0; i < nbytes; i++) {
    321     if (*(buf + i) == '\n') {
    322       outbyte ('\r');
    323     }
    324     outbyte (*(buf + i));
     343 
     344  rw_args->bytes_moved = count;
     345  return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED;
     346}
     347 
     348/*
     349 * write bytes to the serial port. Stdout and stderr are the same.
     350 */
     351 
     352rtems_device_driver console_write(
     353  rtems_device_major_number major,
     354  rtems_device_minor_number minor,
     355  void                    * arg
     356)
     357{
     358  int count;
     359  int maximum;
     360  rtems_libio_rw_args_t *rw_args;
     361  char *buffer;
     362 
     363  rw_args = (rtems_libio_rw_args_t *) arg;
     364 
     365  buffer = rw_args->buffer;
     366  maximum = rw_args->count;
     367 
     368  for (count = 0; count < maximum; count++) {
     369    if ( buffer[ count ] == '\n') {
     370      outbyte('\r');
     371    }
     372    outbyte( buffer[ count ] );
    325373  }
    326   return (nbytes);
    327 }
     374  return maximum;
     375}
     376 
     377/*
     378 *  IO Control entry point
     379 */
     380 
     381rtems_device_driver console_control(
     382  rtems_device_major_number major,
     383  rtems_device_minor_number minor,
     384  void                    * arg
     385)
     386{
     387  return RTEMS_SUCCESSFUL;
     388}
     389
  • c/src/lib/libmisc/error/error.c

    r5072b07 r3a4ae6c  
    9292    { "directive not implemented",          RTEMS_NOT_IMPLEMENTED, },
    9393    { "RTEMS inconsistency detected",       RTEMS_INTERNAL_ERROR, },
    94     { "internal multiprocessing only",      RTEMS_PROXY_BLOCKING, },
    9594    { "could not get enough memory",        RTEMS_NO_MEMORY, },
     95    { "internal multiprocessing only",      THREAD_STATUS_PROXY_BLOCKING, },
    9696    { 0, 0, 0 },
    9797};
     
    135135        local_errno = errno;
    136136
    137     if (_Configuration_Is_multiprocessing())
     137    if (_System_state_Is_multiprocessing)
    138138        fprintf(stderr, "[%d] ", _Configuration_MP_table->node);
    139139   
  • c/src/lib/libmisc/monitor/mon-dname.c

    r5072b07 r3a4ae6c  
    5858    rtems_driver_name_t    *np = 0;
    5959
    60     for (np = table + n ; n<RTEMS_MAX_DRIVER_NAMES; n++, np++)
     60/* XXX should we be using _IO_Number_of_devices */
     61    for (np = table + n ; n<_IO_Number_of_devices; n++, np++)
    6162        if (np->device_name)
    6263            goto done;
  • c/src/lib/libmisc/monitor/mon-extension.c

    r5072b07 r3a4ae6c  
    2323
    2424    rtems_monitor_symbol_canonical_by_value(&canonical_extension->create,
    25                                             e->rtems_task_create);
     25                                            e->thread_create);
    2626
    2727    rtems_monitor_symbol_canonical_by_value(&canonical_extension->start,
    28                                             e->rtems_task_start);
     28                                            e->thread_start);
    2929    rtems_monitor_symbol_canonical_by_value(&canonical_extension->restart,
    30                                             e->rtems_task_restart);
     30                                            e->thread_restart);
    3131    rtems_monitor_symbol_canonical_by_value(&canonical_extension->delete,
    32                                             e->rtems_task_delete);
     32                                            e->thread_delete);
    3333    rtems_monitor_symbol_canonical_by_value(&canonical_extension->tswitch,
    34                                             e->task_switch);
     34                                            e->thread_switch);
    3535    rtems_monitor_symbol_canonical_by_value(&canonical_extension->begin,
    36                                             e->task_begin);
     36                                            e->thread_begin);
    3737    rtems_monitor_symbol_canonical_by_value(&canonical_extension->exitted,
    38                                             e->task_exitted);
     38                                            e->thread_exitted);
    3939    rtems_monitor_symbol_canonical_by_value(&canonical_extension->fatal,
    4040                                            e->fatal);
  • c/src/lib/libmisc/monitor/mon-object.c

    r5072b07 r3a4ae6c  
    9393    },
    9494    { RTEMS_OBJECT_DNAME,
    95       (void *) &rtems_driver_name_table[0],
     95      /* XXX now that the driver name table is allocated from the */
     96      /* XXX Workspace, this does not work */
     97      (void *) 0,
     98      /* (void *) _IO_Driver_name_table, */
    9699      sizeof(rtems_monitor_dname_t),
    97100      (rtems_monitor_object_next_fn)        rtems_monitor_dname_next,
  • c/src/lib/libmisc/monitor/mon-server.c

    r5072b07 r3a4ae6c  
    220220    rtems_status_code status;
    221221   
    222     if (_Configuration_Is_multiprocessing()    &&
     222    if (_System_state_Is_multiprocessing    &&
    223223        (_Configuration_MP_table->maximum_nodes > 1))
    224224    {
  • c/src/lib/libmisc/monitor/mon-task.c

    r5072b07 r3a4ae6c  
    2020{
    2121    Thread_Control       *rtems_thread = (Thread_Control *) thread_void;
     22    RTEMS_API_Control    *api;
     23
     24    api = rtems_thread->API_Extensions[ THREAD_API_RTEMS ];
    2225   
    2326    canonical_task->entry = rtems_thread->Start.entry_point;
     
    2831    canonical_task->state = rtems_thread->current_state;
    2932    canonical_task->wait_id = rtems_thread->Wait.id;
    30     canonical_task->events = rtems_thread->RTEMS_API->pending_events;
    31     canonical_task->modes = rtems_thread->current_modes;
    32     canonical_task->attributes = 0 /* XXX FIX ME rtems_thread->RTEMS_API->attribute_set */;
    33     (void) memcpy(canonical_task->notepad, rtems_thread->RTEMS_API->Notepads, sizeof(canonical_task->notepad));
     33    canonical_task->events = api->pending_events;
     34
     35/* XXX modes and attributes only exist in the RTEMS API .. */
     36/* XXX not directly in the core thread.. they will have to be derived */
     37/* XXX if they are important enough to include anymore.   */
     38    canonical_task->modes = 0; /* XXX FIX ME.... rtems_thread->current_modes; */
     39    canonical_task->attributes = 0 /* XXX FIX ME rtems_thread->API_Extensions[ THREAD_API_RTEMS ]->attribute_set */;
     40    (void) memcpy(canonical_task->notepad, api ->Notepads, sizeof(canonical_task->notepad));
     41/* XXX more to fix */
     42/*
    3443    (void) memcpy(&canonical_task->wait_args, &rtems_thread->Wait.Extra, sizeof(canonical_task->wait_args));
     44*/
    3545}
    3646
  • c/src/lib/libmisc/stackchk/check.c

    r5072b07 r3a4ae6c  
    1919 */
    2020
    21 #include <rtems/system.h>
    22 #include <rtems/extension.h>
    23 #include <rtems/fatal.h>
    24 #include <rtems/heap.h>
    25 #include <rtems/stack.h>
    26 #include <rtems/thread.h>
    27 #ifdef XXX_RTEMS_H_FIXED
    28 #include <bsp.h>
    29 #else
    30 #include <rtems/config.h>
     21#include <rtems.h>
     22
    3123extern rtems_configuration_table BSP_Configuration;
    32 #endif
    3324
    3425#include <assert.h>
     
    5748  0,                                /* rtems_task_delete  */
    5849  Stack_check_Switch_extension,     /* task_switch  */
     50  0,                                /* task_post_switch  */
    5951  Stack_check_Begin_extension,      /* task_begin   */
    6052  0,                                /* task_exitted */
     
    134126void Stack_check_Initialize( void )
    135127{
    136   rtems_status_code status;
    137   Objects_Id   id_ignored;
    138   unsigned32  *p;
     128  rtems_status_code    status;
     129  Objects_Id           id_ignored;
     130  unsigned32          *p;
     131  unsigned32           i;
     132  unsigned32           class_index;
     133  Thread_Control      *the_thread;
     134  Objects_Information *information;
    139135
    140136  if (stack_check_initialized)
     
    172168   */
    173169
     170  /* XXX
     171   *
     172   *  Technically this has not been done for any task created before this
     173   *  happened.  So just run through them and fix the situation.
     174   */
     175#if 0
    174176  if (_Thread_Executing)
    175177  {
    176178      Stack_check_Create_extension(_Thread_Executing, _Thread_Executing);
    177179  }
     180#endif
     181
     182#if 0
     183  for ( class_index = OBJECTS_CLASSES_FIRST ;
     184        class_index <= OBJECTS_CLASSES_LAST ;
     185        class_index++ ) {
     186    information = _Objects_Information_table[ class_index ];
     187    if ( information && information->is_thread ) {
     188      for ( i=1 ; i <= information->maximum ; i++ ) {
     189        the_thread = (Thread_Control *)information->local_table[ i ];
     190        Stack_check_Create_extension( the_thread, the_thread );
     191      }
     192    }
     193  }
     194#endif
    178195
    179196  /*
     
    198215 */
    199216
    200 void Stack_check_Create_extension(
     217boolean Stack_check_Create_extension(
    201218  Thread_Control *running,
    202219  Thread_Control *the_thread
    203220)
    204221{
    205     if (the_thread && (the_thread != _Thread_Executing))
     222    if (the_thread /* XXX && (the_thread != _Thread_Executing) */ )
    206223        stack_check_dope_stack(&the_thread->Start.Initial_stack);
     224
     225    return TRUE;
    207226}
    208227
  • c/src/lib/libmisc/stackchk/internal.h

    r5072b07 r3a4ae6c  
    5151 */
    5252
    53 void Stack_check_Create_extension(
     53boolean Stack_check_Create_extension(
    5454  Thread_Control *running,
    5555  Thread_Control *the_thread
  • c/src/lib/start/i960/start.s

    r5072b07 r3a4ae6c  
    8181        ldconst 0,g0
    8282        ldconst 0,g1
    83         call    _bsp_start
     83        ldconst 0,g2
     84        call    _main
    8485        ret
    8586
  • c/src/lib/start/m68k/start.s

    r5072b07 r3a4ae6c  
    9898#endif
    9999
    100         jsr     SYM (bsp_start)
     100
     101        movel   #0,a7@-               | push environp
     102        movel   #0,a7@-               | push argv
     103        movel   #0,a7@-               | push argc
     104
     105        jsr     SYM (main)
     106        addl    #12,a7
     107
    101108#if ( M68K_HAS_SEPARATE_STACKS == 1 )
    102109        move.l  SYM (initial_isp),a0
Note: See TracChangeset for help on using the changeset viewer.