1 | /*␊ |
2 | *␉NVIDIAGraphicsEnabler Module␊ |
3 | *␉␉Enables many nVidia cards to be used out of the box in OS X.␊ |
4 | *␉␉This was converted from boot2 code to a boot2 module.␊ |
5 | *␊ |
6 | */␊ |
7 | ␊ |
8 | #include "saio_internal.h"␊ |
9 | #include "bootstruct.h"␊ |
10 | #include "pci.h"␊ |
11 | #include "nvidia.h"␊ |
12 | #include "modules.h"␊ |
13 | ␊ |
14 | #define kGraphicsEnablerKey "GraphicsEnabler"␊ |
15 | ␊ |
16 | void GraphicsEnabler_hook(void* arg1, void* arg2, void* arg3, void* arg4);␊ |
17 | ␊ |
18 | ␊ |
19 | void NVIDIAGraphicsEnabler_start()␊ |
20 | {␊ |
21 | ␉register_hook_callback("PCIDevice", &GraphicsEnabler_hook);␊ |
22 | }␊ |
23 | ␊ |
24 | ␊ |
25 | void GraphicsEnabler_hook(void* arg1, void* arg2, void* arg3, void* arg4)␊ |
26 | {␊ |
27 | ␉pci_dt_t* current = arg1;␊ |
28 | ␉␊ |
29 | ␉if (current->class_id != PCI_CLASS_DISPLAY_VGA) return;␊ |
30 | ␉␊ |
31 | ␉char *devicepath = get_pci_dev_path(current);␊ |
32 | ␉␊ |
33 | ␉bool do_gfx_devprop = true;␊ |
34 | ␉getBoolForKey(kGraphicsEnablerKey, &do_gfx_devprop, &bootInfo->chameleonConfig);␊ |
35 | ␉␊ |
36 | ␉if (do_gfx_devprop && (current->vendor_id == PCI_VENDOR_ID_NVIDIA))␊ |
37 | ␉{␊ |
38 | ␉␉verbose("NVIDIA VGA Controller [%04x:%04x] :: %s \n",␊ |
39 | ␉␉␉␉current->vendor_id, current->device_id, devicepath);␊ |
40 | ␉␉setup_nvidia_devprop(current);␊ |
41 | ␉}␊ |
42 | ␉else␊ |
43 | ␉␉verbose("[%04x:%04x] :: %s, is not a NVIDIA VGA Controller.\n",␊ |
44 | ␉␉␉␉current->vendor_id, current->device_id, devicepath);␊ |
45 | }␊ |
46 | |