source: rtems/c/src/lib/libbsp/i386/pc386/startup/bspstart.c @ f770fcb

Last change on this file since f770fcb was f770fcb, checked in by Joel Sherrill <joel@…>, on Mar 3, 2016 at 4:36:24 PM

Add shared PCI support and enhance pc386 to support non-legacy PCI configuration space

This patch fundamentally results from enhancements to the pc386 BSP
to support systems which do NOT have the legacy PCI BIOS. The
patch adds support for detecting when legacy PCI BIOS is not
present and then using IO space to access to PCI Configuration Space.
This resulted in dynamically selected between two implementations
of PCI and refactoring out the shared methods.

This patch adds shared implementations of pci_bus_count() and
pci_find_device(). Subsequent patches will remove implementations
of these methods in other BSPs where possible.

  • Property mode set to 100644
File size: 3.4 KB
Line 
1/*-------------------------------------------------------------------------+
2| This file contains the PC386 BSP startup package. It includes application,
3| board, and monitor specific initialization and configuration. The generic CPU
4| dependent initialization has been performed before this routine is invoked.
5+--------------------------------------------------------------------------+
6| (C) Copyright 1997 -
7| - NavIST Group - Real-Time Distributed Systems and Industrial Automation
8|
9| http://pandora.ist.utl.pt
10|
11| Instituto Superior Tecnico * Lisboa * PORTUGAL
12+--------------------------------------------------------------------------+
13| Disclaimer:
14|
15| This file is provided "AS IS" without warranty of any kind, either
16| expressed or implied.
17+--------------------------------------------------------------------------+
18| This code is based on:
19|   bspstart.c,v 1.8 1996/05/28 13:12:40 joel Exp - go32 BSP
20| With the following copyright notice:
21| **************************************************************************
22| *  COPYRIGHT (c) 1989-2008.
23| *  On-Line Applications Research Corporation (OAR).
24| *
25| *  The license and distribution terms for this file may be
26| *  found in the file LICENSE in this distribution or at
27| *  http://www.rtems.org/license/LICENSE.
28| **************************************************************************
29+--------------------------------------------------------------------------*/
30
31#include <bsp.h>
32#include <bsp/irq.h>
33#include <rtems/pci.h>
34#include <libcpu/cpuModel.h>
35
36/*
37 * PCI Bus Configuration
38 */
39rtems_pci_config_t BSP_pci_configuration = {
40  (volatile unsigned char*)0,
41  (volatile unsigned char*)0,
42  NULL
43};
44
45/*
46 * Helper to initialize the PCI Bus
47 */
48static void bsp_pci_initialize_helper(void)
49{
50#if (BSP_IS_EDISON == 0)
51  const pci_config_access_functions *pci_accessors;
52
53  pci_accessors = pci_bios_initialize();
54  if (pci_accessors != NULL) {
55    printk("PCI bus: using PCI BIOS interface\n");
56    BSP_pci_configuration.pci_functions = pci_accessors;
57    return;
58  }
59
60  pci_accessors = pci_io_initialize();
61  if (pci_accessors != NULL) {
62    printk("PCI bus: using PCI I/O interface\n");
63    BSP_pci_configuration.pci_functions = pci_accessors;
64    return;
65  }
66
67  printk("PCI bus: could not initialize PCI BIOS interface\n");
68#endif
69}
70
71/*-------------------------------------------------------------------------+
72|         Function: bsp_start
73|      Description: Called before main is invoked.
74| Global Variables: None.
75|        Arguments: None.
76|          Returns: Nothing.
77+--------------------------------------------------------------------------*/
78static void bsp_start_default( void )
79{
80  /*
81   * Turn off watchdog
82   */
83#if (BSP_IS_EDISON == 1)
84  volatile uint32_t *edison_wd = (volatile uint32_t *)0xff009000;
85  *edison_wd = 0x11f8;
86#endif
87
88  /*
89   * Calibrate variable for 1ms-loop (see timer.c)
90   */
91#if (BSP_IS_EDISON == 0)
92  Calibrate_loop_1ms();
93#endif
94
95  /*
96   * Init rtems interrupt management
97   */
98  rtems_irq_mngt_init();
99
100  /*
101   * Init rtems exceptions management
102   */
103  rtems_exception_init_mngt();
104
105  /*
106   * init PCI Bios interface...
107   */
108  bsp_pci_initialize_helper();
109
110#if (BSP_IS_EDISON == 0)
111  Clock_driver_install_handler();
112#endif
113
114#if BSP_ENABLE_IDE
115  bsp_ide_cmdline_init();
116#endif
117
118} /* bsp_start_default */
119
120/*
121 *  By making this a weak alias for bsp_start_default, a brave soul
122 *  can override the actual bsp_start routine used.
123 */
124void bsp_start (void) __attribute__ ((weak, alias("bsp_start_default")));
Note: See TracBrowser for help on using the repository browser.