void ohci_init(void *data) { if (! CONFIG_USB_OHCI) return; struct usb_s *cntl = data; // XXX - don't call pci_config_XXX from a thread cntl->type = USB_TYPE_OHCI; u32 baseaddr = pci_config_readl(cntl->bdf, PCI_BASE_ADDRESS_0); cntl->ohci.regs = (void*)(baseaddr & PCI_BASE_ADDRESS_MEM_MASK); dprintf(3, "OHCI init on dev %02x:%02x.%x (regs=%p)\n" , pci_bdf_to_bus(cntl->bdf), pci_bdf_to_dev(cntl->bdf) , pci_bdf_to_fn(cntl->bdf), cntl->ohci.regs); // Enable bus mastering and memory access. pci_config_maskw(cntl->bdf, PCI_COMMAND , 0, PCI_COMMAND_MASTER|PCI_COMMAND_MEMORY); // XXX - check for and disable SMM control? // Disable interrupts writel(&cntl->ohci.regs->intrdisable, ~0); writel(&cntl->ohci.regs->intrstatus, ~0); // Allocate memory struct ohci_hcca *hcca = memalign_high(256, sizeof(*hcca)); struct ohci_ed *control_ed = malloc_high(sizeof(*control_ed)); if (!hcca || !control_ed) { dprintf(1, "No ram for ohci init\n"); return; } memset(hcca, 0, sizeof(*hcca)); memset(control_ed, 0, sizeof(*control_ed)); control_ed->hwINFO = ED_SKIP; cntl->ohci.control_ed = control_ed; int ret = start_ohci(cntl, hcca); if (ret) goto err; int count = check_ohci_ports(cntl); if (! count) goto err; return; err: stop_ohci(cntl); free(hcca); free(control_ed); }
static int smbios_romfile_setup(void) { struct romfile_s *f_anchor = romfile_find("etc/smbios/smbios-anchor"); struct romfile_s *f_tables = romfile_find("etc/smbios/smbios-tables"); struct smbios_entry_point ep; struct smbios_type_0 *t0; u16 qtables_len, need_t0 = 1; u8 *qtables, *tables; if (!f_anchor || !f_tables || f_anchor->size != sizeof(ep)) return 0; f_anchor->copy(f_anchor, &ep, f_anchor->size); if (f_tables->size != ep.structure_table_length) return 0; qtables = malloc_tmphigh(f_tables->size); if (!qtables) { warn_noalloc(); return 0; } f_tables->copy(f_tables, qtables, f_tables->size); ep.structure_table_address = (u32)qtables; /* for smbios_next(), below */ /* did we get a type 0 structure ? */ for (t0 = smbios_next(&ep, NULL); t0; t0 = smbios_next(&ep, t0)) if (t0->header.type == 0) { need_t0 = 0; break; } qtables_len = ep.structure_table_length; if (need_t0) { /* common case: add our own type 0, with 3 strings and 4 '\0's */ u16 t0_len = sizeof(struct smbios_type_0) + strlen(BIOS_NAME) + strlen(VERSION) + strlen(BIOS_DATE) + 4; ep.structure_table_length += t0_len; if (t0_len > ep.max_structure_size) ep.max_structure_size = t0_len; ep.number_of_structures++; } /* allocate final blob and record its address in the entry point */ if (ep.structure_table_length > BUILD_MAX_SMBIOS_FSEG) tables = malloc_high(ep.structure_table_length); else tables = malloc_fseg(ep.structure_table_length); if (!tables) { warn_noalloc(); free(qtables); return 0; } ep.structure_table_address = (u32)tables; /* populate final blob */ if (need_t0) tables = smbios_new_type_0(tables, BIOS_NAME, VERSION, BIOS_DATE); memcpy(tables, qtables, qtables_len); free(qtables); /* finalize entry point */ ep.checksum -= checksum(&ep, 0x10); ep.intermediate_checksum -= checksum((void *)&ep + 0x10, ep.length - 0x10); copy_smbios(&ep); return 1; }