static GSList *scan(GSList *options) { struct drv_context *drvc; struct sr_config *src; GSList *l, *devices; GDir *dir; int ret; const gchar *dev_name; gchar *port = NULL; drvc = di->priv; for (l = options; l; l = l->next) { src = l->data; if (src->key == SR_CONF_CONN) { port = (char *)g_variant_get_string(src->data, NULL); break; } } devices = NULL; if (port) { if (probe_port(port, &devices) == SR_ERR_MALLOC) return NULL; } else { if (!(dir = g_dir_open("/sys/class/usb/", 0, NULL))) return NULL; while ((dev_name = g_dir_read_name(dir))) { if (strncmp(dev_name, "usbtmc", 6)) continue; port = g_strconcat("/dev/", dev_name, NULL); ret = probe_port(port, &devices); g_free(port); if (ret == SR_ERR_MALLOC) { g_dir_close(dir); return NULL; } } g_dir_close(dir); } /* Tack a copy of the newly found devices onto the driver list. */ l = g_slist_copy(devices); drvc->instances = g_slist_concat(drvc->instances, l); return devices; }
void start(uint32_t* modulep, void* physbase, void* physfree) { //Memory Init mm_init(modulep,physbase,physfree); //Memory for PCI pages_for_ahci_start_virtual = (uint64_t *)kmalloc_ahci(32*4096); pages_for_ahci_start = (uint64_t *)PADDR(pages_for_ahci_start_virtual); pages_for_ahci_start = (uint64_t *)(((uint64_t)pages_for_ahci_start+0x0FFF) & ~ 0x0FFF); pages_for_ahci_start_virtual = (uint64_t *)(((uint64_t)pages_for_ahci_start_virtual+0x0FFF) & ~ 0x0FFF); // print("\n vir %x %x", pages_for_ahci_start_virtual, pages_for_ahci_start_virtual + 32*4096); // print("\n phy %x %x", pages_for_ahci_start, pages_for_ahci_start + 32*4096); //Initial setup reload_gdt(); reload_idt(); load_irq(); setup_tss(); print_line(30, 0, "Welcome To SBUnix"); //Kernel process that will be at 0th place in ready queue struct task_struct *pcb0 = (struct task_struct *)kmalloc(sizeof(struct task_struct)); //kernel pcb0->pml4e =(uint64_t)boot_pml4e; // kernel's page table pcb0->cr3 = boot_cr3; // kernel's page table pcb0->pid = 0; // I'm kernel init process so pid 0 pcb0->stack =(uint64_t *)stack; //my stack is already created by prof :) process_count = 0; //at this point we don't have any other process in ready_queue so go ahead and create one and update this sleeping_process_count = 0; // at this point no body is sleeping // initialize processes queue int i=0; for(i=0;i<100;i++) { zombie_queue[i] = 0; // no process is zombie } ready_queue[0] =(uint64_t )pcb0; //kernel //User processes for test char fname1[]="bin/sh"; //Shell program // char fname2[]="bin/malloc"; //Scanf and malloc // char fname3[]="bin/fork"; // Fork test // char fname4[]="bin/fs"; // Fork test // char fname5[]="bin/execvpe"; // Execvpe test struct task_struct *pcb1 = malloc_pcb(fname1); // If you remove this shell wont start // struct task_struct *pcb2 = malloc_pcb(fname5); // struct task_struct *pcb3 = malloc_pcb(fname2); // struct task_struct *pcb4 = malloc_pcb(fname3); //struct task_struct *pcb5 = malloc_pcb(fname4); //print("pcb1 %x pcb2 %x rsp1 %x rsp2 %x\n",pcb1,pcb2,pcb1->rsp,pcb2->rsp); print("pointer %p",pcb1); //print("pointer %p",pcb2); //print("pointer %p",pcb3); //print("pointer %p",pcb4); //print("pointer %p",pcb5); //Initialize tarfs and Hard disk file system tarfs_init(); probe_port((HBA_MEM *)(0xFFFFFFFF00000000+(uintptr_t)bar5)); inialize_sata_table(); asm volatile("mov $0x2b,%ax"); asm volatile("ltr %ax"); init_timer(); __asm__("sti"); while(1); }
int init_sata(int dev) { struct mv_priv *priv; debug("Initialize sata dev: %d\n", dev); if (dev < 0 || dev >= CONFIG_SYS_SATA_MAX_DEVICE) { printf("Invalid sata device %d\n", dev); return -1; } priv = (struct mv_priv *)malloc(sizeof(struct mv_priv)); if (!priv) { printf("Failed to allocate memory for private sata data\n"); return -ENOMEM; } memset((void *)priv, 0, sizeof(struct mv_priv)); /* Allocate and align request buffer */ priv->crqb_alloc = malloc(sizeof(struct crqb) * REQUEST_QUEUE_SIZE + CRQB_ALIGN); if (!priv->crqb_alloc) { printf("Unable to allocate memory for request queue\n"); return -ENOMEM; } memset(priv->crqb_alloc, 0, sizeof(struct crqb) * REQUEST_QUEUE_SIZE + CRQB_ALIGN); priv->request = (struct crqb *)(((u32) priv->crqb_alloc + CRQB_ALIGN) & ~(CRQB_ALIGN - 1)); /* Allocate and align response buffer */ priv->crpb_alloc = malloc(sizeof(struct crpb) * REQUEST_QUEUE_SIZE + CRPB_ALIGN); if (!priv->crpb_alloc) { printf("Unable to allocate memory for response queue\n"); return -ENOMEM; } memset(priv->crpb_alloc, 0, sizeof(struct crpb) * REQUEST_QUEUE_SIZE + CRPB_ALIGN); priv->response = (struct crpb *)(((u32) priv->crpb_alloc + CRPB_ALIGN) & ~(CRPB_ALIGN - 1)); sata_dev_desc[dev].priv = (void *)priv; sprintf(priv->name, "SATA%d", dev); priv->regbase = dev == 0 ? SATA0_BASE : SATA1_BASE; if (!hw_init) { debug("Initialize sata hw\n"); hw_init = 1; mv_reset_one_hc(); mvsata_ide_conf_mbus_windows(); } mv_reset_port(dev); if (probe_port(dev)) { priv->link = 0; return -ENODEV; } priv->link = 1; return 0; }
int board_usb_init(const void *blob) { #ifdef CONFIG_OF_CONTROL struct fdt_usb config; int clk_done = 0; int node, upto = 0; unsigned osc_freq = clock_get_rate(CLOCK_ID_OSC); #if defined(CONFIG_TEGRA3) struct usb_ctlr *usb1ctlr; #endif do { node = fdt_decode_next_alias(blob, "usb", COMPAT_NVIDIA_TEGRA250_USB, &upto); if (node < 0) break; if (fdt_decode_usb(blob, node, osc_freq, &config)) return -1; if (!config.enabled) continue; /* The first port we find gets to set the clocks */ if (!clk_done) { config_clock(config.params); clk_done = 1; } if (config.host_mode) { /* Only one host-dev port is supported */ if (host_dev_ctlr) return -1; host_dev_ctlr = config.reg; } if (add_port(config.periph_id, config.reg, config.params, config.utmi)) return -1; #if defined(CONFIG_TEGRA3) fdt_setup_gpio(&config.vbus_gpio); fdt_setup_gpio(&config.vbus_pullup_gpio); usb1ctlr = (struct usb_ctlr *)NV_PA_USB1_BASE; /* * BIAS Pad Power Down is common among all 3 USB * controllers and can be controlled from USB1 only. */ bf_writel(UTMIP_BIASPD, 0, &usb1ctlr->utmip_bias_cfg0); #endif } while (node); #else enum clock_osc_freq freq; const int *params; /* Get the Oscillator frequency */ freq = clock_get_osc_freq(); /* Enable PLL U for USB */ params = &usb_pll[freq][0]; config_clock(params); /* Set up our two ports */ #ifdef CONFIG_TEGRA2_USB1_HOST host_dev_ctlr = (struct usb_ctlr *)NV_PA_USB1_BASE; #endif probe_port((struct usb_ctlr *)CONFIG_TEGRA2_USB0, params); probe_port((struct usb_ctlr *)CONFIG_TEGRA2_USB1, params); #endif /* CONFIG_OF_CONTROL */ usb_set_host_mode(); port_current = -1; return 0; }