[PATCH 6/8] i386/pc386: Eliminate multiple warnings

Gedare Bloom gedare at rtems.org
Thu Oct 9 19:52:39 UTC 2014


On Thu, Oct 9, 2014 at 2:39 PM, Joel Sherrill <joel.sherrill at oarcorp.com> wrote:
> ---
>  c/src/lib/libbsp/i386/pc386/console/conscfg.c  |  7 +-
>  c/src/lib/libbsp/i386/pc386/console/keyboard.c | 99 +++++++++++++-------------
>  c/src/lib/libbsp/i386/pc386/console/outch.c    |  6 +-
>  c/src/lib/libbsp/i386/pc386/console/rtd316.c   |  3 +-
>  c/src/lib/libbsp/i386/pc386/console/rtd316.h   | 24 ++++++-
>  c/src/lib/libbsp/i386/pc386/ide/ide.c          |  2 +
>  c/src/lib/libbsp/i386/pc386/include/bsp.h      |  6 ++
>  c/src/lib/libbsp/i386/pc386/startup/bspstart.c |  3 -
>  c/src/lib/libbsp/i386/pc386/timer/timer.c      | 39 +++++-----
>  c/src/lib/libbsp/i386/shared/comm/i386-stub.c  | 12 ++--
>  10 files changed, 122 insertions(+), 79 deletions(-)
>
> diff --git a/c/src/lib/libbsp/i386/pc386/console/conscfg.c b/c/src/lib/libbsp/i386/pc386/console/conscfg.c
> index f9ed5d8..f0295ef 100644
> --- a/c/src/lib/libbsp/i386/pc386/console/conscfg.c
> +++ b/c/src/lib/libbsp/i386/pc386/console/conscfg.c
> @@ -5,7 +5,7 @@
>   */
>
>  /*
> - *  COPYRIGHT (c) 1989-2011.
> + *  COPYRIGHT (c) 1989-2014.
>   *  On-Line Applications Research Corporation (OAR).
>   *
>   *  The license and distribution terms for this file may be
> @@ -21,6 +21,7 @@
>  #include "vgacons.h"
>  #include <bsp/irq.h>
>  #include <rtems/pci.h>
> +#include <bsp/rtd316.h>
>
>  #define VGA_CONSOLE_FUNCTIONS  &vgacons_fns
>  #if 0
> @@ -39,7 +40,7 @@
>
>  #define CLOCK_RATE     (115200 * 16)
>
> -uint8_t com_get_register(uint32_t addr, uint8_t i)
> +static uint8_t com_get_register(uint32_t addr, uint8_t i)
>  {
>    register uint8_t val;
>
> @@ -47,7 +48,7 @@ uint8_t com_get_register(uint32_t addr, uint8_t i)
>    return val;
>  }
>
> -void com_set_register(uint32_t addr, uint8_t i, uint8_t val)
> +static void com_set_register(uint32_t addr, uint8_t i, uint8_t val)
>  {
>    outport_byte( (addr + i),val );
>  }
> diff --git a/c/src/lib/libbsp/i386/pc386/console/keyboard.c b/c/src/lib/libbsp/i386/pc386/console/keyboard.c
> index 271c5e3..3a33c54 100644
> --- a/c/src/lib/libbsp/i386/pc386/console/keyboard.c
> +++ b/c/src/lib/libbsp/i386/pc386/console/keyboard.c
> @@ -28,7 +28,7 @@
>  #define KBD_DEFLOCK 0
>  #endif
>
> -int set_bit(int nr, unsigned long * addr)
> +static int set_bit(int nr, unsigned long * addr)
>  {
>    int                   mask;
>    int                   retval;
> @@ -43,7 +43,7 @@ int set_bit(int nr, unsigned long * addr)
>    return retval;
>  }
>
> -int clear_bit(int nr, unsigned long * addr)
> +static int clear_bit(int nr, unsigned long * addr)
>  {
>    int                   mask;
>    int                   retval;
> @@ -58,7 +58,7 @@ int clear_bit(int nr, unsigned long * addr)
>    return retval;
>  }
>
> -int test_bit(int nr, unsigned long * addr)
> +static int test_bit(int nr, unsigned long * addr)
>  {
>    int  mask;
>
> @@ -167,19 +167,20 @@ static int sysrq_pressed;
>   * string, and in both cases we might assume that it is
>   * in utf-8 already.
>   */
> -void to_utf8(ushort c) {
> -    if (c < 0x80)
> -  put_queue(c);      /*  0*******  */
> -    else if (c < 0x800) {
> -  put_queue(0xc0 | (c >> 6));   /*  110***** 10******  */
> -  put_queue(0x80 | (c & 0x3f));
> -    } else {
> -  put_queue(0xe0 | (c >> 12));   /*  1110**** 10****** 10******  */
> -  put_queue(0x80 | ((c >> 6) & 0x3f));
> -  put_queue(0x80 | (c & 0x3f));
> -    }
> -    /* UTF-8 is defined for words of up to 31 bits,
> -       but we need only 16 bits here */
> +static void to_utf8(ushort c)
> +{
> +  if (c < 0x80)
> +    put_queue(c);                  /*  0*******  */
> +  else if (c < 0x800) {
> +    put_queue(0xc0 | (c >> 6));    /*  110***** 10******  */
> +    put_queue(0x80 | (c & 0x3f));
> +  } else {
> +    put_queue(0xe0 | (c >> 12));   /*  1110**** 10****** 10******  */
> +    put_queue(0x80 | ((c >> 6) & 0x3f));
> +    put_queue(0x80 | (c & 0x3f));
> +  }
> +  /* UTF-8 is defined for words of up to 31 bits,
> +     but we need only 16 bits here */
>  }
>
>  /*
> @@ -333,20 +334,19 @@ void handle_scancode(unsigned char scancode, int down)
>  static void ( *driver_input_handler_kbd )( void *, unsigned short, unsigned long ) = 0;
>  /*
>   */
> -void kbd_set_driver_handler( void ( *handler )( void *, unsigned short, unsigned long ) )
> +void kbd_set_driver_handler(
> +  void ( *handler )( void *, unsigned short, unsigned long )
> +)
>  {
>    driver_input_handler_kbd = handler;
>  }
>
>  static void put_queue(int ch)
>  {
> -  if( driver_input_handler_kbd )
> -  {
> -     driver_input_handler_kbd(  ( void *)kbd, (unsigned short)ch,  0 );
> -  }
> -  else
> -  {
> -     add_to_queue( ch );
> +  if ( driver_input_handler_kbd ) {
> +    driver_input_handler_kbd(  ( void *)kbd, (unsigned short)ch,  0 );
> +  } else {
> +    add_to_queue( ch );
>    }
>  }
>
> @@ -377,7 +377,6 @@ static void enter(void)
>
>    if (vc_kbd_mode(kbd,VC_CRLF))
>      put_queue(10);
> -
>  }
>
>  static void caps_toggle(void)
> @@ -403,12 +402,10 @@ static void hold(void)
>    if (rep )
>      return;
>     chg_vc_kbd_led(kbd, VC_SCROLLOCK );
> -
>  }
>
>  static void num(void)
>  {
> -
>    if (vc_kbd_mode(kbd,VC_APPLIC))
>      applkey('P', 1);
>    else
> @@ -771,39 +768,45 @@ static unsigned char ledstate = 0xff; /* undefined */
>  static unsigned char ledioctl;
>
>  unsigned char getledstate(void) {
> -    return ledstate;
> +  return ledstate;
>  }
>
>  void setledstate(struct kbd_struct *kbd, unsigned int led) {
> -    if (!(led & ~7)) {
> -  ledioctl = led;
> -   kbd->ledmode = LED_SHOW_IOCTL;
> -    } else
> +  if (!(led & ~7)) {
> +    ledioctl = led;
> +     kbd->ledmode = LED_SHOW_IOCTL;
> +  } else
>      ;
> -   kbd->ledmode = LED_SHOW_FLAGS;
> -    set_leds();
> +  kbd->ledmode = LED_SHOW_FLAGS;
> +  set_leds();
>  }
>
>  static struct ledptr {
> -    unsigned int *addr;
> -    unsigned int mask;
> -    unsigned char valid:1;
> +  unsigned int *addr;
> +  unsigned int mask;
> +  unsigned char valid:1;
>  } ledptrs[3];
>
> -void register_leds(int console, unsigned int led,
> -       unsigned int *addr, unsigned int mask) {
> -    struct kbd_struct *kbd = kbd_table + console;
> +void register_leds(
> +  int console,
> +  unsigned int led,
> +  unsigned int *addr,
> +  unsigned int mask
> +)
> +{
> +  struct kbd_struct *kbd = kbd_table + console;
>
> -   if (led < 3) {
> -  ledptrs[led].addr = addr;
> -  ledptrs[led].mask = mask;
> -  ledptrs[led].valid = 1;
> -  kbd->ledmode = LED_SHOW_MEM;
> -    } else
> -  kbd->ledmode = LED_SHOW_FLAGS;
> +  if (led < 3) {
> +    ledptrs[led].addr = addr;
> +    ledptrs[led].mask = mask;
> +    ledptrs[led].valid = 1;
> +    kbd->ledmode = LED_SHOW_MEM;
> +  } else
> +    kbd->ledmode = LED_SHOW_FLAGS;
>  }
>
> -static inline unsigned char getleds(void){
> +static inline unsigned char getleds(void)
> +{
>
>      struct kbd_struct *kbd = kbd_table + fg_console;
>
> diff --git a/c/src/lib/libbsp/i386/pc386/console/outch.c b/c/src/lib/libbsp/i386/pc386/console/outch.c
> index f0c7599..90ffedf 100644
> --- a/c/src/lib/libbsp/i386/pc386/console/outch.c
> +++ b/c/src/lib/libbsp/i386/pc386/console/outch.c
> @@ -239,7 +239,7 @@ int ro,co;
>         return rval;
>  }
>
> -void
> +static void
>  clear_screen(void)
>  {
>      int i,j;
> @@ -308,6 +308,10 @@ _IBMPC_initVideo(void)
>  } /* _IBMPC_initVideo */
>
>  /* for old DOS compatibility n-curses type of applications */
> +void gotoxy( int x, int y );
> +int whereX( void );
> +int whereY( void );
> +
>  void gotoxy( int x, int y )
>  {
>    gotorc(y,x);
> diff --git a/c/src/lib/libbsp/i386/pc386/console/rtd316.c b/c/src/lib/libbsp/i386/pc386/console/rtd316.c
> index e27f128..7219ff6 100644
> --- a/c/src/lib/libbsp/i386/pc386/console/rtd316.c
> +++ b/c/src/lib/libbsp/i386/pc386/console/rtd316.c
> @@ -7,7 +7,7 @@
>   */
>
>  /*
> - *  COPYRIGHT (c) 1989-2012.
> + *  COPYRIGHT (c) 1989-2014.
>   *  On-Line Applications Research Corporation (OAR).
>   *
>   *  The license and distribution terms for this file may be
> @@ -26,6 +26,7 @@
>  #include <rtems/bspIo.h>
>  #include <bsp/rtd316.h>
>  #include <rtems/score/i386.h>
> +#include <rtems/console_private.h>
>
>  #define RTD_CLOCK_RATE  (460800 * 32)
>
> diff --git a/c/src/lib/libbsp/i386/pc386/console/rtd316.h b/c/src/lib/libbsp/i386/pc386/console/rtd316.h
> index 6c3478c..aabad2c 100644
> --- a/c/src/lib/libbsp/i386/pc386/console/rtd316.h
> +++ b/c/src/lib/libbsp/i386/pc386/console/rtd316.h
> @@ -7,7 +7,7 @@
>   */
>
>  /*
> - *  COPYRIGHT (c) 1989-2012.
> + *  COPYRIGHT (c) 1989-2014.
>   *  On-Line Applications Research Corporation (OAR).
>   *
>   *  The license and distribution terms for this file may be
> @@ -47,6 +47,28 @@ rtems_device_driver rtd316_initialize(
>    void                      *arg
>  );
>
> +/**
> + *  @brief RTD316 Obtain Register Helper
> + *
> + *  This method is used to read registers on the RTD316.
> + *
> + *  @param[in] addr is the base address
> + *  @param[in] reg is the register number
> + *
> + *  @return This method returns the value of the register.
> + */
> +uint8_t rtd316_com_get_register(uint32_t addr, uint8_t reg);
> +
> +/**
> + *  @brief RTD316 Set Register Helper
> + *
> + *  This method is used to set registers on the RTD316.
> + *
> + *  @param[in] addr is the base address
> + *  @param[in] reg is the register number
> + */
> +void rtd316_com_set_register(uint32_t addr,uint8_t reg, uint8_t val);
> +
>  #ifdef __cplusplus
>  }
>  #endif
> diff --git a/c/src/lib/libbsp/i386/pc386/ide/ide.c b/c/src/lib/libbsp/i386/pc386/ide/ide.c
> index e74a193..73b6df2 100644
> --- a/c/src/lib/libbsp/i386/pc386/ide/ide.c
> +++ b/c/src/lib/libbsp/i386/pc386/ide/ide.c
> @@ -230,6 +230,8 @@ static void pc386_ide_initialize
>      char*       p = &model_number[0];
>      bool        data_ready;
>
> +    (void) cur_multiple_sectors; /* avoid set but not used warning */
> +
>      memset(model_number, 0, sizeof(model_number));
>
>      outport_byte(port+IDE_REGISTER_DEVICE_HEAD,
> diff --git a/c/src/lib/libbsp/i386/pc386/include/bsp.h b/c/src/lib/libbsp/i386/pc386/include/bsp.h
> index ef16b4a..7e6d3f3 100644
> --- a/c/src/lib/libbsp/i386/pc386/include/bsp.h
> +++ b/c/src/lib/libbsp/i386/pc386/include/bsp.h
> @@ -179,9 +179,15 @@ char          _IBMPC_inch     (void);    /* from 'inch.c'   */
>  char          _IBMPC_inch_sleep (void);  /* from 'inch.c'   */
>
>  void Wait_X_ms(unsigned int timeToWait); /* from 'timer.c'  */
> +void Calibrate_loop_1ms(void);           /* from 'timer.c'  */
> +
> +void rtems_irq_mngt_init(void);          /* from 'irq_init.c' */
> +
> +void bsp_size_memory(void);              /* from 'bspstart.c' */
>
>  void Clock_driver_install_handler(void); /* from 'ckinit.c'  */
>  void Clock_driver_support_initialize_hardware(void); /* from 'ckinit.c'  */
> +
>  size_t read_aux(char * buffer, size_t count); /* from 'ps2_mouse.c'  */
>
>  /* Definitions for BSPConsolePort */
> diff --git a/c/src/lib/libbsp/i386/pc386/startup/bspstart.c b/c/src/lib/libbsp/i386/pc386/startup/bspstart.c
> index ff67cc7..ebe6b7c 100644
> --- a/c/src/lib/libbsp/i386/pc386/startup/bspstart.c
> +++ b/c/src/lib/libbsp/i386/pc386/startup/bspstart.c
> @@ -36,9 +36,6 @@
>  /*
>   *  External routines
>   */
> -extern void Calibrate_loop_1ms(void);
> -extern void rtems_irq_mngt_init(void);
> -extern void bsp_size_memory(void);
>  void Clock_driver_install_handler(void);
>
>  /*-------------------------------------------------------------------------+
> diff --git a/c/src/lib/libbsp/i386/pc386/timer/timer.c b/c/src/lib/libbsp/i386/pc386/timer/timer.c
> index 953db03..541d2e3 100644
> --- a/c/src/lib/libbsp/i386/pc386/timer/timer.c
> +++ b/c/src/lib/libbsp/i386/pc386/timer/timer.c
> @@ -65,15 +65,16 @@ void Timer_exit(void);
>   */
>
>  /*
> - *  Timer cleanup routine at RTEMS exit. NOTE: This routine is
> - *  not really necessary, since there will be a reset at exit.
> + *  Timer cleanup routine at RTEMS exit.
> + *
> + *  NOTE: This routine is not really necessary, since there will be
> + *        a reset at exit.
>   */
> -
> -void tsc_timer_exit(void)
> +static void tsc_timer_exit(void)
>  {
>  }
>
> -void tsc_timer_initialize(void)
> +static void tsc_timer_initialize(void)
>  {
>    static bool First = true;
>
> @@ -86,9 +87,9 @@ void tsc_timer_initialize(void)
>  }
>
>  /*
> - *
> + * Read TSC timer value.
>   */
> -uint32_t tsc_read_timer(void)
> +static uint32_t tsc_read_timer(void)
>  {
>    register uint32_t  total;
>
> @@ -151,16 +152,18 @@ static rtems_raw_irq_connect_data timer_raw_irq_data = {
>  };
>
>  /*
> - * Timer cleanup routine at RTEMS exit. NOTE: This routine is
> - *  not really necessary, since there will be a reset at exit.
> - */ void
> -i386_timer_exit(void)
> + * Timer cleanup routine at RTEMS exit.
> + *
> + * NOTE: This routine is not really necessary, since there will be
> + *       a reset at exit.
> + */
> +static void i386_timer_exit(void)
>  {
>    i386_delete_idt_entry (&timer_raw_irq_data);
>  }
>
>  extern void rtems_irq_prologue_0(void);
> -void i386_timer_initialize(void)
> +static void i386_timer_initialize(void)
>  {
>    static bool First = true;
>
> @@ -192,7 +195,7 @@ void i386_timer_initialize(void)
>  /*
>   * Read hardware timer value.
>   */
> -uint32_t i386_read_timer(void)
> +static uint32_t i386_read_timer(void)
>  {
>    register uint32_t         total, clicks;
>    register uint8_t          lsb, msb;
> @@ -268,7 +271,7 @@ static unsigned short lastLoadedValue;
>   *
>   *  Returns: Nothing. Loaded value must be a number of clock bits...
>   */
> -void loadTimerValue( unsigned short loadedValue )
> +static void loadTimerValue( unsigned short loadedValue )
>  {
>    lastLoadedValue = loadedValue;
>    outport_byte(TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_SQWAVE);
> @@ -282,7 +285,7 @@ void loadTimerValue( unsigned short loadedValue )
>   *
>   * Returns: number of clock bits elapsed since last load.
>   */
> -unsigned int readTimer0(void)
> +static unsigned int readTimer0(void)
>  {
>    unsigned short lsb, msb;
>    unsigned char  status;
> @@ -302,19 +305,19 @@ unsigned int readTimer0(void)
>    return (2*lastLoadedValue - count);
>  }
>
> -void Timer0Reset(void)
> +static void Timer0Reset(void)
>  {
>    loadTimerValue(0xffff);
>    readTimer0();
>  }
>
> -void fastLoop (unsigned int loopCount)
> +static void fastLoop (unsigned int loopCount)
>  {
>    unsigned int i;
>    for( i=0; i < loopCount; i++ )outport_byte( SLOW_DOWN_IO, 0 );
>  }
>
> -void slowLoop (unsigned int loopCount)
> +static void slowLoop (unsigned int loopCount)
>  {
>    unsigned int j;
>    for (j=0; j <100 ;  j++) {
> diff --git a/c/src/lib/libbsp/i386/shared/comm/i386-stub.c b/c/src/lib/libbsp/i386/shared/comm/i386-stub.c
> index 578b018..8113d7e 100644
> --- a/c/src/lib/libbsp/i386/shared/comm/i386-stub.c
> +++ b/c/src/lib/libbsp/i386/shared/comm/i386-stub.c
> @@ -607,7 +607,7 @@ set_char (char *addr, int val)
>  /* return a pointer to the last char put in buf (null) */
>  /* If MAY_FAULT is non-zero, then we should set mem_err in response to
>     a fault; if zero treat a fault like any other fault in the stub.  */
> -char *
> +static char *
>  mem2hex (char *mem, char *buf, int count, int may_fault)
>  {
>    int i;
> @@ -654,7 +654,7 @@ hex2mem (char *buf, char *mem, int count, int may_fault)
>
>  /* this function takes the 386 exception vector and attempts to
>     translate this number into a unix compatible signal value */
> -int
> +static int
>  computeSignal (int exceptionVector)
>  {
>    int sigval;
> @@ -715,7 +715,7 @@ computeSignal (int exceptionVector)
>  /* WHILE WE FIND NICE HEX CHARS, BUILD AN INT */
>  /* RETURN NUMBER OF CHARS PROCESSED           */
>  /**********************************************/
> -int
> +static int
>  hexToInt (char **ptr, int *intValue)
>  {
Put the function name on the line with return type? More like this above.

>    int numChars = 0;
> @@ -742,8 +742,12 @@ hexToInt (char **ptr, int *intValue)
>
>  /*
>   * This function does all command procesing for interfacing to gdb.
> + *
> + * NOTE: This method is called from assembly code so must be marked
> + *       as used.
>   */
> -void
> +static void handle_exception (int exceptionVector) __attribute__((used));
> +static void
I'm not certain what the semantics are for declaring  a function
static when it is used from another source file. Perhaps it should be
declared somewhere? Also, there should be an RTEMS_ATTRIBUTE_USED or
similar that should be used here.

>  handle_exception (int exceptionVector)
>  {
>    int sigval;
> --
> 1.9.3
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel



More information about the devel mailing list