Esempio n. 1
0
/*
 * Allocate a GDT slot as follows:
 * 1) If there are entries on the free list, use those.
 * 2) If there are fewer than gdt_size entries in use, there are free slots
 *    near the end that we can sweep through.
 * 3) As a last resort, we increase the size of the GDT, and sweep through
 *    the new slots.
 */
int
gdt_get_slot()
{
	int slot;

	gdt_lock();

	if (gdt_free != GNULL_SEL) {
		slot = gdt_free;
		gdt_free = dynamic_gdt[slot].gd.gd_selector;
	} else {
		if (gdt_next != gdt_count)
			panic("gdt_get_slot: gdt_next != gdt_count");
		if (gdt_next >= gdt_size) {
			if (gdt_size >= MAXGDTSIZ)
				panic("gdt_get_slot: out of GDT descriptors");
			if (dynamic_gdt == gdt)
				panic("gdt_get_slot called before gdt_init");
			gdt_grow();
		}
		slot = gdt_next++;
	}

	gdt_count++;
	gdt_unlock();
	return (slot);
}
Esempio n. 2
0
int
gdt_get_slot1(int which)
{
    int slot;
    size_t offset;

    gdt_lock();

    if (gdt_free[which] != GNULL_SEL) {
        slot = gdt_free[which];
        gdt_free[which] = gdt[slot].gd.gd_selector;
    } else {
        offset = which * MAXGDTSIZ * sizeof(gdt[0]);
        if (gdt_next[which] != gdt_count[which] + offset)
            panic("gdt_get_slot botch 1");
        if (gdt_next[which] - offset >= gdt_size[which]) {
            if (gdt_size[which] >= MAXGDTSIZ)
                panic("gdt_get_slot botch 2");
            gdt_grow(which);
        }
        slot = gdt_next[which]++;
    }

    gdt_count[which]++;
    gdt_unlock();
    return (slot);
}
Esempio n. 3
0
int
gdt_get_slot1(int which)
{
	size_t offset;
	int slot;

	gdt_lock();

	if (gdt_free[which] != GNULL_SEL) {
		slot = gdt_free[which];
		gdt_free[which] = gdt[slot].gd.gd_selector;
	} else {
		offset = which * MAXGDTSIZ * sizeof(gdt[0]);
		if (gdt_next[which] != gdt_count[which] + offset)
			panic("gdt_get_slot1: gdt_next[%d] != gdt_count[%d]",
			    which, which);
		if (gdt_next[which] >= gdt_size[which]) {
			if (gdt_size[which] >= MAXGDTSIZ)
				panic("gdt_get_slot1: out of GDT descriptors");
			gdt_grow(which);
		}
		slot = gdt_next[which]++;
	}

	gdt_count[which]++;
	gdt_unlock();
	return (slot);
}