/kernel/trunk/arch/amd64/src/proc/scheduler.c |
---|
36,7 → 36,6 |
#include <arch/debugger.h> |
#include <print.h> |
#include <arch/pm.h> |
#include <adt/bitmap.h> |
/** Perform amd64 specific tasks needed before the new task is run. |
* |
44,7 → 43,7 |
*/ |
void before_task_runs_arch(void) |
{ |
count_t bits; |
size_t iomap_size; |
ptr_16_64_t cpugdtr; |
descriptor_t *gdt_p; |
54,17 → 53,11 |
/* First, copy the I/O Permission Bitmap. */ |
spinlock_lock(&TASK->lock); |
if ((bits = TASK->arch.iomap.bits)) { |
bitmap_t iomap; |
ASSERT(TASK->arch.iomap.map); |
bitmap_initialize(&iomap, CPU->arch.tss->iomap, TSS_IOMAP_SIZE * 8); |
bitmap_copy(&iomap, &TASK->arch.iomap, TASK->arch.iomap.bits); |
/* |
* It is safe to set the trailing four bits because of the extra |
* convenience byte in TSS_IOMAP_SIZE. |
*/ |
bitmap_set_range(&iomap, TASK->arch.iomap.bits, 4); |
iomap_size = TASK->arch.iomap_size; |
if (iomap_size) { |
ASSERT(TASK->arch.iomap); |
memcpy(CPU->arch.tss->iomap, TASK->arch.iomap, iomap_size); |
CPU->arch.tss->iomap[iomap_size] = 0xff; /* terminating byte */ |
} |
spinlock_unlock(&TASK->lock); |
71,7 → 64,7 |
/* Second, adjust TSS segment limit. */ |
gdtr_store(&cpugdtr); |
gdt_p = (descriptor_t *) cpugdtr.base; |
gdt_tss_setlimit(&gdt_p[TSS_DES], TSS_BASIC_SIZE + BITS2BYTES(bits) - 1); |
gdt_tss_setlimit(&gdt_p[TSS_DES], TSS_BASIC_SIZE + iomap_size - 1); |
gdtr_load(&cpugdtr); |
} |
/kernel/trunk/arch/amd64/src/proc/task.c |
---|
35,5 → 35,6 |
*/ |
void task_create_arch(task_t *t) |
{ |
bitmap_initialize(&t->arch.iomap, NULL, 0); |
t->arch.iomap = NULL; |
t->arch.iomap_size = 0; |
} |
/kernel/trunk/arch/amd64/include/pm.h |
---|
67,7 → 67,6 |
#define DPL_USER (PL_USER<<5) |
#define TSS_BASIC_SIZE 104 |
#define TSS_IOMAP_SIZE (16*1024+1) /* 16K for bitmap + 1 terminating byte for convenience */ |
#ifndef __ASM__ |
145,7 → 144,7 |
__u64 reserve3; |
__u16 reserve4; |
__u16 iomap_base; |
__u8 iomap[TSS_IOMAP_SIZE]; |
__u8 iomap[0x10000 + 1]; /* 64K + 1 terminating byte */ |
} __attribute__ ((packed)); |
typedef struct tss tss_t; |
/kernel/trunk/arch/amd64/include/proc/task.h |
---|
31,10 → 31,10 |
#include <typedefs.h> |
#include <arch/types.h> |
#include <adt/bitmap.h> |
typedef struct { |
bitmap_t iomap; |
count_t iomap_size; |
__u8 *iomap; |
} task_arch_t; |
#endif |
/kernel/trunk/arch/ia32/src/proc/scheduler.c |
---|
35,7 → 35,6 |
#include <arch/debugger.h> |
#include <arch/pm.h> |
#include <arch/asm.h> |
#include <adt/bitmap.h> |
/** Perform ia32 specific tasks needed before the new task is run. |
* |
43,7 → 42,7 |
*/ |
void before_task_runs_arch(void) |
{ |
count_t bits; |
size_t iomap_size; |
ptr_16_32_t cpugdtr; |
descriptor_t *gdt_p; |
53,24 → 52,18 |
/* First, copy the I/O Permission Bitmap. */ |
spinlock_lock(&TASK->lock); |
if ((bits = TASK->arch.iomap.bits)) { |
bitmap_t iomap; |
ASSERT(TASK->arch.iomap.map); |
bitmap_initialize(&iomap, CPU->arch.tss->iomap, TSS_IOMAP_SIZE * 8); |
bitmap_copy(&iomap, &TASK->arch.iomap, TASK->arch.iomap.bits); |
/* |
* It is safe to set the trailing four bits because of the extra |
* convenience byte in TSS_IOMAP_SIZE. |
*/ |
bitmap_set_range(&iomap, TASK->arch.iomap.bits, 4); |
iomap_size = TASK->arch.iomap_size; |
if (iomap_size) { |
ASSERT(TASK->arch.iomap); |
memcpy(CPU->arch.tss->iomap, TASK->arch.iomap, iomap_size); |
CPU->arch.tss->iomap[iomap_size] = 0xff; /* terminating byte */ |
} |
spinlock_unlock(&TASK->lock); |
spinlock_unlock(&TASK->lock); |
/* Second, adjust TSS segment limit. */ |
gdtr_store(&cpugdtr); |
gdt_p = (descriptor_t *) cpugdtr.base; |
gdt_setlimit(&gdt_p[TSS_DES], TSS_BASIC_SIZE + BITS2BYTES(bits) - 1); |
gdt_setlimit(&gdt_p[TSS_DES], TSS_BASIC_SIZE + iomap_size - 1); |
gdtr_load(&cpugdtr); |
} |
/kernel/trunk/arch/ia32/src/proc/task.c |
---|
28,7 → 28,6 |
#include <proc/task.h> |
#include <arch/types.h> |
#include <adt/bitmap.h> |
/** Perform ia32 specific task initialization. |
* |
36,5 → 35,6 |
*/ |
void task_create_arch(task_t *t) |
{ |
bitmap_initialize(&t->arch.iomap, NULL, 0); |
t->arch.iomap = NULL; |
t->arch.iomap_size = 0; |
} |
/kernel/trunk/arch/ia32/include/pm.h |
---|
56,7 → 56,6 |
#define DPL_USER (PL_USER<<5) |
#define TSS_BASIC_SIZE 104 |
#define TSS_IOMAP_SIZE (16*1024+1) /* 16K for bitmap + 1 terminating byte for convenience */ |
#ifndef __ASM__ |
132,7 → 131,7 |
unsigned : 16; |
unsigned : 16; |
__u16 iomap_base; |
__u8 iomap[TSS_IOMAP_SIZE]; |
__u8 iomap[0x10000+1]; /* 64K + 1 terminating byte */ |
} __attribute__ ((packed)); |
typedef struct tss tss_t; |
/kernel/trunk/arch/ia32/include/proc/task.h |
---|
31,10 → 31,10 |
#include <typedefs.h> |
#include <arch/types.h> |
#include <adt/bitmap.h> |
typedef struct { |
bitmap_t iomap; |
count_t iomap_size; |
__u8 *iomap; |
} task_arch_t; |
#endif |