/* * 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); }
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); }
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); }
/* * Deallocate a GDT slot, putting it on the free list. */ void gdt_put_slot(int slot) { gdt_lock(); gdt[slot].gd.gd_type = SDT_SYSNULL; gdt[slot].gd.gd_selector = gdt_free; gdt_free = slot; gdt_unlock(); }
/* * Deallocate a GDT slot, putting it on the free list. */ void gdt_put_slot(int slot) { struct sys_segment_descriptor *gdt; gdt = (struct sys_segment_descriptor *)&gdtstore[DYNSEL_START]; gdt_lock(); gdt[slot].sd_type = SDT_SYSNULL; gdt[slot].sd_xx3 = gdt_free; gdt_free = slot; gdt_unlock(); }
void gdt_put_slot1(int slot, int which) { union descriptor d; d.raw[0] = 0; d.raw[1] = 0; gdt_lock(); gdt_count[which]--; d.gd.gd_type = SDT_SYSNULL; d.gd.gd_selector = gdt_free[which]; update_descriptor(&gdt[slot], &d); gdt_free[which] = slot; gdt_unlock(); }
/* * Allocate a GDT slot as follows: * 1) If there are entries on the free list, use those. * 2) If there are fewer than MAXGDTSIZ entries in use, there are free slots * near the end that we can sweep through. */ int gdt_get_slot(void) { int slot; gdt_lock(); if (gdt_free != GNULL_SEL) { slot = gdt_free; gdt_free = gdt[slot].gd.gd_selector; } else { if (gdt_next >= MAXGDTSIZ) panic("gdt_get_slot: out of GDT descriptors"); slot = gdt_next++; } gdt_unlock(); return (slot); }
/* * Allocate a GDT slot as follows: * 1) If there are entries on the free list, use those. * 2) If there are fewer than MAXGDTSIZ entries in use, there are free slots * near the end that we can sweep through. */ int gdt_get_slot(void) { int slot; struct sys_segment_descriptor *gdt; gdt = (struct sys_segment_descriptor *)&gdtstore[DYNSEL_START]; gdt_lock(); if (gdt_free != GNULL_SEL) { slot = gdt_free; gdt_free = gdt[slot].sd_xx3; /* XXXfvdl res. field abuse */ } else { if (gdt_next >= MAXGDTSIZ) panic("gdt_get_slot: out of GDT descriptors"); slot = gdt_next++; } gdt_unlock(); return (slot); }