USB: Remove BeOSCompatibility.h and associated cruft.

This commit is contained in:
Augustin Cavalier 2018-08-07 17:57:23 -04:00
parent 1a3a613584
commit ce0ef8c870
9 changed files with 3 additions and 290 deletions

View File

@ -1,212 +0,0 @@
#ifndef _USB_BEOS_COMPATIBILITY_H_
#define _USB_BEOS_COMPATIBILITY_H_
#ifndef HAIKU_TARGET_PLATFORM_HAIKU
// 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)
#define B_SPINLOCK_INITIALIZER 0
#define PCI_usb_ehci 0x20
#ifndef HAIKU_TARGET_PLATFORM_DANO
enum {
B_DEV_INVALID_PIPE = B_DEV_DOOR_OPEN + 1,
B_DEV_CRC_ERROR,
B_DEV_STALLED,
B_DEV_BAD_PID,
B_DEV_UNEXPECTED_PID,
B_DEV_DATA_OVERRUN,
B_DEV_DATA_UNDERRUN,
B_DEV_FIFO_OVERRUN,
B_DEV_FIFO_UNDERRUN,
B_DEV_PENDING,
B_DEV_MULTIPLE_ERRORS,
B_DEV_TOO_LATE,
};
#endif
// wrong, but it won't change for BeOS anymore
typedef uint32 addr_t;
typedef struct mutex {
sem_id sem;
int32 count;
} mutex;
inline status_t
mutex_init(mutex *ben, const char *name)
{
if (ben == NULL || name == NULL)
return B_BAD_VALUE;
ben->count = 1;
ben->sem = create_sem(0, name);
if (ben->sem >= B_OK)
return B_OK;
return ben->sem;
}
#define MUTEX_FLAG_CLONE_NAME 1
inline status_t
mutex_init_etc(mutex *ben, const char *name, int32 flags)
{
return mutex_init(ben, name);
}
inline void
mutex_destroy(mutex *ben)
{
delete_sem(ben->sem);
ben->sem = -1;
}
inline status_t
mutex_lock(mutex *ben)
{
if (atomic_add(&ben->count, -1) <= 0)
return acquire_sem(ben->sem);
return B_OK;
}
inline status_t
mutex_unlock(mutex *ben)
{
if (atomic_add(&ben->count, 1) < 0)
return release_sem(ben->sem);
return B_OK;
}
class ConditionVariableEntry {
public:
ConditionVariableEntry()
: fSem(-1)
{
}
~ConditionVariableEntry()
{
if (fSem >= 0)
delete_sem(fSem);
}
sem_id Added()
{
if (fSem < 0)
fSem = create_sem(0, "condvar entry");
return fSem;
}
status_t Wait(uint32 flags, bigtime_t timeout)
{
return acquire_sem_etc(fSem, 1, flags, timeout);
}
private:
sem_id fSem;
};
class ConditionVariable {
public:
ConditionVariable()
: fObject(NULL),
fName("condvar"),
fSemCount(0)
{
}
void Init(void *object, const char *name)
{
fObject = object;
fName = name;
}
void Add(ConditionVariableEntry *entry)
{
fSems[fSemCount++] = entry->Added();
}
void NotifyAll()
{
int32 semCount = fSemCount;
sem_id sems[semCount];
memcpy(sems, fSems, sizeof(sem_id) * semCount);
fSemCount = 0;
for (int32 i = 0; i < semCount; i++)
release_sem(sems[i]);
}
private:
void * fObject;
const char *fName;
sem_id fSems[30];
int32 fSemCount;
};
inline void
load_driver_symbols(char *driver)
{
/* nothing */
}
inline int
snprintf(char *buffer, size_t bufferSize, const char *format, ...)
{
va_list args;
va_start(args, format);
int result = vsprintf(buffer, format, args);
va_end(args);
return result;
}
inline int32
atomic_get(vint32 *value)
{
return atomic_or(value, 0);
}
inline int32
atomic_set(vint32 *value, int32 setValue)
{
int32 result = atomic_and(value, 0);
int32 previous = atomic_add(value, setValue);
if (previous != 0)
result = previous;
return result;
}
inline status_t
user_memcpy(void *target, void *source, size_t length)
{
memcpy(target, source, length);
return B_OK;
}
#undef B_KERNEL_READ_AREA
#define B_KERNEL_READ_AREA 0
#undef B_KERNEL_WRITE_AREA
#define B_KERNEL_WRITE_AREA 0
#endif // !HAIKU_TARGET_PLATFORM_HAIKU
#endif // !_USB_BEOS_COMPATIBILITY_H_

