Author: aljen Date: 2010-05-23 03:22:32 +0200 (Sun, 23 May 2010) New Revision: 36904 Changeset: http://dev.haiku-os.org/changeset/36904/haiku Added: haiku/branches/components/gallium3d/src/add-ons/kernel/drm/drm/drm_pci.c haiku/branches/components/gallium3d/src/add-ons/kernel/drm/drm/waitqueue.h Modified: haiku/branches/components/gallium3d/src/add-ons/kernel/drm/drm/drm_auth.c Log: Forgot about those files Modified: haiku/branches/components/gallium3d/src/add-ons/kernel/drm/drm/drm_auth.c =================================================================== --- haiku/branches/components/gallium3d/src/add-ons/kernel/drm/drm/drm_auth.c 2010-05-23 01:00:00 UTC (rev 36903) +++ haiku/branches/components/gallium3d/src/add-ons/kernel/drm/drm/drm_auth.c 2010-05-23 01:22:32 UTC (rev 36904) @@ -144,7 +144,7 @@ { static drm_magic_t sequence = 0; static spinlock_t lock; - lock.lock = B_SPINLOCK_INITIALIZER; + spin_lock_init(&lock); drm_auth_t *auth = data; /* Find unique magic */ Added: haiku/branches/components/gallium3d/src/add-ons/kernel/drm/drm/drm_pci.c =================================================================== --- haiku/branches/components/gallium3d/src/add-ons/kernel/drm/drm/drm_pci.c (rev 0) +++ haiku/branches/components/gallium3d/src/add-ons/kernel/drm/drm/drm_pci.c 2010-05-23 01:22:32 UTC (rev 36904) @@ -0,0 +1,122 @@ +/* drm_pci.h -- PCI DMA memory management wrappers for DRM -*- linux-c -*- */ +/** + * \file drm_pci.c + * \brief Functions and ioctls to manage PCI memory + * + * \warning These interfaces aren't stable yet. + * + * \todo Implement the remaining ioctl's for the PCI pools. + * \todo The wrappers here are so thin that they would be better off inlined.. + * + * \author José Fonseca <jrfonseca@xxxxxxxxxxxxxxxxxxxx> + * \author Leif Delgass <ldelgass@xxxxxxxxxxxxxxx> + */ + +/* + * Copyright 2003 José Fonseca. + * Copyright 2003 Leif Delgass. + * 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 THE + * AUTHORS 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 <arch/cpu.h> +#include "drmP.h" + +/**********************************************************************/ +/** \name PCI memory */ +/*@{*/ + +/** + * \brief Allocate a PCI consistent memory block, for DMA. + */ +drm_dma_handle_t *drm_pci_alloc(drm_device_t *dev, size_t size, size_t align) +{ + drm_dma_handle_t *dmah; +#if 1 + unsigned long addr; + size_t sz; +#endif + + /* pci_alloc_consistent only guarantees alignment to the smallest + * PAGE_SIZE order which is greater than or equal to the requested size. + * Return NULL here for now to make sure nobody tries for larger alignment + */ + if (align > size) + return NULL; + + dmah = malloc(sizeof(drm_dma_handle_t)); + if (!dmah) + return NULL; + + dmah->size = size; + area_id area; + area = create_area("drm_pci_alloc area", &dmah->vaddr, B_ANY_ADDRESS, + PAGE_ALIGN(size), B_CONTIGUOUS, B_READ_AREA | B_WRITE_AREA); + + if (area < 0) { + free(dmah); + return NULL; + } + + memset(dmah->vaddr, 0, size); + + /* XXX - Is virt_to_page() legal for consistent mem? */ + /* Reserve */ + for (addr = (unsigned long)dmah->vaddr, sz = size; + sz > 0; addr += PAGE_SIZE, sz -= PAGE_SIZE) { +// SetPageReserved(virt_to_page(addr)); + } + + return dmah; +} + +/** + * \brief Free a PCI consistent memory block without freeing its descriptor. + * + * This function is for internal use in the Linux-specific DRM core code. + */ +void __drm_pci_free(drm_device_t *dev, drm_dma_handle_t *dmah) +{ +#if 1 + unsigned long addr; + size_t sz; +#endif + + if (dmah->vaddr) { + /* XXX - Is virt_to_page() legal for consistent mem? */ + /* Unreserve */ + for (addr = (unsigned long)dmah->vaddr, sz = dmah->size; + sz > 0; addr += PAGE_SIZE, sz -= PAGE_SIZE) { +// ClearPageReserved(virt_to_page(addr)); + } + area_id area = area_for(dmah->vaddr); + if (area >= 0) + delete_area(area); + } +} + +/** + * \brief Free a PCI consistent memory block + */ +void drm_pci_free(drm_device_t *dev, drm_dma_handle_t *dmah) +{ + __drm_pci_free(dev, dmah); + free(dmah); +} Added: haiku/branches/components/gallium3d/src/add-ons/kernel/drm/drm/waitqueue.h =================================================================== --- haiku/branches/components/gallium3d/src/add-ons/kernel/drm/drm/waitqueue.h (rev 0) +++ haiku/branches/components/gallium3d/src/add-ons/kernel/drm/drm/waitqueue.h 2010-05-23 01:22:32 UTC (rev 36904) @@ -0,0 +1,63 @@ +#ifndef __DRM_WAITQUEUE_H__ +#define __DRM_WAITQUEUE_H__ + +#include <KernelExport.h> +#include <string.h> +#include "list.h" + +typedef struct wait_queue_head { + struct list_head head; + char name[B_OS_NAME_LENGTH]; + sem_id sem; + uint32 flags; +} wait_queue_head_t; + + +static inline wait_queue_head_t *init_waitqueue(const char *name) +{ + wait_queue_head_t *waitqueue = (wait_queue_head_t *)malloc( + sizeof(*waitqueue)); + if (!waitqueue) + return NULL; + memset(waitqueue, 0, sizeof(*waitqueue)); + sprintf(waitqueue->name, "drm_waitqueue_%s", name); + waitqueue->sem = create_sem(0, waitqueue->name); + if (waitqueue->sem < B_OK) { + free(waitqueue); + return NULL; + } + return waitqueue; +} + +static inline void reset_waitqueue(wait_queue_head_t *waitqueue) +{ + if (!waitqueue) + return; + sem_id sem; + waitqueue->flags = 0; + sem = create_sem(0, waitqueue->name); + if (sem) { + delete_sem(waitqueue->sem); + waitqueue->sem = sem; + } +} + +static inline void delete_waitqueue(wait_queue_head_t *waitqueue) +{ + delete_sem(waitqueue->sem); + free(waitqueue); +} + +static inline int waitqueue_active(wait_queue_head_t *waitqueue) +{ + int32 threadsCount = 0; + get_sem_count(waitqueue->sem, &threadsCount); + return threadsCount ? true : false; +} + +static inline void wake_up(wait_queue_head_t *waitqueue) +{ + +} + +#endif // __DRM_WAITQUEUE_H__