Esempio n. 1
0
/*
 * Map a table at a given offset into the crashdump map.  It first
 * maps the header to determine the table length and then maps the
 * entire table.
 */
static void *
map_table(vm_paddr_t pa, int offset, const char *sig)
{
	ACPI_TABLE_HEADER *header;
	vm_offset_t length;
	void *table;

	header = table_map(pa, offset, sizeof(ACPI_TABLE_HEADER));
	if (strncmp(header->Signature, sig, ACPI_NAME_SIZE) != 0) {
		table_unmap(header, sizeof(ACPI_TABLE_HEADER));
		return (NULL);
	}
	length = header->Length;
	table_unmap(header, sizeof(ACPI_TABLE_HEADER));
	table = table_map(pa, offset, length);
	if (ACPI_FAILURE(AcpiTbChecksum(table, length))) {
		if (bootverbose)
			printf("ACPI: Failed checksum for table %s\n", sig);
#if (ACPI_CHECKSUM_ABORT)
		table_unmap(table, length);
		return (NULL);
#endif
	}
	return (table);
}
Esempio n. 2
0
/*
 *  deallocates the stroage for the configuration data
 */
void (conf_free)(void)
{
    table_map(section, tabfree, section);
    table_free(&section);
    current = NULL;
    preset = 0;
    errcode = CONF_ERR_OK;
    control = 0;
}
Esempio n. 3
0
/*
 *  provides a callback for conf_free()
 */
static void tabfree(const void *key, void **value, void *cl)
{
    UNUSED(key);

    if (cl == section) {    /* for section table */
        table_t *t = *value;
        table_map(t, tabfree, *value);
        table_free(&t);
    } else {    /* for var=val tables */
        struct valnode_t *pnode = *value;
        assert(pnode);
        MEM_FREE(pnode->freep);
        MEM_FREE(pnode);
    }
}
Esempio n. 4
0
static inline int __page_map(paddr_t paddr, size_t pml4, size_t dirtbl, size_t dir, size_t table, int flags)
{
    /* Sanity checking */
    if (pml4 > 511 || dirtbl > 511 || dir > 511 || table > 511) {
        return -EINVAL;
    }

    __page_t page = {.raw = paddr};

    page.present = 1;
    page.write   = !!(flags & (VM_KW | VM_UW));
    page.user    = !!(flags & (VM_URWX));

    /* Check if PDPT is present */
    if (!LVL4[pml4].present) {
        paddr_t paddr = frame_get();
        pdpt_map(paddr, pml4, flags);
    }

    pages[GET_PHYS_ADDR(&LVL4[pml4])/PAGE_SIZE].refs++;

    /* Check if PD is present */
    if (!LVL3(pml4)[dirtbl].present) {
        paddr_t paddr = frame_get();
        pd_map(paddr, pml4, dirtbl, flags);
    }

    pages[GET_PHYS_ADDR(&LVL3(pml4)[dirtbl])/PAGE_SIZE].refs++;

    /* Check if table is present */
    if (!LVL2(pml4, dirtbl)[dir].present) {
        paddr_t paddr = frame_get();
        table_map(paddr, pml4, dirtbl, dir, flags);
    }

    pages[GET_PHYS_ADDR(&LVL2(pml4, dirtbl)[dir])/PAGE_SIZE].refs++;

    LVL1(pml4, dirtbl, dir)[table] = page;

    return 0;
}
Esempio n. 5
0
/*
 * See if a given ACPI table is the requested table.  Returns the
 * length of the able if it matches or zero on failure.
 */
static int
probe_table(vm_paddr_t address, const char *sig)
{
	ACPI_TABLE_HEADER *table;

	table = table_map(address, 0, sizeof(ACPI_TABLE_HEADER));
	if (table == NULL) {
		if (bootverbose)
			printf("ACPI: Failed to map table at 0x%jx\n",
			    (uintmax_t)address);
		return (0);
	}
	if (bootverbose)
		printf("Table '%.4s' at 0x%jx\n", table->Signature,
		    (uintmax_t)address);

	if (strncmp(table->Signature, sig, ACPI_NAME_SIZE) != 0) {
		table_unmap(table, sizeof(ACPI_TABLE_HEADER));
		return (0);
	}
	table_unmap(table, sizeof(ACPI_TABLE_HEADER));
	return (1);
}
Esempio n. 6
0
int main() {
    table_t tab = table_new(1024, cmp, dictGenHashFunction);

    table_put(tab, "append", "cmd_append");
    table_put(tab, "bitcount", "cmd_bitcount");
    table_put(tab, "brpop", "cmd_brpop");
    table_put(tab, "brpoplpush", "cmd_brpoplpush");
    table_put(tab, "decr", "cmd_decr");
    table_put(tab, "decrby", "cmd_decrby");
    table_put(tab, "del", "cmd_del");
    table_put(tab, "exists", "cmd_exists");
    table_put(tab, "get", "cmd_get");
    table_put(tab, "getbit", "cmd_getbit");
    table_put(tab, "getrange", "cmd_getrange");
    table_put(tab, "incr", "cmd_incr");
    table_put(tab, "incrby", "cmd_incrby");
    table_put(tab, "keys", "cmd_keys");
    table_put(tab, "lindex", "cmd_lindex");
    table_put(tab, "linsert", "cmd_linsert");
    table_put(tab, "llen", "cmd_llen");
    table_put(tab, "lpop", "cmd_lpop");
    table_put(tab, "lpush", "cmd_lpush");
    table_put(tab, "lpushx", "cmd_lpushx");
    table_put(tab, "lrange", "cmd_lrange");
    table_put(tab, "lrem", "cmd_lrem");
    table_put(tab, "lset", "cmd_lset");
    table_put(tab, "ltrim", "cmd_ltrim");
    table_put(tab, "mget", "cmd_mget");
    table_put(tab, "msetnx", "cmd_msetnx");
    table_put(tab, "randomkey", "cmd_randomkey");
    table_put(tab, "rename", "cmd_rename");
    table_put(tab, "rpop", "cmd_rpop");
    table_put(tab, "rpoplpush", "cmd_rpoplpush");
    table_put(tab, "rpush", "cmd_rpush");
    table_put(tab, "rpushx", "cmd_rpushx");
    table_put(tab, "set", "cmd_set");
    table_put(tab, "setbit", "cmd_setbit");
    table_put(tab, "setrange", "cmd_setrange");
    table_put(tab, "strlen", "cmd_strlen");
    table_put(tab, "type", "cmd_type");

    table_map(tab, apply);
    printf("len = %d\n", table_length(tab));

    char key[32];
    scanf("%s", key);
    printf("%s\n", (char *)table_get(tab, key));

    printf("remove set\n");
    table_remove(tab, "set");

    table_map(tab, apply);
    printf("len = %d\n", table_length(tab));

    scanf("%s", key);
    printf("%s\n", (char *)table_get(tab, key));

    table_free(&tab);

    return 0;
}