Revision bf1b0071

b/hw/acpi_piix4.c
22 22
#include "pci.h"
23 23
#include "acpi.h"
24 24
#include "sysemu.h"
25
#include "range.h"
25 26

  
26 27
//#define DEBUG
27 28

  
b/hw/msix.c
14 14
#include "hw.h"
15 15
#include "msix.h"
16 16
#include "pci.h"
17
#include "range.h"
17 18

  
18 19
/* MSI-X capability structure */
19 20
#define MSIX_TABLE_OFFSET 4
b/hw/pci.c
28 28
#include "sysemu.h"
29 29
#include "loader.h"
30 30
#include "qemu-objects.h"
31
#include "range.h"
31 32

  
32 33
//#define DEBUG_PCI
33 34
#ifdef DEBUG_PCI
b/hw/pci.h
365 365
    return pci_is_express(d) ? PCIE_CONFIG_SPACE_SIZE : PCI_CONFIG_SPACE_SIZE;
366 366
}
367 367

  
368
/* These are not pci specific. Should move into a separate header.
369
 * Only pci.c uses them, so keep them here for now.
370
 */
371

  
372
/* Get last byte of a range from offset + length.
373
 * Undefined for ranges that wrap around 0. */
374
static inline uint64_t range_get_last(uint64_t offset, uint64_t len)
375
{
376
    return offset + len - 1;
377
}
378

  
379
/* Check whether a given range covers a given byte. */
380
static inline int range_covers_byte(uint64_t offset, uint64_t len,
381
                                    uint64_t byte)
382
{
383
    return offset <= byte && byte <= range_get_last(offset, len);
384
}
385

  
386
/* Check whether 2 given ranges overlap.
387
 * Undefined if ranges that wrap around 0. */
388
static inline int ranges_overlap(uint64_t first1, uint64_t len1,
389
                                 uint64_t first2, uint64_t len2)
390
{
391
    uint64_t last1 = range_get_last(first1, len1);
392
    uint64_t last2 = range_get_last(first2, len2);
393

  
394
    return !(last2 < first1 || last1 < first2);
395
}
396

  
397 368
#endif
b/hw/piix_pci.c
28 28
#include "pci_host.h"
29 29
#include "isa.h"
30 30
#include "sysbus.h"
31
#include "range.h"
31 32

  
32 33
/*
33 34
 * I440FX chipset data sheet.
b/hw/vhost.c
13 13
#include <sys/ioctl.h>
14 14
#include "vhost.h"
15 15
#include "hw/hw.h"
16
/* For range_get_last */
17
#include "pci.h"
16
#include "range.h"
18 17
#include <linux/vhost.h>
19 18

  
20 19
static void vhost_dev_sync_region(struct vhost_dev *dev,
b/range.h
1
#ifndef QEMU_RANGE_H
2
#define QEMU_RANGE_H
3

  
4
/* Get last byte of a range from offset + length.
5
 * Undefined for ranges that wrap around 0. */
6
static inline uint64_t range_get_last(uint64_t offset, uint64_t len)
7
{
8
    return offset + len - 1;
9
}
10

  
11
/* Check whether a given range covers a given byte. */
12
static inline int range_covers_byte(uint64_t offset, uint64_t len,
13
                                    uint64_t byte)
14
{
15
    return offset <= byte && byte <= range_get_last(offset, len);
16
}
17

  
18
/* Check whether 2 given ranges overlap.
19
 * Undefined if ranges that wrap around 0. */
20
static inline int ranges_overlap(uint64_t first1, uint64_t len1,
21
                                 uint64_t first2, uint64_t len2)
22
{
23
    uint64_t last1 = range_get_last(first1, len1);
24
    uint64_t last2 = range_get_last(first2, len2);
25

  
26
    return !(last2 < first1 || last1 < first2);
27
}
28

  
29
#endif

Also available in: Unified diff