143
144 struct pcicfg_find_ctrl {
145 uint_t device;
146 uint_t function;
147 dev_info_t *dip;
148 };
149
150 /*
151 * List of Indirect Config Map Devices. At least the intent of the
152 * design is to look for a device in this list during the configure
153 * operation, and if the device is listed here, then it is a nontransparent
154 * bridge, hence load the driver and avail the config map services from
155 * the driver. Class and Subclass should be as defined in the PCI specs
156 * ie. class is 0x6, and subclass is 0x9.
157 */
158 static struct {
159 uint8_t mem_range_bar_offset;
160 uint8_t io_range_bar_offset;
161 uint8_t prefetch_mem_range_bar_offset;
162 } pcicfg_indirect_map_devs[] = {
163 PCI_CONF_BASE3, PCI_CONF_BASE2, PCI_CONF_BASE3,
164 0, 0, 0,
165 };
166
167 #define PCICFG_MAKE_REG_HIGH(busnum, devnum, funcnum, register)\
168 (\
169 ((ulong_t)(busnum & 0xff) << 16) |\
170 ((ulong_t)(devnum & 0x1f) << 11) |\
171 ((ulong_t)(funcnum & 0x7) << 8) |\
172 ((ulong_t)(register & 0x3f)))
173
174 /*
175 * debug macros:
176 */
177 #if defined(DEBUG)
178 extern void prom_printf(const char *, ...);
179
180 /*
181 * Following values are defined for this debug flag.
182 *
183 * 1 = dump configuration header only.
184 * 2 = dump generic debug data only (no config header dumped)
365 { 0xf01, "tv" },
366 { 0xf02, "audio" },
367 { 0xf03, "voice" },
368 { 0xf04, "data" },
369 { 0, 0 }
370 };
371 #endif /* _DONT_USE_1275_GENERIC_NAMES */
372
373 /*
374 * Module control operations
375 */
376
377 extern struct mod_ops mod_miscops;
378
379 static struct modlmisc modlmisc = {
380 &mod_miscops, /* Type of module */
381 "PCI configurator"
382 };
383
384 static struct modlinkage modlinkage = {
385 MODREV_1, (void *)&modlmisc, NULL
386 };
387
388
389 #ifdef DEBUG
390
391 static void
392 pcicfg_dump_common_config(ddi_acc_handle_t config_handle)
393 {
394 if ((pcicfg_debug & 1) == 0)
395 return;
396 prom_printf(" Vendor ID = [0x%x]\n",
397 pci_config_get16(config_handle, PCI_CONF_VENID));
398 prom_printf(" Device ID = [0x%x]\n",
399 pci_config_get16(config_handle, PCI_CONF_DEVID));
400 prom_printf(" Command REG = [0x%x]\n",
401 pci_config_get16(config_handle, PCI_CONF_COMM));
402 prom_printf(" Status REG = [0x%x]\n",
403 pci_config_get16(config_handle, PCI_CONF_STAT));
404 prom_printf(" Revision ID = [0x%x]\n",
405 pci_config_get8(config_handle, PCI_CONF_REVID));
|
143
144 struct pcicfg_find_ctrl {
145 uint_t device;
146 uint_t function;
147 dev_info_t *dip;
148 };
149
150 /*
151 * List of Indirect Config Map Devices. At least the intent of the
152 * design is to look for a device in this list during the configure
153 * operation, and if the device is listed here, then it is a nontransparent
154 * bridge, hence load the driver and avail the config map services from
155 * the driver. Class and Subclass should be as defined in the PCI specs
156 * ie. class is 0x6, and subclass is 0x9.
157 */
158 static struct {
159 uint8_t mem_range_bar_offset;
160 uint8_t io_range_bar_offset;
161 uint8_t prefetch_mem_range_bar_offset;
162 } pcicfg_indirect_map_devs[] = {
163 { PCI_CONF_BASE3, PCI_CONF_BASE2, PCI_CONF_BASE3 },
164 { 0, 0, 0 },
165 };
166
167 #define PCICFG_MAKE_REG_HIGH(busnum, devnum, funcnum, register)\
168 (\
169 ((ulong_t)(busnum & 0xff) << 16) |\
170 ((ulong_t)(devnum & 0x1f) << 11) |\
171 ((ulong_t)(funcnum & 0x7) << 8) |\
172 ((ulong_t)(register & 0x3f)))
173
174 /*
175 * debug macros:
176 */
177 #if defined(DEBUG)
178 extern void prom_printf(const char *, ...);
179
180 /*
181 * Following values are defined for this debug flag.
182 *
183 * 1 = dump configuration header only.
184 * 2 = dump generic debug data only (no config header dumped)
365 { 0xf01, "tv" },
366 { 0xf02, "audio" },
367 { 0xf03, "voice" },
368 { 0xf04, "data" },
369 { 0, 0 }
370 };
371 #endif /* _DONT_USE_1275_GENERIC_NAMES */
372
373 /*
374 * Module control operations
375 */
376
377 extern struct mod_ops mod_miscops;
378
379 static struct modlmisc modlmisc = {
380 &mod_miscops, /* Type of module */
381 "PCI configurator"
382 };
383
384 static struct modlinkage modlinkage = {
385 MODREV_1, { (void *)&modlmisc, NULL }
386 };
387
388
389 #ifdef DEBUG
390
391 static void
392 pcicfg_dump_common_config(ddi_acc_handle_t config_handle)
393 {
394 if ((pcicfg_debug & 1) == 0)
395 return;
396 prom_printf(" Vendor ID = [0x%x]\n",
397 pci_config_get16(config_handle, PCI_CONF_VENID));
398 prom_printf(" Device ID = [0x%x]\n",
399 pci_config_get16(config_handle, PCI_CONF_DEVID));
400 prom_printf(" Command REG = [0x%x]\n",
401 pci_config_get16(config_handle, PCI_CONF_COMM));
402 prom_printf(" Status REG = [0x%x]\n",
403 pci_config_get16(config_handle, PCI_CONF_STAT));
404 prom_printf(" Revision ID = [0x%x]\n",
405 pci_config_get8(config_handle, PCI_CONF_REVID));
|