Changes in kernel/arch/amd64/src/ddi/ddi.c [98000fb:e9e5b9ab] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/amd64/src/ddi/ddi.c
r98000fb re9e5b9ab 36 36 #include <arch/ddi/ddi.h> 37 37 #include <proc/task.h> 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 #include <adt/bitmap.h> 40 40 #include <mm/slab.h> … … 49 49 * Interrupts are disabled and task is locked. 50 50 * 51 * @param task Task.51 * @param task Task. 52 52 * @param ioaddr Startign I/O space address. 53 * @param size Size of the enabled I/O range.53 * @param size Size of the enabled I/O range. 54 54 * 55 55 * @return 0 on success or an error code from errno.h. 56 * 56 57 */ 57 58 int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size) 58 59 { 59 size_t bits; 60 61 bits = ioaddr + size; 60 size_t bits = ioaddr + size; 62 61 if (bits > IO_PORTS) 63 62 return ENOENT; 64 63 65 64 if (task->arch.iomap.bits < bits) { 66 bitmap_t oldiomap;67 uint8_t *newmap;68 69 65 /* 70 66 * The I/O permission bitmap is too small and needs to be grown. 71 67 */ 72 68 73 newmap = (uint8_t *) malloc(BITS2BYTES(bits), FRAME_ATOMIC);69 uint8_t *newmap = (uint8_t *) malloc(BITS2BYTES(bits), FRAME_ATOMIC); 74 70 if (!newmap) 75 71 return ENOMEM; 76 72 73 bitmap_t oldiomap; 77 74 bitmap_initialize(&oldiomap, task->arch.iomap.map, 78 75 task->arch.iomap.bits); … … 115 112 * 116 113 * Interrupts must be disabled prior this call. 114 * 117 115 */ 118 116 void io_perm_bitmap_install(void) 119 117 { 120 size_t bits;121 ptr_16_64_t cpugdtr;122 descriptor_t *gdt_p;123 tss_descriptor_t *tss_desc;124 size_t ver;125 126 118 /* First, copy the I/O Permission Bitmap. */ 127 spinlock_lock(&TASK->lock); 128 ver = TASK->arch.iomapver; 129 if ((bits = TASK->arch.iomap.bits)) { 119 irq_spinlock_lock(&TASK->lock, false); 120 size_t ver = TASK->arch.iomapver; 121 size_t bits = TASK->arch.iomap.bits; 122 if (bits) { 123 ASSERT(TASK->arch.iomap.map); 124 130 125 bitmap_t iomap; 131 132 ASSERT(TASK->arch.iomap.map);133 126 bitmap_initialize(&iomap, CPU->arch.tss->iomap, 134 127 TSS_IOMAP_SIZE * 8); 135 bitmap_copy(&iomap, &TASK->arch.iomap, TASK->arch.iomap.bits); 128 bitmap_copy(&iomap, &TASK->arch.iomap, bits); 129 130 /* 131 * Set the trailing bits in the last byte of the map to disable 132 * I/O access. 133 */ 134 bitmap_set_range(&iomap, bits, ALIGN_UP(bits, 8) - bits); 136 135 /* 137 136 * It is safe to set the trailing eight bits because of the 138 137 * extra convenience byte in TSS_IOMAP_SIZE. 139 138 */ 140 bitmap_set_range(&iomap, ALIGN_UP( TASK->arch.iomap.bits, 8), 8);139 bitmap_set_range(&iomap, ALIGN_UP(bits, 8), 8); 141 140 } 142 spinlock_unlock(&TASK->lock);141 irq_spinlock_unlock(&TASK->lock, false); 143 142 144 143 /* … … 146 145 * Take the extra ending byte will all bits set into account. 147 146 */ 147 ptr_16_64_t cpugdtr; 148 148 gdtr_store(&cpugdtr); 149 gdt_p = (descriptor_t *) cpugdtr.base; 149 150 descriptor_t *gdt_p = (descriptor_t *) cpugdtr.base; 150 151 gdt_tss_setlimit(&gdt_p[TSS_DES], TSS_BASIC_SIZE + BITS2BYTES(bits)); 151 152 gdtr_load(&cpugdtr); … … 155 156 * type must be changed to describe inactive TSS. 156 157 */ 157 tss_desc = (tss_descriptor_t *) &gdt_p[TSS_DES];158 tss_descriptor_t *tss_desc = (tss_descriptor_t *) &gdt_p[TSS_DES]; 158 159 tss_desc->type = AR_TSS; 159 tr_load( gdtselector(TSS_DES));160 tr_load(GDT_SELECTOR(TSS_DES)); 160 161 161 162 /*
Note:
See TracChangeset
for help on using the changeset viewer.