.. | .. |
---|
22 | 22 | */ |
---|
23 | 23 | #include "priv.h" |
---|
24 | 24 | |
---|
| 25 | +static int |
---|
| 26 | +acpi_read_bios(acpi_handle rom_handle, u8 *bios, u32 offset, u32 length) |
---|
| 27 | +{ |
---|
25 | 28 | #if defined(CONFIG_ACPI) && defined(CONFIG_X86) |
---|
26 | | -int nouveau_acpi_get_bios_chunk(uint8_t *bios, int offset, int len); |
---|
27 | | -bool nouveau_acpi_rom_supported(struct device *); |
---|
28 | | -#else |
---|
29 | | -static inline bool |
---|
30 | | -nouveau_acpi_rom_supported(struct device *dev) |
---|
31 | | -{ |
---|
32 | | - return false; |
---|
33 | | -} |
---|
| 29 | + acpi_status status; |
---|
| 30 | + union acpi_object rom_arg_elements[2], *obj; |
---|
| 31 | + struct acpi_object_list rom_arg; |
---|
| 32 | + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL}; |
---|
34 | 33 | |
---|
35 | | -static inline int |
---|
36 | | -nouveau_acpi_get_bios_chunk(uint8_t *bios, int offset, int len) |
---|
37 | | -{ |
---|
| 34 | + rom_arg.count = 2; |
---|
| 35 | + rom_arg.pointer = &rom_arg_elements[0]; |
---|
| 36 | + |
---|
| 37 | + rom_arg_elements[0].type = ACPI_TYPE_INTEGER; |
---|
| 38 | + rom_arg_elements[0].integer.value = offset; |
---|
| 39 | + |
---|
| 40 | + rom_arg_elements[1].type = ACPI_TYPE_INTEGER; |
---|
| 41 | + rom_arg_elements[1].integer.value = length; |
---|
| 42 | + |
---|
| 43 | + status = acpi_evaluate_object(rom_handle, NULL, &rom_arg, &buffer); |
---|
| 44 | + if (ACPI_FAILURE(status)) { |
---|
| 45 | + pr_info("failed to evaluate ROM got %s\n", |
---|
| 46 | + acpi_format_exception(status)); |
---|
| 47 | + return -ENODEV; |
---|
| 48 | + } |
---|
| 49 | + obj = (union acpi_object *)buffer.pointer; |
---|
| 50 | + length = min(length, obj->buffer.length); |
---|
| 51 | + memcpy(bios+offset, obj->buffer.pointer, length); |
---|
| 52 | + kfree(buffer.pointer); |
---|
| 53 | + return length; |
---|
| 54 | +#else |
---|
38 | 55 | return -EINVAL; |
---|
39 | | -} |
---|
40 | 56 | #endif |
---|
| 57 | +} |
---|
41 | 58 | |
---|
42 | 59 | /* This version of the shadow function disobeys the ACPI spec and tries |
---|
43 | 60 | * to fetch in units of more than 4KiB at a time. This is a LOT faster |
---|
.. | .. |
---|
51 | 68 | u32 fetch = limit - start; |
---|
52 | 69 | |
---|
53 | 70 | if (nvbios_extend(bios, limit) >= 0) { |
---|
54 | | - int ret = nouveau_acpi_get_bios_chunk(bios->data, start, fetch); |
---|
| 71 | + int ret = acpi_read_bios(data, bios->data, start, fetch); |
---|
55 | 72 | if (ret == fetch) |
---|
56 | 73 | return fetch; |
---|
57 | 74 | } |
---|
.. | .. |
---|
73 | 90 | |
---|
74 | 91 | if (nvbios_extend(bios, limit) >= 0) { |
---|
75 | 92 | while (start + fetch < limit) { |
---|
76 | | - int ret = nouveau_acpi_get_bios_chunk(bios->data, |
---|
77 | | - start + fetch, |
---|
78 | | - 0x1000); |
---|
| 93 | + int ret = acpi_read_bios(data, bios->data, |
---|
| 94 | + start + fetch, 0x1000); |
---|
79 | 95 | if (ret != 0x1000) |
---|
80 | 96 | break; |
---|
81 | 97 | fetch += 0x1000; |
---|
.. | .. |
---|
88 | 104 | static void * |
---|
89 | 105 | acpi_init(struct nvkm_bios *bios, const char *name) |
---|
90 | 106 | { |
---|
91 | | - if (!nouveau_acpi_rom_supported(bios->subdev.device->dev)) |
---|
| 107 | +#if defined(CONFIG_ACPI) && defined(CONFIG_X86) |
---|
| 108 | + acpi_status status; |
---|
| 109 | + acpi_handle dhandle, rom_handle; |
---|
| 110 | + |
---|
| 111 | + dhandle = ACPI_HANDLE(bios->subdev.device->dev); |
---|
| 112 | + if (!dhandle) |
---|
92 | 113 | return ERR_PTR(-ENODEV); |
---|
93 | | - return NULL; |
---|
| 114 | + |
---|
| 115 | + status = acpi_get_handle(dhandle, "_ROM", &rom_handle); |
---|
| 116 | + if (ACPI_FAILURE(status)) |
---|
| 117 | + return ERR_PTR(-ENODEV); |
---|
| 118 | + |
---|
| 119 | + return rom_handle; |
---|
| 120 | +#else |
---|
| 121 | + return ERR_PTR(-ENODEV); |
---|
| 122 | +#endif |
---|
94 | 123 | } |
---|
95 | 124 | |
---|
96 | 125 | const struct nvbios_source |
---|