drivers: remove some non-haiku support code.

Change-Id: Ic55bb4832adabeb807f763c87ad938e74fb3a97d
Reviewed-on: https://review.haiku-os.org/520
Reviewed-by: Axel Dörfler <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Jérôme Duval
2018-09-09 17:32:01 +00:00
committed by waddlesplash
parent 24ed1a79a3
commit 21c87a5d83
19 changed files with 27 additions and 171 deletions
@@ -31,19 +31,12 @@
#include <PCI.h>
#include <util/OpenHashTable.h>
#ifdef __HAIKU__
# include <kernel/lock.h>
# include <vm/vm_page.h>
# include <vm/vm_types.h>
#endif
#include <kernel/lock.h>
#include <vm/vm_page.h>
#include <vm/vm_types.h>
#include <lock.h>
#ifndef __HAIKU__
# define PCI_capabilities_ptr 0x34
# define PCI_status_capabilities 0x0010
# define PCI_cap_id_agp 0x02
#endif
#define TRACE_AGP
#ifdef TRACE_AGP
@@ -79,7 +72,7 @@ struct aperture_memory {
addr_t base;
size_t size;
uint32 flags;
#if defined(__HAIKU__) && !defined(GART_TEST)
#if !defined(GART_TEST)
union {
vm_page **pages;
vm_page *page;
@@ -488,7 +481,7 @@ Aperture::CreateMemory(size_t size, size_t alignment, uint32 flags)
", flags %" B_PRIx32 "\n", memory, memory->base, memory->size, flags);
memory->flags = flags;
#if defined(__HAIKU__) && !defined(GART_TEST)
#if !defined(GART_TEST)
memory->pages = NULL;
#else
memory->area = -1;
@@ -537,7 +530,7 @@ Aperture::AllocateMemory(aperture_memory *memory, uint32 flags)
}
TRACE("allocate %ld bytes out of %ld\n", size, memory->size);
#if defined(__HAIKU__) && !defined(GART_TEST)
#if !defined(GART_TEST)
uint32 count = size / B_PAGE_SIZE;
if ((flags & B_APERTURE_NEED_PHYSICAL) != 0) {
@@ -592,7 +585,7 @@ Aperture::AllocateMemory(aperture_memory *memory, uint32 flags)
memory->allocating_thread = find_thread(NULL);
#endif
#else // !__HAIKU__ || GART_TEST
#else // GART_TEST
void *address;
memory->area = create_area("GART memory", &address, B_ANY_KERNEL_ADDRESS,
size, B_FULL_LOCK | ((flags & B_APERTURE_NEED_PHYSICAL) != 0
@@ -644,14 +637,8 @@ Aperture::BindMemory(aperture_memory *memory, addr_t address, size_t size)
if ((memory->flags & ALLOCATED_APERTURE) != 0) {
// We allocated this memory, get the base and size from there
#ifdef __HAIKU__
size = memory->size;
physical = true;
#else
status_t status = get_area_base_and_size(memory->area, address, size);
if (status < B_OK)
return status;
#endif
}
// We don't need to bind reserved memory
@@ -685,7 +672,6 @@ Aperture::BindMemory(aperture_memory *memory, addr_t address, size_t size)
physicalAddress = entry.address;
} else {
#ifdef __HAIKU__
uint32 index = offset >> PAGE_SHIFT;
vm_page *page;
if ((memory->flags & B_APERTURE_NEED_PHYSICAL) != 0)
@@ -695,7 +681,6 @@ Aperture::BindMemory(aperture_memory *memory, addr_t address, size_t size)
physicalAddress
= (phys_addr_t)page->physical_page_number << PAGE_SHIFT;
#endif
}
status = fModule->bind_page(fPrivateAperture, start + offset,
@@ -718,7 +703,7 @@ Aperture::_Free(aperture_memory *memory)
if ((memory->flags & ALLOCATED_APERTURE) == 0)
return;
#if defined(__HAIKU__) && !defined(GART_TEST)
#if !defined(GART_TEST)
// Remove the stolen area from the allocation
size_t size = memory->size;
addr_t reservedEnd = fInfo.base + fInfo.reserved_size;
@@ -1068,7 +1053,7 @@ allocate_memory(aperture_id id, size_t size, size_t alignment, uint32 flags,
}
if (_physicalBase != NULL && (flags & B_APERTURE_NEED_PHYSICAL) != 0) {
#if defined(__HAIKU__) && !defined(GART_TEST)
#if !defined(GART_TEST)
*_physicalBase
= (phys_addr_t)memory->page->physical_page_number * B_PAGE_SIZE;
#else
@@ -68,12 +68,10 @@ PhysicalMemoryAllocator::PhysicalMemoryAllocator(const char *name,
fManagedMemory = fBlockSize[0] * fArrayLength[0];
size_t roundedSize = biggestSize * minCountPerBlock;
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
fDebugBase = roundedSize;
fDebugChunkSize = 128;
fDebugUseMap = 0;
roundedSize += sizeof(fDebugUseMap) * 8 * fDebugChunkSize;
#endif
roundedSize = (roundedSize + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1);
fArea = create_area(fName, &fLogicalBase, B_ANY_KERNEL_ADDRESS,
@@ -133,7 +131,6 @@ status_t
PhysicalMemoryAllocator::Allocate(size_t size, void **logicalAddress,
phys_addr_t *physicalAddress)
{
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
if (debug_debugger_running()) {
if (size > fDebugChunkSize) {
kprintf("usb allocation of %" B_PRIuSIZE
@@ -156,7 +153,6 @@ PhysicalMemoryAllocator::Allocate(size_t size, void **logicalAddress,
return B_NO_MEMORY;
}
#endif
if (size == 0 || size > fBlockSize[fArrayCount - 1]) {
TRACE_ERROR(("PMA: bad value for allocate (%ld bytes)\n", size));
@@ -242,14 +238,12 @@ status_t
PhysicalMemoryAllocator::Deallocate(size_t size, void *logicalAddress,
phys_addr_t physicalAddress)
{
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
if (debug_debugger_running()) {
uint32 index = ((uint8 *)logicalAddress - (uint8 *)fLogicalBase
- fDebugBase) / fDebugChunkSize;
fDebugUseMap &= ~(1LL << index);
return B_OK;
}
#endif
if (size == 0 || size > fBlockSize[fArrayCount - 1]) {
TRACE_ERROR(("PMA: bad value for deallocate (%ld bytes)\n", size));
@@ -5,10 +5,10 @@
* Authors:
* Michael Lotz <[email protected]>
*/
#ifndef _PHYSICAL_MEMORY_ALLOCATOR_H_
#define _PHYSICAL_MEMORY_ALLOCATOR_H_
#include <condition_variable.h>
#include <SupportDefs.h>
#include <lock.h>
@@ -62,11 +62,9 @@ private:
ConditionVariable fNoMemoryCondition;
uint32 fMemoryWaitersCount;
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
uint32 fDebugBase;
uint32 fDebugChunkSize;
uint64 fDebugUseMap;
#endif
};
#endif // !_PHYSICAL_MEMORY_ALLOCATOR_H_
+3 -10
View File
@@ -7,15 +7,15 @@
* Niels S. Reedijk
*/
#include <module.h>
#include <unistd.h>
#include <util/kernel_cpp.h>
#include "usb_private.h"
#include "PhysicalMemoryAllocator.h"
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
#include <fs/devfs.h>
#endif
Stack::Stack()
: fExploreThread(-1),
@@ -389,15 +389,8 @@ Stack::RescanDrivers(rescan_item *rescanItem)
// scan for supported devices or its publish_devices hook will be
// called to expose changed devices.
#ifndef HAIKU_TARGET_PLATFORM_HAIKU
// the R5 way to republish a device in devfs
int devFS = open("/dev", O_WRONLY);
write(devFS, rescanItem->name, strlen(rescanItem->name));
close(devFS);
#else
// use the private devfs API under Haiku
// use the private devfs API to republish a device
devfs_rescan_driver(rescanItem->name);
#endif
rescan_item *next = rescanItem->link;
delete rescanItem;
@@ -7,11 +7,11 @@
* Niels S. Reedijk
*/
#include "usb_private.h"
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
#include <kernel.h>
#endif
#include <kernel.h>
Transfer::Transfer(Pipe *pipe)
: fPipe(pipe),
+1 -32
View File
@@ -7,6 +7,7 @@
* Niels S. Reedijk
*/
#include <util/kernel_cpp.h>
#include "usb_private.h"
#include <USB_rle.h>
@@ -16,7 +17,6 @@
Stack *gUSBStack = NULL;
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
/*! The function is an evil hack to allow <tt> <kdebug>usb_keyboard </tt> to
execute transfers.
When invoked the first time, a new transfer is started, each time the
@@ -137,7 +137,6 @@ debug_clear_stall(int argc, char *argv[])
return B_TIMED_OUT;
}
#endif
static int32
@@ -149,27 +148,8 @@ bus_std_ops(int32 op, ...)
if (gUSBStack)
return B_OK;
#ifdef HAIKU_TARGET_PLATFORM_BEOS
// This code is to handle plain R5 (non-BONE) where the same module
// gets loaded multiple times (once for each exported module
// interface, the USB v2 and v3 API in our case). We don't want to
// ever create multiple stacks however, so we "share" the same stack
// for both modules by storing it's address in a shared area.
void *address = NULL;
area_id shared = find_area("shared usb stack");
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_MODULE("found shared stack at %p\n", gUSBStack);
return B_OK;
}
#endif
#ifdef TRACE_USB
set_dprintf_enabled(true);
#ifndef HAIKU_TARGET_PLATFORM_HAIKU
load_driver_symbols("usb");
#endif
#endif
Stack *stack = new(std::nothrow) Stack();
TRACE_MODULE("usb_module: stack created %p\n", stack);
@@ -183,7 +163,6 @@ bus_std_ops(int32 op, ...)
gUSBStack = stack;
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
add_debugger_command("get_usb_pipe_for_id",
&debug_get_pipe_for_id,
"Sets _usbPipe by resolving _usbPipeID");
@@ -195,14 +174,6 @@ bus_std_ops(int32 op, ...)
&debug_clear_stall,
"Tries to issue a clear feature request for the endpoint halt"
" feature on pipe _usbPipe");
#elif HAIKU_TARGET_PLATFORM_BEOS
// Plain R5 workaround, see comment above.
shared = create_area("shared usb stack", &address,
B_ANY_KERNEL_ADDRESS, B_PAGE_SIZE, B_NO_LOCK,
B_KERNEL_WRITE_AREA);
if (shared >= B_OK)
*((Stack **)address) = gUSBStack;
#endif
break;
}
@@ -211,10 +182,8 @@ bus_std_ops(int32 op, ...)
delete gUSBStack;
gUSBStack = NULL;
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
remove_debugger_command("get_usb_pipe_for_id",
&debug_get_pipe_for_id);
#endif
break;
default:
@@ -32,10 +32,6 @@
#endif
#define ERROR(x...) dprintf("intel_gart: " x)
#ifndef __HAIKU__
# define B_KERNEL_READ_AREA 0
# define B_KERNEL_WRITE_AREA 0
#endif
/* read and write to PCI config space */
#define get_pci_config(info, offset, size) \
-3
View File
@@ -1155,9 +1155,6 @@ EHCI::AddTo(Stack *stack)
{
#ifdef TRACE_USB
set_dprintf_enabled(true);
#ifndef HAIKU_TARGET_PLATFORM_HAIKU
load_driver_symbols("ehci");
#endif
#endif
if (!sPCIModule) {
-3
View File
@@ -584,9 +584,6 @@ OHCI::AddTo(Stack *stack)
{
#ifdef TRACE_USB
set_dprintf_enabled(true);
#ifndef HAIKU_TARGET_PLATFORM_HAIKU
load_driver_symbols("ohci");
#endif
#endif
if (!sPCIModule) {
-3
View File
@@ -1864,9 +1864,6 @@ UHCI::AddTo(Stack *stack)
{
#ifdef TRACE_USB
set_dprintf_enabled(true);
#ifndef HAIKU_TARGET_PLATFORM_HAIKU
load_driver_symbols("uhci");
#endif
#endif
if (!sPCIModule) {
+2 -12
View File
@@ -17,24 +17,14 @@
#include <string.h>
#include <stdlib.h>
#ifndef HAIKU_TARGET_PLATFORM_HAIKU
# define DEVFS_PATH_FORMAT "audio/multi/hda/%lu"
# include <multi_audio.h>
#else
# define DEVFS_PATH_FORMAT "audio/hmulti/hda/%lu"
# include <hmulti_audio.h>
#endif
#define DEVFS_PATH_FORMAT "audio/hmulti/hda/%lu"
#include <hmulti_audio.h>
#include "hda_controller_defs.h"
#include "hda_codec_defs.h"
#define MAX_CARDS 4
/* values for the class_sub field for class_base = 0x04 (multimedia device) */
#ifndef __HAIKU__
# define PCI_hd_audio 3
#endif
#define HDA_MAX_AUDIO_GROUPS 15
#define HDA_MAX_CODECS 15
#define HDA_MAX_STREAMS 16
@@ -1460,7 +1460,6 @@ usb_disk_ioctl(void *cookie, uint32 op, void *buffer, size_t length)
NULL, NULL, false);
break;
#if HAIKU_TARGET_PLATFORM_HAIKU
case B_GET_ICON:
// We don't support this legacy ioctl anymore, but the two other
// icon ioctls below instead.
@@ -1571,7 +1570,6 @@ usb_disk_ioctl(void *cookie, uint32 op, void *buffer, size_t length)
strerror(result));
break;
}
#endif
default:
TRACE_ALWAYS("unhandled ioctl %" B_PRId32 "\n", op);
@@ -1115,7 +1115,6 @@ usb_disk_ioctl(void *cookie, uint32 op, void *buffer, size_t length)
break;
}
#if HAIKU_TARGET_PLATFORM_HAIKU
case B_GET_ICON:
// We don't support this legacy ioctl anymore, but the two other
// icon ioctls below instead.
@@ -1170,7 +1169,6 @@ usb_disk_ioctl(void *cookie, uint32 op, void *buffer, size_t length)
TRACE_ALWAYS("got device name: \"%s\" = %s\n", name, strerror(result));
break;
}
#endif
default:
TRACE_ALWAYS("unhandled ioctl %" B_PRIu32 "\n", op);
@@ -51,13 +51,8 @@ createGARTBuffer(GART_info *gart, size_t size)
gart->buffer.area = create_area("Radeon PCI GART buffer",
&gart->buffer.ptr, B_ANY_KERNEL_ADDRESS,
size, B_FULL_LOCK,
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
// TODO: really user read/write?
B_READ_AREA | B_WRITE_AREA | B_USER_CLONEABLE_AREA
#else
0
#endif
);
B_READ_AREA | B_WRITE_AREA | B_USER_CLONEABLE_AREA);
if (gart->buffer.area < 0) {
SHOW_ERROR(1, "cannot create PCI GART buffer (%s)",
strerror(gart->buffer.area));
@@ -155,13 +150,8 @@ static status_t initGATT( GART_info *gart )
B_32_BIT_CONTIGUOUS,
// TODO: Physical address is cast to 32 bit below! Use B_CONTIGUOUS,
// when that is (/can be) fixed!
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
// TODO: really user read/write?
B_READ_AREA | B_WRITE_AREA | B_USER_CLONEABLE_AREA
#else
0
#endif
);
B_READ_AREA | B_WRITE_AREA | B_USER_CLONEABLE_AREA);
if (gart->GATT.area < 0) {
SHOW_ERROR(1, "cannot create GATT table (%s)",
@@ -75,11 +75,7 @@ status_t Radeon_MapDevice( device_info *di, bool mmio_only )
B_ANY_KERNEL_ADDRESS,
/*// for "poke" debugging
B_READ_AREA + B_WRITE_AREA*/
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA | B_USER_CLONEABLE_AREA,
#else
0,
#endif
(void **)&(di->regs));
if( si->regs_area < 0 )
return si->regs_area;
@@ -217,12 +213,7 @@ status_t Radeon_FirstOpen( device_info *di )
B_ANY_KERNEL_ADDRESS,
(sizeof(shared_info) + (B_PAGE_SIZE - 1)) & ~(B_PAGE_SIZE - 1),
B_FULL_LOCK,
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA | B_USER_CLONEABLE_AREA
#else
0
#endif
);
B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA | B_USER_CLONEABLE_AREA);
if (di->shared_area < 0) {
result = di->shared_area;
goto err8;
@@ -289,12 +280,7 @@ status_t Radeon_FirstOpen( device_info *di )
B_ANY_KERNEL_ADDRESS,
(sizeof(virtual_card) + (B_PAGE_SIZE - 1)) & ~(B_PAGE_SIZE - 1),
B_FULL_LOCK,
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA | B_USER_CLONEABLE_AREA
#else
0
#endif
);
B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA | B_USER_CLONEABLE_AREA);
if (di->virtual_card_area < 0) {
result = di->virtual_card_area;
goto err7;
@@ -24,9 +24,7 @@
#include <fcntl.h>
#include <string.h>
#include <driver_settings.h>
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
#include <net/if_media.h>
#endif
#include <net/if_media.h>
#include "debug.h"
@@ -423,10 +421,8 @@ rtl8169_get_link_state(rtl8169_device *device)
device->full_duplex = full_duplex;
device->speed = speed;
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
if (linkStateChange && device->linkChangeSem >= B_OK)
release_sem_etc(device->linkChangeSem, 1, B_DO_NOT_RESCHEDULE);
#endif
return B_OK;
}
@@ -620,9 +616,7 @@ rtl8169_open(const char *name, uint32 flags, void** cookie)
// configure PHY
phy_config(device);
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
device->linkChangeSem = -1;
#endif
rtl8169_get_link_state(device);
@@ -966,7 +960,6 @@ rtl8169_control(void *cookie, uint32 op, void *arg, size_t len)
*(uint32*)arg = device->maxframesize;
return B_OK;
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
case ETHER_GET_LINK_STATE:
{
ether_link_state_t state;
@@ -995,7 +988,6 @@ rtl8169_control(void *cookie, uint32 op, void *arg, size_t len)
}
return B_OK;
}
#endif
default:
TRACE("rtl8169_control() Invalid command\n");
@@ -97,9 +97,7 @@ typedef struct {
uint32 speed;
bool full_duplex;
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
sem_id linkChangeSem;
#endif
} rtl8169_device;
@@ -16,9 +16,7 @@
#include <stdlib.h>
#include <string.h>
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
# include <net/if_media.h>
#endif
#include <net/if_media.h>
/* device hooks prototypes */
@@ -384,7 +382,6 @@ device_ioctl(void *data, uint32 msg, void *buffer, size_t bufferLength)
/* not yet implemented */
break;
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
case ETHER_GET_LINK_STATE:
{
ether_link_state_t state;
@@ -397,7 +394,6 @@ device_ioctl(void *data, uint32 msg, void *buffer, size_t bufferLength)
return user_memcpy(buffer, &state, sizeof(ether_link_state_t));
}
#endif
default:
TRACE(("ioctl: unknown message %lu (length = %ld)\n", msg, bufferLength));
@@ -425,14 +421,8 @@ device_read(void *data, off_t pos, void *buffer, size_t *_length)
uint32 check;
int16 current;
if (checkDeviceInfo(info = data) != B_OK) {
#ifndef __HAIKU__
*_length = 0;
// net_server work-around; it obviously doesn't care about error conditions
// For Haiku, this can be removed
#endif
if (checkDeviceInfo(info = data) != B_OK)
return B_BAD_VALUE;
}
blockFlag = info->blockFlag;
@@ -440,20 +430,13 @@ device_read(void *data, off_t pos, void *buffer, size_t *_length)
info->rxInterruptIndex, info->rxFree, info->rxCurrent, blockFlag));
// read is not reentrant
if (atomic_or(&info->rxLock, 1)) {
#ifndef __HAIKU__
*_length = 0;
#endif
if (atomic_or(&info->rxLock, 1))
return B_ERROR;
}
// block until data is available (if blocking is allowed)
if ((status = acquire_sem_etc(info->rxSem, 1, B_CAN_INTERRUPT | blockFlag, 0)) != B_NO_ERROR) {
TRACE(("cannot acquire read sem: %lx, %s\n", status, strerror(status)));
atomic_and(&info->rxLock, 0);
#ifndef __HAIKU__
*_length = 0;
#endif
return status;
}
@@ -464,9 +447,6 @@ device_read(void *data, off_t pos, void *buffer, size_t *_length)
if (!(check & SiS900_DESCR_OWN)) { // the buffer is still in use!
TRACE(("ERROR: read: buffer %d still in use: %lx\n", current, status));
atomic_and(&info->rxLock, 0);
#ifndef __HAIKU__
*_length = 0;
#endif
return B_BUSY;
}
@@ -272,7 +272,6 @@ ECMDevice::Control(uint32 op, void *buffer, size_t length)
*(uint32 *)buffer = fMaxSegmentSize;
return B_OK;
#if HAIKU_TARGET_PLATFORM_HAIKU
case ETHER_SET_LINK_STATE_SEM:
fLinkStateChangeSem = *(sem_id *)buffer;
return B_OK;
@@ -286,7 +285,6 @@ ECMDevice::Control(uint32 op, void *buffer, size_t length)
state->speed = fDownstreamSpeed;
return B_OK;
}
#endif
default:
TRACE_ALWAYS("unsupported ioctl %" B_PRIu32 "\n", op);