/kernel/trunk/arch/amd64/include/pm.h |
---|
67,6 → 67,7 |
#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__ |
144,7 → 145,7 |
__u64 reserve3; |
__u16 reserve4; |
__u16 iomap_base; |
__u8 iomap[0x10000 + 1]; /* 64K + 1 terminating byte */ |
__u8 iomap[TSS_IOMAP_SIZE]; |
} __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 { |
count_t iomap_size; |
__u8 *iomap; |
bitmap_t iomap; |
} task_arch_t; |
#endif |
/kernel/trunk/arch/amd64/src/proc/scheduler.c |
---|
36,6 → 36,7 |
#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. |
* |
43,7 → 44,7 |
*/ |
void before_task_runs_arch(void) |
{ |
size_t iomap_size; |
count_t bits; |
ptr_16_64_t cpugdtr; |
descriptor_t *gdt_p; |
53,11 → 54,17 |
/* First, copy the I/O Permission Bitmap. */ |
spinlock_lock(&TASK->lock); |
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 */ |
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); |
} |
spinlock_unlock(&TASK->lock); |
64,7 → 71,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 + iomap_size - 1); |
gdt_tss_setlimit(&gdt_p[TSS_DES], TSS_BASIC_SIZE + BITS2BYTES(bits) - 1); |
gdtr_load(&cpugdtr); |
} |
/kernel/trunk/arch/amd64/src/proc/task.c |
---|
35,6 → 35,5 |
*/ |
void task_create_arch(task_t *t) |
{ |
t->arch.iomap = NULL; |
t->arch.iomap_size = 0; |
bitmap_initialize(&t->arch.iomap, NULL, 0); |
} |
/kernel/trunk/arch/ia32/include/pm.h |
---|
56,6 → 56,7 |
#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__ |
131,7 → 132,7 |
unsigned : 16; |
unsigned : 16; |
__u16 iomap_base; |
__u8 iomap[0x10000+1]; /* 64K + 1 terminating byte */ |
__u8 iomap[TSS_IOMAP_SIZE]; |
} __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 { |
count_t iomap_size; |
__u8 *iomap; |
bitmap_t iomap; |
} task_arch_t; |
#endif |
/kernel/trunk/arch/ia32/src/proc/scheduler.c |
---|
35,6 → 35,7 |
#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. |
* |
42,7 → 43,7 |
*/ |
void before_task_runs_arch(void) |
{ |
size_t iomap_size; |
count_t bits; |
ptr_16_32_t cpugdtr; |
descriptor_t *gdt_p; |
52,18 → 53,24 |
/* First, copy the I/O Permission Bitmap. */ |
spinlock_lock(&TASK->lock); |
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 */ |
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); |
} |
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 + iomap_size - 1); |
gdt_setlimit(&gdt_p[TSS_DES], TSS_BASIC_SIZE + BITS2BYTES(bits) - 1); |
gdtr_load(&cpugdtr); |
} |
/kernel/trunk/arch/ia32/src/proc/task.c |
---|
28,6 → 28,7 |
#include <proc/task.h> |
#include <arch/types.h> |
#include <adt/bitmap.h> |
/** Perform ia32 specific task initialization. |
* |
35,6 → 36,5 |
*/ |
void task_create_arch(task_t *t) |
{ |
t->arch.iomap = NULL; |
t->arch.iomap_size = 0; |
bitmap_initialize(&t->arch.iomap, NULL, 0); |
} |