OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [drivers/] [char/] [drm-4.0/] [ctxbitmap.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/* ctxbitmap.c -- Context bitmap management -*- linux-c -*-
2
 * Created: Thu Jan 6 03:56:42 2000 by jhartmann@precisioninsight.com
3
 *
4
 * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
5
 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
6
 * All Rights Reserved.
7
 *
8
 * Permission is hereby granted, free of charge, to any person obtaining a
9
 * copy of this software and associated documentation files (the "Software"),
10
 * to deal in the Software without restriction, including without limitation
11
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12
 * and/or sell copies of the Software, and to permit persons to whom the
13
 * Software is furnished to do so, subject to the following conditions:
14
 *
15
 * The above copyright notice and this permission notice (including the next
16
 * paragraph) shall be included in all copies or substantial portions of the
17
 * Software.
18
 *
19
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
22
 * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25
 * DEALINGS IN THE SOFTWARE.
26
 *
27
 * Author: Jeff Hartmann <jhartmann@valinux.com>
28
 *
29
 */
30
 
31
#define __NO_VERSION__
32
#include "drmP.h"
33
 
34
void drm_ctxbitmap_free(drm_device_t *dev, int ctx_handle)
35
{
36
        if (ctx_handle < 0) goto failed;
37
 
38
        if (ctx_handle < DRM_MAX_CTXBITMAP) {
39
                clear_bit(ctx_handle, dev->ctx_bitmap);
40
                return;
41
        }
42
failed:
43
        DRM_ERROR("Attempt to free invalid context handle: %d\n",
44
                  ctx_handle);
45
        return;
46
}
47
 
48
int drm_ctxbitmap_next(drm_device_t *dev)
49
{
50
        int bit;
51
 
52
        bit = find_first_zero_bit(dev->ctx_bitmap, DRM_MAX_CTXBITMAP);
53
        if (bit < DRM_MAX_CTXBITMAP) {
54
                set_bit(bit, dev->ctx_bitmap);
55
                DRM_DEBUG("drm_ctxbitmap_next bit : %d\n", bit);
56
                return bit;
57
        }
58
        return -1;
59
}
60
 
61
int drm_ctxbitmap_init(drm_device_t *dev)
62
{
63
        int i;
64
        int temp;
65
 
66
        dev->ctx_bitmap = (unsigned long *) drm_alloc(PAGE_SIZE,
67
                                                      DRM_MEM_CTXBITMAP);
68
        if(dev->ctx_bitmap == NULL) {
69
                return -ENOMEM;
70
        }
71
        memset((void *) dev->ctx_bitmap, 0, PAGE_SIZE);
72
        for(i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
73
                temp = drm_ctxbitmap_next(dev);
74
                DRM_DEBUG("drm_ctxbitmap_init : %d\n", temp);
75
        }
76
 
77
        return 0;
78
}
79
 
80
void drm_ctxbitmap_cleanup(drm_device_t *dev)
81
{
82
        drm_free((void *)dev->ctx_bitmap, PAGE_SIZE,
83
                 DRM_MEM_CTXBITMAP);
84
}
85
 

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.