Esempio n. 1
0
static int cmd_host_exec(struct vmm_chardev *cdev, int argc, char **argv)
{
	int colcnt;
	if (1 < argc) {
		if (strcmp(argv[1], "help") == 0) {
			cmd_host_usage(cdev);
			return VMM_OK;
		} else if (strcmp(argv[1], "info") == 0) {
			cmd_host_info(cdev);
			return VMM_OK;
		} else if (strcmp(argv[1], "cpu") == 0) {
			cmd_host_cpu_info(cdev);
			return VMM_OK;
		} else if ((strcmp(argv[1], "irq") == 0) && (2 < argc)) {
			if (strcmp(argv[2], "stats") == 0) {
				cmd_host_irq_stats(cdev);
				return VMM_OK;
			}
		} else if ((strcmp(argv[1], "ram") == 0) && (2 < argc)) {
			if (strcmp(argv[2], "stats") == 0) {
				cmd_host_ram_stats(cdev);
				return VMM_OK;
			} else if (strcmp(argv[2], "bitmap") == 0) {
				if (3 < argc) {
					colcnt = atoi(argv[3]);
				} else {
					colcnt = 64;
				}
				cmd_host_ram_bitmap(cdev, colcnt);
				return VMM_OK;
			}
		} else if ((strcmp(argv[1], "vapool") == 0) && (2 < argc)) {
			if (strcmp(argv[2], "stats") == 0) {
				cmd_host_vapool_stats(cdev);
				return VMM_OK;
			} else if (strcmp(argv[2], "bitmap") == 0) {
				if (3 < argc) {
					colcnt = atoi(argv[3]);
				} else {
					colcnt = 64;
				}
				cmd_host_vapool_bitmap(cdev, colcnt);
				return VMM_OK;
			}
		}
	}
	cmd_host_usage(cdev);
	return VMM_EFAIL;
}
Esempio n. 2
0
static void cmd_host_bus_list(struct vmm_chardev *cdev)
{
	struct cmd_host_list_iter p = { .num = 0, .cdev = cdev };

	vmm_cprintf(cdev, "----------------------------------------\n");
	vmm_cprintf(cdev, " %-7s %-15s %-15s\n",
			  "Num#", "Bus Name", "Device Count");
	vmm_cprintf(cdev, "----------------------------------------\n");
	vmm_devdrv_bus_iterate(NULL, &p, cmd_host_bus_list_iter);
	vmm_cprintf(cdev, "----------------------------------------\n");
}

static int cmd_host_bus_device_list_iter(struct vmm_device *d,
					 void *data)
{
	struct cmd_host_list_iter *p = data;

	vmm_cprintf(p->cdev, " %-7d %-25s %-25s\n",
		    p->num++, d->name,
		    (d->parent) ? d->parent->name : "---");

	return VMM_OK;
}

static int cmd_host_bus_device_list(struct vmm_chardev *cdev,
				    const char *bus_name)
{
	struct vmm_bus *b;
	struct cmd_host_list_iter p = { .num = 0, .cdev = cdev };

	b = vmm_devdrv_find_bus(bus_name);
	if (!b) {
		vmm_cprintf(cdev, "Failed to find %s bus\n", bus_name);
		return VMM_ENOTAVAIL;
	}

	vmm_cprintf(cdev, "----------------------------------------");
	vmm_cprintf(cdev, "--------------------\n");
	vmm_cprintf(cdev, " %-7s %-25s %-25s\n",
			  "Num#", "Device Name", "Parent Name");
	vmm_cprintf(cdev, "----------------------------------------");
	vmm_cprintf(cdev, "--------------------\n");
	vmm_devdrv_bus_device_iterate(b, NULL, &p,
				      cmd_host_bus_device_list_iter);
	vmm_cprintf(cdev, "----------------------------------------");
	vmm_cprintf(cdev, "--------------------\n");

	return VMM_OK;
}

static int cmd_host_class_list_iter(struct vmm_class *c, void *data)
{
	u32 dcount;
	struct cmd_host_list_iter *p = data;

	dcount = vmm_devdrv_class_device_count(c);
	vmm_cprintf(p->cdev, " %-7d %-15s %-15d\n", p->num++, c->name, dcount);

	return VMM_OK;
}

static void cmd_host_class_list(struct vmm_chardev *cdev)
{
	struct cmd_host_list_iter p = { .num = 0, .cdev = cdev };

	vmm_cprintf(cdev, "----------------------------------------\n");
	vmm_cprintf(cdev, " %-7s %-15s %-15s\n",
			  "Num#", "Class Name", "Device Count");
	vmm_cprintf(cdev, "----------------------------------------\n");
	vmm_devdrv_class_iterate(NULL, &p, cmd_host_class_list_iter);
	vmm_cprintf(cdev, "----------------------------------------\n");
}

