diff options
author | Matthieu Herrb <matthieu@herrb.eu> | 2023-06-15 18:10:47 +0200 |
---|---|---|
committer | Matthieu Herrb <matthieu@herrb.eu> | 2023-06-15 18:10:47 +0200 |
commit | fbd4ec4ce9366cddfb6992902613f8b6b271eaad (patch) | |
tree | 5f7c55fc28f1a9f7538591c8a56e01dda70558bc /src | |
parent | df5b7537c47bca97ffb7a65d9571cd813b549256 (diff) | |
parent | 8980a39004b10298a7db1f1b0b711a19e8b73aee (diff) |
Merge remote-tracking branch 'origin/master' into obsd
Diffstat (limited to 'src')
-rw-r--r-- | src/common_device_name.c | 3 | ||||
-rw-r--r-- | src/common_init.c | 4 | ||||
-rw-r--r-- | src/freebsd_pci.c | 61 | ||||
-rw-r--r-- | src/linux_sysfs.c | 4 | ||||
-rw-r--r-- | src/pci_tools.h | 2 | ||||
-rw-r--r-- | src/pciaccess_private.h | 1 |
6 files changed, 12 insertions, 63 deletions
diff --git a/src/common_device_name.c b/src/common_device_name.c index 3dd35d7..912fc51 100644 --- a/src/common_device_name.c +++ b/src/common_device_name.c @@ -80,12 +80,13 @@ typedef FILE * pci_id_file; static pci_id_file pci_id_file_open(void) { -#ifndef __sun pci_id_file result; result = fopen(PCIIDS_PATH "/pci.ids", "re"); if (result) return result; +#ifdef __FreeBSD__ + return fopen("/usr/share/misc/pci_vendors", "re"); #endif return fopen(PCIIDS_PATH "/pci.ids", "r"); 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/linux_sysfs.c b/src/linux_sysfs.c index d62f48c..20c800e 100644 --- a/src/linux_sysfs.c +++ b/src/linux_sysfs.c @@ -462,7 +462,7 @@ pci_device_linux_sysfs_read( struct pci_device * dev, void * data, while ( temp_size > 0 ) { - const ssize_t bytes = pread64( fd, data_bytes, temp_size, offset ); + const ssize_t bytes = pread( fd, data_bytes, temp_size, offset ); /* If zero bytes were read, then we assume it's the end of the * config file. @@ -522,7 +522,7 @@ pci_device_linux_sysfs_write( struct pci_device * dev, const void * data, while ( temp_size > 0 ) { - const ssize_t bytes = pwrite64( fd, data_bytes, temp_size, offset ); + const ssize_t bytes = pwrite( fd, data_bytes, temp_size, offset ); /* If zero bytes were written, then we assume it's the end of the * config file. diff --git a/src/pci_tools.h b/src/pci_tools.h index 47b121f..ad42d66 100644 --- a/src/pci_tools.h +++ b/src/pci_tools.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, Oracle and/or its affiliates. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), 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 ); |