Exemplo n.º 1
0
void SATA_hook(void* arg1, void* arg2, void* arg3, void* arg4)
{
    pci_dt_t* current = arg1;
    struct DevPropDevice		*device = NULL;
    char *devicepath = NULL;

    if (current && current->class_id == PCI_CLASS_STORAGE_SATA)
    {
        if (!string)
        {
            string = devprop_create_string();
            if (!string) return;
        }
        devicepath = get_pci_dev_path(current);
        if (!devicepath) return;

        device = devprop_add_device(string, devicepath);
        if (!device) return;

        devprop_add_value(device, "device-id", default_SATA_ID, SATA_ID_LEN);

        verbose("SATA device : [%04x:%04x :: %04x], changed to ICH6 ESB2 \n",
                current->vendor_id, current->device_id,current->class_id);

    }

}
Exemplo n.º 2
0
void setup_pci_devs(pci_dt_t *pci_dt)
{
    char *devicepath;
    bool do_eth_devprop, do_gfx_devprop, do_enable_hpet;
    pci_dt_t *current = pci_dt;

    do_eth_devprop = do_gfx_devprop = do_enable_hpet = false;

    getBoolForKey(kEthernetBuiltIn, &do_eth_devprop, &bootInfo->bootConfig);
    getBoolForKey(kGraphicsEnabler, &do_gfx_devprop, &bootInfo->bootConfig);
    getBoolForKey(kForceHPET, &do_enable_hpet, &bootInfo->bootConfig);

    while (current)
    {
        devicepath = get_pci_dev_path(current);

        switch (current->class_id)
        {
        case PCI_CLASS_NETWORK_ETHERNET:
            if (do_eth_devprop)
                set_eth_builtin(current);
            break;

        case PCI_CLASS_DISPLAY_VGA:
            if (do_gfx_devprop)
                switch (current->vendor_id)
                {
                case PCI_VENDOR_ID_ATI:
                    verbose("ATI VGA Controller [%04x:%04x] :: %s \n",
                            current->vendor_id, current->device_id, devicepath);
                    setup_ati_devprop(current);
                    break;

                case PCI_VENDOR_ID_INTEL:
                    /* message to be removed once support for these cards is added */
                    verbose("Intel VGA Controller [%04x:%04x] :: %s (currently NOT SUPPORTED)\n",
                            current->vendor_id, current->device_id, devicepath);
                    break;

                case PCI_VENDOR_ID_NVIDIA:
                    setup_nvidia_devprop(current);
                    break;
                }
            break;

        case PCI_CLASS_SERIAL_USB:
            notify_usb_dev(current);
            break;

        case PCI_CLASS_BRIDGE_ISA:
            if (do_enable_hpet)
                force_enable_hpet(current);
            break;
        }

        setup_pci_devs(current->children);
        current = current->next;
    }
}
Exemplo n.º 3
0
// Ethernet built-in device injection
BOOLEAN set_eth_props(pci_dt_t *eth_dev)
{
#if DEBUG_INJECT
  CHAR8           *devicepath;
#endif
  DevPropDevice   *device;
  UINT8           builtin = 0x0;
  BOOLEAN         Injected = FALSE;
  INT32           i;
  CHAR8           compatible[64];
  
  
  if (!string) {
    string = devprop_create_string();
  }
#if DEBUG_INJECT
  devicepath = get_pci_dev_path(eth_dev);
#endif
  //device = devprop_add_device(string, devicepath);
  device = devprop_add_device_pci(string, eth_dev);
  if (!device)
    return FALSE;
  // -------------------------------------------------
  DBG("LAN Controller [%04x:%04x] :: %a\n", eth_dev->vendor_id, eth_dev->device_id, devicepath);
  if (eth_dev->vendor_id != 0x168c && builtin_set == 0) {
 		builtin_set = 1;
 		builtin = 0x01;
 	}
  
  if (gSettings.NrAddProperties != 0xFFFE) {
    for (i = 0; i < gSettings.NrAddProperties; i++) {
      if (gSettings.AddProperties[i].Device != DEV_LAN) {
        continue;
      }
      Injected = TRUE;
      devprop_add_value(device,
                        gSettings.AddProperties[i].Key,
                        (UINT8*)gSettings.AddProperties[i].Value,
                        gSettings.AddProperties[i].ValueLen);
    }
  }
  if (Injected) {
    DBG("custom LAN properties injected, continue\n");
    //    return TRUE;
  }
  
  //  DBG("Setting dev.prop built-in=0x%x\n", builtin);
  devprop_add_value(device, "device_type", (UINT8*)"Ethernet", 9);
  if (gSettings.FakeLAN) {
    UINT32 FakeID = gSettings.FakeLAN >> 16;
    devprop_add_value(device, "device-id", (UINT8*)&FakeID, 4);
    AsciiSPrint(compatible, 64, "pci%x,%x", (gSettings.FakeLAN & 0xFFFF), FakeID);
    LowCase(compatible);
    devprop_add_value(device, "compatible", (UINT8*)&compatible[0], 12);
    FakeID = gSettings.FakeLAN & 0xFFFF;
    devprop_add_value(device, "vendor-id", (UINT8*)&FakeID, 4);
  }
Exemplo n.º 4
0
void set_eth_builtin(pci_dt_t *eth_dev)
{
	char *devicepath = get_pci_dev_path(eth_dev);
	struct DevPropDevice *device = (struct DevPropDevice*)malloc(sizeof(struct DevPropDevice));

	verbose("LAN Controller [%04x:%04x] :: %s\n", eth_dev->vendor_id, eth_dev->device_id, devicepath);

	if (!string)
		string = devprop_create_string();

	device = devprop_add_device(string, devicepath);
	if(device)
	{
		verbose("Setting up lan keys\n");
		devprop_add_network_template(device, eth_dev->vendor_id);
		stringdata = (uint8_t*)malloc(sizeof(uint8_t) * string->length);
		if(stringdata)
		{
			memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length);
			stringlength = string->length;
		}
	}
}
Exemplo n.º 5
0
void setup_pci_devs(pci_dt_t *pci_dt)
{
	char *devicepath;
	BOOL do_eth_devprop, do_gfx_devprop, fix_ehci, fix_legoff, fix_uhci, fix_usb, do_enable_hpet;
	pci_dt_t *current = pci_dt;

	do_eth_devprop = do_gfx_devprop = fix_ehci = fix_legoff = fix_uhci = fix_usb = do_enable_hpet = false;

	getBoolForKey("EthernetBuiltIn", &do_eth_devprop, &bootInfo->bootConfig);
	getBoolForKey("GraphicsEnabler", &do_gfx_devprop, &bootInfo->bootConfig);
	if (getBoolForKey("USBBusFix", &fix_usb, &bootInfo->bootConfig) && fix_usb)
		fix_ehci = fix_uhci = true;
	else
	{
		getBoolForKey("EHCIacquire", &fix_ehci, &bootInfo->bootConfig);
		getBoolForKey("UHCIreset", &fix_uhci, &bootInfo->bootConfig);
	}
	getBoolForKey("USBLegacyOff", &fix_legoff, &bootInfo->bootConfig);
	getBoolForKey("ForceHPET", &do_enable_hpet, &bootInfo->bootConfig);

	while (current)
	{
		devicepath = get_pci_dev_path(current);

		switch (current->class_id)
		{
			case PCI_CLASS_NETWORK_ETHERNET: 
				if (do_eth_devprop)
					set_eth_builtin(current);
				break;
				
			case PCI_CLASS_DISPLAY_VGA:
				if (do_gfx_devprop)
					switch (current->vendor_id)
					{
						case PCI_VENDOR_ID_ATI:
							verbose("ATI VGA Controller [%04x:%04x] :: %s \n", 
							current->vendor_id, current->device_id, devicepath);
							setup_ati_devprop(current); 
							break;
					
						case PCI_VENDOR_ID_INTEL: 
							/* message to be removed once support for these cards is added */
							verbose("Intel VGA Controller [%04x:%04x] :: %s (currently NOT SUPPORTED)\n", 
								current->vendor_id, current->device_id, devicepath);
							break;
					
						case PCI_VENDOR_ID_NVIDIA: 
							setup_nvidia_devprop(current);
							break;
					}
				break;

			case PCI_CLASS_SERIAL_USB:
				switch (pci_config_read8(current->dev.addr, PCI_CLASS_PROG))
				{
					/* EHCI */
					case 0x20:
				    	if (fix_ehci)
							ehci_acquire(current);
						if (fix_legoff)
							legacy_off(current);
						break;

					/* UHCI */
					case 0x00:
				    	if (fix_uhci)
							uhci_reset(current);
						break;
				}
				break;

			case PCI_CLASS_BRIDGE_ISA:
				if (do_enable_hpet)
					force_enable_hpet(current);
				break;
		}
		
		setup_pci_devs(current->children);
		current = current->next;
	}
}
Exemplo n.º 6
0
void setup_pci_devs(pci_dt_t *pci_dt)
{
	char *devicepath;
	bool do_eth_devprop, do_gfx_devprop, do_enable_hpet, do_igp_devprop;
	pci_dt_t *current = pci_dt;

	do_eth_devprop = do_gfx_devprop = do_enable_hpet = false;

	getBoolForKey(kEthernetBuiltIn, &do_eth_devprop, &bootInfo->chameleonConfig);
	getBoolForKey(kGraphicsEnabler, &do_gfx_devprop, &bootInfo->chameleonConfig);
    getBoolForKey(kIGPEnabler, &do_igp_devprop, &bootInfo->chameleonConfig);
	getBoolForKey(kForceHPET, &do_enable_hpet, &bootInfo->chameleonConfig);

	while (current)
	{
		devicepath = get_pci_dev_path(current);

		switch (current->class_id)
		{
			case PCI_CLASS_BRIDGE_HOST:
					if (current->dev.addr == PCIADDR(0, 0, 0))
						dram_controller_dev = current;
				break;
				
			case PCI_CLASS_NETWORK_ETHERNET: 
				if (do_eth_devprop)
					set_eth_builtin(current);
				break;
				
			case PCI_CLASS_DISPLAY_VGA:
				if (do_gfx_devprop){
					switch (current->vendor_id)
					{
						case PCI_VENDOR_ID_ATI:
							setup_ati_devprop(current); 
							break;
					
						case PCI_VENDOR_ID_INTEL:
							setup_gma_devprop(current);
							break;
					
						case PCI_VENDOR_ID_NVIDIA: 
							setup_nvidia_devprop(current);
							break;
					}
				break;
                } else if (do_igp_devprop){
                        setup_gma_devprop(current);
                        break;
                }

			case PCI_CLASS_SERIAL_USB:
				notify_usb_dev(current);
				break;

			case PCI_CLASS_BRIDGE_ISA:
				if (do_enable_hpet)
					force_enable_hpet(current);
				break;
		}
		
		execute_hook("PCIDevice", current, NULL, NULL, NULL);
		
		setup_pci_devs(current->children);
		current = current->next;
	}
}
Exemplo n.º 7
0
Arquivo: gma.c Projeto: RemC/Chameleon
bool setup_gma_devprop(pci_dt_t *gma_dev)
{
    char					*devicepath;
    volatile uint8_t		*regs;
    uint32_t				bar[7];
    char					*model;
    uint8_t BuiltIn =		0x00;
    uint8_t ClassFix[4] =	{ 0x00, 0x00, 0x03, 0x00 };
    unsigned int			device_id;

    devicepath = get_pci_dev_path(gma_dev);

    bar[0] = pci_config_read32(gma_dev->dev.addr, 0x10);
    regs = (uint8_t *) (bar[0] & ~0x0f);

    model = get_gma_model((gma_dev->vendor_id << 16) | gma_dev->device_id);
    device_id = gma_dev->device_id;

    verbose("Intel %s [%04x:%04x] :: %s\n",
            model, gma_dev->vendor_id, gma_dev->device_id, devicepath);

    if (!string)
        string = devprop_create_string();

    struct DevPropDevice *device = malloc(sizeof(struct DevPropDevice));
    device = devprop_add_device(string, devicepath);

    if (!device)
    {
        printf("Failed initializing dev-prop string dev-entry.\n");
        pause();
        return false;
    }

    devprop_add_value(device, "model", (uint8_t*)model, (strlen(model) + 1));
    devprop_add_value(device, "device_type", (uint8_t*)"display", 8);

    if ((model == (char *)&"Mobile GMA950")
            || (model == (char *)&"Mobile GMA3150"))
    {
        devprop_add_value(device, "AAPL,HasPanel", reg_TRUE, 4);
        devprop_add_value(device, "built-in", &BuiltIn, 1);
        devprop_add_value(device, "class-code", ClassFix, 4);
    }
    else if ((model == (char *)&"Desktop GMA950")
             || (model == (char *)&"Desktop GMA3150"))
    {
        BuiltIn = 0x01;
        devprop_add_value(device, "built-in", &BuiltIn, 1);
        devprop_add_value(device, "class-code", ClassFix, 4);
    }
    else if (model == (char *)&"GMAX3100")
    {
        devprop_add_value(device, "AAPL,HasPanel",					GMAX3100_vals[0], 4);
        devprop_add_value(device, "AAPL,SelfRefreshSupported",		GMAX3100_vals[1], 4);
        devprop_add_value(device, "AAPL,aux-power-connected",		GMAX3100_vals[2], 4);
        devprop_add_value(device, "AAPL,backlight-control",			GMAX3100_vals[3], 4);
        devprop_add_value(device, "AAPL00,blackscreen-preferences", GMAX3100_vals[4], 4);
        devprop_add_value(device, "AAPL01,BacklightIntensity",		GMAX3100_vals[5], 4);
        devprop_add_value(device, "AAPL01,blackscreen-preferences", GMAX3100_vals[6], 4);
        devprop_add_value(device, "AAPL01,DataJustify",				GMAX3100_vals[7], 4);
        devprop_add_value(device, "AAPL01,Depth",					GMAX3100_vals[8], 4);
        devprop_add_value(device, "AAPL01,Dither",					GMAX3100_vals[9], 4);
        devprop_add_value(device, "AAPL01,DualLink",				GMAX3100_vals[10], 4);
        devprop_add_value(device, "AAPL01,Height",					GMAX3100_vals[11], 4);
        devprop_add_value(device, "AAPL01,Interlace",				GMAX3100_vals[12], 4);
        devprop_add_value(device, "AAPL01,Inverter",				GMAX3100_vals[13], 4);
        devprop_add_value(device, "AAPL01,InverterCurrent",			GMAX3100_vals[14], 4);
        devprop_add_value(device, "AAPL01,InverterCurrency",		GMAX3100_vals[15], 4);
        devprop_add_value(device, "AAPL01,LinkFormat",				GMAX3100_vals[16], 4);
        devprop_add_value(device, "AAPL01,LinkType",				GMAX3100_vals[17], 4);
        devprop_add_value(device, "AAPL01,Pipe",					GMAX3100_vals[18], 4);
        devprop_add_value(device, "AAPL01,PixelFormat",				GMAX3100_vals[19], 4);
        devprop_add_value(device, "AAPL01,Refresh",					GMAX3100_vals[20], 4);
        devprop_add_value(device, "AAPL01,Stretch",					GMAX3100_vals[21], 4);
        devprop_add_value(device, "class-code",						ClassFix, 4);
    }
    else if (model == (char *)&"HD Graphics 2000 Mobile")
    {
        devprop_add_value(device, "class-code", ClassFix, 4);
        devprop_add_value(device, "hda-gfx", (uint8_t *)"onboard-1", 10);
        devprop_add_value(device, "AAPL00,PixelFormat", HD2000_vals[0], 4);
        devprop_add_value(device, "AAPL00,T1", HD2000_vals[1], 4);
        devprop_add_value(device, "AAPL00,T2", HD2000_vals[2], 4);
        devprop_add_value(device, "AAPL00,T3", HD2000_vals[3], 4);
        devprop_add_value(device, "AAPL00,T4", HD2000_vals[4], 4);
        devprop_add_value(device, "AAPL00,T5", HD2000_vals[5], 4);
        devprop_add_value(device, "AAPL00,T6", HD2000_vals[6], 4);
        devprop_add_value(device, "AAPL00,T7", HD2000_vals[7], 4);
        devprop_add_value(device, "AAPL00,LinkType", HD2000_vals[8], 4);
        devprop_add_value(device, "AAPL00,LinkFormat", HD2000_vals[9], 4);
        devprop_add_value(device, "AAPL00,DualLink", HD2000_vals[10], 4);
        devprop_add_value(device, "AAPL00,Dither", HD2000_vals[11], 4);
        devprop_add_value(device, "AAPL00,DataJustify", HD3000_vals[12], 4);
        devprop_add_value(device, "graphic-options", HD2000_vals[13], 4);
        devprop_add_value(device, "AAPL,tbl-info", HD2000_tbl_info, 18);
        devprop_add_value(device, "AAPL,os-info", HD2000_os_info, 20);
    }
    else if (model == (char *)&"HD Graphics 3000 Mobile")
    {
        devprop_add_value(device, "class-code", ClassFix, 4);
        devprop_add_value(device, "hda-gfx", (uint8_t *)"onboard-1", 10);
        devprop_add_value(device, "AAPL00,PixelFormat", HD3000_vals[0], 4);
        devprop_add_value(device, "AAPL00,T1", HD3000_vals[1], 4);
        devprop_add_value(device, "AAPL00,T2", HD3000_vals[2], 4);
        devprop_add_value(device, "AAPL00,T3", HD3000_vals[3], 4);
        devprop_add_value(device, "AAPL00,T4", HD3000_vals[4], 4);
        devprop_add_value(device, "AAPL00,T5", HD3000_vals[5], 4);
        devprop_add_value(device, "AAPL00,T6", HD3000_vals[6], 4);
        devprop_add_value(device, "AAPL00,T7", HD3000_vals[7], 4);
        devprop_add_value(device, "AAPL00,LinkType", HD3000_vals[8], 4);
        devprop_add_value(device, "AAPL00,LinkFormat", HD3000_vals[9], 4);
        devprop_add_value(device, "AAPL00,DualLink", HD3000_vals[10], 4);
        devprop_add_value(device, "AAPL00,Dither", HD3000_vals[11], 4);
        devprop_add_value(device, "AAPL00,DataJustify", HD3000_vals[12], 4);
        devprop_add_value(device, "graphic-options", HD3000_vals[13], 4);
        devprop_add_value(device, "AAPL,tbl-info", HD3000_tbl_info, 18);
        devprop_add_value(device, "AAPL,os-info", HD3000_os_info, 20);
    }
    else if (model == (char *)&"HD Graphics 2000")
    {
        devprop_add_value(device, "built-in", &BuiltIn, 1);
        devprop_add_value(device, "class-code", ClassFix, 4);
        devprop_add_value(device, "device-id", (uint8_t*)&device_id, sizeof(device_id));
        devprop_add_value(device, "hda-gfx", (uint8_t *)"onboard-1", 10);
        devprop_add_value(device, "AAPL,tbl-info", HD2000_tbl_info, 18);
        devprop_add_value(device, "AAPL,os-info", HD2000_os_info, 20);
    }
    else if (model == (char *)&"HD Graphics 3000")
    {
        devprop_add_value(device, "built-in", &BuiltIn, 1);
        devprop_add_value(device, "class-code", ClassFix, 4);
        device_id = 0x00000126;											// Inject a valid mobile GPU device id instead of patching kexts
        devprop_add_value(device, "device-id", (uint8_t*)&device_id, sizeof(device_id));
        devprop_add_value(device, "hda-gfx", (uint8_t *)"onboard-1", 10);
        devprop_add_value(device, "AAPL,tbl-info", HD3000_tbl_info, 18);
        devprop_add_value(device, "AAPL,os-info", HD3000_os_info, 20);
    }
    else if(model == (char*)&"HD Graphics 4000" ||
            model == (char*)&"HD Graphics 4000 Mobile")
    {
        uint32_t ram = (((getVBEVideoRam() + 512) / 1024) + 512) / 1024;
        uint32_t ig_platform_id;

        switch (ram)
        {
        case 96:
            ig_platform_id = 0x01660000; // 96mb
            break;

        case 64:
            ig_platform_id = 0x01660009; // 64mb
            break;

        case 32:
            ig_platform_id = 0x01620005; // 32mb
            break;
        default:
            printf("Please specify 96, 64, or 32MB RAM for the HD4000 in the bios.\n"
                   "The selected %dMB RAM configuration is not supported for the  HD4000.\n", ram);
            pause();
            return false;	// Exit early before the AAPL,ig-platform-id property is set.
            break;
        }

        devprop_add_value(device, "built-in", &BuiltIn, 1);
        devprop_add_value(device, "class-code", ClassFix, 4);
        devprop_add_value(device, "hda-gfx", (uint8_t *)"onboard-1", 10);
        devprop_add_value(device, "AAPL,ig-platform-id", (uint8_t*)&ig_platform_id, 4);
    }

    stringdata = malloc(sizeof(uint8_t) * string->length);
    if (!stringdata)
    {
        printf("No stringdata.\n");
        pause();
        return false;
    }

    memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length);
    stringlength = string->length;

    return true;
}
Exemplo n.º 8
0
void setup_pci_devs(pci_dt_t *pci_dt)
{
	char *devicepath;

	bool do_gfx_devprop = false;
	bool do_skip_n_devprop = false;
	bool do_skip_a_devprop = false;
	bool do_skip_i_devprop = false;

	bool do_enable_hpet = false;
	bool do_hda_devprop = false;

	pci_dt_t *current = pci_dt;

	// GraphicsEnabler
	getBoolForKey(kGraphicsEnabler, &do_gfx_devprop, &bootInfo->chameleonConfig);

	// Skip keys
	getBoolForKey(kSkipNvidiaGfx, &do_skip_n_devprop, &bootInfo->chameleonConfig);
	getBoolForKey(kSkipAtiGfx, &do_skip_a_devprop, &bootInfo->chameleonConfig);
	getBoolForKey(kSkipIntelGfx, &do_skip_i_devprop, &bootInfo->chameleonConfig);

	// HDAEnable
	getBoolForKey(kHDAEnabler, &do_hda_devprop, &bootInfo->chameleonConfig);

	// ForceHPET
	getBoolForKey(kForceHPET, &do_enable_hpet, &bootInfo->chameleonConfig);

	while (current)
	{
		devicepath = get_pci_dev_path(current);

		switch (current->class_id)
		{
			case PCI_CLASS_BRIDGE_HOST:
				DBG("Setup BRIDGE_HOST \n");
				if (current->dev.addr == PCIADDR(0, 0, 0))
				{
					dram_controller_dev = current;
				}
				break; // PCI_CLASS_BRIDGE_HOST

			case PCI_CLASS_NETWORK_ETHERNET:
				DBG("Setup ETHERNET %s enabled\n", do_eth_devprop? "is":"is not");
				verbose("[ ETHERNET DEVICE INFO ]\n");
				setup_eth_devdrop(current);
				verbose("\n");
				break; // PCI_CLASS_NETWORK_ETHERNET

			case PCI_CLASS_NETWORK_OTHER:
				DBG("Setup WIRELESS %s enabled\n", do_wifi_devprop? "is":"is not");
				verbose("[ WIRELESS DEVICE INFO ]\n");
				setup_wifi_devdrop(current);
				verbose("\n");
				break; // PCI_CLASS_NETWORK_OTHER

			case PCI_CLASS_DISPLAY_VGA:
				DBG("GraphicsEnabler %s enabled\n", do_gfx_devprop? "is":"is not");
				if (do_gfx_devprop)
				{
					switch (current->vendor_id)
					{
						case PCI_VENDOR_ID_ATI:
							if ( do_skip_a_devprop )
							{
								verbose("Skip ATi/AMD gfx device!\n");
							}
							else
							{
								verbose("[ ATi GFX DEVICE INFO ]\n");
								setup_ati_devprop(current);
								verbose("\n");
							}
							break; // PCI_VENDOR_ID_ATI

						case PCI_VENDOR_ID_INTEL:
							if ( do_skip_i_devprop )
							{
								verbose("Skip Intel gfx device!\n");
							}
							else
							{
								verbose("[ INTEL GMA DEVICE INFO ]\n");
								setup_gma_devprop(current);
								verbose("\n");
							}
							break; // PCI_VENDOR_ID_INTEL

						case PCI_VENDOR_ID_NVIDIA:
							if ( do_skip_n_devprop )
							{
								verbose("Skip Nvidia gfx device!\n");
							}
							else
							{
								verbose("[ NVIDIA GFX DEVICE INFO ]\n");
								setup_nvidia_devprop(current);
								verbose("\n");
							}
							break; // PCI_VENDOR_ID_NVIDIA

						default:
							break;
					}
				}
				break; // PCI_CLASS_DISPLAY_VGA

			case PCI_CLASS_MULTIMEDIA_AUDIO_DEV:
				DBG("Setup HDEF %s enabled\n", do_hda_devprop ? "is":"is not");
				if (do_hda_devprop)
				{
					verbose("[ AUDIO DEVICE INFO ]\n");
					setup_hda_devprop(current);
					verbose("\n");
				}
				break; // PCI_CLASS_MULTIMEDIA_AUDIO_DEV

			case PCI_CLASS_SERIAL_USB:
				DBG("USB\n");
				notify_usb_dev(current);
				break; // PCI_CLASS_SERIAL_USB

			case PCI_CLASS_SERIAL_FIREWIRE:
				DBG("FireWire\n");
				verbose("[ FIREWIRE DEVICE INFO ]\n");
				verbose("\tClass code: [%04X]\n\tFireWire device [%04x:%04x]-[%04x:%04x]\n\t%s\n",
					current->class_id,current->vendor_id, current->device_id,
					current->subsys_id.subsys.vendor_id,
					current->subsys_id.subsys.device_id, devicepath);
//				set_fwr_devdrop(current);
				verbose("\n");
				break; // PCI_CLASS_SERIAL_FIREWIRE

			case PCI_CLASS_BRIDGE_ISA:
				DBG("Force HPET %s enabled\n", do_enable_hpet ? "is":"is not");
				if (do_enable_hpet)
				{
					verbose("[ HPET ]\n");
					force_enable_hpet(current);
					verbose("\n");
				}
				break; // PCI_CLASS_BRIDGE_ISA

			}

		execute_hook("PCIDevice", current, NULL, NULL, NULL);
		DBG("setup_pci_devs current device ID = [%04x:%04x]\n", current->vendor_id, current->device_id);
		setup_pci_devs(current->children);
		current = current->next;
	}
}
Exemplo n.º 9
0
bool setup_hda_devprop(pci_dt_t *hda_dev)
{
	struct		DevPropDevice	*device = NULL;
	char		*devicepath = NULL;
	char		*controller_name = NULL;
	int		len;
	uint8_t		BuiltIn = 0x00;
	uint16_t	controller_vendor_id = hda_dev->vendor_id;
	uint16_t	controller_device_id = hda_dev->device_id;
	const char	*value;

	// Skip keys
	bool do_skip_n_devprop = false;
	bool do_skip_a_devprop = false;
	getBoolForKey(kSkipNvidiaGfx, &do_skip_n_devprop, &bootInfo->chameleonConfig);
	getBoolForKey(kSkipAtiGfx, &do_skip_a_devprop, &bootInfo->chameleonConfig);

	verbose("\tClass code: [%04X]\n", hda_dev->class_id);

	devicepath = get_pci_dev_path(hda_dev);
	controller_name = get_hda_controller_name(controller_device_id, controller_vendor_id);

	if (!string)
	{
		string = devprop_create_string();
		if (!string)
		{
			return 0;
		}
	}

	if (!devicepath)
	{
		return 0;
	}

	device = devprop_add_device(string, devicepath);
	if (!device)
	{
		return 0;
	}

	verbose("\tModel name: %s [%04x:%04x] (rev %02x)\n\tSubsystem: [%04x:%04x]\n\t%s\n",
		 controller_name, hda_dev->vendor_id, hda_dev->device_id, hda_dev->revision_id,
		hda_dev->subsys_id.subsys.vendor_id, hda_dev->subsys_id.subsys.device_id, devicepath);


	switch ((controller_device_id << 16) | controller_vendor_id)
	{

	/***********************************************************************
	* The above case are intended as for HDEF device at address 0x001B0000
	***********************************************************************/
		case HDA_INTEL_OAK:
		case HDA_INTEL_BAY:
		case HDA_INTEL_HSW1:
		case HDA_INTEL_HSW2:
		case HDA_INTEL_HSW3:
		case HDA_INTEL_BDW:
		case HDA_INTEL_CPT:
		case HDA_INTEL_PATSBURG:
		case HDA_INTEL_PPT1:
		case HDA_INTEL_BRASWELL:
		case HDA_INTEL_82801F:
		case HDA_INTEL_63XXESB:
		case HDA_INTEL_82801G:
		case HDA_INTEL_82801H:
		case HDA_INTEL_82801I:
		case HDA_INTEL_ICH9:
		case HDA_INTEL_82801JI:
		case HDA_INTEL_82801JD:
		case HDA_INTEL_PCH:
		case HDA_INTEL_PCH2:
		case HDA_INTEL_SCH:
		case HDA_INTEL_LPT1:
		case HDA_INTEL_LPT2:
		case HDA_INTEL_WCPT:
		case HDA_INTEL_WELLS1:
		case HDA_INTEL_WELLS2:
		case HDA_INTEL_WCPTLP:
		case HDA_INTEL_LPTLP1:
		case HDA_INTEL_LPTLP2:
		case HDA_INTEL_SRSPLP:
		case HDA_INTEL_SRSP:

			/* if the key value kHDEFLayoutID as a value set that value, if not will assign a default layout */
			if (getValueForKey(kHDEFLayoutID, &value, &len, &bootInfo->chameleonConfig) && len == HDEF_LEN * 2)
			{
				uint8_t new_HDEF_layout_id[HDEF_LEN];
				if (hex2bin(value, new_HDEF_layout_id, HDEF_LEN) == 0)
				{
					memcpy(default_HDEF_layout_id, new_HDEF_layout_id, HDEF_LEN);
					verbose("\tUsing user supplied HDEF layout-id: 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
					default_HDEF_layout_id[0], default_HDEF_layout_id[1], default_HDEF_layout_id[2], default_HDEF_layout_id[3]);
				}
			}
			else
			{
				verbose("\tUsing default HDEF layout-id: 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
					default_HDEF_layout_id[0], default_HDEF_layout_id[1], default_HDEF_layout_id[2], default_HDEF_layout_id[3]);
			}
			devprop_add_value(device, "layout-id", default_HDEF_layout_id, HDEF_LEN);
			devprop_add_value(device, "AAPL,slot-name", (uint8_t *)"Built-in", sizeof("Built-in")); // 0x09
			devprop_add_value(device, "name", (uint8_t *)"audio", 6); // 0x06
			devprop_add_value(device, "device-type", (uint8_t *)"High Definition Audio Controller", sizeof("High Definition Audio Controller"));
			devprop_add_value(device, "device_type", (uint8_t *)"Sound", sizeof("Sound"));
			devprop_add_value(device, "built-in", &BuiltIn, 1);
			devprop_add_value(device, "hda-gfx", (uint8_t *)"onboard-1", sizeof("onboard-1")); // 0x0a
			// "AFGLowPowerState" = <03000000>
			break;

	/*****************************************************************************************************************
	 * The above case are intended as for HDAU (NVIDIA) device onboard audio for GFX card with Audio controller HDMi *
	 *****************************************************************************************************************/
		case HDA_NVIDIA_GK107:
		case HDA_NVIDIA_GF110_1:
		case HDA_NVIDIA_GF110_2:
		case HDA_NVIDIA_GK106:
		case HDA_NVIDIA_GK104:
		case HDA_NVIDIA_GF119:
		case HDA_NVIDIA_GT116:
		case HDA_NVIDIA_GT104:
		case HDA_NVIDIA_GT108:
		case HDA_NVIDIA_GT106:
		case HDA_NVIDIA_GT100:
		case HDA_NVIDIA_0BE4:
		case HDA_NVIDIA_0BE3:
		case HDA_NVIDIA_0BE2:
			if ( do_skip_n_devprop )
			{
				verbose("Skip Nvidia audio device!\n");
			}
			else
			{
				/* if the key value kHDAULayoutID as a value set that value, if not will assign a default layout */
				if (getValueForKey(kHDAULayoutID, &value, &len, &bootInfo->chameleonConfig) && len == HDAU_LEN * 2)
				{
					uint8_t new_HDAU_layout_id[HDAU_LEN];
					if (hex2bin(value, new_HDAU_layout_id, HDAU_LEN) == 0)
					{
						memcpy(default_HDAU_layout_id, new_HDAU_layout_id, HDAU_LEN);
						verbose("\tUsing user supplied HDAU layout-id: 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
							default_HDAU_layout_id[0], default_HDAU_layout_id[1], default_HDAU_layout_id[2], default_HDAU_layout_id[3]);
					}
				}
				else
				{
					verbose("\tUsing default HDAU layout-id: 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
						default_HDAU_layout_id[0], default_HDAU_layout_id[1], default_HDAU_layout_id[2], default_HDAU_layout_id[3]);
				}

				devprop_add_value(device, "layout-id", default_HDAU_layout_id, HDAU_LEN); /*FIX ME*/
				devprop_add_value(device, "@0,connector-type", connector_type_value, 4);
				devprop_add_value(device, "@1,connector-type", connector_type_value, 4);
				devprop_add_value(device, "hda-gfx", (uint8_t *)"onboard-2", sizeof("onboard-2"));
				devprop_add_value(device, "built-in", &BuiltIn, 1);
			}
			break;

		/**************************************************************************************************************
		 * The above case are intended as for HDAU (ATi) device onboard audio for GFX card with Audio controller HDMi *
		 **************************************************************************************************************/
		case HDA_ATI_SB450:
		case HDA_ATI_SB600:
		case HDA_ATI_HUDSON:
		case HDA_ATI_RS600:
		case HDA_ATI_RS690:
		case HDA_ATI_RS780:
		case HDA_ATI_R600:
		case HDA_ATI_RV630:
		case HDA_ATI_RV610:
		case HDA_ATI_RV670:
		case HDA_ATI_RV635:
		case HDA_ATI_RV620:
		case HDA_ATI_RV770:
		case HDA_ATI_RV730:
		case HDA_ATI_RV710:
		case HDA_ATI_RV740:
		case HDA_ATI_RV870:
		case HDA_ATI_RV840:
		case HDA_ATI_RV830:
		case HDA_ATI_RV810:
		case HDA_ATI_RV970:
		case HDA_ATI_RV940:
		case HDA_ATI_RV930:
		case HDA_ATI_RV910:
		case HDA_ATI_R1000:
		case HDA_ATI_SI:
		case HDA_ATI_VERDE:
			if ( do_skip_a_devprop )
			{
				verbose("Skip ATi/AMD audio device!\n");
			}
			else
			{
				/* if the key value kHDAULayoutID as a value set that value, if not will assign a default layout */
				if (getValueForKey(kHDAULayoutID, &value, &len, &bootInfo->chameleonConfig) && len == HDAU_LEN * 2)
				{
					uint8_t new_HDAU_layout_id[HDAU_LEN];
					if (hex2bin(value, new_HDAU_layout_id, HDAU_LEN) == 0)
					{
						memcpy(default_HDAU_layout_id, new_HDAU_layout_id, HDAU_LEN);
						verbose("\tUsing user supplied HDAU layout-id: 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
							default_HDAU_layout_id[0], default_HDAU_layout_id[1], default_HDAU_layout_id[2], default_HDAU_layout_id[3]);
					}
				}
				else
				{
					verbose("\tUsing default HDAU layout-id: 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
						default_HDAU_layout_id[0], default_HDAU_layout_id[1], default_HDAU_layout_id[2], default_HDAU_layout_id[3]);
				}

				devprop_add_value(device, "layout-id", default_HDAU_layout_id, HDAU_LEN); /*FIX ME*/
				devprop_add_value(device, "hda-gfx", (uint8_t *)"onboard-2", 10);
				devprop_add_value(device, "built-in", &BuiltIn, 1);
			}
			break;

		default:
			break;
	}

	stringdata = malloc(sizeof(uint8_t) * string->length);
	memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length);
	stringlength = string->length;

	return true;
}
Exemplo n.º 10
0
bool setup_gma_devprop(pci_dt_t *gma_dev)
{
	char				*devicepath = NULL;
	volatile uint8_t		*regs;
	uint32_t			bar[7];
	char				*model = NULL;
	uint8_t BuiltIn =		0x00;
	uint16_t			vendor_id = gma_dev->vendor_id;
	uint16_t			device_id = gma_dev->device_id;
	uint8_t ClassFix[4] =           { 0x00, 0x00, 0x03, 0x00 };
	int				n_igs = 0;
	int				len;
	const char			*value;
	devicepath = get_pci_dev_path(gma_dev);

	bar[0] = pci_config_read32(gma_dev->dev.addr, 0x10);
	regs = (uint8_t *) (bar[0] & ~0x0f);

	model = get_gma_controller_name(device_id, vendor_id);

	verbose("---------------------------------------------\n");
   	verbose("------------ INTEL DEVICE INFO --------------\n");
	verbose("---------------------------------------------\n");
	verbose("Class code: [%04x]\n%s [%04x:%04x] (rev %02x)\nSubsystem: [%04x:%04x] :: %s\n",
			gma_dev->class_id, model, gma_dev->vendor_id, gma_dev->device_id, gma_dev->revision_id, gma_dev->subsys_id.subsys.vendor_id, gma_dev->subsys_id.subsys.device_id, devicepath);

	if (!string) {
		string = devprop_create_string();
	}

	struct DevPropDevice *device = devprop_add_device(string, devicepath);
	if (!device) {
		printf("Failed initializing dev-prop string dev-entry.\n");
		pause();
		return false;
	}

	devprop_add_value(device, "model", (uint8_t*)model, (strlen(model) + 1));
	devprop_add_value(device, "device_type", (uint8_t*)"display", 8);


	switch ((device_id << 16) | vendor_id)
	{
        case GMA_IRONLAKE_D_G: // 0042
        case GMA_IRONLAKE_M_G: // 0046
            devprop_add_value(device, "built-in", &BuiltIn, 1);
            devprop_add_value(device, "class-code", ClassFix, 4);
            devprop_add_value(device, "hda-gfx",			(uint8_t *)"onboard-1", 10);
            devprop_add_value(device, "AAPL,os-info",			HDx000_os_info, 20);
            break;
            /* 27A2, 27AE, 27A6, A001, A011, A012, */
        case GMA_I945_GM: // Mobile GMA950 Mobile GMA3150
        case GMA_I945_GME:
        //case GMA_945GM:
        case GMA_PINEVIEW_G:
        case GMA_PINEVIEW_M:
        case GMA_GMA3150_M:
            devprop_add_value(device, "AAPL,HasPanel", reg_TRUE, 4);
            devprop_add_value(device, "built-in", &BuiltIn, 1);
            devprop_add_value(device, "class-code", ClassFix, 4);
            break;

            /* 2772 ,2776, A002 */
        case GMA_I945_G: // Desktop GMA950 Desktop GMA3150
        //case GMA_82945G:
        case GMA_GMA3150_D:
            BuiltIn = 0x01;
            devprop_add_value(device, "built-in", &BuiltIn, 1);
            devprop_add_value(device, "class-code", ClassFix, 4);
            break;

            /* 2A02, 2A12, 2A13, 2A42, 2A43 */
        case GMA_I965_GM: // GMAX3100
        case GMA_I965_GME:
        //case 0x80862A13:
        case GMA_GM45_GM:
        //case GMA_GM45_GM2:
            devprop_add_value(device, "AAPL,HasPanel",                  GMAX3100_vals[0], 4);
            devprop_add_value(device, "AAPL,SelfRefreshSupported",	GMAX3100_vals[1], 4);
            devprop_add_value(device, "AAPL,aux-power-connected",	GMAX3100_vals[2], 4);
            devprop_add_value(device, "AAPL,backlight-control",         GMAX3100_vals[3], 4);
            devprop_add_value(device, "AAPL00,blackscreen-preferences",	GMAX3100_vals[4], 4);
            devprop_add_value(device, "AAPL01,BacklightIntensity",	GMAX3100_vals[5], 4);
            devprop_add_value(device, "AAPL01,blackscreen-preferences",	GMAX3100_vals[6], 4);
            devprop_add_value(device, "AAPL01,DataJustify",             GMAX3100_vals[7], 4);
            devprop_add_value(device, "AAPL01,Depth",                   GMAX3100_vals[8], 4);
            devprop_add_value(device, "AAPL01,Dither",                  GMAX3100_vals[9], 4);
            devprop_add_value(device, "AAPL01,DualLink",                GMAX3100_vals[10], 4);
            devprop_add_value(device, "AAPL01,Height",                  GMAX3100_vals[11], 4);
            devprop_add_value(device, "AAPL01,Interlace",               GMAX3100_vals[12], 4);
            devprop_add_value(device, "AAPL01,Inverter",                GMAX3100_vals[13], 4);
            devprop_add_value(device, "AAPL01,InverterCurrent",         GMAX3100_vals[14], 4);
            devprop_add_value(device, "AAPL01,InverterCurrency",	GMAX3100_vals[15], 4);
            devprop_add_value(device, "AAPL01,LinkFormat",              GMAX3100_vals[16], 4);
            devprop_add_value(device, "AAPL01,LinkType",                GMAX3100_vals[17], 4);
            devprop_add_value(device, "AAPL01,Pipe",                    GMAX3100_vals[18], 4);
            devprop_add_value(device, "AAPL01,PixelFormat",             GMAX3100_vals[19], 4);
            devprop_add_value(device, "AAPL01,Refresh",                 GMAX3100_vals[20], 4);
            devprop_add_value(device, "AAPL01,Stretch",                 GMAX3100_vals[21], 4);
            //devprop_add_value(device, "AAPL01,InverterFrequency",	GMAX3100_vals[22], 4);
            devprop_add_value(device, "class-code",                     ClassFix, 4);
            break;

            /* 0106 */
        case GMA_SANDYBRIDGE_M_GT1: // HD Graphics 2000 Mobile
            devprop_add_value(device, "class-code", ClassFix, 4);
            devprop_add_value(device, "hda-gfx",			(uint8_t *)"onboard-1", 10);
            devprop_add_value(device, "AAPL00,PixelFormat",		HD2000_vals[0], 4);
            devprop_add_value(device, "AAPL00,T1",			HD2000_vals[1], 4);
            devprop_add_value(device, "AAPL00,T2",			HD2000_vals[2], 4);
            devprop_add_value(device, "AAPL00,T3",			HD2000_vals[3], 4);
            devprop_add_value(device, "AAPL00,T4",			HD2000_vals[4], 4);
            devprop_add_value(device, "AAPL00,T5",			HD2000_vals[5], 4);
            devprop_add_value(device, "AAPL00,T6",			HD2000_vals[6], 4);
            devprop_add_value(device, "AAPL00,T7",			HD2000_vals[7], 4);
            devprop_add_value(device, "AAPL00,LinkType",		HD2000_vals[8], 4);
            devprop_add_value(device, "AAPL00,LinkFormat",		HD2000_vals[9], 4);
            devprop_add_value(device, "AAPL00,DualLink",		HD2000_vals[10], 4);
            devprop_add_value(device, "AAPL00,Dither",			HD2000_vals[11], 4);
            devprop_add_value(device, "AAPL00,DataJustify",		HD3000_vals[12], 4);
            devprop_add_value(device, "graphic-options",		HD2000_vals[13], 4);
            devprop_add_value(device, "AAPL,tbl-info",			HD2000_tbl_info, 18);
            devprop_add_value(device, "AAPL,os-info",			HD2000_os_info, 20);
            break;

            /* 0116, 0126 */
        case GMA_SANDYBRIDGE_M_GT2: // HD Graphics 3000 Mobile
        case GMA_SANDYBRIDGE_M_GT2_PLUS:
            devprop_add_value(device, "class-code",			ClassFix, 4);
            devprop_add_value(device, "hda-gfx",			(uint8_t *)"onboard-1", 10);
            devprop_add_value(device, "AAPL00,PixelFormat",		HD3000_vals[0], 4);
            devprop_add_value(device, "AAPL00,T1",			HD3000_vals[1], 4);
            devprop_add_value(device, "AAPL00,T2",			HD3000_vals[2], 4);
            devprop_add_value(device, "AAPL00,T3",			HD3000_vals[3], 4);
            devprop_add_value(device, "AAPL00,T4",			HD3000_vals[4], 4);
            devprop_add_value(device, "AAPL00,T5",			HD3000_vals[5], 4);
            devprop_add_value(device, "AAPL00,T6",			HD3000_vals[6], 4);
            devprop_add_value(device, "AAPL00,T7",			HD3000_vals[7], 4);
            devprop_add_value(device, "AAPL00,LinkType",		HD3000_vals[8], 4);
            devprop_add_value(device, "AAPL00,LinkFormat",		HD3000_vals[9], 4);
            devprop_add_value(device, "AAPL00,DualLink",		HD3000_vals[10], 4);
            devprop_add_value(device, "AAPL00,Dither",			HD3000_vals[11], 4);
            devprop_add_value(device, "AAPL00,DataJustify",		HD3000_vals[12], 4);
            devprop_add_value(device, "graphic-options",		HD3000_vals[13], 4);
            devprop_add_value(device, "AAPL,tbl-info",			HD3000_tbl_info, 18);
            devprop_add_value(device, "AAPL,os-info",			HD3000_os_info, 20);
            devprop_add_value(device, "AAPL,snb-platform-id",		HD3000_vals[16], 4);// previusly commented
            break;

        /* 0102 */
        /* HD Graphics 2000 */
        case GMA_SANDYBRIDGE_GT1: // 0102
            device_id = 0x00000102;					// Inject a valid mobile GPU device id instead of patching kexts
            devprop_add_value(device, "built-in",			&BuiltIn, 1);
            devprop_add_value(device, "class-code",			ClassFix, 4);
            devprop_add_value(device, "device-id",			(uint8_t*)&device_id, sizeof(device_id));
            devprop_add_value(device, "hda-gfx",			(uint8_t *)"onboard-1", 10);
            devprop_add_value(device, "AAPL,tbl-info",			HD2000_tbl_info, 18);
            devprop_add_value(device, "AAPL,os-info",			HD2000_os_info, 20);
            break;

        /* Sandy Bridge */
        /* HD Graphics 3000 */
        case GMA_SANDYBRIDGE_GT2: // 0112
        case GMA_SANDYBRIDGE_GT2_PLUS: // 0122
            devprop_add_value(device, "built-in",			&BuiltIn, 1);
            devprop_add_value(device, "class-code",			ClassFix, 4);
            device_id = 0x00000126;					// Inject a valid mobile GPU device id instead of patching kexts
            devprop_add_value(device, "device-id",			(uint8_t*)&device_id, sizeof(device_id));
            devprop_add_value(device, "hda-gfx",			(uint8_t *)"onboard-1", 10);
            devprop_add_value(device, "AAPL,tbl-info",			HD3000_tbl_info, 18);
            devprop_add_value(device, "AAPL,os-info",			HD3000_os_info, 20);
            break;

        /* Ivy Bridge */
        /* HD Graphics 4000, HD Graphics 4000 Mobile, HD Graphics P4000, HD Graphics 2500 HD, Graphics 2500 Mobile */
        case GMA_IVYBRIDGE_D_GT1: // 0152
        case GMA_IVYBRIDGE_M_GT1: // 0156
        case GMA_IVYBRIDGE_S_GT1: // 015A
        case GMA_IVYBRIDGE_S_GT3: // 015e
        case GMA_IVYBRIDGE_D_GT2: // 0162
        case GMA_IVYBRIDGE_M_GT2: // 0166
        case GMA_IVYBRIDGE_S_GT2: // 016A
        case GMA_IVYBRIDGE_S_GT4: // 0172
        case GMA_IVYBRIDGE_S_GT5: // 0176

		if (getValueForKey(kAAPLCustomIG, &value, &len, &bootInfo->chameleonConfig) && len == AAPL_LEN_IVY * 2)
		{
			uint8_t new_aapl0[AAPL_LEN_IVY];

			if (hex2bin(value, new_aapl0, AAPL_LEN_IVY) == 0)
			{
				memcpy(default_aapl_ivy, new_aapl0, AAPL_LEN_IVY);

				verbose("Using user supplied AAPL,ig-platform-id\n");
				verbose("AAPL,ig-platform-id: %02x%02x%02x%02x\n",
				default_aapl_ivy[0], default_aapl_ivy[1], default_aapl_ivy[2], default_aapl_ivy[3]);
			}
			devprop_add_value(device, "AAPL,ig-platform-id", default_aapl_ivy, AAPL_LEN_IVY);
		}
		else if (getIntForKey(kIntelCapriFB, &n_igs, &bootInfo->chameleonConfig))
		{
			if ((n_igs >= 0) || (n_igs <= 11))
			{
				verbose("AAPL,ig-platform-id was set in org.chameleon.Boot.plist with value %d\n", n_igs);
				devprop_add_value(device, "AAPL,ig-platform-id", ivy_bridge_ig_vals[n_igs], 4);
			}
			else
			{
				verbose("AAPL,ig-platform-id was set in org.chameleon.Boot.plist with bad value please choose a number between 0 and 11.\n");
			}
		}
		else
		{
			uint32_t ig_platform_id;
			uint32_t ram = (((getVBEVideoRam() + 512) / 1024) + 512) / 1024;
			switch (ram)
			{
				case 96:
					ig_platform_id = 0x01660000; // 96mb Mobile
					break;

				case 64:
					ig_platform_id = 0x01660009; // 64mb Mobile
					break;

				case 32:
					ig_platform_id = 0x01620005; // 32mb Desktop
					break;

				default:
					printf("Please specify 96, 64, or 32MB RAM for the HD4000 in the bios.\n"
					"The selected %dMB RAM configuration is not supported for the  HD4000.\n", ram);
					pause();
					return false;	// Exit early before the AAPL,ig-platform-id property is set.
					break;
			}
			devprop_add_value(device, "AAPL,ig-platform-id", (uint8_t *)&ig_platform_id, 4);
		}

		devprop_add_value(device, "AAPL00,DualLink",    HD4000_vals[10], 4);
		devprop_add_value(device, "built-in", &BuiltIn, 1);
		devprop_add_value(device, "class-code", ClassFix, 4);
		devprop_add_value(device, "hda-gfx", (uint8_t *)"onboard-1", 10);
		break;

        /* Haswell */
        /* HD Graphics 5000, HD Graphics 5000 Mobile, HD Graphics P5000, HD Graphics 4600, HD Graphics 4600 Mobile */
        //case 0x80860090:
        //case 0x80860091:
        //case 0x80860092:
        case GMA_HASWELL_D_GT1: // 0402
        case GMA_HASWELL_M_GT1: // 0406
        case GMA_HASWELL_S_GT1: // 040a
        case GMA_HASWELL_D_GT2: // 0412
        case GMA_HASWELL_M_GT2: // 0416
        case GMA_HASWELL_S_GT2: // 041a
        case GMA_HASWELL_E_GT1: // 040e
        case GMA_HASWELL_E_GT2: // 041e
        case GMA_HASWELL_E_GT3: // 042e
        case GMA_HASWELL_D_GT3: // 0422
        case GMA_HASWELL_M_GT3: // 0426
        case GMA_HASWELL_S_GT3: // 042a
        case GMA_HASWELL_ULT_M_GT1: // 0a06
        case GMA_HASWELL_ULT_E_GT1: // 0a0e
        case GMA_HASWELL_ULT_M_GT2: // 0a16
        case GMA_HASWELL_ULT_E_GT2: // 0a1e
        case GMA_HASWELL_ULT_D_GT3: // 0a22
        case GMA_HASWELL_ULT_M_GT3: // 0a26
        case GMA_HASWELL_ULT_S_GT3: // 0a2a
        case GMA_HASWELL_ULT_E_GT3: // 0a2e
        case GMA_HASWELL_SDV_D_GT1_IG: // 0c02
        case GMA_HASWELL_SDV_M_GT1_IG: // 0c06
        case GMA_HASWELL_SDV_D_GT2_IG: // 0c12
        case GMA_HASWELL_SDV_M_GT2_IG: // 0c16
        case GMA_HASWELL_SDV_D_GT2_PLUS_IG: // 0c22
        case GMA_HASWELL_SDV_M_GT2_PLUS_IG: // 0c26
        case GMA_HASWELL_CRW_D_GT1: // 0d02
        case GMA_HASWELL_CRW_D_GT2: // 0d12
        case GMA_HASWELL_CRW_D_GT3: // 0d22
        case GMA_HASWELL_CRW_M_GT1: // 0d06
        case GMA_HASWELL_CRW_M_GT2: // 0d16
        case GMA_HASWELL_CRW_M_GT3: // 0d26
        case GMA_HASWELL_CRW_S_GT1: // 0d0a
        case GMA_HASWELL_CRW_S_GT2: // 0d1a
        case GMA_HASWELL_CRW_S_GT3: // 0d2a
        case GMA_HASWELL_CRW_B_GT1: // 0d0b
        case GMA_HASWELL_CRW_B_GT2: // 0d1b
        case GMA_HASWELL_CRW_B_GT3: // 0d2b
        case GMA_HASWELL_CRW_E_GT1: // 0d0e
        case GMA_HASWELL_CRW_E_GT2: // 0d1e
        case GMA_HASWELL_CRW_E_GT3: // 0d2e
        case GMA_HASWELL_CRW_M_GT2_PLUS_IG: // 0d36

            if (getValueForKey(kAAPLCustomIG, &value, &len, &bootInfo->chameleonConfig) && len == AAPL_LEN_HSW * 2)
            {
                uint8_t new_aapl0[AAPL_LEN_HSW];
                
                if (hex2bin(value, new_aapl0, AAPL_LEN_HSW) == 0)
                {
                    memcpy(default_aapl_haswell, new_aapl0, AAPL_LEN_HSW);
                    
                    verbose("Using user supplied AAPL,ig-platform-id\n");
                    verbose("AAPL,ig-platform-id: %02x%02x%02x%02x\n",
                            default_aapl_haswell[0], default_aapl_haswell[1], default_aapl_haswell[2], default_aapl_haswell[3]);
                }
                devprop_add_value(device, "AAPL,ig-platform-id", default_aapl_haswell, AAPL_LEN_HSW);
            }
            else if (getIntForKey(kIntelAzulFB, &n_igs, &bootInfo->chameleonConfig))
            {
                if ((n_igs >= 0) || (n_igs <= 15))
                {
                    verbose("AAPL,ig-platform-id was set in org.chameleon.Boot.plist with value %d\n", n_igs);
                    devprop_add_value(device, "AAPL,ig-platform-id", haswell_ig_vals[n_igs], 4);
                }
                else
                {
                    verbose("AAPL,ig-platform-id was set in org.chameleon.Boot.plist with bad value please choose a number between 0 and 15.\n");
                }
            }
            else
            {
		uint32_t ig_platform_id = 0x0000260c; // set the default platform ig
		devprop_add_value(device, "AAPL,ig-platform-id", (uint8_t *)&ig_platform_id, 4);
            }

            devprop_add_value(device, "AAPL00,DualLink",    HD4000_vals[10], 4);
            devprop_add_value(device, "built-in", &BuiltIn, 1);
            devprop_add_value(device, "class-code", ClassFix, 4);
            devprop_add_value(device, "hda-gfx", (uint8_t *)"onboard-1", 10);
            break;

        default:
            break;
	}

	stringdata = malloc(sizeof(uint8_t) * string->length);
	if (!stringdata)
	{
		printf("No stringdata.\n");
		pause();
		return false;
	}

	verbose("---------------------------------------------\n");
	memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length);
	stringlength = string->length;

	return true;
}
Exemplo n.º 11
0
void setup_pci_devs(pci_dt_t *pci_dt)
{
    char *devicepath;
    bool doit, do_eth_devprop, do_wifi_devprop, /*do_usb_devprop,*/ do_gfx_devprop, do_enable_hpet, do_hda_devprop = false;
    pci_dt_t *current = pci_dt;

    getBoolForKey(kEthernetBuiltIn, &do_eth_devprop, &bootInfo->chameleonConfig);
    getBoolForKey(kEnableWifi, &do_wifi_devprop, &bootInfo->chameleonConfig);
    getBoolForKey(kGraphicsEnabler, &do_gfx_devprop, &bootInfo->chameleonConfig);
//	getBoolForKey(kUsbInject, &do_usb_devprop, &bootInfo->chameleonConfig);
    getBoolForKey(kHDAEnabler, &do_hda_devprop, &bootInfo->chameleonConfig);
    getBoolForKey(kForceHPET, &do_enable_hpet, &bootInfo->chameleonConfig);

    while (current)
    {
        devicepath = get_pci_dev_path(current);

        switch (current->class_id)
        {
        case PCI_CLASS_BRIDGE_HOST:
            //DBG("Setup BRIDGE_HOST \n");
            if (current->dev.addr == PCIADDR(0, 0, 0))
            {
                dram_controller_dev = current;
            }
            break;

        case PCI_CLASS_NETWORK_ETHERNET:
            //DBG("Setup ETHERNET %s enabled\n", do_eth_devprop?"":"no");
            if (do_eth_devprop)
            {
                setup_eth_builtin(current);
            }
            break;

        case PCI_CLASS_NETWORK_OTHER:
            //DBG("Setup WIRELESS %s enabled\n", do_wifi_devprop?"":"no");
            if (do_wifi_devprop)
            {
                setup_wifi_airport(current);
            }
            break;

        case PCI_CLASS_DISPLAY_VGA:
            //DBG("GraphicsEnabler %s enabled\n", do_gfx_devprop?"":"no");
            if (do_gfx_devprop)
            {
                switch (current->vendor_id)
                {
                case PCI_VENDOR_ID_ATI:
                    if (getBoolForKey(kSkipAtiGfx, &doit, &bootInfo->chameleonConfig) && doit)
                    {
                        verbose("Skip ATi/AMD gfx device!\n");
                    }
                    else
                    {
                        setup_ati_devprop(current);
                    }
                    break;

                case PCI_VENDOR_ID_INTEL:
                    if (getBoolForKey(kSkipIntelGfx, &doit, &bootInfo->chameleonConfig) && doit)
                    {
                        verbose("Skip Intel gfx device!\n");
                    }
                    else
                    {
                        setup_gma_devprop(current);
                    }
                    break;

                case PCI_VENDOR_ID_NVIDIA:
                    if (getBoolForKey(kSkipNvidiaGfx, &doit, &bootInfo->chameleonConfig) && doit)
                    {
                        verbose("Skip Nvidia gfx device!\n");
                    }
                    else
                    {
                        setup_nvidia_devprop(current);
                    }
                    break;
                }
            }
            break;

        case PCI_CLASS_MULTIMEDIA_AUDIO_DEV:
            //DBG("Setup HDEF %s enabled\n", do_hda_devprop?"":"no");
            if (do_hda_devprop)
            {
                setup_hda_devprop(current);
            }
            break;

        case PCI_CLASS_SERIAL_USB:
            //DBG("USB fix \n");
            notify_usb_dev(current);
            /*if (do_usb_devprop)
            {
            		set_usb_devprop(current);
            	}*/
            break;

        case PCI_CLASS_BRIDGE_ISA:
            //DBG("Force HPET %s enabled\n", do_enable_hpet?"":"no");
            if (do_enable_hpet)
            {
                force_enable_hpet(current);
            }
            break;
        }

        execute_hook("PCIDevice", current, NULL, NULL, NULL);
        //DBG("setup_pci_devs current devID=%08x\n", current->device_id);
        setup_pci_devs(current->children);
        current = current->next;
    }
}
Exemplo n.º 12
0
bool setup_gma_devprop(pci_dt_t *gma_dev)
{
	char					*devicepath;
	volatile uint8_t		*regs;
	uint32_t				bar[7];
	char					*model;
	uint8_t BuiltIn =		0x00;
	uint8_t ClassFix[4] =	{ 0x00, 0x00, 0x03, 0x00 };
	
	devicepath = get_pci_dev_path(gma_dev);
	
	bar[0] = pci_config_read32(gma_dev->dev.addr, 0x10);
	regs = (uint8_t *) (bar[0] & ~0x0f);
	
	model = get_gma_model((gma_dev->vendor_id << 16) | gma_dev->device_id);
	
	verbose("Intel %s [%04x:%04x] :: %s\n",
			model, gma_dev->vendor_id, gma_dev->device_id, devicepath);
	
	if (!string)
		string = devprop_create_string();
	
	struct DevPropDevice *device = malloc(sizeof(struct DevPropDevice));
	device = devprop_add_device(string, devicepath);
	
	if (!device)
	{
		printf("Failed initializing dev-prop string dev-entry, press any key...\n");
		
		getchar();
		return false;
	}
	
	devprop_add_value(device, "model", (uint8_t*)model, (strlen(model) + 1));
	devprop_add_value(device, "device_type", (uint8_t*)"display", 8);	
	
	if ((model == (char *)"Mobile GMA950")
		|| (model == (char *)"Mobile GMA3150"))
	{
		devprop_add_value(device, "AAPL,HasPanel", reg_TRUE, 4);
		devprop_add_value(device, "built-in", &BuiltIn, 1);
		devprop_add_value(device, "class-code", ClassFix, 4);
	}
	else if ((model == (char *)"Desktop GMA950")
			|| (model == (char *)"Desktop GMA3150"))
	{
		BuiltIn = 0x01;
		devprop_add_value(device, "built-in", &BuiltIn, 1);
		devprop_add_value(device, "class-code", ClassFix, 4);
	}
	else if (model == (char *)"GMAX3100")
	{
		devprop_add_value(device, "AAPL,HasPanel",					GMAX3100_vals[0], 4);
		devprop_add_value(device, "AAPL,SelfRefreshSupported",		GMAX3100_vals[1], 4);
		devprop_add_value(device, "AAPL,aux-power-connected",		GMAX3100_vals[2], 4);
		devprop_add_value(device, "AAPL,backlight-control",			GMAX3100_vals[3], 4);
		devprop_add_value(device, "AAPL00,blackscreen-preferences", GMAX3100_vals[4], 4);
		devprop_add_value(device, "AAPL01,BacklightIntensity",		GMAX3100_vals[5], 4);
		devprop_add_value(device, "AAPL01,blackscreen-preferences", GMAX3100_vals[6], 4);
		devprop_add_value(device, "AAPL01,DataJustify",				GMAX3100_vals[7], 4);
		devprop_add_value(device, "AAPL01,Depth",					GMAX3100_vals[8], 4);
		devprop_add_value(device, "AAPL01,Dither",					GMAX3100_vals[9], 4);
		devprop_add_value(device, "AAPL01,DualLink",				GMAX3100_vals[10], 4);
		devprop_add_value(device, "AAPL01,Height",					GMAX3100_vals[11], 4);
		devprop_add_value(device, "AAPL01,Interlace",				GMAX3100_vals[12], 4);
		devprop_add_value(device, "AAPL01,Inverter",				GMAX3100_vals[13], 4);
		devprop_add_value(device, "AAPL01,InverterCurrent",			GMAX3100_vals[14], 4);
		devprop_add_value(device, "AAPL01,InverterCurrency",		GMAX3100_vals[15], 4);
		devprop_add_value(device, "AAPL01,LinkFormat",				GMAX3100_vals[16], 4);
		devprop_add_value(device, "AAPL01,LinkType",				GMAX3100_vals[17], 4);
		devprop_add_value(device, "AAPL01,Pipe",					GMAX3100_vals[18], 4);
		devprop_add_value(device, "AAPL01,PixelFormat",				GMAX3100_vals[19], 4);
		devprop_add_value(device, "AAPL01,Refresh",					GMAX3100_vals[20], 4);
		devprop_add_value(device, "AAPL01,Stretch",					GMAX3100_vals[21], 4);
		devprop_add_value(device, "class-code",						ClassFix, 4);
	}
		
	stringdata = malloc(sizeof(uint8_t) * string->length);
	if (!stringdata)
	{
		printf("no stringdata press a key...\n");
		getchar();
		return false;
	}
	
	memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length);
	stringlength = string->length;
	
	return true;
}