status_t init_driver(void) { SHOW_FLOW0(3, ""); if (get_module(B_PCI_MODULE_NAME, (module_info **)&pci_bus) != B_OK) return B_ERROR; /* get a handle for the agp bus if it exists */ get_module(B_AGP_GART_MODULE_NAME, (module_info **)&sAGP); /* driver private data */ devices = (radeon_devices *)calloc(1, sizeof(radeon_devices)); if (devices == NULL) { put_module(B_PCI_MODULE_NAME); if (sAGP != NULL) put_module(B_AGP_GART_MODULE_NAME); return B_ERROR; } (void)INIT_BEN(devices->kernel, "Radeon Kernel"); GetDriverSettings(); Radeon_ProbeDevices(); return B_OK; }
status_t init_driver(void) { status_t ret = ENODEV; int i; TRACE("init_driver\n"); if (get_module(B_PCI_MODULE_NAME, (module_info **)&gPciBus) != B_OK) { ret = B_ERROR; goto done; } if (!(gPd = calloc(1, sizeof(DeviceData)))) { put_module(B_PCI_MODULE_NAME); ret = B_ERROR; goto done; } /* Remember the PCI information */ for (i = 0; (*gPciBus->get_nth_pci_info)(i, &gPd->pcii) == B_OK; i++) if (gPd->pcii.vendor_id == PCI_VENDOR_ID_VMWARE && gPd->pcii.device_id == PCI_DEVICE_ID_VMWARE_SVGA2) { ret = B_OK; break; } if (ret != B_OK) { free(gPd); put_module(B_PCI_MODULE_NAME); goto done; } /* Create a benaphore for exclusive access in OpenHook/FreeHook */ INIT_BEN(gPd->kernel); /* The device name */ gPd->names[0] = strdup("graphics/vmware"); gPd->names[1] = NULL; /* Usual initializations */ gPd->isOpen = 0; gPd->sharedArea = -1; gPd->si = NULL; done: TRACE("init_driver: %ld\n", ret); return ret; }
status_t init_driver(void) { /* get a handle for the pci bus */ if (get_module(B_PCI_MODULE_NAME, (module_info **)&pci_bus) != B_OK) return B_ERROR; /* driver private data */ pd = (DeviceData *)calloc(1, sizeof(DeviceData)); if (!pd) { put_module(B_PCI_MODULE_NAME); return B_ERROR; } /* initialize the benaphore */ INIT_BEN(pd->kernel); /* find all of our supported devices */ et6000ProbeDevices(); #if DEBUG > 0 add_debugger_command("et6000dump", et6000dump, "dump ET6000 kernel driver persistant data"); #endif return B_OK; }
status_t init_driver(void) { void *settings_handle; // get driver/accelerant settings, apsed settings_handle = load_driver_settings (DRIVER_PREFIX ".settings"); if (settings_handle != NULL) { const char *item; char *end; uint32 value; // for driver item = get_driver_parameter (settings_handle, "accelerant", "", ""); if ((strlen (item) > 0) && (strlen (item) < sizeof (current_settings.accelerant) - 1)) { strcpy (current_settings.accelerant, item); } current_settings.dumprom = get_driver_boolean_parameter (settings_handle, "dumprom", false, false); // for accelerant item = get_driver_parameter (settings_handle, "logmask", "0x00000000", "0x00000000"); value = strtoul (item, &end, 0); if (*end == '\0') current_settings.logmask = value; item = get_driver_parameter (settings_handle, "memory", "0", "0"); value = strtoul (item, &end, 0); if (*end == '\0') current_settings.memory = value; current_settings.hardcursor = get_driver_boolean_parameter (settings_handle, "hardcursor", false, false); current_settings.usebios = get_driver_boolean_parameter (settings_handle, "usebios", false, false); current_settings.switchhead = get_driver_boolean_parameter (settings_handle, "switchhead", false, false); current_settings.force_pci = get_driver_boolean_parameter (settings_handle, "force_pci", false, false); current_settings.unhide_fw = get_driver_boolean_parameter (settings_handle, "unhide_fw", false, false); current_settings.pgm_panel = get_driver_boolean_parameter (settings_handle, "pgm_panel", false, false); unload_driver_settings (settings_handle); } /* get a handle for the pci bus */ if (get_module(B_PCI_MODULE_NAME, (module_info **)&pci_bus) != B_OK) return B_ERROR; /* get a handle for the isa bus */ if (get_module(B_ISA_MODULE_NAME, (module_info **)&isa_bus) != B_OK) { put_module(B_PCI_MODULE_NAME); return B_ERROR; } /* get a handle for the agp bus if it exists */ get_module(B_AGP_GART_MODULE_NAME, (module_info **)&agp_bus); /* driver private data */ pd = (DeviceData *)calloc(1, sizeof(DeviceData)); if (!pd) { if (agp_bus) put_module(B_AGP_GART_MODULE_NAME); put_module(B_ISA_MODULE_NAME); put_module(B_PCI_MODULE_NAME); return B_ERROR; } /* initialize the benaphore */ INIT_BEN(pd->kernel); /* find all of our supported devices */ probe_devices(); return B_OK; }
/* Initialize the accelerant. the_fd is the file handle of the device (in /dev/graphics) that has been opened by the app_server (or some test harness). We need to determine if the kernel driver and the accelerant are compatible. If they are, get the accelerant ready to handle other hook functions and report success or failure. */ status_t INIT_ACCELERANT(int the_fd) { status_t result; int pointer_reservation; //mem reserved for pointer int cnt; //used for iteration through the overlay buffers if (0) { time_t now = time (NULL); // LOG not available from here to next LOG: NULL si // MSG(("INIT_ACCELERANT: booted since %f ms %s\n", system_time()/1000.0, real_time_clock())); MSG(("INIT_ACCELERANT: %s", ctime (&now))); } /* note that we're the primary accelerant (accelerantIsClone is global) */ accelerantIsClone = 0; /* do the initialization common to both the primary and the clones */ result = init_common(the_fd); /* bail out if the common initialization failed */ if (result != B_OK) goto error0; // LOG now available: !NULL si /* ensure that INIT_ACCELERANT is executed just once (copies should be clones) */ if (si->accelerant_in_use) { result = B_NOT_ALLOWED; goto error1; } /* assume G450/G550 signals are connected straight through (before powerup) */ si->crossed_conns = false; /* call the device specific init code */ result = gx00_general_powerup(); /* bail out if it failed */ if (result != B_OK) goto error1; /* Now would be a good time to figure out what video modes your card supports. We'll place the list of modes in another shared area so all of the copies of the driver can see them. The primary copy of the accelerant (ie the one initialized with this routine) will own the "one true copy" of the list. Everybody else get's a read-only clone. */ result = create_mode_list(); if (result != B_OK) { goto error1; } /* Put the cursor at the start of the frame buffer. The typical 64x64 4 color (black, white, transparent, inverse) takes up 1024 bytes of RAM. */ /* Initialize the rest of the cursor information while we're here */ si->cursor.width = 16; si->cursor.height = 16; si->cursor.hot_x = 0; si->cursor.hot_y = 0; si->cursor.x = 0; si->cursor.y = 0; /* Put the frame buffer immediately following the cursor data. We store this info in a frame_buffer_config structure to make it convienient to return to the app_server later. */ pointer_reservation = 0; /* MIL 1/2 cards have a seperate buffer for the cursorbitmap inside the DAC */ if ((si->ps.card_type >= G100) && si->settings.hardcursor) pointer_reservation = 1024; si->fbc.frame_buffer = (void *)((char *)si->framebuffer+pointer_reservation); si->fbc.frame_buffer_dma = (void *)((char *)si->framebuffer_pci+pointer_reservation); /* count of issued parameters or commands */ si->engine.last_idle = si->engine.count = 0; INIT_BEN(si->engine.lock); INIT_BEN(si->overlay.lock); for (cnt = 0; cnt < MAXBUFFERS; cnt++) { /* make sure overlay buffers are 'marked' as being free */ si->overlay.myBuffer[cnt].buffer = NULL; si->overlay.myBuffer[cnt].buffer_dma = NULL; } /* make sure overlay unit is 'marked' as being free */ si->overlay.myToken = NULL; /* note that overlay is not in use (for gx00_bes_move_overlay()) */ si->overlay.active = false; /* bail out if something failed */ if (result != B_OK) goto error1; /* initialise various cursor stuff*/ gx00_crtc_cursor_init(); /* ensure cursor state */ SHOW_CURSOR(false); /* ensure DPMS state */ si->dpms_flags = B_DPMS_ON; /* a winner! */ result = B_OK; /* ensure that INIT_ACCELERANT won't be executed again (copies should be clones) */ si->accelerant_in_use = true; goto error0; error1: /* Initialization failed after init_common() succeeded, so we need to clean up before quiting. */ uninit_common(); error0: return result; }
status_t init_driver(void) { void *settings; // get driver/accelerant settings settings = load_driver_settings(DRIVER_PREFIX ".settings"); if (settings != NULL) { const char *item; char *end; uint32 value; // for driver item = get_driver_parameter(settings, "accelerant", "", ""); if (item[0] && strlen(item) < sizeof(sSettings.accelerant) - 1) strcpy (sSettings.accelerant, item); item = get_driver_parameter(settings, "primary", "", ""); if (item[0] && strlen(item) < sizeof(sSettings.primary) - 1) strcpy(sSettings.primary, item); sSettings.dumprom = get_driver_boolean_parameter(settings, "dumprom", false, false); // for accelerant item = get_driver_parameter(settings, "logmask", "0x00000000", "0x00000000"); value = strtoul(item, &end, 0); if (*end == '\0') sSettings.logmask = value; item = get_driver_parameter(settings, "memory", "0", "0"); value = strtoul(item, &end, 0); if (*end == '\0') sSettings.memory = value; sSettings.hardcursor = get_driver_boolean_parameter(settings, "hardcursor", false, false); sSettings.usebios = get_driver_boolean_parameter(settings, "usebios", false, false); sSettings.switchhead = get_driver_boolean_parameter(settings, "switchhead", false, false); sSettings.pgm_panel = get_driver_boolean_parameter(settings, "pgm_panel", false, false); sSettings.force_sync = get_driver_boolean_parameter(settings, "force_sync", false, false); sSettings.force_ws = get_driver_boolean_parameter(settings, "force_ws", false, false); item = get_driver_parameter(settings, "gpu_clk", "0", "0"); value = strtoul(item, &end, 0); if (*end == '\0') sSettings.gpu_clk = value; item = get_driver_parameter(settings, "ram_clk", "0", "0"); value = strtoul(item, &end, 0); if (*end == '\0') sSettings.ram_clk = value; unload_driver_settings(settings); } /* get a handle for the pci bus */ if (get_module(B_PCI_MODULE_NAME, (module_info **)&pci_bus) != B_OK) return B_ERROR; /* get a handle for the isa bus */ if (get_module(B_ISA_MODULE_NAME, (module_info **)&isa_bus) != B_OK) { put_module(B_PCI_MODULE_NAME); return B_ERROR; } /* driver private data */ pd = (DeviceData *)calloc(1, sizeof(DeviceData)); if (!pd) { put_module(B_PCI_MODULE_NAME); return B_ERROR; } /* initialize the benaphore */ INIT_BEN(pd->kernel); /* find all of our supported devices */ probe_devices(); return B_OK; }