int main(int argc, char **argv) {
    srand(time(NULL));

    // Create the stylesheet.
    uint16_t *stylesheet = (uint16_t *)malloc(MAX_ID);
    for (int i = 0; i < MAX_ID; i++)
        stylesheet[i] = rand();

    // Create the DOM on the host.
    int *ids = (int *)malloc(sizeof(int) * NODE_COUNT);
    create_dom(ids);

    // Allocate the matched rules.
    uint16_t *matched_rules = (uint16_t *)malloc(sizeof(uint16_t) * NODE_COUNT);

    // Time and execute the kernel.
    struct timeval start;
    gettimeofday(&start, NULL);
    match_selectors(ids, stylesheet, matched_rules);
    struct timeval end;
    gettimeofday(&end, NULL);

    fprintf(stderr,
            "Elapsed time: %f ms\n",
            ((double)end.tv_sec - (double)start.tv_sec) * 1000.0 +
            ((double)end.tv_usec - (double)start.tv_usec) / 1000.0);
}
Beispiel #2
0
static void
acpi_init_global (void)
{
	u64 rsdp;
	struct rsdp *p;
	struct facp *q;
	struct acpi_ent_dmar *r;
	struct domain *create_dom() ;

	rsdp_found = false;
	pm1a_cnt_found = false;

	rsdp = find_rsdp ();
	if (rsdp == FIND_RSDP_NOT_FOUND) {
		printf ("ACPI RSDP not found.\n");
		return;
	}
	p = acpi_mapmem (rsdp, sizeof *p);
	memcpy (&rsdp_copy, p, sizeof *p);
	rsdp_found = true;

	r=find_entry(DMAR_SIGNATURE);
	if (!r) {
		printf ("ACPI DMAR not found.\n");
		iommu_detected=0;
	} else {
		int i ;
		printf ("ACPI DMAR found.\n");
		iommu_detected=1;
		
		parse_dmar_bios_report(r) ;
		num_dom=0 ;
		for (i=0 ; i<MAX_IO_DOM ; i++)
			dom_io[i]=create_dom(i) ;
	}

	q = find_facp ();
	if (!q) {
		printf ("ACPI FACP not found.\n");
		return;
	}
#ifdef ACPI_DSDT
	acpi_dsdt_parse (q->dsdt);
#endif
	get_pm1a_cnt_ioaddr (q);
	get_facs_addr (q);
	if (0)
		debug_dump (q, q->header.length);
	if (0)
		printf ("PM1a control port is 0x%X\n", pm1a_cnt_ioaddr);
	pm1a_cnt_found = true;
	clear_mcfg ();
}