From e6a9c2dc9d22a6f5460fcad2863a6a6056e23a8e Mon Sep 17 00:00:00 2001 From: Emmanuel Vadot Date: Fri, 24 Mar 2023 11:33:16 +0100 Subject: FreeBSD: Remove sparc64 code FreeBSD stopped supporting sparc64 a while ago, no need to keep the code. Signed-off-by: Emmanuel Vadot --- src/common_init.c | 4 +--- src/freebsd_pci.c | 61 +++++-------------------------------------------- src/pciaccess_private.h | 1 - 3 files changed, 7 insertions(+), 59 deletions(-) diff --git a/src/common_init.c b/src/common_init.c index 1940cff..1004038 100644 --- a/src/common_init.c +++ b/src/common_init.c @@ -79,9 +79,7 @@ pci_system_init( void ) void pci_system_init_dev_mem(int fd) { -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) - pci_system_freebsd_init_dev_mem(fd); -#elif defined(__OpenBSD__) +#if defined(__OpenBSD__) pci_system_openbsd_init_dev_mem(fd); #endif } diff --git a/src/freebsd_pci.c b/src/freebsd_pci.c index 709bfb6..f7aed43 100644 --- a/src/freebsd_pci.c +++ b/src/freebsd_pci.c @@ -82,10 +82,6 @@ #define PCIM_BAR_MEM_SPACE 0 #define PCIM_BAR_IO_SPACE 1 -#if defined(__sparc64__) -static int screenfd; -#endif - /** * FreeBSD private pci_system structure that extends the base pci_system * structure. @@ -117,18 +113,12 @@ pci_device_freebsd_map_range( struct pci_device *dev, { const int prot = ((map->flags & PCI_DEV_MAP_FLAG_WRITABLE) != 0) ? (PROT_READ | PROT_WRITE) : PROT_READ; -#if !defined(__sparc64__) struct mem_range_desc mrd; struct mem_range_op mro; -#endif int fd, err = 0; -#if defined(__sparc64__) - fd = screenfd; -#else fd = open("/dev/mem", O_RDWR | O_CLOEXEC); -#endif if (fd == -1) return errno; @@ -138,7 +128,6 @@ pci_device_freebsd_map_range( struct pci_device *dev, err = errno; } -#if !defined(__sparc64__) mrd.mr_base = map->base; mrd.mr_len = map->size; strncpy(mrd.mr_owner, "pciaccess", sizeof(mrd.mr_owner)); @@ -159,7 +148,6 @@ pci_device_freebsd_map_range( struct pci_device *dev, } close(fd); -#endif return err; } @@ -168,7 +156,6 @@ static int pci_device_freebsd_unmap_range( struct pci_device *dev, struct pci_device_mapping *map ) { -#if !defined(__sparc64__) struct mem_range_desc mrd; struct mem_range_op mro; int fd; @@ -194,7 +181,6 @@ pci_device_freebsd_unmap_range( struct pci_device *dev, fprintf(stderr, "Failed to open /dev/mem\n"); } } -#endif return pci_device_generic_unmap_range(dev, map); } @@ -313,11 +299,7 @@ pci_device_freebsd_read_rom( struct pci_device * dev, void * buffer ) } printf("Using rom_base = 0x%lx\n", (long)rom_base); -#if defined(__sparc64__) - memfd = screenfd; -#else memfd = open( "/dev/mem", O_RDONLY | O_CLOEXEC ); -#endif if ( memfd == -1 ) return errno; @@ -330,9 +312,7 @@ pci_device_freebsd_read_rom( struct pci_device * dev, void * buffer ) memcpy( buffer, bios, dev->rom_size ); munmap( bios, dev->rom_size ); -#if !defined(__sparc64__) close( memfd ); -#endif if (pci_rom) { pci_device_cfg_write_u32( dev, PCIR_BIOS, rom ); @@ -444,16 +424,9 @@ pci_device_freebsd_open_legacy_io( struct pci_io_handle *ret, struct pci_device *dev, pciaddr_t base, pciaddr_t size ) { -#if defined(__sparc64__) - ret->memory = mmap( NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, - screenfd, base ); - if ( ret->memory == MAP_FAILED ) - return NULL; -#else ret->fd = open( "/dev/io", O_RDWR | O_CLOEXEC ); if ( ret->fd < 0 ) return NULL; -#endif ret->base = base; ret->size = size; ret->is_legacy = 1; @@ -475,18 +448,14 @@ static void pci_device_freebsd_close_io( struct pci_device *dev, struct pci_io_handle *handle ) { -#if !defined(__sparc64__) if ( handle->fd > -1 ) close( handle->fd ); -#endif } static uint32_t pci_device_freebsd_read32( struct pci_io_handle *handle, uint32_t reg ) { -#if defined(__sparc64__) - return *(uint32_t *)((uintptr_t)handle->memory + reg); -#elif defined(__i386__) || defined(__amd64__) +#if defined(__i386__) || defined(__amd64__) return inl( handle->base + reg ); #else struct iodev_pio_req req = { IODEV_PIO_READ, handle->base + reg, 4, 0 }; @@ -499,9 +468,7 @@ pci_device_freebsd_read32( struct pci_io_handle *handle, uint32_t reg ) static uint16_t pci_device_freebsd_read16( struct pci_io_handle *handle, uint32_t reg ) { -#if defined(__sparc64__) - return *(uint16_t *)((uintptr_t)handle->memory + reg); -#elif defined(__i386__) || defined(__amd64__) +#if defined(__i386__) || defined(__amd64__) return inw( handle->base + reg ); #else struct iodev_pio_req req = { IODEV_PIO_READ, handle->base + reg, 2, 0 }; @@ -514,9 +481,7 @@ pci_device_freebsd_read16( struct pci_io_handle *handle, uint32_t reg ) static uint8_t pci_device_freebsd_read8( struct pci_io_handle *handle, uint32_t reg ) { -#if defined(__sparc64__) - return *(uint8_t *)((uintptr_t)handle->memory + reg); -#elif defined(__i386__) || defined(__amd64__) +#if defined(__i386__) || defined(__amd64__) return inb( handle->base + reg ); #else struct iodev_pio_req req = { IODEV_PIO_READ, handle->base + reg, 1, 0 }; @@ -530,9 +495,7 @@ static void pci_device_freebsd_write32( struct pci_io_handle *handle, uint32_t reg, uint32_t data ) { -#if defined(__sparc64__) - *(uint32_t *)((uintptr_t)handle->memory + reg) = data; -#elif defined(__i386__) || defined(__amd64__) +#if defined(__i386__) || defined(__amd64__) outl( handle->base + reg, data ); #else struct iodev_pio_req req = { IODEV_PIO_WRITE, handle->base + reg, 4, data }; @@ -545,9 +508,7 @@ static void pci_device_freebsd_write16( struct pci_io_handle *handle, uint32_t reg, uint16_t data ) { -#if defined(__sparc64__) - *(uint16_t *)((uintptr_t)handle->memory + reg) = data; -#elif defined(__i386__) || defined(__amd64__) +#if defined(__i386__) || defined(__amd64__) outw( handle->base + reg, data ); #else struct iodev_pio_req req = { IODEV_PIO_WRITE, handle->base + reg, 2, data }; @@ -560,9 +521,7 @@ static void pci_device_freebsd_write8( struct pci_io_handle *handle, uint32_t reg, uint8_t data ) { -#if defined(__sparc64__) - *(uint8_t *)((uintptr_t)handle->memory + reg) = data; -#elif defined(__i386__) || defined(__amd64__) +#if defined(__i386__) || defined(__amd64__) outb( handle->base + reg, data ); #else struct iodev_pio_req req = { IODEV_PIO_WRITE, handle->base + reg, 1, data }; @@ -699,11 +658,3 @@ pci_system_freebsd_create( void ) return 0; } - -void -pci_system_freebsd_init_dev_mem(int fd) -{ -#if defined(__sparc64__) - screenfd = fd; -#endif -} diff --git a/src/pciaccess_private.h b/src/pciaccess_private.h index be5d15d..078b7be 100644 --- a/src/pciaccess_private.h +++ b/src/pciaccess_private.h @@ -192,7 +192,6 @@ extern struct pci_system * pci_sys; extern int pci_system_linux_sysfs_create( void ); extern int pci_system_freebsd_create( void ); -extern void pci_system_freebsd_init_dev_mem( int ); extern int pci_system_netbsd_create( void ); extern int pci_system_openbsd_create( void ); extern void pci_system_openbsd_init_dev_mem( int ); -- cgit v1.2.3