A few more things to get the USB stack working under BeOS again. We now have
KDEBUG on by default which causes benaphores to always use their semaphore. Therefore when initing the benaphore with the inline compatibility function and then using it using the lock.h provided inline would always cause a deadlock and a hanging system under BeOS. Also we now (re-)define the B_KERNEL_{READ|WRITE}_AREA defines for non Haiku targets to 0 apparently which would probably also cause the stack to misbehave. Therefore they are now just redefined (again) to plain B_{READ|WRITE}_AREA in BeOSCompatibility.h. Change the inclusion order in some places so things work as expected. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24894 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
c4a7b4e09e
commit
017d539c2a
@ -2,10 +2,12 @@
|
||||
#define _USB_BEOS_COMPATIBILITY_H_
|
||||
#ifndef HAIKU_TARGET_PLATFORM_HAIKU
|
||||
|
||||
#include <lock.h>
|
||||
// prevent inclusion of original lock.h as it conflicts with what we have here
|
||||
#define _KERNEL_LOCK_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <OS.h>
|
||||
|
||||
#define IS_USER_ADDRESS(x) (((uint32)x & 0x80000000) > 0)
|
||||
#define IS_KERNEL_ADDRESS(x) (((uint32)x & 0x80000000) == 0)
|
||||
@ -27,6 +29,13 @@ enum {
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct benaphore {
|
||||
sem_id sem;
|
||||
int32 count;
|
||||
} benaphore;
|
||||
|
||||
|
||||
inline status_t
|
||||
benaphore_init(benaphore *ben, const char *name)
|
||||
{
|
||||
@ -50,6 +59,24 @@ benaphore_destroy(benaphore *ben)
|
||||
}
|
||||
|
||||
|
||||
inline status_t
|
||||
benaphore_lock(benaphore *ben)
|
||||
{
|
||||
if (atomic_add(&ben->count, -1) <= 0)
|
||||
return acquire_sem(ben->sem);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
inline status_t
|
||||
benaphore_unlock(benaphore *ben)
|
||||
{
|
||||
if (atomic_add(&ben->count, 1) < 0)
|
||||
return release_sem(ben->sem);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
load_driver_symbols(char *driver)
|
||||
{
|
||||
@ -67,5 +94,10 @@ snprintf(char *buffer, size_t bufferSize, const char *format, ...)
|
||||
return result;
|
||||
}
|
||||
|
||||
#undef B_KERNEL_READ_AREA
|
||||
#define B_KERNEL_READ_AREA B_READ_AREA
|
||||
#undef B_KERNEL_WRITE_AREA
|
||||
#define B_KERNEL_WRITE_AREA B_WRITE_AREA
|
||||
|
||||
#endif // !HAIKU_TARGET_PLATFORM_HAIKU
|
||||
#endif // !_USB_BEOS_COMPATIBILITY_H_
|
||||
|
@ -20,6 +20,7 @@ bus_std_ops(int32 op, ...)
|
||||
{
|
||||
switch (op) {
|
||||
case B_MODULE_INIT: {
|
||||
TRACE(("usb_module: init\n"));
|
||||
if (gUSBStack)
|
||||
return B_OK;
|
||||
|
||||
@ -28,6 +29,7 @@ bus_std_ops(int32 op, ...)
|
||||
if (shared >= B_OK && clone_area("usb stack clone", &address,
|
||||
B_ANY_KERNEL_ADDRESS, B_KERNEL_READ_AREA, shared) >= B_OK) {
|
||||
gUSBStack = *((Stack **)address);
|
||||
TRACE(("usb_module: found shared stack at %p\n", gUSBStack));
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@ -36,9 +38,9 @@ bus_std_ops(int32 op, ...)
|
||||
#ifndef __HAIKU__
|
||||
load_driver_symbols("usb");
|
||||
#endif
|
||||
TRACE(("usb_module: init\n"));
|
||||
#endif
|
||||
Stack *stack = new(std::nothrow) Stack();
|
||||
TRACE(("usb_module: stack created %p\n", stack));
|
||||
if (!stack)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
|
@ -10,9 +10,9 @@
|
||||
#ifndef _USB_P_
|
||||
#define _USB_P_
|
||||
|
||||
#include <lock.h>
|
||||
#include "usbspec_p.h"
|
||||
#include "BeOSCompatibility.h"
|
||||
#include "usbspec_p.h"
|
||||
#include <lock.h>
|
||||
|
||||
|
||||
#ifdef TRACE_USB
|
||||
|
@ -6,14 +6,15 @@
|
||||
* Michael Lotz <mmlr@mlotz.ch>
|
||||
*/
|
||||
|
||||
#include "BeOSCompatibility.h"
|
||||
#include "usb_raw.h"
|
||||
|
||||
#include <KernelExport.h>
|
||||
#include <Drivers.h>
|
||||
#include <lock.h>
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "usb_raw.h"
|
||||
#include "BeOSCompatibility.h"
|
||||
|
||||
//#define TRACE_USB_RAW
|
||||
#ifdef TRACE_USB_RAW
|
||||
|
Loading…
Reference in New Issue
Block a user