summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/powerpc/shared/vme/vme_universe.c
blob: c4f791ea8bcaa06b286ce9d07ce3e90b16f7a655 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*$Id$*/

#include <rtems.h>
#include <bsp.h>
#include <bsp/VME.h>
#include <bsp/VMEConfig.h>
#include <bsp/irq.h>
#include <bsp/vmeUniverse.h>

/* Wrap BSP VME calls around driver calls - we do this so EPICS doesn't have to
 * include bridge-specific headers. This file provides the necessary glue
 * to make VME.h and vmeconfig.c independent of the bridge chip.
 */

/* Author: Till Straumann <strauman@slac.stanford.edu>, 9/2005 */

int
BSP_vme2local_adrs(unsigned long am, unsigned long vmeaddr, unsigned long *plocaladdr)
{
int rval=vmeUniverseXlateAddr(1,0,am,vmeaddr,plocaladdr);
	*plocaladdr+=PCI_MEM_BASE;
	return rval;
}

int
BSP_local2vme_adrs(unsigned long am, unsigned long localaddr, unsigned long *pvmeaddr)
{
	return vmeUniverseXlateAddr(0, 0, am,localaddr+PCI_DRAM_OFFSET,pvmeaddr);
}


int
BSP_installVME_isr(unsigned long vector, BSP_VME_ISR_t handler, void *arg)
{
	return vmeUniverseInstallISR(vector, handler, arg);
}

int
BSP_removeVME_isr(unsigned long vector, BSP_VME_ISR_t handler, void *arg)
{
	return vmeUniverseRemoveISR(vector, handler, arg);
}

/* retrieve the currently installed ISR for a given vector */
BSP_VME_ISR_t
BSP_getVME_isr(unsigned long vector, void **parg)
{
	return vmeUniverseISRGet(vector, parg);
}

int
BSP_enableVME_int_lvl(unsigned int level)
{
	return vmeUniverseIntEnable(level);
}

int
BSP_disableVME_int_lvl(unsigned int level)
{
	return vmeUniverseIntDisable(level);
}

int
BSP_VMEOutboundPortCfg(
	unsigned long port,
	unsigned long address_space,
	unsigned long vme_address,
	unsigned long pci_address,
	unsigned long size)
{
	return vmeUniverseMasterPortCfg(port, address_space, vme_address, pci_address, size);
}

int
BSP_VMEInboundPortCfg(
	unsigned long port,
	unsigned long address_space,
	unsigned long vme_address,
	unsigned long pci_address,
	unsigned long size)
{
	return vmeUniverseSlavePortCfg(port, address_space, vme_address, pci_address, size);
}

void
BSP_VMEOutboundPortsShow(FILE *f)
{
	vmeUniverseMasterPortsShow(f);
}

void
BSP_VMEInboundPortsShow(FILE *f)
{
	vmeUniverseSlavePortsShow(f);
}


int BSP_VMEInit()
{
  if ( vmeUniverseInit() ) {
	/*  maybe no VME at all - or no universe ... */
	return -1;
  }
  vmeUniverseReset();
  return 0;
}

int BSP_VMEIrqMgrInstall()
{
#ifndef BSP_VME_UNIVERSE_INSTALL_IRQ_MGR
  /* No map; use first line only and obtain PIC wire from PCI config */
  vmeUniverseInstallIrqMgrAlt(
	1,		/* use shared IRQs */
	0, -1,	/* Universe pin0 -> PIC line from config space */
	-1      /* terminate list  */
  );

#else
  BSP_VME_UNIVERSE_INSTALL_IRQ_MGR;
#endif
  if (vmeUniverse0PciIrqLine<0)
	BSP_panic("Unable to get universe interrupt line info from PCI config");
  _BSP_vme_bridge_irq = vmeUniverse0PciIrqLine;
  return 0;
}