Revision f49db805
b/hw/pci.h | ||
---|---|---|
406 | 406 |
PCIBus *sh_pci_register_bus(pci_set_irq_fn set_irq, pci_map_irq_fn map_irq, |
407 | 407 |
void *pic, int devfn_min, int nirq); |
408 | 408 |
|
409 |
/* These are not pci specific. Should move into a separate header. |
|
410 |
* Only pci.c uses them, so keep them here for now. |
|
411 |
*/ |
|
412 |
|
|
413 |
/* Get last byte of a range from offset + length. |
|
414 |
* Undefined for ranges that wrap around 0. */ |
|
415 |
static inline uint64_t range_get_last(uint64_t offset, uint64_t len) |
|
416 |
{ |
|
417 |
return offset + len - 1; |
|
418 |
} |
|
419 |
|
|
420 |
/* Check whether a given range covers a given byte. */ |
|
421 |
static inline int range_covers_byte(uint64_t offset, uint64_t len, |
|
422 |
uint64_t byte) |
|
423 |
{ |
|
424 |
return offset <= byte && byte <= range_get_last(offset, len); |
|
425 |
} |
|
426 |
|
|
427 |
/* Check whether 2 given ranges overlap. |
|
428 |
* Undefined if ranges that wrap around 0. */ |
|
429 |
static inline int ranges_overlap(uint64_t first1, uint64_t len1, |
|
430 |
uint64_t first2, uint64_t len2) |
|
431 |
{ |
|
432 |
uint64_t last1 = range_get_last(first1, len1); |
|
433 |
uint64_t last2 = range_get_last(first2, len2); |
|
434 |
|
|
435 |
return !(last2 < first1 || last1 < first2); |
|
436 |
} |
|
437 |
|
|
409 | 438 |
#endif |
Also available in: Unified diff