View File

@ -4,9 +4,6 @@ SetSubDirSupportedPlatformsBeOSCompatible ;
SubDirC++Flags -fno-rtti ;
local compatSources ;
SubDirSysHdrs $(SUBDIR) ;
UsePrivateKernelHeaders ;
KernelStaticLibrary libusb.a :
@ -19,7 +16,6 @@ KernelStaticLibrary libusb.a :
Interface.cpp
Object.cpp
PhysicalMemoryAllocator.cpp
$(compatSources)
;
KernelAddon usb :
@ -27,6 +23,3 @@ KernelAddon usb :
: libusb.a
: usb.rdef
;
SEARCH on [ FGristFiles $(compatSources) ]
= [ FDirName $(HAIKU_TOP) src system kernel util ] ;

View File

@ -11,7 +11,7 @@
#include <KernelExport.h>
#include <SupportDefs.h>
#include <util/kernel_cpp.h>
#include "BeOSCompatibility.h"
#include "PhysicalMemoryAllocator.h"

View File

@ -9,7 +9,6 @@
#ifndef _USB_PRIVATE_H
#define _USB_PRIVATE_H
#include "BeOSCompatibility.h"
#include "usbspec_private.h"
#include <lock.h>
#include <util/Vector.h>

View File

@ -2,7 +2,6 @@ SubDir HAIKU_TOP src add-ons kernel drivers bus usb ;
SetSubDirSupportedPlatformsBeOSCompatible ;
SubDirSysHdrs $(HAIKU_TOP) src add-ons kernel bus_managers usb ;
UsePrivateKernelHeaders ;
KernelAddon usb_raw :

View File

@ -6,7 +6,6 @@
* Michael Lotz <mmlr@mlotz.ch>
*/
#include "BeOSCompatibility.h"
#include "usb_raw.h"
#include <KernelExport.h>
@ -883,7 +882,7 @@ usb_raw_write(void *cookie, off_t position, const void *buffer, size_t *length)
//
status_t
status_t
init_hardware()
{
TRACE((DRIVER_NAME": init_hardware()\n"));

View File

@ -1,59 +0,0 @@
/*
Driver for USB Ethernet Control Model devices
Copyright (C) 2008 Michael Lotz <mmlr@mlotz.ch>
Distributed under the terms of the MIT license.
*/
#ifndef HAIKU_TARGET_PLATFORM_HAIKU
#ifndef _BEOS_COMPATIBILITY_H_
#define _BEOS_COMPATIBILITY_H_
#include <OS.h>
#define USB_ENDPOINT_ATTR_CONTROL 0x00
#define USB_ENDPOINT_ATTR_ISOCHRONOUS 0x01
#define USB_ENDPOINT_ATTR_BULK 0x02
#define USB_ENDPOINT_ATTR_INTERRUPT 0x03
#define USB_ENDPOINT_ATTR_MASK 0x03
#define USB_ENDPOINT_ADDR_DIR_IN 0x80
#define USB_ENDPOINT_ADDR_DIR_OUT 0x00
typedef struct mutex {
sem_id sem;
int32 count;
} mutex;
static inline void
mutex_init(mutex *lock, const char *name)
{
lock->sem = create_sem(0, name);
lock->count = 0;
}
static inline void
mutex_destroy(mutex *lock)
{
delete_sem(lock->sem);
}
static inline status_t
mutex_lock(mutex *lock)
{
if (atomic_add(&lock->count, -1) < 0)
return acquire_sem(lock->sem);
return B_OK;
}
static inline void
mutex_unlock(mutex *lock)
{
if (atomic_add(&lock->count, 1) < -1)
release_sem(lock->sem);
}
#endif /* !HAIKU_TARGET_PLATFORM_HAIKU */
#endif /* _BEOS_COMPATIBILITY_H_ */

View File

@ -6,12 +6,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
#include <lock.h> // for mutex
#else
#include "BeOSCompatibility.h" // for pseudo mutex
#endif
#include <lock.h>
#include "Driver.h"
#include "ECMDevice.h"

View File

@ -8,7 +8,6 @@
#include <string.h>
#include <stdlib.h>
#include "BeOSCompatibility.h"
#include "ECMDevice.h"
#include "Driver.h"