3 Copyright (C) 2004,2005 Neil Cafferkey
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston,
23 #include <exec/types.h>
24 #include <libraries/prometheus.h>
26 #include <proto/exec.h>
27 #include <proto/prometheus.h>
32 #include "pci_protos.h"
33 #include "prometheus_protos.h"
36 /****i* intelpro100.device/GetPrometheusCount ******************************
42 * count = GetPrometheusCount()
44 * ULONG GetPrometheusCount();
46 ****************************************************************************
50 ULONG
GetPrometheusCount(struct DevBase
*base
)
53 PCIBoard
*card
= NULL
;
54 UPINT vendor_id
, product_id
;
56 while((card
= Prm_FindBoardTagList(card
, NULL
)) != NULL
)
58 Prm_GetBoardAttrsTags(card
, PRM_Vendor
, (UPINT
)&vendor_id
,
59 PRM_Device
, (UPINT
)&product_id
, TAG_END
);
60 if(IsCardCompatible(vendor_id
, product_id
, base
))
69 /****i* intelpro100.device/AllocPrometheusCard *****************************
72 * AllocPrometheusCard -- Take control of a card.
75 * context = AllocPrometheusCard(index)
77 * struct BusContext *AllocPrometheusCard(ULONG);
79 ****************************************************************************
83 struct BusContext
*AllocPrometheusCard(ULONG index
, struct DevBase
*base
)
86 struct BusContext
*context
;
87 PCIBoard
*card
= NULL
;
89 UPINT vendor_id
, product_id
;
91 /* Find a compatible card */
93 context
= AllocMem(sizeof(struct BusContext
), MEMF_PUBLIC
| MEMF_CLEAR
);
101 card
= Prm_FindBoardTagList(card
, NULL
);
102 Prm_GetBoardAttrsTags(card
, PRM_Vendor
, (UPINT
)&vendor_id
,
103 PRM_Device
, (UPINT
)&product_id
, TAG_END
);
104 if(IsCardCompatible(vendor_id
, product_id
, base
))
108 context
->card
= card
;
113 /* Get base address */
117 Prm_GetBoardAttrsTags(card
,
118 PRM_MemoryAddr0
+ BAR_NO
, (UPINT
)&context
->io_base
, TAG_END
);
119 if(context
->io_base
== 0)
127 if(!Prm_SetBoardAttrsTags(card
, PRM_BoardOwner
, (UPINT
)base
, TAG_END
))
133 FreePrometheusCard(context
, base
);
142 /****i* intelpro100.device/FreePrometheusCard ******************************
145 * FreePrometheusCard -- Release a card.
148 * FreePrometheusCard(context)
150 * VOID FreePrometheusCard(struct BusContext *);
152 ****************************************************************************
156 VOID
FreePrometheusCard(struct BusContext
*context
, struct DevBase
*base
)
163 card
= context
->card
;
168 Prm_GetBoardAttrsTags(card
, PRM_BoardOwner
, (UPINT
)&owner
,
171 Prm_SetBoardAttrsTags(card
, PRM_BoardOwner
, NULL
, TAG_END
);
174 FreeMem(context
, sizeof(struct BusContext
));
182 /****i* intelpro100.device/AddPrometheusIntServer **************************
185 * AddPrometheusIntServer
188 * context = AddPrometheusIntServer(index)
190 * struct BusContext *AddPrometheusIntServer(ULONG);
192 ****************************************************************************
196 BOOL
AddPrometheusIntServer(APTR card
, struct Interrupt
*interrupt
,
197 struct DevBase
*base
)
199 return Prm_AddIntServer(card
, interrupt
);
204 /****i* intelpro100.device/RemPrometheusIntServer **************************
207 * RemPrometheusIntServer
210 * RemPrometheusIntServer()
212 * VOID RemPrometheusIntServer(ULONG);
214 ****************************************************************************
218 VOID
RemPrometheusIntServer(APTR card
, struct Interrupt
*interrupt
,
219 struct DevBase
*base
)
221 Prm_RemIntServer(card
, interrupt
);
228 /****i* intelpro100.device/AllocPrometheusDMAMem ***************************
231 * AllocPrometheusDMAMem
234 * mem = AllocPrometheusDMAMem(context, size, alignment)
236 * APTR AllocPrometheusDMAMem(struct BusContext *, UPINT, UWORD);
238 ****************************************************************************
240 * Alignment currently must be minimum of 8 bytes.
244 APTR
AllocPrometheusDMAMem(UPINT size
, struct DevBase
*base
)
246 return Prm_AllocDMABuffer(size
);
251 /****i* intelpro100.device/FreePrometheusDMAMem ****************************
254 * FreePrometheusDMAMem
257 * FreePrometheusDMAMem(context, mem)
259 * VOID FreePrometheusDMAMem(struct BusContext *, APTR);
261 ****************************************************************************
265 VOID
FreePrometheusDMAMem(APTR mem
, UPINT size
, struct DevBase
*base
)
267 Prm_FreeDMABuffer(mem
, size
);