* Replaced benaphore use with a mutex.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34236 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2009-11-25 11:07:49 +00:00
parent b20286c41c
commit b3be7a4135
3 changed files with 47 additions and 60 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2006-2008, Haiku, Inc. All Rights Reserved.
* Copyright 2006-2009, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@ -116,7 +116,7 @@ device_open(const char *name, uint32 /*flags*/, void **_cookie)
intel_info *info = gDeviceInfo[id];
acquire_lock(&gLock);
mutex_lock(&gLock);
if (info->open_count == 0) {
// this device has been opened for the first time, so
@ -132,7 +132,7 @@ device_open(const char *name, uint32 /*flags*/, void **_cookie)
}
}
release_lock(&gLock);
mutex_unlock(&gLock);
if (info->init_status == B_OK)
*_cookie = info;
@ -154,7 +154,7 @@ device_free(void *data)
{
struct intel_info *info = (intel_info *)data;
acquire_lock(&gLock);
mutex_lock(&gLock);
if (info->open_count-- == 1) {
// release info structure
@ -166,7 +166,7 @@ device_free(void *data)
#endif
}
release_lock(&gLock);
mutex_unlock(&gLock);
return B_OK;
}
@ -183,7 +183,7 @@ device_ioctl(void *data, uint32 op, void *buffer, size_t bufferLength)
TRACE((DEVICE_NAME ": accelerant: %s\n", INTEL_ACCELERANT_NAME));
return B_OK;
// needed to share data between kernel and accelerant
// needed to share data between kernel and accelerant
case INTEL_GET_PRIVATE_DATA:
{
intel_get_private_data *data = (intel_get_private_data *)buffer;
@ -268,7 +268,7 @@ device_ioctl(void *data, uint32 op, void *buffer, size_t bufferLength)
static status_t
device_read(void */*data*/, off_t /*pos*/, void */*buffer*/, size_t *_length)
{
*_length = 0;
*_length = 0;
return B_NOT_ALLOWED;
}
@ -276,7 +276,7 @@ device_read(void */*data*/, off_t /*pos*/, void */*buffer*/, size_t *_length)
static status_t
device_write(void */*data*/, off_t /*pos*/, const void */*buffer*/, size_t *_length)
{
*_length = 0;
*_length = 0;
return B_NOT_ALLOWED;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2006-2008, Haiku, Inc. All Rights Reserved.
* Copyright 2006-2009, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@ -21,6 +21,7 @@
#include <PCI.h>
#include <SupportDefs.h>
#define TRACE_DRIVER
#ifdef TRACE_DRIVER
# define TRACE(x) dprintf x
@ -30,11 +31,12 @@
#define MAX_CARDS 4
// list of supported devices
const struct supported_device {
uint32 device_id;
int32 type;
const char *name;
const char* name;
} kSupportedDevices[] = {
{0x3577, INTEL_TYPE_83x, "i830GM"},
{0x2562, INTEL_TYPE_83x, "i845G"},
@ -59,11 +61,11 @@ const struct supported_device {
int32 api_version = B_CUR_DRIVER_API_VERSION;
char *gDeviceNames[MAX_CARDS + 1];
intel_info *gDeviceInfo[MAX_CARDS];
pci_module_info *gPCI;
agp_gart_module_info *gGART;
lock gLock;
char* gDeviceNames[MAX_CARDS + 1];
intel_info* gDeviceInfo[MAX_CARDS];
pci_module_info* gPCI;
agp_gart_module_info* gGART;
mutex gLock;
static status_t
@ -129,32 +131,27 @@ init_driver(void)
{
TRACE((DEVICE_NAME ": init_driver()\n"));
status_t status = get_module(B_PCI_MODULE_NAME, (module_info **)&gPCI);
status_t status = get_module(B_PCI_MODULE_NAME, (module_info**)&gPCI);
if (status != B_OK) {
TRACE((DEVICE_NAME ": pci module unavailable\n"));
return status;
}
status = get_module(B_AGP_GART_MODULE_NAME, (module_info **)&gGART);
status = get_module(B_AGP_GART_MODULE_NAME, (module_info**)&gGART);
if (status != B_OK) {
TRACE((DEVICE_NAME ": AGP GART module unavailable\n"));
put_module(B_PCI_MODULE_NAME);
return status;
}
status = init_lock(&gLock, "intel extreme ksync");
if (status < B_OK) {
put_module(B_AGP_GART_MODULE_NAME);
put_module(B_PCI_MODULE_NAME);
return status;
}
mutex_init(&gLock, "intel extreme ksync");
// find devices
int32 found = 0;
for (int32 cookie = 0; found < MAX_CARDS;) {
pci_info *info = (pci_info *)malloc(sizeof(pci_info));
pci_info* info = (pci_info*)malloc(sizeof(pci_info));
if (info == NULL)
break;
@ -176,7 +173,7 @@ init_driver(void)
if (gDeviceNames[found] == NULL)
break;
gDeviceInfo[found] = (intel_info *)malloc(sizeof(intel_info));
gDeviceInfo[found] = (intel_info*)malloc(sizeof(intel_info));
if (gDeviceInfo[found] == NULL) {
free(gDeviceNames[found]);
break;
@ -201,7 +198,7 @@ init_driver(void)
gDeviceNames[found] = NULL;
if (found == 0) {
uninit_lock(&gLock);
mutex_destroy(&gLock);
put_module(B_AGP_GART_MODULE_NAME);
put_module(B_PCI_MODULE_NAME);
return ENODEV;
@ -216,10 +213,10 @@ uninit_driver(void)
{
TRACE((DEVICE_NAME ": uninit_driver()\n"));
uninit_lock(&gLock);
mutex_destroy(&gLock);
// free device related structures
char *name;
char* name;
for (int32 index = 0; (name = gDeviceNames[index]) != NULL; index++) {
free(gDeviceInfo[index]);
free(name);
@ -230,8 +227,8 @@ uninit_driver(void)
}
extern "C" device_hooks *
find_device(const char *name)
extern "C" device_hooks*
find_device(const char* name)
{
int index;
@ -245,17 +242,3 @@ find_device(const char *name)
return NULL;
}
/*
extern "C" void
wake_driver(void)
{
// for compatibility with Dano, only
}
extern "C" void
suspend_driver(void)
{
// for compatibility with Dano, only
}
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2006-2008, Haiku, Inc. All Rights Reserved.
* Copyright 2006-2009, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@ -12,37 +12,41 @@
#include <KernelExport.h>
#include <PCI.h>
#include <kernel/lock.h>
#include "intel_extreme_private.h"
// PCI Communications
#define read8(address) (*((volatile uint8 *)(address)))
#define read16(address) (*((volatile uint16 *)(address)))
#define read32(address) (*((volatile uint32 *)(address)))
#define write8(address, data) (*((volatile uint8 *)(address)) = (data))
#define write16(address, data) (*((volatile uint16 *)(address)) = (data))
#define write32(address, data) (*((volatile uint32 *)(address)) = (data))
#define read8(address) (*((volatile uint8*)(address)))
#define read16(address) (*((volatile uint16*)(address)))
#define read32(address) (*((volatile uint32*)(address)))
#define write8(address, data) (*((volatile uint8*)(address)) = (data))
#define write16(address, data) (*((volatile uint16*)(address)) = (data))
#define write32(address, data) (*((volatile uint32*)(address)) = (data))
extern char *gDeviceNames[];
extern intel_info *gDeviceInfo[];
extern pci_module_info *gPCI;
extern agp_gart_module_info *gGART;
extern struct lock gLock;
extern char* gDeviceNames[];
extern intel_info* gDeviceInfo[];
extern pci_module_info* gPCI;
extern agp_gart_module_info* gGART;
extern mutex gLock;
static inline uint32
get_pci_config(pci_info *info, uint8 offset, uint8 size)
get_pci_config(pci_info* info, uint8 offset, uint8 size)
{
return gPCI->read_pci_config(info->bus, info->device, info->function, offset, size);
return gPCI->read_pci_config(info->bus, info->device, info->function,
offset, size);
}
static inline void
set_pci_config(pci_info *info, uint8 offset, uint8 size, uint32 value)
set_pci_config(pci_info* info, uint8 offset, uint8 size, uint32 value)
{
gPCI->write_pci_config(info->bus, info->device, info->function, offset, size, value);
gPCI->write_pci_config(info->bus, info->device, info->function, offset,
size, value);
}
#endif /* DRIVER_H */