static int cmd_host_class_device_list_iter(struct vmm_device *d,
					   void *data)
{
	struct cmd_host_list_iter *p = data;

	vmm_cprintf(p->cdev, " %-7d %-25s %-25s\n",
		    p->num++, d->name,
		    (d->parent) ? d->parent->name : "---");

	return VMM_OK;
}

static int cmd_host_class_device_list(struct vmm_chardev *cdev,
				      const char *class_name)
{
	struct vmm_class *c;
	struct cmd_host_list_iter p = { .num = 0, .cdev = cdev };

	c = vmm_devdrv_find_class(class_name);
	if (!c) {
		vmm_cprintf(cdev, "Failed to find %s class\n", class_name);
		return VMM_ENOTAVAIL;
	}

	vmm_cprintf(cdev, "----------------------------------------");
	vmm_cprintf(cdev, "--------------------\n");
	vmm_cprintf(cdev, " %-7s %-25s %-25s\n",
			  "Num#", "Device Name", "Parent Name");
	vmm_cprintf(cdev, "----------------------------------------");
	vmm_cprintf(cdev, "--------------------\n");
	vmm_devdrv_class_device_iterate(c, NULL, &p,
					cmd_host_class_device_list_iter);
	vmm_cprintf(cdev, "----------------------------------------");
	vmm_cprintf(cdev, "--------------------\n");

	return VMM_OK;
}

static int cmd_host_exec(struct vmm_chardev *cdev, int argc, char **argv)
{
	int hirq, hcpu, colcnt, size;

	physical_addr_t physaddr;

	if (argc <= 1) {
		goto fail;
	}

	if (strcmp(argv[1], "help") == 0) {
		cmd_host_usage(cdev);
		return VMM_OK;
	} else if (strcmp(argv[1], "info") == 0) {
		return cmd_host_info(cdev);
	} else if ((strcmp(argv[1], "cpu") == 0) && (2 < argc)) {
		if (strcmp(argv[2], "info") == 0) {
			return cmd_host_cpu_info(cdev);
		} else if (strcmp(argv[2], "stats") == 0) {
			return cmd_host_cpu_stats(cdev);
		}
	} else if ((strcmp(argv[1], "irq") == 0) && (2 < argc)) {
		if (strcmp(argv[2], "stats") == 0) {
			cmd_host_irq_stats(cdev);
			return VMM_OK;
		} else if ((strcmp(argv[2], "set_affinity") == 0) && (4 < argc)) {
			hirq = atoi(argv[3]);
			hcpu = atoi(argv[4]);
			return cmd_host_irq_set_affinity(cdev, hirq, hcpu);
		}
	} else if ((strcmp(argv[1], "extirq") == 0) && (2 < argc)) {
		if (strcmp(argv[2], "stats") == 0) {
			cmd_host_extirq_stats(cdev);
			return VMM_OK;
		}
	} else if ((strcmp(argv[1], "ram") == 0) && (2 < argc)) {
		if (strcmp(argv[2], "info") == 0) {
			cmd_host_ram_info(cdev);
			return VMM_OK;
		} else if (strcmp(argv[2], "bitmap") == 0) {
			if (3 < argc) {
				colcnt = atoi(argv[3]);
			} else {
				colcnt = 64;
			}
			cmd_host_ram_bitmap(cdev, colcnt);
			return VMM_OK;
		} else if (strcmp(argv[2], "reserve") == 0 && 4 < argc) {
			physaddr = strtoul(argv[3], NULL, 16);
			size = strtoul(argv[4], NULL, 16);
			return cmd_host_ram_reserve(cdev, physaddr, size);
		}
	} else if ((strcmp(argv[1], "vapool") == 0) && (2 < argc)) {
		if (strcmp(argv[2], "info") == 0) {
			cmd_host_vapool_info(cdev);
			return VMM_OK;
		} else if (strcmp(argv[2], "state") == 0) {
			return cmd_host_vapool_state(cdev);
		} else if (strcmp(argv[2], "bitmap") == 0) {
			if (3 < argc) {
				colcnt = atoi(argv[3]);
			} else {
				colcnt = 64;
			}
			cmd_host_vapool_bitmap(cdev, colcnt);
			return VMM_OK;
		}
	} else if ((strcmp(argv[1], "memmap") == 0) && (2 < argc)) {
		if (strcmp(argv[2], "info") == 0) {
			cmd_host_memmap_info(cdev);
			return VMM_OK;
		}
	} else if ((strcmp(argv[1], "pagepool") == 0) && (2 < argc)) {
		if (strcmp(argv[2], "info") == 0) {
			cmd_host_pagepool_info(cdev);
			return VMM_OK;
		} else if (strcmp(argv[2], "state") == 0) {
			return cmd_host_pagepool_state(cdev);
		}
	} else if ((strcmp(argv[1], "resources") == 0) && (2 == argc)) {
		cmd_host_resources(cdev);
		return VMM_OK;
	} else if ((strcmp(argv[1], "bus_list") == 0) && (2 == argc)) {
		cmd_host_bus_list(cdev);
		return VMM_OK;
	} else if ((strcmp(argv[1], "bus_device_list") == 0) && (3 == argc)) {
		cmd_host_bus_device_list(cdev, argv[2]);
		return VMM_OK;
	} else if ((strcmp(argv[1], "class_list") == 0) && (2 == argc)) {
		cmd_host_class_list(cdev);
		return VMM_OK;
	} else if ((strcmp(argv[1], "class_device_list") == 0) && (3 == argc)) {
		cmd_host_class_device_list(cdev, argv[2]);
		return VMM_OK;
	}

fail:
	cmd_host_usage(cdev);
	return VMM_EFAIL;
}

