mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-12-27 16:59:41 +03:00
b30a061ac1
git-svn-id: svn://kolibrios.org@3260 a494cfbc-eb01-0410-851d-a64ba20cac60
130 lines
3.2 KiB
C
130 lines
3.2 KiB
C
/**
|
|
* \file drm_stub.h
|
|
* Stub support
|
|
*
|
|
* \author Rickard E. (Rik) Faith <faith@valinux.com>
|
|
*/
|
|
|
|
/*
|
|
* Created: Fri Jan 19 10:48:35 2001 by faith@acm.org
|
|
*
|
|
* Copyright 2001 VA Linux Systems, Inc., Sunnyvale, California.
|
|
* All Rights Reserved.
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
* to deal in the Software without restriction, including without limitation
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice (including the next
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
* Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
* PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
* DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/slab.h>
|
|
#include <drm/drmP.h>
|
|
|
|
struct va_format {
|
|
const char *fmt;
|
|
va_list *va;
|
|
};
|
|
|
|
unsigned int drm_debug = 0; /* 1 to enable debug output */
|
|
EXPORT_SYMBOL(drm_debug);
|
|
|
|
unsigned int drm_vblank_offdelay = 5000; /* Default to 5000 msecs. */
|
|
EXPORT_SYMBOL(drm_vblank_offdelay);
|
|
|
|
unsigned int drm_timestamp_precision = 20; /* Default to 20 usecs. */
|
|
EXPORT_SYMBOL(drm_timestamp_precision);
|
|
|
|
int drm_err(const char *func, const char *format, ...)
|
|
{
|
|
struct va_format vaf;
|
|
va_list args;
|
|
int r;
|
|
|
|
va_start(args, format);
|
|
|
|
vaf.fmt = format;
|
|
vaf.va = &args;
|
|
|
|
r = printk(KERN_ERR "[" DRM_NAME ":%s] *ERROR* %pV", func, &vaf);
|
|
|
|
va_end(args);
|
|
|
|
return r;
|
|
}
|
|
EXPORT_SYMBOL(drm_err);
|
|
|
|
void drm_ut_debug_printk(unsigned int request_level,
|
|
const char *prefix,
|
|
const char *function_name,
|
|
const char *format, ...)
|
|
{
|
|
va_list args;
|
|
|
|
// if (drm_debug & request_level) {
|
|
// if (function_name)
|
|
// printk(KERN_DEBUG "[%s:%s], ", prefix, function_name);
|
|
// va_start(args, format);
|
|
// vprintk(format, args);
|
|
// va_end(args);
|
|
// }
|
|
}
|
|
EXPORT_SYMBOL(drm_ut_debug_printk);
|
|
|
|
/**
|
|
* Compute size order. Returns the exponent of the smaller power of two which
|
|
* is greater or equal to given number.
|
|
*
|
|
* \param size size.
|
|
* \return order.
|
|
*
|
|
* \todo Can be made faster.
|
|
*/
|
|
int drm_order(unsigned long size)
|
|
{
|
|
int order;
|
|
unsigned long tmp;
|
|
|
|
for (order = 0, tmp = size >> 1; tmp; tmp >>= 1, order++) ;
|
|
|
|
if (size & (size - 1))
|
|
++order;
|
|
|
|
return order;
|
|
}
|
|
|
|
extern int x86_clflush_size;
|
|
|
|
static inline void clflush(volatile void *__p)
|
|
{
|
|
asm volatile("clflush %0" : "+m" (*(volatile char*)__p));
|
|
}
|
|
|
|
void
|
|
drm_clflush_virt_range(char *addr, unsigned long length)
|
|
{
|
|
char *end = addr + length;
|
|
mb();
|
|
for (; addr < end; addr += x86_clflush_size)
|
|
clflush(addr);
|
|
clflush(end - 1);
|
|
mb();
|
|
return;
|
|
}
|
|
|