drmP.h revision 95584
1/* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*- 2 * Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com 3 * 4 * Copyright 1999 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 * VA LINUX SYSTEMS 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 25 * OTHER DEALINGS IN THE SOFTWARE. 26 * 27 * Authors: 28 * Rickard E. (Rik) Faith <faith@valinux.com> 29 * Gareth Hughes <gareth@valinux.com> 30 * 31 * $FreeBSD: head/sys/dev/drm/drmP.h 95584 2002-04-27 20:47:57Z anholt $ 32 */ 33 34#ifndef _DRM_P_H_ 35#define _DRM_P_H_ 36 37#if defined(_KERNEL) || defined(__KERNEL__) 38 39/* DRM template customization defaults 40 */ 41#ifndef __HAVE_AGP 42#define __HAVE_AGP 0 43#endif 44#ifndef __HAVE_MTRR 45#define __HAVE_MTRR 0 46#endif 47#ifndef __HAVE_CTX_BITMAP 48#define __HAVE_CTX_BITMAP 0 49#endif 50#ifndef __HAVE_DMA 51#define __HAVE_DMA 0 52#endif 53#ifndef __HAVE_DMA_IRQ 54#define __HAVE_DMA_IRQ 0 55#endif 56#ifndef __HAVE_DMA_WAITLIST 57#define __HAVE_DMA_WAITLIST 0 58#endif 59#ifndef __HAVE_DMA_FREELIST 60#define __HAVE_DMA_FREELIST 0 61#endif 62#ifndef __HAVE_DMA_HISTOGRAM 63#define __HAVE_DMA_HISTOGRAM 0 64#endif 65 66#define DRM_DEBUG_CODE 0 /* Include debugging code (if > 1, then 67 also include looping detection. */ 68 69typedef struct drm_device drm_device_t; 70typedef struct drm_file drm_file_t; 71 72/* There's undoubtably more of this file to go into these OS dependent ones. */ 73#ifdef __linux__ 74#include "dev/drm/drm_os_linux.h" 75#endif /* __linux__ */ 76 77#ifdef __FreeBSD__ 78#include "dev/drm/drm_os_freebsd.h" 79#endif /* __FreeBSD__ */ 80 81#include "dev/drm/drm.h" 82 83/* Begin the DRM... */ 84 85#define DRM_HASH_SIZE 16 /* Size of key hash table */ 86#define DRM_KERNEL_CONTEXT 0 /* Change drm_resctx if changed */ 87#define DRM_RESERVED_CONTEXTS 1 /* Change drm_resctx if changed */ 88#define DRM_LOOPING_LIMIT 5000000 89#define DRM_BSZ 1024 /* Buffer size for /dev/drm? output */ 90#define DRM_LOCK_SLICE 1 /* Time slice for lock, in jiffies */ 91 92#define DRM_FLAG_DEBUG 0x01 93#define DRM_FLAG_NOCTX 0x02 94 95#define DRM_MEM_DMA 0 96#define DRM_MEM_SAREA 1 97#define DRM_MEM_DRIVER 2 98#define DRM_MEM_MAGIC 3 99#define DRM_MEM_IOCTLS 4 100#define DRM_MEM_MAPS 5 101#define DRM_MEM_VMAS 6 102#define DRM_MEM_BUFS 7 103#define DRM_MEM_SEGS 8 104#define DRM_MEM_PAGES 9 105#define DRM_MEM_FILES 10 106#define DRM_MEM_QUEUES 11 107#define DRM_MEM_CMDS 12 108#define DRM_MEM_MAPPINGS 13 109#define DRM_MEM_BUFLISTS 14 110#define DRM_MEM_AGPLISTS 15 111#define DRM_MEM_TOTALAGP 16 112#define DRM_MEM_BOUNDAGP 17 113#define DRM_MEM_CTXBITMAP 18 114#define DRM_MEM_STUB 19 115#define DRM_MEM_SGLISTS 20 116 117#define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8) 118 119 /* Backward compatibility section */ 120 /* _PAGE_WT changed to _PAGE_PWT in 2.2.6 */ 121#ifndef _PAGE_PWT 122#define _PAGE_PWT _PAGE_WT 123#endif 124 125 /* Mapping helper macros */ 126#define DRM_IOREMAP(map) \ 127 (map)->handle = DRM(ioremap)( (map)->offset, (map)->size ) 128 129#define DRM_IOREMAPFREE(map) \ 130 do { \ 131 if ( (map)->handle && (map)->size ) \ 132 DRM(ioremapfree)( (map)->handle, (map)->size ); \ 133 } while (0) 134 135 /* Internal types and structures */ 136#define DRM_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) 137#define DRM_MIN(a,b) ((a)<(b)?(a):(b)) 138#define DRM_MAX(a,b) ((a)>(b)?(a):(b)) 139 140#define DRM_LEFTCOUNT(x) (((x)->rp + (x)->count - (x)->wp) % ((x)->count + 1)) 141#define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x)) 142#define DRM_WAITCOUNT(dev,idx) DRM_BUFCOUNT(&dev->queuelist[idx]->waitlist) 143 144#define DRM_GET_PRIV_SAREA(_dev, _ctx, _map) do { \ 145 (_map) = (_dev)->context_sareas[_ctx]; \ 146} while(0) 147 148#ifdef __linux__ 149typedef int drm_ioctl_t( DRM_OS_IOCTL ); 150#endif /* __linux__ */ 151 152typedef struct drm_pci_list { 153 u16 vendor; 154 u16 device; 155} drm_pci_list_t; 156 157typedef struct drm_ioctl_desc { 158#ifdef __linux__ 159 drm_ioctl_t *func; 160#endif /* __linux__ */ 161#ifdef __FreeBSD__ 162 d_ioctl_t *func; 163#endif /* __FreeBSD__ */ 164 int auth_needed; 165 int root_only; 166} drm_ioctl_desc_t; 167 168typedef struct drm_devstate { 169 pid_t owner; /* X server pid holding x_lock */ 170 171} drm_devstate_t; 172 173typedef struct drm_magic_entry { 174 drm_magic_t magic; 175 struct drm_file *priv; 176 struct drm_magic_entry *next; 177} drm_magic_entry_t; 178 179typedef struct drm_magic_head { 180 struct drm_magic_entry *head; 181 struct drm_magic_entry *tail; 182} drm_magic_head_t; 183 184typedef struct drm_vma_entry { 185 struct vm_area_struct *vma; 186 struct drm_vma_entry *next; 187 pid_t pid; 188} drm_vma_entry_t; 189 190typedef struct drm_buf { 191 int idx; /* Index into master buflist */ 192 int total; /* Buffer size */ 193 int order; /* log-base-2(total) */ 194 int used; /* Amount of buffer in use (for DMA) */ 195 unsigned long offset; /* Byte offset (used internally) */ 196 void *address; /* Address of buffer */ 197 unsigned long bus_address; /* Bus address of buffer */ 198 struct drm_buf *next; /* Kernel-only: used for free list */ 199 __volatile__ int waiting; /* On kernel DMA queue */ 200 __volatile__ int pending; /* On hardware DMA queue */ 201 wait_queue_head_t dma_wait; /* Processes waiting */ 202 pid_t pid; /* PID of holding process */ 203 int context; /* Kernel queue for this buffer */ 204 int while_locked;/* Dispatch this buffer while locked */ 205 enum { 206 DRM_LIST_NONE = 0, 207 DRM_LIST_FREE = 1, 208 DRM_LIST_WAIT = 2, 209 DRM_LIST_PEND = 3, 210 DRM_LIST_PRIO = 4, 211 DRM_LIST_RECLAIM = 5 212 } list; /* Which list we're on */ 213 214#if DRM_DMA_HISTOGRAM 215 cycles_t time_queued; /* Queued to kernel DMA queue */ 216 cycles_t time_dispatched; /* Dispatched to hardware */ 217 cycles_t time_completed; /* Completed by hardware */ 218 cycles_t time_freed; /* Back on freelist */ 219#endif 220 221 int dev_priv_size; /* Size of buffer private stoarge */ 222 void *dev_private; /* Per-buffer private storage */ 223} drm_buf_t; 224 225#if DRM_DMA_HISTOGRAM 226#define DRM_DMA_HISTOGRAM_SLOTS 9 227#define DRM_DMA_HISTOGRAM_INITIAL 10 228#define DRM_DMA_HISTOGRAM_NEXT(current) ((current)*10) 229typedef struct drm_histogram { 230 atomic_t total; 231 232 atomic_t queued_to_dispatched[DRM_DMA_HISTOGRAM_SLOTS]; 233 atomic_t dispatched_to_completed[DRM_DMA_HISTOGRAM_SLOTS]; 234 atomic_t completed_to_freed[DRM_DMA_HISTOGRAM_SLOTS]; 235 236 atomic_t queued_to_completed[DRM_DMA_HISTOGRAM_SLOTS]; 237 atomic_t queued_to_freed[DRM_DMA_HISTOGRAM_SLOTS]; 238 239 atomic_t dma[DRM_DMA_HISTOGRAM_SLOTS]; 240 atomic_t schedule[DRM_DMA_HISTOGRAM_SLOTS]; 241 atomic_t ctx[DRM_DMA_HISTOGRAM_SLOTS]; 242 atomic_t lacq[DRM_DMA_HISTOGRAM_SLOTS]; 243 atomic_t lhld[DRM_DMA_HISTOGRAM_SLOTS]; 244} drm_histogram_t; 245#endif 246 247 /* bufs is one longer than it has to be */ 248typedef struct drm_waitlist { 249 int count; /* Number of possible buffers */ 250 drm_buf_t **bufs; /* List of pointers to buffers */ 251 drm_buf_t **rp; /* Read pointer */ 252 drm_buf_t **wp; /* Write pointer */ 253 drm_buf_t **end; /* End pointer */ 254 DRM_OS_SPINTYPE read_lock; 255 DRM_OS_SPINTYPE write_lock; 256} drm_waitlist_t; 257 258typedef struct drm_freelist { 259 int initialized; /* Freelist in use */ 260 atomic_t count; /* Number of free buffers */ 261 drm_buf_t *next; /* End pointer */ 262 263 wait_queue_head_t waiting; /* Processes waiting on free bufs */ 264 int low_mark; /* Low water mark */ 265 int high_mark; /* High water mark */ 266 atomic_t wfh; /* If waiting for high mark */ 267 DRM_OS_SPINTYPE lock; 268} drm_freelist_t; 269 270typedef struct drm_buf_entry { 271 int buf_size; 272 int buf_count; 273 drm_buf_t *buflist; 274 int seg_count; 275 int page_order; 276 unsigned long *seglist; 277 278 drm_freelist_t freelist; 279} drm_buf_entry_t; 280 281typedef struct drm_hw_lock { 282 __volatile__ unsigned int lock; 283 char padding[60]; /* Pad to cache line */ 284} drm_hw_lock_t; 285 286#ifdef __linux__ 287struct drm_file { 288 int authenticated; 289 int minor; 290 pid_t pid; 291 uid_t uid; 292 drm_magic_t magic; 293 unsigned long ioctl_count; 294 struct drm_file *next; 295 struct drm_file *prev; 296 struct drm_device *dev; 297 int remove_auth_on_close; 298}; 299#endif /* __linux__ */ 300#ifdef __FreeBSD__ 301typedef TAILQ_HEAD(drm_file_list, drm_file) drm_file_list_t; 302struct drm_file { 303 TAILQ_ENTRY(drm_file) link; 304 int authenticated; 305 int minor; 306 pid_t pid; 307 uid_t uid; 308 int refs; 309 drm_magic_t magic; 310 unsigned long ioctl_count; 311 struct drm_device *devXX; 312}; 313#endif /* __FreeBSD__ */ 314 315typedef struct drm_queue { 316 atomic_t use_count; /* Outstanding uses (+1) */ 317 atomic_t finalization; /* Finalization in progress */ 318 atomic_t block_count; /* Count of processes waiting */ 319 atomic_t block_read; /* Queue blocked for reads */ 320 wait_queue_head_t read_queue; /* Processes waiting on block_read */ 321 atomic_t block_write; /* Queue blocked for writes */ 322 wait_queue_head_t write_queue; /* Processes waiting on block_write */ 323#if 1 324 atomic_t total_queued; /* Total queued statistic */ 325 atomic_t total_flushed;/* Total flushes statistic */ 326 atomic_t total_locks; /* Total locks statistics */ 327#endif 328 drm_ctx_flags_t flags; /* Context preserving and 2D-only */ 329 drm_waitlist_t waitlist; /* Pending buffers */ 330 wait_queue_head_t flush_queue; /* Processes waiting until flush */ 331} drm_queue_t; 332 333typedef struct drm_lock_data { 334 drm_hw_lock_t *hw_lock; /* Hardware lock */ 335 pid_t pid; /* PID of lock holder (0=kernel) */ 336 wait_queue_head_t lock_queue; /* Queue of blocked processes */ 337 unsigned long lock_time; /* Time of last lock in jiffies */ 338} drm_lock_data_t; 339 340typedef struct drm_device_dma { 341#if 0 342 /* Performance Counters */ 343 atomic_t total_prio; /* Total DRM_DMA_PRIORITY */ 344 atomic_t total_bytes; /* Total bytes DMA'd */ 345 atomic_t total_dmas; /* Total DMA buffers dispatched */ 346 347 atomic_t total_missed_dma; /* Missed drm_do_dma */ 348 atomic_t total_missed_lock; /* Missed lock in drm_do_dma */ 349 atomic_t total_missed_free; /* Missed drm_free_this_buffer */ 350 atomic_t total_missed_sched;/* Missed drm_dma_schedule */ 351 352 atomic_t total_tried; /* Tried next_buffer */ 353 atomic_t total_hit; /* Sent next_buffer */ 354 atomic_t total_lost; /* Lost interrupt */ 355#endif 356 357 drm_buf_entry_t bufs[DRM_MAX_ORDER+1]; 358 int buf_count; 359 drm_buf_t **buflist; /* Vector of pointers info bufs */ 360 int seg_count; 361 int page_count; 362 unsigned long *pagelist; 363 unsigned long byte_count; 364 enum { 365 _DRM_DMA_USE_AGP = 0x01, 366 _DRM_DMA_USE_SG = 0x02 367 } flags; 368 369 /* DMA support */ 370 drm_buf_t *this_buffer; /* Buffer being sent */ 371 drm_buf_t *next_buffer; /* Selected buffer to send */ 372 drm_queue_t *next_queue; /* Queue from which buffer selected*/ 373 wait_queue_head_t waiting; /* Processes waiting on free bufs */ 374} drm_device_dma_t; 375 376#if __REALLY_HAVE_AGP 377typedef struct drm_agp_mem { 378#ifdef __linux__ 379 unsigned long handle; 380 agp_memory *memory; 381#endif /* __linux__ */ 382#ifdef __FreeBSD__ 383 void *handle; 384#endif /* __FreeBSD__ */ 385 unsigned long bound; /* address */ 386 int pages; 387 struct drm_agp_mem *prev; 388 struct drm_agp_mem *next; 389} drm_agp_mem_t; 390 391typedef struct drm_agp_head { 392#ifdef __linux__ 393 agp_kern_info agp_info; 394#endif /* __linux__ */ 395#ifdef __FreeBSD__ 396 device_t agpdev; 397 struct agp_info info; 398#endif /* __FreeBSD__ */ 399 const char *chipset; 400 drm_agp_mem_t *memory; 401 unsigned long mode; 402 int enabled; 403 int acquired; 404 unsigned long base; 405 int agp_mtrr; 406 int cant_use_aperture; 407 unsigned long page_mask; 408} drm_agp_head_t; 409#endif 410 411typedef struct drm_sg_mem { 412 unsigned long handle; 413 void *virtual; 414 int pages; 415 struct page **pagelist; 416#ifdef __linux__ 417 dma_addr_t *busaddr; 418#endif /* __linux__ */ 419} drm_sg_mem_t; 420 421typedef struct drm_sigdata { 422 int context; 423 drm_hw_lock_t *lock; 424} drm_sigdata_t; 425 426#ifdef __linux__ 427typedef struct drm_map_list { 428 struct list_head head; 429 drm_map_t *map; 430} drm_map_list_t; 431#endif /* __linux__ */ 432#ifdef __FreeBSD__ 433typedef TAILQ_HEAD(drm_map_list, drm_map_list_entry) drm_map_list_t; 434typedef struct drm_map_list_entry { 435 TAILQ_ENTRY(drm_map_list_entry) link; 436 drm_map_t *map; 437} drm_map_list_entry_t; 438#endif /* __FreeBSD__ */ 439 440struct drm_device { 441 const char *name; /* Simple driver name */ 442 char *unique; /* Unique identifier: e.g., busid */ 443 int unique_len; /* Length of unique field */ 444#ifdef __linux__ 445 dev_t device; /* Device number for mknod */ 446#endif /* __linux__ */ 447#ifdef __FreeBSD__ 448 device_t device; /* Device instance from newbus */ 449 dev_t devnode; /* Device number for mknod */ 450#endif /* __FreeBSD__ */ 451 char *devname; /* For /proc/interrupts */ 452 453 int blocked; /* Blocked due to VC switch? */ 454#ifdef __FreeBSD__ 455 int flags; /* Flags to open(2) */ 456 int writable; /* Opened with FWRITE */ 457#endif /* __FreeBSD__ */ 458 struct proc_dir_entry *root; /* Root for this device's entries */ 459 460 /* Locks */ 461#ifdef __linux__ 462 spinlock_t count_lock; /* For inuse, open_count, buf_use */ 463 struct semaphore struct_sem; /* For others */ 464#endif /* __linux__ */ 465#ifdef __FreeBSD__ 466 DRM_OS_SPINTYPE count_lock; /* For inuse, open_count, buf_use */ 467 struct lock dev_lock; /* For others */ 468#endif /* __FreeBSD__ */ 469 /* Usage Counters */ 470 int open_count; /* Outstanding files open */ 471 atomic_t ioctl_count; /* Outstanding IOCTLs pending */ 472 atomic_t vma_count; /* Outstanding vma areas open */ 473 int buf_use; /* Buffers in use -- cannot alloc */ 474 atomic_t buf_alloc; /* Buffer allocation in progress */ 475 476 /* Performance counters */ 477 unsigned long counters; 478 drm_stat_type_t types[15]; 479 atomic_t counts[15]; 480 481 /* Authentication */ 482#ifdef __linux__ 483 drm_file_t *file_first; 484 drm_file_t *file_last; 485#endif /* __linux__ */ 486#ifdef __FreeBSD__ 487 drm_file_list_t files; 488#endif /* __FreeBSD__ */ 489 drm_magic_head_t magiclist[DRM_HASH_SIZE]; 490 491 /* Memory management */ 492 drm_map_list_t *maplist; /* Linked list of regions */ 493 int map_count; /* Number of mappable regions */ 494 495 drm_map_t **context_sareas; 496 int max_context; 497 498 drm_vma_entry_t *vmalist; /* List of vmas (for debugging) */ 499 drm_lock_data_t lock; /* Information on hardware lock */ 500 501 /* DMA queues (contexts) */ 502 int queue_count; /* Number of active DMA queues */ 503 int queue_reserved; /* Number of reserved DMA queues */ 504 int queue_slots; /* Actual length of queuelist */ 505 drm_queue_t **queuelist; /* Vector of pointers to DMA queues */ 506 drm_device_dma_t *dma; /* Optional pointer for DMA support */ 507 508 /* Context support */ 509 int irq; /* Interrupt used by board */ 510#ifdef __FreeBSD__ 511 struct resource *irqr; /* Resource for interrupt used by board */ 512 void *irqh; /* Handle from bus_setup_intr */ 513#endif /* __FreeBSD__ */ 514 __volatile__ long context_flag; /* Context swapping flag */ 515 __volatile__ long interrupt_flag; /* Interruption handler flag */ 516 __volatile__ long dma_flag; /* DMA dispatch flag */ 517#ifdef __linux__ 518 struct timer_list timer; /* Timer for delaying ctx switch */ 519#endif /* __linux__ */ 520#ifdef __FreeBSD__ 521 struct callout timer; /* Timer for delaying ctx switch */ 522#endif /* __FreeBSD__ */ 523 wait_queue_head_t context_wait; /* Processes waiting on ctx switch */ 524 int last_checked; /* Last context checked for DMA */ 525 int last_context; /* Last current context */ 526 unsigned long last_switch; /* jiffies at last context switch */ 527#ifdef __linux__ 528 struct tq_struct tq; 529#endif /* __linux__ */ 530#ifdef __FreeBSD__ 531#if __FreeBSD_version >= 400005 532 struct task task; 533#endif 534#endif /* __FreeBSD__ */ 535 cycles_t ctx_start; 536 cycles_t lck_start; 537#if __HAVE_DMA_HISTOGRAM 538 drm_histogram_t histo; 539#endif 540 541 /* Callback to X server for context switch 542 and for heavy-handed reset. */ 543 char buf[DRM_BSZ]; /* Output buffer */ 544 char *buf_rp; /* Read pointer */ 545 char *buf_wp; /* Write pointer */ 546 char *buf_end; /* End pointer */ 547#ifdef __linux__ 548 struct fasync_struct *buf_async;/* Processes waiting for SIGIO */ 549#endif /* __linux__ */ 550#ifdef __FreeBSD__ 551 struct sigio *buf_sigio; /* Processes waiting for SIGIO */ 552 struct selinfo buf_sel; /* Workspace for select/poll */ 553 int buf_selecting;/* True if poll sleeper */ 554#endif /* __FreeBSD__ */ 555 wait_queue_head_t buf_readers; /* Processes waiting to read */ 556 wait_queue_head_t buf_writers; /* Processes waiting to ctx switch */ 557 558#ifdef __FreeBSD__ 559 /* Sysctl support */ 560 struct drm_sysctl_info *sysctl; 561#endif /* __FreeBSD__ */ 562 563#if __REALLY_HAVE_AGP 564 drm_agp_head_t *agp; 565#endif 566 struct pci_dev *pdev; 567#ifdef __alpha__ 568#if LINUX_VERSION_CODE < 0x020403 569 struct pci_controler *hose; 570#else 571 struct pci_controller *hose; 572#endif 573#endif 574 drm_sg_mem_t *sg; /* Scatter gather memory */ 575 unsigned long *ctx_bitmap; 576 void *dev_private; 577 drm_sigdata_t sigdata; /* For block_all_signals */ 578 sigset_t sigmask; 579}; 580 581extern int DRM(flags); 582extern void DRM(parse_options)( char *s ); 583extern int DRM(cpu_valid)( void ); 584 585 /* Authentication (drm_auth.h) */ 586extern int DRM(add_magic)(drm_device_t *dev, drm_file_t *priv, 587 drm_magic_t magic); 588extern int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic); 589 590 /* Driver support (drm_drv.h) */ 591extern int DRM(version)( DRM_OS_IOCTL ); 592extern int DRM(write_string)(drm_device_t *dev, const char *s); 593 594 /* Memory management support (drm_memory.h) */ 595extern void DRM(mem_init)(void); 596extern void *DRM(alloc)(size_t size, int area); 597extern void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size, 598 int area); 599extern char *DRM(strdup)(const char *s, int area); 600extern void DRM(strfree)(char *s, int area); 601extern void DRM(free)(void *pt, size_t size, int area); 602extern unsigned long DRM(alloc_pages)(int order, int area); 603extern void DRM(free_pages)(unsigned long address, int order, 604 int area); 605extern void *DRM(ioremap)(unsigned long offset, unsigned long size); 606extern void DRM(ioremapfree)(void *pt, unsigned long size); 607 608#if __REALLY_HAVE_AGP 609extern agp_memory *DRM(alloc_agp)(int pages, u32 type); 610extern int DRM(free_agp)(agp_memory *handle, int pages); 611extern int DRM(bind_agp)(agp_memory *handle, unsigned int start); 612extern int DRM(unbind_agp)(agp_memory *handle); 613#endif 614 615extern int DRM(context_switch)(drm_device_t *dev, int old, int new); 616extern int DRM(context_switch_complete)(drm_device_t *dev, int new); 617 618#if __HAVE_CTX_BITMAP 619extern int DRM(ctxbitmap_init)( drm_device_t *dev ); 620extern void DRM(ctxbitmap_cleanup)( drm_device_t *dev ); 621extern void DRM(ctxbitmap_free)( drm_device_t *dev, int ctx_handle ); 622extern int DRM(ctxbitmap_next)( drm_device_t *dev ); 623#endif 624 625 /* Locking IOCTL support (drm_lock.h) */ 626extern int DRM(lock_take)(__volatile__ unsigned int *lock, 627 unsigned int context); 628extern int DRM(lock_transfer)(drm_device_t *dev, 629 __volatile__ unsigned int *lock, 630 unsigned int context); 631extern int DRM(lock_free)(drm_device_t *dev, 632 __volatile__ unsigned int *lock, 633 unsigned int context); 634extern int DRM(flush_unblock)(drm_device_t *dev, int context, 635 drm_lock_flags_t flags); 636extern int DRM(flush_block_and_flush)(drm_device_t *dev, int context, 637 drm_lock_flags_t flags); 638extern int DRM(notifier)(void *priv); 639 640 /* Buffer management support (drm_bufs.h) */ 641extern int DRM(order)( unsigned long size ); 642 643#if __HAVE_DMA 644 /* DMA support (drm_dma.h) */ 645extern int DRM(dma_setup)(drm_device_t *dev); 646extern void DRM(dma_takedown)(drm_device_t *dev); 647extern void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf); 648extern void DRM(reclaim_buffers)(drm_device_t *dev, pid_t pid); 649#if __HAVE_OLD_DMA 650/* GH: This is a dirty hack for now... 651 */ 652extern void DRM(clear_next_buffer)(drm_device_t *dev); 653extern int DRM(select_queue)(drm_device_t *dev, 654 void (*wrapper)(unsigned long)); 655extern int DRM(dma_enqueue)(drm_device_t *dev, drm_dma_t *dma); 656extern int DRM(dma_get_buffers)(drm_device_t *dev, drm_dma_t *dma); 657#endif 658#if __HAVE_DMA_IRQ 659extern int DRM(irq_install)( drm_device_t *dev, int irq ); 660extern int DRM(irq_uninstall)( drm_device_t *dev ); 661extern void DRM(dma_service)( DRM_OS_IRQ_ARGS ); 662#if __HAVE_DMA_IRQ_BH 663extern void DRM(dma_immediate_bh)( DRM_OS_TASKQUEUE_ARGS ); 664#endif 665#endif 666#if DRM_DMA_HISTOGRAM 667extern int DRM(histogram_slot)(unsigned long count); 668extern void DRM(histogram_compute)(drm_device_t *dev, drm_buf_t *buf); 669#endif 670 671 /* Buffer list support (drm_lists.h) */ 672#if __HAVE_DMA_WAITLIST 673extern int DRM(waitlist_create)(drm_waitlist_t *bl, int count); 674extern int DRM(waitlist_destroy)(drm_waitlist_t *bl); 675extern int DRM(waitlist_put)(drm_waitlist_t *bl, drm_buf_t *buf); 676extern drm_buf_t *DRM(waitlist_get)(drm_waitlist_t *bl); 677#endif 678#if __HAVE_DMA_FREELIST 679extern int DRM(freelist_create)(drm_freelist_t *bl, int count); 680extern int DRM(freelist_destroy)(drm_freelist_t *bl); 681extern int DRM(freelist_put)(drm_device_t *dev, drm_freelist_t *bl, 682 drm_buf_t *buf); 683extern drm_buf_t *DRM(freelist_get)(drm_freelist_t *bl, int block); 684#endif 685#endif /* __HAVE_DMA */ 686 687#if __REALLY_HAVE_AGP 688 /* AGP/GART support (drm_agpsupport.h) */ 689extern drm_agp_head_t *DRM(agp_init)(void); 690extern void DRM(agp_uninit)(void); 691extern void DRM(agp_do_release)(void); 692extern agp_memory *DRM(agp_allocate_memory)(size_t pages, u32 type); 693extern int DRM(agp_free_memory)(agp_memory *handle); 694extern int DRM(agp_bind_memory)(agp_memory *handle, off_t start); 695extern int DRM(agp_unbind_memory)(agp_memory *handle); 696#endif 697 698 /* Proc support (drm_proc.h) */ 699extern struct proc_dir_entry *DRM(proc_init)(drm_device_t *dev, 700 int minor, 701 struct proc_dir_entry *root, 702 struct proc_dir_entry **dev_root); 703extern int DRM(proc_cleanup)(int minor, 704 struct proc_dir_entry *root, 705 struct proc_dir_entry *dev_root); 706 707#if __HAVE_SG 708 /* Scatter Gather Support (drm_scatter.h) */ 709extern void DRM(sg_cleanup)(drm_sg_mem_t *entry); 710#endif 711 712#if __REALLY_HAVE_SG 713 /* ATI PCIGART support (ati_pcigart.h) */ 714extern int DRM(ati_pcigart_init)(drm_device_t *dev, 715 unsigned long *addr, 716 dma_addr_t *bus_addr); 717extern int DRM(ati_pcigart_cleanup)(drm_device_t *dev, 718 unsigned long addr, 719 dma_addr_t bus_addr); 720#endif 721 722#endif /* __KERNEL__ */ 723#endif 724