static struct vmm_cmd cmd_host = {
	.name = "host",
	.desc = "host information",
	.usage = cmd_host_usage,
	.exec = cmd_host_exec,
};

static int __init cmd_host_init(void)
{
	return vmm_cmdmgr_register_cmd(&cmd_host);
}

static void __exit cmd_host_exit(void)
{
	vmm_cmdmgr_unregister_cmd(&cmd_host);
}

VMM_DECLARE_MODULE(MODULE_DESC,
			MODULE_AUTHOR,
			MODULE_LICENSE,
			MODULE_IPRIORITY,
			MODULE_INIT,
			MODULE_EXIT);
Esempio n. 3
0
static int cmd_host_exec(struct vmm_chardev *cdev, int argc, char **argv)
{
    int colcnt;

    if (argc <= 1) {
        goto fail;
    }

    if (strcmp(argv[1], "help") == 0) {
        cmd_host_usage(cdev);
        return VMM_OK;
    } else if (strcmp(argv[1], "info") == 0) {
        cmd_host_info(cdev);
        return VMM_OK;
    } else if ((strcmp(argv[1], "cpu") == 0) && (2 < argc)) {
        if (strcmp(argv[2], "info") == 0) {
            cmd_host_cpu_info(cdev);
            return VMM_OK;
        } else if (strcmp(argv[2], "stats") == 0) {
            cmd_host_cpu_stats(cdev);
            return VMM_OK;
        }
    } else if ((strcmp(argv[1], "irq") == 0) && (2 < argc)) {
        if (strcmp(argv[2], "stats") == 0) {
            cmd_host_irq_stats(cdev);
            return VMM_OK;
        }
    } else if ((strcmp(argv[1], "ram") == 0) && (2 < argc)) {
        if (strcmp(argv[2], "info") == 0) {
            cmd_host_ram_info(cdev);
            return VMM_OK;
        } else if (strcmp(argv[2], "bitmap") == 0) {
            if (3 < argc) {
                colcnt = atoi(argv[3]);
            } else {
                colcnt = 64;
            }
            cmd_host_ram_bitmap(cdev, colcnt);
            return VMM_OK;
        }
    } else if ((strcmp(argv[1], "vapool") == 0) && (2 < argc)) {
        if (strcmp(argv[2], "info") == 0) {
            cmd_host_vapool_info(cdev);
            return VMM_OK;
        } else if (strcmp(argv[2], "state") == 0) {
            return cmd_host_vapool_state(cdev);
        } else if (strcmp(argv[2], "bitmap") == 0) {
            if (3 < argc) {
                colcnt = atoi(argv[3]);
            } else {
                colcnt = 64;
            }
            cmd_host_vapool_bitmap(cdev, colcnt);
            return VMM_OK;
        }
    } else if ((strcmp(argv[1], "bus_list") == 0) && (2 == argc)) {
        cmd_host_bus_list(cdev);
        return VMM_OK;
    } else if ((strcmp(argv[1], "bus_device_list") == 0) && (3 == argc)) {
        cmd_host_bus_device_list(cdev, argv[2]);
        return VMM_OK;
    } else if ((strcmp(argv[1], "class_list") == 0) && (2 == argc)) {
        cmd_host_class_list(cdev);
        return VMM_OK;
    } else if ((strcmp(argv[1], "class_device_list") == 0) && (3 == argc)) {
        cmd_host_class_device_list(cdev, argv[2]);
        return VMM_OK;
    }

fail:
    cmd_host_usage(cdev);
    return VMM_EFAIL;
}