Changes in kernel/arch/ia32/src/ddi/ddi.c [c5396c1:9d58539] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia32/src/ddi/ddi.c
rc5396c1 r9d58539 59 59 int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size) 60 60 { 61 size_t elements = ioaddr + size;62 if ( elements > IO_PORTS)61 size_t bits = ioaddr + size; 62 if (bits > IO_PORTS) 63 63 return ENOENT; 64 64 65 if (task->arch.iomap. elements < elements) {65 if (task->arch.iomap.bits < bits) { 66 66 /* 67 67 * The I/O permission bitmap is too small and needs to be grown. 68 68 */ 69 69 70 void *store = malloc(bitmap_size(elements), FRAME_ATOMIC);71 if (! store)70 uint8_t *newmap = (uint8_t *) malloc(BITS2BYTES(bits), FRAME_ATOMIC); 71 if (!newmap) 72 72 return ENOMEM; 73 73 74 74 bitmap_t oldiomap; 75 bitmap_initialize(&oldiomap, task->arch.iomap. elements,75 bitmap_initialize(&oldiomap, task->arch.iomap.map, 76 76 task->arch.iomap.bits); 77 78 bitmap_initialize(&task->arch.iomap, elements, store); 77 bitmap_initialize(&task->arch.iomap, newmap, bits); 79 78 80 79 /* 81 80 * Mark the new range inaccessible. 82 81 */ 83 bitmap_set_range(&task->arch.iomap, oldiomap. elements,84 elements - oldiomap.elements);82 bitmap_set_range(&task->arch.iomap, oldiomap.bits, 83 bits - oldiomap.bits); 85 84 86 85 /* … … 90 89 if (oldiomap.bits) { 91 90 bitmap_copy(&task->arch.iomap, &oldiomap, 92 oldiomap.elements); 93 94 free(oldiomap.bits); 91 oldiomap.bits); 92 free(oldiomap.map); 95 93 } 96 94 } … … 99 97 * Enable the range and we are done. 100 98 */ 101 bitmap_clear_range(&task->arch.iomap, (size_t) ioaddr, size);99 bitmap_clear_range(&task->arch.iomap, (size_t) ioaddr, (size_t) size); 102 100 103 101 /* … … 121 119 /* First, copy the I/O Permission Bitmap. */ 122 120 irq_spinlock_lock(&TASK->lock, false); 123 124 121 size_t ver = TASK->arch.iomapver; 125 size_t elements = TASK->arch.iomap.elements; 126 127 if (elements > 0) { 128 ASSERT(TASK->arch.iomap.bits); 122 size_t bits = TASK->arch.iomap.bits; 123 if (bits) { 124 ASSERT(TASK->arch.iomap.map); 129 125 130 126 bitmap_t iomap; 131 bitmap_initialize(&iomap, TSS_IOMAP_SIZE * 8,132 CPU->arch.tss->iomap);133 bitmap_copy(&iomap, &TASK->arch.iomap, elements);127 bitmap_initialize(&iomap, CPU->arch.tss->iomap, 128 TSS_IOMAP_SIZE * 8); 129 bitmap_copy(&iomap, &TASK->arch.iomap, bits); 134 130 135 131 /* … … 137 133 * I/O access. 138 134 */ 139 bitmap_set_range(&iomap, elements, 140 ALIGN_UP(elements, 8) - elements); 141 135 bitmap_set_range(&iomap, bits, ALIGN_UP(bits, 8) - bits); 142 136 /* 143 137 * It is safe to set the trailing eight bits because of the 144 138 * extra convenience byte in TSS_IOMAP_SIZE. 145 139 */ 146 bitmap_set_range(&iomap, ALIGN_UP( elements, 8), 8);140 bitmap_set_range(&iomap, ALIGN_UP(bits, 8), 8); 147 141 } 148 149 142 irq_spinlock_unlock(&TASK->lock, false); 150 143 … … 157 150 158 151 descriptor_t *gdt_p = (descriptor_t *) cpugdtr.base; 159 size_t size = bitmap_size(elements); 160 gdt_setlimit(&gdt_p[TSS_DES], TSS_BASIC_SIZE + size); 152 gdt_setlimit(&gdt_p[TSS_DES], TSS_BASIC_SIZE + BITS2BYTES(bits)); 161 153 gdtr_load(&cpugdtr); 162 154
Note:
See TracChangeset
for help on using the changeset viewer.