2 * Copyright 2007 Jérôme Glisse
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
26 * Jerome Glisse <glisse@freedesktop.org>
28 #include "radeon_ms.h"
30 int radeon_ms_rom_get_properties(struct drm_device *dev)
32 struct drm_radeon_private *dev_priv = dev->dev_private;
34 switch (dev_priv->rom.type) {
36 return radeon_ms_combios_get_properties(dev);
41 int radeon_ms_rom_init(struct drm_device *dev)
43 struct drm_radeon_private *dev_priv = dev->dev_private;
44 struct radeon_ms_rom *rom = &dev_priv->rom;
46 char atomstr[5] = {0, 0, 0, 0, 0};
49 dev_priv->rom.type = ROM_UNKNOWN;
51 rom_mapped = pci_map_rom(dev->pdev, &rom->rom_size);
52 if (rom_mapped && rom->rom_size) {
53 rom->rom_image = drm_alloc(rom->rom_size, DRM_MEM_DRIVER);
54 if (rom->rom_image == NULL) {
57 memcpy(rom->rom_image, rom_mapped, rom->rom_size);
58 DRM_INFO("[radeon_ms] ROM %d bytes copied\n", rom->rom_size);
60 DRM_INFO("[radeon_ms] no ROM\n");
63 pci_unmap_rom(dev->pdev, rom_mapped);
65 if (rom->rom_image[0] != 0x55 || rom->rom_image[1] != 0xaa) {
66 DRM_INFO("[radeon_ms] no ROM\n");
67 DRM_INFO("[radeon_ms] ROM signature 0x55 0xaa missing\n");
70 offset = (uint16_t *)&rom->rom_image[ROM_HEADER];
71 memcpy(atomstr, &rom->rom_image[*offset + 4], 4);
72 if (!strcpy(atomstr, "ATOM") || !strcpy(atomstr, "MOTA")) {
73 DRM_INFO("[radeon_ms] ATOMBIOS ROM detected\n");
76 struct combios_header **header;
78 header = &rom->rom.combios_header;
79 if ((*offset + sizeof(struct combios_header)) > rom->rom_size) {
80 DRM_INFO("[radeon_ms] wrong COMBIOS header offset\n");
83 dev_priv->rom.type = ROM_COMBIOS;
84 *header = (struct combios_header *)&rom->rom_image[*offset];
85 DRM_INFO("[radeon_ms] COMBIOS type : %d\n",
86 (*header)->ucTypeDefinition);
87 DRM_INFO("[radeon_ms] COMBIOS OEM ID: %02x %02x\n",
88 (*header)->ucOemID1, (*header)->ucOemID2);