Changeset 9fa16b20 in mainline


Ignore:
Timestamp:
2006-04-17T15:45:38Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
73e9b49
Parents:
97a7eff
Message:

Fix amd64 and ia32 management of I/O bitmap in before_task_runs_arch()
by treating the iomap array as a bitmap. Make use of the bitmap type
and functions added in previous commit.

Location:
arch
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • arch/amd64/include/pm.h

    r97a7eff r9fa16b20  
    6868
    6969#define TSS_BASIC_SIZE  104
     70#define TSS_IOMAP_SIZE  (16*1024+1)     /* 16K for bitmap + 1 terminating byte for convenience */
    7071
    7172#ifndef __ASM__
     
    145146        __u16 reserve4;
    146147        __u16 iomap_base;
    147         __u8 iomap[0x10000 + 1];        /* 64K + 1 terminating byte */
     148        __u8 iomap[TSS_IOMAP_SIZE];
    148149} __attribute__ ((packed));
    149150typedef struct tss tss_t;
  • arch/amd64/include/proc/task.h

    r97a7eff r9fa16b20  
    3232#include <typedefs.h>
    3333#include <arch/types.h>
     34#include <adt/bitmap.h>
    3435
    3536typedef struct {
    36         count_t iomap_size;
    37         __u8 *iomap;
     37        bitmap_t iomap;
    3838} task_arch_t;
    3939
  • arch/amd64/src/proc/scheduler.c

    r97a7eff r9fa16b20  
    3737#include <print.h>
    3838#include <arch/pm.h>
     39#include <adt/bitmap.h>
    3940
    4041/** Perform amd64 specific tasks needed before the new task is run.
     
    4445void before_task_runs_arch(void)
    4546{
    46         size_t iomap_size;
     47        count_t bits;
    4748        ptr_16_64_t cpugdtr;
    4849        descriptor_t *gdt_p;
     
    5455        /* First, copy the I/O Permission Bitmap. */
    5556        spinlock_lock(&TASK->lock);
    56         iomap_size = TASK->arch.iomap_size;
    57         if (iomap_size) {
    58                 ASSERT(TASK->arch.iomap);
    59                 memcpy(CPU->arch.tss->iomap, TASK->arch.iomap, iomap_size);
    60                 CPU->arch.tss->iomap[iomap_size] = 0xff;        /* terminating byte */
     57        if ((bits = TASK->arch.iomap.bits)) {
     58                bitmap_t iomap;
     59       
     60                ASSERT(TASK->arch.iomap.map);
     61                bitmap_initialize(&iomap, CPU->arch.tss->iomap, TSS_IOMAP_SIZE * 8);
     62                bitmap_copy(&iomap, &TASK->arch.iomap, TASK->arch.iomap.bits);
     63                /*
     64                 * It is safe to set the trailing four bits because of the extra
     65                 * convenience byte in TSS_IOMAP_SIZE.
     66                 */
     67                bitmap_set_range(&iomap, TASK->arch.iomap.bits, 4);
    6168        }
    6269        spinlock_unlock(&TASK->lock);
     
    6572        gdtr_store(&cpugdtr);
    6673        gdt_p = (descriptor_t *) cpugdtr.base;
    67         gdt_tss_setlimit(&gdt_p[TSS_DES], TSS_BASIC_SIZE + iomap_size - 1);
     74        gdt_tss_setlimit(&gdt_p[TSS_DES], TSS_BASIC_SIZE + BITS2BYTES(bits) - 1);
    6875        gdtr_load(&cpugdtr);
    6976}
  • arch/amd64/src/proc/task.c

    r97a7eff r9fa16b20  
    3636void task_create_arch(task_t *t)
    3737{
    38         t->arch.iomap = NULL;
    39         t->arch.iomap_size = 0;
     38        bitmap_initialize(&t->arch.iomap, NULL, 0);
    4039}
  • arch/ia32/include/pm.h

    r97a7eff r9fa16b20  
    5757
    5858#define TSS_BASIC_SIZE  104
     59#define TSS_IOMAP_SIZE  (16*1024+1)     /* 16K for bitmap + 1 terminating byte for convenience */
    5960
    6061#ifndef __ASM__
     
    132133        unsigned : 16;
    133134        __u16 iomap_base;
    134         __u8 iomap[0x10000+1];  /* 64K + 1 terminating byte */
     135        __u8 iomap[TSS_IOMAP_SIZE];
    135136} __attribute__ ((packed));
    136137typedef struct tss tss_t;
  • arch/ia32/include/proc/task.h

    r97a7eff r9fa16b20  
    3232#include <typedefs.h>
    3333#include <arch/types.h>
     34#include <adt/bitmap.h>
    3435
    3536typedef struct {
    36         count_t iomap_size;
    37         __u8 *iomap;
     37        bitmap_t iomap;
    3838} task_arch_t;
    3939
  • arch/ia32/src/proc/scheduler.c

    r97a7eff r9fa16b20  
    3636#include <arch/pm.h>
    3737#include <arch/asm.h>
     38#include <adt/bitmap.h>
    3839
    3940/** Perform ia32 specific tasks needed before the new task is run.
     
    4344void before_task_runs_arch(void)
    4445{
    45         size_t iomap_size;
     46        count_t bits;
    4647        ptr_16_32_t cpugdtr;
    4748        descriptor_t *gdt_p;
     
    5354        /* First, copy the I/O Permission Bitmap. */
    5455        spinlock_lock(&TASK->lock);
    55         iomap_size = TASK->arch.iomap_size;
    56         if (iomap_size) {
    57                 ASSERT(TASK->arch.iomap);
    58                 memcpy(CPU->arch.tss->iomap, TASK->arch.iomap, iomap_size);
    59                 CPU->arch.tss->iomap[iomap_size] = 0xff;        /* terminating byte */
     56        if ((bits = TASK->arch.iomap.bits)) {
     57                bitmap_t iomap;
     58
     59                ASSERT(TASK->arch.iomap.map);
     60                bitmap_initialize(&iomap, CPU->arch.tss->iomap, TSS_IOMAP_SIZE * 8);
     61                bitmap_copy(&iomap, &TASK->arch.iomap, TASK->arch.iomap.bits);
     62                /*
     63                 * It is safe to set the trailing four bits because of the extra
     64                 * convenience byte in TSS_IOMAP_SIZE.
     65                 */
     66                bitmap_set_range(&iomap, TASK->arch.iomap.bits, 4);
    6067        }
    61         spinlock_unlock(&TASK->lock);   
     68        spinlock_unlock(&TASK->lock);
    6269
    6370        /* Second, adjust TSS segment limit. */
    6471        gdtr_store(&cpugdtr);
    6572        gdt_p = (descriptor_t *) cpugdtr.base;
    66         gdt_setlimit(&gdt_p[TSS_DES], TSS_BASIC_SIZE + iomap_size - 1);
     73        gdt_setlimit(&gdt_p[TSS_DES], TSS_BASIC_SIZE + BITS2BYTES(bits) - 1);
    6774        gdtr_load(&cpugdtr);
    6875}
  • arch/ia32/src/proc/task.c

    r97a7eff r9fa16b20  
    2929#include <proc/task.h>
    3030#include <arch/types.h>
     31#include <adt/bitmap.h>
    3132
    3233/** Perform ia32 specific task initialization.
     
    3637void task_create_arch(task_t *t)
    3738{
    38         t->arch.iomap = NULL;
    39         t->arch.iomap_size = 0;
     39        bitmap_initialize(&t->arch.iomap, NULL, 0);
    4040}
Note: See TracChangeset for help on using the changeset viewer.