4 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include <sys/cdefs.h>
32 __FBSDID("$FreeBSD$");
34 #include <dev/isci/isci.h>
37 #include <machine/pmap.h>
38 #include <machine/vmparam.h>
39 #include <machine/pc/bios.h>
40 #include <dev/isci/scil/scu_bios_definitions.h>
48 uint16_t struct_length;
49 uint8_t struct_revision;
53 uint16_t image_length;
54 uint16_t code_revision;
62 uint8_t signature_byte[2];
65 uint16_t entry_address;
66 uint8_t reserved[0x12];
67 uint16_t pcir_pointer;
71 struct oem_parameters_table
73 uint8_t signature[4]; /* "$OEM" */
76 uint16_t major:8; /* bits [7:0] */
77 uint16_t minor:8; /* bits [8:15] */
88 isci_get_oem_parameters(struct isci_softc *isci)
90 uint32_t OROM_PHYSICAL_ADDRESS_START = 0xC0000;
91 uint32_t OROM_SEARCH_LENGTH = 0x30000;
92 uint16_t OROM_SIGNATURE = 0xAA55;
93 uint32_t OROM_SIZE = 512;
95 (uint8_t *)BIOS_PADDRTOVADDR(OROM_PHYSICAL_ADDRESS_START);
98 while (offset < OROM_SEARCH_LENGTH) {
100 /* Look for the OROM signature at the beginning of every
101 * 512-byte block in the OROM region
103 if (*(uint16_t*)(orom_start + offset) == OROM_SIGNATURE) {
105 struct rom_header *rom_header;
106 struct pcir_header *pcir_header;
107 uint16_t vendor_id = isci->pci_common_header.vendor_id;
108 uint16_t device_id = isci->pci_common_header.device_id;
110 rom = (uint32_t *)(orom_start + offset);
111 rom_header = (struct rom_header *)rom;
112 pcir_header = (struct pcir_header *)
113 ((uint8_t*)rom + rom_header->pcir_pointer);
115 /* OROM signature was found. Now check if the PCI
116 * device and vendor IDs match.
118 if (pcir_header->vendor_id == vendor_id &&
119 pcir_header->device_id == device_id)
121 /* OROM for this PCI device was found. Search
122 * this 512-byte block for the $OEM string,
123 * which will mark the beginning of the OEM
126 uint8_t oem_sig[4] = {'$', 'O', 'E', 'M'};
129 for (dword_index = 0;
130 dword_index < OROM_SIZE/sizeof(uint32_t);
132 if (rom[dword_index] == *(uint32_t *)oem_sig) {
133 /* $OEM signature string was found. Now copy the OEM parameter block
134 * into the struct ISCI_CONTROLLER objects. After the controllers are
135 * constructed, we will pass this OEM parameter data to the SCI core
138 struct oem_parameters_table *oem =
139 (struct oem_parameters_table *)&rom[dword_index];
140 SCI_BIOS_OEM_PARAM_BLOCK_T *oem_data =
141 (SCI_BIOS_OEM_PARAM_BLOCK_T *)oem->data;
144 isci->oem_parameters_found = TRUE;
145 isci_log_message(1, "ISCI", "oem_data->header.num_elements = %d\n",
146 oem_data->header.num_elements);
148 for (index = 0; index < oem_data->header.num_elements; index++)
150 memcpy(&isci->controllers[index].oem_parameters.sds1,
151 &oem_data->controller_element[index],
152 sizeof(SCIC_SDS_OEM_PARAMETERS_T));
154 isci_log_message(1, "ISCI", "OEM Parameter Data for controller %d\n",
157 for (int i = 0; i < sizeof(SCIC_SDS_OEM_PARAMETERS_T); i++) {
158 uint8_t val = ((uint8_t *)&oem_data->controller_element[index])[i];
159 isci_log_message(1, "ISCI", "%02x ", val);
161 isci_log_message(1, "ISCI", "\n");
162 isci->controllers[index].oem_parameters_version = oem_data->header.version;
166 /* No need to continue searching for another
167 * OROM that matches this PCI device, so return