1706f2543Smrg/*
2706f2543Smrg * Copyright (c) 2000-2001 by The XFree86 Project, Inc.
3706f2543Smrg *
4706f2543Smrg * Permission is hereby granted, free of charge, to any person obtaining a
5706f2543Smrg * copy of this software and associated documentation files (the "Software"),
6706f2543Smrg * to deal in the Software without restriction, including without limitation
7706f2543Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8706f2543Smrg * and/or sell copies of the Software, and to permit persons to whom the
9706f2543Smrg * Software is furnished to do so, subject to the following conditions:
10706f2543Smrg *
11706f2543Smrg * The above copyright notice and this permission notice shall be included in
12706f2543Smrg * all copies or substantial portions of the Software.
13706f2543Smrg *
14706f2543Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15706f2543Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16706f2543Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17706f2543Smrg * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18706f2543Smrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19706f2543Smrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20706f2543Smrg * OTHER DEALINGS IN THE SOFTWARE.
21706f2543Smrg *
22706f2543Smrg * Except as contained in this notice, the name of the copyright holder(s)
23706f2543Smrg * and author(s) shall not be used in advertising or otherwise to promote
24706f2543Smrg * the sale, use or other dealings in this Software without prior written
25706f2543Smrg * authorization from the copyright holder(s) and author(s).
26706f2543Smrg */
27706f2543Smrg
28706f2543Smrg/*
29706f2543Smrg * This file contains the interfaces to the bus-specific code
30706f2543Smrg */
31706f2543Smrg
32706f2543Smrg#ifdef HAVE_XORG_CONFIG_H
33706f2543Smrg#include <xorg-config.h>
34706f2543Smrg#endif
35706f2543Smrg
36706f2543Smrg#include <ctype.h>
37706f2543Smrg#include <stdlib.h>
38706f2543Smrg#include <unistd.h>
39706f2543Smrg#include <X11/X.h>
40706f2543Smrg#include "os.h"
41706f2543Smrg#include "xf86.h"
42706f2543Smrg#include "xf86Priv.h"
43706f2543Smrg
44706f2543Smrg#include "xf86Bus.h"
45706f2543Smrg
46706f2543Smrg#define XF86_OS_PRIVS
47706f2543Smrg#include "xf86_OSproc.h"
48706f2543Smrg
49706f2543SmrgBool fbSlotClaimed = FALSE;
50706f2543Smrg
51706f2543Smrgint
52706f2543Smrgxf86ClaimFbSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active)
53706f2543Smrg{
54706f2543Smrg    EntityPtr p;
55706f2543Smrg    int num;
56706f2543Smrg
57706f2543Smrg    if (pciSlotClaimed)
58706f2543Smrg	return -1;
59706f2543Smrg#if defined(__sparc__) || defined (__sparc64__)
60706f2543Smrg    if (sbusSlotClaimed)
61706f2543Smrg	return -1;
62706f2543Smrg#endif
63706f2543Smrg
64706f2543Smrg    num = xf86AllocateEntity();
65706f2543Smrg    p = xf86Entities[num];
66706f2543Smrg    p->driver = drvp;
67706f2543Smrg    p->chipset = 0;
68706f2543Smrg    p->bus.type = BUS_NONE;
69706f2543Smrg    p->active = active;
70706f2543Smrg    p->inUse = FALSE;
71706f2543Smrg    xf86AddDevToEntity(num, dev);
72706f2543Smrg
73706f2543Smrg    fbSlotClaimed = TRUE;
74706f2543Smrg    return num;
75706f2543Smrg}
76706f2543Smrg
77706f2543Smrg/*
78706f2543Smrg * Get the list of FB "slots" claimed by a screen
79706f2543Smrg */
80706f2543Smrgint
81706f2543Smrgxf86GetFbInfoForScreen(int scrnIndex)
82706f2543Smrg{
83706f2543Smrg    int num = 0;
84706f2543Smrg    int i;
85706f2543Smrg    EntityPtr p;
86706f2543Smrg
87706f2543Smrg    for (i = 0; i < xf86Screens[scrnIndex]->numEntities; i++) {
88706f2543Smrg	p = xf86Entities[xf86Screens[scrnIndex]->entityList[i]];
89706f2543Smrg  	if (p->bus.type == BUS_NONE) {
90706f2543Smrg  	    num++;
91706f2543Smrg  	}
92706f2543Smrg    }
93706f2543Smrg    return num;
94706f2543Smrg}
95