Changeset 69ed59f in rtems


Ignore:
Timestamp:
May 14, 2002, 5:10:17 PM (18 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
6a4df9f9
Parents:
3ce2907
Message:

2001-05-14 Till Straumann <strauman@…>

  • bootloader/misc.c, console/Makefile.am, console/console.c, console/consoleIo.h, console/inch.c, console/polled_io.c, console/uart.c, console/uart.h, include/bsp.h, irq/Makefile.am, irq/irq.c, irq/irq.h, irq/irq_init.c, openpic/openpic.c, openpic/openpic.h, pci/Makefile.am, pci/pci.c, pci/pci.h, residual/Makefile.am, start/start.S, startup/bspstart.c, vectors/vectors.S, vectors/vectors.h, vectors/vectors_init.c: Per PR216, "libbsp/powerpc/shared" BSP has been modified considerably with the goal to make it more flexible and reusable by other BSPs. The main strategies were:
    • eliminate hardcoded base addresses; devices use offsets and a BSP defined base address.
    • separate functionality into different files (e.g. reboot from inch.c to reboot.c) which can be overridden by a 'derived' BSP.
    • separate initialization code into separate files (e.g. PCI bridge detection/initialization was separated from the more generic PCI access routines), also to make it easier for 'derived' BSPs to substitute their own initialization code.

There are also a couple of enhancements and fixes:

  • IRQ handling code now has a hook for attaching a VME bridge.
  • OpenPIC is now explicitely initialized (polarities, senses). Eliminated the implicit assumption on the presence of an ISA PIC.
  • UART and console driver now supports more than 1 port. The current maximum of 2 can easily be extended by enlarging a table (it would even be easier if the ISR API was not broken by design).
  • fixed polled_io.c so it correctly supports console on COM2
  • fixed TLB invalidation code (start.S).
  • exception handler prints a stack backtrace.
  • added BSP_pciFindDevice() to scan the pci bus for a particular vendor/device/instance.
Location:
c/src/lib/libbsp/powerpc/shared
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/powerpc/shared/ChangeLog

    r3ce2907 r69ed59f  
     12001-05-14      Till Straumann <strauman@slac.stanford.edu>
     2
     3        * bootloader/misc.c, console/Makefile.am, console/console.c,
     4        console/consoleIo.h, console/inch.c, console/polled_io.c,
     5        console/uart.c, console/uart.h, include/bsp.h, irq/Makefile.am,
     6        irq/irq.c, irq/irq.h, irq/irq_init.c, openpic/openpic.c,
     7        openpic/openpic.h, pci/Makefile.am, pci/pci.c, pci/pci.h,
     8        residual/Makefile.am, start/start.S, startup/bspstart.c,
     9        vectors/vectors.S, vectors/vectors.h, vectors/vectors_init.c:
     10        Per PR216, "libbsp/powerpc/shared" BSP has been modified considerably
     11        with the goal to make it more flexible and reusable by other
     12        BSPs. The main strategies were:
     13            - eliminate hardcoded base addresses; devices use offsets
     14              and a BSP defined base address.
     15            - separate functionality into different files (e.g. reboot from
     16              inch.c to reboot.c) which can be overridden by a 'derived' BSP.
     17            - separate initialization code into separate files (e.g.  PCI
     18              bridge detection/initialization was separated from the more
     19              generic PCI access routines), also to make it easier for
     20              'derived' BSPs to substitute their own initialization code.
     21        There are also a couple of enhancements and fixes:
     22            - IRQ handling code now has a hook for attaching a VME bridge.
     23            - OpenPIC is now explicitely initialized (polarities, senses).
    124              Eliminated the implicit assumption on the presence of an ISA PIC.
    225            - UART and console driver now supports more than 1 port. The current
  • c/src/lib/libbsp/powerpc/shared/bootloader/misc.c

    r3ce2907 r69ed59f  
    234234}
    235235
     236static int ticks_per_ms=0;
     237
     238/* this is from rtems_bsp_delay from libcpu */
     239void
     240boot_udelay(unsigned32 _microseconds)
     241{
     242   unsigned32 start, ticks, now;
     243
     244   ticks = _microseconds * ticks_per_ms / 1000;
     245   CPU_Get_timebase_low( start );
     246   do {
     247     CPU_Get_timebase_low( now );
     248   } while (now - start < ticks);
     249}
     250
    236251void
    237252setup_hw(void)
     
    403418                        break;  /* Exit 'timer' loop */
    404419                }
    405                 udelay(1000);  /* 1 msec */
     420                boot_udelay(1000);  /* 1 msec */
    406421        }
    407422        *cp = 0;
  • c/src/lib/libbsp/powerpc/shared/console/Makefile.am

    r3ce2907 r69ed59f  
    44
    55
    6 C_FILES = console.c inch.c polled_io.c uart.c
     6C_FILES = console.c inch.c polled_io.c uart.c reboot.c
    77
    88H_FILES = consoleIo.h keyboard.h uart.h
     
    1919all-local: $(PREINSTALL_FILES)
    2020
    21 EXTRA_DIST = console.c consoleIo.h inch.c keyboard.h polled_io.c uart.c \
    22     uart.h
     21EXTRA_DIST = console.c inch.c polled_io.c uart.c \
     22    reboot.c console.inl
    2323
    2424include $(top_srcdir)/../../../../../automake/local.am
  • c/src/lib/libbsp/powerpc/shared/console/console.c

    r3ce2907 r69ed59f  
    99 * (C) Copyright 1997 -
    1010 * - NavIST Group - Real-Time Distributed Systems and Industrial Automation
     11 *
     12 * Till Straumann, <strauman@slac.stanford.edu>, 12/20/2001
     13 * separate BSP specific stuff from generics...
    1114 *
    1215 * http://pandora.ist.utl.pt
     
    3538#include <bsp/uart.h>
    3639#include <bsp/consoleIo.h>
     40#include <rtems/bspIo.h>        /* printk */
    3741
    3842/* Definitions for BSPConsolePort */
    39 #define BSP_CONSOLE_PORT_CONSOLE (-1)
    40 #define BSP_CONSOLE_PORT_COM1    (BSP_UART_COM1)
    41 #define BSP_CONSOLE_PORT_COM2    (BSP_UART_COM2)
    4243/*
    4344 * Possible value for console input/output :
     
    4647 *      BSP_UART_COM2
    4748 */
    48 
    49 int BSPConsolePort = BSP_UART_COM1;
    50 
    51 /* int BSPConsolePort = BSP_UART_COM2;  */
    52 int BSPBaseBaud    = 115200;
     49int BSPConsolePort = BSP_CONSOLE_PORT;
     50
     51int BSPBaseBaud    = BSP_UART_BAUD_BASE;
    5352
    5453/*-------------------------------------------------------------------------+
     
    5756
    5857static int  conSetAttr(int minor, const struct termios *);
    59 static void isr_on(const rtems_irq_connect_data *);
    60 static void isr_off(const rtems_irq_connect_data *);
    61 static int  isr_is_on(const rtems_irq_connect_data *);
    62 
    63 
    64 static rtems_irq_connect_data console_isr_data = {BSP_ISA_UART_COM1_IRQ,
    65                                                    BSP_uart_termios_isr_com1,
    66                                                    isr_on,
    67                                                    isr_off,
    68                                                    isr_is_on};
    69 
    70 static void
    71 isr_on(const rtems_irq_connect_data *unused)
    72 {
    73   return;
    74 }
    75                                                    
    76 static void
    77 isr_off(const rtems_irq_connect_data *unused)
    78 {
    79   return;
    80 }
    81 
    82 static int
    83 isr_is_on(const rtems_irq_connect_data *irq)
    84 {
    85   return BSP_irq_enabled_at_i8259s(irq->name);
    86 }
    8758
    8859void __assert (const char *file, int line, const char *msg)
     
    11384}
    11485
     86typedef struct TtySTblRec_ {
     87                char    *name;
     88                void    (*isr)(void); /* STUPID API doesn't pass a parameter :-( */
     89} TtySTblRec, *TtySTbl;
     90
     91static TtySTblRec ttyS[]={
     92                { "/dev/ttyS0",
     93#ifdef BSP_UART_IOBASE_COM1
     94                  BSP_uart_termios_isr_com1
     95#else
     96                  0
     97#endif
     98                },
     99                { "/dev/ttyS1",
     100#ifdef BSP_UART_IOBASE_COM2
     101                  BSP_uart_termios_isr_com2
     102#else
     103                  0
     104#endif
     105                },
     106};
     107
    115108
    116109/*-------------------------------------------------------------------------+
     
    131124   */
    132125
    133 
    134126  /*
    135127   * Set up TERMIOS
     
    140132   * Do device-specific initialization
    141133   */
    142      
    143   /* 9600-8-N-1 */
    144   BSP_uart_init(BSPConsolePort, 9600, 0);
    145      
    146      
    147   /* Set interrupt handler */
    148   if(BSPConsolePort == BSP_UART_COM1)
    149     {
    150       console_isr_data.name = BSP_ISA_UART_COM1_IRQ;
    151       console_isr_data.hdl  = BSP_uart_termios_isr_com1;
    152          
    153     }
    154   else
    155     {
    156       assert(BSPConsolePort == BSP_UART_COM2);
    157       console_isr_data.name = BSP_ISA_UART_COM2_IRQ;
    158       console_isr_data.hdl  = BSP_uart_termios_isr_com2;
    159     }
    160 
    161   status = BSP_install_rtems_irq_handler(&console_isr_data);
    162 
    163   if (!status){
    164     printk("Error installing serial console interrupt handler!\n");
    165     rtems_fatal_error_occurred(status);
     134
     135  /* RTEMS calls this routine once with 'minor'==0; loop through
     136   * all known instances...
     137   */
     138     
     139  for (minor=0; minor < sizeof(ttyS)/sizeof(ttyS[0]); minor++) {
     140        char *nm;
     141          /*
     142           * Skip ports (possibly not supported by BSP...) we have no ISR for
     143           */
     144          if ( ! ttyS[minor].isr )
     145                continue;
     146          /*
     147           * Register the device
     148           */
     149          status = rtems_io_register_name ((nm=ttyS[minor].name), major, minor);
     150          if ( RTEMS_SUCCESSFUL==status && BSPConsolePort == minor)
     151                {
     152                  printk("Registering /dev/console as minor %i (==%s)\n",
     153                                                        minor,
     154                                                        ttyS[minor].name);
     155                  /* also register an alias */
     156                  status = rtems_io_register_name (
     157                                                        (nm="/dev/console"),
     158                                                        major,
     159                                                        minor);
     160                }
     161          if (status != RTEMS_SUCCESSFUL)
     162                {
     163                  printk("Error registering %s!\n",nm);
     164                  rtems_fatal_error_occurred (status);
     165                }
     166
    166167  }
    167   /*
    168    * Register the device
    169    */
    170   status = rtems_io_register_name ("/dev/console", major, 0);
    171   if (status != RTEMS_SUCCESSFUL)
    172     {
    173       printk("Error registering console device!\n");
    174       rtems_fatal_error_occurred (status);
    175     }
    176 
    177   if(BSPConsolePort == BSP_UART_COM1)
    178     {
    179       printk("Initialized console on port COM1 9600-8-N-1\n\n");
    180     }
    181   else
    182     {
    183       printk("Initialized console on port COM2 9600-8-N-1\n\n");
    184     }
    185168  return RTEMS_SUCCESSFUL;
    186169} /* console_initialize */
    187170
     171static int console_first_open(int major, int minor, void *arg)
     172{
     173  rtems_status_code status;
     174
     175          /* must not open a minor device we have no ISR for */
     176          assert( minor>=0 && minor < sizeof(ttyS)/sizeof(ttyS[0]) && ttyS[minor].isr );
     177
     178          /* 9600-8-N-1 */
     179          BSP_uart_init(minor, 9600, 0);
     180          status = BSP_uart_install_isr(minor, ttyS[minor].isr);
     181          if (!status)
     182                {
     183                  printk("Error installing serial console interrupt handler for '%s'!\n",
     184                                ttyS[minor].name);
     185                  rtems_fatal_error_occurred(status);
     186                }
     187          return 0;
     188}
     189
    188190
    189191static int console_last_close(int major, int minor, void *arg)
    190192{
    191   BSP_remove_rtems_irq_handler (&console_isr_data);
    192 
     193  BSP_uart_remove_isr(minor, ttyS[minor].isr);
    193194  return 0;
    194195}
     
    205206  static rtems_termios_callbacks cb =
    206207  {
    207     NULL,                     /* firstOpen */
    208     console_last_close,       /* lastClose */
    209     NULL,                     /* pollRead */
    210     BSP_uart_termios_write_com1, /* write */
    211     conSetAttr,               /* setAttributes */
    212     NULL,                     /* stopRemoteTx */
    213     NULL,                     /* startRemoteTx */
    214     1                         /* outputUsesInterrupts */
     208    console_first_open,                 /* firstOpen */
     209    console_last_close,                 /* lastClose */
     210    NULL,                                               /* pollRead */
     211    BSP_uart_termios_write_com, /* write */
     212    conSetAttr,                                 /* setAttributes */
     213    NULL,                                               /* stopRemoteTx */
     214    NULL,                                               /* startRemoteTx */
     215    1                                                   /* outputUsesInterrupts */
    215216  };
    216 
    217   if(BSPConsolePort == BSP_UART_COM2)
    218     {
    219       cb.write = BSP_uart_termios_write_com2;
    220     }
    221217
    222218  status = rtems_termios_open (major, minor, arg, &cb);
     
    231227   * Pass data area info down to driver
    232228   */
    233   BSP_uart_termios_set(BSPConsolePort,
     229  BSP_uart_termios_set(minor,
    234230                         ((rtems_libio_open_close_args_t *)arg)->iop->data1);
    235231  /* Enable interrupts  on channel */
    236   BSP_uart_intr_ctrl(BSPConsolePort, BSP_UART_INTR_CTRL_TERMIOS);
     232  BSP_uart_intr_ctrl(minor, BSP_UART_INTR_CTRL_TERMIOS);
    237233
    238234  return RTEMS_SUCCESSFUL;
     
    363359    }
    364360
    365   BSP_uart_set_baud(BSPConsolePort, baud);
     361  BSP_uart_set_baud(minor, baud);
    366362
    367363  return 0;
    368364}
    369 
    370 
    371 
  • c/src/lib/libbsp/powerpc/shared/console/consoleIo.h

    r3ce2907 r69ed59f  
    2727  __io_ptr io_base;
    2828  __io_ptr isa_mem_base;
    29   __io_ptr pci_mmio_base;
    30   __io_ptr pci_dma_offset;
    3129} board_memory_map;
    3230
    3331extern board_memory_map *ptr_mem_map;
    34 extern unsigned long ticks_per_ms;
    3532
    3633extern int select_console(ioType t);
    3734/* extern int printk(const char *, ...) __attribute__((format(printf, 1, 2))); */
    38 extern void udelay(int);
    3935extern void debug_putc(const unsigned char c);
    4036extern int debug_getc(void);
  • c/src/lib/libbsp/powerpc/shared/console/inch.c

    r3ce2907 r69ed59f  
    2323#include <bsp/irq.h>
    2424
     25#include "console.inl"
     26
    2527/*-------------------------------------------------------------------------+
    2628| Constants
    2729+--------------------------------------------------------------------------*/
    28 #define KBD_CTL      0x61  /* -------------------------------- */
    29 #define KBD_DATA     0x60  /* Ports for PC keyboard controller */
    30 #define KBD_STATUS   0x64  /* -------------------------------- */
     30#define KBD_CTL      0x1  /* -------------------------------- */
     31#define KBD_DATA     0x0  /* Port offsets for PC keyboard controller */
     32#define KBD_STATUS   0x4  /* -------------------------------- */
    3133
    3234#define KBD_BUF_SIZE 256
     
    6365
    6466/*-------------------------------------------------------------------------+
    65 |         Function: rtemsReboot
    66 |      Description: Reboot the PC.
    67 | Global Variables: None.
    68 |        Arguments: None.
    69 |          Returns: Nothing.
    70 +--------------------------------------------------------------------------*/
    71 void rtemsReboot(void)
    72 {
    73   /* shutdown and reboot */
    74   outport_byte(0x64, 0xFE);      /* use keyboard controler to do the job... */
    75 } /* rtemsReboot */
    76 
    77 /*-------------------------------------------------------------------------+
    7867|         Function: _IBMPC_scankey
    7968|      Description: This function can be called during a poll for input, or by
     
    9887
    9988  /* Read keyboard controller, toggle enable */
    100   inport_byte(KBD_CTL, inChar);
    101   outport_byte(KBD_CTL, inChar & ~0x80);
    102   outport_byte(KBD_CTL, inChar | 0x80);
    103   outport_byte(KBD_CTL, inChar & ~0x80);
     89  inChar=kbd_inb(KBD_CTL);
     90  kbd_outb(KBD_CTL, inChar & ~0x80);
     91  kbd_outb(KBD_CTL, inChar | 0x80);
     92  kbd_outb(KBD_CTL, inChar & ~0x80);
    10493
    10594  /* See if it has data */
    106   inport_byte(KBD_STATUS, inChar);
     95  inChar=kbd_inb(KBD_STATUS);
    10796  if ((inChar & 0x01) == 0)
    10897    return FALSE;
    10998
    11099  /* Read the data.  Handle nonsense with shift, control, etc. */
    111   inport_byte(KBD_DATA, inChar);
     100  inChar=kbd_inb(KBD_DATA);
    112101
    113102  if (extended)
  • c/src/lib/libbsp/powerpc/shared/console/polled_io.c

    r3ce2907 r69ed59f  
    2121#include <libcpu/page.h>
    2222#include <libcpu/mmu.h>
    23 #include "keyboard.h"
    2423#include <libcpu/io.h>
    2524#include <string.h>
    2625#include <stdarg.h>
    2726#include <bsp/consoleIo.h>
     27#include <bsp.h>
    2828#include <libcpu/spr.h>
     29
     30#ifdef BSP_KBD_IOBASE
     31#define USE_KBD_SUPPORT
     32#endif
     33#ifdef BSP_VGA_IOBASE
     34#define USE_VGA_SUPPORT
     35#endif
     36
     37#ifdef USE_KBD_SUPPORT
     38#include "keyboard.h"
     39#endif
     40#include "console.inl"
     41
     42#ifdef __BOOT__
     43extern void boot_udelay();
     44#endif
    2945
    3046typedef unsigned long long u64;
     
    3248typedef unsigned int u32;
    3349
     50#ifdef USE_KBD_SUPPORT
    3451unsigned short plain_map[NR_KEYS] = {
    3552        0xf200, 0xf01b, 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036,
     
    297314/* These #defines have been copied from drivers/char/pc_keyb.h, by
    298315 * Martin Mares (mj@ucw.cz). 
    299  */
    300 #define KBD_STATUS_REG          0x64    /* Status register (R) */
    301 #define KBD_CNTL_REG            0x64    /* Controller command register (W) */
    302 #define KBD_DATA_REG            0x60    /* Keyboard data register (R/W) */
     316 * converted to offsets by Till Straumann <strauman@slac.stanford.edu>
     317 */
     318#define KBD_STATUS_REG          0x4     /* Status register (R) */
     319#define KBD_CNTL_REG            0x4     /* Controller command register (W) */
     320#define KBD_DATA_REG            0x0     /* Keyboard data register (R/W) */
    303321
    304322/*
     
    357375SPR_RO(PVR)
    358376
     377#endif /* USE_KBD_SUPPORT */
     378
    359379
    360380/* Early messages after mm init but before console init are kept in log
     
    378398
    379399static board_memory_map mem_map = {
    380   (__io_ptr) 0x80000000,
    381   (__io_ptr) 0xc0000000,
    382   (__io_ptr) 0xc0000000,
    383   (__io_ptr) 0x80000000
     400  (__io_ptr) _IO_BASE,          /* from libcpu/io.h */
     401  (__io_ptr) _ISA_MEM_BASE,
    384402};
    385403
     
    404422
    405423extern console_io* curIo;
    406 
    407 unsigned long ticks_per_ms = 1000000;   /* Decrementer ticks per ms (true for 601) */
    408 
    409 /* The decrementer is present on all processors and the RTC on the 601
    410  * has the annoying characteristic of jumping from 1e9 to 0, so we
    411  * use the decrementer.
    412  */
    413 void udelay(int us) {
    414         us = us*ticks_per_ms/1000;
    415         _write_DEC(us);
    416         while((int)_read_DEC() >= 0);
    417 }
    418424
    419425void debug_putc(const u_char c)
     
    474480#define LSR_ERR  0x80  /* Error */
    475481
    476 #define COM1    0x3F8
    477482
    478483#ifdef STATIC_LOG_ALLOC
     
    544549}
    545550
     551#ifndef INL_CONSOLE_INB
     552#error "BSP probably didn't define a console port"
     553#endif
     554
    546555void serial_putc(const u_char c)
    547556{
    548         while ((inb(COM1+lsr) & LSR_THRE) == 0) ;
    549         outb(c, COM1+thr);
     557        while ((INL_CONSOLE_INB(lsr) & LSR_THRE) == 0) ;
     558        INL_CONSOLE_OUTB(thr, c);
    550559}
    551560 
    552561int serial_getc(void)
    553562{
    554         while ((inb(COM1+lsr) & LSR_DR) == 0) ;
    555         return (inb(COM1+rbr));
     563        while ((INL_CONSOLE_INB(lsr) & LSR_DR) == 0) ;
     564        return (INL_CONSOLE_INB(rbr));
    556565}
    557566
    558567int serial_tstc(void)
    559568{
    560         return ((inb(COM1+lsr) & LSR_DR) != 0);
    561 }
    562 
     569        return ((INL_CONSOLE_INB(lsr) & LSR_DR) != 0);
     570}
     571
     572#ifdef USE_VGA_SUPPORT
    563573static void scroll(void)
    564574{
     
    580590{
    581591        int pos = console_global_data.cols*y + x;
    582         outb(14, 0x3D4);
    583         outb(pos>>8, 0x3D5);
    584         outb(15, 0x3D4);
    585         outb(pos, 0x3D5);
     592        vga_outb(14, 0x14);
     593        vga_outb(0x15, pos>>8);
     594        vga_outb(0x14, 15);
     595        vga_outb(0x15, pos);
    586596}
    587597
     
    621631        console_global_data.orig_y = y;
    622632}
    623 
     633#endif /* USE_VGA_SUPPORT */
     634
     635#ifdef USE_KBD_SUPPORT
    624636/* Keyboard support */
    625637static int kbd_getc(void)
     
    628640        unsigned code;
    629641loop:
    630         while((inb(KBD_STATUS_REG) & KBD_STAT_OBF) == 0) ;
    631 
    632         dt = inb(KBD_DATA_REG);
     642        while((kbd_inb(KBD_STATUS_REG) & KBD_STAT_OBF) == 0) ;
     643
     644        dt = kbd_inb(KBD_DATA_REG);
    633645
    634646        brk = dt & 0x80;        /* brk == 1 on key release */
     
    668680enter:              /* Wait for key up */
    669681                    while (1) {
    670                         while((inb(KBD_STATUS_REG) & KBD_STAT_OBF) == 0) ;
    671                         dt = inb(KBD_DATA_REG);
     682                        while((kbd_inb(KBD_STATUS_REG) & KBD_STAT_OBF) == 0) ;
     683                        dt = kbd_inb(KBD_DATA_REG);
    672684                        if (dt & 0x80) /* key up */ break;
    673685                    }
     
    733745        int status, data;
    734746        while(1) {
    735                 status = inb(KBD_STATUS_REG);
     747                status = kbd_inb(KBD_STATUS_REG);
    736748                if (status & KBD_STAT_OBF) {
    737                         data = inb(KBD_DATA_REG);
     749                        data = kbd_inb(KBD_DATA_REG);
    738750                        if (status & (KBD_STAT_GTO | KBD_STAT_PERR))
    739751                                return -1;
     
    742754                }
    743755                if (--ms < 0) return -1;
    744                 udelay(1000);
     756#ifdef __BOOT__
     757                boot_udelay(1000);
     758#else
     759                rtems_bsp_delay(1000);
     760#endif
    745761        }
    746762}
    747763
    748764static void kbd_put(u_char c, int ms, int port) {
    749         while (inb(KBD_STATUS_REG) & KBD_STAT_IBF) {
     765        while (kbd_inb(KBD_STATUS_REG) & KBD_STAT_IBF) {
    750766                if (--ms < 0) return;
    751                 udelay(1000);
     767#ifdef __BOOT__
     768                boot_udelay(1000);
     769#else
     770                rtems_bsp_delay(1000);
     771#endif
    752772        }
    753         outb(c, port);
     773        kbd_outb(port, c);
    754774}
    755775
     
    797817int kbd_tstc(void)
    798818{
    799         return ((inb(KBD_STATUS_REG) & KBD_STAT_OBF) != 0);
    800 }
     819        return ((kbd_inb(KBD_STATUS_REG) & KBD_STAT_OBF) != 0);
     820}
     821#endif /* USE_KBD_SUPPORT */
    801822
    802823const struct console_io
     
    812833        vacuum_getc,
    813834        vacuum_tstc
    814 },
    815 
     835}
     836,
    816837serial_console_functions = {
    817838        serial_putc,
    818839        serial_getc,
    819840        serial_tstc
    820 },
    821 
     841}
     842#if defined(USE_KBD_SUPPORT) && defined(USE_VGA_SUPPORT)
     843,
    822844vga_console_functions = {
    823845        vga_putc,
    824846        kbd_getc,
    825847        kbd_tstc
    826 };
     848}
     849#endif
     850;
    827851
    828852console_io* curIo = (console_io*) &vacuum_console_functions;
     
    835859  case CONSOLE_LOG      : curIo = (console_io*)&log_console_functions; break;
    836860  case CONSOLE_SERIAL   : curIo = (console_io*)&serial_console_functions; break;
     861#if defined(USE_KBD_SUPPORT) && defined(USE_VGA_SUPPORT)
    837862  case CONSOLE_VGA      : curIo = (console_io*)&vga_console_functions; break;
     863#endif
    838864  default               : curIo = (console_io*)&vacuum_console_functions;break;
    839865  }
  • c/src/lib/libbsp/powerpc/shared/console/uart.c

    r3ce2907 r69ed59f  
    2020struct uart_data
    2121{
     22  unsigned long ioBase;
    2223  int hwFlow;
    2324  int baud;
    2425};
    2526
    26 static struct uart_data uart_data[2];
    27 
     27/*
     28 * Initialization of BSP specific data.
     29 * The constants are pulled in from a BSP
     30 * specific file, whereas all of the code
     31 * in this file is generic and makes no
     32 * assumptions about addresses, irq vectors
     33 * etc...
     34 */
     35
     36#define UART_UNSUPP ((unsigned long)(-1))
     37
     38static struct uart_data uart_data[2] = {
     39        {
     40#ifdef  BSP_UART_IOBASE_COM1
     41                BSP_UART_IOBASE_COM1,
     42#else
     43                UART_UNSUPP,
     44#endif
     45        },
     46        {
     47#ifdef  BSP_UART_IOBASE_COM2
     48                BSP_UART_IOBASE_COM2,
     49#else
     50                UART_UNSUPP,
     51#endif
     52        },
     53};
     54
     55#define MAX_UARTS (sizeof(uart_data)/sizeof(uart_data[0]))
     56#define SANITY_CHECK(uart) \
     57  assert( MAX_UARTS > (unsigned)(uart) && uart_data[(uart)].ioBase != UART_UNSUPP )
    2858/*
    2959 * Macros to read/wirte register of uart, if configuration is
     
    3464uread(int uart, unsigned int reg)
    3565{
    36   register unsigned char val;
    37 
    38   if(uart == 0)
    39     {
    40       inport_byte(COM1_BASE_IO+reg, val);
    41     }
    42   else
    43     {
    44       inport_byte(COM2_BASE_IO+reg, val);
    45     }
    46 
    47   return val;
     66
     67  return in_8((unsigned char*)(uart_data[uart].ioBase + reg));
     68
    4869}
    4970
     
    5172uwrite(int uart, int reg, unsigned int val)
    5273{
    53   if(uart == 0)
    54     {
    55       outport_byte(COM1_BASE_IO+reg, val);
    56     }
    57   else
    58     {
    59       outport_byte(COM2_BASE_IO+reg, val);
    60     }
     74  out_8((unsigned char*)(uart_data[uart].ioBase + reg), val);
    6175}
    6276
     
    104118 
    105119  /* Sanity check */
    106   assert(uart == BSP_UART_COM1 || uart == BSP_UART_COM2);
     120  SANITY_CHECK(uart);
    107121 
    108122  switch(baud)
     
    167181
    168182  /* Sanity check */
    169   assert(uart == BSP_UART_COM1 || uart == BSP_UART_COM2);
     183  SANITY_CHECK(uart);
    170184 
    171185  /*
     
    198212{
    199213
    200   assert(uart == BSP_UART_COM1 || uart == BSP_UART_COM2);
     214  SANITY_CHECK(uart);
    201215
    202216  switch(cmd)
     
    261275  unsigned int mcr;
    262276 
    263   assert(uart == BSP_UART_COM1 || uart == BSP_UART_COM2);
     277  SANITY_CHECK(uart);
    264278
    265279  if(!uart_data[uart].hwFlow)
     
    282296  unsigned int mcr;
    283297
    284   assert(uart == BSP_UART_COM1 || uart == BSP_UART_COM2);
     298  SANITY_CHECK(uart);
    285299
    286300  if(!uart_data[uart].hwFlow)
     
    312326  unsigned char val;
    313327
    314   assert(uart == BSP_UART_COM1 || uart == BSP_UART_COM2);
     328  SANITY_CHECK(uart);
    315329
    316330  val = uread(uart, LSR);
     
    354368 
    355369  /* Sanity check */
    356   assert(uart == BSP_UART_COM1 || uart == BSP_UART_COM2);
     370  SANITY_CHECK(uart);
    357371 
    358372  for(;;)
     
    395409  unsigned char val;
    396410
    397   assert(uart == BSP_UART_COM1 || uart == BSP_UART_COM2);
     411  SANITY_CHECK(uart);
    398412 
    399413  for(;;)
     
    416430}
    417431
     432static void
     433uart_noop(const rtems_irq_connect_data *unused)
     434{
     435  return;
     436}
     437
     438/* note that the IRQ names contain _ISA_ for legacy
     439 * reasons. They can be any interrupt, depending
     440 * on the particular BSP...
     441 */
     442
     443static int
     444uart_isr_is_on(const rtems_irq_connect_data *irq)
     445{
     446int uart = (irq->name == BSP_ISA_UART_COM1_IRQ) ?
     447                        BSP_UART_COM1 : BSP_UART_COM2;
     448  return uread(uart,IER);
     449}
     450
     451static int
     452doit(int uart, rtems_irq_hdl handler, int (*p)(const rtems_irq_connect_data*))
     453{
     454        rtems_irq_connect_data d={0};
     455        d.name = (uart == BSP_UART_COM1) ?
     456                        BSP_ISA_UART_COM1_IRQ : BSP_ISA_UART_COM2_IRQ;
     457        d.off  = d.on = uart_noop;
     458        d.isOn = uart_isr_is_on;
     459        d.hdl  = handler;
     460        return p(&d);
     461}
     462
     463int
     464BSP_uart_install_isr(int uart, rtems_irq_hdl handler)
     465{
     466        return doit(uart, handler, BSP_install_rtems_irq_handler);
     467}
     468       
     469int
     470BSP_uart_remove_isr(int uart, rtems_irq_hdl handler)
     471{
     472        return doit(uart, handler, BSP_remove_rtems_irq_handler);
     473}
     474
    418475
    419476/* ================ Termios support  =================*/
    420477
    421 static volatile int  termios_stopped_com1        = 0;
    422 static volatile int  termios_tx_active_com1      = 0;
    423 static void*         termios_ttyp_com1           = NULL;
    424 static char          termios_tx_hold_com1        = 0;
    425 static volatile char termios_tx_hold_valid_com1  = 0;
    426 
    427 static volatile int  termios_stopped_com2        = 0;
    428 static volatile int  termios_tx_active_com2      = 0;
    429 static void*         termios_ttyp_com2           = NULL;
    430 static char          termios_tx_hold_com2        = 0;
    431 static volatile char termios_tx_hold_valid_com2  = 0;
     478static volatile int  termios_stopped_com[2]        = {0,0};
     479static volatile int  termios_tx_active_com[2]      = {0,0};
     480static void*         termios_ttyp_com[2]           = {NULL,NULL};
     481static char          termios_tx_hold_com[2]        = {0,0};
     482static volatile char termios_tx_hold_valid_com[2]  = {0,0};
    432483
    433484/*
     
    438489{
    439490  unsigned char val;
    440   assert(uart == BSP_UART_COM1 || uart == BSP_UART_COM2);
    441  
    442   if(uart == BSP_UART_COM1)
    443     {
    444       if(uart_data[uart].hwFlow)
    445         {
    446           val = uread(uart, MSR);
    447 
    448           termios_stopped_com1   = (val & CTS) ? 0 : 1;
    449         }
    450       else
    451         {
    452           termios_stopped_com1 = 0;
    453         }
    454       termios_tx_active_com1      = 0;
    455       termios_ttyp_com1           = ttyp;
    456       termios_tx_hold_com1        = 0;
    457       termios_tx_hold_valid_com1  = 0;
     491  SANITY_CHECK(uart);
     492 
     493  if(uart_data[uart].hwFlow)
     494    {
     495      val = uread(uart, MSR);
     496
     497      termios_stopped_com[uart]    = (val & CTS) ? 0 : 1;
    458498    }
    459499  else
    460     {
    461       if(uart_data[uart].hwFlow)
    462         {
    463           val = uread(uart, MSR);
    464 
    465           termios_stopped_com2   = (val & CTS) ? 0 : 1;
    466         }
    467       else
    468         {
    469           termios_stopped_com2 = 0;
    470         }
    471       termios_tx_active_com2      = 0;
    472       termios_ttyp_com2           = ttyp;
    473       termios_tx_hold_com2        = 0;
    474       termios_tx_hold_valid_com2  = 0;
    475     }
     500  {
     501      termios_stopped_com[uart] = 0;
     502  }
     503  termios_tx_active_com[uart]      = 0;
     504  termios_ttyp_com[uart]           = ttyp;
     505  termios_tx_hold_com[uart]        = 0;
     506  termios_tx_hold_valid_com[uart]  = 0;
    476507
    477508  return;
     
    479510
    480511int
    481 BSP_uart_termios_write_com1(int minor, const char *buf, int len)
    482 {
     512BSP_uart_termios_write_com(int minor, const char *buf, int len)
     513{
     514  int uart=minor;       /* could differ, theoretically */
    483515  assert(buf != NULL);
    484516
     
    492524       
    493525
    494   if(termios_stopped_com1)
     526  if(termios_stopped_com[uart])
    495527    {
    496528      /* CTS low */
    497       termios_tx_hold_com1       = *buf;
    498       termios_tx_hold_valid_com1 = 1;
     529      termios_tx_hold_com[uart]       = *buf;
     530      termios_tx_hold_valid_com[uart] = 1;
    499531      return 0;
    500532    }
    501533
    502534  /* Write character */
    503   uwrite(BSP_UART_COM1, THR, *buf & 0xff);
     535  uwrite(uart, THR, *buf & 0xff);
    504536
    505537  /* Enable interrupts if necessary */
    506   if(!termios_tx_active_com1 && uart_data[BSP_UART_COM1].hwFlow)
    507     {
    508       termios_tx_active_com1 = 1;
    509       uwrite(BSP_UART_COM1, IER,
     538  if(!termios_tx_active_com[uart] && uart_data[uart].hwFlow)
     539    {
     540      termios_tx_active_com[uart] = 1;
     541      uwrite(uart, IER,
    510542             (RECEIVE_ENABLE  |
    511543              TRANSMIT_ENABLE |
     
    515547            );
    516548    }
    517   else if(!termios_tx_active_com1)
    518     {
    519       termios_tx_active_com1 = 1;
    520       uwrite(BSP_UART_COM1, IER,
     549  else if(!termios_tx_active_com[uart])
     550    {
     551      termios_tx_active_com[uart] = 1;
     552      uwrite(uart, IER,
    521553             (RECEIVE_ENABLE  |
    522554              TRANSMIT_ENABLE |
     
    529561}
    530562
    531 int
    532 BSP_uart_termios_write_com2(int minor, const char *buf, int len)
    533 {
    534   assert(buf != NULL);
    535 
    536   if(len <= 0)
    537     {
    538       return 0;
    539     }
    540 
    541 
    542   /* If there TX buffer is busy - something is royally screwed up */
    543   assert((uread(BSP_UART_COM2, LSR) & THRE) != 0);
    544 
    545   if(termios_stopped_com2)
    546     {
    547       /* CTS low */
    548       termios_tx_hold_com2       = *buf;
    549       termios_tx_hold_valid_com2 = 1;
    550       return 0;
    551     }
    552 
    553   /* Write character */
    554 
    555   uwrite(BSP_UART_COM2, THR, *buf & 0xff);
    556 
    557   /* Enable interrupts if necessary */
    558   if(!termios_tx_active_com2 && uart_data[BSP_UART_COM2].hwFlow)
    559     {
    560       termios_tx_active_com2 = 1;
    561       uwrite(BSP_UART_COM2, IER,
    562              (RECEIVE_ENABLE  |
    563               TRANSMIT_ENABLE |
    564               RECEIVER_LINE_ST_ENABLE |
    565               MODEM_ENABLE
    566              )
    567             );
    568     }
    569   else if(!termios_tx_active_com2)
    570     {
    571       termios_tx_active_com2 = 1;
    572       uwrite(BSP_UART_COM2, IER,
    573              (RECEIVE_ENABLE  |
    574               TRANSMIT_ENABLE |
    575               RECEIVER_LINE_ST_ENABLE
    576              )
    577             );
    578     }
    579 
    580   return 0;
    581 }
    582 
    583 
    584 void
    585 BSP_uart_termios_isr_com1(void)
     563static void
     564BSP_uart_termios_isr_com(int uart)
    586565{
    587566  unsigned char buf[40];
     
    593572  for(;;)
    594573    {
    595       vect = uread(BSP_UART_COM1, IIR) & 0xf;
     574      vect = uread(uart, IIR) & 0xf;
    596575     
    597576      switch(vect)
    598577        {
    599578        case MODEM_STATUS :
    600           val = uread(BSP_UART_COM1, MSR);
    601           if(uart_data[BSP_UART_COM1].hwFlow)
     579          val = uread(uart, MSR);
     580          if(uart_data[uart].hwFlow)
    602581            {
    603582              if(val & CTS)
    604583                {
    605584                  /* CTS high */
    606                   termios_stopped_com1 = 0;
    607                   if(termios_tx_hold_valid_com1)
     585                  termios_stopped_com[uart] = 0;
     586                  if(termios_tx_hold_valid_com[uart])
    608587                    {
    609                       termios_tx_hold_valid_com1 = 0;
    610                       BSP_uart_termios_write_com1(0, &termios_tx_hold_com1,
     588                      termios_tx_hold_valid_com[uart] = 0;
     589                      BSP_uart_termios_write_com(uart, &termios_tx_hold_com[uart],
    611590                                                    1);
    612591                    }
     
    615594                {
    616595                  /* CTS low */
    617                   termios_stopped_com1 = 1;
     596                  termios_stopped_com[uart] = 1;
    618597                }
    619598            }
     
    624603            {
    625604              /* Update rx buffer */
    626               rtems_termios_enqueue_raw_characters(termios_ttyp_com1,
     605              rtems_termios_enqueue_raw_characters(termios_ttyp_com[uart],
    627606                                                   (char *)buf,
    628607                                                   off);
     
    635614           */
    636615
    637           ret = rtems_termios_dequeue_characters(termios_ttyp_com1, 1);
     616          ret = rtems_termios_dequeue_characters(termios_ttyp_com[uart], 1);
    638617
    639618          /* If nothing else to send disable interrupts */
    640           if(ret == 0 && uart_data[BSP_UART_COM1].hwFlow)
     619          if(ret == 0 && uart_data[uart].hwFlow)
    641620            {
    642               uwrite(BSP_UART_COM1, IER,
     621              uwrite(uart, IER,
    643622                     (RECEIVE_ENABLE  |
    644623                      RECEIVER_LINE_ST_ENABLE |
     
    646625                     )
    647626                    );
    648               termios_tx_active_com1 = 0;
     627              termios_tx_active_com[uart] = 0;
    649628            }
    650629          else if(ret == 0)
    651630            {
    652               uwrite(BSP_UART_COM1, IER,
     631              uwrite(uart, IER,
    653632                     (RECEIVE_ENABLE  |
    654633                      RECEIVER_LINE_ST_ENABLE
    655634                     )
    656635                    );
    657               termios_tx_active_com1 = 0;
     636              termios_tx_active_com[uart] = 0;
    658637            }
    659638          break;
     
    662641          /* RX data ready */
    663642          assert(off < sizeof(buf));
    664           buf[off++] = uread(BSP_UART_COM1, RBR);
     643          buf[off++] = uread(uart, RBR);
    665644          break;
    666645        case RECEIVER_ERROR:
    667646          /* RX error: eat character */
    668            uartError(BSP_UART_COM1);
     647           uartError(uart);
    669648          break;
    670649        default:
     
    677656         
    678657void
    679 BSP_uart_termios_isr_com2()
    680 {
    681   unsigned char buf[40];
    682   unsigned char val;
    683   int      off, ret, vect;
    684 
    685   off = 0;
    686 
    687   for(;;)
    688     {
    689       vect = uread(BSP_UART_COM2, IIR) & 0xf;
    690      
    691       switch(vect)
    692         {
    693         case MODEM_STATUS :
    694           val = uread(BSP_UART_COM2, MSR);
    695           if(uart_data[BSP_UART_COM2].hwFlow)
    696             {
    697               if(val & CTS)
    698                 {
    699                   /* CTS high */
    700                   termios_stopped_com2 = 0;
    701                   if(termios_tx_hold_valid_com2)
    702                     {
    703                       termios_tx_hold_valid_com2 = 0;
    704                       BSP_uart_termios_write_com2(0, &termios_tx_hold_com2,
    705                                                     1);
    706                     }
    707                 }
    708               else
    709                 {
    710                   /* CTS low */
    711                   termios_stopped_com2 = 1;
    712                 }
    713             }
    714           break;
    715         case NO_MORE_INTR :
    716           /* No more interrupts */
    717           if(off != 0)
    718             {
    719               /* Update rx buffer */
    720               rtems_termios_enqueue_raw_characters(termios_ttyp_com2,
    721                                                    (char *)buf,
    722                                                    off);
    723             }
    724           return;
    725         case TRANSMITTER_HODING_REGISTER_EMPTY :
    726           /*
    727            * TX holding empty: we have to disable these interrupts
    728            * if there is nothing more to send.
    729            */
    730 
    731           ret = rtems_termios_dequeue_characters(termios_ttyp_com2, 1);
    732 
    733           /* If nothing else to send disable interrupts */
    734           if(ret == 0 && uart_data[BSP_UART_COM2].hwFlow)
    735             {
    736               uwrite(BSP_UART_COM2, IER,
    737                      (RECEIVE_ENABLE  |
    738                       RECEIVER_LINE_ST_ENABLE |
    739                       MODEM_ENABLE
    740                      )
    741                     );
    742               termios_tx_active_com2 = 0;
    743             }
    744           else if(ret == 0)
    745             {
    746               uwrite(BSP_UART_COM2, IER,
    747                      (RECEIVE_ENABLE  |
    748                       RECEIVER_LINE_ST_ENABLE
    749                      )
    750                     );
    751               termios_tx_active_com2 = 0;
    752             }
    753           break;
    754         case RECEIVER_DATA_AVAIL :
    755         case CHARACTER_TIMEOUT_INDICATION:
    756           /* RX data ready */
    757           assert(off < sizeof(buf));
    758           buf[off++] = uread(BSP_UART_COM2, RBR);
    759           break;
    760         case RECEIVER_ERROR:
    761           /* RX error: eat character */
    762            uartError(BSP_UART_COM2);
    763           break;
    764         default:
    765           /* Should not happen */
    766           assert(0);
    767           return;
    768         }
    769     }
    770 }
    771          
    772  
    773 
    774 
    775 
    776 
    777 
    778 
     658BSP_uart_termios_isr_com1(void)
     659{
     660        BSP_uart_termios_isr_com(BSP_UART_COM1);
     661}
     662
     663void
     664BSP_uart_termios_isr_com2(void)
     665{
     666        BSP_uart_termios_isr_com(BSP_UART_COM2);
     667}
     668
  • c/src/lib/libbsp/powerpc/shared/console/uart.h

    r3ce2907 r69ed59f  
    1111#define _BSPUART_H
    1212
     13#include <bsp/irq.h>
     14
    1315void BSP_uart_init(int uart, int baud, int hwFlow);
    1416void BSP_uart_set_baud(int aurt, int baud);
     
    2022int  BSP_uart_polled_read(int uart);
    2123void BSP_uart_termios_set(int uart, void *ttyp);
    22 int  BSP_uart_termios_write_com1(int minor, const char *buf, int len);
    23 int  BSP_uart_termios_write_com2(int minor, const char *buf, int len);
     24int  BSP_uart_termios_write_com(int minor, const char *buf, int len);
    2425void BSP_uart_termios_isr_com1();
    2526void BSP_uart_termios_isr_com2();
    2627void BSP_uart_dbgisr_com1(void);
    2728void BSP_uart_dbgisr_com2(void);
     29int  BSP_uart_install_isr(int uart, rtems_irq_hdl handler);
     30int  BSP_uart_remove_isr(int uart, rtems_irq_hdl handler);
     31
    2832extern unsigned BSP_poll_char_via_serial(void);
    2933extern void BSP_output_char_via_serial(int val);
     
    4953#define BSP_UART_COM1            (0)
    5054#define BSP_UART_COM2            (1)
    51 
    52 /*
    53  * Base IO for UART
    54  */
    55 
    56 #define COM1_BASE_IO    0x3F8
    57 #define COM2_BASE_IO    0x2F8
    5855
    5956/*
  • c/src/lib/libbsp/powerpc/shared/include/bsp.h

    r3ce2907 r69ed59f  
    2727 */
    2828
    29 /* #define CONFIGURE_NUMBER_OF_TERMIOS_PORTS 2 */
     29#define CONFIGURE_NUMBER_OF_TERMIOS_PORTS 2
    3030#define CONFIGURE_INTERRUPT_STACK_MEMORY  (16 * 1024)
     31
     32/* fundamental addresses for this BSP (PREPxxx are from libcpu/io.h) */
     33#define _IO_BASE                        PREP_ISA_IO_BASE
     34#define _ISA_MEM_BASE           PREP_ISA_MEM_BASE
     35/* address of our ram on the PCI bus   */
     36#define PCI_DRAM_OFFSET         PREP_PCI_DRAM_OFFSET
     37/* offset of pci memory as seen from the CPU */
     38#define PCI_MEM_BASE            PREP_ISA_MEM_BASE
     39
     40/*
     41 *  base address definitions for several devices
     42 *
     43 */
     44#define BSP_UART_IOBASE_COM1 ((_IO_BASE)+0x3f8)
     45#define BSP_UART_IOBASE_COM2 ((_IO_BASE)+0x2f8)
     46#define BSP_KBD_IOBASE       ((_IO_BASE)+0x60)
     47#define BSP_VGA_IOBASE       ((_IO_BASE)+0x3c0)
     48
     49#define BSP_CONSOLE_PORT        BSP_UART_COM1
     50#define BSP_UART_BAUD_BASE      115200
    3151 
     52#include <bsp/openpic.h>
     53#define BSP_PIC_DO_EOI openpic_eoi(0)
     54
     55
    3256#ifndef ASM
    3357#define outport_byte(port,value) outb(value,port)
  • c/src/lib/libbsp/powerpc/shared/irq/Makefile.am

    r3ce2907 r69ed59f  
    2222all-local: $(PREINSTALL_FILES)
    2323
    24 EXTRA_DIST = i8259.c irq.c irq.h irq_asm.S irq_init.c
     24EXTRA_DIST = i8259.c irq.c irq_asm.S irq_init.c
    2525
    2626include $(top_srcdir)/../../../../../automake/local.am
  • c/src/lib/libbsp/powerpc/shared/irq/irq.c

    r3ce2907 r69ed59f  
    2121#include <bsp/vectors.h>
    2222
     23#include <rtems/bspIo.h> /* for printk */
    2324#define RAVEN_INTR_ACK_REG 0xfeff0030
    2425
     
    125126 
    126127    if (!isValidInterrupt(irq->name)) {
     128      printk("Invalid interrupt vector %i\n",irq->name);
    127129      return 0;
    128130    }
     
    135137     */
    136138    if (rtems_hdl_tbl[irq->name].hdl != default_rtems_entry.hdl) {
     139      printk("IRQ vector %i already connected\n",irq->name);
    137140      return 0;
    138141    }
     
    373376  }
    374377  else {
    375     openpic_eoi(0);
     378#ifdef BSP_PCI_VME_BRIDGE_DOES_EOI
     379        /* leave it to the VME bridge to do EOI, so
     380         * it can re-enable the openpic while handling
     381         * VME interrupts (-> VME priorities in software)
     382         */
     383        if (BSP_PCI_VME_BRIDGE_IRQ!=irq)
     384#endif
     385                openpic_eoi(0);
    376386  }
    377387}
  • c/src/lib/libbsp/powerpc/shared/irq/irq.h

    r3ce2907 r69ed59f  
    8888  BSP_PROCESSOR_IRQ_LOWEST_OFFSET =     BSP_PCI_IRQ_MAX_OFFSET + 1,
    8989  BSP_PROCESSOR_IRQ_MAX_OFFSET  =       BSP_PROCESSOR_IRQ_LOWEST_OFFSET + BSP_PROCESSOR_IRQ_NUMBER - 1,
     90  /* Misc vectors for OPENPIC irqs (IPI, timers)
     91   */
     92  BSP_MISC_IRQ_NUMBER           =       8,
     93  BSP_MISC_IRQ_LOWEST_OFFSET    =       BSP_PROCESSOR_IRQ_MAX_OFFSET + 1,
     94  BSP_MISC_IRQ_MAX_OFFSET       =       BSP_MISC_IRQ_LOWEST_OFFSET + BSP_MISC_IRQ_NUMBER - 1,
    9095  /*
    9196   * Summary
    9297   */
    93   BSP_IRQ_NUMBER                =       BSP_PROCESSOR_IRQ_MAX_OFFSET + 1,
     98  BSP_IRQ_NUMBER                =       BSP_MISC_IRQ_MAX_OFFSET + 1,
    9499  BSP_LOWEST_OFFSET             =       BSP_ISA_IRQ_LOWEST_OFFSET,
    95   BSP_MAX_OFFSET                =       BSP_PROCESSOR_IRQ_MAX_OFFSET,
     100  BSP_MAX_OFFSET                =       BSP_MISC_IRQ_MAX_OFFSET,
    96101    /*
    97102     * Some ISA IRQ symbolic name definition
  • c/src/lib/libbsp/powerpc/shared/irq/irq_init.c

    r3ce2907 r69ed59f  
    88 * Enhanced by Jay Kulpinski <jskulpin@eng01.gdds.com>
    99 * to make it valid for MVME2300 Motorola boards.
     10 *
     11 * Till Straumann <strauman@slac.stanford.edu>, 12/20/2001:
     12 * Use the new interface to openpic_init
    1013 *
    1114 *  The license and distribution terms for this file may be
     
    8891   */
    8992  0
     93};
     94
     95static unsigned char mcp750_openpic_initpolarities[16] = {
     96    1,  /* 8259 cascade */
     97    0,  /* all the rest of them */
    9098};
    9199
     
    227235   * First initialize the Interrupt management hardware
    228236   */
    229   OpenPIC_InitSenses = mcp750_openpic_initsenses;
    230   OpenPIC_NumInitSenses = sizeof(mcp750_openpic_initsenses) / sizeof(char);
    231237#ifdef TRACE_IRQ_INIT 
    232238  printk("Going to initialize raven interrupt controller (openpic compliant)\n");
    233239#endif       
    234   openpic_init(1);
     240  openpic_init(1, mcp750_openpic_initsenses, mcp750_openpic_initpolarities);
    235241#ifdef TRACE_IRQ_INIT 
    236242  printk("Going to initialize the PCI/ISA bridge IRQ related setting (VIA 82C586)\n");
  • c/src/lib/libbsp/powerpc/shared/openpic/openpic.c

    r3ce2907 r69ed59f  
    2727#include <libcpu/byteorder.h>
    2828#include <bsp.h>
    29 
     29#include <rtems/bspIo.h>
     30
     31#ifndef NULL
    3032#define NULL 0
     33#endif
    3134#define REGISTER_DEBUG
    3235#undef REGISTER_DEBUG
     
    3437
    3538volatile struct OpenPIC *OpenPIC = NULL;
    36 unsigned int OpenPIC_NumInitSenses  = 0;
    37 unsigned char *OpenPIC_InitSenses  = NULL;
    3839
    3940static unsigned int NumProcessors;
     
    158159     * report vendor and device id, and gets the wrong number of interrupts.
    159160     * (Motorola did a great job on that one!)
    160      */
    161 
    162 void openpic_init(int main_pic)
     161     *
     162     * T. Straumann, 12/20/2001: polarities and senses are now passed as
     163     *                           parameters, eliminated global vars.
     164     *                           IRQ0 is no longer treated specially.
     165     */
     166
     167void openpic_init(int main_pic, unsigned char *polarities, unsigned char *senses)
    163168{
    164169    unsigned int t, i;
     
    251256            /* Processor 0 */
    252257            openpic_mapirq(0, 1<<0);
    253             for (i = 1; i < NumSources; i++) {
     258            for (i = 0; i < NumSources; i++) {
    254259                    /* Enabled, Priority 8 */
    255                     openpic_initirq(i, 8, OPENPIC_VEC_SOURCE+i, 0,
    256                                     i < OpenPIC_NumInitSenses ? OpenPIC_InitSenses[i] : 1);
     260                    openpic_initirq(i, 8, OPENPIC_VEC_SOURCE+i,
     261                                        polarities ? polarities[i] : 0,
     262                                        senses     ? senses[i]     : 1);
    257263                    /* Processor 0 */
    258264                    openpic_mapirq(i, 1<<0);
  • c/src/lib/libbsp/powerpc/shared/openpic/openpic.h

    r3ce2907 r69ed59f  
    192192
    193193extern volatile struct OpenPIC *OpenPIC;
    194 extern unsigned int OpenPIC_NumInitSenses;
    195 extern unsigned char *OpenPIC_InitSenses;
    196194
    197195
     
    310308
    311309/* Global Operations */
    312 extern void openpic_init(int);
     310extern void openpic_init(int,unsigned char *, unsigned char *);
    313311extern void openpic_reset(void);
    314312extern void openpic_enable_8259_pass_through(void);
  • c/src/lib/libbsp/powerpc/shared/pci/Makefile.am

    r3ce2907 r69ed59f  
    44
    55
    6 C_FILES = pci.c
     6C_FILES = pci.c detect_raven_bridge.c pcifinddevice.c
    77
    88H_FILES = pci.h
     
    1919all-local: $(PREINSTALL_FILES)
    2020
    21 EXTRA_DIST = pci.c pci.h
     21EXTRA_DIST = pci.c pci.h detect_raven_bridge.c pcifinddevice.c
    2222
    2323include $(top_srcdir)/../../../../../automake/local.am
  • c/src/lib/libbsp/powerpc/shared/pci/pci.c

    r3ce2907 r69ed59f  
    1515 *
    1616 *  $Id$
     17 *
     18 *  Till Straumann, <strauman@slac.stanford.edu>, 1/2002
     19 *   - separated bridge detection code out of this file
    1720 */
    1821
    19 #include <bsp/consoleIo.h>
    2022#include <libcpu/io.h>
    2123#include <bsp/pci.h>
    22 #include <bsp/residual.h>
    23 #include <bsp/openpic.h>
    24 #include <bsp.h>
    25 
     24
     25/* allow for overriding these definitions */
     26#ifndef PCI_CONFIG_ADDR
    2627#define PCI_CONFIG_ADDR                 0xcf8
     28#endif
     29#ifndef PCI_CONFIG_DATA
    2730#define PCI_CONFIG_DATA                 0xcfc
     31#endif
     32
    2833#define PCI_INVALID_VENDORDEVICEID      0xffffffff
    2934#define PCI_MULTI_FUNCTION              0x80
    30 #define RAVEN_MPIC_IOSPACE_ENABLE       0x1
    31 #define RAVEN_MPIC_MEMSPACE_ENABLE      0x2
    32 #define RAVEN_MASTER_ENABLE             0x4
    33 #define RAVEN_PARITY_CHECK_ENABLE       0x40
    34 #define RAVEN_SYSTEM_ERROR_ENABLE       0x100
    35 #define RAVEN_CLEAR_EVENTS_MASK         0xf9000000
    36 
     35
     36/* define a shortcut */
     37#define pci     BSP_pci_configuration
    3738
    3839/*
     
    107108}
    108109
    109 static const pci_config_access_functions indirect_functions = {
     110const pci_config_access_functions pci_indirect_functions = {
    110111        indirect_pci_read_config_byte,
    111112        indirect_pci_read_config_word,
     
    116117};
    117118
    118 pci_config pci = {(volatile unsigned char*)PCI_CONFIG_ADDR,
     119pci_config BSP_pci_configuration = {(volatile unsigned char*)PCI_CONFIG_ADDR,
    119120                         (volatile unsigned char*)PCI_CONFIG_DATA,
    120                          &indirect_functions};
     121                         &pci_indirect_functions};
    121122
    122123static int
     
    206207}
    207208
    208 static const pci_config_access_functions direct_functions = {
     209const pci_config_access_functions pci_direct_functions = {
    209210        direct_pci_read_config_byte,
    210211        direct_pci_read_config_word,
     
    216217
    217218
    218 void detect_host_bridge()
    219 {
    220   PPC_DEVICE *hostbridge;
    221   unsigned int id0;
    222   unsigned int tmp;
    223  
    224   /*
    225    * This code assumes that the host bridge is located at
    226    * bus 0, dev 0, func 0 AND that the old pre PCI 2.1
    227    * standart devices detection mecahnism that was used on PC
    228    * (still used in BSD source code) works.
    229    */
    230   hostbridge=residual_find_device(&residualCopy, PROCESSORDEVICE, NULL,
    231                                   BridgeController,
    232                                   PCIBridge, -1, 0);
    233   if (hostbridge) {
    234     if (hostbridge->DeviceId.Interface==PCIBridgeIndirect) {
    235       pci.pci_functions=&indirect_functions;
    236       /* Should be extracted from residual data,
    237        * indeed MPC106 in CHRP mode is different,
    238        * but we should not use residual data in
    239        * this case anyway.
    240        */
    241       pci.pci_config_addr = ((volatile unsigned char *)
    242                               (ptr_mem_map->io_base+0xcf8));
    243       pci.pci_config_data = ptr_mem_map->io_base+0xcfc;
    244     } else if(hostbridge->DeviceId.Interface==PCIBridgeDirect) {
    245       pci.pci_functions=&direct_functions;
    246       pci.pci_config_data=(unsigned char *) 0x80800000;
    247     } else {
    248     }
    249   } else {
    250     /* Let us try by experimentation at our own risk! */
    251     pci.pci_functions = &direct_functions;
    252     /* On all direct bridges I know the host bridge itself
    253      * appears as device 0 function 0.
    254                  */
    255     pci_read_config_dword(0, 0, 0, PCI_VENDOR_ID, &id0);
    256     if (id0==~0U) {
    257       pci.pci_functions = &indirect_functions;
    258       pci.pci_config_addr = ((volatile unsigned char*)
    259                               (ptr_mem_map->io_base+0xcf8));
    260       pci.pci_config_data = ((volatile unsigned char*)ptr_mem_map->io_base+0xcfc);
    261     }
    262     /* Here we should check that the host bridge is actually
    263      * present, but if it not, we are in such a desperate
    264      * situation, that we probably can't even tell it.
    265      */
    266   }
    267   pci_read_config_dword(0, 0, 0, 0, &id0);
    268   if(id0 == PCI_VENDOR_ID_MOTOROLA +
    269      (PCI_DEVICE_ID_MOTOROLA_RAVEN<<16)) {
    270     /*
    271      * We have a Raven bridge. We will get information about its settings
    272      */
    273     pci_read_config_dword(0, 0, 0, PCI_COMMAND, &id0);
    274 #ifdef SHOW_RAVEN_SETTING   
    275     printk("RAVEN PCI command register = %x\n",id0);
    276 #endif   
    277     id0 |= RAVEN_CLEAR_EVENTS_MASK;
    278     pci_write_config_dword(0, 0, 0, PCI_COMMAND, id0);
    279     pci_read_config_dword(0, 0, 0, PCI_COMMAND, &id0);
    280 #ifdef SHOW_RAVEN_SETTING   
    281     printk("After error clearing RAVEN PCI command register = %x\n",id0);
    282 #endif   
    283    
    284     if (id0 & RAVEN_MPIC_IOSPACE_ENABLE) {
    285       pci_read_config_dword(0, 0, 0,PCI_BASE_ADDRESS_0, &tmp);
    286 #ifdef SHOW_RAVEN_SETTING   
    287       printk("Raven MPIC is accessed via IO Space Access at address : %x\n",(tmp & ~0x1));
    288 #endif   
    289     }
    290     if (id0 & RAVEN_MPIC_MEMSPACE_ENABLE) {
    291       pci_read_config_dword(0, 0, 0,PCI_BASE_ADDRESS_1, &tmp);
    292 #ifdef SHOW_RAVEN_SETTING   
    293       printk("Raven MPIC is accessed via memory Space Access at address : %x\n", tmp);
    294 #endif   
    295       OpenPIC=(volatile struct OpenPIC *) (tmp + PREP_ISA_MEM_BASE);
    296       printk("OpenPIC found at %p.\n",
    297              OpenPIC);
    298     }
    299   }
    300   if (OpenPIC == (volatile struct OpenPIC *)0) {
    301     BSP_panic("OpenPic Not found\n");
    302   }
    303 
    304 }
    305 
    306219/*
    307220 * This routine determines the maximum bus number in the system
     
    309222void InitializePCI()
    310223{
     224  extern void detect_host_bridge();
    311225  unsigned char ucSlotNumber, ucFnNumber, ucNumFuncs;
    312226  unsigned char ucHeader;
  • c/src/lib/libbsp/powerpc/shared/pci/pci.h

    r3ce2907 r69ed59f  
    10831083#define PCIBIOS_BUFFER_TOO_SMALL        0x89
    10841084
    1085 #define PCI_MAX_DEVICES                 16
     1085/* T. Straumann, 7/31/2001: increased to 32 - PMC slots are not
     1086 * scanned on mvme2306 otherwise
     1087 */
     1088#define PCI_MAX_DEVICES                 32
    10861089#define PCI_MAX_FUNCTIONS               8
    10871090
     
    11041107  volatile unsigned char*       pci_config_addr;
    11051108  volatile unsigned char*       pci_config_data;
    1106   pci_config_access_functions*  pci_functions;
     1109  const pci_config_access_functions*    pci_functions;
    11071110} pci_config;
    11081111
    1109 extern pci_config pci;
     1112extern pci_config BSP_pci_configuration;
    11101113
    11111114extern inline int
    11121115pci_read_config_byte(unsigned char bus, unsigned char slot, unsigned char function,
    11131116                         unsigned char where, unsigned char * val) {
    1114         return pci.pci_functions->read_config_byte(bus, slot, function, where, val);
     1117        return BSP_pci_configuration.pci_functions->read_config_byte(bus, slot, function, where, val);
    11151118}
    11161119
     
    11181121pci_read_config_word(unsigned char bus, unsigned char slot, unsigned char function,
    11191122                         unsigned char where, unsigned short * val) {
    1120         return pci.pci_functions->read_config_word(bus, slot, function, where, val);
     1123        return BSP_pci_configuration.pci_functions->read_config_word(bus, slot, function, where, val);
    11211124}
    11221125
     
    11241127pci_read_config_dword(unsigned char bus, unsigned char slot, unsigned char function,
    11251128                         unsigned char where, unsigned int * val) {
    1126         return pci.pci_functions->read_config_dword(bus, slot, function, where, val);
     1129        return BSP_pci_configuration.pci_functions->read_config_dword(bus, slot, function, where, val);
    11271130}
    11281131
     
    11301133pci_write_config_byte(unsigned char bus, unsigned char slot, unsigned char function,
    11311134                         unsigned char where, unsigned char val) {
    1132         return pci.pci_functions->write_config_byte(bus, slot, function, where, val);
     1135        return BSP_pci_configuration.pci_functions->write_config_byte(bus, slot, function, where, val);
    11331136}
    11341137
     
    11361139pci_write_config_word(unsigned char bus, unsigned char slot, unsigned char function,
    11371140                         unsigned char where, unsigned short val) {
    1138         return pci.pci_functions->write_config_word(bus, slot, function, where, val);
     1141        return BSP_pci_configuration.pci_functions->write_config_word(bus, slot, function, where, val);
    11391142}
    11401143
     
    11421145pci_write_config_dword(unsigned char bus, unsigned char slot, unsigned char function,
    11431146                         unsigned char where, unsigned int val) {
    1144         return pci.pci_functions->write_config_dword(bus, slot, function, where, val);
     1147        return BSP_pci_configuration.pci_functions->write_config_dword(bus, slot, function, where, val);
    11451148}
    11461149
     
    11511154extern void InitializePCI();
    11521155
     1156/* scan for a specific device */
     1157/* find a particular PCI device
     1158 * (currently, only bus0 is scanned for device/fun0)
     1159 *
     1160 * RETURNS: zero on success, bus/dev/fun in *pbus / *pdev / *pfun
     1161 */
     1162int
     1163BSP_pciFindDevice(unsigned short vendorid, unsigned short deviceid,
     1164                int instance, int *pbus, int *pdev, int *pfun);
     1165
    11531166#endif /* RTEMS_PCI_H */
  • c/src/lib/libbsp/powerpc/shared/residual/Makefile.am

    r3ce2907 r69ed59f  
    1919all-local: $(PREINSTALL_FILES)
    2020
    21 EXTRA_DIST = pnp.h residual.c residual.h
     21EXTRA_DIST = residual.c
    2222
    2323include $(top_srcdir)/../../../../../automake/local.am
  • c/src/lib/libbsp/powerpc/shared/start/start.S

    r3ce2907 r69ed59f  
    1931931:      addic.  r20, r20, -0x1000
    194194        tlbie   r20
    195         blt     1b
     195        bgt     1b
    196196        sync
    197197        blr
  • c/src/lib/libbsp/powerpc/shared/startup/bspstart.c

    r3ce2907 r69ed59f  
    201201   */
    202202  stack = ((unsigned char*) &__rtems_end) + INIT_STACK_SIZE - CPU_MINIMUM_STACK_FRAME_SIZE;
     203
     204 /* tag the bottom (T. Straumann 6/36/2001 <strauman@slac.stanford.edu>) */
     205  *((unsigned32 *)stack) = 0;
     206
    203207  /*
    204208   * Initialize the interrupt related settings
     
    210214   */
    211215  intrStack = ((unsigned char*) &__rtems_end) + INIT_STACK_SIZE + INTR_STACK_SIZE - CPU_MINIMUM_STACK_FRAME_SIZE;
     216
     217 /* tag the bottom (T. Straumann 6/36/2001 <strauman@slac.stanford.edu>) */
     218  *((unsigned32 *)intrStack) = 0;
     219
    212220  asm volatile ("mtspr  273, %0" : "=r" (intrStack) : "0" (intrStack));
    213221  asm volatile ("mtspr  272, %0" : "=r" (intrNestingLevel) : "0" (intrNestingLevel));
     
    229237   * provided by the RAVEN
    230238   */
    231   setdbat(2, 0xc0000000, 0xc0000000, 0x08000000, IO_PAGE);
     239  /* T. Straumann: give more PCI address space */
     240  setdbat(2, 0xc0000000, 0xc0000000, 0x10000000, IO_PAGE);
    232241  /*
    233242   * Must have acces to open pic PCI ACK registers
  • c/src/lib/libbsp/powerpc/shared/vectors/vectors.S

    r3ce2907 r69ed59f  
    8686        mfxer   r28
    8787        stw     r28,  EXC_XER_OFFSET(r1)
     88        mfmsr   r28
     89        stw     r28,  EXC_MSR_OFFSET(r1)
     90        mfdar   r28
     91        stw     r28,  EXC_DAR_OFFSET(r1)
    8892        /*
    8993         * compute SP at exception entry
  • c/src/lib/libbsp/powerpc/shared/vectors/vectors.h

    r3ce2907 r69ed59f  
    6161#define EXC_XER_OFFSET 156
    6262#define EXC_LR_OFFSET 160
    63 #define EXC_DAR_OFFSET 164
     63#define EXC_MSR_OFFSET 164
     64#define EXC_DAR_OFFSET 168
    6465/*
    6566 * maintain the EABI requested 8 bytes aligment
  • c/src/lib/libbsp/powerpc/shared/vectors/vectors_init.c

    r3ce2907 r69ed59f  
    2323
    2424exception_handler_t globalExceptHdl;
     25
     26/* T. Straumann: provide a stack trace
     27 * <strauman@slac.stanford.edu>, 6/26/2001
     28 */
     29typedef struct LRFrameRec_ {
     30        struct LRFrameRec_ *frameLink;
     31        unsigned long *lr;
     32} LRFrameRec, *LRFrame;
     33
     34#define STACK_CLAMP 50  /* in case we have a corrupted bottom */
     35
     36void
     37BSP_printStackTrace(BSP_Exception_frame* excPtr)
     38{
     39LRFrame f;
     40int     i;
     41
     42        printk("Stack Trace: ");
     43        printk("  IP: 0x%08x, LR: 0x%08x\n",
     44                        excPtr->EXC_SRR0, excPtr->EXC_LR);
     45        for (f=(LRFrame)excPtr->GPR1, i=0; f->frameLink && i<STACK_CLAMP; f=f->frameLink) {
     46                printk("--^ 0x%08x", (long)(f->frameLink->lr));
     47                if (!(++i%5))
     48                        printk("\n");
     49        }
     50        if (i>=STACK_CLAMP) {
     51                printk("Too many stack frames (stack possibly corrupted), giving up...\n");
     52        } else {
     53                if (i%5)
     54                        printk("\n");
     55        }
     56}
    2557
    2658void C_exception_handler(BSP_Exception_frame* excPtr)
     
    6799  printk("\t XER = %x\n", excPtr->EXC_XER);
    68100  printk("\t LR = %x\n", excPtr->EXC_LR);
    69   printk("\t MSR = %x\n", excPtr->EXC_MSR);
     101  printk("\t DAR = %x\n", excPtr->EXC_DAR);
     102
     103  BSP_printStackTrace(excPtr);
     104
    70105  if (excPtr->_EXC_number == ASM_DEC_VECTOR)
    71106       recoverable = 1;
Note: See TracChangeset for help on using the changeset viewer.