| 1 |
/* Adapted from include/linux/math.h */ |
| 2 |
#define __round_mask(x, y) ((__typeof__(x))((y)-1)) |
| 3 |
#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1) |
| 4 |
|
| 5 |
/* Reduced from Linux kernel's drivers/gpu/drm/i915/display/intel_bios.c */ |
| 6 |
typedef unsigned short u16; |
| 7 |
typedef unsigned int u32; |
| 8 |
typedef unsigned long __kernel_size_t; |
| 9 |
typedef __kernel_size_t size_t; |
| 10 |
|
| 11 |
extern __attribute__((__alloc_size__(1))) __attribute__((__malloc__)) |
| 12 |
void* kzalloc(size_t size); |
| 13 |
|
| 14 |
typedef struct |
| 15 |
{ |
| 16 |
u32 reg; |
| 17 |
} i915_reg_t; |
| 18 |
struct intel_uncore; |
| 19 |
struct intel_uncore_funcs |
| 20 |
{ |
| 21 |
u32 (*mmio_readl)(struct intel_uncore* uncore, i915_reg_t r); |
| 22 |
}; |
| 23 |
struct intel_uncore |
| 24 |
{ |
| 25 |
void* regs; |
| 26 |
struct intel_uncore_funcs funcs; |
| 27 |
}; |
| 28 |
static inline __attribute__((__gnu_inline__)) __attribute__((__unused__)) |
| 29 |
__attribute__((no_instrument_function)) u32 |
| 30 |
intel_uncore_read(struct intel_uncore* uncore, i915_reg_t reg) |
| 31 |
{ |
| 32 |
return uncore->funcs.mmio_readl(uncore, reg); |
| 33 |
} |
| 34 |
struct drm_i915_private |
| 35 |
{ |
| 36 |
struct intel_uncore uncore; |
| 37 |
}; |
| 38 |
struct vbt_header* |
| 39 |
spi_oprom_get_vbt(struct drm_i915_private* i915) |
| 40 |
{ |
| 41 |
u16 vbt_size; |
| 42 |
u32* vbt; |
| 43 |
vbt_size = |
| 44 |
intel_uncore_read(&i915->uncore, ((const i915_reg_t){ .reg = (0x102040) })); |
| 45 |
vbt_size &= 0xffff; |
| 46 |
vbt = (u32*)kzalloc(round_up (vbt_size, 4)); /* { dg-bogus "allocated buffer size is not a multiple of the pointee's size" "PR analyzer/113654" } */ |
| 47 |
if (!vbt) |
| 48 |
goto err_not_found; |
| 49 |
return (struct vbt_header*)vbt; |
| 50 |
err_not_found: |
| 51 |
return ((struct vbt_header*)0); |
| 52 |
} |