RTEMS 6.3
Loading...
Searching...
No Matches
bsp.h
Go to the documentation of this file.
1
8
9/*
10 *
11 * The license and distribution terms for this file may be
12 * found in the file LICENSE in this distribution or at
13 * http://www.rtems.org/license/LICENSE.
14 */
15#ifndef LIBBSP_POWERPC_MOTOROLA_POWERPC_BSP_H
16#define LIBBSP_POWERPC_MOTOROLA_POWERPC_BSP_H
17
27
28#include <bspopts.h>
30
31#include <rtems.h>
32#include <libcpu/io.h>
33#include <bsp/vectors.h>
34
35#ifdef qemu
36#include <rtems/bspcmdline.h>
37#endif
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
43/*
44 * diagram illustrating the role of the configuration
45 * constants
46 * PCI_MEM_WIN0: CPU starting addr where PCI memory space is visible
47 * PCI_MEM_BASE: CPU address of PCI mem addr. zero. (regardless of this
48 * address being 'visible' or not!).
49 * _VME_A32_WIN0_ON_PCI: PCI starting addr of the 1st window to VME
50 * _VME_A32_WIN0_ON_VME: VME address of that same window
51 *
52 * AFAIK, only PreP boards have a non-zero PCI_MEM_BASE (i.e., an offset between
53 * CPU and PCI addresses). The mvme2307/mvme2700 'ppcbug' firmware configures the
54 * PCI bus using PCI base addresses! I.e., drivers need to add PCI_MEM_BASE to
55 * the base address read from PCI config.space in order to translate that
56 * into a CPU address.
57 *
58 * NOTE: VME addresses should NEVER be translated using these constants!
59 * they are strictly for BSP internal use. Drivers etc. should use
60 * the translation routines int VME.h (BSP_vme2local_adrs/BSP_local2vme_adrs).
61 *
62 * CPU ADDR PCI_ADDR VME ADDR
63 *
64 * 00000000 XXXXXXXX XXXXXXXX
65 * ^ ^ ........
66 * | |
67 * | | e.g., RAM XXXXXXXX
68 * | | 00000000
69 * | | ......... ^
70 * | | (possible offset |
71 * | | between pci and XXXXXXXX | ......
72 * | | cpu addresses) |
73 * | v |
74 * | PCI_MEM_BASE -------------> 00000000 --------------- |
75 * | ........ ........ ^ |
76 * | invisible | |
77 * | ........ from CPU | |
78 * v | |
79 * PCI_MEM_WIN0 ============= first visible PCI addr | |
80 * | |
81 * pci devices pci window | |
82 * visible here v v
83 * mapped by ========== _VME_A32_WIN0_ON_PCI ======= _VME_A32_WIN0_ON_VME
84 * vme window
85 * VME devices hostbridge mapped by
86 * visible here universe
87 * =====================================================
88 *
89 */
90
91/* fundamental addresses for BSP (CHRPxxx and PREPxxx are from libcpu/io.h) */
92#if defined(mot_ppc_mvme2100)
93#define _IO_BASE CHRP_ISA_IO_BASE
94#define _ISA_MEM_BASE CHRP_ISA_MEM_BASE
95/* address of our ram on the PCI bus */
96#define PCI_DRAM_OFFSET CHRP_PCI_DRAM_OFFSET
97/* offset of pci memory as seen from the CPU */
98#define PCI_MEM_BASE 0
99/* where (in CPU addr. space) does the PCI window start */
100#define PCI_MEM_WIN0 0x80000000
101
102#else
103#define _IO_BASE PREP_ISA_IO_BASE
104#define _ISA_MEM_BASE PREP_ISA_MEM_BASE
105#ifndef qemu
106/* address of our ram on the PCI bus */
107#define PCI_DRAM_OFFSET PREP_PCI_DRAM_OFFSET
108/* offset of pci memory as seen from the CPU */
109#define PCI_MEM_BASE PREP_ISA_MEM_BASE
110
111#if defined(mot_ppc_mvme5100)
112#define _REG_STRIDE 4
113#define PCI_MEM_WIN0 0x80000000
114#define BSP_VME_APERTURE_SIZE 0x20000000
115#else
116#define PCI_MEM_WIN0 0
117#endif
118#else
119#define PCI_DRAM_OFFSET 0
120#define PCI_MEM_BASE 0
121#define PCI_MEM_WIN0 PREP_ISA_MEM_BASE
122#endif
123#endif
124
125#if defined(_REG_STRIDE)
126#define BSP_REG_OFF(val) ((val) << _REG_STRIDE)
127#else
128#define BSP_REG_OFF(val) (val)
129#endif
130
131#ifdef mot_ppc_mvme5100
132#define BSP_PGTBL_EXTRA_SIZE BSP_VME_APERTURE_SIZE
133#endif
134
135/*
136 * The BSP has PCI devices. Enable support in LibBSD.
137 */
138#define BSP_HAS_PC_PCI
139
140/*
141 * Remap the PCI address space for LibBSD
142 */
143#define RTEMS_BSP_PCI_IO_REGION_BASE 0
144#define RTEMS_BSP_PCI_MEM_REGION_BASE PCI_DRAM_OFFSET
145#if defined(mot_ppc_mvme5100)
146#define BSP_LOCAL2PCI_ADDR(a) ((uint32_t)(a))
147#define RTEMS_BSP_PCI_DMA_REGION_BASE 0
148#else
149#define RTEMS_BSP_PCI_DMA_REGION_BASE PCI_DRAM_OFFSET
150#endif
151
152/*
153 * Remap the PCI address space for LibBSD
154 */
155#define RTEMS_BSP_ADDR_PTR(_type) uint ## _type ## _t __volatile*
156#define RTEMS_BSP_ADDR_CPTR(_type) const RTEMS_BSP_ADDR_PTR(_type)
157#define RTEMS_BSP_ADDRESS_READ(_addr, _type) \
158 *((RTEMS_BSP_ADDR_CPTR(_type)) (((RTEMS_BSP_ADDR_CPTR(8)) _addr) + PCI_DRAM_OFFSET))
159#define RTEMS_BSP_ADDRESS_WRITE(_addr, _val, _type) \
160 *((RTEMS_BSP_ADDR_PTR(_type)) (((RTEMS_BSP_ADDR_PTR(8)) _addr) + PCI_DRAM_OFFSET)) = (_val)
161
162#define RTEMS_BSP_READ_1(_addr) RTEMS_BSP_ADDRESS_READ(_addr, 8)
163#define RTEMS_BSP_READ_2(_addr) RTEMS_BSP_ADDRESS_READ(_addr, 16)
164#define RTEMS_BSP_READ_4(_addr) RTEMS_BSP_ADDRESS_READ(_addr, 32)
165#define RTEMS_BSP_READ_8(_addr) RTEMS_BSP_ADDRESS_READ(_addr, 64)
166
167#define RTEMS_BSP_WRITE_1(_addr, _val) RTEMS_BSP_ADDRESS_WRITE(_addr, _val, 8)
168#define RTEMS_BSP_WRITE_2(_addr, _val) RTEMS_BSP_ADDRESS_WRITE(_addr, _val, 16)
169#define RTEMS_BSP_WRITE_4(_addr, _val) RTEMS_BSP_ADDRESS_WRITE(_addr, _val, 32)
170#define RTEMS_BSP_WRITE_8(_addr, _val) RTEMS_BSP_ADDRESS_WRITE(_addr, _val, 64)
171
172/*
173 * Base address definitions for several devices
174 *
175 * MVME2100 is very similar but has fewer devices and uses on-CPU EPIC
176 * implementation of OpenPIC controller. It also cannot be probed to
177 * find out what it is which is VERY different from other Motorola boards.
178 */
179
180#if defined(mot_ppc_mvme2100)
181#define BSP_UART_IOBASE_COM1 ((_IO_BASE)+0x01e10000)
182/* #define BSP_UART_IOBASE_COM1 (0xffe10000) */
183#define BSP_OPEN_PIC_BASE_OFFSET 0x40000
184
185#define MVME_HAS_DEC21140
186#elif defined(mot_ppc_mvme5100)
187#define BSP_UART_IOBASE_COM1 (0xfef88000)
188#define BSP_UART_IOBASE_COM2 (0xfef88200)
189#else
190#define BSP_UART_IOBASE_COM1 ((_IO_BASE)+0x3f8)
191#define BSP_UART_IOBASE_COM2 ((_IO_BASE)+0x2f8)
192
193#if ! defined(qemu)
194#define BSP_KBD_IOBASE ((_IO_BASE)+0x60)
195#define BSP_VGA_IOBASE ((_IO_BASE)+0x3c0)
196#endif
197
198#if defined(mvme2300) || defined(mot_ppc_mvme2307) || defined(mot_ppc_mvme2700)
199#define MVME_HAS_DEC21140
200#endif
201#endif
202
203#define BSP_CONSOLE_PORT BSP_UART_COM1
204#define BSP_UART_BAUD_BASE 115200
205
206struct rtems_bsdnet_ifconfig;
207
208#if defined(MVME_HAS_DEC21140)
209#define RTEMS_BSP_NETWORK_DRIVER_NAME "dc1"
210#define RTEMS_BSP_NETWORK_DRIVER_ATTACH rtems_dec21140_driver_attach
211extern int rtems_dec21140_driver_attach(struct rtems_bsdnet_ifconfig *, int);
212#endif
213
214#ifdef qemu
215#define RTEMS_BSP_NETWORK_DRIVER_NAME "ne1"
216#define RTEMS_BSP_NETWORK_DRIVER_ATTACH rtems_ne_driver_attach
217extern int rtems_ne_driver_attach(struct rtems_bsdnet_ifconfig *, int);
218
219static inline const char* bsp_cmdline_arg(const char* arg)
220{
222}
223#endif
224
225#ifdef qemu
226#define BSP_IDLE_TASK_BODY bsp_ppc_idle_task_body
227extern void *bsp_ppc_idle_task_body(uintptr_t arg);
228#endif
229
230#include <bsp/openpic.h>
231/* BSP_PIC_DO_EOI is optionally used by the 'vmeUniverse' driver
232 * to implement VME IRQ priorities in software.
233 * Note that this requires support by the interrupt controller
234 * driver (cf. libbsp/shared/powerpc/irq/openpic_i8259_irq.c)
235 * and the BSP-specific universe initialization/configuration
236 * (cf. libbsp/shared/powerpc/vme/VMEConfig.h vme_universe.c)
237 *
238 * ********* IMPORTANT NOTE ********
239 * When deriving from this file (new BSPs)
240 * DO NOT define "BSP_PIC_DO_EOI" if you don't know what
241 * you are doing i.e., w/o implementing the required pieces
242 * mentioned above.
243 * ********* IMPORTANT NOTE ********
244 */
245#define BSP_PIC_DO_EOI openpic_eoi(0)
246
247#ifndef ASM
248#define outport_byte(port,value) outb(value,port)
249#define outport_word(port,value) outw(value,port)
250#define outport_long(port,value) outl(value,port)
251
252#define inport_byte(port,value) (value = inb(port))
253#define inport_word(port,value) (value = inw(port))
254#define inport_long(port,value) (value = inl(port))
255
256/*
257 * Vital Board data Start using DATA RESIDUAL
258 */
259
260/*
261 * Total memory using RESIDUAL DATA
262 */
263extern unsigned int BSP_mem_size;
264/*
265 * Start of the heap
266 */
267extern unsigned int BSP_heap_start;
268/*
269 * PCI Bus Frequency
270 */
271extern unsigned int BSP_bus_frequency;
272/*
273 * processor clock frequency
274 */
275extern unsigned int BSP_processor_frequency;
276/*
277 * Time base divisior (how many tick for 1 second).
278 */
279extern unsigned int BSP_time_base_divisor;
280
281/*
282 * String passed by the bootloader.
283 */
284extern char *BSP_commandline_string;
285
286#define BSP_Convert_decrementer( _value ) \
287 ((unsigned long long) ((((unsigned long long)BSP_time_base_divisor) * 1000000ULL) /((unsigned long long) BSP_bus_frequency)) * ((unsigned long long) (_value)))
288
289/* extern int printk(const char *, ...) __attribute__((format(printf, 1, 2))); */
290extern int BSP_disconnect_clock_handler (void);
291extern int BSP_connect_clock_handler (void);
292
293/* clear hostbridge errors
294 *
295 * NOTE: The routine returns always (-1) if 'enableMCP==1'
296 * [semantics needed by libbspExt] if the MCP input is not wired.
297 * It returns and clears the error bits of the PCI status register.
298 * MCP support is disabled because:
299 * a) the 2100 has no raven chip
300 * b) the raven (2300, 2307, 2700) would raise machine check interrupts
301 * on PCI config space access to empty slots.
302 */
303extern unsigned long _BSP_clear_hostbridge_errors(int enableMCP, int quiet);
304
305/*
306 * Prototypes for methods called only from .S for dependency tracking
307 */
308char *save_boot_params(
309 void *r3,
310 void *r4,
311 void *r5,
312 char *cmdline_start,
313 char *cmdline_end
314);
315void zero_bss(void);
316
317/*
318 * Prototypes for BSP methods which cross file boundaries
319 */
320void VIA_isa_bridge_interrupts_setup(void);
321
322#endif
323
324#ifdef __cplusplus
325};
326#endif
327
329
330#endif
BSP Command Line Handler.
PowerPC Exceptions API.
This header file provides the default definition of BSP_INITIAL_EXTENSION.
const char * rtems_bsp_cmdline_get_param_raw(const char *name)
Obtain Pointer to the Entire Matching Argument.
Definition bspcmdline_getparamraw.c:47
This header file defines the RTEMS Classic API.