Example #1
0
int agp_generic_remove_memory(struct agp_memory *mem, off_t pg_start, int type)
{
	size_t i;
	int mask_type, num_entries = __get_num_entries();

	if (mem->page_count == 0)
		return 0;

#ifdef __PATCH__
	num_entries = agp_num_entries();
	if (((pg_start + mem->page_count) > num_entries) ||
	    ((pg_start + mem->page_count) < pg_start))
		return -EINVAL;
#endif
	mask_type = __agp_type_to_mask_type(type);
	if (mask_type != 0) {
		/* The generic routines know nothing of memory types */
		return -EINVAL;
	}

	/* AK: bogus, should encode addresses > 4GB */
	for (i = pg_start; i < (mem->page_count + pg_start); i++) { // exp: {{uadd}}
		__writel(i);
	}

	return 0;
}
Example #2
0
static int amd64_insert_memory(struct agp_memory *mem, off_t pg_start, int type)
{
    int i, j, num_entries;
    long long tmp;
    int mask_type;
    struct agp_bridge_data *bridge = mem->bridge;
    u32 pte;

    num_entries = agp_num_entries();

    if (type != mem->type)
        return -EINVAL;
    mask_type = bridge->driver->agp_type_to_mask_type(bridge, type);
    if (mask_type != 0)
        return -EINVAL;


    /* Make sure we can fit the range in the gatt table. */
    /* FIXME: could wrap */
    if (((unsigned long)pg_start + mem->page_count) > num_entries)
        return -EINVAL;

    j = pg_start;

    /* gatt table should be empty. */
    while (j < (pg_start + mem->page_count)) {
        if (!PGE_EMPTY(agp_bridge, readl(agp_bridge->gatt_table+j)))
            return -EBUSY;
        j++;
    }

    if (!mem->is_flushed) {
        global_cache_flush();
        mem->is_flushed = true;
    }

    for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
        tmp = agp_bridge->driver->mask_memory(agp_bridge,
            mem->memory[i], mask_type);

        BUG_ON(tmp & 0xffffff0000000ffcULL);
        pte = (tmp & 0x000000ff00000000ULL) >> 28;
        pte |=(tmp & 0x00000000fffff000ULL);
        pte |= GPTE_VALID | GPTE_COHERENT;

        writel(pte, agp_bridge->gatt_table+j);
        readl(agp_bridge->gatt_table+j);    /* PCI Posting. */
    }
    amd64_tlbflush(mem);
    return 0;
}
Example #3
0
static int amd64_insert_memory(struct agp_memory *mem, off_t pg_start, int type)
{
	int i, j, num_entries;
	long tmp;
	u32 pte;

	num_entries = agp_num_entries();

	if (type != 0 || mem->type != 0)
		return -EINVAL;

	/* Make sure we can fit the range in the gatt table. */
	/* FIXME: could wrap */
	if (((unsigned long)pg_start + mem->page_count) > num_entries)
		return -EINVAL;

	j = pg_start;

	/* gatt table should be empty. */
	while (j < (pg_start + mem->page_count)) {
		if (!PGE_EMPTY(agp_bridge, agp_bridge->gatt_table[j]))
			return -EBUSY;
		j++;
	}

	if (mem->is_flushed == FALSE) {
		global_cache_flush();
		mem->is_flushed = TRUE;
	}

	for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
		tmp = agp_bridge->driver->mask_memory(mem->memory[i], mem->type);

		BUG_ON(tmp & 0xffffff0000000ffcULL);
		pte = (tmp & 0x000000ff00000000ULL) >> 28;
		pte |=(tmp & 0x00000000fffff000ULL);
		pte |= GPTE_VALID | GPTE_COHERENT;

		agp_bridge->gatt_table[j] = pte;
	}
	amd64_tlbflush(mem);
	return 0;
}